openwork-server 0.18.49 → 0.18.50

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 (684) hide show
  1. package/README.md +30 -0
  2. package/bin/openwork-server.mjs +3 -1
  3. package/dist/bin/openwork-server +2 -2
  4. package/dist/opencode-plugins/agent-instruction-compose.js +81 -0
  5. package/dist/opencode-plugins/gmail-attachment-fulfillment.js +199 -0
  6. package/dist/opencode-plugins/managed-policy-client.js +39 -0
  7. package/dist/opencode-plugins/managed-policy-next.js +13894 -0
  8. package/dist/opencode-plugins/managed-policy.js +100 -0
  9. package/dist/opencode-plugins/openwork-anthropic-adaptive-thinking.js +83 -0
  10. package/dist/opencode-plugins/openwork-anthropic-tool-schema.js +154 -0
  11. package/dist/opencode-plugins/openwork-capabilities-knowledge.js +13842 -0
  12. package/dist/opencode-plugins/openwork-chrome-devtools.js +13690 -0
  13. package/dist/opencode-plugins/openwork-extensions-preview-steering.js +295 -0
  14. package/dist/opencode-plugins/openwork-extensions-preview.js +16067 -0
  15. package/dist/opencode-plugins/openwork-gateway-quota-v2.js +13805 -0
  16. package/dist/opencode-plugins/openwork-gateway-quota.js +14130 -0
  17. package/dist/opencode-plugins/openwork-office-attachments.js +3008 -0
  18. package/dist/opencode-plugins/openwork-pdf-attachments.js +23811 -0
  19. package/dist/opencode-plugins/openwork-provider-adapters.js +292 -0
  20. package/dist/opencode-plugins/openwork-spreadsheets.js +16448 -0
  21. package/dist/opencode-plugins/openwork-title-recovery.js +255 -0
  22. package/dist/opencode-plugins/openwork-ui-bridge.js +81 -0
  23. package/dist/opencode-plugins/pdfium.wasm +0 -0
  24. package/dist/opencode-plugins/session-activity.js +45 -0
  25. package/dist/opencode-plugins/workspace-file-identity.js +162 -0
  26. package/package.json +1 -1
  27. package/web/apple-touch-icon.png +0 -0
  28. package/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  29. package/web/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  30. package/web/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  31. package/web/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  32. package/web/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  33. package/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  34. package/web/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  35. package/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  36. package/web/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  37. package/web/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  38. package/web/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  39. package/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  40. package/web/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  41. package/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  42. package/web/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  43. package/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  44. package/web/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  45. package/web/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  46. package/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  47. package/web/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  48. package/web/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  49. package/web/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  50. package/web/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  51. package/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  52. package/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  53. package/web/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  54. package/web/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  55. package/web/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  56. package/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  57. package/web/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  58. package/web/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  59. package/web/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  60. package/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  61. package/web/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  62. package/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  63. package/web/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  64. package/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  65. package/web/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  66. package/web/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  67. package/web/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  68. package/web/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  69. package/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  70. package/web/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  71. package/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  72. package/web/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  73. package/web/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  74. package/web/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  75. package/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  76. package/web/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  77. package/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  78. package/web/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  79. package/web/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  80. package/web/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  81. package/web/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  82. package/web/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  83. package/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  84. package/web/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  85. package/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  86. package/web/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  87. package/web/assets/abap-BdImnpbu.js +1 -0
  88. package/web/assets/abnfDiagram-VCTEODGH-BgnyE_Jl.js +1 -0
  89. package/web/assets/actionscript-3-CoDkCxhg.js +1 -0
  90. package/web/assets/ada-bCR0ucgS.js +1 -0
  91. package/web/assets/andromeeda-C4gqWexZ.js +1 -0
  92. package/web/assets/angular-html-DA-rfuFy.js +1 -0
  93. package/web/assets/angular-ts-BrjP3tb8.js +1 -0
  94. package/web/assets/apache-Pmp26Uib.js +1 -0
  95. package/web/assets/apex-D8_7TLub.js +1 -0
  96. package/web/assets/apl-CORt7UWP.js +1 -0
  97. package/web/assets/app-CyCqD289.js +2581 -0
  98. package/web/assets/app-DOrYoP_4.css +32 -0
  99. package/web/assets/applescript-Co6uUVPk.js +1 -0
  100. package/web/assets/ara-BRHolxvo.js +1 -0
  101. package/web/assets/arc-jSgX49-e.js +1 -0
  102. package/web/assets/architectureDiagram-5GKGNRK7-DD_aGn4v.js +36 -0
  103. package/web/assets/artifact-code-view-DFIq0k-c.js +1906 -0
  104. package/web/assets/artifact-spreadsheet-editor-DFVCYrL7.js +11 -0
  105. package/web/assets/artifact-text-editor-DBngc6bx.js +34 -0
  106. package/web/assets/asciidoc-Ve4PFQV2.js +1 -0
  107. package/web/assets/asm-D_Q5rh1f.js +1 -0
  108. package/web/assets/astro-HNnZUWAn.js +1 -0
  109. package/web/assets/aurora-x-D-2ljcwZ.js +1 -0
  110. package/web/assets/awk-DMzUqQB5.js +1 -0
  111. package/web/assets/ayu-dark-DYE7WIF3.js +1 -0
  112. package/web/assets/ayu-light-BA47KaF1.js +1 -0
  113. package/web/assets/ayu-mirage-32ctXXKs.js +1 -0
  114. package/web/assets/ballerina-BFfxhgS-.js +1 -0
  115. package/web/assets/bat-BkioyH1T.js +1 -0
  116. package/web/assets/beancount-k_qm7-4y.js +1 -0
  117. package/web/assets/berry-uYugtg8r.js +1 -0
  118. package/web/assets/bibtex-CHM0blh-.js +1 -0
  119. package/web/assets/bicep-Bmn6On1c.js +1 -0
  120. package/web/assets/bird2-BIv1doCn.js +1 -0
  121. package/web/assets/blade-BjGOyj-B.js +1 -0
  122. package/web/assets/blockDiagram-OSKFZWR5-CBcZLjLp.js +129 -0
  123. package/web/assets/bsl-BO_Y6i37.js +1 -0
  124. package/web/assets/c-BIGW1oBm.js +1 -0
  125. package/web/assets/c3-eo99z4R2.js +1 -0
  126. package/web/assets/c4Diagram-7LVT6UL2-DMrhFCLj.js +38 -0
  127. package/web/assets/cadence-Bv_4Rxtq.js +1 -0
  128. package/web/assets/cairo-KRGpt6FW.js +1 -0
  129. package/web/assets/catppuccin-frappe-DFWUc33u.js +1 -0
  130. package/web/assets/catppuccin-latte-C9dUb6Cb.js +1 -0
  131. package/web/assets/catppuccin-macchiato-DQyhUUbL.js +1 -0
  132. package/web/assets/catppuccin-mocha-D87Tk5Gz.js +1 -0
  133. package/web/assets/channel-BE8JEd1U.js +1 -0
  134. package/web/assets/chunk-2Q5K7J3B-Ce1X-FJQ.js +1 -0
  135. package/web/assets/chunk-5VM5RSS4-BS48ZtVI.js +15 -0
  136. package/web/assets/chunk-F27PBJKO-COdFZJ-M.js +1 -0
  137. package/web/assets/chunk-HLEWEB6X-Cdw4ABX3.js +206 -0
  138. package/web/assets/chunk-JWPE2WC7-FVVDYZmE.js +1 -0
  139. package/web/assets/chunk-POPQ4Y6H-C7acdUF3.js +1 -0
  140. package/web/assets/chunk-SVP7TREG-BUun0UWD.js +88 -0
  141. package/web/assets/chunk-XXDRQBXY-DLgpJmat.js +1 -0
  142. package/web/assets/chunk-ZLD2IHE6-BdMQ5Cr0.js +231 -0
  143. package/web/assets/clarity-D53aC0YG.js +1 -0
  144. package/web/assets/classDiagram-CYGNFDIV-Cy8V0GW-.js +1 -0
  145. package/web/assets/classDiagram-v2-TLXNO2FR-Cy8V0GW-.js +1 -0
  146. package/web/assets/clojure-P80f7IUj.js +1 -0
  147. package/web/assets/cmake-D1j8_8rp.js +1 -0
  148. package/web/assets/cobol-nBiQ_Alo.js +1 -0
  149. package/web/assets/codeowners-Bp6g37R7.js +1 -0
  150. package/web/assets/codeql-DsOJ9woJ.js +1 -0
  151. package/web/assets/coffee-Ch7k5sss.js +1 -0
  152. package/web/assets/common-lisp-Cg-RD9OK.js +1 -0
  153. package/web/assets/coq-DkFqJrB1.js +1 -0
  154. package/web/assets/cose-bilkent-JH36ORCC-CqWy3Swy.js +1 -0
  155. package/web/assets/cpp-CofmeUqb.js +1 -0
  156. package/web/assets/crystal-DNxU26gB.js +1 -0
  157. package/web/assets/csharp-COcwbKMJ.js +1 -0
  158. package/web/assets/css-CLj8gQPS.js +1 -0
  159. package/web/assets/csv-fuZLfV_i.js +1 -0
  160. package/web/assets/cue-D82EKSYY.js +1 -0
  161. package/web/assets/cynefin-OW5HDTMX-DslesE5Y.js +178 -0
  162. package/web/assets/cynefinDiagram-5FMLGOSQ-B54uZJn_.js +62 -0
  163. package/web/assets/cypher-COkxafJQ.js +1 -0
  164. package/web/assets/cytoscape.esm-CNiYdHpY.js +331 -0
  165. package/web/assets/d-85-TOEBH.js +1 -0
  166. package/web/assets/dagre-OS7QT2EB-Bkahh4gZ.js +4 -0
  167. package/web/assets/dark-plus-C3mMm8J8.js +1 -0
  168. package/web/assets/dart-bE4Kk8sk.js +1 -0
  169. package/web/assets/dax-CEL-wOlO.js +1 -0
  170. package/web/assets/defaultLocale-DX6XiGOO.js +1 -0
  171. package/web/assets/desktop-BmXAJ9_W.js +1 -0
  172. package/web/assets/diagram-S7CK7UJ4-CXQl7SfF.js +30 -0
  173. package/web/assets/diagram-UQ7AKVKN-BA0V8tjK.js +41 -0
  174. package/web/assets/diagram-VSXAHHWV-DlcR8qeO.js +3 -0
  175. package/web/assets/diagram-VX7I27RA-ewm16zDI.js +24 -0
  176. package/web/assets/diagram-Z3DM3KII-Bc2lRc88.js +24 -0
  177. package/web/assets/diff-D97Zzqfu.js +1 -0
  178. package/web/assets/docker-BcOcwvcX.js +1 -0
  179. package/web/assets/dotenv-Da5cRb03.js +1 -0
  180. package/web/assets/dracula-BzJJZx-M.js +1 -0
  181. package/web/assets/dracula-soft-BXkSAIEj.js +1 -0
  182. package/web/assets/dream-maker-BtqSS_iP.js +1 -0
  183. package/web/assets/ebnfDiagram-PWID7BFC-JwCaf6cT.js +1 -0
  184. package/web/assets/edge-FbVlp4U3.js +1 -0
  185. package/web/assets/elixir-CkH2-t6x.js +1 -0
  186. package/web/assets/elm-DbKCFpqz.js +1 -0
  187. package/web/assets/emacs-lisp-CXvaQtF9.js +1 -0
  188. package/web/assets/erDiagram-2YWLMYGG-DOqO-9Yf.js +99 -0
  189. package/web/assets/erb-BYCe7drp.js +1 -0
  190. package/web/assets/erlang-DsQrWhSR.js +1 -0
  191. package/web/assets/everforest-dark-BgDCqdQA.js +1 -0
  192. package/web/assets/everforest-light-C8M2exoo.js +1 -0
  193. package/web/assets/fennel-BYunw83y.js +1 -0
  194. package/web/assets/fish-BvzEVeQv.js +1 -0
  195. package/web/assets/flowDiagram-T62WH6J4-CCZxvIjW.js +168 -0
  196. package/web/assets/fluent-C4IJs8-o.js +1 -0
  197. package/web/assets/fortran-fixed-form-CkoXwp7k.js +1 -0
  198. package/web/assets/fortran-free-form-BxgE0vQu.js +1 -0
  199. package/web/assets/fsharp-CXgrBDvD.js +1 -0
  200. package/web/assets/ganttDiagram-EL5Y4UJY-BczG7RIu.js +292 -0
  201. package/web/assets/gdresource-BOOCDP_w.js +1 -0
  202. package/web/assets/gdscript-C5YyOfLZ.js +1 -0
  203. package/web/assets/gdshader-DkwncUOv.js +1 -0
  204. package/web/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
  205. package/web/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
  206. package/web/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
  207. package/web/assets/genie-D0YGMca9.js +1 -0
  208. package/web/assets/gherkin-DyxjwDmM.js +1 -0
  209. package/web/assets/git-commit-F4YmCXRG.js +1 -0
  210. package/web/assets/git-rebase-r7XF79zn.js +1 -0
  211. package/web/assets/gitGraphDiagram-WWUBYQGX-GOecDN3g.js +106 -0
  212. package/web/assets/github-dark-DHJKELXO.js +1 -0
  213. package/web/assets/github-dark-default-Cuk6v7N8.js +1 -0
  214. package/web/assets/github-dark-dimmed-DH5Ifo-i.js +1 -0
  215. package/web/assets/github-dark-high-contrast-E3gJ1_iC.js +1 -0
  216. package/web/assets/github-light-DAi9KRSo.js +1 -0
  217. package/web/assets/github-light-default-D7oLnXFd.js +1 -0
  218. package/web/assets/github-light-high-contrast-BfjtVDDH.js +1 -0
  219. package/web/assets/gleam-BspZqrRM.js +1 -0
  220. package/web/assets/glimmer-js-ByusRIyA.js +1 -0
  221. package/web/assets/glimmer-ts-BfAWNZQY.js +1 -0
  222. package/web/assets/glsl-DplSGwfg.js +1 -0
  223. package/web/assets/gn-n2N0HUVH.js +1 -0
  224. package/web/assets/gnuplot-DdkO51Og.js +1 -0
  225. package/web/assets/go-C27-OAKa.js +1 -0
  226. package/web/assets/graphql-ChdNCCLP.js +1 -0
  227. package/web/assets/groovy-gcz8RCvz.js +1 -0
  228. package/web/assets/gruvbox-dark-hard-CFHQjOhq.js +1 -0
  229. package/web/assets/gruvbox-dark-medium-GsRaNv29.js +1 -0
  230. package/web/assets/gruvbox-dark-soft-CVdnzihN.js +1 -0
  231. package/web/assets/gruvbox-light-hard-CH1njM8p.js +1 -0
  232. package/web/assets/gruvbox-light-medium-DRw_LuNl.js +1 -0
  233. package/web/assets/gruvbox-light-soft-hJgmCMqR.js +1 -0
  234. package/web/assets/hack-i7_Ulhet.js +1 -0
  235. package/web/assets/haml-D5jkg6IW.js +1 -0
  236. package/web/assets/handlebars-BpdQsYii.js +1 -0
  237. package/web/assets/haskell-Df6bDoY_.js +1 -0
  238. package/web/assets/haxe-CzTSHFRz.js +1 -0
  239. package/web/assets/hcl-BWvSN4gD.js +1 -0
  240. package/web/assets/hjson-D5-asLiD.js +1 -0
  241. package/web/assets/hlsl-D3lLCCz7.js +1 -0
  242. package/web/assets/horizon-BUw7H-hv.js +1 -0
  243. package/web/assets/horizon-bright-CUuTKBJd.js +1 -0
  244. package/web/assets/houston-DnULxvSX.js +1 -0
  245. package/web/assets/html-derivative-DlHx6ybY.js +1 -0
  246. package/web/assets/html-pp8916En.js +1 -0
  247. package/web/assets/http-jrhK8wxY.js +1 -0
  248. package/web/assets/hurl-irOxFIW8.js +1 -0
  249. package/web/assets/hxml-Bvhsp5Yf.js +1 -0
  250. package/web/assets/hy-DFXneXwc.js +1 -0
  251. package/web/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
  252. package/web/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
  253. package/web/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
  254. package/web/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
  255. package/web/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
  256. package/web/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
  257. package/web/assets/imba-DGztddWO.js +1 -0
  258. package/web/assets/index-BZgplq0g.css +1 -0
  259. package/web/assets/index-_gYIQM_z.js +49 -0
  260. package/web/assets/infoDiagram-FKFFQAWI-BbgIVsQp.js +2 -0
  261. package/web/assets/ini-BEwlwnbL.js +1 -0
  262. package/web/assets/init-Gi6I4Gst.js +1 -0
  263. package/web/assets/ishikawaDiagram-5VMMS53U-xutQo5Ip.js +70 -0
  264. package/web/assets/java-CylS5w8V.js +1 -0
  265. package/web/assets/javascript-wDzz0qaB.js +1 -0
  266. package/web/assets/jinja-f2NsQr07.js +1 -0
  267. package/web/assets/jison-wvAkD_A8.js +1 -0
  268. package/web/assets/journeyDiagram-EYS64GPL-BIbzPGaa.js +139 -0
  269. package/web/assets/json-Cp-IABpG.js +1 -0
  270. package/web/assets/json5-C9tS-k6U.js +1 -0
  271. package/web/assets/jsonc-Des-eS-w.js +1 -0
  272. package/web/assets/jsonl-DcaNXYhu.js +1 -0
  273. package/web/assets/jsonnet-DFQXde-d.js +1 -0
  274. package/web/assets/jssm-C2t-YnRu.js +1 -0
  275. package/web/assets/jsx-g9-lgVsj.js +1 -0
  276. package/web/assets/julia-CxzCAyBv.js +1 -0
  277. package/web/assets/just-VxiPbLrw.js +1 -0
  278. package/web/assets/kanagawa-dragon-CkXjmgJE.js +1 -0
  279. package/web/assets/kanagawa-lotus-CfQXZHmo.js +1 -0
  280. package/web/assets/kanagawa-wave-DWedfzmr.js +1 -0
  281. package/web/assets/kanban-definition-UXKFOSKX-BCTiRzck.js +89 -0
  282. package/web/assets/katex-HP8lGamR.js +257 -0
  283. package/web/assets/kdl-DV7GczEv.js +1 -0
  284. package/web/assets/kotlin-BdnUsdx6.js +1 -0
  285. package/web/assets/kusto-wEQ09or8.js +1 -0
  286. package/web/assets/laserwave-DUszq2jm.js +1 -0
  287. package/web/assets/latex-CWtU0Tv5.js +1 -0
  288. package/web/assets/layout-Wpfi54TB.js +1 -0
  289. package/web/assets/lean-BZvkOJ9d.js +1 -0
  290. package/web/assets/less-B1dDrJ26.js +1 -0
  291. package/web/assets/light-plus-B7mTdjB0.js +1 -0
  292. package/web/assets/linear-DLJHPikh.js +1 -0
  293. package/web/assets/liquid-C0sCDyMI.js +1 -0
  294. package/web/assets/llvm-DjAJT7YJ.js +1 -0
  295. package/web/assets/log-2UxHyX5q.js +1 -0
  296. package/web/assets/logo-BtOb2qkB.js +1 -0
  297. package/web/assets/lua-BaeVxFsk.js +1 -0
  298. package/web/assets/luau-C-HG3fhB.js +1 -0
  299. package/web/assets/make-CHLpvVh8.js +1 -0
  300. package/web/assets/markdown-Cvjx9yec.js +1 -0
  301. package/web/assets/marko-DjSrsDqO.js +1 -0
  302. package/web/assets/material-theme-D5KoaKCx.js +1 -0
  303. package/web/assets/material-theme-darker-BfHTSMKl.js +1 -0
  304. package/web/assets/material-theme-lighter-B0m2ddpp.js +1 -0
  305. package/web/assets/material-theme-ocean-CyktbL80.js +1 -0
  306. package/web/assets/material-theme-palenight-Csfq5Kiy.js +1 -0
  307. package/web/assets/matlab-D7o27uSR.js +1 -0
  308. package/web/assets/mdc-DTYItulj.js +1 -0
  309. package/web/assets/mdx-Cmh6b_Ma.js +1 -0
  310. package/web/assets/mermaid-mWjccvbQ.js +1 -0
  311. package/web/assets/mermaid.core-CDRJkis7.js +310 -0
  312. package/web/assets/min-dark-CafNBF8u.js +1 -0
  313. package/web/assets/min-light-CTRr51gU.js +1 -0
  314. package/web/assets/mindmap-definition-THT77NOG-DtphSFs_.js +96 -0
  315. package/web/assets/mipsasm-CKIfxQSi.js +1 -0
  316. package/web/assets/mojo-rZm6bMo-.js +1 -0
  317. package/web/assets/monokai-D4h5O-jR.js +1 -0
  318. package/web/assets/moonbit-_H4v1dQx.js +1 -0
  319. package/web/assets/move-IF9eRakj.js +1 -0
  320. package/web/assets/narrat-DRg8JJMk.js +1 -0
  321. package/web/assets/nextflow-C-mBbutL.js +1 -0
  322. package/web/assets/nextflow-groovy-vE_lwT2v.js +1 -0
  323. package/web/assets/nginx-BpAMiNFr.js +1 -0
  324. package/web/assets/night-owl-C39BiMTA.js +1 -0
  325. package/web/assets/night-owl-light-CMTm3GFP.js +1 -0
  326. package/web/assets/nim-BIad80T-.js +1 -0
  327. package/web/assets/nix-CwoSXNpI.js +1 -0
  328. package/web/assets/nord-Ddv68eIx.js +1 -0
  329. package/web/assets/nushell-Cz2AlsmD.js +1 -0
  330. package/web/assets/objective-c-DXmwc3jG.js +1 -0
  331. package/web/assets/objective-cpp-CLxacb5B.js +1 -0
  332. package/web/assets/ocaml-C0hk2d4L.js +1 -0
  333. package/web/assets/odin-BBf5iR-q.js +1 -0
  334. package/web/assets/one-dark-pro-DVMEJ2y_.js +1 -0
  335. package/web/assets/one-light-C3Wv6jpd.js +1 -0
  336. package/web/assets/openscad-C4EeE6gA.js +1 -0
  337. package/web/assets/ordinal-Cboi1Yqb.js +1 -0
  338. package/web/assets/overlay-zA9qjYXH.js +1 -0
  339. package/web/assets/pascal-D93ZcfNL.js +1 -0
  340. package/web/assets/pegDiagram-XKGWAZYB-CzbjpqK7.js +1 -0
  341. package/web/assets/perl-NvoQZIq0.js +1 -0
  342. package/web/assets/php-R6g_5hLQ.js +1 -0
  343. package/web/assets/pieDiagram-E7YTZNPT-tjxtWWT7.js +39 -0
  344. package/web/assets/pierre-dark-CyvmCCZW.js +1 -0
  345. package/web/assets/pierre-dark-protanopia-deuteranopia-Rgc0TwpF.js +1 -0
  346. package/web/assets/pierre-dark-soft-BHGpRqa4.js +1 -0
  347. package/web/assets/pierre-dark-tritanopia-Beq2gCRQ.js +1 -0
  348. package/web/assets/pierre-dark-vibrant-BWBVywrn.js +1 -0
  349. package/web/assets/pierre-light-480U9XYS.js +1 -0
  350. package/web/assets/pierre-light-protanopia-deuteranopia-CaVOBURG.js +1 -0
  351. package/web/assets/pierre-light-soft-CVdyfjmI.js +1 -0
  352. package/web/assets/pierre-light-tritanopia-B4_gpKOM.js +1 -0
  353. package/web/assets/pierre-light-vibrant-DdTDNdfJ.js +1 -0
  354. package/web/assets/pkl-u5AG7uiY.js +1 -0
  355. package/web/assets/plastic-3e1v2bzS.js +1 -0
  356. package/web/assets/plsql-ChMvpjG-.js +1 -0
  357. package/web/assets/po-BTJTHyun.js +1 -0
  358. package/web/assets/poimandres-CS3Unz2-.js +1 -0
  359. package/web/assets/polar-C0HS_06l.js +1 -0
  360. package/web/assets/postcss-CXtECtnM.js +1 -0
  361. package/web/assets/powerquery-CEu0bR-o.js +1 -0
  362. package/web/assets/powershell-Dpen1YoG.js +1 -0
  363. package/web/assets/prisma-Dd19v3D-.js +1 -0
  364. package/web/assets/prolog-CbFg5uaA.js +1 -0
  365. package/web/assets/proto-C7zT0LnQ.js +1 -0
  366. package/web/assets/pug-DKIMFp6K.js +1 -0
  367. package/web/assets/puppet-BMWR74SV.js +1 -0
  368. package/web/assets/purescript-CklMAg4u.js +1 -0
  369. package/web/assets/python-B6aJPvgy.js +1 -0
  370. package/web/assets/qml-3beO22l8.js +1 -0
  371. package/web/assets/qmldir-C8lEn-DE.js +1 -0
  372. package/web/assets/qss-IeuSbFQv.js +1 -0
  373. package/web/assets/quadrantDiagram-AXDQQJYC-CFC1qey-.js +7 -0
  374. package/web/assets/r-Dspwwk_N.js +1 -0
  375. package/web/assets/racket-BqYA7rlc.js +1 -0
  376. package/web/assets/railroadDiagram-O6MQD6OU-73_BXhNP.js +1 -0
  377. package/web/assets/raku-DXvB9xmW.js +1 -0
  378. package/web/assets/razor-BDqjjVU7.js +1 -0
  379. package/web/assets/red-bN70gL4F.js +1 -0
  380. package/web/assets/reg-C-SQnVFl.js +1 -0
  381. package/web/assets/regexp-CDVJQ6XC.js +1 -0
  382. package/web/assets/rel-C3B-1QV4.js +1 -0
  383. package/web/assets/requirementDiagram-IS5BZ75X-B8i4BL2A.js +84 -0
  384. package/web/assets/riscv-BM1_JUlF.js +1 -0
  385. package/web/assets/ron-D8l8udqQ.js +1 -0
  386. package/web/assets/rose-pine-dawn-DHQR4-dF.js +1 -0
  387. package/web/assets/rose-pine-moon-D4_iv3hh.js +1 -0
  388. package/web/assets/rose-pine-qdsjHGoJ.js +1 -0
  389. package/web/assets/rosmsg-BJDFO7_C.js +1 -0
  390. package/web/assets/rst-CRjBmOyv.js +1 -0
  391. package/web/assets/ruby-Wjq7vjNf.js +1 -0
  392. package/web/assets/rust-B1yitclQ.js +1 -0
  393. package/web/assets/sankeyDiagram-P5KCCOFB-Dll4Naj0.js +40 -0
  394. package/web/assets/sas-cz2c8ADy.js +1 -0
  395. package/web/assets/sass-Cj5Yp3dK.js +1 -0
  396. package/web/assets/scala-C151Ov-r.js +1 -0
  397. package/web/assets/scheme-C98Dy4si.js +1 -0
  398. package/web/assets/scss-D5BDwBP9.js +1 -0
  399. package/web/assets/sdbl-DVxCFoDh.js +1 -0
  400. package/web/assets/sequenceDiagram-WJ2MYXX4-B8Rvjhb5.js +162 -0
  401. package/web/assets/shaderlab-Dg9Lc6iA.js +1 -0
  402. package/web/assets/shellscript-Yzrsuije.js +1 -0
  403. package/web/assets/shellsession-BADoaaVG.js +1 -0
  404. package/web/assets/sizeCapture-INFHLROL-h8YDF-c3.js +1 -0
  405. package/web/assets/slack-dark-BthQWCQV.js +1 -0
  406. package/web/assets/slack-ochin-DqwNpetd.js +1 -0
  407. package/web/assets/smalltalk-BERRCDM3.js +1 -0
  408. package/web/assets/snazzy-light-Bw305WKR.js +1 -0
  409. package/web/assets/solarized-dark-DXbdFlpD.js +1 -0
  410. package/web/assets/solarized-light-L9t79GZl.js +1 -0
  411. package/web/assets/solidity-rGO070M0.js +1 -0
  412. package/web/assets/soy-8wufbnw4.js +1 -0
  413. package/web/assets/sparql-rVzFXLq3.js +1 -0
  414. package/web/assets/splunk-BtCnVYZw.js +1 -0
  415. package/web/assets/sql-BLtJtn59.js +1 -0
  416. package/web/assets/ssh-config-_ykCGR6B.js +1 -0
  417. package/web/assets/stata-BH5u7GGu.js +1 -0
  418. package/web/assets/stateDiagram-XQSTLZYL-COorU6Ga.js +1 -0
  419. package/web/assets/stateDiagram-v2-IH3M54BS-BAu05WuT.js +1 -0
  420. package/web/assets/stylus-BEDo0Tqx.js +1 -0
  421. package/web/assets/surrealql-Bq5Q-fJD.js +1 -0
  422. package/web/assets/svelte-Cy7k_4gC.js +1 -0
  423. package/web/assets/swift-D82vCrfD.js +1 -0
  424. package/web/assets/swimlanes-V6O3JKXN-CAghInFw.js +1 -0
  425. package/web/assets/swimlanesDiagram-JKAHXJPX-CpJNl3pn.js +8 -0
  426. package/web/assets/synthwave-84-CbfX1IO0.js +1 -0
  427. package/web/assets/system-verilog-CnnmHF94.js +1 -0
  428. package/web/assets/systemd-4A_iFExJ.js +1 -0
  429. package/web/assets/talonscript-CkByrt1z.js +1 -0
  430. package/web/assets/tasl-QIJgUcNo.js +1 -0
  431. package/web/assets/tcl-dwOrl1Do.js +1 -0
  432. package/web/assets/templ-DhtptRzy.js +1 -0
  433. package/web/assets/terraform-BETggiCN.js +1 -0
  434. package/web/assets/tex-idrVyKtj.js +1 -0
  435. package/web/assets/timeline-definition-24CTP7MA-Dum2N-ex.js +120 -0
  436. package/web/assets/tokyo-night-hegEt444.js +1 -0
  437. package/web/assets/toml-vGWfd6FD.js +1 -0
  438. package/web/assets/ts-tags-DQrlYJgV.js +1 -0
  439. package/web/assets/tsv-B_m7g4N7.js +1 -0
  440. package/web/assets/tsx-COt5Ahok.js +1 -0
  441. package/web/assets/turtle-BsS91CYL.js +1 -0
  442. package/web/assets/twig-xg9kU7Mw.js +1 -0
  443. package/web/assets/typescript-BPQ3VLAy.js +1 -0
  444. package/web/assets/typespec-CAFt9gP4.js +1 -0
  445. package/web/assets/typst-DHCkPAjA.js +1 -0
  446. package/web/assets/v-BcVCzyr7.js +1 -0
  447. package/web/assets/vala-CsfeWuGM.js +1 -0
  448. package/web/assets/vb-D17OF-Vu.js +1 -0
  449. package/web/assets/vennDiagram-4TSXK5OY-D-JeJumX.js +34 -0
  450. package/web/assets/verilog-BQ8w6xss.js +1 -0
  451. package/web/assets/vesper-DU1UobuO.js +1 -0
  452. package/web/assets/vhdl-CeAyd5Ju.js +1 -0
  453. package/web/assets/viml-CJc9bBzg.js +1 -0
  454. package/web/assets/vitesse-black-Bkuqu6BP.js +1 -0
  455. package/web/assets/vitesse-dark-D0r3Knsf.js +1 -0
  456. package/web/assets/vitesse-light-CVO1_9PV.js +1 -0
  457. package/web/assets/vue-D2xRrEX4.js +1 -0
  458. package/web/assets/vue-html-AaS7Mt5G.js +1 -0
  459. package/web/assets/vue-vine-BoDAl6tE.js +1 -0
  460. package/web/assets/vyper-CDx5xZoG.js +1 -0
  461. package/web/assets/wardleyDiagram-VM6X3IG4-d99FKQIG.js +78 -0
  462. package/web/assets/wasm-CG6Dc4jp.js +1 -0
  463. package/web/assets/wasm-MzD3tlZU.js +1 -0
  464. package/web/assets/wenyan-BV7otONQ.js +1 -0
  465. package/web/assets/wgsl-Dx-B1_4e.js +1 -0
  466. package/web/assets/wikitext-BhOHFoWU.js +1 -0
  467. package/web/assets/wit-5i3qLPDT.js +1 -0
  468. package/web/assets/wolfram-lXgVvXCa.js +1 -0
  469. package/web/assets/workspace-file-tree-CAuhntUr.js +1278 -0
  470. package/web/assets/xml-sdJ4AIDG.js +1 -0
  471. package/web/assets/xsl-CtQFsRM5.js +1 -0
  472. package/web/assets/xychartDiagram-S5SC5T6Z-DdmevfkD.js +7 -0
  473. package/web/assets/yaml-Buea-lGh.js +1 -0
  474. package/web/assets/zenscript-DVFEvuxE.js +1 -0
  475. package/web/assets/zig-VOosw3JB.js +1 -0
  476. package/web/ext-context7.svg +1 -0
  477. package/web/ext-google-workspace.svg +6 -0
  478. package/web/ext-linear.svg +1 -0
  479. package/web/ext-notion.svg +1 -0
  480. package/web/ext-ollama.svg +1 -0
  481. package/web/ext-openai.svg +1 -0
  482. package/web/ext-sentry.svg +1 -0
  483. package/web/ext-stripe.svg +1 -0
  484. package/web/favicon-16x16.png +0 -0
  485. package/web/favicon-32x32.png +0 -0
  486. package/web/grain-art/extension/extension-001.png +0 -0
  487. package/web/grain-art/extension/extension-002.png +0 -0
  488. package/web/grain-art/extension/extension-003.png +0 -0
  489. package/web/grain-art/extension/extension-004.png +0 -0
  490. package/web/grain-art/extension/extension-005.png +0 -0
  491. package/web/grain-art/extension/extension-006.png +0 -0
  492. package/web/grain-art/extension/extension-007.png +0 -0
  493. package/web/grain-art/extension/extension-008.png +0 -0
  494. package/web/grain-art/extension/extension-009.png +0 -0
  495. package/web/grain-art/extension/extension-010.png +0 -0
  496. package/web/grain-art/extension/extension-011.png +0 -0
  497. package/web/grain-art/extension/extension-012.png +0 -0
  498. package/web/grain-art/extension/extension-013.png +0 -0
  499. package/web/grain-art/extension/extension-014.png +0 -0
  500. package/web/grain-art/extension/extension-015.png +0 -0
  501. package/web/grain-art/extension/extension-016.png +0 -0
  502. package/web/grain-art/extension/extension-017.png +0 -0
  503. package/web/grain-art/extension/extension-018.png +0 -0
  504. package/web/grain-art/extension/extension-019.png +0 -0
  505. package/web/grain-art/extension/extension-020.png +0 -0
  506. package/web/grain-art/extension/extension-021.png +0 -0
  507. package/web/grain-art/extension/extension-022.png +0 -0
  508. package/web/grain-art/extension/extension-023.png +0 -0
  509. package/web/grain-art/extension/extension-024.png +0 -0
  510. package/web/grain-art/extension/extension-025.png +0 -0
  511. package/web/grain-art/extension/extension-026.png +0 -0
  512. package/web/grain-art/extension/extension-027.png +0 -0
  513. package/web/grain-art/extension/extension-028.png +0 -0
  514. package/web/grain-art/extension/extension-029.png +0 -0
  515. package/web/grain-art/extension/extension-030.png +0 -0
  516. package/web/grain-art/extension/extension-031.png +0 -0
  517. package/web/grain-art/extension/extension-032.png +0 -0
  518. package/web/grain-art/fallback/fallback-001.png +0 -0
  519. package/web/grain-art/fallback/fallback-002.png +0 -0
  520. package/web/grain-art/fallback/fallback-003.png +0 -0
  521. package/web/grain-art/fallback/fallback-004.png +0 -0
  522. package/web/grain-art/fallback/fallback-005.png +0 -0
  523. package/web/grain-art/fallback/fallback-006.png +0 -0
  524. package/web/grain-art/fallback/fallback-007.png +0 -0
  525. package/web/grain-art/fallback/fallback-008.png +0 -0
  526. package/web/grain-art/fallback/fallback-009.png +0 -0
  527. package/web/grain-art/fallback/fallback-010.png +0 -0
  528. package/web/grain-art/fallback/fallback-011.png +0 -0
  529. package/web/grain-art/fallback/fallback-012.png +0 -0
  530. package/web/grain-art/fallback/fallback-013.png +0 -0
  531. package/web/grain-art/fallback/fallback-014.png +0 -0
  532. package/web/grain-art/fallback/fallback-015.png +0 -0
  533. package/web/grain-art/fallback/fallback-016.png +0 -0
  534. package/web/grain-art/fallback/fallback-017.png +0 -0
  535. package/web/grain-art/fallback/fallback-018.png +0 -0
  536. package/web/grain-art/fallback/fallback-019.png +0 -0
  537. package/web/grain-art/fallback/fallback-020.png +0 -0
  538. package/web/grain-art/fallback/fallback-021.png +0 -0
  539. package/web/grain-art/fallback/fallback-022.png +0 -0
  540. package/web/grain-art/fallback/fallback-023.png +0 -0
  541. package/web/grain-art/fallback/fallback-024.png +0 -0
  542. package/web/grain-art/fallback/fallback-025.png +0 -0
  543. package/web/grain-art/fallback/fallback-026.png +0 -0
  544. package/web/grain-art/fallback/fallback-027.png +0 -0
  545. package/web/grain-art/fallback/fallback-028.png +0 -0
  546. package/web/grain-art/fallback/fallback-029.png +0 -0
  547. package/web/grain-art/fallback/fallback-030.png +0 -0
  548. package/web/grain-art/fallback/fallback-031.png +0 -0
  549. package/web/grain-art/fallback/fallback-032.png +0 -0
  550. package/web/grain-art/mcps/mcps-001.png +0 -0
  551. package/web/grain-art/mcps/mcps-002.png +0 -0
  552. package/web/grain-art/mcps/mcps-003.png +0 -0
  553. package/web/grain-art/mcps/mcps-004.png +0 -0
  554. package/web/grain-art/mcps/mcps-005.png +0 -0
  555. package/web/grain-art/mcps/mcps-006.png +0 -0
  556. package/web/grain-art/mcps/mcps-007.png +0 -0
  557. package/web/grain-art/mcps/mcps-008.png +0 -0
  558. package/web/grain-art/mcps/mcps-009.png +0 -0
  559. package/web/grain-art/mcps/mcps-010.png +0 -0
  560. package/web/grain-art/mcps/mcps-011.png +0 -0
  561. package/web/grain-art/mcps/mcps-012.png +0 -0
  562. package/web/grain-art/mcps/mcps-013.png +0 -0
  563. package/web/grain-art/mcps/mcps-014.png +0 -0
  564. package/web/grain-art/mcps/mcps-015.png +0 -0
  565. package/web/grain-art/mcps/mcps-016.png +0 -0
  566. package/web/grain-art/mcps/mcps-017.png +0 -0
  567. package/web/grain-art/mcps/mcps-018.png +0 -0
  568. package/web/grain-art/mcps/mcps-019.png +0 -0
  569. package/web/grain-art/mcps/mcps-020.png +0 -0
  570. package/web/grain-art/mcps/mcps-021.png +0 -0
  571. package/web/grain-art/mcps/mcps-022.png +0 -0
  572. package/web/grain-art/mcps/mcps-023.png +0 -0
  573. package/web/grain-art/mcps/mcps-024.png +0 -0
  574. package/web/grain-art/mcps/mcps-025.png +0 -0
  575. package/web/grain-art/mcps/mcps-026.png +0 -0
  576. package/web/grain-art/mcps/mcps-027.png +0 -0
  577. package/web/grain-art/mcps/mcps-028.png +0 -0
  578. package/web/grain-art/mcps/mcps-029.png +0 -0
  579. package/web/grain-art/mcps/mcps-030.png +0 -0
  580. package/web/grain-art/mcps/mcps-031.png +0 -0
  581. package/web/grain-art/mcps/mcps-032.png +0 -0
  582. package/web/grain-art/plugins/plugins-001.png +0 -0
  583. package/web/grain-art/plugins/plugins-002.png +0 -0
  584. package/web/grain-art/plugins/plugins-003.png +0 -0
  585. package/web/grain-art/plugins/plugins-004.png +0 -0
  586. package/web/grain-art/plugins/plugins-005.png +0 -0
  587. package/web/grain-art/plugins/plugins-006.png +0 -0
  588. package/web/grain-art/plugins/plugins-007.png +0 -0
  589. package/web/grain-art/plugins/plugins-008.png +0 -0
  590. package/web/grain-art/plugins/plugins-009.png +0 -0
  591. package/web/grain-art/plugins/plugins-010.png +0 -0
  592. package/web/grain-art/plugins/plugins-011.png +0 -0
  593. package/web/grain-art/plugins/plugins-012.png +0 -0
  594. package/web/grain-art/plugins/plugins-013.png +0 -0
  595. package/web/grain-art/plugins/plugins-014.png +0 -0
  596. package/web/grain-art/plugins/plugins-015.png +0 -0
  597. package/web/grain-art/plugins/plugins-016.png +0 -0
  598. package/web/grain-art/plugins/plugins-017.png +0 -0
  599. package/web/grain-art/plugins/plugins-018.png +0 -0
  600. package/web/grain-art/plugins/plugins-019.png +0 -0
  601. package/web/grain-art/plugins/plugins-020.png +0 -0
  602. package/web/grain-art/plugins/plugins-021.png +0 -0
  603. package/web/grain-art/plugins/plugins-022.png +0 -0
  604. package/web/grain-art/plugins/plugins-023.png +0 -0
  605. package/web/grain-art/plugins/plugins-024.png +0 -0
  606. package/web/grain-art/plugins/plugins-025.png +0 -0
  607. package/web/grain-art/plugins/plugins-026.png +0 -0
  608. package/web/grain-art/plugins/plugins-027.png +0 -0
  609. package/web/grain-art/plugins/plugins-028.png +0 -0
  610. package/web/grain-art/plugins/plugins-029.png +0 -0
  611. package/web/grain-art/plugins/plugins-030.png +0 -0
  612. package/web/grain-art/plugins/plugins-031.png +0 -0
  613. package/web/grain-art/plugins/plugins-032.png +0 -0
  614. package/web/grain-art/skills/skills-001.png +0 -0
  615. package/web/grain-art/skills/skills-002.png +0 -0
  616. package/web/grain-art/skills/skills-003.png +0 -0
  617. package/web/grain-art/skills/skills-004.png +0 -0
  618. package/web/grain-art/skills/skills-005.png +0 -0
  619. package/web/grain-art/skills/skills-006.png +0 -0
  620. package/web/grain-art/skills/skills-007.png +0 -0
  621. package/web/grain-art/skills/skills-008.png +0 -0
  622. package/web/grain-art/skills/skills-009.png +0 -0
  623. package/web/grain-art/skills/skills-010.png +0 -0
  624. package/web/grain-art/skills/skills-011.png +0 -0
  625. package/web/grain-art/skills/skills-012.png +0 -0
  626. package/web/grain-art/skills/skills-013.png +0 -0
  627. package/web/grain-art/skills/skills-014.png +0 -0
  628. package/web/grain-art/skills/skills-015.png +0 -0
  629. package/web/grain-art/skills/skills-016.png +0 -0
  630. package/web/grain-art/skills/skills-017.png +0 -0
  631. package/web/grain-art/skills/skills-018.png +0 -0
  632. package/web/grain-art/skills/skills-019.png +0 -0
  633. package/web/grain-art/skills/skills-020.png +0 -0
  634. package/web/grain-art/skills/skills-021.png +0 -0
  635. package/web/grain-art/skills/skills-022.png +0 -0
  636. package/web/grain-art/skills/skills-023.png +0 -0
  637. package/web/grain-art/skills/skills-024.png +0 -0
  638. package/web/grain-art/skills/skills-025.png +0 -0
  639. package/web/grain-art/skills/skills-026.png +0 -0
  640. package/web/grain-art/skills/skills-027.png +0 -0
  641. package/web/grain-art/skills/skills-028.png +0 -0
  642. package/web/grain-art/skills/skills-029.png +0 -0
  643. package/web/grain-art/skills/skills-030.png +0 -0
  644. package/web/grain-art/skills/skills-031.png +0 -0
  645. package/web/grain-art/skills/skills-032.png +0 -0
  646. package/web/grain-art/workspaces/workspaces-001.png +0 -0
  647. package/web/grain-art/workspaces/workspaces-002.png +0 -0
  648. package/web/grain-art/workspaces/workspaces-003.png +0 -0
  649. package/web/grain-art/workspaces/workspaces-004.png +0 -0
  650. package/web/grain-art/workspaces/workspaces-005.png +0 -0
  651. package/web/grain-art/workspaces/workspaces-006.png +0 -0
  652. package/web/grain-art/workspaces/workspaces-007.png +0 -0
  653. package/web/grain-art/workspaces/workspaces-008.png +0 -0
  654. package/web/grain-art/workspaces/workspaces-009.png +0 -0
  655. package/web/grain-art/workspaces/workspaces-010.png +0 -0
  656. package/web/grain-art/workspaces/workspaces-011.png +0 -0
  657. package/web/grain-art/workspaces/workspaces-012.png +0 -0
  658. package/web/grain-art/workspaces/workspaces-013.png +0 -0
  659. package/web/grain-art/workspaces/workspaces-014.png +0 -0
  660. package/web/grain-art/workspaces/workspaces-015.png +0 -0
  661. package/web/grain-art/workspaces/workspaces-016.png +0 -0
  662. package/web/grain-art/workspaces/workspaces-017.png +0 -0
  663. package/web/grain-art/workspaces/workspaces-018.png +0 -0
  664. package/web/grain-art/workspaces/workspaces-019.png +0 -0
  665. package/web/grain-art/workspaces/workspaces-020.png +0 -0
  666. package/web/grain-art/workspaces/workspaces-021.png +0 -0
  667. package/web/grain-art/workspaces/workspaces-022.png +0 -0
  668. package/web/grain-art/workspaces/workspaces-023.png +0 -0
  669. package/web/grain-art/workspaces/workspaces-024.png +0 -0
  670. package/web/grain-art/workspaces/workspaces-025.png +0 -0
  671. package/web/grain-art/workspaces/workspaces-026.png +0 -0
  672. package/web/grain-art/workspaces/workspaces-027.png +0 -0
  673. package/web/grain-art/workspaces/workspaces-028.png +0 -0
  674. package/web/grain-art/workspaces/workspaces-029.png +0 -0
  675. package/web/grain-art/workspaces/workspaces-030.png +0 -0
  676. package/web/grain-art/workspaces/workspaces-031.png +0 -0
  677. package/web/grain-art/workspaces/workspaces-032.png +0 -0
  678. package/web/index.html +129 -0
  679. package/web/manifest.webmanifest +22 -0
  680. package/web/openwork-logo-square.svg +2 -0
  681. package/web/openwork-logo.svg +1 -0
  682. package/web/openwork-mark.svg +16 -0
  683. package/web/openwork-sidebar-mark.svg +17 -0
  684. package/web/overlay.html +29 -0
@@ -0,0 +1,1906 @@
1
+ import{r as Y,j}from"./index-_gYIQM_z.js";import{e as Xi,n as Bo,_ as I,g as Vo,h as Uo,i as Wo,t as $o,j as fe,k as tn,l as je,E as Zi}from"./app-CyCqD289.js";function De(e){const t=Y.useRef(e);return Y.useInsertionEffect(()=>void(t.current=e)),Y.useCallback((...n)=>t.current(...n),[])}const gs=Y.createContext(void 0);function Go({children:e,createEditor:t}){const n=Y.useRef(new WeakMap),i=De(r=>{const s=n.current.get(r);if(s!=null)return s;const o=t(r);return n.current.set(r,o),o});return j.jsx(gs.Provider,{value:i,children:e})}function jo(){return Y.useContext(gs)}const ms={position:"absolute",top:0,bottom:0,textAlign:"center",whiteSpace:"normal",touchAction:"none"},Ko={display:"contents"},vs="diffs-container",qo=(()=>{try{return!1}catch{return!1}})(),Yo=/(?=^diff --git)/gm,Xo=/(?<=\n)/,Zo=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Jo=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,Qo=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,ea=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Hi="header-prefix",Pi="header-filename-suffix",Oi="header-metadata",Dt="header-custom",J={dark:"pierre-dark",light:"pierre-light"},ta="data-theme-css",na="data-unsafe-css",ia="data-diffs-scrollbar-measure",ra="data-diffs-code-view-header",sa="data-diffs-code-view-footer",Ss="--diffs-scrollbar-gutter-measured",oa=1e5,Di={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},vt={...Di,hunkLineCount:1},aa={paddingTop:8,paddingBottom:8,gap:8},la={omega:.015,positionEpsilon:.5,velocityEpsilon:.05},da=Object.freeze({fromStart:0,fromEnd:0}),cn={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},bs={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0};function be(e){return`annotation-${"side"in e?`${e.side}-`:""}${e.lineNumber}`}function ha({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function Ae(e,t){return e-(t===0?0:1)}function pe(e,t){return Ae(e,t)+t}function ca(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:ua(n,e.startContentIndex)}}function ua(e,t){let n=e.unifiedLineStart;for(let i=0;i<t;i++){const r=e.hunkContent[i];n+=r.type==="context"?r.lines:r.deletions+r.additions}return n}function fa({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:i,renderHeaderFilenameSuffix:r,renderHeaderMetadata:s,renderAnnotation:o,renderGutterUtility:a,renderMergeConflictUtility:l,lineAnnotations:h,getHoveredLine:d,getInstance:c}){const u=n?.(e),f=i?.(e),p=r?.(e),g=s?.(e);return j.jsxs(j.Fragment,{children:[u!=null?j.jsx("div",{slot:Dt,children:u}):j.jsxs(j.Fragment,{children:[f!=null&&j.jsx("div",{slot:"header-prefix",children:f}),p!=null&&j.jsx("div",{slot:"header-filename-suffix",children:p}),g!=null&&j.jsx("div",{slot:"header-metadata",children:g})]}),o!=null&&h?.map((m,v)=>j.jsx("div",{slot:be(m),children:o(m)},v)),t!=null&&l!=null&&c!=null&&t.map(m=>{if(m==null)return;const v=pa(m,e);return j.jsx("div",{slot:v,style:Ko,children:l(m,c)},v)}),a!=null&&j.jsx("div",{slot:"gutter-utility-slot",style:ms,children:a(d)})]})}function pa(e,t){const n=ca(e,t);return n!=null?ha({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}function ga({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:i,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:o,renderGutterUtility:a,getHoveredLine:l}){const h=t?.(e),d=n?.(e),c=i?.(e),u=r?.(e);return j.jsxs(j.Fragment,{children:[h!=null?j.jsx("div",{slot:Dt,children:h}):j.jsxs(j.Fragment,{children:[d!=null&&j.jsx("div",{slot:"header-prefix",children:d}),c!=null&&j.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&j.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&o?.map((f,p)=>j.jsx("div",{slot:be(f),children:s(f)},p)),a!=null&&j.jsx("div",{slot:"gutter-utility-slot",style:ms,children:a(l)})]})}function mt(e,t){return e==null||t==null||typeof e=="string"||typeof t=="string"?e===t:e.dark===t.dark&&e.light===t.light}function we(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}const ti=new Set;function At(e){const t=[],n=new Set;for(const c of ma(e.themes)){const u=Cs(c)?c.getThemes():[c];for(const f of u){if(n.has(f.name))throw new Error(`Theme collection already contains theme "${f.name}"`);n.add(f.name),t.push(f)}}const i=Object.freeze([...t]),r=Object.freeze(i.filter(c=>c.colorScheme==="light")),s=Object.freeze(i.filter(c=>c.colorScheme==="dark")),o=new Map(i.map(c=>[c.name,c])),a=Object.freeze(i.map(c=>c.name)),l=Object.freeze(r.map(c=>c.name)),h=Object.freeze(s.map(c=>c.name));function d(c){if(c==null)return i;const{colorScheme:u,collection:f}=c;return f==null?u==="light"?r:u==="dark"?s:i:i.filter(p=>p.collection!==f?!1:u==null||p.colorScheme===u)}return{getTheme(c){return o.get(c)},getThemes(c){return d(c)},getThemeNames(c){return c?.collection==null?c?.colorScheme==="light"?l:c?.colorScheme==="dark"?h:a:d(c).map(u=>u.name)},hasTheme(c){return o.has(c)},orderBy(c){return At({themes:i.map((u,f)=>({descriptor:u,index:f})).sort((u,f)=>{const p=c(u.descriptor,f.descriptor);return p!==0?p:u.index-f.index}).map(u=>u.descriptor)})},pick(c){const u=[],f=new Set;for(const p of c){if(f.has(p))throw new Error(`Theme collection pick already includes theme "${p}"`);f.add(p);const g=o.get(p);if(g==null)throw new Error(`Theme collection does not contain theme "${p}"`);u.push(g)}return At({themes:u})},registerInto(c){for(const u of i)c.registerThemeIfAbsent(u.name,u.load)}}}function ma(e){return va(e)?[e]:e}function va(e){return Cs(e)||Sa(e)}function Sa(e){return typeof e.name=="string"&&typeof e.load=="function"}function Cs(e){return typeof e.getThemes=="function"}function ys(e){return e!==null&&typeof e=="object"&&"default"in e?e.default:e}var ba=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name="DuplicateThemeError"}},Ca=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name="UnregisteredThemeError"}},ya=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name="UnresolvedThemeError"}};function La(){const e=new Map,t=new Map,n=new Map;let i=0;function r(v,S){if(e.has(v))throw new ba(v);e.set(v,S)}function s(v,S){return e.has(v)?!1:(e.set(v,S),!0)}function o(v){return e.has(v)}function a(v){const S=t.get(v);if(S!==void 0)return Promise.resolve(S);const C=n.get(v);if(C!==void 0)return C;const b=e.get(v);if(b===void 0)return Promise.reject(new Ca(v));const y=i,L=b().then(k=>{const E=ys(k);return y===i&&t.set(v,E),n.get(v)===L&&n.delete(v),E}).catch(k=>{throw n.get(v)===L&&n.delete(v),k});return n.set(v,L),L}function l(v){return Promise.all(v.map(S=>a(S)))}function h(v,S){t.set(v,S)}function d(v){for(const[S,C]of v)h(S,C)}function c(v){return t.get(v)}function u(v){const S=[];for(const C of v){const b=t.get(C);if(b===void 0)throw new ya(C);S.push(b)}return S}function f(v){return t.has(v)}function p(v){for(const S of v)if(!t.has(S))return!1;return!0}function g(v){const S=t.get(v);return S!==void 0?S:a(v)}function m(){i++,t.clear(),n.clear()}return{clearResolvedThemes:m,getResolvedOrResolveTheme:g,getResolvedTheme:c,getResolvedThemes:u,hasRegisteredTheme:o,hasResolvedTheme:f,hasResolvedThemes:p,registerTheme:r,registerThemeIfAbsent:s,resolveTheme:a,resolveThemes:l,seedResolvedTheme:h,seedResolvedThemes:d}}const _e=La();function Ji(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let i;if(typeof n=="string"){if(i=_e.getResolvedTheme(n),i==null)throw new Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else i=n,n=n.name,_e.getResolvedTheme(n)==null&&_e.seedResolvedTheme(n,i);ti.has(n)||(ti.add(n),t.loadThemeSync(i))}}const Rt=new Map,Hn=new Map,xa=new Map,ni=new Set;function Qi(e,t){e=Array.isArray(e)?e:[e];for(const n of e){if(ni.has(n.name))continue;let i=Rt.get(n.name);i==null&&(i=n,Rt.set(n.name,i)),ni.add(i.name),t.loadLanguageSync(i.data)}}function Ls(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}async function ka(e){if(Ls())throw new Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);const t=Hn.get(e);if(t!=null)return t;try{let n=xa.get(e);if(n==null&&Object.prototype.hasOwnProperty.call(Xi,e)&&(n=Xi[e]),n==null)throw new Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);const i=n().then(({default:r})=>{const s={name:e,data:r};return Rt.has(e)||Rt.set(e,s),s});return Hn.set(e,i),await i}finally{Hn.delete(e)}}function wa(e){return Rt.get(e)??ka(e)}function xs({name:e,load:t,colorScheme:n,collection:i,displayName:r}){return{name:e,colorScheme:n,collection:i,displayName:r,load:Ea(t)}}function Ea(e){return async()=>Bo(ys(await e()))}const Ta="pierre",Aa=["pierre-dark","pierre-dark-soft","pierre-dark-vibrant","pierre-dark-protanopia-deuteranopia","pierre-dark-tritanopia"],ks=["pierre-light","pierre-light-soft","pierre-light-vibrant","pierre-light-protanopia-deuteranopia","pierre-light-tritanopia"],Ra=[...ks,...Aa],Ia=new Set(ks);function Ma(e){return Ia.has(e)?"light":"dark"}const Ha={"pierre-dark":"Pierre Dark","pierre-dark-soft":"Pierre Dark Soft","pierre-dark-vibrant":"Pierre Dark Vibrant","pierre-dark-protanopia-deuteranopia":"Pierre Dark Protanopia & Deuteranopia","pierre-dark-tritanopia":"Pierre Dark Tritanopia","pierre-light":"Pierre Light","pierre-light-soft":"Pierre Light Soft","pierre-light-vibrant":"Pierre Light Vibrant","pierre-light-protanopia-deuteranopia":"Pierre Light Protanopia & Deuteranopia","pierre-light-tritanopia":"Pierre Light Tritanopia"},Pa={"pierre-dark":()=>I(()=>import("./pierre-dark-CyvmCCZW.js"),[]),"pierre-dark-soft":()=>I(()=>import("./pierre-dark-soft-BHGpRqa4.js"),[]),"pierre-dark-vibrant":()=>I(()=>import("./pierre-dark-vibrant-BWBVywrn.js"),[]),"pierre-dark-protanopia-deuteranopia":()=>I(()=>import("./pierre-dark-protanopia-deuteranopia-Rgc0TwpF.js"),[]),"pierre-dark-tritanopia":()=>I(()=>import("./pierre-dark-tritanopia-Beq2gCRQ.js"),[]),"pierre-light":()=>I(()=>import("./pierre-light-480U9XYS.js"),[]),"pierre-light-soft":()=>I(()=>import("./pierre-light-soft-CVdyfjmI.js"),[]),"pierre-light-vibrant":()=>I(()=>import("./pierre-light-vibrant-DdTDNdfJ.js"),[]),"pierre-light-protanopia-deuteranopia":()=>I(()=>import("./pierre-light-protanopia-deuteranopia-CaVOBURG.js"),[]),"pierre-light-tritanopia":()=>I(()=>import("./pierre-light-tritanopia-B4_gpKOM.js"),[])};function Oa(e){return xs({name:e,collection:Ta,colorScheme:Ma(e),displayName:Ha[e],load:Pa[e]})}const ws=At({themes:Ra.map(e=>Oa(e))}),Da="shiki",Es=["ayu-light","catppuccin-latte","everforest-light","github-light","github-light-default","github-light-high-contrast","gruvbox-light-hard","gruvbox-light-medium","gruvbox-light-soft","horizon-bright","kanagawa-lotus","light-plus","material-theme-lighter","min-light","night-owl-light","one-light","rose-pine-dawn","slack-ochin","snazzy-light","solarized-light","vitesse-light"],_a=["andromeeda","aurora-x","ayu-dark","ayu-mirage","catppuccin-frappe","catppuccin-macchiato","catppuccin-mocha","dark-plus","dracula","dracula-soft","everforest-dark","github-dark","github-dark-default","github-dark-dimmed","github-dark-high-contrast","gruvbox-dark-hard","gruvbox-dark-medium","gruvbox-dark-soft","horizon","houston","kanagawa-dragon","kanagawa-wave","laserwave","material-theme","material-theme-darker","material-theme-ocean","material-theme-palenight","min-dark","monokai","night-owl","nord","one-dark-pro","plastic","poimandres","red","rose-pine","rose-pine-moon","slack-dark","solarized-dark","synthwave-84","tokyo-night","vesper","vitesse-black","vitesse-dark"],Fa=new Set(Es);function Na(e){return Fa.has(e)?"light":"dark"}const za={andromeeda:()=>I(()=>import("./andromeeda-C4gqWexZ.js"),[]),"aurora-x":()=>I(()=>import("./aurora-x-D-2ljcwZ.js"),[]),"ayu-dark":()=>I(()=>import("./ayu-dark-DYE7WIF3.js"),[]),"ayu-light":()=>I(()=>import("./ayu-light-BA47KaF1.js"),[]),"ayu-mirage":()=>I(()=>import("./ayu-mirage-32ctXXKs.js"),[]),"catppuccin-frappe":()=>I(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]),"catppuccin-latte":()=>I(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]),"catppuccin-macchiato":()=>I(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]),"catppuccin-mocha":()=>I(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]),"dark-plus":()=>I(()=>import("./dark-plus-C3mMm8J8.js"),[]),dracula:()=>I(()=>import("./dracula-BzJJZx-M.js"),[]),"dracula-soft":()=>I(()=>import("./dracula-soft-BXkSAIEj.js"),[]),"everforest-dark":()=>I(()=>import("./everforest-dark-BgDCqdQA.js"),[]),"everforest-light":()=>I(()=>import("./everforest-light-C8M2exoo.js"),[]),"github-dark":()=>I(()=>import("./github-dark-DHJKELXO.js"),[]),"github-dark-default":()=>I(()=>import("./github-dark-default-Cuk6v7N8.js"),[]),"github-dark-dimmed":()=>I(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]),"github-dark-high-contrast":()=>I(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]),"github-light":()=>I(()=>import("./github-light-DAi9KRSo.js"),[]),"github-light-default":()=>I(()=>import("./github-light-default-D7oLnXFd.js"),[]),"github-light-high-contrast":()=>I(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]),"gruvbox-dark-hard":()=>I(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]),"gruvbox-dark-medium":()=>I(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]),"gruvbox-dark-soft":()=>I(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]),"gruvbox-light-hard":()=>I(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]),"gruvbox-light-medium":()=>I(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]),"gruvbox-light-soft":()=>I(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]),horizon:()=>I(()=>import("./horizon-BUw7H-hv.js"),[]),"horizon-bright":()=>I(()=>import("./horizon-bright-CUuTKBJd.js"),[]),houston:()=>I(()=>import("./houston-DnULxvSX.js"),[]),"kanagawa-dragon":()=>I(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]),"kanagawa-lotus":()=>I(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]),"kanagawa-wave":()=>I(()=>import("./kanagawa-wave-DWedfzmr.js"),[]),laserwave:()=>I(()=>import("./laserwave-DUszq2jm.js"),[]),"light-plus":()=>I(()=>import("./light-plus-B7mTdjB0.js"),[]),"material-theme":()=>I(()=>import("./material-theme-D5KoaKCx.js"),[]),"material-theme-darker":()=>I(()=>import("./material-theme-darker-BfHTSMKl.js"),[]),"material-theme-lighter":()=>I(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]),"material-theme-ocean":()=>I(()=>import("./material-theme-ocean-CyktbL80.js"),[]),"material-theme-palenight":()=>I(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]),"min-dark":()=>I(()=>import("./min-dark-CafNBF8u.js"),[]),"min-light":()=>I(()=>import("./min-light-CTRr51gU.js"),[]),monokai:()=>I(()=>import("./monokai-D4h5O-jR.js"),[]),"night-owl":()=>I(()=>import("./night-owl-C39BiMTA.js"),[]),"night-owl-light":()=>I(()=>import("./night-owl-light-CMTm3GFP.js"),[]),nord:()=>I(()=>import("./nord-Ddv68eIx.js"),[]),"one-dark-pro":()=>I(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]),"one-light":()=>I(()=>import("./one-light-C3Wv6jpd.js"),[]),plastic:()=>I(()=>import("./plastic-3e1v2bzS.js"),[]),poimandres:()=>I(()=>import("./poimandres-CS3Unz2-.js"),[]),red:()=>I(()=>import("./red-bN70gL4F.js"),[]),"rose-pine":()=>I(()=>import("./rose-pine-qdsjHGoJ.js"),[]),"rose-pine-dawn":()=>I(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]),"rose-pine-moon":()=>I(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]),"slack-dark":()=>I(()=>import("./slack-dark-BthQWCQV.js"),[]),"slack-ochin":()=>I(()=>import("./slack-ochin-DqwNpetd.js"),[]),"snazzy-light":()=>I(()=>import("./snazzy-light-Bw305WKR.js"),[]),"solarized-dark":()=>I(()=>import("./solarized-dark-DXbdFlpD.js"),[]),"solarized-light":()=>I(()=>import("./solarized-light-L9t79GZl.js"),[]),"synthwave-84":()=>I(()=>import("./synthwave-84-CbfX1IO0.js"),[]),"tokyo-night":()=>I(()=>import("./tokyo-night-hegEt444.js"),[]),vesper:()=>I(()=>import("./vesper-DU1UobuO.js"),[]),"vitesse-black":()=>I(()=>import("./vitesse-black-Bkuqu6BP.js"),[]),"vitesse-dark":()=>I(()=>import("./vitesse-dark-D0r3Knsf.js"),[]),"vitesse-light":()=>I(()=>import("./vitesse-light-CVO1_9PV.js"),[])};function er(e){return xs({name:e,collection:Da,colorScheme:Na(e),load:za[e]})}const Ts=At({themes:Object.freeze([...Es.map(e=>er(e)),..._a.map(e=>er(e))])});At({themes:[ws,Ts]});function Ba(e){if(Ls())throw new Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(_e.hasRegisteredTheme(e))return;const t=Ts.getTheme(e);if(t!=null){_e.registerThemeIfAbsent(t.name,t.load);return}throw new Error(`No valid theme loader registered for "${e}"`)}function Va(e,t){if(t.name!==e)throw new Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function Ua(e){Ba(e);const t=await _e.resolveTheme(e);return Va(e,t),t}function Wa(e){return _e.getResolvedTheme(e)??Ua(e)}let ke;async function As({themes:e,langs:t,preferredHighlighter:n="shiki-js"}){ke??=Vo({themes:[],langs:["text"],engine:n==="shiki-wasm"?Uo(I(()=>import("./wasm-CG6Dc4jp.js"),[])):Wo()});const i=$a(ke)?await ke:ke;ke=i;const r=[];for(const o of t){if(o==="text"||o==="ansi")continue;const a=wa(o);"then"in a?r.push(a):Qi(a,i)}const s=[];for(const o of e){const a=Wa(o);"then"in a?s.push(a):Ji(a,ke)}return(r.length>0||s.length>0)&&await Promise.all([Promise.all(r).then(o=>{Qi(o,i)}),Promise.all(s).then(o=>{Ji(o,i)})]),i}function Rs(){if(ke!=null&&!("then"in ke))return ke}function $a(e=ke){return e!=null&&"then"in e}for(const e of ws.getThemes())_e.registerThemeIfAbsent(e.name,e.load);function _i(e=J){const t=[];return typeof e=="string"?t.push(e):(t.push(e.dark),t.push(e.light)),t}function Ga(e){return _e.hasResolvedThemes(e)}function et(e,t){return mt(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}const tt=new Map,St={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",jbuilder:"ruby",builder:"ruby",rabl:"ruby",arb:"ruby",ru:"ruby",podspec:"ruby",Gemfile:"ruby",Rakefile:"ruby",Guardfile:"ruby",Capfile:"ruby",Berksfile:"ruby",Brewfile:"ruby",Vagrantfile:"ruby",Thorfile:"ruby",Appraisals:"ruby",Dangerfile:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",mts:"typescript",cts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function he(e){if(tt.has(e))return tt.get(e)??"text";if(St[e]!=null)return St[e];const t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(tt.has(t[1]))return tt.get(t[1])??"text";if(St[t[1]]!=null)return St[t[1]]??"text"}const n=e.match(/\.([^.]+)$/)?.[1]??"";return tt.has(n)?tt.get(n)??"text":St[n]??"text"}function ii(e){return(e.lang??he(e.name))==="text"}const un=10,fn=13,ja=4,Ka=40;function Fi(e){const t=[0];let n=e.indexOf("\r"),i=e.indexOf(`
2
+ `),r=0,s=0;for(;n!==-1||i!==-1;){let o;if(n!==-1&&(i===-1||n<i)?i===n+1?(o=i+1,n=e.indexOf("\r",o),i=e.indexOf(`
3
+ `,o)):(o=n+1,n=e.indexOf("\r",o)):(o=i+1,i=e.indexOf(`
4
+ `,o)),t.push(o),++s===ja){if(o-r<=Ka){for(let a=o;a<e.length;a++){const l=e.charCodeAt(a);(l===un||l===fn)&&(l===fn&&a+1<e.length&&e.charCodeAt(a+1)===un&&a++,t.push(a+1))}return t}r=o,s=0}}return t}function qa(e){let t=0;for(let n=0;n<e.length;n++){const i=e.charCodeAt(n);(i===un||i===fn)&&(i===fn&&n+1<e.length&&e.charCodeAt(n+1)===un&&n++,t++)}return t}function nn(e){const t=Fi(e);return Array.from({length:t.length},(n,i)=>{const r=t[i],s=t[i+1]??e.length;return e.slice(r,s)})}function Te(e){return{type:"text",value:e}}function F({tagName:e,children:t=[],properties:n={}}){return{type:"element",tagName:e,properties:n,children:t}}function pn({name:e,width:t=16,height:n=16,properties:i}){return F({tagName:"svg",properties:{width:t,height:n,viewBox:"0 0 16 16",...i},children:[F({tagName:"use",properties:{href:`#${e.replace(/^#/,"")}`}})]})}function Ya(e){let t=e.children[0];for(;t!=null;){if(t.type==="element"&&t.tagName==="code")return t;"children"in t?t=t.children[0]:t=null}}function rt(e){return F({tagName:"div",properties:{"data-gutter":""},children:e})}function Is(e,t,n,i={}){return F({tagName:"div",properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...i},children:t!=null?[F({tagName:"span",properties:{"data-line-number-content":""},children:[Te(`${t}`)]})]:void 0})}function ge(e,t,n){return F({tagName:"div",properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t==="annotation"?void 0:e,style:t==="annotation"?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function Xa(e,t,n){const i=typeof n.lineInfo=="function"?n.lineInfo(t):n.lineInfo[t-1];if(i==null){const r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),new Error(r)}return e.tagName="div",e.properties["data-line"]=i.lineNumber,e.properties["data-alt-line"]=i.altLineNumber,e.properties["data-line-type"]=i.type,e.properties["data-line-index"]=i.lineIndex,e.children.length===0&&e.children.push(Te(`
5
+ `)),e}const Nt=Symbol("no-token"),Pn=Symbol("multiple-tokens");function Ms(e){const t=Za(e);if(t!=null)return t;let n=Nt;const i=[];let r=[],s;const o=()=>{if(r.length===0||s==null){r=[],s=void 0;return}if(r.length===1){const l=r[0];if(l?.type==="element"){Ja(l,s);for(const h of l.children)rn(h)}else rn(l);i.push(l),r=[],s=void 0;return}for(const l of r)rn(l);i.push(F({tagName:"span",properties:{"data-char":s},children:r})),r=[],s=void 0},a=l=>{if(l!==Nt){if(l===Pn){n=Pn;return}if(n===Nt){n=l;return}n!==l&&(n=Pn)}};for(const l of e.children){const h=l.type==="element"?Ms(l):Nt;if(a(h),typeof h!="number"){o(),i.push(l);continue}s!=null&&s!==h&&o(),s??=h,r.push(l)}return o(),e.children=i,n}function Za(e){const t=e.properties["data-char"];if(typeof t=="number")return t}function rn(e){if(e.type==="element"){e.properties["data-char"]=void 0;for(const t of e.children)rn(t)}}function Ja(e,t){e.properties["data-char"]=t}function Hs(e=!1,t=!1){const n={lineInfo:[]},i=[{line(r){return delete r.properties.class,r},pre(r){const s=Ya(r),o=[];if(s!=null){let a=1;for(const l of s.children)l.type==="element"&&(e&&Ms(l),o.push(Xa(l,a,n)),a++);s.children=o}return r},...e?{tokens(r){for(const s of r){let o=0;for(const a of s){const l=a;l.__lineChar??=o,o+=a.content.length}}},preprocess(r,s){s.mergeWhitespaces="never"},span(r,s,o,a,l){if(l?.offset!=null&&l.content!=null){const h=l.__lineChar;return h!=null&&(r.properties["data-char"]=h),r}return r}}:null}];return t&&i.push(Qa,tr),e&&i.push({line:r=>(r.type==="element"&&r.children.length===0&&r.children.push({type:"element",tagName:"br",properties:{},children:[]}),r)}),{state:n,transformers:i,toClass:tr}}const tr=$o({classPrefix:"hl-"}),Qa={name:"token-style-normalizer",tokens(e){for(const t of e)for(const n of t){if(n.htmlStyle!=null)continue;const i={};n.color!=null&&(i.color=n.color),n.bgColor!=null&&(i["background-color"]=n.bgColor),n.fontStyle!=null&&n.fontStyle!==0&&((n.fontStyle&1)!==0&&(i["font-style"]="italic"),(n.fontStyle&2)!==0&&(i["font-weight"]="bold"),(n.fontStyle&4)!==0&&(i["text-decoration"]="underline")),Object.keys(i).length>0&&(n.htmlStyle=i)}}};function me(e){return`--${e==="token"?"diffs-token":"diffs"}-`}const el=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,tl=/^0(?:\.0+)?%?$/;function nl(e){const t=e.indexOf("(");if(t<=0||!e.endsWith(")"))return;const n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;const i=e.slice(t+1,-1).trim();if(i.length===0)return;const r=i.lastIndexOf("/");if(r!==-1)return i.slice(r+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){const s=i.split(",");if(s.length===4)return s[3]?.trim()}}function It(e){const t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;const n=t[1];let i,r=1;return n.length===3?i=n.split("").map(s=>s+s).join(""):n.length===6?i=n:(i=n.slice(0,6),r=parseInt(n.slice(6,8),16)/255),[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),r]}function Se(e){if(e==null)return null;const t=It(e);if(t==null)return null;const n=t[0]/255,i=t[1]/255,r=t[2]/255,s=o=>o<=.03928?o/12.92:((o+.055)/1.055)**2.4;return .2126*s(n)+.7152*s(i)+.0722*s(r)}function Ni(e,t){const[n,i]=e>t?[e,t]:[t,e];return(n+.05)/(i+.05)}function il(e,t){if(t==null)return;const n=It(e),i=It(t);if(n==null||i==null)return;const[r,s,o,a]=n,[l,h,d]=i;return"#"+[Math.round(r*a+l*(1-a)),Math.round(s*a+h*(1-a)),Math.round(o*a+d*(1-a))].map(c=>c.toString(16).padStart(2,"0")).join("")}function ri(e){if(e==null)return!1;const t=e.trim().toLowerCase();if(t==="transparent"||el.test(t))return!0;const n=nl(t);return n!=null&&tl.test(n)}function rl(e,t){const n=Se(e);if(n!=null)return n<.4;const i=Se(t);return i!=null?i>.6:!1}function sl(e,t){if(e==null||t==null)return!1;if(e.trim().toLowerCase()===t.trim().toLowerCase())return!0;const n=Se(e),i=Se(t);return n==null||i==null?!1:Math.abs(n-i)<.06}function Ps(e,t,n){if(t==null||n==null)return!1;const i=Se(e),r=Se(t),s=Se(n);return i==null||r==null||s==null?!1:Math.abs(i-s)<Math.abs(i-r)}function ol(e,t){const n=Se(e),i=t.find(o=>o!=null&&o!=="");if(n==null)return i;let r,s=-1;for(const o of t){if(o==null||o==="")continue;const a=Se(o);if(a==null)continue;const l=Ni(n,a);if(l>=3)return o;l>s&&(r=o,s=l)}return r??i}function al(e,t){if(t==null)return e;const n=It(e),i=It(t),r=Se(t);if(n==null||i==null||r==null)return`color-mix(in srgb, ${e} 70%, ${t})`;const[s,o,a]=n,[l,h,d]=i;for(const c of[.6,.7,.8,.9]){const u="#"+[Math.round(s*c+l*(1-c)),Math.round(o*c+h*(1-c)),Math.round(a*c+d*(1-c))].map(p=>p.toString(16).padStart(2,"0")).join(""),f=Se(u);if(f!=null&&Ni(r,f)>=4.5)return u}return e}const nr=new WeakMap;function On(e){const t=nr.get(e);if(t!=null)return t;const n=e.colors??{},i={...n},r=n["editor.background"]??e.bg,s=n["editor.foreground"]??e.fg,o=n["sideBar.background"]??r,a=n["sideBar.foreground"]??s;Le(i,"editor.background",r),Le(i,"editor.foreground",s),Le(i,"sideBar.background",o),Le(i,"sideBar.foreground",a),Le(i,"input.background",n["input.background"]??o),Le(i,"sideBarSectionHeader.foreground",n["sideBarSectionHeader.foreground"]??a),Le(i,"list.activeSelectionForeground",n["list.activeSelectionForeground"]??a),Le(i,"gitDecoration.addedResourceForeground",Dn(n["gitDecoration.addedResourceForeground"],n["terminal.ansiGreen"],n["editorGutter.addedBackground"])),Le(i,"gitDecoration.modifiedResourceForeground",Dn(n["gitDecoration.modifiedResourceForeground"],n["terminal.ansiBlue"],n["editorGutter.modifiedBackground"])),Le(i,"gitDecoration.deletedResourceForeground",Dn(n["gitDecoration.deletedResourceForeground"],n["terminal.ansiRed"],n["editorGutter.deletedBackground"]));const l=(ri(n["list.focusOutline"])?void 0:n["list.focusOutline"])??(ri(n.focusBorder)?void 0:n.focusBorder);l!=null?i["list.focusOutline"]=l:delete i["list.focusOutline"];const h=n["list.hoverBackground"];h!=null&&(ll(h,o)||Ps(h,o,a))&&delete i["list.hoverBackground"];const d=Object.freeze({...e,colors:Object.freeze(i)});return nr.set(e,d),d}function Le(e,t,n){n!=null&&n!==""&&(e[t]=n)}function Dn(...e){for(const t of e)if(t!=null&&t!=="")return t}function ll(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}const dl={compositeOverBg:il,contrastRatio:Ni,deriveMutedFg:al,hoverWouldEraseText:Ps,isDarkSurface:rl,isFullyTransparent:ri,pickReadableForeground:ol,relativeLuminance:Se,surfacesMatch:sl};function Os({theme:e=J,highlighter:t,prefix:n}){let i="";if(typeof e=="string"){const r=t.getTheme(e),s=On(r);i+=`color:${s.fg};`,i+=`background-color:${s.bg};`,i+=`${me("global")}fg:${s.fg};`,i+=`${me("global")}bg:${s.bg};`,i+=_n(r,n)}else{let r=t.getTheme(e.dark),s=On(r);i+=`${me("global")}dark:${s.fg};`,i+=`${me("global")}dark-bg:${s.bg};`,i+=_n(r,"dark"),r=t.getTheme(e.light),s=On(r),i+=`${me("global")}light:${s.fg};`,i+=`${me("global")}light-bg:${s.bg};`,i+=_n(r,"light")}return i}function _n(e,t){t=t!=null?`${t}-`:"";let n="";const i=e.colors?.["gitDecoration.addedResourceForeground"]??e.colors?.["terminal.ansiGreen"];i!=null&&(n+=`${me("global")}${t}addition-color:${i};`);const r=e.colors?.["gitDecoration.deletedResourceForeground"]??e.colors?.["terminal.ansiRed"];r!=null&&(n+=`${me("global")}${t}deletion-color:${r};`);const s=e.colors?.["gitDecoration.modifiedResourceForeground"]??e.colors?.["terminal.ansiBlue"];return s!=null&&(n+=`${me("global")}${t}modified-color:${s};`),n}function si(e){let t=e.children[0];for(;t!=null;){if(t.type==="element"&&t.tagName==="code")return t.children;"children"in t?t=t.children[0]:t=null}throw console.error(e),new Error("getLineNodes: Unable to find children")}const hl={forcePlainText:!1};function cl(e,t,{theme:n=J,tokenizeMaxLineLength:i,useTokenTransformer:r},{forcePlainText:s,startingLine:o,totalLines:a,lines:l}=hl){s?(o??=0,a??=1/0):(o=0,a=1/0);const h=o>0||a<1/0,{state:d,transformers:c}=Hs(r),u=s?"text":e.lang??he(e.name),f=typeof n=="string"?t.getTheme(n).type:void 0,p=Os({theme:n,highlighter:t});d.lineInfo=S=>({type:"context",lineIndex:S-1+o,lineNumber:S+o});const g=typeof n=="string"?{lang:u,theme:n,transformers:c,defaultColor:!1,cssVariablePrefix:me("token"),tokenizeMaxLineLength:i,tokenizeTimeLimit:0}:{lang:u,themes:n,transformers:c,defaultColor:!1,cssVariablePrefix:me("token"),tokenizeMaxLineLength:i,tokenizeTimeLimit:0},m=si(t.codeToHast(h?ul(l??nn(e.contents),o,a):e.contents,g)),v=h?new Array(o):m;return h&&v.push(...m),{code:v,themeStyles:p,baseThemeType:f}}function ul(e,t,n){if(e.length===0)return"";const i=Math.min(t+n,e.length);return e.slice(t,i).join("")}function st(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function nt(e,t){return mt(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function sn(e){const t=e.lang??he(e.name),n=e.lang??(e.prevName!=null?he(e.prevName):"text");return t==="text"&&n==="text"}function Fe(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}function on(e){return{...Di,...e}}function Ee(e,t){const n=fl(e,t);return t?n:e.diffHeaderHeight+n}function fl(e,t){return e.paddingTop??(t?e.spacing:0)}function gn(e){return e.paddingBottom??e.spacing}function pl(e){switch(e){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}function Mt(e){return[Ae(e.additionStart,e.additionCount)+1,pe(e.additionStart,e.additionCount)+1]}function Ne({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}){const s=Math.max(t,0);if(s===0||e)return{fromStart:0,fromEnd:0,rangeSize:s,collapsedLines:s,renderAll:!1};if(n===!0||s<=r)return{fromStart:s,fromEnd:0,rangeSize:s,collapsedLines:0,renderAll:!0};const o=n?.get(i),a=Math.min(Math.max(o?.fromStart??0,0),s),l=Math.min(Math.max(o?.fromEnd??0,0),s),h=a+l,d=h>=s;return{fromStart:d?s:a,fromEnd:d?0:l,rangeSize:s,collapsedLines:Math.max(s-h,0),renderAll:d}}function gl(e){const t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;const n=e.additionLines.length-pe(t.additionStart,t.additionCount),i=e.deletionLines.length-pe(t.deletionStart,t.deletionCount);return n<=0&&i<=0?!1:n!==i}function Ds({fileDiff:e,errorPrefix:t}){const n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;const i=e.additionLines.length-pe(n.additionStart,n.additionCount),r=e.deletionLines.length-pe(n.deletionStart,n.deletionCount);if(i<=0&&r<=0)return 0;if(i!==r)throw new Error(`${t}: trailing context mismatch (additions=${i}, deletions=${r}) for ${e.name}`);return Math.min(i,r)}function ze({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:i,errorPrefix:r}){if(t!==e.hunks.length-1)return;const s=Ds({fileDiff:e,errorPrefix:r});if(s<=0)return;if(n===!0||s<=i)return{fromStart:s,fromEnd:0,rangeSize:s,collapsedLines:0,renderAll:!0};const o=n?.get(e.hunks.length),a=Math.min(Math.max(o?.fromStart??0,0),s);return{fromStart:a,fromEnd:0,rangeSize:s,collapsedLines:s-a,renderAll:a>=s}}function _s({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:i}){if(n===!0||e.isPartial)return!0;for(const[a,l]of e.hunks.entries()){const[h,d]=Mt(l);if(t<h){const c=Ne({isPartial:e.isPartial,rangeSize:l.collapsedBefore,expandedHunks:n,hunkIndex:a,collapsedContextThreshold:i}),u=h-c.rangeSize;return c.renderAll||t<u+c.fromStart||t>=h-c.fromEnd}if(t<d)return!0}const r=ze({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:i,errorPrefix:"isAdditionLineRenderable"});if(r==null||r.renderAll)return!0;const s=e.hunks[e.hunks.length-1],[,o]=Mt(s);return t<o+r.fromStart||t>=o+r.rangeSize}function ml({fileDiff:e,lineNumber:t,direction:n,expandedHunks:i,collapsedContextThreshold:r}){if(i===!0||e.isPartial)return t;const s=[];let o=1;for(const[l,h]of e.hunks.entries()){const[d,c]=Mt(h),u=Ne({isPartial:e.isPartial,rangeSize:h.collapsedBefore,expandedHunks:i,hunkIndex:l,collapsedContextThreshold:r}),f=d-u.rangeSize;u.renderAll?s.push([f,d]):(u.fromStart>0&&s.push([f,f+u.fromStart]),u.fromEnd>0&&s.push([d-u.fromEnd,d])),s.push([d,c]),o=c}const a=ze({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:i,collapsedContextThreshold:r,errorPrefix:"getNearestRenderableAdditionLine"});if(a!=null){const l=o;o=l+a.rangeSize,a.renderAll?s.push([l,o]):a.fromStart>0&&s.push([l,l+a.fromStart])}if(t>=o)return t;if(n==="down"){for(const[l,h]of s)if(h>t)return Math.max(l,t);return}for(let l=s.length-1;l>=0;l--){const[h,d]=s[l];if(h<=t)return Math.min(d-1,t)}}function Fs({type:e,metrics:t}){return t.hunkSeparatorHeight??pl(e)}function Ns({type:e,metrics:t}){return e==="simple"||e==="metadata"||e==="line-info-basic"?0:t.spacing}function vl({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case"simple":return t>0;case"metadata":return n!=null;case"line-info":case"line-info-basic":case"custom":return!0}}function Sl(e){return e!=="simple"&&e!=="metadata"}function Lt({type:e,metrics:t,hunkIndex:n,hunkSpecs:i}){if(!vl({type:e,hunkIndex:n,hunkSpecs:i}))return;const r=Fs({type:e,metrics:t}),s=Ns({type:e,metrics:t}),o=n>0?s:0,a=s;return{height:r,gapBefore:o,gapAfter:a,totalHeight:o+r+a}}function qe({type:e,metrics:t}){if(!Sl(e))return;const n=Fs({type:e,metrics:t}),i=Ns({type:e,metrics:t});return{height:n,gapBefore:i,gapAfter:0,totalHeight:i+n}}function Xe({diff:e,diffStyle:t,startingLine:n=0,totalLines:i=1/0,expandedHunks:r,collapsedContextThreshold:s=1,callback:o}){const a=bl({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:s}),l={viewportStart:n,viewportEnd:n+i,isWindowedHighlight:n>0||i<1/0,splitCount:a.splitCount,unifiedCount:a.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!l.isWindowedHighlight)return!1;const h=l.unifiedCount>=n+i,d=l.splitCount>=n+i;return t==="unified"?h:(t==="split"||h)&&d},shouldSkip(h,d){if(!l.isWindowedHighlight)return!1;const c=h>0&&l.unifiedCount+h<=n,u=d>0&&l.splitCount+d<=n;return t==="unified"?c:(t==="split"||c)&&u},incrementCounts(h,d){(t==="unified"||t==="both")&&(l.unifiedCount+=h),(t==="split"||t==="both")&&(l.splitCount+=d)},isInWindow(h,d){if(!l.isWindowedHighlight)return!0;const c=l.isInUnifiedWindow(h),u=l.isInSplitWindow(d);return t==="unified"?c:t==="split"?u:c||u},isInUnifiedWindow(h){return!l.isWindowedHighlight||l.unifiedCount>=n-h&&l.unifiedCount<n+i},isInSplitWindow(h){return!l.isWindowedHighlight||l.splitCount>=n-h&&l.splitCount<n+i},emit(h,d=!1){return d||(t==="unified"?l.incrementCounts(1,0):t==="split"?l.incrementCounts(0,1):l.incrementCounts(1,1)),o(h)??!1}};e:for(let h=a.hunkIndex;h<e.hunks.length;h++){let S=function(T,R){return m==null||m.collapsedLines<=0||m.fromStart+m.fromEnd>0?0:t==="unified"?T===d.unifiedLineStart+d.unifiedLineCount-1?m.collapsedLines:0:R===d.splitLineStart+d.splitLineCount-1?m.collapsedLines:0},b=function(){return C?0:(C=!0,g.collapsedLines)};const d=e.hunks[h];if(d==null)throw new Error("iterateOverDiff: invalid hunk index");if(l.shouldBreak())break;const c=Ae(d.deletionStart,d.deletionCount),u=Ae(d.additionStart,d.additionCount),f=!e.isPartial&&d.deletionCount===0?c:d.deletionLineIndex,p=!e.isPartial&&d.additionCount===0?u:d.additionLineIndex,g=Ne({isPartial:e.isPartial,rangeSize:d.collapsedBefore,expandedHunks:r,hunkIndex:h,collapsedContextThreshold:s}),m=h===l.finalHunkIndex?ze({fileDiff:e,hunkIndex:h,expandedHunks:r,collapsedContextThreshold:s,errorPrefix:"iterateOverDiff"}):void 0,v=g.fromStart+g.fromEnd;let C=g.collapsedLines===0;if(l.shouldSkip(v,v))l.incrementCounts(v,v),b();else{let T=d.unifiedLineStart-g.rangeSize,R=d.splitLineStart-g.rangeSize,_=f-g.rangeSize,$=p-g.rangeSize,H=c+1-g.rangeSize,D=u+1-g.rangeSize;if(zt(l,g.fromStart,t,B=>l.emit({hunkIndex:h,hunk:d,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:H+B,lineIndex:_+B,noEOFCR:!1,unifiedLineIndex:T+B,splitLineIndex:R+B},additionLine:{unifiedLineIndex:T+B,splitLineIndex:R+B,lineIndex:$+B,lineNumber:D+B,noEOFCR:!1}}))||(T=d.unifiedLineStart-g.fromEnd,R=d.splitLineStart-g.fromEnd,_=f-g.fromEnd,$=p-g.fromEnd,H=c+1-g.fromEnd,D=u+1-g.fromEnd,zt(l,g.fromEnd,t,B=>l.emit({hunkIndex:h,hunk:d,collapsedBefore:b(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:H+B,lineIndex:_+B,noEOFCR:!1,unifiedLineIndex:T+B,splitLineIndex:R+B},additionLine:{unifiedLineIndex:T+B,splitLineIndex:R+B,lineIndex:$+B,lineNumber:D+B,noEOFCR:!1}}),()=>{b()})))break e}let y=d.unifiedLineStart,L=d.splitLineStart,k=f,E=p,x=c+1,w=u+1;const O=d.hunkContent.at(-1);for(const T of d.hunkContent){if(l.shouldBreak())break e;const R=T===O;if(T.type==="context"){if(l.shouldSkip(T.lines,T.lines))l.incrementCounts(T.lines,T.lines),b();else if(zt(l,T.lines,t,_=>{const $=R&&_===T.lines-1,H=y+_,D=L+_;return l.emit({hunkIndex:h,hunk:d,collapsedBefore:b(),collapsedAfter:S(H,D),type:"context",deletionLine:{lineNumber:x+_,lineIndex:k+_,noEOFCR:$&&d.noEOFCRDeletions,unifiedLineIndex:H,splitLineIndex:D},additionLine:{unifiedLineIndex:H,splitLineIndex:D,lineIndex:E+_,lineNumber:w+_,noEOFCR:$&&d.noEOFCRAdditions}})},()=>{b()}))break e;y+=T.lines,L+=T.lines,k+=T.lines,E+=T.lines,x+=T.lines,w+=T.lines}else{const _=Math.max(T.deletions,T.additions),$=T.deletions+T.additions;if(!l.shouldSkip($,_)){const H=Ll(l,T,t);(H[0]?.[0]??0)>0&&b();for(const[D,B]of H)for(let Z=D;Z<B;Z++){const V=S(y+Z,t==="unified"?L+(Z<T.deletions?Z:Z-T.deletions):L+Z);if(l.emit(xl({hunkIndex:h,hunk:d,collapsedBefore:b(),collapsedAfter:V,diffStyle:t,index:Z,unifiedLineIndex:y,splitLineIndex:L,additionLineIndex:E,deletionLineIndex:k,additionLineNumber:w,deletionLineNumber:x,content:T,isLastContent:R,unifiedCount:$,splitCount:_}),!0))break e}}b(),l.incrementCounts($,_),y+=$,L+=_,k+=T.deletions,E+=T.additions,x+=T.deletions,w+=T.additions}}if(m!=null){const{collapsedLines:T,fromStart:R,fromEnd:_}=m,$=R+_;if(zt(l,$,t,H=>{const D=H===$-1;return l.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:D?T:0,type:"context-expanded",deletionLine:{lineNumber:x+H,lineIndex:k+H,noEOFCR:!1,unifiedLineIndex:y+H,splitLineIndex:L+H},additionLine:{unifiedLineIndex:y+H,splitLineIndex:L+H,lineIndex:E+H,lineNumber:w+H,noEOFCR:!1}})},void 0,()=>l.shouldBreak()))break e}}}function bl({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:r}){if(n<=0||t==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};const s=Cl({diff:e,expandedHunks:i,collapsedContextThreshold:r});let o=0,a=e.hunks.length-1,l=e.hunks.length;for(;o<=a;){const d=o+a>>1,c=s[d+1];if(c==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(t==="unified"?c.unifiedCount:c.splitCount)>n?(l=d,a=d-1):o=d+1}if(l>=e.hunks.length){const d=s[e.hunks.length];if(d==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:e.hunks.length,splitCount:d.splitCount,unifiedCount:d.unifiedCount}}const h=s[l];if(h==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:l,splitCount:h.splitCount,unifiedCount:h.unifiedCount}}function Cl({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let i=0,r=0;const s=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let a=0;a<e.hunks.length;a++){const l=e.hunks[a];if(l==null)throw new Error("iterateOverDiff: invalid hunk summary index");const h=Ne({isPartial:e.isPartial,rangeSize:l.collapsedBefore,expandedHunks:t,hunkIndex:a,collapsedContextThreshold:n}),d=h.fromStart+h.fromEnd;i+=d+l.splitLineCount,r+=d+l.unifiedLineCount;const c=a===s?ze({fileDiff:e,hunkIndex:a,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:"iterateOverDiff"}):void 0;if(c!=null){const u=c.fromStart+c.fromEnd;i+=u,r+=u}o.push({splitCount:i,unifiedCount:r})}return o}function yl(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];const i=[];function r(a){const l=Math.max(0,e.viewportStart-a),h=Math.min(t,e.viewportEnd-a);h>l&&i.push([l,h])}if(n!=="split"&&r(e.unifiedCount),n!=="unified"&&r(e.splitCount),i.length===0)return[0,0];let s=i[0][0],o=i[0][1];for(let a=1;a<i.length;a++){const l=i[a];s=Math.min(s,l[0]),o=Math.max(o,l[1])}return[s,o]}function zt(e,t,n,i,r,s){const[o,a]=yl(e,t,n);o>0&&(e.incrementCounts(o,o),r?.());let l=o;for(;l<t;){if(s?.()===!0)return!0;if(l>=a){e.incrementCounts(t-l,t-l);break}if(e.isInWindow(0,0)){if(i(l)===!0)return!0}else e.incrementCounts(1,1);l++}return!1}function Ll(e,t,n){if(!e.isWindowedHighlight)return[[0,n==="unified"?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];const i=n!=="split",r=n!=="unified",s=n==="unified"?"unified":"split",o=[];function a(c,u){if(c+u<=e.viewportStart||c>=e.viewportEnd)return;const f=Math.max(0,e.viewportStart-c),p=Math.min(u,e.viewportEnd-c);return p>f?[f,p]:void 0}function l(c,u){return s==="split"?c:u==="additions"?[c[0]+t.deletions,c[1]+t.deletions]:c}function h(c,u){if(c==null)return;const[f,p]=l(c,u);p>f&&o.push([f,p])}if(i&&(h(a(e.unifiedCount,t.deletions),"deletions"),h(a(e.unifiedCount+t.deletions,t.additions),"additions")),r&&(h(a(e.splitCount,t.deletions),"deletions"),h(a(e.splitCount,t.additions),"additions")),o.length===0)return o;o.sort((c,u)=>c[0]-u[0]);const d=[o[0]];for(const[c,u]of o.slice(1)){const f=d[d.length-1];c<=f[1]?f[1]=Math.max(f[1],u):d.push([c,u])}return d}function xl({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:i,diffStyle:r,index:s,unifiedLineIndex:o,splitLineIndex:a,additionLineIndex:l,deletionLineIndex:h,additionLineNumber:d,deletionLineNumber:c,content:u,isLastContent:f,unifiedCount:p,splitCount:g}){const m=s<u.deletions?o+s:void 0,v=r==="unified"?s>=u.deletions?o+s:void 0:s<u.additions?o+u.deletions+s:void 0,S=r==="unified"?a+(s<u.deletions?s:s-u.deletions):a+s,C=s<u.deletions?h+s:void 0,b=s<u.deletions?c+s:void 0,y=r==="unified"?s>=u.deletions?l+(s-u.deletions):void 0:s<u.additions?l+s:void 0,L=r==="unified"?s>=u.deletions?d+(s-u.deletions):void 0:s<u.additions?d+s:void 0,k=r==="unified"?f&&s===u.deletions-1&&t.noEOFCRDeletions:f&&s===g-1&&t.noEOFCRDeletions,E=r==="unified"?f&&s===p-1&&t.noEOFCRAdditions:f&&s===g-1&&t.noEOFCRAdditions,x=C!=null&&b!=null&&m!=null?{lineNumber:b,lineIndex:C,noEOFCR:k,unifiedLineIndex:m,splitLineIndex:S}:void 0,w=y!=null&&L!=null&&v!=null?{unifiedLineIndex:v,splitLineIndex:S,lineIndex:y,lineNumber:L,noEOFCR:E}:void 0;if(x==null&&w!=null)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:i,deletionLine:void 0,additionLine:w};if(x!=null&&w==null)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:i,deletionLine:x,additionLine:void 0};if(x==null||w==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:i,deletionLine:x,additionLine:w}}class zi{diff(t,n,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);const s=this.castInput(t,i),o=this.castInput(n,i),a=this.removeEmpty(this.tokenize(s,i)),l=this.removeEmpty(this.tokenize(o,i));return this.diffWithOptionsObj(a,l,i,r)}diffWithOptionsObj(t,n,i,r){var s;const o=S=>{if(S=this.postProcess(S,i),r){setTimeout(function(){r(S)},0);return}else return S},a=n.length,l=t.length;let h=1,d=a+l;i.maxEditLength!=null&&(d=Math.min(d,i.maxEditLength));const c=(s=i.timeout)!==null&&s!==void 0?s:1/0,u=Date.now()+c,f=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(f[0],n,t,0,i);if(f[0].oldPos+1>=l&&p+1>=a)return o(this.buildValues(f[0].lastComponent,n,t));let g=-1/0,m=1/0;const v=()=>{for(let S=Math.max(g,-h);S<=Math.min(m,h);S+=2){let C;const b=f[S-1],y=f[S+1];b&&(f[S-1]=void 0);let L=!1;if(y){const E=y.oldPos-S;L=y&&0<=E&&E<a}const k=b&&b.oldPos+1<l;if(!L&&!k){f[S]=void 0;continue}if(!k||L&&b.oldPos<y.oldPos?C=this.addToPath(y,!0,!1,0,i):C=this.addToPath(b,!1,!0,1,i),p=this.extractCommon(C,n,t,S,i),C.oldPos+1>=l&&p+1>=a)return o(this.buildValues(C.lastComponent,n,t))||!0;f[S]=C,C.oldPos+1>=l&&(m=Math.min(m,S-1)),p+1>=a&&(g=Math.max(g,S+1))}h++};if(r)(function S(){setTimeout(function(){if(h>d||Date.now()>u)return r(void 0);v()||S()},0)})();else for(;h<=d&&Date.now()<=u;){const S=v();if(S)return S}}addToPath(t,n,i,r,s){const o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===n&&o.removed===i?{oldPos:t.oldPos+r,lastComponent:{count:o.count+1,added:n,removed:i,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+r,lastComponent:{count:1,added:n,removed:i,previousComponent:o}}}extractCommon(t,n,i,r,s){const o=n.length,a=i.length;let l=t.oldPos,h=l-r,d=0;for(;h+1<o&&l+1<a&&this.equals(i[l+1],n[h+1],s);)h++,l++,d++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!s.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=l,h}equals(t,n,i){return i.comparator?i.comparator(t,n):t===n||!!i.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let i=0;i<t.length;i++)t[i]&&n.push(t[i]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,i){const r=[];let s;for(;t;)r.push(t),s=t.previousComponent,delete t.previousComponent,t=s;r.reverse();const o=r.length;let a=0,l=0,h=0;for(;a<o;a++){const d=r[a];if(d.removed)d.value=this.join(i.slice(h,h+d.count)),h+=d.count;else{if(!d.added&&this.useLongestToken){let c=n.slice(l,l+d.count);c=c.map(function(u,f){const p=i[h+f];return p.length>u.length?p:u}),d.value=this.join(c)}else d.value=this.join(n.slice(l,l+d.count));l+=d.count,d.added||(h+=d.count)}}return r}}class kl extends zi{}const wl=new kl;function El(e,t,n){return wl.diff(e,t,n)}const ir="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}";class Tl extends zi{tokenize(t){const n=new RegExp(`(\\r?\\n)|[${ir}]+|[^\\S\\n\\r]+|[^${ir}]`,"ug");return t.match(n)||[]}}const Al=new Tl;function Rl(e,t,n){return Al.diff(e,t,n)}class Il extends zi{constructor(){super(...arguments),this.tokenize=Hl}equals(t,n,i){return i.ignoreWhitespace?((!i.newlineIsToken||!t.includes(`
6
+ `))&&(t=t.trim()),(!i.newlineIsToken||!n.includes(`
7
+ `))&&(n=n.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(t.endsWith(`
8
+ `)&&(t=t.slice(0,-1)),n.endsWith(`
9
+ `)&&(n=n.slice(0,-1))),super.equals(t,n,i)}}const Ml=new Il;function rr(e,t,n){return Ml.diff(e,t,n)}function Hl(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
10
+ `));const n=[],i=e.split(/(\n|\r\n)/);i[i.length-1]||i.pop();for(let r=0;r<i.length;r++){const s=i[r];r%2&&!t.newlineIsToken?n[n.length-1]+=s:n.push(s)}return n}function Pl(e){for(let t=0;t<e.length;t++)if(e[t]<" "||e[t]>"~"||e[t]==='"'||e[t]==="\\")return!0;return!1}function Ue(e){if(!Pl(e))return e;let t='"';const n=new TextEncoder().encode(e);let i=0;for(;i<n.length;){const r=n[i];r===7?t+="\\a":r===8?t+="\\b":r===9?t+="\\t":r===10?t+="\\n":r===11?t+="\\v":r===12?t+="\\f":r===13?t+="\\r":r===34?t+='\\"':r===92?t+="\\\\":r>=32&&r<=126?t+=String.fromCharCode(r):t+="\\"+r.toString(8).padStart(3,"0"),i++}return t+='"',t}const sr={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function or(e,t,n,i,r,s,o){let a;o?typeof o=="function"?a={callback:o}:a=o:a={},typeof a.context>"u"&&(a.context=4);const l=a.context;if(a.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(a.callback){const{callback:d}=a;rr(n,i,Object.assign(Object.assign({},a),{callback:c=>{const u=h(c);d(u)}}))}else return h(rr(n,i,a));function h(d){if(!d)return;d.push({value:"",lines:[]});function c(S){return S.map(function(C){return" "+C})}const u=[];let f=0,p=0,g=[],m=1,v=1;for(let S=0;S<d.length;S++){const C=d[S],b=C.lines||Dl(C.value);if(C.lines=b,C.added||C.removed){if(!f){const y=d[S-1];f=m,p=v,y&&(g=l>0?c(y.lines.slice(-l)):[],f-=g.length,p-=g.length)}for(const y of b)g.push((C.added?"+":"-")+y);C.added?v+=b.length:m+=b.length}else{if(f)if(b.length<=l*2&&S<d.length-2)for(const y of c(b))g.push(y);else{const y=Math.min(b.length,l);for(const k of c(b.slice(0,y)))g.push(k);const L={oldStart:f,oldLines:m-f+y,newStart:p,newLines:v-p+y,lines:g};u.push(L),f=0,p=0,g=[]}m+=b.length,v+=b.length}}for(const S of u)for(let C=0;C<S.lines.length;C++)S.lines[C].endsWith(`
11
+ `)?S.lines[C]=S.lines[C].slice(0,-1):(S.lines.splice(C+1,0,"\"),C++);return{oldFileName:e,newFileName:t,oldHeader:r,newHeader:s,hunks:u}}}function oi(e,t){var n,i,r,s,o,a;if(t||(t=sr),Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders&&!e.every(d=>d.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?)");return e.map(d=>oi(d,t)).join(`
12
+ `)}const l=[];if(e.isGit){if(t=sr,!e.oldFileName)throw new Error("oldFileName must be specified for Git patches");if(!e.newFileName)throw new Error("newFileName must be specified for Git patches");let d=e.oldFileName,c=e.newFileName;e.isCreate&&d==="/dev/null"?d=c.replace(/^b\//,"a/"):e.isDelete&&c==="/dev/null"&&(c=d.replace(/^a\//,"b/")),l.push("diff --git "+Ue(d)+" "+Ue(c)),e.isDelete&&l.push("deleted file mode "+((n=e.oldMode)!==null&&n!==void 0?n:"100644")),e.isCreate&&l.push("new file mode "+((i=e.newMode)!==null&&i!==void 0?i:"100644")),e.oldMode&&e.newMode&&!e.isDelete&&!e.isCreate&&(l.push("old mode "+e.oldMode),l.push("new mode "+e.newMode)),e.isRename&&(l.push("rename from "+Ue(((r=e.oldFileName)!==null&&r!==void 0?r:"").replace(/^a\//,""))),l.push("rename to "+Ue(((s=e.newFileName)!==null&&s!==void 0?s:"").replace(/^b\//,"")))),e.isCopy&&(l.push("copy from "+Ue(((o=e.oldFileName)!==null&&o!==void 0?o:"").replace(/^a\//,""))),l.push("copy to "+Ue(((a=e.newFileName)!==null&&a!==void 0?a:"").replace(/^b\//,""))))}else t.includeIndex&&e.oldFileName==e.newFileName&&e.oldFileName!==void 0&&l.push("Index: "+e.oldFileName),t.includeUnderline&&l.push("===================================================================");const h=e.hunks.length>0;t.includeFileHeaders&&e.oldFileName!==void 0&&e.newFileName!==void 0&&(!e.isGit||h)&&(l.push("--- "+Ue(e.oldFileName)+(e.oldHeader?" "+e.oldHeader:"")),l.push("+++ "+Ue(e.newFileName)+(e.newHeader?" "+e.newHeader:"")));for(let d=0;d<e.hunks.length;d++){const c=e.hunks[d],u=c.oldLines===0?c.oldStart-1:c.oldStart,f=c.newLines===0?c.newStart-1:c.newStart;l.push("@@ -"+u+","+c.oldLines+" +"+f+","+c.newLines+" @@");for(const p of c.lines)l.push(p)}return l.join(`
13
+ `)+`
14
+ `}function Ol(e,t,n,i,r,s,o){if(typeof o=="function"&&(o={callback:o}),o?.callback){const{callback:a}=o;or(e,t,n,i,r,s,Object.assign(Object.assign({},o),{callback:l=>{a(l?oi(l,o.headerOptions):void 0)}}))}else{const a=or(e,t,n,i,r,s,o);return a?oi(a,o?.headerOptions):void 0}}function Dl(e){const t=e.endsWith(`
15
+ `),n=e.split(`
16
+ `).map(i=>i+`
17
+ `);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function ar({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":""},alwaysWrap:!0}}function Bt({item:e,arr:t,enableJoin:n,isNeutral:i=!1,isLastItem:r=!1}){const s=t[t.length-1];if(s==null||r||!n){t.push([i?0:1,e.value]);return}const o=s[0]===0;if(i===o||i&&e.value.length===1&&!o){s[1]+=e.value;return}t.push([i?0:1,e.value])}const _l={forcePlainText:!1};function Fl(e,t,n,{forcePlainText:i,startingLine:r,totalLines:s,expandedHunks:o,collapsedContextThreshold:a=1}=_l){i?(r??=0,s??=1/0):(r=0,s=1/0);const l=r>0||s<1/0,h=typeof n.theme=="string"?t.getTheme(n.theme).type:void 0,d=Os({theme:n.theme,highlighter:t}),c=i&&!l&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?"none":n.lineDiffType,u={deletionLines:[],additionLines:[]},{maxLineDiffLength:f}=n,p=!i&&!e.isPartial,g=i?o:void 0,m=new Map;function v(C){const b=p?0:C,y=m.get(b)??zl();return m.set(b,y),y}function S(C,b,y,L){if(l){let k=y.at(-1);(k==null||k.targetIndex+k.count!==b)&&(k={targetIndex:b,originalOffset:L.length,count:0},y.push(k)),k.count++}L.push(C)}Xe({diff:e,diffStyle:"both",startingLine:r,totalLines:s,expandedHunks:l?g:!0,collapsedContextThreshold:a,callback:({hunkIndex:C,additionLine:b,deletionLine:y,type:L})=>{const k=v(C),E=b!=null?b.splitLineIndex:y.splitLineIndex;L==="change"&&b!=null&&y!=null&&Nl({additionLine:e.additionLines[b.lineIndex],deletionLine:e.deletionLines[y.lineIndex],deletionLineIndex:k.deletionContent.length,additionLineIndex:k.additionContent.length,deletionDecorations:k.deletionDecorations,additionDecorations:k.additionDecorations,lineDiffType:c,maxLineDiffLength:f}),y!=null&&(S(e.deletionLines[y.lineIndex],y.lineIndex,k.deletionSegments,k.deletionContent),k.deletionInfo.push({type:L==="change"?"change-deletion":L,lineNumber:y.lineNumber,altLineNumber:L==="change"?void 0:b.lineNumber??void 0,lineIndex:`${y.unifiedLineIndex},${E}`})),b!=null&&(S(e.additionLines[b.lineIndex],b.lineIndex,k.additionSegments,k.additionContent),k.additionInfo.push({type:L==="change"?"change-addition":L,lineNumber:b.lineNumber,altLineNumber:L==="change"?void 0:y.lineNumber??void 0,lineIndex:`${b.unifiedLineIndex},${E}`}))}});for(const C of m.values()){if(C.deletionContent.length===0&&C.additionContent.length===0)continue;const b={name:e.prevName??e.name,contents:C.deletionContent.value},y={name:e.name,contents:C.additionContent.value},{deletionLines:L,additionLines:k}=Bl({deletionFile:b,deletionInfo:C.deletionInfo,deletionDecorations:C.deletionDecorations,additionFile:y,additionInfo:C.additionInfo,additionDecorations:C.additionDecorations,highlighter:t,options:n,languageOverride:i?"text":e.lang});if(p){u.deletionLines=L,u.additionLines=k;continue}if(C.deletionSegments.length>0)for(const E of C.deletionSegments)for(let x=0;x<E.count;x++)u.deletionLines[E.targetIndex+x]=L[E.originalOffset+x];else u.deletionLines.push(...L);if(C.additionSegments.length>0)for(const E of C.additionSegments)for(let x=0;x<E.count;x++)u.additionLines[E.targetIndex+x]=k[E.originalOffset+x];else u.additionLines.push(...k)}return{code:u,themeStyles:d,baseThemeType:h}}function Nl({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:i,deletionDecorations:r,additionDecorations:s,lineDiffType:o,maxLineDiffLength:a}){if(e==null||t==null||o==="none"||(e=Fe(e),t=Fe(t),e.length>a||t.length>a))return;const l=o==="char"?El(e,t):Rl(e,t),h=[],d=[],c=o==="word-alt",u=l.at(-1);for(const p of l){const g=p===u;!p.added&&!p.removed?(Bt({item:p,arr:h,enableJoin:c,isNeutral:!0,isLastItem:g}),Bt({item:p,arr:d,enableJoin:c,isNeutral:!0,isLastItem:g})):p.removed?Bt({item:p,arr:h,enableJoin:c,isLastItem:g}):Bt({item:p,arr:d,enableJoin:c,isLastItem:g})}let f=0;for(const p of h)p[0]===1&&r.push(ar({line:n,spanStart:f,spanLength:p[1].length})),f+=p[1].length;f=0;for(const p of d)p[0]===1&&s.push(ar({line:i,spanStart:f,spanLength:p[1].length})),f+=p[1].length}function zl(){return{deletionContent:{push(e){this.value+=e,this.length++},value:"",length:0},additionContent:{push(e){this.value+=e,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function Bl({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:i,highlighter:r,deletionDecorations:s,additionDecorations:o,languageOverride:a,options:{theme:l=J,...h}}){const d=a??he(e.name),c=a??he(t.name),{state:u,transformers:f}=Hs(h.useTokenTransformer),p=typeof l=="string"?{...h,lang:"text",theme:l,transformers:f,decorations:void 0,defaultColor:!1,cssVariablePrefix:me("token"),tokenizeTimeLimit:0}:{...h,lang:"text",themes:l,transformers:f,decorations:void 0,defaultColor:!1,cssVariablePrefix:me("token"),tokenizeTimeLimit:0};return{deletionLines:e.contents===""?[]:(p.lang=d,u.lineInfo=n,p.decorations=s,si(r.codeToHast(Fe(e.contents),p))),additionLines:t.contents===""?[]:(p.lang=c,p.decorations=o,u.lineInfo=i,si(r.codeToHast(Fe(t.contents),p)))}}const Vl=Y.createContext(void 0);function zs(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:Ul(e.items,t.items)}function Ul(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const i=e[n],r=t[n];if(i==null||r==null||i.id!==r.id||i.type!==r.type||i.element!==r.element||i.instance!==r.instance||i.version!==r.version)return!1}return!0}function ft(e,t,n){if(e===t||e==null||t==null)return e===t;const i=new Set(n),r=Object.keys(e),s=new Set(Object.keys(t));for(const o of r)if(s.delete(o),!i.has(o)&&(!(o in t)||e[o]!==t[o]))return!1;for(const o of Array.from(s))if(!i.has(o))return!1;return!0}function Tn(e,t){const n=e?.theme??J,i=t?.theme??J,r=lr(e),s=lr(t);return mt(n,i)&&ft(e,t,["theme","parseDiffOptions"])&&ft(r,s)}function lr(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}const ht=new Set;let ct=null;function Ye(e){ht.add(e),ct??=requestAnimationFrame(Bs)}function Ze(e){ht.delete(e)&&ht.size===0&&ct!=null&&(cancelAnimationFrame(ct),ct=null)}function Bs(e){const t=new Set(ht);ht.clear();for(const n of t)try{n(e)}catch(i){console.error(i)}ht.size>0?ct=requestAnimationFrame(Bs):ct=null}function mn(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function Wl(e,t,n){const i=document.createElement("div");return i.style.display="flow-root",e==="header"?(i.setAttribute(ra,""),t.before(i)):(i.setAttribute(sa,""),t.after(i)),n?.observe(i),i}function $l({scrollTop:e,scrollHeight:t,height:n,fitPerfectly:i=!1,fitPerfectlyOverscroll:r=0,overscrollSize:s}){const o=n+s*2,a=i?n+r*2:o;if(t=Math.max(t,a),o>=t||i){const d=Math.max(e-r,0),c=Math.min(e+a,t);return{top:d,bottom:Math.max(c,d)}}let l=e+n/2-o/2,h=l+o;return l<0&&(l=0),h>t&&(h=t),l=Math.floor(Math.max(l,0)),{top:l,bottom:Math.ceil(Math.max(Math.min(h,t),l))}}const Gl=new TextEncoder,jl=new TextDecoder("utf-8",{ignoreBOM:!0}),Kl=/[\uD800-\uDFFF]/,ai=1024;let ot=new Uint8Array(ai);function ql(){ot.length!==ai&&(ot=new Uint8Array(ai))}function se(e){if(e.length===0)return e;if(Kl.test(e))return JSON.parse(JSON.stringify(e));const t=e.length*3;ot.length<t&&(ot=new Uint8Array(t));const{written:n}=Gl.encodeInto(e,ot);return jl.decode(ot.subarray(0,n))}const Yl=4096,Xl=.5;function Zl(e){for(const t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){const i=t.hunkContent[n];if(i.type!=="change")continue;const r=Ql(e,i);r!=null&&(t.hunkContent.splice(n,1,...r),n+=r.length-1)}Jl(t,e)}}function Jl(e,t){const{hunkContent:n}=e;for(let i=1;i<n.length;i++){const r=n[i],s=n[i-1];if(r.type!=="change"||r.additions>0&&r.deletions>0||s.type!=="context")continue;const o=r.additions>0,a=o?t.additionLines:t.deletionLines,l=o?r.additionLineIndex:r.deletionLineIndex,h=o?r.additions:r.deletions,d=a[l]??"";if(d.trim()!=="")continue;let c=!0;for(let m=1;m<h;m++)if(a[l+m]!==d){c=!1;break}if(!c)continue;let u=0;for(;u<s.lines&&t.additionLines[s.additionLineIndex+s.lines-1-u]===d;)u++;if(u===0||i===1&&u===s.lines)continue;r.additionLineIndex-=u,r.deletionLineIndex-=u;const f=r.additionLineIndex+r.additions,p=r.deletionLineIndex+r.deletions,g=n[i+1];g?.type==="context"?(g.lines+=u,g.additionLineIndex=f,g.deletionLineIndex=p):n.splice(i+1,0,{type:"context",lines:u,additionLineIndex:f,deletionLineIndex:p}),s.lines-=u,s.lines===0&&(n.splice(i-1,1),i--)}}function Ql(e,t){const{deletions:n,additions:i,deletionLineIndex:r,additionLineIndex:s}=t,o=Math.min(n,i),a=Math.abs(i-n);if(o===0||a===0||o*(a+1)>Yl)return null;const l=[];for(let g=0;g<n;g++)l.push(dr(e.deletionLines[r+g]??""));const h=[];for(let g=0;g<i;g++)h.push(dr(e.additionLines[s+g]??""));const d=i>n;let c=0,u=-1;for(let g=0;g<=a;g++){let m=0;for(let v=0;v<o;v++)m+=td(l[v+(d?0:g)],h[v+(d?g:0)]);g===0?u=m+o*Xl:m>u&&(u=m,c=g)}if(c===0)return null;const f=[],p=(g,m,v,S)=>{(g>0||m>0)&&f.push({type:"change",deletions:g,additions:m,deletionLineIndex:v,additionLineIndex:S})};return d?(p(0,c,r,s),p(o,o,r,s+c),p(0,i-o-c,r+o,s+c+o)):(p(c,0,r,s),p(o,o,r+c,s),p(n-o-c,0,r+c+o,s+o)),f}const ed=/\s+/g;function dr(e){return e.replace(ed,"")}function td(e,t){if(e===t)return 1;const n=Math.max(e.length,t.length),i=Math.min(e.length,t.length);if(i===0)return 0;let r=0;for(;r<i&&e[r]===t[r];)r++;let s=0;for(;s<i-r&&e[e.length-1-s]===t[t.length-1-s];)s++;return(r+s)/n}function nd(e,t){try{return id(e,t)}finally{ql()}}function id(e,{cacheKey:t,isGitDiff:n=Yo.test(e),oldFile:i,newFile:r,throwOnError:s=!1}={}){let o=0;const a=ld(e,"@@ ");let l;const h=i==null||r==null;let d=0,c=0;for(const u of a){const f=Vs(u),p=f[0];if(p==null){if(s)throw Error("parsePatchContent: invalid hunk");console.error("parsePatchContent: invalid hunk",u);continue}const g=od(p);let m=0,v=0;if(g==null||l==null){if(l!=null){if(s)throw Error("parsePatchContent: Invalid hunk");console.error("parsePatchContent: Invalid hunk",u);continue}l={name:"",type:"change",hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:h,additionLines:!h&&i!=null&&r!=null?hr(r.contents):[],deletionLines:!h&&i!=null&&r!=null?hr(i.contents):[],cacheKey:ur(t)},l.additionLines.length===1&&r?.contents===""&&(l.additionLines.length=0),l.deletionLines.length===1&&i?.contents===""&&(l.deletionLines.length=0);for(const x of f){if(x.startsWith("diff --git")){const O=x.trim().match(Qo),T=O?.[1]??O?.[2],R=O?.[3]??O?.[4];if(T==null||R==null){if(s)throw Error("parsePatchContent: invalid git diff header");console.error("parsePatchContent: invalid git diff header",x);continue}l.name=se(R.trim()),T!==R&&(l.prevName=se(T.trim()));continue}const w=x.startsWith("---")||x.startsWith("+++")?x.match(n?Jo:Zo):null;if(w!=null){const[,O,T]=w;if(O==="---"&&T!=="/dev/null"){const R=se(T.trim());l.prevName=R,l.name=R}else O==="+++"&&T!=="/dev/null"&&(l.name=se(T.trim()))}else if(n){if(x.startsWith("new mode ")&&(l.mode=se(x.slice(8).trim())),x.startsWith("old mode ")&&(l.prevMode=se(x.slice(8).trim())),x.startsWith("new file mode")&&(l.type="new",l.mode=se(x.slice(13).trim())),x.startsWith("deleted file mode")&&(l.type="deleted",l.mode=se(x.slice(17).trim())),x.startsWith("similarity index")&&(x.startsWith("similarity index 100%")?l.type="rename-pure":l.type="rename-changed"),x.startsWith("index ")){const[,O,T,R]=x.trim().match(ea)??[];O!=null&&(l.prevObjectId=se(O)),T!=null&&(l.newObjectId=se(T)),R!=null&&(l.mode=se(R))}x.startsWith("rename from ")&&(l.prevName=se(x.slice(12).trim())),x.startsWith("rename to ")&&(l.name=se(x.slice(10).trim()))}}continue}let S,C;for(;f.length>0&&(f[f.length-1]===`
18
+ `||f[f.length-1]==="\r"||f[f.length-1]===`\r
19
+ `||f[f.length-1]==="");)f.pop();const{additionStart:b,deletionStart:y}=g;d=h?d:y-1,c=h?c:b-1;const L={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:g.additionCount,additionStart:b,additionLines:m,deletionCount:g.deletionCount,deletionStart:y,deletionLines:v,deletionLineIndex:d,additionLineIndex:c,hunkContent:[],hunkContext:ur(g.hunkContext),hunkSpecs:se(p),noEOFCRAdditions:!1,noEOFCRDeletions:!1};let k=0,E=0;for(let x=1;x<f.length;x++){const w=f[x];if(k>=L.additionCount&&E>=L.deletionCount&&!w.startsWith("\\")){if(s&&rd(w)&&!sd(w))throw Error("parsePatchContent: hunk has more lines than expected");break}const O=w[0];if(O!=="+"&&O!=="-"&&O!==" "&&O!=="\\"){if(s)throw Error("parsePatchContent: invalid hunk line");console.error(`parseLineType: Invalid firstChar: "${O}", full line: "${w}"`),console.error("processFile: invalid rawLine:",w);continue}const T=dd(O);if(T==="addition"){if(s&&k>=L.additionCount)throw Error("parsePatchContent: hunk has too many addition lines");const R=Fn(w);(S==null||S.type!=="change")&&(S=Nn("change",d,c),L.hunkContent.push(S)),c++,k++,h&&l.additionLines.push(R),S.additions++,m++,C="addition"}else if(T==="deletion"){if(s&&E>=L.deletionCount)throw Error("parsePatchContent: hunk has too many deletion lines");const R=Fn(w);(S==null||S.type!=="change")&&(S=Nn("change",d,c),L.hunkContent.push(S)),d++,E++,h&&l.deletionLines.push(R),S.deletions++,v++,C="deletion"}else if(T==="context"){if(s&&(E>=L.deletionCount||k>=L.additionCount))throw Error("parsePatchContent: hunk has too many context lines");const R=Fn(w);(S==null||S.type!=="context")&&(S=Nn("context",d,c),L.hunkContent.push(S)),c++,d++,k++,E++,h&&(l.deletionLines.push(R),l.additionLines.push(R)),S.lines++,C="context"}else if(T==="metadata"&&S!=null){if(S.type==="context"?(L.noEOFCRAdditions=!0,L.noEOFCRDeletions=!0):C==="deletion"?L.noEOFCRDeletions=!0:C==="addition"&&(L.noEOFCRAdditions=!0),h&&(C==="addition"||C==="context")){const R=l.additionLines.length-1;R>=0&&(l.additionLines[R]=Fe(l.additionLines[R]))}if(h&&(C==="deletion"||C==="context")){const R=l.deletionLines.length-1;R>=0&&(l.deletionLines[R]=Fe(l.deletionLines[R]))}}}if(s&&(k!==L.additionCount||E!==L.deletionCount))throw Error("parsePatchContent: hunk line count mismatch");L.additionLines=m,L.deletionLines=v,L.collapsedBefore=Math.max(Ae(L.additionStart,L.additionCount)-o,0),l.hunks.push(L),o=pe(L.additionStart,L.additionCount);for(const x of L.hunkContent)x.type==="context"?(L.splitLineCount+=x.lines,L.unifiedLineCount+=x.lines):(L.splitLineCount+=Math.max(x.additions,x.deletions),L.unifiedLineCount+=x.deletions+x.additions);L.splitLineStart=l.splitLineCount+L.collapsedBefore,L.unifiedLineStart=l.unifiedLineCount+L.collapsedBefore,l.splitLineCount+=L.collapsedBefore+L.splitLineCount,l.unifiedLineCount+=L.collapsedBefore+L.unifiedLineCount}if(l!=null){if(s&&h&&!n&&l.hunks.length===0)throw Error("parsePatchContent: unified file has no hunks");if(l.hunks.length>0&&!h&&l.additionLines.length>0&&l.deletionLines.length>0){const u=l.hunks[l.hunks.length-1],f=pe(u.additionStart,u.additionCount),p=l.additionLines.length,g=Math.max(p-f,0);l.splitLineCount+=g,l.unifiedLineCount+=g}return n||(l.prevName!=null&&l.name!==l.prevName?l.hunks.length>0?l.type="rename-changed":l.type="rename-pure":(i==null||i.contents==="")&&r!=null&&r.contents!==""?l.type="new":i!=null&&i.contents!==""&&(r==null||r.contents==="")&&(l.type="deleted")),l.type!=="rename-pure"&&l.type!=="rename-changed"&&(l.prevName=void 0),Zl(l),l}}function hr(e){const t=Vs(e);for(let n=0;n<t.length;n++)t[n]=se(t[n]);return t}function Vs(e){if(e.length===0)return[""];const t=[];let n=0;for(;;){const i=e.indexOf(`
20
+ `,n);if(i===-1)break;t.push(e.slice(n,i+1)),n=i+1}return n<e.length&&t.push(e.slice(n)),t}function rd(e){const t=e[0];return t==="+"||t==="-"||t===" "}function sd(e){if(!e.startsWith("--"))return!1;for(let t=2;t<e.length;t++){const n=e[t];if(n!==" "&&n!==" "&&n!==`
21
+ `&&n!=="\r")return!1}return!0}function od(e){if(!e.startsWith("@@ -"))return;let t=4;const n=Vt(e,t);if(n==null)return;const i=n.value;t=n.endIndex;let r=1;if(e[t]===","){const d=Vt(e,t+1);if(d==null)return;r=d.value,t=d.endIndex}if(e[t]!==" "||e[t+1]!=="+")return;t+=2;const s=Vt(e,t);if(s==null)return;const o=s.value;t=s.endIndex;let a=1;if(e[t]===","){const d=Vt(e,t+1);if(d==null)return;a=d.value,t=d.endIndex}if(e[t]!==" "||e[t+1]!=="@"||e[t+2]!=="@")return;let l;const h=t+3;return e[h]===" "&&(l=ad(e.slice(h+1))),{additionCount:a,additionStart:o,deletionCount:r,deletionStart:i,hunkContext:l}}function Vt(e,t){let n=t,i=0;for(;n<e.length;n++){const r=e.charCodeAt(n)-48;if(r<0||r>9)break;i=i*10+r}if(n!==t)return{value:i,endIndex:n}}function ad(e){return e.endsWith(`\r
22
+ `)?e.slice(0,-2):e.endsWith(`
23
+ `)?e.slice(0,-1):e}function ld(e,t){if(e.length===0)return[""];const n=`
24
+ ${t}`,i=e.startsWith(t)?0:cr(e,n,0);if(i===-1)return[e];const r=[];i>0&&r.push(e.slice(0,i));let s=i;for(;;){const o=cr(e,n,s+1);if(o===-1)break;r.push(e.slice(s,o)),s=o}return r.push(e.slice(s)),r}function cr(e,t,n){const i=e.indexOf(t,n);return i===-1?-1:i+1}function ur(e){return e==null?e:se(e)}function dd(e){return e===" "?"context":e==="\\"?"metadata":e==="+"?"addition":"deletion"}function Fn(e){const t=e.slice(1);return se(t===""?`
25
+ `:t)}function Nn(e,t,n){return e==="change"?{type:"change",additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:"context",lines:0,additionLineIndex:n,deletionLineIndex:t}}const hd="/dev/null";function Je(e,t,n,i=!1){if(e===null&&t===null)throw new Error("parseDiffFromFile: You must pass oldFile, newFile, or both");const r=e??fr(),s=t??fr(),o=nd(Ol(r.name,s.name,r.contents,s.contents,r.header,s.header,n),{cacheKey:(()=>{const l=e?.cacheKey??e?.name,h=t?.cacheKey??t?.name;return l!=null&&h!=null?l+":"+h:l??h})(),oldFile:r,newFile:s,throwOnError:i});if(o==null)throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");e===null?(o.type="new",o.prevName=void 0):t===null&&(o.type="deleted",o.prevName=void 0);const a=t?.lang??(t===null?e?.lang:void 0);return a!=null&&(o.lang=a),o}function fr(){return{name:hd,contents:""}}function Oe(e,t){const n=Je({name:e.prevName??e.name,contents:e.deletionLines.join("")},{name:e.name,contents:e.additionLines.join(""),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,type:n.type}}function cd(e,t){const n=Math.max(e,1);let i=Array.from({length:n},(r,s)=>`${" ".repeat(s+1)}
26
+ `).join("");return i===t&&(i=Array.from({length:n},(r,s)=>`\0${" ".repeat(s)}
27
+ `).join("")),i}function ud(e){for(const t of e)if(t.trim().length>0)return!1;return!0}function li(e,t){return t.length>0&&t.length<e.deletionLines.length&&ud(t)}function vn(e,t,n){const i=e.deletionLines.join(""),r=cd(t.length,i),s=Je({name:e.prevName??e.name,contents:i},{name:e.name,contents:r,lang:e.lang},n);return{hunks:s.hunks,splitLineCount:s.splitLineCount,unifiedLineCount:s.unifiedLineCount,additionLines:t,deletionLines:s.deletionLines,type:s.type}}function an(e,t){return vn(e,[""],t)}function Us(e,t){if(e.additionLines.length===0)return an(e,t);if(li(e,e.additionLines))return vn(e,e.additionLines,t);const n=e.additionLines,i=Oe(e,t);return Ws(i,n),i}function fd(e){return e.length>1&&e.at(-1)===""}function Ws(e,t){if(!fd(t))return;const n=t.length-e.additionLines.length;if(n<=0)return;const i=e.additionLines.length,r=e.hunks.at(-1);if(r!=null&&pe(r.additionStart,r.additionCount)===i){for(const s of r.hunkContent)if(s.type==="change"&&s.additions<s.deletions&&s.additionLineIndex+s.additions===i){e.additionLines=t,s.additions+=n,r.additionCount+=n,r.additionLines+=n,Vi(e);return}}}function pd(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return Re(e,Oe(e,n));const i=Array.from(t);if(i.length===0)return Re(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(const s of i){const o=e.additionLines[s],a=e.deletionLines[s];if(o==null||a==null||Fe(o)===Fe(a))return Re(e,Oe(e,n))}const r=gd(e,i);if(r.size===0)return Re(e,Oe(e,n));for(const s of r)if(!vd(e,s,n))return Re(e,Oe(e,n));return Vi(e),gl(e)?Re(e,Oe(e,n)):Re(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function Re(e,t){return Object.assign(e,t),t}function gd(e,t){const n=new Set;for(const i of t){const r=md(e,i);if(r==null)return new Set;n.add(r)}return n}function md(e,t){for(const[n,i]of e.hunks.entries()){const r=i.additionLineIndex+i.additionCount;if(t>=i.additionLineIndex&&t<r)return n}}function vd(e,t,n){const i=e.hunks[t];if(i==null)return!1;const r=e.deletionLines.slice(i.deletionLineIndex,i.deletionLineIndex+i.deletionCount),s=e.additionLines.slice(i.additionLineIndex,i.additionLineIndex+i.additionCount),o=Je({name:e.prevName??e.name,contents:r.join("")},{name:e.name,contents:s.join(""),lang:e.lang},{...n,context:0}),a=o.hunks[0];return a==null||o.hunks.length!==1?!1:(Sd(i,a),$s(e,t),!0)}function $s(e,t){const n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}const i=e.additionLines.at(-1),r=e.deletionLines.at(-1);n.noEOFCRAdditions=i!=null&&i!==""&&!i.endsWith(`
28
+ `),n.noEOFCRDeletions=r!=null&&r!==""&&!r.endsWith(`
29
+ `)}function Sd(e,t){const n=e.additionLineIndex,i=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(r=>Gs(r,n,i)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart=e.additionStart+t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=i+t.deletionLineIndex,e.deletionStart=e.deletionStart+t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,Bi(e)}function Gs(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function Bi(e){let t=0,n=0;for(const i of e.hunkContent)i.type==="context"?(t+=i.lines,n+=i.lines):(t+=Math.max(i.additions,i.deletions),n+=i.additions+i.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function Vi(e){let t=0,n=0,i=0;for(const r of e.hunks)r.collapsedBefore=Math.max(Ae(r.additionStart,r.additionCount)-i,0),r.splitLineStart=t+r.collapsedBefore,r.unifiedLineStart=n+r.collapsedBefore,Bi(r),t+=r.collapsedBefore+r.splitLineCount,n+=r.collapsedBefore+r.unifiedLineCount,i=pe(r.additionStart,r.additionCount);if(e.hunks.length>0){const r=e.hunks[e.hunks.length-1],s=Math.max(e.additionLines.length-pe(r.additionStart,r.additionCount),0);t+=s,n+=s}e.splitLineCount=t,e.unifiedLineCount=n}const pr=new WeakMap;function bd(e){return e.length>1&&e[e.length-1]===""?e.slice(0,-1):e}function Cd(e,t){const n=Math.min(e.length,t.length);let i=0;for(;i<n&&e[i]===t[i];)i++;let r=e.length,s=t.length;for(;r>i&&s>i&&e[r-1]===t[s-1];)r--,s--;if(!(i===r&&i===s))return{start:i,deletionEnd:r,additionEnd:s}}function di(e,t){const n=e.hunks,i=e.additionLines,r=bd(i),s=r===i?e:{...e,additionLines:r},o=Rd(n,Ad(s,t),e.deletionLines.length),a=Hd(s,o);if(e.additionLines=r,e.hunks=a,e.editSessionDirty=!0,_d(e),Ws(e,i),!!Od(n,e.hunks))return{regions:o.map(l=>l.previousSpan)}}function yd(e,t,n,i){const r=Array.from(new Set(t)).filter(l=>l>=0&&l<e.additionLines.length).sort((l,h)=>l-h);if(r.length===0)return;const{hunks:s}=e;let o,a=0;for(const l of r){for(;a<s.length;){const c=s[a];if(l<Sn(c)+c.additionCount)break;a++}const h=s[a],d=h==null?void 0:Sn(h);if(d==null||l<d||o!=null&&o!==a)return di(e,n);o=a}if(o!=null){if(Ld(e,r,o,i,n)){e.editSessionDirty=!0;return}return di(e,n)}}function Ld(e,t,n,i,r){if(i==null||r?.ignoreWhitespace===!0||r?.stripTrailingCr===!0)return!1;const s=xd(e),o=e.hunks[n];if(o.hunkContent.some(kd))return!1;for(const a of t){const l=i.get(a),h=e.additionLines[a];if(l==null||h==null||s.has(l)||s.has(h))return!1;let d=!1;for(const c of o.hunkContent)if(c.type==="change"&&c.additions===c.deletions&&a>=c.additionLineIndex&&a<c.additionLineIndex+c.additions){d=!0;break}if(!d)return!1}return!0}function xd(e){const t=pr.get(e);if(t?.lines===e.deletionLines)return t.set;const n=new Set(e.deletionLines);return pr.set(e,{lines:e.deletionLines,set:n}),n}function kd(e){return e?.type==="change"&&(e.additions===0||e.deletions===0)}function wd(e,t){const n=new Map,{regions:i}=t;for(let r=0;r<=i.length;r++){const s=i[r-1],o=i[r],a=r===0?e.get(0):s==null?void 0:e.get(s.lastIndex+1),l=o==null?void 0:e.get(o.firstIndex),h=a?.fromStart??0,d=l?.fromEnd??0;(h>0||d>0)&&n.set(r,{fromStart:h,fromEnd:d})}return n}function Ed(e,t,n){const i=[];if(e.isPartial)return i;for(const[s,o]of e.hunks.entries()){const a=Ne({isPartial:e.isPartial,rangeSize:o.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n});if(a.rangeSize<=n)continue;const l=Qe(o),h=l-a.rangeSize;a.fromStart>0&&i.push([h,h+a.fromStart]),a.fromEnd>0&&i.push([l-a.fromEnd,l])}const r=ze({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:"captureExpansionAnchors"});if(r!=null&&r.fromStart>0&&r.rangeSize>n){const s=e.hunks[e.hunks.length-1],o=Qe(s)+s.deletionCount;i.push([o,o+r.fromStart])}return i}function Td(e,t){const n=new Map;if(t.length===0)return n;const i=(s,o,a)=>{if(a<=o)return;let l=0,h=0;for(const[d,c]of t)c<=o||d>=a||(d<=o&&(l=Math.max(l,Math.min(c,a)-o)),c>=a&&(h=Math.max(h,a-Math.max(d,o))));(l>0||h>0)&&n.set(s,{fromStart:l,fromEnd:h})};for(const[s,o]of e.hunks.entries()){const a=Qe(o);i(s,a-Math.max(o.collapsedBefore,0),a)}const r=e.hunks[e.hunks.length-1];return r!=null&&!e.isPartial&&e.deletionLines.length>0&&i(e.hunks.length,Qe(r)+r.deletionCount,e.deletionLines.length),n}function hi(e,t){return e.editSessionDirty!==!0?!1:(e.editSessionDirty=void 0,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join("")===""?Oe(e,t):Us(e,t)),!0)}function Ad(e,t){if(Cd(e.deletionLines,e.additionLines)==null)return[];const n=Je({name:e.prevName??e.name,contents:e.deletionLines.join("")},{name:e.name,contents:e.additionLines.join(""),lang:e.lang},t),i=[];let r=0,s=0;for(const o of n.hunks){const a=o.additionCount>0?o.additionLineIndex-r:o.deletionLineIndex-s;r+=a,s+=a;for(const l of o.hunkContent){if(l.type==="context"){r+=l.lines,s+=l.lines;continue}const h=Gs(l,0,0);h.additions===0&&(h.additionLineIndex=r),h.deletions===0&&(h.deletionLineIndex=s),i.push(h),r+=h.additions,s+=h.deletions}}return i}function Rd(e,t,n){const i=e.map((o,a)=>{const l=Qe(o);return{deletionStart:l,deletionEnd:l+o.deletionCount,blocks:[],previousSpan:{firstIndex:a,lastIndex:a}}}),r=[];let s=0;for(const o of t){const a=o.deletionLineIndex,l=a+o.deletions;for(;s<i.length&&i[s].deletionEnd<a;)r.push(i[s]),s++;let h=r.length>0&&Id(a,l,r[r.length-1])?r.pop():void 0;for(;s<i.length&&i[s].deletionStart<=l;)h=Md(h,i[s]),s++;if(h==null){let d=a,c=l;if((o.deletions===0||o.additions===0)&&n>o.deletions){const u=r[r.length-1]?.deletionEnd??0,f=i[s]?.deletionStart??n;a>u?d--:l<f&&c++}h={deletionStart:d,deletionEnd:c,blocks:[],previousSpan:void 0}}h.deletionStart=Math.min(h.deletionStart,a),h.deletionEnd=Math.max(h.deletionEnd,l),h.blocks.push(o),r.push(h)}for(;s<i.length;)r.push(i[s]),s++;return r}function Id(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function Md(e,t){return e==null?t:(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null&&(e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex)),e)}function Hd(e,t){const n=[];let i=0,r=0;for(const s of t){const o=s.deletionStart-i;if(o<0)throw new Error("buildRegionHunks: overlapping old-side regions");i+=o,r+=o;const a=r,l=[];for(const d of s.blocks){const c=d.deletionLineIndex-i,u=d.additionLineIndex-r;if(c<0||c!==u)throw new Error("buildRegionHunks: canonical block context mismatch");gr(l,c,r,i),i+=c,r+=u,l.push({...d}),i+=d.deletions,r+=d.additions}const h=s.deletionEnd-i;if(h<0)throw new Error("buildRegionHunks: block exceeds its old-side region");gr(l,h,r,i),i+=h,r+=h,n.push(Pd(e,{additionStart:a,additionEnd:r,deletionStart:s.deletionStart,deletionEnd:s.deletionEnd},l))}if(e.deletionLines.length-i!==e.additionLines.length-r)throw new Error("buildRegionHunks: trailing context mismatch");return n}function Pd(e,t,n){const i=t.additionEnd-t.additionStart,r=t.deletionEnd-t.deletionStart;let s=0,o=0;for(const l of n)l.type==="change"&&(s+=l.additions,o+=l.deletions);const a={collapsedBefore:0,additionStart:Ut(t.additionStart,i),additionCount:i,additionLines:s,additionLineIndex:vr(t.additionStart,i),deletionStart:Ut(t.deletionStart,r),deletionCount:r,deletionLines:o,deletionLineIndex:vr(t.deletionStart,r),hunkContent:n,hunkSpecs:`@@ -${Ut(t.deletionStart,r)},${r} +${Ut(t.additionStart,i)},${i} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return Bi(a),a}function gr(e,t,n,i){t>0&&e.push({type:"context",lines:t,additionLineIndex:n,deletionLineIndex:i})}function Od(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){const i=e[n],r=t[n];if(Qe(i)!==Qe(r)||i.deletionCount!==r.deletionCount||Sn(i)!==Sn(r)||i.additionCount!==r.additionCount||i.splitLineCount!==r.splitLineCount||!Dd(i,r))return!0}return!1}function Dd(e,t){const n=mr(e),i=mr(t);for(;;){const r=n.next(),s=i.next();if(r.done===!0||s.done===!0)return r.done===s.done;if(r.value[0]!==s.value[0]||r.value[1]!==s.value[1])return!1}}function*mr(e){for(const t of e.hunkContent){if(t.type==="context"){for(let i=0;i<t.lines;i++)yield[t.deletionLineIndex+i,t.additionLineIndex+i];continue}const n=Math.max(t.deletions,t.additions);for(let i=0;i<n;i++)yield[i<t.deletions?t.deletionLineIndex+i:void 0,i<t.additions?t.additionLineIndex+i:void 0]}}function Sn(e){return Ae(e.additionStart,e.additionCount)}function Qe(e){return Ae(e.deletionStart,e.deletionCount)}function Ut(e,t){return t===0?e:e+1}function vr(e,t){return t===0?e-1:e}function _d(e){Vi(e);for(let t=0;t<e.hunks.length;t++)$s(e,t)}function Ht(e){if(typeof HTMLStyleElement<"u"&&e instanceof HTMLStyleElement)return!0;const t=e.tagName??e.nodeName;return typeof t=="string"&&t.toLowerCase()==="style"}function Fd(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function xe(e){const t=window.devicePixelRatio??1;return Math.round(e*t)/t}const js="-1,-1";function ci(e){return e?.some(t=>t.lineNumber===0)??!1}function ui(e){const t=e[0];return t!=null&&t.length>0?t:void 0}function An(e){return e.startingLine===0&&e.totalLines>0}function Nd(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function zd(){return F({tagName:"button",properties:{"data-utility-button":"",type:"button"},children:[pn({name:"diffs-icon-plus",properties:{"data-icon":""}})]})}function at(e){for(const t of e)if(t instanceof HTMLElement&&(t.hasAttribute("data-utility-button")||t.hasAttribute("data-gutter-utility-slot")||t.getAttribute("slot")==="gutter-utility-slot"||t.getAttribute("name")==="gutter-utility-slot"))return!0;return!1}var Ks=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:"idle"};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener("click",this.handlePointerClick),this.pre?.removeEventListener("pointerdown",this.handlePointerDown),this.pre?.removeEventListener("pointermove",this.handlePointerMove),this.pre?.removeEventListener("pointerleave",this.handlePointerLeave),this.pre?.removeAttribute("data-interactive-lines"),this.pre?.removeAttribute("data-interactive-line-numbers"),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),Ze(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();const{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode==="gutterSelecting"&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){const n=!(e===this.selectedRange||mn(e??void 0,this.selectedRange??void 0)),i=t?.lineNumberOnly??!1,r=t?.activeLineSide!==this.selectedRangeHighlightSide||i!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!r||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=i,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){const i=e!==this.editorActiveLine,r=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!i&&!r||(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{const e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode==="diff"&&e.type==="diff-line")return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode==="file"&&e.type==="line")return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{const{onHunkExpand:t,onLineClick:n,onLineNumberClick:i,onTokenClick:r,onMergeConflictActionClick:s}=this.options;t==null&&n==null&&i==null&&s==null&&r==null||this.options.onGutterUtilityClick!=null&&at(e.composedPath())||(Ie(this.options.__debugPointerEvents,"click","FileDiff.DEBUG.handlePointerClick:",e),this.handlePointerEvent({eventType:"click",event:e}))};handlePointerMove=e=>{if(e.pointerType!=="mouse")return;const{lineHoverHighlight:t="disabled",onLineEnter:n,onLineLeave:i,onTokenEnter:r,onTokenLeave:s,enableGutterUtility:o=!1}=this.options;t==="disabled"&&!o&&n==null&&i==null&&r==null&&s==null||(Ie(this.options.__debugPointerEvents,"move","FileDiff.DEBUG.handlePointerMove:",e),this.handlePointerEvent({eventType:"move",event:e}))};handlePointerLeave=e=>{const{__debugPointerEvents:t}=this.options;if(Ie(t,"move","FileDiff.DEBUG.handlePointerLeave: no event"),this.hoveredLine==null&&this.hoveredToken==null){Ie(t,"move","FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){const{__debugPointerEvents:n}=this.options,i=t.composedPath();Ie(n,e,"FileDiff.DEBUG.handlePointerEvent:",{eventType:e,composedPath:i});const r=this.resolvePointerTarget(i);Ie(n,e,"FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:",r);const{onLineClick:s,onLineNumberClick:o,onLineEnter:a,onLineLeave:l,onTokenClick:h,onTokenEnter:d,onTokenLeave:c,onHunkExpand:u,onMergeConflictActionClick:f}=this.options;switch(e){case"move":{const p=zn(r)&&this.hoveredLine?.lineElement===r.lineElement;ln(r)&&this.hoveredToken?.tokenElement===r.tokenElement||(this.hoveredToken!=null&&(c?.(this.hoveredToken,t),this.clearHoveredToken()),ln(r)&&(this.setHoveredToken(this.toTokenEventBaseProps(r)),d?.(this.hoveredToken,t))),p||(this.hoveredLine!=null&&(l?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),zn(r)?(this.setHoveredLine(this.toEventBaseProps(r)),this.placeUtility(),a?.({...this.hoveredLine,event:t})):this.placeUtility());break}case"click":{if(r==null)break;if(Ud(r)&&f!=null){f(r);break}if(Vd(r)&&u!=null){u(r.hunkIndex,r.all||t.shiftKey?"both":r.direction,r.all||t.shiftKey?Number.POSITIVE_INFINITY:void 0);break}if(!zn(r))break;ln(r)&&h!=null&&h(this.toTokenEventBaseProps(r),t);const p=this.toEventBaseProps(r);o!=null&&r.numberColumn?o({...p,event:t}):s?.({...p,event:t});break}}}syncPointerListeners(e){const{__debugPointerEvents:t,lineHoverHighlight:n="disabled",onLineClick:i,onLineNumberClick:r,onLineEnter:s,onLineLeave:o,onTokenClick:a,onTokenEnter:l,onTokenLeave:h,onHunkExpand:d,onMergeConflictActionClick:c,enableGutterUtility:u=!1,enableLineSelection:f=!1,onGutterUtilityClick:p}=this.options,g=p!=null,m=n!=="disabled"||i!=null||r!=null||s!=null||o!=null||a!=null||l!=null||h!=null||d!=null||c!=null||u||f||g;m&&!this.hasPointerListeners?(e.addEventListener("click",this.handlePointerClick),e.addEventListener("pointerdown",this.handlePointerDown),e.addEventListener("pointermove",this.handlePointerMove),e.addEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!0,Ie(t,"click","FileDiff.DEBUG.attachEventListeners: Attaching click events for:",(()=>{const C=[];return(t==="both"||t==="click")&&(i!=null&&C.push("onLineClick"),r!=null&&C.push("onLineNumberClick"),d!=null&&C.push("expandable hunk separators"),c!=null&&C.push("merge conflict actions")),C})()),Ie(t,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer move event"),Ie(t,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event")):!m&&this.hasPointerListeners&&(e.removeEventListener("click",this.handlePointerClick),e.removeEventListener("pointerdown",this.handlePointerDown),e.removeEventListener("pointermove",this.handlePointerMove),e.removeEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!1);const v=this.pointerSession.mode==="selecting"||this.pointerSession.mode==="pendingSingleLineUnselect",S=this.pointerSession.mode==="gutterSelecting";(!f&&v||!g&&S)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;const{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,i=e!=null,r=t!=null||n;i&&!this.interactiveLinesAttr?(this.pre.setAttribute("data-interactive-lines",""),this.interactiveLinesAttr=!0):!i&&this.interactiveLinesAttr&&(this.pre.removeAttribute("data-interactive-lines"),this.interactiveLinesAttr=!1),r&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute("data-interactive-line-numbers",""),this.interactiveLineNumbersAttr=!0):!r&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute("data-interactive-line-numbers"),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType==="mouse"&&e.button!==0||this.pre==null||this.pointerSession.mode!=="idle")return;const t=e.composedPath();at(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!=="mouse"&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){const{enableLineSelection:t=!1}=this.options;if(!t)return;const n=this.resolveSelectionInfo(e,{source:"event-path",requireNumberColumn:!0});if(n==null)return;const{pre:i}=this;if(i==null)return;const{lineNumber:r,eventSide:s,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){const a=this.getIndexesFromSelection(this.selectedRange,i.getAttribute("data-diff-type")==="split");if(a==null)return;const l=a.start<=a.end?o>=a.start:o<=a.end;this.selectionAnchor={lineNumber:l?this.selectedRange.start:this.selectedRange.end,side:l?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(r,s,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===r&&this.selectedRange?.end===r){const a={lineNumber:r,side:s};this.selectionAnchor=a,this.pointerSession={mode:"pendingSingleLineUnselect",pointerId:e.pointerId,anchor:a,pending:a},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:r,side:s},this.updateSelection(r,s,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){const{onGutterUtilityClick:t}=this.options;if(t==null)return;const n=this.currentSelectionEnds(),i=n?.bottom??this.resolveSelectionPoint(e,{source:"event-path",excludeUtility:!1}),r=n?.top??i;i==null||r==null||(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:"gutterSelecting",pointerId:e.pointerId,anchor:r,current:i},this.selectionAnchor={lineNumber:r.lineNumber,side:r.side},this.updateSelection(i.lineNumber,i.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionPoint(e,{source:"coordinates-first"});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case"selecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case"pendingSingleLineUnselect":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;const n={lineNumber:t.lineNumber,side:t.eventSide};if(Nd(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:"selecting",pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{const{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{const{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();const i=this.resolveSelectionPoint(e,{source:"coordinates-first"});i!=null&&(n.current=i,this.updateSelection(i.lineNumber,i.side));const r=this.buildSelectedLineRange(n.anchor,n.current);t?.({...r}),this.selectionAnchor=void 0,this.notifySelectionEnd(r),this.notifySelectionCommitted(r),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case"pendingSingleLineUnselect":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case"selecting":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":case"selecting":case"pendingSingleLineUnselect":if("pointerId"in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute("data-hovered"),this.hoveredLine.numberElement.removeAttribute("data-hovered"),this.hoveredLine=void 0)}setHoveredLine(e){const{lineHoverHighlight:t="disabled"}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!=="disabled"&&((t==="both"||t==="line")&&this.hoveredLine.lineElement.setAttribute("data-hovered",""),(t==="both"||t==="number")&&this.hoveredLine.numberElement.setAttribute("data-hovered",""))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer==null&&(this.gutterUtilityContainer=document.createElement("div"),this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot","")),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot==null&&(this.gutterUtilitySlot=document.createElement("slot"),this.gutterUtilitySlot.name="gutter-utility-slot"),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){const t=document.createElement("div");t.innerHTML=fe(zd());const n=t.firstElementChild;if(!(n instanceof HTMLButtonElement))throw new Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");n.remove(),this.gutterUtilityButton=n}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;const t=this.resolvePointerTarget(e);xt(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){const e=this.currentSelectionEnds();if(e==null)return!1;const t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){const e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){const t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},i=this.selectionPointRowIndex(t),r=this.selectionPointRowIndex(n);if(!(i==null||r==null))return i>r?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){const t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;const t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;const n=this.mode==="diff"?`${t[0]},${t[1]}`:`${t[0]}`,i=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(const r of i){if(!(r instanceof HTMLElement))continue;const s=this.resolvePointerTarget(Wt(r));if(xt(s)&&!(this.mode==="diff"&&e.side!=null&&s.side!==e.side))return s}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||(document.addEventListener("pointermove",this.handleDocumentPointerMove),document.addEventListener("pointerup",this.handleDocumentPointerUp),document.addEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&(document.removeEventListener("pointermove",this.handleDocumentPointerMove),document.removeEventListener("pointerup",this.handleDocumentPointerUp),document.removeEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!1)}clearPointerSession(){this.pointerSession={mode:"idle"}}clearPendingSingleLineState(){this.pointerSession.mode==="pendingSingleLineUnselect"&&(this.pointerSession={mode:"idle"})}selectionInfoFromPath(e,t){const n=this.resolvePointerTarget(e);if(xt(n)&&!(t&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode==="diff"?n.side:void 0}}resolveSelectionInfo(e,t){const n=this.resolveSelectionPath(e,t);return n!=null?this.selectionInfoFromPath(n,t.requireNumberColumn):void 0}selectionPointFromPath(e){const t=this.resolvePointerTarget(e);if(xt(t))return{lineNumber:t.lineNumber,side:this.mode==="diff"?t.side:void 0}}resolveSelectionPoint(e,t){const n=this.resolveSelectionPath(e,t);return n!=null?this.selectionPointFromPath(n):void 0}resolveSelectionPath(e,t){const n=t.excludeUtility!==!1;switch(t.source){case"event-path":return this.pathFromEventPath(e.composedPath(),n);case"coordinates-first":{const i=this.pathFromCoordinates(e,n);return i!==void 0?i??void 0:this.pathFromEventPath(e.composedPath(),n)}}}pathFromCoordinates(e,t){const n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&at(e))){for(const n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){const n=Wt(e);if(t&&at(n))return;const i=$d(e);return i!=null?Wt(i):this.pathFromAnnotationSlot(e)}pathFromAnnotationSlot(e){const t=jd(Gd(e));if(t==null)return;const n=this.targetForSelectionPoint(t);return n!=null?Wt(n.lineElement):void 0}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;const t=this.pre?.getRootNode(),n=br(t)?t:br(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){const{getLineIndex:n}=this.options;return n!=null?n(e,t):[e-1,e-1]}getCurrentSelectionRange(){return this.proposedSelectedRange!==void 0?this.proposedSelectedRange:this.selectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){const i=this.getCurrentSelectionRange();let r;if(e==null)r=null;else{const s=this.selectionAnchor?.side??t,o=this.selectionAnchor?.lineNumber??e;r=this.buildSelectionRange(o,e,s,t)}mn(i??void 0,r??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=r:(this.selectedRange=r,Ye(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;const n=this.getLineIndex(e.start,e.side),i=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&i!=null?{start:t?n[1]:n[0],end:t?i[1]:i[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;const i=this.getIndexesFromSelection(e.range,t);if(i==null)throw console.error({rowRange:i,range:e.range}),new Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return i}getLineRenderColumns(e,t,n,i){if(this.pre==null||t==null&&i==null)return[];const{children:r}=this.pre;if(r.length>2)throw console.error(r),new Error("InteractionManager.renderSelection: Somehow there are more than 2 code elements...");const s=[];for(const o of r){const a=o.hasAttribute("data-deletions")?"deletions":o.hasAttribute("data-additions")?"additions":void 0,l=e!=null&&t!=null&&(e.highlightSide==null||a==null||e.highlightSide===a),h=n!=null&&i!=null&&(n.highlightSide==null||a==null||n.highlightSide===a);if(!l&&!h)continue;const[d,c]=o.children;if(!(d instanceof HTMLElement)||!(c instanceof HTMLElement))throw new Error("InteractionManager.renderSelection: missing gutter or content element");if(c.children.length!==d.children.length)throw new Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");s.push({content:c,gutter:d,renderEditorActiveLine:h,renderSelectedLines:l})}return s}renderSelection=()=>{Ze(this.renderSelection);const e=this.getSelectionRenderState();if(this.pre==null)return;const{editorActiveLine:t,selectedLines:n}=e,i=!Cr(this.renderedSelectedLinesState,n),r=!Cr(this.renderedEditorActiveLineState,t);if(!i&&!r)return;i&&(this.renderedSelectedLinesState=void 0),r&&(this.renderedEditorActiveLineState=void 0);const s=this.pre.getAttribute("data-diff-type")==="split",o=i?this.resolveLineRenderRange(n,s,"selected-lines"):void 0,a=r?this.resolveLineRenderRange(t,s,"editor-active-line"):void 0,l=this.getLineRenderColumns(i?n:void 0,o,r?t:void 0,a),h=n.range==null||l.some(g=>g.renderSelectedLines),d=t.range==null||l.some(g=>g.renderEditorActiveLine);if(i)for(const g of this.pre.querySelectorAll("[data-selected-line]"))g.removeAttribute("data-selected-line");if(r)for(const g of this.pre.querySelectorAll("[data-editor-active-line]"))g.removeAttribute("data-editor-active-line");const c=o==null?void 0:Math.min(o.start,o.end),u=o==null?void 0:Math.max(o.start,o.end),f=c===u,p=a?.start;for(const g of l){const{content:m,gutter:v,renderEditorActiveLine:S,renderSelectedLines:C}=g,b=Math.max(C?u??-1/0:-1/0,S?p??-1/0:-1/0),y=m.children.length;for(let L=0;L<y;L++){const k=m.children[L],E=v.children[L];if(!(k instanceof HTMLElement)||!(E instanceof HTMLElement))continue;const x=this.parseLineIndex(k,s);if((x??0)>b)break;if(x!=null){if(C&&c!=null&&u!=null&&x>=c&&x<=u){let w=f?"single":x===c?"first":x===u?"last":"";E.setAttribute("data-selected-line",w),n.lineNumberOnly||(k.setAttribute("data-selected-line",w),E.nextSibling instanceof HTMLElement&&k.nextSibling instanceof HTMLElement&&(k.nextSibling.hasAttribute("data-line-annotation")||k.nextSibling.hasAttribute("data-merge-conflict-actions"))&&(f?(w="last",k.setAttribute("data-selected-line","first")):x===c?w="":x===u&&k.setAttribute("data-selected-line",""),k.nextSibling.setAttribute("data-selected-line",w),E.nextSibling.setAttribute("data-selected-line",w)))}S&&x===p&&(E.setAttribute("data-editor-active-line",""),t.lineNumberOnly||k.setAttribute("data-editor-active-line",""))}}}i&&h&&(this.renderedSelectedLinesState=n),r&&d&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode==="file"?{type:"line",lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:"diff-line",annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:i,tokenElement:r,tokenText:s}){return this.mode==="file"?{type:"token",lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:r,tokenText:s}:{type:"token",lineCharEnd:e,lineCharStart:t,lineNumber:n,side:i,tokenElement:r,tokenText:s}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,i){return{start:e,end:t,...n!=null?{side:n}:{},...n!==i&&i!=null?{endSide:i}:{}}}resolvePointerTarget(e){let t=!1,n,i,r,s,o,a,l,h,d,c;for(const f of e){if(!(f instanceof HTMLElement))continue;if(c==null&&f.hasAttribute("data-merge-conflict-action")){const v=f.getAttribute("data-merge-conflict-action")??void 0,S=f.getAttribute("data-merge-conflict-conflict-index")??void 0,C=S!=null?Number.parseInt(S,10):NaN;Wd(v)&&Number.isFinite(C)&&(c={kind:"merge-conflict-action",resolution:v,conflictIndex:C})}if(a==null&&f.hasAttribute("data-char")){a=f;const v=f.getAttribute("data-char");if(v!=null){const S=Number.parseInt(v,10);if(!Number.isNaN(S)){const C=f.textContent??"",b=S+C.length;(C.trim()!==""||this.options.enableTokenInteractionsOnWhitespace===!0)&&(l={tokenElement:a,lineCharStart:S,lineCharEnd:b,tokenText:C});continue}}}const p=o==null?f.getAttribute("data-column-number")??void 0:void 0;if(p!=null){o=f,d=Number.parseInt(p,10),t=!0,n=Lr(f),s=f.getAttribute("data-line-index")??void 0;continue}const g=r==null?f.getAttribute("data-line")??void 0:void 0;if(g!=null){r=f,d=Number.parseInt(g,10),n=Lr(f),s=f.getAttribute("data-line-index")??void 0;continue}if(h==null&&(f.hasAttribute("data-expand-button")||f.hasAttribute("data-unmodified-lines"))){h={hunkIndex:void 0,direction:f.hasAttribute("data-expand-up")?"up":f.hasAttribute("data-expand-down")?"down":"both",all:f.hasAttribute("data-expand-all-button")};continue}const m=h!=null?f.getAttribute("data-expand-index")??void 0:void 0;if(h!=null&&m!=null){const v=Number.parseInt(m,10);Number.isNaN(v)||(h.hunkIndex=v);continue}if(i==null&&f.hasAttribute("data-code")){i=f;break}}if(c!=null)return c;if(h?.hunkIndex!=null)return{type:"line-info",hunkIndex:h.hunkIndex,direction:h.direction,all:h.all};if(r??=s!=null?Sr(i,`[data-line][data-line-index="${s}"]`):void 0,o??=s!=null?Sr(i,`[data-column-number][data-line-index="${s}"]`):void 0,i==null||r==null||o==null||n==null||d==null||Number.isNaN(d))return;const u=this.parseLineIndex(r,this.isSplitDiff());return l!=null?this.mode==="file"?{kind:"token",lineType:n,lineElement:r,lineNumber:d,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:u,...l}:{kind:"token",lineType:n,lineElement:r,lineNumber:d,numberColumn:t,numberElement:o,side:yr(n,i),splitLineIndex:u,...l}:this.mode==="file"?{kind:"line",lineType:n,lineElement:r,lineNumber:d,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:u}:{kind:"line",lineType:n,lineElement:r,lineNumber:d,numberColumn:t,numberElement:o,side:yr(n,i),splitLineIndex:u}}isSplitDiff(){return this.pre?.getAttribute("data-diff-type")==="split"}parseLineIndex(e,t){const n=(e.getAttribute("data-line-index")??"").split(",").map(i=>Number.parseInt(i,10)).filter(i=>!Number.isNaN(i));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function bn({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:i,onLineClick:r,onLineEnter:s,onLineLeave:o,onLineNumberClick:a,onTokenClick:l,onTokenEnter:h,onTokenLeave:d,renderGutterUtility:c,__debugPointerEvents:u,enableLineSelection:f,controlledSelection:p,onLineSelected:g,onLineSelectionStart:m,onLineSelectionChange:v,onLineSelectionEnd:S},C,b,y){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:Bd({enableGutterUtility:t,renderGutterUtility:c,onGutterUtilityClick:i}),usesCustomGutterUtility:c!=null,lineHoverHighlight:n,onGutterUtilityClick:i,onHunkExpand:C,onMergeConflictActionClick:y,onLineClick:r,onLineEnter:s,onLineLeave:o,onLineNumberClick:a,onTokenClick:l,onTokenEnter:h,onTokenLeave:d,__debugPointerEvents:u,enableLineSelection:f,controlledSelection:p,onLineSelected:g,onLineSelectionStart:m,onLineSelectionChange:v,onLineSelectionEnd:S,getLineIndex:b}}function Bd({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw new Error("Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.");return e??!1}function xt(e){return e!=null&&"kind"in e&&e.kind==="line"}function ln(e){return e!=null&&"kind"in e&&e.kind==="token"}function zn(e){return xt(e)||ln(e)}function Vd(e){return"type"in e&&e.type==="line-info"}function Ud(e){return"kind"in e&&e.kind==="merge-conflict-action"}function Wd(e){return e==="current"||e==="incoming"||e==="both"}function Sr(e,t){const n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function Wt(e){const t=[];let n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function $d(e){const t=e.closest("[data-line], [data-column-number]");if(t instanceof HTMLElement)return t;const n=e.closest('[data-line-annotation], [data-gutter-buffer="annotation"]');if(!(n instanceof HTMLElement))return;const i=n.previousElementSibling;return i instanceof HTMLElement&&(i.hasAttribute("data-line")||i.hasAttribute("data-column-number"))?i:void 0}function Gd(e){const t=e.closest('[slot^="annotation-"]');if(t instanceof HTMLElement)return t.getAttribute("slot")??void 0;if(e instanceof HTMLElement){const n=e.getAttribute("name")??void 0;return n!=null&&n.startsWith("annotation-")?n:void 0}}function jd(e){if(e==null)return;const t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;const n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function br(e){return e!=null&&typeof e.elementFromPoint=="function"}function Kd(e,t){return e===t||mn(e??void 0,t??void 0)}function Cr(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&Kd(e?.range??null,t.range)}function yr(e,t){switch(e){case"change-deletion":return"deletions";case"change-addition":return"additions";default:return t.hasAttribute("data-deletions")?"deletions":"additions"}}function Lr(e){const t=e.getAttribute("data-line-type");if(t!=null)switch(t){case"change-deletion":case"change-addition":case"context":case"context-expanded":return t;default:return}}function Ie(e="none",t,...n){switch(e){case"none":return;case"both":break;case"click":if(t!=="click")return;break;case"move":if(t!=="move")return;break}console.log(...n)}var qs=class He{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){const t=He.resizeObserver??new ResizeObserver(He.handleSharedResizeEntries);return He.resizeObserver=t,t}static handleSharedResizeEntries(t){const n=new Map;for(const i of t){const r=He.managersByElement.get(i.target);if(r==null)continue;const s=n.get(r);s==null?n.set(r,[i]):s.push(i)}for(const[i,r]of n)i.handleResizeEntries(r)}observedNodes=new Map;setup(t,{disableAnnotations:n,columnVariables:i="apply"}){const r=new Set,s=i==="apply";let o=0;const a=new Map(this.observedNodes);this.observedNodes.clear();for(const l of t.children){if(o===2)break;const h=(()=>{if(l instanceof HTMLElement&&l.tagName==="CODE")return l})();if(h==null)continue;o++;let d=a.get(h);if(d!=null&&d.type!=="code")throw new Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");let c=h.firstElementChild;c instanceof HTMLElement||(c=null),d!=null?(this.observedNodes.set(h,d),a.delete(h),d.numberElement!==c?(d.numberElement!=null&&(this.unobserve(d.numberElement),a.delete(d.numberElement)),c!=null&&(this.observe(c),a.delete(c),this.observedNodes.set(c,d)),d.numberElement=c,d.numberWidth=0):d.numberElement!=null?(a.delete(d.numberElement),this.observedNodes.set(d.numberElement,d)):d.numberWidth=0,Xd(d,s)):(d={type:"code",codeElement:h,numberElement:c,codeWidth:"auto",numberWidth:0,applyColumnVariables:s},this.observedNodes.set(h,d),this.observe(h),c!=null&&(this.observedNodes.set(c,d),this.observe(c)))}if(o>1&&!n){const l=t.querySelectorAll('[data-line-annotation*=","]'),h=new Map;for(const d of l){if(!(d instanceof HTMLElement))continue;const c=d.getAttribute("data-line-annotation")??"";if(!/^-?\d+,-?\d+$/.test(c)){console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation",{lineAnnotation:c,element:d});continue}let u=h.get(c);u==null&&(u=[],h.set(c,u)),u.push(d)}for(const[d,c]of h){if(c.length!==2){console.error("DiffFileRenderer.setupResizeObserver: Bad Pair",d,c);continue}const[u,f]=c,p=u.firstElementChild,g=f.firstElementChild;if(!(u instanceof HTMLElement)||!(f instanceof HTMLElement)||!(p instanceof HTMLElement)||!(g instanceof HTMLElement))continue;let m=a.get(p);if(m!=null){this.observedNodes.set(p,m),this.observedNodes.set(g,m),a.delete(p),a.delete(g);continue}const v=p.getBoundingClientRect().height,S=g.getBoundingClientRect().height;m={type:"annotations",column1:{container:u,child:p,childHeight:v},column2:{container:f,child:g,childHeight:S},currentHeight:"auto"},r.add({child1:p,child2:g,item:m,newHeight:Math.max(v,S)})}for(const d of r)this.applyNewHeight(d.item,d.newHeight),this.observedNodes.set(d.child1,d.item),this.observedNodes.set(d.child2,d.item),this.observe(d.child1),this.observe(d.child2);r.clear()}for(const[l,h]of a)this.unobserve(l),h.type==="code"?Zd(h):Jd(h);a.clear()}cleanUp(){for(const t of this.observedNodes.keys())this.unobserve(t);this.observedNodes.clear()}observe(t){const{managersByElement:n}=He,i=n.get(t);if(i!==this){if(i!=null&&i!==this)throw new Error("ResizeManager.observe: element is already owned by another ResizeManager");n.set(t,this),He.getResizeObserver().observe(t)}}unobserve(t){const{managersByElement:n,resizeObserver:i}=He,r=n.get(t);if(r!=null){if(r!==this)throw new Error("ResizeManager.unobserve: element is owned by another ResizeManager");n.delete(t),i?.unobserve(t),i!=null&&n.size===0&&(i.disconnect(),He.resizeObserver=void 0)}}handleResizeEntries(t){const n=new Map,i=new Set;for(const r of t){const{target:s,borderBoxSize:o,contentBoxSize:a}=r;if(!(s instanceof HTMLElement)){console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver",r);continue}const l=this.observedNodes.get(s);if(l==null){console.error("ResizeManager.handleResizeEntries: Not a valid observed node",r);continue}if(l.type==="annotations"){const h=(()=>{if(s===l.column1.child)return l.column1;if(s===l.column2.child)return l.column2})();if(h==null){console.error("ResizeManager.handleResizeEntries: Couldn't find a column for",{item:l,target:s});continue}h.childHeight=o[0].blockSize,i.add(l)}else if(l.type==="code"){const h=n.get(l)??{},d=a[0].inlineSize;s===l.codeElement?h.codeInlineSize=d:s===l.numberElement&&(h.numberInlineSize=d),n.set(l,h)}}this.applyAnnotationUpdates(i),i.clear(),this.applyColumnUpdates(n),n.clear()}applyAnnotationUpdates(t){for(const n of t)this.applyNewHeight(n,Math.max(n.column1.childHeight,n.column2.childHeight))}applyColumnUpdates=t=>{for(const[n,i]of t){const r=i.codeInlineSize!=null?qd(i.codeInlineSize):n.codeWidth,s=i.numberInlineSize!=null?Yd(i.numberInlineSize):n.numberWidth,o=r!==n.codeWidth,a=s!==n.numberWidth;!o&&!a||(n.codeWidth=r,n.numberWidth=s,n.applyColumnVariables&&Ys(n,{codeWidthChanged:o,numberWidthChanged:a}))}};applyNewHeight(t,n){n!==t.currentHeight&&(t.currentHeight=Math.max(n,0),t.column1.container.style.setProperty("--diffs-annotation-min-height",`${t.currentHeight}px`),t.column2.container.style.setProperty("--diffs-annotation-min-height",`${t.currentHeight}px`))}};function qd(e){const t=Math.max(Math.floor(e),0);return t===0?"auto":t}function Yd(e){return Math.max(Math.ceil(e),0)}function Xd(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?Ys(e,{codeWidthChanged:!0,numberWidthChanged:!0}):Xs(e))}function Ys(e,{codeWidthChanged:t,numberWidthChanged:n}){const{codeElement:i,codeWidth:r,numberWidth:s}=e;if(t&&i.style.setProperty("--diffs-column-width",`${typeof r=="number"?`${r}px`:"auto"}`),n&&i.style.setProperty("--diffs-column-number-width",`${s===0?"auto":`${s}px`}`),t||n&&r!=="auto"){const o=typeof r=="number"?Math.max(r-s,0):0;i.style.setProperty("--diffs-column-content-width",`${o>0?`${o}px`:"auto"}`)}}function Xs(e){e.codeElement.style.removeProperty("--diffs-column-content-width"),e.codeElement.style.removeProperty("--diffs-column-number-width"),e.codeElement.style.removeProperty("--diffs-column-width")}function Zd(e){e.codeElement.isConnected&&Xs(e)}function Jd(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty("--diffs-annotation-min-height"),e.column2.container.isConnected&&e.column2.container.style.removeProperty("--diffs-annotation-min-height")}function Rn(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function Cn(e){for(const t of Array.isArray(e)?e:[e])if(!(t==="text"||t==="ansi")&&!ni.has(t))return!1;return!0}function Tt(e){for(const t of _i(e))if(!ti.has(t))return!1;return!0}function Zs(e,t){return e.endsWith(`\r
30
+ `)?t+`\r
31
+ `:e.endsWith("\r")?t+"\r":e.endsWith(`
32
+ `)?t+`
33
+ `:t}function fi(e){return F({tagName:"div",children:[F({tagName:"div",children:e.annotations?.map(t=>F({tagName:"slot",properties:{name:t}})),properties:{"data-annotation-content":""}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function Js(e,t){return F({tagName:"div",children:e,properties:{"data-content":"",style:`grid-row: span ${t}`}})}function Qd(e){switch(e){case"file":return"diffs-icon-file-code";case"change":return"diffs-icon-symbol-modified";case"new":return"diffs-icon-symbol-added";case"deleted":return"diffs-icon-symbol-deleted";case"rename-pure":case"rename-changed":return"diffs-icon-symbol-moved"}}function Qs({fileOrDiff:e,mode:t,stickyHeader:n}){const i="type"in e?e:void 0,r={"data-diffs-header":t,"data-change-type":i?.type,"data-sticky":n?"":void 0};return F({tagName:"div",children:[t==="custom"?F({tagName:"slot",properties:{name:Dt}}):eh({name:e.name,prevName:"prevName"in e?e.prevName:void 0,iconType:i?.type??"file"}),...t==="custom"?[]:[th(i)]],properties:r})}function eh({name:e,prevName:t,iconType:n}){const i=[F({tagName:"slot",properties:{name:Hi}}),pn({name:Qd(n),properties:{"data-change-icon":n}})];return t!=null&&(i.push(F({tagName:"div",children:[F({tagName:"bdi",children:[Te(t)]})],properties:{"data-prev-name":""}})),i.push(pn({name:"diffs-icon-arrow-right-short",properties:{"data-rename-icon":""}}))),i.push(F({tagName:"div",children:[F({tagName:"bdi",children:[Te(e)]})],properties:{"data-title":""}})),i.push(F({tagName:"slot",properties:{name:Pi}})),F({tagName:"div",children:i,properties:{"data-header-content":""}})}function th(e){const t=[];if(e!=null){let n=0,i=0;for(const r of e.hunks)n+=r.additionLines,i+=r.deletionLines;(i>0||n===0)&&t.push(F({tagName:"span",children:[Te(`-${i}`)],properties:{"data-deletions-count":""}})),(n>0||i===0)&&t.push(F({tagName:"span",children:[Te(`+${n}`)],properties:{"data-additions-count":""}}))}return t.push(F({tagName:"slot",properties:{name:Oi}})),F({tagName:"div",children:t,properties:{"data-metadata":""}})}function eo(e){return F({tagName:"pre",properties:nh(e)})}function nh({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:i,split:r,totalLines:s,type:o,customProperties:a}){return{...a,"data-diff":o==="diff"?"":void 0,"data-file":o==="file"?"":void 0,"data-diff-type":o==="diff"?r?"split":"single":void 0,"data-overflow":i,"data-disable-line-numbers":n?"":void 0,"data-background":t?void 0:"","data-indicators":e==="bars"||e==="classic"?e:void 0,style:`--diffs-min-number-column-width-default:${`${s}`.length}ch;`}}function to(e,{theme:t,preferredHighlighter:n="shiki-js"}){return{langs:[e??"text"],themes:_i(t),preferredHighlighter:n}}function $t(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}let ih=-1;var rh=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++ih}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;constructor(e={theme:J},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=Tt(e.theme??J)?Rs():void 0)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(const t of e){const n=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=n,n.push(t)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(){this.editSessionActive=!0}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){const{renderCache:e,lineCache:t}=this;e?.isDirty!==!0||t==null||!$t(t,e.file)||(e.file.contents=t.lines.join(""))}hasUnkeyedFileContentsChanged(e){const{lineCache:t}=this;return e.cacheKey==null&&t!=null&&t.file===e&&t.sourceContents!==e.contents}invalidateChangedUnkeyedFile(e){this.hasUnkeyedFileContentsChanged(e)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile(),this.pendingStructuralRows=void 0;const e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(e.file.cacheKey)}hydrate(e){const{options:t}=this.getRenderOptions(e),n=Bn(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());let i=this.workerManager?.getFileResultCache(e);i!=null&&!et(t,i.options)&&(i=void 0),this.renderCache??={file:e,options:t,highlighted:!n&&!ii(e),result:n?void 0:i?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,e):this.highlighter==null&&(this.computedLang=e.lang??he(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??J}getEffectiveCodeOptions(){const e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){const t=(()=>{if(this.workerManager?.isWorkingPool()===!0){const r=this.workerManager.getFileRenderOptions();return this.editSessionActive&&r.useTokenTransformer!==!0?{...r,useTokenTransformer:!0}:r}const{tokenizeMaxLineLength:i=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:i}})(),{renderCache:n}=this;return n?.result==null?{options:t,forceHighlight:!0}:!we(e,n.file)||!et(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getOrCreateLineCache(e){this.invalidateChangedUnkeyedFile(e);let{lineCache:t}=this;return(t==null||!$t(t,e))&&(t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:nn(e.contents)}),this.lineCache=t,t.lines}getLineCount(e){const t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t,n=!1){if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:i,result:r}=this.renderCache;if(r==null)return;const s=n?new Map:void 0;this.pendingStructuralRows=s;const o=this.lineCache!=null&&$t(this.lineCache,i)?this.lineCache:void 0;for(const[a,l]of e){if(s===void 0&&o!=null&&a<o.lines.length){const d=l.map(c=>c[2]).join("");o.lines[a]=Zs(o.lines[a]??"",d)}const h={type:"element",tagName:"div",properties:{"data-line":a+1,"data-line-type":"context","data-line-index":a},children:l.map(([d,c,u])=>d===0&&c===""?u===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:u}:{type:"element",tagName:"span",properties:{"data-char":d,style:`color:${c};`},children:[{type:"text",value:u}]})};s!==void 0?s.set(a,h):r.code[a]=h}r.baseThemeType=t,this.renderCache.isDirty=!0}applyDocumentChange(e){const t=this.pendingStructuralRows;if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:n,result:i}=this.renderCache;if(i==null)return;const r=this.lineCache!=null&&$t(this.lineCache,n)?this.lineCache.lines:nn(n.contents),s=nn(e.getText());if(r.length!==s.length){const o=Math.min(r.length,s.length);let a=0;for(;a<o&&r[a]===s[a];)a++;let l=0;for(;l<o-a&&r[r.length-1-l]===s[s.length-1-l];)l++;const h=i.code;i.code=new Array(s.length);for(let d=0;d<a;d++)i.code[d]=h[d];for(let d=0;d<l;d++)i.code[s.length-1-d]=h[r.length-1-d];if(t!==void 0)for(const[d,c]of t)d<s.length&&(i.code[d]=c);for(let d=a;d<s.length-l;d++)i.code[d]??={type:"element",tagName:"div",properties:{"data-line":d+1,"data-line-type":"context","data-line-index":d},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:e.getLineText(d)}]}]};for(let d=0;d<i.code.length;d++){const c=i.code[d];c?.type==="element"&&(c.properties["data-line"]=d+1,c.properties["data-line-index"]=d)}this.renderCache.isDirty=!0}this.lineCache={cacheKey:n.cacheKey,file:n,sourceContents:n.contents,lines:s},this.textDocumentCache.set(n,e)}renderFile(e=this.renderCache?.file,t=cn){if(e==null)return;this.invalidateChangedUnkeyedFile(e),this.renderCache?.isDirty===!0&&!we(e,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:n,forceHighlight:i}=this.getRenderOptions(e);this.renderCache?.isDirty===!0&&!et(n,this.renderCache.options)&&this.clearRenderCache();const r=this.getMatchingWorkerResultCache(e,n);r!=null&&!this.hasHighlightedRenderCache(e,n)&&(this.renderCache={file:e,highlighted:!0,renderRange:void 0,...r},i=!1),this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(e),o=e.contents.length>0,a=!o||ii(e)||Bn(s.length,this.getTokenizeMaxLength()),l=!we(e,this.renderCache.file),h=!Rn(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)(a||this.renderCache.result==null||!this.renderCache.highlighted&&(l||h))&&(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||h||i)&&(this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,s)),this.renderCache.renderRange=t),!a&&o&&(!this.renderCache.highlighted||i)&&this.workerManager.highlightFileAST(this,e);else{this.computedLang=e.lang??he(e.name);const d=this.highlighter!=null&&Tt(n.theme),c=this.highlighter!=null&&Cn(this.computedLang),u=!a&&c;if(this.highlighter!=null&&d&&(i||a||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:f,options:p}=this.renderFileWithHighlighter(e,this.highlighter,a||!c);this.renderCache={file:e,options:p,highlighted:u,result:f,renderRange:void 0}}(!d||!a&&!c)&&this.asyncHighlight(e).then(({result:f,options:p})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,f,p,!a)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,t,this.renderCache.result):void 0}async asyncRender(e,t=cn){const{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){const t=Bn(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?"text":e.lang??he(e.name);const n=this.highlighter!=null&&Ga(_i(this.getLocalHighlightTheme())),i=t||this.highlighter!=null&&Cn(this.computedLang);return(this.highlighter==null||!n||!i)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){const{options:i}=this.getRenderOptions(e);return{result:cl(e,t,i,{forcePlainText:n}),options:i}}processFileResult(e,t,{code:n,themeStyles:i,baseThemeType:r}){const s=this.getLineCount(e),{disableFileHeader:o=!1}=this.options,a=[],l=rt(),h=Math.min(t.startingLine+t.totalLines,s);let d=0;const c=An(t)?ui(this.lineAnnotations):void 0;c!=null&&(l.children.push(ge("context","annotation",1)),a.push(fi({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>be(u))})),d++);for(let u=t.startingLine;u<h;u++){const f=u+1,p=n[u];if(p==null){const m="FileRenderer.processFileResult: Line doesnt exist";throw console.error(m,{name:e.name,lineIndex:u,lineNumber:f}),new Error(m)}l.children.push(Is("context",f,`${u}`)),a.push(p),d++;const g=this.lineAnnotations[f];g!=null&&(l.children.push(ge("context","annotation",1)),a.push(fi({hunkIndex:0,lineIndex:f,annotations:g.map(m=>be(m))})),d++)}return l.properties.style=`grid-row: span ${d}`,{gutterAST:l.children??[],contentAST:a,preAST:this.createPreElement(s),headerAST:o?void 0:this.renderHeader(e),totalLines:s,rowCount:d,themeStyles:i,baseThemeType:r,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderHeader(e){const{headerRenderMode:t="default",stickyHeader:n=!1}=this.options;return Qs({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return fe(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(F({tagName:"code",children:this.renderCodeAST(e),properties:{"data-code":""}})),{...e.preAST,children:t}}renderCodeAST(e){const t=rt();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,Js(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){return t?fe(F({tagName:"code",children:e,properties:{"data-code":""}})):fe(e)}async initializeHighlighter(){return this.highlighter=await As(to(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(e,t,n,i=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,i)}applyHighlightResult(e,t,n,i=!0){if(this.renderCache==null)return;const r=!we(e,this.renderCache.file)||!this.renderCache.highlighted||!et(n,this.renderCache.options);this.renderCache={file:e,options:n,highlighted:i,result:t,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;const n=this.workerManager?.getFileResultCache(e);if(!(n==null||!et(t,n.options)))return n}hasHighlightedRenderCache(e,t){const{renderCache:n}=this;return n?.result!=null&&n.highlighted&&we(e,n.file)&&et(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){const{disableLineNumbers:t=!1,overflow:n="scroll"}=this.options;return eo({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function Bn(e,t){return e>t}const no=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
34
+ <symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
35
+ <path d="M8.47 4.22a.75.75 0 0 0 0 1.06l1.97 1.97H3.75a.75.75 0 0 0 0 1.5h6.69l-1.97 1.97a.75.75 0 1 0 1.06 1.06l3.25-3.25a.75.75 0 0 0 0-1.06L9.53 4.22a.75.75 0 0 0-1.06 0"/>
36
+ </symbol>
37
+ <symbol id="diffs-icon-brand-github" viewBox="0 0 16 16">
38
+ <path d="M8 0c4.42 0 8 3.58 8 8a8.01 8.01 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27s-1.36.09-2 .27c-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8"/>
39
+ </symbol>
40
+ <symbol id="diffs-icon-chevron" viewBox="0 0 16 16">
41
+ <path d="M1.47 4.47a.75.75 0 0 1 1.06 0L8 9.94l5.47-5.47a.75.75 0 1 1 1.06 1.06l-6 6a.75.75 0 0 1-1.06 0l-6-6a.75.75 0 0 1 0-1.06"/>
42
+ </symbol>
43
+ <symbol id="diffs-icon-chevrons-narrow" viewBox="0 0 10 16">
44
+ <path d="M4.47 2.22a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1-1.06 1.06L5 3.81 2.28 6.53a.75.75 0 0 1-1.06-1.06zM1.22 9.47a.75.75 0 0 1 1.06 0L5 12.19l2.72-2.72a.75.75 0 0 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0l-3.25-3.25a.75.75 0 0 1 0-1.06"/>
45
+ </symbol>
46
+ <symbol id="diffs-icon-diff-split" viewBox="0 0 16 16">
47
+ <path d="M14 0H8.5v16H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2m-1.5 6.5v1h1a.5.5 0 0 1 0 1h-1v1a.5.5 0 0 1-1 0v-1h-1a.5.5 0 0 1 0-1h1v-1a.5.5 0 0 1 1 0"/><path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h5.5V0zm.5 7.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1" opacity=".3"/>
48
+ </symbol>
49
+ <symbol id="diffs-icon-diff-unified" viewBox="0 0 16 16">
50
+ <path fill-rule="evenodd" d="M16 14a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V8.5h16zm-8-4a.5.5 0 0 0-.5.5v1h-1a.5.5 0 0 0 0 1h1v1a.5.5 0 0 0 1 0v-1h1a.5.5 0 0 0 0-1h-1v-1A.5.5 0 0 0 8 10" clip-rule="evenodd"/><path fill-rule="evenodd" d="M14 0a2 2 0 0 1 2 2v5.5H0V2a2 2 0 0 1 2-2zM6.5 3.5a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z" clip-rule="evenodd" opacity=".4"/>
51
+ </symbol>
52
+ <symbol id="diffs-icon-expand" viewBox="0 0 16 16">
53
+ <path d="M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06"/>
54
+ </symbol>
55
+ <symbol id="diffs-icon-expand-all" viewBox="0 0 16 16">
56
+ <path d="M11.47 9.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06L8 12.94zM7.526 1.418a.75.75 0 0 1 1.004.052l4 4a.75.75 0 1 1-1.06 1.06L8 3.06 4.53 6.53a.75.75 0 1 1-1.06-1.06l4-4z"/>
57
+ </symbol>
58
+ <symbol id="diffs-icon-file-code" viewBox="0 0 16 16">
59
+ <path d="M10.75 0c.199 0 .39.08.53.22l3.5 3.5c.14.14.22.331.22.53v9A2.75 2.75 0 0 1 12.25 16h-8.5A2.75 2.75 0 0 1 1 13.25V2.75A2.75 2.75 0 0 1 3.75 0zm-7 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h8.5c.69 0 1.25-.56 1.25-1.25V5h-1.25A2.25 2.25 0 0 1 10 2.75V1.5z"/><path d="M7.248 6.19a.75.75 0 0 1 .063 1.058L5.753 9l1.558 1.752a.75.75 0 0 1-1.122.996l-2-2.25a.75.75 0 0 1 0-.996l2-2.25a.75.75 0 0 1 1.06-.063M8.69 7.248a.75.75 0 1 1 1.12-.996l2 2.25a.75.75 0 0 1 0 .996l-2 2.25a.75.75 0 1 1-1.12-.996L10.245 9z"/>
60
+ </symbol>
61
+ <symbol id="diffs-icon-plus" viewBox="0 0 16 16">
62
+ <path d="M8 3a.75.75 0 0 1 .75.75v3.5h3.5a.75.75 0 0 1 0 1.5h-3.5v3.5a.75.75 0 0 1-1.5 0v-3.5h-3.5a.75.75 0 0 1 0-1.5h3.5v-3.5A.75.75 0 0 1 8 3"/>
63
+ </symbol>
64
+ <symbol id="diffs-icon-symbol-added" viewBox="0 0 16 16">
65
+ <path d="M8 4a.75.75 0 0 1 .75.75v2.5h2.5a.75.75 0 0 1 0 1.5h-2.5v2.5a.75.75 0 0 1-1.5 0v-2.5h-2.5a.75.75 0 0 1 0-1.5h2.5v-2.5A.75.75 0 0 1 8 4"/><path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/>
66
+ </symbol>
67
+ <symbol id="diffs-icon-symbol-deleted" viewBox="0 0 16 16">
68
+ <path d="M4 8a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5A.75.75 0 0 1 4 8"/><path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/>
69
+ </symbol>
70
+ <symbol id="diffs-icon-symbol-diffstat" viewBox="0 0 16 16">
71
+ <path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/><path d="M8.75 4.296a.75.75 0 0 0-1.5 0V6.25h-2a.75.75 0 0 0 0 1.5h2v1.5h1.5v-1.5h2a.75.75 0 0 0 0-1.5h-2zM5.25 10a.75.75 0 0 0 0 1.5h5.5a.75.75 0 0 0 0-1.5z"/>
72
+ </symbol>
73
+ <symbol id="diffs-icon-symbol-ignored" viewBox="0 0 16 16">
74
+ <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706s.826.607 1.706.802c.898.2 2.091.288 3.704.288s2.806-.088 3.704-.288c.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5s-2.806.088-3.704.288c-.88.196-1.381.478-1.706.802s-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8M0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m11.53-2.47a.75.75 0 0 0-1.06-1.06l-6 6a.75.75 0 1 0 1.06 1.06z"/>
75
+ </symbol>
76
+ <symbol id="diffs-icon-symbol-modified" viewBox="0 0 16 16">
77
+ <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706s.826.607 1.706.802c.898.2 2.091.288 3.704.288s2.806-.088 3.704-.288c.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5s-2.806.088-3.704.288c-.88.196-1.381.478-1.706.802s-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8M0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m8 3a3 3 0 1 0 0-6 3 3 0 0 0 0 6"/>
78
+ </symbol>
79
+ <symbol id="diffs-icon-symbol-moved" viewBox="0 0 16 16">
80
+ <path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/><path d="M8.495 4.695a.75.75 0 0 0-.05 1.06L10.486 8l-2.041 2.246a.75.75 0 0 0 1.11 1.008l2.5-2.75a.75.75 0 0 0 0-1.008l-2.5-2.75a.75.75 0 0 0-1.06-.051m-4 0a.75.75 0 0 0-.05 1.06l2.044 2.248-1.796 1.995a.75.75 0 0 0 1.114 1.004l2.25-2.5a.75.75 0 0 0-.002-1.007l-2.5-2.75a.75.75 0 0 0-1.06-.05"/>
81
+ </symbol>
82
+ <symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
83
+ <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706.286.286.71.54 1.41.73V1.86c-.7.19-1.124.444-1.41.73-.324.325-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8m4 6.397c.697.07 1.522.103 2.5.103 1.613 0 2.806-.088 3.704-.288.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5c-.978 0-1.803.033-2.5.103zM0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m7-2a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>
84
+ </symbol>
85
+ </svg>`;function sh(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function io(e,t){return e==null||t==null?e===t:oh(e.customProperties,t.customProperties)&&e.type===t.type&&e.diffIndicators===t.diffIndicators&&e.disableBackground===t.disableBackground&&e.disableLineNumbers===t.disableLineNumbers&&e.overflow===t.overflow&&e.split===t.split&&e.totalLines===t.totalLines}const xr={};function oh(e=xr,t=xr){if(e===t)return!0;const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const r of n)if(e[r]!==t[r])return!1;return!0}function ro(e){const t=document.createElement("div");return t.dataset.annotationSlot="",t.slot=e,t.style.whiteSpace="normal",t}function so(){const e=document.createElement("div");return e.slot="gutter-utility-slot",e.style.position="absolute",e.style.top="0",e.style.bottom="0",e.style.textAlign="center",e.style.whiteSpace="normal",e.style.touchAction="none",e}function oo(){const e=document.createElement("style");return e.setAttribute(na,""),e}let Gt;function Pt(e){if(Gt!=null)return Gt;const t=e.host;if(typeof HTMLElement<"u"&&t instanceof HTMLElement&&!t.isConnected)return;const n=document.createElement("div");n.setAttribute("data-code",""),n.setAttribute(ia,"true");const i=document.createElement("div");return i.style.position="relative",i.style.width="200%",i.style.height="200%",n.appendChild(i),e.appendChild(n),Gt=Math.max(n.offsetHeight-n.clientHeight,0),n.remove(),Gt}function ao(e){return`${Ss}: ${e==null?"var(--diffs-scrollbar-gutter-fallback)":`${e}px`};`}var ah=`@layer base {
86
+ :host {
87
+ --diffs-font-fallback: "SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono",
88
+ "Courier New", monospace;
89
+ --diffs-header-font-fallback: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
90
+ "Noto Sans", "Liberation Sans", Arial, sans-serif;
91
+ --diffs-mixer: light-dark(#000, #fff);
92
+ --diffs-gap-fallback: 8px;
93
+ --diffs-scrollbar-gutter-fallback: 6px;
94
+ --diffs-scrollbar-gutter: var(--diffs-scrollbar-gutter-override, var(--diffs-scrollbar-gutter-measured, var(--diffs-scrollbar-gutter-fallback)));
95
+ --diffs-added-light: #0dbe4e;
96
+ --diffs-added-dark: #5ecc71;
97
+ --diffs-modified-light: #009fff;
98
+ --diffs-modified-dark: #69b1ff;
99
+ --diffs-deleted-light: #ff2e3f;
100
+ --diffs-deleted-dark: #ff6762;
101
+ --diffs-warning-light: #d5a910;
102
+ --diffs-warning-dark: #ffd452;
103
+ color-scheme: light dark;
104
+ font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
105
+ font-size: var(--diffs-font-size, 13px);
106
+ line-height: var(--diffs-line-height, 20px);
107
+ font-feature-settings: var(--diffs-font-features);
108
+ --diffs-bg: light-dark(var(--diffs-light-bg, #fff), var(--diffs-dark-bg, #000));
109
+ --diffs-bg-buffer: var(--diffs-bg-buffer-override, light-dark(color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer))));
110
+ --diffs-bg-context: var(--diffs-bg-context-override, light-dark(color-mix(in lab, var(--diffs-bg) 98.5%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-bg) 92.5%, var(--diffs-mixer))));
111
+ --diffs-bg-context-gutter: var(--diffs-bg-context-gutter-override, light-dark(color-mix(in lab, var(--diffs-bg-context) 90%, var(--diffs-bg)), color-mix(in lab, var(--diffs-bg-context) 45%, var(--diffs-bg))));
112
+ --diffs-bg-separator: var(--diffs-bg-separator-override, light-dark(color-mix(in lab, var(--diffs-bg) 96%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-bg) 85%, var(--diffs-mixer))));
113
+ --diffs-fg: light-dark(var(--diffs-light, #000), var(--diffs-dark, #fff));
114
+ --diffs-fg-number: var(--diffs-fg-number-override, light-dark(color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg)), color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg))));
115
+ --diffs-fg-conflict-marker: var(--diffs-fg-conflict-marker-override, var(--diffs-fg-number));
116
+ --diffs-deletion-base: var(--diffs-deletion-color-override, light-dark(var(--diffs-light-deletion-color, var(--diffs-deletion-color, var(--diffs-deleted-light))), var(--diffs-dark-deletion-color, var(--diffs-deletion-color, var(--diffs-deleted-dark)))));
117
+ --diffs-addition-base: var(--diffs-addition-color-override, light-dark(var(--diffs-light-addition-color, var(--diffs-addition-color, var(--diffs-added-light))), var(--diffs-dark-addition-color, var(--diffs-addition-color, var(--diffs-added-dark)))));
118
+ --diffs-modified-base: var(--diffs-modified-color-override, light-dark(var(--diffs-light-modified-color, var(--diffs-modified-color, var(--diffs-modified-light))), var(--diffs-dark-modified-color, var(--diffs-modified-color, var(--diffs-modified-dark)))));
119
+ --diffs-bg-deletion: var(--diffs-bg-deletion-override, light-dark(color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-deletion-base)), color-mix(in lab, var(--diffs-bg) 80%, var(--diffs-deletion-base))));
120
+ --diffs-bg-deletion-emphasis: var(--diffs-bg-deletion-emphasis-override, light-dark(rgb(from var(--diffs-deletion-base) r g b / .15), rgb(from var(--diffs-deletion-base) r g b / .2)));
121
+ --diffs-bg-addition: var(--diffs-bg-addition-override, light-dark(color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-addition-base)), color-mix(in lab, var(--diffs-bg) 80%, var(--diffs-addition-base))));
122
+ --diffs-bg-addition-emphasis: var(--diffs-bg-addition-emphasis-override, light-dark(rgb(from var(--diffs-addition-base) r g b / .15), rgb(from var(--diffs-addition-base) r g b / .2)));
123
+ --diffs-selection-base: var(--diffs-modified-base);
124
+ --diffs-selection-number-fg: light-dark(color-mix(in lab, var(--diffs-selection-base) 65%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-selection-base) 75%, var(--diffs-mixer)));
125
+ background-color: var(--diffs-bg);
126
+ color: var(--diffs-fg);
127
+ display: block;
128
+ }
129
+
130
+ pre, code, [data-error-wrapper] {
131
+ isolation: isolate;
132
+ font-family: var(--diffs-font-family, var(--diffs-font-fallback));
133
+ outline: none;
134
+ margin: 0;
135
+ padding: 0;
136
+ display: block;
137
+ }
138
+
139
+ pre, code {
140
+ background-color: var(--diffs-bg);
141
+ }
142
+
143
+ code {
144
+ contain: content;
145
+ }
146
+
147
+ input, button {
148
+ font-family: inherit;
149
+ font-size: inherit;
150
+ line-height: inherit;
151
+ }
152
+
153
+ *, :before, :after {
154
+ box-sizing: border-box;
155
+ }
156
+
157
+ [data-icon-sprite] {
158
+ display: none;
159
+ }
160
+
161
+ [data-diffs-header], [data-separator] {
162
+ font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
163
+ }
164
+
165
+ [data-diffs-header][data-sticky] {
166
+ z-index: 1;
167
+ background-color: var(--diffs-bg);
168
+ position: sticky;
169
+ top: 0;
170
+ }
171
+
172
+ [data-file-info] {
173
+ color: var(--fg);
174
+ background-color: color-mix(in lab, var(--bg) 98%, var(--fg));
175
+ border-block: 1px solid color-mix(in lab, var(--bg) 95%, var(--fg));
176
+ padding: 10px;
177
+ font-weight: 700;
178
+ }
179
+
180
+ [data-diff], [data-file] {
181
+ --diffs-grid-number-column-width: minmax(min-content, max-content);
182
+ --diffs-code-grid: var(--diffs-grid-number-column-width) 1fr;
183
+
184
+ &[data-dehydrated] {
185
+ --diffs-code-grid: var(--diffs-grid-number-column-width) minmax(0, 1fr);
186
+ }
187
+
188
+ &:hover [data-code]::-webkit-scrollbar-thumb {
189
+ background-color: var(--diffs-bg-context);
190
+ }
191
+ }
192
+
193
+ @supports (-webkit-touch-callout: none) {
194
+ :host {
195
+ --diffs-scrollbar-gutter-fallback: 0px;
196
+ }
197
+ }
198
+
199
+ [data-line] span {
200
+ color: light-dark(var(--diffs-token-light, var(--diffs-light)), var(--diffs-token-dark, var(--diffs-dark)));
201
+ background-color: light-dark(var(--diffs-token-light-bg, inherit), var(--diffs-token-dark-bg, inherit));
202
+ font-weight: light-dark(var(--diffs-token-light-font-weight, inherit), var(--diffs-token-dark-font-weight, inherit));
203
+ font-style: light-dark(var(--diffs-token-light-font-style, inherit), var(--diffs-token-dark-font-style, inherit));
204
+ text-decoration: light-dark(var(--diffs-token-light-text-decoration, inherit), var(--diffs-token-dark-text-decoration, inherit));
205
+ }
206
+
207
+ [data-line], [data-gutter-buffer], [data-column-number], [data-line-annotation], [data-no-newline], [data-merge-conflict], [data-merge-conflict-actions], [data-editor-overlay] {
208
+ --diffs-computed-decoration-bg: var(--diffs-bg);
209
+ --diffs-computed-diff-line-bg: var(--diffs-computed-decoration-bg);
210
+ --diffs-computed-selected-line-bg: var(--diffs-computed-diff-line-bg);
211
+ --diffs-computed-editor-active-line-bg: var(--diffs-computed-selected-line-bg);
212
+ --diffs-computed-hovered-line-bg: var(--diffs-computed-editor-active-line-bg);
213
+ --diffs-hover-mix-target: var(--diffs-bg-hover-override, var(--diffs-mixer));
214
+ --diffs-line-bg: var(--diffs-computed-hovered-line-bg);
215
+ color: var(--diffs-fg);
216
+ background-color: var(--diffs-line-bg, var(--diffs-bg));
217
+ }
218
+
219
+ [data-line], [data-no-newline] {
220
+ &[data-decoration-bg] {
221
+ --mix-deco-light: 92%;
222
+ --mix-deco-dark: 85%;
223
+
224
+ &[data-decoration-bg-depth="2"] {
225
+ --mix-deco-light: 88%;
226
+ --mix-deco-dark: 80%;
227
+ }
228
+
229
+ &[data-decoration-bg-depth="3"] {
230
+ --mix-deco-light: 85%;
231
+ --mix-deco-dark: 78%;
232
+ }
233
+
234
+ --diffs-hover-mix-target: var(--diffs-decoration-bg);
235
+ --diffs-computed-decoration-bg: light-dark(color-mix(in lab,
236
+ var(--diffs-bg) var(--mix-deco-light),
237
+ var(--diffs-decoration-bg)), color-mix(in lab,
238
+ var(--diffs-bg) var(--mix-deco-dark),
239
+ var(--diffs-decoration-bg)));
240
+ }
241
+ }
242
+
243
+ [data-line-annotation], [data-gutter-buffer="annotation"] {
244
+ --diffs-annotation-bg: var(--diffs-bg-context);
245
+ --diffs-computed-decoration-bg: var(--diffs-annotation-bg);
246
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
247
+ }
248
+
249
+ [data-merge-conflict-actions], [data-gutter-buffer="merge-conflict-action"], [data-gutter-buffer="merge-conflict-marker-base"], [data-gutter-buffer="merge-conflict-marker-separator"], [data-merge-conflict="marker-base"], [data-merge-conflict="marker-separator"] {
250
+ --diffs-computed-decoration-bg: var(--diffs-bg-context);
251
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
252
+ }
253
+
254
+ [data-gutter-buffer="merge-conflict-marker-start"], [data-merge-conflict="marker-start"] {
255
+ --diffs-computed-decoration-bg: light-dark(color-mix(in lab,
256
+ var(--diffs-bg) 78%,
257
+ var(--conflict-bg-current-header-override, var(--diffs-addition-base))), color-mix(in lab,
258
+ var(--diffs-bg) 68%,
259
+ var(--conflict-bg-current-header-override, var(--diffs-addition-base))));
260
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
261
+ }
262
+
263
+ [data-gutter-buffer="merge-conflict-marker-end"], [data-merge-conflict="marker-end"] {
264
+ --diffs-computed-decoration-bg: light-dark(color-mix(in lab,
265
+ var(--diffs-bg) 78%,
266
+ var(--conflict-bg-incoming-header-override, var(--diffs-modified-base))), color-mix(in lab,
267
+ var(--diffs-bg) 68%,
268
+ var(--conflict-bg-incoming-header-override, var(--diffs-modified-base))));
269
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
270
+ }
271
+
272
+ [data-has-merge-conflict] [data-line-annotation], [data-has-merge-conflict] [data-gutter-buffer="annotation"] {
273
+ --diffs-computed-decoration-bg: var(--diffs-bg);
274
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
275
+ }
276
+
277
+ :where([data-background]) {
278
+ & [data-gutter-buffer], & [data-column-number] {
279
+ --mix-light: 91%;
280
+ --mix-dark: 85%;
281
+ }
282
+
283
+ & [data-line], & [data-no-newline] {
284
+ --mix-light: 88%;
285
+ --mix-dark: 80%;
286
+ }
287
+
288
+ & [data-gutter-buffer], & [data-column-number], & [data-line], & [data-no-newline] {
289
+ --diffs-diff-line-mix-target: var(--diffs-bg);
290
+
291
+ &[data-line-type="change-deletion"] {
292
+ --diffs-diff-line-mix-target: var(--diffs-bg-deletion-override, var(--diffs-deletion-base));
293
+ --diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
294
+
295
+ &:where([data-gutter-buffer], [data-column-number]) {
296
+ color: var(--diffs-fg-number-deletion-override, var(--diffs-deletion-base));
297
+ --diffs-diff-line-mix-target: var(--diffs-bg-deletion-number-override, var(--diffs-deletion-base));
298
+ }
299
+
300
+ --diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
301
+ var(--diffs-computed-decoration-bg) var(--mix-light),
302
+ var(--diffs-diff-line-mix-target)), color-mix(in lab,
303
+ var(--diffs-computed-decoration-bg) var(--mix-dark),
304
+ var(--diffs-diff-line-mix-target)));
305
+ }
306
+
307
+ &[data-line-type="change-addition"] {
308
+ --diffs-diff-line-mix-target: var(--diffs-bg-addition-override, var(--diffs-addition-base));
309
+ --diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
310
+
311
+ &:where([data-gutter-buffer], [data-column-number]) {
312
+ color: var(--diffs-fg-number-addition-override, var(--diffs-addition-base));
313
+ --diffs-diff-line-mix-target: var(--diffs-bg-addition-number-override, var(--diffs-addition-base));
314
+ }
315
+
316
+ --diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
317
+ var(--diffs-computed-decoration-bg) var(--mix-light),
318
+ var(--diffs-diff-line-mix-target)), color-mix(in lab,
319
+ var(--diffs-computed-decoration-bg) var(--mix-dark),
320
+ var(--diffs-diff-line-mix-target)));
321
+ }
322
+
323
+ &[data-merge-conflict="current"] {
324
+ --diffs-diff-line-mix-target: var(--conflict-bg-current-override, var(--diffs-addition-base));
325
+ --diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
326
+
327
+ &:where([data-gutter-buffer], [data-column-number]) {
328
+ color: var(--diffs-fg-number-addition-override, var(--diffs-addition-base));
329
+ --diffs-diff-line-mix-target: var(--conflict-bg-current-number-override, var(--diffs-addition-base));
330
+ }
331
+
332
+ --diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
333
+ var(--diffs-computed-decoration-bg) var(--mix-light),
334
+ var(--diffs-diff-line-mix-target)), color-mix(in lab,
335
+ var(--diffs-computed-decoration-bg) var(--mix-dark),
336
+ var(--diffs-diff-line-mix-target)));
337
+ }
338
+
339
+ &[data-merge-conflict="incoming"] {
340
+ --diffs-diff-line-mix-target: var(--conflict-bg-incoming-override, var(--diffs-modified-base));
341
+ --diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
342
+
343
+ &:where([data-gutter-buffer], [data-column-number]) {
344
+ color: var(--diffs-modified-base);
345
+ --diffs-diff-line-mix-target: var(--conflict-bg-incoming-number-override, var(--diffs-modified-base));
346
+ }
347
+
348
+ --diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
349
+ var(--diffs-computed-decoration-bg) var(--mix-light),
350
+ var(--diffs-diff-line-mix-target)), color-mix(in lab,
351
+ var(--diffs-computed-decoration-bg) var(--mix-dark),
352
+ var(--diffs-diff-line-mix-target)));
353
+ }
354
+ }
355
+ }
356
+
357
+ [data-gutter-buffer], [data-column-number], [data-line], [data-line-annotation], [data-merge-conflict], [data-merge-conflict-actions], [data-no-newline], [data-editor-overlay] {
358
+ --diffs-selection-mix-target: var(--diffs-bg-selection-override, var(--diffs-selection-base));
359
+ --diffs-selection-emphasis-mix-target: var(--diffs-selection-mix-target);
360
+
361
+ &:where([data-editor-overlay]), &:where([data-line], [data-line-annotation], [data-merge-conflict], [data-merge-conflict-actions], [data-no-newline])[data-selected-line] {
362
+ --mix-selection-light: 82%;
363
+ --mix-selection-dark: 75%;
364
+ --diffs-hover-mix-target: var(--diffs-selection-mix-target);
365
+ }
366
+
367
+ &:where([data-gutter-buffer][data-selected-line], [data-column-number]:is([data-selected-line], [data-editor-active-line])) {
368
+ --mix-selection-light: 75%;
369
+ --mix-selection-dark: 60%;
370
+ --diffs-selection-mix-target: var(--diffs-bg-selection-number-override, var(--diffs-selection-base));
371
+ --diffs-hover-mix-target: var(--diffs-selection-mix-target);
372
+ }
373
+
374
+ &:where([data-line][data-selected-line]):is([data-line-type="change-addition"], [data-line-type="change-deletion"]) {
375
+ --diffs-selection-emphasis-mix-target: light-dark(color-mix(in lab,
376
+ var(--diffs-diff-line-mix-target, var(--diffs-selection-mix-target))
377
+ var(--mix-selection-light),
378
+ var(--diffs-selection-mix-target)), var(--diffs-selection-mix-target));
379
+ }
380
+
381
+ &:where([data-editor-overlay]), &[data-selected-line] {
382
+ --diffs-computed-selected-line-bg: light-dark(color-mix(in lab,
383
+ var(--diffs-computed-diff-line-bg) var(--mix-selection-light),
384
+ var(--diffs-selection-mix-target)), color-mix(in lab,
385
+ var(--diffs-computed-diff-line-bg) var(--mix-selection-dark),
386
+ var(--diffs-selection-mix-target)));
387
+ }
388
+ }
389
+
390
+ [data-line][data-editor-active-line], [data-column-number][data-editor-active-line] {
391
+ --diffs-computed-editor-active-line-bg: color-mix(in lab,
392
+ var(--diffs-computed-selected-line-bg)
393
+ var(--diffs-editor-active-line-source-mix, 100%),
394
+ var(--diffs-selection-emphasis-mix-target));
395
+ }
396
+
397
+ @media (pointer: fine) {
398
+ [data-line][data-hovered], [data-gutter-buffer][data-hovered], [data-column-number][data-hovered], [data-line-annotation][data-hovered], [data-no-newline][data-hovered], [data-merge-conflict][data-hovered], [data-merge-conflict-actions][data-hovered], [data-editor-overlay][data-hovered] {
399
+ --diffs-computed-hovered-line-bg: light-dark(color-mix(in lab,
400
+ var(--diffs-computed-editor-active-line-bg) 97%,
401
+ var(--diffs-hover-mix-target)), color-mix(in lab,
402
+ var(--diffs-computed-editor-active-line-bg) 91%,
403
+ var(--diffs-hover-mix-target)));
404
+ }
405
+ }
406
+
407
+ [data-gutter-buffer][data-selected-line], [data-column-number]:is([data-selected-line], [data-editor-active-line]) {
408
+ color: var(--diffs-selection-number-fg);
409
+ }
410
+
411
+ [data-no-newline] {
412
+ user-select: none;
413
+
414
+ & span {
415
+ opacity: .6;
416
+ }
417
+ }
418
+
419
+ [data-diff-type="split"][data-overflow="scroll"] {
420
+ grid-template-columns: 1fr 1fr;
421
+ display: grid;
422
+
423
+ & [data-additions] {
424
+ border-left: 1px solid var(--diffs-bg);
425
+ }
426
+
427
+ & [data-deletions] {
428
+ border-right: 1px solid var(--diffs-bg);
429
+ }
430
+ }
431
+
432
+ [data-code] {
433
+ grid-auto-flow: dense;
434
+ grid-template-columns: var(--diffs-code-grid);
435
+ overflow: var(--diffs-overflow-override, scroll) clip;
436
+ overscroll-behavior-x: none;
437
+ tab-size: var(--diffs-tab-size, 2);
438
+ padding-top: var(--diffs-gap-block, var(--diffs-gap-fallback));
439
+ padding-bottom: max(0px,
440
+ calc(var(--diffs-gap-block, var(--diffs-gap-fallback)) -
441
+ var(--diffs-scrollbar-gutter)));
442
+ scrollbar-gutter: stable;
443
+ align-self: flex-start;
444
+ display: grid;
445
+ }
446
+
447
+ [data-diffs-scrollbar-measure] {
448
+ opacity: 0;
449
+ pointer-events: none;
450
+ scrollbar-gutter: auto;
451
+ grid-template-columns: none;
452
+ width: 100px;
453
+ height: 100px;
454
+ padding: 0;
455
+ position: absolute;
456
+ top: -200px;
457
+ left: -200px;
458
+ }
459
+
460
+ [data-container-size] {
461
+ container-type: inline-size;
462
+ }
463
+
464
+ [data-code]::-webkit-scrollbar {
465
+ width: 0;
466
+ height: var(--diffs-scrollbar-gutter);
467
+ }
468
+
469
+ [data-code]::-webkit-scrollbar-track {
470
+ background: none;
471
+ }
472
+
473
+ [data-code]::-webkit-scrollbar-thumb {
474
+ background-color: #0000;
475
+ background-clip: content-box;
476
+ border: 1px solid #0000;
477
+ border-radius: 3px;
478
+ }
479
+
480
+ [data-code]::-webkit-scrollbar-corner {
481
+ background-color: #0000;
482
+ }
483
+
484
+ @supports ((-moz-appearance: none)) {
485
+ [data-code] {
486
+ scrollbar-width: thin;
487
+ scrollbar-color: var(--diffs-bg-context) transparent;
488
+ padding-bottom: var(--diffs-gap-block, var(--diffs-gap-fallback));
489
+ }
490
+ }
491
+
492
+ [data-diffs-header] ~ [data-diff], [data-diffs-header] ~ [data-file] {
493
+ & [data-code], &[data-overflow="wrap"], &[data-dehydrated][data-diff-type="split"][data-overflow="scroll"] {
494
+ padding-top: 0;
495
+ }
496
+ }
497
+
498
+ [data-gutter] {
499
+ grid-template-rows: subgrid;
500
+ grid-template-columns: subgrid;
501
+ z-index: 3;
502
+ background-color: var(--diffs-bg);
503
+ grid-column: 1;
504
+ display: grid;
505
+ position: relative;
506
+
507
+ & [data-gutter-buffer], & [data-column-number] {
508
+ border-right: var(--diffs-gap-style, 2px solid var(--diffs-bg));
509
+ }
510
+ }
511
+
512
+ [data-content] {
513
+ grid-template-rows: subgrid;
514
+ grid-template-columns: subgrid;
515
+ background-color: var(--diffs-bg);
516
+ grid-column: 2;
517
+ min-width: 0;
518
+ display: grid;
519
+ }
520
+
521
+ [data-diff-type="split"][data-overflow="wrap"], [data-dehydrated][data-diff-type="split"][data-overflow="scroll"] {
522
+ grid-auto-flow: dense;
523
+ grid-template-columns: repeat(2, var(--diffs-code-grid));
524
+ padding-block: var(--diffs-gap-block, var(--diffs-gap-fallback));
525
+ display: grid;
526
+
527
+ & [data-code] {
528
+ display: contents;
529
+ }
530
+
531
+ & [data-deletions] {
532
+ & [data-gutter] {
533
+ grid-column: 1;
534
+ }
535
+
536
+ & [data-content] {
537
+ border-right: 1px solid var(--diffs-bg);
538
+ grid-column: 2;
539
+ }
540
+ }
541
+
542
+ & [data-additions] {
543
+ & [data-gutter] {
544
+ border-left: 1px solid var(--diffs-bg);
545
+ grid-column: 3;
546
+ }
547
+
548
+ & [data-content] {
549
+ grid-column: 4;
550
+ }
551
+ }
552
+ }
553
+
554
+ [data-dehydrated][data-diff-type="split"][data-overflow="scroll"] [data-content] {
555
+ overflow: clip;
556
+ }
557
+
558
+ [data-overflow="scroll"] [data-gutter] {
559
+ position: sticky;
560
+ left: 0;
561
+ }
562
+
563
+ [data-interactive-lines] [data-line] {
564
+ cursor: pointer;
565
+ }
566
+
567
+ [data-interactive-line-numbers] [data-column-number] {
568
+ cursor: pointer;
569
+ touch-action: none;
570
+ }
571
+
572
+ [data-content-buffer], [data-gutter-buffer] {
573
+ user-select: none;
574
+ min-height: 1lh;
575
+ position: relative;
576
+ }
577
+
578
+ [data-gutter-buffer] {
579
+ padding-left: 2ch;
580
+ padding-right: 1ch;
581
+
582
+ &:before {
583
+ content: "";
584
+ min-width: var(--diffs-min-number-column-width, var(--diffs-min-number-column-width-default, 3ch));
585
+ display: block;
586
+ }
587
+ }
588
+
589
+ [data-gutter-buffer="annotation"] {
590
+ --diffs-annotation-bg: var(--diffs-bg-context-gutter);
591
+ min-height: 0;
592
+ }
593
+
594
+ [data-gutter-buffer="buffer"] {
595
+ --diffs-line-bg: var(--diffs-bg-context-gutter);
596
+ }
597
+
598
+ [data-content-buffer] {
599
+ background-position: 5px 0;
600
+ background-size: 8px 8px;
601
+ background-origin: border-box;
602
+ background-image: repeating-linear-gradient(-45deg,
603
+ transparent,
604
+ transparent calc(3px * 1.414),
605
+ var(--diffs-bg-buffer) calc(3px * 1.414),
606
+ var(--diffs-bg-buffer) calc(4px * 1.414));
607
+ grid-column: 1;
608
+ }
609
+
610
+ [data-separator] {
611
+ box-sizing: content-box;
612
+ background-color: var(--diffs-bg);
613
+ }
614
+
615
+ [data-separator="simple"] {
616
+ min-height: 4px;
617
+ }
618
+
619
+ [data-separator="line-info"], [data-separator="line-info-basic"], [data-separator="metadata"], [data-separator="simple"] {
620
+ background-color: var(--diffs-bg-separator);
621
+ }
622
+
623
+ [data-separator="line-info"], [data-separator="line-info-basic"], [data-separator="metadata"] {
624
+ height: 32px;
625
+ position: relative;
626
+ }
627
+
628
+ [data-separator-wrapper] {
629
+ user-select: none;
630
+ fill: currentColor;
631
+ background-color: var(--diffs-bg);
632
+ align-items: center;
633
+ height: 100%;
634
+ display: flex;
635
+ position: absolute;
636
+ inset-inline: 0;
637
+ }
638
+
639
+ [data-content] [data-separator-wrapper] {
640
+ display: none;
641
+ }
642
+
643
+ [data-separator="metadata"] [data-separator-wrapper] {
644
+ background-color: var(--diffs-bg-separator);
645
+ height: 100%;
646
+ color: var(--diffs-fg-number);
647
+ white-space: nowrap;
648
+ text-overflow: ellipsis;
649
+ min-width: min-content;
650
+ padding-inline: 1ch;
651
+ inset-inline: 100% auto;
652
+ overflow: hidden;
653
+ }
654
+
655
+ [data-separator="line-info"] {
656
+ margin-block: var(--diffs-gap-block, var(--diffs-gap-fallback));
657
+
658
+ & [data-separator-wrapper] {
659
+ min-width: 16px;
660
+ }
661
+ }
662
+
663
+ [data-separator="line-info-basic"], [data-separator="metadata"] {
664
+ margin-block: 0;
665
+ }
666
+
667
+ [data-separator="line-info"][data-separator-first] {
668
+ margin-top: 0;
669
+ }
670
+
671
+ [data-separator="line-info"][data-separator-last] {
672
+ margin-bottom: 0;
673
+ }
674
+
675
+ [data-expand-index] [data-separator-wrapper] {
676
+ grid-template-columns: 32px auto;
677
+ display: grid;
678
+ }
679
+
680
+ [data-expand-index] [data-separator-wrapper][data-separator-multi-button] {
681
+ grid-template-columns: 32px 32px auto;
682
+ }
683
+
684
+ [data-expand-button], [data-separator-content] {
685
+ background-color: var(--diffs-bg-separator);
686
+ flex: none;
687
+ align-items: center;
688
+ display: flex;
689
+ }
690
+
691
+ [data-expand-index] [data-separator-content]:hover {
692
+ cursor: pointer;
693
+ text-decoration: underline;
694
+ }
695
+
696
+ [data-expand-button] {
697
+ cursor: pointer;
698
+ min-width: 32px;
699
+ color: var(--diffs-fg-number);
700
+ border-right: 2px solid var(--diffs-bg);
701
+ flex-shrink: 0;
702
+ justify-content: center;
703
+ align-self: stretch;
704
+
705
+ &:hover {
706
+ color: var(--diffs-fg);
707
+ }
708
+
709
+ &[data-expand-all-button] {
710
+ display: none;
711
+ }
712
+ }
713
+
714
+ [data-expand-down] [data-icon] {
715
+ transform: scaleY(-1);
716
+ }
717
+
718
+ [data-separator-content] {
719
+ height: 100%;
720
+ color: var(--diffs-fg-number);
721
+ flex: auto;
722
+ justify-content: flex-start;
723
+ padding: 0 1ch;
724
+ overflow: hidden;
725
+ }
726
+
727
+ [data-separator="line-info"], [data-separator="line-info-basic"] {
728
+ & [data-separator-content] {
729
+ user-select: none;
730
+ height: 100%;
731
+ overflow: clip;
732
+ }
733
+ }
734
+
735
+ [data-unmodified-lines] {
736
+ text-overflow: ellipsis;
737
+ white-space: nowrap;
738
+ flex: 0 auto;
739
+ min-width: 0;
740
+ display: block;
741
+ overflow: hidden;
742
+ }
743
+
744
+ @supports (width: 1cqi) {
745
+ [data-unified] {
746
+ & [data-separator="line-info"] [data-separator-wrapper] {
747
+ padding-inline: var(--diffs-gap-inline, var(--diffs-gap-fallback));
748
+ width: 100cqi;
749
+
750
+ & [data-separator-content] {
751
+ border-radius: 6px;
752
+ }
753
+ }
754
+
755
+ & [data-separator="line-info"][data-expand-index] [data-separator-wrapper] [data-separator-content] {
756
+ border-top-left-radius: unset;
757
+ border-bottom-left-radius: unset;
758
+ }
759
+ }
760
+
761
+ [data-gutter] {
762
+ & [data-separator="line-info"] [data-separator-wrapper] {
763
+ padding-left: var(--diffs-gap-inline, var(--diffs-gap-fallback));
764
+ }
765
+
766
+ & [data-separator="line-info"] [data-separator-content] {
767
+ border-top-left-radius: 6px;
768
+ border-bottom-left-radius: 6px;
769
+ }
770
+
771
+ & [data-separator="line-info"][data-expand-index] [data-separator-content] {
772
+ border-top-left-radius: unset;
773
+ border-bottom-left-radius: unset;
774
+ }
775
+ }
776
+
777
+ [data-additions] {
778
+ & [data-content] [data-separator="line-info"] {
779
+ background-color: var(--diffs-bg);
780
+
781
+ & [data-separator-wrapper] {
782
+ display: none;
783
+ }
784
+ }
785
+
786
+ & [data-gutter] [data-separator="line-info"] [data-separator-wrapper] {
787
+ background-color: var(--diffs-bg-separator);
788
+ border-top-right-radius: 6px;
789
+ border-bottom-right-radius: 6px;
790
+ height: 100%;
791
+ display: block;
792
+
793
+ & [data-separator-content], & [data-expand-button] {
794
+ display: none;
795
+ }
796
+ }
797
+ }
798
+
799
+ [data-overflow="scroll"] [data-additions] [data-gutter] [data-separator="line-info"] [data-separator-wrapper] {
800
+ width: calc(100cqi - var(--diffs-gap-inline, var(--diffs-gap-fallback)));
801
+ }
802
+
803
+ [data-overflow="wrap"] [data-additions] [data-content] [data-separator="line-info"] [data-separator-wrapper] {
804
+ background-color: var(--diffs-bg-separator);
805
+ height: 100%;
806
+ margin-right: var(--diffs-gap-inline, var(--diffs-gap-fallback));
807
+ border-top-right-radius: 6px;
808
+ border-bottom-right-radius: 6px;
809
+ display: block;
810
+
811
+ & [data-separator-content], & [data-expand-button] {
812
+ display: none;
813
+ }
814
+ }
815
+
816
+ [data-separator="line-info"] [data-separator-wrapper] {
817
+ & [data-expand-both], & [data-expand-down], & [data-expand-up] {
818
+ border-top-left-radius: 6px;
819
+ border-bottom-left-radius: 6px;
820
+ }
821
+ }
822
+
823
+ @media (pointer: fine) {
824
+ [data-separator="line-info"] [data-separator-wrapper] {
825
+ &[data-separator-multi-button] {
826
+ & [data-expand-up] {
827
+ border-top-left-radius: 6px;
828
+ border-bottom-left-radius: unset;
829
+ }
830
+
831
+ & [data-expand-down] {
832
+ border-bottom-left-radius: 6px;
833
+ border-top-left-radius: unset;
834
+ }
835
+ }
836
+ }
837
+ }
838
+ }
839
+
840
+ @media (pointer: coarse) {
841
+ [data-separator="line-info-basic"] [data-separator-wrapper][data-separator-multi-button] {
842
+ grid-template-columns: 34px 34px auto;
843
+
844
+ & [data-separator-content] {
845
+ grid-column: unset;
846
+ grid-row: unset;
847
+ }
848
+ }
849
+
850
+ @supports (width: 1cqi) {
851
+ [data-separator="line-info"] [data-separator-wrapper] {
852
+ & [data-expand-both], & [data-expand-down], & [data-expand-up] {
853
+ border-top-left-radius: 6px;
854
+ border-bottom-left-radius: 6px;
855
+ }
856
+
857
+ &[data-separator-multi-button] {
858
+ & [data-expand-up] {
859
+ border-top-left-radius: 6px;
860
+ border-bottom-left-radius: 6px;
861
+ }
862
+
863
+ & [data-expand-down] {
864
+ border-bottom-left-radius: unset;
865
+ border-top-left-radius: unset;
866
+ }
867
+ }
868
+ }
869
+ }
870
+ }
871
+
872
+ @media (pointer: fine) {
873
+ [data-separator-wrapper][data-separator-multi-button] {
874
+ grid-template-rows: 50% 50%;
875
+ display: grid;
876
+
877
+ & [data-separator-content] {
878
+ grid-area: 1 / 2 / -1;
879
+ min-width: min-content;
880
+ }
881
+
882
+ & [data-expand-button] {
883
+ grid-column: 1;
884
+ }
885
+ }
886
+
887
+ [data-separator="line-info"] [data-separator-wrapper], [data-separator="line-info"] [data-separator-wrapper][data-separator-multi-button] {
888
+ grid-template-columns: 34px auto;
889
+ }
890
+
891
+ [data-separator="line-info-basic"][data-expand-index] [data-separator-wrapper] {
892
+ grid-template-columns: 100% auto;
893
+ }
894
+
895
+ [data-separator="line-info"], [data-separator="line-info-basic"] {
896
+ & [data-separator-multi-button] {
897
+ & [data-expand-up] {
898
+ border-bottom: 1px solid var(--diffs-bg);
899
+ border-right: 2px solid var(--diffs-bg);
900
+ }
901
+
902
+ & [data-expand-down] {
903
+ border-top: 1px solid var(--diffs-bg);
904
+ border-right: 2px solid var(--diffs-bg);
905
+ }
906
+ }
907
+ }
908
+ }
909
+
910
+ [data-additions] [data-gutter] [data-separator-wrapper], [data-additions] [data-separator="line-info-basic"] [data-separator-wrapper], [data-content] [data-separator-wrapper] {
911
+ display: none;
912
+ }
913
+
914
+ [data-line-annotation] {
915
+ min-height: var(--diffs-annotation-min-height, 0);
916
+ z-index: 2;
917
+ }
918
+
919
+ [data-merge-conflict-actions] {
920
+ z-index: 2;
921
+ }
922
+
923
+ [data-separator="custom"] {
924
+ grid-template-columns: subgrid;
925
+ display: grid;
926
+ }
927
+
928
+ [data-line], [data-column-number], [data-no-newline] {
929
+ padding-inline: 1ch;
930
+ position: relative;
931
+ }
932
+
933
+ [data-indicators="classic"] [data-line] {
934
+ padding-inline-start: 2ch;
935
+ }
936
+
937
+ [data-indicators="classic"] {
938
+ & [data-line-type="change-addition"], & [data-line-type="change-deletion"] {
939
+ &[data-no-newline], &[data-line] {
940
+ &:before {
941
+ user-select: none;
942
+ width: 1ch;
943
+ height: 1lh;
944
+ display: inline-block;
945
+ position: absolute;
946
+ top: 0;
947
+ left: 0;
948
+ }
949
+ }
950
+ }
951
+
952
+ & [data-line-type="change-addition"] {
953
+ &[data-line], &[data-no-newline] {
954
+ &:before {
955
+ content: "+";
956
+ color: var(--diffs-addition-base);
957
+ }
958
+ }
959
+ }
960
+
961
+ & [data-line-type="change-deletion"] {
962
+ &[data-line], &[data-no-newline] {
963
+ &:before {
964
+ content: "-";
965
+ color: var(--diffs-deletion-base);
966
+ }
967
+ }
968
+ }
969
+ }
970
+
971
+ [data-indicators="bars"] {
972
+ & [data-line-type="change-deletion"], & [data-line-type="change-addition"] {
973
+ &[data-column-number] {
974
+ &:before {
975
+ content: "";
976
+ user-select: none;
977
+ contain: strict;
978
+ width: 4px;
979
+ height: 100%;
980
+ display: block;
981
+ position: absolute;
982
+ top: 0;
983
+ left: 0;
984
+ }
985
+ }
986
+ }
987
+
988
+ & [data-line-type="change-deletion"] {
989
+ &[data-column-number] {
990
+ &:before {
991
+ background-image: linear-gradient(0deg,
992
+ var(--diffs-bg-deletion) 50%,
993
+ var(--diffs-deletion-base) 50%);
994
+ background-repeat: repeat;
995
+ background-size: 2px 2px;
996
+ background-size: calc(1lh / round(1lh / 2px))
997
+ calc(1lh / round(1lh / 2px));
998
+ }
999
+ }
1000
+ }
1001
+
1002
+ & [data-line-type="change-addition"] {
1003
+ &[data-column-number] {
1004
+ &:before {
1005
+ background-color: var(--diffs-addition-base);
1006
+ }
1007
+ }
1008
+ }
1009
+ }
1010
+
1011
+ [data-overflow="wrap"] {
1012
+ & [data-line] {
1013
+ white-space: pre-wrap;
1014
+ word-break: break-word;
1015
+ }
1016
+
1017
+ & [data-annotation-content] {
1018
+ word-break: break-word;
1019
+ }
1020
+ }
1021
+
1022
+ [data-overflow="scroll"] [data-line] {
1023
+ white-space: pre;
1024
+ min-height: 1lh;
1025
+ }
1026
+
1027
+ [data-column-number] {
1028
+ box-sizing: content-box;
1029
+ text-align: right;
1030
+ user-select: none;
1031
+ color: var(--diffs-fg-number);
1032
+ padding-left: 2ch;
1033
+ }
1034
+
1035
+ [data-line-number-content] {
1036
+ min-width: var(--diffs-min-number-column-width, var(--diffs-min-number-column-width-default, 3ch));
1037
+ z-index: 1;
1038
+ display: inline-block;
1039
+ position: relative;
1040
+ }
1041
+
1042
+ [data-disable-line-numbers] {
1043
+ & [data-gutter-buffer], & [data-column-number] {
1044
+ min-width: 4px;
1045
+ padding: 0;
1046
+
1047
+ &:before {
1048
+ min-width: 0;
1049
+ }
1050
+ }
1051
+
1052
+ & [data-line-number-content] {
1053
+ display: none;
1054
+ }
1055
+
1056
+ & [data-gutter-utility-slot] {
1057
+ right: unset;
1058
+ justify-content: flex-start;
1059
+ left: 0;
1060
+ }
1061
+
1062
+ &[data-indicators="bars"] [data-gutter-utility-slot] {
1063
+ left: 6px;
1064
+ }
1065
+ }
1066
+
1067
+ [data-file][data-disable-line-numbers] {
1068
+ & [data-gutter-buffer], & [data-column-number] {
1069
+ border-right: 0;
1070
+ min-width: 0;
1071
+ }
1072
+ }
1073
+
1074
+ [data-diff-span] {
1075
+ box-decoration-break: clone;
1076
+ border-radius: 3px;
1077
+ }
1078
+
1079
+ [data-line-type="change-addition"] [data-diff-span] {
1080
+ background-color: var(--diffs-bg-addition-emphasis);
1081
+ }
1082
+
1083
+ [data-line-type="change-deletion"] [data-diff-span] {
1084
+ background-color: var(--diffs-bg-deletion-emphasis);
1085
+ }
1086
+
1087
+ [data-merge-conflict="marker-start"], [data-merge-conflict="marker-base"], [data-merge-conflict="marker-separator"], [data-merge-conflict="marker-end"] {
1088
+ color: var(--diffs-fg);
1089
+ padding-left: 1ch;
1090
+ }
1091
+
1092
+ [data-merge-conflict="marker-start"], [data-merge-conflict="marker-end"] {
1093
+ align-items: center;
1094
+ display: flex;
1095
+
1096
+ &:after {
1097
+ color: var(--diffs-fg-conflict-marker);
1098
+ font-size: .75rem;
1099
+ font-style: normal;
1100
+ line-height: 1.25rem;
1101
+ font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
1102
+ padding-left: 1ch;
1103
+ }
1104
+ }
1105
+
1106
+ [data-merge-conflict="marker-start"]:after {
1107
+ content: "(Current Change)";
1108
+ }
1109
+
1110
+ [data-merge-conflict="marker-end"]:after {
1111
+ content: "(Incoming Change)";
1112
+ }
1113
+
1114
+ [data-merge-conflict-actions-content] {
1115
+ min-height: 1.75rem;
1116
+ font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
1117
+ color: var(--diffs-fg);
1118
+ align-items: center;
1119
+ gap: .25rem;
1120
+ padding-inline: .5rem;
1121
+ font-size: .75rem;
1122
+ line-height: 1.2;
1123
+ display: flex;
1124
+ }
1125
+
1126
+ [data-merge-conflict-action] {
1127
+ appearance: none;
1128
+ color: var(--diffs-fg-number);
1129
+ font: inherit;
1130
+ cursor: pointer;
1131
+ background: none;
1132
+ border: 0;
1133
+ padding: 0;
1134
+ font-style: normal;
1135
+ }
1136
+
1137
+ [data-merge-conflict-action]:hover {
1138
+ color: var(--diffs-fg);
1139
+ }
1140
+
1141
+ [data-merge-conflict-action="current"]:hover {
1142
+ color: var(--diffs-addition-base);
1143
+ }
1144
+
1145
+ [data-merge-conflict-action="incoming"]:hover {
1146
+ color: var(--diffs-modified-base);
1147
+ }
1148
+
1149
+ [data-merge-conflict-action-separator] {
1150
+ color: var(--diffs-fg-number);
1151
+ opacity: .6;
1152
+ user-select: none;
1153
+ }
1154
+
1155
+ [data-diffs-header="default"] {
1156
+ background-color: var(--diffs-bg);
1157
+ justify-content: space-between;
1158
+ align-items: center;
1159
+ gap: var(--diffs-gap-inline, var(--diffs-gap-fallback));
1160
+ min-height: calc(1lh + (var(--diffs-gap-block, var(--diffs-gap-fallback)) * 3));
1161
+ z-index: 2;
1162
+ flex-direction: row;
1163
+ padding-inline: 16px;
1164
+ display: flex;
1165
+ position: relative;
1166
+ top: 0;
1167
+ }
1168
+
1169
+ [data-header-content] {
1170
+ align-items: center;
1171
+ gap: var(--diffs-gap-inline, var(--diffs-gap-fallback));
1172
+ white-space: nowrap;
1173
+ flex-direction: row;
1174
+ min-width: 0;
1175
+ display: flex;
1176
+ }
1177
+
1178
+ [data-header-content] [data-prev-name], [data-header-content] [data-title] {
1179
+ text-overflow: ellipsis;
1180
+ white-space: nowrap;
1181
+ direction: rtl;
1182
+ min-width: 0;
1183
+ overflow: hidden;
1184
+ }
1185
+
1186
+ [data-prev-name] {
1187
+ opacity: .7;
1188
+ }
1189
+
1190
+ [data-rename-icon] {
1191
+ fill: currentColor;
1192
+ flex-grow: 0;
1193
+ flex-shrink: 0;
1194
+ }
1195
+
1196
+ [data-diffs-header="default"] [data-metadata] {
1197
+ white-space: nowrap;
1198
+ align-items: center;
1199
+ gap: 1ch;
1200
+ display: flex;
1201
+ }
1202
+
1203
+ [data-diffs-header="default"] [data-additions-count] {
1204
+ font-family: var(--diffs-font-family, var(--diffs-font-fallback));
1205
+ color: var(--diffs-addition-base);
1206
+ }
1207
+
1208
+ [data-diffs-header="default"] [data-deletions-count] {
1209
+ font-family: var(--diffs-font-family, var(--diffs-font-fallback));
1210
+ color: var(--diffs-deletion-base);
1211
+ }
1212
+
1213
+ [data-change-icon] {
1214
+ fill: currentColor;
1215
+ flex-shrink: 0;
1216
+ }
1217
+
1218
+ [data-change-icon="change"], [data-change-icon="rename-pure"], [data-change-icon="rename-changed"] {
1219
+ color: var(--diffs-modified-base);
1220
+ }
1221
+
1222
+ [data-change-icon="new"] {
1223
+ color: var(--diffs-addition-base);
1224
+ }
1225
+
1226
+ [data-change-icon="deleted"] {
1227
+ color: var(--diffs-deletion-base);
1228
+ }
1229
+
1230
+ [data-change-icon="file"] {
1231
+ opacity: .6;
1232
+ }
1233
+
1234
+ [data-annotation-content] {
1235
+ z-index: 2;
1236
+ isolation: isolate;
1237
+ white-space: normal;
1238
+ align-self: flex-start;
1239
+ min-width: 0;
1240
+ display: flow-root;
1241
+ position: relative;
1242
+ }
1243
+
1244
+ [data-overflow="scroll"] [data-annotation-content], [data-overflow="scroll"] [data-merge-conflict-actions-content] {
1245
+ width: var(--diffs-column-content-width, auto);
1246
+ left: var(--diffs-column-number-width, 0);
1247
+ position: sticky;
1248
+ }
1249
+
1250
+ [data-annotation-slot] {
1251
+ text-wrap-mode: wrap;
1252
+ word-break: normal;
1253
+ white-space-collapse: collapse;
1254
+ }
1255
+
1256
+ [data-gutter-utility-slot] {
1257
+ touch-action: none;
1258
+ justify-content: flex-end;
1259
+ display: flex;
1260
+ position: absolute;
1261
+ top: 0;
1262
+ bottom: 0;
1263
+ right: 0;
1264
+ }
1265
+
1266
+ [data-utility-button] {
1267
+ appearance: none;
1268
+ cursor: pointer;
1269
+ width: 1lh;
1270
+ height: 1lh;
1271
+ font-size: var(--diffs-font-size, 13px);
1272
+ line-height: var(--diffs-line-height, 20px);
1273
+ background-color: var(--diffs-modified-base);
1274
+ color: var(--diffs-bg);
1275
+ fill: currentColor;
1276
+ z-index: 4;
1277
+ touch-action: none;
1278
+ border: none;
1279
+ border-radius: 4px;
1280
+ justify-content: center;
1281
+ align-items: center;
1282
+ margin-right: calc(-1lh + 1ch);
1283
+ padding: 0;
1284
+ display: flex;
1285
+ position: relative;
1286
+
1287
+ &:before {
1288
+ content: "";
1289
+ display: block;
1290
+ position: absolute;
1291
+ inset: 0 0 0 -4px;
1292
+ }
1293
+ }
1294
+
1295
+ [data-decoration-bar-stack] {
1296
+ pointer-events: none;
1297
+ isolation: isolate;
1298
+ z-index: 1;
1299
+ background-color: var(--diffs-decoration-bar-color, transparent);
1300
+ box-sizing: content-box;
1301
+ border-left: 2px solid var(--diffs-bg);
1302
+ border-right: 2px solid var(--diffs-bg);
1303
+ width: 6px;
1304
+ position: absolute;
1305
+ top: 0;
1306
+ bottom: 0;
1307
+ right: -2px;
1308
+
1309
+ [data-decoration-bar-depth="1"] & {
1310
+ background-color: color-mix(in lab,
1311
+ var(--diffs-bg) 20%,
1312
+ var(--diffs-decoration-bar-color, transparent));
1313
+ }
1314
+
1315
+ [data-decoration-bar-depth="2"] & {
1316
+ background-color: color-mix(in lab,
1317
+ var(--diffs-bg) 45%,
1318
+ var(--diffs-decoration-bar-color, transparent));
1319
+ }
1320
+
1321
+ [data-decoration-bar-depth="3"] & {
1322
+ background-color: color-mix(in lab,
1323
+ var(--diffs-bg) 65%,
1324
+ var(--diffs-decoration-bar-color, transparent));
1325
+ }
1326
+
1327
+ [data-decoration-bar-start] & {
1328
+ border-top-left-radius: 5px;
1329
+ border-top-right-radius: 5px;
1330
+ }
1331
+
1332
+ [data-decoration-bar-end] & {
1333
+ z-index: 3;
1334
+ border-bottom-right-radius: 5px;
1335
+ border-bottom-left-radius: 5px;
1336
+ }
1337
+ }
1338
+
1339
+ [data-placeholder] {
1340
+ contain: strict;
1341
+ }
1342
+
1343
+ [data-error-wrapper] {
1344
+ padding: var(--diffs-gap-block, var(--diffs-gap-fallback))
1345
+ var(--diffs-gap-inline, var(--diffs-gap-fallback));
1346
+ scrollbar-width: none;
1347
+ max-height: 400px;
1348
+ overflow: auto;
1349
+
1350
+ & [data-error-message] {
1351
+ color: var(--diffs-deletion-base);
1352
+ font-size: 18px;
1353
+ font-weight: bold;
1354
+ }
1355
+
1356
+ & [data-error-stack] {
1357
+ color: var(--diffs-fg-number);
1358
+ }
1359
+ }
1360
+ }
1361
+
1362
+ @layer theme, rendered, unsafe;
1363
+ `;const lo="@layer base, theme, rendered, unsafe;",lh=new RegExp(`${dh(Ss)}\\s*:\\s*[^;]+;`);function ho(e){return`${lo}
1364
+ @layer unsafe {
1365
+ ${e}
1366
+ }`}function co(e,t="system",n){return`${lo}
1367
+ @layer rendered {
1368
+ :host {${t==="system"?"":`
1369
+ color-scheme: ${t};`}
1370
+ ${ao(n)}
1371
+ ${e}
1372
+ }
1373
+ }`}function uo(e,t){const n=ao(t);return e.replace(lh,n)}function dh(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fo(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function kr(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:fo(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader!=null?"custom":"default"}}function dn({code:e,pre:t,columnType:n,rowSpan:i,containerSize:r=!1}={}){return e==null&&(e=document.createElement("code"),e.setAttribute("data-code",""),n!=null&&e.setAttribute(`data-${n}`,""),t?.appendChild(e)),i!=null?e.style.setProperty("grid-row",`span ${i}`):e.style.removeProperty("grid-row"),r?e.setAttribute("data-container-size",""):e.removeAttribute("data-container-size"),e}function pi(e,t){const n=e?.offsetHeight??0;if(e==null||n===0){t();return}e.style.minHeight=`${n}px`;try{t(),e.offsetHeight}finally{e.style.minHeight=""}}function po({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===""){t?.remove();return}return t??=hh(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function hh(){const e=document.createElement("style");return e.setAttribute(ta,""),e}let ch,uh;function In(){return ch??=/macOS|MacIntel|iPhone|iPad|iPod/i.test(fh())}function yn(){return uh??="safari"in window&&"pushNotification"in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function fh(){const e=globalThis.navigator;return e?.platform??e?.userAgentData?.platform??"unknown"}function go(e,t){if(t==null)return;const n=e.shadowRoot??e.attachShadow({mode:"open"});n.innerHTML===""&&(n.innerHTML=t)}function mo(e,{type:t,diffIndicators:n,disableBackground:i,disableLineNumbers:r,overflow:s,split:o,totalLines:a,customProperties:l}){if(l!=null)for(const h in l){const d=l[h];d!=null&&e.setAttribute(h,`${d}`)}switch(t==="diff"?(e.setAttribute("data-diff",""),e.removeAttribute("data-file")):(e.setAttribute("data-file",""),e.removeAttribute("data-diff")),n){case"bars":case"classic":e.setAttribute("data-indicators",n);break;case"none":e.removeAttribute("data-indicators");break}return r?e.setAttribute("data-disable-line-numbers",""):e.removeAttribute("data-disable-line-numbers"),i?e.removeAttribute("data-background"):e.setAttribute("data-background",""),t==="diff"?e.setAttribute("data-diff-type",o?"split":"single"):e.removeAttribute("data-diff-type"),e.setAttribute("data-overflow",s),e.style.setProperty("--diffs-min-number-column-width-default",`${`${a}`.length}ch`),e}if(typeof HTMLElement<"u"&&customElements.get("diffs-container")==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;const i=this.attachShadow({mode:"open"});e==null&&(e=new CSSStyleSheet,e.replaceSync(ah)),i.adoptedStyleSheets=[e]}connectedCallback(){Pt(this.shadowRoot??this.attachShadow({mode:"open"}))}}customElements.define(vs,t)}const ph=[""];let gh=-1;var mh=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++gh}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:J},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new rh(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new qs,this.interactionManager=new Ks("file",bn(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(bn(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!mt(this.appliedThemeCSS.theme,this.options.theme??J)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e==="wrap",columnVariables:this.shouldApplyColumnVariables(e)?"apply":"measure"}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e==="scroll"&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:i=!1,file:r,lineAnnotations:s}=e;if(!this.enabled)throw new Error("File.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw new Error("File.hydrate: hydrate can only be called before the instance has rendered or hydrated");this.hydrateElements(t,n),vh(this.pre,r,this.options.collapsed)||Sh(this.headerElement,r,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:r,lineAnnotations:s}),i||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),go(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(kr(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):ph}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file,i=this.lineAnnotations,r=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(s=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(s,t,n,i,r)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.fileRenderer.beginEditSession();const t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.fileRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),()=>{this.editor=void 0,this.fileRenderer.endEditSession()}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t,n){this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render(e){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");const t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:i=!1,containerWrapper:r,deferManagers:s=!1,lineAnnotations:o,renderRange:a}){this.editor?.__postponeBgTokenizeToNextFrame();const{collapsed:l=!1,themeType:h="system"}=this.options,d=l?void 0:a,c=this.renderRange,u=this.hasThemeChanged(),f=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1,p=!we(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!l&&!n&&Rn(d,this.renderRange)&&!p&&!f&&!u)return this.applyCachedThemeState(h);this.renderRange=d,p&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(kr(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:g=!1,disableFileHeader:m=!1}=this.options;if(m&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,r),this.applyCachedThemeState(h),l){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const v=this.fileRenderer.renderFile(e,bs);v!=null&&this.applyThemeState(t,v.themeStyles,h,v.baseThemeType),v?.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.injectUnsafeCSS()}catch(v){if(g)throw v;console.error(v),v instanceof Error&&this.applyErrorToDOM(v,t)}return i||this.emitPostRender(),!0}try{const v=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,f,p||u)||!this.applyPartialRender(c,d)){const S=this.fileRenderer.renderFile(e,d);if(S==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,S.themeStyles,h,S.baseThemeType),S.headerAST!=null&&this.applyHeaderToDOM(S.headerAST,t),this.applyFullRender(S,v)}this.applyBuffers(v,d),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,s||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(v){if(g)throw v;console.error(v),v instanceof Error&&this.applyErrorToDOM(v,t)}return i||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const i=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,i)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.file){const{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||ii(e))return;const n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(i=>{console.error(i)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,i]of this.lineAnnotations.entries()){const r=`${n}-${be(i)}`;let s=this.annotationCache.get(r);if(s==null||!sh(i,s.annotation)){s?.element.remove();const o=t(i);if(o==null)continue;s={element:ro(be(i)),annotation:i},s.element.appendChild(o),this.fileContainer.appendChild(s.element),this.annotationCache.set(r,s)}e.delete(r)}for(const[n,{element:i}]of e.entries())this.annotationCache.delete(n),i.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=so();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=oo(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=ho(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,i){const r=e.shadowRoot??e.attachShadow({mode:"open"}),s=i??n,o=this.options.theme??J,a=typeof o=="string"?o:{...o},l=Pt(r);if(this.themeCSSStyle?.parentNode===r&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===s&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=a;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===r){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:a,themeStyles:t,themeType:s,baseThemeType:i,scrollbarGutter:l};return}this.themeCSSStyle=po({shadowRoot:r,currentNode:this.themeCSSStyle,themeCSS:co(t,s,l)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:a,themeStyles:t,themeType:s,baseThemeType:i,scrollbarGutter:l}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=uo(this.themeCSSStyle.textContent??"",Pt(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&yn()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);const n=this.code=dn({code:this.code}),i=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();const r=()=>{if(n.childElementCount>=2)for(let s=0;s<2;s++){const o=n.children[s],a=i[s];o.innerHTML=fe(a.children),o.style.cssText=a.properties.style}else n.innerHTML=fe(i);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?pi(t,r):r(),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:i}=this,r=i!=null?this.getColumns(i):void 0;if(n==null||i==null||r==null)return!1;const s=e.startingLine,o=t.startingLine,a=e.totalLines===1/0?Number.POSITIVE_INFINITY:s+e.totalLines,l=t.totalLines===1/0?Number.POSITIVE_INFINITY:o+t.totalLines,h=Math.max(s,o),d=Math.min(a,l);if(d<=h)return!1;if(!this.trimDOMToOverlap(r.gutter,h,d)||!this.trimDOMToOverlap(r.content,h,d))throw new Error("File.applyPartialRender: failed to trim to overlap");let{length:c}=r.content.children;const u=(m,v)=>{if(!(v<=0))return this.fileRenderer.renderFile(n,{startingLine:m,totalLines:v,bufferBefore:0,bufferAfter:0})},f=o<h?u(o,h-o):void 0;if(f===void 0&&o<h)return!1;const p=l===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,l-d),g=l>d?u(d,p):void 0;return g===void 0&&l>d?!1:(this.cleanupErrorWrapper(),f!=null&&(r.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.gutterAST)),r.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.contentAST)),c+=f.rowCount),g!=null&&(r.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.gutterAST)),r.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.contentAST)),c+=g.rowCount),this.lastRowCount!==c&&(r.gutter.style.setProperty("grid-row",`span ${c}`),r.content.style.setProperty("grid-row",`span ${c}`),this.lastRowCount=c),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const i=this.getDOMBoundaryIndices(e,[t,n]),r=i.get(t)??e.children.length,s=i.get(n)??e.children.length;if(r>s)return!1;for(let o=e.children.length-1;o>=s;o-=1)e.children[o]?.remove();for(let o=r-1;o>=0;o-=1)e.children[o]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((a,l)=>a-l),i=new Map;if(n.length===0)return i;let r=0,s=n[r];const{children:o}=e;s===0&&(i.set(0,0),r+=1,s=n[r]);for(let a=0;a<o.length;a+=1){const l=o[a];if(!(l instanceof HTMLElement))continue;const h=this.getLineIndexFromDOMNode(l);if(h!=null){for(;s!=null&&h>=s;)i.set(s,a),r+=1,s=n[r];if(r>=n.length)break}}for(const a of n)i.has(a)||i.set(a,o.length);return i}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const i=this.cachedHeaderHTML??fe(e);if(this.cachedHeaderHTML=i,i!==this.lastRenderedHeaderHTML){const l=document.createElement("div");l.innerHTML=i;const h=l.firstElementChild;if(!(h instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(h,this.headerElement):t.shadowRoot?.prepend(h),this.headerElement=h,this.lastRenderedHeaderHTML=i}if(this.isContainerManaged)return;const{renderHeaderPrefix:r,renderHeaderFilenameSuffix:s,renderCustomHeader:o,renderHeaderMetadata:a}=this.options;if(o!=null){const l=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Dt,l),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const l=r?.(n)??void 0,h=s?.(n)??void 0,d=a?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Hi,l),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Pi,h),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Oi,d),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,i){if(i==null){t?.remove();return}const r=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(r),this.replaceHeaderSlotContent(r,i),r}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,i=e??n??document.createElement("diffs-container"),r=n!==i;return n!=null&&r&&this.editor?.__captureFocusForDOMReplacement(),r&&this.emitPostRender(!0),this.fileContainer=i,n!=null&&r&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),r&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:Ht(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):Ht(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=no;const i=n.firstChild;i instanceof SVGElement&&(this.spriteSVG=i)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:i=!1}=this.options,r={type:"file",split:!1,overflow:n,disableLineNumbers:i,diffIndicators:"none",disableBackground:!0,totalLines:t};io(r,this.appliedPreAttributes)||(mo(e,r),this.appliedPreAttributes=r)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const i=document.createElement("div");i.dataset.errorMessage="",i.innerText=e.message,this.errorWrapper.appendChild(i);const r=document.createElement("pre");r.dataset.errorStack="",r.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(r)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function vh(e,t,n=!1){return!n&&e==null&&t!=null}function Sh(e,t,n=!1){return e==null&&t!=null&&!n}const bh=5e3;let Ch=-1;function yh(e,t){return(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var Lh=class extends mh{virtualizer;metrics;__id=`virtualized-file:${++Ch}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=Di,i,r=!1){super(e,i,r),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){const n=on(e);!t&&ft(this.metrics,n)||(this.metrics=n,this.resetLayoutCache())}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache()}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}hasLineAnnotations(){return this.lineAnnotations.some(e=>e.lineNumber>0)}getLineHeight(e,t=!1){const n=this.cache.heights.get(e);if(n!=null)return n;const i=t?2:1;return this.metrics.lineHeight*i}setOptions(e){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(e==null)return;const{options:t}=this,n=!Tn(t,e),i=yh(t,e);super.setOptions(e),i&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,i)}setThemeType(e){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&t&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(e=!0),this.height=0,e;const{overflow:t="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),t==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return e;const n=this.code.children[1];if(!(n instanceof HTMLElement))return e;const i=ci(this.lineAnnotations);if(this.renderRange!=null&&i&&An(this.renderRange)){const r=xh(n)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,e=!0)}else!i&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,e=!0);for(const r of n.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const o=Number(s);let a=r.getBoundingClientRect().height,l=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(l=!0),a+=r.nextElementSibling.getBoundingClientRect().height);const h=this.getLineHeight(o,l);a!==h&&(e=!0,a===this.metrics.lineHeight*(l?2:1)?this.cache.heights.delete(o):this.cache.heights.set(o,a))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(e,t,n,i){const r=this.syncLineAnnotations(i),s=!we(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);let o=n?.resetFileLayoutCache===!0||s||r;n?.metrics!=null&&(this.metrics=n.metrics,o=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,o=!0),o&&this.resetLayoutCache(),this.file!==e&&(this.layoutDirty=!0),this.file=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e){if(this.file==null||e<1)return;const{disableFileHeader:t=!1,collapsed:n=!1}=this.options,i=this.fileRenderer.getLineCount(this.file)-1;let r=Ee(this.metrics,t);if(n||i<0)return{top:r,height:0};const s=Math.min(Math.max(e-1,0),i),{overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics;if(r+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())return{top:r+s*a,height:a};const l=this.getLayoutCheckpointBeforeLineIndex(s);r=l?.top??r;for(let h=l?.lineIndex??0;h<s;h++)r+=this.getLineHeight(h,!1);return{top:r,height:this.getLineHeight(s,!1)}}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:t=!1,collapsed:n=!1,overflow:i="scroll"}=this.options;if(n||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=Ee(this.metrics,t),o=Math.min(this.renderRange.startingLine,r),a=Math.min(o+this.renderRange.totalLines-1,r);if(a<o)return;const{fileAnnotationHeight:l}=this.cache;if(i==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:d}=this.metrics,c=s+(o===0?l:this.renderRange.bufferBefore),u=o+Math.max(Math.ceil((e-c)/d),0);return u>a?void 0:{lineNumber:u+1,top:s+l+u*d}}let h=s+(o===0?l:this.renderRange.bufferBefore);for(let d=o;d<=a;d++){if(h>=e)return{lineNumber:d+1,top:h};h+=this.getLineHeight(d)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const t=e!=null?this.computeRenderRangeFromWindow(this.file,this.top,e):this.renderRange;if(t==null)return;const{bufferBefore:n,bufferAfter:i,totalLines:r}=t;let s=0;if(r===0){const o=e??this.virtualizer.getWindowSpecs();this.top<o.top&&(s=i)}return{topOffset:this.top+n+s,height:this.height-(n+i)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(e)}computeApproximateSize(e=!1,t=this.file){const n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;const i=this.height===0;if(this.height=0,this.cache.checkpoints=[],t==null){this.layoutDirty=!1;return}const{disableFileHeader:r=!1,collapsed:s=!1,overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(t),h=Ee(this.metrics,r),d=gn(this.metrics);if(this.height+=h,s){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())this.height+=l*a;else for(let c=0;c<l;c++)this.addLayoutCheckpoint(c,this.height),this.height+=this.getLineHeight(c,!1);if(l>0&&(this.height+=d),this.fileContainer!=null&&n&&!i){const c=this.fileContainer.getBoundingClientRect();c.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:t.name,elementHeight:c.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){const{renderRange:i}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&i!==void 0&&this.file!==void 0){const r=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(this.file,this.top??0,r);s.bufferAfter!==i.bufferAfter&&this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}renderPreparedFile({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:i,...r}){const s=this.file==null||!we(this.file,t)||this.fileRenderer.hasUnkeyedFileContentsChanged(t),{forceRenderOverride:o,isSetup:a}=this;this.forceRenderOverride=void 0;const l=this.syncLineAnnotations(i);if(l&&this.resetLayoutCache(),e=this.getOrCreateFileContainerNode(e),t==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(a)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,t));else{this.computeApproximateSize(!1,t);const f=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(f==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");f.connect(e,this),this.isVisible=f.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!s||!a))return this.file=t,s&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);const h=this.virtualizer.getWindowSpecs(),d=this.top??0,c=this.computeRenderRangeFromWindow(t,d,h),u=super.renderPreparedFile({file:t,fileContainer:e,renderRange:c,lineAnnotations:i,forceRender:(o??n)||l||s,...r});return this.isSimpleMode()&&u&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),u}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(e,t){e%bh===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,i;for(;t<=n;){const r=t+n>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=e?(i=s,t=r+1):n=r-1}return i}getLayoutCheckpointBeforeTop(e,t){let n=0,i=this.cache.checkpoints.length-1,r=-1;for(;n<=i;){const s=n+i>>1,o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");o.top<=e?(r=s,n=s+1):i=s-1}if(t==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(o.lineIndex%t===0)return o}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:i}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:o,lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(e),h=this.height,d=Ee(this.metrics,r),c=l>0?gn(this.metrics):0,{fileAnnotationHeight:u}=this.cache,f=d+u,p=Math.max(0,h-d-u-c),g=ci(this.lineAnnotations),m=t+d,v=u>0&&g&&m<i&&m+u>n;if(t<n-h||t>i)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-d-c};if(l<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};const S=Math.ceil(Math.max(i-n,0)/a),C=Math.ceil(S/o)*o+o,b=C/o,y=(n+i)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const z=t+f,ee=z+p;if(!v&&!(z<i&&ee>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-d-c};const ie=Math.floor(v&&y<t+f?0:(y-(t+f))/a),oe=Math.floor(ie/o)-Math.floor(b/2),re=Math.ceil(l/o),M=Math.max(0,Math.min(oe,re))*o,U=oe<0?C+oe*o:C,K=M===0?0:u+M*a,ae=Math.min(U,l-M);return{startingLine:M,totalLines:U,bufferBefore:K,bufferAfter:Math.max(0,(l-M-ae)*a)}}const L=b,k=[],E=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*a*2),o);let x=t+(E?.top??f),w=E?.lineIndex??0,O,T,R;const _=E?.lineIndex??0;for(let z=_;z<l;z++){const ee=w%o===0,ie=Math.floor(w/o);if(ee&&(k[ie]=x-(t+f),R!=null)){if(R<=0)break;R--}const oe=this.getLineHeight(z,!1);x>n-oe&&x<i&&(O??=ie),x+oe>y&&(T??=ie),R==null&&x>=i&&ee&&(R=L),w++,x+=oe}if(O==null)if(v)O=0,T=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-d-c};T??=O;const $=Math.round(T-b/2),H=Math.max(0,Math.ceil(l/o)-b),D=Math.max(0,Math.min($,H)),B=D*o,Z=$<0?C+$*o:C,V=k[D]??0,A=B===0?0:u+V,P=D+Z/o,N=P<k.length?p-k[P]:p-(x-t-f);return{startingLine:B,totalLines:Z,bufferBefore:A,bufferAfter:Math.max(0,N)}}};function xh(e){let t;for(const n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===js&&(t=Math.max(t??0,n.getBoundingClientRect().height));return t}async function gi(e,t=300){let n;try{await Promise.race([e(),new Promise(i=>{n=setTimeout(i,t)})])}finally{n!=null&&clearTimeout(n)}}function kh({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:i,expandUnchanged:r,expandedHunks:s,collapsedContextThreshold:o,canHydratePartialDiff:a}){let l=Ee(t,n),h=l;const d=r?!0:s,c=e.hunks.length-1;for(let u=0;u<e.hunks.length;u++){const f=e.hunks[u];if(f==null)throw new Error("computeEstimatedDiffHeights: invalid hunk index");const p=Ne({isPartial:e.isPartial,rangeSize:f.collapsedBefore,expandedHunks:d,hunkIndex:u,collapsedContextThreshold:o}),g=(p.fromStart+p.fromEnd)*t.lineHeight;if(l+=g,h+=g,p.collapsedLines>0){const S=Lt({type:i,metrics:t,hunkIndex:u,hunkSpecs:f.hunkSpecs})?.totalHeight??0;l+=S,h+=S}l+=f.splitLineCount*t.lineHeight,h+=f.unifiedLineCount*t.lineHeight;const m=wh(f);l+=m.split*t.lineHeight,h+=m.unified*t.lineHeight;const v=u===c?ze({fileDiff:e,hunkIndex:u,expandedHunks:d,collapsedContextThreshold:o,errorPrefix:"computeEstimatedDiffHeights"}):void 0;if(v!=null){const S=(v.fromStart+v.fromEnd)*t.lineHeight;if(l+=S,h+=S,v.collapsedLines>0){const C=qe({type:i,metrics:t})?.totalHeight??0;l+=C,h+=C}}else if(u===c&&e.isPartial&&a){const S=qe({type:i,metrics:t})?.totalHeight??0;l+=S,h+=S}}if(e.hunks.length>0){const u=gn(t);l+=u,h+=u}return{splitHeight:l,unifiedHeight:h}}function wh(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};const t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type==="context"){const n=t.lines>0?1:0;return{split:n,unified:n}}return Eh(e,t)}function Eh(e,t){const n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),i=t.deletions>0&&e.noEOFCRDeletions,r=t.additions>0&&e.noEOFCRAdditions;return{split:i||r?1:0,unified:n}}function mi({oldFile:e,newFile:t},n){if(!(e===void 0&&t===void 0)){if(e===void 0||t===void 0)throw new Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw new Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return t===null?{oldFile:e,newFile:t}:{oldFile:e,newFile:t}}}function Th(e){return{...e,hunks:e.hunks.map(t=>({...t,hunkContent:t.hunkContent.map(n=>({...n}))})),deletionLines:[...e.deletionLines],additionLines:[...e.additionLines]}}function vi(e){return e!==""?e.split(Xo):[]}function Si(e,t,n){const i=e==="clone"?Th(t):t;if(!i.isPartial)throw new Error("hydratePartialDiff: fileDiff must be partial");switch(i.type){case"change":case"rename-changed":return Ah(i,Ih(i,n),wr(i,n));case"rename-pure":{const r=wr(i,n);Mh(i,n);const s=vi(r.contents);return i.isPartial=!1,i.deletionLines=s,i.additionLines=s,vo(i,null,r),i}}throw new Error(`hydratePartialDiff: ${i.type} diffs cannot be hydrated from loaded files`)}function Ah(e,t,n){const i=vi(t.contents),r=vi(n.contents),{hunks:s,splitLineCount:o,unifiedLineCount:a}=Rh(e.hunks,r.length);return e.hunks=s,e.splitLineCount=o,e.unifiedLineCount=a,e.isPartial=!1,e.deletionLines=i,e.additionLines=r,vo(e,t,n),e}function Rh(e,t){let n=0,i=0,r=0;const s=[];for(const o of e){const a=Math.max(o.additionStart-1,0),l=Math.max(o.deletionStart-1,0);let h=a,d=l,c=0,u=0,f=0,p=0;const g=[];for(const v of o.hunkContent){if(v.type==="context"){g.push({...v,additionLineIndex:h,deletionLineIndex:d}),h+=v.lines,d+=v.lines,f+=v.lines,p+=v.lines;continue}g.push({...v,additionLineIndex:h,deletionLineIndex:d}),h+=v.additions,d+=v.deletions,c+=v.additions,u+=v.deletions,f+=Math.max(v.additions,v.deletions),p+=v.additions+v.deletions}const m=Math.max(Ae(o.additionStart,o.additionCount)-r,0);s.push({...o,collapsedBefore:m,additionLineIndex:a,deletionLineIndex:l,additionLines:c,deletionLines:u,hunkContent:g,splitLineStart:n+m,unifiedLineStart:i+m,splitLineCount:f,unifiedLineCount:p}),n+=m+f,i+=m+p,r=pe(o.additionStart,o.additionCount)}if(s.length>0){const o=s[s.length-1],a=pe(o.additionStart,o.additionCount),l=Math.max(t-a,0);n+=l,i+=l}return{hunks:s,splitLineCount:n,unifiedLineCount:i}}function Ih(e,t){if(t.oldFile==null)throw new Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function wr(e,t){if(t.newFile==null)throw new Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Mh(e,t){if(t.oldFile!==null)throw new Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function Hh(e,t,n){return e.cacheKey!=null?`${e.cacheKey}:hydrated`:Ph(t,n)}function vo(e,t,n){const i=Hh(e,t,n);if(i==null){delete e.cacheKey;return}e.cacheKey=i}function Ph(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?`${e.cacheKey}:${t.cacheKey}`:void 0:e?.cacheKey??t?.cacheKey}var Oh=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&(this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,this.enabled=!1)}setup(e,t,n){if(t==null||n==null)for(const i of e.children??[])i instanceof HTMLElement&&("deletions"in i.dataset?t=i:"additions"in i.dataset&&(n=i));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener("scroll",this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener("scroll",this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function bi(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function jt(e){return F({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function Kt(e){return F({tagName:"div",children:[F({tagName:"span",children:[Te("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":e,"data-column-content":""}})}function Vn(e){return F({tagName:"div",children:[pn({name:e==="both"?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{role:"button","data-expand-button":"","data-expand-both":e==="both"?"":void 0,"data-expand-up":e==="up"?"":void 0,"data-expand-down":e==="down"?"":void 0}})}function it({type:e,content:t,expandIndex:n,chunked:i=!1,slotName:r,isFirstHunk:s,isLastHunk:o}){let a=0;const l=[];if(e==="metadata"&&t!=null&&l.push(F({tagName:"div",children:[Te(t)],properties:{"data-separator-wrapper":""}})),(e==="line-info"||e==="line-info-basic")&&t!=null){const h=[];n!=null&&(i?(s||(h.push(Vn("up")),a++),o||(h.push(Vn("down")),a++)):(h.push(Vn(!s&&!o?"both":s?"down":"up")),a++)),h.push(F({tagName:"div",children:[F({tagName:"span",children:[Te(t)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),i&&n!=null&&h.push(F({tagName:"div",children:[Te("Expand all")],properties:{role:"button","data-expand-button":"","data-expand-all-button":""}})),l.push(F({tagName:"div",children:h,properties:{"data-separator-wrapper":"","data-separator-multi-button":a>1?"":void 0}}))}return e==="custom"&&r!=null&&l.push(F({tagName:"slot",properties:{name:r}})),F({tagName:"div",children:l,properties:{"data-separator":l.length===0?"simple":e,"data-expand-index":n,"data-separator-first":s?"":void 0,"data-separator-last":o?"":void 0}})}function Dh(e,t){return`hunk-separator-${e}-${t}`}function _h(e){const t=e.at(-1);return t==null?0:Math.max(pe(t.additionStart,t.additionCount),pe(t.deletionStart,t.deletionCount))}let Fh=-1;var Nh=class{options;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++Fh}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang="text";renderCache;editSessionActive=!1;constructor(e={theme:J},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=Tt(e.theme??J)?Rs():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this),this.endEditSession()}beginEditSession(){this.editSessionActive=!0;const e=this.diffCache;e!=null&&!e.isPartial&&e.additionLines.length===0&&(Object.assign(e,an(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache())}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){const{renderCache:e}=this;if(e==null||sn(e.diff)||Xt(e.diff,this.getTokenizeMaxLength()))return Promise.resolve();const{diff:t}=e,{workerManager:n}=this;return!this.editSessionActive&&n?.isWorkingPool()===!0&&t.cacheKey!=null?(n.evictDiffFromCache(t.cacheKey),n.primeDiffHighlightCache(t).then(()=>{this.applyRefreshedResult(t,n.getDiffResultCache(t))}).catch(i=>this.onHighlightError(i))):this.asyncHighlight(t).then(i=>this.applyRefreshedResult(t,i)).catch(i=>this.onHighlightError(i))}applyRefreshedResult(e,t){if(t==null||this.renderCache==null||this.renderCache.diff!==e||this.editSessionActive)return;const{options:n}=this.getRenderOptions(e);nt(n,t.options)&&(this.renderCache={diff:e,options:t.options,highlighted:!0,result:t.result,renderRange:void 0},this.onRenderUpdate?.())}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){const e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.diff.cacheKey!=null&&this.workerManager?.evictDiffFromCache(e.diff.cacheKey)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){const i={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t==="up"||t==="both")&&(i.fromStart+=n),(t==="down"||t==="both")&&(i.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,i)}getExpandedHunk(e){return this.expandedHunks.get(e)??da}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(const t of e){const n=(()=>{switch(t.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),i=n[t.lineNumber]??[];n[t.lineNumber]=i,i.push(t)}}updateRenderCache(e,t,n=!1){if(this.renderCache==null)return!1;const{result:i,diff:r}=this.renderCache;if(i==null)return!1;if(r.isPartial)throw new Error("Could not update render cache for partial diff");const s=i.code.additionLines,o=[],a=new Map;for(const[h,d]of e){const c=s[h]?.properties??{},u=d.map(m=>m[2]).join(""),f=h<r.additionLines.length,p=f?r.additionLines[h]??"":"",g=Fe(p);f&&(r.additionLines[h]=Zs(p,u),g!==u&&(o.push(h),a.set(h,p))),s[h]={type:"element",tagName:"div",properties:{"data-line":c["data-line"]??h+1,"data-line-index":c["data-line-index"]??h,"data-line-type":c["data-line-type"]??"context"},children:d.map(([m,v,S])=>m===0&&v===""?S===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:S}:{type:"element",tagName:"span",properties:{"data-char":m,style:`color:${v};`},children:[{type:"text",value:S}]})}}let l=!1;if(o.length>0)if(this.editSessionActive&&!r.isPartial){if(!n)if(r.additionLines.length<=1&&r.additionLines.join("")==="")Object.assign(r,an(r,this.options.parseDiffOptions)),this.markEditSessionPass(r),l=!0;else if(li(r,r.additionLines))Object.assign(r,vn(r,r.additionLines,this.options.parseDiffOptions)),this.markEditSessionPass(r),l=!0;else{const h=yd(r,o,this.options.parseDiffOptions,a);this.applyExpansionRemap(h),l=h!=null}}else Object.assign(r,pd(r,o,this.options.parseDiffOptions));return i.baseThemeType=t,this.renderCache.isDirty=!0,l}applyExpansionRemap(e){e!=null&&(this.expandedHunks=wd(this.expandedHunks,e))}applyDocumentChange(e){if(this.renderCache==null)return;const{diff:t,result:n}=this.renderCache;if(n==null)return;if(t.isPartial)throw new Error("Could not apply document change for partial diff");const{additionLines:i}=t;t.additionLines=Uh(e,i),n.code.additionLines=Vh(i,t.additionLines,n.code.additionLines,e),t.additionLines.length<=1&&t.additionLines.join("")===""?(Object.assign(t,an(t,this.options.parseDiffOptions)),n.code.additionLines[0]=Ci(0,e.getLineText(0)),this.markEditSessionPass(t)):this.editSessionActive?this.applySessionDocumentChange(t):Object.assign(t,Us(t,this.options.parseDiffOptions)),this.renderCache.isDirty=!0}applySessionDocumentChange(e){const{parseDiffOptions:t}=this.options,n=e.additionLines;if(li(e,n)){Object.assign(e,vn(e,n,t)),this.markEditSessionPass(e);return}this.applyExpansionRemap(di(e,t))}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){const n=t==="change"?e==="deletions"?"change-deletion":"change-addition":t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>fi(e);getOptionsWithDefaults(){const{diffIndicators:e="bars",diffStyle:t="split",disableBackground:n=!1,disableFileHeader:i=!1,disableLineNumbers:r=!1,disableVirtualizationBuffers:s=!1,collapsed:o=!1,expandUnchanged:a=!1,collapsedContextThreshold:l=1,expansionLineCount:h=100,hunkSeparators:d="line-info",lineDiffType:c="word-alt",maxLineDiffLength:u=1e3,overflow:f="scroll",stickyHeader:p=!1,theme:g=J,headerRenderMode:m="default",tokenizeMaxLineLength:v=1e3,tokenizeMaxLength:S=oa,useTokenTransformer:C=!1,useCSSClasses:b=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:i,disableLineNumbers:r,disableVirtualizationBuffers:s,collapsed:o,expandUnchanged:a,collapsedContextThreshold:l,expansionLineCount:h,hunkSeparators:d,lineDiffType:c,maxLineDiffLength:u,overflow:f,stickyHeader:p,theme:this.workerManager?.getDiffRenderOptions().theme??g,headerRenderMode:m,tokenizeMaxLineLength:v,tokenizeMaxLength:S,useTokenTransformer:C,useCSSClasses:b}}async initializeHighlighter(){return this.highlighter=await As(to(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;const{options:t}=this.getRenderOptions(e),n=Xt(e,this.getTokenizeMaxLength());let i=this.workerManager?.getDiffResultCache(e);i!=null&&!nt(t,i.options)&&(i=void 0),this.renderCache??={diff:e,highlighted:!n&&!sn(e),options:t,result:n?void 0:i?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter==null&&(this.computedLang=e.lang??he(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??J}getEffectiveCodeOptions(){const e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){const t=(()=>{if(this.workerManager?.isWorkingPool()===!0){const a=this.workerManager.getDiffRenderOptions();return this.editSessionActive&&a.useTokenTransformer!==!0?{...a,useTokenTransformer:!0}:a}const{theme:i,tokenizeMaxLineLength:r,lineDiffType:s,maxLineDiffLength:o}=this.getOptionsWithDefaults();return{theme:i,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:r,lineDiffType:s,maxLineDiffLength:o}})();this.getOptionsWithDefaults();const{renderCache:n}=this;return n?.result==null?{options:t,forceHighlight:!0}:!st(e,n.diff)||!nt(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=cn){if(e==null)return;const{expandUnchanged:n,collapsedContextThreshold:i}=this.getOptionsWithDefaults();let{options:r,forceHighlight:s}=this.getRenderOptions(e);const o=this.getMatchingWorkerResultCache(e,r);o!=null&&!this.hasHighlightedRenderCache(e,r)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},s=!1),this.renderCache??={diff:e,highlighted:!1,options:r,result:void 0,renderRange:void 0};const a=e.additionLines.length>0||e.deletionLines.length>0,l=!a||sn(e)||Xt(e,this.getTokenizeMaxLength()),h=!st(e,this.renderCache.diff),d=!Rn(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){const c=this.renderCache.result==null&&this.renderCache.highlighted&&!l&&!h&&bi(t);c&&(this.renderCache.highlightPending=!0),!c&&(l||this.renderCache.result==null||!this.renderCache.highlighted&&(h||d))&&(this.renderCache.diff=e,this.renderCache.options=r,this.renderCache.highlighted=!1,(this.renderCache.result==null||h||d||s)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,bi(t)||n?!0:this.expandedHunks,i)),this.renderCache.renderRange=t),!l&&a&&(!this.renderCache.highlighted||s)&&this.workerManager.highlightDiffAST(this,e)}else{this.computedLang=e.lang??he(e.name);const c=this.highlighter!=null&&Tt(r.theme),u=this.highlighter!=null&&Cn(this.computedLang),f=!l&&u;if(this.highlighter!=null&&c&&(s||l||!this.renderCache.highlighted&&f||this.renderCache.result==null)){const{result:p,options:g}=this.renderDiffWithHighlighter(e,this.highlighter,l||!u);this.renderCache={diff:e,options:g,highlighted:f,result:p,renderRange:void 0}}(!c||!l&&!u)&&this.asyncHighlight(e).then(({result:p,options:g})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,p,g,!l)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,t,this.renderCache.result):void 0}async asyncRender(e,t=cn){const{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){const{diffIndicators:i,disableBackground:r,disableLineNumbers:s,overflow:o}=this.getOptionsWithDefaults();return eo({type:"diff",diffIndicators:i,disableBackground:r,disableLineNumbers:s,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){const t=Xt(e,this.getTokenizeMaxLength());this.computedLang=t?"text":e.lang??he(e.name);const n=this.highlighter!=null&&Tt(this.getLocalHighlightTheme()),i=t||this.highlighter!=null&&Cn(this.computedLang);return(this.highlighter==null||!n||!i)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){const{options:i}=this.getRenderOptions(e),{collapsedContextThreshold:r}=this.getOptionsWithDefaults(),s=Fl(e,t,i,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:r});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===""&&s.code.additionLines[0]==null){let o;if(Xe({diff:e,diffStyle:"both",expandedHunks:n?!0:void 0,collapsedContextThreshold:r,callback:({additionLine:a})=>{if(a?.lineIndex===0)return o=a,!0}}),o==null)throw new Error("DiffHunksRenderer: missing empty addition line");s.code.additionLines[0]=Ci(0,"",o.unifiedLineIndex,o.splitLineIndex)}return{result:s,options:i}}onHighlightSuccess(e,t,n,i=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,i)}applyHighlightResult(e,t,n,i=!0){if(this.renderCache==null)return;const r=this.renderCache.highlightPending===!0||!this.renderCache.highlighted||!nt(this.renderCache.options,n)||!st(this.renderCache.diff,e);this.renderCache={diff:e,options:n,highlighted:i,result:t,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;const n=this.workerManager?.getDiffResultCache(e);if(!(n==null||!nt(t,n.options)))return n}hasHighlightedRenderCache(e,t){const{renderCache:n}=this;return n?.result!=null&&n.highlighted&&st(e,n.diff)&&nt(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:i,baseThemeType:r}){const{diffStyle:s,disableFileHeader:o,expandUnchanged:a,expansionLineCount:l,collapsedContextThreshold:h,hunkSeparators:d}=this.getOptionsWithDefaults(),c=this.renderCache?.isDirty??!1;this.diff=e;const u=s==="unified",f=Gh(e,this.options.loadDiffFiles!=null),p=!e.isPartial||f;let g=[],m=[],v=[];const S=[],{additionLines:C,deletionLines:b}=n,y={rowCount:0,hunkSeparators:d,additionsContentAST:g,deletionsContentAST:m,unifiedContentAST:v,unifiedGutterAST:rt(),deletionsGutterAST:rt(),additionsGutterAST:rt(),expansionLineCount:l,hunkData:S,incrementRowCount(H=1){y.rowCount+=H},pushToGutter(H,D){switch(H){case"unified":y.unifiedGutterAST.children.push(D);break;case"deletions":y.deletionsGutterAST.children.push(D);break;case"additions":y.additionsGutterAST.children.push(D);break}}},L=Ds({fileDiff:e,errorPrefix:"DiffHunksRenderer.processDiffResult"}),k={size:0,side:void 0,increment(){this.size+=1},flush(){if(s!=="unified"){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side==="additions"?(y.pushToGutter("additions",ge(void 0,"buffer",this.size)),g?.push(jt(this.size))):(y.pushToGutter("deletions",ge(void 0,"buffer",this.size)),m?.push(jt(this.size))),this.size=0,this.side=void 0}}},E=(H,D,B,Z,V)=>{y.pushToGutter(H,Is(D,B,Z,V))};function x(H){k.flush(),s==="unified"?Un("unified",H,y):(Un("deletions",H,y),Un("additions",H,y))}this.pushFileLevelAnnotations(e,s,t,y),Xe({diff:e,diffStyle:s,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:a?!0:this.expandedHunks,collapsedContextThreshold:h,callback:({hunkIndex:H,hunk:D,collapsedBefore:B,collapsedAfter:Z,additionLine:V,deletionLine:A,type:P})=>{const N=A!=null?A.splitLineIndex:V.splitLineIndex,z=V!=null?V.unifiedLineIndex:A.unifiedLineIndex;s==="split"&&P!=="change"&&k.flush(),B>0&&x({hunkIndex:H,collapsedLines:B,rangeSize:Math.max(D?.collapsedBefore??0,0),hunkSpecs:D?.hunkSpecs,isFirstHunk:H===0,isLastHunk:!1,isExpandable:p});const ee=s==="unified"?z:N,ie={type:P,hunkIndex:H,lineIndex:ee,unifiedLineIndex:z,splitLineIndex:N,deletionLine:A,additionLine:V};if(s==="unified"){const X=this.getUnifiedInjectedRowsForLine?.(ie);X?.before!=null&&Tr(X.before,y);let te=A!=null?b[A.lineIndex]:void 0,le=V!=null?C[V.lineIndex]:void 0;if(te==null&&le==null){const Ce="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(Ce,{file:e.name}),new Error(Ce)}const ye=P==="change"?V!=null?"change-addition":"change-deletion":P,de=this.getUnifiedLineDecoration({type:P,lineType:ye,additionLineIndex:V?.lineIndex,deletionLineIndex:A?.lineIndex});E("unified",de.gutterLineType,V!=null?V.lineNumber:A.lineNumber,`${z},${N}`,de.gutterProperties),le!=null?le=Yt(le,de.contentProperties,c&&V!=null?{"data-line":V.lineNumber,"data-line-index":`${z},${N}`}:void 0):te!=null&&(te=Yt(te,de.contentProperties,c&&A!=null?{"data-line":A.lineNumber,"data-line-index":`${z},${N}`}:void 0)),qt({diffStyle:"unified",type:P,deletionLine:te,additionLine:le,unifiedSpan:this.getAnnotations("unified",A?.lineNumber,V?.lineNumber,H,ee),createAnnotationElement:Ce=>this.createAnnotationElement(Ce),context:y}),X?.after!=null&&Tr(X.after,y)}else{const X=this.getSplitInjectedRowsForLine?.(ie);X?.before!=null&&Ar(X.before,y,k);let te=A!=null?b[A.lineIndex]:void 0,le=V!=null?C[V.lineIndex]:void 0;const ye=this.getSplitLineDecoration({side:"deletions",type:P,lineIndex:A?.lineIndex}),de=this.getSplitLineDecoration({side:"additions",type:P,lineIndex:V?.lineIndex});if(te==null&&le==null){const ce="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(ce,{file:e.name}),new Error(ce)}const Ce=(()=>{if(P==="change"){if(le==null)return"additions";if(te==null)return"deletions"}})();Ce!=null?(k.side!=null&&k.side!==Ce&&k.flush(),k.side=Ce,k.increment()):P==="change"&&k.flush();const Ve=this.getAnnotations("split",A?.lineNumber,V?.lineNumber,H,ee);if(Ve!=null&&k.size>0&&k.flush(),A!=null){const ce=Yt(te,ye.contentProperties,c?{"data-line":A.lineNumber,"data-line-index":`${A.unifiedLineIndex},${N}`}:void 0);E("deletions",ye.gutterLineType,A.lineNumber,`${A.unifiedLineIndex},${N}`,ye.gutterProperties),ce!=null&&(te=ce)}if(V!=null){const ce=Yt(le,de.contentProperties,c?{"data-line":V.lineNumber,"data-line-index":`${V.unifiedLineIndex},${N}`}:void 0);E("additions",de.gutterLineType,V.lineNumber,`${V.unifiedLineIndex},${N}`,de.gutterProperties),ce!=null&&(le=ce)}qt({diffStyle:"split",type:P,additionLine:le,deletionLine:te,...Ve,createAnnotationElement:ce=>this.createAnnotationElement(ce),context:y}),X?.after!=null&&Ar(X.after,y,k)}const oe=s==="split"&&D!=null&&N===D.splitLineStart+D.splitLineCount-1,re=H===e.hunks.length-1&&D!=null&&(s==="split"?N===D.splitLineStart+D.splitLineCount-1:z===D.unifiedLineStart+D.unifiedLineCount-1),M=oe?D.noEOFCRDeletions:!1,U=oe?D.noEOFCRAdditions:!1,K=(A?.noEOFCR??!1)||M,ae=(V?.noEOFCR??!1)||U;if(ae||K){if(s==="split"&&k.flush(),K){const X=P==="context"||P==="context-expanded"?P:"change-deletion";s==="unified"?(y.unifiedContentAST.push(Kt(X)),y.pushToGutter("unified",ge(X,"metadata",1))):(y.deletionsContentAST.push(Kt(X)),y.pushToGutter("deletions",ge(X,"metadata",1)),ae||(y.pushToGutter("additions",ge(void 0,"buffer",1)),y.additionsContentAST.push(jt(1))))}if(ae){const X=P==="context"||P==="context-expanded"?P:"change-addition";s==="unified"?(y.unifiedContentAST.push(Kt(X)),y.pushToGutter("unified",ge(X,"metadata",1))):(y.additionsContentAST.push(Kt(X)),y.pushToGutter("additions",ge(X,"metadata",1)),K||(y.pushToGutter("deletions",ge(void 0,"buffer",1)),y.deletionsContentAST.push(jt(1))))}y.incrementRowCount(1)}d!=="simple"&&d!=="metadata"&&(Z>0||re&&f)&&x({hunkIndex:P==="context-expanded"?H:H+1,collapsedLines:re&&f?"unknown":Z,rangeSize:L,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:p}),y.incrementRowCount(1)}}),s==="split"&&k.flush();const w=Math.max(_h(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),O=t.bufferBefore>0||t.bufferAfter>0,T=!u&&e.type!=="deleted",R=!u&&e.type!=="new",_=y.rowCount>0||O;g=T&&_?g:void 0,m=R&&_?m:void 0,v=u&&_?v:void 0;const $=this.createPreElement(m!=null&&g!=null,w);return{unifiedGutterAST:u&&_?y.unifiedGutterAST.children:void 0,unifiedContentAST:v,deletionsGutterAST:R&&_?y.deletionsGutterAST.children:void 0,deletionsContentAST:m,additionsGutterAST:T&&_?y.additionsGutterAST.children:void 0,additionsContentAST:g,hunkData:S,preNode:$,themeStyles:i,baseThemeType:r,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:w,rowCount:y.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderCodeAST(e,t){const n=e==="unified"?t.unifiedGutterAST:e==="deletions"?t.deletionsGutterAST:t.additionsGutterAST,i=e==="unified"?t.unifiedContentAST:e==="deletions"?t.deletionsContentAST:t.additionsContentAST;if(n==null||i==null)return;const r=rt(n);return r.properties.style=`grid-row: span ${t.rowCount}`,[r,Js(i,t.rowCount)]}renderFullAST(e,t=[]){const n=this.getOptionsWithDefaults().hunkSeparators==="line-info",i=this.renderCodeAST("unified",e);if(i!=null)return t.push(F({tagName:"code",children:i,properties:{"data-code":"","data-container-size":n?"":void 0,"data-unified":""}})),{...e.preNode,children:t};const r=this.renderCodeAST("deletions",e);r!=null&&t.push(F({tagName:"code",children:r,properties:{"data-code":"","data-container-size":n?"":void 0,"data-deletions":""}}));const s=this.renderCodeAST("additions",e);return s!=null&&t.push(F({tagName:"code",children:s,properties:{"data-code":"","data-container-size":n?"":void 0,"data-additions":""}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return fe(this.renderFullAST(e,t))}renderPartialHTML(e,t){return t==null?fe(e):fe(F({tagName:"code",children:e,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${t}`]:""}}))}pushFileLevelAnnotations(e,t,n,i){if(!An(n))return;const r=e.type!=="new"?Er(ui(this.deletionAnnotations)):[],s=e.type!=="deleted"?Er(ui(this.additionAnnotations)):[];if(r.length===0&&s.length===0)return;const o=-1,a=-1,{createAnnotationElement:l}=this;if(t==="unified"){qt({diffStyle:t,type:"context",unifiedSpan:{type:"annotation",hunkIndex:o,lineIndex:a,annotations:r.concat(s)},createAnnotationElement:l,context:i});return}qt({diffStyle:t,type:"context",deletionSpan:{type:"annotation",hunkIndex:o,lineIndex:a,annotations:r},additionSpan:{type:"annotation",hunkIndex:o,lineIndex:a,annotations:s},createAnnotationElement:l,context:i})}getAnnotations(e,t,n,i,r){const s={type:"annotation",hunkIndex:i,lineIndex:r,annotations:[]};if(t!=null)for(const a of this.deletionAnnotations[t]??[])s.annotations.push(be(a));const o={type:"annotation",hunkIndex:i,lineIndex:r,annotations:[]};if(n!=null)for(const a of this.additionAnnotations[n]??[])(e==="unified"?s:o).annotations.push(be(a));if(e==="unified")return s.annotations.length>0?s:void 0;if(!(o.annotations.length===0&&s.annotations.length===0))return{deletionSpan:s,additionSpan:o}}renderHeader(e){const{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return Qs({fileOrDiff:e,mode:t,stickyHeader:n})}};function Er(e){return e?.map(t=>be(t))??[]}const zh=new Intl.PluralRules("en-US");function Bh(e){return`${e} unmodified line${zh.select(e)==="one"?"":"s"}`}function Tr(e,t){for(const n of e)t.unifiedContentAST.push(n.content),t.pushToGutter("unified",n.gutter),t.incrementRowCount(1)}function Ar(e,t,n){for(const{deletion:i,addition:r}of e){if(i==null&&r==null)continue;const s=i!=null&&r!=null?void 0:i==null?"deletions":"additions";(s==null||n.side!==s)&&n.flush(),i!=null&&(t.deletionsContentAST.push(i.content),t.pushToGutter("deletions",i.gutter)),r!=null&&(t.additionsContentAST.push(r.content),t.pushToGutter("additions",r.gutter)),s!=null&&(n.side=s,n.increment()),t.incrementRowCount(1)}}function qt({diffStyle:e,type:t,deletionLine:n,additionLine:i,unifiedSpan:r,deletionSpan:s,additionSpan:o,createAnnotationElement:a,context:l}){let h=!1;if(e==="unified"){if(i!=null?l.unifiedContentAST.push(i):n!=null&&l.unifiedContentAST.push(n),r!=null){const d=t==="change"?n!=null?"change-deletion":"change-addition":t;l.unifiedContentAST.push(a(r)),l.pushToGutter("unified",ge(d,"annotation",1)),h=!0}}else if(e==="split"){if(n!=null&&l.deletionsContentAST.push(n),i!=null&&l.additionsContentAST.push(i),s!=null){const d=t==="change"?n!=null?"change-deletion":"context":t;l.deletionsContentAST.push(a(s)),l.pushToGutter("deletions",ge(d,"annotation",1)),h=!0}if(o!=null){const d=t==="change"?i!=null?"change-addition":"context":t;l.additionsContentAST.push(a(o)),l.pushToGutter("additions",ge(d,"annotation",1)),h=!0}}h&&l.incrementRowCount(1)}function Un(e,{hunkIndex:t,collapsedLines:n,rangeSize:i,hunkSpecs:r,isFirstHunk:s,isLastHunk:o,isExpandable:a},l){if(typeof n=="number"&&n<=0)return;const h=e==="unified"?l.unifiedContentAST:e==="deletions"?l.deletionsContentAST:l.additionsContentAST;if(l.hunkSeparators==="metadata"){r!=null&&(l.pushToGutter(e,it({type:"metadata",content:r,isFirstHunk:s,isLastHunk:o})),h.push(it({type:"metadata",content:r,isFirstHunk:s,isLastHunk:o})),e!=="additions"&&l.incrementRowCount(1));return}if(l.hunkSeparators==="simple"){t>0&&(l.pushToGutter(e,it({type:"simple",isFirstHunk:s,isLastHunk:!1})),h.push(it({type:"simple",isFirstHunk:s,isLastHunk:!1})),e!=="additions"&&l.incrementRowCount(1));return}const d=Dh(e,t),c=i>l.expansionLineCount,u=a?t:void 0,f=typeof n=="number"?Bh(n):"More unchanged context may be available";l.pushToGutter(e,it({type:l.hunkSeparators,content:f,expandIndex:u,chunked:c,slotName:d,isFirstHunk:s,isLastHunk:o})),h.push(it({type:l.hunkSeparators,content:f,expandIndex:u,chunked:c,slotName:d,isFirstHunk:s,isLastHunk:o})),e!=="additions"&&l.incrementRowCount(1),l.hunkData.push({slotName:d,hunkIndex:t,lines:typeof n=="number"?n:0,lineCountKnown:typeof n=="number",type:e,expandable:a?{up:!s,down:!o,chunked:c}:void 0})}function Yt(e,t,n){return e==null||e.type!=="element"||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function Rr(e){return e.length>0&&e[e.length-1]===""?e.length-1:e.length}function Vh(e,t,n,i){const r=Rr(e),s=Rr(t),o=Math.min(r,s);let a=0;for(;a<o&&e[a]===t[a];)a++;let l=0;for(;l<o-a&&e[r-1-l]===t[s-1-l];)l++;const h=new Array(t.length);for(let d=0;d<a;d++)h[d]=n[d];for(let d=0;d<l;d++)h[s-1-d]=n[r-1-d];r<e.length&&s<t.length&&(h[t.length-1]=n[e.length-1]);for(let d=e.length;d<t.length;d++)h[d]??=n[d];for(let d=a;d<t.length;d++)h[d]??=Ci(d,i.getLineText(d));return h}function Ci(e,t,n=e,i=e){return{type:"element",tagName:"div",properties:{"data-line":e+1,"data-line-index":`${n},${i}`,"data-line-type":"context"},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:t}]}]}}function Uh(e,t){const n=[],i=$h(t);for(let r=0;r<e.lineCount;r++){const s=e.getLineText(r,!0);n.push(r<e.lineCount-1&&!Wh(s)?s+i:s)}return n}function Wh(e){return e.endsWith(`
1374
+ `)||e.endsWith("\r")}function $h(e){for(const t of e){if(t.endsWith(`\r
1375
+ `))return`\r
1376
+ `;if(t.endsWith(`
1377
+ `))return`
1378
+ `;if(t.endsWith("\r"))return"\r"}return`
1379
+ `}function Xt(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function Gh(e,t){return e.isPartial&&t&&(e.type==="change"||e.type==="rename-changed")}function jh(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function Kh(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function qh(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:fo(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader!=null?"custom":"default"}}function Yh(e){return e.isPartial&&(e.type==="change"||e.type==="rename-changed"||e.type==="rename-pure")}let Xh=-1;var Zh=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++Xh}`;type="file-diff";fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;pendingFiles;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:J},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new qs,this.scrollSyncManager=new Oh,this.interactionManager=new Ks("diff",bn(e,typeof e.hunkSeparators=="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getHunksRendererOptions(e){return qh(e)}createHunksRenderer(e){return new Nh(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t="additions")=>{const n=this.fileDiffCache;if(n==null)return;const i=n.hunks.at(-1);let r,s;e:for(const o of n.hunks){const a=t==="deletions"?o.deletionStart:o.additionStart,l=t==="deletions"?o.deletionCount:o.additionCount;let h=Ae(a,l)+1,d=o.splitLineStart,c=o.unifiedLineStart;if(e<h){const u=h-e;r=Math.max(c-u,0),s=Math.max(d-u,0);break e}if(e>=h+l){if(o===i){const u=e-(h+l);r=c+o.unifiedLineCount+u,s=d+o.splitLineCount+u;break e}continue}for(const u of o.hunkContent)if(u.type==="context")if(e<h+u.lines){const f=e-h;s=d+f,r=c+f;break e}else h+=u.lines,d+=u.lines,c+=u.lines;else{const f=t==="deletions"?u.deletions:u.additions;if(e<h+f){const p=e-h;r=c+(t==="additions"?u.deletions:0)+p,s=d+p;break e}else h+=f,d+=Math.max(u.deletions,u.additions),c+=u.deletions+u.additions}break e}if(!(r==null||s==null))return[r,s]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(bn(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!mt(this.appliedThemeCSS.theme,this.options.theme??J)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators=="function")}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}flushDeferredLineState(){const{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{diffStyle:e="split",overflow:t="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t==="wrap",columnVariables:this.shouldApplyColumnVariables(t)?"apply":"measure"}),t==="scroll"&&e==="split"?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators=="function"?!0:e==="scroll"&&(this.lineAnnotations.length>0||this.pre?.hasAttribute("data-has-merge-conflict")===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){Ze(this.handleEditSessionRender),this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.pendingFiles=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:i,fileDiff:r,...s}){if(!this.enabled)throw new Error("FileDiff.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw new Error("FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated");const o=mi(s,"FileDiff.hydrate"),a=o?.oldFile,l=o?.newFile;this.hydrateElements(e,t),ec(this.pre,Jh({fileDiff:r,oldFile:a,newFile:l}),this.options.collapsed)||tc(this.headerElement,Qh({fileDiff:r,oldFile:a,newFile:l}),this.options.disableFileHeader)?this.render({...s,fileContainer:e,lineAnnotations:i,fileDiff:r,preventEmit:!0}):this.hydrationSetup({fileDiff:r,lineAnnotations:i,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),go(e,t);for(const n of e.shadowRoot?.children??[]){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n;for(const i of n.children)!(i instanceof HTMLElement)||i.tagName.toLowerCase()!=="code"||("deletions"in i.dataset&&(this.codeDeletions=i),"additions"in i.dataset&&(this.codeAdditions=i),"unified"in i.dataset&&(this.codeUnified=i));continue}if("diffsHeader"in n.dataset){this.headerElement=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:i}){this.lineAnnotations=i??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?Je(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.loadFilesIfNecessary(),this.rerender()};loadFilesIfNecessary(){const{fileDiff:e,options:{loadDiffFiles:t}}=this;e==null||t==null||!Yh(e)||this.pendingFiles?.fileDiff===e||(this.pendingFiles={fileDiff:e,promise:this.loadFilesForDiff(e,t)})}async loadFilesForDiff(e,t){try{const n=await t(e);if(!this.enabled||this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(n){if(this.options.disableErrorHandling===!0)throw n;console.error(n)}finally{this.pendingFiles?.fileDiff===e&&(this.pendingFiles=void 0)}}async handleFilesLoaded(e,t){this.fileDiff!==e||!e.isPartial||(Si("merge",e,t),this.setHydratedState(t),await gi(()=>this.primeHighlightCache(e)),!(!this.enabled||this.fileDiff!==e)&&this.rerender())}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:i=!1,lineAnnotations:r,fileContainer:s,containerWrapper:o,renderRange:a,...l}){const h=mi(l,"FileDiff.render"),d=h?.oldFile,c=h?.newFile;if(!this.enabled)throw new Error("FileDiff.render: attempting to call render after cleaned up");e!=null&&e.cacheKey===void 0&&(e.cacheKey=e.prevName!=null?e.prevName+":"+e.name:e.name),this.editor?.__postponeBgTokenizeToNextFrame();const{collapsed:u=!1,themeType:f="system",expandUnchanged:p=!1}=this.options,g=u?void 0:a,m=this.hasThemeChanged(),v=h!=null,S=v&&(!Ir(d,this.deletionFile)||!Ir(c,this.additionFile));let C=e!=null&&e!==this.fileDiff;const b=r!=null&&(r.length>0||this.lineAnnotations.length>0)?r!==this.lineAnnotations:!1;if(!u&&Rn(g,this.renderRange)&&!n&&!b&&!m&&(e!=null&&e===this.fileDiff||e==null&&!S))return this.applyCachedThemeState(f);let y;e==null&&v&&(S||this.fileDiff==null)&&(y=Je(h.oldFile,h.newFile,this.options.parseDiffOptions));const{renderRange:L}=this;if(this.renderRange=g,v?(this.deletionFile=d,this.additionFile=c):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null?this.fileDiff=e:y!=null&&(C=!0,this.fileDiff=y),C&&(this.cachedHeaderHTML=void 0),r!=null&&this.setLineAnnotations(r),this.fileDiff==null)return!1;this.fileDiff.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(hi(this.fileDiff,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),p&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:k=!1,disableFileHeader:E=!1}=this.options;if(E&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),s=this.getOrCreateFileContainer(s,o),this.applyCachedThemeState(f),u){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const x=this.hunksRenderer.renderDiff(this.fileDiff,bs);x!=null&&this.applyThemeState(s,x.themeStyles,f,x.baseThemeType),x?.headerElement!=null&&this.applyHeaderToDOM(x.headerElement,s),this.renderSeparators([]),this.injectUnsafeCSS()}catch(x){if(k)throw x;console.error(x),x instanceof Error&&this.applyErrorToDOM(x,s)}return i||this.emitPostRender(),!0}try{const x=this.getOrCreatePreNode(s);if(!(this.canPartiallyRender(n,b,S||C||m)&&this.applyPartialRender({previousRenderRange:L,renderRange:g}))){const w=this.hunksRenderer.renderDiff(this.fileDiff,g);if(w==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(s,w.themeStyles,f,w.baseThemeType),w.headerElement!=null&&this.applyHeaderToDOM(w.headerElement,s),w.additionsContentAST!=null||w.deletionsContentAST!=null||w.unifiedContentAST!=null?this.applyHunksToDOM(x,w):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(w.hunkData)}this.applyBuffers(x,g),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(x){if(k)throw x;console.error(x),x instanceof Error&&this.applyErrorToDOM(x,s)}return i||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,"unmount");return}if(t==null)return;const i=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,i)}get fileDiffCache(){return this.hunksRenderer.diffCache??this.fileDiff}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.fileDiffCache,i=this.lineAnnotations,r=this.computeEditorRenderRange(this.renderRange);e!=null&&t!=null&&n!=null&&!n.isPartial&&this.hunksRenderer.initializeHighlighter().then(s=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.fileDiffCache!==n||e.__syncRenderView(s,t,n,i,r)})}computeEditorRenderRange(e){const t=this.fileDiffCache;if(e==null||t==null||bi(e))return e;const{diffStyle:n="split",expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options;let s,o;return Xe({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,callback:({additionLine:a})=>{a!=null&&(s??=a.lineNumber,o=a.lineNumber)}}),s==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:s-1,totalLines:o-s+1}}attachEditor(e){if(this.type!=="file-diff")throw new Error(`FileDiff.attachEditor: cannot attach an editor to a "${this.type}" diff`);return this.editor?.cleanUp(),this.editor=e,this.hunksRenderer.beginEditSession(),this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary(),this.hunksRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),t=>{this.editor=void 0,t!==!0&&this.finishEditSession()}}finishEditSession(){this.hunksRenderer.endEditSession(),this.completeEditSession()}completeEditSession(){const e=this.fileDiffCache;if(e==null||e.editSessionDirty!==!0)return!1;const{collapsedContextThreshold:t=1}=this.options,n=Ed(e,this.hunksRenderer.getExpandedHunksMap(),t);return hi(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(Td(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){this.hunksRenderer.applyDocumentChange(e);const n=this.hunksRenderer.diffCache;if(n!=null){const i=this.fileDiff?.cacheKey;i!=null&&n.cacheKey==null&&(n.cacheKey=i),this.fileDiff=n}t!==void 0&&t!==this.lineAnnotations&&(this.setLineAnnotations(t),this.hunksRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations()),this.rerender(),this.interactionManager.setSelectionDirty()}updateRenderCache(e,t,n={}){const{shouldRefreshDiffsView:i,lineCountChangeInFlight:r}=n;if(this.hunksRenderer.updateRenderCache(e,t,r)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}i===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle==="split"?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}isLineRenderable(e){const t=this.fileDiffCache;if(t==null)return!0;const{expandUnchanged:n=!1,collapsedContextThreshold:i=1}=this.options;return _s({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}getNearestRenderableLine(e,t){const n=this.fileDiffCache;if(n==null)return e;const{expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options;return ml({fileDiff:n,lineNumber:e,direction:t,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}revealLine(e){const t=this.fileDiffCache,{expandUnchanged:n=!1,collapsedContextThreshold:i=1,expansionLineCount:r=100}=this.options;if(t==null||t.isPartial||n)return!1;const s=this.hunksRenderer.getExpandedHunksMap();for(const[h,d]of t.hunks.entries()){const[c,u]=Mt(d);if(e<c){const f=Ne({isPartial:t.isPartial,rangeSize:d.collapsedBefore,expandedHunks:s,hunkIndex:h,collapsedContextThreshold:i}),p=c-f.rangeSize;if(f.renderAll||e<p+f.fromStart||e>=c-f.fromEnd)return!1;const g=e-(p+f.fromStart)+1,m=c-f.fromEnd-e;return g<=m?this.expandHunk(h,"up",g+r):this.expandHunk(h,"down",m+r),!0}if(e<u)return!1}const o=ze({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:s,collapsedContextThreshold:i,errorPrefix:"FileDiff.revealLine"});if(o==null||o.renderAll)return!1;const a=t.hunks[t.hunks.length-1],[,l]=Mt(a);return e<l+o.fromStart||e>=l+o.rangeSize?!1:(this.expandHunk(t.hunks.length,"up",e-(l+o.fromStart)+1+r),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){Ye(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.fileDiff){const{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||sn(e))return;const n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(i=>{console.error(i)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){const{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!="function"){for(const{element:i}of this.separatorCache.values())i.remove();this.separatorCache.clear();return}const n=new Map(this.separatorCache);for(const i of e){const r=i.slotName;let s=this.separatorCache.get(r);if(s==null||!Kh(i,s.hunkData)){s?.element.remove();const o=document.createElement("div");o.style.display="contents",o.slot=i.slotName;const a=t(i,this);a!=null&&o.appendChild(a),this.fileContainer.appendChild(o),s={element:o,hunkData:i},this.separatorCache.set(r,s)}n.delete(r)}for(const[i,{element:r}]of n.entries())this.separatorCache.delete(i),r.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,i]of this.lineAnnotations.entries()){const r=`${n}-${be(i)}`;let s=this.annotationCache.get(r);if(s==null||!jh(i,s.annotation)){s?.element.remove();const o=t(i);if(o==null)continue;s={element:ro(be(i)),annotation:i},s.element.appendChild(o),this.fileContainer.appendChild(s.element),this.annotationCache.set(r,s)}e.delete(r)}for(const[n,{element:i}]of e.entries())this.annotationCache.delete(n),i.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=so();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){const{fileContainer:n}=this,i=e??n??document.createElement("diffs-container"),r=n!==i;return n!=null&&r&&this.editor?.__captureFocusForDOMReplacement(),r&&this.emitPostRender(!0),this.fileContainer=i,n!=null&&r&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),r&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:Ht(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):Ht(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=no;const i=n.firstChild;i instanceof SVGElement&&(this.spriteSVG=i)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(const t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute("data-unified")?this.codeUnified=t:t.hasAttribute("data-deletions")?this.codeDeletions=t:t.hasAttribute("data-additions")&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const{fileDiff:n}=this,i=this.cachedHeaderHTML??fe(e);if(this.cachedHeaderHTML=i,i!==this.lastRenderedHeaderHTML){const c=document.createElement("div");c.innerHTML=i;const u=c.firstElementChild;if(!(u instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(u,this.headerElement):t.shadowRoot?.prepend(u),this.headerElement=u,this.lastRenderedHeaderHTML=i}if(this.isContainerManaged||n==null)return;const{renderCustomHeader:r,renderHeaderPrefix:s,renderHeaderFilenameSuffix:o,renderHeaderMetadata:a}=this.options;if(r!=null){const c=r(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Dt,c),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}const l=s?.(n)??void 0,h=o?.(n)??void 0,d=a?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Hi,l),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Pi,h),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Oi,d),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,i){if(i==null){t?.remove();return}const r=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(r),this.replaceHeaderSlotContent(r,i),r}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=oo(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=ho(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,i){const r=e.shadowRoot??e.attachShadow({mode:"open"}),s=i??n,o=this.options.theme??J,a=typeof o=="string"?o:{...o},l=Pt(r);if(this.themeCSSStyle?.parentNode===r&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===s&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=a;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===r){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:a,themeStyles:t,themeType:s,baseThemeType:i,scrollbarGutter:l};return}this.themeCSSStyle=po({shadowRoot:r,currentNode:this.themeCSSStyle,themeCSS:co(t,s,l)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:a,themeStyles:t,themeType:s,baseThemeType:i,scrollbarGutter:l}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=uo(this.themeCSSStyle.textContent??"",Pt(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&yn()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?pi(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){const i=this.getColumnPair(e);if(i==null)return!1;const r=We(t[0]),s=We(t[1]);return r==null||s==null?!1:(i.gutter.innerHTML=fe(r),i.content.innerHTML=fe(s),n!==this.lastRowCount&&(i.gutter.style.setProperty("grid-row",`span ${n}`),i.content.style.setProperty("grid-row",`span ${n}`)),!0)}replaceCodeColumns(e,t){const{overflow:n="scroll"}=this.options,i=(this.options.hunkSeparators??"line-info")==="line-info",r=n==="wrap"?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let s=!1;const o=[],a=this.hunksRenderer.renderCodeAST("unified",t),l=this.hunksRenderer.renderCodeAST("deletions",t),h=this.hunksRenderer.renderCodeAST("additions",t);this.editor?.__captureFocusForDOMReplacement(),a!=null?(s=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=dn({code:this.codeUnified,columnType:"unified",rowSpan:r,containerSize:i}),this.applyCodeColumnsInPlace(this.codeUnified,a,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(a)),o.push(this.codeUnified)):l!=null||h!=null?(l!=null?(s=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=dn({code:this.codeDeletions,columnType:"deletions",rowSpan:r,containerSize:i}),this.applyCodeColumnsInPlace(this.codeDeletions,l,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeDeletions)):(this.codeDeletions?.remove(),this.codeDeletions=void 0),h!=null?(s=s||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=dn({code:this.codeAdditions,columnType:"additions",rowSpan:r,containerSize:i}),this.applyCodeColumnsInPlace(this.codeAdditions,h,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(h)),o.push(this.codeAdditions)):(this.codeAdditions?.remove(),this.codeAdditions=void 0)):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0),o.length===0?e.textContent="":s&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){const{pre:n,codeUnified:i,codeAdditions:r,codeDeletions:s,options:{diffStyle:o="split"}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;const a=this.getCodeColumns(o,i,s,r);if(a==null)return!1;const l=e.startingLine,h=t.startingLine,d=l+e.totalLines,c=h+t.totalLines,u=Math.max(l,h),f=Math.min(d,c);if(f<=u)return!1;const p=Math.max(0,u-l),g=Math.max(0,d-f),m=this.trimColumns({columns:a,trimStart:p,trimEnd:g,previousStart:l,overlapStart:u,overlapEnd:f,diffStyle:o});if(m<0)throw new Error("FileDiff.applyPartialRender: failed to trim to overlap");if(this.lastRowCount<m)throw new Error("FileDiff.applyPartialRender: trimmed beyond DOM row count");let v=this.lastRowCount-m;const S=(L,k)=>{if(!(k<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:L,totalLines:k,bufferBefore:0,bufferAfter:0})},C=S(h,Math.max(u-h,0));if(C==null&&h<u)return!1;const b=S(f,Math.max(c-f,0));if(b==null&&c>f)return!1;const y=(L,k)=>{if(L!=null){if(o==="unified"&&!Array.isArray(a))this.insertPartialHTML(o,a,L,k);else if(o==="split"&&Array.isArray(a))this.insertPartialHTML(o,a,L,k);else throw new Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");v+=L.rowCount}};return this.cleanupErrorWrapper(),y(C,"afterbegin"),y(b,"beforeend"),this.lastRowCount!==v&&(this.applyRowSpan(o,a,v),this.lastRowCount=v),!0}insertPartialHTML(e,t,n,i){if(e==="unified"&&!Array.isArray(t)){const r=this.hunksRenderer.renderCodeAST("unified",n);this.renderPartialColumn(t,r,i)}else if(e==="split"&&Array.isArray(t)){const r=this.hunksRenderer.renderCodeAST("deletions",n),s=this.hunksRenderer.renderCodeAST("additions",n);this.renderPartialColumn(t[0],r,i),this.renderPartialColumn(t[1],s,i)}else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition")}refreshSplitDiffView(){if(this.options.diffStyle!=="split")return;const e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;const t=this.getCodeColumns("split",this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(t))return;const n=(i,r)=>{if(r==null)return;const s=this.hunksRenderer.renderCodeAST(i,e),o=We(s?.[0]),a=We(s?.[1]);for(const[l,h]of[[r.gutter,o],[r.content,a]])if(h!=null&&l.childElementCount===h.length)for(let d=0;d<h.length;d++){const c=l.children[d],u=h[d].properties["data-line-type"];u!=null&&c.dataset.lineType!==u&&(c.dataset.lineType=u)}};n("deletions",t[0]),n("additions",t[1])}refreshUnifiedDiffView(){if(this.options.diffStyle!=="unified")return;const e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;const t=this.getCodeColumns("unified",this.codeUnified,this.codeDeletions,this.codeAdditions);if(t==null||Array.isArray(t))return;const n=this.hunksRenderer.renderCodeAST("unified",e),i=We(n?.[0]),r=We(n?.[1]),s=()=>{for(const[o,a]of[[t.gutter,i],[t.content,r]])a!=null&&(o.innerHTML=fe(a));e.rowCount!==this.lastRowCount&&(this.applyRowSpan("unified",t,e.rowCount),this.lastRowCount=e.rowCount)};this.shouldGuardRebuildScroll()?pi(this.pre,s):s(),this.renderSeparators(e.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;const i=We(t[0]),r=We(t[1]);if(i==null||r==null)throw new Error("FileDiff.insertPartialHTML: Unexpected AST structure");const s=r.at(0);n==="beforeend"&&s?.type==="element"&&typeof s.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(s.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],i,r,!0);const o=r.at(-1);n==="afterbegin"&&o?.type==="element"&&typeof o.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(o.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],i,r,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r))}mergeBuffersIfNecessary(e,t,n,i,r,s){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;const o=this.getBufferSize(t.dataset);o!=null&&(s?(i.shift(),r.shift()):(i.pop(),r.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){const i=r=>{r!=null&&(r.gutter.style.setProperty("grid-row",`span ${n}`),r.content.style.setProperty("grid-row",`span ${n}`))};if(e==="unified"&&!Array.isArray(t))i(t);else if(e==="split"&&Array.isArray(t))i(t[0]),i(t[1]);else throw new Error("dun fuuuuked up")}trimColumnRows(e,t,n){let i=0,r=0,s=0,o=!1;const a=n>=0;if(e==null)return 0;const l=Array.from(e.content.children),h=Array.from(e.gutter.children);if(l.length!==h.length)throw new Error("FileDiff.trimColumnRows: columns do not match");for(;s<l.length&&!(t<=0&&!a&&!o);){const d=h[s],c=l[s];if(s++,!(d instanceof HTMLElement)||!(c instanceof HTMLElement))throw console.error({gutterElement:d,contentElement:c}),new Error("FileDiff.trimColumnRows: invalid row elements");if(o&&(o=!1,d.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in c.dataset||d.dataset.gutterBuffer==="metadata"&&"noNewline"in c.dataset)){d.remove(),c.remove(),r++;continue}if("lineIndex"in d.dataset&&"lineIndex"in c.dataset){(t>0||a&&i>=n)&&(d.remove(),c.remove(),t>0&&(t--,t===0&&(o=!0)),r++),i++;continue}if("separator"in d.dataset&&"separator"in c.dataset){(t>0||a&&i>=n)&&(d.remove(),c.remove(),r++);continue}if(d.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in c.dataset){(t>0||a&&i>=n)&&(d.remove(),c.remove(),r++);continue}if(d.dataset.gutterBuffer==="metadata"&&"noNewline"in c.dataset){(t>0||a&&i>=n)&&(d.remove(),c.remove(),r++);continue}if(d.dataset.gutterBuffer==="buffer"&&"contentBuffer"in c.dataset){const u=this.getBufferSize(c.dataset);if(u==null)throw new Error("FileDiff.trimColumnRows: invalid element");if(t>0){const f=Math.min(t,u),p=u-f;p>0?(this.updateBufferSize(d,p),this.updateBufferSize(c,p),r+=f):(d.remove(),c.remove(),r+=u),t-=f,t===0&&p===0&&(o=!0)}else if(a){const f=i,p=i+u-1;if(n<=f)d.remove(),c.remove(),r+=u;else if(n<=p){const g=p-n+1,m=u-g;this.updateBufferSize(d,m),this.updateBufferSize(c,m),r+=g}}i+=u;continue}throw console.error({gutterElement:d,contentElement:c}),new Error("FileDiff.trimColumnRows: unknown row elements")}return r}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:i,previousStart:r,trimEnd:s,trimStart:o}){const a=Math.max(0,i-r),l=n-r;if(l<0)throw new Error("FileDiff.trimColumns: overlap ends before previous");const h=o>0,d=s>0;if(!h&&!d)return 0;const c=h?a:0,u=d?l:-1;if(t==="unified"&&!Array.isArray(e))return this.trimColumnRows(e,c,u);if(t==="split"&&Array.isArray(e)){const f=this.trimColumnRows(e[0],c,u),p=this.trimColumnRows(e[1],c,u);if(e[0]!=null&&e[1]!=null&&f!==p)throw new Error("FileDiff.trimColumns: split columns out of sync");return e[0]!=null?f:p}else throw console.error({diffStyle:t,columns:e}),new Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){const t=Number.parseInt(e?.bufferSize??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}getCodeColumns(e,t,n,i){if(e==="unified")return this.getColumnPair(t);{const r=this.getColumnPair(n),s=this.getColumnPair(i);return r!=null||s!=null?[r,s]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:i},r){const{diffIndicators:s="bars",disableBackground:o=!1,disableLineNumbers:a=!1,overflow:l="scroll",diffStyle:h="split"}=this.options,d={type:"diff",diffIndicators:s,disableBackground:o,disableLineNumbers:a,overflow:l,split:h==="unified"?!1:t!=null&&n!=null,totalLines:i,customProperties:r};io(d,this.appliedPreAttributes)||(mo(e,d),this.appliedPreAttributes=d)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const i=document.createElement("div");i.dataset.errorMessage="",i.innerText=e.message,this.errorWrapper.appendChild(i);const r=document.createElement("pre");r.dataset.errorStack="",r.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(r)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Ir(e,t){return e==null||t==null?e==null&&t==null:we(e,t)}function Jh({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function Qh({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function ec(e,t,n=!1){return!n&&e==null&&t}function tc(e,t,n=!1){return e==null&&t&&!n}function We(e){if(!(e==null||e.type!=="element"))return e.children??[]}const yi=3e3;let nc=-1;var ic=class extends Zh{__id=`little-virtualized-file-diff:${++nc}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;currentExpandUnchanged;pendingHydratedDiff;pendingExpansions;constructor(e,t,n,i,r=!1){super(e,i,r),this.virtualizer=t,this.metrics=on(n)}setMetrics(e,t=!1){const n=on(e);!t&&ft(this.metrics,n)||(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}setFileAnnotationHeight(e){const t=this.cache.fileAnnotationHeight;return e===t?!1:(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e=this.fileDiff){return e==null||!ci(this.lineAnnotations)?!1:this.lineAnnotations.some(t=>t.lineNumber!==0?!1:e.type==="new"?t.side==="additions":e.type==="deleted"?t.side==="deletions":!0)}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){const t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw new Error("VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(e==null)return;const{options:t}=this,n=!Tn(t,e),i=n&&dc(t,e);super.setOptions(e),i&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:hc(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,i)}setThemeType(e){if(this.isAdvancedMode())throw new Error("VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}reconcileHeights(){let e=!1;const{overflow:t="scroll"}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;const n=this.getDiffStyle(),i=n==="split"?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],r=this.hasFileAnnotations(this.fileDiff);if(this.renderRange!=null&&r&&An(this.renderRange)){const s=rc(i)??0;this.setFileAnnotationHeight(s)&&(e=!0)}else!r&&this.setFileAnnotationHeight(0)&&(e=!0);for(const s of i){if(s==null)continue;const o=s.children[1];if(o instanceof HTMLElement)for(const a of o.children){if(!(a instanceof HTMLElement))continue;const l=a.dataset.lineIndex;if(l==null)continue;const h=uc(l,n);let d=a.getBoundingClientRect().height,c=!1;a.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in a.nextElementSibling.dataset||"noNewline"in a.nextElementSibling.dataset)&&("noNewline"in a.nextElementSibling.dataset&&(c=!0),d+=a.nextElementSibling.getBoundingClientRect().height);const u=this.getEstimatedLineHeight(c),f=this.cache.heightDeltas.get(h)??0,p=d-u;p!==f&&(e=!0,this.cache.measuredHeightDeltaTotal+=p-f,p===0?this.cache.heightDeltas.delete(h):this.cache.heightDeltas.set(h,p))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}prepareCodeViewItem(e,t,n,i){const r=!st(this.fileDiff,e),s=this.syncLineAnnotations(i);let o=n?.resetDiffLayoutCache===!0||r||s,a=r||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights;n?.metrics!=null&&(this.metrics=on(n.metrics),o=!0,a=!0);const{collapsed:l=!1,expandUnchanged:h=!1}=this.options;return this.currentCollapsed!==l&&(this.currentCollapsed=l,o=!0),this.currentExpandUnchanged!==h&&(this.currentExpandUnchanged=h,o=!0,a=!0),o&&this.resetLayoutCache({includeEstimatedHeights:a}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t="additions"){if(this.fileDiff==null||e<1)return;const n=this.getLineIndex(e,t);if(n==null)return;const{disableFileHeader:i=!1,expandUnchanged:r=!1,collapsed:s=!1,collapsedContextThreshold:o=1}=this.options,a=this.getDiffStyle(),l=this.getHunkSeparatorType(),h=a==="split"?n[1]:n[0];this.approximateLayoutCheckpoints();const d=Ee(this.metrics,i),c=this.getLayoutCheckpointBeforeLineIndex(h);let u=c?.top??d+this.cache.fileAnnotationHeight;if(s)return{top:d,height:0};let f;return Xe({diff:this.fileDiff,diffStyle:a,startingLine:c?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:p,hunk:g,collapsedBefore:m,collapsedAfter:v,deletionLine:S,additionLine:C})=>{const b=a==="split"?C?.splitLineIndex??S?.splitLineIndex:C?.unifiedLineIndex??S?.unifiedLineIndex;if(b==null)throw new Error("VirtualizedFileDiff.getLinePosition: missing line index data");if(m>0){const L=Lt({type:l,metrics:this.metrics,hunkIndex:p,hunkSpecs:g?.hunkSpecs});if(L!=null){if(u+=L.gapBefore,h>=b-m&&h<b)return f={top:u,height:L.height},!0;u+=L.height+L.gapAfter}}const y=this.getLineHeight(b,(C?.noEOFCR??!1)||(S?.noEOFCR??!1));if(b===h)return f={top:u,height:y},!0;if(u+=y,v>0){const L=qe({type:l,metrics:this.metrics});if(L!=null){if(h>b&&h<=b+v)return f={top:u+L.gapBefore,height:L.height},!0;u+=L.totalHeight}}return!1}}),f}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.fileDiff==null)return;const{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:i=!1,collapsedContextThreshold:r=1}=this.options;if(i)return;const s=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();const a=this.getLayoutCheckpointBeforeTop(e);let l=a?.top??Ee(this.metrics,t)+this.cache.fileAnnotationHeight,h;return Xe({diff:this.fileDiff,diffStyle:s,startingLine:a?.renderedLineIndex??0,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,callback:({hunkIndex:d,hunk:c,collapsedBefore:u,collapsedAfter:f,deletionLine:p,additionLine:g})=>{const m=s==="split"?g?.splitLineIndex??p?.splitLineIndex:g?.unifiedLineIndex??p?.unifiedLineIndex;if(m==null)throw new Error("VirtualizedFileDiff.getNumericScrollAnchor: missing line index data");if(u>0){const S=Lt({type:o,metrics:this.metrics,hunkIndex:d,hunkSpecs:c?.hunkSpecs});S!=null&&(l+=S.totalHeight)}if(l>=e&&(p!=null?h={lineNumber:p.lineNumber,side:"deletions",top:l}:g!=null&&(h={lineNumber:g.lineNumber,side:"additions",top:l}),h!=null))return!0;const v=this.getLineHeight(m,(g?.noEOFCR??!1)||(p?.noEOFCR??!1));if(l+=v,f>0){const S=qe({type:o,metrics:this.metrics});S!=null&&(l+=S.totalHeight)}return!1}}),h}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const t=e!=null?this.computeRenderRangeFromWindow(this.fileDiff,this.top,e):this.renderRange;if(t==null)return;const{bufferBefore:n,bufferAfter:i,totalLines:r}=t;let s=0;if(r===0){const o=e??this.virtualizer.getWindowSpecs();this.top<o.top&&(s=i)}return{topOffset:this.top+n+s,height:this.height-(n+i)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,n)=>{this.fileDiff!=null&&(this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.loadFilesIfNecessary(),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(!(this.fileDiff!==e||!e.isPartial)){if(this.isAdvancedMode()){const n=Si("clone",e,t);if(await gi(()=>this.primeHighlightCache(n)),!this.enabled||this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Si("merge",e,t),this.setHydratedState(t),await gi(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}consumeCodeViewLayoutChanges(e){let t=!1,n;const{pendingExpansions:i,pendingHydratedDiff:r}=this;if(i!=null){this.pendingExpansions=void 0;for(const s of i)this.hunksRenderer.expandHunk(s.hunkIndex,s.direction,s.expansionLineCountOverride),t=!0}return r!=null&&(this.pendingHydratedDiff=void 0,r.expectedDiff===e&&(this.setHydratedState(r.files),n=r.nextDiff)),n!=null?(this.forceRenderOverride=!0,this.resetLayoutCache({includeEstimatedHeights:!0})):t&&(this.forceRenderOverride=!0,this.invalidateDerivedLayoutCache(!0)),n}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;const{pendingExpansions:t}=this,n=this.fileDiffCache;if(t==null||t.length===0||n==null)return!1;const{expansionLineCount:i=100,collapsedContextThreshold:r=1}=this.options,s=new Map(this.hunksRenderer.getExpandedHunksMap());for(const o of t){const a={...s.get(o.hunkIndex)??{fromStart:0,fromEnd:0}},l=o.expansionLineCountOverride??i;(o.direction==="up"||o.direction==="both")&&(a.fromStart+=l),(o.direction==="down"||o.direction==="both")&&(a.fromEnd+=l),s.set(o.hunkIndex,a)}return _s({fileDiff:n,lineNumber:e,expandedHunks:s,collapsedContextThreshold:r})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),!(!this.enabled||this.fileDiff==null)&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){const{renderRange:i}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&i!==void 0&&this.fileDiff!==void 0){const r=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(this.fileDiff,this.top??0,r);s.bufferAfter!==i.bufferAfter&&this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.fileDiff){const n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;const i=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}const{disableFileHeader:r=!1,collapsed:s=!1}=this.options,o=Ee(this.metrics,r);if(this.height+=o,s){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!i&&this.validateComputedHeight(t),this.layoutDirty=!1}getActiveEstimatedHeight(e=this.fileDiff){this.ensureEstimatedDiffHeights(e);const t=this.getDiffStyle()==="split"?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw new Error("VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height");return t}ensureEstimatedDiffHeights(e=this.fileDiff){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;const{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:i=1}=this.options,{splitHeight:r,unifiedHeight:s}=kh({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,canHydratePartialDiff:Wn(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=r,this.cache.estimatedUnifiedHeight=s}validateComputedHeight(e=this.fileDiff){if(this.fileContainer==null||e==null)return;const t=this.fileContainer.getBoundingClientRect();t.height!==this.height?console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:e.name,elementHeight:t.height,computedHeight:this.height}):console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:i,...r}={}){const s=mi(r,"VirtualizedFileDiff.render"),o=s!=null,a=s?.oldFile,l=s?.newFile,h=o&&(!Pr(a,this.deletionFile)||!Pr(l,this.additionFile));let d=t??this.fileDiff;t==null&&o&&(h||this.fileDiff==null)&&(d=Je(s.oldFile,s.newFile,this.options.parseDiffOptions));const{forceRenderOverride:c,isSetup:u}=this;this.forceRenderOverride=void 0;const f=this.syncLineAnnotations(i);f&&this.resetLayoutCache({includeEstimatedHeights:!1});const p=t!=null&&t!==this.fileDiff,g=d!=null&&!st(this.fileDiff,d),m=p||h;if(g&&this.resetLayoutCache({includeEstimatedHeights:!0}),e=this.getOrCreateFileContainer(e),d==null)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(u)this.top??=this.getVirtualizedTop(),g&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,d));else{this.computeApproximateSize(!1,d);const y=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(y==null)throw new Error("VirtualizedFileDiff.render: simple virtualizer is not available");y.connect(e,this),this.isVisible=y.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!m||!u))return this.fileDiff=d,s!=null&&(this.deletionFile=a,this.additionFile=l),g&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);const v=this.virtualizer.getWindowSpecs(),S=this.top??0,C=this.computeRenderRangeFromWindow(d,S,v),b=super.render({fileDiff:d,fileContainer:e,renderRange:C,lineAnnotations:i,forceRender:(c??n)||f||g,...s,...r});return this.isSimpleMode()&&b&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),b}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??"split"}getHunkSeparatorType(){return cc(this.options.hunkSeparators)}approximateLayoutCheckpoints(e=this.fileDiff){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e==null||e.hunks.length===0||this.options.collapsed===!0)return;const{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:i=1}=this.options,r=e.hunks.length-1,s=Wn(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),a=this.getHunkSeparatorType(),l=n?!0:this.hunksRenderer.getExpandedHunksMap(),h=sc(this.cache.heightDeltas);let d=Ee(this.metrics,t)+this.cache.fileAnnotationHeight,c=0;const u=({rowCount:f,startLineIndex:p,preSeparatorHeight:g=0,postSeparatorHeight:m=0,metadataOffsets:v=[]})=>{if(f<=0)return;const S=c,C=c+f;let b=oc(S);for(;b<C;){const y=b-S,L=d+(y>0?g:0)+y*this.metrics.lineHeight+ac(v,y)*this.metrics.lineHeight+Mr(h,p,p+y);this.cache.checkpoints.push({renderedLineIndex:b,lineIndex:p+y,top:L}),b+=yi}d+=g+f*this.metrics.lineHeight+v.length*this.metrics.lineHeight+Mr(h,p,p+f)+m,c=C};for(let f=0;f<e.hunks.length;f++){const p=e.hunks[f];if(p==null)throw new Error("VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index");const g=Ne({isPartial:e.isPartial,rangeSize:p.collapsedBefore,expandedHunks:l,hunkIndex:f,collapsedContextThreshold:i}),m=g.collapsedLines>0?Lt({type:a,metrics:this.metrics,hunkIndex:f,hunkSpecs:p.hunkSpecs})?.totalHeight??0:0;u({rowCount:g.fromStart,startLineIndex:(o==="split"?p.splitLineStart:p.unifiedLineStart)-g.rangeSize});let v=m;u({rowCount:g.fromEnd,startLineIndex:(o==="split"?p.splitLineStart:p.unifiedLineStart)-g.fromEnd,preSeparatorHeight:v}),g.fromEnd>0&&(v=0);const S=f===r?ze({fileDiff:e,hunkIndex:f,expandedHunks:l,collapsedContextThreshold:i,errorPrefix:"VirtualizedFileDiff"}):void 0,C=S!=null&&S.collapsedLines>0?qe({type:a,metrics:this.metrics})?.totalHeight??0:f===r&&s?qe({type:a,metrics:this.metrics})?.totalHeight??0:0,b=S!=null?S.fromStart+S.fromEnd:0,y=o==="split"?p.splitLineCount:p.unifiedLineCount,L=o==="split"?p.splitLineStart:p.unifiedLineStart;u({rowCount:y,startLineIndex:L,preSeparatorHeight:v,postSeparatorHeight:b===0?C:0,metadataOffsets:lc({diffStyle:o,hunk:p,rowCount:y})}),S!=null&&b>0&&u({rowCount:b,startLineIndex:L+y,postSeparatorHeight:C})}this.cache.totalLines=c}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,i;for(;t<=n;){const r=t+n>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");s.lineIndex<=e?(i=s,t=r+1):n=r-1}return i}getLayoutCheckpointBeforeTop(e,t){let n=0,i=this.cache.checkpoints.length-1,r=-1;for(;n<=i;){const s=n+i>>1,o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");o.top<=e?(r=s,n=s+1):i=s-1}if(t==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");if(o.renderedLineIndex%t===0)return o}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(const a of e.hunks)n+=t==="split"?a.splitLineCount:a.unifiedLineCount;return n}const{expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options,s=i?!0:this.hunksRenderer.getExpandedHunksMap();for(const[a,l]of e.hunks.entries()){const h=t==="split"?l.splitLineCount:l.unifiedLineCount;n+=h;const d=Math.max(l.collapsedBefore,0),{fromStart:c,fromEnd:u,renderAll:f}=Ne({isPartial:e.isPartial,rangeSize:d,expandedHunks:s,hunkIndex:a,collapsedContextThreshold:r});d>0&&(n+=f?d:c+u)}const o=ze({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:s,collapsedContextThreshold:r,errorPrefix:"VirtualizedFileDiff"});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){const n=this.getExpandedLineCount(e,t),i=t==="split"?e.splitLineCount:e.unifiedLineCount;return Math.max(n,i,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:i}){const{disableFileHeader:r=!1,expandUnchanged:s=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:a,lineHeight:l}=this.metrics,h=this.getDiffStyle(),d=this.getHunkSeparatorType(),c=Wn(e,this.options.loadDiffFiles!=null),u=this.height;let f=this.getLayoutLineCount(e,h);const p=Ee(this.metrics,r),g=e.hunks.length>0?gn(this.metrics):0,{fileAnnotationHeight:m}=this.cache,v=p+m,S=Math.max(0,u-p-m-g),C=this.hasFileAnnotations(e),b=t+p,y=m>0&&C&&b<i&&b+m>n;if(t<n-u||t>i)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:u-p-g};if(f<=a||e.hunks.length===0)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),f=this.getLayoutLineCount(e,h);const L=Math.ceil(Math.max(i-n,0)/l),k=Math.ceil(L/a)*a+a,E=k/a,x=E,w=[],O=(n+i)/2,T=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-k*l*2),a);let R=t+(T?.top??v),_=T?.renderedLineIndex??0,$,H,D;if(Xe({diff:e,diffStyle:h,startingLine:T?.renderedLineIndex??0,expandedHunks:s?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:oe,hunk:re,collapsedBefore:M,collapsedAfter:U,deletionLine:K,additionLine:ae})=>{const X=ae!=null?ae.splitLineIndex:K.splitLineIndex,te=ae!=null?ae.unifiedLineIndex:K.unifiedLineIndex,le=(ae?.noEOFCR??!1)||(K?.noEOFCR??!1),ye=oe===e.hunks.length-1&&re!=null&&(h==="split"?X===re.splitLineStart+re.splitLineCount-1:te===re.unifiedLineStart+re.unifiedLineCount-1),de=(M>0?Lt({type:d,metrics:this.metrics,hunkIndex:oe,hunkSpecs:re?.hunkSpecs}):void 0)?.totalHeight??0;R+=de;const Ce=_%a===0,Ve=Math.floor(_/a);if(Ce&&(w[Ve]=R-(t+v+de),D!=null)){if(D<=0)return!0;D--}const ce=this.getLineHeight(h==="split"?X:te,le);if(R>n-ce&&R<i&&($??=Ve),H==null&&R+ce>O&&(H=Ve),D==null&&R>=i&&Ce&&(D=x),_++,R+=ce,U>0||ye&&c){const Ft=qe({type:d,metrics:this.metrics});Ft!=null&&(R<i&&R+Ft.totalHeight>n&&($??=Ve),H==null&&R+Ft.totalHeight>O&&(H=Ve),R+=Ft.totalHeight)}return!1}}),$==null)if(y)$=0,H=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:u-p-g};H??=$;const B=Math.round(H-E/2),Z=Math.max(0,Math.ceil(f/a)-E),V=Math.max(0,Math.min(B,Z)),A=V*a,P=B<0?k+B*a:k,N=w[V]??0,z=A===0?0:m+N,ee=V+P/a,ie=ee<w.length?S-w[ee]:S-(R-t-v);return{startingLine:A,totalLines:P,bufferBefore:z,bufferAfter:Math.max(0,ie)}}};function rc(e){let t;for(const n of e){if(n==null)continue;const i=n.children[1];if(i instanceof HTMLElement)for(const r of i.children)r instanceof HTMLElement&&r.dataset.lineAnnotation===js&&(t=Math.max(t??0,r.getBoundingClientRect().height))}return t}function sc(e){const t=Array.from(e).sort((s,o)=>s[0]-o[0]),n=[],i=[0];let r=0;for(const[s,o]of t)n.push(s),r+=o,i.push(r);return{lineIndexes:n,prefixTotals:i}}function Mr({lineIndexes:e,prefixTotals:t},n,i){if(n>=i||e.length===0)return 0;const r=Hr(e,n);return(t[Hr(e,i)]??0)-(t[r]??0)}function Hr(e,t){let n=0,i=e.length;for(;n<i;){const r=n+i>>1,s=e[r];if(s==null)throw new Error("VirtualizedFileDiff: invalid prefix index");s<t?n=r+1:i=r}return n}function oc(e){return Math.ceil(e/yi)*yi}function ac(e,t){let n=0;for(const i of e)i<t&&n++;return n}function lc({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];const i=t.hunkContent.at(-1);if(i==null)return[];if(i.type==="context")return[n-1];const r=Math.max(i.deletions,i.additions),s=i.deletions+i.additions;if(e==="split")return r>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];const o=[],a=n-s;return i.deletions>0&&t.noEOFCRDeletions&&o.push(a+i.deletions-1),i.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function dc(e,t){return(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function hc(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Wn(e,t){return e.isPartial&&t&&(e.type==="change"||e.type==="rename-changed")}function cc(e){return typeof e=="function"?"custom":e??"line-info"}function Pr(e,t){return e==null||t==null?e==null&&t==null:we(e,t)}function uc(e,t){const[n,i]=e.split(",").map(Number);return t==="split"?i:n}const fc=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","diffStyle","diffIndicators","disableBackground","expandUnchanged","loadDiffFiles","collapsedContextThreshold","lineDiffType","maxLineDiffLength","expansionLineCount","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],pc=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],Or=["renderCustomHeader","renderHeaderPrefix","renderHeaderFilenameSuffix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","onPostRender","onGutterUtilityClick","onLineClick","onLineNumberClick","onLineEnter","onLineLeave","onTokenClick","onTokenEnter","onTokenLeave"],Dr=["onLineSelected","onLineSelectionStart","onLineSelectionChange","onLineSelectionEnd"],So=Symbol("CodeView.itemOptionsState");function _r(e,t){Object.defineProperty(e,So,{configurable:!1,enumerable:!1,value:t})}function bt(e){return e[So]}function Me(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}const gc=120,Fr=1,Nr="--diffs-overflow-override",Ui=12e6,bo=1e6,Co=2e6,mc=Ui-Co,zr=Ui-bo;function vc(e){if(e==null)throw new Error("CodeView: createEditor is required for items with edit: true")}const Sc=(()=>{const{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),i=e.platform==="MacIntel"&&e.maxTouchPoints>1;return(n||i)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})();var bc=class Pe{static __STOP=!1;static __lastScrollPosition=0;type="advanced";config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=vt;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement("div");stickyContainer=document.createElement("div");stickyOffset=document.createElement("div");header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;isContainerManaged;constructor(t={theme:J},n,i=!1){this.options=t,this.computeMetricsCache(t.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=n,this.isContainerManaged=i,this.stickyOffset.style.contain="layout size",this.stickyContainer.style.position="sticky",this.stickyContainer.style.width="100%",this.stickyContainer.style.contain="layout style inline-size",this.stickyContainer.style.isolation="isolate",this.stickyContainer.style.display="flex",this.stickyContainer.style.flexDirection="column"}getLayout(){return this.options.layout??aa}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(t){return this.itemMetricsCache={hunkLineCount:t?.hunkLineCount??vt.hunkLineCount,lineHeight:t?.lineHeight??vt.lineHeight,diffHeaderHeight:t?.diffHeaderHeight??vt.diffHeaderHeight,hunkSeparatorHeight:t?.hunkSeparatorHeight,spacing:t?.spacing??vt.spacing,paddingTop:t?.paddingTop,paddingBottom:t?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??la}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return qo&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(t){if(!this.shouldValidateItemHeights()||t.element==null)return;const n=t.instance.getAdvancedStickySpecs();if(n==null)return;const i=n.height,r=t.element.getBoundingClientRect().height;i!==r&&console.error("CodeView: reconciled item height does not match DOM height",{id:t.item.id,type:t.type,index:t.index,version:t.version,expectedHeight:i,actualHeight:r,delta:r-i,stickyTopOffset:n.topOffset,virtualizedHeight:t.instance.getVirtualizedHeight(),top:t.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:t.element,instance:t.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;const{firstIndex:t,lastIndex:n,stickyHeight:i,stickyTop:r,stickyBottom:s}=this.renderState;if(t===-1||n===-1)return;const o=this.stickyContainer.getBoundingClientRect().height;Math.abs(o-i)<Fr||console.error("CodeView: sticky container height does not match computed layout",{computedStickyHeight:i,actualStickyHeight:o,delta:o-i,stickyTop:r,stickyBottom:s,firstIndex:t,lastIndex:n,firstStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[n]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents="none",this.pointerEventsDisabled=!0),Sc&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(Nr,"hidden"),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,gc)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&(this.stickyContainer.style.removeProperty("pointer-events"),this.pointerEventsDisabled=!1),this.codeOverflowFix&&(this.stickyContainer.style.setProperty(Nr,"auto"),this.codeOverflowFix=!1)};syncLayout(){const{gap:t,paddingBottom:n,paddingTop:i}=this.getLayout();this.stickyContainer.style.gap=`${t}px`,this.container?.style.setProperty("margin-top",`${i}px`),this.container?.style.setProperty("margin-bottom",`${n}px`)}reconcileHeaderFooterHosts(){const t=this.reconcileHost("header"),n=this.reconcileHost("footer");return t||n}reconcileHost(t){const{root:n,container:i}=this;if(n==null||i==null)return!1;const r=t==="header"?this.header:this.footer,s=t==="header"?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(s==null)return r.element==null||(this.resizeObserver?.unobserve(r.element),r.element.remove(),r.element=void 0,r.render=void 0,this.setHostHeight(r,0)),!1;if(r.element!=null&&s===r.render)return!1;const o=r.element??Wl(t,i,this.resizeObserver);r.element=o;const a=s();return a!=null?o.replaceChildren(a):!this.isContainerManaged&&o.children.length>0&&(o.textContent=""),r.render=s,!0}setHostHeight(t,n){t.height!==n&&(t.height=n,this.scrollDirty=!0)}measureMountedHosts(){this.header.element!=null&&this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height),this.footer.element!=null&&this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw new Error("CodeView.setup: already setup");this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor="none",this.root.hasAttribute("tabindex")||(this.root.tabIndex=-1),this.container??=document.createElement("div"),this.container.style.contain="layout style",this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener("scroll",this.handleScroll,{passive:!0}),this.root.addEventListener("wheel",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("touchstart",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("pointerdown",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("keydown",this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{Pe.__STOP?(Pe.__STOP=!1,this.scrollTo({type:"position",position:Pe.__lastScrollPosition,behavior:"instant"})):(Pe.__lastScrollPosition=this.getScrollTop(),Pe.__STOP=!0)}}reset(){Ze(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();for(const t of this.itemEditors.values())t.editor.cleanUp();this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear(),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent="",this.stickyOffset.style.height="",this.container?.style.removeProperty("height"),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isContainerManaged||this.flushSlotCoordinator()}cleanUp(){this.reset(),this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener("scroll",this.handleScroll),this.root?.removeEventListener("wheel",this.clearPendingScroll),this.root?.removeEventListener("touchstart",this.clearPendingScroll),this.root?.removeEventListener("pointerdown",this.clearPendingScroll),this.root?.removeEventListener("keydown",this.clearPendingScroll),this.root?.style.removeProperty("overflow-anchor"),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent="",this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let t=this.renderState.firstIndex;t<=this.renderState.lastIndex;t++){const n=this.items[t];if(n==null)throw new Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${t}`);this.releaseRenderedItem(n)}}primeScrollTarget(t){if(t.type==="position")return;const n=this.idToItem.get(t.id);n?.instance.primeHighlightCache()}getElementPoolLimit(){const t=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:n}=this.itemMetricsCache;return Math.max(8,Math.ceil(t/Math.max(n,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let t=this.elementPool.pop();for(;t!=null&&!this.isElementPoolGenerationCurrent(t);)t=this.elementPool.pop();return t??=document.createElement(vs),this.markElementPoolGenerationCurrent(t),t}releaseRenderedItem(t){const{element:n}=t;n!=null&&this.renderedItemOwnsFocus(n)&&(this.shouldFixContainerFocus=!0),t.instance.cleanUp(!0),this.attachedEditors.delete(t.item.id),t.element=void 0,n!=null&&(n.remove(),this.cleanElement(n),this.queueElementForPool(n))}renderedItemOwnsFocus(t){const{activeElement:n}=document;return n===t||t.contains(n)||t.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(t){const{shadowRoot:n}=t;if(n!=null)for(const i of Array.from(n.children))kc(i)||i.remove();this.isContainerManaged||t.replaceChildren()}queueElementForPool(t){const n=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(t)||this.getElementPoolSize()>=n||(this.isElementClean(t)?this.elementPool.push(t):this.pendingElementPool.push(t))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;const{pendingElementPool:t}=this;this.pendingElementPool=[];const n=this.getElementPoolLimit();for(const i of t)this.isElementPoolGenerationCurrent(i)&&this.isElementClean(i)&&this.elementPool.length<n?this.elementPool.push(i):this.isElementPoolGenerationCurrent(i)&&this.getElementPoolSize()<n&&this.pendingElementPool.push(i)}isElementClean(t){return t.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(t){this.elementPoolTracker.set(t,this.elementPoolVersion)}isElementPoolGenerationCurrent(t){return this.elementPoolTracker.get(t)===this.elementPoolVersion}resolveEffectiveScrollBehavior(t,n){return Fd()?"instant":t.behavior!=="smooth-auto"?t.behavior??"instant":Math.abs(n-this.getScrollTop())<=this.getHeight()*10?"smooth":"instant"}scrollTo(t){if(this.root==null)return;const n=this.normalizeScrollTarget(t);if(n==null)return;const i=this.resolveScrollTargetTop(n);i!=null&&(this.primeScrollTarget(n),this.resolveEffectiveScrollBehavior(n,i)==="smooth"?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=n,this.render())}setSelectedLines(t,n){this.applySelectedLines(t,n)}getSelectedLines(){return this.selectedLines}clearSelectedLines(t){this.applySelectedLines(null,t)}getItem(t){return this.idToItem.get(t)?.item}getEditor(t){return this.itemEditors.get(t)?.editor}updateItem(t){const n=this.idToItem.get(t.id);return n==null?(console.error(`CodeView.updateItem: unknown item id "${t.id}"`),!1):this.syncItemRecord(n,t)?(this.markItemLayoutDirty(n),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(t,n){if(t===n)return!0;const i=this.idToItem.get(t);if(i==null)return console.error(`CodeView.updateItemId: unknown item id "${t}"`),!1;if(this.idToItem.has(n))return console.error(`CodeView.updateItemId: duplicate item id "${n}"`),!1;this.idToItem.delete(t),i.item.id=n,this.idToItem.set(n,i),this.updateItemOptionsId(i.instance.options,n),this.selectedLines?.id===t&&(this.selectedLines={...this.selectedLines,id:n},this.options.onSelectedLinesChange?.(this.selectedLines));const r=this.itemEditors.get(t);return r!=null&&(r.state.id=n,this.itemEditors.delete(t),this.itemEditors.set(n,r),this.attachedEditors.delete(t)&&this.attachedEditors.add(n)),this.renamePendingScrollTarget(t,n),this.renamePendingLayoutAnchor(t,n),this.render(),!0}addItem(t){this.addItems([t])}addItems(t){this.appendItemsInternal(t),this.syncItemEditors(),this.syncSelection()}removeItem(t){const n=this.idToItem.get(t);if(n==null)return console.error(`CodeView.removeItem: unknown item id "${t}"`),!1;const i=[];for(const r of this.items)r!==n&&i.push(r.item);return this.setItems(i),!0}setItems(t){let n;this.items.length===0?this.appendItemsInternal(t):this.tryAppendItems(t)||(n=this.reconcileItems(t)),this.syncItemEditors(n),this.syncSelection()}appendItemsInternal(t,n=!0){if(t.length===0)return;const i=this.getLayout();let r=this.items.length===0?0:this.scrollHeight+i.gap;const s=r;for(let o=0;o<t.length;o++){const a=t[o];if(a==null)throw new Error("CodeView.appendItemsInternal: missing input item");if(this.idToItem.has(a.id))throw new Error(`CodeView.addItem: duplicate id "${a.id}"`);const l=this.createItem(a,this.items.length,r);this.items.push(l),this.idToItem.set(l.item.id,l),this.instanceToItem.set(l.instance,l),l.height=Cc(l),r+=l.height+i.gap}this.scrollHeight=r-i.gap,this.scrollDirty=!0,n&&(this.canSkipRenderForAppend(s)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(t){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&t>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(t){if(t==null)return;this.capturePendingLayoutAnchor();const{options:n}=this,i=this.getLayout(),{itemMetricsCache:r}=this;yc(n,t)&&this.invalidateElementPool(),this.options=t;const s=this.computeMetricsCache(t.itemMetrics),o=!ft(r,s),a=!ft(i,this.getLayout());a&&this.syncLayout();const l=o||Lc(n,t);if(l){const d=this.pendingLayoutReset;this.pendingLayoutReset={metrics:o?s:d?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:d?.includeEstimatedDiffHeights===!0||o||xc(n,t)}}(a||l)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),Tn(n,t)||this.renderOptionsRevision++,this.syncItemEditors();const h=n.renderCodeViewHeader!==t.renderCodeViewHeader||n.renderCodeViewFooter!==t.renderCodeViewFooter;!this.isContainerManaged&&(this.items.length>0||h)&&this.render()}capturePendingLayoutAnchor(t=this.idToItem){this.root==null||this.items.length===0||this.pendingScrollTarget!=null||(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),t))}render(t=!1){Pe.__STOP||(t?(Ze(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):Ye(this.computeRenderRangeAndEmit))}isReady(){const{workerManager:t}=this;return t==null||t.isInitialized()||t.getStats().workersFailed?(this.clearReadySubscription(),!0):(this.isReadySubscription??=t.subscribeToStatChanges(n=>{n.managerState!=="initialized"&&!n.workersFailed||(this.clearReadySubscription(),this.render(!0))}),t.getStats().managerState==="waiting"&&t.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0)}instanceChanged(t,n){const i=this.instanceToItem.get(t);if(i==null)throw new Error("CodeView.instanceChanged: An instance has changed that is not registered");n&&this.markItemLayoutDirty(i),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){const{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1||n===-1||n<t)return[];const i=[];for(let r=t;r<=n;r++){const s=this.items[r];s?.element!=null&&(s.type==="diff"?i.push({id:s.item.id,type:"diff",item:s.item,version:s.version,element:s.element,instance:s.instance}):i.push({id:s.item.id,type:"file",item:s.item,version:s.version,element:s.element,instance:s.instance}))}return i}setSlotCoordinator(t){return t===this.slotCoordinator?!1:(this.slotCoordinator=t,this.slotSnapshot=void 0,!0)}getSlotSnapshot(t){return this.buildSlotSnapshot(t)}buildSlotSnapshot(t){const n=Ec(this.getRenderedItems(),t),{element:i}=this.header,{element:r}=this.footer;if(!(n==null&&i==null&&r==null))return{items:n,header:i,footer:r}}subscribeToScroll(t){return this.scrollListeners.add(t),()=>{this.scrollListeners.delete(t)}}getLocalTopForInstance(t){const n=this.instanceToItem.get(t);if(n==null)throw new Error("CodeView.getLocalTopForInstance: unknown virtualized instance");return n.top}getTopForItem(t){const n=this.idToItem.get(t);if(n!=null)return n.top+this.getItemTopOffset()}createItem(t,n,i){const{itemMetricsCache:r}=this;if(t.type==="diff"){const o=new ic(this.createDiffOptions(t.id),this,r,this.workerManager,this.isContainerManaged);return{type:"diff",item:t,version:t.version,index:n,top:i,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:o}}const s=new Lh(this.createFileOptions(t.id),this,r,this.workerManager,this.isContainerManaged);return{type:"file",item:t,version:t.version,index:n,top:i,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:s}}applySelectedLines(t,n){const{selectedLines:i}=this;t==null&&i==null||t!=null&&i?.id===t.id&&mn(i.range,t.range)||(i!=null&&i.id!==t?.id&&this.idToItem.get(i.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=t,this.idToItem.get(t?.id??"")?.instance.setSelectedLines(t?.range??null,n))}syncSelection(){if(this.selectedLines==null)return;const t=this.idToItem.get(this.selectedLines.id);if(t==null){this.selectedLines=null,this.options.onSelectedLinesChange?.(null);return}t.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(t){return t.item.edit===!0&&t.item.collapsed!==!0}attachItemEditor(t){const{id:n}=t.item,{createEditor:i}=this.options;if(t.element==null||this.attachedEditors.has(n)||!this.isItemInEditMode(t))return;let r=this.itemEditors.get(n),s=!1;try{if(r==null){vc(i);const o={id:n},a=i({onChange:(l,h)=>{const d=this.idToItem.get(o.id);d!=null&&(o.lastChange={item:d.item,file:l,lineAnnotations:h},this.options.onItemEditChange?.(d.item,l,h))}});if(a==null)return;r={editor:a,state:o},this.itemEditors.set(n,r),s=!0}r.editor.edit(t.instance),this.attachedEditors.add(n)}catch(o){throw s&&r!=null&&(this.itemEditors.delete(n),r.editor.cleanUp()),this.releaseRenderedItem(t),o}}syncItemEditors(t){if(this.itemEditors.size===0)return;const n=[];for(const[i,r]of this.itemEditors){const s=this.idToItem.get(i),o=t?.get(i);if(o==null&&s!=null&&this.isItemInEditMode(s))continue;r.editor.cleanUp(),this.itemEditors.delete(i),this.attachedEditors.delete(i);const{lastChange:a}=r.state,l=o==null?s?.item??a?.item:a?.item??o.item;l?.type==="diff"&&(o==null&&s!=null&&s.type==="diff"&&s.instance.completeEditSession()&&(this.markItemLayoutDirty(s),this.render()),hi(l.fileDiff)),a!=null&&n.push(o!=null||s==null?a:{...a,item:s.item})}for(const{item:i,file:r,lineAnnotations:s}of n)this.options.onItemEditComplete?.(i,r,s)}renamePendingScrollTarget(t,n){const{pendingScrollTarget:i}=this;i==null||i.type==="position"||i.id!==t||(this.pendingScrollTarget={...i,id:n})}renamePendingLayoutAnchor(t,n){this.pendingLayoutAnchor?.id===t&&(this.pendingLayoutAnchor.id=n)}createFileOptionsPrototype(){const t={};for(const n of pc)Me(t,n,()=>this.options[n]);Me(t,"stickyHeader",()=>this.options.stickyHeaders),Me(t,"collapsed",n=>{const i=bt(n);if(i!=null)return this.getItemOptions(i,"file")?.item.collapsed});for(const n of Or)this.defineItemSharedCallback(t,"file",n);for(const n of Dr)this.defineItemSelectionCallback(t,"file",n);return t}createDiffOptionsPrototype(){const t={};for(const n of fc)Me(t,n,()=>this.options[n]);Me(t,"stickyHeader",()=>this.options.stickyHeaders),Me(t,"hunkSeparators",()=>this.options.hunkSeparators),Me(t,"collapsed",n=>{const i=bt(n);if(i!=null)return this.getItemOptions(i,"diff")?.item.collapsed});for(const n of Or)this.defineItemSharedCallback(t,"diff",n);for(const n of Dr)this.defineItemSelectionCallback(t,"diff",n);return t}createFileOptions(t){const n=Object.create(this.fileOptionsPrototype);return _r(n,{id:t}),n}createDiffOptions(t){const n=Object.create(this.diffOptionsPrototype);return _r(n,{id:t}),n}updateItemOptionsId(t,n){const i=bt(t);if(i==null)throw new Error("CodeView.updateItemOptionsId: No valid state");i.id=n}getItemOptions(t,n){const i=this.idToItem.get(t.id);if(!(i==null||i.type!==n))return i}defineItemSharedCallback(t,n,i){Me(t,i,r=>{if(this.options[i]==null)return;const s=bt(r);if(s==null)return;const o=s.callbackCache??={};let a=o[i];return a==null&&(a=((...l)=>{const h=this.getItemOptions(s,n);if(h==null)return;const d=this.options[i];return d?.(...l,h)}),o[i]=a),a})}defineItemSelectionCallback(t,n,i){Me(t,i,r=>{const s=bt(r);if(s==null)return;const o=s.callbackCache??={};let a=o[i];return a==null&&(a=(l=>{const h=this.getItemOptions(s,n);if(h==null)return;const d=l==null?null:{id:h.item.id,range:l};this.options.controlledSelection!==!0&&(l!=null||this.selectedLines?.id===h.item.id)&&this.applySelectedLines(d,{notify:!1}),this.options.onSelectedLinesChange?.(d);const c=this.options[i];return c?.(l,h)}),o[i]=a),a})}markLayoutDirtyFromIndex(t){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??t,t)}markItemLayoutDirty(t){if(this.items[t.index]!==t)throw new Error(`CodeView.markItemLayoutDirty: unknown item id "${t.item.id}"`);this.markLayoutDirtyFromIndex(t.index)}tryAppendItems(t){if(t.length<=this.items.length)return!1;for(let n=0;n<this.items.length;n++){const i=this.items[n];if(i==null)throw new Error("CodeView.tryAppendItems: missing existing item");const r=t[n];if(r==null||i.item.id!==r.id||i.type!==r.type)return!1}for(let n=0;n<this.items.length;n++){const i=this.items[n];if(i==null)throw new Error("CodeView.tryAppendItems: missing existing item");const r=t[n];if(r==null)throw new Error("CodeView.tryAppendItems: append candidate missing prefix item");this.syncItemRecord(i,r)&&this.markLayoutDirtyFromIndex(n)}return this.appendItemsInternal(t.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(t){const{items:n,idToItem:i}=this,r=new Set(n),s=[],o=new Map,a=new Map,l=new Map;let h;for(let d=0;d<t.length;d++){const c=t[d];if(c==null)throw new Error("CodeView.reconcileItems: missing input item");if(o.has(c.id))throw new Error(`CodeView.setItems: duplicate id "${c.id}"`);const u=i.get(c.id),f=u!=null&&u.type===c.type?u:this.createItem(c,d,0);f.index=d,u!=null&&u.type===c.type?(r.delete(u),this.syncItemRecord(f,c)&&(h=Math.min(h??d,d))):h=Math.min(h??d,d),n[d]!==f&&(h=Math.min(h??d,d)),s.push(f),o.set(c.id,f),a.set(f.instance,f)}if(h==null){if(r.size===0)return;h=Math.max(s.length-1,0)}this.capturePendingLayoutAnchor(o);for(let d=0;d<n.length;d++){const c=n[d];if(c==null||!r.has(c))continue;l.set(c.item.id,c),this.releaseRenderedItem(c);const u=Math.max(s.length-1,0);h=Math.min(h??u,u)}return this.items=s,this.idToItem=o,this.instanceToItem=a,this.renderState.firstIndex>=s.length?this.resetRenderState():this.renderState.lastIndex>=s.length&&(this.renderState.lastIndex=s.length-1),this.markLayoutDirtyFromIndex(h),this.scrollDirty=!0,this.render(),l.size>0?l:void 0}syncItemRecord(t,n){if(t.type!==n.type)throw new Error(`CodeView.syncItemRecord: type mismatch for id "${n.id}"`);return t.version===n.version?!1:(t.item=n,t.version=n.version,t.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(t){const{paddingBottom:n,paddingTop:i}=this.getLayout();return Math.max(i+this.header.height+t+this.footer.height+n-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>zr}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),Ui):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(t){const n=this.getMaxPagedScrollTop();return Math.max(0,Math.min(t,n))}clampScrollTop(t){const n=this.getMaxScrollTop();return Math.max(0,Math.min(t,n))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(t){const n=this.getMaxScrollPageOffset();return Math.max(0,Math.min(t,n))}resolveScrollPageWindow(t,n){let i=xe(this.clampPagedScrollTop(n)),r=this.clampScrollPageOffset(t-i);return i=xe(this.clampPagedScrollTop(t-r)),r=this.clampScrollPageOffset(t-i),{pagedScrollTop:i,scrollPageOffset:r}}resolvePagedScrollPosition(t){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(t),scrollPageOffset:0};const n=this.clampScrollPageOffset(this.scrollPageOffset),i=t-n,r=this.getMaxPagedScrollTop(),s=this.getMaxScrollPageOffset(),o=i>zr&&n<s,a=i<bo&&n>0;return i<0||i>r||o||a?this.resolveScrollPageWindow(t,a?Math.min(mc,r):Co):{pagedScrollTop:xe(this.clampPagedScrollTop(i)),scrollPageOffset:n}}needsScrollPageUpdate(t){const n=xe(this.clampScrollTop(t)),{scrollPageOffset:i}=this.resolvePagedScrollPosition(n);return i!==this.scrollPageOffset}getPagedLayoutTop(t){return this.shouldRebaseScroll()?Math.max(t-this.scrollPageOffset,0):t}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(t){const n=this.idToItem.get(t.id);if(n==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return{top:n.top,height:n.height};if(t.type==="range"){const r=this.getRangeScrollPosition(n,t);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Br(t.range)} for item "${t.id}"`);return}return{top:n.top+r.top,height:r.height}}const i=this.getLineScrollPosition(n,t);if(i==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return{top:n.top+i.top,height:i.height}}normalizeScrollTarget(t){if(t.type==="position"||t.align!=="nearest")return t;const n=this.getScrollTargetRect(t);if(n==null)return;const i=t.offset??0,r=this.getItemTopOffset()+n.top,s=r+n.height,o=this.getScrollTop(),a=o+(t.type==="line"||t.type==="range"?this.getStickyHeaderOffset():0),l=o+this.getHeight();if(!(r-i<=a&&s+i>=l)){if(r-i<a)return{...t,align:"start"};if(s+i>l)return{...t,align:"end"}}}resolveScrollTargetTop(t){if(t.type==="position"){const r=this.clampScrollTop(t.position);return r!==t.position?r:this.clampScrollTop(t.position-this.getStickyHeaderOffset())}const n=this.idToItem.get(t.id);if(n==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top,n.height,t.align,t.offset));if(t.type==="range"){const r=this.getRangeScrollPosition(n,t);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Br(t.range)} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top+r.top,r.height,t.align,t.offset,this.getStickyHeaderOffset()))}const i=this.getLineScrollPosition(n,t);if(i==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top+i.top,i.height,t.align,t.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(t,n,i,r=0,s=0){t+=this.getItemTopOffset();const o=this.getHeight();return i==="center"&&n+r<o?t-(o-n)/2+r:i==="end"?t-(o-n)+r:t-s-r}getLineScrollPosition(t,n){return t.type==="diff"?t.instance.getLinePosition(n.lineNumber,n.side):t.instance.getLinePosition(n.lineNumber)}getRangeScrollPosition(t,n){const{range:i}=n,r=this.getLineScrollPosition(t,{type:"line",id:n.id,lineNumber:i.start,side:i.side}),s=this.getLineScrollPosition(t,{type:"line",id:n.id,lineNumber:i.end,side:i.endSide??i.side});if(r==null||s==null)return;const o=r.top,a=o+r.height,l=s.top,h=l+s.height,d=Math.min(o,l);return{top:d,height:Math.max(a,h)-d}}computeTargetScrollTopForFrame(t,n){if(this.pendingScrollTarget==null)return t;const i=this.resolveScrollTargetTop(this.pendingScrollTarget);if(i==null)return t;const{scrollAnimation:r}=this;return r==null?i:this.computeSpringStep(r,i,n).position}computeSpringStep(t,n,i){const r=Math.max(0,i-t.lastTimestamp),{omega:s}=this.getSmoothScrollSettings(),o=Math.exp(-s*r),a=t.position-n,l=t.velocity+s*a;return{position:n+(a+l*r)*o,velocity:(l*(1-s*r)-s*a)*o}}advanceScrollAnimation(t,n){if(this.pendingScrollTarget==null)return;const i=this.resolveScrollTargetTop(this.pendingScrollTarget);if(i==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}const r=this.scrollAnimation;if(r==null)return i;r.position+=n;const{position:s,velocity:o}=this.computeSpringStep(r,i,t);r.lastTimestamp=t,r.position=s,r.velocity=o;const{positionEpsilon:a,velocityEpsilon:l}=this.getSmoothScrollSettings();return Math.abs(i-s)<=a&&Math.abs(o)<=l?(r.position=i,r.velocity=0,this.scrollAnimation=void 0,i):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(Pe.__STOP||this.container==null||!this.isReady())return;const n=this.getHeight(),i=this.getScrollTop();let r=i,s=this.pendingLayoutAnchor!=null,o=this.getScrollAnchor(r);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,s=!0),s&&o!=null){const k=this.resolveAnchoredScrollTop(o);if(k!=null){const E=k-r;r=k,this.scrollAnimation!=null&&(this.scrollAnimation.position+=E)}}s&&(r=this.clampScrollTop(r),this.syncContainerHeight());const a=this.computeTargetScrollTopForFrame(r,t),l=!s&&(this.renderState.scrollTop===-1||Math.abs(a-this.renderState.scrollTop)>n+this.config.overscrollSize*2);l&&(o=void 0),this.windowSpecs=$l({scrollTop:a-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:l,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let h=i;(this.pendingScrollTarget!=null&&a!==h||this.needsScrollPageUpdate(a))&&(this.applyScrollFix(a,h,this.windowSpecs),h=a);const{top:d,bottom:c}=this.windowSpecs,{firstIndex:u,lastIndex:f}=this.renderState;if(u>=0)for(let k=u;k<=f;k++){const E=this.items[k];if(E==null)throw new Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${k}`);E.top>d-E.height&&E.top<=c||this.releaseRenderedItem(E)}const p=this.reconcileHeaderFooterHosts();let g;const m=new Set,v=this.findFirstVisibleIndex(d),S=this.findLastVisibleIndex(c);for(let k=v;k<=S;k++){const E=this.items[k];if(E==null)throw new Error("CodeView.computeRenderRangeAndEmit: missing item");const{instance:x}=E;E.element==null?(E.element=this.acquireElement(),Wr(this.stickyContainer,E.element,g),x.virtualizedSetup(),Ur(E,E.element)&&(E.renderedOptionsRevision=this.renderOptionsRevision,m.add(E)),g=E.element):(Wr(this.stickyContainer,E.element,g),Ur(E,void 0,E.renderedOptionsRevision!==this.renderOptionsRevision)&&(E.renderedOptionsRevision=this.renderOptionsRevision,m.add(E)),g=E.element),E.item.edit===!0&&this.attachItemEditor(E)}this.renderState.firstIndex=v<=S?v:-1,this.renderState.lastIndex=S,this.flushSlotCoordinator(),this.flushManagers(m),p&&this.measureMountedHosts(),this.reconcileRenderedItems(m),this.syncContainerHeight(),this.updateStickyPositioning();const C=o!=null?this.resolveAnchoredScrollTop(o):void 0;o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);const b=C!=null?C-r:0;let y=a,L=!1;if(this.pendingScrollTarget!=null){const k=this.advanceScrollAnimation(t,b);k!=null?(y=k,L=!0):y=r}else y=C??a;y!==h&&(this.applyScrollFix(y,h,this.windowSpecs),h=y),L&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=xe(h),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),(l||this.scrollAnimation!=null)&&this.render()};flushManagers(t){for(const n of t)n.instance.flushManagers()}syncContainerHeight(){const t=this.getPagedScrollHeight();this.container==null||this.containerHeight===t||(this.container.style.height=`${t}px`,this.containerHeight=t)}getStickyBounds(t){const{firstIndex:n,lastIndex:i}=t!=null?{firstIndex:this.findFirstVisibleIndex(t.top),lastIndex:this.findLastVisibleIndex(t.bottom)}:this.renderState;if(n===-1||i===-1||n>i)return;const r=this.items[n]?.instance.getAdvancedStickySpecs(t),s=this.items[i]?.instance.getAdvancedStickySpecs(t);if(!(r==null||s==null))return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(s.topOffset+s.height)}}applyStickyPositioning({stickyTop:t,stickyBottom:n}){const i=this.getHeight(),{itemMetricsCache:r}=this,s=n-t;this.renderState.stickyHeight=s,this.renderState.stickyTop=t,this.renderState.stickyBottom=n,this.stickyOffset.style.height=`${t}px`;const o=(Math.random()*r.lineHeight>>0)*-1,a=-Math.max(s+o,0)+i;this.stickyContainer.style.top=`${a}px`,this.stickyContainer.style.bottom=`${a+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(t){this.syncContainerHeight();const n=this.getStickyBounds(t);n!=null&&this.applyStickyPositioning(n)}reconcileRenderedItems(t){const{firstIndex:n,lastIndex:i}=this.renderState;if(n===-1)return;let r=-1,s=!1;for(let o=n;o<this.items.length&&!(!s&&o>i);o++){const a=this.items[o];if(a==null)throw new Error("CodeView.reconcileRenderedItems: Invalid item");r===-1?r=a.top:a.top!==r&&(a.top=r,a.instance.syncVirtualizedTop(),s=!0),(t==null?o<=i:t.has(a))&&(a.instance.reconcileHeights()&&(s=!0,a.height=a.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(a)),r+=a.instance.getVirtualizedHeight(),o<this.items.length-1&&(r+=this.getLayout().gap)}s&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){const t=this.getStickyBounds();if(t==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height="");return}const{stickyTop:n,stickyBottom:i}=t;i-n===this.renderState.stickyHeight&&n===this.renderState.stickyTop&&i===this.renderState.stickyBottom||this.applyStickyPositioning(t)}handleScroll=()=>{Pe.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=t=>{let n=!1;for(const i of t)if(i.target===this.stickyContainer){const r=i.borderBoxSize[0].blockSize;if(Math.abs(r-this.renderState.stickyHeight)>=Fr){const s=this.getScrollTop(),o=this.getScrollAnchor(s);this.reconcileRenderedItems(),this.updateStickyPositioning();const a=o!=null?this.resolveAnchoredScrollTop(o):void 0;if(a!=null){const l=a-s;this.applyScrollFix(a,s,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=l)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),n=!0}}else if(i.target===this.header.element||i.target===this.footer.element){const r=i.target===this.header.element?this.header:this.footer,s=i.borderBoxSize[0].blockSize;if(s!==r.height){const o=this.getScrollTop(),a=this.getScrollAnchor(o);this.setHostHeight(r,s);const l=a!=null?this.resolveAnchoredScrollTop(a):void 0;if(l!=null){const h=l-o;this.applyScrollFix(l,o,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=h)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),n=!0}}else this.scrollDirty=!0,this.heightDirty=!0,n=!0;n&&this.render(!0)};getScrollAnchorViewportTop(t,n){return t<n?n+this.getStickyHeaderOffset():n}getScrollAnchor(t,n=this.idToItem){let i;const{pendingLayoutAnchor:r}=this;if(r!=null){const d=this.idToItem.get(r.id);if(d!=null&&n.get(r.id)===d)return r;d!=null&&(i=d)}if(t<=0)return;const{firstIndex:s,lastIndex:o,stickyTop:a,stickyBottom:l}=this.renderState;if(s===-1||o===-1)return;const h=this.getHeight();if(!(a===-1||l===-1)){for(let d=s;d<=o;d++){const c=this.items[d];if(c==null)continue;const u=this.getItemTopOffset()+c.top;if(u+c.height<=t)continue;if(u>=t+h)break;if(n.get(c.item.id)!==c){i??=c;continue}if(u>=t)return{type:"item",id:c.item.id,viewportOffset:u-t};const f=this.getScrollAnchorViewportTop(u,t)-u,p=c.instance.getNumericScrollAnchor(f);if(p!=null){const g=u+p.top;return{type:"line",id:c.item.id,lineNumber:p.lineNumber,side:p.side,viewportOffset:g-t}}}if(i!=null)for(let d=i.index+1;d<this.items.length;d++){const c=this.items[d];if(c!=null&&n.get(c.item.id)===c)return{type:"item",id:c.item.id,viewportOffset:0}}}}resolveAnchoredScrollTop(t){const n=this.idToItem.get(t.id);if(n==null)return;const i=this.getItemTopOffset();if(t.type==="item"){const o=i+n.top;return this.clampScrollTop(o-t.viewportOffset)}const r=n.type==="diff"?n.instance.getLinePosition(t.lineNumber,t.side):n.instance.getLinePosition(t.lineNumber);if(r==null)return;const s=i+n.top+r.top;return this.clampScrollTop(s-t.viewportOffset)}applyScrollFix(t,n,i){if(this.root==null)return;const r=xe(this.clampScrollTop(t)),s=xe(n),{scrollPageOffset:o}=this,a=xe(this.clampPagedScrollTop(s-o)),{pagedScrollTop:l,scrollPageOffset:h}=this.resolvePagedScrollPosition(r),d=l,c=o!==h;r===this.renderState.scrollTop&&r===s&&d===a&&!c||(this.suspendScrollInteractions(),(d!==a||c)&&(this.scrollPageOffset=h,this.syncPagedScrollScaffolding(i)),d!==a&&this.root.scrollTo({top:d,behavior:"instant"}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(t){const n=this.resolveScrollTargetTop(t);return n==null?!0:xe(this.getScrollTop())===xe(n)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;const t=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(t+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;const t=this.buildSlotSnapshot(this.slotCoordinator);zs(this.slotSnapshot,t)||(this.slotSnapshot=t,this.slotCoordinator.onSnapshotChange(t))}notifyScroll(){if(this.scrollListeners.size===0)return;const t=this.getScrollTop();for(const n of this.scrollListeners)n(t,this)}findFirstVisibleIndex(t){let n=0,i=this.items.length-1,r=this.items.length;for(;n<=i;){const s=n+i>>1,o=this.items[s];if(o==null)throw new Error("CodeView.findFirstVisibleIndex: invalid item index");o.top+o.height>t?(r=s,i=s-1):n=s+1}return r}findLastVisibleIndex(t){let n=0,i=this.items.length-1,r=-1;for(;n<=i;){const s=n+i>>1,o=this.items[s];if(o==null)throw new Error("CodeView.findLastVisibleIndex: invalid item index");o.top<=t?(r=s,n=s+1):i=s-1}return r}recomputeLayout(t=0,n){if(this.items.length===0){this.scrollHeight=0;return}const i=this.getLayout();let r=0;if(t>0){const s=this.items[t-1];if(s==null)throw new Error("CodeView.recomputeLayout: invalid dirty index");r=s.top+s.height+i.gap}for(let s=t;s<this.items.length;s++){const o=this.items[s];if(o==null)throw new Error("CodeView.recomputeLayout: invalid item index");if(o.top=r,o.type==="diff"){const a=o.instance.consumeCodeViewLayoutChanges(o.item.fileDiff);a!=null&&Object.assign(o.item.fileDiff,a),o.height=o.instance.prepareCodeViewItem(o.item.fileDiff,r,n,o.item.annotations??[])}else o.height=o.instance.prepareCodeViewItem(o.item.file,r,n,o.item.annotations??[]);r+=o.height,s<this.items.length-1&&(r+=i.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function Cc(e){return e.instance.cleanUp(!0),e.type==="diff"?e.instance.prepareCodeViewItem(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.prepareCodeViewItem(e.item.file,e.top,void 0,e.item.annotations??[])}function yc(e,t){return!mt(e.theme??J,t.theme??J)||(e.themeType??"system")!==(t.themeType??"system")||e.unsafeCSS!==t.unsafeCSS}function Lc(e,t){return(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function xc(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function kc(e){return e instanceof SVGElement?!0:Ht(e)&&(e.hasAttribute("data-core-css")||e.hasAttribute("data-theme-css")||e.hasAttribute("data-unsafe-css"))}function Br(e){const t=Vr(e.start,e.side),n=Vr(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function Vr(e,t){return t==null?`${e}`:`${t==="deletions"?"D":"A"}${e}`}function Ur(e,t,n=!1){return e.type==="diff"?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function Wr(e,t,n){if(n==null){e.firstChild!==t&&e.prepend(t);return}n.nextSibling!==t&&n.after(t)}function wc(e){return(e.annotations?.length??0)>0}function Ec(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:i}){if(e.length===0)return;if(t||i)return e;if(!n)return;const r=[];for(const s of e)wc(s.item)&&r.push(s);return r.length>0?r:void 0}const $r=typeof window>"u"?Y.useEffect:Y.useLayoutEffect;function Gr(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function Tc(e,t){const{className:n,containerRef:i,disableWorkerPool:r=!1,editorOptions:s,initialItems:o,items:a,onItemEditChange:l,onItemEditComplete:h,onScroll:d,onSelectedLinesChange:c,options:u,renderAnnotation:f,renderCodeViewFooter:p,renderCodeViewHeader:g,renderCustomHeader:m,renderGutterUtility:v,renderHeaderFilenameSuffix:S,renderHeaderMetadata:C,renderHeaderPrefix:b,selectedLines:y,style:L}=e,k=a!==void 0,E=jo(),x=Y.useContext(Vl),w=Y.useRef(Gr(k)),O=m!=null,T=f!=null,R=v!=null,_=O||b!=null||S!=null||C!=null,$=_||T||R,H=g!=null,D=p!=null,B=De(M=>{c?.(M)}),Z=y!==void 0,V=De(M=>{if(E==null)throw new Error("CodeView: EditContext is not attached");const U=E({...s,...M});if(U==null)throw new Error("CodeView: EditProvider.createEditor must return an editor instance");return U}),A=De((M,U,K)=>{l?.(M,U,K)}),P=De((M,U,K)=>{h?.(M,U,K)}),N=Y.useMemo(()=>Hc({options:u,hasCustomHeader:O,hasGutterRenderer:R,hasCodeViewHeader:H,hasCodeViewFooter:D,onSelectedLinesChange:c!=null?B:void 0,controlledSelection:Z,createEditor:E!=null?V:void 0,onItemEditChange:l!=null?A:void 0,onItemEditComplete:h!=null?P:void 0}),[E,Z,V,A,P,B,D,H,O,R,l,h,c,u]),[z]=Y.useState(()=>Mc()),[,ee]=Y.useState({}),ie=De(M=>{w.current.instance!=null&&(M==null||M!==w.current.instance.getContainerElement())&&(w.current.instance.cleanUp(),z.publish(void 0),w.current=Gr(k)),M!=null&&M!==w.current.instance?.getContainerElement()&&(w.current.instance=new bc(N,r?void 0:x,!0),w.current.instance.setup(M)),typeof i=="function"?i(M):i!=null&&(i.current=M)}),oe=De(M=>{w.current.disableFlushSync?z.publish(M):tn.flushSync(()=>{z.publish(M)})}),re=Y.useMemo(()=>{if(!(!_&&!T&&!R&&!H&&!D))return{hasHeaderRenderers:_,hasAnnotationRenderer:T,hasGutterRenderer:R,onSnapshotChange:oe}},[oe,T,R,_,H,D]);return $r(()=>d!=null?w.current.instance?.subscribeToScroll(d):void 0),$r(()=>{const{instance:M,controlled:U,items:K,managedOptions:ae,slotCoordinator:X}=w.current;if(M!=null)try{w.current.disableFlushSync=!0;let te=!1;if(Tn(N,ae)||(w.current.managedOptions=N,M.setOptions(N),te=!0),U!==k){console.error("CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.");return}if(k)a!==K&&(Ic(K,a)?w.current.items=a:Rc(K,a)?(w.current.items=a,M.addItems(a.slice(K.length))):(w.current.items=a,M.setItems(a),te=!0));else if(K==null){const de=o??[];w.current.items=de,de.length>0&&(M.setItems(de),te=!0)}y!==void 0&&M.setSelectedLines(y,{notify:!1});const le=M.setSlotCoordinator(re);let ye=!1;re!==X&&((re==null||X==null)&&(ye=!0),w.current.slotCoordinator=re),(te||le)&&M.render(!0),le&&re==null&&z.publish(void 0),ye&&ee({})}finally{w.current.disableFlushSync=!1}}),Y.useImperativeHandle(t,()=>({addItems(M){const{controlled:U,instance:K}=w.current;Zt(U,"addItems"),K==null?console.error("CodeView.addItems: no valid instance to append items with",M):K.addItems(M)},getItem(M){const{instance:U}=w.current;if(U==null){console.error("CodeView.getItem: no valid instance exists",M);return}else return U.getItem(M)},removeItem(M){const{controlled:U,instance:K}=w.current;return Zt(U,"removeItem"),K==null?(console.error("CodeView.removeItem: no valid instance to remove item from",M),!1):K.removeItem(M)},updateItem(M){const{controlled:U,instance:K}=w.current;return Zt(U,"updateItem"),K==null?(console.error("CodeView.updateItem: no valid instance to update item with",M),!1):K.updateItem(M)},updateItemId(M,U){const{controlled:K,instance:ae}=w.current;return Zt(K,"updateItemId"),ae==null?(console.error("CodeView.updateItemId: no valid instance to update item id with",M,U),!1):ae.updateItemId(M,U)},scrollTo(M){const{instance:U}=w.current;U==null?console.error("CodeView.scrollTo: no valid instance to scroll with",M):U.scrollTo(M)},setSelectedLines(M){const{instance:U}=w.current;U==null?console.error("CodeView.setSelectedLines: no valid instance to update selection with",M):(U.setSelectedLines(M,{notify:!1}),B(M))},getSelectedLines(){const{instance:M}=w.current;return M==null?(console.error("CodeView.getSelectedLines: no valid instance exists"),null):M.getSelectedLines()},clearSelectedLines(){const{instance:M}=w.current;M==null?console.error("CodeView.clearSelectedLines: no valid instance to update selection with"):(M.clearSelectedLines({notify:!1}),B(null))},getEditor(M){const{instance:U}=w.current;if(U==null){console.error("CodeView.getEditor: no valid instance exists",M);return}return U.getEditor(M)},getInstance(){return w.current.instance}}),[B]),j.jsxs(j.Fragment,{children:[j.jsx("div",{ref:ie,className:n,style:L}),($||H||D)&&j.jsx(Pc,{managedContentStore:z,renderCustomHeader:m,renderHeaderPrefix:b,renderHeaderFilenameSuffix:S,renderHeaderMetadata:C,renderAnnotation:f,renderGutterUtility:v,renderCodeViewHeader:g,renderCodeViewFooter:p})]})}const Ac=Y.forwardRef(Tc);function Rc(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function Ic(e,t){if(e==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Zt(e,t){if(e)throw new Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function Mc(){let e;const t=new Set;return{getSnapshot(){return e},publish(n){if(!zs(e,n)){e=n;for(const i of t)i()}},subscribe(n){return t.add(n),()=>{t.delete(n)}}}}function Hc({options:e,hasCustomHeader:t,hasGutterRenderer:n,hasCodeViewHeader:i,hasCodeViewFooter:r,onSelectedLinesChange:s,controlledSelection:o,createEditor:a,onItemEditChange:l,onItemEditComplete:h}){const d={...e,controlledSelection:o,onSelectedLinesChange:s,createEditor:a};return l!=null&&(d.onItemEditChange=l),h!=null&&(d.onItemEditComplete=h),t&&(d.renderCustomHeader=Jt),n&&(d.renderGutterUtility=Jt),i&&(d.renderCodeViewHeader=Jt),r&&(d.renderCodeViewFooter=Jt),d}const Pc=Y.memo(function({managedContentStore:t,renderCustomHeader:n,renderHeaderPrefix:i,renderHeaderFilenameSuffix:r,renderHeaderMetadata:s,renderAnnotation:o,renderGutterUtility:a,renderCodeViewHeader:l,renderCodeViewFooter:h}){"use no memo";const d=De(p=>t.subscribe(p)),c=De(()=>t.getSnapshot()),u=Y.useSyncExternalStore(d,c,c);let f="";for(const p of u?.items??[])f+=`${p.id}:${p.version}:${p.type}`;return j.jsxs(j.Fragment,{children:[Y.useMemo(()=>u?.items?.map(p=>tn.createPortal(Oc({renderedItem:p,renderCustomHeader:n,renderHeaderPrefix:i,renderHeaderFilenameSuffix:r,renderHeaderMetadata:s,renderAnnotation:o,renderGutterUtility:a}),p.element,p.id)),[n,i,r,s,o,a,f]),Y.useMemo(()=>l!=null&&u?.header!=null?tn.createPortal(l(),u.header):null,[l,u?.header]),Y.useMemo(()=>h!=null&&u?.footer!=null?tn.createPortal(h(),u.footer):null,[h,u?.footer])]})});function Oc({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:i,renderHeaderMetadata:r,renderAnnotation:s,renderGutterUtility:o}){if(e.type==="diff"){const{item:a,instance:l}=e;return fa({fileDiff:a.fileDiff,renderCustomHeader:t!=null?()=>t(a):void 0,renderHeaderPrefix:n!=null?()=>n(a):void 0,renderHeaderFilenameSuffix:i!=null?()=>i(a):void 0,renderHeaderMetadata:r!=null?()=>r(a):void 0,renderAnnotation:s!=null?h=>s(h,a):void 0,lineAnnotations:a.annotations,renderGutterUtility:o!=null?h=>o(h,a):void 0,getHoveredLine:l.getHoveredLine})}else{const{item:a,instance:l}=e;return ga({file:a.file,renderCustomHeader:t!=null?()=>t(a):void 0,renderHeaderPrefix:n!=null?()=>n(a):void 0,renderHeaderFilenameSuffix:i!=null?()=>i(a):void 0,renderHeaderMetadata:r!=null?()=>r(a):void 0,renderAnnotation:s!=null?h=>s(h,a):void 0,lineAnnotations:a.annotations,renderGutterUtility:o!=null?h=>o(h,a):void 0,getHoveredLine:l.getHoveredLine})}}function Jt(){}const Dc=100,kt=1,Wi=2,$i=3;var yo=class{#t=[];#e=[];#s;#n=!1;constructor(e){this.#s=Math.max(1,e?.maxEntries??Dc)}get canUndo(){return this.#t.length>0}get canRedo(){return this.#e.length>0}clear(){this.#t.length=0,this.#e.length=0,this.#n=!1}clearRedo(){this.#e.length=0}push(e){this.#t.push(e),this.clearRedo(),this.#n=!0,this.#t.length>this.#s&&this.#t.shift()}setLastUndoSelectionsAfter(e){const t=this.#t[this.#t.length-1];t!==void 0&&(t.selectionsAfter=e.map(n=>({...n})))}setLastUndoLineAnnotations(e,t){const n=this.#t[this.#t.length-1];n!==void 0&&(n.lineAnnotationsBefore=e.slice(),n.lineAnnotationsAfter=t.slice())}peekUndo(){return this.#t[this.#t.length-1]}peekUndoForCoalescing(){return this.#n?this.peekUndo():void 0}replaceLastUndo(e){if(this.#t.length===0){this.push(e);return}this.#t[this.#t.length-1]=e,this.clearRedo(),this.#n=!0}popUndoToRedo(){const e=this.#t.pop();if(e!==void 0)return this.#e.push(e),this.#n=!1,e}popRedoToUndo(){const e=this.#e.pop();if(e!==void 0)return this.#t.push(e),this.#n=!1,e}};function _c(e,t,n,i,r,s,o,a){const l=[...t].sort((c,u)=>c.start-u.start),h=[];let d;if(r?.length===l.length){const c=[];for(const u of r){if(u.start.line!==u.end.line||u.start.character!==u.end.character)break;c.push(e.offsetAt(u.start))}if(c.length===l.length){c.sort((p,g)=>p-g);let u=!0,f=!0;for(let p=0;p<l.length;p++){const g=l[p];if(g.text.length>0||g.start===g.end){u=!1,f=!1;break}u&&=c[p]===g.end,f&&=c[p]===g.start}d=u?Wi:f?$i:void 0}}for(let c=0,u=0;c<l.length;c++){const f=l[c],p=e.getTextSlice(f.start,f.end),g=f.start+u;h.push({start:g,end:g+f.text.length,text:p}),u+=f.text.length-(f.end-f.start)}return{forwardEdits:l.map(c=>({...c})),inverseEdits:h,versionBefore:n,versionAfter:i,selectionsBefore:r?.map(c=>({...c})),selectionsAfter:s?.map(c=>({...c})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:a?.slice(),coalescingMode:d}}function Fc(e,t){if(e===void 0||e.undoBoundary===!0||t.undoBoundary===!0||e.forwardEdits.length===0||e.forwardEdits.length!==e.inverseEdits.length||e.forwardEdits.length!==t.forwardEdits.length||t.forwardEdits.length!==t.inverseEdits.length)return!1;let n;for(let i=0;i<e.forwardEdits.length;i++){const r=e.forwardEdits[i],s=e.inverseEdits[i],o=t.forwardEdits[i],a=t.inverseEdits[i],l=Lo(o.start,e.forwardEdits),h=r.start<=r.end&&r.text.length>0&&!r.text.includes(`
1380
+ `)&&!s.text.includes(`
1381
+ `),d=o.start===o.end&&o.text.length>0&&!o.text.includes(`
1382
+ `)&&a.text.length===0;if(h&&d){if(o.start!==s.end||(n??=kt,n!==kt||e.coalescingMode!==void 0&&e.coalescingMode!==kt||t.coalescingMode!==void 0&&t.coalescingMode!==kt))return!1;continue}const c=r.text.length===0&&r.end>r.start&&s.text.length>0,u=o.text.length===0&&o.end>o.start&&a.text.length>0;if(c&&u){let f;if(l===r.end)f=$i;else{if(l+(o.end-o.start)!==r.start)return!1;f=Wi}if(n??=f,n!==f||e.coalescingMode!==void 0&&e.coalescingMode!==f||t.coalescingMode!==void 0&&t.coalescingMode!==f)return!1;continue}return!1}return n!==void 0}function Nc(e,t){const n=[],i=[];let r;for(let s=0;s<e.forwardEdits.length;s++){const o=e.forwardEdits[s],a=e.inverseEdits[s],l=t.forwardEdits[s],h=t.inverseEdits[s],d=Lo(l.start,e.forwardEdits);if(o.text.length>0){r??=kt,n.push({start:o.start,end:o.end,text:o.text+l.text}),i.push(a.text);continue}if(d===o.end){r??=$i,n.push({start:o.start,end:d+(l.end-l.start),text:""}),i.push(a.text+h.text);continue}r??=Wi,n.push({start:Math.min(o.start,d),end:o.end,text:""}),i.push(h.text+a.text)}return{forwardEdits:n,inverseEdits:zc(n,i),versionBefore:e.versionBefore,versionAfter:t.versionAfter,selectionsBefore:e.selectionsBefore?.slice(),selectionsAfter:t.selectionsAfter?.slice(),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:t.lineAnnotationsAfter?.slice(),coalescingMode:r}}function zc(e,t){const n=[];for(let i=0,r=0;i<e.length;i++){const s=e[i],o=s.start+r;n.push({start:o,end:o+s.text.length,text:t[i]}),r+=s.text.length-(s.end-s.start)}return n}function Lo(e,t){let n=e;for(const i of t){const r=i.end-i.start,s=i.text.length,o=s-r;if(!(n<i.start)){if(n>=i.start+s){n-=o;continue}n=i.start+Math.min(n-i.start,r)}}return n}const Bc=1e5,Li=10,Ln=13,Vc="`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?";var wt=class{source;offset;length;lineOffsetStart;lineOffsetEnd;hasVirtualTrailingCRBreak;firstCharCode;lastCharCode;static Original=0;static Added=1;constructor(e,t,n,i,r,s,o,a){this.source=e,this.offset=t,this.length=n,this.lineOffsetStart=i,this.lineOffsetEnd=r,this.hasVirtualTrailingCRBreak=s,this.firstCharCode=o,this.lastCharCode=a}get lineBreakCount(){return this.lineOffsetEnd-this.lineOffsetStart+(this.hasVirtualTrailingCRBreak?1:0)}},jr=class{text;lineOffsets;constructor(e){this.text=e,this.lineOffsets=Fi(e)}append(e){const t=this.text.length;for(let n=0;n<e.length;n++){const i=e.charCodeAt(n);i!==Li&&i!==Ln||(i===Ln&&e.charCodeAt(n+1)===Li&&n++,this.lineOffsets.push(t+n+1))}return this.text+=e,t}},Qt=class{piece;subtreeLength;subtreeLineBreakCount;subtreeFirstCharCode;subtreeLastCharCode;left=null;right=null;parent=null;priority=0;constructor(e,t=e.length,n=e.lineBreakCount,i=e.firstCharCode,r=e.lastCharCode){this.piece=e,this.subtreeLength=t,this.subtreeLineBreakCount=n,this.subtreeFirstCharCode=i,this.subtreeLastCharCode=r}updateSubtreeLength(){this.subtreeLength=(this.left?.subtreeLength??0)+this.piece.length+(this.right?.subtreeLength??0),this.subtreeLineBreakCount=(this.left?.subtreeLineBreakCount??0)+this.piece.lineBreakCount+(this.right?.subtreeLineBreakCount??0)-($e(this.left?.subtreeLastCharCode,this.piece.firstCharCode)?1:0)-($e(this.piece.lastCharCode,this.right?.subtreeFirstCharCode)?1:0),this.subtreeFirstCharCode=this.left?.subtreeFirstCharCode??this.piece.firstCharCode,this.subtreeLastCharCode=this.right?.subtreeLastCharCode??this.piece.lastCharCode}},Uc=class{#t;#e=new jr("");#s=null;#n=0;#a=0;#d=null;#l=null;#g=null;#x=2654435769;constructor(e){this.#t=new jr(e);const t=this.#w(wt.Original,0,e.length);this.#s=t.length>0?this.#K(t):null,this.#n=this.#s?.subtreeLength??0,this.#a=(this.#s?.subtreeLineBreakCount??0)+1}get lineCount(){return this.#a}getText(e){if(e===void 0)return this.#P();const t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this.getTextSlice(t,n)}getLineText(e,t=!1){if(this.#d!==null&&this.#d[0]===e&&this.#d[1]===t)return this.#d[2];const n=this.#k(e);if(n===void 0)throw new Error(`Line index out of range: ${e}`);const i=this.getTextSlice(n[0],n[1],!t);return this.#d=[e,t,i],this.#l=[e,t,i.length],i}getLineLength(e,t=!1){const n=this.#l,i=this.#d;if(n!==null&&n[0]===e&&n[1]===t)return n[2];if(i!==null&&i[0]===e&&i[1]===t){const l=i[2].length;return this.#l=[e,t,l],l}const r=this.#k(e);if(r===void 0)throw new Error(`Line index out of range: ${e}`);const[s,o]=r;let a=o-s;if(!t)for(;a>0&&$n(this.charAt(s+a-1).charCodeAt(0));)a--;return this.#l=[e,t,a],a}getTextSlice(e,t,n=!1){if(e>=t)return"";const i=ve(e,0,this.#n),r=ve(t,i,this.#n);if(i>=r)return"";const s=this.#C(i);if(s===void 0)return"";const o=[];let[a,l]=s,h=r-i;for(;a!==null&&h>0;){const d=Math.min(a.piece.length-l,h),c=this.#v(a.piece.source),u=a.piece.offset+l;let f=u+d;if(n)for(;f>u&&$n(c.text.charCodeAt(f-1));)f--;o.push(c.text.slice(u,f)),h-=d,l=0,a=this.#m(a)}return o.join("")}charAt(e){const t=this.#C(e);if(t===void 0)return"";const[n,i]=t;return this.#v(n.piece.source).text.charAt(n.piece.offset+i)}includes(e){if(e.length===0)return!0;const t=Kr(e);let n=0,i=!1;return this.#b(r=>{for(let s=r.start;s<r.end;s++){const o=r.text.charCodeAt(s);for(;n>0&&o!==e.charCodeAt(n);)n=t[n-1];if(o===e.charCodeAt(n)&&n++,n===e.length)return i=!0,!1}return!0}),i}findNextNonOverlappingSubstring(e,t){if(e.length===0||e.length>this.#n)return;const n=Wc(t,this.#n),i=n.reduce((h,[,d])=>Math.max(h,d),0),r=Kr(e);let s=0,o=0,a,l;return this.#b(h=>{for(let d=h.start;d<h.end;d++){const c=h.text.charCodeAt(d);for(;s>0&&c!==e.charCodeAt(s);)s=r[s-1];if(c===e.charCodeAt(s)&&s++,s===e.length){const u=o-e.length+1;if(!$c(n,u,u+e.length)){if(u>=i)return l=u,!1;a??=u}s=r[s-1]}o++}return!0}),l??a}search(e){if(e.text.length===0||this.#n===0)return[];if(e.text.includes(`
1383
+ `)||e.text.includes("\r")||e.regex&&(e.text.includes("\\n")||e.text.includes("\\r")))return[];let t;try{t=xo(e.text,e.regex,e.caseSensitive)}catch{return[]}return this.#f(t,e.wholeWord,Bc)}#f(e,t,n){const i=[],r=this.#P(),s=r.length,o=Fi(r);for(let a=0;a<o.length;a++){const l=o[a];let h=o[a+1]??s;for(;h>l&&$n(r.charCodeAt(h-1));)h--;const d=r.slice(l,h);e.lastIndex=0;let c;for(;(c=e.exec(d))!==null;){const u=c.index,f=c[0];if(f.length===0){e.lastIndex=Yr(d,u);continue}const p=l+u;if((!t||qc(r,p,f.length))&&(i.push([p,p+f.length]),i.length>=n))return i;u===e.lastIndex&&(e.lastIndex=Yr(d,u))}}return i}insert(e,t){if(e.length===0)return;const n=ve(t,0,this.#n);this.#p(n,n,e),this.#R()}delete(e,t){if(t<=0||this.#n===0)return;const n=ve(e,0,this.#n),i=ve(n+t,n,this.#n);n!==i&&(this.#p(n,i,""),this.#R())}applyEdits(e){if(e.length!==0){for(let t=e.length-1;t>=0;t--){const n=e[t],i=ve(n.start,0,this.#n),r=ve(n.end,i,this.#n);this.#p(i,r,n.text)}this.#R()}}positionAt(e){const t=ve(e,0,this.#n);if(this.#n===0)return{line:0,character:0};const n=this.#E(t),i=t-(n===0?0:this.#B(n-1));return this.#g=[n,i,t],{line:n,character:i}}positionsAt(e){const t=Array.from({length:e.length});if(e.length===0)return t;if(this.#n===0)return t.fill({line:0,character:0});for(let n=0;n<e.length;n++)t[n]=this.positionAt(e[n]);return t}offsetAt(e){if(e.line<0||this.#n===0)return 0;if(e.line>=this.#a)throw new Error(`Line index out of range: ${e.line}`);const t=this.#g;if(t!==null&&t[0]===e.line&&t[1]===e.character)return t[2];const n=this.#k(e.line);if(n===void 0)throw new Error(`Line index out of range: ${e.line}`);const i=ve(e.character,0,n[1]-n[0]);return n[0]+i}#C(e){if(e<0||e>=this.#n)return;let t=this.#s,n=e;for(;t!==null;){const i=t.left?.subtreeLength??0;if(n<i){t=t.left;continue}if(n-=i,n<t.piece.length)return[t,n];n-=t.piece.length,t=t.right}}#m(e){if(e.right!==null){let n=e.right;for(;n.left!==null;)n=n.left;return n}let t=e;for(;t.parent!==null&&t===t.parent.right;)t=t.parent;return t.parent}#k(e){if(e<0)throw new Error(`Line index out of range: ${e}`);if(this.#n===0){if(e===0)return[0,0];throw new Error(`Line index out of range: ${e}`)}if(e>=this.#a)throw new Error(`Line index out of range: ${e}`);return[e===0?0:this.#B(e-1),e<this.#a-1?this.#B(e):this.#n]}#E(e){let t=this.#s,n=ve(e,0,this.#n),i=0;for(;t!==null;){const r=t.left?.subtreeLength??0;if(n<r){t=t.left;continue}if(i+=(t.left?.subtreeLineBreakCount??0)-($e(t.left?.subtreeLastCharCode,t.piece.firstCharCode)?1:0),n-=r,n<=t.piece.length){const s=this.#v(t.piece.source),o=Math.min(Gn(s.lineOffsets,t.piece.offset+n),t.piece.lineOffsetEnd);return i+=o-t.piece.lineOffsetStart,n===t.piece.length&&t.piece.hasVirtualTrailingCRBreak&&i++,n===t.piece.length&&$e(t.piece.lastCharCode,this.#m(t)?.piece.firstCharCode)&&i--,i}i+=t.piece.lineBreakCount-($e(t.piece.lastCharCode,t.right?.subtreeFirstCharCode)?1:0),n-=t.piece.length,t=t.right}return this.#a-1}#B(e){let t=this.#s,n=e,i=0,r;for(;t!==null;){const s=(t.left?.subtreeLineBreakCount??0)-($e(t.left?.subtreeLastCharCode,t.piece.firstCharCode)?1:0);if(n<s){r=t.piece.firstCharCode,t=t.left;continue}const o=t.left?.subtreeLength??0;i+=o,n-=s;const a=t.right?.subtreeFirstCharCode??r,l=t.piece.lineBreakCount-($e(t.piece.lastCharCode,a)?1:0);if(n<l)return i+this.#o(t.piece,n);i+=t.piece.length,n-=l,t=t.right}return this.#n}#o(e,t){return t<e.lineOffsetEnd-e.lineOffsetStart?this.#v(e.source).lineOffsets[e.lineOffsetStart+t]-e.offset:e.length}#P(){const e=[];return this.#b(t=>{e.push(t.text.slice(t.start,t.end))}),e.join("")}#b(e){this.#V(this.#s,t=>{const n=this.#v(t.piece.source);return e({text:n.text,lineOffsets:n.lineOffsets,lineOffsetStart:t.piece.lineOffsetStart,lineOffsetEnd:t.piece.lineOffsetEnd,start:t.piece.offset,end:t.piece.offset+t.piece.length})})}#v(e){return e===wt.Original?this.#t:this.#e}#w(e,t,n){const i=this.#v(e),r=t+n,s=Gn(i.lineOffsets,t),o=Gn(i.lineOffsets,r),a=i.text.charCodeAt(r-1);return new wt(e,t,n,s,o,a===Ln&&i.lineOffsets[o-1]!==r,i.text.charCodeAt(t),a)}#p(e,t,n){if(e===t&&n.length===0)return;const[i,r]=this.#U(this.#s,e),s=this.#L(r,t-e);let o;if(n.length>0){const a=this.#w(wt.Added,this.#e.append(n),n.length);o=this.#D(this.#h(i,a),s)}else{const[a,l]=this.#W(s);o=a===void 0?i:this.#D(this.#h(i,a),l)}o!==null&&(o.parent=null),this.#s=o,this.#n=o?.subtreeLength??0,this.#a=(o?.subtreeLineBreakCount??0)+1}#R(){this.#d=null,this.#l=null,this.#g=null}#S(){return this.#x=Math.imul(this.#x,1664525)+1013904223>>>0,this.#x}#K(e){const t=new Qt(e);return t.priority=this.#S(),t}#T(e,t){e.left=t,t!==null&&(t.parent=e)}#H(e,t){e.right=t,t!==null&&(t.parent=e)}#U(e,t){if(e===null)return[null,null];if(t<=0)return[null,e];if(t>=e.subtreeLength)return[e,null];const n=e.left?.subtreeLength??0;if(t<=n){const[a,l]=this.#U(e.left,t);return this.#T(e,l),e.updateSubtreeLength(),[a,e]}const i=e.piece.length;if(t>=n+i){const[a,l]=this.#U(e.right,t-n-i);return this.#H(e,a),e.updateSubtreeLength(),[e,l]}const r=t-n,s=new Qt(this.#w(e.piece.source,e.piece.offset,r)),o=new Qt(this.#w(e.piece.source,e.piece.offset+r,i-r));return s.priority=e.priority,o.priority=e.priority,this.#T(s,e.left),this.#H(o,e.right),s.updateSubtreeLength(),o.updateSubtreeLength(),[s,o]}#L(e,t){if(e===null||t>=e.subtreeLength)return null;if(t<=0)return e;const n=e.left?.subtreeLength??0;if(t<=n)return this.#T(e,this.#L(e.left,t)),e.updateSubtreeLength(),e;const i=n+e.piece.length;if(t>=i)return this.#L(e.right,t-i);const r=t-n,s=new Qt(this.#w(e.piece.source,e.piece.offset+r,e.piece.length-r));return s.priority=e.priority,this.#H(s,e.right),s.updateSubtreeLength(),s}#D(e,t){return e===null?t:t===null?e:e.priority>=t.priority?(this.#H(e,this.#D(e.right,t)),e.updateSubtreeLength(),e):(this.#T(t,this.#D(e,t.left)),t.updateSubtreeLength(),t)}#h(e,t){if(e===null)return this.#K(t);let n=e;for(;n.right!==null;)n=n.right;if(Gc(n.piece,t)){n.piece=jc(n.piece,t);for(let i=n;i!==null&&(i.updateSubtreeLength(),i!==e);)i=i.parent;return e}return this.#D(e,this.#K(t))}#W(e){if(e===null)return[void 0,null];if(e.left===null)return[e.piece,e.right];const[t,n]=this.#W(e.left);return this.#T(e,n),e.updateSubtreeLength(),[t,e]}#V(e,t){return e===null?!0:!this.#V(e.left,t)||t(e)===!1?!1:this.#V(e.right,t)}};function $n(e){return e===10||e===13}function ve(e,t,n){return Math.min(Math.max(e,t),n)}function Kr(e){const t=Array.from({length:e.length}).fill(0);let n=0;for(let i=1;i<e.length;i++){const r=e.charCodeAt(i);for(;n>0&&r!==e.charCodeAt(n);)n=t[n-1];r===e.charCodeAt(n)&&n++,t[i]=n}return t}function Wc(e,t){const n=[];for(const[r,s]of e){const o=ve(r,0,t),a=ve(s,o,t);o<a&&n.push([o,a])}n.sort((r,s)=>r[0]-s[0]);const i=[];for(const r of n){const s=i[i.length-1];if(s!==void 0&&r[0]<=s[1]){s[1]=Math.max(s[1],r[1]);continue}i.push(r)}return i}function $c(e,t,n){let i=0,r=e.length;for(;i<r;){const o=i+Math.floor((r-i)/2);e[o][1]<=t?i=o+1:r=o}const s=e[i];return s!==void 0&&s[0]<n}function Gc(e,t){return e.source===t.source&&e.offset+e.length===t.offset&&!$e(e.lastCharCode,t.firstCharCode)}function jc(e,t){return new wt(e.source,e.offset,e.length+t.length,e.lineOffsetStart,t.lineOffsetEnd,t.hasVirtualTrailingCRBreak,e.firstCharCode,t.lastCharCode)}function $e(e,t){return e===Ln&&t===Li}function Gn(e,t){let n=0,i=e.length;for(;n<i;){const r=n+Math.floor((i-n)/2);e[r]<=t?n=r+1:i=r}return n}function Kc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qr(e){if(e<=32||e===127)return!0;const t=String.fromCharCode(e);return Vc.includes(t)}function qc(e,t,n){const i=t<=0||qr(e.charCodeAt(t-1)),r=t+n>=e.length||qr(e.charCodeAt(t+n));return i&&r}function xo(e,t,n){const i=t?e:Kc(e);return new RegExp(i,`g${n?"":"i"}${t?"m":""}`)}function Yc(e,t){return e.replace(/\$([$&]|\d+)/g,(n,i)=>i==="$"?"$":i==="&"?t[0]??"":t[Number(i)]??"")}function Xc(e,t,n,i,r,s){if(!i.regex)return i.replaceText;const o=e(r),a=n(o.line),l=r-t({line:o.line,character:0});let h;try{h=xo(i.text,!0,i.caseSensitive)}catch{return i.replaceText}h.lastIndex=l;const d=h.exec(a);return d===null||d.index!==l||d[0].length!==s-r?i.replaceText:Yc(i.replaceText,d)}function Yr(e,t){if(t+1<e.length){const n=e.charCodeAt(t),i=e.charCodeAt(t+1);if(n>=55296&&n<=56319&&i>=56320&&i<=57343)return t+2}return t+1}var Zc=class xi{#t;#e;#s;#n;#a;#d;constructor(t,n,i="text",r=0,s=new yo){this.#t=new URL(t,"file://").toString(),this.#e=i,this.#s=r,this.#n=new Uc(n),this.#a=s;const o=this.#n.getLineText(0,!0);o.endsWith(`\r
1384
+ `)?this.#d=`\r
1385
+ `:o.endsWith("\r")?this.#d="\r":this.#d=`
1386
+ `}get uri(){return this.#t}get languageId(){return this.#e}get version(){return this.#s}get lineCount(){return this.#n.lineCount}get eol(){return this.#d}get canUndo(){return this.#a.canUndo}get canRedo(){return this.#a.canRedo}positionAt(t){return this.normalizePosition(this.#n.positionAt(t))}positionsAt(t){const n=this.#n.positionsAt(t);for(let i=0;i<n.length;i++)n[i]=this.normalizePosition(n[i]);return n}offsetAt(t){return this.#n.offsetAt(this.normalizePosition(t))}getText(t){return t===void 0?this.#n.getText():this.#n.getText({start:this.normalizePosition(t.start),end:this.normalizePosition(t.end)})}getLineText(t,n){return this.#n.getLineText(t,n)}normalizeEol(t){return t.replace(/\r\n|\r|\n/g,this.eol)}getLineLength(t,n){return this.#n.getLineLength(t,n)}charAt(t){return typeof t=="number"?this.#n.charAt(t):this.#n.charAt(this.offsetAt(t))}getTextSlice(t,n){return this.#n.getTextSlice(t,n)}findNextNonOverlappingSubstring(t,n){return this.#n.findNextNonOverlappingSubstring(t,n)}search(t){return this.#n.search(t)}applyEdits(t,n=!0,i,r,s=!1){if(t.length!==0)return this.#l(this.#m(this.resolveEdits(t)),n,i,r,s)}resolveEdits(t){return t.map(n=>this.#x(n))}applyResolvedEdits(t,n=!0,i,r,s=!1){if(t.length!==0)return this.#l(this.#m(t.map(o=>this.#f(o))),n,i,r,s)}#l(t,n,i,r,s){const o=_c(this,t,this.#s,this.#s+1,n?i:void 0,n?r:void 0);n&&s&&(o.undoBoundary=!0);const a=this.#a.peekUndoForCoalescing(),l=this.#k(t);return this.#s++,l.lineDelta===0&&Fc(a,o)?this.#a.replaceLastUndo(Nc(a,o)):this.#a.push(o),l}setLastUndoSelectionsAfter(t){this.#a.setLastUndoSelectionsAfter(t)}setLastUndoLineAnnotations(t,n){this.#a.setLastUndoLineAnnotations(t,n)}undo(){const t=this.#a.popUndoToRedo();if(t===void 0)return;const n=this.#k(t.inverseEdits);if(n===void 0)return;this.#s=t.versionBefore;const i=t.selectionsBefore?.slice();return[n,i,t.lineAnnotationsBefore?.slice(),i===void 0?t.inverseEdits.map(r=>({...r})):void 0]}redo(){const t=this.#a.popRedoToUndo();if(t===void 0)return;const n=this.#k(t.forwardEdits);if(n===void 0)return;this.#s=t.versionAfter;const i=t.selectionsAfter?.slice();return[n,i,t.lineAnnotationsAfter?.slice(),i===void 0?t.forwardEdits.map(r=>({...r})):void 0]}normalizePosition(t){const n=xi.#g(t.line,this.lineCount-1);return{line:n,character:xi.#g(t.character,this.getLineLength(n))}}static#g(t,n){return Number.isNaN(t)?0:Math.max(0,Math.min(Math.floor(t),n))}#x(t){let n=this.offsetAt(t.range.start),i=this.offsetAt(t.range.end);if(n>i){const r=n;n=i,i=r}return this.#f({start:n,end:i,text:t.newText})}#f(t){let{start:n,end:i}=t;const r=n===i;return this.#C(n)&&n--,r?i=n:this.#C(i)&&i++,{start:n,end:i,text:t.text}}#C(t){const n=this.#n.charAt(t-1).charCodeAt(0),i=this.#n.charAt(t).charCodeAt(0);return n>=55296&&n<=56319&&i>=56320&&i<=57343}#m(t){const n=[...t].sort((i,r)=>{const s=i.start-r.start;return s===0?i.end-r.end:s});for(let i=0;i<n.length-1;i++)if(n[i].end>n[i+1].start)throw new Error("Overlapping text edits are not supported");return n}#k(t){const n=this.#n.lineCount,i=this.positionsAt(t.flatMap(h=>[h.start,h.end])),r=this.#E(t,i),s=i[0],o=i[i.length-1],a=o.line===n-1&&o.character===this.#n.getLineLength(o.line);this.#n.applyEdits(t);const l=this.#n.lineCount;return{changes:t.map((h,d)=>({...h,range:{start:i[d*2],end:i[d*2+1]}})),startLine:r.startLine,startCharacter:s.character,endCharacter:o.character,endLine:Math.min(r.endLine,Math.max(0,l-1)),endedAtDocumentEnd:a,previousLineCount:n,lineCount:l,lineDelta:l-n,changedLineRanges:r.ranges,changedLineChanges:r.changes}}#E(t,n){let i=1/0,r=0,s=0;const o=[],a=[],l=this.#n.lineCount-1,h=this.#n.getLineLength(l);for(let d=0;d<t.length;d++){const c=t[d],u=n[d*2],f=n[d*2+1],p=u.line,g=f.line,m=qa(c.text),v=p+s,S=v+m,C=m-(g-p);i=Math.min(i,p),r=Math.max(r,S);const b=o[o.length-1];b!==void 0&&v<=b[1]+1?o[o.length-1]=[b[0],Math.max(b[1],S)]:o.push([v,S]),a.push([v,S,C,u.character,f.character,g===l&&f.character===h]),s+=C}return i===1/0?{startLine:0,endLine:0,ranges:[[0,0]],changes:[[0,0,0,0,0,!1]]}:{startLine:i,endLine:r,ranges:o,changes:a}}};function Ot({metaKey:e,ctrlKey:t},n=In()){return n?e&&!t:t&&!e}function Jc(e){if(In()&&e.ctrlKey&&!e.altKey&&!e.metaKey)switch(e.key){case"a":return"start";case"e":return"end";case"p":return"up";case"n":return"down";case"f":return"right";case"b":return"left"}if(!e.altKey&&!e.ctrlKey&&!e.metaKey){if(e.key==="ArrowUp")return"up";if(e.key==="ArrowDown")return"down";if(e.key==="ArrowLeft")return"left";if(e.key==="ArrowRight")return"right";if(e.key==="Home")return"start";if(e.key==="End")return"end"}if(Ot(e)){if(e.key==="ArrowLeft")return"textStart";if(e.key==="ArrowRight")return"end"}}const Xr=new WeakMap,Qc=ko([{bindings:{Tab:"indent","shift+Tab":"outdent","cmdOrCtrl+[":"indentLess","cmdOrCtrl+]":"indentMore","cmdOrCtrl+z":"undo","cmdOrCtrl+shift+z":"redo","cmdOrCtrl+a":"selectAll","cmdOrCtrl+d":"findNextMatch","cmdOrCtrl+f":"openSearchPanel","cmdOrCtrl+alt+f":"openSearchReplacePanel","alt+ArrowUp":"moveLineUp","alt+ArrowDown":"moveLineDown","shift+alt+ArrowUp":"copyLineUp","shift+alt+ArrowDown":"copyLineDown",Escape:"simplifySelection","cmdOrCtrl+Enter":"insertBlankLine","cmdOrCtrl+/":"toggleComment","shift+alt+a":"toggleBlockComment","cmdOrCtrl+Home":"moveCursorToDocStart","cmdOrCtrl+End":"moveCursorToDocEnd","cmdOrCtrl+shift+Home":"expandSelectionDocStart","cmdOrCtrl+shift+End":"expandSelectionDocEnd"}},{platform:"mac",bindings:{"ctrl+k":"deleteHardLineForward","ctrl+alt+p":"moveLineUp","ctrl+alt+n":"moveLineDown","cmd+ArrowUp":"moveCursorToDocStart","cmd+ArrowDown":"moveCursorToDocEnd","cmd+shift+ArrowUp":"expandSelectionDocStart","cmd+shift+ArrowDown":"expandSelectionDocEnd"}},{platform:"windows",bindings:{"ctrl+y":"redo"}},{platform:"linux",bindings:{"ctrl+y":"redo","ctrl+alt+p":"moveLineUp","ctrl+alt+n":"moveLineDown"}}]),eu={Backquote:"`",Minus:"-",Equal:"=",Comma:",",Period:".",Slash:"/",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Backslash:"\\",Space:"Space"};function ko(e){let t=Xr.get(e);if(t===void 0){t={mac:new Map,windows:new Map,linux:new Map};for(const n of e)for(const i of Object.keys(n.bindings)){const r=n.bindings[i];if(r===void 0)continue;const s=i.split("+"),o=s.pop();for(const a of["mac","windows","linux"]){if(n.platform!==void 0&&n.platform!==a)continue;let l=0;for(const d of s)d==="alt"?l|=1:d==="ctrl"?l|=2:d==="cmd"?l|=4:d==="shift"?l|=8:d==="cmdOrCtrl"&&(l|=a==="mac"?4:2);let h=t[a].get(l);h===void 0&&(h=new Map,t[a].set(l,h)),h.set(o,r)}}Xr.set(e,t)}return t}function tu(e,t,n=In()){const i=e.key===" "?"Space":e.key.length===1?e.key.toLowerCase():e.key,r=e.code??"",s=r.startsWith("Key")&&r.length===4?r.slice(3).toLowerCase():r.startsWith("Digit")&&r.length===6?r.slice(5):eu[r],o=n?"mac":globalThis.navigator?.platform.includes("Linux")===!0?"linux":"windows",a=(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);if(t!==void 0){const h=ko(t)[o].get(a),d=h?.get(i)??(s===void 0?void 0:h?.get(s));if(d!==void 0)return d}const l=Qc[o].get(a);return l?.get(i)??(s===void 0?void 0:l?.get(s))}function ki(e,t=In()){if(!e.altKey&&Ot(e,t)&&((e.key.length===1?e.key.toLowerCase():e.key)==="g"||e.code==="KeyG"))return e.shiftKey?"previous":"next"}var nu=`::selection {
1387
+ background-color: #0000;
1388
+ }
1389
+
1390
+ [data-deleted-text-selection] [data-deletions] ::selection, [data-deleted-text-selection] [data-line-type="change-deletion"] ::selection {
1391
+ background-color: var(--diffs-editor-selection-bg);
1392
+ }
1393
+
1394
+ @keyframes blinking {
1395
+ 0% {
1396
+ opacity: 1;
1397
+ }
1398
+
1399
+ 50% {
1400
+ opacity: 0;
1401
+ }
1402
+
1403
+ 100% {
1404
+ opacity: 1;
1405
+ }
1406
+ }
1407
+
1408
+ :host, [data-code], [data-content], [data-diff-type="split"][data-overflow="wrap"] {
1409
+ position: relative;
1410
+ }
1411
+
1412
+ [data-code] {
1413
+ container-type: inline-size;
1414
+ }
1415
+
1416
+ [data-content] {
1417
+ cursor: text;
1418
+ caret-color: var(--diffs-bg-caret);
1419
+ background-color: #0000;
1420
+ outline: none;
1421
+ }
1422
+
1423
+ [data-line] {
1424
+ cursor: text;
1425
+ background-color: #0000;
1426
+ }
1427
+
1428
+ [data-line]:after {
1429
+ content: "";
1430
+ z-index: -20;
1431
+ background-color: var(--diffs-line-bg);
1432
+ pointer-events: none;
1433
+ position: absolute;
1434
+ inset: 0;
1435
+ }
1436
+
1437
+ [data-line][data-editor-active-line]:after {
1438
+ box-shadow: inset 0 0 0 1px var(--diffs-editor-line-highlight-border);
1439
+ }
1440
+
1441
+ [data-editor-overlay] {
1442
+ display: contents;
1443
+ }
1444
+
1445
+ [data-caret], [data-selection-range], [data-match-range], [data-bracket-match-range], [data-marker-range] {
1446
+ height: 1lh;
1447
+ line-height: var(--diffs-line-height);
1448
+ pointer-events: none;
1449
+ position: absolute;
1450
+ top: 0;
1451
+ left: 0;
1452
+ }
1453
+
1454
+ [data-caret] {
1455
+ background-color: var(--diffs-bg-caret-override, var(--diffs-editor-cursor-fg, light-dark(color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg)), color-mix(in lab, var(--diffs-fg) 75%, var(--diffs-bg)))));
1456
+ visibility: hidden;
1457
+ width: 2px;
1458
+ }
1459
+
1460
+ @media (prefers-reduced-motion: no-preference) {
1461
+ [data-caret] {
1462
+ animation: 1.2s .8s infinite blinking;
1463
+ }
1464
+ }
1465
+
1466
+ [data-selection-range] {
1467
+ z-index: -10;
1468
+ background-color: var(--diffs-editor-selection-bg);
1469
+ }
1470
+
1471
+ [data-selection-corner] {
1472
+ background-color: var(--diffs-selection-corner-bg, var(--diffs-bg));
1473
+ width: 100%;
1474
+ height: 100%;
1475
+ }
1476
+
1477
+ [data-match-range] {
1478
+ z-index: -10;
1479
+ background-color: var(--diffs-editor-match-bg, var(--diffs-editor-selection-bg));
1480
+ }
1481
+
1482
+ [data-match-range]:not([data-focus]) {
1483
+ background-color: var(--diffs-editor-match-highlight-bg, light-dark(#ff963288, #ff963266));
1484
+ }
1485
+
1486
+ [data-bracket-match-range] {
1487
+ z-index: -9;
1488
+ box-sizing: border-box;
1489
+ border-bottom: 1px solid
1490
+ var(--diffs-editor-bracket-match-border, color-mix(in lab, var(--diffs-fg) 60%, transparent));
1491
+ background-color: var(--diffs-editor-bracket-match-bg, color-mix(in lab, var(--diffs-fg) 5%, transparent));
1492
+ }
1493
+
1494
+ [data-rtl] {
1495
+ border-top-left-radius: 3px;
1496
+ }
1497
+
1498
+ [data-rtr] {
1499
+ border-top-right-radius: 3px;
1500
+ }
1501
+
1502
+ [data-rbl] {
1503
+ border-bottom-left-radius: 3px;
1504
+ }
1505
+
1506
+ [data-rbr] {
1507
+ border-bottom-right-radius: 3px;
1508
+ }
1509
+
1510
+ [data-marker-range] {
1511
+ z-index: 1;
1512
+ background-color: var(--diffs-marker-bg);
1513
+ mask-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2IiBoZWlnaHQ9IjMiPjxwYXRoIGQ9Im0wIDIuNSBsMiAtMS41IGwxIDAgbDIgMS41IGwxIDAiIHN0cm9rZT0iI2ZmZiIgZmlsbD0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIi8+PC9zdmc+");
1514
+ mask-position: 0 100%;
1515
+ mask-size: 6px 3px;
1516
+ mask-repeat: repeat-x;
1517
+ }
1518
+
1519
+ [data-marker-error] {
1520
+ --diffs-marker-contrast: light-dark(#fff, #000);
1521
+ --diffs-marker-bg: var(--diffs-editor-error-fg, var(--diffs-deletion-base));
1522
+ }
1523
+
1524
+ [data-marker-warning] {
1525
+ --diffs-marker-contrast: #000;
1526
+ --diffs-marker-bg: var(--diffs-editor-warning-fg, light-dark(var(--diffs-warning-light), var(--diffs-warning-dark)));
1527
+ }
1528
+
1529
+ [data-marker-info] {
1530
+ --diffs-marker-contrast: #000;
1531
+ --diffs-marker-bg: var(--diffs-editor-info-fg, var(--diffs-modified-base));
1532
+ }
1533
+
1534
+ [data-marker-hint] {
1535
+ --diffs-marker-contrast: light-dark(#fff, #000);
1536
+ --diffs-marker-bg: var(--diffs-editor-hint-fg, var(--diffs-fg-number));
1537
+ }
1538
+
1539
+ @media (width >= 480px) {
1540
+ [data-content] {
1541
+ caret-color: #0000;
1542
+ }
1543
+
1544
+ [data-content]:focus ~ [data-editor-overlay] [data-caret] {
1545
+ visibility: visible;
1546
+ }
1547
+ }
1548
+
1549
+ [data-editor-widget] {
1550
+ --diffs-widget-fg: var(--diffs-fg);
1551
+ --diffs-widget-bg: color-mix(in lab, var(--diffs-fg) 4%, var(--diffs-bg));
1552
+ --diffs-widget-border: color-mix(in lab, var(--diffs-fg) 20%, transparent);
1553
+ --diffs-widget-shadow: inset 0 0 0 1px var(--diffs-bg), 0 4px 8px #00000013,
1554
+ 0 6px 18px #00000013;
1555
+ z-index: 100;
1556
+ width: fit-content;
1557
+ max-width: calc(100% - 24px);
1558
+ font: 14px/20px var(--diffs-header-font-fallback);
1559
+ border: 1px solid var(--diffs-widget-border);
1560
+ background-color: var(--diffs-widget-bg);
1561
+ box-shadow: var(--diffs-widget-shadow);
1562
+ background-clip: padding-box;
1563
+ border-radius: 9px;
1564
+ position: absolute;
1565
+ top: 0;
1566
+ left: 0;
1567
+ }
1568
+
1569
+ [data-marker-popover], [data-selection-action-popover] {
1570
+ --popover-gap: var(--diffs-popover-gap, var(--diffs-gap-fallback, 8px));
1571
+ --popover-viewport-left: 0px;
1572
+ --popover-viewport-right: 100cqw;
1573
+ --popover-viewport-top: -99999px;
1574
+ --popover-viewport-bottom: 99999px;
1575
+ --popover-min-left: calc(var(--popover-viewport-left) + var(--gutter-width, 0px) + var(--popover-gap));
1576
+ --popover-available-width: max(0px,
1577
+ calc(var(--popover-viewport-right) - var(--popover-min-left) -
1578
+ var(--popover-gap)));
1579
+ max-width: min(640px, var(--popover-available-width));
1580
+ translate: clamp(var(--popover-min-left),
1581
+ var(--popover-x, var(--popover-min-left)),
1582
+ calc(var(--popover-viewport-right) - var(--popover-gap) - 100%))
1583
+ /* Clamp into the scrollport so a popover with no fitting side stays in view. */
1584
+ clamp(var(--popover-viewport-top),
1585
+ calc(var(--popover-y, 0px) + var(--popover-y-shift, 0px)),
1586
+ calc(var(--popover-viewport-bottom) - var(--popover-gap) - 100%));
1587
+ }
1588
+
1589
+ [data-marker-popover] {
1590
+ --diffs-widget-bg: var(--diffs-marker-bg);
1591
+ --diffs-widget-shadow: 0 4px 8px #00000026, 0 6px 18px #00000026;
1592
+ min-width: min(180px, var(--popover-available-width));
1593
+ overflow-wrap: anywhere;
1594
+ color: var(--diffs-marker-contrast);
1595
+ white-space: normal;
1596
+ pointer-events: auto;
1597
+ border: 0;
1598
+ padding: 8px 12px;
1599
+
1600
+ @supports (color: contrast-color(red)) {
1601
+ color: contrast-color(var(--diffs-marker-bg, var(--diffs-bg)));
1602
+ }
1603
+
1604
+ & [data-marker-message] {
1605
+ white-space: normal;
1606
+ overflow-wrap: anywhere;
1607
+
1608
+ & code {
1609
+ white-space: normal;
1610
+ color: inherit;
1611
+ background-color: #0000;
1612
+ display: inline;
1613
+ }
1614
+ }
1615
+ }
1616
+
1617
+ [data-selection-action-popover] {
1618
+ pointer-events: auto;
1619
+ flex-wrap: wrap;
1620
+ align-items: center;
1621
+ gap: 4px;
1622
+ width: max-content;
1623
+ padding: 4px;
1624
+ display: flex;
1625
+ }
1626
+
1627
+ [data-search-panel] {
1628
+ z-index: 100;
1629
+ flex-direction: column;
1630
+ justify-content: right;
1631
+ width: 100%;
1632
+ height: 0;
1633
+ display: flex;
1634
+ position: sticky;
1635
+ top: 16px;
1636
+ right: 16px;
1637
+ container: search-panel / inline-size;
1638
+
1639
+ & [data-editor-widget] {
1640
+ z-index: 100;
1641
+ flex-shrink: 0;
1642
+ align-items: stretch;
1643
+ gap: 8px;
1644
+ min-width: 260px;
1645
+ max-width: 100%;
1646
+ margin-inline: auto 16px;
1647
+ padding: 4px;
1648
+ display: flex;
1649
+ position: relative;
1650
+ }
1651
+
1652
+ & svg {
1653
+ fill: currentColor;
1654
+ width: 12px;
1655
+ height: 12px;
1656
+ display: block;
1657
+ }
1658
+ }
1659
+
1660
+ [data-search-grid] {
1661
+ grid-template-columns: auto auto auto;
1662
+ grid-template-areas: "find matches nav"
1663
+ "replace actions .";
1664
+ align-items: center;
1665
+ gap: 4px 6px;
1666
+ width: 100%;
1667
+ display: grid;
1668
+ }
1669
+
1670
+ [data-input-box][data-find] {
1671
+ grid-area: find;
1672
+ }
1673
+
1674
+ [data-search-nav] {
1675
+ grid-area: nav;
1676
+ }
1677
+
1678
+ [data-input-box][data-replace] {
1679
+ grid-area: replace;
1680
+ }
1681
+
1682
+ [data-replace-actions] {
1683
+ grid-area: actions;
1684
+ }
1685
+
1686
+ [data-search-grid][data-mode="find"] {
1687
+ grid-template-areas: "find matches nav";
1688
+ }
1689
+
1690
+ [data-search-grid][data-mode="find"] [data-replace-cell] {
1691
+ display: none;
1692
+ }
1693
+
1694
+ @container search-panel (width < 400px) {
1695
+ [data-search-panel] [data-editor-widget] {
1696
+ padding: 10px;
1697
+ }
1698
+
1699
+ [data-search-grid][data-mode="replace"] {
1700
+ grid-template-columns: auto 1fr auto;
1701
+ grid-template-areas: "find find find"
1702
+ "replace replace replace"
1703
+ "nav matches actions";
1704
+ }
1705
+
1706
+ [data-search-grid][data-mode="find"] {
1707
+ grid-template-columns: auto 1fr auto;
1708
+ grid-template-areas: "find find find"
1709
+ "nav matches matches";
1710
+ }
1711
+
1712
+ [data-replace-actions] {
1713
+ justify-self: end;
1714
+ }
1715
+
1716
+ [data-search-grid] [data-input-box] {
1717
+ width: auto;
1718
+ }
1719
+ }
1720
+
1721
+ [data-input-box] {
1722
+ align-items: center;
1723
+ width: 200px;
1724
+ display: flex;
1725
+ position: relative;
1726
+
1727
+ & input {
1728
+ width: 100%;
1729
+ min-width: 0;
1730
+ color: var(--diffs-fg);
1731
+ background-color: var(--diffs-bg);
1732
+ border: 1px solid color-mix(in lab, var(--diffs-fg) 12%, var(--diffs-bg));
1733
+ border-radius: 6px;
1734
+ outline: none;
1735
+ flex-grow: 1;
1736
+ padding-inline: 6px;
1737
+ font-size: 13px;
1738
+ line-height: 24px;
1739
+
1740
+ &::selection {
1741
+ background-color: color-mix(in lab, var(--diffs-fg) 8%, var(--diffs-bg));
1742
+ }
1743
+
1744
+ &:focus-visible {
1745
+ outline: 1px solid var(--diffs-modified-base);
1746
+ }
1747
+ }
1748
+
1749
+ &[data-find] input {
1750
+ padding-inline-end: 72px;
1751
+ }
1752
+
1753
+ & [data-search-icon] {
1754
+ --diffs-search-icon-size: 20px;
1755
+ }
1756
+ }
1757
+
1758
+ [data-search-toggles] {
1759
+ align-items: center;
1760
+ gap: 1px;
1761
+ display: flex;
1762
+ position: absolute;
1763
+ top: 50%;
1764
+ right: 4px;
1765
+ transform: translateY(-50%);
1766
+ }
1767
+
1768
+ [data-matches] {
1769
+ white-space: nowrap;
1770
+ min-width: 50px;
1771
+ color: color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg));
1772
+ flex-shrink: 0;
1773
+ grid-area: matches;
1774
+ font-size: 12px;
1775
+ font-weight: 500;
1776
+ line-height: 20px;
1777
+
1778
+ &[data-no-matches] {
1779
+ color: color-mix(in lab, var(--diffs-fg) 35%, var(--diffs-bg));
1780
+ }
1781
+ }
1782
+
1783
+ [data-replace-actions], [data-search-nav] {
1784
+ align-items: center;
1785
+ display: flex;
1786
+ }
1787
+
1788
+ [data-search-icon] {
1789
+ appearance: none;
1790
+ width: var(--diffs-search-icon-size, 24px);
1791
+ height: var(--diffs-search-icon-size, 24px);
1792
+ color: color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg));
1793
+ border-radius: var(--diffs-search-icon-radius, 4px);
1794
+ cursor: pointer;
1795
+ background: none;
1796
+ border: 0;
1797
+ flex-shrink: 0;
1798
+ justify-content: center;
1799
+ align-items: center;
1800
+ margin: 0;
1801
+ padding: 0;
1802
+ transition: background-color .1s ease-in-out, color .1s ease-in-out;
1803
+ display: flex;
1804
+
1805
+ &:disabled {
1806
+ opacity: .25;
1807
+ cursor: default;
1808
+ }
1809
+
1810
+ &:not(:disabled):hover {
1811
+ color: var(--diffs-fg);
1812
+ }
1813
+
1814
+ &:focus-visible {
1815
+ outline: 1px solid var(--diffs-modified-base);
1816
+ }
1817
+
1818
+ &[aria-pressed="true"] {
1819
+ color: var(--diffs-modified-base);
1820
+ }
1821
+ }
1822
+
1823
+ [data-search-close] {
1824
+ --diffs-search-icon-size: 20px;
1825
+ --diffs-search-icon-radius: 50%;
1826
+ color: var(--diffs-widget-bg);
1827
+ background-color: color-mix(in lab,
1828
+ var(--diffs-widget-fg) 50%,
1829
+ var(--diffs-bg));
1830
+ position: absolute;
1831
+ top: 0;
1832
+ right: 0;
1833
+ transform: translate(50%, -50%);
1834
+
1835
+ &:not(:disabled):hover {
1836
+ opacity: 1;
1837
+ color: var(--diffs-widget-bg);
1838
+ background-color: var(--diffs-widget-fg);
1839
+ }
1840
+ }
1841
+ `;const iu="//",ru=["/*","*/"],su={sql:{lineComment:"--"},ruby:{lineComment:"#",blockComment:["=begin","=end"]},rst:{lineComment:".."},coffeescript:{lineComment:"#",blockComment:["###","###"]},cmd:{lineComment:"@REM"},julia:{lineComment:"#",blockComment:["#=","=#"]},yaml:{lineComment:"#"},yml:{lineComment:"#"},markdown:{lineComment:null,blockComment:["<!--","-->"]},zsh:{lineComment:"#"},makefile:{lineComment:"#"},handlebars:{lineComment:null,blockComment:["{{!--","--}}"]},ini:{lineComment:";",blockComment:[";"," "]},powershell:{lineComment:"#",blockComment:["<#","#>"]},vb:{lineComment:"'"},xml:{lineComment:null,blockComment:["<!--","-->"]},lua:{lineComment:"--",blockComment:["--[[","]]"]},html:{lineComment:null,blockComment:["<!--","-->"]},diff:{lineComment:"#",blockComment:["#"," "]},r:{lineComment:"#"},fsharp:{blockComment:["(*","*)"]},pug:{lineComment:"//-"},perl:{lineComment:"#"},tex:{lineComment:"%"},clojure:{lineComment:";;"},css:{lineComment:null},python:{lineComment:"#",blockComment:['"""','"""']},dotenv:{lineComment:"#"},dockerfile:{lineComment:"#"},razor:{lineComment:null,blockComment:["<!--","-->"]},prompt:{lineComment:null,blockComment:["<!--","-->"]}};function ou(e,t){const n={...su[e],...t?.[e]};return{lineComment:n.lineComment===void 0?iu:n.lineComment,blockComment:n.blockComment??ru}}function au(e,t,n){const i=[],r=new Set;for(const a of t){let l=a.end.line;a.start.line<l&&a.end.character===0&&l--;const h=i.length;let d=1/0;for(let c=a.start.line;c<=l;c++){if(r.has(c))continue;r.add(c);const u=e.getLineText(c),f=u.length-u.trimStart().length,p=f===u.length;p||(d=Math.min(d,f)),i.push({line:c,comment:u.slice(f,f+n.length)===n?f:-1,empty:p,indent:f,single:!1})}if(d!==1/0)for(let c=h;c<i.length;c++)i[c].empty||(i[c].indent=d);i.length===h+1&&(i[h].single=!0)}const s=i.some(a=>a.comment<0&&(!a.empty||a.single)),o=[];if(s){for(const a of i){if(a.empty&&!a.single)continue;const l={line:a.line,character:a.indent};o.push({range:{start:l,end:l},newText:n+" "})}return o}for(const a of i){if(a.comment<0)continue;const l=e.getLineText(a.line),h=a.comment,d=h+n.length+(l[h+n.length]===" "?1:0);o.push({range:{start:{line:a.line,character:h},end:{line:a.line,character:d}},newText:""})}return o}const Ct=50;function lu(e,t,n,i,r){const s=Math.max(0,i-Ct),o=e.getTextSlice(s,i),a=e.getTextSlice(r,r+Ct),l=o.length-o.trimEnd().length,h=a.length-a.trimStart().length,d=o.length-l;if(o.slice(d-t.length,d)===t&&a.slice(h,h+n.length)===n)return{open:{start:i-l-t.length,end:i-l+(l>0?1:0),text:""},close:{start:r+h-(h>0?1:0),end:r+h+n.length,text:""},contentStart:i,contentEnd:r};const c=r-i<=Ct*2?e.getTextSlice(i,r):void 0,u=c??e.getTextSlice(i,i+Ct),f=c??e.getTextSlice(r-Ct,r),p=u.length-u.trimStart().length,g=r-(f.length-f.trimEnd().length)-n.length;if(u.slice(p,p+t.length)!==t||e.getTextSlice(g,g+n.length)!==n)return;const m=i+p,v=m+t.length+(/\s/.test(u[t.length+p]??"")?1:0),S=g-(/\s/.test(e.getTextSlice(g-1,g))?1:0);return{open:{start:m,end:v,text:""},close:{start:S,end:g+n.length,text:""},contentStart:v,contentEnd:S}}function Zr(e,t,n,i){let r=0,s=t.length;for(;r<s;){const a=r+s>>>1;t[a].end<e?r=a+1:s=a}let o=n[r];for(let a=r;a<t.length;a++){const l=t[a];if(e<l.start)break;if(l.start===l.end&&e===l.start){if(i<0)break;o+=l.text.length;continue}if(e>l.end){o+=l.text.length-(l.end-l.start);continue}return e===l.end?l.start+o+l.text.length:l.start+o+(i>0?l.text.length:0)}return e+o}function du(e,t,[n,i],r=!1){const s=t.map(c=>{let{start:u,end:f}=c;if(r){let p=f.line;u.line<p&&f.character===0&&p--;const g=e.getLineText(u.line),m=g.length-g.trimStart().length;u={line:u.line,character:m},f={line:p,character:e.getLineLength(p)}}return{from:e.offsetAt(u),to:e.offsetAt(f),direction:c.direction,comment:void 0}});if(r&&s.length>1){s.sort((u,f)=>{const p=u.from-f.from;return p!==0?p:u.to-f.to});let c=0;for(let u=1;u<s.length;u++){const f=s[c],p=s[u];p.from<=f.to?f.to=Math.max(f.to,p.to):s[++c]=p}s.length=c+1}for(const c of s)c.comment=lu(e,n,i,c.from,c.to);const o=s.every(c=>c.comment!==void 0),a=[];for(const c of s){const u=c.comment;if(o&&u!==void 0){a.push(u.open,u.close);continue}if(u===void 0){if(c.from===c.to){a.push({start:c.from,end:c.to,text:n+" "+i});continue}a.push({start:c.from,end:c.from,text:n+" "},{start:c.to,end:c.to,text:" "+i})}}if(a.length===0)return;a.sort((c,u)=>{const f=c.start-u.start;return f!==0?f:c.end-u.end});const l=a.map(c=>({range:{start:e.positionAt(c.start),end:e.positionAt(c.end)},newText:c.text}));if(r)return{edits:l,nextSelectionOffsets:[]};const h=s.map(c=>{const u=c.comment;return o&&u!==void 0?{start:u.contentStart,end:u.contentEnd,startAssociation:1,endAssociation:-1}:u!==void 0?{start:c.from,end:c.to,startAssociation:1,endAssociation:1}:c.from===c.to?{start:c.from,end:c.to,startAssociation:-1,endAssociation:-1,collapsedInset:n.length+1}:{start:c.from,end:c.to,startAssociation:1,endAssociation:-1}}),d=new Array(a.length+1);d[0]=0;for(let c=0;c<a.length;c++){const u=a[c];d[c+1]=d[c]+u.text.length-(u.end-u.start)}return{edits:l,nextSelectionOffsets:h.map((c,u)=>{const f=Zr(c.start,a,d,c.startAssociation)+(c.collapsedInset??0);return[f,c.collapsedInset===void 0?Zr(c.end,a,d,c.endAssociation):f,s[u].direction]})}}function W(e,t,n){const{style:i,dataset:r,children:s,...o}=t??{},a=document.createElement(e);return Object.assign(a,o),i!==void 0&&(typeof i=="string"?a.style.cssText=i:Object.assign(a.style,i)),r!==void 0&&(typeof r=="string"?a.dataset[r]="":Array.isArray(r)?r.forEach(l=>{a.dataset[l]=""}):Object.assign(a.dataset,r)),s!==void 0&&a.replaceChildren(...s),n!==void 0&&n.appendChild(a),a}function G(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function ue(e,t="line"){const n=e.dataset[t];if(n===void 0)return;const i=parseInt(n,10);if(!Number.isNaN(i))return i}function Jr(e,t){if(e.nodeType===3){const n=e.textContent?.length??0;return Math.max(0,Math.min(t,n))}return e.nodeType===1?Math.max(0,Math.min(t,e.childNodes.length)):0}function hu(e,t){return Object.assign(e,t)}function cu(e,t){let n;return function(...i){clearTimeout(n),n=setTimeout(()=>e.apply(this,i),t)}}function lt(e,t=1e3){return Math.round(e*t)/t}function uu(e){return e.endsWith(`
1842
+ `)||e.endsWith("\r")}function wo(e){if(!(typeof Intl>"u"||typeof Intl.Segmenter!="function"))return new Intl.Segmenter(void 0,e)}let Qr,es=!1;function pt(){return es||(Qr=wo({granularity:"grapheme"}),es=!0),Qr}function fu(e){const t=e.ownerDocument;let n=e.parentElement;for(;n!=null&&n!==t.body&&n!==t.documentElement;){const i=n.ownerDocument.defaultView?.getComputedStyle(n).overflowY;if(i==="auto"||i==="scroll"||i==="overlay")return n;n=n.parentElement}return t}function Mn(e,t){const n=pu(e);if(n.length===0)return;const i=[];let r=!1;for(const s of t){if(s.side==="deletions"||s.lineNumber<=0){i.push(s);continue}let o=s.lineNumber-1,a=e.previousLineCount,l=!1;for(const d of n){const c=Math.max(1,a+d.lineDelta),u=gu(o,d,c);if(u===void 0){l=!0,o=void 0;break}(u!==o||vu(o,d))&&(l=!0),o=u,a=c}if(o===void 0){r=!0;continue}const h=o+1;if(l){i.push(h===s.lineNumber?s:{...s,lineNumber:h}),r=!0;continue}i.push(s)}return r?i:void 0}function pu(e){if(e.changedLineChanges!==void 0)return e.changedLineChanges.flatMap(([i,r,s,o=0,a=0,l=!1])=>{if(s===0)return[];const h=Math.max(0,r-i);return[{startLine:i,startCharacter:o,endLine:i+Math.max(0,h-s),deletesEndLine:s<0&&l,insertedLineBreaks:h,lineDelta:s}]});if(e.lineDelta===0)return e.changedLineRanges.flatMap(([i,r])=>{const s=r-i;return s<=0?[]:[{startLine:i,startCharacter:0,endLine:i,deletesEndLine:!1,insertedLineBreaks:s,lineDelta:s}]});const t=Math.max(0,-e.lineDelta),n=e.endedAtDocumentEnd&&e.startLine+t===e.previousLineCount-1;return[{startLine:e.startLine,startCharacter:e.startCharacter,endLine:e.startLine+t,deletesEndLine:n,insertedLineBreaks:Math.max(0,e.lineDelta),lineDelta:e.lineDelta}]}function gu(e,t,n){if(e<t.startLine)return e;if(e>t.endLine||t.endLine>t.startLine&&e===t.endLine&&!t.deletesEndLine)return e+t.lineDelta;if(t.startLine===t.endLine)return t.startCharacter===0?e+t.insertedLineBreaks:e;if(mu(e,t))return;const i=Math.min(Math.max(0,e-t.startLine),t.insertedLineBreaks);return Su(t.startLine+i,n)}function mu(e,t){return!(t.lineDelta>=0||e<t.startLine||e>t.endLine||e===t.startLine&&t.startCharacter>0||e===t.endLine&&!t.deletesEndLine)}function vu(e,t){return t.lineDelta===0||e<t.startLine||e>t.endLine?!1:!(t.endLine>t.startLine&&e===t.endLine&&!t.deletesEndLine)}function Su(e,t){return Math.max(0,Math.min(e,Math.max(0,t-1)))}function bu(e,t,n){const i=new Map,r=new Map;for(const d of e){const c=d.lineNumber;i.has(c)||i.set(c,[]),r.has(c)||r.set(c,[]),(d.side==="deletions"?r:i).get(c).push(be(d))}const s=t.parentElement?.previousElementSibling;let o,a;if(s!=null&&s instanceof HTMLElement&&s.dataset.deletions!==void 0)for(const d of s.children){const c=d,{gutter:u,content:f}=c.dataset;u!==void 0?o=c:f!==void 0&&(a=c)}ts(t,n),a!==void 0&&ts(a,o);const l=ns(i,t,n);if(a===void 0)return;const h=ns(r,a,o);requestAnimationFrame(()=>{Cu(i,r,l,h)})}function ts(e,t){const n=[];for(let i=1;i<e.childElementCount;i++){const r=e.children[i];r.dataset.lineAnnotation!==void 0&&(n.push(r),t!==void 0&&n.push(t.children[i]))}for(const i of n)i.remove()}function ns(e,t,n){const i=new Map;for(const r of t.children){const s=ue(r);if(s!==void 0){const o=e.get(s);if(o!==void 0){const a=W("div",{dataset:{lineAnnotation:"0,"+(s-1)},children:[W("div",{dataset:"annotationContent",children:o.map(l=>W("slot",{name:l}))})]});r.after(a),i.set(s,a)}}}if(n!==void 0)for(const r of n.children){const s=ue(r,"columnNumber");if(s!==void 0&&e.has(s)){const o=W("div",{dataset:{gutterBuffer:"annotation",bufferSize:"1"},style:{gridRow:"span 1"}});r.after(o)}}return i}function Cu(e,t,n,i){const r=new Map;for(const[s,o]of e.entries()){const a=i.get(s);if(o.length===0&&a!==void 0){const l=is(a);l>0&&r.set(s,l)}}for(const[s,o]of t.entries()){const a=n.get(s);if(o.length===0&&a!==void 0){const l=is(a);l>0&&r.set(s,l)}}rs(e,n,r),rs(t,i,r)}function is(e){const t=e.firstElementChild;return t instanceof HTMLElement?t.getBoundingClientRect().height:0}function rs(e,t,n){for(const[i,r]of t.entries()){const s=e.get(i),o=n.get(i);s?.length===0&&o!==void 0&&r.style.setProperty("--diffs-annotation-min-height",`${o}px`)}}var yu=class{#t;#e;#s;#n;#a;#d;#l=0;#g=0;#x=0;#f=!0;#C;#m=new Map;#k;#E;constructor(e){this.#k=e.hasActivePopover,this.#E=e.updateActivePopover}setViewportElements(e,t){const n=this.#t!==e||this.#e!==t;this.#t=e,n&&(this.#e=t,this.#f=!0,this.#C?.forEach(i=>i()),this.#C=void 0)}cleanUp(){this.#e=void 0,this.#t=void 0,this.#s=void 0,this.#n=void 0,this.#a=void 0,this.#d=void 0,this.#l=0,this.#g=0,this.#x=0,this.#f=!0,this.#C?.forEach(e=>e()),this.#C=void 0,this.#m.clear()}resetPlacement(e="default"){this.#m.delete(e)}setPlacement(e,t="default"){this.#m.set(t,e)}choosePlacement(e){const{preferred:t,fallback:n,viewport:i,popoverHeight:r,atDocumentEdge:s,placementKey:o="default"}=e,a=this.#m.get(o);let l;if(i!==void 0&&r>0){const h=(d,c=0)=>d.top>=i.top+c&&d.bottom<=i.bottom-c;a==="fallback"&&h(n)&&!h(t,4)||!h(t)&&h(n)?l="fallback":l="preferred"}else l=s?"fallback":"preferred";return this.#m.set(o,l),l}getPlacementBounds(){const e=this.#P();if(e===void 0)return;const t=this.#b();let n,i;if(t!==void 0?(n=t.top,i=t.bottom):(n=0,i=window.innerHeight),n=Math.max(n,e.top),i=Math.min(i,e.bottom),i<=n)return;const r=this.#l,s=this.#g,o=this.#x>0?this.#x:e.width,a=t!==void 0?t.left:0,l=t!==void 0?t.right:window.innerWidth,h=r,d=r+o,c=Math.max(h,a-e.left+r),u=Math.min(d,l-e.left+r);return{top:n-e.top+s,bottom:i-e.top+s,left:c,right:Math.max(c,u)}}#B(){const e=this.#t;if(e===void 0)return;if(this.#n===e&&(this.#s===void 0||this.#s.isConnected))return this.#s;let t=e.parentElement;for(;t!==null;){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="overlay")return this.#s=t,this.#n=e,t;t=t.parentElement}this.#s=void 0,this.#n=e}#o(){if(!this.#f)return;this.#v();const e=this.#e;this.#a=e?.getBoundingClientRect(),this.#l=e?.scrollLeft??0,this.#g=e?.scrollTop??0,this.#x=e?.clientWidth??0,this.#d=this.#B()?.getBoundingClientRect(),this.#f=!1}#P(){return this.#o(),this.#a}#b(){return this.#o(),this.#d}#v(){if(this.#C!==void 0)return;let e;const t=()=>{this.#f=!0,!(!this.#k()||e!==void 0)&&(e=requestAnimationFrame(()=>{e=void 0,this.#E()}))},n=this.#B(),i=this.#e;this.#C=[n!==void 0?G(n,"scroll",t,{passive:!0}):G(window,"scroll",t,{passive:!0}),...i!==void 0?[G(i,"scroll",t,{passive:!0})]:[],G(window,"resize",t,{passive:!0}),()=>{e!==void 0&&(cancelAnimationFrame(e),e=void 0)}]}};function Eo(e,{gutterWidth:t,placeAbove:n,viewport:i,x:r,y:s}){if(e.style.setProperty("--gutter-width",t+"px"),e.style.setProperty("--popover-x",r+"px"),e.style.setProperty("--popover-y",s+"px"),e.style.setProperty("--popover-y-shift",n?"-100%":"0px"),i===void 0){e.style.removeProperty("--popover-viewport-left"),e.style.removeProperty("--popover-viewport-right"),e.style.removeProperty("--popover-viewport-top"),e.style.removeProperty("--popover-viewport-bottom");return}e.style.setProperty("--popover-viewport-left",i.left+"px"),e.style.setProperty("--popover-viewport-right",i.right+"px"),e.style.setProperty("--popover-viewport-top",i.top+"px"),e.style.setProperty("--popover-viewport-bottom",i.bottom+"px")}const To=new Map([["'","'"],['"','"'],["`","`"],["{","}"],["[","]"],["<",">"],["(",")"]]),Lu=new Set(["'",'"',"`"]),xu=new Set(["{","[","(","<"]);function ku(e,t=0){const n=hs(e.startContainer,e.startOffset),i=hs(e.endContainer,e.endOffset);if(!(n===null||i===null))return{start:n,end:i,direction:t}}function wu(e,t,n,i){if(e===void 0)return[[],t];const{start:r,end:s}=t,o=[];let a={...t};const l=r.line!==s.line;let h=s.line;r.line<s.line&&s.character===0&&h--;for(let d=r.line;d<=h;d++){const c=e.getLineText(d);if(c===void 0||l&&c.trim().length===0)continue;const u=c.startsWith(" ")?" ":" ".repeat(n);let f=0,p=u;if(i){if(c.startsWith(" "))f=1;else if(c.startsWith(" ")){const m=c.length-c.trimStart().length;f=Math.min(u.length,m)}if(f===0)continue;p=""}o.push({range:{start:{line:d,character:0},end:{line:d,character:f}},newText:p});const g=p.length-f;d===r.line&&(a={...a,start:{...r,character:Math.max(0,r.character+g)}}),d===s.line&&(a={...a,end:{...s,character:Math.max(0,s.character+g)}})}return[o,a]}function Ao(e,t,n,i={}){const r=e.lineCount;return t.map(s=>{let{line:o,character:a}=n==="up"||n==="left"?s.start:s.end;if(n==="textStart"||n==="start"||n==="end"){const h=ne(s);o=h.line,a=h.character;const d=Ro(e,o,a,i);if(n==="textStart"){const c=e.getLineText(o).slice(d.start,d.end),u=d.start+Oo(c);a=a===u?d.start:u}else a=n==="start"?d.start:d.end}else if(n==="up"){const h=ss(e,o,a,-1,i);h!==void 0?(o=h.line,a=h.character):o>0&&(o=i.resolveRenderableLine==null?o-1:i.resolveRenderableLine(o-1,"up")??o)}else if(n==="down"){const h=ss(e,o,a,1,i);if(h!==void 0)o=h.line,a=h.character;else{const d=Math.max(r-1,0);o<d&&(o=i.resolveRenderableLine==null?o+1:Math.min(i.resolveRenderableLine(o+1,"down")??o,d))}}else if(Q(s)){const h=e.getLineLength(o);if(a=Math.min(a,h),n==="left"){if(a>0)a=kn(e,o,a,!1);else if(o>0){const d=i.resolveRenderableLine==null?o-1:i.resolveRenderableLine(o-1,"up");d!==void 0&&(o=d,a=e.getLineLength(o))}}else if(a<h)a=kn(e,o,a,!0);else if(o<r-1){const d=i.resolveRenderableLine==null?o+1:i.resolveRenderableLine(o+1,"down");d!==void 0&&(o=Math.min(d,r-1),a=0)}}const l={line:o,character:a};return{start:l,end:l,direction:0}})}function ss(e,t,n,i,r){if(r.getSoftLineOffsets===void 0)return;const s=Ro(e,t,n,r),o=s.index+i;let a=t,l;if(o>=0&&o<s.count)l=xn(e,a,o,r);else{const f=t+i;if(f<0||f>=e.lineCount)return{line:t,character:n};const p=r.resolveRenderableLine==null?f:r.resolveRenderableLine(f,i<0?"up":"down");if(p===void 0)return{line:t,character:n};a=Math.min(p,e.lineCount-1);const g=Tu(e,a,r);l=xn(e,a,i<0?g-1:0,r)}const h=Math.max(0,n-s.start),d=l.start+h,c=l.index===l.count-1?d:Math.min(d,l.end),u=e.getLineText(a);return{line:a,character:c>u.length?c:Eu(u,c)}}function Eu(e,t){if(t<=0||t>=e.length)return t;const n=pt();if(n!==void 0){for(const r of n.segment(e)){if(t<=r.index)return t;const s=r.index+r.segment.length;if(t<s)return s}return t}let i=0;for(const r of e){if(t<=i)return t;const s=i+r.length;if(t<s)return s;i=s}return t}function Ro(e,t,n,i){const r=e.getLineLength(t),s=i.getSoftLineOffsets?.(t);if(s===void 0||s.length<2)return{start:0,end:r,index:0,count:1};for(let o=0;o+1<s.length;o++){const a=xn(e,t,o,i);if(n>=a.start&&n<=a.end)return a}return xn(e,t,n<(s[0]??0)?0:s.length-2,i)}function Tu(e,t,n){const i=n.getSoftLineOffsets?.(t);return i===void 0||i.length<2?1:i.length-1}function xn(e,t,n,i){const r=e.getLineLength(t),s=i.getSoftLineOffsets?.(t);if(s===void 0||s.length<2)return{start:0,end:r,index:0,count:1};const o=s.length-1,a=Math.max(0,Math.min(n,o-1)),l=Math.max(0,Math.min(r,s[a]??0));return{start:l,end:Math.max(l,Math.min(r,s[a+1]??r)),index:a,count:o}}function Au(e,t,n,i={}){return t.map(r=>{const s=r.direction===-1?r.start:r.end,[o]=Ao(e,[{start:s,end:s,direction:0}],n,i);return wi(r,o)})}function Ru(e,t,n,i,r=2,s=!1){if(t[t.length-1]===void 0)return{nextSelections:[]};const o=[];for(const b of t)o.push(b.start,b.end);const a=o.map(b=>e.offsetAt(b)),l=a[(t.length-1)*2],h=a[(t.length-1)*2+1],d=[];let c=!0;for(let b=0;b<t.length;b++){const y={index:b,start:a[b*2],end:a[b*2+1]},L=d[d.length-1];L!==void 0&&(y.start<L.start||y.start===L.start&&y.end<L.end)&&(c=!1),d.push(y)}c||d.sort((b,y)=>{const L=b.start-y.start;if(L!==0)return L;const k=b.end-y.end;return k!==0?k:b.index-y.index});const u=Ri(e,n,r),f=[],p=Array.from({length:t.length});let g=0,m;const v=()=>{if(m===void 0)return;const b=Ri(e,{start:m.start,end:m.end,text:u.text},r),y=Po(e,b.text,b.start);f.push({start:b.start,end:b.end,text:y});const L=[m.start+g+y.length,m.start+g+y.length];for(const k of m.indices)p[k]=L;g+=y.length-(b.end-b.start),m=void 0};for(const b of d){const y=Math.max(0,b.start+(u.start-l)),L=Math.max(y,b.end+(u.end-h));if(m!==void 0&&y<m.end){m.end=Math.max(m.end,L),m.indices.push(b.index);continue}v(),m={start:y,end:L,indices:[b.index]}}v();const S=e.applyResolvedEdits(f,!0,t,void 0,s),C=Ki(e,p.map(b=>{if(b===void 0)throw new Error("Missing next selection offsets");return b}));if(e.setLastUndoSelectionsAfter(C),S!==void 0&&i!==void 0){const b=Mn(S,i);b!==void 0&&e.setLastUndoLineAnnotations(i,b)}return{nextSelections:C,change:S}}function Iu(e,t){if(t.length!==e.length+2)return;const n=To.get(t[0]);if(!(n===void 0||t[t.length-1]!==n||t.slice(1,-1)!==e))return 1}function Mu(e,t,n,i){const r=t.start+n,s=r+i.length;if(t.end-t.start>0){const o=e.getTextSlice(t.start,t.end),a=Iu(o,i)??i.indexOf(o);if(a!==-1&&a+o.length<=i.length){const l=r+a;return[l,l+o.length]}}return[s,s]}function _t(e,t,n,i,r=!1,s="selection"){if(t.length!==n.length)throw new Error("Selection text replacements must match the selection count");const o=[];for(const g of t)o.push(g.start,g.end);const a=o.map(g=>e.offsetAt(g)),l=[];let h=!0;for(let g=0;g<t.length;g++){const m={index:g,start:a[g*2],end:a[g*2+1]},v=l[l.length-1];v!==void 0&&(m.start<v.start||m.start===v.start&&m.end<v.end)&&(h=!1),l.push(m)}h||l.sort((g,m)=>{const v=g.start-m.start;if(v!==0)return v;const S=g.end-m.end;return S!==0?S:g.index-m.index});const d=n.every(g=>g==="");let c;const u=Array.from({length:t.length});if(d){c=[];let g=!1;for(const m of l){if(u[m.index]=[m.end,m.end],m.start>=m.end)continue;g=!0;const v=c[c.length-1];v!==void 0&&m.start<v.end?c[c.length-1]={start:v.start,end:Math.max(v.end,m.end),text:""}:c.push({start:m.start,end:m.end,text:""})}if(!g)return{nextSelections:t};for(const m of l){const v=m.end;let S=0,C=v;for(const b of c){if(v<=b.start)break;if(v>=b.end){S-=b.end-b.start;continue}C=b.start+S;break}C===v&&(C+=S),u[m.index]=[C,C]}}else{c=[];let g=0,m=-1;for(let v=0;v<l.length;v++){const S=l[v];if(S.start<m)throw new Error("Overlapping multi-selection edits are not supported");m=S.end;const C=Po(e,n[s==="document"?v:S.index],S.start);c.push({start:S.start,end:S.end,text:C}),u[S.index]=Mu(e,S,g,C),g+=C.length-(S.end-S.start)}}const f=e.applyResolvedEdits(c,!0,t,void 0,r),p=Ki(e,u.map(g=>{if(g===void 0)throw new Error("Missing next selection offsets");return g}));if(e.setLastUndoSelectionsAfter(p),f!==void 0&&i!==void 0){const g=Mn(f,i);g!==void 0&&e.setLastUndoLineAnnotations(i,g)}return{nextSelections:p,change:f}}function Hu(e,t){return e==="never"?!1:e==="brackets"?xu.has(t):e==="quotes"?Lu.has(t):!0}function Pu(e,t,n,i){if(n.length!==1||t.length===0)return;const r=To.get(n);if(r===void 0||!Hu(i,n))return;const s=[];for(const o of t){if(Q(o))return;s.push(n+e.getText(o)+r)}return s}function Ou(e,t,n){const i=[],r=[];for(const a of t){const[l,h]=Qu(e,a);if(!Q(a)){r.push([l,h]);continue}const{line:d,character:c}=a.start,u=l,f=e.getLineText(d),p=f.length,g=u-c,m=Ai(f);let v;if(c>0&&c<p){const S=Et(f,c,!1,m),C=Et(f,c,!0,m);v={start:g+S,end:g+C,text:f.slice(c,C)+f.slice(S,c)},r.push([g+C,g+C])}else if(c===p&&m.length>=2){const S=m[m.length-1],C=m[m.length-2];v={start:g+C,end:u,text:f.slice(S,p)+f.slice(C,S)},r.push([u,u])}else if(c===0&&d>0&&p>0){const S=d-1,C=e.getLineText(S),b=C.length,y=e.offsetAt({line:S,character:b}),L=b>0?Et(C,b,!1,Ai(C)):b,k=Et(f,0,!0,m),E=y-(b-L),x=f.slice(0,k)+e.getTextSlice(y,u)+C.slice(L,b);v={start:E,end:u+k,text:x};const w=E+x.length;r.push([w,w])}else{r.push([l,h]);continue}i.push(v)}if(i.length===0)return{nextSelections:t};i.sort((a,l)=>a.start-l.start);for(let a=1;a<i.length;a++)if(i[a].start<i[a-1].end)throw new Error("Overlapping multi-selection edits are not supported");const s=e.applyResolvedEdits(i,!0,t),o=Ki(e,r);if(e.setLastUndoSelectionsAfter(o),s!==void 0&&n!==void 0){const a=Mn(s,n);a!==void 0&&e.setLastUndoLineAnnotations(n,a)}return{nextSelections:o,change:s}}function Du(e,t,n){const i=t.map(r=>{const s=ef(e,r);return{start:s.start,end:s.end,direction:0}});return _t(e,i,i.map(()=>""),n)}function _u(e,t,n,i){const r=t.map(s=>{if(!Q(s))return{start:s.start,end:s.end,direction:0};const o=ne(s),{line:a,character:l}=o,h=n?.(a,l)??0;if(l>h)return{start:{line:a,character:h},end:{line:a,character:l},direction:0};if(a===0)return{start:o,end:o,direction:0};const d=e.getLineLength(a-1);return{start:{line:a-1,character:d},end:{line:a,character:0},direction:0}});return _t(e,r,r.map(()=>""),i)}function Fu(e,t,n){const i=t.map(r=>{const[s,o]=Ju(e,r);return{start:s,end:o,direction:0}});return _t(e,i,i.map(()=>""),n)}function Nu(e,t,n){if(!Q(t))return[t.start,t.end];const i=ne(t);let{line:r,character:s}=i;const o=e.getLineLength(r),a=e.lineCount;if(s=Math.min(s,o),n)return s<o?[{line:r,character:s},{line:r,character:kn(e,r,s,!0)}]:r<a-1?[{line:r,character:o},{line:r+1,character:0}]:[i,i];if(s>0)return[{line:r,character:kn(e,r,s,!1)},{line:r,character:s}];if(r>0){const l=e.getLineLength(r-1);return[{line:r-1,character:l},{line:r,character:0}]}return[i,i]}function zu(e,t,n,i,r=2){const s=t.map(o=>{let[a,l]=Nu(e,o,n);if(!n&&Q(o)){const h=Ri(e,{start:e.offsetAt(a),end:e.offsetAt(l),text:""},r);a=e.positionAt(h.start),l=e.positionAt(h.end)}return{start:a,end:l,direction:0}});return _t(e,s,s.map(()=>""),i)}function Q(e){return e.start.line===e.end.line&&e.start.character===e.end.character}function ne(e){const{start:t,end:n,direction:i}=e;return i===-1?t:n}function yt(e){return e==="context"||e==="context-expanded"||e==="change-addition"}function Gi(e,t){const n=Q(e),i=Q(t);return n&&i?q(e.start,t.start)===0:n?q(t.start,e.start)<=0&&q(e.start,t.end)<=0:i?q(e.start,t.start)<=0&&q(t.start,e.end)<=0:q(e.start,t.end)<0&&q(t.start,e.end)<0}function q(e,t){return e.line!==t.line?e.line-t.line:e.character-t.character}function ji(e,t,n){const i=t===n?0:t<n?1:-1,r=Math.min(t,n),s=Math.max(t,n);return{start:e.positionAt(r),end:e.positionAt(s),direction:i}}function os(e,t){let n=0;for(const i of t){if(e<i.start)break;if(e>=i.end)n+=i.text.length-(i.end-i.start);else return i.start+n+i.text.length}return e+n}function jn(e,t,n,i){return t.map((r,s)=>{const[o,a]=n[s],l=os(o,i),h=os(a,i);return ji(e,r.direction===-1?h:l,r.direction===-1?l:h)})}function wi(e,t){const n=e.direction===-1?e.end:e.start,i=q(n,t.start),r=q(n,t.end);let s=t.end;i<=0?s=t.end:r>=0?s=t.start:s=i===0?t.end:t.start;const o=q(n,s);return{start:o<=0?n:s,end:o<=0?s:n,direction:o===0?0:o<0?1:-1}}function Io(e,t){const n=q(t.start,e.start)<0,i=q(t.end,e.end)>0;return n&&!i?{start:t.start,end:e.end,direction:-1}:i&&!n?{start:e.start,end:t.end,direction:1}:e.direction===-1?{start:t.start,end:e.end,direction:q(t.start,e.end)===0?0:-1}:{start:e.start,end:t.end,direction:q(e.start,t.end)===0?0:1}}function Bu(e,t){return Mo(e.map(n=>Io(n,t)))}function Mo(e){if(e.length<=1)return e;const t=e.map((r,s)=>({index:s,selection:r})).sort((r,s)=>{const o=q(r.selection.start,s.selection.start);if(o!==0)return o;const a=q(r.selection.end,s.selection.end);return a!==0?a:r.index-s.index}),n=[];let i=t[0];for(const r of t.slice(1)){if(Gi(i.selection,r.selection)){const s=r.index>i.index?r:i,o=q(r.selection.start,i.selection.start)<0?r.selection.start:i.selection.start,a=q(r.selection.end,i.selection.end)>0?r.selection.end:i.selection.end;let l=s.selection.direction;l===0&&q(o,a)!==0&&(l=q(s.selection.start,o)===0?-1:1),i={index:s.index,selection:{direction:l,end:a,start:o}};continue}n.push(i),i=r}return n.push(i),n.sort((r,s)=>r.index-s.index).map(({selection:r})=>r)}function as(e){const t=e.map(i=>{let r=i.end.line;return i.end.character===0&&q(i.start,i.end)!==0&&r--,{startLine:i.start.line,endLine:Math.max(i.start.line,r)}}).sort((i,r)=>{const s=i.startLine-r.startLine;return s!==0?s:i.endLine-r.endLine}),n=[];for(const i of t){const r=n.at(-1);r!==void 0&&i.startLine<=r.endLine+1?r.endLine=Math.max(r.endLine,i.endLine):n.push({...i})}return n}function Vu(e,t,n,i){const r=s=>{const o=s.line+t;if(o>=n){const a=Math.max(0,n-1);return{line:a,character:i(a)}}return o<0?{line:0,character:0}:{line:o,character:s.character}};return{start:r(e.start),end:r(e.end),direction:e.direction}}function Uu(e,t){if(t.length===0)return;const n=t.map(l=>Q(l)?Ti(e,l):l),i=n.map(l=>e.getText(l)),r=i[0];if(r.length===0||i.some(l=>l!==r))return;const s=n.map(l=>[e.offsetAt(l.start),e.offsetAt(l.end)]),o=e.findNextNonOverlappingSubstring(r,s);if(o===void 0)return n.some((l,h)=>{const d=t[h];return q(l.start,d.start)!==0||q(l.end,d.end)!==0||l.direction!==d.direction})?n:void 0;const a=ji(e,o,o+r.length);return[...n,a]}function Wu(e){const t=e.lineCount-1;return{start:{line:0,character:0},end:{line:t,character:e.getLineLength(t)},direction:1}}function ls(e,t,n){let i=0;if(t){const o=e.lineCount-1;i=n===!0&&o>0&&e.getLineLength(o)===0?o-1:o}const r=t?e.getLineLength(i):0,s={line:i,character:r};return{start:s,end:s,direction:1}}function $u(e,t){if(Q(t)){const r=t.start.line;return{start:e.offsetAt({line:r,character:0}),end:r<e.lineCount-1?e.offsetAt({line:r+1,character:0}):e.offsetAt({line:r,character:e.getLineLength(r)})}}const n=e.offsetAt(t.start),i=e.offsetAt(t.end);return n<=i?{start:n,end:i}:{start:i,end:n}}function Ho(e,t){return t.map(n=>$u(e,n)).sort((n,i)=>{const r=n.start-i.start;return r!==0?r:n.end-i.end})}function Gu(e,t){return Ho(e,t).map(({start:n,end:i})=>e.getTextSlice(n,i))}function Ei(e,t){const n=Ho(e,t),i=e.eol;let r="",s=-1;for(const o of n)if(!(o.end<=o.start)){if(o.start<=s){o.end>s&&(r+=e.getTextSlice(s,o.end),s=o.end);continue}r.length>0&&!uu(r)&&(r+=i),r+=e.getTextSlice(o.start,o.end),s=o.end}return r}function ju(e,t){if(Q(t))return Ku(e,t);const[n,i]=q(t.start,t.end)<=0?[t.start,t.end]:[t.end,t.start];return{start:e.offsetAt(n),end:e.offsetAt(i),text:""}}function Ku(e,t){const n=t.start.line,i=e.offsetAt({line:n,character:0}),r=e.offsetAt({line:n,character:e.getLineLength(n)});return n<e.lineCount-1?{start:i,end:e.offsetAt({line:n+1,character:0}),text:""}:n>0?{start:e.offsetAt({line:n-1,character:e.getLineLength(n-1)}),end:r,text:""}:{start:i,end:r,text:""}}function qu(e){const t=[];for(const{edit:n}of e){if(n.start>=n.end)continue;const i=t.at(-1);i!==void 0&&n.start<=i.end?t[t.length-1]={start:i.start,end:Math.max(i.end,n.end),text:""}:t.push(n)}return t}function Yu(e,t){const n=Array.from({length:e.length});let i=0,r=0;for(const s of e){for(;i<t.length&&s.edit.start>t[i].end;){const a=t[i];r-=a.end-a.start,i++}const o=t[i];o!==void 0&&s.edit.start>=o.start&&s.edit.start<=o.end?n[s.index]=o.start+r:n[s.index]=s.edit.start+r}return n}function Xu(e,t){const n=[...t.map((r,s)=>({index:s,edit:ju(e,r)}))].sort((r,s)=>{const o=r.edit.start-s.edit.start;if(o!==0)return o;const a=r.edit.end-s.edit.end;return a!==0?a:r.index-s.index}),i=qu(n);return{text:Ei(e,t),edits:i,nextSelectionOffsets:Yu(n,i)}}function ds(e,t){const n=Math.max(0,t),i=Do(e);let r=null;for(const a of i){r=a;const l=Be(a);if(n<=l+(a.textContent?.length??0)){const h=cs(a,n<l?0:n-l);if(h!==null)return h}}if(r!==null){const a=cs(r,r.textContent?.length??0);return a!==null?a:[r,0]}let s=0,o=null;for(const a of e.childNodes){if(a.nodeType===1&&a.tagName==="BR")return[a,0];if(a.nodeType!==3)continue;o=a;const l=Ge(o.textContent,o.textContent?.length??0);if(n<=s+l)return[o,Ge(o.textContent,n-s)];s+=l}return o!==null?[o,Ge(o.textContent,o.textContent?.length??0)]:[e,0]}function Ti(e,t){const{line:n,character:i}=t.start,r=e.getLineText(n),s=Zu(r,Math.max(0,Math.min(i,r.length)));return s===void 0?t:{start:{line:n,character:s.start},end:{line:n,character:s.end},direction:1}}function Zu(e,t){const n=wo({granularity:"word"});if(n!==void 0){for(const s of n.segment(e)){if(s.isWordLike!==!0)continue;const o=s.index,a=o+s.segment.length;if(t>=o&&t<=a)return{start:o,end:a}}return}const i=/[\p{Alphabetic}\p{Number}_]+/gu;let r;for(;(r=i.exec(e))!==null;){const s=r.index,o=s+r[0].length;if(t>=s&&t<=o)return{start:s,end:o}}}function Ju(e,t){if(!Q(t))return[t.start,t.end];const n=ne(t),{line:i,character:r}=n;if(r===0){if(i===0)return[n,n];const h=e.getLineLength(i-1);return[{line:i-1,character:h},{line:i,character:0}]}const s=e.getLineText(i),o=Ai(s);let a=r,l;for(;a>0;){const h=Et(s,a,!1,o),d=s.slice(h,a),c=/\S/.test(d)?/\p{Alphabetic}|\p{Number}|_/u.test(d)?1:2:0;if(l!==void 0&&c!==l)break;(c!==0||a!==r)&&(l=c),a=h}return[{line:i,character:a},{line:i,character:r}]}function Et(e,t,n,i){if(n){for(const r of i)if(r>t)return r;return e.length}for(let r=i.length-1;r>=0;r--){const s=i[r];if(s<t)return s}return 0}function Ai(e){const t=[0],n=pt();if(n!==void 0){for(const r of n.segment(e))r.index>0&&t.push(r.index);return t}let i=0;for(const r of e)i>0&&t.push(i),i+=r.length;return t}function kn(e,t,n,i){const r=e.getLineLength(t);if(i){if(n>=r)return r;const d=e.offsetAt({line:t,character:0}),c=e.getTextSlice(d+n,d+r),u=pt();if(u!==void 0){for(const f of u.segment(c))return n+f.segment.length;return r}for(const f of c)return n+f.length;return r}if(n<=0)return 0;const s=e.offsetAt({line:t,character:0}),o=e.getTextSlice(s,s+n);let a=0;const l=pt();if(l!==void 0){for(const d of l.segment(o))a=d.index;return a}let h=0;for(const d of o)a=h,h+=d.length;return a}function Qu(e,t){const n=t.direction===-1;return[e.offsetAt(n?t.end:t.start),e.offsetAt(ne(t))]}function ef(e,t){if(!Q(t))return{start:t.start,end:t.end};const{line:n,character:i}=t.start,r=e.getLineText(n).length;return i<r?{start:{line:n,character:i},end:{line:n,character:r}}:n<e.lineCount-1?{start:{line:n,character:i},end:{line:n+1,character:0}}:{start:{line:n,character:i},end:{line:n,character:i}}}function Po(e,t,n){if(t!==`
1843
+ `&&t!=="\r"&&t!==`\r
1844
+ `)return t;const i=e.positionAt(n).line,r=e.getLineText(i),s=Oo(r);return s===0?t:t+r.slice(0,s)}function Oo(e){let t=0;for(;t<e.length;t++){const n=e.charCodeAt(t);if(n!==32&&n!==9)break}return t}function Ki(e,t){const n=[];for(const[r,s]of t)n.push(Math.min(r,s),Math.max(r,s));const i=e.positionsAt(n);return t.map(([r,s],o)=>{const a=r===s?0:r<s?1:-1;return{start:i[o*2],end:i[o*2+1],direction:a}})}function Ri(e,t,n){if(t.text!==""||t.start!==t.end-1)return t;const i=e.positionAt(t.end);if(i.character===0)return t;const r=e.getLineText(i.line),s=r.slice(0,i.character);if(/[^ \t]/.test(s)||r[i.character-1]===" ")return t;const o=Math.max(0,i.character-n),a=r.slice(o,i.character);return a.length===n&&/^ +$/.test(a)?{...t,start:t.end-a.length}:t}function hs(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n!==null&&wn(n)===void 0;)n=n.parentElement;if(n===null)return null;const i=wn(n);if(i===void 0)return null;if(e.nodeType===3)return e.parentElement===null?null:Ii(e.parentElement)!==null?{line:i,character:ut(e,t)}:{line:i,character:Kn(n,e)+Ge(e.textContent,t)};if(e.nodeType===1){const r=e;if(r.tagName==="DIV"){let s=0;for(let o=0;o<t;o++)s=ut(r.childNodes[o]);return{line:i,character:s}}if(r.tagName==="BR")return{line:i,character:0};if(r.tagName==="SPAN"){if(t<r.childNodes.length){const s=r.childNodes[t];if(s?.nodeType===1){const o=Be(s);if(o!==void 0)return{line:i,character:o};const a=Ii(s),l=a===null?void 0:Be(a);if(l!==void 0)return{line:i,character:l}}}return{line:i,character:t>0?ut(r.childNodes[t-1]):Kn(n,r)}}return{line:i,character:Kn(n,r)}}return null}function Do(e){const t=[];for(const n of e.childNodes){if(n.nodeType!==1)continue;const i=n;if(i.tagName==="SPAN"){if(Be(i)!==void 0){t.push(i);continue}for(const r of i.childNodes)r.nodeType===1&&Be(r)!==void 0&&t.push(r)}}return t}function cs(e,t){let n=Math.max(0,t);const i=[{container:e,index:0}];for(;i.length>0;){const r=i[i.length-1];if(r.index>=r.container.childNodes.length){i.pop();continue}const s=r.container.childNodes[r.index];if(r.index++,s.nodeType===3){const o=Ge(s.textContent,s.textContent?.length??0);if(n<=o)return[s,n];n-=o}else s.nodeType===1&&i.push({container:s,index:0})}return null}function _o(e,t){let n=0;const i=[{container:e,index:0}];for(;i.length>0;){const r=i[i.length-1];if(r.index>=r.container.childNodes.length){i.pop();continue}const s=r.container.childNodes[r.index];if(s===t)return n;r.index++,s.nodeType===3?n+=Ge(s.textContent,s.textContent?.length??0):s.nodeType===1&&i.push({container:s,index:0})}return n}function tf(e,t){let n=t;for(;n!==null;){if(n===e)return!0;n=n.parentElement}return!1}function Kn(e,t){if(t.parentElement===e){let r=0;const s=Array.prototype.indexOf.call(e.childNodes,t);for(let o=0;o<s;o++)r=ut(e.childNodes[o]);return r}for(const r of Do(e))if(tf(r,t))return Be(r)+(t.nodeType===3?_o(r,t):0);let n=0,i=t.nodeType===1?t:t.parentElement;for(;i!==null&&i.parentElement!==null&&wn(i.parentElement)===void 0;){const r=i.parentElement,s=Array.prototype.indexOf.call(r.childNodes,i);for(let o=0;o<s;o++)n=ut(r.childNodes[o]);i=r}return n}function Ii(e){let t=e;for(;t!==null;){if(wn(t)!==void 0)return null;if(Be(t)!==void 0)return t;t=t.parentElement}return null}function ut(e,t){if(e===void 0)return 0;if(e.nodeType===3){const s=e.parentElement;if(s===null)return 0;const o=Ii(s);if(o===null)return 0;const a=Be(o);if(a===void 0)return 0;const l=t===void 0?Ge(e.textContent,e.textContent?.length??0):Ge(e.textContent,t);return a+_o(o,e)+l}if(e.nodeType!==1)return 0;const n=e;if(n.tagName!=="SPAN"&&n.tagName!=="BR")return 0;const i=Be(n);if(i!==void 0)return i+(n.textContent?.length??0);let r=0;for(const s of n.childNodes)r=Math.max(r,ut(s));return r}function wn(e){const{line:t,lineType:n}=e.dataset;if(t!==void 0&&n!=="change-deletion"){const i=parseInt(t,10);if(!Number.isNaN(i))return i-1}}function Be(e){const{char:t}=e.dataset;if(t!==void 0){const n=parseInt(t,10);if(!Number.isNaN(n))return n}}function Ge(e,t){const n=e??"",i=n.search(/[\r\n]/);return Math.min(t,i===-1?n.length:i)}const nf=300,rf=100,qn="marker-popover";var sf=class{#t;#e=[];#s=0;#n;#a;#d;#l;#g;#x;#f;#C=!1;constructor(e){this.#t=e}get markers(){return this.#e}isPopoverVisible(){return this.#f!==void 0}updatePopoverPosition(){const e=this.#f,t=this.#n;if(e===void 0||t===void 0)return;const n=this.#e[e];if(n===void 0){this.removePopover();return}this.#b(t,n.start.line,n.start.character)}setMarkers(e,t){this.#s=t.lineCount,this.#e=e.map(n=>({...n,start:t.normalizePosition(n.start),end:t.normalizePosition(n.end)})),this.removePopover()}listenHover(e){this.#d?.forEach(t=>t()),this.#d=void 0,this.#e.length!==0&&(this.#d=[G(e,"mouseover",t=>{if(this.#t.isMouseDown())return;const n=t.composedPath()[0];if(n===void 0)return;const i=this.#m(n);i!==void 0?this.#B(i):(this.#k(),this.#o())}),G(e,"mouseleave",()=>{this.#k(),this.#o()})])}removePopover(){this.#k(),this.#E(),this.#v()}cleanup(){this.#d?.forEach(e=>e()),this.#d=void 0,this.removePopover(),this.#e=[]}#m(e){const t=e.closest("[data-line]");if(t==null)return;const n=ue(t);if(n===void 0)return;let i;if(e.tagName==="SPAN"){const s=e.dataset.char;if(s===void 0||(i=parseInt(s,10),Number.isNaN(i)))return}else if(e.tagName==="BR")i=0;else return;const r={line:n-1,character:i};for(let s=this.#e.length-1;s>=0;s--)if(Gi({start:r,end:r},this.#e[s]))return s}#k(){this.#l!==void 0&&(clearTimeout(this.#l),this.#l=void 0),this.#x=void 0}#E(){this.#g!==void 0&&(clearTimeout(this.#g),this.#g=void 0)}#B(e){if(e===this.#f||e===this.#x){this.#E();return}if(this.#k(),this.#E(),this.#n!==void 0){this.#w(e);return}this.#x=e,this.#l=setTimeout(()=>{this.#l=void 0,this.#x=void 0,this.#w(e)},nf)}#o(){this.#C||(this.#E(),this.#g=setTimeout(()=>{this.#g=void 0,this.#C||this.removePopover()},rf))}#P(e,t,n,i,r=this.#t.popoverManager.getPlacementBounds()){Eo(e,{gutterWidth:this.#t.getGutterWidth(),placeAbove:i,viewport:r,x:t,y:n})}#b(e,t,n){const{getCharX:i,getLineY:r,getLineHeight:s,popoverManager:o}=this.#t,[a,l]=i(t,n),h=s(),d=r(t)+l*h,c=e.offsetHeight,u={top:d+h,bottom:d+h+c},f={top:d-c,bottom:d},p=t>=this.#s-3,g=o.getPlacementBounds(),m=o.choosePlacement({preferred:u,fallback:f,viewport:g,popoverHeight:c,atDocumentEdge:p,placementKey:qn})==="fallback";this.#P(e,a,m?d:d+h,m,g)}#v(){this.#a?.forEach(e=>e()),this.#a=void 0,this.#n?.remove(),this.#n=void 0,this.#f=void 0,this.#C=!1,this.#t.popoverManager.resetPlacement(qn)}#w(e){if(e===this.#f)return;const t=this.#t.getOverlayElement();if(e>=this.#e.length||t==null)return;const{start:n,message:i,severity:r}=this.#e[e],{line:s,character:o}=n,a=this.#n;if(this.#t.popoverManager.resetPlacement(qn),a!==void 0){af(a,r);const l=a.firstElementChild;l?.dataset.markerMessage!==void 0&&(typeof i=="string"?l.textContent=i:i instanceof HTMLElement?l.replaceChildren(i):l.innerHTML=i.html),this.#b(a,s,o),this.#f=e;return}this.#n=W("div",{dataset:{editorWidget:"",markerPopover:"",[En(r)]:""},children:[W("div",{dataset:"markerMessage",...typeof i=="string"?{textContent:i}:i instanceof HTMLElement?{children:[i]}:{innerHTML:i.html}})]},t),this.#b(this.#n,s,o),this.#f=e,this.#a=[G(this.#n,"mouseenter",()=>{this.#C=!0,this.#E()}),G(this.#n,"mouseleave",()=>{this.#C=!1,this.#o()})]}};const of=["error","warning","info","hint"];function af(e,t){for(const n of of)delete e.dataset[En(n)];e.dataset[En(t)]=""}function En(e){switch(e){case"error":return"markerError";case"warning":return"markerWarning";case"info":return"markerInfo";case"hint":return"markerHint"}}const qi=new Map([["(",")"],["[","]"],["{","}"]]),Fo=new Map([...qi].map(([e,t])=>[t,e])),No=1e3,zo=5e4;function lf(e,t,n){const i=df(e,t,e.normalizePosition(n));if(i===void 0)return;const r=qi.get(i.char),s=Fo.get(i.char);if(r!==void 0)return fs(i,cf(e,t,i,r));if(s!==void 0)return fs(uf(e,t,i,s),i)}function df(e,t,n){const i=hf(n);if(i!==void 0){const r=us(e,t,i);if(r!==void 0)return r}return us(e,t,n)}function hf(e){if(e.character>0)return{line:e.line,character:e.character-1}}function us(e,t,n){const i=e.getLineText(n.line)[n.character];if(!(i===void 0||!qi.has(i)&&!Fo.has(i)||ff(t,n)))return{...n,char:i}}function cf(e,t,n,i){let r=0,s=0,o=0;for(let a=n.line;a<e.lineCount;a++){if(s>=No)return;s++;const l=e.getLineText(a),h=t.getStringCommentRegexpRangesInLine(a),d={index:0},c=a===n.line?n.character:0;for(let u=c;u<l.length;u++){if(o>=zo)return;if(o++,gf(h,u,d))continue;const f=l[u];if(f===n.char)r++;else if(f===i&&(r--,r===0))return{line:a,character:u,char:f}}}}function uf(e,t,n,i){let r=0,s=0,o=0;for(let a=n.line;a>=0;a--){if(s>=No)return;s++;const l=e.getLineText(a),h=t.getStringCommentRegexpRangesInLine(a),d={index:h===null?-1:h.length-1},c=a===n.line?n.character:l.length-1;for(let u=c;u>=0;u--){if(o>=zo)return;if(o++,mf(h,u,d))continue;const f=l[u];if(f===n.char)r++;else if(f===i&&(r--,r===0))return{line:a,character:u,char:f}}}}function ff(e,t){return pf(e.getStringCommentRegexpRangesInLine(t.line),t.character)}function pf(e,t){if(e===null)return!1;for(const[n,i]of e){if(t<n)return!1;if(t<i)return!0}return!1}function gf(e,t,n){if(e===null)return!1;for(;n.index<e.length&&t>=e[n.index][1];)n.index++;const i=e[n.index];return i!==void 0&&t>=i[0]}function mf(e,t,n){if(e===null)return!1;for(;n.index>=0&&t<e[n.index][0];)n.index--;const i=e[n.index];return i!==void 0&&t<i[1]}function fs(e,t){if(!(e===void 0||t===void 0))return[ps(e),ps(t)]}function ps(e){return{start:{line:e.line,character:e.character},end:{line:e.line,character:e.character+1}}}const vf=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
1845
+ <symbol id="diffs-editor-icon-close" viewBox="0 0 16 16">
1846
+ <path fill="currentColor" d="M3.21967 3.21967C3.51256 2.92678 3.98744 2.92678 4.28033 3.21967L8 6.93934L11.7197 3.21967C12.0126 2.92678 12.4874 2.92678 12.7803 3.21967C13.0732 3.51256 13.0732 3.98744 12.7803 4.28033L9.06066 8L12.7803 11.7197C13.0732 12.0126 13.0732 12.4874 12.7803 12.7803C12.4874 13.0732 12.0126 13.0732 11.7197 12.7803L8 9.06066L4.28033 12.7803C3.98744 13.0732 3.51256 13.0732 3.21967 12.7803C2.92678 12.4874 2.92678 12.0126 3.21967 11.7197L6.93934 8L3.21967 4.28033C2.92678 3.98744 2.92678 3.51256 3.21967 3.21967Z"></path>
1847
+ </symbol>
1848
+ <symbol id="diffs-editor-icon-arrow-up" viewBox="0 0 16 16">
1849
+ <path fill="currentColor" transform="rotate(-90 8 8)" d="M8.46967 2.21967C8.17678 2.51256 8.17678 2.98744 8.46967 3.28033L12.4393 7.25H1.75C1.33579 7.25 1 7.58579 1 8C1 8.41421 1.33579 8.75 1.75 8.75H12.4393L8.46967 12.7197C8.17678 13.0126 8.17678 13.4874 8.46967 13.7803C8.76256 14.0732 9.23744 14.0732 9.53033 13.7803L14.7803 8.53033C15.0732 8.23744 15.0732 7.76256 14.7803 7.46967L9.53033 2.21967C9.23744 1.92678 8.76256 1.92678 8.46967 2.21967Z"></path>
1850
+ </symbol>
1851
+ <symbol id="diffs-editor-icon-arrow-down" viewBox="0 0 16 16">
1852
+ <path fill="currentColor" transform="rotate(90 8 8)" d="M8.46967 2.21967C8.17678 2.51256 8.17678 2.98744 8.46967 3.28033L12.4393 7.25H1.75C1.33579 7.25 1 7.58579 1 8C1 8.41421 1.33579 8.75 1.75 8.75H12.4393L8.46967 12.7197C8.17678 13.0126 8.17678 13.4874 8.46967 13.7803C8.76256 14.0732 9.23744 14.0732 9.53033 13.7803L14.7803 8.53033C15.0732 8.23744 15.0732 7.76256 14.7803 7.46967L9.53033 2.21967C9.23744 1.92678 8.76256 1.92678 8.46967 2.21967Z"></path>
1853
+ </symbol>
1854
+ <symbol id="diffs-editor-icon-case" viewBox="0 0 16 16">
1855
+ <path fill="currentColor" d="M12.2969 12.9969C10.7109 12.9969 9.61719 12.0125 9.61719 10.5047C9.61719 9.06719 10.6172 8.16094 12.5 8.15312H14.6641V7.31719C14.6641 6.23906 14.0391 5.64531 12.9297 5.64531C11.875 5.64531 11.2734 6.18437 11.1953 7.00469H9.92969C10.0156 5.56719 10.9922 4.52031 12.9766 4.52031C14.7266 4.52031 16 5.47344 16 7.2V12.8641H14.7109V11.8406H14.6719C14.2578 12.5047 13.5078 12.9969 12.2969 12.9969ZM12.6562 11.8797C13.8047 11.8797 14.6641 11.1609 14.6641 10.1375V9.18437H12.6016C11.4766 9.18437 10.9922 9.71562 10.9922 10.4578C10.9922 11.4266 11.7969 11.8797 12.6562 11.8797Z"></path>
1856
+ <path fill="currentColor" d="M1.42188 12.8641H0L3.79688 2H5.1875L8.98438 12.8641H7.54688L6.46875 9.66094H2.5L1.42188 12.8641ZM4.50781 3.60938H4.46875L2.86719 8.55937H6.10156L4.50781 3.60938Z"></path>
1857
+ </symbol>
1858
+ <symbol id="diffs-editor-icon-whole-word" viewBox="0 0 16 16">
1859
+ <path fill="currentColor" d="M11.4089 9.99449C11.1417 9.99449 10.8961 9.95595 10.6722 9.87887C10.4519 9.80179 10.2605 9.69167 10.098 9.54852C9.93551 9.40537 9.81453 9.23469 9.73508 9.03648H9.67007V9.91191H8.5V2H9.70258V5.01721H9.76758C9.81092 4.86671 9.88314 4.7309 9.98426 4.60977C10.089 4.48497 10.2136 4.37853 10.358 4.29043C10.5025 4.19867 10.6668 4.13076 10.851 4.08672C11.0352 4.039 11.2302 4.01514 11.436 4.01514C11.8802 4.01514 12.2648 4.11792 12.5898 4.32347C12.9149 4.52535 13.164 4.81532 13.3374 5.19339C13.5107 5.57146 13.5974 6.02478 13.5974 6.55334V7.45079C13.5974 7.97568 13.5089 8.429 13.332 8.81074C13.1586 9.1888 12.9076 9.48061 12.579 9.68617C12.2504 9.89172 11.8604 9.99449 11.4089 9.99449ZM11.0785 8.99243C11.353 8.99243 11.5859 8.92636 11.7773 8.79422C11.9723 8.66208 12.1204 8.46937 12.2215 8.2161C12.3226 7.95916 12.3732 7.65267 12.3732 7.29663V6.73503C12.3732 6.37164 12.3208 6.06332 12.2161 5.81005C12.115 5.55311 11.9669 5.35673 11.7719 5.22092C11.5769 5.08511 11.3385 5.01721 11.0568 5.01721C10.7824 5.01721 10.5422 5.08328 10.3364 5.21542C10.1341 5.34389 9.97704 5.52925 9.86509 5.77151C9.75675 6.01009 9.70258 6.2964 9.70258 6.63042V7.47281C9.70258 7.77013 9.76036 8.03441 9.87592 8.26566C9.99509 8.49323 10.1576 8.67125 10.3635 8.79972C10.5729 8.92819 10.8113 8.99243 11.0785 8.99243Z"></path>
1860
+ <path fill="currentColor" d="M4.70482 9.99449C4.15229 9.99449 3.70087 9.83482 3.35057 9.51548C3.00388 9.19247 2.83054 8.75935 2.83054 8.2161C2.83054 7.70223 3.00207 7.28745 3.34515 6.97178C3.69184 6.65244 4.19562 6.49277 4.8565 6.49277H6.30284V5.94769C6.30284 5.61367 6.20533 5.36774 6.01032 5.20991C5.81531 5.04841 5.55349 4.96765 5.22485 4.96765C5.00817 4.96765 4.82941 4.99702 4.68857 5.05575C4.54773 5.11081 4.43758 5.18789 4.35813 5.28699C4.27868 5.38243 4.22271 5.49621 4.19021 5.62835H3.04722C3.06527 5.3861 3.12305 5.16586 3.22056 4.96765C3.32168 4.76577 3.46252 4.59326 3.64309 4.4501C3.82727 4.30328 4.05297 4.19133 4.32021 4.11425C4.59106 4.03716 4.90525 3.99862 5.26277 3.99862C5.67086 3.99862 6.04463 4.06286 6.38409 4.19133C6.72356 4.31613 6.99441 4.52168 7.19665 4.80798C7.39888 5.09429 7.5 5.4797 7.5 5.96421V9.9064H6.35701V9.1521H6.30284C6.21978 9.29892 6.10783 9.43657 5.96698 9.56504C5.82614 9.69351 5.65099 9.79812 5.44153 9.87887C5.23569 9.95595 4.99012 9.99449 4.70482 9.99449ZM5.07318 9.04749C5.3043 9.04749 5.51196 8.99977 5.69613 8.90434C5.88031 8.80523 6.02657 8.67309 6.13491 8.50791C6.24686 8.34274 6.30284 8.1537 6.30284 7.94081V7.31314H5.04609C4.69579 7.31314 4.43939 7.39206 4.27688 7.5499C4.11798 7.70773 4.03853 7.90961 4.03853 8.15554C4.03853 8.4602 4.14326 8.68594 4.35272 8.83276C4.56578 8.97591 4.80594 9.04749 5.07318 9.04749Z"></path>
1861
+ <path fill="currentColor" d="M2.5 12.5L13.5 12.5C14.3284 12.5 15 11.8284 15 11V9.5C15 9.22386 15.2239 9 15.5 9C15.7761 9 16 9.22386 16 9.5V11C16 12.3807 14.8807 13.5 13.5 13.5L2.5 13.5C1.11929 13.5 -7.56324e-07 12.3807 0 11L6.55675e-08 9.5C3.58362e-07 9.22386 0.223858 9 0.5 9C0.776142 9 1 9.22386 1 9.5L1 11C0.999999 11.8284 1.67157 12.5 2.5 12.5Z"></path>
1862
+ </symbol>
1863
+ <symbol id="diffs-editor-icon-regex" viewBox="0 0 16 16">
1864
+ <path fill="currentColor" d="M8.60788 6.59074C8.78227 6.46701 9.02141 6.60508 9.00146 6.81797L8.77564 9.22666C8.76189 9.37331 8.87726 9.5 9.02455 9.5H9.97548C10.1228 9.5 10.2381 9.37331 10.2244 9.22667L9.99858 6.81801C9.97862 6.60513 10.2178 6.46706 10.3922 6.59079L12.3652 7.99066C12.4853 8.07589 12.6527 8.03932 12.7264 7.91177L13.2018 7.08823C13.2755 6.96068 13.2234 6.79742 13.0896 6.73601L10.8907 5.72723C10.6963 5.63807 10.6963 5.36193 10.8907 5.27277L13.0896 4.264C13.2234 4.20258 13.2755 4.03932 13.2018 3.91177L12.7263 3.08824C12.6527 2.96068 12.4853 2.92411 12.3652 3.00934L10.3922 4.40921C10.2178 4.53294 9.97862 4.39486 9.99858 4.18198L10.2244 1.77334C10.2381 1.62669 10.1228 1.5 9.97548 1.5H9.02455C8.87726 1.5 8.76189 1.62669 8.77564 1.77334L9.00146 4.18203C9.02141 4.39491 8.78227 4.53298 8.60788 4.40926L6.63479 3.00934C6.51466 2.92411 6.34726 2.96068 6.27362 3.08823L5.79815 3.91177C5.72451 4.03932 5.77654 4.20258 5.91041 4.26399L8.10929 5.27277C8.30363 5.36193 8.30363 5.63807 8.10929 5.72723L5.91041 6.73601C5.77653 6.79742 5.7245 6.96068 5.79814 7.08824L6.27361 7.91177C6.34725 8.03932 6.51466 8.07589 6.63478 7.99066L8.60788 6.59074Z"></path>
1865
+ <path fill="currentColor" d="M4 11C3.44772 11 3 11.4477 3 12V13C3 13.5523 3.44772 14 4 14H5C5.55228 14 6 13.5523 6 13V12C6 11.4477 5.55228 11 5 11H4Z"></path>
1866
+ </symbol>
1867
+ <symbol id="diffs-editor-icon-replace" viewBox="0 0 16 16">
1868
+ <path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M5.28033 5.71967C5.57322 6.01256 5.57322 6.48744 5.28033 6.78033L3.56066 8.5H11.75C12.7165 8.5 13.5 7.7165 13.5 6.75V2.75C13.5 2.33579 13.8358 2 14.25 2C14.6642 2 15 2.33579 15 2.75V6.75C15 8.54493 13.5449 10 11.75 10H3.56066L5.28033 11.7197C5.57322 12.0126 5.57322 12.4874 5.28033 12.7803C4.98744 13.0732 4.51256 13.0732 4.21967 12.7803L1.21967 9.78033C0.926777 9.48744 0.926777 9.01256 1.21967 8.71967L4.21967 5.71967C4.51256 5.42678 4.98744 5.42678 5.28033 5.71967Z"></path>
1869
+ </symbol>
1870
+ <symbol id="diffs-editor-icon-replace-all" viewBox="0 0 16 16">
1871
+ <path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M10.7197 0.21967C11.0126 -0.0732233 11.4874 -0.0732233 11.7803 0.21967L14.7803 3.21967C15.0732 3.51256 15.0732 3.98744 14.7803 4.28033L11.7803 7.28033C11.4874 7.57322 11.0126 7.57322 10.7197 7.28033C10.4268 6.98744 10.4268 6.51256 10.7197 6.21967L12.4393 4.5H4.25C3.2835 4.5 2.5 5.2835 2.5 6.25V6.875C2.5 7.28921 2.16421 7.625 1.75 7.625C1.33579 7.625 1 7.28921 1 6.875V6.25C1 4.45507 2.45508 3 4.25 3H12.4393L10.7197 1.28033C10.4268 0.987437 10.4268 0.512563 10.7197 0.21967ZM5.28033 8.71967C5.57322 9.01256 5.57322 9.48744 5.28033 9.78033L3.56066 11.5H11.75C12.7165 11.5 13.5 10.7165 13.5 9.75V9.125C13.5 8.71079 13.8358 8.375 14.25 8.375C14.6642 8.375 15 8.71079 15 9.125V9.75C15 11.5449 13.5449 13 11.75 13H3.56066L5.28033 14.7197C5.57322 15.0126 5.57322 15.4874 5.28033 15.7803C4.98744 16.0732 4.51256 16.0732 4.21967 15.7803L1.21967 12.7803C0.926777 12.4874 0.926777 12.0126 1.21967 11.7197L4.21967 8.71967C4.51256 8.42678 4.98744 8.42678 5.28033 8.71967Z"></path>
1872
+ </symbol>
1873
+ </svg>`,Sf=()=>{const e=document.createElement("div");e.innerHTML=vf;const t=e.firstElementChild;if(t===null||!(t instanceof SVGSVGElement))throw new Error("Failed to create sprite element");return t},bf=(e,t=16)=>`<svg width="${t}" height="${t}" aria-hidden="true" focusable="false">
1874
+ <use href="#diffs-editor-icon-${e}"></use>
1875
+ </svg>`;var Cf=class{#t;#e;#s;#n;#a;#d;constructor(e){const{textDocument:t,containerElement:n,defaultQuery:i,mode:r="find",initialMatch:s,scrollToMatch:o,applyReplace:a,onUpdate:l,onClose:h}=e,d={text:i,replaceText:"",caseSensitive:!1,wholeWord:!1,regex:!1},c={all:[],current:void 0},u=W("div",{dataset:{matches:"",noMatches:""},textContent:"No results"}),f=A=>{c.all=d.text!==""?t.search(d):[];const P=c.all.length===0;if($.disabled=P,H.disabled=P,P){u.textContent="No results",u.dataset.noMatches="",c.current=void 0,l([]);return}if(delete u.dataset.noMatches,A?.syncSelection===!1){p(l(c.all,{syncSelection:!1}));return}p(l(c.all))};this.#s=f;const p=A=>{if(A===void 0)u.textContent=`${c.all.length} results`;else{const[P,N]=A;u.textContent=`${c.all.findIndex(z=>z[0]===P&&z[1]===N)+1} of ${c.all.length}`}c.current=A},g=(A,P)=>{d[A]=P,f()},m=(A=!1,P=!1)=>{const N=c.all;let z=N[0];if(N.length>0)if(A){const ee=c.current?.[0]??0;z=N.at(-1);for(const ie of N)if(ie[1]<=ee)z=ie;else break}else{const ee=c.current?.[1]??0;for(const ie of N)if(ie[0]>=ee){z=ie;break}}z!==void 0&&(p(z),o(z,P)),c.current=z};this.#a=A=>m(A,!0);const v=(A,P)=>({start:A,end:P,text:Xc(N=>t.positionAt(N),N=>t.offsetAt(N),N=>t.getLineText(N),d,A,P)}),S=()=>{if(d.text===""||c.all.length===0)return;let A=c.current;if(A===void 0&&(m(!1,!0),A=c.current,A===void 0))return;const[P,N]=A,z=v(P,N);a([z]),o([P+z.text.length,P+z.text.length],!0),c.current=void 0,f()},C=()=>{d.text===""||c.all.length===0||(a(c.all.map(([A,P])=>v(A,P))),c.current=void 0,f())},b=()=>{this.cleanup(),h()};this.#d=b;const y=A=>W("button",{type:"button",title:A.label,ariaLabel:A.label,dataset:{searchIcon:"",...A.dataset},innerHTML:bf(A.icon,A.size??16),onclick:A.onClick}),L=(A,P,N)=>{const z=y({icon:A,label:P,size:14,onClick:()=>{const ee=!d[N];z.ariaPressed=String(ee),g(N,ee)}});return z.ariaPressed=String(d[N]),z},k=L("case","Match Case","caseSensitive"),E=L("whole-word","Whole Word","wholeWord"),x=L("regex","Regexp","regex"),w=W("input",{type:"text",placeholder:"Replace",dataset:"replace",value:"",oninput:A=>{d.replaceText=A.target.value},onkeydown:A=>{if(A.isComposing)return;const P=ki(A);A.key==="Escape"?(A.preventDefault(),b()):A.key==="Enter"?(A.preventDefault(),S()):P!==void 0&&(A.preventDefault(),m(P==="previous",!0))}});this.#e=W("input",{type:"text",placeholder:"Search",dataset:"search",value:i,oninput:A=>{d.text=A.target.value,c.current=void 0,f()},onkeydown:A=>{const P=ki(A);A.key==="Escape"?(A.preventDefault(),b()):A.key==="Enter"?(A.preventDefault(),m(A.shiftKey,!0)):P!==void 0?(A.preventDefault(),m(P==="previous",!0)):Ot(A)&&(A.key==="f"||A.code==="KeyF")&&(A.preventDefault(),V(A.altKey?"replace":"find"))}});const O=W("div",{dataset:"searchToggles",children:[k,E,x]}),T=W("div",{dataset:{inputBox:"",find:""},children:[this.#e,O]}),R=W("div",{dataset:{inputBox:"",replace:"",replaceCell:""},children:[w]}),_=W("div",{dataset:{replaceActions:"",replaceCell:""},children:[y({icon:"replace",label:"Replace",onClick:S}),y({icon:"replace-all",label:"Replace All",onClick:C})]}),$=y({icon:"arrow-up",label:"Previous",onClick:()=>{m(!0)}}),H=y({icon:"arrow-down",label:"Next",onClick:()=>{m()}});$.disabled=!0,H.disabled=!0;const D=W("div",{dataset:"searchNav",children:[$,H]}),B=y({icon:"close",label:"Close",onClick:b,dataset:{searchClose:""}}),Z=W("div",{dataset:{searchGrid:"",mode:r},children:[T,R,_,u,D,B]}),V=A=>{Z.dataset.mode=A,this.#e.focus(),this.#e.select()};this.#n=V,this.#t=W("div",{dataset:"searchPanel",children:[W("div",{dataset:"editorWidget",children:[Z]})]}),c.current=s,n.before(this.#t),requestAnimationFrame(()=>{s!==void 0?f():l([]),this.#e.select()})}focus(){this.#e.focus()}navigate(e){this.#a?.(e)}updateMatches(e){this.#s?.(e)}setMode(e){this.#n?.(e)}close(){this.#d?.()}cleanup(){this.#t.remove()}},yf=class{#t;#e;#s;constructor(e,t,n){this.#t=W("div",{dataset:{editorWidget:"",selectionActionPopover:""},contentEditable:"false",children:[e]},t),this.#e=this.#t.offsetHeight,this.#s=new ResizeObserver(()=>{const i=this.#t.offsetHeight;i!==this.#e&&(this.#e=i,n())}),this.#s.observe(this.#t)}reposition(e,t,n,i,r,s){this.#t.style.visibility=r?"":"hidden",Eo(this.#t,{gutterWidth:n,placeAbove:i,viewport:s,x:e,y:t})}get height(){return this.#e}cleanup(){this.#s.disconnect(),this.#t.remove()}};function gt(e){return{selections:e.selections?.map(t=>({start:{...t.start},end:{...t.end},direction:t.direction})),view:e.view===void 0?void 0:{...e.view}}}function Lf(e){return typeof e=="object"?e:e==="indexedDB"?new Ef:new xf}var xf=class{#t=new Map;get(e){const t=this.#t.get(e);return t===void 0?void 0:gt(t)}set(e,t){this.#t.set(e,gt(t))}};const kf="pierre-diffs-editor-state",wf=1,dt="states";var Ef=class{#t=Tf();async get(e){const t=await this.#t;if(t===void 0)return;const n=await Mi(t.transaction(dt,"readonly").objectStore(dt).get(e));return n===void 0?void 0:gt(n)}async set(e,t){const n=await this.#t;n!==void 0&&await Mi(n.transaction(dt,"readwrite").objectStore(dt).put(gt(t),e))}};function Tf(){try{const e=globalThis.indexedDB;if(e===void 0)return Promise.resolve(void 0);const t=e.open(kf,wf);return t.onupgradeneeded=()=>{const n=t.result;n.objectStoreNames.contains(dt)||n.createObjectStore(dt)},Mi(t)}catch{return Promise.resolve(void 0)}}function Mi(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}const Af=4096,Rf=/\p{Mark}/u;var If=class{#t;#e;#s;#n=new Map;ch=-1;tabSize=2;lineHeight=20;paddingTop=0;init(e){if(this.#t===e&&this.#e!==void 0&&this.ch!==-1)return;if(this.#t=e,this.#e??=document.createElement("canvas").getContext("2d")??void 0,this.#e===void 0)throw new Error("Could not get canvas context");const t=e.parentElement;if(t!==null){const{paddingTop:l}=getComputedStyle(t);l.endsWith("px")&&(this.paddingTop=parseFloat(l.slice(0,-2)))}const{fontSize:n,fontFamily:i,tabSize:r,lineHeight:s}=getComputedStyle(e);s.endsWith("px")?this.lineHeight=parseFloat(s.slice(0,-2)):n.endsWith("px")&&(this.lineHeight=lt(parseFloat(n.slice(0,-2))*parseFloat(s)));const o=n+" "+i;(this.#s!==o||this.ch===-1)&&(this.#s=o,this.#e.font=o,this.ch=this.canvasMeasureTextWidth("0"),this.clearTextWidthCache());const a=parseInt(r,10);Number.isNaN(a)||(this.tabSize=a)}remeasureCharacterWidth(){if(this.#e===void 0||this.#s===void 0)return!1;this.#e.font=this.#s;const e=this.canvasMeasureTextWidth("0"),t=e!==this.ch;t&&(this.ch=e);const n=this.#d();return t||n}measureTextWidth(e){if(!e.includes(" "))return this.#a(e);if(this.#e===void 0)throw new Error("Metrics not initialized");const t=hn(e,this.tabSize);if(t!==-1)return t*this.ch;let n=0,i=0;const r=this.tabSize*this.ch;for(let s=0;s<e.length;s++)if(e.charCodeAt(s)===9){if(s>i&&(n+=this.#a(e.slice(i,s))),r>0){const o=n%r;n+=o===0?r:r-o}i=s+1}return i<e.length&&(n+=this.#a(e.slice(i))),lt(n)}#a(e){return Yi(e)?this.domMeasureTextWidth(e):this.canvasMeasureTextWidth(e)}canvasMeasureTextWidth(e){if(this.#e===void 0)throw new Error("Metrics not initialized");return lt(this.#e.measureText(e).width)}domMeasureTextWidth(e){if(this.#t===void 0)throw new Error("Metrics not initialized");const t=e+"|"+this.#s,n=this.#n.get(t);if(n!==void 0)return n;const i=W("span",{style:{position:"absolute",top:"0",left:"0",visibility:"hidden",pointerEvents:"none",whiteSpace:"pre",font:"inherit"},textContent:e},this.#t);let r;try{r=lt(i.getBoundingClientRect().width)}finally{i.remove()}if(this.#n.size>=Af){const s=this.#n.keys().next().value;s!==void 0&&this.#n.delete(s)}return this.#n.set(t,r),r}clearTextWidthCache(){this.#d()}#d(){const e=this.#n.size>0;return this.#n.clear(),e}};function Yi(e){for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n>=55296&&n<=57343||n===8205||n===65038||n===65039||n>127&&Rf.test(e.charAt(t)))return!0}return!1}function Mf(e,t){const n=Math.max(0,Math.min(t,e.length));if(n===0||n===e.length||!Yi(e))return n;const i=pt();if(i!==void 0){for(const s of i.segment(e)){const o=s.index,a=o+s.segment.length;if(n>o&&n<a)return a;if(n<=o)break}return n}let r=0;for(const s of e){const o=r+s.length;if(n>r&&n<o)return o;if(n<=r)break;r=o}return n}function Hf(e){if(!Yi(e))return;const t=[0],n=pt();if(n!==void 0){for(const r of n.segment(e))t.push(r.index+r.segment.length);return t}let i=0;for(const r of e)i+=r.length,t.push(i);return t}function hn(e,t){let n=0;for(let i=0;i<e.length;i++){const r=e.charCodeAt(i);if(r>127)return-1;n+=r===9?t-n%t:1}return n}const Yn=500;let Pf=0;var Of=class{#t;#e;#s;#n="dark";#a="";#d;#l;#g;#x;#f;#C;#m;#k;#E;#B=!1;#o=[je];#P=[];#b=0;#v=[];#w=-1;#p=!0;#R=!1;#S=0;#K=++Pf;#T=-1;#H=-1;#U;#L=0;#D=[];#h=!1;#W=cu(async e=>{if(this.#B)return;const{startingLine:t=0,totalLines:n=1/0}=e??{},i=Math.min(n===1/0?1/0:t+n,this.#l.lineCount);if(this.#e===void 0&&!en(this.#l.languageId)){if(await this.#t.loadLanguage(this.#l.languageId),this.#B)return;this.#e=this.#t.getLanguage(this.#l.languageId)}this.#_(),this.#O(i)},500);#V=({data:e})=>{if(typeof e!="object"||e===null)return;const{type:t,tokenizerId:n,jobId:i}=e;t==="tokenize"&&n===this.#K&&typeof i=="number"&&i===this.#S&&(this.#T>=0?this.#M(i):this.#ve(i))};get themeType(){return this.#n}getStringCommentRegexpRangesInLine(e){if(!this.#m||e<0||e>=this.#l.lineCount||(this.#A(),this.#e===void 0))return null;if(this.#D[e]===void 0){this.#I(e);const t=this.#o[e]??je,n=this.#F(e,t);this.#o[e+1]=n.state}return this.#D[e]??null}constructor({codeOptions:e,highlighter:t,textDocument:n,matchBrackets:i,setStyle:r,onDeferTokenize:s,onThemeChange:o,__debug:a}){const{themeType:l="system",theme:h=J,tokenizeMaxLineLength:d=1e3}=e;this.#s=window.matchMedia("(prefers-color-scheme: dark)");let c;if(l==="system"?c=this.#X():c=l,typeof h!="string"&&l==="system"){const u=new MutationObserver(f=>{for(const{type:p,attributeName:g}of f)if(p==="attributes"&&g!==null&&(g==="class"||g.startsWith("data-"))){const m=this.#X();this.#Y(h[m],m);break}});u.observe(document.documentElement,{attributes:!0}),u.observe(document.body,{attributes:!0}),this.#E=[G(this.#s,"change",()=>{const f=this.#X();this.#Y(h[f],f)}),()=>u.disconnect()]}this.#t=t,this.#l=n,this.#g=d,this.#x=r,this.#f=s,this.#C=o,this.#m=i!==!1,this.#k=a??!1,this.#A(),this.#d=[],this.#u(typeof h=="string"?h:h[c],typeof h=="string"?void 0:c)}#Y(e,t){e===this.#a&&t===this.#n||(this.#u(e,t),this.stopBackgroundTokenize(),this.#o=[je],this.#P=[],this.#b=0,this.#v=[],this.#e!==void 0&&this.#l.lineCount>0&&this.#y(0),this.#C?.())}#X(){try{if(typeof document<"u"&&typeof getComputedStyle=="function"&&document.body!=null){const e=getComputedStyle(document.body).colorScheme.split(/\s+/),t=e.includes("dark");if(t!==e.includes("light"))return t?"dark":"light"}}catch{}return this.#s.matches?"dark":"light"}syncTheme(e){const{themeType:t="system",theme:n=J}=e;if(typeof n=="string"){const s=this.#t.getTheme(n).type;if(n===this.#a&&s===this.#n)return;this.#Y(n,s);return}const i=t==="system"?this.#X():t,r=n[i];i===this.#n&&r===this.#a||this.#Y(r,i)}#u(e,t){const{theme:n,colorMap:i}=this.#t.setTheme(e),{colors:r={}}=this.#t.getTheme(e),s=r["editor.selectionBackground"],o=r["editor.lineHighlightBackground"],a=o!=null&&o.trim()!==""&&!dl.isFullyTransparent(o)?o:void 0,l=r["editor.lineHighlightBorder"]??(a==null?"color-mix(in lab, var(--diffs-bg) 70%, var(--diffs-fg))":"transparent"),h=a==null?"100%":"85%",d=r["editorCursor.foreground"],c=r["editor.findMatchBackground"],u=r["editor.findMatchHighlightBackground"],f=r["editorBracketMatch.background"],p=r["editorBracketMatch.border"],g=r["editorHint.foreground"],m=r["editorInfo.foreground"],v=r["editorWarning.foreground"],S=r["editorError.foreground"];this.#x(`:host {
1876
+ --diffs-editor-selection-bg: ${s??"var(--diffs-line-bg)"};
1877
+ --diffs-editor-line-highlight-border: ${l};
1878
+ --diffs-editor-active-line-source-mix: ${h};
1879
+ --diffs-editor-match-bg: ${c??"initial"};
1880
+ --diffs-editor-match-highlight-bg: ${u??"initial"};
1881
+ --diffs-editor-bracket-match-bg: ${f??"initial"};
1882
+ --diffs-editor-bracket-match-border: ${p??"initial"};
1883
+ --diffs-editor-cursor-fg: ${d??"initial"};
1884
+ --diffs-editor-hint-fg: ${g??"initial"};
1885
+ --diffs-editor-info-fg: ${m??"initial"};
1886
+ --diffs-editor-warning-fg: ${v??"initial"};
1887
+ --diffs-editor-error-fg: ${S??"initial"};
1888
+ }`),this.#a=e,this.#n=t??n.type,this.#d=i}#_(){if(this.#a==="")return;const{colorMap:e}=this.#t.setTheme(this.#a);this.#d=e}cleanUp(){this.#B=!0,this.stopBackgroundTokenize(),this.#$(),this.#E?.forEach(e=>e()),this.#E=void 0}tokenize(e,t,n=!1){if(this.#A(),this.#_(),this.#e===void 0&&!en(this.#l.languageId))throw new Error(`Grammar for language "${this.#l.languageId}" not loaded`);this.#m&&(this.#D.length=Math.min(this.#D.length,e.startLine));const{lineCount:i}=this.#l,{startingLine:r=0,totalLines:s=1/0}=t??{},o=s===1/0?i:Math.min(r+s,i),a=e.startLine,l=Math.max(r,a),h=t!==void 0&&s!==1/0&&e.lineDelta>0&&a<o&&e.endLine>=o,d=e.lineDelta===0&&(e.changedLineChanges?.every(([,,x])=>x===0)??!0),c=n&&e.lineDelta!==0&&a>=r,u=d||t===void 0||a>=l,f=e.changedLineRanges??[[a,e.endLine]];this.#P=[],this.#b=0,this.#v=[];let p=-1;if(a<l)for(const[x,w]of f)x<l&&(p=Math.max(p,Math.min(w,l-1)));const g=p>=a&&(d||e.lineDelta<0);d?this.#I(a):(this.#z(e),(t===void 0||a>=l)&&this.#I(l));let m=0,v=f[m][1],S,C=0,b=d?f[m][0]:l,y=!1;const L=new Map,k=g?new Map:void 0;if(k!==void 0&&!d){const x=Math.min(p+1,l,o);if(x>a){this.#I(x);let w=a,O=this.#o[w]??je;for(;w<x;w++){const T=this.#F(w,O);O=T.state,k.set(w,T.resolvedTokens)}this.#o[x]=O}}let E=this.#o[b]??je;for(;b<o;){const x=d?this.#o[b+1]:c?this.#Z(b+1):void 0;u&&(this.#o[b]=E);const{resolvedTokens:w,state:O}=this.#F(b,E);if(E=O,b>=l?L.set(b,w):k?.set(b,w),u&&(this.#o[b+1]=E),y=b>=v&&(d||c)&&x!==void 0&&E.equals(x),y){m++;const T=f[m];if(T===void 0)break;if(T[0]>=o){S=T[0],C=m;break}let R=this.#o[T[0]];if(c)for(let _=b+2;_<=T[0]&&(R=this.#Z(_),R!==void 0);_++)this.#o[_]=R;R===void 0?(v=T[1],b++):(b=T[0],E=R,v=T[1]),y=!1;continue}b++}if(u&&(b<o?this.#o[b+1]=E:this.#o[b]=E),y&&c&&S===void 0){for(let x=b+2;x<=i;x++){const w=this.#Z(x);if(w===void 0)break;this.#o[x]=w}this.#P=[],this.#b=0,this.#v=[]}if(k!==void 0&&k.size>0&&this.#f(k,this.#n),S!==void 0)this.#y(S,f,C);else if(!y&&b<i){const x=h&&a>=l?o:a<l&&!d?a:b;this.#y(x,f,m)}return L}prebuildStateStack(e){this.#A(),this.#W(e)}stopBackgroundTokenize(){this.#H=-1,!this.#p&&(this.#p=!0,this.#R=!1,this.#w=-1,this.#T=-1,this.#U=void 0,this.#L=0,this.#P=[],this.#b=0,this.#v=[],this.#$())}pauseBackgroundTokenize(){this.#p||this.#R||(this.#k&&console.log("[diffs/editor] background tokenization paused",{jobId:this.#S}),this.#R=!0)}resumeBackgroundTokenize(){this.#p||!this.#R||this.#e===void 0||this.#w<0||(this.#k&&console.log("[diffs/editor] background tokenization resumed",{jobId:this.#S}),this.#R=!1,this.#Q(this.#S))}#A(){this.#e===void 0&&!en(this.#l.languageId)&&this.#t.getLoadedLanguages().includes(this.#l.languageId)&&(this.#e=this.#t.getLanguage(this.#l.languageId))}#r(){this.#h||(globalThis.addEventListener("message",this.#V),this.#h=!0)}#$(){this.#h&&(globalThis.removeEventListener("message",this.#V),this.#h=!1)}#Q(e){globalThis.postMessage({type:"tokenize",tokenizerId:this.#K,jobId:e})}#y(e,t,n=0){if(en(this.#l.languageId))return;const i=++this.#S;this.#k&&console.log("[diffs/editor] background tokenization scheduled",{jobId:i,startLine:e,changedLineRanges:t,changedRangeIndex:n}),this.#p=!1,this.#R=!1,this.#w=e,this.#T>=0&&(this.#H=Math.max(this.#H,this.#T)),this.#T=-1,this.#U=t,this.#L=n,this.#r(),this.#Q(i)}#O(e){if(this.#e===void 0||this.#o.length>e)return;if(!this.#p){this.#T>=0?this.#T=Math.max(this.#T,e):this.#H=Math.max(this.#H,e);return}const t=++this.#S;this.#p=!1,this.#R=!1,this.#w=this.#o.length-1,this.#T=e,this.#H=-1,this.#U=void 0,this.#L=0,this.#r(),this.#Q(t)}#F(e,t){const n=this.#l.getLineText(e);if(n.length>this.#g)return console.warn(`[diffs] Line(${e}) too long to tokenize: ${n.length}`),this.#N(e,null),{resolvedTokens:[[0,"",n]],state:t};if(this.#e===void 0||n===""||n.trim()==="")return this.#N(e,null),{resolvedTokens:[[0,"",n]],state:t};const i=Xn(this.#e,this.#d,n,t,Yn,this.#m);return this.#N(e,i.bracketIgnoredRanges),{resolvedTokens:i.resolvedTokens,state:i.ruleStack}}#N(e,t){this.#m&&(this.#D[e]=t)}#z(e){const t=e.changedLineChanges??[[e.startLine,e.endLine,e.lineDelta]],n=e.startLine+1;n<=this.#o.length-n?(this.#P=this.#o,this.#b=0,this.#o=this.#o.slice(0,n)):(this.#b=n,this.#P=this.#o.slice(n),this.#o.length=Math.min(this.#o.length,n)),this.#v=t}#Z(e){let t=e;for(let n=this.#v.length-1;n>=0;n--){const[i,r,s]=this.#v[n];if(s!==0){if(t>r)t-=s;else if(t>i)return this.#o[e]}}return this.#P[t-this.#b]??this.#o[e]}#I(e,t){const n=Math.min(Math.max(0,e),this.#l.lineCount);if(this.#o.length>n||this.#e===void 0)return!0;const i=t===void 0?0:performance.now();let r=this.#o.length-1,s=this.#o[r]??je;for(;r<n;){this.#o[r]=s;const o=this.#l.getLineText(r);if(o.length<=this.#g&&o!==""&&o.trim()!==""){const a=Xn(this.#e,this.#d,o,s,Yn,this.#m,!1);this.#N(r,a.bracketIgnoredRanges),s=a.ruleStack}else this.#N(r,null);if(r++,this.#o[r]=s,t!==void 0&&performance.now()-i>t)break}return r>=n}#M(e){if(this.#p||this.#R||this.#e===void 0||e!==this.#S)return;this.#_();const t=this.#I(this.#T,1);if(!(this.#p||this.#R||e!==this.#S)){if(t){this.stopBackgroundTokenize();return}this.#w=this.#o.length-1,this.#Q(e)}}#ve(e){if(this.#p||this.#R||this.#e===void 0||e!==this.#S)return;this.#_();const t=performance.now(),n=new Map,i=this.#l.lineCount,r=this.#U;let s=this.#w,o=this.#o[s]??je,a=!1,l=this.#L,h=r?.[l]?.[1];for(;s<i;){this.#o[s]=o;const d=h!==void 0?this.#Z(s+1):void 0,c=this.#l.getLineText(s);if(c.length>this.#g)console.warn(`[diffs] Line(${s}) too long to tokenize: ${c.length}`),n.set(s,[[0,"",c]]),this.#N(s,null);else if(c===""||c.trim()==="")n.set(s,[[0,"",c]]),this.#N(s,null);else{const u=Xn(this.#e,this.#d,c,o,Yn,this.#m);n.set(s,u.resolvedTokens),this.#N(s,u.bracketIgnoredRanges),o=u.ruleStack}if(this.#o[s+1]=o,a=h!==void 0&&s>=h&&d!==void 0&&o.equals(d),s++,a){l++;const u=r?.[l];if(u===void 0)break;if(h=u[1],this.#o[u[0]]===void 0)a=!1;else{s=u[0],o=this.#o[s]??o,a=!1;continue}}if(performance.now()-t>1)break}if(this.#f(n,this.#n),!(this.#p||this.#R||e!==this.#S)){if(a||s>=i){const d=this.#H;this.stopBackgroundTokenize(),d>=0&&this.#O(d);return}this.#w=s,this.#L=l,this.#Q(e)}}};function Xn(e,t,n,i,r,s=!0,o=!0){const a=e.tokenizeLine2(n,i,r);a.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);const l=a.tokens,h=l.length/2,d=[],c=[];if(!o&&!s)return{ruleStack:a.ruleStack,resolvedTokens:d,bracketIgnoredRanges:c};for(let u=0;u<h;u++){const f=l[2*u],p=u+1<h?l[2*u+2]:n.length;if(f===p)continue;const g=l[2*u+1];if(o){const m=Zi.getForeground(g);d.push([f,t[m],n.slice(f,p)])}s&&Zi.getTokenType(g)>0&&c.push([f,p])}return{ruleStack:a.ruleStack,resolvedTokens:d,bracketIgnoredRanges:c}}function Zn(e){return e.map(([t,n,i])=>t===0&&n===""?i===""?W("br"):i:W("span",{dataset:{char:t.toString()},style:`color:${n};`,textContent:i}))}function en(e){return e==="text"||e==="ansi"}function Df(e){const t=e.getSelection?.();if(t==null||t.rangeCount===0)return;const n=t.getRangeAt(0);return{collapsed:n.collapsed,startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}}function Ke(e){if(typeof e.cacheKey!="string"||e.cacheKey.length===0)throw new Error(`Editor persistState requires a non-empty file.cacheKey for "${e.name}". Provide a unique, stable cacheKey for every editable file.`);return e.cacheKey}function Jn(e){return typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function"}const _f=2,Ff=1e4,Qn="selection-action",ei="application/vnd.pierre.diffs-selections+json";var Nf=class{#t;#e=new If;#s;#n;#a=new Map;#d;#l;#g=new Map;#x;#f=0;#C=!1;#m;#k;#E;#B;#o={generation:0,callback:void 0,delivered:!1};#P;#b;#v;#w=new Map;#p=new Map;#R=new Map;#S;#K;#T;#H;#U;#L;#D;#h;#W;#V;#Y;#X;#u;#_;#A;#r;#$;#Q;#y;#O;#F;#N=!0;#z=!1;#Z=!1;#I=!1;#M;#ve=!1;#Se=!1;#re=!1;#Pe=!1;#q;#be="";#Ce;#Oe;#i;#J;#ee;#he;#ke=!1;#ce=!1;#ae=!1;#De=!1;#ue;#St=(e,t)=>{if(this.#u?.updateRenderCache(e,t),this.#$!==void 0&&this.#$.totalLines!==1/0){const{startingLine:n,totalLines:i}=this.#$,r=Math.min(n+i,this.#r?.lineCount??0);for(const[s,o]of e)if(s>=n&&s<r){const a=this.#de(s);a!==void 0&&a.replaceChildren(...Zn(o))}}};constructor(e={}){this.#t=e}setOptions(e){const t=this.#t.persistStateStorage??"inMemory",n={...this.#t,...e};if(n.persistState===!0&&this.#u?.type==="file"){const i=this.#u.__getCurrentFile?.()??this.#_;i!==void 0&&Ke(i)}this.#t=n,this.#t.persistState!==!0&&(this.#a.clear(),this.#f++,this.#C=!1),(this.#t.persistStateStorage??"inMemory")!==t&&(this.#f++,this.#d=void 0,this.#l=void 0,this.#g.clear())}edit(e){if(this.#t.persistState===!0&&e.type==="file"){const t=e.__getCurrentFile?.();t!==void 0&&Ke(t)}return this.#Fe(),this.#u=e,this.#kt(),this.#B=e.attachEditor(this),()=>this.cleanUp()}applyEdits(e,t=!0){const n=this.#r;if(n==null)throw new Error("Editor is not attached");const i=this.#I,r=this.#i,s=r?.map(h=>[n.offsetAt(h.start),n.offsetAt(h.end)]),o=r===void 0?void 0:n.resolveEdits(e).sort((h,d)=>h.start-d.start),a=n.applyEdits(e,t,r);if(a===void 0)return;let l;r!==void 0&&s!==void 0&&o!==void 0&&(l=jn(n,r,s,o),t&&n.setLastUndoSelectionsAfter(l)),this.#j(a,l,this.#ie(a),{skipFocus:!i})}get canUndo(){return this.#r?.canUndo??!1}get canRedo(){return this.#r?.canRedo??!1}undo(){this.#ze("undo")}redo(){this.#ze("redo")}getFile(){const e=this.#_,t=this.#r;if(e===void 0||t===void 0)return;const n={...e};return Object.defineProperty(n,"contents",{enumerable:!0,get:()=>t.getText()}),n}getText(){return this.#r?.getText()??""}getState(){const e=this.#u;return{selections:this.#i,view:e!=null?{scrollLeft:e.getCodeScrollLeft(),scrollTop:this.#xt()}:void 0}}setState({selections:e,view:t}){if(this.#u===void 0||this.#r===void 0)throw new Error("Editor is not attached");if(this.#N=!1,this.#c(e??[]),t!=null){this.#u.setCodeScrollLeft(t.scrollLeft),t.scrollTop!==void 0&&this.#Ze(t.scrollTop);return}this.#ne()}setSelections(e){const t=this.#r;if(t===void 0)throw new Error("Text document is not initialized");const n=e.map(r=>{let s=t.normalizePosition(r.start),o=t.normalizePosition(r.end),a=r.direction==="none"?0:r.direction==="backward"?-1:1;return q(s,o)>0&&([s,o]=[o,s],a!==0&&(a=a===1?-1:1)),{direction:a,start:s,end:o}});this.#N=!1,this.#c(n);const i=n.at(-1);i!==void 0&&this.#le(ne(i).line),this.#ne()}setMarkers(e){const t=this.#r;if(t===void 0)throw new Error("Text document is not initialized");if(e.length===0){this.#y?.cleanup(),this.#y=void 0,this.#c(this.#i??[]);return}this.#y??=new sf({popoverManager:this.#Ee(),getLineHeight:()=>this.#e.lineHeight,getOverlayElement:()=>this.#W,getGutterWidth:()=>this.#oe(),getCharX:(n,i)=>this.#me(n,i),getLineY:n=>this.#ge(n),isMouseDown:()=>this.#re||this.#Se}),this.#y.setMarkers(e,t),this.#h!==void 0&&this.#y.listenHover(this.#h),this.#c(this.#i??[])}focus(e){const t=e?.preventScroll??!1,n=e?.lineNumber;if(n==="first-visible"||typeof n=="number"){const r=this.#r;if(r==null||this.#u==null)return;const s=n==="first-visible"?this.#Pt(e?.offset):n;if(s==null)return;const o=r.normalizePosition({line:s-1,character:n==="first-visible"?0:e?.character??0});this.#Ot(o,t);return}const i=this.#i?.at(-1);if(i!==void 0){const r=i.direction===-1?i.end:i.start;this.#G(r,t)}else this.#G(void 0,t)}blur(){this.#M=void 0,this.#I=!1,this.#z=!1,this.#h?.blur()}cleanUp(e=!1){this.#Fe(),e||(this.#o.delivered=!1);const t=this.#u!=null,n=this.#t.persistState===!0;this.#f++,this.#Ke(),t&&(this.#C=n),Ze(this.#Qe),this.#s?.cleanUp(),this.#s=void 0,e||(this.#r=void 0,this.#_=void 0),this.#k?.forEach(i=>i()),this.#k=void 0,this.#m?.forEach(i=>i()),this.#m=void 0,this.#E?.forEach(i=>i()),this.#E=void 0,this.#B?.(e),this.#B=void 0,this.#b=void 0,this.#v=void 0,this.#w.clear(),this.#p.clear(),this.#R.clear(),this.#S=void 0,this.#K?.remove(),this.#K=void 0,this.#T?.remove(),this.#T=void 0,this.#H?.remove(),this.#H=void 0,this.#U?.remove(),this.#U=void 0,this.#L=void 0,this.#n?.cleanUp(),this.#n=void 0,this.#D=void 0,this.#h?.removeAttribute("contentEditable"),this.#h=void 0,this.#M=void 0,this.#I=!1,this.#W?.remove(),this.#W=void 0,this.#X?.disconnect(),this.#X=void 0,this.#De=!1,this.#ue!==void 0&&(cancelAnimationFrame(this.#ue),this.#ue=void 0),this.#Xe(),this.#u=void 0}__prepareFile(e){if(this.#t.persistState!==!0)return e;const t=Ke(e),n=this.#_,i=e.lang??he(e.name);n!==void 0&&(Ke(n)!==t||n.name!==e.name||this.#r?.languageId!==i)&&(this.#f++,this.#Ke());const r=this.#Ge(e,t);return r===void 0||r.getText()===e.contents?e:{...e,contents:r.getText()}}__postponeBgTokenizeToNextFrame(){const e=this.#s;e!==void 0&&(e.pauseBackgroundTokenize(),requestAnimationFrame(()=>{e.resumeBackgroundTokenize()}))}__captureFocusForDOMReplacement(){const e=this.#h,t=this.#L?.shadowRoot?.activeElement;e!=null&&(this.#I||t===e||t!=null&&e.contains(t))&&(this.#M={})}__syncRenderView=(e,t,n,i,r)=>{const s=this.#u;if(s==null)return;const o=t.shadowRoot;if(o==null){console.error("[editor] Could not find the shadow root.");return}let a,l,h;for(const p of o.querySelectorAll("[data-code]"))if(p.dataset.deletions===void 0){a=p;for(const g of p.children){const m=g,{gutter:v,content:S}=m.dataset;v!==void 0?l=m:S!==void 0&&(h=m)}break}if(a===void 0||h===void 0){this.#M=void 0;return}this.#Ee().setViewportElements(t,a),this.#L!==t&&(this.#L=t,this.#K!==void 0&&t.appendChild(this.#K),this.#T!==void 0&&o.appendChild(this.#T),this.#H!==void 0&&o.appendChild(this.#H),this.#U!==void 0&&o.prepend(this.#U));const d=this.#r===void 0||this.#_===void 0||this.#_.name!==n.name||this.#_.lang!==n.lang||this.#_.cacheKey!==n.cacheKey,c=this.#t.persistState===!0?Ke(n):void 0;let u;if(d){this.#Fe();let p="";"contents"in n?p=n.contents:p=n.additionLines.join("");const g=new yo({maxEntries:this.#t.historyMaxEntries}),{name:m,lang:v,cacheKey:S}=n,C=v??he(n.name),b=c!==void 0?this.#Ge(n,c):void 0,y=s.type==="file"||b?.getText()===p?b:void 0,L=y??new Zc(n.name,p,C,0,g);this.#_={name:m,lang:v,cacheKey:S},this.#r=L,c!==void 0&&(this.#a.set(c,L),u={cacheKey:c,textDocument:L}),this.#s?.cleanUp(),this.#s=void 0,this.#Xe(),this.#p.clear(),this.#i=this.#Oe,this.#t.__debug===!0&&console.log(y!==void 0?"[diffs/editor] cached text document reused for":"[diffs/editor] text document rebuilt from",n.name)}u===void 0&&this.#C&&c!==void 0&&this.#r!==void 0&&(u={cacheKey:c,textDocument:this.#r});const f=this.#r;if(this.#s==null&&f!=null&&(this.#s=new Of({highlighter:e,textDocument:f,codeOptions:this.#u?.__getEffectiveCodeOptions()??{},matchBrackets:this.#t.matchBrackets,onDeferTokenize:this.#St,onThemeChange:()=>this.#_t(),setStyle:p=>{this.#H.textContent=p},__debug:this.#t.__debug})),this.#h!==h&&(this.#D=l,this.#h=hu(h,{contentEditable:"true",role:"textbox",ariaMultiLine:"true",autocapitalize:"off",writingSuggestions:"off",autocorrect:!1,spellcheck:!1,translate:!1}),this.#W!==void 0&&h.after(this.#W),this.#e.init(h),this.#Mt(),this.#wt(h,l),this.#h!==void 0&&this.#t.__debug===!0&&console.log("[diffs/editor] full re-render triggered !!!")),this.#M!=null&&(this.#M.target=h),h.ariaLabel!==n.name&&(h.ariaLabel=n.name),i!==void 0&&i.length>0||this.#te)for(const p of this.#h.children){const g=p,{lineAnnotation:m,lineType:v,separator:S}=g.dataset;(m!==void 0||S!==void 0||v==="change-deletion")&&g.setAttribute("contenteditable","false")}if(this.#_e(),this.#s?.syncTheme(this.#u?.__getEffectiveCodeOptions()??{}),this.#A=i,this.#$=r,this.#Q=r?.totalLines,this.#s?.prebuildStateStack(r),this.#y?.removePopover(),(this.#i!==void 0||this.#J!==void 0||this.#y!==void 0)&&this.#c(this.#i??[]),this.#Oe!==void 0&&this.#Y!==void 0?(this.#Oe=void 0,this.#ne(!1,"center")):this.#ee!==void 0?this.#Ve(this.#ee,this.#he,this.#ce):this.#M!==void 0?this.#Be():this.#i!==void 0&&this.#i.length>0&&this.#I&&!this.#ae&&this.focus({preventScroll:!0}),this.#ae&&this.#O?.focus(),this.#t.__debug===!0&&r!==void 0){const{startingLine:p,totalLines:g}=r;console.log("[diffs/editor] render file:",n.name,"RenderRange:",p+"-"+(p+g),"of",this.#r?.lineCount,"lines")}u!==void 0&&(this.#C=!1,this.#bt(u.cacheKey,u.textDocument)),this.#Lt(s)};#Ge(e,t){const n=this.#a.get(t),i=e.lang??he(e.name);return n?.languageId===i?n:void 0}#je(){const e=this.#t.persistStateStorage??"inMemory";return(this.#d===void 0||this.#l!==e)&&(this.#d=Lf(e),this.#l=e),this.#d}#Ke(){const e=this.#_,t=this.#r;if(this.#t.persistState!==!0||this.#u===void 0||e===void 0||t===void 0)return;const n=Ke(e);this.#a.set(n,t);let i;try{i=this.#je()}catch{return}const r=gt(this.getState()),s=this.#x;if(s?.cacheKey===n&&s.textDocument===t){if(this.#x=void 0,t.version===s.documentVersion&&this.#i===s.selections&&r.view?.scrollLeft===s.view?.scrollLeft&&r.view?.scrollTop===s.view?.scrollTop)return;this.#qe(i,n,r,s.completion);return}this.#qe(i,n,r)}#qe(e,t,n,i){const r=this.#g.get(t);if(i!==void 0||r!==void 0){let o=i??Promise.resolve();r!==void 0&&(o=o.then(()=>r)),this.#Ye(t,o.then(()=>e.set(t,n)));return}let s;try{s=e.set(t,n)}catch{return}Jn(s)&&this.#Ye(t,s)}#Ye(e,t){const n=t.catch(()=>{});this.#g.set(e,n),n.finally(()=>{this.#g.get(e)===n&&this.#g.delete(e)})}#bt(e,t){const n=++this.#f,i=t.version,r=this.#i,s=this.getState().view;let o;const a=c=>{const u=this.getState().view;if(n!==this.#f||this.#r!==t||t.version!==i||this.#i!==r||u?.scrollLeft!==s?.scrollLeft||this.#_===void 0||Ke(this.#_)!==e)return;const f=o?.userScrolled()===!0;if(c===void 0){this.#u?.setCodeScrollLeft(0),f||this.#Ze(0);return}const p=gt(c);f&&p.view!==void 0&&(p.view={scrollLeft:p.view.scrollLeft}),this.setState(p)},l=()=>{let c;try{c=this.#je().get(e)}catch{return}if(Jn(c))return c.then(a).catch(()=>{});try{a(c)}catch{}},h=this.#g.get(e),d=h===void 0?l():h.then(l);if(Jn(d)){o=this.#Ct();const c={cacheKey:e,textDocument:t,documentVersion:i,selections:r,view:s,completion:d.catch(()=>{})};this.#x=c,c.completion.finally(()=>{o?.dispose(),this.#x===c&&(this.#x=void 0)})}}#Ct(){const e=this.#Te();if(!(e instanceof HTMLElement))return;let t=!1;const n=["wheel","touchstart","mousedown"],i=()=>{for(const s of n)e.removeEventListener(s,r,{capture:!0})},r=()=>{t=!0,i()};for(const s of n)e.addEventListener(s,r,{capture:!0,passive:!0});return{userScrolled:()=>t,dispose:i}}#ye(e){return this.#u?.isLineRenderable?.(e+1)??!0}get#yt(){const e=this.#u;if(e?.getNearestRenderableLine!=null)return(t,n)=>{const i=e.getNearestRenderableLine(t+1,n);return i==null?void 0:i-1}}#le(e){this.#ye(e)||this.#u?.revealLine?.(e+1)}get#we(){return this.#u?.options.diffStyle??"split"}get#te(){return this.#u?.type==="file-diff"}get#se(){return this.#u?.options.overflow==="wrap"}#Ee(){return this.#n??=new yu({hasActivePopover:()=>this.#F!==void 0||this.#y?.isPopoverVisible()===!0,updateActivePopover:()=>{this.#Ue(),this.#y?.updatePopoverPosition()}})}#_e(){this.#w.clear(),this.#R.clear(),this.#S=void 0}#Xe(){this.#xe(null),this.#b=void 0,this.#v=void 0,this.#z=!1,this.#Z=!1,this.#V?.forEach(e=>e.remove()),this.#V=void 0,this.#i=void 0,this.#Ce=void 0,this.#ee=void 0,this.#y?.cleanup(),this.#y=void 0,this.#O?.cleanup(),this.#O=void 0,this.#F?.cleanup(),this.#F=void 0,this.#N=!0}#Fe(){const e=this.#o;e.generation++,e.callback!=null&&(Ze(e.callback),e.callback=void 0)}#Lt(e){const t=this.#o,n=this.#r;if(t.delivered||t.callback!=null||n==null)return;const{generation:i}=t,r=()=>{if(t.callback!==r||(t.callback=void 0,i!==t.generation||this.#u!==e||this.#r!==n))return;const s=this.#h,o=this.#L?.shadowRoot;s==null||o==null||!o.contains(s)||(t.delivered=!0,this.#t.onAttach?.(this,e))};t.callback=r,Ye(r)}#Te(){const e=this.#u?.getEditorViewport?.();if(e!==void 0)return e;const t=this.#L;if(!(this.#u==null||t==null))return fu(t)}#xt(){const e=this.#Te();return e instanceof HTMLElement?e.scrollTop:e?.defaultView?.scrollY??0}#Ze(e){const t=this.#Te();t instanceof HTMLElement?t.scrollTop=e:t instanceof Document&&t.defaultView?.scrollTo({top:e})}#kt(){this.#K=W("style",{dataset:"editorGlobalCss",textContent:`
1889
+ [data-annotation-slot] {
1890
+ user-select: none;
1891
+ -webkit-user-select: none;
1892
+ }
1893
+ `}),this.#T=W("style",{dataset:"editorCss",textContent:nu}),this.#H=W("style",{dataset:"editorThemeCss"}),this.#U=Sf(),this.#W=W("div",{dataset:"editorOverlay"});const e=n=>{const i=n.composedPath()[0];return i instanceof Node&&this.#h?.contains(i)===!0},t=()=>{this.#M!=null&&(this.#M=void 0,this.#I=!1,this.#z=!1)};this.#k=[G(document,"focusin",n=>{e(n)||t()},{passive:!0}),G(document,"pointerdown",n=>{e(n)||queueMicrotask(t)},{capture:!0,passive:!0}),G(document,"selectionchange",()=>{const n=this.#L?.shadowRoot;if(this.#z||this.#Z||n==null||!this.#I||this.#i!==void 0&&this.#i.length>1&&!this.#re)return;const i=document.getSelection();if(i==null)return;const r=typeof i.getComposedRanges=="function"?i.getComposedRanges({shadowRoots:[n]})?.[0]:Df(n);if(r===void 0||!this.#Kt(r))return;let s=ku(r,0);if(s!==void 0){if(this.#re&&this.#Pe&&this.#i!==void 0&&this.#i.length>0){const o=this.#i.at(-1);this.#c([Io(o,s)]);return}if(this.#re)this.#q!==void 0?s=wi(this.#q,s):this.#q=s;else if(this.#q!==void 0)s.direction=wi(this.#q,s).direction;else if(this.#i!==void 0&&this.#i.length===1){const o=this.#i[0];q(o.start,s.start)===0&&q(o.end,s.end)===0&&(s.direction=o.direction)}this.#Ce!==void 0?this.#c([...this.#Ce.filter(o=>!Gi(o,s)),s]):this.#c([s])}},{passive:!0}),G(document,"pointerup",n=>{n.pointerType==="mouse"&&(this.#E?.forEach(i=>i()),this.#E=void 0,this.#Se&&(this.#Se=!1,this.#G()),this.#z=!1,this.#re=!1,this.#Pe=!1,this.#q=void 0,this.#Ce=void 0,this.#t.enabledSelectionAction===!0&&this.#i!==void 0&&this.#i.length>0&&!Q(this.#i.at(-1))&&this.#c(this.#i))},{passive:!0}),G(document,"keydown",n=>{n.key==="Shift"&&(this.#q=this.#i?.at(-1))},{passive:!0}),G(document,"keyup",n=>{n.key==="Shift"&&(this.#q=void 0)},{passive:!0})]}#Ne(e){this.#E?.forEach(t=>t()),this.#E=e}#Je(){return this.#u?.options.enableLineSelection===!0}#Ae(){this.#Z=this.#i!==void 0}#wt(e,t){const{onFocus:n,onBlur:i}=this.#t,r=o=>{const a=o.composedPath()[0];return a!==void 0&&(a===e||e.contains(a))};this.#m?.forEach(o=>o()),this.#m=[G(e,"focus",()=>{this.#I=!0,n?.(),!this.#re&&!this.#z&&this.#i!==void 0&&this.#i.length>0&&this.#Le(this.#i.at(-1))},{passive:!0}),G(e,"blur",()=>{this.#M?.target===e&&(this.#M=void 0,this.#z=!1),this.#I=!1,i?.()},{passive:!0}),G(e,"pointerdown",o=>{if(this.#N=!0,this.#Z=!1,o.pointerType==="mouse"){if(this.#Dt(o)){this.#Ie(!0),this.#i!==void 0&&this.#c([]);return}if(this.#Ie(!1),this.#y?.removePopover(),yn()&&this.#A!==void 0&&this.#A.length>0){const a=[...e.querySelectorAll("[data-line-annotation]")].map(l=>[G(l,"mouseenter",()=>{this.#z=!0}),G(l,"mouseleave",()=>{this.#z=!1})]).flat();this.#Ne(a)}if(this.#re=!0,this.#q=void 0,o.button===0&&Ot(o)&&(this.#Ce=this.#i?.map(a=>({...a}))),o.shiftKey){const a=this.#i?.at(-1);if(a!==void 0){const l=a.direction===-1?a.end:a.start;this.#Le({start:l,end:l,direction:0})}this.#Pe=!0}}},{passive:!0}),G(e,"keydown",o=>{if(!r(o))return;this.#N=!0,this.#Z=!1;const a=tu(o,this.#t.keymap);if(a!==void 0){o.preventDefault(),a==="simplifySelection"&&(this.#O?.close(),this.#O=void 0,this.#ae=!1,this.#F?.cleanup(),this.#F=void 0),this.#ze(a);return}const l=Jc(o),h=this.#r;if(this.#i!==void 0&&this.#i.length>0&&l!==void 0&&h!==void 0){const d={getSoftLineOffsets:this.#se?c=>this.#$e(c):void 0,resolveRenderableLine:this.#yt};o.shiftKey?this.#c(Au(h,this.#i,l,d)):this.#c(Ao(h,this.#i,l,d)),this.#ne(),o.preventDefault();return}if((o.key.length===1?o.key.toLowerCase():o.key)==="v"&&Ot(o)){if(o.repeat&&this.#te){o.preventDefault();return}if(this.#t.clipboard!==void 0){o.preventDefault(),Ye(this.#Qe);return}}if(this.#O!==void 0){const d=ki(o);if(d!==void 0){o.preventDefault(),this.#O.navigate(d==="previous");return}}}),G(e,"copy",o=>{r(o)&&(o.preventDefault(),this.#lt()?o.clipboardData?.setData("text",this.#dt()):this.#pt(o.clipboardData,this.#Bt(),this.#ft()))}),G(e,"cut",o=>{if(r(o))if(o.preventDefault(),this.#lt())o.clipboardData?.setData("text",this.#dt());else{const a=this.#ft();this.#pt(o.clipboardData,this.#Vt(),a)}}),G(e,"paste",o=>{if(!r(o))return;o.preventDefault();const a=o.clipboardData,l=this.#r;if(a===null||l===void 0)return;let h=a.getData("text");const d=this.#i?.length??0;if(d>1){const c=a.getData(ei);if(c!==void 0)try{const u=JSON.parse(c);Array.isArray(u)&&u.length===d&&(h=u)}catch{}}this.#pe(Array.isArray(h)?h.map(c=>l.normalizeEol(c)):l.normalizeEol(h),void 0,!0,"document")}),G(e,"beforeinput",o=>{r(o)&&o.inputType!=="insertCompositionText"&&(o.preventDefault(),this.#tt(o.inputType,o.data))}),G(e,"drop",o=>{r(o)&&o.preventDefault()}),G(e,"compositionstart",o=>{r(o)&&(this.#ve=!0,this.#z=!0)},{passive:!0}),G(e,"compositionend",o=>{if(!r(o))return;this.#z=!1;const a=this.#ve;this.#ve=!1,(o.data!==""||!a)&&this.#tt("insertText",o.data)},{passive:!0})];const s=this.#L?.shadowRoot?.querySelector("[data-deletions]");if(s!=null&&this.#m.push(G(s,"pointerdown",o=>{const a=o.composedPath();if(at(a)){this.#Ae();return}const l=a[0],h=l instanceof HTMLElement?l.closest("[data-column-number]"):null;if(h instanceof HTMLElement){if(this.#Je()){this.#Ae();return}if(this.#at(h,s,o.pointerType==="mouse"))return}this.#Ie(!0),this.#i!==void 0&&this.#c([])},{passive:!0})),t!==void 0){const o=(l,h=!1)=>{let d=l;return d?.dataset.lineNumberContent!==void 0?d=d.parentElement??void 0:h&&d?.tagName==="SPAN"&&(d=d.closest("[data-line]")),d},a=l=>{if(l===void 0)return;const h=l.dataset.lineType,d=ue(l)??ue(l,"columnNumber");if(!(d===void 0||h===void 0||!yt(h)))return d-1};this.#m.push(G(t,"pointerdown",l=>{const h=l.composedPath();if(at(h)){this.#Ae();return}const d=o(h[0]);if(d!==void 0&&this.#Je()){this.#Ae();return}if(d?.dataset.lineType==="change-deletion"){const p=d.closest("[data-code]");p!=null&&this.#at(d,p,l.pointerType==="mouse");return}if(l.pointerType!=="mouse")return;const c=this.#r,u=a(d);if(u===void 0||c===void 0)return;this.#N=!0,this.#y?.removePopover();const f=this.#rt(u,u,c);this.#Se=!0,this.#q=f,this.#c([f]),this.#Le(f),this.#G(),this.#Ne([G(document,"mousemove",p=>{if(!this.#Se)return;const g=this.#r,m=a(o(p.composedPath()[0],!0));if(m===void 0||g===void 0)return;const v=this.#q?.start.line??m,S=this.#rt(v,m,g);this.#q??=S,this.#c([S]),this.#G(S.direction===-1?S.start:S.end)},{passive:!0})])},{passive:!0}))}this.#y?.listenHover(e),this.#X?.disconnect(),this.#X=new ResizeObserver(this.#It),this.#X.observe(e),this.#X.observe(e.parentElement),this.#et(e)}#Qe=async()=>{const e=this.#t.clipboard;if(e!==void 0){let t=await e.readText();const n=this.#i?.length??0;if(n>1){const r=await e.readText(ei);try{const s=JSON.parse(r);Array.isArray(s)&&s.length===n&&(t=s)}catch{}}const i=this.#r;i!==void 0&&this.#pe(Array.isArray(t)?t.map(r=>i.normalizeEol(r)):i.normalizeEol(t),void 0,!0,"document")}};#et(e){this.#te&&this.#we==="split"&&this.#se&&(this.#P={top:e.offsetTop,left:e.offsetLeft-this.#oe()},this.#t.__debug===!0&&console.log("[diffs/editor] content offset:",this.#P))}get#fe(){if(this.#te&&this.#we==="split"&&this.#se)return this.#P}#ze(e){const t=this.#r;if(t!==void 0)switch(e){case"openSearchPanel":this.#ut("find");break;case"openSearchReplacePanel":this.#ut("replace");break;case"findNextMatch":{const n=this.#i;if(n===void 0)break;if(n.some(Q)){const i=n.map(r=>Q(r)?Ti(t,r):r);this.#c(i),this.focus()}else{const i=Uu(t,n);if(i!==void 0){this.#c(i);const r=i.at(-1);r!==void 0&&this.#le(ne(r).line),this.#ne()}}break}case"moveLineUp":case"moveLineDown":this.#Rt(e==="moveLineUp"?-1:1);break;case"copyLineUp":case"copyLineDown":this.#Tt(e==="copyLineUp"?-1:1);break;case"simplifySelection":{const n=this.#i,i=n?.at(-1);if(n===void 0||i===void 0)break;if(n.length>1)this.#c([i]),this.#G(ne(i));else if(!Q(i)){const r=ne(i);this.#c([{start:r,end:r,direction:0}]),this.#G(r)}break}case"insertBlankLine":this.#At();break;case"deleteHardLineForward":this.#Gt();break;case"toggleComment":case"toggleBlockComment":{const n=this.#i;if(n===void 0)break;const{lineComment:i,blockComment:r}=ou(t.languageId,this.#t.languageCommentConfig);if(e==="toggleComment"&&i!==null){this.#Re(au(t,n,i));break}const s=e==="toggleComment",o=du(t,n,r,s);o!==void 0&&this.#Re(o.edits,s?void 0:a=>o.nextSelectionOffsets.map(([l,h,d])=>({start:a.positionAt(l),end:a.positionAt(h),direction:d})));break}case"indent":case"outdent":case"indentLess":case"indentMore":if(this.#i!==void 0){const n=[],i=[],r=new Set,s=[];for(const a of this.#i){const l=a.start.line,h=e==="outdent"||e==="indentLess",d=e==="indentLess"||e==="indentMore";if(l!==a.end.line||h||d){const c=wu(t,a,this.#e.tabSize,h);for(const u of c[0]){const f=u.range.start.line;r.has(f)||(r.add(f),n.push(u))}i.push(c[1])}else{const c=t.charAt({line:l,character:0})===" "?" ":" ".repeat(this.#e.tabSize);n.push({range:a,newText:c}),s.push({line:l,startCharacter:a.start.character,addedLength:c.length-(a.end.character-a.start.character),selectionIndex:i.length});const u={line:a.start.line,character:a.start.character+c.length};i.push({start:u,end:u,direction:0})}}for(const a of s){let l=0;for(const h of s)h.line===a.line&&h.startCharacter<a.startCharacter&&(l+=h.addedLength);if(l!==0){const h=i[a.selectionIndex],d={line:a.line,character:h.start.character+l};i[a.selectionIndex]={start:d,end:d,direction:0}}}const o=t.applyEdits(n,!0,this.#i,i);o!==void 0&&this.#j(o,i)}break;case"selectAll":{const n=Wu(t);this.#c([n]),this.focus();const i=this.#mt(),r=i[0]?.[0],s=i.at(-1)?.[1];r!==void 0&&s!==void 0&&(this.#Z=!0,this.#Le({start:{line:r,character:0},end:{line:s,character:t.getLineLength(s)},direction:1}));break}case"moveCursorToDocStart":case"moveCursorToDocEnd":{const n=ls(t,e==="moveCursorToDocEnd",this.#te);this.#c([n]),this.#le(ne(n).line),this.#ne()}break;case"expandSelectionDocStart":case"expandSelectionDocEnd":{const n=e==="expandSelectionDocEnd",i=this.#i;if(i!==void 0){const r=ls(t,n,this.#te);this.#c(Bu(i,r)),this.#le(ne(r).line),this.#ne()}}break;case"undo":case"redo":this.#Et(e);break}}#Et(e){const t=this.#r;if(t===void 0||e==="undo"&&!t.canUndo||e==="redo"&&!t.canRedo)return;const n=this.#i,i=n?.map(d=>[t.offsetAt(d.start),t.offsetAt(d.end)]),r=e==="undo"?t.undo():t.redo();if(r===void 0)return;const[s,o,a,l]=r,h=o??(n!==void 0&&i!==void 0&&l!==void 0?jn(t,n,i,l):void 0);this.#j(s,h,a)}#Re(e,t){const n=this.#r,i=this.#i;if(n===void 0||i===void 0)return;const r=t===void 0,s=r?i.map(h=>[n.offsetAt(h.start),n.offsetAt(h.end)]):void 0,o=r?e.map(h=>{const d=n.offsetAt(h.range.start),c=n.offsetAt(h.range.end);return{start:Math.min(d,c),end:Math.max(d,c),text:h.newText}}).sort((h,d)=>{const c=h.start-d.start;return c!==0?c:h.end-d.end}):void 0,a=n.applyEdits(e,!0,i,void 0,!0);if(a===void 0)return;const l=r?jn(n,i,s,o):t(n);n.setLastUndoSelectionsAfter(l),this.#j(a,l,this.#ie(a))}#Tt(e){const t=this.#r,n=this.#i;if(t===void 0||n===void 0)return;const i=as(n);if(i.length===0)return;const r=[];let s=0;const o=[];for(const l of i){r.push(s);const h=l.endLine-l.startLine+1;s+=h;const d=t.getText({start:{line:l.startLine,character:0},end:{line:l.endLine,character:t.getLineLength(l.endLine)}});if(e>0){const c={line:l.startLine,character:0};o.push({range:{start:c,end:c},newText:d+t.eol})}else if(l.endLine<t.lineCount-1){const c={line:l.endLine+1,character:0};o.push({range:{start:c,end:c},newText:d+t.eol})}else{const c={line:l.endLine,character:t.getLineLength(l.endLine)};o.push({range:{start:c,end:c},newText:t.eol+d})}}const a=n.map(l=>{const h=l.start.line;let d=0,c=i.length-1;for(;d<=c;){const g=d+c>>>1,m=i[g];if(h<m.startLine)c=g-1;else if(h>m.endLine)d=g+1;else{d=g;break}}const u=Math.max(0,d<=c?d:c),f=i[u],p=r[u]+(e>0?f.endLine-f.startLine+1:0);return{start:{...l.start,line:l.start.line+p},end:{...l.end,line:l.end.line+p},direction:l.direction}});this.#Re(o,()=>a)}#At(){const e=this.#r,t=this.#i;if(e===void 0||t===void 0)return;const n=t.map(l=>ne(l).line),i=Array.from(new Set(n)).sort((l,h)=>l-h),r=new Map,s=new Map,o=[];for(let l=0;l<i.length;l++){const h=i[l],d=e.getLineText(h),c=/^\s*/.exec(d)?.[0]??"";r.set(h,l),s.set(h,c);const u={line:h,character:e.getLineLength(h)};o.push({range:{start:u,end:u},newText:e.eol+c})}const a=t.map((l,h)=>{const d=n[h],c={line:d+1+r.get(d),character:s.get(d).length};return{start:c,end:c,direction:0}});this.#Re(o,()=>a)}#Rt(e){const t=this.#r,n=this.#i;if(t===void 0||n===void 0)return;const i=as(n);if(i.length===0||e<0&&i[0].startLine===0||e>0&&i.at(-1).endLine>=t.lineCount-1)return;const r=t.lineCount,s=u=>u<r-1?{line:u+1,character:0}:{line:u,character:t.getLineLength(u)},o=(u,f)=>{const p=u.map(g=>t.getLineText(g)).join(t.eol);return f?p+t.eol:p},a=[];if(e<0)for(const u of i){const f=u.startLine-1,p=[];for(let g=u.startLine;g<=u.endLine;g++)p.push(g);a.push({range:{start:{line:f,character:0},end:s(u.endLine)},newText:o([...p,f],u.endLine<r-1)})}else for(let u=i.length-1;u>=0;u--){const f=i[u],p=f.endLine+1,g=[];for(let m=f.startLine;m<=f.endLine;m++)g.push(m);a.push({range:{start:{line:f.startLine,character:0},end:s(p)},newText:o([p,...g],p<r-1)})}const l=i.at(-1),h=e>0&&l.endLine===r-2?t.getLineLength(l.endLine):t.getLineLength(r-1),d=n.map(u=>Vu(u,e,r,f=>f===r-1?h:t.getLineLength(f))),c=t.applyEdits(a,!0,n,d,!0);c!==void 0&&this.#j(c,d)}#It=()=>{const e=this.#A?.length??0,t=this.#b,n=this.#v;this.#b=void 0,this.#v=void 0;const i=this.#oe()!==t,r=this.#We()!==n;!i&&!r||(this.#R.clear(),this.#S=void 0,this.#e.clearTextWidthCache(),r&&(this.#p.clear(),(this.#se||e>0)&&this.#w.clear()),(this.#i!==void 0||this.#J!==void 0||this.#y!==void 0)&&(this.#c(this.#i??[]),this.#i!==void 0&&this.#I&&this.focus()),this.#y?.removePopover(),this.#et(this.#h))};#Mt(){if(this.#De)return;const e=document.fonts;e!==void 0&&(this.#De=!0,e.ready.then(()=>{this.#h===void 0||!this.#e.remeasureCharacterWidth()||(this.#b=void 0,this.#v=void 0,this.#_e(),this.#p.clear(),(this.#i!==void 0||this.#J!==void 0||this.#y!==void 0)&&this.#c(this.#i??[]),this.#y?.removePopover())}))}#Ht(e,t,n=this.#$,i){const r=this.#s,s=this.#u,o=this.#r,a=this.#D,l=this.#h;if(r===void 0||s===void 0||o===void 0||l===void 0)return;r.stopBackgroundTokenize();const h=performance.now(),d=r.tokenize(e,n,!this.#te),c=performance.now();if(d.size>0){const f=l.children,p=new Set;for(const g of d.keys())this.#ye(g)&&p.add(g);for(let g=0;g<f.length;g++){const m=f[g];if(m!==void 0){const v=ue(m),S=m.dataset.lineType;if(v===void 0||S==="change-deletion")continue;const C=v-1;if(p.has(C)){const b=d.get(C);if(m.replaceChildren(...Zn(b)),p.delete(C),p.size===0)break}}}if(p.size>0){let g=0;for(let m=f.length-1;m>=0;m--){const v=f[m],S=ue(v);if(S!==void 0&&v.dataset.lineType!=="change-deletion"){g=S;break}}for(const m of p){if(m<g)continue;const v=d.get(m),S=String(m+1);W("div",{dataset:{line:S,lineType:"context",lineIndex:m.toString()},children:Zn(v)},l),a!==void 0&&W("div",{dataset:{lineType:"context",columnNumber:S,lineIndex:m.toString()},children:[W("span",{dataset:{lineNumberContent:""},textContent:S})]},a)}}}if(e.lineDelta<0)for(const f of[l.children,a?.children??[]])for(let p=f.length-1;p>=0;p--){const g=f[p],m=ue(g)??ue(g,"columnNumber"),v=g.dataset.lineType;if(!(m===void 0||v==="change-deletion")){if(m-1<e.lineCount)break;g.remove()}}const u=e.lineDelta!==0;if(u){let f=l.children.length;for(const p of l.children){const{bufferSize:g}=p.dataset;g!==void 0&&(f+=parseInt(g)-1)}l.style.gridRow="span "+f,a!==void 0&&(a.style.gridRow="span "+f)}s.updateRenderCache(d,r.themeType,{shouldRefreshDiffsView:this.#te&&!u,lineCountChangeInFlight:u}),u&&s.applyDocumentChange(o,t,i),(u||this.#te&&this.#we==="unified")&&this.#_e(),t!==void 0&&(this.#A=t,bu(t,l,a)),this.#t.__debug===!0&&console.log(`[diffs/editor] re-render in: ${lt(performance.now()-c)}ms,`,`tokenize in: ${lt(c-h)}ms (${d.size} dirty lines)`)}#tt(e,t){switch(e){case"insertText":{const n=t??"",i=this.#r,r=this.#i,s=i!==void 0&&r!==void 0?Pu(i,r,n,this.#t.autoSurround):void 0;this.#pe(s??n);break}case"insertCompositionText":break;case"insertLineBreak":case"insertParagraph":this.#pe(this.#r?.eol??`
1894
+ `);break;case"deleteContentBackward":this.#gt();break;case"deleteContentForward":this.#gt(!0);break;case"deleteSoftLineBackward":case"deleteHardLineBackward":this.#Wt();break;case"deleteWordBackward":this.#$t();break;case"insertTranspose":this.#jt();break;default:console.warn(`[diffs] Unknown input type: ${e}`,t);break}}#G(e,t=!0,n){this.#I=!0,e!==void 0?(this.#z=!0,this.#Le({start:e,end:e,direction:0}),Ye(()=>{if(n?.()===!1||!this.#I){this.#z=!1;return}this.#h?.focus({preventScroll:t}),Ye(()=>{this.#z=!1})})):n?.()!==!1?this.#h?.focus({preventScroll:t}):this.#I=!1}#Be(e){const t=this.#M;if(t==null)return;if(this.#ae){this.#M=void 0,this.#I=!1,this.#z=!1;return}const n=this.#h;if(n==null||!this.#nt(n)){this.#M=void 0,this.#I=!1;return}const i=()=>{if(this.#M!==t)return!1;const o=this.#nt(n);return this.#M=void 0,o};if(e!=null){this.#G(e,!0,i);return}const r=this.#i?.at(-1);if(r==null){this.#G(void 0,!0,i);return}const s=r.direction===-1?r.end:r.start;this.#G(s,!0,i)}#nt(e){const t=this.#L,n=t?.shadowRoot;if(t==null||n==null||this.#h!==e||!n.contains(e))return!1;const{activeElement:i}=n;if(i===e||i!=null&&e.contains(i))return!0;if(i!=null)return!1;const{ownerDocument:r}=t,{activeElement:s}=r;return s==null||s===r.body||s===r.documentElement||s===t}#Pt(e=0){const t=this.#h,n=this.#L;if(this.#r==null||t==null||n==null)return;const i=this.#Te();if(i===void 0)return;let r,s;if(i instanceof HTMLElement){const a=i.getBoundingClientRect();r=a.top,s=a.bottom}else r=0,s=i.defaultView?.innerHeight??0;const o=n.shadowRoot?.querySelector("[data-diffs-header][data-sticky]");if(o!=null&&(r=Math.max(r,o.getBoundingClientRect().bottom)),Number.isFinite(e)&&(r+=Math.max(0,e)),!(s<=r))for(const a of t.children){const l=a,h=ue(l),d=l.dataset.lineType;if(h==null||d==null||!yt(d))continue;const c=l.getBoundingClientRect();if(!(c.bottom<=c.top)&&c.top>=r&&c.top<s)return h}}#Ot(e,t){const n={start:e,end:e,direction:0};this.#N=!1,this.#c([n]),this.#le(e.line),t?this.#G(e,!0):this.#ne()}#Le(e){const t=window.getSelection();if(t===null)return;let{start:n,end:i,direction:r}=e;q(n,i)>0&&([n,i]=[i,n]);const s=this.#de(n.line),o=this.#de(i.line);if(s===void 0||o===void 0)return;let[a,l]=ds(s,n.character),[h,d]=ds(o,i.character);r===-1&&([a,l,h,d]=[h,d,a,l]);try{t.setBaseAndExtent(a,Jr(a,l),h,Jr(h,d))}catch(c){console.error("[diffs/editor] failed to update window selection:",c)}}#ne(e=!1,t="nearest"){const n=this.#i?.at(-1);if(n===void 0)return;const i=this.#Y;if(i!==void 0){if(i.scrollIntoView({block:t,inline:"nearest"}),!e){const r=n.direction===-1?n.end:n.start;this.#M!==void 0?this.#Be(r):this.#G(r)}}else{const r=ne(n);this.#Ve(r.line,r.character,e)}}#it(){const e=this.#O!==void 0?48:0,t=this.#oe()+this.#e.ch;return`${e}px ${this.#e.ch}px 0 ${t}px`}#Ve(e,t=0,n=!1){this.__postponeBgTokenizeToNextFrame();const i=W("div",{style:{position:"absolute",left:"0",width:"2px",height:this.#e.lineHeight+"px",scrollMargin:this.#it()}});if(this.#de(e)!==void 0){const[r,s]=this.#me(e,t),o=this.#ge(e)+s*this.#e.lineHeight;if(i.style.top=o+"px",i.style.left=r+"px",this.#W?.appendChild(i),i.scrollIntoView({block:"center",inline:"nearest"}),!n){const a={line:e,character:t};this.#M!==void 0?this.#Be(a):this.#G(a)}this.#ee=void 0,this.#he=void 0,this.#ke=!1,this.#ce=!1}else{const r=this.#u?.getLinePosition?.(e+1);if(r!==void 0)i.style.top=r.top+"px",this.#L?.shadowRoot?.appendChild(i),i.scrollIntoView({block:"center",inline:"nearest"}),r.height>0&&this.#ye(e)?(this.#ee=e,this.#he=t,this.#ce=n):(this.#ee=void 0,this.#he=void 0,this.#ce=!1);else{let s=0;if(this.#ee===e&&this.#h!==void 0)for(let a=this.#h.childElementCount-1;a>=0;a--){const l=this.#h.children[a],h=l.dataset.lineType,d=ue(l);if(h!==void 0&&yt(h)&&d!==void 0){s=(e-(d-1))*this.#e.lineHeight;break}}const o=((this.#A??[]).filter(a=>a.lineNumber<e).length+e)*this.#e.lineHeight+s;i.style.top=o+"px",this.#L?.shadowRoot?.appendChild(i),i.scrollIntoView({block:"center",inline:"nearest"}),this.#ee===e&&(s===0||this.#ke)||!this.#ye(e)?(this.#ee=void 0,this.#he=void 0,this.#ke=!1,this.#ce=!1):(this.#ee=e,this.#he=t,this.#ke=s!==0,this.#ce=n)}}i.remove()}#rt(e,t,n){const i=s=>({line:s,character:0}),r=s=>({line:s,character:n.getLineText(s).length});return t<e?{start:i(t),end:r(e),direction:-1}:{start:i(e),end:r(t),direction:1}}#Dt(e){const t=e.composedPath()[0];return t instanceof HTMLElement&&t.closest("[data-line]")?.getAttribute("data-line-type")==="change-deletion"}#st(e,t,n){const i=[...n.querySelectorAll("[data-content] > [data-line]")],r=i.indexOf(e),s=i.indexOf(t),[o,a]=s<r?[t,e]:[e,t],l=window.getSelection();if(l!==null){const c=document.createRange();c.setStart(o,0),c.setEnd(a,a.childNodes.length),l.removeAllRanges(),l.addRange(c)}this.#Ie(!0),this.#c([]),this.#xe(ue(t)??null,!0,"deletions");const h=Math.min(r,s),d=Math.max(r,s);this.#be=h<0?"":i.slice(h,d+1).filter(c=>c.getAttribute("data-line-type")==="change-deletion").map(c=>c.textContent??"").join(`
1895
+ `)}#ot(e,t){const n=e.parentElement;if(n==null||t==null)return;const i=[...n.children].indexOf(e),r=t.children[i];return r instanceof HTMLElement?r:void 0}#at(e,t,n){const i=t.querySelector("[data-content]"),r=this.#ot(e,i);return r===void 0?!1:(this.#st(r,r,t),n&&this.#Ne([G(document,"mousemove",s=>{const o=s.composedPath()[0],a=o instanceof HTMLElement?o.closest("[data-column-number]"):null;if(a instanceof HTMLElement&&t.contains(a)){const l=this.#ot(a,i);l!==void 0&&this.#st(r,l,t)}},{passive:!0})]),!0)}#lt(){return this.#L?.shadowRoot?.querySelector("pre")?.hasAttribute("data-deleted-text-selection")??!1}#dt(){return this.#be!==""?this.#be:window.getSelection()?.toString()??""}#Ie(e){const t=this.#L?.shadowRoot?.querySelector("pre");t!=null&&(e?(t.setAttribute("data-deleted-text-selection",""),this.#xe(null),this.#be=""):(t.removeAttribute("data-deleted-text-selection"),this.#be=""))}#xe(e,t=!1,n="additions"){try{this.#u?.setEditorActiveLine(e,{lineNumberOnly:t,side:n})}catch{}}#_t(){this.#ue===void 0&&(this.#ue=requestAnimationFrame(()=>{this.#ue=void 0,(this.#i!==void 0||this.#J!==void 0||this.#y!==void 0)&&this.#c(this.#i??[])}))}#c(e){if(this.__postponeBgTokenizeToNextFrame(),this.#Y=void 0,this.#xe(null),e.length===0&&this.#J===void 0&&this.#y===void 0){this.#i=void 0,this.#V?.forEach(r=>r.remove()),this.#V?.clear(),this.#F?.cleanup(),this.#F=void 0;return}const t=document.createDocumentFragment(),n={fragment:t,elements:new Map};if(e.length>0){const r=Mo(e),s=r.at(-1);this.#i=r;const o=r.some(h=>!Q(h)),a=ne(s).line+1;this.#xe(a,o);for(const h of r)Q(h)||this.#Me(n,"selection",h),this.#Nt(n,h,h===s);const l=this.#t.matchBrackets!==!1&&this.#r!==void 0&&this.#s!==void 0&&Q(s)?lf(this.#r,this.#s,s.start):void 0;if(l!==void 0)for(const h of l)this.#Me(n,"bracketMatch",h)}const i=this.#r;if(this.#J!==void 0&&i!==void 0){const r=this.#J,s=this.#$,o=s!==void 0&&Number.isFinite(s.totalLines)||this.#te&&this.#u?.options.expandUnchanged!==!0?this.#mt():void 0,a=this.#i?.at(-1),l=a!==void 0?i.offsetAt(a.start):-1,h=a!==void 0?i.offsetAt(a.end):-1;let d=0;const c=o?.length??1;for(let u=0;u<c;u++){let f=1/0;const p=o?.[u];if(p!==void 0){const[g,m]=p,v=i.offsetAt({line:g,character:0}),S=m+1;f=S<i.lineCount?i.offsetAt({line:S,character:0}):i.offsetAt({line:S-1,character:i.getLineLength(S-1)});let C=d,b=r.length;for(;C<b;){const y=C+Math.floor((b-C)/2);r[y][1]<=v?C=y+1:b=y}d=C}for(;d<r.length;d++){const[g,m]=r[d];if(g>=f)break;const v={start:i.positionAt(g),end:i.positionAt(m)},S=l===g&&h===m;this.#Me(n,"match",v,S?"focus":void 0)}}}if(this.#y!==void 0&&i!==void 0)for(const r of this.#y.markers)this.#Me(n,"marker",r,En(r.severity));this.#W?.appendChild(t),this.#V?.forEach(r=>r.remove()),this.#V?.clear(),this.#V=n.elements,this.#Ue()}#Me(e,t,n,i){if(this.#r===void 0)return;const{start:r,end:s}=n;let o=r.line,a=s.line+1;if(this.#$!==void 0){const{startingLine:l,totalLines:h}=this.#$;o=Math.max(o,l),a=Math.min(a,l+h)}for(let l=o;l<a;l++){if(!this.#He(l))continue;const h=l===s.line,d=l===r.line?r.character:0,c=h?s.character:this.#r.getLineLength(l);if(this.#se){const g=this.#We(),m=this.#r.getLineText(l);if(2*this.#e.ch+this.#e.measureTextWidth(m)>g){this.#Ft(e,l,m,d,c,h,t,i);continue}}let u=0,f=0,p=0;d===0?u=this.#oe()+this.#e.ch+(this.#fe?.left??0):u=this.#me(l,d)[0],!h&&t==="selection"&&(p=this.#e.ch),d===c?f=p:f=this.#me(l,c)[0]-u+p,this.#ct(e,t,l,0,u,f,i)}}#Ft(e,t,n,i,r,s,o,a){const l=this.#$e(t),h=l.length-1,d=this.#oe()+this.#e.ch+(this.#fe?.left??0);for(let c=0;c<h;c++){const u=l[c],f=l[c+1],p=Math.max(i,u),g=Math.min(r,f);if(p>g)continue;const m=this.#ht(n,u,p),v=d+m;let S=0;!s&&c===h-1&&o==="selection"&&(S=this.#e.ch);const C=p===g?S:this.#ht(n,u,g)-m+S;this.#ct(e,o,t,c,v,C,a)}}#ht(e,t,n){if(n<=t)return 0;const i=e.slice(t,n),r=hn(i,this.#e.tabSize);return r!==-1?r*this.#e.ch:this.#e.measureTextWidth(i)}#ct(e,t,n,i,r,s,o){if(s===0)return;const{ch:a,lineHeight:l}=this.#e,h=this.#ge(n)+i*l,d=`${t}-${n}/${i}-${r}-${s} ${o??""}`,c=this.#V,u=(this.#t.roundedSelection??!0)&&t==="selection",f=(m,v,S,C)=>{const b=this.#ge(m)+v*l,y=this.#de(m);let L="initial";y!==void 0&&(y.dataset.lineType==="change-addition"||y.dataset.selectedLine!==void 0)&&(L=getComputedStyle(y).getPropertyValue("--diffs-line-bg"));const k=`width:${a}px;transform:translateX(${S}px) translateY(${b}px);--diffs-selection-corner-bg:${L}`,E={selectionCorner:"",[C]:""},x=`${t}-block-${m}/${v}-${S}-1ch`;let w=x+"-"+C;if(C==="rbl"){const T=x+"-rtl",R=e.elements.get(T);R!==void 0&&(R.remove(),e.elements.delete(T),w+="-rtl",E.rtl="")}let O=e.elements.get(w);O===void 0&&(c?.has(w)===!0?(O=c.get(w),O.style.cssText=k,c.delete(w)):O=W("div",{dataset:"selectionRange",style:{cssText:k},children:[W("div",{dataset:E})]},e.fragment),e.elements.set(w,O))},p=m=>{const v=r+s,S=m.dataset,C=e.previousSelectionRange;if((C===void 0||C.line!==n||C.wrapLine!==i)&&(e.previousSelectionRange={element:m,line:n,wrapLine:i,left:r,width:s}),C===void 0||v<=C.left)["rtl","rtr","rbl","rbr"].forEach(b=>{S[b]=""});else{const b=C.line,y=C.wrapLine,L=C.left,k=C.element.dataset,E=L+C.width;L>r&&f(b,y,L-a,"rbr"),delete k.rbl,delete S.rtl,delete S.rtr,v>=E&&delete k.rbr,v>E&&(f(b,y,E,"rbl"),S.rtr=""),v<E&&f(n,i,v,"rtl"),r<L&&(S.rtl=""),S.rbl="",S.rbr=""}};let g=e.elements.get(d);if(g!==void 0){u&&p(g);return}c?.has(d)===!0?(g=c.get(d),c.delete(d)):g=W("div",{dataset:o?[t+"Range",o]:t+"Range"},e.fragment),g.style.width=`${s}px`,g.style.transform=`translateX(${r}px) translateY(${h}px)`,u&&p(g),e.elements.set(d,g)}#Nt(e,t,n){const{line:i,character:r}=ne(t);if(!this.#He(i))return;const[s,o]=this.#me(i,r),a="caret-"+i+"/"+o+":"+r;if(e.elements.has(a))return;const l=W("div",{dataset:"caret",style:{transform:`translateX(${s-1}px) translateY(${this.#ge(i)+o*this.#e.lineHeight}px)`}},e.fragment);e.elements.set(a,l),n&&(l.style.scrollMargin=this.#it(),this.#Y=l)}#Ue(){const e=this.#i?.at(-1),t=this.#W,n=this.#r,i=this.#t.renderSelectionAction,r=()=>{this.#F?.cleanup(),this.#F=void 0};if(this.#t.enabledSelectionAction!==!0||i===void 0||e===void 0||Q(e)||this.#re||t===void 0||n===void 0){r();return}const s=ne(e);if(!this.#He(s.line)){r();return}if(this.#F===void 0){if(!this.#N)return;const x=()=>this.#i?.at(-1)??e,w=i({textDocument:n,get selection(){return x()},applyEdits:O=>this.applyEdits(O),getSelectionText:()=>this.#r?.getText(x())??"",replaceSelectionText:O=>{this.#pe(O,[x()])},close:()=>{r(),this.#ne()}});this.#F=new yf(w,t,()=>this.#Ue()),this.#Ee().resetPlacement(Qn)}const o=this.#e.lineHeight,a=e.direction===-1,l={placeAbove:a,anchor:s},h=a?{placeAbove:!1,anchor:e.end}:{placeAbove:!0,anchor:e.start},d=this.#F.height,c=x=>{const[w,O]=this.#me(x.anchor.line,x.anchor.character),T=this.#ge(x.anchor.line)+O*o,R=x.placeAbove?T:T+o,_=x.placeAbove?R-d:R;return{top:_,bottom:_+d,left:w,anchorTop:R,rowTop:T}},u=c(l),f=n.lineCount,p=a?s.line<3:s.line>=f-3,g=this.#He(h.anchor.line)?c(h):void 0,m=this.#Ee(),v=m.getPlacementBounds(),S=g!==void 0&&m.choosePlacement({preferred:u,fallback:g,viewport:v,popoverHeight:d,atDocumentEdge:p,placementKey:Qn})==="fallback";g===void 0&&m.setPlacement("preferred",Qn);const{placeAbove:C}=S?h:l,{left:b,anchorTop:y}=S&&g!==void 0?g:u,L=a?u.rowTop:g?.rowTop??-1/0,k=(a?g?.rowTop??1/0:u.rowTop)+(e.end.line>e.start.line&&e.end.character===0?0:o),E=v===void 0||k>v.top&&L<v.bottom;this.#F.reposition(b,y,this.#oe(),C,E,v)}#ut(e){if(this.#O!==void 0){this.#O.setMode(e);return}this.#zt(e)}#zt(e){this.#O?.cleanup();const t=this.#r,n=this.#L?.shadowRoot?.querySelector("pre"),i=this.#i;if(t===void 0||n==null)return;let r="",s;if(i!==void 0&&i.length>0){let l=i.at(-1);if(Q(l)){l=Ti(t,l),this.#c([...i.slice(0,-1),l]);const h=t.getText(l);h!==""&&!h.includes(`
1896
+ `)&&(r=h,s=[t.offsetAt(l.start),t.offsetAt(l.end)])}}const o=([l,h],d)=>{const c=ji(t,l,h);this.#c([c]),this.#le(ne(c).line),this.#ne(!0),this.#ae=d},a=new Cf({textDocument:t,containerElement:n,defaultQuery:r,mode:e,initialMatch:s,scrollToMatch:o,applyReplace:l=>{if(l.length===0)return;const h=t.applyEdits(l.map(d=>({range:{start:t.positionAt(d.start),end:t.positionAt(d.end)},newText:d.text})),!0,this.#i);h!==void 0&&this.#j(h,void 0,this.#ie(h),{skipSearchRefresh:!0})},onUpdate:(l,h)=>{if(l.length===0){this.#J=void 0,this.#c(this.#i??[]);return}if(this.#J=l,h?.syncSelection===!1){this.#c(this.#i??[]);const f=this.#i?.at(-1);if(f!==void 0){const p=t.offsetAt(f.start),g=t.offsetAt(f.end);for(const m of l)if(m[0]===p&&m[1]===g)return m}return}const d=this.#i?.at(-1);let c=0,u;d!==void 0&&(c=t.offsetAt(d.start));for(const f of l)if(f[0]>=c){u=f;break}return u!==void 0?o(u,!0):this.#c(this.#i??[]),u},onClose:()=>{this.#O=void 0,this.#ae=!1,this.#J=void 0,this.#c(this.#i??[])}});this.#O=a,this.#ae=!1}#Bt(){const e=this.#r,t=this.#i;return e===void 0||t===void 0?"":Ei(e,t)}#ft(){const e=this.#r,t=this.#i;return e===void 0||t===void 0?[]:Gu(e,t)}#pt(e,t,n){e!==null&&(e.setData("text",t),n.length>1&&e.setData(ei,JSON.stringify(n)))}#Vt(){const e=this.#r,t=this.#i;if(e===void 0||t===void 0||t.length===0)return"";if(t.some(i=>Q(i))){const i=Xu(e,t);return this.#Ut(i.edits,i.nextSelectionOffsets),i.text}const n=Ei(e,t);return this.#pe("",void 0,!0),n}#Ut(e,t){const n=this.#r,i=this.#i;if(n===void 0||i===void 0||e.length===0)return;const r=n.applyResolvedEdits(e,!0,i,void 0,!0);if(r===void 0)return;const s=t.map(o=>{const a=n.positionAt(o);return{start:a,end:a,direction:0}});n.setLastUndoSelectionsAfter(s),this.#j(r,s,this.#ie(r))}#pe(e,t=this.#i,n=!1,i="selection"){if(t===void 0)return;const r=this.#r,s=t.at(-1);if(r===void 0||s===void 0)return;const{nextSelections:o,change:a}=Array.isArray(e)&&e.length===t.length?_t(r,t,e,this.#A,n,i):Ru(r,t,{start:r.offsetAt(s.start),end:r.offsetAt(s.end),text:Array.isArray(e)?e.join(r.eol):e},this.#A,void 0,n);a!==void 0&&this.#j(a,o,this.#ie(a))}#gt(e=!1){const t=this.#i,n=this.#r;if(t===void 0||n===void 0)return;const{nextSelections:i,change:r}=zu(n,t,e,this.#A,this.#e.tabSize);r!==void 0&&this.#j(r,i,this.#ie(r))}#Wt(){const e=this.#i,t=this.#r;if(e===void 0||t===void 0)return;const{nextSelections:n,change:i}=_u(t,e,this.#se?(r,s)=>{const o=this.#$e(r);for(let a=0;a+1<o.length;a++){const l=o[a],h=o[a+1];if(s>=l&&s<=h)return l}return 0}:void 0,this.#A);i!==void 0&&this.#j(i,n,this.#ie(i))}#$t(){const e=this.#i,t=this.#r;if(e===void 0||t===void 0)return;const{nextSelections:n,change:i}=Fu(t,e,this.#A);i!==void 0&&this.#j(i,n,this.#ie(i))}#Gt(){const e=this.#i,t=this.#r;if(e===void 0||t===void 0)return;const{nextSelections:n,change:i}=Du(t,e,this.#A);i!==void 0&&this.#j(i,n,this.#ie(i))}#jt(){const e=this.#i,t=this.#r;if(e===void 0||t===void 0)return;const{nextSelections:n,change:i}=Ou(t,e,this.#A);i!==void 0&&this.#j(i,n,this.#ie(i))}#j(e,t,n,i){const r=this.getFile(),s=this.#t.onChange;if(r!==void 0&&s!==void 0){const l=n??this.#A;s(r,l,{changes:e.changes,file:r,lineAnnotations:l})}if(e.lineDelta!==0||this.#se)for(const l of this.#w.keys())l>=e.startLine&&this.#w.delete(l);if(this.#p.size>0)if(e.lineDelta===0&&(e.changedLineRanges.length===1||e.changedLineChanges?.every(([,,l])=>l===0)===!0))for(const[l,h]of e.changedLineRanges)for(let d=l;d<=h;d++)this.#p.delete(d);else for(const l of this.#p.keys())l>=e.startLine&&this.#p.delete(l);this.#S=void 0;let o=this.#$,a;if(o!==void 0&&t!==void 0&&t.length>0){const l=t.at(-1),h=o.startingLine+o.totalLines;if(l.end.line>=h){const d=l.end.line-o.startingLine+1,c=this.#Q===void 0||this.#Q===1/0?1/0:this.#Q*_f;e.startLine<=h&&d<=c&&this.#ye(l.end.line)?(l.end.line>h&&(a=!0),o={...o,totalLines:d},this.#$=o):a=!0}}if(this.#Ht(e,n,o,a),i?.skipSearchRefresh!==!0&&this.#O!==void 0&&this.#J!==void 0&&this.#O.updateMatches({syncSelection:!1}),t!==void 0&&(this.#c(t),i?.skipFocus!==!0)){const l=t.at(-1);if(l!==void 0&&this.#le(ne(l).line),this.#Y!==void 0)requestAnimationFrame(()=>{this.#Y?.scrollIntoView({block:"nearest",inline:"nearest"})});else if(t.length>0){const h=ne(t.at(-1));this.#Ve(h.line,h.character)}this.focus({preventScroll:!0})}}#ie(e){if(this.#A!==void 0){const t=Mn(e,this.#A);if(t!==void 0)return this.#r?.setLastUndoLineAnnotations(this.#A,t),t}}#mt(){const e=this.#h;if(e===void 0)return[];const t=[];for(const n of e.children){const i=n,r=i.dataset.lineType,s=ue(i);if(s===void 0||r===void 0||!yt(r))continue;const o=s-1,a=t.at(-1);a!==void 0&&o<=a[1]+1?a[1]=Math.max(a[1],o):t.push([o,o])}return t}#de(e){let t=this.#R.get(e);if(t!==void 0)return t??void 0;const n=this.#$;if(n!==void 0&&(e<n.startingLine||e>=n.startingLine+n.totalLines))return;const i=this.#h;if(i!==void 0){if(n!==void 0){const{startingLine:r}=n,{children:s}=i;for(let o=e-r;o<=s.length;o++){const a=s[o];if(a===void 0)break;const l=ue(a),h=a.dataset.lineType;if(l!==void 0&&l===e+1&&h!==void 0&&yt(h)){t=a;break}}}return t??=i.querySelector(`[data-line="${e+1}"]`+(this.#we==="unified"?':not([data-line-type="change-deletion"])':"")),t!==void 0&&this.#R.set(e,t),t??void 0}}#oe(){if(this.#D===void 0)return 0;if(this.#b===void 0){const e=this.#h?.parentElement?.style.getPropertyValue("--diffs-column-number-width");e!==void 0&&e.length>2&&e.endsWith("px")?this.#b=parseInt(e.slice(0,-2),10):this.#b=this.#D.offsetWidth}return this.#b}#We(){if(this.#h===void 0)return 0;if(this.#v===void 0){const e=this.#h.parentElement?.style.getPropertyValue("--diffs-column-content-width");e!==void 0&&e.length>2&&e.endsWith("px")?this.#v=parseFloat(e.slice(0,-2)):this.#v=this.#h.offsetWidth}return this.#v}#ge(e){const t=this.#w.get(e);if(t!==void 0)return t;const n=this.#de(e);if(n===void 0)return-1;let i=n.offsetTop+this.#e.paddingTop;return i+=this.#fe?.top??0,this.#w.set(e,i),i}#me(e,t){if(this.#S!==void 0&&this.#S[0]===e&&this.#S[1]===t)return[this.#S[2],this.#S[3]];const n=this.#r?.getLineText(e),i=this.#oe()+this.#e.ch;if(n===void 0||n.length===0||t<=0)return[i+(this.#fe?.left??0),0];const r=Mf(n,Math.min(t,n.length)),s=n.slice(0,r),o=hn(s,this.#e.tabSize);let a=0,l=0;if(o!==-1?a=i+o*this.#e.ch:a=i+this.#e.measureTextWidth(s),this.#se){const h=this.#We();if(2*this.#e.ch+this.#e.measureTextWidth(n)>h){const d=this.#vt(e);if(d==null)return[a+(this.#fe?.left??0),0];for(let c=0;c+1<d.length;c++){const u=d[c];if(r<=d[c+1]){l=c;const f=n.slice(u,r),p=hn(f,this.#e.tabSize);p!==-1?a=i+p*this.#e.ch:a=i+this.#e.measureTextWidth(f);break}}}a+=this.#fe?.left??0}return this.#S!==void 0?(this.#S[0]=e,this.#S[1]=t,this.#S[2]=a,this.#S[3]=l):this.#S=[e,t,a,l],[a,l]}#vt(e){const t=this.#p.get(e);if(t!==void 0)return t;this.#p.size>=Ff&&this.#p.clear();const n=this.#r?.getLineText(e);if(n===void 0||n.length===0){const l=new Uint32Array([0]);return this.#p.set(e,l),l}const i=this.#h;if(i==null||!i.isConnected)return;const r=W("div",{style:{position:"absolute",top:"0",left:"0",width:"100%",boxSizing:"border-box",visibility:"hidden",pointerEvents:"none",whiteSpace:"pre-wrap",wordBreak:"break-word",font:"inherit",paddingInline:"1ch",tabSize:this.#e.tabSize.toString()},textContent:n},i),s=r.firstChild,o=document.createRange(),a=[];try{const l=r.getBoundingClientRect();if(l.width===0)return;const h=Hf(n),d=l.left+this.#e.ch,c=h===void 0?n.length:h.length-1,u=v=>h===void 0?v:h[v],f=v=>(o.setStart(s,u(v)),o.setEnd(s,u(v+1)),o.getBoundingClientRect());a.push(0);let p=f(0).top,g=1;for(;g<c;){let v=g,S=c;for(;v<S;){const L=v+S>>1;f(L).top>p?S=L:v=L+1}if(v>=c)break;const{left:C,top:b}=f(v),y=yn()&&C-d>this.#e.ch/2;a.push(u(y?v-1:v)),p=b,g=v+1}const m=new Uint32Array(a.length+1);for(let v=0;v<a.length;v++)m[v]=a[v];return m[a.length]=n.length,this.#p.set(e,m),m}finally{r.remove()}}#$e(e){const t=this.#vt(e);if(t!==void 0)return t;const n=this.#r?.getLineText(e)?.length??0;return Uint32Array.of(0,n)}#Kt({startContainer:e,endContainer:t}){const n=this.#h;return n===void 0?!1:n.contains(e)&&n.contains(t)}#He(e){const t=this.#r?.lineCount??0;return e<0||e>=t?!1:this.#de(e)!==void 0}};const zf=`
1897
+ :host {
1898
+ --diffs-font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
1899
+ --diffs-font-size: 12px;
1900
+ --diffs-line-height: 20px;
1901
+ display: block;
1902
+ min-height: 100%;
1903
+ background: var(--background);
1904
+ }
1905
+ [data-file] { min-height: 100%; }
1906
+ `;function Uf({name:e,path:t,content:n,editable:i=!1,onChange:r}){const s=Y.useRef(r);s.current=r;const o=Y.useRef(n),a=Y.useRef(t);a.current!==t&&(a.current=t,o.current=n);const l=Y.useCallback(h=>new Nf(h),[]);return j.jsx("div",{className:"h-full overflow-hidden bg-background","data-artifact-code-view":t,children:j.jsx(Go,{createEditor:l,children:j.jsx(Ac,{className:"h-full overflow-auto",disableWorkerPool:!0,items:[{id:t,type:"file",file:{name:e,contents:i?o.current:n,cacheKey:t},edit:i}],onItemEditChange:(h,d)=>{typeof d.contents=="string"&&s.current?.(d.contents)},options:{theme:{light:"github-light",dark:"github-dark"},disableFileHeader:!0,overflow:"wrap",unsafeCSS:zf}})})})}export{Uf as ArtifactCodeView};