@vite-hub/ui 0.0.3

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 (329) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +114 -0
  3. package/dist/abap-LtYK6g-v.js +3 -0
  4. package/dist/actionscript-3-Czo0lKSf.js +3 -0
  5. package/dist/ada-twHwrVWN.js +3 -0
  6. package/dist/andromeeda-DnSv6o6l.js +4 -0
  7. package/dist/angular-html-Ct-40ew8.js +33 -0
  8. package/dist/angular-ts-D6akBVit.js +27 -0
  9. package/dist/apache-BIl2qPOf.js +3 -0
  10. package/dist/apex-BkQQFAhi.js +3 -0
  11. package/dist/apl-Cxjn4xYu.js +17 -0
  12. package/dist/applescript-CJ80B5XJ.js +3 -0
  13. package/dist/ara-IxnQjO6j.js +3 -0
  14. package/dist/asciidoc-Dsw6zvwf.js +3 -0
  15. package/dist/asm-wBDSgBbA.js +3 -0
  16. package/dist/astro-BPVTb8uX.js +19 -0
  17. package/dist/aurora-x-XJ5I8rFc.js +4 -0
  18. package/dist/awk-D6dA05Ye.js +3 -0
  19. package/dist/ayu-dark-CBRGL64-.js +4 -0
  20. package/dist/ayu-light-BlrCS3Ih.js +4 -0
  21. package/dist/ayu-mirage-CqpTmLcF.js +4 -0
  22. package/dist/ballerina-DIdXD2KH.js +3 -0
  23. package/dist/bat-hQslfzu-.js +3 -0
  24. package/dist/beancount-CXtOQ8oS.js +3 -0
  25. package/dist/berry-CgA2ea0_.js +3 -0
  26. package/dist/bibtex-BzgdqG3s.js +3 -0
  27. package/dist/bicep-CZ338dSk.js +3 -0
  28. package/dist/bird2-GLyzhwkD.js +3 -0
  29. package/dist/blade-0LMawyyw.js +21 -0
  30. package/dist/bsl-0NWGiiFE.js +6 -0
  31. package/dist/c-Dc0_AVM6.js +6 -0
  32. package/dist/c3-BLXk7BLN.js +3 -0
  33. package/dist/cadence-B1ELWULD.js +3 -0
  34. package/dist/cairo-DjG4M3vq.js +6 -0
  35. package/dist/catppuccin-frappe-COUg_LSX.js +4 -0
  36. package/dist/catppuccin-latte-r30LFfsa.js +4 -0
  37. package/dist/catppuccin-macchiato-D-EwZyPh.js +4 -0
  38. package/dist/catppuccin-mocha-C6RD5yh3.js +4 -0
  39. package/dist/clarity-2iIoRiLx.js +3 -0
  40. package/dist/clojure-DDsQ0FaV.js +3 -0
  41. package/dist/cmake-DPsCB_V6.js +3 -0
  42. package/dist/cobol-CocL1RYn.js +11 -0
  43. package/dist/codeowners-CxEKPWu0.js +3 -0
  44. package/dist/codeql-BwdvwJnv.js +3 -0
  45. package/dist/coffee-DtqnQNu5.js +6 -0
  46. package/dist/common-lisp-DJtwvW4V.js +3 -0
  47. package/dist/config-BwhBDTjC.d.ts +30 -0
  48. package/dist/config-CzOjpPth.js +43 -0
  49. package/dist/coq-Ds6Ye5el.js +3 -0
  50. package/dist/cpp-Mb4ikSI3.js +25 -0
  51. package/dist/crystal-D4OMbAh_.js +19 -0
  52. package/dist/csharp-CFKaLbHg.js +3 -0
  53. package/dist/css-DTzmO9U0.js +6 -0
  54. package/dist/csv-DqIVFkK7.js +3 -0
  55. package/dist/cue-B5KneM5p.js +3 -0
  56. package/dist/cypher-D8Bb8Cq2.js +3 -0
  57. package/dist/d-BQY8TDgQ.js +3 -0
  58. package/dist/dark-plus-BCxGtnt0.js +4 -0
  59. package/dist/dart-C6DUdjib.js +3 -0
  60. package/dist/dax-S-Noo-ku.js +3 -0
  61. package/dist/desktop-BgOb7Aj4.js +3 -0
  62. package/dist/diff-Blb4MjsC.js +3 -0
  63. package/dist/docker-PC1tuYpa.js +3 -0
  64. package/dist/dotenv-Dkdv7Sm2.js +3 -0
  65. package/dist/dracula-fPErIccy.js +4 -0
  66. package/dist/dracula-soft-BrQbqXs8.js +4 -0
  67. package/dist/dream-maker-CngiPd8U.js +3 -0
  68. package/dist/edge-DrFNu-N9.js +13 -0
  69. package/dist/elixir-OpZyQ8Ht.js +6 -0
  70. package/dist/elm-CjX_545P.js +6 -0
  71. package/dist/emacs-lisp-DxhFFVu_.js +3 -0
  72. package/dist/erb-trZRdc47.js +11 -0
  73. package/dist/erlang-BJeTH9QH.js +6 -0
  74. package/dist/everforest-dark-gTeBQCos.js +4 -0
  75. package/dist/everforest-light-DUjxsp-2.js +4 -0
  76. package/dist/fennel-B3wtZRne.js +3 -0
  77. package/dist/fish-D7qAeWQz.js +3 -0
  78. package/dist/fluent-BjfpB34g.js +3 -0
  79. package/dist/fortran-fixed-form-B_eBTsj9.js +6 -0
  80. package/dist/fortran-free-form-yxJ7igsv.js +3 -0
  81. package/dist/fsharp-UvrT6oWG.js +6 -0
  82. package/dist/gdresource-Dl9wvKCd.js +11 -0
  83. package/dist/gdscript-jjgTGGzd.js +3 -0
  84. package/dist/gdshader-D7JfdFV3.js +3 -0
  85. package/dist/genie-DnK2KWIP.js +3 -0
  86. package/dist/getSingularPatch-D0VFiyjB.js +1556 -0
  87. package/dist/gherkin-D6Lr12YQ.js +3 -0
  88. package/dist/git-commit-2LMniMoO.js +6 -0
  89. package/dist/git-rebase-DUOURRPN.js +6 -0
  90. package/dist/github-dark-Dg1hl_QD.js +4 -0
  91. package/dist/github-dark-default-Dym2P842.js +4 -0
  92. package/dist/github-dark-dimmed-7iDMx266.js +4 -0
  93. package/dist/github-dark-high-contrast-DkV2fyPG.js +4 -0
  94. package/dist/github-light-BQKYgor9.js +4 -0
  95. package/dist/github-light-default-BZhIfzqQ.js +4 -0
  96. package/dist/github-light-high-contrast-C7zHfx4C.js +4 -0
  97. package/dist/gleam-CTllUdfC.js +3 -0
  98. package/dist/glimmer-js-D_32hFh8.js +15 -0
  99. package/dist/glimmer-ts-CVt002zd.js +15 -0
  100. package/dist/glsl-pHhzolba.js +8 -0
  101. package/dist/gn-DDjbVPF4.js +3 -0
  102. package/dist/gnuplot-DgWvVXI8.js +3 -0
  103. package/dist/go-aXtTCanQ.js +3 -0
  104. package/dist/graphql-BjqekQIR.js +17 -0
  105. package/dist/groovy-Bw2Ku4bU.js +3 -0
  106. package/dist/gruvbox-dark-hard-CQiwpF03.js +4 -0
  107. package/dist/gruvbox-dark-medium-BKe6XKBS.js +4 -0
  108. package/dist/gruvbox-dark-soft-Cz6U6pa4.js +4 -0
  109. package/dist/gruvbox-light-hard-DgU_i19B.js +4 -0
  110. package/dist/gruvbox-light-medium-D64I06ER.js +4 -0
  111. package/dist/gruvbox-light-soft-B-YxAs1L.js +4 -0
  112. package/dist/hack-BITNGzgt.js +11 -0
  113. package/dist/haml-DVwRP8W9.js +13 -0
  114. package/dist/handlebars-T3TJj8Il.js +15 -0
  115. package/dist/haskell-CfGsE1Cf.js +3 -0
  116. package/dist/haxe-B0odltAZ.js +3 -0
  117. package/dist/hcl-DHg_Osgo.js +3 -0
  118. package/dist/headless.d.ts +176 -0
  119. package/dist/headless.js +333 -0
  120. package/dist/hjson-Cuaphql8.js +3 -0
  121. package/dist/hlsl-BJLUNfne.js +3 -0
  122. package/dist/horizon-DYoumREk.js +4 -0
  123. package/dist/horizon-bright-CPyV7XIA.js +4 -0
  124. package/dist/houston-B3NWfq0V.js +4 -0
  125. package/dist/html-CamevgpM.js +13 -0
  126. package/dist/html-derivative-jMOJf6rB.js +6 -0
  127. package/dist/http-BEHztmFP.js +15 -0
  128. package/dist/hurl-LmFBxrwm.js +13 -0
  129. package/dist/hxml-BQ4V4Tez.js +6 -0
  130. package/dist/hy-CJKxDzbh.js +3 -0
  131. package/dist/imba-96qKoJCa.js +3 -0
  132. package/dist/index.d.ts +6402 -0
  133. package/dist/index.js +12338 -0
  134. package/dist/ini-C24lZfdM.js +3 -0
  135. package/dist/java-Cfowl-Ex.js +6 -0
  136. package/dist/javascript-C4sF7sej.js +6 -0
  137. package/dist/jinja-CCAEwzP4.js +10 -0
  138. package/dist/jison-BKCoBkyT.js +6 -0
  139. package/dist/json-E4f3l6hr.js +6 -0
  140. package/dist/json5-xULSgPQI.js +3 -0
  141. package/dist/jsonc-Cu6rqcrJ.js +3 -0
  142. package/dist/jsonl-Bp0qqr10.js +3 -0
  143. package/dist/jsonnet-BafgE6cE.js +3 -0
  144. package/dist/jssm-Dx5A5sBR.js +3 -0
  145. package/dist/jsx-BZjOirBP.js +6 -0
  146. package/dist/julia-nEdJo0dp.js +17 -0
  147. package/dist/just-Brtw3q7S.js +19 -0
  148. package/dist/kanagawa-dragon-DExkuQAs.js +4 -0
  149. package/dist/kanagawa-lotus-qdYh7_RY.js +4 -0
  150. package/dist/kanagawa-wave-CSW_hADG.js +4 -0
  151. package/dist/kdl-DkTyxPcj.js +3 -0
  152. package/dist/kotlin-BHE8CoV9.js +3 -0
  153. package/dist/kusto-6FdaWTzR.js +3 -0
  154. package/dist/laserwave-DkfjiLxA.js +4 -0
  155. package/dist/latex-QHQNiZDD.js +6 -0
  156. package/dist/lean-BwOKScIt.js +3 -0
  157. package/dist/less-BzbdhFUi.js +3 -0
  158. package/dist/light-plus-DuO6rXxZ.js +4 -0
  159. package/dist/liquid-DYQ7uW5u.js +15 -0
  160. package/dist/llvm-uY68ROGz.js +3 -0
  161. package/dist/log-Dad54gsi.js +3 -0
  162. package/dist/logo-DTXV8SKw.js +3 -0
  163. package/dist/lua-BhkUWs1q.js +8 -0
  164. package/dist/luau-YC4aaMmR.js +3 -0
  165. package/dist/make-B2ukzWs3.js +3 -0
  166. package/dist/markdown-CkmxmzqY.js +3 -0
  167. package/dist/marko-BHWvxp04.js +15 -0
  168. package/dist/material-theme-C_YrwKEa.js +4 -0
  169. package/dist/material-theme-darker-DB3YVCla.js +4 -0
  170. package/dist/material-theme-lighter-D2fgNrBK.js +4 -0
  171. package/dist/material-theme-ocean-DVy172Rs.js +4 -0
  172. package/dist/material-theme-palenight-uMMwIfpG.js +4 -0
  173. package/dist/matlab-CfRK6IMC.js +3 -0
  174. package/dist/mdc-Dg7VPYLa.js +13 -0
  175. package/dist/mdx-BK9ZufRc.js +3 -0
  176. package/dist/mermaid-r7OoIYpE.js +3 -0
  177. package/dist/min-dark-C7Ec8I_2.js +4 -0
  178. package/dist/min-light-Be6foA7m.js +4 -0
  179. package/dist/mipsasm-EL46Y4Xg.js +3 -0
  180. package/dist/mojo-YCzvCoMT.js +3 -0
  181. package/dist/monokai-CREPpJ3k.js +4 -0
  182. package/dist/moonbit-B_9L5rST.js +3 -0
  183. package/dist/move-Dqi5fhOb.js +3 -0
  184. package/dist/narrat-D9rrR0H5.js +3 -0
  185. package/dist/nextflow-CgUAk9iA.js +6 -0
  186. package/dist/nextflow-groovy-CdFFX-gF.js +3 -0
  187. package/dist/nginx-Q-E8IJvs.js +6 -0
  188. package/dist/night-owl-CqqbiLON.js +4 -0
  189. package/dist/night-owl-light-B9vYgGRt.js +4 -0
  190. package/dist/nim-CNcTuF14.js +21 -0
  191. package/dist/nix-Bm1Ax-Z3.js +7 -0
  192. package/dist/nord-BZ9DVmcN.js +4 -0
  193. package/dist/nushell-r7hBzeS_.js +3 -0
  194. package/dist/nuxt.d.ts +10 -0
  195. package/dist/nuxt.js +43 -0
  196. package/dist/objective-c-6dJF64Dt.js +3 -0
  197. package/dist/objective-cpp-_ooRQ-PY.js +3 -0
  198. package/dist/ocaml-vm1Y8An6.js +3 -0
  199. package/dist/odin-vjOJSyfV.js +3 -0
  200. package/dist/one-dark-pro-Ev8UPkf4.js +4 -0
  201. package/dist/one-light-CzxBC38_.js +4 -0
  202. package/dist/openscad-jn-f1Ocl.js +3 -0
  203. package/dist/pascal-D8-gNZ2I.js +3 -0
  204. package/dist/perl-Bbgb6Twx.js +17 -0
  205. package/dist/php-CBOR45_G.js +19 -0
  206. package/dist/pierre-code-view-DYpF5M8R.js +27928 -0
  207. package/dist/pierre-dark-DDWDl8g6.js +4 -0
  208. package/dist/pierre-dark-protanopia-deuteranopia-C35UMuvO.js +4 -0
  209. package/dist/pierre-dark-soft-Bb-4-biO.js +4 -0
  210. package/dist/pierre-dark-tritanopia-CIJISGWF.js +4 -0
  211. package/dist/pierre-dark-vibrant-8oZzB3gw.js +4 -0
  212. package/dist/pierre-light-CWhW4NrH.js +4 -0
  213. package/dist/pierre-light-protanopia-deuteranopia-u0U7N4Hn.js +4 -0
  214. package/dist/pierre-light-soft-BCU6fuhO.js +4 -0
  215. package/dist/pierre-light-tritanopia-3c8Yx3co.js +4 -0
  216. package/dist/pierre-light-vibrant-Cwh332o_.js +4 -0
  217. package/dist/pkl-C7lWzykI.js +3 -0
  218. package/dist/plastic-BGkJ2das.js +4 -0
  219. package/dist/plsql-DCNXypXO.js +3 -0
  220. package/dist/po-IjpR1yHO.js +3 -0
  221. package/dist/poimandres-CpnMgZuc.js +4 -0
  222. package/dist/polar-4pN1JrJ8.js +3 -0
  223. package/dist/postcss-D1gKt4z_.js +3 -0
  224. package/dist/powerquery-SrvS_NBM.js +3 -0
  225. package/dist/powershell-CpTLv_ai.js +3 -0
  226. package/dist/prisma-BWfa4-tI.js +3 -0
  227. package/dist/prolog-Bacii3Ue.js +3 -0
  228. package/dist/proto-ClkOcAW0.js +3 -0
  229. package/dist/pug-Cn_U_o_I.js +13 -0
  230. package/dist/puppet-CQlPp728.js +3 -0
  231. package/dist/purescript-CLpaGMbw.js +3 -0
  232. package/dist/python-BjnOIxPe.js +3 -0
  233. package/dist/qml-DNlrbxJT.js +6 -0
  234. package/dist/qmldir-Dz8ttxjf.js +3 -0
  235. package/dist/qss-Iltvkn1C.js +3 -0
  236. package/dist/r-VqTZMNY_.js +6 -0
  237. package/dist/racket-DRv7j6nv.js +3 -0
  238. package/dist/raku-DI9yGpeW.js +3 -0
  239. package/dist/razor-Bw2un3e8.js +11 -0
  240. package/dist/red-EHiRGXSv.js +4 -0
  241. package/dist/reg-DpJf71oO.js +3 -0
  242. package/dist/regexp-5HbFqwky.js +6 -0
  243. package/dist/rel-BT0iIKKw.js +3 -0
  244. package/dist/riscv-CvzikGLb.js +3 -0
  245. package/dist/ron-DzAo6FTJ.js +3 -0
  246. package/dist/rose-pine-DTI-z1Qp.js +4 -0
  247. package/dist/rose-pine-dawn-BIiGXpWs.js +4 -0
  248. package/dist/rose-pine-moon-DU4wt90U.js +4 -0
  249. package/dist/rosmsg-CyYq6XdT.js +3 -0
  250. package/dist/rst-BZPDb03W.js +23 -0
  251. package/dist/ruby-BbVp0_gQ.js +31 -0
  252. package/dist/runtime/nuxt-plugin.d.ts +4 -0
  253. package/dist/runtime/nuxt-plugin.js +9 -0
  254. package/dist/rust-COBzcmTx.js +3 -0
  255. package/dist/sas-DSkdG4wF.js +6 -0
  256. package/dist/sass-DI2zJwx7.js +3 -0
  257. package/dist/scala-CtSYTRYT.js +3 -0
  258. package/dist/scheme-D3A2QBtM.js +3 -0
  259. package/dist/scss-BQ7uffpQ.js +8 -0
  260. package/dist/sdbl-CdQg5gu1.js +3 -0
  261. package/dist/shaderlab-CWP9wBCf.js +6 -0
  262. package/dist/shellscript-B42c0JAn.js +6 -0
  263. package/dist/shellsession-Oc9-NqAv.js +6 -0
  264. package/dist/slack-dark-BS2AOOdo.js +4 -0
  265. package/dist/slack-ochin-Nc7Cucwk.js +4 -0
  266. package/dist/smalltalk-BEQkVl4K.js +3 -0
  267. package/dist/snazzy-light-C2ghKZXY.js +4 -0
  268. package/dist/solarized-dark-UHgjRWhr.js +4 -0
  269. package/dist/solarized-light-B-Zcwve2.js +4 -0
  270. package/dist/solidity-lB9VjfB9.js +3 -0
  271. package/dist/soy-tgh9u9aW.js +6 -0
  272. package/dist/sparql-B4t0ZbEe.js +6 -0
  273. package/dist/splunk-xP_ZjUH2.js +3 -0
  274. package/dist/sql-CrPlEQn4.js +6 -0
  275. package/dist/ssh-config-DXFPABYp.js +3 -0
  276. package/dist/stata-D_KqT8cj.js +6 -0
  277. package/dist/styles.css +2562 -0
  278. package/dist/stylus-ZZDn1yUO.js +3 -0
  279. package/dist/surrealql-C0KhgoyZ.js +6 -0
  280. package/dist/svelte-DuHT0xxw.js +15 -0
  281. package/dist/swift-BTPQlRLK.js +3 -0
  282. package/dist/synthwave-84-CPtGYwOz.js +4 -0
  283. package/dist/system-verilog-BEoxaBuU.js +3 -0
  284. package/dist/systemd-DFbUltlW.js +3 -0
  285. package/dist/talonscript-CLxaFu-b.js +3 -0
  286. package/dist/tasl-_AAbKiWM.js +3 -0
  287. package/dist/tcl-DLe0Tsfm.js +3 -0
  288. package/dist/templ-DF54artD.js +13 -0
  289. package/dist/terraform-v0KN9QQh.js +3 -0
  290. package/dist/tex-Bbhb8xAP.js +6 -0
  291. package/dist/tokyo-night-BKYoawWu.js +4 -0
  292. package/dist/toml-B7BHZIqX.js +3 -0
  293. package/dist/ts-tags-DH1AB-Ri.js +59 -0
  294. package/dist/tsv-BorGVq2Z.js +3 -0
  295. package/dist/tsx-BR8s1Lhs.js +6 -0
  296. package/dist/turtle-BEG5g_eT.js +3 -0
  297. package/dist/twig-DziFF7iU.js +19 -0
  298. package/dist/typescript-D8TR6ff2.js +6 -0
  299. package/dist/typespec-C_R5TbvO.js +3 -0
  300. package/dist/typst-BV9w0z8-.js +3 -0
  301. package/dist/v-DfbeXLo8.js +3 -0
  302. package/dist/vala-BnnASFsX.js +3 -0
  303. package/dist/vb-DU29mvss.js +3 -0
  304. package/dist/verilog-BW5U03XW.js +3 -0
  305. package/dist/vesper-ClvmKzqD.js +4 -0
  306. package/dist/vhdl-Co2XFKY7.js +3 -0
  307. package/dist/viml-BReTXeDA.js +3 -0
  308. package/dist/vite.d.ts +12 -0
  309. package/dist/vite.js +12 -0
  310. package/dist/vitesse-black-BY6Qtyq-.js +4 -0
  311. package/dist/vitesse-dark-BT-v_EgR.js +4 -0
  312. package/dist/vitesse-light-Box8ZFz6.js +4 -0
  313. package/dist/vue-BRy8iDCZ.js +31 -0
  314. package/dist/vue-html-B24bjO_3.js +6 -0
  315. package/dist/vue-vine-l7O7Mg81.js +19 -0
  316. package/dist/vyper-C6KGx0YU.js +3 -0
  317. package/dist/wasm-BRCjOXGL.js +7 -0
  318. package/dist/wasm-gNIKwGlD.js +3 -0
  319. package/dist/wenyan-BeysbCrW.js +3 -0
  320. package/dist/wgsl-1s5rV5xS.js +3 -0
  321. package/dist/wikitext-wjhjmmzD.js +3 -0
  322. package/dist/wit-CeQiCbz_.js +3 -0
  323. package/dist/wolfram-CcZPfnLd.js +3 -0
  324. package/dist/xml-CduVPlYa.js +8 -0
  325. package/dist/xsl-BeH_vLTK.js +6 -0
  326. package/dist/yaml-Cb0uRU1q.js +6 -0
  327. package/dist/zenscript-BoijL7rl.js +3 -0
  328. package/dist/zig-lTQvxhLD.js +3 -0
  329. package/package.json +98 -0
@@ -0,0 +1,1556 @@
1
+ //#region src/internal/pierre-props.ts
2
+ const pierrePropTypes = {
3
+ codeViewItems: Array,
4
+ codeViewOptions: Object,
5
+ codeViewSelection: Object,
6
+ diffLineAnnotations: Array,
7
+ fileContents: Object,
8
+ fileDiff: Object,
9
+ fileDiffOptions: Object,
10
+ fileOptions: Object,
11
+ lineAnnotations: Array,
12
+ nullableFileContents: [Object, null],
13
+ selectedLines: Object,
14
+ unresolvedFileOptions: Object
15
+ };
16
+ //#endregion
17
+ //#region ../../node_modules/.pnpm/@pierre+diffs@1.3.5_patch_hash=e39d9610970efa5b40101d721a2dd9c46d2c5065627574538bf6c398_88985040eb86a95c0004dc1cccf3d81b/node_modules/@pierre/diffs/dist/constants.js
18
+ const DIFFS_TAG_NAME = "diffs-container";
19
+ const DIFFS_DEVELOPMENT_BUILD = (() => {
20
+ try {
21
+ return process.env.NODE_ENV === "development";
22
+ } catch {
23
+ return false;
24
+ }
25
+ })();
26
+ const COMMIT_METADATA_SPLIT = /(?=^From [a-f0-9]+ .+$)/m;
27
+ const GIT_DIFF_FILE_BREAK_REGEX = /(?=^diff --git)/gm;
28
+ const SPLIT_WITH_NEWLINES = /(?<=\n)/;
29
+ const FILENAME_HEADER_REGEX = /^(---|\+\+\+)\s+([^\t\r\n]+)/;
30
+ const FILENAME_HEADER_REGEX_GIT = /^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/;
31
+ const ALTERNATE_FILE_NAMES_GIT = /^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/;
32
+ const INDEX_LINE_METADATA = /^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i;
33
+ const HEADER_PREFIX_SLOT_ID = "header-prefix";
34
+ const HEADER_FILENAME_SUFFIX_SLOT_ID = "header-filename-suffix";
35
+ const HEADER_METADATA_SLOT_ID = "header-metadata";
36
+ const CUSTOM_HEADER_SLOT_ID = "header-custom";
37
+ const DEFAULT_THEMES = {
38
+ dark: "pierre-dark",
39
+ light: "pierre-light"
40
+ };
41
+ const THEME_CSS_ATTRIBUTE = "data-theme-css";
42
+ const UNSAFE_CSS_ATTRIBUTE = "data-unsafe-css";
43
+ const DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE = "data-diffs-scrollbar-measure";
44
+ const CODE_VIEW_HEADER_ATTRIBUTE = "data-diffs-code-view-header";
45
+ const CODE_VIEW_FOOTER_ATTRIBUTE = "data-diffs-code-view-footer";
46
+ const DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY = "--diffs-scrollbar-gutter-measured";
47
+ const DEFAULT_TOKENIZE_MAX_LENGTH = 1e5;
48
+ const DEFAULT_VIRTUAL_FILE_METRICS = {
49
+ hunkLineCount: 50,
50
+ lineHeight: 20,
51
+ diffHeaderHeight: 44,
52
+ spacing: 8
53
+ };
54
+ const DEFAULT_CODE_VIEW_FILE_METRICS = {
55
+ ...DEFAULT_VIRTUAL_FILE_METRICS,
56
+ hunkLineCount: 1
57
+ };
58
+ const DEFAULT_CODE_VIEW_LAYOUT = {
59
+ paddingTop: 8,
60
+ paddingBottom: 8,
61
+ gap: 8
62
+ };
63
+ const DEFAULT_SMOOTH_SCROLL_SETTINGS = {
64
+ omega: .015,
65
+ positionEpsilon: .5,
66
+ velocityEpsilon: .05
67
+ };
68
+ const DEFAULT_EXPANDED_REGION = Object.freeze({
69
+ fromStart: 0,
70
+ fromEnd: 0
71
+ });
72
+ const DEFAULT_RENDER_RANGE = {
73
+ startingLine: 0,
74
+ totalLines: Infinity,
75
+ bufferBefore: 0,
76
+ bufferAfter: 0
77
+ };
78
+ const EMPTY_RENDER_RANGE = {
79
+ startingLine: 0,
80
+ totalLines: 0,
81
+ bufferBefore: 0,
82
+ bufferAfter: 0
83
+ };
84
+ //#endregion
85
+ //#region ../../node_modules/.pnpm/@pierre+diffs@1.3.5_patch_hash=e39d9610970efa5b40101d721a2dd9c46d2c5065627574538bf6c398_88985040eb86a95c0004dc1cccf3d81b/node_modules/@pierre/diffs/dist/utils/cleanLastNewline.js
86
+ function cleanLastNewline(contents) {
87
+ let end = contents.length;
88
+ if (contents.charCodeAt(end - 1) === 10) {
89
+ end--;
90
+ if (contents.charCodeAt(end - 1) === 13) end--;
91
+ }
92
+ return contents.slice(0, end);
93
+ }
94
+ //#endregion
95
+ //#region ../../node_modules/.pnpm/@pierre+diffs@1.3.5_patch_hash=e39d9610970efa5b40101d721a2dd9c46d2c5065627574538bf6c398_88985040eb86a95c0004dc1cccf3d81b/node_modules/@pierre/diffs/dist/utils/detachString.js
96
+ const stringDetachEncoder = new TextEncoder();
97
+ const stringDetachDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
98
+ const SURROGATE_CODE_UNIT_PATTERN = /[\uD800-\uDFFF]/;
99
+ const STRING_DETACH_INITIAL_BUFFER_SIZE = 1024;
100
+ let stringDetachBuffer = new Uint8Array(STRING_DETACH_INITIAL_BUFFER_SIZE);
101
+ function releaseStringDetachBuffer() {
102
+ if (stringDetachBuffer.length !== STRING_DETACH_INITIAL_BUFFER_SIZE) stringDetachBuffer = new Uint8Array(STRING_DETACH_INITIAL_BUFFER_SIZE);
103
+ }
104
+ function detachString(value) {
105
+ if (value.length === 0) return value;
106
+ if (SURROGATE_CODE_UNIT_PATTERN.test(value)) return JSON.parse(JSON.stringify(value));
107
+ const requiredByteLength = value.length * 3;
108
+ if (stringDetachBuffer.length < requiredByteLength) stringDetachBuffer = new Uint8Array(requiredByteLength);
109
+ const { written } = stringDetachEncoder.encodeInto(value, stringDetachBuffer);
110
+ return stringDetachDecoder.decode(stringDetachBuffer.subarray(0, written));
111
+ }
112
+ //#endregion
113
+ //#region ../../node_modules/.pnpm/@pierre+diffs@1.3.5_patch_hash=e39d9610970efa5b40101d721a2dd9c46d2c5065627574538bf6c398_88985040eb86a95c0004dc1cccf3d81b/node_modules/@pierre/diffs/dist/utils/getHunkSideBoundaries.js
114
+ /** Converts a unified hunk side's start/count into its consumed-file range. */
115
+ function getHunkSideStartBoundary(start, count) {
116
+ return start - (count === 0 ? 0 : 1);
117
+ }
118
+ function getHunkSideEndBoundary(start, count) {
119
+ return getHunkSideStartBoundary(start, count) + count;
120
+ }
121
+ //#endregion
122
+ //#region ../../node_modules/.pnpm/@pierre+diffs@1.3.5_patch_hash=e39d9610970efa5b40101d721a2dd9c46d2c5065627574538bf6c398_88985040eb86a95c0004dc1cccf3d81b/node_modules/@pierre/diffs/dist/utils/realignChangeContent.js
123
+ const MAX_ALIGNMENT_COMPARISONS = 4096;
124
+ const MIN_IMPROVEMENT_PER_PAIR = .5;
125
+ /**
126
+ * Re-split count-mismatched change blocks in every hunk so paired lines are
127
+ * chosen by content similarity instead of position, then slide blank-line
128
+ * insert/delete blocks to the top of their blank run. Mutates `hunks` in
129
+ * place; rendered row counts are unchanged (a split block covers the same
130
+ * split/unified rows as the original).
131
+ */
132
+ function realignChangeContentBySimilarity(diff) {
133
+ for (const hunk of diff.hunks) {
134
+ for (let index = 0; index < hunk.hunkContent.length; index++) {
135
+ const content = hunk.hunkContent[index];
136
+ if (content.type !== "change") continue;
137
+ const replacement = realignChangeBlock(diff, content);
138
+ if (replacement != null) {
139
+ hunk.hunkContent.splice(index, 1, ...replacement);
140
+ index += replacement.length - 1;
141
+ }
142
+ }
143
+ slideBlankBoundaryBlocksUp(hunk, diff);
144
+ }
145
+ }
146
+ /**
147
+ * Slide pure insert/delete blocks made entirely of blank lines to the top of
148
+ * the blank run they sit in. Adding or removing a blank line next to
149
+ * existing blanks is ambiguous, and the diff library reports the change at
150
+ * the run's bottom — so pressing Enter at the end of a line marks a blank
151
+ * *below* the caret as inserted while the caret's own new line renders as
152
+ * context. Sliding up anchors the change to the content above it (the caret
153
+ * line after an Enter) instead.
154
+ *
155
+ * The slide is all-or-nothing: it only applies when the block comes to rest
156
+ * directly beneath remaining in-hunk content. A slide that would consume the
157
+ * hunk's entire leading context was stopped by the hunk's edge — a context
158
+ * window cut, not the top of the blank run — and that landing spot is
159
+ * arbitrary, so the block keeps the library's bottom-of-run anchor (which
160
+ * sits against the content below the run). Non-blank blocks never slide, so
161
+ * code that merely ends like its neighbor (an added function before an
162
+ * identical `}`) keeps the library's canonical position.
163
+ */
164
+ function slideBlankBoundaryBlocksUp(hunk, diff) {
165
+ const { hunkContent } = hunk;
166
+ for (let index = 1; index < hunkContent.length; index++) {
167
+ const block = hunkContent[index];
168
+ const previous = hunkContent[index - 1];
169
+ if (block.type !== "change" || block.additions > 0 && block.deletions > 0 || previous.type !== "context") continue;
170
+ const isInsert = block.additions > 0;
171
+ const lines = isInsert ? diff.additionLines : diff.deletionLines;
172
+ const blockStart = isInsert ? block.additionLineIndex : block.deletionLineIndex;
173
+ const blockLength = isInsert ? block.additions : block.deletions;
174
+ const unit = lines[blockStart] ?? "";
175
+ if (unit.trim() !== "") continue;
176
+ let uniform = true;
177
+ for (let offset = 1; offset < blockLength; offset++) if (lines[blockStart + offset] !== unit) {
178
+ uniform = false;
179
+ break;
180
+ }
181
+ if (!uniform) continue;
182
+ let slide = 0;
183
+ while (slide < previous.lines && diff.additionLines[previous.additionLineIndex + previous.lines - 1 - slide] === unit) slide++;
184
+ if (slide === 0) continue;
185
+ if (index === 1 && slide === previous.lines) continue;
186
+ block.additionLineIndex -= slide;
187
+ block.deletionLineIndex -= slide;
188
+ const blockAdditionEnd = block.additionLineIndex + block.additions;
189
+ const blockDeletionEnd = block.deletionLineIndex + block.deletions;
190
+ const next = hunkContent[index + 1];
191
+ if (next?.type === "context") {
192
+ next.lines += slide;
193
+ next.additionLineIndex = blockAdditionEnd;
194
+ next.deletionLineIndex = blockDeletionEnd;
195
+ } else hunkContent.splice(index + 1, 0, {
196
+ type: "context",
197
+ lines: slide,
198
+ additionLineIndex: blockAdditionEnd,
199
+ deletionLineIndex: blockDeletionEnd
200
+ });
201
+ previous.lines -= slide;
202
+ if (previous.lines === 0) {
203
+ hunkContent.splice(index - 1, 1);
204
+ index--;
205
+ }
206
+ }
207
+ }
208
+ function realignChangeBlock(diff, content) {
209
+ const { deletions, additions, deletionLineIndex, additionLineIndex } = content;
210
+ const pairCount = Math.min(deletions, additions);
211
+ const surplus = Math.abs(additions - deletions);
212
+ if (pairCount === 0 || surplus === 0 || pairCount * (surplus + 1) > MAX_ALIGNMENT_COMPARISONS) return null;
213
+ const strippedDeletions = [];
214
+ for (let line = 0; line < deletions; line++) strippedDeletions.push(stripWhitespace(diff.deletionLines[deletionLineIndex + line] ?? ""));
215
+ const strippedAdditions = [];
216
+ for (let line = 0; line < additions; line++) strippedAdditions.push(stripWhitespace(diff.additionLines[additionLineIndex + line] ?? ""));
217
+ const additionsAreLonger = additions > deletions;
218
+ let bestOffset = 0;
219
+ let bestScore = -1;
220
+ for (let offset = 0; offset <= surplus; offset++) {
221
+ let score = 0;
222
+ for (let pair = 0; pair < pairCount; pair++) score += lineSimilarity(strippedDeletions[pair + (additionsAreLonger ? 0 : offset)], strippedAdditions[pair + (additionsAreLonger ? offset : 0)]);
223
+ if (offset === 0) bestScore = score + pairCount * MIN_IMPROVEMENT_PER_PAIR;
224
+ else if (score > bestScore) {
225
+ bestScore = score;
226
+ bestOffset = offset;
227
+ }
228
+ }
229
+ if (bestOffset === 0) return null;
230
+ const blocks = [];
231
+ const pushBlock = (blockDeletions, blockAdditions, blockDeletionIndex, blockAdditionIndex) => {
232
+ if (blockDeletions > 0 || blockAdditions > 0) blocks.push({
233
+ type: "change",
234
+ deletions: blockDeletions,
235
+ additions: blockAdditions,
236
+ deletionLineIndex: blockDeletionIndex,
237
+ additionLineIndex: blockAdditionIndex
238
+ });
239
+ };
240
+ if (additionsAreLonger) {
241
+ pushBlock(0, bestOffset, deletionLineIndex, additionLineIndex);
242
+ pushBlock(pairCount, pairCount, deletionLineIndex, additionLineIndex + bestOffset);
243
+ pushBlock(0, additions - pairCount - bestOffset, deletionLineIndex + pairCount, additionLineIndex + bestOffset + pairCount);
244
+ } else {
245
+ pushBlock(bestOffset, 0, deletionLineIndex, additionLineIndex);
246
+ pushBlock(pairCount, pairCount, deletionLineIndex + bestOffset, additionLineIndex);
247
+ pushBlock(deletions - pairCount - bestOffset, 0, deletionLineIndex + bestOffset + pairCount, additionLineIndex + pairCount);
248
+ }
249
+ return blocks;
250
+ }
251
+ const WHITESPACE = /\s+/g;
252
+ function stripWhitespace(line) {
253
+ return line.replace(WHITESPACE, "");
254
+ }
255
+ function lineSimilarity(a, b) {
256
+ if (a === b) return 1;
257
+ const maxLength = Math.max(a.length, b.length);
258
+ const minLength = Math.min(a.length, b.length);
259
+ if (minLength === 0) return 0;
260
+ let prefix = 0;
261
+ while (prefix < minLength && a[prefix] === b[prefix]) prefix++;
262
+ let suffix = 0;
263
+ while (suffix < minLength - prefix && a[a.length - 1 - suffix] === b[b.length - 1 - suffix]) suffix++;
264
+ return (prefix + suffix) / maxLength;
265
+ }
266
+ //#endregion
267
+ //#region ../../node_modules/.pnpm/@pierre+diffs@1.3.5_patch_hash=e39d9610970efa5b40101d721a2dd9c46d2c5065627574538bf6c398_88985040eb86a95c0004dc1cccf3d81b/node_modules/@pierre/diffs/dist/utils/parsePatchFiles.js
268
+ function processPatch(data, cacheKeyPrefix, throwOnError) {
269
+ try {
270
+ return _processPatch(data, cacheKeyPrefix, throwOnError);
271
+ } finally {
272
+ releaseStringDetachBuffer();
273
+ }
274
+ }
275
+ function _processPatch(data, cacheKeyPrefix, throwOnError = false) {
276
+ const isGitDiff = isGitDiffPatch(data);
277
+ const rawFiles = isGitDiff ? splitGitDiffFiles(data) : splitUnifiedDiffFiles(data);
278
+ let patchMetadata;
279
+ const files = [];
280
+ for (const fileOrPatchMetadata of rawFiles) {
281
+ if (isGitDiff && !GIT_DIFF_FILE_BREAK_REGEX.test(fileOrPatchMetadata)) {
282
+ if (patchMetadata == null) patchMetadata = detachString(fileOrPatchMetadata);
283
+ else if (throwOnError) throw Error("parsePatchContent: unknown file blob");
284
+ else console.error("parsePatchContent: unknown file blob:", fileOrPatchMetadata);
285
+ continue;
286
+ } else if (!isGitDiff && !startsWithUnifiedDiffFileHeader(fileOrPatchMetadata)) {
287
+ if (patchMetadata == null) patchMetadata = detachString(fileOrPatchMetadata);
288
+ else if (throwOnError) throw Error("parsePatchContent: unknown file blob");
289
+ else console.error("parsePatchContent: unknown file blob:", fileOrPatchMetadata);
290
+ continue;
291
+ }
292
+ const currentFile = _processFile(fileOrPatchMetadata, {
293
+ cacheKey: cacheKeyPrefix != null ? `${cacheKeyPrefix}-${files.length}` : void 0,
294
+ isGitDiff,
295
+ throwOnError
296
+ });
297
+ if (currentFile != null) files.push(currentFile);
298
+ }
299
+ return {
300
+ patchMetadata,
301
+ files
302
+ };
303
+ }
304
+ function processFile(fileDiffString, options) {
305
+ try {
306
+ return _processFile(fileDiffString, options);
307
+ } finally {
308
+ releaseStringDetachBuffer();
309
+ }
310
+ }
311
+ function _processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(fileDiffString), oldFile, newFile, throwOnError = false } = {}) {
312
+ let lastHunkEnd = 0;
313
+ const hunks = splitAtLinePrefix(fileDiffString, "@@ ");
314
+ let currentFile;
315
+ const isPartial = oldFile == null || newFile == null;
316
+ let deletionLineIndex = 0;
317
+ let additionLineIndex = 0;
318
+ for (const hunk of hunks) {
319
+ const lines = splitWithNewlines(hunk);
320
+ const firstLine = lines[0];
321
+ if (firstLine == null) {
322
+ if (throwOnError) throw Error("parsePatchContent: invalid hunk");
323
+ else console.error("parsePatchContent: invalid hunk", hunk);
324
+ continue;
325
+ }
326
+ const fileHeader = parseHunkHeader(firstLine);
327
+ let additionLines = 0;
328
+ let deletionLines = 0;
329
+ if (fileHeader == null || currentFile == null) {
330
+ if (currentFile != null) {
331
+ if (throwOnError) throw Error("parsePatchContent: Invalid hunk");
332
+ else console.error("parsePatchContent: Invalid hunk", hunk);
333
+ continue;
334
+ }
335
+ currentFile = {
336
+ name: "",
337
+ type: "change",
338
+ hunks: [],
339
+ splitLineCount: 0,
340
+ unifiedLineCount: 0,
341
+ isPartial,
342
+ additionLines: !isPartial && oldFile != null && newFile != null ? splitFileContents(newFile.contents) : [],
343
+ deletionLines: !isPartial && oldFile != null && newFile != null ? splitFileContents(oldFile.contents) : [],
344
+ cacheKey: maybeDetachOptionalString(cacheKey)
345
+ };
346
+ if (currentFile.additionLines.length === 1 && newFile?.contents === "") currentFile.additionLines.length = 0;
347
+ if (currentFile.deletionLines.length === 1 && oldFile?.contents === "") currentFile.deletionLines.length = 0;
348
+ for (const line of lines) {
349
+ if (line.startsWith("diff --git")) {
350
+ const filenameMatch = line.trim().match(ALTERNATE_FILE_NAMES_GIT);
351
+ const prevName = filenameMatch?.[1] ?? filenameMatch?.[2];
352
+ const name = filenameMatch?.[3] ?? filenameMatch?.[4];
353
+ if (prevName == null || name == null) {
354
+ if (throwOnError) throw Error("parsePatchContent: invalid git diff header");
355
+ else console.error("parsePatchContent: invalid git diff header", line);
356
+ continue;
357
+ }
358
+ currentFile.name = detachString(name.trim());
359
+ if (prevName !== name) currentFile.prevName = detachString(prevName.trim());
360
+ continue;
361
+ }
362
+ const filenameMatch = line.startsWith("---") || line.startsWith("+++") ? line.match(isGitDiff ? FILENAME_HEADER_REGEX_GIT : FILENAME_HEADER_REGEX) : null;
363
+ if (filenameMatch != null) {
364
+ const [, type, fileName] = filenameMatch;
365
+ if (type === "---" && fileName !== "/dev/null") {
366
+ const detachedFileName = detachString(fileName.trim());
367
+ currentFile.prevName = detachedFileName;
368
+ currentFile.name = detachedFileName;
369
+ } else if (type === "+++" && fileName !== "/dev/null") currentFile.name = detachString(fileName.trim());
370
+ } else if (isGitDiff) {
371
+ if (line.startsWith("new mode ")) currentFile.mode = detachString(line.slice(8).trim());
372
+ if (line.startsWith("old mode ")) currentFile.prevMode = detachString(line.slice(8).trim());
373
+ if (line.startsWith("new file mode")) {
374
+ currentFile.type = "new";
375
+ currentFile.mode = detachString(line.slice(13).trim());
376
+ }
377
+ if (line.startsWith("deleted file mode")) {
378
+ currentFile.type = "deleted";
379
+ currentFile.mode = detachString(line.slice(17).trim());
380
+ }
381
+ if (line.startsWith("similarity index")) if (line.startsWith("similarity index 100%")) currentFile.type = "rename-pure";
382
+ else currentFile.type = "rename-changed";
383
+ if (line.startsWith("index ")) {
384
+ const [, prevObjectId, newObjectId, mode] = line.trim().match(INDEX_LINE_METADATA) ?? [];
385
+ if (prevObjectId != null) currentFile.prevObjectId = detachString(prevObjectId);
386
+ if (newObjectId != null) currentFile.newObjectId = detachString(newObjectId);
387
+ if (mode != null) currentFile.mode = detachString(mode);
388
+ }
389
+ if (line.startsWith("rename from ")) currentFile.prevName = detachString(line.slice(12).trim());
390
+ if (line.startsWith("rename to ")) currentFile.name = detachString(line.slice(10).trim());
391
+ }
392
+ }
393
+ continue;
394
+ }
395
+ let currentContent;
396
+ let lastLineType;
397
+ while (lines.length > 0 && (lines[lines.length - 1] === "\n" || lines[lines.length - 1] === "\r" || lines[lines.length - 1] === "\r\n" || lines[lines.length - 1] === "")) lines.pop();
398
+ const { additionStart, deletionStart } = fileHeader;
399
+ deletionLineIndex = isPartial ? deletionLineIndex : deletionStart - 1;
400
+ additionLineIndex = isPartial ? additionLineIndex : additionStart - 1;
401
+ const hunkData = {
402
+ collapsedBefore: 0,
403
+ splitLineCount: 0,
404
+ splitLineStart: 0,
405
+ unifiedLineCount: 0,
406
+ unifiedLineStart: 0,
407
+ additionCount: fileHeader.additionCount,
408
+ additionStart,
409
+ additionLines,
410
+ deletionCount: fileHeader.deletionCount,
411
+ deletionStart,
412
+ deletionLines,
413
+ deletionLineIndex,
414
+ additionLineIndex,
415
+ hunkContent: [],
416
+ hunkContext: maybeDetachOptionalString(fileHeader.hunkContext),
417
+ hunkSpecs: detachString(firstLine),
418
+ noEOFCRAdditions: false,
419
+ noEOFCRDeletions: false
420
+ };
421
+ let parsedAdditionLines = 0;
422
+ let parsedDeletionLines = 0;
423
+ for (let lineIndex = 1; lineIndex < lines.length; lineIndex++) {
424
+ const rawLine = lines[lineIndex];
425
+ if (parsedAdditionLines >= hunkData.additionCount && parsedDeletionLines >= hunkData.deletionCount && !rawLine.startsWith("\\")) {
426
+ if (throwOnError && isHunkBodyLine(rawLine) && !isFormatPatchVersionSeparator(rawLine)) throw Error("parsePatchContent: hunk has more lines than expected");
427
+ break;
428
+ }
429
+ const firstChar = rawLine[0];
430
+ if (firstChar !== "+" && firstChar !== "-" && firstChar !== " " && firstChar !== "\\") {
431
+ if (throwOnError) throw Error("parsePatchContent: invalid hunk line");
432
+ console.error(`parseLineType: Invalid firstChar: "${firstChar}", full line: "${rawLine}"`);
433
+ console.error("processFile: invalid rawLine:", rawLine);
434
+ continue;
435
+ }
436
+ const type = parseRawLineType(firstChar);
437
+ if (type === "addition") {
438
+ if (throwOnError && parsedAdditionLines >= hunkData.additionCount) throw Error("parsePatchContent: hunk has too many addition lines");
439
+ const line = getParsedLineContent(rawLine);
440
+ if (currentContent == null || currentContent.type !== "change") {
441
+ currentContent = createContentGroup("change", deletionLineIndex, additionLineIndex);
442
+ hunkData.hunkContent.push(currentContent);
443
+ }
444
+ additionLineIndex++;
445
+ parsedAdditionLines++;
446
+ if (isPartial) currentFile.additionLines.push(line);
447
+ currentContent.additions++;
448
+ additionLines++;
449
+ lastLineType = "addition";
450
+ } else if (type === "deletion") {
451
+ if (throwOnError && parsedDeletionLines >= hunkData.deletionCount) throw Error("parsePatchContent: hunk has too many deletion lines");
452
+ const line = getParsedLineContent(rawLine);
453
+ if (currentContent == null || currentContent.type !== "change") {
454
+ currentContent = createContentGroup("change", deletionLineIndex, additionLineIndex);
455
+ hunkData.hunkContent.push(currentContent);
456
+ }
457
+ deletionLineIndex++;
458
+ parsedDeletionLines++;
459
+ if (isPartial) currentFile.deletionLines.push(line);
460
+ currentContent.deletions++;
461
+ deletionLines++;
462
+ lastLineType = "deletion";
463
+ } else if (type === "context") {
464
+ if (throwOnError && (parsedDeletionLines >= hunkData.deletionCount || parsedAdditionLines >= hunkData.additionCount)) throw Error("parsePatchContent: hunk has too many context lines");
465
+ const line = getParsedLineContent(rawLine);
466
+ if (currentContent == null || currentContent.type !== "context") {
467
+ currentContent = createContentGroup("context", deletionLineIndex, additionLineIndex);
468
+ hunkData.hunkContent.push(currentContent);
469
+ }
470
+ additionLineIndex++;
471
+ deletionLineIndex++;
472
+ parsedAdditionLines++;
473
+ parsedDeletionLines++;
474
+ if (isPartial) {
475
+ currentFile.deletionLines.push(line);
476
+ currentFile.additionLines.push(line);
477
+ }
478
+ currentContent.lines++;
479
+ lastLineType = "context";
480
+ } else if (type === "metadata" && currentContent != null) {
481
+ if (currentContent.type === "context") {
482
+ hunkData.noEOFCRAdditions = true;
483
+ hunkData.noEOFCRDeletions = true;
484
+ } else if (lastLineType === "deletion") hunkData.noEOFCRDeletions = true;
485
+ else if (lastLineType === "addition") hunkData.noEOFCRAdditions = true;
486
+ if (isPartial && (lastLineType === "addition" || lastLineType === "context")) {
487
+ const lastIndex = currentFile.additionLines.length - 1;
488
+ if (lastIndex >= 0) currentFile.additionLines[lastIndex] = cleanLastNewline(currentFile.additionLines[lastIndex]);
489
+ }
490
+ if (isPartial && (lastLineType === "deletion" || lastLineType === "context")) {
491
+ const lastIndex = currentFile.deletionLines.length - 1;
492
+ if (lastIndex >= 0) currentFile.deletionLines[lastIndex] = cleanLastNewline(currentFile.deletionLines[lastIndex]);
493
+ }
494
+ }
495
+ }
496
+ if (throwOnError && (parsedAdditionLines !== hunkData.additionCount || parsedDeletionLines !== hunkData.deletionCount)) throw Error("parsePatchContent: hunk line count mismatch");
497
+ hunkData.additionLines = additionLines;
498
+ hunkData.deletionLines = deletionLines;
499
+ hunkData.collapsedBefore = Math.max(getHunkSideStartBoundary(hunkData.additionStart, hunkData.additionCount) - lastHunkEnd, 0);
500
+ currentFile.hunks.push(hunkData);
501
+ lastHunkEnd = getHunkSideEndBoundary(hunkData.additionStart, hunkData.additionCount);
502
+ for (const content of hunkData.hunkContent) if (content.type === "context") {
503
+ hunkData.splitLineCount += content.lines;
504
+ hunkData.unifiedLineCount += content.lines;
505
+ } else {
506
+ hunkData.splitLineCount += Math.max(content.additions, content.deletions);
507
+ hunkData.unifiedLineCount += content.deletions + content.additions;
508
+ }
509
+ hunkData.splitLineStart = currentFile.splitLineCount + hunkData.collapsedBefore;
510
+ hunkData.unifiedLineStart = currentFile.unifiedLineCount + hunkData.collapsedBefore;
511
+ currentFile.splitLineCount += hunkData.collapsedBefore + hunkData.splitLineCount;
512
+ currentFile.unifiedLineCount += hunkData.collapsedBefore + hunkData.unifiedLineCount;
513
+ }
514
+ if (currentFile == null) return;
515
+ if (throwOnError && isPartial && !isGitDiff && currentFile.hunks.length === 0) throw Error("parsePatchContent: unified file has no hunks");
516
+ if (currentFile.hunks.length > 0 && !isPartial && currentFile.additionLines.length > 0 && currentFile.deletionLines.length > 0) {
517
+ const lastHunk = currentFile.hunks[currentFile.hunks.length - 1];
518
+ const lastHunkEnd = getHunkSideEndBoundary(lastHunk.additionStart, lastHunk.additionCount);
519
+ const totalFileLines = currentFile.additionLines.length;
520
+ const collapsedAfter = Math.max(totalFileLines - lastHunkEnd, 0);
521
+ currentFile.splitLineCount += collapsedAfter;
522
+ currentFile.unifiedLineCount += collapsedAfter;
523
+ }
524
+ if (!isGitDiff) {
525
+ if (currentFile.prevName != null && currentFile.name !== currentFile.prevName) if (currentFile.hunks.length > 0) currentFile.type = "rename-changed";
526
+ else currentFile.type = "rename-pure";
527
+ else if ((oldFile == null || oldFile.contents === "") && newFile != null && newFile.contents !== "") currentFile.type = "new";
528
+ else if (oldFile != null && oldFile.contents !== "" && (newFile == null || newFile.contents === "")) currentFile.type = "deleted";
529
+ }
530
+ if (currentFile.type !== "rename-pure" && currentFile.type !== "rename-changed") currentFile.prevName = void 0;
531
+ realignChangeContentBySimilarity(currentFile);
532
+ return currentFile;
533
+ }
534
+ /**
535
+ * Parses a patch file string into an array of parsed patches.
536
+ *
537
+ * @param data - The raw patch file content (supports multi-commit patches)
538
+ * @param cacheKeyPrefix - Optional prefix for generating cache keys. When provided,
539
+ * each file in the patch will get a cache key in the format `prefix-patchIndex-fileIndex`.
540
+ * This enables caching of rendered diff results in the worker pool.
541
+ */
542
+ function parsePatchFiles(data, cacheKeyPrefix, throwOnError = false) {
543
+ const patches = [];
544
+ const rawPatches = hasCommitMetadataBoundary(data) ? data.split(COMMIT_METADATA_SPLIT) : [data];
545
+ for (const patch of rawPatches) try {
546
+ patches.push(processPatch(patch, cacheKeyPrefix != null ? `${cacheKeyPrefix}-${patches.length}` : void 0, throwOnError));
547
+ } catch (error) {
548
+ if (throwOnError) throw error;
549
+ else console.error(error);
550
+ }
551
+ return patches;
552
+ }
553
+ function hasCommitMetadataBoundary(data) {
554
+ return data.startsWith("From ") || data.includes("\nFrom ");
555
+ }
556
+ function splitFileContents(contents) {
557
+ const lines = splitWithNewlines(contents);
558
+ for (let index = 0; index < lines.length; index++) lines[index] = detachString(lines[index]);
559
+ return lines;
560
+ }
561
+ function splitWithNewlines(contents) {
562
+ if (contents.length === 0) return [""];
563
+ const lines = [];
564
+ let startIndex = 0;
565
+ for (;;) {
566
+ const newlineIndex = contents.indexOf("\n", startIndex);
567
+ if (newlineIndex === -1) break;
568
+ lines.push(contents.slice(startIndex, newlineIndex + 1));
569
+ startIndex = newlineIndex + 1;
570
+ }
571
+ if (startIndex < contents.length) lines.push(contents.slice(startIndex));
572
+ return lines;
573
+ }
574
+ function splitGitDiffFiles(contents) {
575
+ return splitAtLinePrefix(contents, "diff --git");
576
+ }
577
+ function splitUnifiedDiffFiles(contents) {
578
+ if (contents.length === 0) return [""];
579
+ const parts = [];
580
+ let partStartIndex = 0;
581
+ let lineStartIndex = 0;
582
+ let remainingDeletionLines = 0;
583
+ let remainingAdditionLines = 0;
584
+ let hasOpenedUnifiedFile = false;
585
+ while (lineStartIndex < contents.length) {
586
+ const nextLineStartIndex = getNextLineStartIndex(contents, lineStartIndex);
587
+ if (remainingDeletionLines <= 0 && remainingAdditionLines <= 0) {
588
+ if (isUnifiedDiffFileHeaderAt(contents, lineStartIndex)) {
589
+ if (lineStartIndex > partStartIndex) parts.push(contents.slice(partStartIndex, lineStartIndex));
590
+ partStartIndex = lineStartIndex;
591
+ hasOpenedUnifiedFile = true;
592
+ lineStartIndex = getNextLineStartIndex(contents, nextLineStartIndex);
593
+ continue;
594
+ }
595
+ if (hasOpenedUnifiedFile && contents.startsWith("@@ -", lineStartIndex)) {
596
+ const fileHeader = parseHunkHeader(contents.slice(lineStartIndex, nextLineStartIndex));
597
+ if (fileHeader != null) {
598
+ remainingDeletionLines = fileHeader.deletionCount;
599
+ remainingAdditionLines = fileHeader.additionCount;
600
+ }
601
+ }
602
+ lineStartIndex = nextLineStartIndex;
603
+ continue;
604
+ }
605
+ const firstChar = contents[lineStartIndex];
606
+ if (firstChar === "\\") {
607
+ lineStartIndex = nextLineStartIndex;
608
+ continue;
609
+ }
610
+ if (firstChar === " ") {
611
+ remainingDeletionLines = Math.max(remainingDeletionLines - 1, 0);
612
+ remainingAdditionLines = Math.max(remainingAdditionLines - 1, 0);
613
+ } else if (firstChar === "-") remainingDeletionLines = Math.max(remainingDeletionLines - 1, 0);
614
+ else if (firstChar === "+") remainingAdditionLines = Math.max(remainingAdditionLines - 1, 0);
615
+ lineStartIndex = nextLineStartIndex;
616
+ }
617
+ parts.push(contents.slice(partStartIndex));
618
+ return parts;
619
+ }
620
+ function startsWithUnifiedDiffFileHeader(contents) {
621
+ return isUnifiedDiffFileHeaderAt(contents, 0);
622
+ }
623
+ function isUnifiedDiffFileHeaderAt(contents, lineStartIndex) {
624
+ const nextLineStartIndex = getNextLineStartIndex(contents, lineStartIndex);
625
+ return isUnifiedDiffHeaderLineAt(contents, lineStartIndex, "---") && isUnifiedDiffHeaderLineAt(contents, nextLineStartIndex, "+++");
626
+ }
627
+ function isUnifiedDiffHeaderLineAt(contents, lineStartIndex, prefix) {
628
+ if (!contents.startsWith(prefix, lineStartIndex)) return false;
629
+ const separator = contents[lineStartIndex + prefix.length];
630
+ if (separator !== " " && separator !== " ") return false;
631
+ for (let index = lineStartIndex + prefix.length + 1; index < contents.length; index++) {
632
+ const char = contents[index];
633
+ if (char === "\n" || char === "\r") break;
634
+ if (char !== " " && char !== " ") return true;
635
+ }
636
+ return false;
637
+ }
638
+ function getNextLineStartIndex(contents, lineStartIndex) {
639
+ const newlineIndex = contents.indexOf("\n", lineStartIndex);
640
+ return newlineIndex === -1 ? contents.length : newlineIndex + 1;
641
+ }
642
+ function isHunkBodyLine(line) {
643
+ const firstChar = line[0];
644
+ return firstChar === "+" || firstChar === "-" || firstChar === " ";
645
+ }
646
+ function isFormatPatchVersionSeparator(line) {
647
+ if (!line.startsWith("--")) return false;
648
+ for (let index = 2; index < line.length; index++) {
649
+ const char = line[index];
650
+ if (char !== " " && char !== " " && char !== "\n" && char !== "\r") return false;
651
+ }
652
+ return true;
653
+ }
654
+ function parseHunkHeader(line) {
655
+ if (!line.startsWith("@@ -")) return;
656
+ let index = 4;
657
+ const deletionStartResult = readPositiveInteger(line, index);
658
+ if (deletionStartResult == null) return;
659
+ const deletionStart = deletionStartResult.value;
660
+ index = deletionStartResult.endIndex;
661
+ let deletionCount = 1;
662
+ if (line[index] === ",") {
663
+ const deletionCountResult = readPositiveInteger(line, index + 1);
664
+ if (deletionCountResult == null) return;
665
+ deletionCount = deletionCountResult.value;
666
+ index = deletionCountResult.endIndex;
667
+ }
668
+ if (line[index] !== " " || line[index + 1] !== "+") return;
669
+ index += 2;
670
+ const additionStartResult = readPositiveInteger(line, index);
671
+ if (additionStartResult == null) return;
672
+ const additionStart = additionStartResult.value;
673
+ index = additionStartResult.endIndex;
674
+ let additionCount = 1;
675
+ if (line[index] === ",") {
676
+ const additionCountResult = readPositiveInteger(line, index + 1);
677
+ if (additionCountResult == null) return;
678
+ additionCount = additionCountResult.value;
679
+ index = additionCountResult.endIndex;
680
+ }
681
+ if (line[index] !== " " || line[index + 1] !== "@" || line[index + 2] !== "@") return;
682
+ let hunkContext;
683
+ const contextStartIndex = index + 3;
684
+ if (line[contextStartIndex] === " ") hunkContext = trimLineEnd(line.slice(contextStartIndex + 1));
685
+ return {
686
+ additionCount,
687
+ additionStart,
688
+ deletionCount,
689
+ deletionStart,
690
+ hunkContext
691
+ };
692
+ }
693
+ function readPositiveInteger(value, startIndex) {
694
+ let index = startIndex;
695
+ let parsedValue = 0;
696
+ for (; index < value.length; index++) {
697
+ const digit = value.charCodeAt(index) - 48;
698
+ if (digit < 0 || digit > 9) break;
699
+ parsedValue = parsedValue * 10 + digit;
700
+ }
701
+ if (index === startIndex) return;
702
+ return {
703
+ value: parsedValue,
704
+ endIndex: index
705
+ };
706
+ }
707
+ function trimLineEnd(value) {
708
+ if (value.endsWith("\r\n")) return value.slice(0, -2);
709
+ if (value.endsWith("\n")) return value.slice(0, -1);
710
+ return value;
711
+ }
712
+ function isGitDiffPatch(data) {
713
+ return data.startsWith("diff --git") || data.includes("\ndiff --git");
714
+ }
715
+ function splitAtLinePrefix(contents, prefix) {
716
+ if (contents.length === 0) return [""];
717
+ const newlinePrefix = `\n${prefix}`;
718
+ const firstBoundaryIndex = contents.startsWith(prefix) ? 0 : findLinePrefixIndex(contents, newlinePrefix, 0);
719
+ if (firstBoundaryIndex === -1) return [contents];
720
+ const parts = [];
721
+ if (firstBoundaryIndex > 0) parts.push(contents.slice(0, firstBoundaryIndex));
722
+ let startIndex = firstBoundaryIndex;
723
+ for (;;) {
724
+ const nextBoundaryIndex = findLinePrefixIndex(contents, newlinePrefix, startIndex + 1);
725
+ if (nextBoundaryIndex === -1) break;
726
+ parts.push(contents.slice(startIndex, nextBoundaryIndex));
727
+ startIndex = nextBoundaryIndex;
728
+ }
729
+ parts.push(contents.slice(startIndex));
730
+ return parts;
731
+ }
732
+ function findLinePrefixIndex(contents, newlinePrefix, fromIndex) {
733
+ const index = contents.indexOf(newlinePrefix, fromIndex);
734
+ return index === -1 ? -1 : index + 1;
735
+ }
736
+ function maybeDetachOptionalString(value) {
737
+ return value == null ? value : detachString(value);
738
+ }
739
+ function parseRawLineType(firstChar) {
740
+ return firstChar === " " ? "context" : firstChar === "\\" ? "metadata" : firstChar === "+" ? "addition" : "deletion";
741
+ }
742
+ function getParsedLineContent(rawLine) {
743
+ const processedLine = rawLine.slice(1);
744
+ return detachString(processedLine === "" ? "\n" : processedLine);
745
+ }
746
+ function createContentGroup(type, deletionLineIndex, additionLineIndex) {
747
+ if (type === "change") return {
748
+ type: "change",
749
+ additions: 0,
750
+ deletions: 0,
751
+ additionLineIndex,
752
+ deletionLineIndex
753
+ };
754
+ return {
755
+ type: "context",
756
+ lines: 0,
757
+ additionLineIndex,
758
+ deletionLineIndex
759
+ };
760
+ }
761
+ //#endregion
762
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/base.js
763
+ var Diff = class {
764
+ diff(oldStr, newStr, options = {}) {
765
+ let callback;
766
+ if (typeof options === "function") {
767
+ callback = options;
768
+ options = {};
769
+ } else if ("callback" in options) callback = options.callback;
770
+ const oldString = this.castInput(oldStr, options);
771
+ const newString = this.castInput(newStr, options);
772
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
773
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
774
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
775
+ }
776
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
777
+ var _a;
778
+ const done = (value) => {
779
+ value = this.postProcess(value, options);
780
+ if (callback) {
781
+ setTimeout(function() {
782
+ callback(value);
783
+ }, 0);
784
+ return;
785
+ } else return value;
786
+ };
787
+ const newLen = newTokens.length, oldLen = oldTokens.length;
788
+ let editLength = 1;
789
+ let maxEditLength = newLen + oldLen;
790
+ if (options.maxEditLength != null) maxEditLength = Math.min(maxEditLength, options.maxEditLength);
791
+ const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
792
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
793
+ const bestPath = [{
794
+ oldPos: -1,
795
+ lastComponent: void 0
796
+ }];
797
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
798
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
799
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
800
+ const execEditLength = () => {
801
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
802
+ let basePath;
803
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
804
+ if (removePath) bestPath[diagonalPath - 1] = void 0;
805
+ let canAdd = false;
806
+ if (addPath) {
807
+ const addPathNewPos = addPath.oldPos - diagonalPath;
808
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
809
+ }
810
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
811
+ if (!canAdd && !canRemove) {
812
+ bestPath[diagonalPath] = void 0;
813
+ continue;
814
+ }
815
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) basePath = this.addToPath(addPath, true, false, 0, options);
816
+ else basePath = this.addToPath(removePath, false, true, 1, options);
817
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
818
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
819
+ else {
820
+ bestPath[diagonalPath] = basePath;
821
+ if (basePath.oldPos + 1 >= oldLen) maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
822
+ if (newPos + 1 >= newLen) minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
823
+ }
824
+ }
825
+ editLength++;
826
+ };
827
+ if (callback) (function exec() {
828
+ setTimeout(function() {
829
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) return callback(void 0);
830
+ if (!execEditLength()) exec();
831
+ }, 0);
832
+ })();
833
+ else while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
834
+ const ret = execEditLength();
835
+ if (ret) return ret;
836
+ }
837
+ }
838
+ addToPath(path, added, removed, oldPosInc, options) {
839
+ const last = path.lastComponent;
840
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) return {
841
+ oldPos: path.oldPos + oldPosInc,
842
+ lastComponent: {
843
+ count: last.count + 1,
844
+ added,
845
+ removed,
846
+ previousComponent: last.previousComponent
847
+ }
848
+ };
849
+ else return {
850
+ oldPos: path.oldPos + oldPosInc,
851
+ lastComponent: {
852
+ count: 1,
853
+ added,
854
+ removed,
855
+ previousComponent: last
856
+ }
857
+ };
858
+ }
859
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
860
+ const newLen = newTokens.length, oldLen = oldTokens.length;
861
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
862
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
863
+ newPos++;
864
+ oldPos++;
865
+ commonCount++;
866
+ if (options.oneChangePerToken) basePath.lastComponent = {
867
+ count: 1,
868
+ previousComponent: basePath.lastComponent,
869
+ added: false,
870
+ removed: false
871
+ };
872
+ }
873
+ if (commonCount && !options.oneChangePerToken) basePath.lastComponent = {
874
+ count: commonCount,
875
+ previousComponent: basePath.lastComponent,
876
+ added: false,
877
+ removed: false
878
+ };
879
+ basePath.oldPos = oldPos;
880
+ return newPos;
881
+ }
882
+ equals(left, right, options) {
883
+ if (options.comparator) return options.comparator(left, right);
884
+ else return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
885
+ }
886
+ removeEmpty(array) {
887
+ const ret = [];
888
+ for (let i = 0; i < array.length; i++) if (array[i]) ret.push(array[i]);
889
+ return ret;
890
+ }
891
+ castInput(value, options) {
892
+ return value;
893
+ }
894
+ tokenize(value, options) {
895
+ return Array.from(value);
896
+ }
897
+ join(chars) {
898
+ return chars.join("");
899
+ }
900
+ postProcess(changeObjects, options) {
901
+ return changeObjects;
902
+ }
903
+ get useLongestToken() {
904
+ return false;
905
+ }
906
+ buildValues(lastComponent, newTokens, oldTokens) {
907
+ const components = [];
908
+ let nextComponent;
909
+ while (lastComponent) {
910
+ components.push(lastComponent);
911
+ nextComponent = lastComponent.previousComponent;
912
+ delete lastComponent.previousComponent;
913
+ lastComponent = nextComponent;
914
+ }
915
+ components.reverse();
916
+ const componentLen = components.length;
917
+ let componentPos = 0, newPos = 0, oldPos = 0;
918
+ for (; componentPos < componentLen; componentPos++) {
919
+ const component = components[componentPos];
920
+ if (!component.removed) {
921
+ if (!component.added && this.useLongestToken) {
922
+ let value = newTokens.slice(newPos, newPos + component.count);
923
+ value = value.map(function(value, i) {
924
+ const oldValue = oldTokens[oldPos + i];
925
+ return oldValue.length > value.length ? oldValue : value;
926
+ });
927
+ component.value = this.join(value);
928
+ } else component.value = this.join(newTokens.slice(newPos, newPos + component.count));
929
+ newPos += component.count;
930
+ if (!component.added) oldPos += component.count;
931
+ } else {
932
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
933
+ oldPos += component.count;
934
+ }
935
+ }
936
+ return components;
937
+ }
938
+ };
939
+ //#endregion
940
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/character.js
941
+ var CharacterDiff = class extends Diff {};
942
+ const characterDiff = new CharacterDiff();
943
+ function diffChars(oldStr, newStr, options) {
944
+ return characterDiff.diff(oldStr, newStr, options);
945
+ }
946
+ //#endregion
947
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/util/string.js
948
+ function longestCommonPrefix(str1, str2) {
949
+ let i;
950
+ for (i = 0; i < str1.length && i < str2.length; i++) if (str1[i] != str2[i]) return str1.slice(0, i);
951
+ return str1.slice(0, i);
952
+ }
953
+ function longestCommonSuffix(str1, str2) {
954
+ let i;
955
+ if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) return "";
956
+ for (i = 0; i < str1.length && i < str2.length; i++) if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) return str1.slice(-i);
957
+ return str1.slice(-i);
958
+ }
959
+ function replacePrefix(string, oldPrefix, newPrefix) {
960
+ if (string.slice(0, oldPrefix.length) != oldPrefix) throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
961
+ return newPrefix + string.slice(oldPrefix.length);
962
+ }
963
+ function replaceSuffix(string, oldSuffix, newSuffix) {
964
+ if (!oldSuffix) return string + newSuffix;
965
+ if (string.slice(-oldSuffix.length) != oldSuffix) throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
966
+ return string.slice(0, -oldSuffix.length) + newSuffix;
967
+ }
968
+ function removePrefix(string, oldPrefix) {
969
+ return replacePrefix(string, oldPrefix, "");
970
+ }
971
+ function removeSuffix(string, oldSuffix) {
972
+ return replaceSuffix(string, oldSuffix, "");
973
+ }
974
+ function maximumOverlap(string1, string2) {
975
+ return string2.slice(0, overlapCount(string1, string2));
976
+ }
977
+ function overlapCount(a, b) {
978
+ let startA = 0;
979
+ if (a.length > b.length) startA = a.length - b.length;
980
+ let endB = b.length;
981
+ if (a.length < b.length) endB = a.length;
982
+ const map = Array(endB);
983
+ let k = 0;
984
+ map[0] = 0;
985
+ for (let j = 1; j < endB; j++) {
986
+ if (b[j] == b[k]) map[j] = map[k];
987
+ else map[j] = k;
988
+ while (k > 0 && b[j] != b[k]) k = map[k];
989
+ if (b[j] == b[k]) k++;
990
+ }
991
+ k = 0;
992
+ for (let i = startA; i < a.length; i++) {
993
+ while (k > 0 && a[i] != b[k]) k = map[k];
994
+ if (a[i] == b[k]) k++;
995
+ }
996
+ return k;
997
+ }
998
+ /**
999
+ * Split a string into segments using a word segmenter, merging consecutive
1000
+ * segments if they are both whitespace segments. Whitespace segments can
1001
+ * appear adjacent to one another for two reasons:
1002
+ * - newlines always get their own segment
1003
+ * - where a diacritic is attached to a whitespace character in the text, the
1004
+ * segment ends after the diacritic, so e.g. " \u0300 " becomes two segments.
1005
+ * This function therefore runs the segmenter's .segment() method and then
1006
+ * merges consecutive segments of whitespace into a single part.
1007
+ */
1008
+ function segment(string, segmenter) {
1009
+ const parts = [];
1010
+ for (const segmentObj of Array.from(segmenter.segment(string))) {
1011
+ const segment = segmentObj.segment;
1012
+ if (parts.length && /\s/.test(parts[parts.length - 1]) && /\s/.test(segment)) parts[parts.length - 1] += segment;
1013
+ else parts.push(segment);
1014
+ }
1015
+ return parts;
1016
+ }
1017
+ function trailingWs(string, segmenter) {
1018
+ if (segmenter) return leadingAndTrailingWs(string, segmenter)[1];
1019
+ let i;
1020
+ for (i = string.length - 1; i >= 0; i--) if (!string[i].match(/\s/)) break;
1021
+ return string.substring(i + 1);
1022
+ }
1023
+ function leadingWs(string, segmenter) {
1024
+ if (segmenter) return leadingAndTrailingWs(string, segmenter)[0];
1025
+ const match = string.match(/^\s*/);
1026
+ return match ? match[0] : "";
1027
+ }
1028
+ function leadingAndTrailingWs(string, segmenter) {
1029
+ if (!segmenter) return [leadingWs(string), trailingWs(string)];
1030
+ if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
1031
+ const segments = segment(string, segmenter);
1032
+ const firstSeg = segments[0];
1033
+ const lastSeg = segments[segments.length - 1];
1034
+ return [/\s/.test(firstSeg) ? firstSeg : "", /\s/.test(lastSeg) ? lastSeg : ""];
1035
+ }
1036
+ //#endregion
1037
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/word.js
1038
+ const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
1039
+ const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
1040
+ var WordDiff = class extends Diff {
1041
+ equals(left, right, options) {
1042
+ if (options.ignoreCase) {
1043
+ left = left.toLowerCase();
1044
+ right = right.toLowerCase();
1045
+ }
1046
+ return left.trim() === right.trim();
1047
+ }
1048
+ tokenize(value, options = {}) {
1049
+ let parts;
1050
+ if (options.intlSegmenter) {
1051
+ const segmenter = options.intlSegmenter;
1052
+ if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
1053
+ parts = segment(value, segmenter);
1054
+ } else parts = value.match(tokenizeIncludingWhitespace) || [];
1055
+ const tokens = [];
1056
+ let prevPart = null;
1057
+ parts.forEach((part) => {
1058
+ if (/\s/.test(part)) if (prevPart == null) tokens.push(part);
1059
+ else tokens.push(tokens.pop() + part);
1060
+ else if (prevPart != null && /\s/.test(prevPart)) if (tokens[tokens.length - 1] == prevPart) tokens.push(tokens.pop() + part);
1061
+ else tokens.push(prevPart + part);
1062
+ else tokens.push(part);
1063
+ prevPart = part;
1064
+ });
1065
+ return tokens;
1066
+ }
1067
+ join(tokens) {
1068
+ return tokens.map((token, i) => {
1069
+ if (i == 0) return token;
1070
+ else return token.replace(/^\s+/, "");
1071
+ }).join("");
1072
+ }
1073
+ postProcess(changes, options) {
1074
+ if (!changes || options.oneChangePerToken) return changes;
1075
+ let lastKeep = null;
1076
+ let insertion = null;
1077
+ let deletion = null;
1078
+ changes.forEach((change) => {
1079
+ if (change.added) insertion = change;
1080
+ else if (change.removed) deletion = change;
1081
+ else {
1082
+ if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change, options.intlSegmenter);
1083
+ lastKeep = change;
1084
+ insertion = null;
1085
+ deletion = null;
1086
+ }
1087
+ });
1088
+ if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null, options.intlSegmenter);
1089
+ return changes;
1090
+ }
1091
+ };
1092
+ new WordDiff();
1093
+ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep, segmenter) {
1094
+ if (deletion && insertion) {
1095
+ const [oldWsPrefix, oldWsSuffix] = leadingAndTrailingWs(deletion.value, segmenter);
1096
+ const [newWsPrefix, newWsSuffix] = leadingAndTrailingWs(insertion.value, segmenter);
1097
+ if (startKeep) {
1098
+ const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
1099
+ startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
1100
+ deletion.value = removePrefix(deletion.value, commonWsPrefix);
1101
+ insertion.value = removePrefix(insertion.value, commonWsPrefix);
1102
+ }
1103
+ if (endKeep) {
1104
+ const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
1105
+ endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
1106
+ deletion.value = removeSuffix(deletion.value, commonWsSuffix);
1107
+ insertion.value = removeSuffix(insertion.value, commonWsSuffix);
1108
+ }
1109
+ } else if (insertion) {
1110
+ if (startKeep) {
1111
+ const ws = leadingWs(insertion.value, segmenter);
1112
+ insertion.value = insertion.value.substring(ws.length);
1113
+ }
1114
+ if (endKeep) {
1115
+ const ws = leadingWs(endKeep.value, segmenter);
1116
+ endKeep.value = endKeep.value.substring(ws.length);
1117
+ }
1118
+ } else if (startKeep && endKeep) {
1119
+ const newWsFull = leadingWs(endKeep.value, segmenter), [delWsStart, delWsEnd] = leadingAndTrailingWs(deletion.value, segmenter);
1120
+ const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
1121
+ deletion.value = removePrefix(deletion.value, newWsStart);
1122
+ const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
1123
+ deletion.value = removeSuffix(deletion.value, newWsEnd);
1124
+ endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
1125
+ startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
1126
+ } else if (endKeep) {
1127
+ const endKeepWsPrefix = leadingWs(endKeep.value, segmenter);
1128
+ const overlap = maximumOverlap(trailingWs(deletion.value, segmenter), endKeepWsPrefix);
1129
+ deletion.value = removeSuffix(deletion.value, overlap);
1130
+ } else if (startKeep) {
1131
+ const overlap = maximumOverlap(trailingWs(startKeep.value, segmenter), leadingWs(deletion.value, segmenter));
1132
+ deletion.value = removePrefix(deletion.value, overlap);
1133
+ }
1134
+ }
1135
+ var WordsWithSpaceDiff = class extends Diff {
1136
+ tokenize(value) {
1137
+ const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
1138
+ return value.match(regex) || [];
1139
+ }
1140
+ };
1141
+ const wordsWithSpaceDiff = new WordsWithSpaceDiff();
1142
+ function diffWordsWithSpace(oldStr, newStr, options) {
1143
+ return wordsWithSpaceDiff.diff(oldStr, newStr, options);
1144
+ }
1145
+ //#endregion
1146
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/line.js
1147
+ var LineDiff = class extends Diff {
1148
+ constructor() {
1149
+ super(...arguments);
1150
+ this.tokenize = tokenize;
1151
+ }
1152
+ equals(left, right, options) {
1153
+ if (options.ignoreWhitespace) {
1154
+ if (!options.newlineIsToken || !left.includes("\n")) left = left.trim();
1155
+ if (!options.newlineIsToken || !right.includes("\n")) right = right.trim();
1156
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
1157
+ if (left.endsWith("\n")) left = left.slice(0, -1);
1158
+ if (right.endsWith("\n")) right = right.slice(0, -1);
1159
+ }
1160
+ return super.equals(left, right, options);
1161
+ }
1162
+ };
1163
+ const lineDiff = new LineDiff();
1164
+ function diffLines(oldStr, newStr, options) {
1165
+ return lineDiff.diff(oldStr, newStr, options);
1166
+ }
1167
+ function tokenize(value, options) {
1168
+ if (options.stripTrailingCr) value = value.replace(/\r\n/g, "\n");
1169
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
1170
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) linesAndNewlines.pop();
1171
+ for (let i = 0; i < linesAndNewlines.length; i++) {
1172
+ const line = linesAndNewlines[i];
1173
+ if (i % 2 && !options.newlineIsToken) retLines[retLines.length - 1] += line;
1174
+ else retLines.push(line);
1175
+ }
1176
+ return retLines;
1177
+ }
1178
+ //#endregion
1179
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/sentence.js
1180
+ function isSentenceEndPunct(char) {
1181
+ return char == "." || char == "!" || char == "?";
1182
+ }
1183
+ var SentenceDiff = class extends Diff {
1184
+ tokenize(value) {
1185
+ var _a;
1186
+ const result = [];
1187
+ let tokenStartI = 0;
1188
+ for (let i = 0; i < value.length; i++) {
1189
+ if (i == value.length - 1) {
1190
+ result.push(value.slice(tokenStartI));
1191
+ break;
1192
+ }
1193
+ if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
1194
+ result.push(value.slice(tokenStartI, i + 1));
1195
+ i = tokenStartI = i + 1;
1196
+ while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\s/)) i++;
1197
+ result.push(value.slice(tokenStartI, i + 1));
1198
+ tokenStartI = i + 1;
1199
+ }
1200
+ }
1201
+ return result;
1202
+ }
1203
+ };
1204
+ new SentenceDiff();
1205
+ //#endregion
1206
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/css.js
1207
+ var CssDiff = class extends Diff {
1208
+ tokenize(value) {
1209
+ return value.split(/([{}:;,]|\s+)/);
1210
+ }
1211
+ };
1212
+ new CssDiff();
1213
+ //#endregion
1214
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/json.js
1215
+ var JsonDiff = class extends Diff {
1216
+ constructor() {
1217
+ super(...arguments);
1218
+ this.tokenize = tokenize;
1219
+ }
1220
+ get useLongestToken() {
1221
+ return true;
1222
+ }
1223
+ castInput(value, options) {
1224
+ const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
1225
+ return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
1226
+ }
1227
+ equals(left, right, options) {
1228
+ return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
1229
+ }
1230
+ };
1231
+ new JsonDiff();
1232
+ function canonicalize(obj, stack, replacementStack, replacer, key) {
1233
+ stack = stack || [];
1234
+ replacementStack = replacementStack || [];
1235
+ if (replacer) obj = replacer(key === void 0 ? "" : key, obj);
1236
+ let i;
1237
+ for (i = 0; i < stack.length; i += 1) if (stack[i] === obj) return replacementStack[i];
1238
+ let canonicalizedObj;
1239
+ if ("[object Array]" === Object.prototype.toString.call(obj)) {
1240
+ stack.push(obj);
1241
+ canonicalizedObj = new Array(obj.length);
1242
+ replacementStack.push(canonicalizedObj);
1243
+ for (i = 0; i < obj.length; i += 1) canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
1244
+ stack.pop();
1245
+ replacementStack.pop();
1246
+ return canonicalizedObj;
1247
+ }
1248
+ if (obj && obj.toJSON) obj = obj.toJSON();
1249
+ if (typeof obj === "object" && obj !== null) {
1250
+ stack.push(obj);
1251
+ canonicalizedObj = {};
1252
+ replacementStack.push(canonicalizedObj);
1253
+ const sortedKeys = [];
1254
+ let key;
1255
+ for (key in obj)
1256
+ /* istanbul ignore else */
1257
+ if (Object.prototype.hasOwnProperty.call(obj, key)) sortedKeys.push(key);
1258
+ sortedKeys.sort();
1259
+ for (i = 0; i < sortedKeys.length; i += 1) {
1260
+ key = sortedKeys[i];
1261
+ canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);
1262
+ }
1263
+ stack.pop();
1264
+ replacementStack.pop();
1265
+ } else canonicalizedObj = obj;
1266
+ return canonicalizedObj;
1267
+ }
1268
+ //#endregion
1269
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/array.js
1270
+ var ArrayDiff = class extends Diff {
1271
+ tokenize(value) {
1272
+ return value.slice();
1273
+ }
1274
+ join(value) {
1275
+ return value;
1276
+ }
1277
+ removeEmpty(value) {
1278
+ return value;
1279
+ }
1280
+ };
1281
+ new ArrayDiff();
1282
+ //#endregion
1283
+ //#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/patch/create.js
1284
+ /**
1285
+ * Returns true if the filename contains characters that require C-style
1286
+ * quoting (as used by Git and GNU diffutils in diff output).
1287
+ */
1288
+ function needsQuoting(s) {
1289
+ for (let i = 0; i < s.length; i++) if (s[i] < " " || s[i] > "~" || s[i] === "\"" || s[i] === "\\") return true;
1290
+ return false;
1291
+ }
1292
+ /**
1293
+ * C-style quotes a filename, encoding special characters as escape sequences
1294
+ * and non-ASCII bytes as octal escapes. This is the inverse of
1295
+ * `parseQuotedFileName` in parse.ts.
1296
+ *
1297
+ * Non-ASCII bytes are encoded as UTF-8 before being emitted as octal escapes.
1298
+ * This matches the behaviour of both Git and GNU diffutils, which always emit
1299
+ * UTF-8 octal escapes regardless of the underlying filesystem encoding (e.g.
1300
+ * Git for Windows converts from NTFS's UTF-16 to UTF-8 internally).
1301
+ *
1302
+ * If the filename doesn't need quoting, returns it as-is.
1303
+ */
1304
+ function quoteFileNameIfNeeded(s) {
1305
+ if (!needsQuoting(s)) return s;
1306
+ let result = "\"";
1307
+ const bytes = new TextEncoder().encode(s);
1308
+ let i = 0;
1309
+ while (i < bytes.length) {
1310
+ const b = bytes[i];
1311
+ if (b === 7) result += "\\a";
1312
+ else if (b === 8) result += "\\b";
1313
+ else if (b === 9) result += "\\t";
1314
+ else if (b === 10) result += "\\n";
1315
+ else if (b === 11) result += "\\v";
1316
+ else if (b === 12) result += "\\f";
1317
+ else if (b === 13) result += "\\r";
1318
+ else if (b === 34) result += "\\\"";
1319
+ else if (b === 92) result += "\\\\";
1320
+ else if (b >= 32 && b <= 126) result += String.fromCharCode(b);
1321
+ else result += "\\" + b.toString(8).padStart(3, "0");
1322
+ i++;
1323
+ }
1324
+ result += "\"";
1325
+ return result;
1326
+ }
1327
+ const INCLUDE_HEADERS = {
1328
+ includeIndex: true,
1329
+ includeUnderline: true,
1330
+ includeFileHeaders: true
1331
+ };
1332
+ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
1333
+ let optionsObj;
1334
+ if (!options) optionsObj = {};
1335
+ else if (typeof options === "function") optionsObj = { callback: options };
1336
+ else optionsObj = options;
1337
+ if (typeof optionsObj.context === "undefined") optionsObj.context = 4;
1338
+ const context = optionsObj.context;
1339
+ if (optionsObj.newlineIsToken) throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
1340
+ if (!optionsObj.callback) return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
1341
+ else {
1342
+ const { callback } = optionsObj;
1343
+ diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
1344
+ callback(diffLinesResultToPatch(diff));
1345
+ } }));
1346
+ }
1347
+ function diffLinesResultToPatch(diff) {
1348
+ if (!diff) return;
1349
+ diff.push({
1350
+ value: "",
1351
+ lines: []
1352
+ });
1353
+ function contextLines(lines) {
1354
+ return lines.map(function(entry) {
1355
+ return " " + entry;
1356
+ });
1357
+ }
1358
+ const hunks = [];
1359
+ let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
1360
+ for (let i = 0; i < diff.length; i++) {
1361
+ const current = diff[i], lines = current.lines || splitLines(current.value);
1362
+ current.lines = lines;
1363
+ if (current.added || current.removed) {
1364
+ if (!oldRangeStart) {
1365
+ const prev = diff[i - 1];
1366
+ oldRangeStart = oldLine;
1367
+ newRangeStart = newLine;
1368
+ if (prev) {
1369
+ curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
1370
+ oldRangeStart -= curRange.length;
1371
+ newRangeStart -= curRange.length;
1372
+ }
1373
+ }
1374
+ for (const line of lines) curRange.push((current.added ? "+" : "-") + line);
1375
+ if (current.added) newLine += lines.length;
1376
+ else oldLine += lines.length;
1377
+ } else {
1378
+ if (oldRangeStart) if (lines.length <= context * 2 && i < diff.length - 2) for (const line of contextLines(lines)) curRange.push(line);
1379
+ else {
1380
+ const contextSize = Math.min(lines.length, context);
1381
+ for (const line of contextLines(lines.slice(0, contextSize))) curRange.push(line);
1382
+ const hunk = {
1383
+ oldStart: oldRangeStart,
1384
+ oldLines: oldLine - oldRangeStart + contextSize,
1385
+ newStart: newRangeStart,
1386
+ newLines: newLine - newRangeStart + contextSize,
1387
+ lines: curRange
1388
+ };
1389
+ hunks.push(hunk);
1390
+ oldRangeStart = 0;
1391
+ newRangeStart = 0;
1392
+ curRange = [];
1393
+ }
1394
+ oldLine += lines.length;
1395
+ newLine += lines.length;
1396
+ }
1397
+ }
1398
+ for (const hunk of hunks) for (let i = 0; i < hunk.lines.length; i++) if (hunk.lines[i].endsWith("\n")) hunk.lines[i] = hunk.lines[i].slice(0, -1);
1399
+ else {
1400
+ hunk.lines.splice(i + 1, 0, "\");
1401
+ i++;
1402
+ }
1403
+ return {
1404
+ oldFileName,
1405
+ newFileName,
1406
+ oldHeader,
1407
+ newHeader,
1408
+ hunks
1409
+ };
1410
+ }
1411
+ }
1412
+ /**
1413
+ * creates a unified diff patch.
1414
+ *
1415
+ * @param patch either a single structured patch object (as returned by `structuredPatch`) or an
1416
+ * array of them (as returned by `parsePatch`).
1417
+ * @param headerOptions behaves the same as the `headerOptions` option of `createTwoFilesPatch`.
1418
+ * Ignored for patches where `isGit` is `true`.
1419
+ *
1420
+ * When a patch has `isGit: true`, `formatPatch` output is changed to more closely match Git's
1421
+ * output: it emits a `diff --git` header, emits Git extended headers as appropriate based on
1422
+ * properties like `isRename`, `isCreate`, `newMode`, etc, and will omit `---`/`+++` file
1423
+ * headers for patches with no hunks (e.g. renames without content changes).
1424
+ */
1425
+ function formatPatch(patch, headerOptions) {
1426
+ var _a, _b, _c, _d, _e, _f;
1427
+ if (!headerOptions) headerOptions = INCLUDE_HEADERS;
1428
+ if (Array.isArray(patch)) {
1429
+ if (patch.length > 1 && !headerOptions.includeFileHeaders && !patch.every((p) => p.isGit)) throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");
1430
+ return patch.map((p) => formatPatch(p, headerOptions)).join("\n");
1431
+ }
1432
+ const ret = [];
1433
+ if (patch.isGit) {
1434
+ headerOptions = INCLUDE_HEADERS;
1435
+ if (!patch.oldFileName) throw new Error("oldFileName must be specified for Git patches");
1436
+ if (!patch.newFileName) throw new Error("newFileName must be specified for Git patches");
1437
+ let gitOldName = patch.oldFileName;
1438
+ let gitNewName = patch.newFileName;
1439
+ if (patch.isCreate && gitOldName === "/dev/null") gitOldName = gitNewName.replace(/^b\//, "a/");
1440
+ else if (patch.isDelete && gitNewName === "/dev/null") gitNewName = gitOldName.replace(/^a\//, "b/");
1441
+ ret.push("diff --git " + quoteFileNameIfNeeded(gitOldName) + " " + quoteFileNameIfNeeded(gitNewName));
1442
+ if (patch.isDelete) ret.push("deleted file mode " + ((_a = patch.oldMode) !== null && _a !== void 0 ? _a : "100644"));
1443
+ if (patch.isCreate) ret.push("new file mode " + ((_b = patch.newMode) !== null && _b !== void 0 ? _b : "100644"));
1444
+ if (patch.oldMode && patch.newMode && !patch.isDelete && !patch.isCreate) {
1445
+ ret.push("old mode " + patch.oldMode);
1446
+ ret.push("new mode " + patch.newMode);
1447
+ }
1448
+ if (patch.isRename) {
1449
+ ret.push("rename from " + quoteFileNameIfNeeded(((_c = patch.oldFileName) !== null && _c !== void 0 ? _c : "").replace(/^a\//, "")));
1450
+ ret.push("rename to " + quoteFileNameIfNeeded(((_d = patch.newFileName) !== null && _d !== void 0 ? _d : "").replace(/^b\//, "")));
1451
+ }
1452
+ if (patch.isCopy) {
1453
+ ret.push("copy from " + quoteFileNameIfNeeded(((_e = patch.oldFileName) !== null && _e !== void 0 ? _e : "").replace(/^a\//, "")));
1454
+ ret.push("copy to " + quoteFileNameIfNeeded(((_f = patch.newFileName) !== null && _f !== void 0 ? _f : "").replace(/^b\//, "")));
1455
+ }
1456
+ } else {
1457
+ if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName && patch.oldFileName !== void 0) ret.push("Index: " + patch.oldFileName);
1458
+ if (headerOptions.includeUnderline) ret.push("===================================================================");
1459
+ }
1460
+ const hasHunks = patch.hunks.length > 0;
1461
+ if (headerOptions.includeFileHeaders && patch.oldFileName !== void 0 && patch.newFileName !== void 0 && (!patch.isGit || hasHunks)) {
1462
+ ret.push("--- " + quoteFileNameIfNeeded(patch.oldFileName) + (patch.oldHeader ? " " + patch.oldHeader : ""));
1463
+ ret.push("+++ " + quoteFileNameIfNeeded(patch.newFileName) + (patch.newHeader ? " " + patch.newHeader : ""));
1464
+ }
1465
+ for (let i = 0; i < patch.hunks.length; i++) {
1466
+ const hunk = patch.hunks[i];
1467
+ const oldStart = hunk.oldLines === 0 ? hunk.oldStart - 1 : hunk.oldStart;
1468
+ const newStart = hunk.newLines === 0 ? hunk.newStart - 1 : hunk.newStart;
1469
+ ret.push("@@ -" + oldStart + "," + hunk.oldLines + " +" + newStart + "," + hunk.newLines + " @@");
1470
+ for (const line of hunk.lines) ret.push(line);
1471
+ }
1472
+ return ret.join("\n") + "\n";
1473
+ }
1474
+ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
1475
+ if (typeof options === "function") options = { callback: options };
1476
+ if (!(options === null || options === void 0 ? void 0 : options.callback)) {
1477
+ const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
1478
+ if (!patchObj) return;
1479
+ return formatPatch(patchObj, options === null || options === void 0 ? void 0 : options.headerOptions);
1480
+ } else {
1481
+ const { callback } = options;
1482
+ structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
1483
+ if (!patchObj) callback(void 0);
1484
+ else callback(formatPatch(patchObj, options.headerOptions));
1485
+ } }));
1486
+ }
1487
+ }
1488
+ /**
1489
+ * Split `text` into an array of lines, including the trailing newline character (where present)
1490
+ */
1491
+ function splitLines(text) {
1492
+ const hasTrailingNl = text.endsWith("\n");
1493
+ const result = text.split("\n").map((line) => line + "\n");
1494
+ if (hasTrailingNl) result.pop();
1495
+ else result.push(result.pop().slice(0, -1));
1496
+ return result;
1497
+ }
1498
+ //#endregion
1499
+ //#region ../../node_modules/.pnpm/@pierre+diffs@1.3.5_patch_hash=e39d9610970efa5b40101d721a2dd9c46d2c5065627574538bf6c398_88985040eb86a95c0004dc1cccf3d81b/node_modules/@pierre/diffs/dist/utils/parseDiffFromFile.js
1500
+ const MISSING_FILE_NAME = "/dev/null";
1501
+ /**
1502
+ * Parses a diff from two file contents objects.
1503
+ *
1504
+ * If both `oldFile` and `newFile` have a `cacheKey`, the resulting diff will
1505
+ * automatically get a combined cache key in the format `oldKey:newKey`.
1506
+ */
1507
+ function parseDiffFromFile(oldFile, newFile, options, throwOnError = false) {
1508
+ if (oldFile === null && newFile === null) throw new Error("parseDiffFromFile: You must pass oldFile, newFile, or both");
1509
+ const resolvedOldFile = oldFile ?? createMissingFile();
1510
+ const resolvedNewFile = newFile ?? createMissingFile();
1511
+ const fileData = processFile(createTwoFilesPatch(resolvedOldFile.name, resolvedNewFile.name, resolvedOldFile.contents, resolvedNewFile.contents, resolvedOldFile.header, resolvedNewFile.header, options), {
1512
+ cacheKey: (() => {
1513
+ const oldCacheKey = oldFile?.cacheKey ?? oldFile?.name;
1514
+ const newCacheKey = newFile?.cacheKey ?? newFile?.name;
1515
+ if (oldCacheKey != null && newCacheKey != null) return oldCacheKey + ":" + newCacheKey;
1516
+ return oldCacheKey ?? newCacheKey;
1517
+ })(),
1518
+ oldFile: resolvedOldFile,
1519
+ newFile: resolvedNewFile,
1520
+ throwOnError
1521
+ });
1522
+ if (fileData == null) throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");
1523
+ if (oldFile === null) {
1524
+ fileData.type = "new";
1525
+ fileData.prevName = void 0;
1526
+ } else if (newFile === null) {
1527
+ fileData.type = "deleted";
1528
+ fileData.prevName = void 0;
1529
+ }
1530
+ const language = newFile?.lang ?? (newFile === null ? oldFile?.lang : void 0);
1531
+ if (language != null) fileData.lang = language;
1532
+ return fileData;
1533
+ }
1534
+ function createMissingFile() {
1535
+ return {
1536
+ name: MISSING_FILE_NAME,
1537
+ contents: ""
1538
+ };
1539
+ }
1540
+ //#endregion
1541
+ //#region ../../node_modules/.pnpm/@pierre+diffs@1.3.5_patch_hash=e39d9610970efa5b40101d721a2dd9c46d2c5065627574538bf6c398_88985040eb86a95c0004dc1cccf3d81b/node_modules/@pierre/diffs/dist/utils/getSingularPatch.js
1542
+ function getSingularPatch(patch) {
1543
+ const parsedPatches = parsePatchFiles(patch);
1544
+ if (parsedPatches.length !== 1) {
1545
+ console.error(parsedPatches);
1546
+ throw new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");
1547
+ }
1548
+ const { files } = parsedPatches[0];
1549
+ if (files.length !== 1) {
1550
+ console.error(files);
1551
+ throw new Error("FileDiff: Provided patch must contain exactly 1 file diff");
1552
+ }
1553
+ return files[0];
1554
+ }
1555
+ //#endregion
1556
+ export { UNSAFE_CSS_ATTRIBUTE as A, DIFFS_TAG_NAME as C, HEADER_PREFIX_SLOT_ID as D, HEADER_METADATA_SLOT_ID as E, SPLIT_WITH_NEWLINES as O, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE as S, HEADER_FILENAME_SUFFIX_SLOT_ID as T, DEFAULT_THEMES as _, parsePatchFiles as a, DIFFS_DEVELOPMENT_BUILD as b, cleanLastNewline as c, CUSTOM_HEADER_SLOT_ID as d, DEFAULT_CODE_VIEW_FILE_METRICS as f, DEFAULT_SMOOTH_SCROLL_SETTINGS as g, DEFAULT_RENDER_RANGE as h, diffChars as i, pierrePropTypes as j, THEME_CSS_ATTRIBUTE as k, CODE_VIEW_FOOTER_ATTRIBUTE as l, DEFAULT_EXPANDED_REGION as m, parseDiffFromFile as n, getHunkSideEndBoundary as o, DEFAULT_CODE_VIEW_LAYOUT as p, diffWordsWithSpace as r, getHunkSideStartBoundary as s, getSingularPatch as t, CODE_VIEW_HEADER_ATTRIBUTE as u, DEFAULT_TOKENIZE_MAX_LENGTH as v, EMPTY_RENDER_RANGE as w, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY as x, DEFAULT_VIRTUAL_FILE_METRICS as y };