dimcode-web 0.0.0-stage → 0.1.0-alpha.11

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 (218) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +13 -4
  3. package/release-manifest.json +227 -0
  4. package/web/assets/CodeBlockNode-BExJacPr.js +43 -0
  5. package/web/assets/PreCodeBlock-CS3fZBao.js +1 -0
  6. package/web/assets/Tooltip-B1Jun8pl.js +1 -0
  7. package/web/assets/andromeeda-C4gqWexZ.js +1 -0
  8. package/web/assets/angular-html-BpR8Pn47.js +1 -0
  9. package/web/assets/arc-oZVymZ-6.js +1 -0
  10. package/web/assets/architectureDiagram-3BPJPVTR-Bdsx3Rrl.js +36 -0
  11. package/web/assets/aurora-x-D-2ljcwZ.js +1 -0
  12. package/web/assets/ayu-dark-DYE7WIF3.js +1 -0
  13. package/web/assets/ayu-light-BA47KaF1.js +1 -0
  14. package/web/assets/ayu-mirage-32ctXXKs.js +1 -0
  15. package/web/assets/blockDiagram-GPEHLZMM-BK2IeRUA.js +132 -0
  16. package/web/assets/c-BIGW1oBm.js +1 -0
  17. package/web/assets/c4Diagram-AAUBKEIU-DMleCZQv.js +10 -0
  18. package/web/assets/catppuccin-frappe-DFWUc33u.js +1 -0
  19. package/web/assets/catppuccin-latte-C9dUb6Cb.js +1 -0
  20. package/web/assets/catppuccin-macchiato-DQyhUUbL.js +1 -0
  21. package/web/assets/catppuccin-mocha-D87Tk5Gz.js +1 -0
  22. package/web/assets/channel-DGamL3Zm.js +1 -0
  23. package/web/assets/chunk-2J33WTMH-DqhOMsnJ.js +1 -0
  24. package/web/assets/chunk-4BX2VUAB-eVCJx28A.js +1 -0
  25. package/web/assets/chunk-55IACEB6-DEbLCIoP.js +1 -0
  26. package/web/assets/chunk-727SXJPM-GwPb-eQY.js +206 -0
  27. package/web/assets/chunk-AQP2D5EJ-BFlYl-9N.js +231 -0
  28. package/web/assets/chunk-FMBD7UC4-5QtzaUQO.js +15 -0
  29. package/web/assets/chunk-ND2GUHAM-CySCSlmy.js +1 -0
  30. package/web/assets/chunk-QZHKN3VN-DNkBno1P.js +1 -0
  31. package/web/assets/classDiagram-4FO5ZUOK-nWhIUIyS.js +1 -0
  32. package/web/assets/classDiagram-v2-Q7XG4LA2-nWhIUIyS.js +1 -0
  33. package/web/assets/cmake-D1j8_8rp.js +1 -0
  34. package/web/assets/cose-bilkent-S5V4N54A-Cqajiw-2.js +1 -0
  35. package/web/assets/cpp-B-lmv-kZ.js +1 -0
  36. package/web/assets/csharp-COcwbKMJ.js +1 -0
  37. package/web/assets/css-DPfMkruS.js +1 -0
  38. package/web/assets/csv-fuZLfV_i.js +1 -0
  39. package/web/assets/cynefin-OW5HDTMX-CGp-_RPy.js +178 -0
  40. package/web/assets/cytoscape.esm-Ix0LnXOy.js +331 -0
  41. package/web/assets/dagre-BM42HDAG-BScsLv8J.js +4 -0
  42. package/web/assets/dark-plus-C3mMm8J8.js +1 -0
  43. package/web/assets/defaultLocale-DX6XiGOO.js +1 -0
  44. package/web/assets/diagram-2AECGRRQ-e16PRdi7.js +43 -0
  45. package/web/assets/diagram-5GNKFQAL-DuWJHiuL.js +10 -0
  46. package/web/assets/diagram-KO2AKTUF-C1E0cLdw.js +3 -0
  47. package/web/assets/diagram-LMA3HP47-CyF5HRCw.js +24 -0
  48. package/web/assets/diagram-OG6HWLK6-aUfbCvvL.js +24 -0
  49. package/web/assets/diff-D97Zzqfu.js +1 -0
  50. package/web/assets/docker-BcOcwvcX.js +1 -0
  51. package/web/assets/dracula-BzJJZx-M.js +1 -0
  52. package/web/assets/dracula-soft-BXkSAIEj.js +1 -0
  53. package/web/assets/elixir-CDX3lj18.js +1 -0
  54. package/web/assets/erDiagram-TEJ5UH35-DnVqKEfD.js +85 -0
  55. package/web/assets/erlang-DsQrWhSR.js +1 -0
  56. package/web/assets/everforest-dark-BgDCqdQA.js +1 -0
  57. package/web/assets/everforest-light-C8M2exoo.js +1 -0
  58. package/web/assets/extended-p72mFE2C.js +1 -0
  59. package/web/assets/floating-ui.dom-rMPa4aDr.js +1 -0
  60. package/web/assets/flowDiagram-I6XJVG4X-00TiWiHH.js +162 -0
  61. package/web/assets/ganttDiagram-6RSMTGT7-DhmsSHDy.js +292 -0
  62. package/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  63. package/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  64. package/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  65. package/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  66. package/web/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
  67. package/web/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
  68. package/web/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
  69. package/web/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
  70. package/web/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
  71. package/web/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
  72. package/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  73. package/web/assets/gitGraphDiagram-PVQCEYII-DebPzL-q.js +106 -0
  74. package/web/assets/github-dark-DHJKELXO.js +1 -0
  75. package/web/assets/github-dark-default-Cuk6v7N8.js +1 -0
  76. package/web/assets/github-dark-dimmed-DH5Ifo-i.js +1 -0
  77. package/web/assets/github-dark-high-contrast-E3gJ1_iC.js +1 -0
  78. package/web/assets/github-light-DAi9KRSo.js +1 -0
  79. package/web/assets/github-light-default-D7oLnXFd.js +1 -0
  80. package/web/assets/github-light-high-contrast-BfjtVDDH.js +1 -0
  81. package/web/assets/go-CxLEBnE3.js +1 -0
  82. package/web/assets/graph-CAnANduQ.js +1 -0
  83. package/web/assets/graphql-ChdNCCLP.js +1 -0
  84. package/web/assets/groovy-gcz8RCvz.js +1 -0
  85. package/web/assets/gruvbox-dark-hard-CFHQjOhq.js +1 -0
  86. package/web/assets/gruvbox-dark-medium-GsRaNv29.js +1 -0
  87. package/web/assets/gruvbox-dark-soft-CVdnzihN.js +1 -0
  88. package/web/assets/gruvbox-light-hard-CH1njM8p.js +1 -0
  89. package/web/assets/gruvbox-light-medium-DRw_LuNl.js +1 -0
  90. package/web/assets/gruvbox-light-soft-hJgmCMqR.js +1 -0
  91. package/web/assets/haskell-Df6bDoY_.js +1 -0
  92. package/web/assets/hcl-BWvSN4gD.js +1 -0
  93. package/web/assets/horizon-BUw7H-hv.js +1 -0
  94. package/web/assets/horizon-bright-Cn-bp-IR.js +1 -0
  95. package/web/assets/houston-DnULxvSX.js +1 -0
  96. package/web/assets/html-GMplVEZG.js +1 -0
  97. package/web/assets/index-B0sf41uB.js +329 -0
  98. package/web/assets/index-D6IZb5kR.css +1 -0
  99. package/web/assets/index-RWtzc3nz.js +220 -0
  100. package/web/assets/index-Zlr3P937.js +220 -0
  101. package/web/assets/index10-DMROqqrK.js +8 -0
  102. package/web/assets/index5-A4hqyBCh.js +1 -0
  103. package/web/assets/index6-gqTWHimn.js +1 -0
  104. package/web/assets/index8-Jm7D2Uuu.js +2 -0
  105. package/web/assets/index9-DhsBkPMm.js +1 -0
  106. package/web/assets/infoDiagram-5YYISTIA-BlWEgGgR.js +2 -0
  107. package/web/assets/ini-BEwlwnbL.js +1 -0
  108. package/web/assets/init-Gi6I4Gst.js +1 -0
  109. package/web/assets/ishikawaDiagram-YF4QCWOH-D2U9WN2D.js +70 -0
  110. package/web/assets/java-CylS5w8V.js +1 -0
  111. package/web/assets/javascript-wDzz0qaB.js +1 -0
  112. package/web/assets/journeyDiagram-JHISSGLW-CKb3VgZk.js +139 -0
  113. package/web/assets/json-Cp-IABpG.js +1 -0
  114. package/web/assets/json5-C9tS-k6U.js +1 -0
  115. package/web/assets/jsonc-Des-eS-w.js +1 -0
  116. package/web/assets/jsx-g9-lgVsj.js +1 -0
  117. package/web/assets/kanagawa-dragon-CkXjmgJE.js +1 -0
  118. package/web/assets/kanagawa-lotus-CfQXZHmo.js +1 -0
  119. package/web/assets/kanagawa-wave-DWedfzmr.js +1 -0
  120. package/web/assets/kanban-definition-UN3LZRKU-CtxT87gS.js +89 -0
  121. package/web/assets/katex-C5jXJg4s.js +257 -0
  122. package/web/assets/kotlin-BdnUsdx6.js +1 -0
  123. package/web/assets/laserwave-DUszq2jm.js +1 -0
  124. package/web/assets/latex-CR2LgHuU.js +1 -0
  125. package/web/assets/layout-DGIYPm2g.js +1 -0
  126. package/web/assets/layout-DloY-SLW.js +4 -0
  127. package/web/assets/light-plus-B7mTdjB0.js +1 -0
  128. package/web/assets/linear-Ddk7u-wL.js +1 -0
  129. package/web/assets/lua-BaeVxFsk.js +1 -0
  130. package/web/assets/make-CHLpvVh8.js +1 -0
  131. package/web/assets/markdown-Cvjx9yec.js +1 -0
  132. package/web/assets/markstream-B2Peo11i.js +7 -0
  133. package/web/assets/material-theme-D5KoaKCx.js +1 -0
  134. package/web/assets/material-theme-darker-BfHTSMKl.js +1 -0
  135. package/web/assets/material-theme-lighter-B0m2ddpp.js +1 -0
  136. package/web/assets/material-theme-ocean-CyktbL80.js +1 -0
  137. package/web/assets/material-theme-palenight-Csfq5Kiy.js +1 -0
  138. package/web/assets/mermaid.core-CIDPCsfA.js +309 -0
  139. package/web/assets/mhchem-MNFFEueS.js +1 -0
  140. package/web/assets/min-dark-CafNBF8u.js +1 -0
  141. package/web/assets/min-light-CTRr51gU.js +1 -0
  142. package/web/assets/mindmap-definition-RKZ34NQL-veskSkgC.js +96 -0
  143. package/web/assets/monokai-D4h5O-jR.js +1 -0
  144. package/web/assets/nginx-BpAMiNFr.js +1 -0
  145. package/web/assets/night-owl-C39BiMTA.js +1 -0
  146. package/web/assets/night-owl-light-CMTm3GFP.js +1 -0
  147. package/web/assets/nord-Ddv68eIx.js +1 -0
  148. package/web/assets/objective-c-DXmwc3jG.js +1 -0
  149. package/web/assets/one-dark-pro-DVMEJ2y_.js +1 -0
  150. package/web/assets/one-light-C3Wv6jpd.js +1 -0
  151. package/web/assets/ordinal-Cboi1Yqb.js +1 -0
  152. package/web/assets/perl-C0TMdlhV.js +1 -0
  153. package/web/assets/php-Dhbhpdrm.js +1 -0
  154. package/web/assets/pieDiagram-4H26LBE5-BOU-b_Ew.js +30 -0
  155. package/web/assets/pierre-dark-CyvmCCZW.js +1 -0
  156. package/web/assets/pierre-dark-protanopia-deuteranopia-Rgc0TwpF.js +1 -0
  157. package/web/assets/pierre-dark-soft-BHGpRqa4.js +1 -0
  158. package/web/assets/pierre-dark-tritanopia-Beq2gCRQ.js +1 -0
  159. package/web/assets/pierre-dark-vibrant-BWBVywrn.js +1 -0
  160. package/web/assets/pierre-light-480U9XYS.js +1 -0
  161. package/web/assets/pierre-light-protanopia-deuteranopia-CaVOBURG.js +1 -0
  162. package/web/assets/pierre-light-soft-CVdyfjmI.js +1 -0
  163. package/web/assets/pierre-light-tritanopia-B4_gpKOM.js +1 -0
  164. package/web/assets/pierre-light-vibrant-DdTDNdfJ.js +1 -0
  165. package/web/assets/plastic-3e1v2bzS.js +1 -0
  166. package/web/assets/poimandres-CS3Unz2-.js +1 -0
  167. package/web/assets/powershell-Dpen1YoG.js +1 -0
  168. package/web/assets/preCodeDiffMetrics-6xZ6qvnP.js +1 -0
  169. package/web/assets/proto-C7zT0LnQ.js +1 -0
  170. package/web/assets/python-B6aJPvgy.js +1 -0
  171. package/web/assets/quadrantDiagram-W4KKPZXB-BSS1N1TF.js +7 -0
  172. package/web/assets/r-Dspwwk_N.js +1 -0
  173. package/web/assets/red-bN70gL4F.js +1 -0
  174. package/web/assets/regexp-CDVJQ6XC.js +1 -0
  175. package/web/assets/requirementDiagram-4Y6WPE33-DsN8PjFw.js +84 -0
  176. package/web/assets/rose-pine-dawn-DHQR4-dF.js +1 -0
  177. package/web/assets/rose-pine-moon-D4_iv3hh.js +1 -0
  178. package/web/assets/rose-pine-qdsjHGoJ.js +1 -0
  179. package/web/assets/ruby-BymL1q8G.js +1 -0
  180. package/web/assets/rust-B1yitclQ.js +1 -0
  181. package/web/assets/sankeyDiagram-5OEKKPKP-CnW7IbtR.js +40 -0
  182. package/web/assets/scala-C151Ov-r.js +1 -0
  183. package/web/assets/scss-OYdSNvt2.js +1 -0
  184. package/web/assets/sequenceDiagram-3UESZ5HK-DrDAXqp6.js +162 -0
  185. package/web/assets/shellscript-Yzrsuije.js +1 -0
  186. package/web/assets/slack-dark-BthQWCQV.js +1 -0
  187. package/web/assets/slack-ochin-DqwNpetd.js +1 -0
  188. package/web/assets/snazzy-light-Bw305WKR.js +1 -0
  189. package/web/assets/solarized-dark-DXbdFlpD.js +1 -0
  190. package/web/assets/solarized-light-L9t79GZl.js +1 -0
  191. package/web/assets/sql-BLtJtn59.js +1 -0
  192. package/web/assets/stateDiagram-AJRCARHV-DlPqWlqf.js +1 -0
  193. package/web/assets/stateDiagram-v2-BHNVJYJU-bvuvx9tw.js +1 -0
  194. package/web/assets/svelte-DZMnMd3x.js +1 -0
  195. package/web/assets/swift-D82vCrfD.js +1 -0
  196. package/web/assets/synthwave-84-CbfX1IO0.js +1 -0
  197. package/web/assets/timeline-definition-PNZ67QCA-DpzLLOwj.js +120 -0
  198. package/web/assets/tokyo-night-hegEt444.js +1 -0
  199. package/web/assets/toml-vGWfd6FD.js +1 -0
  200. package/web/assets/tsx-COt5Ahok.js +1 -0
  201. package/web/assets/typescript-BPQ3VLAy.js +1 -0
  202. package/web/assets/unused-optional-NNwleJvF.js +1 -0
  203. package/web/assets/vendor-vue-C21-5sm4.js +53 -0
  204. package/web/assets/vennDiagram-CIIHVFJN-BFiOUoie.js +34 -0
  205. package/web/assets/vesper-DU1UobuO.js +1 -0
  206. package/web/assets/vitesse-black-Bkuqu6BP.js +1 -0
  207. package/web/assets/vitesse-dark-D0r3Knsf.js +1 -0
  208. package/web/assets/vitesse-light-CVO1_9PV.js +1 -0
  209. package/web/assets/vue-DVfSmUF7.js +1 -0
  210. package/web/assets/wardleyDiagram-YWT4CUSO-CF-vWJdt.js +78 -0
  211. package/web/assets/xml-sdJ4AIDG.js +1 -0
  212. package/web/assets/xychartDiagram-2RQKCTM6-ko8fvtbV.js +7 -0
  213. package/web/assets/yaml-Buea-lGh.js +1 -0
  214. package/web/assets/zh-CN-Ctd5q_Jn.js +1 -0
  215. package/web/assets/zig-VOosw3JB.js +1 -0
  216. package/web/dimcode-web.json +5 -0
  217. package/web/index.html +44 -0
  218. package/README.md +0 -3
@@ -0,0 +1,329 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-BpR8Pn47.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/cpp-B-lmv-kZ.js","assets/regexp-CDVJQ6XC.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/elixir-CDX3lj18.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/graphql-ChdNCCLP.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/latex-CR2LgHuU.js","assets/r-Dspwwk_N.js","assets/lua-BaeVxFsk.js","assets/nginx-BpAMiNFr.js","assets/perl-C0TMdlhV.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/php-Dhbhpdrm.js","assets/json-Cp-IABpG.js","assets/ruby-BymL1q8G.js","assets/shellscript-Yzrsuije.js","assets/yaml-Buea-lGh.js","assets/scss-OYdSNvt2.js","assets/svelte-DZMnMd3x.js","assets/vue-DVfSmUF7.js"])))=>i.map(i=>d[i]);
2
+ var Vc=Object.defineProperty;var Gc=Object.getPrototypeOf;var Wc=Reflect.get;var ro=t=>{throw TypeError(t)};var jc=(t,e,n)=>e in t?Vc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var g=(t,e,n)=>jc(t,typeof e!="symbol"?e+"":e,n),lr=(t,e,n)=>e.has(t)||ro("Cannot "+n);var ge=(t,e,n)=>(lr(t,e,"read from private field"),n?n.call(t):e.get(t)),kt=(t,e,n)=>e.has(t)?ro("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),ze=(t,e,n,i)=>(lr(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),dr=(t,e,n)=>(lr(t,e,"access private method"),n);var so=(t,e,n)=>Wc(Gc(t),n,e);import{_ as L}from"./index-Zlr3P937.js";import"./vendor-vue-C21-5sm4.js";const al="diffs-container",qc=(()=>{try{return!1}catch{return!1}})(),Kc=/(?=^From [a-f0-9]+ .+$)/m,ll=/(?=^diff --git)/gm,cS=/(?=^---\s+\S)/gm,uS=/(?=^@@ )/gm,Xc=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: (.*))?/m,Yc=new RegExp("(?<=\\n)"),Qc=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Zc=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,hS=/^<{7,}(?:\s.*)?$/,fS=/^\|{7,}(?:\s.*)?$/,pS=/^={7,}$/,gS=/^>{7,}(?:\s.*)?$/,ws="header-prefix",xs="header-filename-suffix",ks="header-metadata",Ls="header-custom",j={dark:"pierre-dark",light:"pierre-light"},dl="data-theme-css",cl="data-unsafe-css",Jc="data-core-css",eu="data-diffs-scrollbar-measure",tu="data-diffs-code-view-header",nu="data-diffs-code-view-footer",ul="--diffs-scrollbar-gutter-measured",mS=1,iu=1e5,Es={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},mn={...Es,hunkLineCount:1},ru={paddingTop:8,paddingBottom:8,gap:8},su={omega:.015,positionEpsilon:.5,velocityEpsilon:.05},ou=Object.freeze({fromStart:0,fromEnd:0}),Jt={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},hl={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},wt=new Map,cr=new Map,Gr=new Map,Ri=new Set;function An(t){for(const e of Array.isArray(t)?t:[t])if(!(e==="text"||e==="ansi")&&!Ri.has(e))return!1;return!0}function oo(t,e){t=Array.isArray(t)?t:[t];for(const n of t){if(Ri.has(n.name))continue;let i=wt.get(n.name);i==null&&(i=n,wt.set(n.name,i));const r=i.data.find(s=>{var o;return s.name===i.name||((o=s.aliases)==null?void 0:o.includes(i.name))===!0});if(r==null)throw new Error(`attachResolvedLanguages: No returned grammar declares "${i.name}" as its name or an alias.`);e.loadLanguageSync(i.data);try{e.getLanguage(i.name)}catch{throw new Error(`attachResolvedLanguages: "${r.name}" is already loaded without alias "${i.name}". Load the alias first or give the grammar a unique name.`)}Ri.add(i.name)}}function au(){wt.clear(),Ri.clear()}function fl(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}let J=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function lu(t){return Rs(t)}function Rs(t){return Array.isArray(t)?du(t):t instanceof RegExp?t:typeof t=="object"?cu(t):t}function du(t){let e=[];for(let n=0,i=t.length;n<i;n++)e[n]=Rs(t[n]);return e}function cu(t){let e={};for(let n in t)e[n]=Rs(t[n]);return e}function pl(t,...e){return e.forEach(n=>{for(let i in n)t[i]=n[i]}),t}function gl(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?gl(t.substring(0,t.length-1)):t.substr(~e+1)}var ur=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Kn=class{static hasCaptures(t){return t===null?!1:(ur.lastIndex=0,ur.test(t))}static replaceCaptures(t,e,n){return t.replace(ur,(i,r,s,o)=>{let l=n[parseInt(r||s,10)];if(l){let a=e.substring(l.start,l.end);for(;a[0]===".";)a=a.substring(1);switch(o){case"downcase":return a.toLowerCase();case"upcase":return a.toUpperCase();default:return a}}else return i})}};function ml(t,e){return t<e?-1:t>e?1:0}function yl(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,i=e.length;if(n===i){for(let r=0;r<n;r++){let s=ml(t[r],e[r]);if(s!==0)return s}return 0}return n-i}function ao(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function vl(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Cl=class{constructor(t){g(this,"cache",new Map);this.fn=t}get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},_i=class{constructor(t,e,n){g(this,"_cachedMatchRoot",new Cl(t=>this._root.match(t)));this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(fu(t),e)}static createFromParsedTheme(t,e){return gu(t,e)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,i=this._cachedMatchRoot.get(e).find(r=>uu(t.parent,r.parentScopes));return i?new Sl(i.fontStyle,i.foreground,i.background):null}},hr=class vi{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const i of n)e=new vi(e,i);return e}static from(...e){let n=null;for(let i=0;i<e.length;i++)n=new vi(n,e[i]);return n}push(e){return new vi(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let i=this;for(;i&&i!==e;)n.push(i.scopeName),i=i.parent;return i===e?n.reverse():void 0}};function uu(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let i=e[n],r=!1;if(i===">"){if(n===e.length-1)return!1;i=e[++n],r=!0}for(;t&&!hu(t.scopeName,i);){if(r)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function hu(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var Sl=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function fu(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],i=0;for(let r=0,s=e.length;r<s;r++){let o=e[r];if(!o.settings)continue;let l;if(typeof o.scope=="string"){let u=o.scope;u=u.replace(/^[,]+/,""),u=u.replace(/[,]+$/,""),l=u.split(",")}else Array.isArray(o.scope)?l=o.scope:l=[""];let a=-1;if(typeof o.settings.fontStyle=="string"){a=0;let u=o.settings.fontStyle.split(" ");for(let h=0,f=u.length;h<f;h++)switch(u[h]){case"italic":a=a|1;break;case"bold":a=a|2;break;case"underline":a=a|4;break;case"strikethrough":a=a|8;break}}let d=null;typeof o.settings.foreground=="string"&&ao(o.settings.foreground)&&(d=o.settings.foreground);let c=null;typeof o.settings.background=="string"&&ao(o.settings.background)&&(c=o.settings.background);for(let u=0,h=l.length;u<h;u++){let p=l[u].trim().split(" "),y=p[p.length-1],v=null;p.length>1&&(v=p.slice(0,p.length-1),v.reverse()),n[i++]=new pu(y,v,r,a,d,c)}}return n}var pu=class{constructor(t,e,n,i,r,s){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=i,this.foreground=r,this.background=s}},fe=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(fe||{});function gu(t,e){t.sort((a,d)=>{let c=ml(a.scope,d.scope);return c!==0||(c=yl(a.parentScopes,d.parentScopes),c!==0)?c:a.index-d.index});let n=0,i="#000000",r="#ffffff";for(;t.length>=1&&t[0].scope==="";){let a=t.shift();a.fontStyle!==-1&&(n=a.fontStyle),a.foreground!==null&&(i=a.foreground),a.background!==null&&(r=a.background)}let s=new mu(e),o=new Sl(n,s.getId(i),s.getId(r)),l=new vu(new Wr(0,null,-1,0,0),[]);for(let a=0,d=t.length;a<d;a++){let c=t[a];l.insert(0,c.scope,c.parentScopes,c.fontStyle,s.getId(c.foreground),s.getId(c.background))}return new _i(s,o,l)}var mu=class{constructor(t){g(this,"_isFrozen");g(this,"_lastColorId");g(this,"_id2color");g(this,"_color2id");if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},yu=Object.freeze([]),Wr=class bl{constructor(e,n,i,r,s){g(this,"scopeDepth");g(this,"parentScopes");g(this,"fontStyle");g(this,"foreground");g(this,"background");this.scopeDepth=e,this.parentScopes=n||yu,this.fontStyle=i,this.foreground=r,this.background=s}clone(){return new bl(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let i=0,r=e.length;i<r;i++)n[i]=e[i].clone();return n}acceptOverwrite(e,n,i,r){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),i!==0&&(this.foreground=i),r!==0&&(this.background=r)}},vu=class jr{constructor(e,n=[],i={}){g(this,"_rulesWithParentScopes");this._mainRule=e,this._children=i,this._rulesWithParentScopes=n}static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let i=0,r=0;for(;e.parentScopes[i]===">"&&i++,n.parentScopes[r]===">"&&r++,!(i>=e.parentScopes.length||r>=n.parentScopes.length);){const s=n.parentScopes[r].length-e.parentScopes[i].length;if(s!==0)return s;i++,r++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let i=e.indexOf("."),r,s;if(i===-1?(r=e,s=""):(r=e.substring(0,i),s=e.substring(i+1)),this._children.hasOwnProperty(r))return this._children[r].match(s)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(jr._cmpBySpecificity),n}insert(e,n,i,r,s,o){if(n===""){this._doInsertHere(e,i,r,s,o);return}let l=n.indexOf("."),a,d;l===-1?(a=n,d=""):(a=n.substring(0,l),d=n.substring(l+1));let c;this._children.hasOwnProperty(a)?c=this._children[a]:(c=new jr(this._mainRule.clone(),Wr.cloneArr(this._rulesWithParentScopes)),this._children[a]=c),c.insert(e+1,d,i,r,s,o)}_doInsertHere(e,n,i,r,s){if(n===null){this._mainRule.acceptOverwrite(e,i,r,s);return}for(let o=0,l=this._rulesWithParentScopes.length;o<l;o++){let a=this._rulesWithParentScopes[o];if(yl(a.parentScopes,n)===0){a.acceptOverwrite(e,i,r,s);return}}i===-1&&(i=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new Wr(e,n,i,r,s))}},en=class De{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=De.getLanguageId(e),i=De.getTokenType(e),r=De.getFontStyle(e),s=De.getForeground(e),o=De.getBackground(e);console.log({languageId:n,tokenType:i,fontStyle:r,foreground:s,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,i,r,s,o,l){let a=De.getLanguageId(e),d=De.getTokenType(e),c=De.containsBalancedBrackets(e)?1:0,u=De.getFontStyle(e),h=De.getForeground(e),f=De.getBackground(e);return n!==0&&(a=n),i!==8&&(d=i),r!==null&&(c=r?1:0),s!==-1&&(u=s),o!==0&&(h=o),l!==0&&(f=l),(a<<0|d<<8|c<<10|u<<11|h<<15|f<<24)>>>0}};function Ti(t,e){const n=[],i=Cu(t);let r=i.next();for(;r!==null;){let a=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":a=1;break;case"L":a=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=i.next()}let d=o();if(n.push({matcher:d,priority:a}),r!==",")break;r=i.next()}return n;function s(){if(r==="-"){r=i.next();const a=s();return d=>!!a&&!a(d)}if(r==="("){r=i.next();const a=l();return r===")"&&(r=i.next()),a}if(lo(r)){const a=[];do a.push(r),r=i.next();while(lo(r));return d=>e(a,d)}return null}function o(){const a=[];let d=s();for(;d;)a.push(d),d=s();return c=>a.every(u=>u(c))}function l(){const a=[];let d=o();for(;d&&(a.push(d),r==="|"||r===",");){do r=i.next();while(r==="|"||r===",");d=o()}return c=>a.some(u=>u(c))}}function lo(t){return!!t&&!!t.match(/[\w\.:]+/)}function Cu(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const i=n[0];return n=e.exec(t),i}}}function wl(t){typeof t.dispose=="function"&&t.dispose()}var Pn=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},Su=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},bu=class{constructor(){g(this,"_references",[]);g(this,"_seenReferenceKeys",new Set);g(this,"visitedRule",new Set)}get references(){return this._references}add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},wu=class{constructor(t,e){g(this,"seenFullScopeRequests",new Set);g(this,"seenPartialScopeRequests",new Set);g(this,"Q");this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Pn(this.initialScopeName)]}processQueue(){const t=this.Q;this.Q=[];const e=new bu;for(const n of t)xu(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof Pn){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function xu(t,e,n,i){const r=n.lookup(t.scopeName);if(!r){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const s=n.lookup(e);t instanceof Pn?Ci({baseGrammar:s,selfGrammar:r},i):qr(t.ruleName,{baseGrammar:s,selfGrammar:r,repository:r.repository},i);const o=n.injections(t.scopeName);if(o)for(const l of o)i.add(new Pn(l))}function qr(t,e,n){if(e.repository&&e.repository[t]){const i=e.repository[t];Ii([i],e,n)}}function Ci(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&Ii(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&Ii(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Ii(t,e,n){for(const i of t){if(n.visitedRule.has(i))continue;n.visitedRule.add(i);const r=i.repository?pl({},e.repository,i.repository):e.repository;Array.isArray(i.patterns)&&Ii(i.patterns,{...e,repository:r},n);const s=i.include;if(!s)continue;const o=xl(s);switch(o.kind){case 0:Ci({...e,selfGrammar:e.baseGrammar},n);break;case 1:Ci(e,n);break;case 2:qr(o.ruleName,{...e,repository:r},n);break;case 3:case 4:const l=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(l){const a={baseGrammar:e.baseGrammar,selfGrammar:l,repository:r};o.kind===4?qr(o.ruleName,a,n):Ci(a,n)}else o.kind===4?n.add(new Su(o.scopeName,o.ruleName)):n.add(new Pn(o.scopeName));break}}}var ku=class{constructor(){g(this,"kind",0)}},Lu=class{constructor(){g(this,"kind",1)}},Eu=class{constructor(t){g(this,"kind",2);this.ruleName=t}},Ru=class{constructor(t){g(this,"kind",3);this.scopeName=t}},_u=class{constructor(t,e){g(this,"kind",4);this.scopeName=t,this.ruleName=e}};function xl(t){if(t==="$base")return new ku;if(t==="$self")return new Lu;const e=t.indexOf("#");if(e===-1)return new Ru(t);if(e===0)return new Eu(t.substring(1));{const n=t.substring(0,e),i=t.substring(e+1);return new _u(n,i)}}var Tu=/\\(\d+)/,co=/\\(\d+)/g,Iu=-1,kl=-2;var Wn=class{constructor(t,e,n,i){g(this,"$location");g(this,"id");g(this,"_nameIsCapturing");g(this,"_name");g(this,"_contentNameIsCapturing");g(this,"_contentName");this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=Kn.hasCaptures(this._name),this._contentName=i||null,this._contentNameIsCapturing=Kn.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${gl(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:Kn.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Kn.replaceCaptures(this._contentName,t,e)}},Au=class extends Wn{constructor(e,n,i,r,s){super(e,n,i,r);g(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,n){throw new Error("Not supported!")}compile(e,n){throw new Error("Not supported!")}compileAG(e,n,i,r){throw new Error("Not supported!")}},Pu=class extends Wn{constructor(e,n,i,r,s){super(e,n,i,null);g(this,"_match");g(this,"captures");g(this,"_cachedCompiledPatterns");this._match=new Mn(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,n){n.push(this._match)}compile(e,n){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,n,i,r){return this._getCachedCompiledPatterns(e).compileAG(e,i,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Dn,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},uo=class extends Wn{constructor(e,n,i,r,s){super(e,n,i,r);g(this,"hasMissingPatterns");g(this,"patterns");g(this,"_cachedCompiledPatterns");this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,n){for(const i of this.patterns)e.getRule(i).collectPatterns(e,n)}compile(e,n){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,n,i,r){return this._getCachedCompiledPatterns(e).compileAG(e,i,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Dn,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Kr=class extends Wn{constructor(e,n,i,r,s,o,l,a,d,c){super(e,n,i,r);g(this,"_begin");g(this,"beginCaptures");g(this,"_end");g(this,"endHasBackReferences");g(this,"endCaptures");g(this,"applyEndPatternLast");g(this,"hasMissingPatterns");g(this,"patterns");g(this,"_cachedCompiledPatterns");this._begin=new Mn(s,this.id),this.beginCaptures=o,this._end=new Mn(l||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=d||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,n){return this._end.resolveBackReferences(e,n)}collectPatterns(e,n){n.push(this._begin)}compile(e,n){return this._getCachedCompiledPatterns(e,n).compile(e)}compileAG(e,n,i,r){return this._getCachedCompiledPatterns(e,n).compileAG(e,i,r)}_getCachedCompiledPatterns(e,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Dn;for(const i of this.patterns)e.getRule(i).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,n):this._cachedCompiledPatterns.setSource(0,n)),this._cachedCompiledPatterns}},Ai=class extends Wn{constructor(e,n,i,r,s,o,l,a,d){super(e,n,i,r);g(this,"_begin");g(this,"beginCaptures");g(this,"whileCaptures");g(this,"_while");g(this,"whileHasBackReferences");g(this,"hasMissingPatterns");g(this,"patterns");g(this,"_cachedCompiledPatterns");g(this,"_cachedCompiledWhilePatterns");this._begin=new Mn(s,this.id),this.beginCaptures=o,this.whileCaptures=a,this._while=new Mn(l,kl),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=d.patterns,this.hasMissingPatterns=d.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,n){return this._while.resolveBackReferences(e,n)}collectPatterns(e,n){n.push(this._begin)}compile(e,n){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,n,i,r){return this._getCachedCompiledPatterns(e).compileAG(e,i,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Dn;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,n){return this._getCachedCompiledWhilePatterns(e,n).compile(e)}compileWhileAG(e,n,i,r){return this._getCachedCompiledWhilePatterns(e,n).compileAG(e,i,r)}_getCachedCompiledWhilePatterns(e,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Dn,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},Ll=class ce{static createCaptureRule(e,n,i,r,s){return e.registerRule(o=>new Au(n,o,i,r,s))}static getCompiledRuleId(e,n,i){return e.id||n.registerRule(r=>{if(e.id=r,e.match)return new Pu(e.$vscodeTextmateLocation,e.id,e.name,e.match,ce._compileCaptures(e.captures,n,i));if(typeof e.begin>"u"){e.repository&&(i=pl({},i,e.repository));let s=e.patterns;return typeof s>"u"&&e.include&&(s=[{include:e.include}]),new uo(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,ce._compilePatterns(s,n,i))}return e.while?new Ai(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,ce._compileCaptures(e.beginCaptures||e.captures,n,i),e.while,ce._compileCaptures(e.whileCaptures||e.captures,n,i),ce._compilePatterns(e.patterns,n,i)):new Kr(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,ce._compileCaptures(e.beginCaptures||e.captures,n,i),e.end,ce._compileCaptures(e.endCaptures||e.captures,n,i),e.applyEndPatternLast,ce._compilePatterns(e.patterns,n,i))}),e.id}static _compileCaptures(e,n,i){let r=[];if(e){let s=0;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const l=parseInt(o,10);l>s&&(s=l)}for(let o=0;o<=s;o++)r[o]=null;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const l=parseInt(o,10);let a=0;e[o].patterns&&(a=ce.getCompiledRuleId(e[o],n,i)),r[l]=ce.createCaptureRule(n,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,a)}}return r}static _compilePatterns(e,n,i){let r=[];if(e)for(let s=0,o=e.length;s<o;s++){const l=e[s];let a=-1;if(l.include){const d=xl(l.include);switch(d.kind){case 0:case 1:a=ce.getCompiledRuleId(i[l.include],n,i);break;case 2:let c=i[d.ruleName];c&&(a=ce.getCompiledRuleId(c,n,i));break;case 3:case 4:const u=d.scopeName,h=d.kind===4?d.ruleName:null,f=n.getExternalGrammar(u,i);if(f)if(h){let p=f.repository[h];p&&(a=ce.getCompiledRuleId(p,n,f.repository))}else a=ce.getCompiledRuleId(f.repository.$self,n,f.repository);break}}else a=ce.getCompiledRuleId(l,n,i);if(a!==-1){const d=n.getRule(a);let c=!1;if((d instanceof uo||d instanceof Kr||d instanceof Ai)&&d.hasMissingPatterns&&d.patterns.length===0&&(c=!0),c)continue;r.push(a)}}return{patterns:r,hasMissingPatterns:(e?e.length:0)!==r.length}}},Mn=class El{constructor(e,n){g(this,"source");g(this,"ruleId");g(this,"hasAnchor");g(this,"hasBackReferences");g(this,"_anchorCache");if(e&&typeof e=="string"){const i=e.length;let r=0,s=[],o=!1;for(let l=0;l<i;l++)if(e.charAt(l)==="\\"&&l+1<i){const d=e.charAt(l+1);d==="z"?(s.push(e.substring(r,l)),s.push("$(?!\\n)(?<!\\n)"),r=l+2):(d==="A"||d==="G")&&(o=!0),l++}this.hasAnchor=o,r===0?this.source=e:(s.push(e.substring(r,i)),this.source=s.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=Tu.test(this.source):this.hasBackReferences=!1}clone(){return new El(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let i=n.map(r=>e.substring(r.start,r.end));return co.lastIndex=0,this.source.replace(co,(r,s)=>vl(i[parseInt(s,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],i=[],r=[],s,o,l,a;for(s=0,o=this.source.length;s<o;s++)l=this.source.charAt(s),e[s]=l,n[s]=l,i[s]=l,r[s]=l,l==="\\"&&s+1<o&&(a=this.source.charAt(s+1),a==="A"?(e[s+1]="￿",n[s+1]="￿",i[s+1]="A",r[s+1]="A"):a==="G"?(e[s+1]="￿",n[s+1]="G",i[s+1]="￿",r[s+1]="G"):(e[s+1]=a,n[s+1]=a,i[s+1]=a,r[s+1]=a),s++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:i.join(""),A1_G1:r.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Dn=class{constructor(){g(this,"_items");g(this,"_hasAnchors");g(this,"_cached");g(this,"_anchorCache");this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new ho(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let i=this._items.map(r=>r.resolveAnchors(e,n));return new ho(t,i,this._items.map(r=>r.ruleId))}},ho=class{constructor(t,e,n){g(this,"scanner");this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
3
+ `)}findNextMatchSync(t,e,n){const i=this.scanner.findNextMatchSync(t,e,n);return i?{ruleId:this.rules[i.index],captureIndices:i.captureIndices}:null}},fr=class{constructor(t,e){this.languageId=t,this.tokenType=e}},st,Mu=(st=class{constructor(e,n){g(this,"_defaultAttributes");g(this,"_embeddedLanguagesMatcher");g(this,"_getBasicScopeAttributes",new Cl(e=>{const n=this._scopeToLanguage(e),i=this._toStandardTokenType(e);return new fr(n,i)}));this._defaultAttributes=new fr(e,8),this._embeddedLanguagesMatcher=new Du(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?st._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(st.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}},g(st,"_NULL_SCOPE_METADATA",new fr(0,0)),g(st,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),st),Du=class{constructor(t){g(this,"values");g(this,"scopesRegExp");if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([n,i])=>vl(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},fo=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function Rl(t,e,n,i,r,s,o,l){const a=e.content.length;let d=!1,c=-1;if(o){const f=Hu(t,e,n,i,r,s);r=f.stack,i=f.linePos,n=f.isFirstLine,c=f.anchorPosition}const u=Date.now();for(;!d;){if(l!==0&&Date.now()-u>l)return new fo(r,!0);h()}return new fo(r,!1);function h(){const f=Ou(t,e,n,i,r,c);if(!f){s.produce(r,a),d=!0;return}const p=f.captureIndices,y=f.matchedRuleId,v=p&&p.length>0?p[0].end>i:!1;if(y===Iu){const m=r.getRule(t);s.produce(r,p[0].start),r=r.withContentNameScopesList(r.nameScopesList),wn(t,e,n,r,s,m.endCaptures,p),s.produce(r,p[0].end);const C=r;if(r=r.parent,c=C.getAnchorPos(),!v&&C.getEnterPos()===i){r=C,s.produce(r,a),d=!0;return}}else{const m=t.getRule(y);s.produce(r,p[0].start);const C=r,S=m.getName(e.content,p),w=r.contentNameScopesList.pushAttributed(S,t);if(r=r.push(y,i,c,p[0].end===a,null,w,w),m instanceof Kr){const b=m;wn(t,e,n,r,s,b.beginCaptures,p),s.produce(r,p[0].end),c=p[0].end;const k=b.getContentName(e.content,p),x=w.pushAttributed(k,t);if(r=r.withContentNameScopesList(x),b.endHasBackReferences&&(r=r.withEndRule(b.getEndWithResolvedBackReferences(e.content,p))),!v&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,a),d=!0;return}}else if(m instanceof Ai){const b=m;wn(t,e,n,r,s,b.beginCaptures,p),s.produce(r,p[0].end),c=p[0].end;const k=b.getContentName(e.content,p),x=w.pushAttributed(k,t);if(r=r.withContentNameScopesList(x),b.whileHasBackReferences&&(r=r.withEndRule(b.getWhileWithResolvedBackReferences(e.content,p))),!v&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,a),d=!0;return}}else if(wn(t,e,n,r,s,m.captures,p),s.produce(r,p[0].end),r=r.pop(),!v){r=r.safePop(),s.produce(r,a),d=!0;return}}p[0].end>i&&(i=p[0].end,n=!1)}}function Hu(t,e,n,i,r,s){let o=r.beginRuleCapturedEOL?0:-1;const l=[];for(let a=r;a;a=a.pop()){const d=a.getRule(t);d instanceof Ai&&l.push({rule:d,stack:a})}for(let a=l.pop();a;a=l.pop()){const{ruleScanner:d,findOptions:c}=$u(a.rule,t,a.stack.endRule,n,i===o),u=d.findNextMatchSync(e,i,c);if(u){if(u.ruleId!==kl){r=a.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(s.produce(a.stack,u.captureIndices[0].start),wn(t,e,n,a.stack,s,a.rule.whileCaptures,u.captureIndices),s.produce(a.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>i&&(i=u.captureIndices[0].end,n=!1))}else{r=a.stack.pop();break}}return{stack:r,linePos:i,anchorPosition:o,isFirstLine:n}}function Ou(t,e,n,i,r,s){const o=Nu(t,e,n,i,r,s),l=t.getInjections();if(l.length===0)return o;const a=Fu(l,t,e,n,i,r,s);if(!a)return o;if(!o)return a;const d=o.captureIndices[0].start,c=a.captureIndices[0].start;return c<d||a.priorityMatch&&c===d?a:o}function Nu(t,e,n,i,r,s){const o=r.getRule(t),{ruleScanner:l,findOptions:a}=_l(o,t,r.endRule,n,i===s),d=l.findNextMatchSync(e,i,a);return d?{captureIndices:d.captureIndices,matchedRuleId:d.ruleId}:null}function Fu(t,e,n,i,r,s,o){let l=Number.MAX_VALUE,a=null,d,c=0;const u=s.contentNameScopesList.getScopeNames();for(let h=0,f=t.length;h<f;h++){const p=t[h];if(!p.matcher(u))continue;const y=e.getRule(p.ruleId),{ruleScanner:v,findOptions:m}=_l(y,e,null,i,r===o),C=v.findNextMatchSync(n,r,m);if(!C)continue;const S=C.captureIndices[0].start;if(!(S>=l)&&(l=S,a=C.captureIndices,d=C.ruleId,c=p.priority,l===r))break}return a?{priorityMatch:c===-1,captureIndices:a,matchedRuleId:d}:null}function _l(t,e,n,i,r){return{ruleScanner:t.compileAG(e,n,i,r),findOptions:0}}function $u(t,e,n,i,r){return{ruleScanner:t.compileWhileAG(e,n,i,r),findOptions:0}}function wn(t,e,n,i,r,s,o){if(s.length===0)return;const l=e.content,a=Math.min(s.length,o.length),d=[],c=o[0].end;for(let u=0;u<a;u++){const h=s[u];if(h===null)continue;const f=o[u];if(f.length===0)continue;if(f.start>c)break;for(;d.length>0&&d[d.length-1].endPos<=f.start;)r.produceFromScopes(d[d.length-1].scopes,d[d.length-1].endPos),d.pop();if(d.length>0?r.produceFromScopes(d[d.length-1].scopes,f.start):r.produce(i,f.start),h.retokenizeCapturedWithRuleId){const y=h.getName(l,o),v=i.contentNameScopesList.pushAttributed(y,t),m=h.getContentName(l,o),C=v.pushAttributed(m,t),S=i.push(h.retokenizeCapturedWithRuleId,f.start,-1,!1,null,v,C),w=t.createOnigString(l.substring(0,f.end));Rl(t,w,n&&f.start===0,f.start,S,r,!1,0),wl(w);continue}const p=h.getName(l,o);if(p!==null){const v=(d.length>0?d[d.length-1].scopes:i.contentNameScopesList).pushAttributed(p,t);d.push(new zu(v,f.end))}}for(;d.length>0;)r.produceFromScopes(d[d.length-1].scopes,d[d.length-1].endPos),d.pop()}var zu=class{constructor(t,e){g(this,"scopes");g(this,"endPos");this.scopes=t,this.endPos=e}};function Uu(t,e,n,i,r,s,o,l){return new Vu(t,e,n,i,r,s,o,l)}function po(t,e,n,i,r){const s=Ti(e,Pi),o=Ll.getCompiledRuleId(n,i,r.repository);for(const l of s)t.push({debugSelector:e,matcher:l.matcher,ruleId:o,grammar:r,priority:l.priority})}function Pi(t,e){if(e.length<t.length)return!1;let n=0;return t.every(i=>{for(let r=n;r<e.length;r++)if(Bu(e[r],i))return n=r+1,!0;return!1})}function Bu(t,e){if(!t)return!1;if(t===e)return!0;const n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var Vu=class{constructor(t,e,n,i,r,s,o,l){g(this,"_rootId");g(this,"_lastRuleId");g(this,"_ruleId2desc");g(this,"_includedGrammars");g(this,"_grammarRepository");g(this,"_grammar");g(this,"_injections");g(this,"_basicScopeAttributesProvider");g(this,"_tokenTypeMatchers");if(this._rootScopeName=t,this.balancedBracketSelectors=s,this._onigLib=l,this._basicScopeAttributesProvider=new Mu(n,i),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=go(e,null),this._injections=null,this._tokenTypeMatchers=[],r)for(const a of Object.keys(r)){const d=Ti(a,Pi);for(const c of d)this._tokenTypeMatchers.push({matcher:c.matcher,type:r[a]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const t of this._ruleId2desc)t&&t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){const t={lookup:r=>r===this._rootScopeName?this._grammar:this.getExternalGrammar(r),injections:r=>this._grammarRepository.injections(r)},e=[],n=this._rootScopeName,i=t.lookup(n);if(i){const r=i.injections;if(r)for(let o in r)po(e,o,r[o],this,i);const s=this._grammarRepository.injections(n);s&&s.forEach(o=>{const l=this.getExternalGrammar(o);if(l){const a=l.injectionSelector;a&&po(e,a,l,this,l)}})}return e.sort((r,s)=>r.priority-s.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(t){const e=++this._lastRuleId,n=t(e);return this._ruleId2desc[e]=n,n}getRule(t){return this._ruleId2desc[t]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];if(this._grammarRepository){const n=this._grammarRepository.lookup(t);if(n)return this._includedGrammars[t]=go(n,e&&e.$base),this._includedGrammars[t]}}tokenizeLine(t,e,n=0){const i=this._tokenize(t,e,!1,n);return{tokens:i.lineTokens.getResult(i.ruleStack,i.lineLength),ruleStack:i.ruleStack,stoppedEarly:i.stoppedEarly}}tokenizeLine2(t,e,n=0){const i=this._tokenize(t,e,!0,n);return{tokens:i.lineTokens.getBinaryResult(i.ruleStack,i.lineLength),ruleStack:i.ruleStack,stoppedEarly:i.stoppedEarly}}_tokenize(t,e,n,i){this._rootId===-1&&(this._rootId=Ll.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!e||e===Xr.NULL){r=!0;const d=this._basicScopeAttributesProvider.getDefaultAttributes(),c=this.themeProvider.getDefaults(),u=en.set(0,d.languageId,d.tokenType,null,c.fontStyle,c.foregroundId,c.backgroundId),h=this.getRule(this._rootId).getName(null,null);let f;h?f=Rn.createRootAndLookUpScopeName(h,u,this):f=Rn.createRoot("unknown",u),e=new Xr(null,this._rootId,-1,-1,!1,null,f,f)}else r=!1,e.reset();t=t+`
4
+ `;const s=this.createOnigString(t),o=s.content.length,l=new Wu(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),a=Rl(this,s,r,0,e,l,!0,i);return wl(s),{lineLength:o,lineTokens:l,ruleStack:a.stack,stoppedEarly:a.stoppedEarly}}};function go(t,e){return t=lu(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var Rn=class Ke{constructor(e,n,i){this.parent=e,this.scopePath=n,this.tokenAttributes=i}static fromExtension(e,n){let i=e,r=(e==null?void 0:e.scopePath)??null;for(const s of n)r=hr.push(r,s.scopeNames),i=new Ke(i,r,s.encodedTokenAttributes);return i}static createRoot(e,n){return new Ke(null,new hr(null,e),n)}static createRootAndLookUpScopeName(e,n,i){const r=i.getMetadataForScope(e),s=new hr(null,e),o=i.themeProvider.themeMatch(s),l=Ke.mergeAttributes(n,r,o);return new Ke(null,s,l)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return Ke.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,i){let r=-1,s=0,o=0;return i!==null&&(r=i.fontStyle,s=i.foregroundId,o=i.backgroundId),en.set(e,n.languageId,n.tokenType,null,r,s,o)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return Ke._pushAttributed(this,e,n);const i=e.split(/ /g);let r=this;for(const s of i)r=Ke._pushAttributed(r,s,n);return r}static _pushAttributed(e,n,i){const r=i.getMetadataForScope(n),s=e.scopePath.push(n),o=i.themeProvider.themeMatch(s),l=Ke.mergeAttributes(e.tokenAttributes,r,o);return new Ke(e,s,l)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){var r;const n=[];let i=this;for(;i&&i!==e;)n.push({encodedTokenAttributes:i.tokenAttributes,scopeNames:i.scopePath.getExtensionIfDefined(((r=i.parent)==null?void 0:r.scopePath)??null)}),i=i.parent;return i===e?n.reverse():void 0}},He,Xr=(He=class{constructor(e,n,i,r,s,o,l,a){g(this,"_stackElementBrand");g(this,"_enterPos");g(this,"_anchorPos");g(this,"depth");this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=s,this.endRule=o,this.nameScopesList=l,this.contentNameScopesList=a,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=i,this._anchorPos=r}equals(e){return e===null?!1:He._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?Rn.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){He._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,i,r,s,o,l){return new He(this,e,n,i,r,s,o,l)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){var i,r;return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${(i=this.nameScopesList)==null?void 0:i.toString()}, ${(r=this.contentNameScopesList)==null?void 0:r.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new He(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){var e,n,i;return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:((n=this.nameScopesList)==null?void 0:n.getExtensionIfDefined(((e=this.parent)==null?void 0:e.nameScopesList)??null))??[],contentNameScopesList:((i=this.contentNameScopesList)==null?void 0:i.getExtensionIfDefined(this.nameScopesList))??[]}}static pushFrame(e,n){const i=Rn.fromExtension((e==null?void 0:e.nameScopesList)??null,n.nameScopesList);return new He(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,i,Rn.fromExtension(i,n.contentNameScopesList))}},g(He,"NULL",new He(null,0,0,0,!1,null,null,null)),He),Gu=class{constructor(t,e){g(this,"balancedBracketScopes");g(this,"unbalancedBracketScopes");g(this,"allowAny",!1);this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Ti(n,Pi).map(i=>i.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>Ti(n,Pi).map(i=>i.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},Wu=class{constructor(t,e,n,i){g(this,"_emitBinaryTokens");g(this,"_lineText");g(this,"_tokens");g(this,"_binaryTokens");g(this,"_lastTokenEndIndex");g(this,"_tokenTypeOverrides");this.balancedBracketSelectors=i,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){var i;if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=(t==null?void 0:t.tokenAttributes)??0,s=!1;if((i=this.balancedBracketSelectors)!=null&&i.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=(t==null?void 0:t.getScopeNames())??[];for(const l of this._tokenTypeOverrides)l.matcher(o)&&(r=en.set(r,0,l.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(r=en.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=(t==null?void 0:t.getScopeNames())??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let i=0,r=this._binaryTokens.length;i<r;i++)n[i]=this._binaryTokens[i];return n}},ju=class{constructor(t,e){g(this,"_grammars",new Map);g(this,"_rawGrammars",new Map);g(this,"_injectionGrammars",new Map);g(this,"_theme");this._onigLib=e,this._theme=t}dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,i,r){if(!this._grammars.has(t)){let s=this._rawGrammars.get(t);if(!s)return null;this._grammars.set(t,Uu(t,s,e,n,i,r,this,this._onigLib))}return this._grammars.get(t)}},qu=class{constructor(e){g(this,"_options");g(this,"_syncRegistry");g(this,"_ensureGrammarCache");this._options=e,this._syncRegistry=new ju(_i.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(_i.createFromRawTheme(e,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,n,i){return this.loadGrammarWithConfiguration(e,n,{embeddedLanguages:i})}loadGrammarWithConfiguration(e,n,i){return this._loadGrammar(e,n,i.embeddedLanguages,i.tokenTypes,new Gu(i.balancedBracketSelectors||[],i.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,i,r,s){const o=new wu(this._syncRegistry,e);for(;o.Q.length>0;)o.Q.map(l=>this._loadSingleGrammar(l.scopeName)),o.processQueue();return this._grammarForScopeName(e,n,i,r,s)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const n=this._options.loadGrammar(e);if(n){const i=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(n,i)}}addGrammar(e,n=[],i=0,r=null){return this._syncRegistry.addGrammar(e,n),this._grammarForScopeName(e.scopeName,i,r)}_grammarForScopeName(e,n=0,i=null,r=null,s=null){return this._syncRegistry.grammarForScopeName(e,n,i,r,s)}},Yr=Xr.NULL;const Ku=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class jn{constructor(e,n,i){this.normal=n,this.property=e,i&&(this.space=i)}}jn.prototype.normal={};jn.prototype.property={};jn.prototype.space=void 0;function Tl(t,e){const n={},i={};for(const r of t)Object.assign(n,r.property),Object.assign(i,r.normal);return new jn(n,i,e)}function Qr(t){return t.toLowerCase()}class Ee{constructor(e,n){this.attribute=n,this.property=e}}Ee.prototype.attribute="";Ee.prototype.booleanish=!1;Ee.prototype.boolean=!1;Ee.prototype.commaOrSpaceSeparated=!1;Ee.prototype.commaSeparated=!1;Ee.prototype.defined=!1;Ee.prototype.mustUseProperty=!1;Ee.prototype.number=!1;Ee.prototype.overloadedBoolean=!1;Ee.prototype.property="";Ee.prototype.spaceSeparated=!1;Ee.prototype.space=void 0;let Xu=0;const O=$t(),Q=$t(),Zr=$t(),T=$t(),W=$t(),Pt=$t(),Te=$t();function $t(){return 2**++Xu}const Jr=Object.freeze(Object.defineProperty({__proto__:null,boolean:O,booleanish:Q,commaOrSpaceSeparated:Te,commaSeparated:Pt,number:T,overloadedBoolean:Zr,spaceSeparated:W},Symbol.toStringTag,{value:"Module"})),pr=Object.keys(Jr);class _s extends Ee{constructor(e,n,i,r){let s=-1;if(super(e,n),mo(this,"space",r),typeof i=="number")for(;++s<pr.length;){const o=pr[s];mo(this,pr[s],(i&Jr[o])===Jr[o])}}}_s.prototype.defined=!0;function mo(t,e,n){n&&(t[e]=n)}function on(t){const e={},n={};for(const[i,r]of Object.entries(t.properties)){const s=new _s(i,t.transform(t.attributes||{},i),r,t.space);t.mustUseProperty&&t.mustUseProperty.includes(i)&&(s.mustUseProperty=!0),e[i]=s,n[Qr(i)]=i,n[Qr(s.attribute)]=i}return new jn(e,n,t.space)}const Il=on({properties:{ariaActiveDescendant:null,ariaAtomic:Q,ariaAutoComplete:null,ariaBusy:Q,ariaChecked:Q,ariaColCount:T,ariaColIndex:T,ariaColSpan:T,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:Q,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:Q,ariaFlowTo:W,ariaGrabbed:Q,ariaHasPopup:null,ariaHidden:Q,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:T,ariaLive:null,ariaModal:Q,ariaMultiLine:Q,ariaMultiSelectable:Q,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:T,ariaPressed:Q,ariaReadOnly:Q,ariaRelevant:null,ariaRequired:Q,ariaRoleDescription:W,ariaRowCount:T,ariaRowIndex:T,ariaRowSpan:T,ariaSelected:Q,ariaSetSize:T,ariaSort:null,ariaValueMax:T,ariaValueMin:T,ariaValueNow:T,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function Al(t,e){return e in t?t[e]:e}function Pl(t,e){return Al(t,e.toLowerCase())}const Yu=on({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Pt,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:O,allowPaymentRequest:O,allowUserMedia:O,alpha:O,alt:null,as:null,async:O,autoCapitalize:null,autoComplete:W,autoFocus:O,autoPlay:O,blocking:W,capture:null,charSet:null,checked:O,cite:null,className:W,closedBy:null,colorSpace:null,cols:T,colSpan:T,command:null,commandFor:null,content:null,contentEditable:Q,controls:O,controlsList:W,coords:T|Pt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:O,defer:O,dir:null,dirName:null,disabled:O,download:Zr,draggable:Q,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:O,formTarget:null,headers:W,height:T,hidden:Zr,high:T,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:O,inputMode:null,integrity:null,is:null,isMap:O,itemId:null,itemProp:W,itemRef:W,itemScope:O,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:O,low:T,manifest:null,max:null,maxLength:T,media:null,method:null,min:null,minLength:T,multiple:O,muted:O,name:null,nonce:null,noModule:O,noValidate:O,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:O,optimum:T,pattern:null,ping:W,placeholder:null,playsInline:O,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:O,referrerPolicy:null,rel:W,required:O,reversed:O,rows:T,rowSpan:T,sandbox:W,scope:null,scoped:O,seamless:O,selected:O,shadowRootClonable:O,shadowRootCustomElementRegistry:O,shadowRootDelegatesFocus:O,shadowRootMode:null,shadowRootSerializable:O,shape:null,size:T,sizes:null,slot:null,span:T,spellCheck:Q,src:null,srcDoc:null,srcLang:null,srcSet:null,start:T,step:null,style:null,tabIndex:T,target:null,title:null,translate:null,type:null,typeMustMatch:O,useMap:null,value:Q,width:T,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:T,borderColor:null,bottomMargin:T,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:O,declare:O,event:null,face:null,frame:null,frameBorder:null,hSpace:T,leftMargin:T,link:null,longDesc:null,lowSrc:null,marginHeight:T,marginWidth:T,noResize:O,noHref:O,noShade:O,noWrap:O,object:null,profile:null,prompt:null,rev:null,rightMargin:T,rules:null,scheme:null,scrolling:Q,standby:null,summary:null,text:null,topMargin:T,valueType:null,version:null,vAlign:null,vLink:null,vSpace:T,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:O,disablePictureInPicture:O,disableRemotePlayback:O,exportParts:Pt,part:W,prefix:null,property:null,results:T,security:null,unselectable:null},space:"html",transform:Pl}),Qu=on({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Te,accentHeight:T,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:T,amplitude:T,arabicForm:null,ascent:T,attributeName:null,attributeType:null,azimuth:T,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:T,by:null,calcMode:null,capHeight:T,className:W,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:T,diffuseConstant:T,direction:null,display:null,dur:null,divisor:T,dominantBaseline:null,download:O,dx:null,dy:null,edgeMode:null,editable:null,elevation:T,enableBackground:null,end:null,event:null,exponent:T,externalResourcesRequired:null,fill:null,fillOpacity:T,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Pt,g2:Pt,glyphName:Pt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:T,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:T,horizOriginX:T,horizOriginY:T,id:null,ideographic:T,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:T,k:T,k1:T,k2:T,k3:T,k4:T,kernelMatrix:Te,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:T,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:T,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:T,overlineThickness:T,paintOrder:null,panose1:null,path:null,pathLength:T,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:T,pointsAtY:T,pointsAtZ:T,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Te,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Te,rev:Te,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Te,requiredFeatures:Te,requiredFonts:Te,requiredFormats:Te,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:T,specularExponent:T,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:T,strikethroughThickness:T,string:null,stroke:null,strokeDashArray:Te,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:T,strokeOpacity:T,strokeWidth:null,style:null,surfaceScale:T,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Te,tabIndex:T,tableValues:null,target:null,targetX:T,targetY:T,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Te,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:T,underlineThickness:T,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:T,values:null,vAlphabetic:T,vMathematical:T,vectorEffect:null,vHanging:T,vIdeographic:T,version:null,vertAdvY:T,vertOriginX:T,vertOriginY:T,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:T,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Al}),Ml=on({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),Dl=on({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Pl}),Hl=on({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),Zu=/[A-Z]/g,yo=/-[a-z]/g,Ju=/^data[-\w.:]+$/i;function eh(t,e){const n=Qr(e);let i=e,r=Ee;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Ju.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(yo,nh);i="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!yo.test(s)){let o=s.replace(Zu,th);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}r=_s}return new r(i,e)}function th(t){return"-"+t.toLowerCase()}function nh(t){return t.charAt(1).toUpperCase()}const ih=Tl([Il,Yu,Ml,Dl,Hl],"html"),Ol=Tl([Il,Qu,Ml,Dl,Hl],"svg"),vo={}.hasOwnProperty;function rh(t,e){const n=e||{};function i(r,...s){let o=i.invalid;const l=i.handlers;if(r&&vo.call(r,t)){const a=String(r[t]);o=vo.call(l,a)?l[a]:i.unknown}if(o)return o.call(this,r,...s)}return i.handlers=n.handlers||{},i.invalid=n.invalid,i.unknown=n.unknown,i}const sh=/["&'<>`]/g,oh=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,ah=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,lh=/[|\\{}()[\]^$+*?.]/g,Co=new WeakMap;function dh(t,e){if(t=t.replace(e.subset?ch(e.subset):sh,i),e.subset||e.escapeOnly)return t;return t.replace(oh,n).replace(ah,i);function n(r,s,o){return e.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,o.charCodeAt(s+2),e)}function i(r,s,o){return e.format(r.charCodeAt(0),o.charCodeAt(s+1),e)}}function ch(t){let e=Co.get(t);return e||(e=uh(t),Co.set(t,e)),e}function uh(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(lh,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const hh=/[\dA-Fa-f]/;function fh(t,e,n){const i="&#x"+t.toString(16).toUpperCase();return n&&e&&!hh.test(String.fromCharCode(e))?i:i+";"}const ph=/\d/;function gh(t,e,n){const i="&#"+String(t);return n&&e&&!ph.test(String.fromCharCode(e))?i:i+";"}const mh=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],gr={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},yh=["cent","copy","divide","gt","lt","not","para","times"],Nl={}.hasOwnProperty,es={};let Xn;for(Xn in gr)Nl.call(gr,Xn)&&(es[gr[Xn]]=Xn);const vh=/[^\dA-Za-z]/;function Ch(t,e,n,i){const r=String.fromCharCode(t);if(Nl.call(es,r)){const s=es[r],o="&"+s;return n&&mh.includes(s)&&!yh.includes(s)&&(!i||e&&e!==61&&vh.test(String.fromCharCode(e)))?o:o+";"}return""}function Sh(t,e,n){let i=fh(t,e,n.omitOptionalSemicolons),r;if((n.useNamedReferences||n.useShortestReferences)&&(r=Ch(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!r)&&n.useShortestReferences){const s=gh(t,e,n.omitOptionalSemicolons);s.length<i.length&&(i=s)}return r&&(!n.useShortestReferences||r.length<i.length)?r:i}function Zt(t,e){return dh(t,Object.assign({format:Sh},e))}const bh=/^>|^->|<!--|-->|--!>|<!-$/g,wh=[">"],xh=["<",">"];function kh(t,e,n,i){return i.settings.bogusComments?"<?"+Zt(t.value,Object.assign({},i.settings.characterReferences,{subset:wh}))+">":"<!--"+t.value.replace(bh,r)+"-->";function r(s){return Zt(s,Object.assign({},i.settings.characterReferences,{subset:xh}))}}function Lh(t,e,n,i){return"<!"+(i.settings.upperDoctype?"DOCTYPE":"doctype")+(i.settings.tightDoctype?"":" ")+"html>"}function So(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let i=0,r=n.indexOf(e);for(;r!==-1;)i++,r=n.indexOf(e,r+e.length);return i}function Eh(t,e){const n=e||{};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function Rh(t){return t.join(" ").trim()}const _h=/[ \t\n\f\r]/g;function Ts(t){return typeof t=="object"?t.type==="text"?bo(t.value):!1:bo(t)}function bo(t){return t.replace(_h,"")===""}const ie=$l(1),Fl=$l(-1),Th=[];function $l(t){return e;function e(n,i,r){const s=n?n.children:Th;let o=(i||0)+t,l=s[o];if(!r)for(;l&&Ts(l);)o+=t,l=s[o];return l}}const Ih={}.hasOwnProperty;function zl(t){return e;function e(n,i,r){return Ih.call(t,n.tagName)&&t[n.tagName](n,i,r)}}const Is=zl({body:Ph,caption:mr,colgroup:mr,dd:Oh,dt:Hh,head:mr,html:Ah,li:Dh,optgroup:Nh,option:Fh,p:Mh,rp:wo,rt:wo,tbody:zh,td:xo,tfoot:Uh,th:xo,thead:$h,tr:Bh});function mr(t,e,n){const i=ie(n,e,!0);return!i||i.type!=="comment"&&!(i.type==="text"&&Ts(i.value.charAt(0)))}function Ah(t,e,n){const i=ie(n,e);return!i||i.type!=="comment"}function Ph(t,e,n){const i=ie(n,e);return!i||i.type!=="comment"}function Mh(t,e,n){const i=ie(n,e);return i?i.type==="element"&&(i.tagName==="address"||i.tagName==="article"||i.tagName==="aside"||i.tagName==="blockquote"||i.tagName==="details"||i.tagName==="div"||i.tagName==="dl"||i.tagName==="fieldset"||i.tagName==="figcaption"||i.tagName==="figure"||i.tagName==="footer"||i.tagName==="form"||i.tagName==="h1"||i.tagName==="h2"||i.tagName==="h3"||i.tagName==="h4"||i.tagName==="h5"||i.tagName==="h6"||i.tagName==="header"||i.tagName==="hgroup"||i.tagName==="hr"||i.tagName==="main"||i.tagName==="menu"||i.tagName==="nav"||i.tagName==="ol"||i.tagName==="p"||i.tagName==="pre"||i.tagName==="section"||i.tagName==="table"||i.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function Dh(t,e,n){const i=ie(n,e);return!i||i.type==="element"&&i.tagName==="li"}function Hh(t,e,n){const i=ie(n,e);return!!(i&&i.type==="element"&&(i.tagName==="dt"||i.tagName==="dd"))}function Oh(t,e,n){const i=ie(n,e);return!i||i.type==="element"&&(i.tagName==="dt"||i.tagName==="dd")}function wo(t,e,n){const i=ie(n,e);return!i||i.type==="element"&&(i.tagName==="rp"||i.tagName==="rt")}function Nh(t,e,n){const i=ie(n,e);return!i||i.type==="element"&&i.tagName==="optgroup"}function Fh(t,e,n){const i=ie(n,e);return!i||i.type==="element"&&(i.tagName==="option"||i.tagName==="optgroup")}function $h(t,e,n){const i=ie(n,e);return!!(i&&i.type==="element"&&(i.tagName==="tbody"||i.tagName==="tfoot"))}function zh(t,e,n){const i=ie(n,e);return!i||i.type==="element"&&(i.tagName==="tbody"||i.tagName==="tfoot")}function Uh(t,e,n){return!ie(n,e)}function Bh(t,e,n){const i=ie(n,e);return!i||i.type==="element"&&i.tagName==="tr"}function xo(t,e,n){const i=ie(n,e);return!i||i.type==="element"&&(i.tagName==="td"||i.tagName==="th")}const Vh=zl({body:jh,colgroup:qh,head:Wh,html:Gh,tbody:Kh});function Gh(t){const e=ie(t,-1);return!e||e.type!=="comment"}function Wh(t){const e=new Set;for(const i of t.children)if(i.type==="element"&&(i.tagName==="base"||i.tagName==="title")){if(e.has(i.tagName))return!1;e.add(i.tagName)}const n=t.children[0];return!n||n.type==="element"}function jh(t){const e=ie(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&Ts(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function qh(t,e,n){const i=Fl(n,e),r=ie(t,-1,!0);return n&&i&&i.type==="element"&&i.tagName==="colgroup"&&Is(i,n.children.indexOf(i),n)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function Kh(t,e,n){const i=Fl(n,e),r=ie(t,-1);return n&&i&&i.type==="element"&&(i.tagName==="thead"||i.tagName==="tbody")&&Is(i,n.children.indexOf(i),n)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}const Yn={name:[[`
5
+ \f\r &/=>`.split(""),`
6
+ \f\r "&'/=>\``.split("")],[`\0
7
+ \f\r "&'/<=>`.split(""),`\0
8
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
9
+ \f\r &>`.split(""),`\0
10
+ \f\r "&'<=>\``.split("")],[`\0
11
+ \f\r "&'<=>\``.split(""),`\0
12
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Xh(t,e,n,i){const r=i.schema,s=r.space==="svg"?!1:i.settings.omitOptionalTags;let o=r.space==="svg"?i.settings.closeEmptyElements:i.settings.voids.includes(t.tagName.toLowerCase());const l=[];let a;r.space==="html"&&t.tagName==="svg"&&(i.schema=Ol);const d=Yh(i,t.properties),c=i.all(r.space==="html"&&t.tagName==="template"?t.content:t);return i.schema=r,c&&(o=!1),(d||!s||!Vh(t,e,n))&&(l.push("<",t.tagName,d?" "+d:""),o&&(r.space==="svg"||i.settings.closeSelfClosing)&&(a=d.charAt(d.length-1),(!i.settings.tightSelfClosing||a==="/"||a&&a!=='"'&&a!=="'")&&l.push(" "),l.push("/")),l.push(">")),l.push(c),!o&&(!s||!Is(t,e,n))&&l.push("</"+t.tagName+">"),l.join("")}function Yh(t,e){const n=[];let i=-1,r;if(e){for(r in e)if(e[r]!==null&&e[r]!==void 0){const s=Qh(t,r,e[r]);s&&n.push(s)}}for(;++i<n.length;){const s=t.settings.tightAttributes?n[i].charAt(n[i].length-1):void 0;i!==n.length-1&&s!=='"'&&s!=="'"&&(n[i]+=" ")}return n.join("")}function Qh(t,e,n){const i=eh(t.schema,e),r=t.settings.allowParseErrors&&t.schema.space==="html"?0:1,s=t.settings.allowDangerousCharacters?0:1;let o=t.quote,l;if(i.overloadedBoolean&&(n===i.attribute||n==="")?n=!0:(i.boolean||i.overloadedBoolean)&&(typeof n!="string"||n===i.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const a=Zt(i.attribute,Object.assign({},t.settings.characterReferences,{subset:Yn.name[r][s]}));return n===!0||(n=Array.isArray(n)?(i.commaSeparated?Eh:Rh)(n,{padLeft:!t.settings.tightCommaSeparatedLists}):String(n),t.settings.collapseEmptyAttributes&&!n)?a:(t.settings.preferUnquoted&&(l=Zt(n,Object.assign({},t.settings.characterReferences,{attribute:!0,subset:Yn.unquoted[r][s]}))),l!==n&&(t.settings.quoteSmart&&So(n,o)>So(n,t.alternative)&&(o=t.alternative),l=o+Zt(n,Object.assign({},t.settings.characterReferences,{subset:(o==="'"?Yn.single:Yn.double)[r][s],attribute:!0}))+o),a+(l&&"="+l))}const Zh=["<","&"];function Ul(t,e,n,i){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?t.value:Zt(t.value,Object.assign({},i.settings.characterReferences,{subset:Zh}))}function Jh(t,e,n,i){return i.settings.allowDangerousHtml?t.value:Ul(t,e,n,i)}function ef(t,e,n,i){return i.all(t)}const tf=rh("type",{invalid:nf,unknown:rf,handlers:{comment:kh,doctype:Lh,element:Xh,raw:Jh,root:ef,text:Ul}});function nf(t){throw new Error("Expected node, not `"+t+"`")}function rf(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const sf={},of={},af=[];function Ce(t,e){const n=e||sf,i=n.quote||'"',r=i==='"'?"'":'"';if(i!=='"'&&i!=="'")throw new Error("Invalid quote `"+i+"`, expected `'` or `\"`");return{one:lf,all:df,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Ku,characterReferences:n.characterReferences||of,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Ol:ih,quote:i,alternative:r}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function lf(t,e,n){return tf(t,e,n,this)}function df(t){const e=[],n=t&&t.children||af;let i=-1;for(;++i<n.length;)e[i]=this.one(n[i],i,t);return e.join("")}function Mi(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},i=typeof t=="string"?t:t.name;for(const[r,s]of Object.entries((e==null?void 0:e.colorReplacements)||{}))typeof s=="string"?n[r]=s:r===i&&Object.assign(n,s);return n}function St(t,e){return t&&((e==null?void 0:e[t==null?void 0:t.toLowerCase()])||t)}function cf(t){return Array.isArray(t)?t:[t]}async function Bl(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function As(t){return!t||["plaintext","txt","text","plain"].includes(t)}function Vl(t){return t==="ansi"||As(t)}function Ps(t){return t==="none"}function Gl(t){return Ps(t)}function Wl(t,e){var i;if(!e)return t;t.properties||(t.properties={}),(i=t.properties).class||(i.class=[]),typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(/\s+/g);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}function Yi(t,e=!1){var s;if(t.length===0)return[["",0]];const n=t.split(/(\r?\n)/g);let i=0;const r=[];for(let o=0;o<n.length;o+=2){const l=e?n[o]+(n[o+1]||""):n[o];r.push([l,i]),i+=n[o].length,i+=((s=n[o+1])==null?void 0:s.length)||0}return r}function uf(t){const e=Yi(t,!0).map(([r])=>r);function n(r){if(r===t.length)return{line:e.length-1,character:e[e.length-1].length};let s=r,o=0;for(const l of e){if(s<l.length)break;s-=l.length,o++}return{line:o,character:s}}function i(r,s){let o=0;for(let l=0;l<r;l++)o+=e[l].length;return o+=s,o}return{lines:e,indexToPos:n,posToIndex:i}}const Ms="light-dark()",hf=["color","background-color"];function ff(t,e){let n=0;const i=[];for(const r of e)r>n&&i.push({...t,content:t.content.slice(n,r),offset:t.offset+n}),n=r;return n<t.content.length&&i.push({...t,content:t.content.slice(n),offset:t.offset+n}),i}function pf(t,e){const n=Array.from(e instanceof Set?e:new Set(e)).sort((i,r)=>i-r);return n.length?t.map(i=>i.flatMap(r=>{const s=n.filter(o=>r.offset<o&&o<r.offset+r.content.length).map(o=>o-r.offset).sort((o,l)=>o-l);return s.length?ff(r,s):r})):t}function gf(t,e,n,i,r="css-vars"){const s={content:t.content,explanation:t.explanation,offset:t.offset},o=e.map(c=>Hn(t.variants[c])),l=new Set(o.flatMap(c=>Object.keys(c))),a={},d=(c,u)=>{const h=u==="color"?"":u==="background-color"?"-bg":`-${u}`;return n+e[c]+(u==="color"?"":h)};return o.forEach((c,u)=>{for(const h of l){const f=c[h]||"inherit";if(u===0&&i&&hf.includes(h))if(i===Ms&&o.length>1){const p=e.findIndex(C=>C==="light"),y=e.findIndex(C=>C==="dark");if(p===-1||y===-1)throw new J('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const v=o[p][h]||"inherit",m=o[y][h]||"inherit";a[h]=`light-dark(${v}, ${m})`,r==="css-vars"&&(a[d(u,h)]=f)}else a[h]=f;else r==="css-vars"&&(a[d(u,h)]=f)}}),s.htmlStyle=a,s}function Hn(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&fe.Italic&&(e["font-style"]="italic"),t.fontStyle&fe.Bold&&(e["font-weight"]="bold");const n=[];t.fontStyle&fe.Underline&&n.push("underline"),t.fontStyle&fe.Strikethrough&&n.push("line-through"),n.length&&(e["text-decoration"]=n.join(" "))}return e}function Di(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const jl=new WeakMap;function Qi(t,e){jl.set(t,e)}function On(t){return jl.get(t)}class an{constructor(...e){g(this,"_stacks",{});g(this,"lang");if(e.length===2){const[n,i]=e;this.lang=i,this._stacks=n}else{const[n,i,r]=e;this.lang=i,this._stacks={[r]:n}}}get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new an(Object.fromEntries(cf(n).map(i=>[i,Yr])),e)}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return mf(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function mf(t){const e=[],n=new Set;function i(r){var o;if(n.has(r))return;n.add(r);const s=(o=r==null?void 0:r.nameScopesList)==null?void 0:o.scopeName;s&&e.push(s),r.parent&&i(r.parent)}return i(t),e}function yf(t,e){if(!(t instanceof an))throw new J("Invalid grammar state");return t.getInternalStack(e)}function vf(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let i=function(o){if(typeof o=="number"){if(o<0||o>n.source.length)throw new J(`Invalid decoration offset: ${o}. Code length: ${n.source.length}`);return{...r.indexToPos(o),offset:o}}else{const l=r.lines[o.line];if(l===void 0)throw new J(`Invalid decoration position ${JSON.stringify(o)}. Lines length: ${r.lines.length}`);let a=o.character;if(a<0&&(a=l.length+a),a<0||a>l.length)throw new J(`Invalid decoration position ${JSON.stringify(o)}. Line ${o.line} length: ${l.length}`);return{...o,character:a,offset:r.posToIndex(o.line,a)}}};const r=uf(n.source),s=(n.options.decorations||[]).map(o=>({...o,start:i(o.start),end:i(o.end)}));Cf(s),t.set(n.meta,{decorations:s,converter:r,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){var o;if(!((o=this.options.decorations)!=null&&o.length))return;const r=e(this).decorations.flatMap(l=>[l.start.offset,l.end.offset]);return pf(n,r)},code(n){var c;if(!((c=this.options.decorations)!=null&&c.length))return;const i=e(this),r=Array.from(n.children).filter(u=>u.type==="element"&&u.tagName==="span");if(r.length!==i.converter.lines.length)throw new J(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${i.converter.lines.length}). Failed to apply decorations.`);function s(u,h,f,p){const y=r[u];let v="",m=-1,C=-1;if(h===0&&(m=0),f===0&&(C=0),f===Number.POSITIVE_INFINITY&&(C=y.children.length),m===-1||C===-1)for(let w=0;w<y.children.length;w++)v+=ql(y.children[w]),m===-1&&v.length===h&&(m=w+1),C===-1&&v.length===f&&(C=w+1);if(m===-1)throw new J(`Failed to find start index for decoration ${JSON.stringify(p.start)}`);if(C===-1)throw new J(`Failed to find end index for decoration ${JSON.stringify(p.end)}`);const S=y.children.slice(m,C);if(!p.alwaysWrap&&S.length===y.children.length)l(y,p,"line");else if(!p.alwaysWrap&&S.length===1&&S[0].type==="element")l(S[0],p,"token");else{const w={type:"element",tagName:"span",properties:{},children:S};l(w,p,"wrapper"),y.children.splice(m,S.length,w)}}function o(u,h){r[u]=l(r[u],h,"line")}function l(u,h,f){var v;const p=h.properties||{},y=h.transform||(m=>m);return u.tagName=h.tagName||"span",u.properties={...u.properties,...p,class:u.properties.class},(v=h.properties)!=null&&v.class&&Wl(u,h.properties.class),u=y(u,f)||u,u}const a=[],d=i.decorations.sort((u,h)=>h.start.offset-u.start.offset||u.end.offset-h.end.offset);for(const u of d){const{start:h,end:f}=u;if(h.line===f.line)s(h.line,h.character,f.character,u);else if(h.line<f.line){s(h.line,h.character,Number.POSITIVE_INFINITY,u);for(let p=h.line+1;p<f.line;p++)a.unshift(()=>o(p,u));s(f.line,0,f.character,u)}}a.forEach(u=>u())}}}function Cf(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new J(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let i=e+1;i<t.length;i++){const r=t[i],s=n.start.offset<=r.start.offset&&r.start.offset<n.end.offset,o=n.start.offset<r.end.offset&&r.end.offset<=n.end.offset,l=r.start.offset<=n.start.offset&&n.start.offset<r.end.offset,a=r.start.offset<n.end.offset&&n.end.offset<=r.end.offset;if(s||o||l||a){if(s&&o||l&&a||l&&n.start.offset===n.end.offset||o&&r.start.offset===r.end.offset)continue;throw new J(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function ql(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(ql).join(""):""}const Sf=[vf()];function Hi(t){const e=bf(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...Sf]}function bf(t){const e=[],n=[],i=[];for(const r of t)switch(r.enforce){case"pre":e.push(r);break;case"post":n.push(r);break;default:i.push(r)}return{pre:e,post:n,normal:i}}var _t=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],yr={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function wf(t,e){const n=t.indexOf("\x1B",e);if(n!==-1&&t[n+1]==="["){const i=t.indexOf("m",n);if(i!==-1)return{sequence:t.substring(n+2,i).split(";"),startPosition:n,position:i+1}}return{position:t.length}}function ko(t){const e=t.shift();if(e==="2"){const n=t.splice(0,3).map(i=>Number.parseInt(i));return n.length!==3||n.some(i=>Number.isNaN(i))?void 0:{type:"rgb",rgb:n}}else if(e==="5"){const n=t.shift();if(n)return{type:"table",index:Number(n)}}}function xf(t){const e=[];for(;t.length>0;){const n=t.shift();if(!n)continue;const i=Number.parseInt(n);if(!Number.isNaN(i))if(i===0)e.push({type:"resetAll"});else if(i<=9)yr[i]&&e.push({type:"setDecoration",value:yr[i]});else if(i<=29){const r=yr[i-20];r&&(e.push({type:"resetDecoration",value:r}),r==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(i<=37)e.push({type:"setForegroundColor",value:{type:"named",name:_t[i-30]}});else if(i===38){const r=ko(t);r&&e.push({type:"setForegroundColor",value:r})}else if(i===39)e.push({type:"resetForegroundColor"});else if(i<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:_t[i-40]}});else if(i===48){const r=ko(t);r&&e.push({type:"setBackgroundColor",value:r})}else i===49?e.push({type:"resetBackgroundColor"}):i===53?e.push({type:"setDecoration",value:"overline"}):i===55?e.push({type:"resetDecoration",value:"overline"}):i>=90&&i<=97?e.push({type:"setForegroundColor",value:{type:"named",name:_t[i-90+8]}}):i>=100&&i<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:_t[i-100+8]}})}return e}function kf(){let t=null,e=null,n=new Set;return{parse(i){const r=[];let s=0;do{const o=wf(i,s),l=o.sequence?i.substring(s,o.startPosition):i.substring(s);if(l.length>0&&r.push({value:l,foreground:t,background:e,decorations:new Set(n)}),o.sequence){const a=xf(o.sequence);for(const d of a)d.type==="resetAll"?(t=null,e=null,n.clear()):d.type==="resetForegroundColor"?t=null:d.type==="resetBackgroundColor"?e=null:d.type==="resetDecoration"&&n.delete(d.value);for(const d of a)d.type==="setForegroundColor"?t=d.value:d.type==="setBackgroundColor"?e=d.value:d.type==="setDecoration"&&n.add(d.value)}s=o.position}while(s<i.length);return r}}}var Lf={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function Ef(t=Lf){function e(l){return t[l]}function n(l){return`#${l.map(a=>Math.max(0,Math.min(a,255)).toString(16).padStart(2,"0")).join("")}`}let i;function r(){if(i)return i;i=[];for(let d=0;d<_t.length;d++)i.push(e(_t[d]));let l=[0,95,135,175,215,255];for(let d=0;d<6;d++)for(let c=0;c<6;c++)for(let u=0;u<6;u++)i.push(n([l[d],l[c],l[u]]));let a=8;for(let d=0;d<24;d++,a+=10)i.push(n([a,a,a]));return i}function s(l){return r()[l]}function o(l){switch(l.type){case"named":return e(l.name);case"rgb":return n(l.rgb);case"table":return s(l.index)}}return{value:o}}const Rf={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function _f(t,e,n){const i=Mi(t,n),r=Yi(e),s=Object.fromEntries(_t.map(a=>{var u;const d=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`,c=(u=t.colors)==null?void 0:u[d];return[a,c||Rf[a]]})),o=Ef(s),l=kf();return r.map(a=>l.parse(a[0]).map(d=>{let c,u;d.decorations.has("reverse")?(c=d.background?o.value(d.background):t.bg,u=d.foreground?o.value(d.foreground):t.fg):(c=d.foreground?o.value(d.foreground):t.fg,u=d.background?o.value(d.background):void 0),c=St(c,i),u=St(u,i),d.decorations.has("dim")&&(c=Tf(c));let h=fe.None;return d.decorations.has("bold")&&(h|=fe.Bold),d.decorations.has("italic")&&(h|=fe.Italic),d.decorations.has("underline")&&(h|=fe.Underline),d.decorations.has("strikethrough")&&(h|=fe.Strikethrough),{content:d.value,offset:a[1],color:c,bgColor:u,fontStyle:h}}))}function Tf(t){const e=t.match(/#([0-9a-f]{3,8})/i);if(e){const i=e[1];if(i.length===8){const r=Math.round(Number.parseInt(i.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${i.slice(0,6)}${r}`}else{if(i.length===6)return`#${i}80`;if(i.length===4){const r=i[0],s=i[1],o=i[2],l=i[3],a=Math.round(Number.parseInt(`${l}${l}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${s}${s}${o}${o}${a}`}else if(i.length===3){const r=i[0],s=i[1],o=i[2];return`#${r}${r}${s}${s}${o}${o}80`}}}const n=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:t}function Ds(t,e,n={}){const{theme:i=t.getLoadedThemes()[0]}=n,r=t.resolveLangAlias(n.lang||"text");if(As(r)||Ps(i))return Yi(e).map(a=>[{content:a[0],offset:a[1]}]);const{theme:s,colorMap:o}=t.setTheme(i);if(r==="ansi")return _f(s,e,n);const l=t.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==l.name)throw new J(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${l.name}"`);if(!n.grammarState.themes.includes(s.name))throw new J(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return Af(e,l,s,o,n)}function If(...t){if(t.length===2)return On(t[1]);const[e,n,i={}]=t,{lang:r="text",theme:s=e.getLoadedThemes()[0]}=i;if(As(r)||Ps(s))throw new J("Plain language does not have grammar state");if(r==="ansi")throw new J("ANSI language does not have grammar state");const{theme:o,colorMap:l}=e.setTheme(s),a=e.getLanguage(r);return new an(Hs(n,a,o,l,i).stateStack,a.name,o.name)}function Af(t,e,n,i,r){const s=Hs(t,e,n,i,r),o=new an(s.stateStack,e.name,n.name);return Qi(s.tokens,o),s.tokens}function Hs(t,e,n,i,r){const s=Mi(n,r),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:l=500}=r,a=Yi(t);let d=r.grammarState?yf(r.grammarState,n.name)??Yr:r.grammarContextCode!=null?Hs(r.grammarContextCode,e,n,i,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Yr,c=[];const u=[];for(let h=0,f=a.length;h<f;h++){const[p,y]=a[h];if(p===""){c=[],u.push([]);continue}if(o>0&&p.length>=o){c=[],u.push([{content:p,offset:y,color:"",fontStyle:0}]);continue}let v,m,C;r.includeExplanation&&(v=e.tokenizeLine(p,d,l),m=v.tokens,C=0);const S=e.tokenizeLine2(p,d,l),w=S.tokens.length/2;for(let b=0;b<w;b++){const k=S.tokens[2*b],x=b+1<w?S.tokens[2*b+2]:p.length;if(k===x)continue;const E=S.tokens[2*b+1],R=St(i[en.getForeground(E)],s),A=en.getFontStyle(E),D={content:p.substring(k,x),offset:y+k,color:R,fontStyle:A};if(r.includeExplanation){const I=[];if(r.includeExplanation!=="scopeName")for(const H of n.settings){let U;switch(typeof H.scope){case"string":U=H.scope.split(/,/).map(V=>V.trim());break;case"object":U=H.scope;break;default:continue}I.push({settings:H,selectors:U.map(V=>V.split(/ /))})}D.explanation=[];let _=0;for(;k+_<x;){const H=m[C],U=p.substring(H.startIndex,H.endIndex);_+=U.length,D.explanation.push({content:U,scopes:r.includeExplanation==="scopeName"?Pf(H.scopes):Mf(I,H.scopes)}),C+=1}}c.push(D)}u.push(c),c=[],d=S.ruleStack}return{tokens:u,stateStack:d}}function Pf(t){return t.map(e=>({scopeName:e}))}function Mf(t,e){const n=[];for(let i=0,r=e.length;i<r;i++){const s=e[i];n[i]={scopeName:s,themeMatches:Hf(t,s,e.slice(0,i))}}return n}function Lo(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function Df(t,e,n){if(!Lo(t[t.length-1],e))return!1;let i=t.length-2,r=n.length-1;for(;i>=0&&r>=0;)Lo(t[i],n[r])&&(i-=1),r-=1;return i===-1}function Hf(t,e,n){const i=[];for(const{selectors:r,settings:s}of t)for(const o of r)if(Df(o,e,n)){i.push(s);break}return i}function Kl(t,e,n){const i=Object.entries(n.themes).filter(a=>a[1]).map(a=>({color:a[0],theme:a[1]})),r=i.map(a=>{const d=Ds(t,e,{...n,theme:a.theme}),c=On(d),u=typeof a.theme=="string"?a.theme:a.theme.name;return{tokens:d,state:c,theme:u}}),s=Of(...r.map(a=>a.tokens)),o=s[0].map((a,d)=>a.map((c,u)=>{const h={content:c.content,variants:{},offset:c.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=c.explanation),s.forEach((f,p)=>{const{content:y,explanation:v,offset:m,...C}=f[d][u];h.variants[i[p].color]=C}),h})),l=r[0].state?new an(Object.fromEntries(r.map(a=>{var d;return[a.theme,(d=a.state)==null?void 0:d.getInternalStack(a.theme)]})),r[0].state.lang):void 0;return l&&Qi(o,l),o}function Of(...t){const e=t.map(()=>[]),n=t.length;for(let i=0;i<t[0].length;i++){const r=t.map(a=>a[i]),s=e.map(()=>[]);e.forEach((a,d)=>a.push(s[d]));const o=r.map(()=>0),l=r.map(a=>a[0]);for(;l.every(a=>a);){const a=Math.min(...l.map(d=>d.content.length));for(let d=0;d<n;d++){const c=l[d];c.content.length===a?(s[d].push(c),o[d]+=1,l[d]=r[d][o[d]]):(s[d].push({...c,content:c.content.slice(0,a)}),l[d]={...c,content:c.content.slice(a),offset:c.offset+a})}}}return e}function Oi(t,e,n){let i,r,s,o,l,a;if("themes"in n){const{defaultColor:d="light",cssVariablePrefix:c="--shiki-",colorsRendering:u="css-vars"}=n,h=Object.entries(n.themes).filter(m=>m[1]).map(m=>({color:m[0],theme:m[1]})).sort((m,C)=>m.color===d?-1:C.color===d?1:0);if(h.length===0)throw new J("`themes` option must not be empty");const f=Kl(t,e,n);if(a=On(f),d&&Ms!==d&&!h.find(m=>m.color===d))throw new J(`\`themes\` option must contain the defaultColor key \`${d}\``);const p=h.map(m=>t.getTheme(m.theme)),y=h.map(m=>m.color);s=f.map(m=>m.map(C=>gf(C,y,c,d,u))),a&&Qi(s,a);const v=h.map(m=>Mi(m.theme,n));r=Eo(h,p,v,c,d,"fg",u),i=Eo(h,p,v,c,d,"bg",u),o=`shiki-themes ${p.map(m=>m.name).join(" ")}`,l=d?void 0:[r,i].join(";")}else if("theme"in n){const d=Mi(n.theme,n);s=Ds(t,e,n);const c=t.getTheme(n.theme);i=St(c.bg,d),r=St(c.fg,d),o=c.name,a=On(s)}else throw new J("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:i,themeName:o,rootStyle:l,grammarState:a}}function Eo(t,e,n,i,r,s,o){return t.map((l,a)=>{const d=St(e[a][s],n[a])||"inherit",c=`${i+l.color}${s==="bg"?"-bg":""}:${d}`;if(a===0&&r){if(r===Ms&&t.length>1){const u=t.findIndex(y=>y.color==="light"),h=t.findIndex(y=>y.color==="dark");if(u===-1||h===-1)throw new J('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const f=St(e[u][s],n[u])||"inherit",p=St(e[h][s],n[h])||"inherit";return`light-dark(${f}, ${p});${c}`}return d}return o==="css-vars"?c:null}).filter(l=>!!l).join(";")}function Ni(t,e,n,i={meta:{},options:n,codeToHast:(r,s)=>Ni(t,r,s),codeToTokens:(r,s)=>Oi(t,r,s)}){var p,y;let r=e;for(const v of Hi(n))r=((p=v.preprocess)==null?void 0:p.call(i,r,n))||r;let{tokens:s,fg:o,bg:l,themeName:a,rootStyle:d,grammarState:c}=Oi(t,r,n);const{mergeWhitespaces:u=!0,mergeSameStyleTokens:h=!1}=n;u===!0?s=Ff(s):u==="never"&&(s=$f(s)),h&&(s=zf(s));const f={...i,get source(){return r}};for(const v of Hi(n))s=((y=v.tokens)==null?void 0:y.call(f,s))||s;return Nf(s,{...n,fg:o,bg:l,themeName:a,rootStyle:n.rootStyle===!1?!1:n.rootStyle??d},f,c)}function Nf(t,e,n,i=On(t)){var y,v,m,C;const r=Hi(e),s=[],o={type:"root",children:[]},{structure:l="classic",tabindex:a="0"}=e,d={class:`shiki ${e.themeName||""}`};e.rootStyle!==!1&&(e.rootStyle!=null?d.style=e.rootStyle:d.style=`background-color:${e.bg};color:${e.fg}`),a!==!1&&a!=null&&(d.tabindex=a.toString());for(const[S,w]of Object.entries(e.meta||{}))S.startsWith("_")||(d[S]=w);let c={type:"element",tagName:"pre",properties:d,children:[],data:e.data},u={type:"element",tagName:"code",properties:{},children:s};const h=[],f={...n,structure:l,addClassToHast:Wl,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return o},get pre(){return c},get code(){return u},get lines(){return h}};if(t.forEach((S,w)=>{var x,E;w&&(l==="inline"?o.children.push({type:"element",tagName:"br",properties:{},children:[]}):l==="classic"&&s.push({type:"text",value:`
13
+ `}));let b={type:"element",tagName:"span",properties:{class:"line"},children:[]},k=0;for(const R of S){let A={type:"element",tagName:"span",properties:{...R.htmlAttrs},children:[{type:"text",value:R.content}]};const D=Di(R.htmlStyle||Hn(R));D&&(A.properties.style=D);for(const I of r)A=((x=I==null?void 0:I.span)==null?void 0:x.call(f,A,w+1,k,b,R))||A;l==="inline"?o.children.push(A):l==="classic"&&b.children.push(A),k+=R.content.length}if(l==="classic"){for(const R of r)b=((E=R==null?void 0:R.line)==null?void 0:E.call(f,b,w+1))||b;h.push(b),s.push(b)}else l==="inline"&&h.push(b)}),l==="classic"){for(const S of r)u=((y=S==null?void 0:S.code)==null?void 0:y.call(f,u))||u;c.children.push(u);for(const S of r)c=((v=S==null?void 0:S.pre)==null?void 0:v.call(f,c))||c;o.children.push(c)}else if(l==="inline"){const S=[];let w={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const x of o.children)x.type==="element"&&x.tagName==="br"?(S.push(w),w={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(x.type==="element"||x.type==="text")&&w.children.push(x);S.push(w);let k={type:"element",tagName:"code",properties:{},children:S};for(const x of r)k=((m=x==null?void 0:x.code)==null?void 0:m.call(f,k))||k;o.children=[];for(let x=0;x<k.children.length;x++){x>0&&o.children.push({type:"element",tagName:"br",properties:{},children:[]});const E=k.children[x];E.type==="element"&&o.children.push(...E.children)}}let p=o;for(const S of r)p=((C=S==null?void 0:S.root)==null?void 0:C.call(f,p))||p;return i&&Qi(p,i),p}function Ff(t){return t.map(e=>{const n=[];let i="",r;return e.forEach((s,o)=>{const a=!(s.fontStyle&&(s.fontStyle&fe.Underline||s.fontStyle&fe.Strikethrough));a&&s.content.match(/^\s+$/)&&e[o+1]?(r===void 0&&(r=s.offset),i+=s.content):i?(a?n.push({...s,offset:r,content:i+s.content}):n.push({content:i,offset:r},s),r=void 0,i=""):n.push(s)}),n})}function $f(t){return t.map(e=>e.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const i=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!i)return n;const[,r,s,o]=i;if(!r&&!o)return n;const l=[{...n,offset:n.offset+r.length,content:s}];return r&&l.unshift({content:r,offset:n.offset}),o&&l.push({content:o,offset:n.offset+r.length+s.length}),l}))}function zf(t){return t.map(e=>{const n=[];for(const i of e){if(n.length===0){n.push({...i});continue}const r=n[n.length-1],s=Di(r.htmlStyle||Hn(r)),o=Di(i.htmlStyle||Hn(i)),l=r.fontStyle&&(r.fontStyle&fe.Underline||r.fontStyle&fe.Strikethrough),a=i.fontStyle&&(i.fontStyle&fe.Underline||i.fontStyle&fe.Strikethrough);!l&&!a&&s===o?r.content+=i.content:n.push({...i})}return n})}const Uf=Ce;function Bf(t,e,n){var s;const i={meta:{},options:n,codeToHast:(o,l)=>Ni(t,o,l),codeToTokens:(o,l)=>Oi(t,o,l)};let r=Uf(Ni(t,e,n,i));for(const o of Hi(n))r=((s=o.postprocess)==null?void 0:s.call(i,r,n))||r;return r}const Ro={light:"#333333",dark:"#bbbbbb"},_o={light:"#fffffe",dark:"#1e1e1e"},To="__shiki_resolved";function Zi(t){var l,a,d,c,u;if(t!=null&&t[To])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||(e.type="dark"),e.colorReplacements={...e.colorReplacements},e.settings||(e.settings=[]);let{bg:n,fg:i}=e;if(!n||!i){const h=e.settings?e.settings.find(f=>!f.name&&!f.scope):void 0;(l=h==null?void 0:h.settings)!=null&&l.foreground&&(i=h.settings.foreground),(a=h==null?void 0:h.settings)!=null&&a.background&&(n=h.settings.background),!i&&((d=e==null?void 0:e.colors)!=null&&d["editor.foreground"])&&(i=e.colors["editor.foreground"]),!n&&((c=e==null?void 0:e.colors)!=null&&c["editor.background"])&&(n=e.colors["editor.background"]),i||(i=e.type==="light"?Ro.light:Ro.dark),n||(n=e.type==="light"?_o.light:_o.dark),e.fg=i,e.bg=n}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let r=0;const s=new Map;function o(h){var p;if(s.has(h))return s.get(h);r+=1;const f=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return(p=e.colorReplacements)!=null&&p[`#${f}`]?o(h):(s.set(h,f),f)}e.settings=e.settings.map(h=>{var v,m;const f=((v=h.settings)==null?void 0:v.foreground)&&!h.settings.foreground.startsWith("#"),p=((m=h.settings)==null?void 0:m.background)&&!h.settings.background.startsWith("#");if(!f&&!p)return h;const y={...h,settings:{...h.settings}};if(f){const C=o(h.settings.foreground);e.colorReplacements[C]=h.settings.foreground,y.settings.foreground=C}if(p){const C=o(h.settings.background);e.colorReplacements[C]=h.settings.background,y.settings.background=C}return y});for(const h of Object.keys(e.colors||{}))if((h==="editor.foreground"||h==="editor.background"||h.startsWith("terminal.ansi"))&&!((u=e.colors[h])!=null&&u.startsWith("#"))){const f=o(e.colors[h]);e.colorReplacements[f]=e.colors[h],e.colors[h]=f}return Object.defineProperty(e,To,{enumerable:!1,writable:!1,value:!0}),e}async function Xl(t){return Array.from(new Set((await Promise.all(t.filter(e=>!Vl(e)).map(async e=>await Bl(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function Yl(t){return(await Promise.all(t.map(async n=>Gl(n)?null:Zi(await Bl(n))))).filter(n=>!!n)}let Vf=3;function Gf(t,e=3){e>Vf||console.trace(`[SHIKI DEPRECATE]: ${t}`)}let Xt=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Ql(t,e){if(!e)return t;if(e[t]){const n=new Set([t]);for(;e[t];){if(t=e[t],n.has(t))throw new Xt(`Circular alias \`${Array.from(n).join(" -> ")} -> ${t}\``);n.add(t)}}return t}class Wf extends qu{constructor(n,i,r,s={}){super(n);g(this,"_resolvedThemes",new Map);g(this,"_resolvedGrammars",new Map);g(this,"_langMap",new Map);g(this,"_langGraph",new Map);g(this,"_textmateThemeCache",new WeakMap);g(this,"_loadedThemesCache",null);g(this,"_loadedLanguagesCache",null);this._resolver=n,this._themes=i,this._langs=r,this._alias=s,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}getTheme(n){return typeof n=="string"?this._resolvedThemes.get(n):this.loadTheme(n)}loadTheme(n){const i=Zi(n);return i.name&&(this._resolvedThemes.set(i.name,i),this._loadedThemesCache=null),i}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(n){let i=this._textmateThemeCache.get(n);i||(i=_i.createFromRawTheme(n),this._textmateThemeCache.set(n,i)),this._syncRegistry.setTheme(i)}getGrammar(n){return n=Ql(n,this._alias),this._resolvedGrammars.get(n)}loadLanguage(n){var o,l,a,d;if(this.getGrammar(n.name))return;const i=new Set([...this._langMap.values()].filter(c=>{var u;return(u=c.embeddedLangsLazy)==null?void 0:u.includes(n.name)}));this._resolver.addLanguage(n);const r={balancedBracketSelectors:n.balancedBracketSelectors||["*"],unbalancedBracketSelectors:n.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(n.scopeName,n);const s=this.loadGrammarWithConfiguration(n.scopeName,1,r);if(s.name=n.name,this._resolvedGrammars.set(n.name,s),n.aliases&&n.aliases.forEach(c=>{this._alias[c]=n.name}),this._loadedLanguagesCache=null,i.size)for(const c of i)this._resolvedGrammars.delete(c.name),this._loadedLanguagesCache=null,(l=(o=this._syncRegistry)==null?void 0:o._injectionGrammars)==null||l.delete(c.scopeName),(d=(a=this._syncRegistry)==null?void 0:a._grammars)==null||d.delete(c.scopeName),this.loadLanguage(this._langMap.get(c.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(n){for(const s of n)this.resolveEmbeddedLanguages(s);const i=Array.from(this._langGraph.entries()),r=i.filter(([s,o])=>!o);if(r.length){const s=i.filter(([o,l])=>{if(!l)return!1;const a=l.embeddedLanguages||l.embeddedLangs;return a==null?void 0:a.some(d=>r.map(([c])=>c).includes(d))}).filter(o=>!r.includes(o));throw new Xt(`Missing languages ${r.map(([o])=>`\`${o}\``).join(", ")}, required by ${s.map(([o])=>`\`${o}\``).join(", ")}`)}for(const[s,o]of i)this._resolver.addLanguage(o);for(const[s,o]of i)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(n){this._langMap.set(n.name,n),this._langGraph.set(n.name,n);const i=n.embeddedLanguages??n.embeddedLangs;if(i)for(const r of i)this._langGraph.set(r,this._langMap.get(r))}}class jf{constructor(e,n){g(this,"_langs",new Map);g(this,"_scopeToLang",new Map);g(this,"_injections",new Map);g(this,"_onigLib");this._onigLib={createOnigScanner:i=>e.createScanner(i),createOnigString:i=>e.createString(i)},n.forEach(i=>this.addLanguage(i))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(n=>{this._langs.set(n,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(e.scopeName)})}getInjections(e){const n=e.split(".");let i=[];for(let r=1;r<=n.length;r++){const s=n.slice(0,r).join(".");i=[...i,...this._injections.get(s)||[]]}return i}}let yn=0;function qf(t){yn+=1,t.warnings!==!1&&yn>=10&&yn%10===0&&console.warn(`[Shiki] ${yn} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new Xt("`engine` option is required for synchronous mode");const n=(t.langs||[]).flat(1),i=(t.themes||[]).flat(1).map(Zi),r=new jf(t.engine,n),s=new Wf(r,i,n,t.langAlias);let o;function l(S){return Ql(S,t.langAlias)}function a(S){m();const w=s.getGrammar(typeof S=="string"?S:S.name);if(!w)throw new Xt(`Language \`${S}\` not found, you may need to load it first`);return w}function d(S){if(S==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};m();const w=s.getTheme(S);if(!w)throw new Xt(`Theme \`${S}\` not found, you may need to load it first`);return w}function c(S){m();const w=d(S);o!==S&&(s.setTheme(w),o=S);const b=s.getColorMap();return{theme:w,colorMap:b}}function u(){return m(),s.getLoadedThemes()}function h(){return m(),s.getLoadedLanguages()}function f(...S){m(),s.loadLanguages(S.flat(1))}async function p(...S){return f(await Xl(S))}function y(...S){m();for(const w of S.flat(1))s.loadTheme(w)}async function v(...S){return m(),y(await Yl(S))}function m(){if(e)throw new Xt("Shiki instance has been disposed")}function C(){e||(e=!0,s.dispose(),yn-=1)}return{setTheme:c,getTheme:d,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:h,resolveLangAlias:l,loadLanguage:p,loadLanguageSync:f,loadTheme:v,loadThemeSync:y,dispose:C,[Symbol.dispose]:C}}async function Kf(t){t.engine||Gf("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[e,n,i]=await Promise.all([Yl(t.themes||[]),Xl(t.langs||[]),t.engine]);return qf({...t,themes:e,langs:n,engine:i})}async function Xf(t){const e=await Kf(t);return{getLastGrammarState:(...n)=>If(e,...n),codeToTokensBase:(n,i)=>Ds(e,n,i),codeToTokensWithThemes:(n,i)=>Kl(e,n,i),codeToTokens:(n,i)=>Oi(e,n,i),codeToHast:(n,i)=>Ni(e,n,i),codeToHtml:(n,i)=>Bf(e,n,i),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}function Yf(t){const e=t.langs,n=t.themes,i=t.engine;async function r(s){function o(u){var h;if(typeof u=="string"){if(u=((h=s.langAlias)==null?void 0:h[u])||u,Vl(u))return[];const f=e[u];if(!f)throw new J(`Language \`${u}\` is not included in this bundle. You may want to load it from external source.`);return f}return u}function l(u){if(Gl(u))return"none";if(typeof u=="string"){const h=n[u];if(!h)throw new J(`Theme \`${u}\` is not included in this bundle. You may want to load it from external source.`);return h}return u}const a=(s.themes??[]).map(u=>l(u)),d=(s.langs??[]).map(u=>o(u)),c=await Xf({engine:s.engine??i(),...s,themes:a,langs:d});return{...c,loadLanguage(...u){return c.loadLanguage(...u.map(o))},loadTheme(...u){return c.loadTheme(...u.map(l))},getBundledLanguages(){return e},getBundledThemes(){return n}}}return r}function Qf(t){let e;async function n(i={}){if(e){const r=await e;return await Promise.all([r.loadTheme(...i.themes||[]),r.loadLanguage(...i.langs||[])]),r}else{e=t({...i,themes:[],langs:[]});const r=await e;return await Promise.all([r.loadTheme(...i.themes||[]),r.loadLanguage(...i.langs||[])]),r}}return n}function Zf(t,e){const n=Qf(t);async function i(r,s){var a;const o=await n({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),l=await((a=e==null?void 0:e.guessEmbeddedLanguages)==null?void 0:a.call(e,r,s.lang,o));return l&&await o.loadLanguage(...l),o}return{getSingletonHighlighter(r){return n(r)},async codeToHtml(r,s){return(await i(r,s)).codeToHtml(r,s)},async codeToHast(r,s){return(await i(r,s)).codeToHast(r,s)},async codeToTokens(r,s){return(await i(r,s)).codeToTokens(r,s)},async codeToTokensBase(r,s){return(await i(r,s)).codeToTokensBase(r,s)},async codeToTokensWithThemes(r,s){return(await i(r,s)).codeToTokensWithThemes(r,s)},async getLastGrammarState(r,s){return(await n({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(r,s)}}}function Jf(t={}){var o;const{name:e="css-variables",variablePrefix:n="--shiki-",fontStyle:i=!0}=t,r=l=>{var a;return(a=t.variableDefaults)!=null&&a[l]?`var(${n}${l}, ${t.variableDefaults[l]})`:`var(${n}${l})`},s={name:e,type:"dark",colors:{"editor.foreground":r("foreground"),"editor.background":r("background"),"terminal.ansiBlack":r("ansi-black"),"terminal.ansiRed":r("ansi-red"),"terminal.ansiGreen":r("ansi-green"),"terminal.ansiYellow":r("ansi-yellow"),"terminal.ansiBlue":r("ansi-blue"),"terminal.ansiMagenta":r("ansi-magenta"),"terminal.ansiCyan":r("ansi-cyan"),"terminal.ansiWhite":r("ansi-white"),"terminal.ansiBrightBlack":r("ansi-bright-black"),"terminal.ansiBrightRed":r("ansi-bright-red"),"terminal.ansiBrightGreen":r("ansi-bright-green"),"terminal.ansiBrightYellow":r("ansi-bright-yellow"),"terminal.ansiBrightBlue":r("ansi-bright-blue"),"terminal.ansiBrightMagenta":r("ansi-bright-magenta"),"terminal.ansiBrightCyan":r("ansi-bright-cyan"),"terminal.ansiBrightWhite":r("ansi-bright-white")},tokenColors:[{scope:["keyword.operator.accessor","meta.group.braces.round.function.arguments","meta.template.expression","markup.fenced_code meta.embedded.block"],settings:{foreground:r("foreground")}},{scope:"emphasis",settings:{fontStyle:"italic"}},{scope:["strong","markup.heading.markdown","markup.bold.markdown"],settings:{fontStyle:"bold"}},{scope:["markup.italic.markdown"],settings:{fontStyle:"italic"}},{scope:"meta.link.inline.markdown",settings:{fontStyle:"underline",foreground:r("token-link")}},{scope:["string","markup.fenced_code","markup.inline"],settings:{foreground:r("token-string")}},{scope:["comment","string.quoted.docstring.multi"],settings:{foreground:r("token-comment")}},{scope:["constant.numeric","constant.language","constant.other.placeholder","constant.character.format.placeholder","variable.language.this","variable.other.object","variable.other.class","variable.other.constant","meta.property-name","meta.property-value","support"],settings:{foreground:r("token-constant")}},{scope:["keyword","storage.modifier","storage.type","storage.control.clojure","entity.name.function.clojure","entity.name.tag.yaml","support.function.node","support.type.property-name.json","punctuation.separator.key-value","punctuation.definition.template-expression"],settings:{foreground:r("token-keyword")}},{scope:"variable.parameter.function",settings:{foreground:r("token-parameter")}},{scope:["support.function","entity.name.type","entity.other.inherited-class","meta.function-call","meta.instance.constructor","entity.other.attribute-name","entity.name.function","constant.keyword.clojure"],settings:{foreground:r("token-function")}},{scope:["entity.name.tag","string.quoted","string.regexp","string.interpolated","string.template","string.unquoted.plain.out.yaml","keyword.other.template"],settings:{foreground:r("token-string-expression")}},{scope:["punctuation.definition.arguments","punctuation.definition.dict","punctuation.separator","meta.function-call.arguments"],settings:{foreground:r("token-punctuation")}},{scope:["markup.underline.link","punctuation.definition.metadata.markdown"],settings:{foreground:r("token-link")}},{scope:["beginning.punctuation.definition.list.markdown"],settings:{foreground:r("token-string")}},{scope:["punctuation.definition.string.begin.markdown","punctuation.definition.string.end.markdown","string.other.link.title.markdown","string.other.link.description.markdown"],settings:{foreground:r("token-keyword")}},{scope:["markup.inserted","meta.diff.header.to-file","punctuation.definition.inserted"],settings:{foreground:r("token-inserted")}},{scope:["markup.deleted","meta.diff.header.from-file","punctuation.definition.deleted"],settings:{foreground:r("token-deleted")}},{scope:["markup.changed","punctuation.definition.changed"],settings:{foreground:r("token-changed")}}]};return i||(s.tokenColors=(o=s.tokenColors)==null?void 0:o.map(l=>{var a;return(a=l.settings)!=null&&a.fontStyle&&delete l.settings.fontStyle,l})),s}function ln(t){if([...t].length!==1)throw new Error(`Expected "${t}" to be a single code point`);return t.codePointAt(0)}function ep(t,e,n){return t.has(e)||t.set(e,n),t.get(e)}const Os=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),se=String.raw;function dn(t,e){if(t==null)throw new Error(e??"Value expected");return t}const Zl=se`\[\^?`,Jl=`c.? | C(?:-.?)?|${se`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${se`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${se`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${se`o\{[^\}]*\}?`}|${se`\d{1,3}`}`,Ns=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Qn=new RegExp(se`
14
+ \\ (?:
15
+ ${Jl}
16
+ | [gk]<[^>]*>?
17
+ | [gk]'[^']*'?
18
+ | .
19
+ )
20
+ | \( (?:
21
+ \? (?:
22
+ [:=!>({]
23
+ | <[=!]
24
+ | <[^>]*>
25
+ | '[^']*'
26
+ | ~\|?
27
+ | #(?:[^)\\]|\\.?)*
28
+ | [^:)]*[:)]
29
+ )?
30
+ | \*[^\)]*\)?
31
+ )?
32
+ | (?:${Ns.source})+
33
+ | ${Zl}
34
+ | .
35
+ `.replace(/\s+/g,""),"gsu"),vr=new RegExp(se`
36
+ \\ (?:
37
+ ${Jl}
38
+ | .
39
+ )
40
+ | \[:(?:\^?\p{Alpha}+|\^):\]
41
+ | ${Zl}
42
+ | &&
43
+ | .
44
+ `.replace(/\s+/g,""),"gsu");function tp(t,e={}){const n={flags:"",...e,rules:{captureGroup:!1,singleline:!1,...e.rules}};if(typeof t!="string")throw new Error("String expected as pattern");const i=Sp(n.flags),r=[i.extended],s={captureGroup:n.rules.captureGroup,getCurrentModX(){return r.at(-1)},numOpenGroups:0,popModX(){r.pop()},pushModX(u){r.push(u)},replaceCurrentModX(u){r[r.length-1]=u},singleline:n.rules.singleline};let o=[],l;for(Qn.lastIndex=0;l=Qn.exec(t);){const u=np(s,t,l[0],Qn.lastIndex);u.tokens?o.push(...u.tokens):u.token&&o.push(u.token),u.lastIndex!==void 0&&(Qn.lastIndex=u.lastIndex)}const a=[];let d=0;o.filter(u=>u.type==="GroupOpen").forEach(u=>{u.kind==="capturing"?u.number=++d:u.raw==="("&&a.push(u)}),d||a.forEach((u,h)=>{u.kind="capturing",u.number=h+1});const c=d||a.length;return{tokens:o.map(u=>u.type==="EscapedNumber"?wp(u,c):u).flat(),flags:i}}function np(t,e,n,i){const[r,s]=n;if(n==="["||n==="[^"){const o=ip(e,n,i);return{tokens:o.tokens,lastIndex:o.lastIndex}}if(r==="\\"){if("AbBGyYzZ".includes(s))return{token:Io(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:fp(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:td(n)}}if(s==="K")return{token:nd("keep",n)};if(s==="N"||s==="R")return{token:Tt("newline",n,{negate:s==="N"})};if(s==="O")return{token:Tt("any",n)};if(s==="X")return{token:Tt("text_segment",n)};const o=ed(n,{inCharClass:!1});return Array.isArray(o)?{tokens:o}:{token:o}}if(r==="("){if(s==="*")return{token:yp(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(e[i]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:i+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:mp(n,t)};if(t.pushModX(t.getCurrentModX()),t.numOpenGroups++,n==="("&&!t.captureGroup||n==="(?:")return{token:qt("group",n)};if(n==="(?>")return{token:qt("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:qt(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&t.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:qt("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:qt("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(t.popModX(),t.numOpenGroups--,t.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:cp(n)}}if(t.getCurrentModX()){if(n==="#"){const o=e.indexOf(`
45
+ `,i);return{lastIndex:o===-1?e.length:o}}if(/^\s$/.test(n)){const o=/\s+/y;return o.lastIndex=i,{lastIndex:o.exec(e)?o.lastIndex:i}}}if(n===".")return{token:Tt("dot",n)};if(n==="^"||n==="$"){const o=t.singleline?{"^":se`\A`,$:se`\Z`}[n]:n;return{token:Io(o,n)}}return n==="|"?{token:sp(n)}:Ns.test(n)?{tokens:xp(n)}:{token:ot(ln(n),n)}}function ip(t,e,n){const i=[Ao(e[1]==="^",e)];let r=1,s;for(vr.lastIndex=n;s=vr.exec(t);){const o=s[0];if(o[0]==="["&&o[1]!==":")r++,i.push(Ao(o[1]==="^",o));else if(o==="]"){if(i.at(-1).type==="CharacterClassOpen")i.push(ot(93,o));else if(r--,i.push(op(o)),!r)break}else{const l=rp(o);Array.isArray(l)?i.push(...l):i.push(l)}}return{tokens:i,lastIndex:vr.lastIndex||t.length}}function rp(t){if(t[0]==="\\")return ed(t,{inCharClass:!0});if(t[0]==="["){const e=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(t);if(!e||!Os.has(e.groups.name))throw new Error(`Invalid POSIX class "${t}"`);return Tt("posix",t,{value:e.groups.name,negate:!!e.groups.negate})}return t==="-"?ap(t):t==="&&"?lp(t):ot(ln(t),t)}function ed(t,{inCharClass:e}){const n=t[1];if(n==="c"||n==="C")return gp(t);if("dDhHsSwW".includes(n))return vp(t);if(t.startsWith(se`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${t}"`);if(/^\\[pP]\{/.test(t)){if(t.length===3)throw new Error(`Incomplete or invalid Unicode property "${t}"`);return Cp(t)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(t))try{const i=t.split(/\\x/).slice(1).map(o=>parseInt(o,16)),r=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(i)),s=new TextEncoder;return[...r].map(o=>{const l=[...s.encode(o)].map(a=>`\\x${a.toString(16)}`).join("");return ot(ln(o),l)})}catch{throw new Error(`Multibyte code "${t}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return ot(bp(t),t);if(Po.has(n))return ot(Po.get(n),t);if(/\d/.test(n))return dp(e,t);if(t==="\\")throw new Error(se`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${t}"`);if([...t].length===2)return ot(t.codePointAt(1),t);throw new Error(`Unexpected escape "${t}"`)}function sp(t){return{type:"Alternator",raw:t}}function Io(t,e){return{type:"Assertion",kind:t,raw:e}}function td(t){return{type:"Backreference",raw:t}}function ot(t,e){return{type:"Character",value:t,raw:e}}function op(t){return{type:"CharacterClassClose",raw:t}}function ap(t){return{type:"CharacterClassHyphen",raw:t}}function lp(t){return{type:"CharacterClassIntersector",raw:t}}function Ao(t,e){return{type:"CharacterClassOpen",negate:t,raw:e}}function Tt(t,e,n={}){return{type:"CharacterSet",kind:t,...n,raw:e}}function nd(t,e,n={}){return t==="keep"?{type:"Directive",kind:t,raw:e}:{type:"Directive",kind:t,flags:dn(n.flags),raw:e}}function dp(t,e){return{type:"EscapedNumber",inCharClass:t,raw:e}}function cp(t){return{type:"GroupClose",raw:t}}function qt(t,e,n={}){return{type:"GroupOpen",kind:t,...n,raw:e}}function up(t,e,n,i){return{type:"NamedCallout",kind:t,tag:e,arguments:n,raw:i}}function hp(t,e,n,i){return{type:"Quantifier",kind:t,min:e,max:n,raw:i}}function fp(t){return{type:"Subroutine",raw:t}}const pp=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Po=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function gp(t){const e=t[1]==="c"?t[2]:t[3];if(!e||!/[A-Za-z]/.test(e))throw new Error(`Unsupported control character "${t}"`);return ot(ln(e.toUpperCase())-64,t)}function mp(t,e){let{on:n,off:i}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(t).groups;i??(i="");const r=(e.getCurrentModX()||n.includes("x"))&&!i.includes("x"),s=Do(n),o=Do(i),l={};if(s&&(l.enable=s),o&&(l.disable=o),t.endsWith(")"))return e.replaceCurrentModX(r),nd("flags",t,{flags:l});if(t.endsWith(":"))return e.pushModX(r),e.numOpenGroups++,qt("group",t,{...(s||o)&&{flags:l}});throw new Error(`Unexpected flag modifier "${t}"`)}function yp(t){const e=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(t);if(!e)throw new Error(`Incomplete or invalid named callout "${t}"`);const{name:n,tag:i,args:r}=e.groups;if(!n)throw new Error(`Invalid named callout "${t}"`);if(i==="")throw new Error(`Named callout tag with empty value not allowed "${t}"`);const s=r?r.split(",").filter(c=>c!=="").map(c=>/^[+-]?\d+$/.test(c)?+c:c):[],[o,l,a]=s,d=pp.has(n)?n.toLowerCase():"custom";switch(d){case"fail":case"mismatch":case"skip":if(s.length>0)throw new Error(`Named callout arguments not allowed "${s}"`);break;case"error":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(typeof o=="string")throw new Error(`Named callout argument must be a number "${o}"`);break;case"max":if(!s.length||s.length>2)throw new Error(`Named callout must have one or two arguments "${s}"`);if(typeof o=="string"&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(s.length===2&&(typeof l=="number"||!/^[<>X]$/.test(l)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${l}"`);break;case"count":case"total_count":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(s.length===1&&(typeof o=="number"||!/^[<>X]$/.test(o)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case"cmp":if(s.length!==3)throw new Error(`Named callout must have three arguments "${s}"`);if(typeof o=="string"&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof l=="number"||!/^(?:[<>!=]=|[<>])$/.test(l))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${l}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument three must be a tag or number "${a}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${d}"`)}return up(d,i??null,(r==null?void 0:r.split(","))??null,t)}function Mo(t){let e=null,n,i;if(t[0]==="{"){const{minStr:r,maxStr:s}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(t).groups,o=1e5;if(+r>o||s&&+s>o)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+r,i=s===void 0?+r:s===""?1/0:+s,n>i&&(e="possessive",[n,i]=[i,n]),t.endsWith("?")){if(e==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');e="lazy"}else e||(e="greedy")}else n=t[0]==="+"?1:0,i=t[0]==="?"?1:1/0,e=t[1]==="+"?"possessive":t[1]==="?"?"lazy":"greedy";return hp(e,n,i,t)}function vp(t){const e=t[1].toLowerCase();return Tt({d:"digit",h:"hex",s:"space",w:"word"}[e],t,{negate:t[1]!==e})}function Cp(t){const{p:e,neg:n,value:i}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(t).groups;return Tt("property",t,{value:i,negate:e==="P"&&!n||e==="p"&&!!n})}function Do(t){const e={};return t.includes("i")&&(e.ignoreCase=!0),t.includes("m")&&(e.dotAll=!0),t.includes("x")&&(e.extended=!0),Object.keys(e).length?e:null}function Sp(t){const e={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<t.length;n++){const i=t[n];if(!"imxDPSWy".includes(i))throw new Error(`Invalid flag "${i}"`);if(i==="y"){if(!/^y{[gw]}/.test(t.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');e.textSegmentMode=t[n+2]==="g"?"grapheme":"word",n+=3;continue}e[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[i]]=!0}return e}function bp(t){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(t))throw new Error(`Incomplete or invalid escape "${t}"`);const e=t[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(t).groups.hex:t.slice(2);return parseInt(e,16)}function wp(t,e){const{raw:n,inCharClass:i}=t,r=n.slice(1);if(!i&&(r!=="0"&&r.length===1||r[0]!=="0"&&+r<=e))return[td(n)];const s=[],o=r.match(/^[0-7]+|\d/g);for(let l=0;l<o.length;l++){const a=o[l];let d;if(l===0&&a!=="8"&&a!=="9"){if(d=parseInt(a,8),d>127)throw new Error(se`Octal encoded byte above 177 unsupported "${n}"`)}else d=ln(a);s.push(ot(d,(l===0?"\\":"")+a))}return s}function xp(t){const e=[],n=new RegExp(Ns,"gy");let i;for(;i=n.exec(t);){const r=i[0];if(r[0]==="{"){const s=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(r);if(s){const{min:o,max:l}=s.groups;if(+o>+l&&r.endsWith("?")){n.lastIndex--,e.push(Mo(r.slice(0,-1)));continue}}}e.push(Mo(r))}return e}function id(t,e){if(!Array.isArray(t.body))throw new Error("Expected node with body array");if(t.body.length!==1)return!1;const n=t.body[0];return!e||Object.keys(e).every(i=>e[i]===n[i])}function kp(t){return Lp.has(t.type)}const Lp=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function rd(t,e={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e,rules:{captureGroup:!1,singleline:!1,...e.rules}},i=tp(t,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),r=(h,f)=>{const p=i.tokens[s.nextIndex];switch(s.parent=h,s.nextIndex++,p.type){case"Alternator":return Ht();case"Assertion":return Ep(p);case"Backreference":return Rp(p,s);case"Character":return Ji(p.value,{useLastValid:!!f.isCheckingRangeEnd});case"CharacterClassHyphen":return _p(p,s,f);case"CharacterClassOpen":return Tp(p,s,f);case"CharacterSet":return Ip(p,s);case"Directive":return Op(p.kind,{flags:p.flags});case"GroupOpen":return Ap(p,s,f);case"NamedCallout":return Fp(p.kind,p.tag,p.arguments);case"Quantifier":return Pp(p,s);case"Subroutine":return Mp(p,s);default:throw new Error(`Unexpected token type "${p.type}"`)}},s={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:i.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:r},o=zp(Np(i.flags));let l=o.body[0];for(;s.nextIndex<i.tokens.length;){const h=r(l,{});h.type==="Alternative"?(o.body.push(h),l=h):l.body.push(h)}const{capturingGroups:a,hasNumberedRef:d,namedGroupsByName:c,subroutines:u}=s;if(d&&c.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:h}of u)if(typeof h=="number"){if(h>a.length)throw new Error("Subroutine uses a group number that's not defined");h&&(a[h-1].isSubroutined=!0)}else if(c.has(h)){if(c.get(h).length>1)throw new Error(se`Subroutine uses a duplicate group name "\g<${h}>"`);c.get(h)[0].isSubroutined=!0}else throw new Error(se`Subroutine uses a group name that's not defined "\g<${h}>"`);return o}function Ep({kind:t}){return ts(dn({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[t],`Unexpected assertion kind "${t}"`),{negate:t===se`\B`||t===se`\Y`})}function Rp({raw:t},e){const n=/^\\k[<']/.test(t),i=n?t.slice(3,-1):t.slice(1),r=(s,o=!1)=>{const l=e.capturingGroups.length;let a=!1;if(s>l)if(e.skipBackrefValidation)a=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,ns(o?l+1-s:s,{orphan:a})};if(n){const s=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(i);if(s)return r(+s.groups.num,!!s.groups.sign);if(/[-+]/.test(i))throw new Error(`Invalid backref name "${t}"`);if(!e.namedGroupsByName.has(i))throw new Error(`Group name not defined to the left "${t}"`);return ns(i)}return r(+i)}function _p(t,e,n){const{tokens:i,walk:r}=e,s=e.parent,o=s.body.at(-1),l=i[e.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!=="CharacterClass"&&o.type!=="CharacterClassRange"&&l&&l.type!=="CharacterClassOpen"&&l.type!=="CharacterClassClose"&&l.type!=="CharacterClassIntersector"){const a=r(s,{...n,isCheckingRangeEnd:!0});if(o.type==="Character"&&a.type==="Character")return s.body.pop(),Hp(o,a);throw new Error("Invalid character class range")}return Ji(ln("-"))}function Tp({negate:t},e,n){const{tokens:i,walk:r}=e,s=[Si()],o=i[e.nextIndex];let l=No(o);for(;l.type!=="CharacterClassClose";){if(l.type==="CharacterClassIntersector")s.push(Si()),e.nextIndex++;else{const d=s.at(-1);d.body.push(r(d,n))}l=No(i[e.nextIndex],o)}const a=Si({negate:t});return s.length===1?a.body=s[0].body:(a.kind="intersection",a.body=s.map(d=>d.body.length===1?d.body[0]:d)),e.nextIndex++,a}function Ip({kind:t,negate:e,value:n},i){const{normalizeUnknownPropertyNames:r,skipPropertyNameValidation:s,unicodePropertyMap:o}=i;if(t==="property"){const l=er(n);if(Os.has(l)&&!(o!=null&&o.has(l)))t="posix",n=l;else return Kt(n,{negate:e,normalizeUnknownPropertyNames:r,skipPropertyNameValidation:s,unicodePropertyMap:o})}return t==="posix"?$p(n,{negate:e}):is(t,{negate:e})}function Ap(t,e,n){const{tokens:i,capturingGroups:r,namedGroupsByName:s,skipLookbehindValidation:o,walk:l}=e,a=Up(t),d=a.type==="AbsenceFunction",c=Oo(a),u=c&&a.negate;if(a.type==="CapturingGroup"&&(r.push(a),a.name&&ep(s,a.name,[]).push(a)),d&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let h=Fo(i[e.nextIndex]);for(;h.type!=="GroupClose";){if(h.type==="Alternator")a.body.push(Ht()),e.nextIndex++;else{const f=a.body.at(-1),p=l(f,{...n,isInAbsenceFunction:n.isInAbsenceFunction||d,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||u});if(f.body.push(p),(c||n.isInLookbehind)&&!o){const y="Lookbehind includes a pattern not allowed by Oniguruma";if(u||n.isInNegLookbehind){if(Ho(p)||p.type==="CapturingGroup")throw new Error(y)}else if(Ho(p)||Oo(p)&&p.negate)throw new Error(y)}}h=Fo(i[e.nextIndex])}return e.nextIndex++,a}function Pp({kind:t,min:e,max:n},i){const r=i.parent,s=r.body.at(-1);if(!s||!kp(s))throw new Error("Quantifier requires a repeatable token");const o=od(t,e,n,s);return r.body.pop(),o}function Mp({raw:t},e){const{capturingGroups:n,subroutines:i}=e;let r=t.slice(3,-1);const s=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(r);if(s){const l=+s.groups.num,a=n.length;if(e.hasNumberedRef=!0,r={"":l,"+":a+l,"-":a+1-l}[s.groups.sign],r<1)throw new Error("Invalid subroutine number")}else r==="0"&&(r=0);const o=ad(r);return i.push(o),o}function Dp(t,e){return{type:"AbsenceFunction",kind:t,body:qn(e==null?void 0:e.body)}}function Ht(t){return{type:"Alternative",body:ld(t==null?void 0:t.body)}}function ts(t,e){const n={type:"Assertion",kind:t};return(t==="word_boundary"||t==="text_segment_boundary")&&(n.negate=!!(e!=null&&e.negate)),n}function ns(t,e){const n=!!(e!=null&&e.orphan);return{type:"Backreference",ref:t,...n&&{orphan:n}}}function sd(t,e){const n={name:void 0,isSubroutined:!1,...e};if(n.name!==void 0&&!Bp(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:t,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:qn(e==null?void 0:e.body)}}function Ji(t,e){const n={useLastValid:!1,...e};if(t>1114111){const i=t.toString(16);if(n.useLastValid)t=1114111;else throw t>1310719?new Error(`Invalid code point out of range "\\x{${i}}"`):new Error(`Invalid code point out of range in JS "\\x{${i}}"`)}return{type:"Character",value:t}}function Si(t){const e={kind:"union",negate:!1,...t};return{type:"CharacterClass",kind:e.kind,negate:e.negate,body:ld(t==null?void 0:t.body)}}function Hp(t,e){if(e.value<t.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:t,max:e}}function is(t,e){const n=!!(e!=null&&e.negate),i={type:"CharacterSet",kind:t};return(t==="digit"||t==="hex"||t==="newline"||t==="space"||t==="word")&&(i.negate=n),(t==="text_segment"||t==="newline"&&!n)&&(i.variableLength=!0),i}function Op(t,e={}){if(t==="keep")return{type:"Directive",kind:t};if(t==="flags")return{type:"Directive",kind:t,flags:dn(e.flags)};throw new Error(`Unexpected directive kind "${t}"`)}function Np(t){return{type:"Flags",...t}}function Ve(t){const e=t==null?void 0:t.atomic,n=t==null?void 0:t.flags;if(e&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...e&&{atomic:e},...n&&{flags:n},body:qn(t==null?void 0:t.body)}}function Et(t){const e={behind:!1,negate:!1,...t};return{type:"LookaroundAssertion",kind:e.behind?"lookbehind":"lookahead",negate:e.negate,body:qn(t==null?void 0:t.body)}}function Fp(t,e,n){return{type:"NamedCallout",kind:t,tag:e,arguments:n}}function $p(t,e){const n=!!(e!=null&&e.negate);if(!Os.has(t))throw new Error(`Invalid POSIX class "${t}"`);return{type:"CharacterSet",kind:"posix",value:t,negate:n}}function od(t,e,n,i){if(e>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:t,min:e,max:n,body:i}}function zp(t,e){return{type:"Regex",body:qn(e==null?void 0:e.body),flags:t}}function ad(t){return{type:"Subroutine",ref:t}}function Kt(t,e){var r;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e};let i=(r=n.unicodePropertyMap)==null?void 0:r.get(er(t));if(!i){if(n.normalizeUnknownPropertyNames)i=Vp(t);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(se`Invalid Unicode property "\p{${t}}"`)}return{type:"CharacterSet",kind:"property",value:i??t,negate:n.negate}}function Up({flags:t,kind:e,name:n,negate:i,number:r}){switch(e){case"absence_repeater":return Dp("repeater");case"atomic":return Ve({atomic:!0});case"capturing":return sd(r,{name:n});case"group":return Ve({flags:t});case"lookahead":case"lookbehind":return Et({behind:e==="lookbehind",negate:i});default:throw new Error(`Unexpected group kind "${e}"`)}}function qn(t){if(t===void 0)t=[Ht()];else if(!Array.isArray(t)||!t.length||!t.every(e=>e.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return t}function ld(t){if(t===void 0)t=[];else if(!Array.isArray(t)||!t.every(e=>!!e.type))throw new Error("Invalid body; expected array of nodes");return t}function Ho(t){return t.type==="LookaroundAssertion"&&t.kind==="lookahead"}function Oo(t){return t.type==="LookaroundAssertion"&&t.kind==="lookbehind"}function Bp(t){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(t)}function Vp(t){return t.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function er(t){return t.replace(/[- _]+/g,"").toLowerCase()}function No(t,e){const n=e;return dn(t,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function Fo(t){return dn(t,"Unclosed group")}function _n(t,e,n=null){function i(s,o){for(let l=0;l<s.length;l++){const a=r(s[l],o,l,s);l=Math.max(-1,l+a)}}function r(s,o=null,l=null,a=null){var m,C;let d=0,c=!1;const u={node:s,parent:o,key:l,container:a,root:t,remove(){Zn(a).splice(Math.max(0,Bt(l)+d),1),d--,c=!0},removeAllNextSiblings(){return Zn(a).splice(Bt(l)+1)},removeAllPrevSiblings(){const S=Bt(l)+d;return d-=S,Zn(a).splice(0,Math.max(0,S))},replaceWith(S,w={}){const b=!!w.traverse;a?a[Math.max(0,Bt(l)+d)]=S:dn(o,"Can't replace root node")[l]=S,b&&r(S,o,l,a),c=!0},replaceWithMultiple(S,w={}){const b=!!w.traverse;if(Zn(a).splice(Math.max(0,Bt(l)+d),1,...S),d+=S.length-1,b){let k=0;for(let x=0;x<S.length;x++)k+=r(S[x],o,Bt(l)+x+k,a)}c=!0},skip(){c=!0}},{type:h}=s,f=e["*"],p=e[h],y=typeof f=="function"?f:f==null?void 0:f.enter,v=typeof p=="function"?p:p==null?void 0:p.enter;if(y==null||y(u,n),v==null||v(u,n),!c)switch(h){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":i(s.body,s);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":r(s.min,s,"min"),r(s.max,s,"max");break;case"Quantifier":r(s.body,s,"body");break;case"Regex":i(s.body,s),r(s.flags,s,"flags");break;default:throw new Error(`Unexpected node type "${h}"`)}return(m=p==null?void 0:p.exit)==null||m.call(p,u,n),(C=f==null?void 0:f.exit)==null||C.call(f,u,n),d}return r(t),t}function Zn(t){if(!Array.isArray(t))throw new Error("Container expected");return t}function Bt(t){if(typeof t!="number")throw new Error("Numeric key expected");return t}const Gp=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Wp(t,e){for(let n=0;n<t.length;n++)t[n]>=e&&t[n]++}function jp(t,e,n,i){return t.slice(0,e)+i+t.slice(e+n.length)}const Ne=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Fs(t,e,n,i){const r=new RegExp(String.raw`${e}|(?<$skip>\[\^?|\\?.)`,"gsu"),s=[!1];let o=0,l="";for(const a of t.matchAll(r)){const{0:d,groups:{$skip:c}}=a;if(!c&&(!i||i===Ne.DEFAULT==!o)){n instanceof Function?l+=n(a,{context:o?Ne.CHAR_CLASS:Ne.DEFAULT,negated:s[s.length-1]}):l+=n;continue}d[0]==="["?(o++,s.push(d[1]==="^")):d==="]"&&o&&(o--,s.pop()),l+=d}return l}function dd(t,e,n,i){Fs(t,e,n,i)}function qp(t,e,n=0,i){if(!new RegExp(e,"su").test(t))return null;const r=new RegExp(`${e}|(?<$skip>\\\\?.)`,"gsu");r.lastIndex=n;let s=0,o;for(;o=r.exec(t);){const{0:l,groups:{$skip:a}}=o;if(!a&&(!i||i===Ne.DEFAULT==!s))return o;l==="["?s++:l==="]"&&s&&s--,r.lastIndex==o.index&&r.lastIndex++}return null}function Jn(t,e,n){return!!qp(t,e,0,n)}function Kp(t,e){const n=/\\?./gsu;n.lastIndex=e;let i=t.length,r=0,s=1,o;for(;o=n.exec(t);){const[l]=o;if(l==="[")r++;else if(r)l==="]"&&r--;else if(l==="(")s++;else if(l===")"&&(s--,!s)){i=o.index;break}}return t.slice(e,i)}const $o=new RegExp(String.raw`(?<noncapturingStart>${Gp})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Xp(t,e){const n=(e==null?void 0:e.hiddenCaptures)??[];let i=(e==null?void 0:e.captureTransfers)??new Map;if(!/\(\?>/.test(t))return{pattern:t,captureTransfers:i,hiddenCaptures:n};const r="(?>",s="(?:(?=(",o=[0],l=[];let a=0,d=0,c=NaN,u;do{u=!1;let h=0,f=0,p=!1,y;for($o.lastIndex=Number.isNaN(c)?0:c+s.length;y=$o.exec(t);){const{0:v,index:m,groups:{capturingStart:C,noncapturingStart:S}}=y;if(v==="[")h++;else if(h)v==="]"&&h--;else if(v===r&&!p)c=m,p=!0;else if(p&&S)f++;else if(C)p?f++:(a++,o.push(a+d));else if(v===")"&&p){if(!f){d++;const w=a+d;if(t=`${t.slice(0,c)}${s}${t.slice(c+r.length,m)}))<$$${w}>)${t.slice(m+1)}`,u=!0,l.push(w),Wp(n,w),i.size){const b=new Map;i.forEach((k,x)=>{b.set(x>=w?x+1:x,k.map(E=>E>=w?E+1:E))}),i=b}break}f--}}}while(u);return n.push(...l),t=Fs(t,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:h,groups:{backrefNum:f,wrappedBackrefNum:p}})=>{if(f){const y=+f;if(y>o.length-1)throw new Error(`Backref "${h}" greater than number of captures`);return`\\${o[y]}`}return`\\${p}`},Ne.DEFAULT),{pattern:t,captureTransfers:i,hiddenCaptures:n}}const cd=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Cr=new RegExp(String.raw`
46
+ \\(?: \d+
47
+ | c[A-Za-z]
48
+ | [gk]<[^>]+>
49
+ | [pPu]\{[^\}]+\}
50
+ | u[A-Fa-f\d]{4}
51
+ | x[A-Fa-f\d]{2}
52
+ )
53
+ | \((?: \? (?: [:=!>]
54
+ | <(?:[=!]|[^>]+>)
55
+ | [A-Za-z\-]+:
56
+ | \(DEFINE\)
57
+ ))?
58
+ | (?<qBase>${cd})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
59
+ | \\?.
60
+ `.replace(/\s+/g,""),"gsu");function Yp(t){if(!new RegExp(`${cd}\\+`).test(t))return{pattern:t};const e=[];let n=null,i=null,r="",s=0,o;for(Cr.lastIndex=0;o=Cr.exec(t);){const{0:l,index:a,groups:{qBase:d,qMod:c,invalidQ:u}}=o;if(l==="[")s||(i=a),s++;else if(l==="]")s?s--:i=null;else if(!s)if(c==="+"&&r&&!r.startsWith("(")){if(u)throw new Error(`Invalid quantifier "${l}"`);let h=-1;if(/^\{\d+\}$/.test(d))t=jp(t,a+d.length,c,"");else{if(r===")"||r==="]"){const f=r===")"?n:i;if(f===null)throw new Error(`Invalid unmatched "${r}"`);t=`${t.slice(0,f)}(?>${t.slice(f,a)}${d})${t.slice(a+l.length)}`}else t=`${t.slice(0,a-r.length)}(?>${r}${d})${t.slice(a+l.length)}`;h+=4}Cr.lastIndex+=h}else l[0]==="("?e.push(a):l===")"&&(n=e.length?e.pop():null);r=l}return{pattern:t}}const Oe=String.raw,Qp=Oe`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,rs=Oe`\(\?R=(?<rDepth>[^\)]+)\)|${Qp}`,tr=Oe`\(\?<(?![=!])(?<captureName>[^>]+)>`,ud=Oe`${tr}|(?<unnamed>\()(?!\?)`,Lt=new RegExp(Oe`${tr}|${rs}|\(\?|\\?.`,"gsu"),Sr="Cannot use multiple overlapping recursions";function Zp(t,e){const{hiddenCaptures:n,mode:i}={hiddenCaptures:[],mode:"plugin",...e};let r=(e==null?void 0:e.captureTransfers)??new Map;if(!new RegExp(rs,"su").test(t))return{pattern:t,captureTransfers:r,hiddenCaptures:n};if(i==="plugin"&&Jn(t,Oe`\(\?\(DEFINE\)`,Ne.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const s=[],o=Jn(t,Oe`\\[1-9]`,Ne.DEFAULT),l=new Map,a=[];let d=!1,c=0,u=0,h;for(Lt.lastIndex=0;h=Lt.exec(t);){const{0:f,groups:{captureName:p,rDepth:y,gRNameOrNum:v,gRDepth:m}}=h;if(f==="[")c++;else if(c)f==="]"&&c--;else if(y){if(zo(y),d)throw new Error(Sr);if(o)throw new Error(`${i==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const C=t.slice(0,h.index),S=t.slice(Lt.lastIndex);if(Jn(S,rs,Ne.DEFAULT))throw new Error(Sr);const w=+y-1;t=Uo(C,S,w,!1,n,s,u),r=Vo(r,C,w,s.length,0,u);break}else if(v){zo(m);let C=!1;for(const I of a)if(I.name===v||I.num===+v){if(C=!0,I.hasRecursedWithin)throw new Error(Sr);break}if(!C)throw new Error(Oe`Recursive \g cannot be used outside the referenced group "${i==="external"?v:Oe`\g<${v}&R=${m}>`}"`);const S=l.get(v),w=Kp(t,S);if(o&&Jn(w,Oe`${tr}|\((?!\?)`,Ne.DEFAULT))throw new Error(`${i==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const b=t.slice(S,h.index),k=w.slice(b.length+f.length),x=s.length,E=+m-1,R=Uo(b,k,E,!0,n,s,u);r=Vo(r,b,E,s.length-x,x,u);const A=t.slice(0,S),D=t.slice(S+w.length);t=`${A}${R}${D}`,Lt.lastIndex+=R.length-f.length-b.length-k.length,a.forEach(I=>I.hasRecursedWithin=!0),d=!0}else if(p)u++,l.set(String(u),Lt.lastIndex),l.set(p,Lt.lastIndex),a.push({num:u,name:p});else if(f[0]==="("){const C=f==="(";C&&(u++,l.set(String(u),Lt.lastIndex)),a.push(C?{num:u}:{})}else f===")"&&a.pop()}return n.push(...s),{pattern:t,captureTransfers:r,hiddenCaptures:n}}function zo(t){const e=`Max depth must be integer between 2 and 100; used ${t}`;if(!/^[1-9]\d*$/.test(t))throw new Error(e);if(t=+t,t<2||t>100)throw new Error(e)}function Uo(t,e,n,i,r,s,o){const l=new Set;i&&dd(t+e,tr,({groups:{captureName:d}})=>{l.add(d)},Ne.DEFAULT);const a=[n,i?l:null,r,s,o];return`${t}${Bo(`(?:${t}`,"forward",...a)}(?:)${Bo(`${e})`,"backward",...a)}${e}`}function Bo(t,e,n,i,r,s,o){const a=c=>e==="forward"?c+2:n-c+2-1;let d="";for(let c=0;c<n;c++){const u=a(c);d+=Fs(t,Oe`${ud}|\\k<(?<backref>[^>]+)>`,({0:h,groups:{captureName:f,unnamed:p,backref:y}})=>{if(y&&i&&!i.has(y))return h;const v=`_$${u}`;if(p||f){const m=o+s.length+1;return s.push(m),Jp(r,m),p?h:`(?<${f}${v}>`}return Oe`\k<${y}${v}>`},Ne.DEFAULT)}return d}function Jp(t,e){for(let n=0;n<t.length;n++)t[n]>=e&&t[n]++}function Vo(t,e,n,i,r,s){if(t.size&&i){let o=0;dd(e,ud,()=>o++,Ne.DEFAULT);const l=s-o+r,a=new Map;return t.forEach((d,c)=>{const u=(i-o*n)/n,h=o*n,f=c>l+o?c+i:c,p=[];for(const y of d)if(y<=l)p.push(y);else if(y>l+o+u)p.push(y+i);else if(y<=l+o)for(let v=0;v<=n;v++)p.push(y+o*v);else for(let v=0;v<=n;v++)p.push(y+h+u*v);a.set(f,p)}),a}return t}var te=String.fromCodePoint,$=String.raw,We={},nr=globalThis.RegExp;We.flagGroups=(()=>{try{new nr("(?i:)")}catch{return!1}return!0})();We.unicodeSets=(()=>{try{new nr("[[]]","v")}catch{return!1}return!0})();We.bugFlagVLiteralHyphenIsRange=We.unicodeSets?(()=>{try{new nr($`[\d\-a]`,"v")}catch{return!0}return!1})():!1;We.bugNestedClassIgnoresNegation=We.unicodeSets&&new nr("[[^a]]","v").test("a");function Fi(t,{enable:e,disable:n}){return{dotAll:!(n!=null&&n.dotAll)&&!!(e!=null&&e.dotAll||t.dotAll),ignoreCase:!(n!=null&&n.ignoreCase)&&!!(e!=null&&e.ignoreCase||t.ignoreCase)}}function Nn(t,e,n){return t.has(e)||t.set(e,n),t.get(e)}function ss(t,e){return Go[t]>=Go[e]}function eg(t,e){if(t==null)throw new Error(e??"Value expected");return t}var Go={ES2025:2025,ES2024:2024,ES2018:2018},tg={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function hd(t={}){if({}.toString.call(t)!=="[object Object]")throw new Error("Unexpected options");if(t.target!==void 0&&!tg[t.target])throw new Error(`Unexpected target "${t.target}"`);const e={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...t,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...t.rules}};return e.target==="auto"&&(e.target=We.flagGroups?"ES2025":We.unicodeSets?"ES2024":"ES2018"),e}var ng="[ -\r ]",ig=new Set([te(304),te(305)]),Ze=$`[\p{L}\p{M}\p{N}\p{Pc}]`;function fd(t){if(ig.has(t))return[t];const e=new Set,n=t.toLowerCase(),i=n.toUpperCase(),r=og.get(n),s=rg.get(n),o=sg.get(n);return[...i].length===1&&e.add(i),o&&e.add(o),r&&e.add(r),e.add(n),s&&e.add(s),[...e]}var $s=new Map(`C Other
61
+ Cc Control cntrl
62
+ Cf Format
63
+ Cn Unassigned
64
+ Co Private_Use
65
+ Cs Surrogate
66
+ L Letter
67
+ LC Cased_Letter
68
+ Ll Lowercase_Letter
69
+ Lm Modifier_Letter
70
+ Lo Other_Letter
71
+ Lt Titlecase_Letter
72
+ Lu Uppercase_Letter
73
+ M Mark Combining_Mark
74
+ Mc Spacing_Mark
75
+ Me Enclosing_Mark
76
+ Mn Nonspacing_Mark
77
+ N Number
78
+ Nd Decimal_Number digit
79
+ Nl Letter_Number
80
+ No Other_Number
81
+ P Punctuation punct
82
+ Pc Connector_Punctuation
83
+ Pd Dash_Punctuation
84
+ Pe Close_Punctuation
85
+ Pf Final_Punctuation
86
+ Pi Initial_Punctuation
87
+ Po Other_Punctuation
88
+ Ps Open_Punctuation
89
+ S Symbol
90
+ Sc Currency_Symbol
91
+ Sk Modifier_Symbol
92
+ Sm Math_Symbol
93
+ So Other_Symbol
94
+ Z Separator
95
+ Zl Line_Separator
96
+ Zp Paragraph_Separator
97
+ Zs Space_Separator
98
+ ASCII
99
+ ASCII_Hex_Digit AHex
100
+ Alphabetic Alpha
101
+ Any
102
+ Assigned
103
+ Bidi_Control Bidi_C
104
+ Bidi_Mirrored Bidi_M
105
+ Case_Ignorable CI
106
+ Cased
107
+ Changes_When_Casefolded CWCF
108
+ Changes_When_Casemapped CWCM
109
+ Changes_When_Lowercased CWL
110
+ Changes_When_NFKC_Casefolded CWKCF
111
+ Changes_When_Titlecased CWT
112
+ Changes_When_Uppercased CWU
113
+ Dash
114
+ Default_Ignorable_Code_Point DI
115
+ Deprecated Dep
116
+ Diacritic Dia
117
+ Emoji
118
+ Emoji_Component EComp
119
+ Emoji_Modifier EMod
120
+ Emoji_Modifier_Base EBase
121
+ Emoji_Presentation EPres
122
+ Extended_Pictographic ExtPict
123
+ Extender Ext
124
+ Grapheme_Base Gr_Base
125
+ Grapheme_Extend Gr_Ext
126
+ Hex_Digit Hex
127
+ IDS_Binary_Operator IDSB
128
+ IDS_Trinary_Operator IDST
129
+ ID_Continue IDC
130
+ ID_Start IDS
131
+ Ideographic Ideo
132
+ Join_Control Join_C
133
+ Logical_Order_Exception LOE
134
+ Lowercase Lower
135
+ Math
136
+ Noncharacter_Code_Point NChar
137
+ Pattern_Syntax Pat_Syn
138
+ Pattern_White_Space Pat_WS
139
+ Quotation_Mark QMark
140
+ Radical
141
+ Regional_Indicator RI
142
+ Sentence_Terminal STerm
143
+ Soft_Dotted SD
144
+ Terminal_Punctuation Term
145
+ Unified_Ideograph UIdeo
146
+ Uppercase Upper
147
+ Variation_Selector VS
148
+ White_Space space
149
+ XID_Continue XIDC
150
+ XID_Start XIDS`.split(/\s/).map(t=>[er(t),t])),rg=new Map([["s",te(383)],[te(383),"s"]]),sg=new Map([[te(223),te(7838)],[te(107),te(8490)],[te(229),te(8491)],[te(969),te(8486)]]),og=new Map([mt(453),mt(456),mt(459),mt(498),...br(8072,8079),...br(8088,8095),...br(8104,8111),mt(8124),mt(8140),mt(8188)]),ag=new Map([["alnum",$`[\p{Alpha}\p{Nd}]`],["alpha",$`\p{Alpha}`],["ascii",$`\p{ASCII}`],["blank",$`[\p{Zs}\t]`],["cntrl",$`\p{Cc}`],["digit",$`\p{Nd}`],["graph",$`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",$`\p{Lower}`],["print",$`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",$`[\p{P}\p{S}]`],["space",$`\p{space}`],["upper",$`\p{Upper}`],["word",$`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",$`\p{AHex}`]]);function lg(t,e){const n=[];for(let i=t;i<=e;i++)n.push(i);return n}function mt(t){const e=te(t);return[e.toLowerCase(),e]}function br(t,e){return lg(t,e).map(n=>mt(n))}var pd=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function dg(t,e){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...e};gd(t);const i={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:ss(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:t.flags.digitIsAscii,spaceIsAscii:t.flags.spaceIsAscii,wordIsAscii:t.flags.wordIsAscii};_n(t,cg,i);const r={dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},s={currentFlags:r,prevFlags:null,globalFlags:r,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:i.subroutineRefMap};_n(t,ug,s);const o={groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer};return _n(t,hg,o),t._originMap=s.groupOriginByCopy,t._strategy=i.strategy,t}var cg={AbsenceFunction({node:t,parent:e,replaceWith:n}){const{body:i,kind:r}=t;if(r==="repeater"){const s=Ve();s.body[0].body.push(Et({negate:!0,body:i}),Kt("Any"));const o=Ve();o.body[0].body.push(od("greedy",0,1/0,s)),n(X(o,e),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:t,parent:e,key:n},{flagDirectivesByAlt:i}){const r=t.body.filter(s=>s.kind==="flags");for(let s=n+1;s<e.body.length;s++){const o=e.body[s];Nn(i,o,[]).push(...r)}},exit({node:t},{flagDirectivesByAlt:e}){var n;if((n=e.get(t))!=null&&n.length){const i=yd(e.get(t));if(i){const r=Ve({flags:i});r.body[0].body=t.body,t.body=[X(r,t)]}}}},Assertion({node:t,parent:e,key:n,container:i,root:r,remove:s,replaceWith:o},l){const{kind:a,negate:d}=t,{asciiWordBoundaries:c,avoidSubclass:u,supportedGNodes:h,wordIsAscii:f}=l;if(a==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${d?"Y":"y"}"`);if(a==="line_end")o(X(Et({body:[Ht({body:[ts("string_end")]}),Ht({body:[Ji(10)]})]}),e));else if(a==="line_start")o(X(Je($`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),e));else if(a==="search_start")if(h.has(t))r.flags.sticky=!0,s();else{const p=i[n-1];if(p&&vg(p))o(X(Et({negate:!0}),e));else{if(u)throw new Error($`Uses "\G" in a way that requires a subclass`);o(yt(ts("string_start"),e)),l.strategy="clip_search"}}else if(!(a==="string_end"||a==="string_start"))if(a==="string_end_newline")o(X(Je($`(?=\n?\z)`),e));else if(a==="word_boundary"){if(!f&&!c){const p=`(?:(?<=${Ze})(?!${Ze})|(?<!${Ze})(?=${Ze}))`,y=`(?:(?<=${Ze})(?=${Ze})|(?<!${Ze})(?!${Ze}))`;o(X(Je(d?y:p),e))}}else throw new Error(`Unexpected assertion kind "${a}"`)},Backreference({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!xr(n)&&(n=wr(n,e),t.ref=n)},CapturingGroup({node:t},{jsGroupNameMap:e,subroutineRefMap:n}){let{name:i}=t;i&&!xr(i)&&(i=wr(i,e),t.name=i),n.set(t.number,t),i&&n.set(i,t)},CharacterClassRange({node:t,parent:e,replaceWith:n}){if(e.kind==="intersection"){const i=Si({body:[t]});n(X(i,e),{traverse:!0})}},CharacterSet({node:t,parent:e,replaceWith:n},{accuracy:i,minTargetEs2024:r,digitIsAscii:s,spaceIsAscii:o,wordIsAscii:l}){const{kind:a,negate:d,value:c}=t;if(s&&(a==="digit"||c==="digit")){n(yt(is("digit",{negate:d}),e));return}if(o&&(a==="space"||c==="space")){n(X(kr(Je(ng),d),e));return}if(l&&(a==="word"||c==="word")){n(yt(is("word",{negate:d}),e));return}if(a==="any")n(yt(Kt("Any"),e));else if(a==="digit")n(yt(Kt("Nd",{negate:d}),e));else if(a!=="dot")if(a==="text_segment"){if(i==="strict")throw new Error($`Use of "\X" requires non-strict accuracy`);const u="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",h=$`\p{RI}{2}|${u}(?:\u200D${u})*`;n(X(Je($`(?>\r\n|${r?$`\p{RGI_Emoji}`:h}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),e))}else if(a==="hex")n(yt(Kt("AHex",{negate:d}),e));else if(a==="newline")n(X(Je(d?`[^
151
+ ]`:`(?>\r
152
+ ?|[
153
+ \v\f…\u2028\u2029])`),e));else if(a==="posix")if(!r&&(c==="graph"||c==="print")){if(i==="strict")throw new Error(`POSIX class "${c}" requires min target ES2024 or non-strict accuracy`);let u={graph:"!-~",print:" -~"}[c];d&&(u=`\0-${te(u.codePointAt(0)-1)}${te(u.codePointAt(2)+1)}-􏿿`),n(X(Je(`[${u}]`),e))}else n(X(kr(Je(ag.get(c)),d),e));else if(a==="property")$s.has(er(c))||(t.key="sc");else if(a==="space")n(yt(Kt("space",{negate:d}),e));else if(a==="word")n(X(kr(Je(Ze),d),e));else throw new Error(`Unexpected character set kind "${a}"`)},Directive({node:t,parent:e,root:n,remove:i,replaceWith:r,removeAllPrevSiblings:s,removeAllNextSiblings:o}){const{kind:l,flags:a}=t;if(l==="flags")if(!a.enable&&!a.disable)i();else{const d=Ve({flags:a});d.body[0].body=o(),r(X(d,e),{traverse:!0})}else if(l==="keep"){const d=n.body[0],u=n.body.length===1&&id(d,{type:"Group"})&&d.body[0].body.length===1?d.body[0]:n;if(e.parent!==u||u.body.length>1)throw new Error($`Uses "\K" in a way that's unsupported`);const h=Et({behind:!0});h.body[0].body=s(),r(X(h,e))}else throw new Error(`Unexpected directive kind "${l}"`)},Flags({node:t,parent:e}){if(t.posixIsAscii)throw new Error('Unsupported flag "P"');if(t.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete t[n]),Object.assign(t,{global:!1,hasIndices:!1,multiline:!1,sticky:t.sticky??!1}),e.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:t}){if(!t.flags)return;const{enable:e,disable:n}=t.flags;e!=null&&e.extended&&delete e.extended,n!=null&&n.extended&&delete n.extended,e!=null&&e.dotAll&&(n!=null&&n.dotAll)&&delete e.dotAll,e!=null&&e.ignoreCase&&(n!=null&&n.ignoreCase)&&delete e.ignoreCase,e&&!Object.keys(e).length&&delete t.flags.enable,n&&!Object.keys(n).length&&delete t.flags.disable,!t.flags.enable&&!t.flags.disable&&delete t.flags},LookaroundAssertion({node:t},e){const{kind:n}=t;n==="lookbehind"&&(e.passedLookbehind=!0)},NamedCallout({node:t,parent:e,replaceWith:n}){const{kind:i}=t;if(i==="fail")n(X(Et({negate:!0}),e));else throw new Error(`Unsupported named callout "(*${i.toUpperCase()}"`)},Quantifier({node:t}){if(t.body.type==="Quantifier"){const e=Ve();e.body[0].body.push(t.body),t.body=X(e,t)}},Regex:{enter({node:t},{supportedGNodes:e}){const n=[];let i=!1,r=!1;for(const s of t.body)if(s.body.length===1&&s.body[0].kind==="search_start")s.body.pop();else{const o=Cd(s.body);o?(i=!0,Array.isArray(o)?n.push(...o):n.push(o)):r=!0}i&&!r&&n.forEach(s=>e.add(s))},exit(t,{accuracy:e,passedLookbehind:n,strategy:i}){if(e==="strict"&&n&&i)throw new Error($`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!xr(n)&&(n=wr(n,e),t.ref=n)}},ug={Backreference({node:t},{multiplexCapturesToLeftByRef:e,reffedNodesByReferencer:n}){const{orphan:i,ref:r}=t;i||n.set(t,[...e.get(r).map(({node:s})=>s)])},CapturingGroup:{enter({node:t,parent:e,replaceWith:n,skip:i},{groupOriginByCopy:r,groupsByName:s,multiplexCapturesToLeftByRef:o,openRefs:l,reffedNodesByReferencer:a}){const d=r.get(t);if(d&&l.has(t.number)){const u=yt(Wo(t.number),e);a.set(u,l.get(t.number)),n(u);return}l.set(t.number,t),o.set(t.number,[]),t.name&&Nn(o,t.name,[]);const c=o.get(t.name??t.number);for(let u=0;u<c.length;u++){const h=c[u];if(d===h.node||d&&d===h.origin||t===h.origin){c.splice(u,1);break}}if(o.get(t.number).push({node:t,origin:d}),t.name&&o.get(t.name).push({node:t,origin:d}),t.name){const u=Nn(s,t.name,new Map);let h=!1;if(d)h=!0;else for(const f of u.values())if(!f.hasDuplicateNameToRemove){h=!0;break}s.get(t.name).set(t,{node:t,hasDuplicateNameToRemove:h})}},exit({node:t},{openRefs:e}){e.get(t.number)===t&&e.delete(t.number)}},Group:{enter({node:t},e){e.prevFlags=e.currentFlags,t.flags&&(e.currentFlags=Fi(e.currentFlags,t.flags))},exit(t,e){e.currentFlags=e.prevFlags}},Subroutine({node:t,parent:e,replaceWith:n},i){const{isRecursive:r,ref:s}=t;if(r){let c=e;for(;(c=c.parent)&&!(c.type==="CapturingGroup"&&(c.name===s||c.number===s)););i.reffedNodesByReferencer.set(t,c);return}const o=i.subroutineRefMap.get(s),l=s===0,a=l?Wo(0):md(o,i.groupOriginByCopy,null);let d=a;if(!l){const c=yd(gg(o,h=>h.type==="Group"&&!!h.flags)),u=c?Fi(i.globalFlags,c):i.globalFlags;fg(u,i.currentFlags)||(d=Ve({flags:mg(u)}),d.body[0].body.push(a))}n(X(d,e),{traverse:!l})}},hg={Backreference({node:t,parent:e,replaceWith:n},i){if(t.orphan){i.highestOrphanBackref=Math.max(i.highestOrphanBackref,t.ref);return}const s=i.reffedNodesByReferencer.get(t).filter(o=>pg(o,t));if(!s.length)n(X(Et({negate:!0}),e));else if(s.length>1){const o=Ve({atomic:!0,body:s.reverse().map(l=>Ht({body:[ns(l.number)]}))});n(X(o,e))}else t.ref=s[0].number},CapturingGroup({node:t},e){t.number=++e.numCapturesToLeft,t.name&&e.groupsByName.get(t.name).get(t).hasDuplicateNameToRemove&&delete t.name},Regex:{exit({node:t},e){const n=Math.max(e.highestOrphanBackref-e.numCapturesToLeft,0);for(let i=0;i<n;i++){const r=sd();t.body.at(-1).body.push(r)}}},Subroutine({node:t},e){!t.isRecursive||t.ref===0||(t.ref=e.reffedNodesByReferencer.get(t).number)}};function gd(t){_n(t,{"*"({node:e,parent:n}){e.parent=n}})}function fg(t,e){return t.dotAll===e.dotAll&&t.ignoreCase===e.ignoreCase}function pg(t,e){let n=e;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===t)return!1;const i=vd(n.parent);for(const r of i){if(r===n)break;if(r===t||Sd(r,t))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function md(t,e,n,i){const r=Array.isArray(t)?[]:{};for(const[s,o]of Object.entries(t))s==="parent"?r.parent=Array.isArray(n)?i:n:o&&typeof o=="object"?r[s]=md(o,e,r,n):(s==="type"&&o==="CapturingGroup"&&e.set(r,e.get(t)??t),r[s]=o);return r}function Wo(t){const e=ad(t);return e.isRecursive=!0,e}function gg(t,e){const n=[];for(;t=t.parent;)(!e||e(t))&&n.push(t);return n}function wr(t,e){if(e.has(t))return e.get(t);const n=`$${e.size}_${t.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return e.set(t,n),n}function yd(t){const e=["dotAll","ignoreCase"],n={enable:{},disable:{}};return t.forEach(({flags:i})=>{e.forEach(r=>{var s,o;(s=i.enable)!=null&&s[r]&&(delete n.disable[r],n.enable[r]=!0),(o=i.disable)!=null&&o[r]&&(n.disable[r]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function mg({dotAll:t,ignoreCase:e}){const n={};return(t||e)&&(n.enable={},t&&(n.enable.dotAll=!0),e&&(n.enable.ignoreCase=!0)),(!t||!e)&&(n.disable={},!t&&(n.disable.dotAll=!0),!e&&(n.disable.ignoreCase=!0)),n}function vd(t){if(!t)throw new Error("Node expected");const{body:e}=t;return Array.isArray(e)?e:e?[e]:null}function Cd(t){const e=t.find(n=>n.kind==="search_start"||Cg(n,{negate:!1})||!yg(n));if(!e)return null;if(e.kind==="search_start")return e;if(e.type==="LookaroundAssertion")return e.body[0].body[0];if(e.type==="CapturingGroup"||e.type==="Group"){const n=[];for(const i of e.body){const r=Cd(i.body);if(!r)return null;Array.isArray(r)?n.push(...r):n.push(r)}return n}return null}function Sd(t,e){const n=vd(t)??[];for(const i of n)if(i===e||Sd(i,e))return!0;return!1}function yg({type:t}){return t==="Assertion"||t==="Directive"||t==="LookaroundAssertion"}function vg(t){const e=["Character","CharacterClass","CharacterSet"];return e.includes(t.type)||t.type==="Quantifier"&&t.min&&e.includes(t.body.type)}function Cg(t,e){const n={negate:null,...e};return t.type==="LookaroundAssertion"&&(n.negate===null||t.negate===n.negate)&&t.body.length===1&&id(t.body[0],{type:"Assertion",kind:"search_start"})}function xr(t){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(t)}function Je(t,e){const i=rd(t,{...e,unicodePropertyMap:$s}).body;return i.length>1||i[0].body.length>1?Ve({body:i}):i[0].body[0]}function kr(t,e){return t.negate=e,t}function yt(t,e){return t.parent=e,t}function X(t,e){return gd(t),t.parent=e,t}function Sg(t,e){const n=hd(e),i=ss(n.target,"ES2024"),r=ss(n.target,"ES2025"),s=n.rules.recursionLimit;if(!Number.isInteger(s)||s<2||s>20)throw new Error("Invalid recursionLimit; use 2-20");let o=null,l=null;if(!r){const f=[t.flags.ignoreCase];_n(t,bg,{getCurrentModI:()=>f.at(-1),popModI(){f.pop()},pushModI(p){f.push(p)},setHasCasedChar(){f.at(-1)?o=!0:l=!0}})}const a={dotAll:t.flags.dotAll,ignoreCase:!!((t.flags.ignoreCase||o)&&!l)};let d=t;const c={accuracy:n.accuracy,appliedGlobalFlags:a,captureMap:new Map,currentFlags:{dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},inCharClass:!1,lastNode:d,originMap:t._originMap,recursionLimit:s,useAppliedIgnoreCase:!!(!r&&o&&l),useFlagMods:r,useFlagV:i,verbose:n.verbose};function u(f){return c.lastNode=d,d=f,eg(wg[f.type],`Unexpected node type "${f.type}"`)(f,c,u)}const h={pattern:t.body.map(u).join("|"),flags:u(t.flags),options:{...t.options}};return i||(delete h.options.force.v,h.options.disable.v=!0,h.options.unicodeSetsPlugin=null),h._captureTransfers=new Map,h._hiddenCaptures=[],c.captureMap.forEach((f,p)=>{f.hidden&&h._hiddenCaptures.push(p),f.transferTo&&Nn(h._captureTransfers,f.transferTo,[]).push(p)}),h}var bg={"*":{enter({node:t},e){if(qo(t)){const n=e.getCurrentModI();e.pushModI(t.flags?Fi({ignoreCase:n},t.flags).ignoreCase:n)}},exit({node:t},e){qo(t)&&e.popModI()}},Backreference(t,e){e.setHasCasedChar()},Character({node:t},e){zs(te(t.value))&&e.setHasCasedChar()},CharacterClassRange({node:t,skip:e},n){e(),bd(t,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:t},e){t.kind==="property"&&pd.has(t.value)&&e.setHasCasedChar()}},wg={Alternative({body:t},e,n){return t.map(n).join("")},Assertion({kind:t,negate:e}){if(t==="string_end")return"$";if(t==="string_start")return"^";if(t==="word_boundary")return e?$`\B`:$`\b`;throw new Error(`Unexpected assertion kind "${t}"`)},Backreference({ref:t},e){if(typeof t!="number")throw new Error("Unexpected named backref in transformed AST");if(!e.useFlagMods&&e.accuracy==="strict"&&e.currentFlags.ignoreCase&&!e.captureMap.get(t).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+t},CapturingGroup(t,e,n){const{body:i,name:r,number:s}=t,o={ignoreCase:e.currentFlags.ignoreCase},l=e.originMap.get(t);return l&&(o.hidden=!0,s>l.number&&(o.transferTo=l.number)),e.captureMap.set(s,o),`(${r?`?<${r}>`:""}${i.map(n).join("|")})`},Character({value:t},e){const n=te(t),i=Vt(t,{escDigit:e.lastNode.type==="Backreference",inCharClass:e.inCharClass,useFlagV:e.useFlagV});if(i!==n)return i;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase&&zs(n)){const r=fd(n);return e.inCharClass?r.join(""):r.length>1?`[${r.join("")}]`:r[0]}return n},CharacterClass(t,e,n){const{kind:i,negate:r,parent:s}=t;let{body:o}=t;if(i==="intersection"&&!e.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");We.bugFlagVLiteralHyphenIsRange&&e.useFlagV&&o.some(Ko)&&(o=[Ji(45),...o.filter(d=>!Ko(d))]);const l=()=>`[${r?"^":""}${o.map(n).join(i==="intersection"?"&&":"")}]`;if(!e.inCharClass){if((!e.useFlagV||We.bugNestedClassIgnoresNegation)&&!r){const c=o.filter(u=>u.type==="CharacterClass"&&u.kind==="union"&&u.negate);if(c.length){const u=Ve(),h=u.body[0];return u.parent=s,h.parent=u,o=o.filter(f=>!c.includes(f)),t.body=o,o.length?(t.parent=h,h.body.push(t)):u.body.pop(),c.forEach(f=>{const p=Ht({body:[f]});f.parent=p,p.parent=u,u.body.push(p)}),n(u)}}e.inCharClass=!0;const d=l();return e.inCharClass=!1,d}const a=o[0];if(i==="union"&&!r&&a&&((!e.useFlagV||!e.verbose)&&s.kind==="union"&&!(We.bugFlagVLiteralHyphenIsRange&&e.useFlagV)||!e.verbose&&s.kind==="intersection"&&o.length===1&&a.type!=="CharacterClassRange"))return o.map(n).join("");if(!e.useFlagV&&s.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return l()},CharacterClassRange(t,e){const n=t.min.value,i=t.max.value,r={escDigit:!1,inCharClass:!0,useFlagV:e.useFlagV},s=Vt(n,r),o=Vt(i,r),l=new Set;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase){const a=bd(t);Rg(a).forEach(c=>{l.add(Array.isArray(c)?`${Vt(c[0],r)}-${Vt(c[1],r)}`:Vt(c,r))})}return`${s}-${o}${[...l].join("")}`},CharacterSet({kind:t,negate:e,value:n,key:i},r){if(t==="dot")return r.currentFlags.dotAll?r.appliedGlobalFlags.dotAll||r.useFlagMods?".":"[^]":$`[^\n]`;if(t==="digit")return e?$`\D`:$`\d`;if(t==="property"){if(r.useAppliedIgnoreCase&&r.currentFlags.ignoreCase&&pd.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${e?$`\P`:$`\p`}{${i?`${i}=`:""}${n}}`}if(t==="word")return e?$`\W`:$`\w`;throw new Error(`Unexpected character set kind "${t}"`)},Flags(t,e){return(e.appliedGlobalFlags.ignoreCase?"i":"")+(t.dotAll?"s":"")+(t.sticky?"y":"")},Group({atomic:t,body:e,flags:n,parent:i},r,s){const o=r.currentFlags;n&&(r.currentFlags=Fi(o,n));const l=e.map(s).join("|"),a=!r.verbose&&e.length===1&&i.type!=="Quantifier"&&!t&&(!r.useFlagMods||!n)?l:`(?${_g(t,n,r.useFlagMods)}${l})`;return r.currentFlags=o,a},LookaroundAssertion({body:t,kind:e,negate:n},i,r){return`(?${`${e==="lookahead"?"":"<"}${n?"!":"="}`}${t.map(r).join("|")})`},Quantifier(t,e,n){return n(t.body)+Tg(t)},Subroutine({isRecursive:t,ref:e},n){if(!t)throw new Error("Unexpected non-recursive subroutine in transformed AST");const i=n.recursionLimit;return e===0?`(?R=${i})`:$`\g<${e}&R=${i}>`}},xg=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),kg=new Set(["-","\\","]","^","["]),Lg=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),jo=new Map([[9,$`\t`],[10,$`\n`],[11,$`\v`],[12,$`\f`],[13,$`\r`],[8232,$`\u2028`],[8233,$`\u2029`],[65279,$`\uFEFF`]]),Eg=new RegExp("^\\p{Cased}$","u");function zs(t){return Eg.test(t)}function bd(t,e){const n=!!(e!=null&&e.firstOnly),i=t.min.value,r=t.max.value,s=[];if(i<65&&(r===65535||r>=131071)||i===65536&&r>=131071)return s;for(let o=i;o<=r;o++){const l=te(o);if(!zs(l))continue;const a=fd(l).filter(d=>{const c=d.codePointAt(0);return c<i||c>r});if(a.length&&(s.push(...a),n))break}return s}function Vt(t,{escDigit:e,inCharClass:n,useFlagV:i}){if(jo.has(t))return jo.get(t);if(t<32||t>126&&t<160||t>262143||e&&Ig(t))return t>255?`\\u{${t.toString(16).toUpperCase()}}`:`\\x${t.toString(16).toUpperCase().padStart(2,"0")}`;const r=n?i?Lg:kg:xg,s=te(t);return(r.has(s)?"\\":"")+s}function Rg(t){const e=t.map(r=>r.codePointAt(0)).sort((r,s)=>r-s),n=[];let i=null;for(let r=0;r<e.length;r++)e[r+1]===e[r]+1?i??(i=e[r]):i===null?n.push(e[r]):(n.push([i,e[r]]),i=null);return n}function _g(t,e,n){if(t)return">";let i="";if(e&&n){const{enable:r,disable:s}=e;i=(r!=null&&r.ignoreCase?"i":"")+(r!=null&&r.dotAll?"s":"")+(s?"-":"")+(s!=null&&s.ignoreCase?"i":"")+(s!=null&&s.dotAll?"s":"")}return`${i}:`}function Tg({kind:t,max:e,min:n}){let i;return!n&&e===1?i="?":!n&&e===1/0?i="*":n===1&&e===1/0?i="+":n===e?i=`{${n}}`:i=`{${n},${e===1/0?"":e}}`,i+{greedy:"",lazy:"?",possessive:"+"}[t]}function qo({type:t}){return t==="CapturingGroup"||t==="Group"||t==="LookaroundAssertion"}function Ig(t){return t>47&&t<58}function Ko({type:t,value:e}){return t==="Character"&&e===45}var vt,rt,It,Ct,At,Gn,os,bt,Ag=(bt=class extends RegExp{constructor(n,i,r){var e=(...Ib)=>(super(...Ib),kt(this,Gn),kt(this,vt,new Map),kt(this,rt,null),kt(this,It),kt(this,Ct,null),kt(this,At,null),g(this,"rawOptions",{}),this);const s=!!(r!=null&&r.lazyCompile);if(n instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");const o=n;e(o,i),ze(this,It,o.source),o instanceof bt&&(ze(this,vt,ge(o,vt)),ze(this,Ct,ge(o,Ct)),ze(this,At,ge(o,At)),this.rawOptions=o.rawOptions)}else{const o={hiddenCaptures:[],strategy:null,transfers:[],...r};e(s?"":n,i),ze(this,It,n),ze(this,vt,Mg(o.hiddenCaptures,o.transfers)),ze(this,At,o.strategy),this.rawOptions=r??{}}s||ze(this,rt,this)}get source(){return ge(this,It)||"(?:)"}exec(n){if(!ge(this,rt)){const{lazyCompile:s,...o}=this.rawOptions;ze(this,rt,new bt(ge(this,It),this.flags,o))}const i=this.global||this.sticky,r=this.lastIndex;if(ge(this,At)==="clip_search"&&i&&r){this.lastIndex=0;const s=dr(this,Gn,os).call(this,n.slice(r));return s&&(Pg(s,r,n,this.hasIndices),this.lastIndex+=r),s}return dr(this,Gn,os).call(this,n)}},vt=new WeakMap,rt=new WeakMap,It=new WeakMap,Ct=new WeakMap,At=new WeakMap,Gn=new WeakSet,os=function(n){ge(this,rt).lastIndex=this.lastIndex;const i=so(bt.prototype,this,"exec").call(ge(this,rt),n);if(this.lastIndex=ge(this,rt).lastIndex,!i||!ge(this,vt).size)return i;const r=[...i];i.length=1;let s;this.hasIndices&&(s=[...i.indices],i.indices.length=1);const o=[0];for(let l=1;l<r.length;l++){const{hidden:a,transferTo:d}=ge(this,vt).get(l)??{};if(a?o.push(null):(o.push(i.length),i.push(r[l]),this.hasIndices&&i.indices.push(s[l])),d&&r[l]!==void 0){const c=o[d];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(i[c]=r[l],this.hasIndices&&(i.indices[c]=s[l]),i.groups){ge(this,Ct)||ze(this,Ct,Dg(this.source));const u=ge(this,Ct).get(d);u&&(i.groups[u]=r[l],this.hasIndices&&(i.indices.groups[u]=s[l]))}}}return i},bt);function Pg(t,e,n,i){if(t.index+=e,t.input=n,i){const r=t.indices;for(let o=0;o<r.length;o++){const l=r[o];l&&(r[o]=[l[0]+e,l[1]+e])}const s=r.groups;s&&Object.keys(s).forEach(o=>{const l=s[o];l&&(s[o]=[l[0]+e,l[1]+e])})}}function Mg(t,e){const n=new Map;for(const i of t)n.set(i,{hidden:!0});for(const[i,r]of e)for(const s of r)Nn(n,s,{}).transferTo=i;return n}function Dg(t){const e=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let i=0,r=0,s;for(;s=e.exec(t);){const{0:o,groups:{capture:l,name:a}}=s;o==="["?i++:i?o==="]"&&i--:l&&(r++,a&&n.set(r,a))}return n}function Hg(t,e){const n=Og(t,e);return n.options?new Ag(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Og(t,e){const n=hd(e),i=rd(t,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:$s}),r=dg(i,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),s=Sg(r,n),o=Zp(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),l=Yp(o.pattern),a=Xp(l.pattern,{captureTransfers:o.captureTransfers,hiddenCaptures:o.hiddenCaptures}),d={pattern:a.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${s.flags}${s.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const c=a.hiddenCaptures.sort((p,y)=>p-y),u=Array.from(a.captureTransfers),h=r._strategy,f=d.pattern.length>=n.lazyCompileLength;(c.length||u.length||h||f)&&(d.options={...c.length&&{hiddenCaptures:c},...u.length&&{transfers:u},...h&&{strategy:h},...f&&{lazyCompile:f}})}return d}const Xo=4294967295;class Ng{constructor(e,n={}){g(this,"regexps");this.patterns=e,this.options=n;const{forgiving:i=!1,cache:r,regexConstructor:s}=n;if(!s)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(o=>{if(typeof o!="string")return o;const l=r==null?void 0:r.get(o);if(l){if(l instanceof RegExp)return l;if(i)return null;throw l}try{const a=s(o);return r==null||r.set(o,a),a}catch(a){if(r==null||r.set(o,a),i)return null;throw a}})}findNextMatchSync(e,n,i){const r=typeof e=="string"?e:e.content,s=[];function o(l,a,d=0){return{index:l,captureIndices:a.indices.map(c=>c==null?{start:Xo,end:Xo,length:0}:{start:c[0]+d,end:c[1]+d,length:c[1]-c[0]})}}for(let l=0;l<this.regexps.length;l++){const a=this.regexps[l];if(a)try{a.lastIndex=n;const d=a.exec(r);if(!d)continue;if(d.index===n)return o(l,d,0);s.push([l,d,0])}catch(d){if(this.options.forgiving)continue;throw d}}if(s.length){const l=Math.min(...s.map(a=>a[1].index));for(const[a,d,c]of s)if(d.index===l)return o(a,d,c)}return null}}function Fg(t,e){return Hg(t,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...e})}function wd(t={}){const e=Object.assign({target:"auto",cache:new Map},t);return e.regexConstructor||(e.regexConstructor=n=>Fg(n,{target:e.target})),{createScanner(n){return new Ng(n,e)},createString(n){return{content:n}}}}class Us extends Error{constructor(e){super(e),this.name="ShikiError"}}function $g(){return 2147483648}function zg(){return typeof performance<"u"?performance.now():Date.now()}const Ug=(t,e)=>t+(e-t%e)%e;async function Bg(t){let e,n;const i={};function r(f){n=f,i.HEAPU8=new Uint8Array(f),i.HEAPU32=new Uint32Array(f)}function s(f,p,y){i.HEAPU8.copyWithin(f,p,p+y)}function o(f){try{return e.grow(f-n.byteLength+65535>>>16),r(e.buffer),1}catch{}}function l(f){const p=i.HEAPU8.length;f=f>>>0;const y=$g();if(f>y)return!1;for(let v=1;v<=4;v*=2){let m=p*(1+.2/v);m=Math.min(m,f+100663296);const C=Math.min(y,Ug(Math.max(f,m),65536));if(o(C))return!0}return!1}const a=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function d(f,p,y=1024){const v=p+y;let m=p;for(;f[m]&&!(m>=v);)++m;if(m-p>16&&f.buffer&&a)return a.decode(f.subarray(p,m));let C="";for(;p<m;){let S=f[p++];if(!(S&128)){C+=String.fromCharCode(S);continue}const w=f[p++]&63;if((S&224)===192){C+=String.fromCharCode((S&31)<<6|w);continue}const b=f[p++]&63;if((S&240)===224?S=(S&15)<<12|w<<6|b:S=(S&7)<<18|w<<12|b<<6|f[p++]&63,S<65536)C+=String.fromCharCode(S);else{const k=S-65536;C+=String.fromCharCode(55296|k>>10,56320|k&1023)}}return C}function c(f,p){return f?d(i.HEAPU8,f,p):""}const u={emscripten_get_now:zg,emscripten_memcpy_big:s,emscripten_resize_heap:l,fd_write:()=>0};async function h(){const p=await t({env:u,wasi_snapshot_preview1:u});e=p.memory,r(e.buffer),Object.assign(i,p),i.UTF8ToString=c}return await h(),i}var Vg=Object.defineProperty,Gg=(t,e,n)=>e in t?Vg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ne=(t,e,n)=>Gg(t,typeof e!="symbol"?e+"":e,n);let re=null;function Wg(t){throw new Us(t.UTF8ToString(t.getLastOnigError()))}class ir{constructor(e){ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16Value"),ne(this,"utf8Value"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16");const n=e.length,i=ir._utf8ByteLength(e),r=i!==n,s=r?new Uint32Array(n+1):null;r&&(s[n]=i);const o=r?new Uint32Array(i+1):null;r&&(o[i]=n);const l=new Uint8Array(i);let a=0;for(let d=0;d<n;d++){const c=e.charCodeAt(d);let u=c,h=!1;if(c>=55296&&c<=56319&&d+1<n){const f=e.charCodeAt(d+1);f>=56320&&f<=57343&&(u=(c-55296<<10)+65536|f-56320,h=!0)}r&&(s[d]=a,h&&(s[d+1]=a),u<=127?o[a+0]=d:u<=2047?(o[a+0]=d,o[a+1]=d):u<=65535?(o[a+0]=d,o[a+1]=d,o[a+2]=d):(o[a+0]=d,o[a+1]=d,o[a+2]=d,o[a+3]=d)),u<=127?l[a++]=u:u<=2047?(l[a++]=192|(u&1984)>>>6,l[a++]=128|(u&63)>>>0):u<=65535?(l[a++]=224|(u&61440)>>>12,l[a++]=128|(u&4032)>>>6,l[a++]=128|(u&63)>>>0):(l[a++]=240|(u&1835008)>>>18,l[a++]=128|(u&258048)>>>12,l[a++]=128|(u&4032)>>>6,l[a++]=128|(u&63)>>>0),h&&d++}this.utf16Length=n,this.utf8Length=i,this.utf16Value=e,this.utf8Value=l,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let n=0;for(let i=0,r=e.length;i<r;i++){const s=e.charCodeAt(i);let o=s,l=!1;if(s>=55296&&s<=56319&&i+1<r){const a=e.charCodeAt(i+1);a>=56320&&a<=57343&&(o=(s-55296<<10)+65536|a-56320,l=!0)}o<=127?n+=1:o<=2047?n+=2:o<=65535?n+=3:n+=4,l&&i++}return n}createString(e){const n=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,n),n}}const rr=class Xe{constructor(e){if(ne(this,"id",++Xe.LAST_ID),ne(this,"_onigBinding"),ne(this,"content"),ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16"),ne(this,"ptr"),!re)throw new Us("Must invoke loadWasm first.");this._onigBinding=re,this.content=e;const n=new ir(e);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Xe._sharedPtrInUse?(Xe._sharedPtr||(Xe._sharedPtr=re.omalloc(1e4)),Xe._sharedPtrInUse=!0,re.HEAPU8.set(n.utf8Value,Xe._sharedPtr),this.ptr=Xe._sharedPtr):this.ptr=n.createString(re)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===Xe._sharedPtr?Xe._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};ne(rr,"LAST_ID",0);ne(rr,"_sharedPtr",0);ne(rr,"_sharedPtrInUse",!1);let xd=rr;class jg{constructor(e){if(ne(this,"_onigBinding"),ne(this,"_ptr"),!re)throw new Us("Must invoke loadWasm first.");const n=[],i=[];for(let l=0,a=e.length;l<a;l++){const d=new ir(e[l]);n[l]=d.createString(re),i[l]=d.utf8Length}const r=re.omalloc(4*e.length);re.HEAPU32.set(n,r/4);const s=re.omalloc(4*e.length);re.HEAPU32.set(i,s/4);const o=re.createOnigScanner(r,s,e.length);for(let l=0,a=e.length;l<a;l++)re.ofree(n[l]);re.ofree(s),re.ofree(r),o===0&&Wg(re),this._onigBinding=re,this._ptr=o}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,n,i){let r=0;if(typeof i=="number"&&(r=i),typeof e=="string"){e=new xd(e);const s=this._findNextMatchSync(e,n,!1,r);return e.dispose(),s}return this._findNextMatchSync(e,n,!1,r)}_findNextMatchSync(e,n,i,r){const s=this._onigBinding,o=s.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(n),r);if(o===0)return null;const l=s.HEAPU32;let a=o/4;const d=l[a++],c=l[a++],u=[];for(let h=0;h<c;h++){const f=e.convertUtf8OffsetToUtf16(l[a++]),p=e.convertUtf8OffsetToUtf16(l[a++]);u[h]={start:f,end:p,length:p-f}}return{index:d,captureIndices:u}}}function qg(t){return typeof t.instantiator=="function"}function Kg(t){return typeof t.default=="function"}function Xg(t){return typeof t.data<"u"}function Yg(t){return typeof Response<"u"&&t instanceof Response}function Qg(t){var e;return typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||ArrayBuffer.isView(t))||typeof Buffer<"u"&&((e=Buffer.isBuffer)==null?void 0:e.call(Buffer,t))||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&t instanceof Uint32Array}let ei;function Zg(t){if(ei)return ei;async function e(){re=await Bg(async n=>{let i=t;return i=await i,typeof i=="function"&&(i=await i(n)),typeof i=="function"&&(i=await i(n)),qg(i)?i=await i.instantiator(n):Kg(i)?i=await i.default(n):(Xg(i)&&(i=i.data),Yg(i)?typeof WebAssembly.instantiateStreaming=="function"?i=await Jg(i)(n):i=await em(i)(n):Qg(i)?i=await Lr(i)(n):i instanceof WebAssembly.Module?i=await Lr(i)(n):"default"in i&&i.default instanceof WebAssembly.Module&&(i=await Lr(i.default)(n))),"instance"in i&&(i=i.instance),"exports"in i&&(i=i.exports),i})}return ei=e(),ei}function Lr(t){return e=>WebAssembly.instantiate(t,e)}function Jg(t){return e=>WebAssembly.instantiateStreaming(t,e)}function em(t){return async e=>{const n=await t.arrayBuffer();return WebAssembly.instantiate(n,e)}}async function tm(t){return t&&await Zg(t),{createScanner(e){return new jg(e.map(n=>typeof n=="string"?n:n.source))},createString(e){return new xd(e)}}}const as={angular_html:()=>L(()=>import("./angular-html-BpR8Pn47.js"),__vite__mapDeps([0,1,2,3])),bash:()=>L(()=>import("./shellscript-Yzrsuije.js"),[]),c:()=>L(()=>import("./c-BIGW1oBm.js"),[]),cmake:()=>L(()=>import("./cmake-D1j8_8rp.js"),[]),console:()=>L(()=>import("./shellscript-Yzrsuije.js"),[]),cpp:()=>L(()=>import("./cpp-B-lmv-kZ.js"),__vite__mapDeps([4,5,6,7])),csharp:()=>L(()=>import("./csharp-COcwbKMJ.js"),[]),css:()=>L(()=>import("./css-DPfMkruS.js"),[]),csv:()=>L(()=>import("./csv-fuZLfV_i.js"),[]),diff:()=>L(()=>import("./diff-D97Zzqfu.js"),[]),docker:()=>L(()=>import("./docker-BcOcwvcX.js"),[]),dockerfile:()=>L(()=>import("./docker-BcOcwvcX.js"),[]),elixir:()=>L(()=>import("./elixir-CDX3lj18.js"),__vite__mapDeps([8,1,2,3])),erlang:()=>L(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([9,10])),go:()=>L(()=>import("./go-CxLEBnE3.js"),[]),graphql:()=>L(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([11,2,12,13,14])),groovy:()=>L(()=>import("./groovy-gcz8RCvz.js"),[]),haskell:()=>L(()=>import("./haskell-Df6bDoY_.js"),[]),hcl:()=>L(()=>import("./hcl-BWvSN4gD.js"),[]),html:()=>L(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([1,2,3])),ini:()=>L(()=>import("./ini-BEwlwnbL.js"),[]),java:()=>L(()=>import("./java-CylS5w8V.js"),[]),javascript:()=>L(()=>import("./javascript-wDzz0qaB.js"),[]),js:()=>L(()=>import("./javascript-wDzz0qaB.js"),[]),json:()=>L(()=>import("./json-Cp-IABpG.js"),[]),json5:()=>L(()=>import("./json5-C9tS-k6U.js"),[]),jsonc:()=>L(()=>import("./jsonc-Des-eS-w.js"),[]),jsx:()=>L(()=>import("./jsx-g9-lgVsj.js"),[]),kotlin:()=>L(()=>import("./kotlin-BdnUsdx6.js"),[]),latex:()=>L(()=>import("./latex-CR2LgHuU.js"),__vite__mapDeps([15,16])),lua:()=>L(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([17,6])),make:()=>L(()=>import("./make-CHLpvVh8.js"),[]),makefile:()=>L(()=>import("./make-CHLpvVh8.js"),[]),markdown:()=>L(()=>import("./markdown-Cvjx9yec.js"),[]),md:()=>L(()=>import("./markdown-Cvjx9yec.js"),[]),nginx:()=>L(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([18,17,6])),objective_c:()=>L(()=>import("./objective-c-DXmwc3jG.js"),[]),perl:()=>L(()=>import("./perl-C0TMdlhV.js"),__vite__mapDeps([19,1,2,3,20,21,7])),php:()=>L(()=>import("./php-Dhbhpdrm.js"),__vite__mapDeps([22,1,2,3,20,21,7,23])),powershell:()=>L(()=>import("./powershell-Dpen1YoG.js"),[]),proto:()=>L(()=>import("./proto-C7zT0LnQ.js"),[]),protobuf:()=>L(()=>import("./proto-C7zT0LnQ.js"),[]),ps1:()=>L(()=>import("./powershell-Dpen1YoG.js"),[]),py:()=>L(()=>import("./python-B6aJPvgy.js"),[]),python:()=>L(()=>import("./python-B6aJPvgy.js"),[]),r:()=>L(()=>import("./r-Dspwwk_N.js"),[]),regexp:()=>L(()=>import("./regexp-CDVJQ6XC.js"),[]),ruby:()=>L(()=>import("./ruby-BymL1q8G.js"),__vite__mapDeps([24,1,2,3,20,21,7,11,12,13,14,4,5,6,25,17,26])),rust:()=>L(()=>import("./rust-B1yitclQ.js"),[]),scala:()=>L(()=>import("./scala-C151Ov-r.js"),[]),scss:()=>L(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([27,3])),sh:()=>L(()=>import("./shellscript-Yzrsuije.js"),[]),shell:()=>L(()=>import("./shellscript-Yzrsuije.js"),[]),shellscript:()=>L(()=>import("./shellscript-Yzrsuije.js"),[]),sql:()=>L(()=>import("./sql-BLtJtn59.js"),[]),svelte:()=>L(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([28,2,12,3])),swift:()=>L(()=>import("./swift-D82vCrfD.js"),[]),toml:()=>L(()=>import("./toml-vGWfd6FD.js"),[]),ts:()=>L(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>L(()=>import("./tsx-COt5Ahok.js"),[]),typescript:()=>L(()=>import("./typescript-BPQ3VLAy.js"),[]),vue:()=>L(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([29,3,2,12,23,1])),xml:()=>L(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([20,21])),yaml:()=>L(()=>import("./yaml-Buea-lGh.js"),[]),yml:()=>L(()=>import("./yaml-Buea-lGh.js"),[]),zig:()=>L(()=>import("./zig-VOosw3JB.js"),[])},nm={"vitesse-dark":()=>L(()=>import("./vitesse-dark-D0r3Knsf.js"),[]),"vitesse-light":()=>L(()=>import("./vitesse-light-CVO1_9PV.js"),[])},kd=Yf({langs:as,themes:nm,engine:()=>wd()}),{codeToHtml:SS}=Zf(kd);async function Ld(t){if(fl())throw new Error(`resolveLanguage("${t}") 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 e=cr.get(t);if(e!=null)return e;try{let n=Gr.get(t);if(n==null&&Object.prototype.hasOwnProperty.call(as,t)&&(n=as[t]),n==null)throw new Error(`resolveLanguage: "${t}" not found in bundled or custom languages`);const i=n().then(({default:r})=>{const s={name:t,data:r};return wt.has(t)||wt.set(t,s),s});return cr.set(t,i),await i}finally{cr.delete(t)}}function Ed(t){return wt.get(t)??Ld(t)}function cn(t=j){const e=[];return typeof t=="string"?e.push(t):(e.push(t.dark),e.push(t.light)),e}const $i=new Set;function Ge(t){for(const e of cn(t))if(!$i.has(e))return!1;return!0}function Fn(t){const e=[],n=new Set;for(const u of im(t.themes)){const h=Rd(u)?u.getThemes():[u];for(const f of h){if(n.has(f.name))throw new Error(`Theme collection already contains theme "${f.name}"`);n.add(f.name),e.push(f)}}const i=Object.freeze([...e]),r=Object.freeze(i.filter(u=>u.colorScheme==="light")),s=Object.freeze(i.filter(u=>u.colorScheme==="dark")),o=new Map(i.map(u=>[u.name,u])),l=Object.freeze(i.map(u=>u.name)),a=Object.freeze(r.map(u=>u.name)),d=Object.freeze(s.map(u=>u.name));function c(u){if(u==null)return i;const{colorScheme:h,collection:f}=u;return f==null?h==="light"?r:h==="dark"?s:i:i.filter(p=>p.collection!==f?!1:h==null||p.colorScheme===h)}return{getTheme(u){return o.get(u)},getThemes(u){return c(u)},getThemeNames(u){return(u==null?void 0:u.collection)==null?(u==null?void 0:u.colorScheme)==="light"?a:(u==null?void 0:u.colorScheme)==="dark"?d:l:c(u).map(h=>h.name)},hasTheme(u){return o.has(u)},orderBy(u){return Fn({themes:i.map((h,f)=>({descriptor:h,index:f})).sort((h,f)=>{const p=u(h.descriptor,f.descriptor);return p!==0?p:h.index-f.index}).map(h=>h.descriptor)})},pick(u){const h=[],f=new Set;for(const p of u){if(f.has(p))throw new Error(`Theme collection pick already includes theme "${p}"`);f.add(p);const y=o.get(p);if(y==null)throw new Error(`Theme collection does not contain theme "${p}"`);h.push(y)}return Fn({themes:h})},registerInto(u){for(const h of i)u.registerThemeIfAbsent(h.name,h.load)}}}function im(t){return rm(t)?[t]:t}function rm(t){return Rd(t)||sm(t)}function sm(t){return typeof t.name=="string"&&typeof t.load=="function"}function Rd(t){return typeof t.getThemes=="function"}function _d(t){return t!==null&&typeof t=="object"&&"default"in t?t.default:t}var Td=class extends Error{constructor(t){super(`Theme "${t}" is already registered`),this.name="DuplicateThemeError"}},om=class extends Error{constructor(t){super(`No loader registered for theme "${t}"`),this.name="UnregisteredThemeError"}},am=class extends Error{constructor(t){super(`Theme "${t}" has not been resolved`),this.name="UnresolvedThemeError"}};function lm(){const t=new Map,e=new Map,n=new Map;let i=0;function r(m,C){if(t.has(m))throw new Td(m);t.set(m,C)}function s(m,C){return t.has(m)?!1:(t.set(m,C),!0)}function o(m){return t.has(m)}function l(m){const C=e.get(m);if(C!==void 0)return Promise.resolve(C);const S=n.get(m);if(S!==void 0)return S;const w=t.get(m);if(w===void 0)return Promise.reject(new om(m));const b=i,k=w().then(x=>{const E=_d(x);return b===i&&e.set(m,E),n.get(m)===k&&n.delete(m),E}).catch(x=>{throw n.get(m)===k&&n.delete(m),x});return n.set(m,k),k}function a(m){return Promise.all(m.map(C=>l(C)))}function d(m,C){e.set(m,C)}function c(m){for(const[C,S]of m)d(C,S)}function u(m){return e.get(m)}function h(m){const C=[];for(const S of m){const w=e.get(S);if(w===void 0)throw new am(S);C.push(w)}return C}function f(m){return e.has(m)}function p(m){for(const C of m)if(!e.has(C))return!1;return!0}function y(m){const C=e.get(m);return C!==void 0?C:l(m)}function v(){i++,e.clear(),n.clear()}return{clearResolvedThemes:v,getResolvedOrResolveTheme:y,getResolvedTheme:u,getResolvedThemes:h,hasRegisteredTheme:o,hasResolvedTheme:f,hasResolvedThemes:p,registerTheme:r,registerThemeIfAbsent:s,resolveTheme:l,resolveThemes:a,seedResolvedTheme:d,seedResolvedThemes:c}}const Ie=lm();function Yo(t,e){t=Array.isArray(t)?t:[t];for(let n of t){let i;if(typeof n=="string"){if(i=Ie.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,Ie.getResolvedTheme(n)==null&&Ie.seedResolvedTheme(n,i);$i.has(n)||($i.add(n),e.loadThemeSync(i))}}function dm(){Ie.clearResolvedThemes(),$i.clear()}function Bs({name:t,load:e,colorScheme:n,collection:i,displayName:r}){return{name:t,colorScheme:n,collection:i,displayName:r,load:cm(e)}}function cm(t){return async()=>Zi(_d(await t()))}const um="pierre",hm=["pierre-dark","pierre-dark-soft","pierre-dark-vibrant","pierre-dark-protanopia-deuteranopia","pierre-dark-tritanopia"],Id=["pierre-light","pierre-light-soft","pierre-light-vibrant","pierre-light-protanopia-deuteranopia","pierre-light-tritanopia"],fm=[...Id,...hm],pm=new Set(Id);function gm(t){return pm.has(t)?"light":"dark"}const mm={"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"},ym={"pierre-dark":()=>L(()=>import("./pierre-dark-CyvmCCZW.js"),[]),"pierre-dark-soft":()=>L(()=>import("./pierre-dark-soft-BHGpRqa4.js"),[]),"pierre-dark-vibrant":()=>L(()=>import("./pierre-dark-vibrant-BWBVywrn.js"),[]),"pierre-dark-protanopia-deuteranopia":()=>L(()=>import("./pierre-dark-protanopia-deuteranopia-Rgc0TwpF.js"),[]),"pierre-dark-tritanopia":()=>L(()=>import("./pierre-dark-tritanopia-Beq2gCRQ.js"),[]),"pierre-light":()=>L(()=>import("./pierre-light-480U9XYS.js"),[]),"pierre-light-soft":()=>L(()=>import("./pierre-light-soft-CVdyfjmI.js"),[]),"pierre-light-vibrant":()=>L(()=>import("./pierre-light-vibrant-DdTDNdfJ.js"),[]),"pierre-light-protanopia-deuteranopia":()=>L(()=>import("./pierre-light-protanopia-deuteranopia-CaVOBURG.js"),[]),"pierre-light-tritanopia":()=>L(()=>import("./pierre-light-tritanopia-B4_gpKOM.js"),[])};function vm(t){return Bs({name:t,collection:um,colorScheme:gm(t),displayName:mm[t],load:ym[t]})}const Ad=Fn({themes:fm.map(t=>vm(t))}),Cm="shiki",Pd=["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"],Sm=["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"],bm=new Set(Pd);function wm(t){return bm.has(t)?"light":"dark"}const xm={andromeeda:()=>L(()=>import("./andromeeda-C4gqWexZ.js"),[]),"aurora-x":()=>L(()=>import("./aurora-x-D-2ljcwZ.js"),[]),"ayu-dark":()=>L(()=>import("./ayu-dark-DYE7WIF3.js"),[]),"ayu-light":()=>L(()=>import("./ayu-light-BA47KaF1.js"),[]),"ayu-mirage":()=>L(()=>import("./ayu-mirage-32ctXXKs.js"),[]),"catppuccin-frappe":()=>L(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]),"catppuccin-latte":()=>L(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]),"catppuccin-macchiato":()=>L(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]),"catppuccin-mocha":()=>L(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]),"dark-plus":()=>L(()=>import("./dark-plus-C3mMm8J8.js"),[]),dracula:()=>L(()=>import("./dracula-BzJJZx-M.js"),[]),"dracula-soft":()=>L(()=>import("./dracula-soft-BXkSAIEj.js"),[]),"everforest-dark":()=>L(()=>import("./everforest-dark-BgDCqdQA.js"),[]),"everforest-light":()=>L(()=>import("./everforest-light-C8M2exoo.js"),[]),"github-dark":()=>L(()=>import("./github-dark-DHJKELXO.js"),[]),"github-dark-default":()=>L(()=>import("./github-dark-default-Cuk6v7N8.js"),[]),"github-dark-dimmed":()=>L(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]),"github-dark-high-contrast":()=>L(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]),"github-light":()=>L(()=>import("./github-light-DAi9KRSo.js"),[]),"github-light-default":()=>L(()=>import("./github-light-default-D7oLnXFd.js"),[]),"github-light-high-contrast":()=>L(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]),"gruvbox-dark-hard":()=>L(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]),"gruvbox-dark-medium":()=>L(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]),"gruvbox-dark-soft":()=>L(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]),"gruvbox-light-hard":()=>L(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]),"gruvbox-light-medium":()=>L(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]),"gruvbox-light-soft":()=>L(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]),horizon:()=>L(()=>import("./horizon-BUw7H-hv.js"),[]),"horizon-bright":()=>L(()=>import("./horizon-bright-Cn-bp-IR.js"),[]),houston:()=>L(()=>import("./houston-DnULxvSX.js"),[]),"kanagawa-dragon":()=>L(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]),"kanagawa-lotus":()=>L(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]),"kanagawa-wave":()=>L(()=>import("./kanagawa-wave-DWedfzmr.js"),[]),laserwave:()=>L(()=>import("./laserwave-DUszq2jm.js"),[]),"light-plus":()=>L(()=>import("./light-plus-B7mTdjB0.js"),[]),"material-theme":()=>L(()=>import("./material-theme-D5KoaKCx.js"),[]),"material-theme-darker":()=>L(()=>import("./material-theme-darker-BfHTSMKl.js"),[]),"material-theme-lighter":()=>L(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]),"material-theme-ocean":()=>L(()=>import("./material-theme-ocean-CyktbL80.js"),[]),"material-theme-palenight":()=>L(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]),"min-dark":()=>L(()=>import("./min-dark-CafNBF8u.js"),[]),"min-light":()=>L(()=>import("./min-light-CTRr51gU.js"),[]),monokai:()=>L(()=>import("./monokai-D4h5O-jR.js"),[]),"night-owl":()=>L(()=>import("./night-owl-C39BiMTA.js"),[]),"night-owl-light":()=>L(()=>import("./night-owl-light-CMTm3GFP.js"),[]),nord:()=>L(()=>import("./nord-Ddv68eIx.js"),[]),"one-dark-pro":()=>L(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]),"one-light":()=>L(()=>import("./one-light-C3Wv6jpd.js"),[]),plastic:()=>L(()=>import("./plastic-3e1v2bzS.js"),[]),poimandres:()=>L(()=>import("./poimandres-CS3Unz2-.js"),[]),red:()=>L(()=>import("./red-bN70gL4F.js"),[]),"rose-pine":()=>L(()=>import("./rose-pine-qdsjHGoJ.js"),[]),"rose-pine-dawn":()=>L(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]),"rose-pine-moon":()=>L(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]),"slack-dark":()=>L(()=>import("./slack-dark-BthQWCQV.js"),[]),"slack-ochin":()=>L(()=>import("./slack-ochin-DqwNpetd.js"),[]),"snazzy-light":()=>L(()=>import("./snazzy-light-Bw305WKR.js"),[]),"solarized-dark":()=>L(()=>import("./solarized-dark-DXbdFlpD.js"),[]),"solarized-light":()=>L(()=>import("./solarized-light-L9t79GZl.js"),[]),"synthwave-84":()=>L(()=>import("./synthwave-84-CbfX1IO0.js"),[]),"tokyo-night":()=>L(()=>import("./tokyo-night-hegEt444.js"),[]),vesper:()=>L(()=>import("./vesper-DU1UobuO.js"),[]),"vitesse-black":()=>L(()=>import("./vitesse-black-Bkuqu6BP.js"),[]),"vitesse-dark":()=>L(()=>import("./vitesse-dark-D0r3Knsf.js"),[]),"vitesse-light":()=>L(()=>import("./vitesse-light-CVO1_9PV.js"),[])};function Qo(t){return Bs({name:t,collection:Cm,colorScheme:wm(t),load:xm[t]})}const Md=Fn({themes:Object.freeze([...Pd.map(t=>Qo(t)),...Sm.map(t=>Qo(t))])});Fn({themes:[Ad,Md]});function Dd(t){if(fl())throw new Error(`Theme "${t}" 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(Ie.hasRegisteredTheme(t))return;const e=Md.getTheme(t);if(e!=null){Ie.registerThemeIfAbsent(e.name,e.load);return}throw new Error(`No valid theme loader registered for "${t}"`)}function Hd(t,e){if(e.name!==t)throw new Error(`resolvedTheme: themeName: ${t} does not match theme.name: ${e.name}`)}async function km(t){Dd(t);const e=await Ie.resolveTheme(t);return Hd(t,e),e}function Lm(t){return Ie.getResolvedTheme(t)??km(t)}let ve;async function un({themes:t,langs:e,preferredHighlighter:n="shiki-js"}){ve??(ve=kd({themes:[],langs:["text"],engine:n==="shiki-wasm"?tm(L(()=>import("./unused-optional-NNwleJvF.js"),[])):wd()}));const i=Rm(ve)?await ve:ve;ve=i;const r=[];for(const o of Array.from(new Set(e))){if(o==="text"||o==="ansi")continue;const l=Ed(o);"then"in l?r.push(l):oo(l,i)}const s=[];for(const o of t){const l=Lm(o);"then"in l?s.push(l):Yo(l,ve)}return(r.length>0||s.length>0)&&await Promise.all([Promise.all(r).then(o=>{oo(o,i)}),Promise.all(s).then(o=>{Yo(o,i)})]),i}function Em(t=ve){return t!=null&&!("then"in t)}function tn(t){if(!(ve==null||"then"in ve)&&!(t!=null&&(!Ge(t.theme)||!An(t.lang))))return ve}function Rm(t=ve){return t!=null&&"then"in t}function bS(t=ve){return t==null}async function _m(t){await un(t)}async function wS(){ve!=null&&((await ve).dispose(),au(),dm(),ve=void 0)}for(const t of Ad.getThemes())Ie.registerThemeIfAbsent(t.name,t.load);const Mt=new Set;let lt=null;function de(t){Mt.add(t),lt??(lt=requestAnimationFrame(Od))}function Ot(t){Mt.delete(t)&&Mt.size===0&&lt!=null&&(cancelAnimationFrame(lt),lt=null)}function xS(){Mt.clear(),lt!=null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(lt),lt=null}function Od(t){const e=new Set(Mt);Mt.clear();for(const n of e)try{n(t)}catch(i){console.error(i)}Mt.size>0?lt=requestAnimationFrame(Od):lt=null}function nn(t,e,n){if(t===e||t==null||e==null)return t===e;const i=new Set(n),r=Object.keys(t),s=new Set(Object.keys(e));for(const o of r)if(s.delete(o),!i.has(o)&&(!(o in e)||t[o]!==e[o]))return!1;for(const o of Array.from(s))if(!i.has(o))return!1;return!0}function zt(t,e){return t==null||e==null||typeof t=="string"||typeof e=="string"?t===e:t.dark===e.dark&&t.light===e.light}function Vs(t,e){const n=(t==null?void 0:t.theme)??j,i=(e==null?void 0:e.theme)??j,r=Zo(t),s=Zo(e);return zt(n,i)&&nn(t,e,["theme","parseDiffOptions"])&&nn(r,s)}function Zo(t){if(t!=null&&"parseDiffOptions"in t)return t.parseDiffOptions}function zi(t,e){return(t==null?void 0:t.start)===(e==null?void 0:e.start)&&(t==null?void 0:t.end)===(e==null?void 0:e.end)&&(t==null?void 0:t.side)===(e==null?void 0:e.side)&&(t==null?void 0:t.endSide)===(e==null?void 0:e.endSide)}function ls({scrollTop:t,scrollHeight:e,height:n,fitPerfectly:i=!1,fitPerfectlyOverscroll:r=0,overscrollSize:s}){const o=n+s*2,l=i?n+r*2:o;if(e=Math.max(e,l),o>=e||i){const c=Math.max(t-r,0),u=Math.min(t+l,e);return{top:c,bottom:Math.max(u,c)}}let a=t+n/2-o/2,d=a+o;return a<0&&(a=0),d>e&&(d=e),a=Math.floor(Math.max(a,0)),{top:a,bottom:Math.ceil(Math.max(Math.min(d,e),a))}}function Tm(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Se(t){return{type:"text",value:t}}function M({tagName:t,children:e=[],properties:n={}}){return{type:"element",tagName:t,properties:n,children:e}}function Ui({name:t,width:e=16,height:n=16,properties:i}){return M({tagName:"svg",properties:{width:e,height:n,viewBox:"0 0 16 16",...i},children:[M({tagName:"use",properties:{href:`#${t.replace(/^#/,"")}`}})]})}function Im(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e;"children"in e?e=e.children[0]:e=null}}function Yt(t){return M({tagName:"div",properties:{"data-gutter":""},children:t})}function Nd(t,e,n,i={}){return M({tagName:"div",properties:{"data-line-type":t,"data-column-number":e,"data-line-index":n,...i},children:e!=null?[M({tagName:"span",properties:{"data-line-number-content":""},children:[Se(`${e}`)]})]:void 0})}function Le(t,e,n){return M({tagName:"div",properties:{"data-gutter-buffer":e,"data-buffer-size":n,"data-line-type":e==="annotation"?void 0:t,style:e==="annotation"?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function Am(){return M({tagName:"button",properties:{"data-utility-button":"",type:"button"},children:[Ui({name:"diffs-icon-plus",properties:{"data-icon":""}})]})}function Pm(t,e){return t.lineNumber===e.lineNumber&&t.side===e.side}function ti(t){for(const e of t)if(e instanceof HTMLElement&&(e.hasAttribute("data-utility-button")||e.hasAttribute("data-gutter-utility-slot")||e.getAttribute("slot")==="gutter-utility-slot"||e.getAttribute("name")==="gutter-utility-slot"))return!0;return!1}var Fd=class{constructor(t,e){g(this,"mode");g(this,"options");g(this,"hoveredLine");g(this,"hoveredToken");g(this,"pre");g(this,"gutterUtilityLine");g(this,"gutterUtilityContainer");g(this,"gutterUtilityButton");g(this,"gutterUtilitySlot");g(this,"interactiveLinesAttr",!1);g(this,"interactiveLineNumbersAttr",!1);g(this,"hasPointerListeners",!1);g(this,"hasDocumentPointerListeners",!1);g(this,"selectedRange",null);g(this,"selectedRangeHighlightSide");g(this,"selectedRangeLineNumberOnly",!1);g(this,"editorActiveLine",null);g(this,"editorActiveLineSide");g(this,"editorLineNumberOnly",!1);g(this,"proposedSelectedRange");g(this,"renderedSelectedLinesState");g(this,"renderedEditorActiveLineState");g(this,"selectionAnchor");g(this,"pointerSession",{mode:"idle"});g(this,"getHoveredLine",()=>{const t=this.gutterUtilityLine??this.hoveredLine;if(t!=null){if(this.mode==="diff"&&t.type==="diff-line")return{lineNumber:t.lineNumber,side:t.annotationSide};if(this.mode==="file"&&t.type==="line")return{lineNumber:t.lineNumber}}});g(this,"handlePointerClick",t=>{const{onHunkExpand:e,onLineClick:n,onLineNumberClick:i,onTokenClick:r,onMergeConflictActionClick:s}=this.options;e==null&&n==null&&i==null&&s==null&&r==null||this.options.onGutterUtilityClick!=null&&ti(t.composedPath())||(et(this.options.__debugPointerEvents,"click","FileDiff.DEBUG.handlePointerClick:",t),this.handlePointerEvent({eventType:"click",event:t}))});g(this,"handlePointerMove",t=>{if(t.pointerType!=="mouse")return;const{lineHoverHighlight:e="disabled",onLineEnter:n,onLineLeave:i,onTokenEnter:r,onTokenLeave:s,enableGutterUtility:o=!1}=this.options;e==="disabled"&&!o&&n==null&&i==null&&r==null&&s==null||(et(this.options.__debugPointerEvents,"move","FileDiff.DEBUG.handlePointerMove:",t),this.handlePointerEvent({eventType:"move",event:t}))});g(this,"handlePointerLeave",t=>{var n,i,r,s;const{__debugPointerEvents:e}=this.options;if(et(e,"move","FileDiff.DEBUG.handlePointerLeave: no event"),this.hoveredLine==null&&this.hoveredToken==null){et(e,"move","FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");return}this.hoveredToken!=null&&((i=(n=this.options).onTokenLeave)==null||i.call(n,this.hoveredToken,t),this.clearHoveredToken()),this.hoveredLine!=null&&((s=(r=this.options).onLineLeave)==null||s.call(r,{...this.hoveredLine,event:t}),this.clearHoveredLine()),this.placeUtility()});g(this,"handlePointerDown",t=>{if(t.pointerType==="mouse"&&t.button!==0||this.pre==null||this.pointerSession.mode!=="idle")return;const e=t.composedPath();ti(e)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(t):(t.pointerType!=="mouse"&&this.revealUtilityFromGutterPath(e),this.startLineSelectionFromPointerDown(t))});g(this,"handleDocumentPointerMove",t=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(t.pointerId!==this.pointerSession.pointerId)return;t.preventDefault();const e=this.resolveSelectionPoint(t,{source:"coordinates-first"});if(e==null)return;this.pointerSession.current=e,this.updateSelection(e.lineNumber,e.side);return}case"selecting":{if(t.pointerId!==this.pointerSession.pointerId)return;t.preventDefault();const e=this.resolveSelectionInfo(t,{source:"coordinates-first",requireNumberColumn:!1});if(e==null||this.selectionAnchor==null)return;this.updateSelection(e.lineNumber,e.eventSide);return}case"pendingSingleLineUnselect":{if(t.pointerId!==this.pointerSession.pointerId)return;t.preventDefault();const e=this.resolveSelectionInfo(t,{source:"coordinates-first",requireNumberColumn:!1});if(e==null||this.selectionAnchor==null)return;const n={lineNumber:e.lineNumber,side:e.eventSide};if(Pm(this.pointerSession.pending,n))return;this.updateSelection(e.lineNumber,e.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:"selecting",pointerId:t.pointerId};return}}});g(this,"handleDocumentPointerUp",t=>{const{onGutterUtilityClick:e}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{const{pointerSession:n}=this;if(t.pointerId!==n.pointerId)return;t.preventDefault();const i=this.resolveSelectionPoint(t,{source:"coordinates-first"});i!=null&&(n.current=i,this.updateSelection(i.lineNumber,i.side));const r=this.buildSelectedLineRange(n.anchor,n.current);e==null||e({...r}),this.selectionAnchor=void 0,this.notifySelectionEnd(r),this.notifySelectionCommitted(r),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case"pendingSingleLineUnselect":if(t.pointerId!==this.pointerSession.pointerId)return;t.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(t.pointerId!==this.pointerSession.pointerId)return;t.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}});g(this,"handleDocumentPointerCancel",t=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":case"selecting":case"pendingSingleLineUnselect":if("pointerId"in this.pointerSession&&t.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}});g(this,"renderSelection",()=>{Ot(this.renderSelection);const t=this.getSelectionRenderState();if(this.pre==null)return;const{editorActiveLine:e,selectedLines:n}=t,i=!ta(this.renderedSelectedLinesState,n),r=!ta(this.renderedEditorActiveLineState,e);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,l=r?this.resolveLineRenderRange(e,s,"editor-active-line"):void 0,a=this.getLineRenderColumns(i?n:void 0,o,r?e:void 0,l),d=n.range==null||a.some(y=>y.renderSelectedLines),c=e.range==null||a.some(y=>y.renderEditorActiveLine);if(i)for(const y of this.pre.querySelectorAll("[data-selected-line]"))y.removeAttribute("data-selected-line");if(r)for(const y of this.pre.querySelectorAll("[data-editor-active-line]"))y.removeAttribute("data-editor-active-line");const u=o==null?void 0:Math.min(o.start,o.end),h=o==null?void 0:Math.max(o.start,o.end),f=u===h,p=l==null?void 0:l.start;for(const y of a){const{content:v,gutter:m,renderEditorActiveLine:C,renderSelectedLines:S}=y,w=Math.max(S?h??-1/0:-1/0,C?p??-1/0:-1/0),b=v.children.length;for(let k=0;k<b;k++){const x=v.children[k],E=m.children[k];if(!(x instanceof HTMLElement)||!(E instanceof HTMLElement))continue;const R=this.parseLineIndex(x,s);if((R??0)>w)break;if(R!=null){if(S&&u!=null&&h!=null&&R>=u&&R<=h){let A=f?"single":R===u?"first":R===h?"last":"";E.setAttribute("data-selected-line",A),n.lineNumberOnly||(x.setAttribute("data-selected-line",A),E.nextSibling instanceof HTMLElement&&x.nextSibling instanceof HTMLElement&&(x.nextSibling.hasAttribute("data-line-annotation")||x.nextSibling.hasAttribute("data-merge-conflict-actions"))&&(f?(A="last",x.setAttribute("data-selected-line","first")):R===u?A="":R===h&&x.setAttribute("data-selected-line",""),x.nextSibling.setAttribute("data-selected-line",A),E.nextSibling.setAttribute("data-selected-line",A)))}C&&R===p&&(E.setAttribute("data-editor-active-line",""),e.lineNumberOnly||x.setAttribute("data-editor-active-line",""))}}}i&&d&&(this.renderedSelectedLinesState=n),r&&c&&(this.renderedEditorActiveLineState=e)});this.mode=t,this.options=e}setOptions(t){this.options=t}cleanUp(){var t,e,n,i,r,s,o;(t=this.pre)==null||t.removeEventListener("click",this.handlePointerClick),(e=this.pre)==null||e.removeEventListener("pointerdown",this.handlePointerDown),(n=this.pre)==null||n.removeEventListener("pointermove",this.handlePointerMove),(i=this.pre)==null||i.removeEventListener("pointerleave",this.handlePointerLeave),(r=this.pre)==null||r.removeAttribute("data-interactive-lines"),(s=this.pre)==null||s.removeAttribute("data-interactive-line-numbers"),this.pre=void 0,(o=this.gutterUtilityContainer)==null||o.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(),Ot(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(t){this.setSelectionDirty();const{usesCustomGutterUtility:e=!1,enableGutterUtility:n=!1}=this.options;this.pre!==t&&(this.cleanUp(),this.pre=t),n?this.ensureGutterUtilityNode(e):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(t),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(t,e){const n=!(t===this.selectedRange||zi(t??void 0,this.selectedRange??void 0)),i=(e==null?void 0:e.lineNumberOnly)??!1,r=(e==null?void 0:e.activeLineSide)!==this.selectedRangeHighlightSide||i!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!r||(this.proposedSelectedRange=void 0,this.selectedRange=t,this.selectedRangeHighlightSide=e==null?void 0:e.activeLineSide,this.selectedRangeLineNumberOnly=i,this.renderSelection(),this.placeUtility(),n&&(e==null?void 0:e.notify)!==!1&&this.notifySelectionCommitted(t))}setEditorActiveLine(t,{lineNumberOnly:e=!1,side:n}={}){const i=t!==this.editorActiveLine,r=n!==this.editorActiveLineSide||e!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!i&&!r||(this.editorActiveLine=t,this.editorActiveLineSide=n,this.editorLineNumberOnly=e,this.renderSelection())}getSelection(){return this.selectedRange}handlePointerEvent({eventType:t,event:e}){var p,y;const{__debugPointerEvents:n}=this.options,i=e.composedPath();et(n,t,"FileDiff.DEBUG.handlePointerEvent:",{eventType:t,composedPath:i});const r=this.resolvePointerTarget(i);et(n,t,"FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:",r);const{onLineClick:s,onLineNumberClick:o,onLineEnter:l,onLineLeave:a,onTokenClick:d,onTokenEnter:c,onTokenLeave:u,onHunkExpand:h,onMergeConflictActionClick:f}=this.options;switch(t){case"move":{const v=Er(r)&&((p=this.hoveredLine)==null?void 0:p.lineElement)===r.lineElement;bi(r)&&((y=this.hoveredToken)==null?void 0:y.tokenElement)===r.tokenElement||(this.hoveredToken!=null&&(u==null||u(this.hoveredToken,e),this.clearHoveredToken()),bi(r)&&(this.setHoveredToken(this.toTokenEventBaseProps(r)),c==null||c(this.hoveredToken,e))),v||(this.hoveredLine!=null&&(a==null||a({...this.hoveredLine,event:e}),this.clearHoveredLine()),Er(r)?(this.setHoveredLine(this.toEventBaseProps(r)),this.placeUtility(),l==null||l({...this.hoveredLine,event:e})):this.placeUtility());break}case"click":{if(r==null)break;if(Hm(r)&&f!=null){f(r);break}if(Dm(r)&&h!=null){h(r.hunkIndex,r.all||e.shiftKey?"both":r.direction,r.all||e.shiftKey?Number.POSITIVE_INFINITY:void 0);break}if(!Er(r))break;bi(r)&&d!=null&&d(this.toTokenEventBaseProps(r),e);const v=this.toEventBaseProps(r);o!=null&&r.numberColumn?o({...v,event:e}):s!=null&&s({...v,event:e});break}}}syncPointerListeners(t){const{__debugPointerEvents:e,lineHoverHighlight:n="disabled",onLineClick:i,onLineNumberClick:r,onLineEnter:s,onLineLeave:o,onTokenClick:l,onTokenEnter:a,onTokenLeave:d,onHunkExpand:c,onMergeConflictActionClick:u,enableGutterUtility:h=!1,enableLineSelection:f=!1,onGutterUtilityClick:p}=this.options,y=p!=null,v=n!=="disabled"||i!=null||r!=null||s!=null||o!=null||l!=null||a!=null||d!=null||c!=null||u!=null||h||f||y;v&&!this.hasPointerListeners?(t.addEventListener("click",this.handlePointerClick),t.addEventListener("pointerdown",this.handlePointerDown),t.addEventListener("pointermove",this.handlePointerMove),t.addEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!0,et(e,"click","FileDiff.DEBUG.attachEventListeners: Attaching click events for:",(()=>{const S=[];return(e==="both"||e==="click")&&(i!=null&&S.push("onLineClick"),r!=null&&S.push("onLineNumberClick"),c!=null&&S.push("expandable hunk separators"),u!=null&&S.push("merge conflict actions")),S})()),et(e,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer move event"),et(e,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event")):!v&&this.hasPointerListeners&&(t.removeEventListener("click",this.handlePointerClick),t.removeEventListener("pointerdown",this.handlePointerDown),t.removeEventListener("pointermove",this.handlePointerMove),t.removeEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!1);const m=this.pointerSession.mode==="selecting"||this.pointerSession.mode==="pendingSingleLineUnselect",C=this.pointerSession.mode==="gutterSelecting";(!f&&m||!y&&C)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;const{onLineClick:t,onLineNumberClick:e,enableLineSelection:n=!1}=this.options,i=t!=null,r=e!=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)}startLineSelectionFromPointerDown(t){var l,a;const{enableLineSelection:e=!1}=this.options;if(!e)return;const n=this.resolveSelectionInfo(t,{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(t.shiftKey&&this.selectedRange!=null){const d=this.getIndexesFromSelection(this.selectedRange,i.getAttribute("data-diff-type")==="split");if(d==null)return;const c=d.start<=d.end?o>=d.start:o<=d.end;this.selectionAnchor={lineNumber:c?this.selectedRange.start:this.selectedRange.end,side:c?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(r,s,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:t.pointerId},this.attachDocumentPointerListeners();return}if(((l=this.selectedRange)==null?void 0:l.start)===r&&((a=this.selectedRange)==null?void 0:a.end)===r){const d={lineNumber:r,side:s};this.selectionAnchor=d,this.pointerSession={mode:"pendingSingleLineUnselect",pointerId:t.pointerId,anchor:d,pending:d},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:t.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(t){const{onGutterUtilityClick:e}=this.options;if(e==null)return;const n=this.currentSelectionEnds(),i=(n==null?void 0:n.bottom)??this.resolveSelectionPoint(t,{source:"event-path",excludeUtility:!1}),r=(n==null?void 0:n.top)??i;i==null||r==null||(t.preventDefault(),t.stopPropagation(),this.pointerSession={mode:"gutterSelecting",pointerId:t.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())}clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute("data-hovered"),this.hoveredLine.numberElement.removeAttribute("data-hovered"),this.hoveredLine=void 0)}setHoveredLine(t){const{lineHoverHighlight:e="disabled"}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=t,e!=="disabled"&&((e==="both"||e==="line")&&this.hoveredLine.lineElement.setAttribute("data-hovered",""),(e==="both"||e==="number")&&this.hoveredLine.numberElement.setAttribute("data-hovered",""))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(t){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=t}ensureGutterUtilityNode(t){var e;if(this.gutterUtilityContainer==null&&(this.gutterUtilityContainer=document.createElement("div"),this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot","")),t)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((e=this.gutterUtilitySlot)==null||e.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){const n=document.createElement("div");n.innerHTML=Ce(Am());const i=n.firstElementChild;if(!(i instanceof HTMLButtonElement))throw new Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");i.remove(),this.gutterUtilityButton=i}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(t){if(this.placeUtilityFromSelection())return;const e=this.resolvePointerTarget(t);xn(e)&&e.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(e))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){const t=this.currentSelectionEnds();if(t==null)return!1;const e=this.targetForSelectionPoint(t.bottom);return e==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(e)),!0}showUtilityOnLine(t){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=t,t.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){var t;(t=this.gutterUtilityContainer)==null||t.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){const t=this.getCurrentSelectionRange();return t==null?void 0:this.selectionEnds(t)}selectionEnds(t){const e={lineNumber:t.start,side:t.side},n={lineNumber:t.end,side:t.endSide??t.side},i=this.selectionPointRowIndex(e),r=this.selectionPointRowIndex(n);if(!(i==null||r==null))return i>r?{top:n,bottom:e}:{top:e,bottom:n}}selectionPointRowIndex(t){const e=this.getLineIndex(t.lineNumber,t.side);if(e!=null)return this.isSplitDiff()?e[1]:e[0]}targetForSelectionPoint(t){if(this.pre==null)return;const e=this.getLineIndex(t.lineNumber,t.side);if(e==null)return;const n=this.mode==="diff"?`${e[0]},${e[1]}`:`${e[0]}`,i=this.pre.querySelectorAll(`[data-column-number="${t.lineNumber}"][data-line-index="${n}"]`);for(const r of i){if(!(r instanceof HTMLElement))continue;const s=this.resolvePointerTarget(vn(r));if(xn(s)&&!(this.mode==="diff"&&t.side!=null&&s.side!==t.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(t,e){const n=this.resolvePointerTarget(t);if(xn(n)&&!(e&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode==="diff"?n.side:void 0}}resolveSelectionInfo(t,e){const n=this.resolveSelectionPath(t,e);return n!=null?this.selectionInfoFromPath(n,e.requireNumberColumn):void 0}selectionPointFromPath(t){const e=this.resolvePointerTarget(t);if(xn(e))return{lineNumber:e.lineNumber,side:this.mode==="diff"?e.side:void 0}}resolveSelectionPoint(t,e){const n=this.resolveSelectionPath(t,e);return n!=null?this.selectionPointFromPath(n):void 0}resolveSelectionPath(t,e){const n=e.excludeUtility!==!1;switch(e.source){case"event-path":return this.pathFromEventPath(t.composedPath(),n);case"coordinates-first":{const i=this.pathFromCoordinates(t,n);return i!==void 0?i??void 0:this.pathFromEventPath(t.composedPath(),n)}}}pathFromCoordinates(t,e){const n=this.hitTest(t);if(n!==void 0)return n===null?null:this.pathFromElement(n,e)??null}pathFromEventPath(t,e){if(!(e&&ti(t))){for(const n of t)if(n instanceof Element)return this.pathFromElement(n,e)}}pathFromElement(t,e){const n=vn(t);if(e&&ti(n))return;const i=Nm(t);return i!=null?vn(i):this.pathFromAnnotationSlot(t)}pathFromAnnotationSlot(t){var r;const e=(r=Fm(t))==null?void 0:r.previousElementSibling;if(e instanceof HTMLElement&&(e.hasAttribute("data-line")||e.hasAttribute("data-column-number")))return vn(e);const n=zm($m(t));if(n==null)return;const i=this.targetForSelectionPoint(n);return i!=null?vn(i.lineElement):void 0}hitTest(t){var i;if(!Number.isFinite(t.clientX)||!Number.isFinite(t.clientY))return;const e=(i=this.pre)==null?void 0:i.getRootNode(),n=ea(e)?e:ea(document)?document:void 0;if(n!=null)return n.elementFromPoint(t.clientX,t.clientY)}getLineIndex(t,e){const{getLineIndex:n}=this.options;return n!=null?n(t,e):[t-1,t-1]}getCurrentSelectionRange(){return this.proposedSelectedRange!==void 0?this.proposedSelectedRange:this.selectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(t,e,n=!0){var s,o;const i=this.getCurrentSelectionRange();let r;if(t==null)r=null;else{const l=((s=this.selectionAnchor)==null?void 0:s.side)??e,a=((o=this.selectionAnchor)==null?void 0:o.lineNumber)??t;r=this.buildSelectionRange(a,t,l,e)}zi(i??void 0,r??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=r:(this.selectedRange=r,de(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(t,e){if(this.pre==null)return;const n=this.getLineIndex(t.start,t.side),i=this.getLineIndex(t.end,t.endSide??t.side);return n!=null&&i!=null?{start:e?n[1]:n[0],end:e?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(t,e,n){if(t.range==null)return;const i=this.getIndexesFromSelection(t.range,e);if(i==null)throw console.error({rowRange:i,range:t.range}),new Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return i}getLineRenderColumns(t,e,n,i){if(this.pre==null||e==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 l=o.hasAttribute("data-deletions")?"deletions":o.hasAttribute("data-additions")?"additions":void 0,a=t!=null&&e!=null&&(t.highlightSide==null||l==null||t.highlightSide===l),d=n!=null&&i!=null&&(n.highlightSide==null||l==null||n.highlightSide===l);if(!a&&!d)continue;const[c,u]=o.children;if(!(c instanceof HTMLElement)||!(u instanceof HTMLElement))throw new Error("InteractionManager.renderSelection: missing gutter or content element");if(u.children.length!==c.children.length)throw new Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");s.push({content:u,gutter:c,renderEditorActiveLine:d,renderSelectedLines:a})}return s}notifySelectionCommitted(t){var e,n;(n=(e=this.options).onLineSelected)==null||n.call(e,t)}notifySelectionChangeDelta(){var t,e;(e=(t=this.options).onLineSelectionChange)==null||e.call(t,this.getCurrentSelectionRange()??null)}notifySelectionStart(t){var e,n;(n=(e=this.options).onLineSelectionStart)==null||n.call(e,t)}notifySelectionEnd(t){var e,n;(n=(e=this.options).onLineSelectionEnd)==null||n.call(e,t)}toEventBaseProps(t){return this.mode==="file"?{type:"line",lineElement:t.lineElement,lineNumber:t.lineNumber,numberColumn:t.numberColumn,numberElement:t.numberElement}:{type:"diff-line",annotationSide:t.side,lineType:t.lineType,lineElement:t.lineElement,numberElement:t.numberElement,lineNumber:t.lineNumber,numberColumn:t.numberColumn}}toTokenEventBaseProps({lineCharEnd:t,lineCharStart:e,lineNumber:n,side:i,tokenElement:r,tokenText:s}){return this.mode==="file"?{type:"token",lineCharEnd:t,lineCharStart:e,lineNumber:n,tokenElement:r,tokenText:s}:{type:"token",lineCharEnd:t,lineCharStart:e,lineNumber:n,side:i,tokenElement:r,tokenText:s}}buildSelectedLineRange(t,e){return this.buildSelectionRange(t.lineNumber,e.lineNumber,t.side,e.side)}buildSelectionRange(t,e,n,i){return{start:t,end:e,...n!=null?{side:n}:{},...n!==i&&i!=null?{endSide:i}:{}}}resolvePointerTarget(t){let e=!1,n,i,r,s,o,l,a,d,c,u;for(const f of t){if(!(f instanceof HTMLElement))continue;if(u==null&&f.hasAttribute("data-merge-conflict-action")){const m=f.getAttribute("data-merge-conflict-action")??void 0,C=f.getAttribute("data-merge-conflict-conflict-index")??void 0,S=C!=null?Number.parseInt(C,10):NaN;Om(m)&&Number.isFinite(S)&&(u={kind:"merge-conflict-action",resolution:m,conflictIndex:S})}if(l==null&&f.hasAttribute("data-char")){l=f;const m=f.getAttribute("data-char");if(m!=null){const C=Number.parseInt(m,10);if(!Number.isNaN(C)){const S=f.textContent??"",w=C+S.length;(S.trim()!==""||this.options.enableTokenInteractionsOnWhitespace===!0)&&(a={tokenElement:l,lineCharStart:C,lineCharEnd:w,tokenText:S});continue}}}const p=o==null?f.getAttribute("data-column-number")??void 0:void 0;if(p!=null){o=f,c=Number.parseInt(p,10),e=!0,n=ia(f),s=f.getAttribute("data-line-index")??void 0;continue}const y=r==null?f.getAttribute("data-line")??void 0:void 0;if(y!=null){r=f,c=Number.parseInt(y,10),n=ia(f),s=f.getAttribute("data-line-index")??void 0;continue}if(d==null&&(f.hasAttribute("data-expand-button")||f.hasAttribute("data-unmodified-lines"))){d={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 v=d!=null?f.getAttribute("data-expand-index")??void 0:void 0;if(d!=null&&v!=null){const m=Number.parseInt(v,10);Number.isNaN(m)||(d.hunkIndex=m);continue}if(i==null&&f.hasAttribute("data-code")){i=f;break}}if(u!=null)return u;if((d==null?void 0:d.hunkIndex)!=null)return{type:"line-info",hunkIndex:d.hunkIndex,direction:d.direction,all:d.all};if(r??(r=s!=null?Jo(i,`[data-line][data-line-index="${s}"]`):void 0),o??(o=s!=null?Jo(i,`[data-column-number][data-line-index="${s}"]`):void 0),i==null||r==null||o==null||n==null||c==null||Number.isNaN(c))return;const h=this.parseLineIndex(r,this.isSplitDiff());return a!=null?this.mode==="file"?{kind:"token",lineType:n,lineElement:r,lineNumber:c,numberColumn:e,numberElement:o,side:void 0,splitLineIndex:h,...a}:{kind:"token",lineType:n,lineElement:r,lineNumber:c,numberColumn:e,numberElement:o,side:na(n,i),splitLineIndex:h,...a}:this.mode==="file"?{kind:"line",lineType:n,lineElement:r,lineNumber:c,numberColumn:e,numberElement:o,side:void 0,splitLineIndex:h}:{kind:"line",lineType:n,lineElement:r,lineNumber:c,numberColumn:e,numberElement:o,side:na(n,i),splitLineIndex:h}}isSplitDiff(){var t;return((t=this.pre)==null?void 0:t.getAttribute("data-diff-type"))==="split"}parseLineIndex(t,e){const n=(t.getAttribute("data-line-index")??"").split(",").map(i=>Number.parseInt(i,10)).filter(i=>!Number.isNaN(i));if(e&&n.length===2)return n[1];if(!e)return n[0]}};function $n({enableTokenInteractionsOnWhitespace:t,enableGutterUtility:e,lineHoverHighlight:n,onGutterUtilityClick:i,onLineClick:r,onLineEnter:s,onLineLeave:o,onLineNumberClick:l,onTokenClick:a,onTokenEnter:d,onTokenLeave:c,renderGutterUtility:u,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:p,onLineSelected:y,onLineSelectionStart:v,onLineSelectionChange:m,onLineSelectionEnd:C},S,w,b){return{enableTokenInteractionsOnWhitespace:t,enableGutterUtility:Mm({enableGutterUtility:e,renderGutterUtility:u,onGutterUtilityClick:i}),usesCustomGutterUtility:u!=null,lineHoverHighlight:n,onGutterUtilityClick:i,onHunkExpand:S,onMergeConflictActionClick:b,onLineClick:r,onLineEnter:s,onLineLeave:o,onLineNumberClick:l,onTokenClick:a,onTokenEnter:d,onTokenLeave:c,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:p,onLineSelected:y,onLineSelectionStart:v,onLineSelectionChange:m,onLineSelectionEnd:C,getLineIndex:w}}function Mm({enableGutterUtility:t,renderGutterUtility:e,onGutterUtilityClick:n}){if(n!=null&&e!=null)throw new Error("Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.");return t??!1}function xn(t){return t!=null&&"kind"in t&&t.kind==="line"}function bi(t){return t!=null&&"kind"in t&&t.kind==="token"}function Er(t){return xn(t)||bi(t)}function Dm(t){return"type"in t&&t.type==="line-info"}function Hm(t){return"kind"in t&&t.kind==="merge-conflict-action"}function Om(t){return t==="current"||t==="incoming"||t==="both"}function Jo(t,e){const n=t==null?void 0:t.querySelector(e);return n instanceof HTMLElement?n:void 0}function vn(t){const e=[];let n=t;for(;n!=null;)e.push(n),n=n.parentNode;return e}function Nm(t){const e=t.closest("[data-line], [data-column-number]");if(e instanceof HTMLElement)return e;const n=t.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 Fm(t){var i;const e=t.closest('[slot^="annotation-"]'),n=(i=e instanceof HTMLElement&&e.assignedSlot!=null?e.assignedSlot:t.tagName==="SLOT"?t:void 0)==null?void 0:i.closest("[data-line-annotation]");return n instanceof HTMLElement?n:void 0}function $m(t){const e=t.closest('[slot^="annotation-"]');if(e instanceof HTMLElement)return e.getAttribute("slot")??void 0;if(t instanceof HTMLElement){const n=t.getAttribute("name")??void 0;return n!=null&&n.startsWith("annotation-")?n:void 0}}function zm(t){if(t==null)return;const e=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(t);if(e==null)return;const n=Number.parseInt(e[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:e[1]}}function ea(t){return t!=null&&typeof t.elementFromPoint=="function"}function Um(t,e){return t===e||zi(t??void 0,e??void 0)}function ta(t,e){return(t==null?void 0:t.highlightSide)===e.highlightSide&&(t==null?void 0:t.lineNumberOnly)===e.lineNumberOnly&&Um((t==null?void 0:t.range)??null,e.range)}function na(t,e){switch(t){case"change-deletion":return"deletions";case"change-addition":return"additions";default:return e.hasAttribute("data-deletions")?"deletions":"additions"}}function ia(t){const e=t.getAttribute("data-line-type");if(e!=null)switch(e){case"change-deletion":case"change-addition":case"context":case"context-expanded":return e;default:return}}function et(t="none",e,...n){switch(t){case"none":return;case"both":break;case"click":if(e!=="click")return;break;case"move":if(e!=="move")return}console.log(...n)}var me,$d=(me=class{constructor(){g(this,"observedNodes",new Map);g(this,"applyColumnUpdates",e=>{for(const[n,i]of e){const r=i.codeInlineSize!=null?Bm(i.codeInlineSize):n.codeWidth,s=i.numberInlineSize!=null?Vm(i.numberInlineSize):n.numberWidth,o=r!==n.codeWidth,l=s!==n.numberWidth;!o&&!l||(n.codeWidth=r,n.numberWidth=s,n.applyColumnVariables&&zd(n,{codeWidthChanged:o,numberWidthChanged:l}))}})}static getResizeObserver(){const e=me.resizeObserver??new ResizeObserver(me.handleSharedResizeEntries);return me.resizeObserver=e,e}static handleSharedResizeEntries(e){const n=new Map;for(const i of e){const r=me.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)}setup(e,{disableAnnotations:n,columnVariables:i="apply"}){const r=new Set,s=i==="apply";let o=0;const l=new Map(this.observedNodes);this.observedNodes.clear();for(const a of e.children){if(o===2)break;const d=(()=>{if(a instanceof HTMLElement&&a.tagName==="CODE")return a})();if(d==null)continue;o++;let c=l.get(d);if(c!=null&&c.type!=="code")throw new Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");let u=d.firstElementChild;u instanceof HTMLElement||(u=null),c!=null?(this.observedNodes.set(d,c),l.delete(d),c.numberElement!==u?(c.numberElement!=null&&(this.unobserve(c.numberElement),l.delete(c.numberElement)),u!=null&&(this.observe(u),l.delete(u),this.observedNodes.set(u,c)),c.numberElement=u,c.numberWidth=0):c.numberElement!=null?(l.delete(c.numberElement),this.observedNodes.set(c.numberElement,c)):c.numberWidth=0,Gm(c,s)):(c={type:"code",codeElement:d,numberElement:u,codeWidth:"auto",numberWidth:0,applyColumnVariables:s},this.observedNodes.set(d,c),this.observe(d),u!=null&&(this.observedNodes.set(u,c),this.observe(u)))}if(o>1&&!n){const a=e.querySelectorAll('[data-line-annotation*=","]'),d=new Map;for(const c of a){if(!(c instanceof HTMLElement))continue;const u=c.getAttribute("data-line-annotation")??"";if(!/^-?\d+,-?\d+$/.test(u)){console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation",{lineAnnotation:u,element:c});continue}let h=d.get(u);h==null&&(h=[],d.set(u,h)),h.push(c)}for(const[c,u]of d){if(u.length!==2){console.error("DiffFileRenderer.setupResizeObserver: Bad Pair",c,u);continue}const[h,f]=u,p=h.firstElementChild,y=f.firstElementChild;if(!(h instanceof HTMLElement)||!(f instanceof HTMLElement)||!(p instanceof HTMLElement)||!(y instanceof HTMLElement))continue;let v=l.get(p);if(v!=null){this.observedNodes.set(p,v),this.observedNodes.set(y,v),l.delete(p),l.delete(y);continue}const m=p.getBoundingClientRect().height,C=y.getBoundingClientRect().height;v={type:"annotations",column1:{container:h,child:p,childHeight:m},column2:{container:f,child:y,childHeight:C},currentHeight:"auto"},r.add({child1:p,child2:y,item:v,newHeight:Math.max(m,C)})}for(const c of r)this.applyNewHeight(c.item,c.newHeight),this.observedNodes.set(c.child1,c.item),this.observedNodes.set(c.child2,c.item),this.observe(c.child1),this.observe(c.child2);r.clear()}for(const[a,d]of l)this.unobserve(a),d.type==="code"?Wm(d):jm(d);l.clear()}cleanUp(){for(const e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(e){const{managersByElement:n}=me,i=n.get(e);if(i!==this){if(i!=null&&i!==this)throw new Error("ResizeManager.observe: element is already owned by another ResizeManager");n.set(e,this),me.getResizeObserver().observe(e)}}unobserve(e){const{managersByElement:n,resizeObserver:i}=me,r=n.get(e);if(r!=null){if(r!==this)throw new Error("ResizeManager.unobserve: element is owned by another ResizeManager");n.delete(e),i==null||i.unobserve(e),i!=null&&n.size===0&&(i.disconnect(),me.resizeObserver=void 0)}}handleResizeEntries(e){const n=new Map,i=new Set;for(const r of e){const{target:s,borderBoxSize:o,contentBoxSize:l}=r;if(!(s instanceof HTMLElement)){console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver",r);continue}const a=this.observedNodes.get(s);if(a==null){console.error("ResizeManager.handleResizeEntries: Not a valid observed node",r);continue}if(a.type==="annotations"){const d=(()=>{if(s===a.column1.child)return a.column1;if(s===a.column2.child)return a.column2})();if(d==null){console.error("ResizeManager.handleResizeEntries: Couldn't find a column for",{item:a,target:s});continue}d.childHeight=o[0].blockSize,i.add(a)}else if(a.type==="code"){const d=n.get(a)??{},c=l[0].inlineSize;s===a.codeElement?d.codeInlineSize=c:s===a.numberElement&&(d.numberInlineSize=c),n.set(a,d)}}this.applyAnnotationUpdates(i),i.clear(),this.applyColumnUpdates(n),n.clear()}applyAnnotationUpdates(e){for(const n of e)this.applyNewHeight(n,Math.max(n.column1.childHeight,n.column2.childHeight))}applyNewHeight(e,n){n!==e.currentHeight&&(e.currentHeight=Math.max(n,0),e.column1.container.style.setProperty("--diffs-annotation-min-height",`${e.currentHeight}px`),e.column2.container.style.setProperty("--diffs-annotation-min-height",`${e.currentHeight}px`))}},g(me,"resizeObserver"),g(me,"managersByElement",new Map),me);function Bm(t){const e=Math.max(Math.floor(t),0);return e===0?"auto":e}function Vm(t){return Math.max(Math.ceil(t),0)}function Gm(t,e){t.applyColumnVariables!==e&&(t.applyColumnVariables=e,e?zd(t,{codeWidthChanged:!0,numberWidthChanged:!0}):Ud(t))}function zd(t,{codeWidthChanged:e,numberWidthChanged:n}){const{codeElement:i,codeWidth:r,numberWidth:s}=t;if(e&&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`}`),e||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 Ud(t){t.codeElement.style.removeProperty("--diffs-column-content-width"),t.codeElement.style.removeProperty("--diffs-column-number-width"),t.codeElement.style.removeProperty("--diffs-column-width")}function Wm(t){t.codeElement.isConnected&&Ud(t)}function jm(t){t.column1.container.isConnected&&t.column1.container.style.removeProperty("--diffs-annotation-min-height"),t.column2.container.isConnected&&t.column2.container.style.removeProperty("--diffs-annotation-min-height")}function qm(t){return Ie.hasResolvedThemes(t)}function ht(t,e){return zt(t.theme,e.theme)&&t.useTokenTransformer===e.useTokenTransformer&&t.tokenizeMaxLineLength===e.tokenizeMaxLineLength}function sr(t,e){return t==null||e==null?t===e:t.startingLine===e.startingLine&&t.totalLines===e.totalLines&&t.bufferBefore===e.bufferBefore&&t.bufferAfter===e.bufferAfter}function ds(t){var e;return M({tagName:"div",children:[M({tagName:"div",children:(e=t.annotations)==null?void 0:e.map(n=>M({tagName:"slot",properties:{name:n}})),properties:{"data-annotation-content":""}})],properties:{"data-line-annotation":`${t.hunkIndex},${t.lineIndex}`}})}function Km(t){switch(t){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 Bd({fileOrDiff:t,mode:e,stickyHeader:n}){const i="type"in t?t:void 0,r={"data-diffs-header":e,"data-change-type":i==null?void 0:i.type,"data-sticky":n?"":void 0};return M({tagName:"div",children:[e==="custom"?M({tagName:"slot",properties:{name:Ls}}):Xm({name:t.name,prevName:"prevName"in t?t.prevName:void 0,iconType:(i==null?void 0:i.type)??"file"}),...e==="custom"?[]:[Ym(i)]],properties:r})}function Xm({name:t,prevName:e,iconType:n}){const i=[M({tagName:"slot",properties:{name:ws}}),Ui({name:Km(n),properties:{"data-change-icon":n}})];return e!=null&&(i.push(M({tagName:"div",children:[M({tagName:"bdi",children:[Se(e)]})],properties:{"data-prev-name":""}})),i.push(Ui({name:"diffs-icon-arrow-right-short",properties:{"data-rename-icon":""}}))),i.push(M({tagName:"div",children:[M({tagName:"bdi",children:[Se(t)]})],properties:{"data-title":""}})),i.push(M({tagName:"slot",properties:{name:xs}})),M({tagName:"div",children:i,properties:{"data-header-content":""}})}function Ym(t){const e=[];if(t!=null){let n=0,i=0;for(const r of t.hunks)n+=r.additionLines,i+=r.deletionLines;(i>0||n===0)&&e.push(M({tagName:"span",children:[Se(`-${i}`)],properties:{"data-deletions-count":""}})),(n>0||i===0)&&e.push(M({tagName:"span",children:[Se(`+${n}`)],properties:{"data-additions-count":""}}))}return e.push(M({tagName:"slot",properties:{name:ks}})),M({tagName:"div",children:e,properties:{"data-metadata":""}})}function Vd(t){return M({tagName:"pre",properties:Qm(t)})}function Qm({diffIndicators:t,disableBackground:e,disableLineNumbers:n,overflow:i,split:r,totalLines:s,type:o,customProperties:l}){return{...l,"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":e?void 0:"","data-indicators":t==="bars"||t==="classic"?t:void 0,style:`--diffs-min-number-column-width-default:${`${s}`.length}ch;`}}const Be=new Map;let Bi=0;const Gt={"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",odin:"odin",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",BUCK:"python",BUILD:"python",PACKAGE:"python",WORKSPACE:"python",Tiltfile:"python",bazel:"python",bxl:"python",bzl:"python",bzlmod:"python",star:"python",sky:"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 be(t){const e=ra(t);if(e!=null)return e;const n=t.split(/[/\\]/).pop()??t;return n===t?"text":ra(n)??"text"}function ra(t){var i;if(Be.has(t))return Be.get(t)??"text";if(Object.hasOwn(Gt,t))return Gt[t]??null;const e=t.match(/\.([^/\\]+\.[^/\\]+)$/);if(e!=null){if(Be.has(e[1]))return Be.get(e[1])??"text";if(Object.hasOwn(Gt,e[1]))return Gt[e[1]]??"text"}const n=((i=t.match(/\.([^.]+)$/))==null?void 0:i[1])??"";return Be.has(n)?Be.get(n)??"text":Object.hasOwn(Gt,n)?Gt[n]??"text":null}function kS(t,e){if(t<=Bi)return!1;Be.clear();for(const n in e){const i=e[n];i!=null&&Be.set(n,i)}return Bi=t,!0}function LS(){return Bi}function Zm(t,e){const n=Be.get(t);return n===e?!1:(n!=null&&console.warn(`setCustomExtension: overriding custom mapping for "${t}" from "${n}" to "${e}"`),Be.set(t,e),Bi++,!0)}function ES(){return Object.fromEntries(Be)}function Gs(t,{theme:e,preferredHighlighter:n="shiki-js"}){return{langs:Array.isArray(t)?t:[t??"text"],themes:cn(e),preferredHighlighter:n}}function Ye(t){return`annotation-${"side"in t?`${t.side}-`:""}${t.lineNumber}`}function Vi(t){return t.startingLine===0&&t.totalLines===1/0&&t.bufferBefore===0&&t.bufferAfter===0}function Jm(t,e,n){const i=typeof n.lineInfo=="function"?n.lineInfo(e):n.lineInfo[e-1];if(i==null){const r=`processLine: line ${e}, contains no state.lineInfo`;throw console.error(r,{node:t,line:e,state:n}),new Error(r)}return t.tagName="div",t.properties["data-line"]=i.lineNumber,t.properties["data-alt-line"]=i.altLineNumber,t.properties["data-line-type"]=i.type,t.properties["data-line-index"]=i.lineIndex,t.children.length===0&&t.children.push(Se(`
154
+ `)),t}const ni=Symbol("no-token"),Rr=Symbol("multiple-tokens");function Gd(t){const e=e0(t);if(e!=null)return e;let n=ni;const i=[];let r=[],s;const o=()=>{if(r.length===0||s==null){r=[],s=void 0;return}if(r.length===1){const a=r[0];if((a==null?void 0:a.type)==="element"){t0(a,s);for(const d of a.children)wi(d)}else wi(a);i.push(a),r=[],s=void 0;return}for(const a of r)wi(a);i.push(M({tagName:"span",properties:{"data-char":s},children:r})),r=[],s=void 0},l=a=>{if(a!==ni){if(a===Rr){n=Rr;return}if(n===ni){n=a;return}n!==a&&(n=Rr)}};for(const a of t.children){const d=a.type==="element"?Gd(a):ni;if(l(d),typeof d!="number"){o(),i.push(a);continue}s!=null&&s!==d&&o(),s??(s=d),r.push(a)}return o(),t.children=i,n}function e0(t){const e=t.properties["data-char"];if(typeof e=="number")return e}function wi(t){if(t.type==="element"){t.properties["data-char"]=void 0;for(const e of t.children)wi(e)}}function t0(t,e){t.properties["data-char"]=e}function n0(t={}){const{classPrefix:e="__shiki_",classSuffix:n="",classReplacer:i=l=>l}=t,r=new Map;function s(l){return Object.entries(l).map(([a,d])=>`${a}:${d}`).join(";")}function o(l){const a=typeof l=="string"?l:s(l);let d=e+i0(a)+n;return d=i(d),r.has(d)||r.set(d,typeof l=="string"?l:{...l}),d}return{name:"@shikijs/transformers:style-to-class",pre(l){if(!l.properties.style)return;const a=o(l.properties.style);delete l.properties.style,this.addClassToHast(l,a)},tokens(l){for(const a of l)for(const d of a){if(!d.htmlStyle)continue;const c=o(d.htmlStyle);d.htmlStyle={},d.htmlAttrs||(d.htmlAttrs={}),d.htmlAttrs.class?d.htmlAttrs.class+=` ${c}`:d.htmlAttrs.class=c}},getClassRegistry(){return r},getCSS(){let l="";for(const[a,d]of r.entries())l+=`.${a}{${typeof d=="string"?d:s(d)}}`;return l},clearRegistry(){r.clear()}}}function i0(t,e=0){let n=3735928559^e,i=1103547991^e;for(let r=0,s;r<t.length;r++)s=t.charCodeAt(r),n=Math.imul(n^s,2654435761),i=Math.imul(i^s,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&i)+(n>>>0)).toString(36).slice(0,6)}function Wd(t=!1,e=!1){const n={lineInfo:[]},i=[{line(r){return delete r.properties.class,r},pre(r){const s=Im(r),o=[];if(s!=null){let l=1;for(const a of s.children)a.type==="element"&&(t&&Gd(a),o.push(Jm(a,l,n)),l++);s.children=o}return r},...t?{tokens(r){for(const s of r){let o=0;for(const l of s){const a=l;a.__lineChar??(a.__lineChar=o),o+=l.content.length}}},preprocess(r,s){s.mergeWhitespaces="never"},span(r,s,o,l,a){if((a==null?void 0:a.offset)!=null&&a.content!=null){const d=a.__lineChar;return d!=null&&(r.properties["data-char"]=d),r}return r}}:null}];return e&&i.push(r0,sa),t&&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:sa}}const sa=n0({classPrefix:"hl-"}),r0={name:"token-style-normalizer",tokens(t){for(const e of t)for(const n of e){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 he(t){return`--${t==="token"?"diffs-token":"diffs"}-`}const s0=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,o0=/^0(?:\.0+)?%?$/;function a0(t){var s;const e=t.indexOf("(");if(e<=0||!t.endsWith(")"))return;const n=t.slice(0,e).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;const i=t.slice(e+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 o=i.split(",");if(o.length===4)return(s=o[3])==null?void 0:s.trim()}}function l0(t){const e=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(t.trim());if(e==null)return null;const n=e[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 _r(t){if(t==null)return null;const e=l0(t);if(e==null)return null;const n=e[0]/255,i=e[1]/255,r=e[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 oa(t){if(t==null)return!1;const e=t.trim().toLowerCase();if(e==="transparent"||s0.test(e))return!0;const n=a0(e);return n!=null&&o0.test(n)}function d0(t,e,n){if(e==null||n==null)return!1;const i=_r(t),r=_r(e),s=_r(n);return i==null||r==null||s==null?!1:Math.abs(i-s)<Math.abs(i-r)}const aa=new WeakMap;function Tr(t){const e=aa.get(t);if(e!=null)return e;const n=t.colors??{},i={...n},r=n["editor.background"]??t.bg,s=n["editor.foreground"]??t.fg,o=n["sideBar.background"]??r,l=n["sideBar.foreground"]??s;je(i,"editor.background",r),je(i,"editor.foreground",s),je(i,"sideBar.background",o),je(i,"sideBar.foreground",l),je(i,"input.background",n["input.background"]??o),je(i,"sideBarSectionHeader.foreground",n["sideBarSectionHeader.foreground"]??l),je(i,"list.activeSelectionForeground",n["list.activeSelectionForeground"]??l),je(i,"gitDecoration.addedResourceForeground",Ir(n["gitDecoration.addedResourceForeground"],n["terminal.ansiGreen"],n["editorGutter.addedBackground"])),je(i,"gitDecoration.modifiedResourceForeground",Ir(n["gitDecoration.modifiedResourceForeground"],n["terminal.ansiBlue"],n["editorGutter.modifiedBackground"])),je(i,"gitDecoration.deletedResourceForeground",Ir(n["gitDecoration.deletedResourceForeground"],n["terminal.ansiRed"],n["editorGutter.deletedBackground"]));const a=(oa(n["list.focusOutline"])?void 0:n["list.focusOutline"])??(oa(n.focusBorder)?void 0:n.focusBorder);a!=null?i["list.focusOutline"]=a:delete i["list.focusOutline"];const d=n["list.hoverBackground"];d!=null&&(c0(d,o)||d0(d,o,l))&&delete i["list.hoverBackground"];const c=Object.freeze({...t,colors:Object.freeze(i)});return aa.set(t,c),c}function je(t,e,n){n!=null&&n!==""&&(t[e]=n)}function Ir(...t){for(const e of t)if(e!=null&&e!=="")return e}function c0(t,e){return e!=null&&t.toLowerCase()===e.toLowerCase()}function Ws({theme:t=j,highlighter:e,prefix:n}){let i="";if(typeof t=="string"){const r=e.getTheme(t),s=Tr(r);i+=`color:${s.fg};`,i+=`background-color:${s.bg};`,i+=`${he("global")}fg:${s.fg};`,i+=`${he("global")}bg:${s.bg};`,i+=Ar(r,n)}else{let r=e.getTheme(t.dark),s=Tr(r);i+=`${he("global")}dark:${s.fg};`,i+=`${he("global")}dark-bg:${s.bg};`,i+=Ar(r,"dark"),r=e.getTheme(t.light),s=Tr(r),i+=`${he("global")}light:${s.fg};`,i+=`${he("global")}light-bg:${s.bg};`,i+=Ar(r,"light")}return i}function Ar(t,e){var o,l,a,d,c,u;e=e!=null?`${e}-`:"";let n="";const i=((o=t.colors)==null?void 0:o["gitDecoration.addedResourceForeground"])??((l=t.colors)==null?void 0:l["terminal.ansiGreen"]);i!=null&&(n+=`${he("global")}${e}addition-color:${i};`);const r=((a=t.colors)==null?void 0:a["gitDecoration.deletedResourceForeground"])??((d=t.colors)==null?void 0:d["terminal.ansiRed"]);r!=null&&(n+=`${he("global")}${e}deletion-color:${r};`);const s=((c=t.colors)==null?void 0:c["gitDecoration.modifiedResourceForeground"])??((u=t.colors)==null?void 0:u["terminal.ansiBlue"]);return s!=null&&(n+=`${he("global")}${e}modified-color:${s};`),n}function cs(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e.children;"children"in e?e=e.children[0]:e=null}throw console.error(t),new Error("getLineNodes: Unable to find children")}const la=10,da=13,u0=4,h0=40;function f0(t){const e=[0];let n=t.indexOf("\r"),i=t.indexOf(`
155
+ `),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=t.indexOf("\r",o),i=t.indexOf(`
156
+ `,o)):(o=n+1,n=t.indexOf("\r",o)):(o=i+1,i=t.indexOf(`
157
+ `,o)),e.push(o),++s===u0){if(o-r<=h0){for(let l=o;l<t.length;l++){const a=t.charCodeAt(l);(a===la||a===da)&&(a===da&&l+1<t.length&&t.charCodeAt(l+1)===la&&l++,e.push(l+1))}return e}r=o,s=0}}return e}function kn(t){const e=f0(t);return Array.from({length:e.length},(n,i)=>{const r=e[i],s=e[i+1]??t.length;return t.slice(r,s)})}function rn(t,e){for(const n of e)t.push(n)}const p0={forcePlainText:!1};function g0(t,e,{theme:n,tokenizeMaxLineLength:i,useTokenTransformer:r},{forcePlainText:s,startingLine:o,totalLines:l,lines:a}=p0){s?(o??(o=0),l??(l=1/0)):(o=0,l=1/0);const d=o>0||l<1/0,{state:c,transformers:u}=Wd(r),h=s?"text":t.lang??be(t.name),f=typeof n=="string"?e.getTheme(n).type:void 0,p=Ws({theme:n,highlighter:e});c.lineInfo=C=>({type:"context",lineIndex:C-1+o,lineNumber:C+o});const y=typeof n=="string"?{lang:h,theme:n,transformers:u,defaultColor:!1,cssVariablePrefix:he("token"),tokenizeMaxLineLength:i,tokenizeTimeLimit:0}:{lang:h,themes:n,transformers:u,defaultColor:!1,cssVariablePrefix:he("token"),tokenizeMaxLineLength:i,tokenizeTimeLimit:0},v=cs(e.codeToHast(m0(d?y0(a??kn(t.contents),o,l):t.contents),y)),m=d?new Array(o):v;return d&&rn(m,v),{code:m,themeStyles:p,baseThemeType:f}}function m0(t){return t.replace(/\r(?!\n)/g,`
158
+ `)}function y0(t,e,n){if(t.length===0)return"";const i=Math.min(e+n,t.length);return t.slice(e,i).join("")}function Z(t,e){return(t==null?void 0:t.cacheKey)!=null||(e==null?void 0:e.cacheKey)!=null?(t==null?void 0:t.cacheKey)===(e==null?void 0:e.cacheKey):(t==null?void 0:t.contents)===(e==null?void 0:e.contents)&&(t==null?void 0:t.name)===(e==null?void 0:e.name)&&(t==null?void 0:t.lang)===(e==null?void 0:e.lang)}const jd="-1,-1";function qd(t){return(t==null?void 0:t.some(e=>e.lineNumber===0))??!1}function us(t){const e=t[0];return e!=null&&e.length>0?e:void 0}function or(t){return t.startingLine===0&&t.totalLines>0}function Kd(t,e){return t.endsWith(`\r
159
+ `)?e+`\r
160
+ `:t.endsWith("\r")?e+"\r":t.endsWith(`
161
+ `)?e+`
162
+ `:e}function Xd(t,e){return M({tagName:"div",children:t,properties:{"data-content":"",style:`grid-row: span ${e}`}})}function xi(t){return(t.lang??be(t.name))==="text"}function ii(t,e){return e.cacheKey==null?t.file===e&&t.sourceContents===e.contents:t.cacheKey===e.cacheKey}let v0=-1;var C0=class{constructor(t={theme:j},e=Ye,n,i){g(this,"options");g(this,"annotationSlotName");g(this,"onRenderUpdate");g(this,"workerManager");g(this,"__id",`file-renderer:${++v0}`);g(this,"highlighter");g(this,"file");g(this,"renderCache");g(this,"pendingHighlightResult");g(this,"computedLang","text");g(this,"lineAnnotations",{});g(this,"lineCache");g(this,"pendingStructuralRows");g(this,"textDocumentCache",new WeakMap);g(this,"editSessionActive",!1);this.options=t,this.annotationSlotName=e,this.onRenderUpdate=n,this.workerManager=i,(i==null?void 0:i.isWorkingPool())!==!0&&(this.highlighter=Ge(t.theme??j)?tn():void 0)}get fileCache(){var t;return(t=this.renderCache)==null?void 0:t.file}setOptions(t){this.options=t}mergeOptions(t){this.options={...this.options,...t}}setLineAnnotations(t){this.lineAnnotations={};for(const e of t){const n=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=n,n.push(e)}}cleanUp(){this.endEditSession(),this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(t,e){const{editSessionActive:n,renderCache:i}=this;if(this.editSessionActive=!0,n||(this.pendingHighlightResult=void 0),this.file=t,i==null||n&&i.file===t)return;if(n){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}const{options:r}=this.getRenderOptions(t),s=i.file===t,o=e!=null&&Z(i.file,e),{result:l}=i;if(!i.highlighted||l==null||!ht(i.options,r)||!s&&!o){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}if(s)return;this.renderCache={...i,file:t,result:{...l,code:[...l.code]}};const{lineCache:a}=this;a!=null&&e!=null&&ii(a,e)?this.lineCache={cacheKey:void 0,file:t,sourceContents:t.contents,lines:a.lines}:this.lineCache=void 0}endEditSession(t){if(this.editSessionActive=!1,this.pendingHighlightResult=void 0,this.file==null){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}const{renderCache:e}=this;t==null||e==null||e.file===t||!Z(e.file,t)||(e.file=t)}editorRenderReady(){var t;return((t=this.renderCache)==null?void 0:t.options.useTokenTransformer)===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){var t;this.editSessionActive?(this.renderCache!=null&&(this.renderCache.renderRange=void 0),this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0):(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap),this.highlighter=void 0,(t=this.workerManager)==null||t.cleanUpTasks(this),this.file=void 0}clearRenderCache(){this.pendingStructuralRows=void 0,this.renderCache=void 0,this.pendingHighlightResult=void 0}hydrate(t){var r,s;this.file=t;const{options:e}=this.getRenderOptions(t),n=ri(this.getOrCreateLineCache(t).length,this.getTokenizeMaxLength());let i=(r=this.workerManager)==null?void 0:r.getFileResultCache(t);i!=null&&!ht(e,i.options)&&(i=void 0),this.renderCache??(this.renderCache={file:t,hydrated:!0,options:e,highlighted:!n&&!xi(t),result:n||i==null?void 0:i.result,renderRange:void 0}),!this.editSessionActive&&((s=this.workerManager)==null?void 0:s.isWorkingPool())===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,t):this.highlighter==null&&(this.computedLang=t.lang??be(t.name),this.initializeHighlighter())}getLocalHighlightTheme(){var t;return((t=this.workerManager)==null?void 0:t.getFileRenderOptions().theme)??this.options.theme??j}getEffectiveCodeOptions(){var e;const t=((e=this.workerManager)==null?void 0:e.isWorkingPool())===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:(t==null?void 0:t.tokenizeMaxLineLength)??this.options.tokenizeMaxLineLength}}getRenderOptions(t){const e=(()=>{var r;if(((r=this.workerManager)==null?void 0:r.isWorkingPool())===!0){const s=this.workerManager.getFileRenderOptions();return this.editSessionActive&&s.useTokenTransformer!==!0?{...s,useTokenTransformer:!0}:s}const{tokenizeMaxLineLength:i=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:i}})(),{renderCache:n}=this;return(n==null?void 0:n.result)==null?{options:e,forceHighlight:!0}:!Z(t,n.file)||!ht(e,n.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getFileForNextRender(t){const{options:e}=this.getRenderOptions(t);if(this.getReadyRenderResult(t,e)!=null)return t;const{renderCache:n}=this;if(n==null)return t;if(Z(n.file,t))return n.file;const i=kn(t.contents),r=t.contents.length===0||xi(t)||ri(i.length,this.getTokenizeMaxLength());return this.canRenderFile(t,e,r)?t:n.file}canRenderFile(t,e,n){var r,s;const{renderCache:i}=this;return i==null||Z(i.file,t)?!0:n?i.result==null&&i.hydrated!==!0||((r=this.workerManager)==null?void 0:r.isWorkingPool())===!0||this.highlighter!=null&&Ge(e.theme):i.result==null&&i.hydrated!==!0?!0:!this.editSessionActive&&((s=this.workerManager)==null?void 0:s.isWorkingPool())===!0?!i.highlighted:this.highlighter!=null&&Ge(e.theme)}getOrCreateLineCache(t){let{lineCache:e}=this;return(e==null||!ii(e,t))&&(e={cacheKey:t.cacheKey,file:t,sourceContents:t.contents,lines:kn(t.contents)}),this.lineCache=e,e.lines}getLineCount(t){var n;const e=this.getOrCreateLineCache(t);return((n=this.textDocumentCache.get(t))==null?void 0:n.lineCount)??e.length}updateRenderCache(t,e,n=!1){this.pendingStructuralRows=void 0;const{renderCache:i}=this;if(i==null)return;const{file:r,result:s}=i;if(s==null)return;const o=n?new Map:void 0;this.pendingStructuralRows=o;const l=this.lineCache!=null&&ii(this.lineCache,r)?this.lineCache:void 0;for(const[a,d]of t){if(o==null&&l!=null&&a<l.lines.length){const u=d.map(h=>h[2]).join("");l.lines[a]=Kd(l.lines[a]??"",u)}const c={type:"element",tagName:"div",properties:{"data-line":a+1,"data-line-type":"context","data-line-index":a},children:d.map(([u,h,f])=>u===0&&h===""?f===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:f}:{type:"element",tagName:"span",properties:{"data-char":u,style:`color:${h};`},children:[{type:"text",value:f}]})};o!=null?o.set(a,c):s.code[a]=c}s.baseThemeType=e,i.isDirty=!0,o==null&&l!=null&&(r.contents=l.lines.join(""),l.sourceContents=r.contents)}applyDocumentChange(t){var a;const{pendingStructuralRows:e,renderCache:n}=this;this.pendingStructuralRows=void 0;const i=this.file??(n==null?void 0:n.file);if(i==null)return;const r=n==null?void 0:n.result,s=this.lineCache!=null&&ii(this.lineCache,i)?this.lineCache.lines:kn(i.contents),o=kn(t.getText());if(r!=null&&s.length!==o.length){const d=Math.min(s.length,o.length);let c=0;for(;c<d&&s[c]===o[c];)c++;let u=0;for(;u<d-c&&s[s.length-1-u]===o[o.length-1-u];)u++;const h=r.code;r.code=new Array(o.length);for(let f=0;f<c;f++)r.code[f]=h[f];for(let f=0;f<u;f++)r.code[o.length-1-f]=h[s.length-1-f];if(e!==void 0)for(const[f,p]of e)f<o.length&&(r.code[f]=p);for(let f=c;f<o.length-u;f++)(a=r.code)[f]??(a[f]={type:"element",tagName:"div",properties:{"data-line":f+1,"data-line-type":"context","data-line-index":f},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:t.getLineText(f)}]}]});for(let f=0;f<r.code.length;f++){const p=r.code[f];(p==null?void 0:p.type)==="element"&&(p.properties["data-line"]=f+1,p.properties["data-line-index"]=f)}n!=null&&(n.isDirty=!0)}const l=t.getText();this.lineCache={cacheKey:i.cacheKey,file:i,sourceContents:l,lines:o},this.textDocumentCache.set(i,t),i.contents=l}renderFile(t=this.file,e=Jt){var u;if(this.file=t,t==null){this.pendingHighlightResult=void 0;return}let{options:n,forceHighlight:i}=this.getRenderOptions(t);const r=this.getReadyRenderResult(t,n);this.pendingHighlightResult=void 0,r!=null&&(this.renderCache={...r,file:t,renderRange:void 0},i=!1),this.renderCache??(this.renderCache={file:t,highlighted:!1,options:n,result:void 0,renderRange:void 0});const s=this.getOrCreateLineCache(t),o=t.contents.length>0,l=!o||xi(t)||ri(s.length,this.getTokenizeMaxLength()),a=this.canRenderFile(t,n,l),d=!Z(t,this.renderCache.file),c=!sr(this.renderCache.renderRange,e);if(!this.editSessionActive&&((u=this.workerManager)==null?void 0:u.isWorkingPool())===!0){const h=this.renderCache.result==null&&this.renderCache.highlighted&&!l&&!d&&Vi(e);a&&!h&&(l||this.renderCache.result==null||!this.renderCache.highlighted&&(d||c))&&(this.renderCache.file=t,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||d||c||i)&&(this.renderCache.result=this.workerManager.getPlainFileAST(t,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!l&&o&&(!this.renderCache.highlighted||i)&&this.workerManager.highlightFileAST(this,t)}else{this.computedLang=t.lang??be(t.name),this.highlighter??(this.highlighter=tn());const h=this.highlighter!=null&&Ge(n.theme),f=this.highlighter!=null&&An(this.computedLang),p=!l&&f;if(a&&this.highlighter!=null&&h&&(i||l||!this.renderCache.highlighted&&p||this.renderCache.result==null)){const{result:y,options:v}=this.renderFileWithHighlighter(t,this.highlighter,l||!f);this.renderCache={file:t,options:v,highlighted:p,result:y,renderRange:void 0}}(!h||!l&&!f)&&this.asyncHighlight(t).then(({result:y,options:v})=>{this.applyHighlightResult(t,y,v,!l)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(t,e=Jt){this.file=t;const{result:n}=await this.asyncHighlight(t);return this.processFileResult(t,e,n)}async asyncHighlight(t){const e=ri(this.getOrCreateLineCache(t).length,this.getTokenizeMaxLength());this.computedLang=e?"text":t.lang??be(t.name);const n=this.highlighter!=null&&qm(cn(this.getLocalHighlightTheme())),i=e||this.highlighter!=null&&An(this.computedLang);return(this.highlighter==null||!n||!i)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(t,this.highlighter,e)}renderFileWithHighlighter(t,e,n=!1){const{options:i}=this.getRenderOptions(t);return{result:g0(t,e,i,{forcePlainText:n}),options:i}}processFileResult(t,e,{code:n,themeStyles:i,baseThemeType:r}){const s=this.getLineCount(t),{disableFileHeader:o=!1}=this.options,l=[],a=Yt(),d=Math.min(e.startingLine+e.totalLines,s);let c=0;const u=or(e)?us(this.lineAnnotations):void 0;u!=null&&(a.children.push(Le("context","annotation",1)),l.push(ds({hunkIndex:-1,lineIndex:-1,annotations:u.map(h=>this.annotationSlotName(h))})),c++);for(let h=e.startingLine;h<d;h++){const f=h+1,p=n[h];if(p==null){const v="FileRenderer.processFileResult: Line doesnt exist";throw console.error(v,{name:t.name,lineIndex:h,lineNumber:f}),new Error(v)}a.children.push(Nd("context",f,`${h}`)),l.push(p),c++;const y=this.lineAnnotations[f];y!=null&&(a.children.push(Le("context","annotation",1)),l.push(ds({hunkIndex:0,lineIndex:f,annotations:y.map(v=>this.annotationSlotName(v))})),c++)}return a.properties.style=`grid-row: span ${c}`,{file:t,gutterAST:a.children??[],contentAST:l,preAST:this.createPreElement(s),headerAST:o?void 0:this.renderHeader(t),totalLines:s,rowCount:c,themeStyles:i,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(t){const{headerRenderMode:e="default",stickyHeader:n=!1}=this.options;return Bd({fileOrDiff:t,mode:e,stickyHeader:n})}renderFullHTML(t){return Ce(this.renderFullAST(t))}renderFullAST(t,e=[]){return e.push(M({tagName:"code",children:this.renderCodeAST(t),properties:{"data-code":""}})),{...t.preAST,children:e}}renderCodeAST(t){const e=Yt();return e.children=t.gutterAST,e.properties.style=`grid-row: span ${t.rowCount}`,[e,Xd(t.contentAST,t.rowCount)]}renderPartialHTML(t,e=!1){return Ce(e?M({tagName:"code",children:t,properties:{"data-code":""}}):t)}async initializeHighlighter(){var t;return this.highlighter=await un(Gs(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:((t=this.workerManager)==null?void 0:t.getPreferredHighlighter())??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(t,e,n,i=!0){this.editSessionActive||this.applyHighlightResult(t,e,n,i)}applyHighlightResult(t,e,n,i=!0){var o;const{file:r,renderCache:s}=this;r==null||s==null||!Z(t,r)||!ht(n,this.getRenderOptions(r).options)||(s.result==null||!s.highlighted||!ht(s.options,n)||!Z(s.file,r))&&(this.pendingHighlightResult={file:r,options:n,highlighted:i,result:e},(o=this.onRenderUpdate)==null||o.call(this))}getMatchingWorkerResultCache(t,e){var i;if(this.editSessionActive)return;const n=(i=this.workerManager)==null?void 0:i.getFileResultCache(t);if(!(n==null||!ht(e,n.options)))return n}getReadyRenderResult(t,e){const{pendingHighlightResult:n}=this;if(n!=null&&Z(n.file,t)&&ht(n.options,e))return n;const i=this.getMatchingWorkerResultCache(t,e);if(!(i==null||this.hasHighlightedRenderCache(t,e)))return{file:t,highlighted:!0,...i}}hasHighlightedRenderCache(t,e){const{renderCache:n}=this;return(n==null?void 0:n.result)!=null&&n.highlighted&&Z(t,n.file)&&ht(e,n.options)}onHighlightError(t){console.error(t)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(t){const{disableLineNumbers:e=!1,overflow:n="scroll"}=this.options;return Vd({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:n,split:!1,totalLines:t})}};function ri(t,e){return t>e}const Yd=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
163
+ <symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
164
+ <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"/>
165
+ </symbol>
166
+ <symbol id="diffs-icon-brand-github" viewBox="0 0 16 16">
167
+ <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"/>
168
+ </symbol>
169
+ <symbol id="diffs-icon-chevron" viewBox="0 0 16 16">
170
+ <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"/>
171
+ </symbol>
172
+ <symbol id="diffs-icon-chevrons-narrow" viewBox="0 0 10 16">
173
+ <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"/>
174
+ </symbol>
175
+ <symbol id="diffs-icon-diff-split" viewBox="0 0 16 16">
176
+ <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"/>
177
+ </symbol>
178
+ <symbol id="diffs-icon-diff-unified" viewBox="0 0 16 16">
179
+ <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"/>
180
+ </symbol>
181
+ <symbol id="diffs-icon-expand" viewBox="0 0 16 16">
182
+ <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"/>
183
+ </symbol>
184
+ <symbol id="diffs-icon-expand-all" viewBox="0 0 16 16">
185
+ <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"/>
186
+ </symbol>
187
+ <symbol id="diffs-icon-eye-slash" viewBox="0 0 16 16">
188
+ <path d="m13.47 1.47-12 12 1.06 1.06 12-12zM8 14c-.92 0-1.802-.208-2.624-.547l1.173-1.174c.476.142.963.221 1.451.221 1.66 0 3.307-.949 4.626-2.196a10.4 10.4 0 0 0 1.494-1.751A5 5 0 0 0 14.443 8a5 5 0 0 0-.323-.553 10 10 0 0 0-1.238-1.5l1.061-1.062C15.222 6.173 16 7.511 16 8c0 1.05-3.582 6-8 6"/><path d="M8 11q-.084 0-.167-.005l3.162-3.162q.006.083.005.167a3 3 0 0 1-3 3M5.005 8.167l3.162-3.162a3 3 0 0 0-3.162 3.162"/><path d="M8 3.5c.485 0 .97.081 1.445.227l1.168-1.169C9.794 2.212 8.915 2 8 2 3.582 2 0 6.8 0 8c0 .555.766 1.88 2.027 3.144l1.06-1.06a9.5 9.5 0 0 1-1.203-1.461 4.3 4.3 0 0 1-.345-.617L1.536 8l.003-.006c.064-.149.176-.359.345-.617a9.8 9.8 0 0 1 1.482-1.73C4.675 4.427 6.326 3.5 8 3.5"/>
189
+ </symbol>
190
+ <symbol id="diffs-icon-file-code" viewBox="0 0 16 16">
191
+ <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"/>
192
+ </symbol>
193
+ <symbol id="diffs-icon-plus" viewBox="0 0 16 16">
194
+ <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"/>
195
+ </symbol>
196
+ <symbol id="diffs-icon-symbol-added" viewBox="0 0 16 16">
197
+ <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"/>
198
+ </symbol>
199
+ <symbol id="diffs-icon-symbol-added-duo" viewBox="0 0 16 16">
200
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><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"/>
201
+ </symbol>
202
+ <symbol id="diffs-icon-symbol-added-fill" viewBox="0 0 16 16">
203
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m0 4a.75.75 0 0 0-.75.75v2.5h-2.5a.75.75 0 0 0 0 1.5h2.5v2.5a.75.75 0 0 0 1.5 0v-2.5h2.5a.75.75 0 0 0 0-1.5h-2.5v-2.5A.75.75 0 0 0 8 4" clip-rule="evenodd"/>
204
+ </symbol>
205
+ <symbol id="diffs-icon-symbol-deleted" viewBox="0 0 16 16">
206
+ <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"/>
207
+ </symbol>
208
+ <symbol id="diffs-icon-symbol-deleted-duo" viewBox="0 0 16 16">
209
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><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"/>
210
+ </symbol>
211
+ <symbol id="diffs-icon-symbol-deleted-fill" viewBox="0 0 16 16">
212
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8M4.75 7.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/>
213
+ </symbol>
214
+ <symbol id="diffs-icon-symbol-diffstat" viewBox="0 0 16 16">
215
+ <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"/>
216
+ </symbol>
217
+ <symbol id="diffs-icon-symbol-diffstat-duo" viewBox="0 0 16 16">
218
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><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"/>
219
+ </symbol>
220
+ <symbol id="diffs-icon-symbol-diffstat-fill" viewBox="0 0 16 16">
221
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8M5.25 10a.75.75 0 0 0 0 1.5h5.5a.75.75 0 0 0 0-1.5zM8 3.546a.75.75 0 0 0-.75.75V6.25h-2a.75.75 0 0 0 0 1.5h2v1.5h1.5v-1.5h2a.75.75 0 0 0 0-1.5h-2V4.296a.75.75 0 0 0-.75-.75" clip-rule="evenodd"/>
222
+ </symbol>
223
+ <symbol id="diffs-icon-symbol-extracted" viewBox="0 0 16 16">
224
+ <path d="M8.25 4.25a.75.75 0 0 1 0 1.5H6.81l3.302 3.302a1.5 1.5 0 1 1-1.06 1.06L5.75 6.811V8.25a.75.75 0 0 1-1.5 0V5A.75.75 0 0 1 5 4.25z"/><path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m0 1.5c-1.613 0-2.807.089-3.704.288-.88.196-1.382.477-1.706.802-.325.324-.606.826-.802 1.706C1.588 5.193 1.5 6.387 1.5 8s.089 2.807.288 3.704c.196.88.477 1.382.802 1.706.324.325.826.606 1.706.802.897.2 2.091.288 3.704.288s2.807-.089 3.704-.288c.88-.196 1.382-.477 1.706-.802.325-.324.606-.826.802-1.706.2-.897.288-2.091.288-3.704s-.089-2.807-.288-3.704c-.196-.88-.477-1.382-.802-1.706-.324-.325-.826-.606-1.706-.802C10.807 1.588 9.613 1.5 8 1.5" clip-rule="evenodd"/>
225
+ </symbol>
226
+ <symbol id="diffs-icon-symbol-extracted-duo" viewBox="0 0 16 16">
227
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8" clip-rule="evenodd" opacity=".2"/><path d="M8.25 4.25a.75.75 0 0 1 0 1.5H6.81l3.302 3.302a1.5 1.5 0 1 1-1.06 1.06L5.75 6.811V8.25a.75.75 0 0 1-1.5 0V5A.75.75 0 0 1 5 4.25z"/>
228
+ </symbol>
229
+ <symbol id="diffs-icon-symbol-extracted-fill" viewBox="0 0 16 16">
230
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8M5 4.25a.75.75 0 0 0-.75.75v3.25a.75.75 0 0 0 1.5 0V6.81l3.302 3.302a1.5 1.5 0 1 0 1.06-1.06L6.811 5.75H8.25a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/>
231
+ </symbol>
232
+ <symbol id="diffs-icon-symbol-ignored" viewBox="0 0 16 16">
233
+ <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"/>
234
+ </symbol>
235
+ <symbol id="diffs-icon-symbol-ignored-duo" viewBox="0 0 16 16">
236
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><path d="M11.53 4.47a.75.75 0 0 1 0 1.06l-6 6a.75.75 0 0 1-1.06-1.06l6-6a.75.75 0 0 1 1.06 0"/>
237
+ </symbol>
238
+ <symbol id="diffs-icon-symbol-ignored-fill" viewBox="0 0 16 16">
239
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m3.53 4.47a.75.75 0 0 0-1.06 0l-6 6a.75.75 0 1 0 1.06 1.06l6-6a.75.75 0 0 0 0-1.06" clip-rule="evenodd"/>
240
+ </symbol>
241
+ <symbol id="diffs-icon-symbol-inlined" viewBox="0 0 16 16">
242
+ <path d="M7.75 11.75a.75.75 0 0 1 0-1.5h1.44L5.887 6.948a1.5 1.5 0 1 1 1.06-1.06l3.302 3.301V7.75a.75.75 0 0 1 1.5 0V11a.75.75 0 0 1-.75.75z"/><path fill-rule="evenodd" d="M8 16c-6.588 0-8-1.412-8-8s1.412-8 8-8 8 1.412 8 8-1.412 8-8 8m0-1.5c1.613 0 2.807-.089 3.704-.288.88-.196 1.382-.477 1.706-.802.325-.324.606-.826.802-1.706.2-.897.288-2.091.288-3.704s-.089-2.807-.288-3.704c-.196-.88-.477-1.382-.802-1.706-.324-.325-.826-.606-1.706-.802C10.807 1.588 9.613 1.5 8 1.5s-2.807.089-3.704.288c-.88.196-1.382.477-1.706.802-.325.324-.606.826-.802 1.706C1.588 5.193 1.5 6.387 1.5 8s.089 2.807.288 3.704c.196.88.477 1.382.802 1.706.324.325.826.606 1.706.802.897.2 2.091.288 3.704.288" clip-rule="evenodd"/>
243
+ </symbol>
244
+ <symbol id="diffs-icon-symbol-inlined-duo" viewBox="0 0 16 16">
245
+ <path fill-rule="evenodd" d="M8 16c-6.588 0-8-1.412-8-8s1.412-8 8-8 8 1.412 8 8-1.412 8-8 8" clip-rule="evenodd" opacity=".2"/><path d="M7.75 11.75a.75.75 0 0 1 0-1.5h1.44L5.887 6.948a1.5 1.5 0 1 1 1.06-1.06l3.302 3.301V7.75a.75.75 0 0 1 1.5 0V11a.75.75 0 0 1-.75.75z"/>
246
+ </symbol>
247
+ <symbol id="diffs-icon-symbol-inlined-fill" viewBox="0 0 16 16">
248
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8M5.5 4a1.5 1.5 0 1 0 .388 2.948l3.301 3.302H7.75a.75.75 0 0 0 0 1.5H11a.75.75 0 0 0 .75-.75V7.75a.75.75 0 0 0-1.5 0v1.44L6.948 5.887A1.5 1.5 0 0 0 5.5 4" clip-rule="evenodd"/>
249
+ </symbol>
250
+ <symbol id="diffs-icon-symbol-modified" viewBox="0 0 16 16">
251
+ <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"/>
252
+ </symbol>
253
+ <symbol id="diffs-icon-symbol-modified-duo" viewBox="0 0 16 16">
254
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><path d="M11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0"/>
255
+ </symbol>
256
+ <symbol id="diffs-icon-symbol-modified-fill" viewBox="0 0 16 16">
257
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m0 5a3 3 0 1 0 0 6 3 3 0 0 0 0-6" clip-rule="evenodd"/>
258
+ </symbol>
259
+ <symbol id="diffs-icon-symbol-moved" viewBox="0 0 16 16">
260
+ <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"/>
261
+ </symbol>
262
+ <symbol id="diffs-icon-symbol-moved-duo" viewBox="0 0 16 16">
263
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><path d="M8.496 4.695a.75.75 0 0 0-.051 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-.051 1.06L6.49 8.003 4.693 9.998a.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"/>
264
+ </symbol>
265
+ <symbol id="diffs-icon-symbol-moved-fill" viewBox="0 0 16 16">
266
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m1.555 4.745a.75.75 0 0 0-1.11 1.01L10.486 8l-2.04 2.245a.75.75 0 0 0 1.109 1.01l2.5-2.75a.75.75 0 0 0 0-1.01zm-4 0a.75.75 0 0 0-1.11 1.01l2.043 2.248-1.796 1.995a.75.75 0 0 0 1.116 1.004l2.25-2.5a.75.75 0 0 0-.003-1.007z" clip-rule="evenodd"/>
267
+ </symbol>
268
+ <symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
269
+ <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"/>
270
+ </symbol>
271
+ </svg>`;function S0(t,e){return t.lineNumber===e.lineNumber&&t.metadata===e.metadata}function Qd(t,e){return t==null||e==null?t===e:b0(t.customProperties,e.customProperties)&&t.type===e.type&&t.diffIndicators===e.diffIndicators&&t.disableBackground===e.disableBackground&&t.disableLineNumbers===e.disableLineNumbers&&t.overflow===e.overflow&&t.split===e.split&&t.totalLines===e.totalLines}const ca={};function b0(t=ca,e=ca){if(t===e)return!0;const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const r of n)if(t[r]!==e[r])return!1;return!0}function js(t){const e=document.createElement("div");return e.dataset.annotationSlot="",e.slot=t,e.style.whiteSpace="normal",e}function Zd(){const t=document.createElement("div");return t.slot="gutter-utility-slot",t.style.position="absolute",t.style.top="0",t.style.bottom="0",t.style.textAlign="center",t.style.whiteSpace="normal",t.style.touchAction="none",t}function Jd(){const t=document.createElement("style");return t.setAttribute(cl,""),t}var ec=`@layer base,theme,rendered,unsafe;@layer base{:host{--diffs-font-fallback:"SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono", "Courier New", monospace;--diffs-header-font-fallback:system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;--diffs-mixer:light-dark(#000,#fff);--diffs-gap-fallback:8px;--diffs-scrollbar-gutter-fallback:6px;--diffs-scrollbar-gutter:var(--diffs-scrollbar-gutter-override,var(--diffs-scrollbar-gutter-measured,var(--diffs-scrollbar-gutter-fallback)));--diffs-added-light:#0dbe4e;--diffs-added-dark:#5ecc71;--diffs-modified-light:#009fff;--diffs-modified-dark:#69b1ff;--diffs-deleted-light:#ff2e3f;--diffs-deleted-dark:#ff6762;--diffs-warning-light:#d5a910;--diffs-warning-dark:#ffd452;color-scheme:light dark;font-family:var(--diffs-header-font-family,var(--diffs-header-font-fallback));font-size:var(--diffs-font-size,13px);line-height:var(--diffs-line-height,20px);font-feature-settings:var(--diffs-font-features);--diffs-bg:light-dark(var(--diffs-light-bg,#fff),var(--diffs-dark-bg,#000));--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))));--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))));--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))));--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))));--diffs-fg:light-dark(var(--diffs-light,#000),var(--diffs-dark,#fff));--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))));--diffs-fg-conflict-marker:var(--diffs-fg-conflict-marker-override,var(--diffs-fg-number));--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)))));--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)))));--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)))));--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))));--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)));--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))));--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)));--diffs-selection-base:var(--diffs-modified-base);--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)));background-color:var(--diffs-bg);color:var(--diffs-fg);display:block}pre,code,[data-error-wrapper]{isolation:isolate;font-family:var(--diffs-font-family,var(--diffs-font-fallback));outline:none;margin:0;padding:0;display:block}pre,code{background-color:var(--diffs-bg)}code{contain:content}input,button{font-family:inherit;font-size:inherit;line-height:inherit}*,:before,:after{box-sizing:border-box}[data-icon-sprite]{display:none}[data-diffs-header],[data-separator]{font-family:var(--diffs-header-font-family,var(--diffs-header-font-fallback))}[data-diffs-header][data-sticky]{z-index:1;background-color:var(--diffs-bg);position:sticky;top:0}[data-file-info]{color:var(--fg);background-color:color-mix(in lab, var(--bg) 98%, var(--fg));border-block:1px solid color-mix(in lab, var(--bg) 95%, var(--fg));padding:10px;font-weight:700}[data-diff],[data-file]{--diffs-grid-number-column-width:minmax(min-content, max-content);--diffs-code-grid:var(--diffs-grid-number-column-width) 1fr;&[data-dehydrated]{--diffs-code-grid:var(--diffs-grid-number-column-width) minmax(0, 1fr)}&:hover [data-code]::-webkit-scrollbar-thumb{background-color:var(--diffs-bg-context)}}@supports (-webkit-touch-callout:none){:host{--diffs-scrollbar-gutter-fallback:0px}}[data-line] span,[data-edit-prediction-suffix] span{color:light-dark(var(--diffs-token-light,var(--diffs-light)),var(--diffs-token-dark,var(--diffs-dark)));background-color:light-dark(var(--diffs-token-light-bg,inherit),var(--diffs-token-dark-bg,inherit));font-weight:light-dark(var(--diffs-token-light-font-weight,inherit),var(--diffs-token-dark-font-weight,inherit));font-style:light-dark(var(--diffs-token-light-font-style,inherit),var(--diffs-token-dark-font-style,inherit));text-decoration:light-dark(var(--diffs-token-light-text-decoration,inherit),var(--diffs-token-dark-text-decoration,inherit))}[data-line],[data-gutter-buffer],[data-column-number],[data-line-annotation],[data-no-newline],[data-merge-conflict],[data-merge-conflict-actions],[data-editor-overlay]{--diffs-computed-decoration-bg:var(--diffs-bg);--diffs-computed-diff-line-bg:var(--diffs-computed-decoration-bg);--diffs-computed-selected-line-bg:var(--diffs-computed-diff-line-bg);--diffs-computed-editor-active-line-bg:var(--diffs-computed-selected-line-bg);--diffs-computed-hovered-line-bg:var(--diffs-computed-editor-active-line-bg);--diffs-hover-mix-target:var(--diffs-bg-hover-override,var(--diffs-mixer));--diffs-line-bg:var(--diffs-computed-hovered-line-bg);color:var(--diffs-fg);background-color:var(--diffs-line-bg,var(--diffs-bg))}[data-line],[data-no-newline]{&[data-decoration-bg]{--mix-deco-light:92%;--mix-deco-dark:85%;&[data-decoration-bg-depth="2"]{--mix-deco-light:88%;--mix-deco-dark:80%}&[data-decoration-bg-depth="3"]{--mix-deco-light:85%;--mix-deco-dark:78%}--diffs-hover-mix-target:var(--diffs-decoration-bg);--diffs-computed-decoration-bg:light-dark(color-mix(in lab, var(--diffs-bg) var(--mix-deco-light), var(--diffs-decoration-bg)),color-mix(in lab, var(--diffs-bg) var(--mix-deco-dark), var(--diffs-decoration-bg)))}}[data-line-annotation],[data-gutter-buffer=annotation]{--diffs-annotation-bg:var(--diffs-bg-context);--diffs-computed-decoration-bg:var(--diffs-annotation-bg);--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}[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]{--diffs-computed-decoration-bg:var(--diffs-bg-context);--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}[data-gutter-buffer=merge-conflict-marker-start],[data-merge-conflict=marker-start]{--diffs-computed-decoration-bg:light-dark(color-mix(in lab, var(--diffs-bg) 78%, var(--conflict-bg-current-header-override,var(--diffs-addition-base))),color-mix(in lab, var(--diffs-bg) 68%, var(--conflict-bg-current-header-override,var(--diffs-addition-base))));--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}[data-gutter-buffer=merge-conflict-marker-end],[data-merge-conflict=marker-end]{--diffs-computed-decoration-bg:light-dark(color-mix(in lab, var(--diffs-bg) 78%, var(--conflict-bg-incoming-header-override,var(--diffs-modified-base))),color-mix(in lab, var(--diffs-bg) 68%, var(--conflict-bg-incoming-header-override,var(--diffs-modified-base))));--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}[data-has-merge-conflict] [data-line-annotation],[data-has-merge-conflict] [data-gutter-buffer=annotation]{--diffs-computed-decoration-bg:var(--diffs-bg);--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}:where([data-background]){& [data-gutter-buffer],& [data-column-number]{--mix-light:91%;--mix-dark:85%}& [data-line],& [data-no-newline]{--mix-light:88%;--mix-dark:80%}& [data-gutter-buffer],& [data-column-number],& [data-line],& [data-no-newline]{--diffs-diff-line-mix-target:var(--diffs-bg);&[data-line-type=change-deletion]{--diffs-diff-line-mix-target:var(--diffs-bg-deletion-override,var(--diffs-deletion-base));--diffs-hover-mix-target:var(--diffs-diff-line-mix-target);&:where([data-gutter-buffer],[data-column-number]){color:var(--diffs-fg-number-deletion-override,var(--diffs-deletion-base));--diffs-diff-line-mix-target:var(--diffs-bg-deletion-number-override,var(--diffs-deletion-base))}--diffs-computed-diff-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-light), var(--diffs-diff-line-mix-target)),color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-dark), var(--diffs-diff-line-mix-target)))}&[data-line-type=change-addition]{--diffs-diff-line-mix-target:var(--diffs-bg-addition-override,var(--diffs-addition-base));--diffs-hover-mix-target:var(--diffs-diff-line-mix-target);&:where([data-gutter-buffer],[data-column-number]){color:var(--diffs-fg-number-addition-override,var(--diffs-addition-base));--diffs-diff-line-mix-target:var(--diffs-bg-addition-number-override,var(--diffs-addition-base))}--diffs-computed-diff-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-light), var(--diffs-diff-line-mix-target)),color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-dark), var(--diffs-diff-line-mix-target)))}&[data-merge-conflict=current]{--diffs-diff-line-mix-target:var(--conflict-bg-current-override,var(--diffs-addition-base));--diffs-hover-mix-target:var(--diffs-diff-line-mix-target);&:where([data-gutter-buffer],[data-column-number]){color:var(--diffs-fg-number-addition-override,var(--diffs-addition-base));--diffs-diff-line-mix-target:var(--conflict-bg-current-number-override,var(--diffs-addition-base))}--diffs-computed-diff-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-light), var(--diffs-diff-line-mix-target)),color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-dark), var(--diffs-diff-line-mix-target)))}&[data-merge-conflict=incoming]{--diffs-diff-line-mix-target:var(--conflict-bg-incoming-override,var(--diffs-modified-base));--diffs-hover-mix-target:var(--diffs-diff-line-mix-target);&:where([data-gutter-buffer],[data-column-number]){color:var(--diffs-modified-base);--diffs-diff-line-mix-target:var(--conflict-bg-incoming-number-override,var(--diffs-modified-base))}--diffs-computed-diff-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-light), var(--diffs-diff-line-mix-target)),color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-dark), var(--diffs-diff-line-mix-target)))}}}[data-gutter-buffer],[data-column-number],[data-line],[data-line-annotation],[data-merge-conflict],[data-merge-conflict-actions],[data-no-newline],[data-editor-overlay]{--diffs-selection-mix-target:var(--diffs-bg-selection-override,var(--diffs-selection-base));--diffs-selection-emphasis-mix-target:var(--diffs-selection-mix-target);&:where([data-editor-overlay]),&:where([data-line],[data-line-annotation],[data-merge-conflict],[data-merge-conflict-actions],[data-no-newline])[data-selected-line]{--mix-selection-light:82%;--mix-selection-dark:75%;--diffs-hover-mix-target:var(--diffs-selection-mix-target)}&:where([data-gutter-buffer][data-selected-line],[data-column-number]:is([data-selected-line],[data-editor-active-line])){--mix-selection-light:75%;--mix-selection-dark:60%;--diffs-selection-mix-target:var(--diffs-bg-selection-number-override,var(--diffs-selection-base));--diffs-hover-mix-target:var(--diffs-selection-mix-target)}&:where([data-line][data-selected-line]):is([data-line-type=change-addition],[data-line-type=change-deletion]){--diffs-selection-emphasis-mix-target:light-dark(color-mix(in lab, var(--diffs-diff-line-mix-target,var(--diffs-selection-mix-target)) var(--mix-selection-light), var(--diffs-selection-mix-target)),var(--diffs-selection-mix-target))}&:where([data-editor-overlay]),&[data-selected-line]{--diffs-computed-selected-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-diff-line-bg) var(--mix-selection-light), var(--diffs-selection-mix-target)),color-mix(in lab, var(--diffs-computed-diff-line-bg) var(--mix-selection-dark), var(--diffs-selection-mix-target)))}}[data-line][data-editor-active-line],[data-column-number][data-editor-active-line]{--diffs-computed-editor-active-line-bg:color-mix(in lab, var(--diffs-computed-selected-line-bg) var(--diffs-editor-active-line-source-mix,100%), var(--diffs-selection-emphasis-mix-target))}@media (pointer:fine){[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]{--diffs-computed-hovered-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-editor-active-line-bg) 97%, var(--diffs-hover-mix-target)),color-mix(in lab, var(--diffs-computed-editor-active-line-bg) 91%, var(--diffs-hover-mix-target)))}}[data-gutter-buffer][data-selected-line],[data-column-number]:is([data-selected-line],[data-editor-active-line]){color:var(--diffs-selection-number-fg)}[data-no-newline]{user-select:none;& span{opacity:.6}}[data-diff-type=split][data-overflow=scroll]{grid-template-columns:1fr 1fr;display:grid;& [data-additions]{border-left:1px solid var(--diffs-bg)}& [data-deletions]{border-right:1px solid var(--diffs-bg)}}[data-code]{grid-auto-flow:dense;grid-template-columns:var(--diffs-code-grid);overflow:var(--diffs-overflow-override,scroll) clip;overscroll-behavior-x:none;tab-size:var(--diffs-tab-size,2);padding-top:var(--diffs-gap-block,var(--diffs-gap-fallback));padding-bottom:max(0px, calc(var(--diffs-gap-block,var(--diffs-gap-fallback)) - var(--diffs-scrollbar-gutter)));scrollbar-gutter:stable;align-self:flex-start;display:grid}[data-diffs-scrollbar-measure]{opacity:0;pointer-events:none;scrollbar-gutter:auto;grid-template-columns:none;width:100px;height:100px;padding:0;position:absolute;top:-200px;left:-200px}[data-container-size]{container-type:inline-size}[data-code]::-webkit-scrollbar{width:0;height:var(--diffs-scrollbar-gutter)}[data-code]::-webkit-scrollbar-track{background:0 0}[data-code]::-webkit-scrollbar-thumb{background-color:#0000;background-clip:content-box;border:1px solid #0000;border-radius:3px}[data-code]::-webkit-scrollbar-corner{background-color:#0000}@supports ((-moz-appearance:none)){[data-code]{scrollbar-width:thin;scrollbar-color:var(--diffs-bg-context) transparent;padding-bottom:var(--diffs-gap-block,var(--diffs-gap-fallback))}}[data-diffs-header]~[data-diff],[data-diffs-header]~[data-file]{& [data-code],&[data-overflow=wrap],&[data-dehydrated][data-diff-type=split][data-overflow=scroll]{padding-top:0}}[data-gutter]{grid-template-rows:subgrid;grid-template-columns:subgrid;z-index:3;background-color:var(--diffs-bg);grid-column:1;display:grid;position:relative;& [data-gutter-buffer],& [data-column-number]{border-right:var(--diffs-gap-style,2px solid var(--diffs-bg))}}[data-content]{grid-template-rows:subgrid;grid-template-columns:subgrid;background-color:var(--diffs-bg);grid-column:2;min-width:0;display:grid}[data-diff-type=split][data-overflow=wrap],[data-dehydrated][data-diff-type=split][data-overflow=scroll]{grid-auto-flow:dense;grid-template-columns:repeat(2, var(--diffs-code-grid));padding-block:var(--diffs-gap-block,var(--diffs-gap-fallback));display:grid;& [data-code]{display:contents}& [data-deletions]{& [data-gutter]{grid-column:1}& [data-content]{border-right:1px solid var(--diffs-bg);grid-column:2}}& [data-additions]{& [data-gutter]{border-left:1px solid var(--diffs-bg);grid-column:3}& [data-content]{grid-column:4}}}[data-dehydrated][data-diff-type=split][data-overflow=scroll] [data-content]{overflow:clip}[data-overflow=scroll] [data-gutter]{position:sticky;left:0}[data-interactive-lines] [data-line]{cursor:pointer}[data-interactive-line-numbers] [data-column-number]{cursor:pointer;touch-action:none}[data-content-buffer],[data-gutter-buffer]{user-select:none;min-height:1lh;position:relative}[data-gutter-buffer]{padding-left:2ch;padding-right:1ch;&:before{content:"";min-width:var(--diffs-min-number-column-width,var(--diffs-min-number-column-width-default,3ch));display:block}}[data-gutter-buffer=annotation]{--diffs-annotation-bg:var(--diffs-bg-context-gutter);min-height:0}[data-gutter-buffer=buffer]{--diffs-line-bg:var(--diffs-bg-context-gutter)}[data-content-buffer]{background-position:5px 0;background-size:8px 8px;background-origin:border-box;background-image:repeating-linear-gradient(-45deg, transparent, transparent calc(3px * 1.414), var(--diffs-bg-buffer) calc(3px * 1.414), var(--diffs-bg-buffer) calc(4px * 1.414));grid-column:1}[data-separator]{box-sizing:content-box;background-color:var(--diffs-bg)}[data-separator=simple]{min-height:4px}[data-separator=line-info],[data-separator=line-info-basic],[data-separator=metadata],[data-separator=simple]{background-color:var(--diffs-bg-separator)}[data-separator=line-info],[data-separator=line-info-basic],[data-separator=metadata]{height:32px;position:relative}[data-separator-wrapper]{user-select:none;fill:currentColor;background-color:var(--diffs-bg);align-items:center;height:100%;display:flex;position:absolute;inset-inline:0}[data-content] [data-separator-wrapper]{display:none}[data-separator=metadata] [data-separator-wrapper]{background-color:var(--diffs-bg-separator);height:100%;color:var(--diffs-fg-number);white-space:nowrap;text-overflow:ellipsis;min-width:min-content;padding-inline:1ch;inset-inline:100% auto;overflow:hidden}[data-separator=line-info]{margin-block:var(--diffs-gap-block,var(--diffs-gap-fallback));& [data-separator-wrapper]{min-width:16px}}[data-separator=line-info-basic],[data-separator=metadata]{margin-block:0}[data-separator=line-info][data-separator-first]{margin-top:0}[data-separator=line-info][data-separator-last]{margin-bottom:0}[data-expand-index] [data-separator-wrapper]{grid-template-columns:32px auto;display:grid}[data-expand-index] [data-separator-wrapper][data-separator-multi-button]{grid-template-columns:32px 32px auto}[data-expand-button],[data-separator-content]{background-color:var(--diffs-bg-separator);flex:none;align-items:center;display:flex}[data-expand-index] [data-separator-content]:hover{cursor:pointer;text-decoration:underline}[data-expand-button]{cursor:pointer;min-width:32px;color:var(--diffs-fg-number);border-right:2px solid var(--diffs-bg);flex-shrink:0;justify-content:center;align-self:stretch;&:hover{color:var(--diffs-fg)}&[data-expand-all-button]{display:none}}[data-expand-down] [data-icon]{transform:scaleY(-1)}[data-separator-content]{height:100%;color:var(--diffs-fg-number);flex:auto;justify-content:flex-start;padding:0 1ch;overflow:hidden}[data-separator=line-info],[data-separator=line-info-basic]{& [data-separator-content]{user-select:none;height:100%;overflow:clip}}[data-unmodified-lines]{text-overflow:ellipsis;white-space:nowrap;flex:0 auto;min-width:0;display:block;overflow:hidden}@supports (width:1cqi){[data-unified]{& [data-separator=line-info] [data-separator-wrapper]{padding-inline:var(--diffs-gap-inline,var(--diffs-gap-fallback));width:100cqi;& [data-separator-content]{border-radius:6px}}& [data-separator=line-info][data-expand-index] [data-separator-wrapper] [data-separator-content]{border-top-left-radius:unset;border-bottom-left-radius:unset}}[data-gutter]{& [data-separator=line-info] [data-separator-wrapper]{padding-left:var(--diffs-gap-inline,var(--diffs-gap-fallback))}& [data-separator=line-info] [data-separator-content]{border-top-left-radius:6px;border-bottom-left-radius:6px}& [data-separator=line-info][data-expand-index] [data-separator-content]{border-top-left-radius:unset;border-bottom-left-radius:unset}}[data-additions]{& [data-content] [data-separator=line-info]{background-color:var(--diffs-bg);& [data-separator-wrapper]{display:none}}& [data-gutter] [data-separator=line-info] [data-separator-wrapper]{background-color:var(--diffs-bg-separator);border-top-right-radius:6px;border-bottom-right-radius:6px;height:100%;display:block;& [data-separator-content],& [data-expand-button]{display:none}}}[data-overflow=scroll] [data-additions] [data-gutter] [data-separator=line-info] [data-separator-wrapper]{width:calc(100cqi - var(--diffs-gap-inline,var(--diffs-gap-fallback)))}[data-overflow=wrap] [data-additions] [data-content] [data-separator=line-info] [data-separator-wrapper]{background-color:var(--diffs-bg-separator);height:100%;margin-right:var(--diffs-gap-inline,var(--diffs-gap-fallback));border-top-right-radius:6px;border-bottom-right-radius:6px;display:block;& [data-separator-content],& [data-expand-button]{display:none}}[data-separator=line-info] [data-separator-wrapper]{& [data-expand-both],& [data-expand-down],& [data-expand-up]{border-top-left-radius:6px;border-bottom-left-radius:6px}}@media (pointer:fine){[data-separator=line-info] [data-separator-wrapper]{&[data-separator-multi-button]{& [data-expand-up]{border-top-left-radius:6px;border-bottom-left-radius:unset}& [data-expand-down]{border-bottom-left-radius:6px;border-top-left-radius:unset}}}}}@media (pointer:coarse){[data-separator=line-info-basic] [data-separator-wrapper][data-separator-multi-button]{grid-template-columns:34px 34px auto;& [data-separator-content]{grid-column:unset;grid-row:unset}}@supports (width:1cqi){[data-separator=line-info] [data-separator-wrapper]{& [data-expand-both],& [data-expand-down],& [data-expand-up]{border-top-left-radius:6px;border-bottom-left-radius:6px}&[data-separator-multi-button]{& [data-expand-up]{border-top-left-radius:6px;border-bottom-left-radius:6px}& [data-expand-down]{border-bottom-left-radius:unset;border-top-left-radius:unset}}}}}@media (pointer:fine){[data-separator-wrapper][data-separator-multi-button]{grid-template-rows:50% 50%;display:grid;& [data-separator-content]{grid-area:1/2/-1;min-width:min-content}& [data-expand-button]{grid-column:1}}[data-separator=line-info] [data-separator-wrapper],[data-separator=line-info] [data-separator-wrapper][data-separator-multi-button]{grid-template-columns:34px auto}[data-separator=line-info-basic][data-expand-index] [data-separator-wrapper]{grid-template-columns:100% auto}[data-separator=line-info],[data-separator=line-info-basic]{& [data-separator-multi-button]{& [data-expand-up]{border-bottom:1px solid var(--diffs-bg);border-right:2px solid var(--diffs-bg)}& [data-expand-down]{border-top:1px solid var(--diffs-bg);border-right:2px solid var(--diffs-bg)}}}}[data-additions] [data-gutter] [data-separator-wrapper],[data-additions] [data-separator=line-info-basic] [data-separator-wrapper],[data-content] [data-separator-wrapper]{display:none}[data-line-annotation]{min-height:var(--diffs-annotation-min-height,0);z-index:2}[data-merge-conflict-actions]{z-index:2}[data-separator=custom]{grid-template-columns:subgrid;display:grid}[data-line],[data-column-number],[data-no-newline]{padding-inline:1ch;position:relative}[data-indicators=classic] [data-line]{padding-inline-start:2ch}[data-indicators=classic]{& [data-line-type=change-addition],& [data-line-type=change-deletion]{&[data-no-newline],&[data-line]{&:before{user-select:none;width:1ch;height:1lh;display:inline-block;position:absolute;top:0;left:0}}}& [data-line-type=change-addition]{&[data-line],&[data-no-newline]{&:before{content:"+";color:var(--diffs-addition-base)}}}& [data-line-type=change-deletion]{&[data-line],&[data-no-newline]{&:before{content:"-";color:var(--diffs-deletion-base)}}}}[data-indicators=bars]{& [data-line-type=change-deletion],& [data-line-type=change-addition]{&[data-column-number]{&:before{content:"";user-select:none;contain:strict;width:4px;height:100%;display:block;position:absolute;top:0;left:0}}}& [data-line-type=change-deletion]{&[data-column-number]{&:before{background-image:linear-gradient(0deg, var(--diffs-bg-deletion) 50%, var(--diffs-deletion-base) 50%);background-repeat:repeat;background-size:2px 2px;background-size:calc(1lh / round(1lh / 2px)) calc(1lh / round(1lh / 2px))}}}& [data-line-type=change-addition]{&[data-column-number]{&:before{background-color:var(--diffs-addition-base)}}}}[data-overflow=wrap]{& [data-line]{white-space:pre-wrap;word-break:break-word}& [data-annotation-content]{word-break:break-word}}[data-overflow=scroll] [data-line]{white-space:pre;min-height:1lh}[data-column-number]{box-sizing:content-box;text-align:right;user-select:none;color:var(--diffs-fg-number);padding-left:2ch}[data-line-number-content]{min-width:var(--diffs-min-number-column-width,var(--diffs-min-number-column-width-default,3ch));z-index:1;display:inline-block;position:relative}[data-disable-line-numbers]{& [data-gutter-buffer],& [data-column-number]{min-width:4px;padding:0;&:before{min-width:0}}& [data-line-number-content]{display:none}& [data-gutter-utility-slot]{right:unset;justify-content:flex-start;left:0}&[data-indicators=bars] [data-gutter-utility-slot]{left:6px}}[data-file][data-disable-line-numbers]{& [data-gutter-buffer],& [data-column-number]{border-right:0;min-width:0}}[data-diff-span]{box-decoration-break:clone;border-radius:3px}[data-line-type=change-addition] [data-diff-span]{background-color:var(--diffs-bg-addition-emphasis)}[data-line-type=change-deletion] [data-diff-span]{background-color:var(--diffs-bg-deletion-emphasis)}[data-merge-conflict=marker-start],[data-merge-conflict=marker-base],[data-merge-conflict=marker-separator],[data-merge-conflict=marker-end]{color:var(--diffs-fg);padding-left:1ch}[data-merge-conflict=marker-start],[data-merge-conflict=marker-end]{align-items:center;display:flex;&:after{color:var(--diffs-fg-conflict-marker);font-size:.75rem;font-style:normal;line-height:1.25rem;font-family:var(--diffs-header-font-family,var(--diffs-header-font-fallback));padding-left:1ch}}[data-merge-conflict=marker-start]:after{content:"(Current Change)"}[data-merge-conflict=marker-end]:after{content:"(Incoming Change)"}[data-merge-conflict-actions-content]{min-height:1.75rem;font-family:var(--diffs-header-font-family,var(--diffs-header-font-fallback));color:var(--diffs-fg);align-items:center;gap:.25rem;padding-inline:.5rem;font-size:.75rem;line-height:1.2;display:flex}[data-merge-conflict-action]{appearance:none;color:var(--diffs-fg-number);font:inherit;cursor:pointer;background:0 0;border:0;padding:0;font-style:normal}[data-merge-conflict-action]:hover{color:var(--diffs-fg)}[data-merge-conflict-action=current]:hover{color:var(--diffs-addition-base)}[data-merge-conflict-action=incoming]:hover{color:var(--diffs-modified-base)}[data-merge-conflict-action-separator]{color:var(--diffs-fg-number);opacity:.6;user-select:none}[data-diffs-header=default]{background-color:var(--diffs-bg);justify-content:space-between;align-items:center;gap:var(--diffs-gap-inline,var(--diffs-gap-fallback));min-height:calc(1lh + (var(--diffs-gap-block,var(--diffs-gap-fallback)) * 3));z-index:2;flex-direction:row;padding-inline:16px;display:flex;position:relative;top:0}[data-header-content]{align-items:center;gap:var(--diffs-gap-inline,var(--diffs-gap-fallback));white-space:nowrap;flex-direction:row;min-width:0;display:flex}[data-header-content] [data-prev-name],[data-header-content] [data-title]{text-overflow:ellipsis;white-space:nowrap;direction:rtl;min-width:0;overflow:hidden}[data-prev-name]{opacity:.7}[data-rename-icon]{fill:currentColor;flex-grow:0;flex-shrink:0}[data-diffs-header=default] [data-metadata]{white-space:nowrap;align-items:center;gap:1ch;display:flex}[data-diffs-header=default] [data-additions-count]{font-family:var(--diffs-font-family,var(--diffs-font-fallback));color:var(--diffs-addition-base)}[data-diffs-header=default] [data-deletions-count]{font-family:var(--diffs-font-family,var(--diffs-font-fallback));color:var(--diffs-deletion-base)}[data-change-icon]{fill:currentColor;flex-shrink:0}[data-change-icon=change],[data-change-icon=rename-pure],[data-change-icon=rename-changed]{color:var(--diffs-modified-base)}[data-change-icon=new]{color:var(--diffs-addition-base)}[data-change-icon=deleted]{color:var(--diffs-deletion-base)}[data-change-icon=file]{opacity:.6}[data-annotation-content]{z-index:2;isolation:isolate;white-space:normal;align-self:flex-start;min-width:0;display:flow-root;position:relative}[data-overflow=scroll] [data-annotation-content],[data-overflow=scroll] [data-merge-conflict-actions-content]{width:var(--diffs-column-content-width,auto);left:var(--diffs-column-number-width,0);position:sticky}[data-annotation-slot]{text-wrap-mode:wrap;word-break:normal;white-space-collapse:collapse}[data-gutter-utility-slot]{touch-action:none;justify-content:flex-end;display:flex;position:absolute;top:0;bottom:0;right:0}[data-utility-button]{appearance:none;cursor:pointer;width:1lh;height:1lh;font-size:var(--diffs-font-size,13px);line-height:var(--diffs-line-height,20px);background-color:var(--diffs-modified-base);color:var(--diffs-bg);fill:currentColor;z-index:4;touch-action:none;border:none;border-radius:4px;justify-content:center;align-items:center;margin-right:calc(-1lh + 1ch);padding:0;display:flex;position:relative;&:before{content:"";display:block;position:absolute;inset:0 0 0 -4px}}[data-decoration-bar-stack]{pointer-events:none;isolation:isolate;z-index:1;background-color:var(--diffs-decoration-bar-color,transparent);box-sizing:content-box;border-left:2px solid var(--diffs-bg);border-right:2px solid var(--diffs-bg);width:6px;position:absolute;top:0;bottom:0;right:-2px;[data-decoration-bar-depth="1"] &{background-color:color-mix(in lab, var(--diffs-bg) 20%, var(--diffs-decoration-bar-color,transparent))}[data-decoration-bar-depth="2"] &{background-color:color-mix(in lab, var(--diffs-bg) 45%, var(--diffs-decoration-bar-color,transparent))}[data-decoration-bar-depth="3"] &{background-color:color-mix(in lab, var(--diffs-bg) 65%, var(--diffs-decoration-bar-color,transparent))}[data-decoration-bar-start] &{border-top-left-radius:5px;border-top-right-radius:5px}[data-decoration-bar-end] &{z-index:3;border-bottom-right-radius:5px;border-bottom-left-radius:5px}}[data-placeholder]{contain:strict}[data-error-wrapper]{padding:var(--diffs-gap-block,var(--diffs-gap-fallback)) var(--diffs-gap-inline,var(--diffs-gap-fallback));scrollbar-width:none;max-height:400px;overflow:auto;& [data-error-message]{color:var(--diffs-deletion-base);font-size:18px;font-weight:700}& [data-error-stack]{color:var(--diffs-fg-number)}}}@layer theme,rendered,unsafe;
272
+ `;let si;function sn(t){if(si!=null)return si;const e=t.host;if(typeof HTMLElement<"u"&&e instanceof HTMLElement&&!e.isConnected)return;const n=document.createElement("div");n.setAttribute("data-code",""),n.setAttribute(eu,"true");const i=document.createElement("div");return i.style.position="relative",i.style.width="200%",i.style.height="200%",n.appendChild(i),t.appendChild(n),si=Math.max(n.offsetHeight-n.clientHeight,0),n.remove(),si}function tc(t){const e=t==null?"var(--diffs-scrollbar-gutter-fallback)":`${t}px`;return`${ul}: ${e};`}const qs="@layer base, theme, rendered, unsafe;",w0=new RegExp(`${k0(ul)}\\s*:\\s*[^;]+;`);function x0(t){return`${qs}
273
+ ${ec}
274
+ @layer theme {
275
+ ${t}
276
+ }`}function Ks(t){return`${qs}
277
+ @layer unsafe {
278
+ ${t}
279
+ }`}function Xs(t,e="system",n){const i=e==="system"?"":`
280
+ color-scheme: ${e};`,r=tc(n);return`${qs}
281
+ @layer rendered {
282
+ :host {${i}
283
+ ${r}
284
+ ${t}
285
+ }
286
+ }`}function nc(t,e){const n=tc(e);return t.replace(w0,n)}function k0(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const ic=new WeakMap;function Ys(t){const e=ic.get(t);return e??t}function RS(t,e){ic.set(t,e)}function Tn({code:t,pre:e,columnType:n,rowSpan:i,containerSize:r=!1}={}){return t==null&&(t=document.createElement("code"),t.setAttribute("data-code",""),n!=null&&t.setAttribute(`data-${n}`,""),e==null||e.appendChild(t)),i!=null?t.style.setProperty("grid-row",`span ${i}`):t.style.removeProperty("grid-row"),r?t.setAttribute("data-container-size",""):t.removeAttribute("data-container-size"),t}function rc(t,e){if(e==null)return;const n=t.shadowRoot??t.attachShadow({mode:"open"});n.innerHTML===""&&(n.innerHTML=e)}function Qs(t,{type:e,diffIndicators:n,disableBackground:i,disableLineNumbers:r,overflow:s,split:o,totalLines:l,customProperties:a}){if(a!=null)for(const d in a){const c=a[d];c!=null&&t.setAttribute(d,`${c}`)}switch(e==="diff"?(t.setAttribute("data-diff",""),t.removeAttribute("data-file")):(t.setAttribute("data-file",""),t.removeAttribute("data-diff")),n){case"bars":case"classic":t.setAttribute("data-indicators",n);break;case"none":t.removeAttribute("data-indicators")}return r?t.setAttribute("data-disable-line-numbers",""):t.removeAttribute("data-disable-line-numbers"),i?t.removeAttribute("data-background"):t.setAttribute("data-background",""),e==="diff"?t.setAttribute("data-diff-type",o?"split":"single"):t.removeAttribute("data-diff-type"),t.setAttribute("data-overflow",s),t.style.setProperty("--diffs-min-number-column-width-default",`${`${l}`.length}ch`),t}function zn(t){if(typeof HTMLStyleElement<"u"&&t instanceof HTMLStyleElement)return!0;const e=t.tagName??t.nodeName;return typeof e=="string"&&e.toLowerCase()==="style"}let L0,E0;function sc(){return L0??(L0="safari"in window&&"pushNotification"in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent))}function R0(){return E0??(E0=/\bFirefox\//.test(navigator.userAgent))}function Gi(t,e,n){const i=new Map;for(const r of t){const s=Ys(r);i.set(s,(n==null?void 0:n.slotNames.get(s))??e(r))}return{provided:t,current:t,slotNames:i}}function oc(t,e,n){for(const i of e){const r=Ys(i);t.slotNames.has(r)||t.slotNames.set(r,n(i))}t.provided=e,t.current=e}function ac(t,e,n){if(t==null)return n(e);const i=Ys(e);let r=t.slotNames.get(i);return r==null&&(r=n(e),t.slotNames.set(i,r)),r}function Zs(t){return(t==null?void 0:t.useTokenTransformer)===!0||(t==null?void 0:t.onTokenClick)!=null||(t==null?void 0:t.onTokenEnter)!=null||(t==null?void 0:t.onTokenLeave)!=null}function ua(t){return{theme:t==null?void 0:t.theme,disableLineNumbers:t==null?void 0:t.disableLineNumbers,overflow:t==null?void 0:t.overflow,themeType:t==null?void 0:t.themeType,collapsed:t==null?void 0:t.collapsed,disableFileHeader:t==null?void 0:t.disableFileHeader,disableVirtualizationBuffers:t==null?void 0:t.disableVirtualizationBuffers,stickyHeader:t==null?void 0:t.stickyHeader,preferredHighlighter:t==null?void 0:t.preferredHighlighter,useCSSClasses:t==null?void 0:t.useCSSClasses,useTokenTransformer:Zs(t),tokenizeMaxLineLength:t==null?void 0:t.tokenizeMaxLineLength,tokenizeMaxLength:t==null?void 0:t.tokenizeMaxLength,unsafeCSS:t==null?void 0:t.unsafeCSS,headerRenderMode:(t==null?void 0:t.renderCustomHeader)!=null?"custom":"default"}}function hs(t,e){const n=(t==null?void 0:t.offsetHeight)??0;if(t==null||n===0){e();return}t.style.minHeight=`${n}px`;try{e(),t.offsetHeight}finally{t.style.minHeight=""}}function Js({shadowRoot:t,currentNode:e,themeCSS:n}){if(n.trim()===""){e==null||e.remove();return}return e??(e=_0()),e.textContent=n,e.parentNode!==t&&t.appendChild(e),e}function _0(){const t=document.createElement("style");return t.setAttribute(dl,""),t}var T0=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated"),this.name="WorkerPoolTerminatedError"}},I0=class extends Error{constructor(){super("WorkerPoolManager: operation canceled before the task completed"),this.name="WorkerPoolTaskCanceledError"}},A0=class extends Error{constructor(t,e){super(t,e),this.name="WorkerPoolWorkerError"}};const P0=new WeakSet;function M0(t){return t instanceof T0||t instanceof I0}function lc(t){return M0(t)||t instanceof A0&&P0.has(t)}if(typeof HTMLElement<"u"&&customElements.get("diffs-container")==null){let t;class e extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;const i=this.attachShadow({mode:"open"});t==null&&(t=new CSSStyleSheet,t.replaceSync(ec)),i.adoptedStyleSheets=[t]}connectedCallback(){const i=this.shadowRoot??this.attachShadow({mode:"open"});sn(i)}}customElements.define(al,e)}const D0=[""];function H0(t){const e={...t};return delete e.cacheKey,e}let O0=-1;var Br,N0=(Br=class{constructor(t={theme:j},e,n=!1){g(this,"options");g(this,"workerManager");g(this,"isContainerManaged");g(this,"__id",`file:${++O0}`);g(this,"type","file");g(this,"fileContainer");g(this,"spriteSVG");g(this,"pre");g(this,"code");g(this,"bufferBefore");g(this,"bufferAfter");g(this,"themeCSSStyle");g(this,"appliedThemeCSS");g(this,"hasAdoptedThemeCSS",!1);g(this,"unsafeCSSStyle");g(this,"appliedUnsafeCSS");g(this,"gutterUtilityContent");g(this,"errorWrapper");g(this,"placeHolder");g(this,"lastRenderedHeaderHTML");g(this,"cachedHeaderHTML");g(this,"appliedPreAttributes");g(this,"lastRowCount");g(this,"mounted",!1);g(this,"headerElement");g(this,"headerCustom");g(this,"headerPrefix");g(this,"headerFilenameSuffix");g(this,"headerMetadata");g(this,"fileRenderer");g(this,"resizeManager");g(this,"interactionManager");g(this,"annotationCache",new Map);g(this,"lineAnnotations",[]);g(this,"managersDirty",!1);g(this,"file");g(this,"editSession");g(this,"renderedFile");g(this,"renderRange");g(this,"enabled",!0);g(this,"editor");g(this,"getAnnotationSlotName",t=>{var e;return ac((e=this.editSession)==null?void 0:e.annotations,t,Ye)});g(this,"handleHighlightRender",()=>{this.rerender()});g(this,"getHoveredLine",()=>this.interactionManager.getHoveredLine());var i;this.options=t,this.workerManager=e,this.isContainerManaged=n,this.fileRenderer=new C0(t,this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager),this.resizeManager=new $d,this.interactionManager=new Fd("file",$n(t)),(i=this.workerManager)==null||i.subscribeToThemeChanges(this)}rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}getTheme(){var t;return((t=this.workerManager)==null?void 0:t.getFileRenderOptions().theme)??this.options.theme??j}getLatestFile(t=this.file){var e;return((e=this.editSession)==null?void 0:e.file)??t}getRenderedFile(){return this.renderedFile}getLatestAnnotations(){var t,e;return((e=(t=this.editSession)==null?void 0:t.annotations)==null?void 0:e.current)??this.lineAnnotations}isNewAnnotations(t){var n;const e=(n=this.editSession)==null?void 0:n.annotations;return t===this.lineAnnotations?!1:e==null||t!==e.provided&&t!==e.current}updateExternalFile(t,e){var i,r;if(Z(this.file,t))return!1;const n=this.editSession!=null;return this.file=t,n||this.editor!=null?this.installEditSession(t,n||(i=this.editor)==null?void 0:i.__getDocumentContents(t),!0):this.editSession=void 0,((r=this.editSession)==null?void 0:r.annotations)!=null&&e!=null&&(this.lineAnnotations=e,this.editSession.annotations=Gi(e,Ye,this.editSession.annotations)),!0}installEditSession(t,e,n=!1){var s;const i=e==null||e.name===t.name&&e.lang===t.lang&&e.contents===t.contents,r=H0(e??t);this.editSession={file:r,externalReplacement:n&&i,annotations:((s=this.editSession)==null?void 0:s.annotations)??Gi(this.lineAnnotations,Ye)},this.fileRenderer.beginEditSession(r,i?t:void 0)}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(t){t!=null&&(this.options=t,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions($n(this.options))}mergeOptions(t){this.options={...this.options,...t}}setThemeType(t){(this.options.themeType??"system")!==t&&(this.mergeOptions({themeType:t}),this.applyCachedThemeState(t))}applyCachedThemeState(t){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const e=this.appliedThemeCSS.baseThemeType??t;return this.appliedThemeCSS.themeType===e?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,t,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!zt(this.appliedThemeCSS.theme,this.getTheme())}setLineAnnotations(t){var n;const e=(n=this.editSession)==null?void 0:n.annotations;if(e==null){this.lineAnnotations=t;return}this.isNewAnnotations(t)&&(this.lineAnnotations=t,oc(e,t,Ye))}syncEditSessionAnnotationsFromEditor(t){var n;const e=(n=this.editSession)==null?void 0:n.annotations;return e==null||t===e.current?!1:(e.current=t,this.fileRenderer.setLineAnnotations(t),this.renderAnnotations(),!0)}setSelectedLines(t,e){this.interactionManager.setSelection(t,e)}setEditorActiveLine(t,e){this.interactionManager.setEditorActiveLine(t,{lineNumberOnly:e==null?void 0:e.lineNumberOnly,side:(e==null?void 0:e.side)??"additions"})}getCodeScrollLeft(){var t;return((t=this.code)==null?void 0:t.scrollLeft)??0}setCodeScrollLeft(t){this.code!=null&&(this.code.scrollLeft=t)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:t="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t==="wrap",columnVariables:this.shouldApplyColumnVariables(t)?"apply":"measure"}),this.managersDirty=!1}shouldApplyColumnVariables(t){return t==="scroll"&&this.getLatestAnnotations().length>0}cleanUp(t=!1){var n,i,r,s,o,l;const e=this.editor;this.emitPostRender(!0),e==null||e.cleanUp(t?"recycle":"discard"),t||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,(n=this.workerManager)==null||n.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||(i=this.fileContainer)==null||i.remove(),this.fileContainer=void 0,this.mounted=!1,t||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,(r=this.bufferBefore)==null||r.remove(),this.bufferBefore=void 0,(s=this.bufferAfter)==null||s.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,t||(this.cachedHeaderHTML=void 0),(o=this.errorWrapper)==null||o.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,(l=this.placeHolder)==null||l.remove(),this.placeHolder=void 0,t?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0,this.editSession=void 0,this.renderedFile=void 0),this.enabled=!1}virtualizedSetup(){var t;this.enabled=!0,(t=this.workerManager)==null||t.subscribeToThemeChanges(this)}hydrate(t){const{fileContainer:e,prerenderedHTML:n,preventEmit:i=!1,file:r,lineAnnotations:s}=t;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(e,n);const o=this.editor!=null;o||F0(this.pre,r,this.options.collapsed)||$0(this.headerElement,r,this.options.disableFileHeader)?this.render({...t,forceRender:o||t.forceRender,preventEmit:!0}):this.hydrationSetup({file:r,lineAnnotations:s}),i||this.emitPostRender()}hydrateElements(t,e){var n;this.fileContainer!==t&&this.emitPostRender(!0),rc(t,e);for(const i of Array.from(((n=t.shadowRoot)==null?void 0:n.children)??[])){if(i instanceof SVGElement){this.spriteSVG=i;continue}if(i instanceof HTMLElement){if(i instanceof HTMLPreElement){this.pre=i,this.appliedPreAttributes=void 0;continue}if(i instanceof HTMLStyleElement&&i.hasAttribute("data-theme-css")){this.themeCSSStyle=i;continue}if(i instanceof HTMLStyleElement&&i.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=i,this.appliedUnsafeCSS=i.textContent;continue}if("diffsHeader"in i.dataset){this.headerElement=i,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=t,this.hydrateMeasuredScrollbar()}hydrationSetup({file:t,lineAnnotations:e}){this.lineAnnotations=e??this.lineAnnotations,this.file=t,this.fileRenderer.setOptions(ua(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(t),this.renderedFile=t,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(t=this.getLatestFile()){return t!=null?this.fileRenderer.getOrCreateLineCache(t):D0}updateBuffers(t){this.pre!=null&&this.applyBuffers(this.pre,t)}syncRenderViewToEditor(){var d;const{editor:t,fileContainer:e,renderRange:n}=this,i=this.getLatestAnnotations(),r=this.getLatestFile();if(t==null||e==null||r==null)return;const s=c=>{var u;!this.enabled||this.editor!==t||this.fileContainer!==e||this.getLatestFile()!==r||t.__syncRenderView({highlighter:c,fileContainer:e,file:r,lineAnnotations:i,renderRange:n,externalDocument:((u=this.editSession)==null?void 0:u.externalReplacement)===!0})},o=this.getTheme(),l=r.lang??be(r.name),a=tn({theme:o,lang:l});a!=null?s(a):un({themes:cn(o),langs:Array.from(new Set(["text",l])),preferredHighlighter:((d=this.workerManager)==null?void 0:d.getPreferredHighlighter())??this.options.preferredHighlighter}).then(s)}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.externalReplacement=!1)}__acceptEditorChange(t){const{lineAnnotations:e}=t;e!=null&&this.syncEditSessionAnnotationsFromEditor(e)}emitEditChange(t){const{onEditChange:e}=this.options;e==null||e(t)}__captureDocumentSessionState(){}__attachEditor(t){if(this.editor!=null)throw new Error("File.__attachEditor: an editor is already attached");this.editor=t;const e=()=>{this.editor=void 0,this.fileRenderer.endEditSession()};try{return this.resumeEditorRendering(t),e}catch(n){throw e(),n}}__resumeEditor(t){if(this.editor!==t)throw new Error("File.__resumeEditor: editor association changed");this.resumeEditorRendering(t)}resumeEditorRendering(t){var n;this.editSession!=null?this.fileRenderer.beginEditSession(this.editSession.file):this.file!=null&&this.installEditSession(this.file,t.__getDocumentContents(this.file));const e=(n=this.editSession)==null?void 0:n.file;this.fileRenderer.editorRenderReady()?(this.fileRenderer.fileCache===e&&(this.renderedFile=e),this.syncRenderViewToEditor()):this.rerender()}__completeEditSession(t,e){this.settleEditSession(e==="install",t)}settleEditSession(t,e){var y,v;const{editSession:n,file:i,lineAnnotations:r}=this;if(n==null||i==null)return;const{file:s,annotations:o}=n;if(this.editor!=null)throw new Error("File.__completeEditSession: detach the editor before completing the session");const l=o==null?void 0:o.current;let a,d=!1,c;if(e==null)throw new Error("File.__completeEditSession: editor is required for completion");const u={...s},h={file:u,editor:e,originalFile:i,lineAnnotations:l,originalLineAnnotations:r};Object.freeze(h);try{if(e.__emitEditComplete(h),((v=(y=this.options).onEditComplete)==null?void 0:v.call(y,h))==="accept"){if(u.cacheKey!=null&&u.cacheKey===i.cacheKey)throw new Error("File.__completeEditSession: an accepted file must not reuse the replaced file cacheKey");a=u}}catch(m){d=!0,c=m}t&&a!=null&&(this.file=a,l!=null&&(this.lineAnnotations=l)),this.editSession=void 0;const{renderedFile:f,file:p}=this;if(this.fileRenderer.endEditSession(p),f!=null&&p!=null&&f!==p&&Z(f,p)&&(this.renderedFile=p),t&&this.fileContainer!=null&&this.rerender(),d)throw c}applyDocumentChange(t,e){var i;const n=(i=this.editSession)==null?void 0:i.file;if(n==null)throw new Error("File.applyDocumentChange: requires an active edit session");this.fileRenderer.beginEditSession(n),this.fileRenderer.applyDocumentChange(t),e!=null&&this.syncEditSessionAnnotationsFromEditor(e)}applySuspendedDocumentChange(t,e){this.editSession!=null&&(this.applyDocumentChange(t,e),this.fileRenderer.clearRenderCache())}updateRenderCache(t,e,n){var r;const i=(r=this.editSession)==null?void 0:r.file;if(i==null)throw new Error("File.updateRenderCache: requires an active edit session");this.fileRenderer.beginEditSession(i),this.fileRenderer.updateRenderCache(t,e,n==null?void 0:n.lineCountChangeInFlight)}render({file:t,fileContainer:e,forceRender:n=!1,preventEmit:i=!1,containerWrapper:r,deferManagers:s=!1,lineAnnotations:o,renderRange:l}){var C,S;if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");(C=this.editor)==null||C.__postponeBgTokenizeToNextFrame();const{collapsed:a=!1,themeType:d="system"}=this.options,c=a?void 0:l,u=this.renderRange,h=this.hasThemeChanged(),f=o!=null&&(o.length>0||this.getLatestAnnotations().length>0)?this.isNewAnnotations(o):!1,p=!Z(this.file,t);p&&this.updateExternalFile(t,o);const y=this.getLatestFile(t)??t;if(!a&&!n&&sr(c,this.renderRange)&&!p&&!f&&!h){const w=this.applyCachedThemeState(d);return w&&this.finalizeRender(),w}this.renderRange=c,p&&(this.cachedHeaderHTML=void 0),this.fileRenderer.setOptions(ua(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.getLatestAnnotations());const{disableErrorHandling:v=!1,disableFileHeader:m=!1}=this.options;if(m&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),e=this.getOrCreateFileContainerNode(e,r),this.applyCachedThemeState(d),a){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const w=this.fileRenderer.renderFile(y,hl);w!=null&&this.applyThemeState(e,w.themeStyles,d,w.baseThemeType),(w==null?void 0:w.headerAST)!=null&&this.applyHeaderToDOM(w.headerAST,e,w.file),this.renderedFile=(w==null?void 0:w.file)??y,this.injectUnsafeCSS()}catch(w){if(v)throw w;console.error(w),w instanceof Error&&this.applyErrorToDOM(w,e)}return this.finalizeRender(),i||this.emitPostRender(),!0}try{const w=this.getOrCreatePreNode(e);if(!this.canPartiallyRender(n,f,p||h||!Z(this.renderedFile,y))||!this.applyPartialRender(y,u,c)){const b=this.fileRenderer.renderFile(y,c);if(b==null)return((S=this.workerManager)==null?void 0:S.isInitialized())===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(e,b.themeStyles,d,b.baseThemeType),b.headerAST!=null&&this.applyHeaderToDOM(b.headerAST,e,b.file),this.applyFullRender(b,w),this.renderedFile=b.file}this.applyBuffers(w,c),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,s||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(w){if(v)throw w;console.error(w),w instanceof Error&&this.applyErrorToDOM(w,e)}return i||this.emitPostRender(),!0}finalizeRender(){}emitPostRender(t=!1){const{fileContainer:e,options:{onPostRender:n}}=this;if(t){if(!this.mounted||(this.mounted=!1,e==null))return;n==null||n(e,this,"unmount");return}if(e==null)return;const i=this.mounted?"update":"mount";this.mounted=!0,n==null||n(e,this,i)}removeRenderedCode(){var t,e,n,i;this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),(t=this.bufferBefore)==null||t.remove(),this.bufferBefore=void 0,(e=this.bufferAfter)==null||e.remove(),this.bufferAfter=void 0,(n=this.code)==null||n.remove(),this.code=void 0,(i=this.pre)==null||i.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){var t;for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),(t=this.gutterUtilityContent)==null||t.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(t,e,n){return!(t||e||n)}renderPlaceholder(t){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",e.appendChild(this.placeHolder)}return this.setPlaceholderHeight(t)}setPlaceholderHeight(t){return this.placeHolder==null?!1:(this.placeHolder.style.setProperty("height",`${t}px`),!0)}async primeHighlightCache(t=this.file){const{workerManager:e}=this;if(t==null||e==null||!e.isWorkingPool()||t.cacheKey==null||xi(t))return;const n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(t).length>n||await e.primeFileHighlightCache(t).catch(i=>{lc(i)||console.error(i)})}cleanChildNodes(){var t,e,n,i,r,s,o,l,a,d,c,u,h;this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),(t=this.bufferAfter)==null||t.remove(),(e=this.bufferBefore)==null||e.remove(),(n=this.code)==null||n.remove(),(i=this.errorWrapper)==null||i.remove(),(r=this.headerElement)==null||r.remove(),(s=this.headerPrefix)==null||s.remove(),(o=this.headerFilenameSuffix)==null||o.remove(),(l=this.headerMetadata)==null||l.remove(),(a=this.headerCustom)==null||a.remove(),(d=this.pre)==null||d.remove(),(c=this.spriteSVG)==null||c.remove(),(u=this.themeCSSStyle)==null||u.remove(),(h=this.unsafeCSSStyle)==null||h.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:i}of this.annotationCache.values())i.remove();this.annotationCache.clear();return}const t=new Map(this.annotationCache),{renderAnnotation:e}=this.options,n=this.getLatestAnnotations();if(e!=null&&n.length>0)for(const[i,r]of n.entries()){const s=this.getAnnotationSlotName(r),o=`${i}-${s}`;let l=this.annotationCache.get(o);if(l==null||!S0(r,l.annotation)){l==null||l.element.remove();const a=e(r);if(a==null)continue;l={element:js(s),annotation:r},l.element.appendChild(a),this.fileContainer.appendChild(l.element),this.annotationCache.set(o,l)}t.delete(o)}for(const[i,{element:r}]of t.entries())this.annotationCache.delete(i),r.remove()}renderGutterUtility(){var i,r;const{renderGutterUtility:t}=this.options;if(this.fileContainer==null||t==null){(i=this.gutterUtilityContent)==null||i.remove(),this.gutterUtilityContent=void 0;return}const e=t(this.interactionManager.getHoveredLine);if(e!=null&&this.gutterUtilityContent!=null)return;if(e==null){(r=this.gutterUtilityContent)==null||r.remove(),this.gutterUtilityContent=void 0;return}const n=Zd();n.appendChild(e),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){var n,i;const{unsafeCSS:t}=this.options,e=(n=this.fileContainer)==null?void 0:n.shadowRoot;if(e!=null){if(t==null||t===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}((i=this.unsafeCSSStyle)==null?void 0:i.parentNode)===e&&this.appliedUnsafeCSS===t||(this.unsafeCSSStyle??(this.unsafeCSSStyle=Jd()),this.unsafeCSSStyle.parentNode!==e&&e.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ks(t),this.appliedUnsafeCSS=t)}}applyThemeState(t,e,n,i){var d,c,u;const r=t.shadowRoot??t.attachShadow({mode:"open"}),s=i??n,o=this.getTheme(),l=typeof o=="string"?o:{...o},a=sn(r);if(((d=this.themeCSSStyle)==null?void 0:d.parentNode)===r&&((c=this.appliedThemeCSS)==null?void 0:c.themeStyles)===e&&this.appliedThemeCSS.themeType===s&&this.appliedThemeCSS.scrollbarGutter===a){this.appliedThemeCSS.theme=l;return}if(this.hasAdoptedThemeCSS&&((u=this.themeCSSStyle)==null?void 0:u.parentNode)===r){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:l,themeStyles:e,themeType:s,baseThemeType:i,scrollbarGutter:a};return}this.themeCSSStyle=Js({shadowRoot:r,currentNode:this.themeCSSStyle,themeCSS:Xs(e,s,a)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:l,themeStyles:e,themeType:s,baseThemeType:i,scrollbarGutter:a}:void 0}hydrateMeasuredScrollbar(){var e;const t=(e=this.fileContainer)==null?void 0:e.shadowRoot;t==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=nc(this.themeCSSStyle.textContent??"",sn(t)))}shouldGuardRebuildScroll(){return this.editor!=null&&sc()}applyFullRender(t,e){var s;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);const n=this.code=Tn({code:this.code}),i=this.fileRenderer.renderCodeAST(t);(s=this.editor)==null||s.__captureFocusForDOMReplacement();const r=()=>{if(n.childElementCount>=2)for(let o=0;o<2;o++){const l=n.children[o],a=i[o];l.innerHTML=Ce(a.children),l.style.cssText=a.properties.style}else n.innerHTML=Ce(i);e.contains(n)||e.replaceChildren(n)};this.shouldGuardRebuildScroll()?hs(e,r):r(),this.lastRowCount=t.rowCount}applyPartialRender(t,e,n){if(e==null||n==null)return!1;const{code:i}=this,r=i!=null?this.getColumns(i):void 0;if(i==null||r==null)return!1;const s=e.startingLine,o=n.startingLine,l=e.totalLines===1/0?Number.POSITIVE_INFINITY:s+e.totalLines,a=n.totalLines===1/0?Number.POSITIVE_INFINITY:o+n.totalLines,d=Math.max(s,o),c=Math.min(l,a);if(c<=d)return!1;if(!this.trimDOMToOverlap(r.gutter,d,c)||!this.trimDOMToOverlap(r.content,d,c))throw new Error("File.applyPartialRender: failed to trim to overlap");let{length:u}=r.content.children;const h=(v,m)=>{if(!(m<=0))return this.fileRenderer.renderFile(t,{startingLine:v,totalLines:m,bufferBefore:0,bufferAfter:0})},f=o<d?h(o,d-o):void 0;if(f===void 0&&o<d)return!1;const p=a===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,a-c),y=a>c?h(c,p):void 0;return y===void 0&&a>c?!1:(this.cleanupErrorWrapper(),f!=null&&(r.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.gutterAST)),r.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.contentAST)),u+=f.rowCount),y!=null&&(r.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(y.gutterAST)),r.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(y.contentAST)),u+=y.rowCount),this.lastRowCount!==u&&(r.gutter.style.setProperty("grid-row",`span ${u}`),r.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(t){const e=t.children[0],n=t.children[1];if(!(!(e instanceof HTMLElement)||!(n instanceof HTMLElement)||e.dataset.gutter==null||n.dataset.content==null))return{gutter:e,content:n}}trimDOMToOverlap(t,e,n){var o,l;const i=this.getDOMBoundaryIndices(t,[e,n]),r=i.get(e)??t.children.length,s=i.get(n)??t.children.length;if(r>s)return!1;for(let a=t.children.length-1;a>=s;a-=1)(o=t.children[a])==null||o.remove();for(let a=r-1;a>=0;a-=1)(l=t.children[a])==null||l.remove();return!0}getDOMBoundaryIndices(t,e){const n=[...new Set(e)].sort((l,a)=>l-a),i=new Map;if(n.length===0)return i;let r=0,s=n[r];const{children:o}=t;s===0&&(i.set(0,0),r+=1,s=n[r]);for(let l=0;l<o.length;l+=1){const a=o[l];if(!(a instanceof HTMLElement))continue;const d=this.getLineIndexFromDOMNode(a);if(d!=null){for(;s!=null&&d>=s;)i.set(s,l),r+=1,s=n[r];if(r>=n.length)break}}for(const l of n)i.has(l)||i.set(l,o.length);return i}getLineIndexFromDOMNode(t){const e=t.dataset.lineIndex;if(e==null)return;const n=Number(e);return Number.isNaN(n)?void 0:n}applyBuffers(t,e){if(e==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}e.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",t.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${e.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),e.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",t.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${e.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(t,e,n){var a,d,c,u,h,f,p;this.cleanupErrorWrapper(),(a=this.placeHolder)==null||a.remove(),this.placeHolder=void 0;const i=this.cachedHeaderHTML??Ce(t);if(this.cachedHeaderHTML=i,i!==this.lastRenderedHeaderHTML){const y=document.createElement("div");y.innerHTML=i;const v=y.firstElementChild;if(!(v instanceof HTMLElement))return;this.headerElement!=null?(d=e.shadowRoot)==null||d.replaceChild(v,this.headerElement):(c=e.shadowRoot)==null||c.prepend(v),this.headerElement=v,this.lastRenderedHeaderHTML=i}if(this.isContainerManaged)return;const{renderHeaderPrefix:r,renderHeaderFilenameSuffix:s,renderCustomHeader:o,renderHeaderMetadata:l}=this.options;if(o!=null){const y=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(e,this.headerCustom,Ls,y),(u=this.headerPrefix)==null||u.remove(),(h=this.headerFilenameSuffix)==null||h.remove(),(f=this.headerMetadata)==null||f.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const y=(r==null?void 0:r(n))??void 0,v=(s==null?void 0:s(n))??void 0,m=(l==null?void 0:l(n))??void 0;this.headerPrefix=this.upsertHeaderSlotElement(e,this.headerPrefix,ws,y),this.headerFilenameSuffix=this.upsertHeaderSlotElement(e,this.headerFilenameSuffix,xs,v),this.headerMetadata=this.upsertHeaderSlotElement(e,this.headerMetadata,ks,m),(p=this.headerCustom)==null||p.remove(),this.headerCustom=void 0}}clearHeaderSlots(){var t,e,n,i;(t=this.headerPrefix)==null||t.remove(),(e=this.headerFilenameSuffix)==null||e.remove(),(n=this.headerMetadata)==null||n.remove(),(i=this.headerCustom)==null||i.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(t,e,n,i){if(i==null){e==null||e.remove();return}const r=e??this.createHeaderSlotElement(n);return e==null&&t.appendChild(r),this.replaceHeaderSlotContent(r,i),r}replaceHeaderSlotContent(t,e){t.replaceChildren(),e instanceof Element?t.appendChild(e):t.innerText=`${e}`}createHeaderSlotElement(t){const e=document.createElement("div");return e.slot=t,e}getOrCreateFileContainerNode(t,e){var s;const{fileContainer:n}=this,i=t??n??document.createElement("diffs-container"),r=n!==i;return n!=null&&r&&((s=this.editor)==null||s.__captureFocusForDOMReplacement()),r&&this.emitPostRender(!0),this.fileContainer=i,n!=null&&r&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),e!=null&&this.fileContainer.parentNode!==e&&e.appendChild(this.fileContainer),r&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(t){const{shadowRoot:e}=t;if(e!=null)for(const n of e.children)n instanceof SVGElement?this.spriteSVG??(this.spriteSVG=n):zn(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??(this.themeCSSStyle=n),this.hasAdoptedThemeCSS=!0):zn(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??(this.unsafeCSSStyle=n),this.appliedUnsafeCSS??(this.appliedUnsafeCSS=this.options.unsafeCSS??void 0))}ensureSpriteSVG(t){const e=t.shadowRoot??t.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=Yd;const i=n.firstChild;i instanceof SVGElement&&(this.spriteSVG=i)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==e&&e.appendChild(this.spriteSVG)}getOrCreatePreNode(t){var n,i,r;const e=t.shadowRoot??t.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,e.appendChild(this.pre)):this.pre.parentNode!==e&&((n=this.editor)==null||n.__captureFocusForDOMReplacement(),(i=t.shadowRoot)==null||i.appendChild(this.pre),this.appliedPreAttributes=void 0),(r=this.placeHolder)==null||r.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(t){this.code=void 0;for(const e of Array.from(t.children))if(e instanceof HTMLElement&&e.hasAttribute("data-code")){this.code=e;return}}applyPreNodeAttributes(t,{totalLines:e}){const{overflow:n="scroll",disableLineNumbers:i=!1}=this.options,r={type:"file",split:!1,overflow:n,disableLineNumbers:i,diffIndicators:"none",disableBackground:!0,totalLines:e};Qd(r,this.appliedPreAttributes)||(Qs(t,r),this.appliedPreAttributes=r)}applyErrorToDOM(t,e){var s;this.cleanupErrorWrapper(),(s=this.pre)==null||s.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=e.shadowRoot??e.attachShadow({mode:"open"});this.errorWrapper??(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=t.message,this.errorWrapper.appendChild(i);const r=document.createElement("pre");r.dataset.errorStack="",r.innerText=t.stack??"No Error Stack",this.errorWrapper.appendChild(r)}cleanupErrorWrapper(){var t;(t=this.errorWrapper)==null||t.remove(),this.errorWrapper=void 0}},g(Br,"LoadedCustomComponent",!0),Br);function F0(t,e,n=!1){return!n&&t==null&&e!=null}function $0(t,e,n=!1){return t==null&&e!=null&&!n}function ki(t){return{...Es,...t}}function at(t,e){return Un(t,e)+z0(t,e)}function Un(t,e){return e?0:t.diffHeaderHeight}function z0(t,e){return t.paddingTop??(e?t.spacing:0)}function Wi(t){return t.paddingBottom??t.spacing}function U0(t){switch(t){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}const B0=5e3,oi=new Map;let V0=-1;function G0(t,e){return(t.overflow??"scroll")!==(e.overflow??"scroll")||(t.collapsed??!1)!==(e.collapsed??!1)||(t.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(t.disableFileHeader??!1)!==(e.disableFileHeader??!1)||t.unsafeCSS!==e.unsafeCSS}var W0=class extends N0{constructor(e,n,i=Es,r,s=!1){super(e,r,s);g(this,"virtualizer");g(this,"metrics");g(this,"__id",`virtualized-file:${++V0}`);g(this,"renderType","virtualized");g(this,"top");g(this,"height",0);g(this,"cache",{heights:new Map,checkpoints:[],fileAnnotationHeight:0,ghostTextRows:oi});g(this,"pendingRender");g(this,"isVisible",!1);g(this,"isSetup",!1);g(this,"layoutDirty",!0);g(this,"forceRenderOverride");g(this,"currentCollapsed");g(this,"onRender",e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file})));this.virtualizer=n,this.metrics=i}setMetrics(e,n=!1){const i=ki(e);!n&&nn(this.metrics,i)||(this.metrics=i,this.resetLayoutCache())}setLineAnnotations(e){this.syncLineAnnotations(e)&&(this.forceRenderOverride=!0)}syncLineAnnotations(e){return e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0?!1:(super.setLineAnnotations(e),!0)}syncEditSessionAnnotationsFromEditor(e){return super.syncEditSessionAnnotationsFromEditor(e)?(this.forceRenderOverride=!0,!0):!1}hasLineAnnotations(){return this.getLatestAnnotations().some(e=>e.lineNumber>0)}hasUniformLineHeights(){const{overflow:e="scroll"}=this.options;return e==="scroll"&&!this.hasLineAnnotations()&&this.cache.heights.size===0}getLineHeight(e,n=!1){const i=this.cache.heights.get(e);if(i!=null)return i;const r=n?2:1;return this.metrics.lineHeight*r}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:n}=this,i=!Vs(n,e),r=G0(n,e);super.setOptions(e),r&&this.resetLayoutCache(!0),i&&(this.forceRenderOverride=!0),i&&this.virtualizer.instanceChanged(this,r)}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,n=!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.cache.ghostTextRows=oi,this.renderRange!=null&&n&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}applyGhostTextRows(e){const{heights:n,ghostTextRows:i}=this.cache;if(i===e)return!1;const{lineHeight:r}=this.metrics;let s=!1;for(const o of new Set([...i.keys(),...e.keys()])){const l=i.get(o)??0,a=e.get(o)??0;if(a===l)continue;const d=(n.get(o)??r)-l*r+a*r;d===r?n.delete(o):n.set(o,d),s=!0}return this.cache.ghostTextRows=e,s}reconcileHeights(){var l;let e=!1;if(this.fileContainer==null||this.getLayoutFile()==null)return this.height!==0&&(e=!0),this.height=0,e;const{overflow:n="scroll"}=this.options;this.top=this.getVirtualizedTop();const i=((l=this.editor)==null?void 0:l.__getGhostTextRows())??oi;e=this.applyGhostTextRows(i);const r=n!=="scroll"||this.getLatestAnnotations().length>0||this.isResizeDebuggingEnabled();if(this.placeHolder!=null||!r&&this.cache.heights.size===0&&this.cache.fileAnnotationHeight===0)return e&&(this.computeApproximateSize(!0),this.setPlaceholderHeight(this.height)),e;const{lineHeight:s}=this.metrics;if(this.code==null)return e;const o=this.code.children[1];if(!(o instanceof HTMLElement))return e;if(this.renderRange!=null&&or(this.renderRange)){const a=j0(o)??0;a!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=a,e=!0)}for(const a of o.children){if(!(a instanceof HTMLElement))continue;const d=a.dataset.lineIndex;if(d==null)continue;const c=Number(d),u=(i.get(c)??0)*s,h=this.cache.heights.get(c);if(!r&&(h==null||h===s+u))continue;let f=a.getBoundingClientRect().height+u,p=!1;a.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in a.nextElementSibling.dataset||"noNewline"in a.nextElementSibling.dataset)&&("noNewline"in a.nextElementSibling.dataset&&(p=!0),f+=a.nextElementSibling.getBoundingClientRect().height);const y=this.getLineHeight(c,p);f!==y&&(e=!0,f===this.metrics.lineHeight*(p?2:1)?this.cache.heights.delete(c):this.cache.heights.set(c,f))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}updateCodeViewLayout(e,n,i,r){const s=!Z(this.file,e);s&&this.updateExternalFile(e,r);const{pendingRenderFile:o,layoutFileChanged:l,renderedFileChanged:a,annotationsChanged:d}=this.updatePendingRender(e,r);let c=(i==null?void 0:i.resetFileLayoutCache)===!0||l;(i==null?void 0:i.metrics)!=null&&(this.metrics=i.metrics,c=!0);const{collapsed:u=!1}=this.options;return this.currentCollapsed!==u&&(this.currentCollapsed=u,c=!0),c&&this.resetLayoutCache(),s&&(this.layoutDirty=!0),!this.forceRenderOverride&&(s||a||d)&&(this.forceRenderOverride=!0),this.top=n,this.computeApproximateSize(!1,o),this.height}getLayoutFile(){var e;return((e=this.pendingRender)==null?void 0:e.file)??this.getRenderedFile()}getLinePosition(e){const n=this.getLayoutFile();if(n==null||e<1)return;const{disableFileHeader:i=!1,collapsed:r=!1}=this.options,s=this.fileRenderer.getLineCount(n)-1;if(r)return{top:Un(this.metrics,i),height:0};let o=at(this.metrics,i);if(s<0)return{top:o,height:0};const l=Math.min(Math.max(e-1,0),s),{lineHeight:a}=this.metrics;if(o+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())return{top:o+l*a,height:a};const d=this.getLayoutCheckpointBeforeLineIndex(l);o=(d==null?void 0:d.top)??o;for(let c=(d==null?void 0:d.lineIndex)??0;c<l;c++)o+=this.getLineHeight(c,!1);return{top:o,height:this.getLineHeight(l,!1)}}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){const n=this.getLayoutFile();if(n==null||this.renderRange==null)return;const{disableFileHeader:i=!1,collapsed:r=!1}=this.options;if(r||this.renderRange.totalLines<=0)return;const s=this.fileRenderer.getLineCount(n)-1;if(s<0)return;const o=at(this.metrics,i),l=Math.min(this.renderRange.startingLine,s),a=Math.min(l+this.renderRange.totalLines-1,s);if(a<l)return;const{fileAnnotationHeight:d}=this.cache;if(this.hasUniformLineHeights()){const{lineHeight:u}=this.metrics,h=o+(l===0?d:this.renderRange.bufferBefore),f=l+Math.max(Math.ceil((e-h)/u),0);return f>a?void 0:{lineNumber:f+1,top:o+d+f*u}}let c=o+(l===0?d:this.renderRange.bufferBefore);for(let u=l;u<=a;u++){if(c>=e)return{lineNumber:u+1,top:c};c+=this.getLineHeight(u)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){const n=this.getLayoutFile();if(this.top==null||n==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const i=e!=null?this.computeRenderRangeFromWindow(n,this.top,e):this.renderRange;if(i==null)return;const{bufferBefore:r,bufferAfter:s,totalLines:o}=i;let l=0;if(o===0){const a=e??this.virtualizer.getWindowSpecs();this.top<a.top&&(l=s)}return{topOffset:this.top+r+l,height:this.height-(r+s)}}cleanUp(e=!1){var r;const n=this.cache.ghostTextRows.size>0;n&&(this.layoutDirty=!0);const i=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(n||!Z(this.getRenderedFile(),this.getLatestFile()));this.fileContainer!=null&&this.isSimpleMode()&&((r=this.getSimpleVirtualizer())==null||r.disconnect(this.fileContainer)),e||this.resetLayoutCache(),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),i&&this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,n=this.getLayoutFile()){var u;const i=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!i)return;const r=this.height===0;if(this.height=0,this.cache.checkpoints=[],n==null){this.layoutDirty=!1;return}this.applyGhostTextRows(((u=this.editor)==null?void 0:u.__getGhostTextRows())??oi);const{disableFileHeader:s=!1,collapsed:o=!1}=this.options,{lineHeight:l}=this.metrics,a=this.fileRenderer.getLineCount(n);if(o){this.height+=Un(this.metrics,s),this.layoutDirty=!1;return}const d=at(this.metrics,s),c=Wi(this.metrics);if(this.height+=d,this.height+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())this.height+=a*l;else for(let h=0;h<a;h++)this.addLayoutCheckpoint(h,this.height),this.height+=this.getLineHeight(h,!1);if(a>0&&(this.height+=c),this.fileContainer!=null&&i&&!r){const h=this.fileContainer.getBoundingClientRect();h.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:n.name,elementHeight:h.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(){if(!this.enabled||this.file==null)return;const e=this.getLatestFile(),n=e==null?void 0:this.fileRenderer.getFileForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!Z(this.getRenderedFile(),n))}syncGhostTextRows(){var n;const e=this.getAdvancedVirtualizer();e!=null?(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0)):(n=this.getSimpleVirtualizer())==null||n.requestHeightReconcile(this)}applyDocumentChange(e,n,i=!1){var o,l;const{renderRange:r}=this;(o=this.getAdvancedVirtualizer())==null||o.capturePendingLayoutAnchor(),super.applyDocumentChange(e,n),(l=this.getSimpleVirtualizer())==null||l.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1);const s=this.getRenderedFile();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(i&&r!=null&&s!=null){const a=this.virtualizer.getWindowSpecs(),d=this.computeRenderRangeFromWindow(s,this.top??0,a);d.bufferAfter!==r.bufferAfter&&this.updateBuffers(d)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}render({fileContainer:e,file:n,forceRender:i=!1,lineAnnotations:r,...s}){var v;const o=!Z(this.file,n);o&&(this.updateExternalFile(n,r),this.cachedHeaderHTML=void 0);const{pendingRenderFile:l,layoutFileChanged:a,renderedFileChanged:d,annotationsChanged:c}=this.pendingRender!=null&&this.pendingRender.latestFile===(this.getLatestFile(n)??n)?{pendingRenderFile:this.pendingRender.file,layoutFileChanged:!1,renderedFileChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(n,r),{forceRenderOverride:u,isSetup:h}=this;if(this.forceRenderOverride=void 0,a&&this.resetLayoutCache(),e=this.getOrCreateFileContainerNode(e),h)this.top??(this.top=this.getVirtualizedTop()),this.layoutDirty&&this.isSimpleMode()&&((v=this.getSimpleVirtualizer())==null||v.markDOMDirty(),this.computeApproximateSize(!1,l));else{this.computeApproximateSize(!1,l);const m=this.getSimpleVirtualizer();if(this.top??(this.top=this.getVirtualizedTop()),this.isAdvancedMode())this.isVisible=!0;else{if(m==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");m.connect(e,this),this.isVisible=m.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!o||!h))return this.renderPlaceholder(this.height);const f=this.virtualizer.getWindowSpecs(),p=this.top??0,y=this.computeRenderRangeFromWindow(l,p,f);return super.render({file:n,fileContainer:e,renderRange:y,lineAnnotations:r,forceRender:(u??i)||c||d||o,...s})}finalizeRender(){var e,n;if(this.getRenderedFile()!==((e=this.pendingRender)==null?void 0:e.file))throw new Error("VirtualizedFile.render: rendered a different file than its prepared layout");this.pendingRender=void 0,this.isSimpleMode()&&((n=this.getSimpleVirtualizer())==null||n.requestHeightReconcile(this))}updatePendingRender(e,n){var l;const i=this.getLatestFile(e)??e,r=this.getRenderedFile(),s=((l=this.pendingRender)==null?void 0:l.file)??r,o=this.fileRenderer.getFileForNextRender(i);return this.pendingRender={latestFile:i,file:o},{pendingRenderFile:o,annotationsChanged:this.syncLineAnnotations(n),layoutFileChanged:!Z(s,o),renderedFileChanged:!Z(r,o)}}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,n){e%B0===0&&this.cache.checkpoints.push({lineIndex:e,top:n})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let n=0,i=this.cache.checkpoints.length-1,r;for(;n<=i;){const s=n+i>>1,o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");o.lineIndex<=e?(r=o,n=s+1):i=s-1}return r}getLayoutCheckpointBeforeTop(e,n){let i=0,r=this.cache.checkpoints.length-1,s=-1;for(;i<=r;){const o=i+r>>1,l=this.cache.checkpoints[o];if(l==null)throw new Error("VirtualizedFile: invalid checkpoint index");l.top<=e?(s=o,i=o+1):r=o-1}if(n==null)return s>=0?this.cache.checkpoints[s]:void 0;for(let o=s;o>=0;o--){const l=this.cache.checkpoints[o];if(l==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(l.lineIndex%n===0)return l}}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(){var e;return((e=this.getSimpleVirtualizer())==null?void 0:e.config.resizeDebugging)??!1}computeRenderRangeFromWindow(e,n,{top:i,bottom:r}){const{disableFileHeader:s=!1}=this.options,{hunkLineCount:o,lineHeight:l}=this.metrics,a=this.fileRenderer.getLineCount(e),d=this.height,c=at(this.metrics,s),u=a>0?Wi(this.metrics):0,{fileAnnotationHeight:h}=this.cache,f=c+h,p=Math.max(0,d-c-h-u),y=qd(this.getLatestAnnotations()),v=n+c,m=h>0&&y&&v<r&&v+h>i;if(n<i-d||n>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-c-u};if(a<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};const C=Math.ceil(Math.max(r-i,0)/l),S=Math.ceil(C/o)*o+o,w=S/o,b=(i+r)/2;if(this.hasUniformLineHeights()){const Y=n+f,Re=Y+p;if(!m&&!(Y<r&&Re>i))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-c-u};const Ae=Math.floor(m&&b<n+f?0:(b-(n+f))/l),Pe=Math.floor(Ae/o)-Math.floor(w/2),xt=Math.ceil(a/o),le=Math.max(0,Math.min(Pe,xt))*o,Ut=Pe<0?S+Pe*o:S,hn=le===0?0:h+le*l,Fe=Math.min(Ut,a-le);return{startingLine:le,totalLines:Ut,bufferBefore:hn,bufferAfter:Math.max(0,(a-le-Fe)*l)}}const k=w,x=[],E=this.getLayoutCheckpointBeforeTop(Math.max(0,i-n-S*l*2),o);let R=n+((E==null?void 0:E.top)??f),A=(E==null?void 0:E.lineIndex)??0,D,I,_;const H=(E==null?void 0:E.lineIndex)??0;for(let Y=H;Y<a;Y++){const Re=A%o===0,Ae=Math.floor(A/o);if(Re&&(x[Ae]=R-(n+f),_!=null)){if(_<=0)break;_--}const Pe=this.getLineHeight(Y,!1);R>i-Pe&&R<r&&(D??(D=Ae)),R+Pe>b&&(I??(I=Ae)),_==null&&R>=r&&Re&&(_=k),A++,R+=Pe}if(D==null)if(m)D=0,I=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-c-u};I??(I=D);const U=Math.round(I-w/2),V=Math.max(0,Math.ceil(a/o)-w),P=Math.max(0,Math.min(U,V)),N=P*o,B=U<0?S+U*o:S,ae=x[P]??0,F=N===0?0:h+ae,z=P+B/o,q=z<x.length?p-x[z]:p-(R-n-f);return{startingLine:N,totalLines:B,bufferBefore:F,bufferAfter:Math.max(0,q)}}};function j0(t){let e;for(const n of t.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===jd&&(e=Math.max(e??0,n.getBoundingClientRect().height));return e}function K(t,e){return(t==null?void 0:t.cacheKey)!=null||(e==null?void 0:e.cacheKey)!=null?(t==null?void 0:t.cacheKey)===(e==null?void 0:e.cacheKey):t===e}function In(t,e){return(t==null?void 0:t.cacheKey)===(e==null?void 0:e.cacheKey)&&(t==null?void 0:t.contents)===(e==null?void 0:e.contents)&&(t==null?void 0:t.name)===(e==null?void 0:e.name)&&(t==null?void 0:t.lang)===(e==null?void 0:e.lang)}function dc(t){return t.map(e=>({...e,hunkContent:e.hunkContent.map(n=>({...n}))}))}function cc(t){return{...t,hunks:dc(t.hunks),deletionLines:[...t.deletionLines],additionLines:[...t.additionLines]}}function we(t,e){return t-(e===0?0:1)}function oe(t,e){return we(t,e)+e}const q0=1;function ji(t,...e){return`ck${q0}:${JSON.stringify([t,...e])}`}function Bn(t){return t!==""?t.split(Yc):[]}function fs(t,e,n){const i=t==="clone"?cc(e):e;if(!i.isPartial)throw new Error("hydratePartialDiff: fileDiff must be partial");switch(i.type){case"change":case"rename-changed":return K0(i,Y0(i,n),ha(i,n));case"rename-pure":{const r=ha(i,n);Q0(i,n);const s=Bn(r.contents);return i.isPartial=!1,i.deletionLines=s,i.additionLines=s,uc(i,null,r),i}}throw new Error(`hydratePartialDiff: ${i.type} diffs cannot be hydrated from loaded files`)}function K0(t,e,n){const i=Bn(e.contents),r=Bn(n.contents),{hunks:s,splitLineCount:o,unifiedLineCount:l}=X0(t.hunks,r.length);return t.hunks=s,t.splitLineCount=o,t.unifiedLineCount=l,t.isPartial=!1,t.deletionLines=i,t.additionLines=r,uc(t,e,n),t}function X0(t,e){let n=0,i=0,r=0;const s=[];for(const o of t){const l=Math.max(o.additionStart-1,0),a=Math.max(o.deletionStart-1,0);let d=l,c=a,u=0,h=0,f=0,p=0;const y=[];for(const m of o.hunkContent){if(m.type==="context"){y.push({...m,additionLineIndex:d,deletionLineIndex:c}),d+=m.lines,c+=m.lines,f+=m.lines,p+=m.lines;continue}y.push({...m,additionLineIndex:d,deletionLineIndex:c}),d+=m.additions,c+=m.deletions,u+=m.additions,h+=m.deletions,f+=Math.max(m.additions,m.deletions),p+=m.additions+m.deletions}const v=Math.max(we(o.additionStart,o.additionCount)-r,0);s.push({...o,collapsedBefore:v,additionLineIndex:l,deletionLineIndex:a,additionLines:u,deletionLines:h,hunkContent:y,splitLineStart:n+v,unifiedLineStart:i+v,splitLineCount:f,unifiedLineCount:p}),n+=v+f,i+=v+p,r=oe(o.additionStart,o.additionCount)}if(s.length>0){const o=s[s.length-1],l=oe(o.additionStart,o.additionCount),a=Math.max(e-l,0);n+=a,i+=a}return{hunks:s,splitLineCount:n,unifiedLineCount:i}}function Y0(t,e){if(e.oldFile==null)throw new Error(`hydratePartialDiff: ${t.type} diff for ${t.name} requires oldFile`);return e.oldFile}function ha(t,e){if(e.newFile==null)throw new Error(`hydratePartialDiff: ${t.type} diff for ${t.name} requires newFile`);return e.newFile}function Q0(t,e){if(e.oldFile!==null)throw new Error(`hydratePartialDiff: ${t.type} diff for ${t.name} requires oldFile to be null`)}function Z0(t,e,n){return t.cacheKey!=null?`${t.cacheKey}:hydrated`:J0(e,n)}function uc(t,e,n){const i=Z0(t,e,n);if(i==null){delete t.cacheKey;return}t.cacheKey=i}function J0(t,e){return t!=null&&e!=null?t.cacheKey!=null&&e.cacheKey!=null?ji("hydrated-files",t.cacheKey,e.cacheKey):void 0:(t==null?void 0:t.cacheKey)??(e==null?void 0:e.cacheKey)}function Qe(t){let e=t.length;return t.charCodeAt(e-1)===10&&(e--,t.charCodeAt(e-1)===13&&e--),t.slice(0,e)}const ey=new TextEncoder,ty=new TextDecoder("utf-8",{ignoreBOM:!0}),ny=/[\uD800-\uDFFF]/,ps=1024;let Qt=new Uint8Array(ps);function eo(){Qt.length!==ps&&(Qt=new Uint8Array(ps))}function ee(t){if(t.length===0)return t;if(ny.test(t))return JSON.parse(JSON.stringify(t));const e=t.length*3;Qt.length<e&&(Qt=new Uint8Array(e));const{written:n}=ey.encodeInto(t,Qt);return ty.decode(Qt.subarray(0,n))}const iy=new TextDecoder("utf-8",{ignoreBOM:!0}),ry={'"':'"',"\\":"\\",a:"\x07",b:"\b",t:" ",n:`
287
+ `,v:"\v",f:"\f",r:"\r"};function sy(t){if(t[0]!=='"')return;let e="",n=1;for(;n<t.length;){const i=t[n];if(i==='"')return{fileName:e,rawLength:n+1};if(i!=="\\"){e+=i,n++;continue}const r=ry[t[n+1]];if(r!=null){e+=r,n+=2;continue}const s=[];do{const o=oy(t,n+1);if(o==null)return;s.push(o),n+=4}while(t[n]==="\\"&&t[n+1]>="0"&&t[n+1]<="7");e+=iy.decode(new Uint8Array(s))}}function oy(t,e){const n=t.charCodeAt(e)-48,i=t.charCodeAt(e+1)-48,r=t.charCodeAt(e+2)-48;if(n>=0&&n<=3&&i>=0&&i<=7&&r>=0&&r<=7)return n*64+i*8+r}const ay=4096,ly=.5;function dy(t){for(const e of t.hunks)for(let n=0;n<e.hunkContent.length;n++){const i=e.hunkContent[n];if(i.type!=="change")continue;const r=uy(t,i);r!=null&&(e.hunkContent.splice(n,1,...r),n+=r.length-1)}}function cy(t,e,n){const{hunkContent:i}=t;for(let r=1;r<i.length;r++){const s=i[r],o=i[r-1];if(s.type!=="change"||s.additions>0&&s.deletions>0||o.type!=="context")continue;const l=s.additions>0,a=l?e.additionLines:e.deletionLines,d=l?s.additionLineIndex:s.deletionLineIndex,c=l?s.additions:s.deletions,u=a[d]??"";if(u.trim()!=="")continue;let h=!0;for(let m=1;m<c;m++)if(a[d+m]!==u){h=!1;break}if(!h)continue;let f=0;for(;f<o.lines&&e.additionLines[o.additionLineIndex+o.lines-1-f]===u;)f++;if(f===0||r===1&&f===o.lines||n!=null&&(f=n(s,f),f===0))continue;s.additionLineIndex-=f,s.deletionLineIndex-=f;const p=s.additionLineIndex+s.additions,y=s.deletionLineIndex+s.deletions,v=i[r+1];(v==null?void 0:v.type)==="context"?(v.lines+=f,v.additionLineIndex=p,v.deletionLineIndex=y):i.splice(r+1,0,{type:"context",lines:f,additionLineIndex:p,deletionLineIndex:y}),o.lines-=f,o.lines===0&&(i.splice(r-1,1),r--)}}function uy(t,e){const{deletions:n,additions:i,deletionLineIndex:r,additionLineIndex:s}=e,o=Math.min(n,i),l=Math.abs(i-n);if(o===0||l===0||o*(l+1)>ay)return null;const a=[];for(let y=0;y<n;y++)a.push(fa(t.deletionLines[r+y]??""));const d=[];for(let y=0;y<i;y++)d.push(fa(t.additionLines[s+y]??""));const c=i>n;let u=0,h=-1;for(let y=0;y<=l;y++){let v=0;for(let m=0;m<o;m++)v+=fy(a[m+(c?0:y)],d[m+(c?y:0)]);y===0?h=v+o*ly:v>h&&(h=v,u=y)}if(u===0)return null;const f=[],p=(y,v,m,C)=>{(y>0||v>0)&&f.push({type:"change",deletions:y,additions:v,deletionLineIndex:m,additionLineIndex:C})};return c?(p(0,u,r,s),p(o,o,r,s+u),p(0,i-o-u,r+o,s+u+o)):(p(u,0,r,s),p(o,o,r+u,s),p(n-o-u,0,r+u+o,s+o)),f}const hy=/\s+/g;function fa(t){return t.replace(hy,"")}function fy(t,e){if(t===e)return 1;const n=Math.max(t.length,e.length),i=Math.min(t.length,e.length);if(i===0)return 0;let r=0;for(;r<i&&t[r]===e[r];)r++;let s=0;for(;s<i-r&&t[t.length-1-s]===e[e.length-1-s];)s++;return(r+s)/n}const py=/^diff --git ("a\/(?:[^"\\]|\\.)*"|a\/.+?) ("b\/(?:[^"\\]|\\.)*"|b\/.+?)$/;function _S(t,e,n){try{return hc(t,e,n)}finally{eo()}}function hc(t,e,n=!1,i){const r=ky(t),s=r?vy(t):Cy(t);let o;const l=[];for(const a of s){if(r&&!ll.test(a)){if(o==null)o=ee(a);else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",a)}continue}else if(!r&&!Sy(a)){if(o==null)o=ee(a);else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",a)}continue}const d=fc(a,{cacheKey:e!=null?i==null?ji("patch-file",e,String(l.length)):ji("patch-file",e,String(i),String(l.length)):void 0,isGitDiff:r,throwOnError:n});d!=null&&l.push(d)}return{patchMetadata:o,files:l}}function gy(t,e){try{return fc(t,e)}finally{eo()}}function fc(t,{cacheKey:e,isGitDiff:n=ll.test(t),oldFile:i,newFile:r,throwOnError:s=!1}={}){let o=0;const l=yc(t,"@@ ");let a;const d=i==null||r==null;let c=0,u=0;for(const h of l){const f=pc(h),p=f[0];if(p==null){if(s)throw Error("parsePatchContent: invalid hunk");console.error("parsePatchContent: invalid hunk",h);continue}const y=mc(p);let v=0,m=0;if(y==null||a==null){if(a!=null){if(s)throw Error("parsePatchContent: Invalid hunk");console.error("parsePatchContent: Invalid hunk",h);continue}a={name:"",type:"change",hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:d,additionLines:!d&&i!=null&&r!=null?pa(r.contents):[],deletionLines:!d&&i!=null&&r!=null?pa(i.contents):[],cacheKey:ya(e)},a.additionLines.length===1&&(r==null?void 0:r.contents)===""&&(a.additionLines.length=0),a.deletionLines.length===1&&(i==null?void 0:i.contents)===""&&(a.deletionLines.length=0);for(const R of f){if(R.startsWith("diff --git")){const D=R.trim().match(py);if(D==null){if(s)throw Error("parsePatchContent: invalid git diff header");console.error("parsePatchContent: invalid git diff header",R);continue}const I=Cn(D[1],!0),_=Cn(D[2],!0);a.name=ee(_),I!==_&&(a.prevName=ee(I));continue}const A=R.startsWith("---")||R.startsWith("+++")?R.match(Qc):null;if(A!=null){const[,D,I]=A,_=Cn(I,n);if(D==="---"&&_!=="/dev/null"){const H=ee(_);a.prevName=H,a.name=H}else D==="+++"&&_!=="/dev/null"&&(a.name=ee(_))}else if(n){if(R.startsWith("new mode ")&&(a.mode=ee(R.slice(8).trim())),R.startsWith("old mode ")&&(a.prevMode=ee(R.slice(8).trim())),R.startsWith("new file mode")&&(a.type="new",a.mode=ee(R.slice(13).trim())),R.startsWith("deleted file mode")&&(a.type="deleted",a.mode=ee(R.slice(17).trim())),R.startsWith("similarity index")&&(R.startsWith("similarity index 100%")?a.type="rename-pure":a.type="rename-changed"),R.startsWith("index ")){const[,D,I,_]=R.trim().match(Zc)??[];D!=null&&(a.prevObjectId=ee(D)),I!=null&&(a.newObjectId=ee(I)),_!=null&&(a.mode=ee(_))}(R.startsWith("rename from ")||R.startsWith("copy from "))&&(a.prevName=ee(Cn(R.slice(R.startsWith("rename")?12:10)))),(R.startsWith("rename to ")||R.startsWith("copy to "))&&(a.name=ee(Cn(R.slice(R.startsWith("rename")?10:8))))}}continue}let C,S;for(;f.length>0&&(f[f.length-1]===`
288
+ `||f[f.length-1]==="\r"||f[f.length-1]===`\r
289
+ `||f[f.length-1]==="");)f.pop();const{additionStart:w,deletionStart:b}=y;c=d?c:b-1,u=d?u:w-1;const k={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:y.additionCount,additionStart:w,additionLines:v,deletionCount:y.deletionCount,deletionStart:b,deletionLines:m,deletionLineIndex:c,additionLineIndex:u,hunkContent:[],hunkContext:ya(y.hunkContext),hunkSpecs:ee(p),noEOFCRAdditions:!1,noEOFCRDeletions:!1};let x=0,E=0;for(let R=1;R<f.length;R++){const A=f[R];if(x>=k.additionCount&&E>=k.deletionCount&&!A.startsWith("\\")){if(!(by(A)&&!wy(A)))break;if(s)throw Error("parsePatchContent: hunk has more lines than expected")}const D=A[0];if(D!=="+"&&D!=="-"&&D!==" "&&D!=="\\"){if(s)throw Error("parsePatchContent: invalid hunk line");console.error(`parseLineType: Invalid firstChar: "${D}", full line: "${A}"`),console.error("processFile: invalid rawLine:",A);continue}const I=Ly(D);if(I==="addition"){if(s&&x>=k.additionCount)throw Error("parsePatchContent: hunk has too many addition lines");const _=Pr(A);(C==null||C.type!=="change")&&(C=Mr("change",c,u),k.hunkContent.push(C)),u++,x++,d&&a.additionLines.push(_),C.additions++,v++,S="addition"}else if(I==="deletion"){if(s&&E>=k.deletionCount)throw Error("parsePatchContent: hunk has too many deletion lines");const _=Pr(A);(C==null||C.type!=="change")&&(C=Mr("change",c,u),k.hunkContent.push(C)),c++,E++,d&&a.deletionLines.push(_),C.deletions++,m++,S="deletion"}else if(I==="context"){if(s&&(E>=k.deletionCount||x>=k.additionCount))throw Error("parsePatchContent: hunk has too many context lines");const _=Pr(A);(C==null||C.type!=="context")&&(C=Mr("context",c,u),k.hunkContent.push(C)),u++,c++,x++,E++,d&&(a.deletionLines.push(_),a.additionLines.push(_)),C.lines++,S="context"}else if(I==="metadata"&&C!=null){if(C.type==="context"?(k.noEOFCRAdditions=!0,k.noEOFCRDeletions=!0):S==="deletion"?k.noEOFCRDeletions=!0:S==="addition"&&(k.noEOFCRAdditions=!0),d&&(S==="addition"||S==="context")){const _=a.additionLines.length-1;_>=0&&(a.additionLines[_]=Qe(a.additionLines[_]))}if(d&&(S==="deletion"||S==="context")){const _=a.deletionLines.length-1;_>=0&&(a.deletionLines[_]=Qe(a.deletionLines[_]))}}}if(x!==k.additionCount||E!==k.deletionCount){if(s)throw Error("parsePatchContent: hunk line count mismatch");console.error(`parsePatchContent: hunk line count mismatch: "${p.trimEnd()}", declared old/new ${k.deletionCount}/${k.additionCount}, parsed old/new ${E}/${x}`);const R=we(k.additionStart,k.additionCount)+(x===0?0:1),A=we(k.deletionStart,k.deletionCount)+(E===0?0:1);if(!d){const D=R-k.additionStart,I=A-k.deletionStart;k.additionLineIndex+=D,k.deletionLineIndex+=I;for(const _ of k.hunkContent)_.additionLineIndex+=D,_.deletionLineIndex+=I}k.additionStart=R,k.deletionStart=A,k.additionCount=x,k.deletionCount=E}k.additionLines=v,k.deletionLines=m,k.collapsedBefore=Math.max(we(k.additionStart,k.additionCount)-o,0),a.hunks.push(k),o=oe(k.additionStart,k.additionCount);for(const R of k.hunkContent)R.type==="context"?(k.splitLineCount+=R.lines,k.unifiedLineCount+=R.lines):(k.splitLineCount+=Math.max(R.additions,R.deletions),k.unifiedLineCount+=R.deletions+R.additions);k.splitLineStart=a.splitLineCount+k.collapsedBefore,k.unifiedLineStart=a.unifiedLineCount+k.collapsedBefore,a.splitLineCount+=k.collapsedBefore+k.splitLineCount,a.unifiedLineCount+=k.collapsedBefore+k.unifiedLineCount}if(a!=null){if(s&&d&&!n&&a.hunks.length===0)throw Error("parsePatchContent: unified file has no hunks");if(a.hunks.length>0&&!d&&a.additionLines.length>0&&a.deletionLines.length>0){const h=a.hunks[a.hunks.length-1],f=oe(h.additionStart,h.additionCount),p=a.additionLines.length,y=Math.max(p-f,0);a.splitLineCount+=y,a.unifiedLineCount+=y}return n||(a.prevName!=null&&a.name!==a.prevName?a.hunks.length>0?a.type="rename-changed":a.type="rename-pure":(i==null||i.contents==="")&&r!=null&&r.contents!==""?a.type="new":i!=null&&i.contents!==""&&(r==null||r.contents==="")&&(a.type="deleted")),a.type!=="rename-pure"&&a.type!=="rename-changed"&&(a.prevName=void 0),dy(a),a}}function my(t,e,n=!1){const i=[],r=yy(t)?t.split(Kc):[t];for(const s of r)try{i.push(hc(s,e,n,e!=null?i.length:void 0))}catch(o){if(n)throw o;console.error(o)}finally{eo()}return i}function Cn(t,e=!1){var r;const n=t.trim(),i=n.startsWith('"')?((r=sy(n))==null?void 0:r.fileName)??n:n;return e&&(i.startsWith("a/")||i.startsWith("b/"))?i.slice(2):i}function yy(t){return t.startsWith("From ")||t.includes(`
290
+ From `)}function pa(t){const e=pc(t);for(let n=0;n<e.length;n++)e[n]=ee(e[n]);return e}function pc(t){if(t.length===0)return[""];const e=[];let n=0;for(;;){const i=t.indexOf(`
291
+ `,n);if(i===-1)break;e.push(t.slice(n,i+1)),n=i+1}return n<t.length&&e.push(t.slice(n)),e}function vy(t){return yc(t,"diff --git")}function Cy(t){if(t.length===0)return[""];const e=[];let n=0,i=0,r=0,s=0,o=!1;for(;i<t.length;){const l=gs(t,i);if(r<=0&&s<=0){if(gc(t,i)){i>n&&e.push(t.slice(n,i)),n=i,o=!0,i=gs(t,l);continue}if(o&&t.startsWith("@@ -",i)){const d=mc(t.slice(i,l));d!=null&&(r=d.deletionCount,s=d.additionCount)}i=l;continue}const a=t[i];if(a==="\\"){i=l;continue}a===" "?(r=Math.max(r-1,0),s=Math.max(s-1,0)):a==="-"?r=Math.max(r-1,0):a==="+"&&(s=Math.max(s-1,0)),i=l}return e.push(t.slice(n)),e}function Sy(t){return gc(t,0)}function gc(t,e){const n=gs(t,e);return ga(t,e,"---")&&ga(t,n,"+++")}function ga(t,e,n){if(!t.startsWith(n,e))return!1;const i=t[e+n.length];if(i!==" "&&i!==" ")return!1;for(let r=e+n.length+1;r<t.length;r++){const s=t[r];if(s===`
292
+ `||s==="\r")break;if(s!==" "&&s!==" ")return!0}return!1}function gs(t,e){const n=t.indexOf(`
293
+ `,e);return n===-1?t.length:n+1}function by(t){const e=t[0];return e==="+"||e==="-"||e===" "}function wy(t){if(!t.startsWith("--"))return!1;for(let e=2;e<t.length;e++){const n=t[e];if(n!==" "&&n!==" "&&n!==`
294
+ `&&n!=="\r")return!1}return!0}function mc(t){if(!t.startsWith("@@ -"))return;let e=4;const n=ai(t,e);if(n==null)return;const i=n.value;e=n.endIndex;let r=1;if(t[e]===","){const c=ai(t,e+1);if(c==null)return;r=c.value,e=c.endIndex}if(t[e]!==" "||t[e+1]!=="+")return;e+=2;const s=ai(t,e);if(s==null)return;const o=s.value;e=s.endIndex;let l=1;if(t[e]===","){const c=ai(t,e+1);if(c==null)return;l=c.value,e=c.endIndex}if(t[e]!==" "||t[e+1]!=="@"||t[e+2]!=="@")return;let a;const d=e+3;return t[d]===" "&&(a=xy(t.slice(d+1))),{additionCount:l,additionStart:o,deletionCount:r,deletionStart:i,hunkContext:a}}function ai(t,e){let n=e,i=0;for(;n<t.length;n++){const r=t.charCodeAt(n)-48;if(r<0||r>9)break;i=i*10+r}if(n!==e)return{value:i,endIndex:n}}function xy(t){return t.endsWith(`\r
295
+ `)?t.slice(0,-2):t.endsWith(`
296
+ `)?t.slice(0,-1):t}function ky(t){return t.startsWith("diff --git")||t.includes(`
297
+ diff --git`)}function yc(t,e){if(t.length===0)return[""];const n=`
298
+ ${e}`,i=t.startsWith(e)?0:ma(t,n,0);if(i===-1)return[t];const r=[];i>0&&r.push(t.slice(0,i));let s=i;for(;;){const o=ma(t,n,s+1);if(o===-1)break;r.push(t.slice(s,o)),s=o}return r.push(t.slice(s)),r}function ma(t,e,n){const i=t.indexOf(e,n);return i===-1?-1:i+1}function ya(t){return t==null?t:ee(t)}function Ly(t){return t===" "?"context":t==="\\"?"metadata":t==="+"?"addition":"deletion"}function Pr(t){const e=t.slice(1);return ee(e===""?`
299
+ `:e)}function Mr(t,e,n){return t==="change"?{type:"change",additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:e}:{type:"context",lines:0,additionLineIndex:n,deletionLineIndex:e}}class to{diff(e,n,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);const s=this.castInput(e,i),o=this.castInput(n,i),l=this.removeEmpty(this.tokenize(s,i)),a=this.removeEmpty(this.tokenize(o,i));return this.diffWithOptionsObj(l,a,i,r)}diffWithOptionsObj(e,n,i,r){var s;const o=C=>{if(C=this.postProcess(C,i),r){setTimeout(function(){r(C)},0);return}else return C},l=n.length,a=e.length;let d=1,c=l+a;i.maxEditLength!=null&&(c=Math.min(c,i.maxEditLength));const u=(s=i.timeout)!==null&&s!==void 0?s:1/0,h=Date.now()+u,f=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(f[0],n,e,0,i);if(f[0].oldPos+1>=a&&p+1>=l)return o(this.buildValues(f[0].lastComponent,n,e));let y=-1/0,v=1/0;const m=()=>{for(let C=Math.max(y,-d);C<=Math.min(v,d);C+=2){let S;const w=f[C-1],b=f[C+1];w&&(f[C-1]=void 0);let k=!1;if(b){const E=b.oldPos-C;k=b&&0<=E&&E<l}const x=w&&w.oldPos+1<a;if(!k&&!x){f[C]=void 0;continue}if(!x||k&&w.oldPos<b.oldPos?S=this.addToPath(b,!0,!1,0,i):S=this.addToPath(w,!1,!0,1,i),p=this.extractCommon(S,n,e,C,i),S.oldPos+1>=a&&p+1>=l)return o(this.buildValues(S.lastComponent,n,e))||!0;f[C]=S,S.oldPos+1>=a&&(v=Math.min(v,C-1)),p+1>=l&&(y=Math.max(y,C+1))}d++};if(r)(function C(){setTimeout(function(){if(d>c||Date.now()>h)return r(void 0);m()||C()},0)})();else for(;d<=c&&Date.now()<=h;){const C=m();if(C)return C}}addToPath(e,n,i,r,s){const o=e.lastComponent;return o&&!s.oneChangePerToken&&o.added===n&&o.removed===i?{oldPos:e.oldPos+r,lastComponent:{count:o.count+1,added:n,removed:i,previousComponent:o.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:n,removed:i,previousComponent:o}}}extractCommon(e,n,i,r,s){const o=n.length,l=i.length;let a=e.oldPos,d=a-r,c=0;for(;d+1<o&&a+1<l&&this.equals(i[a+1],n[d+1],s);)d++,a++,c++,s.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return c&&!s.oneChangePerToken&&(e.lastComponent={count:c,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,d}equals(e,n,i){return i.comparator?i.comparator(e,n):e===n||!!i.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let i=0;i<e.length;i++)e[i]&&n.push(e[i]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,i){const r=[];let s;for(;e;)r.push(e),s=e.previousComponent,delete e.previousComponent,e=s;r.reverse();const o=r.length;let l=0,a=0,d=0;for(;l<o;l++){const c=r[l];if(c.removed)c.value=this.join(i.slice(d,d+c.count)),d+=c.count;else{if(!c.added&&this.useLongestToken){let u=n.slice(a,a+c.count);u=u.map(function(h,f){const p=i[d+f];return p.length>h.length?p:h}),c.value=this.join(u)}else c.value=this.join(n.slice(a,a+c.count));a+=c.count,c.added||(d+=c.count)}}return r}}class Ey extends to{}const Ry=new Ey;function _y(t,e,n){return Ry.diff(t,e,n)}const va="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 Ty extends to{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${va}]+|[^\\S\\n\\r]+|[^${va}]`,"ug");return e.match(n)||[]}}const Iy=new Ty;function Ay(t,e,n){return Iy.diff(t,e,n)}class Py extends to{constructor(){super(...arguments),this.tokenize=Dy}equals(e,n,i){return i.ignoreWhitespace?((!i.newlineIsToken||!e.includes(`
300
+ `))&&(e=e.trim()),(!i.newlineIsToken||!n.includes(`
301
+ `))&&(n=n.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(e.endsWith(`
302
+ `)&&(e=e.slice(0,-1)),n.endsWith(`
303
+ `)&&(n=n.slice(0,-1))),super.equals(e,n,i)}}const My=new Py;function Ca(t,e,n){return My.diff(t,e,n)}function Dy(t,e){e.stripTrailingCr&&(t=t.replace(/\r\n/g,`
304
+ `));const n=[],i=t.split(/(\n|\r\n)/);i[i.length-1]||i.pop();for(let r=0;r<i.length;r++){const s=i[r];r%2&&!e.newlineIsToken?n[n.length-1]+=s:n.push(s)}return n}function Hy(t){for(let e=0;e<t.length;e++)if(t[e]<" "||t[e]>"~"||t[e]==='"'||t[e]==="\\")return!0;return!1}function ft(t){if(!Hy(t))return t;let e='"';const n=new TextEncoder().encode(t);let i=0;for(;i<n.length;){const r=n[i];r===7?e+="\\a":r===8?e+="\\b":r===9?e+="\\t":r===10?e+="\\n":r===11?e+="\\v":r===12?e+="\\f":r===13?e+="\\r":r===34?e+='\\"':r===92?e+="\\\\":r>=32&&r<=126?e+=String.fromCharCode(r):e+="\\"+r.toString(8).padStart(3,"0"),i++}return e+='"',e}const Sa={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function ba(t,e,n,i,r,s,o){let l;o?typeof o=="function"?l={callback:o}:l=o:l={},typeof l.context>"u"&&(l.context=4);const a=l.context;if(l.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(l.callback){const{callback:c}=l;Ca(n,i,Object.assign(Object.assign({},l),{callback:u=>{const h=d(u);c(h)}}))}else return d(Ca(n,i,l));function d(c){if(!c)return;c.push({value:"",lines:[]});function u(C){return C.map(function(S){return" "+S})}const h=[];let f=0,p=0,y=[],v=1,m=1;for(let C=0;C<c.length;C++){const S=c[C],w=S.lines||Ny(S.value);if(S.lines=w,S.added||S.removed){if(!f){const b=c[C-1];f=v,p=m,b&&(y=a>0?u(b.lines.slice(-a)):[],f-=y.length,p-=y.length)}for(const b of w)y.push((S.added?"+":"-")+b);S.added?m+=w.length:v+=w.length}else{if(f)if(w.length<=a*2&&C<c.length-2)for(const b of u(w))y.push(b);else{const b=Math.min(w.length,a);for(const x of u(w.slice(0,b)))y.push(x);const k={oldStart:f,oldLines:v-f+b,newStart:p,newLines:m-p+b,lines:y};h.push(k),f=0,p=0,y=[]}v+=w.length,m+=w.length}}for(const C of h)for(let S=0;S<C.lines.length;S++)C.lines[S].endsWith(`
305
+ `)?C.lines[S]=C.lines[S].slice(0,-1):(C.lines.splice(S+1,0,"\"),S++);return{oldFileName:t,newFileName:e,oldHeader:r,newHeader:s,hunks:h}}}function ms(t,e){var n,i,r,s,o,l;if(e||(e=Sa),Array.isArray(t)){if(t.length>1&&!e.includeFileHeaders&&!t.every(c=>c.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 t.map(c=>ms(c,e)).join(`
306
+ `)}const a=[];if(t.isGit){if(e=Sa,!t.oldFileName)throw new Error("oldFileName must be specified for Git patches");if(!t.newFileName)throw new Error("newFileName must be specified for Git patches");let c=t.oldFileName,u=t.newFileName;t.isCreate&&c==="/dev/null"?c=u.replace(/^b\//,"a/"):t.isDelete&&u==="/dev/null"&&(u=c.replace(/^a\//,"b/")),a.push("diff --git "+ft(c)+" "+ft(u)),t.isDelete&&a.push("deleted file mode "+((n=t.oldMode)!==null&&n!==void 0?n:"100644")),t.isCreate&&a.push("new file mode "+((i=t.newMode)!==null&&i!==void 0?i:"100644")),t.oldMode&&t.newMode&&!t.isDelete&&!t.isCreate&&(a.push("old mode "+t.oldMode),a.push("new mode "+t.newMode)),t.isRename&&(a.push("rename from "+ft(((r=t.oldFileName)!==null&&r!==void 0?r:"").replace(/^a\//,""))),a.push("rename to "+ft(((s=t.newFileName)!==null&&s!==void 0?s:"").replace(/^b\//,"")))),t.isCopy&&(a.push("copy from "+ft(((o=t.oldFileName)!==null&&o!==void 0?o:"").replace(/^a\//,""))),a.push("copy to "+ft(((l=t.newFileName)!==null&&l!==void 0?l:"").replace(/^b\//,""))))}else e.includeIndex&&t.oldFileName==t.newFileName&&t.oldFileName!==void 0&&a.push("Index: "+t.oldFileName),e.includeUnderline&&a.push("===================================================================");const d=t.hunks.length>0;e.includeFileHeaders&&t.oldFileName!==void 0&&t.newFileName!==void 0&&(!t.isGit||d)&&(a.push("--- "+ft(t.oldFileName)+(t.oldHeader?" "+t.oldHeader:"")),a.push("+++ "+ft(t.newFileName)+(t.newHeader?" "+t.newHeader:"")));for(let c=0;c<t.hunks.length;c++){const u=t.hunks[c],h=u.oldLines===0?u.oldStart-1:u.oldStart,f=u.newLines===0?u.newStart-1:u.newStart;a.push("@@ -"+h+","+u.oldLines+" +"+f+","+u.newLines+" @@");for(const p of u.lines)a.push(p)}return a.join(`
307
+ `)+`
308
+ `}function Oy(t,e,n,i,r,s,o){if(typeof o=="function"&&(o={callback:o}),o!=null&&o.callback){const{callback:l}=o;ba(t,e,n,i,r,s,Object.assign(Object.assign({},o),{callback:a=>{l(a?ms(a,o.headerOptions):void 0)}}))}else{const l=ba(t,e,n,i,r,s,o);return l?ms(l,o==null?void 0:o.headerOptions):void 0}}function Ny(t){const e=t.endsWith(`
309
+ `),n=t.split(`
310
+ `).map(i=>i+`
311
+ `);return e?n.pop():n.push(n.pop().slice(0,-1)),n}const Fy="/dev/null";function Nt(t,e,n,i=!1){if(t===null&&e===null)throw new Error("parseDiffFromFile: You must pass oldFile, newFile, or both");const r=t??wa(),s=e??wa(),o=Oy(r.name,s.name,r.contents,s.contents,r.header,s.header,n),l=gy(o,{cacheKey:(()=>{const d=t==null?void 0:t.cacheKey,c=e==null?void 0:e.cacheKey;return d!=null&&c!=null?ji("diff",d,c):void 0})(),oldFile:r,newFile:s,throwOnError:i});if(l==null)throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");t===null?(l.type="new",l.prevName=void 0):e===null&&(l.type="deleted",l.prevName=void 0);const a=(e==null?void 0:e.lang)??(e===null?t==null?void 0:t.lang:void 0);return a!=null&&(l.lang=a),l}function wa(){return{name:Fy,contents:""}}var $y=class{constructor(){g(this,"isDeletionsScrolling",!1);g(this,"isAdditionsScrolling",!1);g(this,"timeoutId",-1);g(this,"codeDeletions");g(this,"codeAdditions");g(this,"enabled",!1);g(this,"handleDeletionsScroll",()=>{var t,e;this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),(e=this.codeAdditions)==null||e.scrollTo({left:(t=this.codeDeletions)==null?void 0:t.scrollLeft}))});g(this,"handleAdditionsScroll",()=>{var t,e;this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),(e=this.codeDeletions)==null||e.scrollTo({left:(t=this.codeAdditions)==null?void 0:t.scrollLeft}))})}cleanUp(){var t,e;this.enabled&&((t=this.codeDeletions)==null||t.removeEventListener("scroll",this.handleDeletionsScroll),(e=this.codeAdditions)==null||e.removeEventListener("scroll",this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,this.enabled=!1)}setup(t,e,n){var i,r;if(e==null||n==null)for(const s of t.children??[])s instanceof HTMLElement&&("deletions"in s.dataset?e=s:"additions"in s.dataset&&(n=s));if(n==null||e==null){this.cleanUp();return}this.codeDeletions!==e&&((i=this.codeDeletions)==null||i.removeEventListener("scroll",this.handleDeletionsScroll),this.codeDeletions=e,e.addEventListener("scroll",this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&((r=this.codeAdditions)==null||r.removeEventListener("scroll",this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener("scroll",this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}};function tt(t,e){return zt(t.theme,e.theme)&&t.useTokenTransformer===e.useTokenTransformer&&t.tokenizeMaxLineLength===e.tokenizeMaxLineLength&&t.lineDiffType===e.lineDiffType&&t.maxLineDiffLength===e.maxLineDiffLength}function li(t){return M({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":t,style:`grid-row: span ${t};min-height:calc(${t} * 1lh)`}})}function di(t){return M({tagName:"div",children:[M({tagName:"span",children:[Se("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":t,"data-column-content":""}})}function Dr(t){return M({tagName:"div",children:[Ui({name:t==="both"?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{role:"button","data-expand-button":"","data-expand-both":t==="both"?"":void 0,"data-expand-up":t==="up"?"":void 0,"data-expand-down":t==="down"?"":void 0}})}function Wt({type:t,content:e,expandIndex:n,chunked:i=!1,slotName:r,isFirstHunk:s,isLastHunk:o}){let l=0;const a=[];if(t==="metadata"&&e!=null&&a.push(M({tagName:"div",children:[Se(e)],properties:{"data-separator-wrapper":""}})),(t==="line-info"||t==="line-info-basic")&&e!=null){const d=[];n!=null&&(i?(s||(d.push(Dr("up")),l++),o||(d.push(Dr("down")),l++)):(d.push(Dr(!s&&!o?"both":s?"down":"up")),l++)),d.push(M({tagName:"div",children:[M({tagName:"span",children:[Se(e)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),i&&n!=null&&d.push(M({tagName:"div",children:[Se("Expand all")],properties:{role:"button","data-expand-button":"","data-expand-all-button":""}})),a.push(M({tagName:"div",children:d,properties:{"data-separator-wrapper":"","data-separator-multi-button":l>1?"":void 0}}))}return t==="custom"&&r!=null&&a.push(M({tagName:"slot",properties:{name:r}})),M({tagName:"div",children:a,properties:{"data-separator":a.length===0?"simple":t,"data-expand-index":n,"data-separator-first":s?"":void 0,"data-separator-last":o?"":void 0}})}function zy(t,e){return`hunk-separator-${t}-${e}`}function Uy(t){const e=t.at(-1);return e==null?0:Math.max(oe(e.additionStart,e.additionCount),oe(e.deletionStart,e.deletionCount))}function qi({line:t,spanStart:e,spanLength:n}){return{start:{line:t,character:e},end:{line:t,character:e+n},properties:{"data-diff-span":""},alwaysWrap:!0}}function ci({item:t,arr:e,enableJoin:n,isNeutral:i=!1,isLastItem:r=!1}){const s=e[e.length-1];if(s==null||r||!n){e.push([i?0:1,t.value]);return}const o=s[0]===0;if(i===o||i&&t.value.length===1&&!o){s[1]+=t.value;return}e.push([i?0:1,t.value])}function Vn(t){return[we(t.additionStart,t.additionCount)+1,oe(t.additionStart,t.additionCount)+1]}function dt({isPartial:t,rangeSize:e,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}){const s=Math.max(e,0);if(s===0||t)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==null?void 0:n.get(i),l=Math.min(Math.max((o==null?void 0:o.fromStart)??0,0),s),a=Math.min(Math.max((o==null?void 0:o.fromEnd)??0,0),s),d=l+a,c=d>=s;return{fromStart:c?s:l,fromEnd:c?0:a,rangeSize:s,collapsedLines:Math.max(s-d,0),renderAll:c}}function By(t){const e=t.hunks[t.hunks.length-1];if(e==null||t.isPartial||t.additionLines.length===0||t.deletionLines.length===0)return!1;const n=t.additionLines.length-oe(e.additionStart,e.additionCount),i=t.deletionLines.length-oe(e.deletionStart,e.deletionCount);return n<=0&&i<=0?!1:n!==i}function vc({fileDiff:t,errorPrefix:e}){const n=t.hunks[t.hunks.length-1];if(n==null||t.isPartial||t.additionLines.length===0||t.deletionLines.length===0)return 0;const i=t.additionLines.length-oe(n.additionStart,n.additionCount),r=t.deletionLines.length-oe(n.deletionStart,n.deletionCount);if(i<=0&&r<=0)return 0;if(i!==r)throw new Error(`${e}: trailing context mismatch (additions=${i}, deletions=${r}) for ${t.name}`);return Math.min(i,r)}function ct({fileDiff:t,hunkIndex:e,expandedHunks:n,collapsedContextThreshold:i,errorPrefix:r}){if(e!==t.hunks.length-1)return;const s=vc({fileDiff:t,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==null?void 0:n.get(t.hunks.length),l=Math.min(Math.max((o==null?void 0:o.fromStart)??0,0),s);return{fromStart:l,fromEnd:0,rangeSize:s,collapsedLines:s-l,renderAll:l>=s}}function Cc({fileDiff:t,lineNumber:e,expandedHunks:n,collapsedContextThreshold:i}){if(n===!0||t.isPartial)return!0;for(const[l,a]of t.hunks.entries()){const[d,c]=Vn(a);if(e<d){const u=dt({isPartial:t.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:l,collapsedContextThreshold:i}),h=d-u.rangeSize;return u.renderAll||e<h+u.fromStart||e>=d-u.fromEnd}if(e<c)return!0}const r=ct({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:n,collapsedContextThreshold:i,errorPrefix:"isAdditionLineRenderable"});if(r==null||r.renderAll)return!0;const s=t.hunks[t.hunks.length-1],[,o]=Vn(s);return e<o+r.fromStart||e>=o+r.rangeSize}function Vy({fileDiff:t,lineNumber:e,direction:n,expandedHunks:i,collapsedContextThreshold:r}){if(i===!0||t.isPartial)return e;const s=[];let o=1;for(const[a,d]of t.hunks.entries()){const[c,u]=Vn(d),h=dt({isPartial:t.isPartial,rangeSize:d.collapsedBefore,expandedHunks:i,hunkIndex:a,collapsedContextThreshold:r}),f=c-h.rangeSize;h.renderAll?s.push([f,c]):(h.fromStart>0&&s.push([f,f+h.fromStart]),h.fromEnd>0&&s.push([c-h.fromEnd,c])),s.push([c,u]),o=u}const l=ct({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:i,collapsedContextThreshold:r,errorPrefix:"getNearestRenderableAdditionLine"});if(l!=null){const a=o;o=a+l.rangeSize,l.renderAll?s.push([a,o]):l.fromStart>0&&s.push([a,a+l.fromStart])}if(e>=o)return e;if(n==="down"){for(const[a,d]of s)if(d>e)return Math.max(a,e);return}for(let a=s.length-1;a>=0;a--){const[d,c]=s[a];if(d<=e)return Math.min(c-1,e)}}function Sc({type:t,metrics:e}){return e.hunkSeparatorHeight??U0(t)}function bc({type:t,metrics:e}){return t==="simple"||t==="metadata"||t==="line-info-basic"?0:e.spacing}function Gy({type:t,hunkIndex:e,hunkSpecs:n}){switch(t){case"simple":return e>0;case"metadata":return n!=null;case"line-info":case"line-info-basic":case"custom":return!0}}function Wy(t){return t!=="simple"&&t!=="metadata"}function Ln({type:t,metrics:e,hunkIndex:n,hunkSpecs:i}){if(!Gy({type:t,hunkIndex:n,hunkSpecs:i}))return;const r=Sc({type:t,metrics:e}),s=bc({type:t,metrics:e}),o=n>0?s:0,l=s;return{height:r,gapBefore:o,gapAfter:l,totalHeight:o+r+l}}function Rt({type:t,metrics:e}){if(!Wy(t))return;const n=Sc({type:t,metrics:e}),i=bc({type:t,metrics:e});return{height:n,gapBefore:i,gapAfter:0,totalHeight:i+n}}function Dt({diff:t,diffStyle:e,startingLine:n=0,totalLines:i=1/0,expandedHunks:r,collapsedContextThreshold:s=1,callback:o}){var d;const l=jy({diff:t,diffStyle:e,startingLine:n,expandedHunks:r,collapsedContextThreshold:s}),a={viewportStart:n,viewportEnd:n+i,isWindowedHighlight:n>0||i<1/0,splitCount:l.splitCount,unifiedCount:l.unifiedCount,finalHunkIndex:t.hunks.length-1,shouldBreak(){if(!a.isWindowedHighlight)return!1;const c=a.unifiedCount>=n+i,u=a.splitCount>=n+i;return e==="unified"?c:(e==="split"||c)&&u},shouldSkip(c,u){if(!a.isWindowedHighlight)return!1;const h=c>0&&a.unifiedCount+c<=n,f=u>0&&a.splitCount+u<=n;return e==="unified"?h:(e==="split"||h)&&f},incrementCounts(c,u){(e==="unified"||e==="both")&&(a.unifiedCount+=c),(e==="split"||e==="both")&&(a.splitCount+=u)},isInWindow(c,u){if(!a.isWindowedHighlight)return!0;const h=a.isInUnifiedWindow(c),f=a.isInSplitWindow(u);return e==="unified"?h:e==="split"?f:h||f},isInUnifiedWindow(c){return!a.isWindowedHighlight||a.unifiedCount>=n-c&&a.unifiedCount<n+i},isInSplitWindow(c){return!a.isWindowedHighlight||a.splitCount>=n-c&&a.splitCount<n+i},emit(c,u=!1){return u||(e==="unified"?a.incrementCounts(1,0):e==="split"?a.incrementCounts(0,1):a.incrementCounts(1,1)),o(c)??!1}};e:for(let c=l.hunkIndex;c<t.hunks.length;c++){let S=function(_,H){return m==null||m.collapsedLines<=0||m.fromStart+m.fromEnd>0?0:e==="unified"?_===u.unifiedLineStart+u.unifiedLineCount-1?m.collapsedLines:0:H===u.splitLineStart+u.splitLineCount-1?m.collapsedLines:0},b=function(){return w?0:(w=!0,v.collapsedLines)};const u=t.hunks[c];if(u==null)throw new Error("iterateOverDiff: invalid hunk index");if(a.shouldBreak())break;const h=we(u.deletionStart,u.deletionCount),f=we(u.additionStart,u.additionCount),p=!t.isPartial&&u.deletionCount===0?h:u.deletionLineIndex,y=!t.isPartial&&u.additionCount===0?f:u.additionLineIndex,v=dt({isPartial:t.isPartial,rangeSize:u.collapsedBefore,expandedHunks:r,hunkIndex:c,collapsedContextThreshold:s}),m=c===a.finalHunkIndex?ct({fileDiff:t,hunkIndex:c,expandedHunks:r,collapsedContextThreshold:s,errorPrefix:"iterateOverDiff"}):void 0,C=v.fromStart+v.fromEnd;let w=v.collapsedLines===0;if(a.shouldSkip(C,C))a.incrementCounts(C,C),b();else{let _=u.unifiedLineStart-v.rangeSize,H=u.splitLineStart-v.rangeSize,U=p-v.rangeSize,V=y-v.rangeSize,P=h+1-v.rangeSize,N=f+1-v.rangeSize;if(ui(a,v.fromStart,e,B=>a.emit({hunkIndex:c,hunk:u,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:P+B,lineIndex:U+B,noEOFCR:!1,unifiedLineIndex:_+B,splitLineIndex:H+B},additionLine:{unifiedLineIndex:_+B,splitLineIndex:H+B,lineIndex:V+B,lineNumber:N+B,noEOFCR:!1}}))||(_=u.unifiedLineStart-v.fromEnd,H=u.splitLineStart-v.fromEnd,U=p-v.fromEnd,V=y-v.fromEnd,P=h+1-v.fromEnd,N=f+1-v.fromEnd,ui(a,v.fromEnd,e,B=>a.emit({hunkIndex:c,hunk:u,collapsedBefore:b(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:P+B,lineIndex:U+B,noEOFCR:!1,unifiedLineIndex:_+B,splitLineIndex:H+B},additionLine:{unifiedLineIndex:_+B,splitLineIndex:H+B,lineIndex:V+B,lineNumber:N+B,noEOFCR:!1}}),()=>{b()})))break e}let k=u.unifiedLineStart,x=u.splitLineStart,E=p,R=y,A=h+1,D=f+1;const I=u.hunkContent.at(-1);for(const _ of u.hunkContent){if(a.shouldBreak())break e;const H=_===I;if(_.type==="context"){if(a.shouldSkip(_.lines,_.lines))a.incrementCounts(_.lines,_.lines),b();else if(ui(a,_.lines,e,U=>{const V=H&&U===_.lines-1,P=k+U,N=x+U;return a.emit({hunkIndex:c,hunk:u,collapsedBefore:b(),collapsedAfter:S(P,N),type:"context",deletionLine:{lineNumber:A+U,lineIndex:E+U,noEOFCR:V&&u.noEOFCRDeletions,unifiedLineIndex:P,splitLineIndex:N},additionLine:{unifiedLineIndex:P,splitLineIndex:N,lineIndex:R+U,lineNumber:D+U,noEOFCR:V&&u.noEOFCRAdditions}})},()=>{b()}))break e;k+=_.lines,x+=_.lines,E+=_.lines,R+=_.lines,A+=_.lines,D+=_.lines}else{const U=Math.max(_.deletions,_.additions),V=_.deletions+_.additions;if(!a.shouldSkip(V,U)){const P=Xy(a,_,e);(((d=P[0])==null?void 0:d[0])??0)>0&&b();for(const[N,B]of P)for(let ae=N;ae<B;ae++){const F=S(k+ae,e==="unified"?x+(ae<_.deletions?ae:ae-_.deletions):x+ae);if(a.emit(Yy({hunkIndex:c,hunk:u,collapsedBefore:b(),collapsedAfter:F,diffStyle:e,index:ae,unifiedLineIndex:k,splitLineIndex:x,additionLineIndex:R,deletionLineIndex:E,additionLineNumber:D,deletionLineNumber:A,content:_,isLastContent:H,unifiedCount:V,splitCount:U}),!0))break e}}b(),a.incrementCounts(V,U),k+=V,x+=U,E+=_.deletions,R+=_.additions,A+=_.deletions,D+=_.additions}}if(m!=null){const{collapsedLines:_,fromStart:H,fromEnd:U}=m,V=H+U;if(ui(a,V,e,P=>{const N=P===V-1;return a.emit({hunkIndex:t.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:N?_:0,type:"context-expanded",deletionLine:{lineNumber:A+P,lineIndex:E+P,noEOFCR:!1,unifiedLineIndex:k+P,splitLineIndex:x+P},additionLine:{unifiedLineIndex:k+P,splitLineIndex:x+P,lineIndex:R+P,lineNumber:D+P,noEOFCR:!1}})},void 0,()=>a.shouldBreak()))break e}}}function jy({diff:t,diffStyle:e,startingLine:n,expandedHunks:i,collapsedContextThreshold:r}){if(n<=0||e==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};const s=qy({diff:t,expandedHunks:i,collapsedContextThreshold:r});let o=0,l=t.hunks.length-1,a=t.hunks.length;for(;o<=l;){const c=o+l>>1,u=s[c+1];if(u==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(e==="unified"?u.unifiedCount:u.splitCount)>n?(a=c,l=c-1):o=c+1}if(a>=t.hunks.length){const c=s[t.hunks.length];if(c==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:t.hunks.length,splitCount:c.splitCount,unifiedCount:c.unifiedCount}}const d=s[a];if(d==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:a,splitCount:d.splitCount,unifiedCount:d.unifiedCount}}function qy({diff:t,expandedHunks:e,collapsedContextThreshold:n}){let i=0,r=0;const s=t.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let l=0;l<t.hunks.length;l++){const a=t.hunks[l];if(a==null)throw new Error("iterateOverDiff: invalid hunk summary index");const d=dt({isPartial:t.isPartial,rangeSize:a.collapsedBefore,expandedHunks:e,hunkIndex:l,collapsedContextThreshold:n}),c=d.fromStart+d.fromEnd;i+=c+a.splitLineCount,r+=c+a.unifiedLineCount;const u=l===s?ct({fileDiff:t,hunkIndex:l,expandedHunks:e,collapsedContextThreshold:n,errorPrefix:"iterateOverDiff"}):void 0;if(u!=null){const h=u.fromStart+u.fromEnd;i+=h,r+=h}o.push({splitCount:i,unifiedCount:r})}return o}function Ky(t,e,n){if(!t.isWindowedHighlight||e<=0)return[0,e];const i=[];function r(l){const a=Math.max(0,t.viewportStart-l),d=Math.min(e,t.viewportEnd-l);d>a&&i.push([a,d])}if(n!=="split"&&r(t.unifiedCount),n!=="unified"&&r(t.splitCount),i.length===0)return[0,0];let s=i[0][0],o=i[0][1];for(let l=1;l<i.length;l++){const a=i[l];s=Math.min(s,a[0]),o=Math.max(o,a[1])}return[s,o]}function ui(t,e,n,i,r,s){const[o,l]=Ky(t,e,n);o>0&&(t.incrementCounts(o,o),r==null||r());let a=o;for(;a<e;){if((s==null?void 0:s())===!0)return!0;if(a>=l){t.incrementCounts(e-a,e-a);break}if(t.isInWindow(0,0)){if(i(a)===!0)return!0}else t.incrementCounts(1,1);a++}return!1}function Xy(t,e,n){if(!t.isWindowedHighlight)return[[0,n==="unified"?e.deletions+e.additions:Math.max(e.deletions,e.additions)]];const i=n!=="split",r=n!=="unified",s=n==="unified"?"unified":"split",o=[];function l(u,h){if(u+h<=t.viewportStart||u>=t.viewportEnd)return;const f=Math.max(0,t.viewportStart-u),p=Math.min(h,t.viewportEnd-u);return p>f?[f,p]:void 0}function a(u,h){return s==="split"?u:h==="additions"?[u[0]+e.deletions,u[1]+e.deletions]:u}function d(u,h){if(u==null)return;const[f,p]=a(u,h);p>f&&o.push([f,p])}if(i&&(d(l(t.unifiedCount,e.deletions),"deletions"),d(l(t.unifiedCount+e.deletions,e.additions),"additions")),r&&(d(l(t.splitCount,e.deletions),"deletions"),d(l(t.splitCount,e.additions),"additions")),o.length===0)return o;o.sort((u,h)=>u[0]-h[0]);const c=[o[0]];for(const[u,h]of o.slice(1)){const f=c[c.length-1];u<=f[1]?f[1]=Math.max(f[1],h):c.push([u,h])}return c}function Yy({hunkIndex:t,hunk:e,collapsedAfter:n,collapsedBefore:i,diffStyle:r,index:s,unifiedLineIndex:o,splitLineIndex:l,additionLineIndex:a,deletionLineIndex:d,additionLineNumber:c,deletionLineNumber:u,content:h,isLastContent:f,unifiedCount:p,splitCount:y}){const v=s<h.deletions?o+s:void 0,m=r==="unified"?s>=h.deletions?o+s:void 0:s<h.additions?o+h.deletions+s:void 0,C=r==="unified"?l+(s<h.deletions?s:s-h.deletions):l+s,S=s<h.deletions?d+s:void 0,w=s<h.deletions?u+s:void 0,b=r==="unified"?s>=h.deletions?a+(s-h.deletions):void 0:s<h.additions?a+s:void 0,k=r==="unified"?s>=h.deletions?c+(s-h.deletions):void 0:s<h.additions?c+s:void 0,x=r==="unified"?f&&s===h.deletions-1&&e.noEOFCRDeletions:f&&s===y-1&&e.noEOFCRDeletions,E=r==="unified"?f&&s===p-1&&e.noEOFCRAdditions:f&&s===y-1&&e.noEOFCRAdditions,R=S!=null&&w!=null&&v!=null?{lineNumber:w,lineIndex:S,noEOFCR:x,unifiedLineIndex:v,splitLineIndex:C}:void 0,A=b!=null&&k!=null&&m!=null?{unifiedLineIndex:m,splitLineIndex:C,lineIndex:b,lineNumber:k,noEOFCR:E}:void 0;if(R==null&&A!=null)return{type:"change",hunkIndex:t,hunk:e,collapsedAfter:n,collapsedBefore:i,deletionLine:void 0,additionLine:A};if(R!=null&&A==null)return{type:"change",hunkIndex:t,hunk:e,collapsedAfter:n,collapsedBefore:i,deletionLine:R,additionLine:void 0};if(R==null||A==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:t,hunk:e,collapsedAfter:n,collapsedBefore:i,deletionLine:R,additionLine:A}}const Qy={forcePlainText:!1};function Zy(t,e,n,{forcePlainText:i,startingLine:r,totalLines:s,expandedHunks:o,collapsedContextThreshold:l=1}=Qy){i?(r??(r=0),s??(s=1/0)):(r=0,s=1/0);const a=r>0||s<1/0,d=typeof n.theme=="string"?e.getTheme(n.theme).type:void 0,c=Ws({theme:n.theme,highlighter:e}),u=i&&!a&&(t.unifiedLineCount>1e3||t.splitLineCount>1e3)?"none":n.lineDiffType,h={deletionLines:[],additionLines:[]},{maxLineDiffLength:f}=n,p=!i&&!t.isPartial,y=i?o:void 0,v=new Map;function m(S){const w=p?0:S,b=v.get(w)??tv();return v.set(w,b),b}function C(S,w,b,k){if(a){let x=b.at(-1);(x==null||x.targetIndex+x.count!==w)&&(x={targetIndex:w,originalOffset:k.length,count:0},b.push(x)),x.count++}k.push(S)}Dt({diff:t,diffStyle:"both",startingLine:r,totalLines:s,expandedHunks:a?y:!0,collapsedContextThreshold:l,callback:({hunkIndex:S,additionLine:w,deletionLine:b,type:k})=>{const x=m(S),E=w!=null?w.splitLineIndex:b.splitLineIndex;k==="change"&&w!=null&&b!=null&&ev({additionLine:t.additionLines[w.lineIndex],deletionLine:t.deletionLines[b.lineIndex],deletionLineIndex:x.deletionContent.length,additionLineIndex:x.additionContent.length,deletionDecorations:x.deletionDecorations,additionDecorations:x.additionDecorations,lineDiffType:u,maxLineDiffLength:f}),b!=null&&(C(t.deletionLines[b.lineIndex],b.lineIndex,x.deletionSegments,x.deletionContent),x.deletionInfo.push({type:k==="change"?"change-deletion":k,lineNumber:b.lineNumber,altLineNumber:k==="change"?void 0:w.lineNumber??void 0,lineIndex:`${b.unifiedLineIndex},${E}`})),w!=null&&(C(t.additionLines[w.lineIndex],w.lineIndex,x.additionSegments,x.additionContent),x.additionInfo.push({type:k==="change"?"change-addition":k,lineNumber:w.lineNumber,altLineNumber:k==="change"?void 0:b.lineNumber??void 0,lineIndex:`${w.unifiedLineIndex},${E}`}))}});for(const S of v.values()){if(S.deletionContent.length===0&&S.additionContent.length===0)continue;const w={name:t.prevName??t.name,contents:S.deletionContent.value},b={name:t.name,contents:S.additionContent.value},{deletionLines:k,additionLines:x}=nv({deletionFile:w,deletionInfo:S.deletionInfo,deletionDecorations:S.deletionDecorations,additionFile:b,additionInfo:S.additionInfo,additionDecorations:S.additionDecorations,highlighter:e,options:n,languageOverride:i?"text":t.lang});if(p){h.deletionLines=k,h.additionLines=x;continue}if(S.deletionSegments.length>0)for(const E of S.deletionSegments)for(let R=0;R<E.count;R++)h.deletionLines[E.targetIndex+R]=k[E.originalOffset+R];else rn(h.deletionLines,k);if(S.additionSegments.length>0)for(const E of S.additionSegments)for(let R=0;R<E.count;R++)h.additionLines[E.targetIndex+R]=x[E.originalOffset+R];else rn(h.additionLines,x)}return{code:h,themeStyles:c,baseThemeType:d}}function Jy(t,{deletionLineIndex:e,additionLineIndex:n,deletionDecorations:i,additionDecorations:r}){let s=0,o=0,l=-1,a=0,d=-1,c=0;for(const{value:u,added:h,removed:f}of t)f?(l===-1&&(l=s),s+=u.length,a=s):h?(d===-1&&(d=o),o+=u.length,c=o):(s+=u.length,o+=u.length);l!==-1&&i.push(qi({line:e,spanStart:l,spanLength:a-l})),d!==-1&&r.push(qi({line:n,spanStart:d,spanLength:c-d}))}function ev({deletionLine:t,additionLine:e,deletionLineIndex:n,additionLineIndex:i,deletionDecorations:r,additionDecorations:s,lineDiffType:o,maxLineDiffLength:l}){if(t==null||e==null||o==="none"||(t=Qe(t),e=Qe(e),t.length>l||e.length>l))return;const a=o==="char"?_y(t,e):Ay(t,e);if(o==="word-line"){Jy(a,{deletionLineIndex:n,additionLineIndex:i,deletionDecorations:r,additionDecorations:s});return}const d=[],c=[],u=o==="word-alt",h=a.at(-1);for(const p of a){const y=p===h;!p.added&&!p.removed?(ci({item:p,arr:d,enableJoin:u,isNeutral:!0,isLastItem:y}),ci({item:p,arr:c,enableJoin:u,isNeutral:!0,isLastItem:y})):p.removed?ci({item:p,arr:d,enableJoin:u,isLastItem:y}):ci({item:p,arr:c,enableJoin:u,isLastItem:y})}let f=0;for(const p of d)p[0]===1&&r.push(qi({line:n,spanStart:f,spanLength:p[1].length})),f+=p[1].length;f=0;for(const p of c)p[0]===1&&s.push(qi({line:i,spanStart:f,spanLength:p[1].length})),f+=p[1].length}function tv(){return{deletionContent:{push(t){this.value+=t,this.length++},value:"",length:0},additionContent:{push(t){this.value+=t,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function nv({deletionFile:t,additionFile:e,deletionInfo:n,additionInfo:i,highlighter:r,deletionDecorations:s,additionDecorations:o,languageOverride:l,options:{theme:a,...d}}){const c=l??be(t.name),u=l??be(e.name),{state:h,transformers:f}=Wd(d.useTokenTransformer),p=typeof a=="string"?{...d,lang:"text",theme:a,transformers:f,decorations:void 0,defaultColor:!1,cssVariablePrefix:he("token"),tokenizeTimeLimit:0}:{...d,lang:"text",themes:a,transformers:f,decorations:void 0,defaultColor:!1,cssVariablePrefix:he("token"),tokenizeTimeLimit:0};return{deletionLines:t.contents===""?[]:(p.lang=c,h.lineInfo=n,p.decorations=s,cs(r.codeToHast(Qe(t.contents),p))),additionLines:e.contents===""?[]:(p.lang=u,p.decorations=o,h.lineInfo=i,cs(r.codeToHast(Qe(e.contents),p)))}}function it(t,e){const n=Nt({name:t.prevName??t.name,contents:t.deletionLines.join("")},{name:t.name,contents:t.additionLines.join(""),lang:t.lang},e);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,type:n.type}}function iv(t,e){const n=Math.max(t,1);let i=Array.from({length:n},(r,s)=>`${" ".repeat(s+1)}
312
+ `).join("");return i===e&&(i=Array.from({length:n},(r,s)=>`\0${" ".repeat(s)}
313
+ `).join("")),i}function rv(t){for(const e of t)if(e.trim().length>0)return!1;return!0}function ys(t,e){return e.length>0&&e.length<t.deletionLines.length&&rv(e)}function Ki(t,e,n){const i=t.deletionLines.join(""),r=iv(e.length,i),s=Nt({name:t.prevName??t.name,contents:i},{name:t.name,contents:r,lang:t.lang},n);return{hunks:s.hunks,splitLineCount:s.splitLineCount,unifiedLineCount:s.unifiedLineCount,additionLines:e,deletionLines:s.deletionLines,type:s.type}}function Li(t,e){return Ki(t,[""],e)}function wc(t,e){if(t.additionLines.length===0)return Li(t,e);if(ys(t,t.additionLines))return Ki(t,t.additionLines,e);const n=t.additionLines,i=it(t,e);return xc(i,n),i}function sv(t){return t.length>1&&t.at(-1)===""}function xc(t,e){if(!sv(e))return;const n=e.length-t.additionLines.length;if(n<=0)return;const i=t.additionLines.length,r=t.hunks.at(-1);if(r!=null&&oe(r.additionStart,r.additionCount)===i){for(const s of r.hunkContent)if(s.type==="change"&&s.additions<s.deletions&&s.additionLineIndex+s.additions===i){t.additionLines=e,s.additions+=n,r.additionCount+=n,r.additionLines+=n,ar(t);return}}}function ov(t,e,n){if(t.isPartial||t.deletionLines.length!==t.additionLines.length)return nt(t,it(t,n));const i=Array.from(e);if(i.length===0)return nt(t,{hunks:t.hunks,splitLineCount:t.splitLineCount,unifiedLineCount:t.unifiedLineCount,type:t.type});for(const s of i){const o=t.additionLines[s],l=t.deletionLines[s];if(o==null||l==null||Qe(o)===Qe(l))return nt(t,it(t,n))}const r=av(t,i);if(r.size===0)return nt(t,it(t,n));for(const s of r)if(!dv(t,s,n))return nt(t,it(t,n));return ar(t),By(t)?nt(t,it(t,n)):nt(t,{hunks:t.hunks,splitLineCount:t.splitLineCount,unifiedLineCount:t.unifiedLineCount,type:t.type})}function nt(t,e){return Object.assign(t,e),e}function av(t,e){const n=new Set;for(const i of e){const r=lv(t,i);if(r==null)return new Set;n.add(r)}return n}function lv(t,e){for(const[n,i]of t.hunks.entries()){const r=i.additionLineIndex+i.additionCount;if(e>=i.additionLineIndex&&e<r)return n}}function dv(t,e,n){const i=t.hunks[e];if(i==null)return!1;const r=t.deletionLines.slice(i.deletionLineIndex,i.deletionLineIndex+i.deletionCount),s=t.additionLines.slice(i.additionLineIndex,i.additionLineIndex+i.additionCount),o=Nt({name:t.prevName??t.name,contents:r.join("")},{name:t.name,contents:s.join(""),lang:t.lang},{...n,context:0}),l=o.hunks[0];return l==null||o.hunks.length!==1?!1:(cv(i,l),kc(t,e),!0)}function kc(t,e){const n=t.hunks[e];if(n==null)return;if(e!==t.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}const i=t.additionLines.at(-1),r=t.deletionLines.at(-1);n.noEOFCRAdditions=i!=null&&i!==""&&!i.endsWith(`
314
+ `),n.noEOFCRDeletions=r!=null&&r!==""&&!r.endsWith(`
315
+ `)}function cv(t,e){const n=t.additionLineIndex,i=t.deletionLineIndex;t.hunkContent=e.hunkContent.map(r=>Lc(r,n,i)),t.additionLineIndex=n+e.additionLineIndex,t.additionStart=t.additionStart+e.additionLineIndex,t.additionCount=e.additionCount,t.additionLines=e.additionLines,e.deletionLineIndex>=0&&(t.deletionLineIndex=i+e.deletionLineIndex,t.deletionStart=t.deletionStart+e.deletionLineIndex),t.deletionCount=e.deletionCount,t.deletionLines=e.deletionLines,t.noEOFCRAdditions=e.noEOFCRAdditions,t.noEOFCRDeletions=e.noEOFCRDeletions,no(t)}function Lc(t,e,n){return{...t,additionLineIndex:t.additionLineIndex+e,deletionLineIndex:t.deletionLineIndex+n}}function no(t){let e=0,n=0;for(const i of t.hunkContent)i.type==="context"?(e+=i.lines,n+=i.lines):(e+=Math.max(i.additions,i.deletions),n+=i.additions+i.deletions);t.splitLineCount=e,t.unifiedLineCount=n}function ar(t){let e=0,n=0,i=0;for(const r of t.hunks)r.collapsedBefore=Math.max(we(r.additionStart,r.additionCount)-i,0),r.splitLineStart=e+r.collapsedBefore,r.unifiedLineStart=n+r.collapsedBefore,no(r),e+=r.collapsedBefore+r.splitLineCount,n+=r.collapsedBefore+r.unifiedLineCount,i=oe(r.additionStart,r.additionCount);if(t.hunks.length>0){const r=t.hunks[t.hunks.length-1],s=Math.max(t.additionLines.length-oe(r.additionStart,r.additionCount),0);e+=s,n+=s}t.splitLineCount=e,t.unifiedLineCount=n}const xa=new WeakMap;function uv(t){return t.length>1&&t[t.length-1]===""?t.slice(0,-1):t}function hv(t,e){const n=Math.min(t.length,e.length);let i=0;for(;i<n&&t[i]===e[i];)i++;let r=t.length,s=e.length;for(;r>i&&s>i&&t[r-1]===e[s-1];)r--,s--;if(!(i===r&&i===s))return{start:i,deletionEnd:r,additionEnd:s}}function vs(t,e,n){const i=t.hunks,r=t.additionLines,s=uv(r),o=s===r?t:{...t,additionLines:s},l=wv(i,Sv(o,e,n),t.deletionLines.length),a=Lv(o,l);if(t.additionLines=s,t.hunks=a,t.editSessionDirty=!0,Tv(t),xc(t,r),!!Rv(i,t.hunks))return{regions:l.map(d=>d.previousSpan)}}function fv(t,e,n,i){const r=new Set(e),s=Array.from(r).filter(c=>c>=0&&c<t.additionLines.length).sort((c,u)=>c-u);if(s.length===0)return;const o=c=>r.has(c)?i==null?void 0:i.get(c):t.additionLines[c],{hunks:l}=t;let a,d=0;for(const c of s){for(;d<l.length;){const f=l[d];if(c<Xi(f)+f.additionCount)break;d++}const u=l[d],h=u==null?void 0:Xi(u);if(h==null||c<h||a!=null&&a!==d)return vs(t,n,o);a=d}if(a!=null){if(pv(t,s,a,i,n)){t.editSessionDirty=!0;return}return vs(t,n,o)}}function pv(t,e,n,i,r){if(i==null||(r==null?void 0:r.ignoreWhitespace)===!0||(r==null?void 0:r.stripTrailingCr)===!0)return!1;const s=gv(t),o=t.hunks[n];if(o.hunkContent.some(mv))return!1;for(const l of e){const a=i.get(l),d=t.additionLines[l];if(a==null||d==null||s.has(a)||s.has(d))return!1;let c=!1;for(const u of o.hunkContent)if(u.type==="change"&&u.additions===u.deletions&&l>=u.additionLineIndex&&l<u.additionLineIndex+u.additions){c=!0;break}if(!c)return!1}return!0}function gv(t){const e=xa.get(t);if((e==null?void 0:e.lines)===t.deletionLines)return e.set;const n=new Set(t.deletionLines);return xa.set(t,{lines:t.deletionLines,set:n}),n}function mv(t){return(t==null?void 0:t.type)==="change"&&(t.additions===0||t.deletions===0)}function yv(t,e){const n=new Map,{regions:i}=e;for(let r=0;r<=i.length;r++){const s=i[r-1],o=i[r],l=r===0?t.get(0):s==null?void 0:t.get(s.lastIndex+1),a=o==null?void 0:t.get(o.firstIndex),d=(l==null?void 0:l.fromStart)??0,c=(a==null?void 0:a.fromEnd)??0;(d>0||c>0)&&n.set(r,{fromStart:d,fromEnd:c})}return n}function vv(t,e,n){const i=[];if(t.isPartial)return i;for(const[s,o]of t.hunks.entries()){const l=dt({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:e,hunkIndex:s,collapsedContextThreshold:n});if(l.rangeSize<=n)continue;const a=Ft(o),d=a-l.rangeSize;l.fromStart>0&&i.push([d,d+l.fromStart]),l.fromEnd>0&&i.push([a-l.fromEnd,a])}const r=ct({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:e,collapsedContextThreshold:n,errorPrefix:"captureExpansionAnchors"});if(r!=null&&r.fromStart>0&&r.rangeSize>n){const s=t.hunks[t.hunks.length-1],o=Ft(s)+s.deletionCount;i.push([o,o+r.fromStart])}return i}function Cv(t,e){const n=new Map;if(e.length===0)return n;const i=(s,o,l)=>{if(l<=o)return;let a=0,d=0;for(const[c,u]of e)u<=o||c>=l||(c<=o&&(a=Math.max(a,Math.min(u,l)-o)),u>=l&&(d=Math.max(d,l-Math.max(c,o))));(a>0||d>0)&&n.set(s,{fromStart:a,fromEnd:d})};for(const[s,o]of t.hunks.entries()){const l=Ft(o);i(s,l-Math.max(o.collapsedBefore,0),l)}const r=t.hunks[t.hunks.length-1];return r!=null&&!t.isPartial&&t.deletionLines.length>0&&i(t.hunks.length,Ft(r)+r.deletionCount,t.deletionLines.length),n}function ka(t,e){return t.editSessionDirty!==!0?!1:(delete t.editSessionDirty,Object.assign(t,t.additionLines.length<=1&&t.additionLines.join("")===""?it(t,e):wc(t,e)),!0)}function Sv(t,e,n){if(hv(t.deletionLines,t.additionLines)==null)return[];const i=Nt({name:t.prevName??t.name,contents:t.deletionLines.join("")},{name:t.name,contents:t.additionLines.join(""),lang:t.lang},e);let r;const s=(d,c)=>{r??(r=bv(t.hunks));for(let u=0;u<=c;u++){const h=r.get(d.deletionLineIndex-u);if(!(h==null||h.additions!==d.additions||h.deletions!==d.deletions)){if(d.additions>0&&n!=null){for(let f=0;f<d.additions;f++)if(n(h.additionLineIndex+f)!==i.additionLines[d.additionLineIndex+f])return c}return u}}return c},o=[];let l=0,a=0;for(const d of i.hunks){cy(d,i,s);const c=d.additionCount>0?d.additionLineIndex-l:d.deletionLineIndex-a;l+=c,a+=c;for(const u of d.hunkContent){if(u.type==="context"){l+=u.lines,a+=u.lines;continue}const h=Lc(u,0,0);h.additions===0&&(h.additionLineIndex=l),h.deletions===0&&(h.deletionLineIndex=a),o.push(h),l+=h.additions,a+=h.deletions}}return o}function bv(t){const e=new Map;for(const n of t)for(const i of n.hunkContent)i.type==="change"&&(i.additions===0||i.deletions===0)&&e.set(i.deletionLineIndex,i);return e}function wv(t,e,n){var o,l;const i=t.map((a,d)=>{const c=Ft(a);return{deletionStart:c,deletionEnd:c+a.deletionCount,blocks:[],previousSpan:{firstIndex:d,lastIndex:d}}}),r=[];let s=0;for(const a of e){const d=a.deletionLineIndex,c=d+a.deletions;for(;s<i.length&&i[s].deletionEnd<d;)r.push(i[s]),s++;let u=r.length>0&&xv(d,c,r[r.length-1])?r.pop():void 0;for(;s<i.length&&i[s].deletionStart<=c;)u=kv(u,i[s]),s++;if(u==null){let h=d,f=c;if((a.deletions===0||a.additions===0)&&n>a.deletions){const p=((o=r[r.length-1])==null?void 0:o.deletionEnd)??0,y=((l=i[s])==null?void 0:l.deletionStart)??n;d>p?h--:c<y&&f++}u={deletionStart:h,deletionEnd:f,blocks:[],previousSpan:void 0}}u.deletionStart=Math.min(u.deletionStart,d),u.deletionEnd=Math.max(u.deletionEnd,c),u.blocks.push(a),r.push(u)}for(;s<i.length;)r.push(i[s]),s++;return r}function xv(t,e,n){return t<=n.deletionEnd&&e>=n.deletionStart}function kv(t,e){return t==null?e:(t.deletionStart=Math.min(t.deletionStart,e.deletionStart),t.deletionEnd=Math.max(t.deletionEnd,e.deletionEnd),t.blocks.push(...e.blocks),e.previousSpan!=null&&(t.previousSpan??(t.previousSpan={...e.previousSpan}),t.previousSpan.firstIndex=Math.min(t.previousSpan.firstIndex,e.previousSpan.firstIndex),t.previousSpan.lastIndex=Math.max(t.previousSpan.lastIndex,e.previousSpan.lastIndex)),t)}function Lv(t,e){const n=[];let i=0,r=0;for(const s of e){const o=s.deletionStart-i;if(o<0)throw new Error("buildRegionHunks: overlapping old-side regions");i+=o,r+=o;const l=r,a=[];for(const c of s.blocks){const u=c.deletionLineIndex-i,h=c.additionLineIndex-r;if(u<0||u!==h)throw new Error("buildRegionHunks: canonical block context mismatch");La(a,u,r,i),i+=u,r+=h,a.push({...c}),i+=c.deletions,r+=c.additions}const d=s.deletionEnd-i;if(d<0)throw new Error("buildRegionHunks: block exceeds its old-side region");La(a,d,r,i),i+=d,r+=d,n.push(Ev(t,{additionStart:l,additionEnd:r,deletionStart:s.deletionStart,deletionEnd:s.deletionEnd},a))}if(t.deletionLines.length-i!==t.additionLines.length-r)throw new Error("buildRegionHunks: trailing context mismatch");return n}function Ev(t,e,n){const i=e.additionEnd-e.additionStart,r=e.deletionEnd-e.deletionStart;let s=0,o=0;for(const a of n)a.type==="change"&&(s+=a.additions,o+=a.deletions);const l={collapsedBefore:0,additionStart:hi(e.additionStart,i),additionCount:i,additionLines:s,additionLineIndex:Ra(e.additionStart,i),deletionStart:hi(e.deletionStart,r),deletionCount:r,deletionLines:o,deletionLineIndex:Ra(e.deletionStart,r),hunkContent:n,hunkSpecs:`@@ -${hi(e.deletionStart,r)},${r} +${hi(e.additionStart,i)},${i} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return no(l),l}function La(t,e,n,i){e>0&&t.push({type:"context",lines:e,additionLineIndex:n,deletionLineIndex:i})}function Rv(t,e){if(t.length!==e.length)return!0;for(let n=0;n<t.length;n++){const i=t[n],r=e[n];if(Ft(i)!==Ft(r)||i.deletionCount!==r.deletionCount||Xi(i)!==Xi(r)||i.additionCount!==r.additionCount||i.splitLineCount!==r.splitLineCount||!_v(i,r))return!0}return!1}function _v(t,e){const n=Ea(t),i=Ea(e);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*Ea(t){for(const e of t.hunkContent){if(e.type==="context"){for(let i=0;i<e.lines;i++)yield[e.deletionLineIndex+i,e.additionLineIndex+i];continue}const n=Math.max(e.deletions,e.additions);for(let i=0;i<n;i++)yield[i<e.deletions?e.deletionLineIndex+i:void 0,i<e.additions?e.additionLineIndex+i:void 0]}}function Xi(t){return we(t.additionStart,t.additionCount)}function Ft(t){return we(t.deletionStart,t.deletionCount)}function hi(t,e){return e===0?t:t+1}function Ra(t,e){return e===0?t-1:t}function Tv(t){ar(t);for(let e=0;e<t.hunks.length;e++)kc(t,e)}function En(t){const e=t.lang??be(t.name),n=t.lang??(t.prevName!=null?be(t.prevName):"text");return e==="text"&&n==="text"}let Iv=-1;var Ec=class{constructor(t={theme:j},e=Ye,n,i){g(this,"options");g(this,"annotationSlotName");g(this,"onRenderUpdate");g(this,"workerManager");g(this,"__id",`diff-hunks-renderer:${++Iv}`);g(this,"highlighter");g(this,"diff");g(this,"expandedHunks",new Map);g(this,"deletionAnnotations",{});g(this,"additionAnnotations",{});g(this,"computedLangs",["text"]);g(this,"renderCache");g(this,"pendingHighlightResult");g(this,"pendingStructuralRows");g(this,"editSessionActive",!1);g(this,"createAnnotationElement",t=>ds(t));this.options=t,this.annotationSlotName=e,this.onRenderUpdate=n,this.workerManager=i,(i==null?void 0:i.isWorkingPool())!==!0&&(this.highlighter=Ge(t.theme??j)?tn():void 0)}cleanUp(){this.endEditSession(),this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){var t;this.highlighter=void 0,this.diff=void 0,this.editSessionActive?(this.renderCache!=null&&(this.renderCache.renderRange=void 0),this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0):this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},(t=this.workerManager)==null||t.cleanUpTasks(this)}beginEditSession(t,e){const{editSessionActive:n}=this;this.editSessionActive=!0,n||(this.pendingHighlightResult=void 0),this.diff=t,n&&this.renderCache!=null&&this.renderCache.diff!==t&&this.clearRenderCache();const{renderCache:i}=this;if(!t.isPartial&&t.additionLines.length===0){Object.assign(t,Li(t,this.options.parseDiffOptions)),this.markEditSessionPass(t),this.clearRenderCache();return}if(i==null||n&&i.diff===t)return;const{options:r}=this.getRenderOptions(t),s=i.diff===t,o=e!=null&&K(i.diff,e),{result:l}=i;if(!i.highlighted||l==null||!tt(i.options,r)||!s&&!o){this.clearRenderCache();return}s||(this.renderCache={diff:t,options:r,highlighted:!0,result:{...l,code:{...l.code,additionLines:[...l.code.additionLines]}},renderRange:i.renderRange})}endEditSession(){this.editSessionActive=!1,this.pendingHighlightResult=void 0,this.diff==null&&this.clearRenderCache()}editorRenderReady(){var t;return((t=this.renderCache)==null?void 0:t.options.useTokenTransformer)===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){const{diff:t,renderCache:e,workerManager:n}=this;return t==null||e==null||!K(e.diff,t)||En(t)||Sn(t,this.getTokenizeMaxLength())?Promise.resolve():!this.editSessionActive&&(n==null?void 0: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(t,e){var s;const{diff:n,renderCache:i}=this;if(e==null||n==null||i==null||!K(n,t)||!K(i.diff,t)||this.editSessionActive)return;const{options:r}=this.getRenderOptions(n);tt(r,e.options)&&(this.pendingHighlightResult={diff:n,options:e.options,highlighted:!0,result:e.result},(s=this.onRenderUpdate)==null||s.call(this))}get diffCache(){var t;return((t=this.renderCache)==null?void 0:t.diff)??this.diff}clearRenderCache(){this.renderCache=void 0,this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0}setOptions(t){this.options=t}mergeOptions(t){this.options={...this.options,...t}}expandHunk(t,e,n=this.getOptionsWithDefaults().expansionLineCount){var r;const i={...this.expandedHunks.get(t)??{fromStart:0,fromEnd:0}};(e==="up"||e==="both")&&(i.fromStart+=n),(e==="down"||e==="both")&&(i.fromEnd+=n),((r=this.renderCache)==null?void 0:r.highlighted)!==!0&&this.clearRenderCache(),this.expandedHunks.set(t,i)}getExpandedHunk(t){return this.expandedHunks.get(t)??ou}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(t){this.expandedHunks=t}setLineAnnotations(t){this.additionAnnotations={},this.deletionAnnotations={};for(const e of t){const n=(()=>{switch(e.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),i=n[e.lineNumber]??[];n[e.lineNumber]=i,i.push(e)}}updateRenderCache(t,e,n=!1,i,r){var f;this.pendingStructuralRows=void 0;const{renderCache:s}=this;if(s==null)return!1;const{result:o,diff:l}=s;if(o==null)return!1;if(l.isPartial)throw new Error("Could not update render cache for partial diff");const a=o.code.additionLines,d=this.pendingStructuralRows=n?new Map:void 0,c=[],u=new Map;if(d==null&&i!=null){const p=l.additionLines.length,y=Dv(l.additionLines,r);for(const[v,m]of i){if(v<0||v>p||v===p&&(m===""||!y))continue;const C=l.additionLines[v]??"";C!==m&&(l.additionLines[v]=m,c.push(v),u.set(v,C),t.has(v)||(a[v]=Ei(v,Qe(m))))}}for(const[p,y]of t){const v=((f=a[p])==null?void 0:f.properties)??{},m=y.map(k=>k[2]).join(""),C=p<l.additionLines.length,S=C?l.additionLines[p]??"":"",w=Qe(S);d==null&&C&&(i==null?void 0:i.has(p))!==!0&&(l.additionLines[p]=Kd(S,m),w!==m&&(c.push(p),u.set(p,S)));const b={type:"element",tagName:"div",properties:{"data-line":v["data-line"]??p+1,"data-line-index":v["data-line-index"]??p,"data-line-type":v["data-line-type"]??"context"},children:y.map(([k,x,E])=>k===0&&x===""?E===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:E}:{type:"element",tagName:"span",properties:{"data-char":k,style:`color:${x};`},children:[{type:"text",value:E}]})};d!=null?d.set(p,b):a[p]=b}let h=!1;if(c.length>0)if(this.editSessionActive)if(l.additionLines.length<=1&&l.additionLines.join("")==="")this.applyRecomputePreservingSessionType(l,Li(l,this.options.parseDiffOptions)),h=!0;else if(ys(l,l.additionLines))this.applyRecomputePreservingSessionType(l,Ki(l,l.additionLines,this.options.parseDiffOptions)),h=!0;else{const p=fv(l,c,this.options.parseDiffOptions,u);this.applyExpansionRemap(p),h=p!=null}else Object.assign(l,ov(l,c,this.options.parseDiffOptions));return o.baseThemeType=e,s.isDirty=!0,h}applyExpansionRemap(t){t!=null&&(this.expandedHunks=yv(this.expandedHunks,t))}applyDocumentChange(t){const{pendingStructuralRows:e,renderCache:n}=this;this.pendingStructuralRows=void 0;const i=this.diff??(n==null?void 0:n.diff);if(i==null)return;const r=n==null?void 0:n.result;if(i.isPartial)throw new Error("Could not apply document change for partial diff");const{additionLines:s}=i;if(i.additionLines=Hv(t),r!=null&&(r.code.additionLines=Mv(s,i.additionLines,r.code.additionLines,t)),i.additionLines.length<=1&&i.additionLines.join("")===""?(this.applyRecomputePreservingSessionType(i,Li(i,this.options.parseDiffOptions)),r!=null&&(r.code.additionLines[0]=Ei(0,t.getLineText(0)))):this.editSessionActive?this.applySessionDocumentChange(i,s):Object.assign(i,wc(i,this.options.parseDiffOptions)),e!=null&&r!=null)for(const[o,l]of e)o<r.code.additionLines.length&&(r.code.additionLines[o]=l);n!=null&&(n.isDirty=!0)}applySessionDocumentChange(t,e){const{parseDiffOptions:n}=this.options,i=t.additionLines;if(ys(t,i)){this.applyRecomputePreservingSessionType(t,Ki(t,i,n));return}this.applyExpansionRemap(vs(t,n,r=>e[r]))}applyRecomputePreservingSessionType(t,e){const n=this.editSessionActive?t.type:void 0;Object.assign(t,e),n!=null&&(t.type=n),this.markEditSessionPass(t)}markEditSessionPass(t){this.editSessionActive&&(t.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:t}){return{gutterLineType:t,contentProperties:{"data-line-type":t}}}getSplitLineDecoration({side:t,type:e}){const n=e==="change"?t==="deletions"?"change-deletion":"change-addition":e;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}getOptionsWithDefaults(){var b;const{diffIndicators:t="bars",diffStyle:e="split",disableBackground:n=!1,disableFileHeader:i=!1,disableLineNumbers:r=!1,disableVirtualizationBuffers:s=!1,collapsed:o=!1,expandUnchanged:l=!1,collapsedContextThreshold:a=1,expansionLineCount:d=100,hunkSeparators:c="line-info",lineDiffType:u="word-alt",maxLineDiffLength:h=1e3,overflow:f="scroll",stickyHeader:p=!1,theme:y=j,headerRenderMode:v="default",tokenizeMaxLineLength:m=1e3,tokenizeMaxLength:C=iu,useTokenTransformer:S=!1,useCSSClasses:w=!1}=this.options;return{diffIndicators:t,diffStyle:e,disableBackground:n,disableFileHeader:i,disableLineNumbers:r,disableVirtualizationBuffers:s,collapsed:o,expandUnchanged:l,collapsedContextThreshold:a,expansionLineCount:d,hunkSeparators:c,lineDiffType:u,maxLineDiffLength:h,overflow:f,stickyHeader:p,theme:((b=this.workerManager)==null?void 0:b.getDiffRenderOptions().theme)??y,headerRenderMode:v,tokenizeMaxLineLength:m,tokenizeMaxLength:C,useTokenTransformer:S,useCSSClasses:w}}async initializeHighlighter(){var t;return this.highlighter=await un(Gs(this.computedLangs,{theme:this.getLocalHighlightTheme(),preferredHighlighter:((t=this.workerManager)==null?void 0:t.getPreferredHighlighter())??this.options.preferredHighlighter})),this.highlighter}hydrate(t){var r,s;if(t==null)return;this.diff=t;const{options:e}=this.getRenderOptions(t),n=Sn(t,this.getTokenizeMaxLength());let i=(r=this.workerManager)==null?void 0:r.getDiffResultCache(t);i!=null&&!tt(e,i.options)&&(i=void 0),this.renderCache??(this.renderCache={diff:t,hydrated:!0,highlighted:!n&&!En(t),options:e,result:n||i==null?void 0:i.result,renderRange:void 0}),!this.editSessionActive&&((s=this.workerManager)==null?void 0:s.isWorkingPool())===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter==null&&(this.computedLangs=Or(t),this.initializeHighlighter())}getLocalHighlightTheme(){var t;return((t=this.workerManager)==null?void 0:t.getDiffRenderOptions().theme)??this.options.theme??j}getEffectiveCodeOptions(){var e;const t=((e=this.workerManager)==null?void 0:e.isWorkingPool())===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:(t==null?void 0:t.tokenizeMaxLineLength)??this.options.tokenizeMaxLineLength}}getRenderOptions(t){const e=(()=>{var l;if(((l=this.workerManager)==null?void 0:l.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==null?void 0:n.result)==null?{options:e,forceHighlight:!0}:!K(t,n.diff)||!tt(e,n.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getDiffForNextRender(t){const{options:e}=this.getRenderOptions(t);if(this.getReadyRenderResult(t,e)!=null||this.renderCache==null)return t;if(K(this.renderCache.diff,t))return this.renderCache.diff;const n=!(t.additionLines.length>0||t.deletionLines.length>0)||En(t)||Sn(t,this.getTokenizeMaxLength());return this.canRenderDiff(t,e,n)?t:this.renderCache.diff}canRenderDiff(t,e,n){var r,s;const{renderCache:i}=this;return i==null||K(i.diff,t)?!0:n?i.result==null&&i.hydrated!==!0||((r=this.workerManager)==null?void 0:r.isWorkingPool())===!0||this.highlighter!=null&&Ge(e.theme):i.result==null&&i.hydrated!==!0?!0:!this.editSessionActive&&((s=this.workerManager)==null?void 0:s.isWorkingPool())===!0?!i.highlighted:this.highlighter!=null&&Ge(e.theme)}renderDiff(t=this.diff,e=Jt){var h;if(this.diff=t,t==null){this.pendingHighlightResult=void 0;return}const{expandUnchanged:n,collapsedContextThreshold:i}=this.getOptionsWithDefaults();let{options:r,forceHighlight:s}=this.getRenderOptions(t);const o=this.getReadyRenderResult(t,r);this.pendingHighlightResult=void 0,o!=null&&(this.renderCache={...o,diff:t,renderRange:void 0},s=!1),this.renderCache??(this.renderCache={diff:t,highlighted:!1,options:r,result:void 0,renderRange:void 0});const l=t.additionLines.length>0||t.deletionLines.length>0,a=!l||En(t)||Sn(t,this.getTokenizeMaxLength()),d=this.canRenderDiff(t,r,a),c=!K(t,this.renderCache.diff),u=!sr(this.renderCache.renderRange,e);if(!this.editSessionActive&&((h=this.workerManager)==null?void 0:h.isWorkingPool())===!0){const f=this.renderCache.result==null&&this.renderCache.highlighted&&!a&&!c&&Vi(e);d&&!f&&(a||this.renderCache.result==null||!this.renderCache.highlighted&&(c||u))&&(this.renderCache.diff=t,this.renderCache.options=r,this.renderCache.highlighted=!1,(this.renderCache.result==null||c||u||s)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(t,e.startingLine,e.totalLines,Vi(e)||n?!0:this.expandedHunks,i)),this.renderCache.renderRange=e),!a&&l&&(!this.renderCache.highlighted||s)&&this.workerManager.highlightDiffAST(this,t)}else{this.computedLangs=Or(t),this.highlighter??(this.highlighter=tn());const f=this.highlighter!=null&&Ge(r.theme),p=this.highlighter!=null&&An(this.computedLangs),y=!a&&p;if(d&&this.highlighter!=null&&f&&(s||a||!this.renderCache.highlighted&&y||this.renderCache.result==null)){const{result:v,options:m}=this.renderDiffWithHighlighter(t,this.highlighter,a||!p);this.renderCache={diff:t,options:m,highlighted:y,result:v,renderRange:void 0}}(!f||!a&&!p)&&this.asyncHighlight(t).then(({result:v,options:m})=>{this.applyHighlightResult(t,v,m,!a)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,e,this.renderCache.result):void 0}async asyncRender(t,e=Jt){this.diff=t;const{result:n}=await this.asyncHighlight(t);return this.processDiffResult(t,e,n)}createPreElement(t,e,n){const{diffIndicators:i,disableBackground:r,disableLineNumbers:s,overflow:o}=this.getOptionsWithDefaults();return Vd({type:"diff",diffIndicators:i,disableBackground:r,disableLineNumbers:s,overflow:o,split:t,totalLines:e,customProperties:n})}async asyncHighlight(t){const e=Sn(t,this.getTokenizeMaxLength());this.computedLangs=e?["text"]:Or(t);const n=this.highlighter!=null&&Ge(this.getLocalHighlightTheme()),i=e||this.highlighter!=null&&An(this.computedLangs);return(this.highlighter==null||!n||!i)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(t,this.highlighter,e)}renderDiffWithHighlighter(t,e,n=!1){const{options:i}=this.getRenderOptions(t),{collapsedContextThreshold:r}=this.getOptionsWithDefaults(),s=Zy(t,e,i,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:r});if(this.editSessionActive&&t.additionLines.length===1&&t.additionLines[0]===""&&s.code.additionLines[0]==null){let o;if(Dt({diff:t,diffStyle:"both",expandedHunks:n?!0:void 0,collapsedContextThreshold:r,callback:({additionLine:l})=>{if((l==null?void 0:l.lineIndex)===0)return o=l,!0}}),o==null)throw new Error("DiffHunksRenderer: missing empty addition line");s.code.additionLines[0]=Ei(0,"",o.unifiedLineIndex,o.splitLineIndex)}return{result:s,options:i}}onHighlightSuccess(t,e,n,i=!0){this.editSessionActive||this.applyHighlightResult(t,e,n,i)}applyHighlightResult(t,e,n,i=!0){var o;const{diff:r,renderCache:s}=this;r==null||s==null||!K(r,t)||!tt(n,this.getRenderOptions(r).options)||(s.result==null||!s.highlighted||!tt(s.options,n)||!K(s.diff,r))&&(this.pendingHighlightResult={diff:r,options:n,highlighted:i,result:e},(o=this.onRenderUpdate)==null||o.call(this))}getMatchingWorkerResultCache(t,e){var i;if(this.editSessionActive)return;const n=(i=this.workerManager)==null?void 0:i.getDiffResultCache(t);if(!(n==null||!tt(e,n.options)))return n}getReadyRenderResult(t,e){const{pendingHighlightResult:n}=this;if(n!=null&&K(n.diff,t)&&tt(n.options,e))return n;const i=this.getMatchingWorkerResultCache(t,e);if(!(i==null||this.hasHighlightedRenderCache(t,e)))return{diff:t,highlighted:!0,...i}}hasHighlightedRenderCache(t,e){const{renderCache:n}=this;return(n==null?void 0:n.result)!=null&&n.highlighted&&K(t,n.diff)&&tt(e,n.options)}onHighlightError(t){console.error(t)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(t,e,{code:n,themeStyles:i,baseThemeType:r}){var V;const{diffStyle:s,disableFileHeader:o,expandUnchanged:l,expansionLineCount:a,collapsedContextThreshold:d,hunkSeparators:c}=this.getOptionsWithDefaults(),u=((V=this.renderCache)==null?void 0:V.isDirty)??!1,h=s==="unified",f=Ov(t,this.options.loadDiffFiles!=null),p=!t.isPartial||f;let y=[],v=[],m=[];const C=[],{additionLines:S,deletionLines:w}=n,b={rowCount:0,hunkSeparators:c,additionsContentAST:y,deletionsContentAST:v,unifiedContentAST:m,unifiedGutterAST:Yt(),deletionsGutterAST:Yt(),additionsGutterAST:Yt(),expansionLineCount:a,hunkData:C,incrementRowCount(P=1){b.rowCount+=P},pushToGutter(P,N){switch(P){case"unified":b.unifiedGutterAST.children.push(N);break;case"deletions":b.deletionsGutterAST.children.push(N);break;case"additions":b.additionsGutterAST.children.push(N)}}},k=vc({fileDiff:t,errorPrefix:"DiffHunksRenderer.processDiffResult"}),x={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"?(b.pushToGutter("additions",Le(void 0,"buffer",this.size)),y==null||y.push(li(this.size))):(b.pushToGutter("deletions",Le(void 0,"buffer",this.size)),v==null||v.push(li(this.size))),this.size=0,this.side=void 0}}},E=(P,N,B,ae,F)=>{b.pushToGutter(P,Nd(N,B,ae,F))};function R(P){x.flush(),s==="unified"?Hr("unified",P,b):(Hr("deletions",P,b),Hr("additions",P,b))}this.pushFileLevelAnnotations(t,s,e,b),Dt({diff:t,diffStyle:s,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:l?!0:this.expandedHunks,collapsedContextThreshold:d,callback:({hunkIndex:P,hunk:N,collapsedBefore:B,collapsedAfter:ae,additionLine:F,deletionLine:z,type:q})=>{var fn,pn;const Y=z!=null?z.splitLineIndex:F.splitLineIndex,Re=F!=null?F.unifiedLineIndex:z.unifiedLineIndex;s==="split"&&q!=="change"&&x.flush(),B>0&&R({hunkIndex:P,collapsedLines:B,rangeSize:Math.max((N==null?void 0:N.collapsedBefore)??0,0),hunkSpecs:N==null?void 0:N.hunkSpecs,isFirstHunk:P===0,isLastHunk:!1,isExpandable:p});const Ae=s==="unified"?Re:Y,Pe={type:q,hunkIndex:P,lineIndex:Ae,unifiedLineIndex:Re,splitLineIndex:Y,deletionLine:z,additionLine:F};if(s==="unified"){const G=(fn=this.getUnifiedInjectedRowsForLine)==null?void 0:fn.call(this,Pe);(G==null?void 0:G.before)!=null&&_a(G.before,b);let _e=z!=null?w[z.lineIndex]:void 0,xe=F!=null?S[F.lineIndex]:void 0;if(_e==null&&xe==null){const Me="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(Me,{file:t.name}),new Error(Me)}const ut=q==="change"?F!=null?"change-addition":"change-deletion":q,ke=this.getUnifiedLineDecoration({type:q,lineType:ut,additionLineIndex:F==null?void 0:F.lineIndex,deletionLineIndex:z==null?void 0:z.lineIndex});E("unified",ke.gutterLineType,F!=null?F.lineNumber:z.lineNumber,`${Re},${Y}`,ke.gutterProperties),xe!=null?xe=pi(xe,ke.contentProperties,u&&F!=null?{"data-line":F.lineNumber,"data-line-index":`${Re},${Y}`}:void 0):_e!=null&&(_e=pi(_e,ke.contentProperties,u&&z!=null?{"data-line":z.lineNumber,"data-line-index":`${Re},${Y}`}:void 0)),fi({diffStyle:"unified",type:q,deletionLine:_e,additionLine:xe,unifiedSpan:this.getAnnotations("unified",z==null?void 0:z.lineNumber,F==null?void 0:F.lineNumber,P,Ae),createAnnotationElement:Me=>this.createAnnotationElement(Me),context:b}),(G==null?void 0:G.after)!=null&&_a(G.after,b)}else{const G=(pn=this.getSplitInjectedRowsForLine)==null?void 0:pn.call(this,Pe);(G==null?void 0:G.before)!=null&&Ta(G.before,b,x);let _e=z!=null?w[z.lineIndex]:void 0,xe=F!=null?S[F.lineIndex]:void 0;const ut=this.getSplitLineDecoration({side:"deletions",type:q,lineIndex:z==null?void 0:z.lineIndex}),ke=this.getSplitLineDecoration({side:"additions",type:q,lineIndex:F==null?void 0:F.lineIndex});if(_e==null&&xe==null){const pe="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(pe,{file:t.name}),new Error(pe)}const Me=(()=>{if(q==="change"){if(xe==null)return"additions";if(_e==null)return"deletions"}})();Me!=null?(x.side!=null&&x.side!==Me&&x.flush(),x.side=Me,x.increment()):q==="change"&&x.flush();const gn=this.getAnnotations("split",z==null?void 0:z.lineNumber,F==null?void 0:F.lineNumber,P,Ae);if(gn!=null&&x.size>0&&x.flush(),z!=null){const pe=pi(_e,ut.contentProperties,u?{"data-line":z.lineNumber,"data-line-index":`${z.unifiedLineIndex},${Y}`}:void 0);E("deletions",ut.gutterLineType,z.lineNumber,`${z.unifiedLineIndex},${Y}`,ut.gutterProperties),pe!=null&&(_e=pe)}if(F!=null){const pe=pi(xe,ke.contentProperties,u?{"data-line":F.lineNumber,"data-line-index":`${F.unifiedLineIndex},${Y}`}:void 0);E("additions",ke.gutterLineType,F.lineNumber,`${F.unifiedLineIndex},${Y}`,ke.gutterProperties),pe!=null&&(xe=pe)}fi({diffStyle:"split",type:q,additionLine:xe,deletionLine:_e,...gn,createAnnotationElement:pe=>this.createAnnotationElement(pe),context:b}),(G==null?void 0:G.after)!=null&&Ta(G.after,b,x)}const xt=s==="split"&&N!=null&&Y===N.splitLineStart+N.splitLineCount-1,le=P===t.hunks.length-1&&N!=null&&(s==="split"?Y===N.splitLineStart+N.splitLineCount-1:Re===N.unifiedLineStart+N.unifiedLineCount-1),Ut=xt?N.noEOFCRDeletions:!1,hn=xt?N.noEOFCRAdditions:!1,Fe=((z==null?void 0:z.noEOFCR)??!1)||Ut,$e=((F==null?void 0:F.noEOFCR)??!1)||hn;if($e||Fe){if(s==="split"&&x.flush(),Fe){const G=q==="context"||q==="context-expanded"?q:"change-deletion";s==="unified"?(b.unifiedContentAST.push(di(G)),b.pushToGutter("unified",Le(G,"metadata",1))):(b.deletionsContentAST.push(di(G)),b.pushToGutter("deletions",Le(G,"metadata",1)),$e||(b.pushToGutter("additions",Le(void 0,"buffer",1)),b.additionsContentAST.push(li(1))))}if($e){const G=q==="context"||q==="context-expanded"?q:"change-addition";s==="unified"?(b.unifiedContentAST.push(di(G)),b.pushToGutter("unified",Le(G,"metadata",1))):(b.additionsContentAST.push(di(G)),b.pushToGutter("additions",Le(G,"metadata",1)),Fe||(b.pushToGutter("deletions",Le(void 0,"buffer",1)),b.deletionsContentAST.push(li(1))))}b.incrementRowCount(1)}c!=="simple"&&c!=="metadata"&&(ae>0||le&&f)&&R({hunkIndex:q==="context-expanded"?P:P+1,collapsedLines:le&&f?"unknown":ae,rangeSize:k,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:p}),b.incrementRowCount(1)}}),s==="split"&&x.flush();const A=Math.max(Uy(t.hunks),t.additionLines.length??0,t.deletionLines.length??0),D=e.bufferBefore>0||e.bufferAfter>0,I=!h&&t.type!=="deleted",_=!h&&t.type!=="new",H=b.rowCount>0||D;y=I&&H?y:void 0,v=_&&H?v:void 0,m=h&&H?m:void 0;const U=this.createPreElement(v!=null&&y!=null,A);return{fileDiff:t,unifiedGutterAST:h&&H?b.unifiedGutterAST.children:void 0,unifiedContentAST:m,deletionsGutterAST:_&&H?b.deletionsGutterAST.children:void 0,deletionsContentAST:v,additionsGutterAST:I&&H?b.additionsGutterAST.children:void 0,additionsContentAST:y,hunkData:C,preNode:U,themeStyles:i,baseThemeType:r,headerElement:o?void 0:this.renderHeader(t),totalLines:A,rowCount:b.rowCount,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderCodeAST(t,e){const n=t==="unified"?e.unifiedGutterAST:t==="deletions"?e.deletionsGutterAST:e.additionsGutterAST,i=t==="unified"?e.unifiedContentAST:t==="deletions"?e.deletionsContentAST:e.additionsContentAST;if(n==null||i==null)return;const r=Yt(n);return r.properties.style=`grid-row: span ${e.rowCount}`,[r,Xd(i,e.rowCount)]}renderFullAST(t,e=[]){const n=this.getOptionsWithDefaults().hunkSeparators==="line-info",i=this.renderCodeAST("unified",t);if(i!=null)return e.push(M({tagName:"code",children:i,properties:{"data-code":"","data-container-size":n?"":void 0,"data-unified":""}})),{...t.preNode,children:e};const r=this.renderCodeAST("deletions",t);r!=null&&e.push(M({tagName:"code",children:r,properties:{"data-code":"","data-container-size":n?"":void 0,"data-deletions":""}}));const s=this.renderCodeAST("additions",t);return s!=null&&e.push(M({tagName:"code",children:s,properties:{"data-code":"","data-container-size":n?"":void 0,"data-additions":""}})),{...t.preNode,children:e}}renderFullHTML(t,e=[]){return Ce(this.renderFullAST(t,e))}renderPartialHTML(t,e){return e==null?Ce(t):Ce(M({tagName:"code",children:t,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${e}`]:""}}))}pushFileLevelAnnotations(t,e,n,i){if(!or(n))return;const r=t.type!=="new"?this.getAnnotationNames(us(this.deletionAnnotations)):[],s=t.type!=="deleted"?this.getAnnotationNames(us(this.additionAnnotations)):[];if(r.length===0&&s.length===0)return;const o=-1,l=-1,{createAnnotationElement:a}=this;if(e==="unified"){fi({diffStyle:e,type:"context",unifiedSpan:{type:"annotation",hunkIndex:o,lineIndex:l,annotations:r.concat(s)},createAnnotationElement:a,context:i});return}fi({diffStyle:e,type:"context",deletionSpan:{type:"annotation",hunkIndex:o,lineIndex:l,annotations:r},additionSpan:{type:"annotation",hunkIndex:o,lineIndex:l,annotations:s},createAnnotationElement:a,context:i})}getAnnotations(t,e,n,i,r){const s={type:"annotation",hunkIndex:i,lineIndex:r,annotations:[]};if(e!=null)for(const l of this.deletionAnnotations[e]??[])s.annotations.push(this.annotationSlotName(l));const o={type:"annotation",hunkIndex:i,lineIndex:r,annotations:[]};if(n!=null)for(const l of this.additionAnnotations[n]??[])(t==="unified"?s:o).annotations.push(this.annotationSlotName(l));if(t==="unified")return s.annotations.length>0?s:void 0;if(!(o.annotations.length===0&&s.annotations.length===0))return{deletionSpan:s,additionSpan:o}}getAnnotationNames(t){return(t==null?void 0:t.map(e=>this.annotationSlotName(e)))??[]}renderHeader(t){const{headerRenderMode:e,stickyHeader:n}=this.getOptionsWithDefaults();return Bd({fileOrDiff:t,mode:e,stickyHeader:n})}};const Av=new Intl.PluralRules("en-US");function Pv(t){return`${t} unmodified line${Av.select(t)==="one"?"":"s"}`}function _a(t,e){for(const n of t)e.unifiedContentAST.push(n.content),e.pushToGutter("unified",n.gutter),e.incrementRowCount(1)}function Ta(t,e,n){for(const{deletion:i,addition:r}of t){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&&(e.deletionsContentAST.push(i.content),e.pushToGutter("deletions",i.gutter)),r!=null&&(e.additionsContentAST.push(r.content),e.pushToGutter("additions",r.gutter)),s!=null&&(n.side=s,n.increment()),e.incrementRowCount(1)}}function fi({diffStyle:t,type:e,deletionLine:n,additionLine:i,unifiedSpan:r,deletionSpan:s,additionSpan:o,createAnnotationElement:l,context:a}){let d=!1;if(t==="unified"){if(i!=null?a.unifiedContentAST.push(i):n!=null&&a.unifiedContentAST.push(n),r!=null){const c=e==="change"?n!=null?"change-deletion":"change-addition":e;a.unifiedContentAST.push(l(r)),a.pushToGutter("unified",Le(c,"annotation",1)),d=!0}}else if(t==="split"){if(n!=null&&a.deletionsContentAST.push(n),i!=null&&a.additionsContentAST.push(i),s!=null){const c=e==="change"?n!=null?"change-deletion":"context":e;a.deletionsContentAST.push(l(s)),a.pushToGutter("deletions",Le(c,"annotation",1)),d=!0}if(o!=null){const c=e==="change"?i!=null?"change-addition":"context":e;a.additionsContentAST.push(l(o)),a.pushToGutter("additions",Le(c,"annotation",1)),d=!0}}d&&a.incrementRowCount(1)}function Hr(t,{hunkIndex:e,collapsedLines:n,rangeSize:i,hunkSpecs:r,isFirstHunk:s,isLastHunk:o,isExpandable:l},a){if(typeof n=="number"&&n<=0)return;const d=t==="unified"?a.unifiedContentAST:t==="deletions"?a.deletionsContentAST:a.additionsContentAST;if(a.hunkSeparators==="metadata"){r!=null&&(a.pushToGutter(t,Wt({type:"metadata",content:r,isFirstHunk:s,isLastHunk:o})),d.push(Wt({type:"metadata",content:r,isFirstHunk:s,isLastHunk:o})),t!=="additions"&&a.incrementRowCount(1));return}if(a.hunkSeparators==="simple"){e>0&&(a.pushToGutter(t,Wt({type:"simple",isFirstHunk:s,isLastHunk:!1})),d.push(Wt({type:"simple",isFirstHunk:s,isLastHunk:!1})),t!=="additions"&&a.incrementRowCount(1));return}const c=zy(t,e),u=i>a.expansionLineCount,h=l?e:void 0,f=typeof n=="number"?Pv(n):"More unchanged context may be available";a.pushToGutter(t,Wt({type:a.hunkSeparators,content:f,expandIndex:h,chunked:u,slotName:c,isFirstHunk:s,isLastHunk:o})),d.push(Wt({type:a.hunkSeparators,content:f,expandIndex:h,chunked:u,slotName:c,isFirstHunk:s,isLastHunk:o})),t!=="additions"&&a.incrementRowCount(1),a.hunkData.push({slotName:c,hunkIndex:e,lines:typeof n=="number"?n:0,lineCountKnown:typeof n=="number",type:t,expandable:l?{up:!s,down:!o,chunked:u}:void 0})}function pi(t,e,n){return t==null||t.type!=="element"||e==null&&n==null?t:{...t,properties:{...t.properties,...e,...n}}}function Ia(t){return t.length>0&&t[t.length-1]===""?t.length-1:t.length}function Mv(t,e,n,i){const r=Ia(t),s=Ia(e),o=Math.min(r,s);let l=0;for(;l<o&&t[l]===e[l];)l++;let a=0;for(;a<o-l&&t[r-1-a]===e[s-1-a];)a++;const d=new Array(e.length);for(let c=0;c<l;c++)d[c]=n[c];for(let c=0;c<a;c++)d[s-1-c]=n[r-1-c];r<t.length&&s<e.length&&(d[e.length-1]=n[t.length-1]);for(let c=l;c<e.length;c++)d[c]??(d[c]=Ei(c,i.getLineText(c)));return d}function Dv(t,e){var n;return e===t.length+1&&((n=t.at(-1))==null?void 0:n.endsWith(`
316
+ `))===!0}function Ei(t,e,n=t,i=t){return{type:"element",tagName:"div",properties:{"data-line":t+1,"data-line-index":`${n},${i}`,"data-line-type":"context"},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:e}]}]}}function Hv(t){const e=[];for(let n=0;n<t.lineCount;n++)e.push(t.getLineText(n,!0));return e}function Or(t){if(t.lang!=null)return[t.lang];const e=be(t.prevName??t.name),n=be(t.name);return e===n?[n]:[e,n]}function Sn(t,e){return Math.max(t.additionLines.length,t.deletionLines.length)>e}function Ov(t,e){return t.isPartial&&e&&(t.type==="change"||t.type==="rename-changed")}function Nv(t,e){return t.lineNumber===e.lineNumber&&t.side===e.side&&t.metadata===e.metadata}function Fv(t,e){var n,i,r,s,o,l;return t.slotName===e.slotName&&t.hunkIndex===e.hunkIndex&&t.lines===e.lines&&t.lineCountKnown===e.lineCountKnown&&t.type===e.type&&((n=t.expandable)==null?void 0:n.chunked)===((i=e.expandable)==null?void 0:i.chunked)&&((r=t.expandable)==null?void 0:r.up)===((s=e.expandable)==null?void 0:s.up)&&((o=t.expandable)==null?void 0:o.down)===((l=e.expandable)==null?void 0:l.down)}async function Cs(t,e=300){let n;try{await Promise.race([t(),new Promise(i=>{n=setTimeout(i,e)})])}finally{n!=null&&clearTimeout(n)}}function Ss({oldFile:t,newFile:e},n){if(!(t===void 0&&e===void 0)){if(t===void 0||e===void 0)throw new Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(t===null){if(e===null)throw new Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:t,newFile:e}}return e===null?{oldFile:t,newFile:e}:{oldFile:t,newFile:e}}}function $v(t){return{theme:t==null?void 0:t.theme,disableLineNumbers:t==null?void 0:t.disableLineNumbers,overflow:t==null?void 0:t.overflow,collapsed:t==null?void 0:t.collapsed,disableFileHeader:t==null?void 0:t.disableFileHeader,disableVirtualizationBuffers:t==null?void 0:t.disableVirtualizationBuffers,stickyHeader:t==null?void 0:t.stickyHeader,preferredHighlighter:t==null?void 0:t.preferredHighlighter,useCSSClasses:t==null?void 0:t.useCSSClasses,useTokenTransformer:Zs(t),tokenizeMaxLineLength:t==null?void 0:t.tokenizeMaxLineLength,tokenizeMaxLength:t==null?void 0:t.tokenizeMaxLength,diffStyle:t==null?void 0:t.diffStyle,diffIndicators:t==null?void 0:t.diffIndicators,disableBackground:t==null?void 0:t.disableBackground,hunkSeparators:typeof(t==null?void 0:t.hunkSeparators)=="function"?"custom":t==null?void 0:t.hunkSeparators,expandUnchanged:t==null?void 0:t.expandUnchanged,loadDiffFiles:t==null?void 0:t.loadDiffFiles,parseDiffOptions:t==null?void 0:t.parseDiffOptions,collapsedContextThreshold:t==null?void 0:t.collapsedContextThreshold,lineDiffType:t==null?void 0:t.lineDiffType,maxLineDiffLength:t==null?void 0:t.maxLineDiffLength,expansionLineCount:t==null?void 0:t.expansionLineCount,headerRenderMode:(t==null?void 0:t.renderCustomHeader)!=null?"custom":"default"}}function Nr(t){return t.isPartial&&(t.type==="change"||t.type==="rename-changed"||t.type==="rename-pure")}function zv(t){const e={...t};return delete e.cacheKey,e}function Aa(t,e){if(t.isPartial||e.isPartial)throw new Error("FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated");const n=t.lang??be(t.name),i=e.lang??be(e.name),r=t.type!=="new",s=e.type!=="new";return t.name!==e.name||n!==i||r!==s||t.deletionLines.length!==e.deletionLines.length?!0:t.deletionLines.some((o,l)=>o!==e.deletionLines[l])}function Uv(t,e){return t.length===e.length&&t.every((n,i)=>n===e[i])}function Bv(t,e){const{oldFile:n}=t;return n==null?e.type==="new":e.type!=="new"&&n.name===(e.prevName??e.name)&&Uv(n.lines,e.deletionLines)}let Vv=-1;var Vr,Rc=(Vr=class{constructor(t={theme:j},e,n=!1){g(this,"options");g(this,"workerManager");g(this,"isContainerManaged");g(this,"__id",`file-diff:${++Vv}`);g(this,"type","file-diff");g(this,"fileContainer");g(this,"spriteSVG");g(this,"pre");g(this,"codeUnified");g(this,"codeDeletions");g(this,"codeAdditions");g(this,"bufferBefore");g(this,"bufferAfter");g(this,"themeCSSStyle");g(this,"appliedThemeCSS");g(this,"hasAdoptedThemeCSS",!1);g(this,"unsafeCSSStyle");g(this,"appliedUnsafeCSS");g(this,"gutterUtilityContent");g(this,"headerElement");g(this,"headerPrefix");g(this,"headerFilenameSuffix");g(this,"headerMetadata");g(this,"headerCustom");g(this,"separatorCache",new Map);g(this,"errorWrapper");g(this,"placeHolder");g(this,"hunksRenderer");g(this,"resizeManager");g(this,"scrollSyncManager");g(this,"interactionManager");g(this,"annotationCache",new Map);g(this,"lineAnnotations",[]);g(this,"managersDirty",!1);g(this,"deletionFile");g(this,"additionFile");g(this,"fileDiff");g(this,"editSession");g(this,"renderedDiff");g(this,"renderRange");g(this,"pendingFiles");g(this,"appliedPreAttributes");g(this,"headerCache",{lastRenderedHTML:void 0,html:void 0,fileDiff:void 0});g(this,"lastRowCount");g(this,"mounted",!1);g(this,"enabled",!0);g(this,"editor");g(this,"refreshViewTimeout");g(this,"lineStateRefreshPending",!1);g(this,"deferredSelectedLines");g(this,"deferredEditorActiveLine");g(this,"handleHighlightRender",()=>{this.rerender()});g(this,"getLineIndex",(t,e="additions")=>this.getLineIndexForDiff(this.getDiffForLineIndex(),t,e));g(this,"getHoveredLine",()=>this.interactionManager.getHoveredLine());g(this,"getAnnotationSlotName",t=>{var e;return ac((e=this.editSession)==null?void 0:e.annotations,t,Ye)});g(this,"handleExpandHunk",(t,e,n)=>{this.expandHunk(t,e,n)});g(this,"expandHunk",(t,e,n)=>{this.loadFilesIfNecessary(),this.hunksRenderer.expandHunk(t,e,n),this.rerender()});g(this,"handleEditSessionRender",()=>{this.rerender(),this.flushDeferredLineState()});var i;this.options=t,this.workerManager=e,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(t),this.resizeManager=new $d,this.scrollSyncManager=new $y,this.interactionManager=new Fd("diff",$n(t,typeof t.hunkSeparators=="function"||(t.hunkSeparators??"line-info")==="line-info"||t.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),(i=this.workerManager)==null||i.subscribeToThemeChanges(this),this.enabled=!0}getTheme(){var t;return((t=this.workerManager)==null?void 0:t.getDiffRenderOptions().theme)??this.options.theme??j}getHunksRendererOptions(t){return $v(t)}createHunksRenderer(t){return new Ec(this.getHunksRendererOptions(t),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getDiffForLineIndex(){return this.getRenderedDiff()}getLineIndexForDiff(t,e,n){if(t==null)return;const i=t.hunks.at(-1);let r,s;e:for(const o of t.hunks){const l=n==="deletions"?o.deletionStart:o.additionStart,a=n==="deletions"?o.deletionCount:o.additionCount;let d=we(l,a)+1,c=o.splitLineStart,u=o.unifiedLineStart;if(e<d){const h=d-e;r=Math.max(u-h,0),s=Math.max(c-h,0);break e}if(e>=d+a){if(o===i){const h=e-(d+a);r=u+o.unifiedLineCount+h,s=c+o.splitLineCount+h;break e}continue}for(const h of o.hunkContent)if(h.type==="context")if(e<d+h.lines){const f=e-d;s=c+f,r=u+f;break e}else d+=h.lines,c+=h.lines,u+=h.lines;else{const f=n==="deletions"?h.deletions:h.additions;if(e<d+f){const p=e-d;r=u+(n==="additions"?h.deletions:0)+p,s=c+p;break e}else d+=f,c+=Math.max(h.deletions,h.additions),u+=h.deletions+h.additions}break e}if(!(r==null||s==null))return[r,s]}setOptions(t){t!=null&&(this.options=t,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(t)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions($n(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(t){this.options={...this.options,...t}}setThemeType(t){(this.options.themeType??"system")!==t&&(this.mergeOptions({themeType:t}),this.applyCachedThemeState(t))}applyCachedThemeState(t){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const e=this.appliedThemeCSS.baseThemeType??t;return this.appliedThemeCSS.themeType===e?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,t,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!zt(this.appliedThemeCSS.theme,this.getTheme())}getLatestAnnotations(){var t,e;return((e=(t=this.editSession)==null?void 0:t.annotations)==null?void 0:e.current)??this.lineAnnotations}isNewAnnotations(t){var n;const e=(n=this.editSession)==null?void 0:n.annotations;return t===this.lineAnnotations?!1:e==null||t!==e.provided&&t!==e.current}setLineAnnotations(t){var n;const e=(n=this.editSession)==null?void 0:n.annotations;if(e==null){this.lineAnnotations=t;return}this.isNewAnnotations(t)&&(this.lineAnnotations=t,oc(e,t,Ye))}syncEditSessionAnnotationsFromEditor(t){var n;const e=(n=this.editSession)==null?void 0:n.annotations;return e==null||t===e.current?!1:(e.current=t,this.hunksRenderer.setLineAnnotations(t),this.renderAnnotations(),!0)}canPartiallyRender(t,e,n){return!(t||e||n||typeof this.options.hunkSeparators=="function")}setSelectedLines(t,e){this.lineStateRefreshPending?this.deferredSelectedLines=[t,e]:this.interactionManager.setSelection(t,e)}setEditorActiveLine(t,e){this.lineStateRefreshPending?this.deferredEditorActiveLine=[t,e]:this.interactionManager.setEditorActiveLine(t,{lineNumberOnly:e==null?void 0:e.lineNumberOnly,side:(e==null?void 0:e.side)??"additions"})}flushDeferredLineState(){const{deferredEditorActiveLine:t,deferredSelectedLines:e}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,t!=null&&this.setEditorActiveLine(...t),e!=null&&this.interactionManager.setSelection(...e)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{diffStyle:t="split",overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e==="wrap",columnVariables:this.shouldApplyColumnVariables(e)?"apply":"measure"}),e==="scroll"&&t==="split"?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(t){var e;return typeof this.options.hunkSeparators=="function"?!0:t==="scroll"&&(this.getLatestAnnotations().length>0||((e=this.pre)==null?void 0:e.hasAttribute("data-has-merge-conflict"))===!0)}getCodeScrollLeft(){var t,e,n;return Math.max(((t=this.codeUnified)==null?void 0:t.scrollLeft)??0,((e=this.codeDeletions)==null?void 0:e.scrollLeft)??0,((n=this.codeAdditions)==null?void 0:n.scrollLeft)??0)}setCodeScrollLeft(t){this.codeUnified!=null&&(this.codeUnified.scrollLeft=t),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=t),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=t)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(t=!1){var n,i,r,s,o,l;const{editor:e}=this;Ot(this.handleEditSessionRender),this.emitPostRender(!0),e==null||e.cleanUp(t?"recycle":"discard"),t||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,(n=this.workerManager)==null||n.unsubscribeToThemeChanges(this),this.renderRange=void 0,t||(this.pendingFiles=void 0),this.isContainerManaged||(i=this.fileContainer)==null||i.remove(),this.fileContainer=void 0,this.mounted=!1,t||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,(r=this.bufferBefore)==null||r.remove(),this.bufferBefore=void 0,(s=this.bufferAfter)==null||s.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,(o=this.placeHolder)==null||o.remove(),this.placeHolder=void 0,this.headerCache.lastRenderedHTML=void 0,t||this.clearReusableHeader(),(l=this.errorWrapper)==null||l.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,t?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.editSession=void 0,this.renderedDiff=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(){var t;this.enabled=!0,(t=this.workerManager)==null||t.subscribeToThemeChanges(this)}hydrate({fileContainer:t,prerenderedHTML:e,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=Ss(s,"FileDiff.hydrate"),l=o==null?void 0:o.oldFile,a=o==null?void 0:o.newFile;this.hydrateElements(t,e);const d=this.editor!=null;d||qv(this.pre,Wv({fileDiff:r,oldFile:l,newFile:a}),this.options.collapsed)||Kv(this.headerElement,jv({fileDiff:r,oldFile:l,newFile:a}),this.options.disableFileHeader)?this.render({...s,fileContainer:t,lineAnnotations:i,fileDiff:r,forceRender:d||s.forceRender,preventEmit:!0}):this.hydrationSetup({fileDiff:r,lineAnnotations:i,...o}),n||this.emitPostRender()}hydrateElements(t,e){var n;this.fileContainer!==t&&this.emitPostRender(!0),rc(t,e);for(const i of((n=t.shadowRoot)==null?void 0:n.children)??[]){if(i instanceof SVGElement){this.spriteSVG=i;continue}if(i instanceof HTMLElement){if(i instanceof HTMLPreElement){this.pre=i;for(const r of i.children)!(r instanceof HTMLElement)||r.tagName.toLowerCase()!=="code"||("deletions"in r.dataset&&(this.codeDeletions=r),"additions"in r.dataset&&(this.codeAdditions=r),"unified"in r.dataset&&(this.codeUnified=r));continue}if("diffsHeader"in i.dataset){this.headerElement=i;continue}if(i instanceof HTMLStyleElement&&i.hasAttribute("data-theme-css")){this.themeCSSStyle=i;continue}if(i instanceof HTMLStyleElement&&i.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=i,this.appliedUnsafeCSS=i.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=t,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:t,oldFile:e,newFile:n,lineAnnotations:i}){this.lineAnnotations=i??this.lineAnnotations,this.additionFile=n,this.deletionFile=e,this.fileDiff=t??(e!==void 0&&n!==void 0?Nt(e,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderedDiff=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()}loadFilesIfNecessary(){var s;const{fileDiff:t,options:{loadDiffFiles:e}}=this;if(t==null||!Nr(t)||((s=this.pendingFiles)==null?void 0:s.fileDiff)===t)return;if(e==null)throw new Error("FileDiff: loadDiffFiles is required to load full files for a partial diff");const n=this.loadFilesForDiff(t,e),i=this.pendingFiles={fileDiff:t,promise:n},r=()=>{this.pendingFiles===i&&(this.pendingFiles=void 0)};i.promise=n.finally(r)}__canAttachEditor(){return this.fileDiff!=null&&!this.fileDiff.isPartial}async prepareForEditing(){var e;if(this.__canAttachEditor())return;const t=this.__prepareForEditing();if(t==null)throw((e=this.fileDiff)==null?void 0:e.isPartial)===!0&&!Nr(this.fileDiff)?new Error("FileDiff.prepareForEditing: this partial diff cannot be hydrated; provide a complete diff"):new Error("FileDiff.prepareForEditing: a partial diff requires loadDiffFiles");if(await t,!this.__canAttachEditor())throw new Error("FileDiff.prepareForEditing: the diff did not finish loading")}__prepareForEditing(){var t,e;if(!this.__canAttachEditor()){if(((t=this.fileDiff)==null?void 0:t.isPartial)===!0&&!Nr(this.fileDiff))throw new Error("FileDiff: this partial diff cannot be hydrated; provide a complete diff to edit");return this.loadFilesIfNecessary(),(e=this.pendingFiles)==null?void 0:e.promise}}async loadFilesForDiff(t,e){try{const n=await e(t);if(this.fileDiff!==t)return;await this.handleFilesLoaded(t,n)}catch(n){if(this.options.disableErrorHandling===!0)throw n;console.error(n)}}async handleFilesLoaded(t,e){if(!(this.fileDiff!==t||!t.isPartial)){if(fs("merge",t,e),this.setHydratedState(e),this.installHydratedSessionDiff(t)){this.rerender();return}await Cs(()=>this.primeHighlightCache(t)),!(!this.enabled||this.fileDiff!==t)&&this.rerender()}}installHydratedSessionDiff(t){var e;if(t.isPartial)throw new Error("FileDiff.installHydratedSessionDiff: diffs cannot be partial for editing");return this.fileDiff!==t?!1:((e=this.editSession)==null?void 0:e.outgoingDiff)!=null?(this.installEditSession(t),!0):!1}updateExternalDiff(t,e){var i,r,s;if(K(this.fileDiff,t))return!1;const n=((i=this.editSession)==null?void 0:i.outgoingDiff)??((r=this.editSession)==null?void 0:r.diff);return this.fileDiff=t,n!=null&&(t.isPartial?this.loadFilesIfNecessary():this.installEditSession(t),this.editSession!=null&&(this.editSession.outgoingDiff=n)),((s=this.editSession)==null?void 0:s.annotations)!=null&&e!=null&&(this.lineAnnotations=e,this.editSession.annotations=Gi(e,Ye,this.editSession.annotations)),!0}installEditSession(t,e,n){var a,d;const i=t.additionLines.join(""),r=e!=null?Bn(e.contents):void 0,s=n!=null&&Bv(n,t);if(n!=null&&!s)throw new Error("FileDiff: retained session cannot resume against a different old file");if(e!=null&&e.contents!==i&&!s)throw new Error("FileDiff: retained edits are missing their diff session state");const o=e==null||e.name===t.name&&e.lang===t.lang&&e.contents===i,l=zv(t);e!=null&&r!=null&&!o&&(l.name=e.name,l.lang=e.lang),s&&n!=null&&r!=null&&(l.additionLines=r,l.type=n.type,l.hunks=n.hunks,l.editSessionDirty=!0,ar(l)),this.editSession={diff:l,annotations:((a=this.editSession)==null?void 0:a.annotations)??Gi(this.lineAnnotations,Ye),outgoingDiff:(d=this.editSession)==null?void 0:d.outgoingDiff},this.hunksRenderer.beginEditSession(l,o&&!s?t:void 0)}setHydratedState(t){var e;this.deletionFile=t.oldFile,this.additionFile=t.newFile,(e=this.workerManager)==null||e.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:t,deferManagers:e=!1,forceRender:n=!1,preventEmit:i=!1,lineAnnotations:r,fileContainer:s,containerWrapper:o,renderRange:l,...a}){var A,D;if(!this.enabled)throw new Error("FileDiff.render: attempting to call render after cleaned up");const d=Ss(a,"FileDiff.render"),c=d==null?void 0:d.oldFile,u=d==null?void 0:d.newFile;(A=this.editor)==null||A.__postponeBgTokenizeToNextFrame();const{collapsed:h=!1,themeType:f="system",expandUnchanged:p=!1}=this.options,y=h?void 0:l,v=this.hasThemeChanged(),m=d!=null,C=m&&(!Pa(c,this.deletionFile)||!Pa(u,this.additionFile));let S=t!=null&&!K(t,this.fileDiff);const w=r!=null&&(r.length>0||this.getLatestAnnotations().length>0)?this.isNewAnnotations(r):!1;if(!h&&sr(y,this.renderRange)&&!n&&!w&&!v&&(t!=null&&!S||t==null&&!C)){const I=this.applyCachedThemeState(f);return I&&this.finalizeRender(),I}let b;t==null&&m&&(C||this.fileDiff==null)&&(b=Nt(d.oldFile,d.newFile,this.options.parseDiffOptions));const{renderRange:k}=this;this.renderRange=y,m?(this.deletionFile=c,this.additionFile=u):t!=null&&(this.deletionFile=void 0,this.additionFile=void 0),t!=null&&S?this.updateExternalDiff(t,r):b!=null&&(S=!0,this.updateExternalDiff(b,r)),S&&this.clearReusableHeader(),r!=null&&this.setLineAnnotations(r);const x=this.getLatestDiff();if(x==null)return!1;x.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(ka(x,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),p&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.getLatestAnnotations());const{disableErrorHandling:E=!1,disableFileHeader:R=!1}=this.options;if(R&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0),this.clearHeaderSlots()),s=this.getOrCreateFileContainer(s,o),this.applyCachedThemeState(f),h){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const I=this.hunksRenderer.renderDiff(x,hl);I!=null&&this.applyThemeState(s,I.themeStyles,f,I.baseThemeType),(I==null?void 0:I.headerElement)!=null&&this.applyHeaderToDOM(I.headerElement,s,I.fileDiff),this.renderSeparators([]),this.renderedDiff=(I==null?void 0:I.fileDiff)??x,this.injectUnsafeCSS()}catch(I){if(E)throw I;console.error(I),I instanceof Error&&this.applyErrorToDOM(I,s)}return this.finalizeRender(),i||this.emitPostRender(),!0}try{const I=this.getOrCreatePreNode(s);if(!(this.canPartiallyRender(n,w,C||S||v||!K(this.renderedDiff,x))&&this.applyPartialRender({fileDiff:x,previousRenderRange:k,renderRange:y}))){const _=this.hunksRenderer.renderDiff(x,y);if(_==null)return((D=this.workerManager)==null?void 0:D.isInitialized())===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(s,_.themeStyles,f,_.baseThemeType),_.headerElement!=null&&this.applyHeaderToDOM(_.headerElement,s,_.fileDiff),_.additionsContentAST!=null||_.deletionsContentAST!=null||_.unifiedContentAST!=null?this.applyHunksToDOM(I,_):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(_.hunkData),this.renderedDiff=_.fileDiff}this.applyBuffers(I,y),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,e||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(I){if(E)throw I;console.error(I),I instanceof Error&&this.applyErrorToDOM(I,s)}return i||this.emitPostRender(),!0}finalizeRender(){}emitPostRender(t=!1){var r,s;const{fileContainer:e,options:{onPostRender:n}}=this;if(t){if(!this.mounted||(this.mounted=!1,e==null))return;(s=(r=this.options).onPostRender)==null||s.call(r,e,this,"unmount");return}if(e==null)return;const i=this.mounted?"update":"mount";this.mounted=!0,n==null||n(e,this,i)}getLatestDiff(t=this.fileDiff){var e;return((e=this.editSession)==null?void 0:e.diff)??t}getRenderedDiff(){return this.renderedDiff}syncRenderViewToEditor(){var d;const{editor:t,fileContainer:e}=this,n=this.getLatestAnnotations(),i=this.computeEditorRenderRange(this.renderRange),r=this.getLatestDiff();if(t==null||e==null||r==null||r.isPartial)return;const s=c=>{var y;if(!this.enabled||this.editor!==t||this.fileContainer!==e||this.getLatestDiff()!==r)return;const u=(y=this.editSession)==null?void 0:y.outgoingDiff,{fileDiff:h}=this,f=u!=null&&h!=null&&u!==r,p=f&&u!=null&&h!=null?Aa(u,h):!1;t.__syncRenderView({highlighter:c,fileContainer:e,fileDiff:r,lineAnnotations:n,renderRange:i,externalDocument:f,resetHistory:p})},o=this.getTheme(),l=r.lang??be(r.name),a=tn({theme:o,lang:l});a!=null?s(a):un({themes:cn(o),langs:["text",l],preferredHighlighter:((d=this.workerManager)==null?void 0:d.getPreferredHighlighter())??this.options.preferredHighlighter}).then(s)}computeEditorRenderRange(t){const e=this.getLatestDiff();if(t==null||e==null||Vi(t))return t;const{diffStyle:n="split",expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options;let s,o;return Dt({diff:e,diffStyle:n,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,callback:({additionLine:l})=>{l!=null&&(s??(s=l.lineNumber),o=l.lineNumber)}}),s==null||o==null?{...t,startingLine:0,totalLines:0}:{...t,startingLine:s-1,totalLines:o-s+1}}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.outgoingDiff=void 0)}__acceptEditorChange(t){const{lineAnnotations:e}=t;e!=null&&this.syncEditSessionAnnotationsFromEditor(e)}emitEditChange(t){const{onEditChange:e}=this.options;e==null||e(t)}__captureDocumentSessionState(t=!0){let{fileDiff:e,editSession:{diff:n,outgoingDiff:i}={}}=this;if(i!=null&&e!=null){if(!e.isPartial&&Aa(i,e))return;n=i}if(!(n==null||n.isPartial))return{diffSession:{oldFile:n.type!=="new"?{name:n.prevName??n.name,lines:t?[...n.deletionLines]:n.deletionLines}:null,type:n.type,hunks:t?dc(n.hunks):n.hunks},hasChanges:n.editSessionDirty===!0}}__attachEditor(t){if(this.type!=="file-diff")throw new Error(`FileDiff.__attachEditor: cannot attach an editor to a "${this.type}" diff`);if(this.editor!=null)throw new Error("FileDiff.__attachEditor: an editor is already attached");if(!this.__canAttachEditor())throw new Error("FileDiff.__attachEditor: a complete diff is required before editing");const e=()=>{this.editor=void 0,this.finishEditSession()};try{return this.resumeEditorRendering(t),e}catch(n){throw e(),n}}__resumeEditor(t){if(this.editor!==t)throw new Error("FileDiff.__resumeEditor: editor association changed");this.resumeEditorRendering(t)}resumeEditorRendering(t){var s,o,l,a;const{fileDiff:e}=this,n=(s=this.editSession)==null?void 0:s.outgoingDiff;n!=null&&e!=null&&!e.isPartial&&((o=this.editSession)==null?void 0:o.diff)===n&&this.installEditSession(e);const i=this.editSession==null&&e!=null&&!e.isPartial?e:void 0;i!=null?this.installEditSession(i,t.__getDocumentContents(Gv(i)),t.__getDocumentSessionState()):this.editSession!=null&&this.hunksRenderer.beginEditSession(this.editSession.diff),this.editor=t,((l=this.fileDiff)==null?void 0:l.isPartial)===!0&&this.loadFilesIfNecessary();const r=(a=this.editSession)==null?void 0:a.diff;this.hunksRenderer.editorRenderReady()?(r!=null&&this.hunksRenderer.diffCache===r&&(this.renderedDiff=r),this.syncRenderViewToEditor()):this.rerender()}finishEditSession(){this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks()}__completeEditSession(t,e){this.settleEditSession(e==="install",t)}settleEditSession(t,e){var v,m;const{editSession:n,fileDiff:i,lineAnnotations:r}=this;if(n==null||i==null)return;const{diff:s,annotations:o}=n;if(this.editor!=null)throw new Error("FileDiff.__completeEditSession: detach the editor before completing the session");this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();const l=o==null?void 0:o.current;let a,d=null,c=null,u=!1,h;if(e==null)throw new Error("FileDiff.__completeEditSession: editor is required for completion");const f=cc(s),p={name:f.name,contents:f.additionLines.join("")};f.lang!=null&&(p.lang=f.lang);const y={fileDiff:f,editor:e,originalFileDiff:i,oldFile:f.type==="new"?null:{name:f.prevName??f.name,contents:f.deletionLines.join("")},newFile:p,lineAnnotations:l,originalLineAnnotations:r};Object.freeze(y);try{if(e.__emitEditComplete(y),((m=(v=this.options).onEditComplete)==null?void 0:m.call(v,y))==="accept"){if(f.cacheKey!=null&&f.cacheKey===i.cacheKey)throw new Error("FileDiff.__completeEditSession: an accepted diff must not reuse the replaced diff cacheKey");a=f,d=y.oldFile,c=y.newFile}}catch(C){u=!0,h=C}if(t&&a!=null&&(this.fileDiff=a,this.additionFile!=null&&(this.deletionFile=d,this.additionFile=c),l!=null&&(this.lineAnnotations=l)),this.editSession=void 0,t&&this.fileContainer!=null&&this.rerender(),u)throw h}finalizeEditSessionHunks(){const t=this.getLatestDiff();if(t==null||t.editSessionDirty!==!0)return!1;const{collapsedContextThreshold:e=1}=this.options,n=vv(t,this.hunksRenderer.getExpandedHunksMap(),e);return ka(t,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(Cv(t,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(t,e){var i;const n=(i=this.editSession)==null?void 0:i.diff;if(n==null)throw new Error("FileDiff.applyDocumentChange: requires an active edit session");this.detachAdditionLines(),this.hunksRenderer.beginEditSession(n),this.hunksRenderer.applyDocumentChange(t),e!=null&&this.syncEditSessionAnnotationsFromEditor(e),this.rerender(),this.interactionManager.setSelectionDirty()}applySuspendedDocumentChange(t,e){this.applyDocumentChange(t,e),this.hunksRenderer.clearRenderCache()}updateRenderCache(t,e,n={}){var o;const i=(o=this.editSession)==null?void 0:o.diff;if(i==null)throw new Error("FileDiff.updateRenderCache: requires an active edit session");this.detachAdditionLines(),this.hunksRenderer.beginEditSession(i);const{shouldRefreshDiffsView:r,lineCountChangeInFlight:s}=n;if(this.hunksRenderer.updateRenderCache(t,e,s,n.changedDocumentLines,n.documentLineCount)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}r===!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))}detachAdditionLines(){var n;const t=(n=this.editSession)==null?void 0:n.diff,{fileDiff:e}=this;t!=null&&(t.additionLines===(e==null?void 0:e.additionLines)||t.additionLines===t.deletionLines)&&(t.additionLines=[...t.additionLines])}isLineRenderable(t){const e=this.getRenderedDiff();if(e==null)return!0;const{expandUnchanged:n=!1,collapsedContextThreshold:i=1}=this.options;return Cc({fileDiff:e,lineNumber:t,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}getNearestRenderableLine(t,e){const n=this.getRenderedDiff();if(n==null)return t;const{expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options;return Vy({fileDiff:n,lineNumber:t,direction:e,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}revealLine(t){const e=this.getRenderedDiff(),{expandUnchanged:n=!1,collapsedContextThreshold:i=1,expansionLineCount:r=100}=this.options;if(e==null||e.isPartial||n)return!1;const s=this.hunksRenderer.getExpandedHunksMap();for(const[d,c]of e.hunks.entries()){const[u,h]=Vn(c);if(t<u){const f=dt({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:s,hunkIndex:d,collapsedContextThreshold:i}),p=u-f.rangeSize;if(f.renderAll||t<p+f.fromStart||t>=u-f.fromEnd)return!1;const y=t-(p+f.fromStart)+1,v=u-f.fromEnd-t;return y<=v?this.expandHunk(d,"up",y+r):this.expandHunk(d,"down",v+r),!0}if(t<h)return!1}const o=ct({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:s,collapsedContextThreshold:i,errorPrefix:"FileDiff.revealLine"});if(o==null||o.renderAll)return!1;const l=e.hunks[e.hunks.length-1],[,a]=Vn(l);return t<a+o.fromStart||t>=a+o.rangeSize?!1:(this.expandHunk(e.hunks.length,"up",t-(a+o.fromStart)+1+r),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){de(this.handleEditSessionRender)}removeRenderedCode(){var t,e,n,i,r,s;this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),(t=this.bufferBefore)==null||t.remove(),this.bufferBefore=void 0,(e=this.bufferAfter)==null||e.remove(),this.bufferAfter=void 0,(n=this.codeUnified)==null||n.remove(),this.codeUnified=void 0,(i=this.codeDeletions)==null||i.remove(),this.codeDeletions=void 0,(r=this.codeAdditions)==null||r.remove(),this.codeAdditions=void 0,(s=this.pre)==null||s.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){var t;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(),(t=this.gutterUtilityContent)==null||t.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(t){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",e.appendChild(this.placeHolder)}return this.setPlaceholderHeight(t)}setPlaceholderHeight(t){return this.placeHolder==null?!1:(this.placeHolder.style.setProperty("height",`${t}px`),!0)}async primeHighlightCache(t=this.fileDiff){const{workerManager:e}=this;if(t==null||e==null||!e.isWorkingPool()||t.cacheKey==null||En(t))return;const n=this.options.tokenizeMaxLength??1e5;Math.max(t.additionLines.length,t.deletionLines.length)>n||await e.primeDiffHighlightCache(t).catch(i=>{lc(i)||console.error(i)})}cleanChildNodes(){var t,e,n,i,r,s,o,l,a,d,c,u,h,f,p;this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),(t=this.bufferAfter)==null||t.remove(),(e=this.bufferBefore)==null||e.remove(),(n=this.codeAdditions)==null||n.remove(),(i=this.codeDeletions)==null||i.remove(),(r=this.codeUnified)==null||r.remove(),(s=this.errorWrapper)==null||s.remove(),(o=this.headerElement)==null||o.remove(),(l=this.headerPrefix)==null||l.remove(),(a=this.headerFilenameSuffix)==null||a.remove(),(d=this.headerMetadata)==null||d.remove(),(c=this.headerCustom)==null||c.remove(),(u=this.pre)==null||u.remove(),(h=this.spriteSVG)==null||h.remove(),(f=this.themeCSSStyle)==null||f.remove(),(p=this.unsafeCSSStyle)==null||p.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.headerCache.lastRenderedHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(t){const{hunkSeparators:e}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof e!="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 t){const r=i.slotName;let s=this.separatorCache.get(r);if(s==null||!Fv(i,s.hunkData)){s==null||s.element.remove();const o=document.createElement("div");o.style.display="contents",o.slot=i.slotName;const l=e(i,this);l!=null&&o.appendChild(l),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:i}of this.annotationCache.values())i.remove();this.annotationCache.clear();return}const t=new Map(this.annotationCache),{renderAnnotation:e}=this.options,n=this.getLatestAnnotations();if(e!=null&&n.length>0)for(const[i,r]of n.entries()){const s=this.getAnnotationSlotName(r),o=`${i}-${s}`;let l=this.annotationCache.get(o);if(l==null||!Nv(r,l.annotation)){l==null||l.element.remove();const a=e(r);if(a==null)continue;l={element:js(s),annotation:r},l.element.appendChild(a),this.fileContainer.appendChild(l.element),this.annotationCache.set(o,l)}t.delete(o)}for(const[i,{element:r}]of t.entries())this.annotationCache.delete(i),r.remove()}renderGutterUtility(){var i,r;const{renderGutterUtility:t}=this.options;if(this.fileContainer==null||t==null){(i=this.gutterUtilityContent)==null||i.remove(),this.gutterUtilityContent=void 0;return}const e=t(this.interactionManager.getHoveredLine);if(e!=null&&this.gutterUtilityContent!=null)return;if(e==null){(r=this.gutterUtilityContent)==null||r.remove(),this.gutterUtilityContent=void 0;return}const n=Zd();n.appendChild(e),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(t,e){var s;const{fileContainer:n}=this,i=t??n??document.createElement("diffs-container"),r=n!==i;return n!=null&&r&&((s=this.editor)==null||s.__captureFocusForDOMReplacement()),r&&this.emitPostRender(!0),this.fileContainer=i,n!=null&&r&&(this.headerCache.lastRenderedHTML=void 0,this.headerElement=void 0),e!=null&&this.fileContainer.parentNode!==e&&e.appendChild(this.fileContainer),r&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(t){const{shadowRoot:e}=t;if(e!=null)for(const n of e.children)n instanceof SVGElement?this.spriteSVG??(this.spriteSVG=n):zn(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??(this.themeCSSStyle=n),this.hasAdoptedThemeCSS=!0):zn(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??(this.unsafeCSSStyle=n),this.appliedUnsafeCSS??(this.appliedUnsafeCSS=this.options.unsafeCSS??void 0))}ensureSpriteSVG(t){const e=t.shadowRoot??t.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=Yd;const i=n.firstChild;i instanceof SVGElement&&(this.spriteSVG=i)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==e&&e.appendChild(this.spriteSVG)}getOrCreatePreNode(t){var n,i;const e=t.shadowRoot??t.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,e.appendChild(this.pre)):this.pre.parentNode!==e&&((n=this.editor)==null||n.__captureFocusForDOMReplacement(),e.appendChild(this.pre),this.appliedPreAttributes=void 0),(i=this.placeHolder)==null||i.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(t){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(const e of Array.from(t.children))e instanceof HTMLElement&&(e.hasAttribute("data-unified")?this.codeUnified=e:e.hasAttribute("data-deletions")?this.codeDeletions=e:e.hasAttribute("data-additions")&&(this.codeAdditions=e))}applyHeaderToDOM(t,e,n){var p,y,v,m,C,S,w,b;this.cleanupErrorWrapper(),(p=this.placeHolder)==null||p.remove(),this.placeHolder=void 0;const{headerCache:{fileDiff:i,html:r,lastRenderedHTML:s}}=this,o=(n!==((y=this.editSession)==null?void 0:y.diff)&&K(i,n)?r:void 0)??Ce(t);if(this.headerCache.html=o,this.headerCache.fileDiff=n,o!==s){const k=document.createElement("div");k.innerHTML=o;const x=k.firstElementChild;if(!(x instanceof HTMLElement))return;this.headerElement!=null?(v=e.shadowRoot)==null||v.replaceChild(x,this.headerElement):(m=e.shadowRoot)==null||m.prepend(x),this.headerElement=x,this.headerCache.lastRenderedHTML=o}if(this.isContainerManaged)return;const{renderCustomHeader:l,renderHeaderPrefix:a,renderHeaderFilenameSuffix:d,renderHeaderMetadata:c}=this.options;if(l!=null){const k=l(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(e,this.headerCustom,Ls,k),(C=this.headerPrefix)==null||C.remove(),(S=this.headerFilenameSuffix)==null||S.remove(),(w=this.headerMetadata)==null||w.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}const u=(a==null?void 0:a(n))??void 0,h=(d==null?void 0:d(n))??void 0,f=(c==null?void 0:c(n))??void 0;this.headerPrefix=this.upsertHeaderSlotElement(e,this.headerPrefix,ws,u),this.headerFilenameSuffix=this.upsertHeaderSlotElement(e,this.headerFilenameSuffix,xs,h),this.headerMetadata=this.upsertHeaderSlotElement(e,this.headerMetadata,ks,f),(b=this.headerCustom)==null||b.remove(),this.headerCustom=void 0}clearReusableHeader(){this.headerCache.html=void 0,this.headerCache.fileDiff=void 0}clearHeaderSlots(){var t,e,n,i;(t=this.headerPrefix)==null||t.remove(),(e=this.headerFilenameSuffix)==null||e.remove(),(n=this.headerMetadata)==null||n.remove(),(i=this.headerCustom)==null||i.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(t,e,n,i){if(i==null){e==null||e.remove();return}const r=e??this.createHeaderSlotElement(n);return e==null&&t.appendChild(r),this.replaceHeaderSlotContent(r,i),r}replaceHeaderSlotContent(t,e){t.replaceChildren(),e instanceof Element?t.appendChild(e):t.innerText=`${e}`}createHeaderSlotElement(t){const e=document.createElement("div");return e.slot=t,e}injectUnsafeCSS(){var n,i;const{unsafeCSS:t}=this.options,e=(n=this.fileContainer)==null?void 0:n.shadowRoot;if(e!=null){if(t==null||t===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}((i=this.unsafeCSSStyle)==null?void 0:i.parentNode)===e&&this.appliedUnsafeCSS===t||(this.unsafeCSSStyle??(this.unsafeCSSStyle=Jd()),this.unsafeCSSStyle.parentNode!==e&&e.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ks(t),this.appliedUnsafeCSS=t)}}applyThemeState(t,e,n,i){var d,c,u;const r=t.shadowRoot??t.attachShadow({mode:"open"}),s=i??n,o=this.getTheme(),l=typeof o=="string"?o:{...o},a=sn(r);if(((d=this.themeCSSStyle)==null?void 0:d.parentNode)===r&&((c=this.appliedThemeCSS)==null?void 0:c.themeStyles)===e&&this.appliedThemeCSS.themeType===s&&this.appliedThemeCSS.scrollbarGutter===a){this.appliedThemeCSS.theme=l;return}if(this.hasAdoptedThemeCSS&&((u=this.themeCSSStyle)==null?void 0:u.parentNode)===r){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:l,themeStyles:e,themeType:s,baseThemeType:i,scrollbarGutter:a};return}this.themeCSSStyle=Js({shadowRoot:r,currentNode:this.themeCSSStyle,themeCSS:Xs(e,s,a)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:l,themeStyles:e,themeType:s,baseThemeType:i,scrollbarGutter:a}:void 0}hydrateMeasuredScrollbar(){var e;const t=(e=this.fileContainer)==null?void 0:e.shadowRoot;t==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=nc(this.themeCSSStyle.textContent??"",sn(t)))}shouldGuardRebuildScroll(){return this.editor!=null&&sc()}applyHunksToDOM(t,e){this.shouldGuardRebuildScroll()?hs(t,()=>this.replaceCodeColumns(t,e)):this.replaceCodeColumns(t,e)}applyCodeColumnsInPlace(t,e,n){const i=this.getColumnPair(t);if(i==null)return!1;const r=pt(e[0]),s=pt(e[1]);return r==null||s==null?!1:(i.gutter.innerHTML=Ce(r),i.content.innerHTML=Ce(s),n!==this.lastRowCount&&(i.gutter.style.setProperty("grid-row",`span ${n}`),i.content.style.setProperty("grid-row",`span ${n}`)),!0)}replaceCodeColumns(t,e){var c,u,h,f,p,y,v,m,C,S;const{overflow:n="scroll"}=this.options,i=(this.options.hunkSeparators??"line-info")==="line-info",r=n==="wrap"?e.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);let s=!1;const o=[],l=this.hunksRenderer.renderCodeAST("unified",e),a=this.hunksRenderer.renderCodeAST("deletions",e),d=this.hunksRenderer.renderCodeAST("additions",e);(c=this.editor)==null||c.__captureFocusForDOMReplacement(),l!=null?(s=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,(u=this.codeDeletions)==null||u.remove(),this.codeDeletions=void 0,(h=this.codeAdditions)==null||h.remove(),this.codeAdditions=void 0,this.codeUnified=Tn({code:this.codeUnified,columnType:"unified",rowSpan:r,containerSize:i}),this.applyCodeColumnsInPlace(this.codeUnified,l,e.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeUnified)):a!=null||d!=null?(a!=null?(s=this.codeDeletions==null||this.codeUnified!=null,(f=this.codeUnified)==null||f.remove(),this.codeUnified=void 0,this.codeDeletions=Tn({code:this.codeDeletions,columnType:"deletions",rowSpan:r,containerSize:i}),this.applyCodeColumnsInPlace(this.codeDeletions,a,e.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(a)),o.push(this.codeDeletions)):((p=this.codeDeletions)==null||p.remove(),this.codeDeletions=void 0),d!=null?(s=s||this.codeAdditions==null||this.codeUnified!=null,(y=this.codeUnified)==null||y.remove(),this.codeUnified=void 0,this.codeAdditions=Tn({code:this.codeAdditions,columnType:"additions",rowSpan:r,containerSize:i}),this.applyCodeColumnsInPlace(this.codeAdditions,d,e.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(d)),o.push(this.codeAdditions)):((v=this.codeAdditions)==null||v.remove(),this.codeAdditions=void 0)):((m=this.codeUnified)==null||m.remove(),this.codeUnified=void 0,(C=this.codeDeletions)==null||C.remove(),this.codeDeletions=void 0,(S=this.codeAdditions)==null||S.remove(),this.codeAdditions=void 0),o.length===0?t.textContent="":s&&t.replaceChildren(...o),this.lastRowCount=e.rowCount}applyPartialRender({fileDiff:t,previousRenderRange:e,renderRange:n}){const{pre:i,codeUnified:r,codeAdditions:s,codeDeletions:o,options:{diffStyle:l="split"}}=this;if(i==null||e==null||n==null||!Number.isFinite(e.totalLines)||!Number.isFinite(n.totalLines)||this.lastRowCount==null)return!1;const a=this.getCodeColumns(l,r,o,s);if(a==null)return!1;const d=e.startingLine,c=n.startingLine,u=d+e.totalLines,h=c+n.totalLines,f=Math.max(d,c),p=Math.min(u,h);if(p<=f)return!1;const y=Math.max(0,f-d),v=Math.max(0,u-p),m=this.trimColumns({columns:a,trimStart:y,trimEnd:v,previousStart:d,overlapStart:f,overlapEnd:p,diffStyle:l});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 C=this.lastRowCount-m;const S=(x,E)=>{if(!(E<=0))return this.hunksRenderer.renderDiff(t,{startingLine:x,totalLines:E,bufferBefore:0,bufferAfter:0})},w=S(c,Math.max(f-c,0));if(w==null&&c<f)return!1;const b=S(p,Math.max(h-p,0));if(b==null&&h>p)return!1;const k=(x,E)=>{if(x!=null){if(l==="unified"&&!Array.isArray(a))this.insertPartialHTML(l,a,x,E);else if(l==="split"&&Array.isArray(a))this.insertPartialHTML(l,a,x,E);else throw new Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");C+=x.rowCount,this.renderedDiff=x.fileDiff}};return this.cleanupErrorWrapper(),k(w,"afterbegin"),k(b,"beforeend"),this.lastRowCount!==C&&(this.applyRowSpan(l,a,C),this.lastRowCount=C),!0}insertPartialHTML(t,e,n,i){if(t==="unified"&&!Array.isArray(e)){const r=this.hunksRenderer.renderCodeAST("unified",n);this.renderPartialColumn(e,r,i)}else if(t==="split"&&Array.isArray(e)){const r=this.hunksRenderer.renderCodeAST("deletions",n),s=this.hunksRenderer.renderCodeAST("additions",n);this.renderPartialColumn(e[0],r,i),this.renderPartialColumn(e[1],s,i)}else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition")}refreshSplitDiffView(){const t=this.getLatestDiff();if(this.options.diffStyle!=="split"||t==null)return;const e=this.hunksRenderer.renderDiff(t,this.renderRange);if(e==null)return;const n=this.getCodeColumns("split",this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(n))return;const i=(r,s)=>{if(s==null)return;const o=this.hunksRenderer.renderCodeAST(r,e),l=pt(o==null?void 0:o[0]),a=pt(o==null?void 0:o[1]);for(const[d,c]of[[s.gutter,l],[s.content,a]])if(c!=null&&d.childElementCount===c.length)for(let u=0;u<c.length;u++){const h=d.children[u],f=c[u].properties["data-line-type"];f!=null&&h.dataset.lineType!==f&&(h.dataset.lineType=f)}};i("deletions",n[0]),i("additions",n[1]),this.renderedDiff=e.fileDiff}refreshUnifiedDiffView(){const t=this.getLatestDiff();if(this.options.diffStyle!=="unified"||t==null)return;const e=this.hunksRenderer.renderDiff(t,this.renderRange);if(e==null)return;const n=this.getCodeColumns("unified",this.codeUnified,this.codeDeletions,this.codeAdditions);if(n==null||Array.isArray(n))return;const i=this.hunksRenderer.renderCodeAST("unified",e),r=pt(i==null?void 0:i[0]),s=pt(i==null?void 0:i[1]),o=()=>{for(const[l,a]of[[n.gutter,r],[n.content,s]])a!=null&&(l.innerHTML=Ce(a));e.rowCount!==this.lastRowCount&&(this.applyRowSpan("unified",n,e.rowCount),this.lastRowCount=e.rowCount),this.renderedDiff=e.fileDiff};this.shouldGuardRebuildScroll()?hs(this.pre,o):o(),this.renderSeparators(e.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(t,e,n){if(t==null||e==null)return;const i=pt(e[0]),r=pt(e[1]);if(i==null||r==null)throw new Error("FileDiff.insertPartialHTML: Unexpected AST structure");const s=r.at(0);n==="beforeend"&&(s==null?void 0:s.type)==="element"&&typeof s.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(s.properties["data-buffer-size"],t.content.children[t.content.children.length-1],t.gutter.children[t.gutter.children.length-1],i,r,!0);const o=r.at(-1);n==="afterbegin"&&(o==null?void 0:o.type)==="element"&&typeof o.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(o.properties["data-buffer-size"],t.content.children[0],t.gutter.children[0],i,r,!1),t.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i)),t.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r))}mergeBuffersIfNecessary(t,e,n,i,r,s){if(!(e instanceof HTMLElement)||!(n instanceof HTMLElement))return;const o=this.getBufferSize(e.dataset);o!=null&&(s?(i.shift(),r.shift()):(i.pop(),r.pop()),this.updateBufferSize(e,o+t),this.updateBufferSize(n,o+t))}applyRowSpan(t,e,n){const i=r=>{r!=null&&(r.gutter.style.setProperty("grid-row",`span ${n}`),r.content.style.setProperty("grid-row",`span ${n}`))};if(t==="unified"&&!Array.isArray(e))i(e);else if(t==="split"&&Array.isArray(e))i(e[0]),i(e[1]);else throw new Error("dun fuuuuked up")}trimColumnRows(t,e,n){let i=0,r=0,s=0,o=!1;const l=n>=0;if(t==null)return 0;const a=Array.from(t.content.children),d=Array.from(t.gutter.children);if(a.length!==d.length)throw new Error("FileDiff.trimColumnRows: columns do not match");for(;s<a.length&&!(e<=0&&!l&&!o);){const c=d[s],u=a[s];if(s++,!(c instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:c,contentElement:u}),new Error("FileDiff.trimColumnRows: invalid row elements");if(o&&(o=!1,c.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in u.dataset||c.dataset.gutterBuffer==="metadata"&&"noNewline"in u.dataset)){c.remove(),u.remove(),r++;continue}if("lineIndex"in c.dataset&&"lineIndex"in u.dataset){(e>0||l&&i>=n)&&(c.remove(),u.remove(),e>0&&(e--,e===0&&(o=!0)),r++),i++;continue}if("separator"in c.dataset&&"separator"in u.dataset){(e>0||l&&i>=n)&&(c.remove(),u.remove(),r++);continue}if(c.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in u.dataset){(e>0||l&&i>=n)&&(c.remove(),u.remove(),r++);continue}if(c.dataset.gutterBuffer==="metadata"&&"noNewline"in u.dataset){(e>0||l&&i>=n)&&(c.remove(),u.remove(),r++);continue}if(c.dataset.gutterBuffer==="buffer"&&"contentBuffer"in u.dataset){const h=this.getBufferSize(u.dataset);if(h==null)throw new Error("FileDiff.trimColumnRows: invalid element");if(e>0){const f=Math.min(e,h),p=h-f;p>0?(this.updateBufferSize(c,p),this.updateBufferSize(u,p),r+=f):(c.remove(),u.remove(),r+=h),e-=f,e===0&&p===0&&(o=!0)}else if(l){const f=i,p=i+h-1;if(n<=f)c.remove(),u.remove(),r+=h;else if(n<=p){const y=p-n+1,v=h-y;this.updateBufferSize(c,v),this.updateBufferSize(u,v),r+=y}}i+=h;continue}throw console.error({gutterElement:c,contentElement:u}),new Error("FileDiff.trimColumnRows: unknown row elements")}return r}trimColumns({columns:t,diffStyle:e,overlapEnd:n,overlapStart:i,previousStart:r,trimEnd:s,trimStart:o}){const l=Math.max(0,i-r),a=n-r;if(a<0)throw new Error("FileDiff.trimColumns: overlap ends before previous");const d=o>0,c=s>0;if(!d&&!c)return 0;const u=d?l:0,h=c?a:-1;if(e==="unified"&&!Array.isArray(t))return this.trimColumnRows(t,u,h);if(e==="split"&&Array.isArray(t)){const f=this.trimColumnRows(t[0],u,h),p=this.trimColumnRows(t[1],u,h);if(t[0]!=null&&t[1]!=null&&f!==p)throw new Error("FileDiff.trimColumns: split columns out of sync");return t[0]!=null?f:p}else throw console.error({diffStyle:e,columns:t}),new Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(t){const e=Number.parseInt((t==null?void 0:t.bufferSize)??"",10);return Number.isNaN(e)?void 0:e}updateBufferSize(t,e){t.dataset.bufferSize=`${e}`,t.style.setProperty("grid-row",`span ${e}`),t.style.setProperty("min-height",`calc(${e} * 1lh)`)}getColumnPair(t){if(t==null)return;const e=t.children[0],n=t.children[1];if(!(!(e instanceof HTMLElement)||!(n instanceof HTMLElement)||e.dataset.gutter==null||n.dataset.content==null))return{gutter:e,content:n}}getCodeColumns(t,e,n,i){if(t==="unified")return this.getColumnPair(e);{const r=this.getColumnPair(n),s=this.getColumnPair(i);return r!=null||s!=null?[r,s]:void 0}}updateBuffers(t){this.pre!=null&&this.applyBuffers(this.pre,t)}applyBuffers(t,e){if(e==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}e.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",t.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${e.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),e.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",t.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${e.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(t,{additionsContentAST:e,deletionsContentAST:n,totalLines:i},r){const{diffIndicators:s="bars",disableBackground:o=!1,disableLineNumbers:l=!1,overflow:a="scroll",diffStyle:d="split"}=this.options,c={type:"diff",diffIndicators:s,disableBackground:o,disableLineNumbers:l,overflow:a,split:d==="unified"?!1:e!=null&&n!=null,totalLines:i,customProperties:r};Qd(c,this.appliedPreAttributes)||(Qs(t,c),this.appliedPreAttributes=c)}applyErrorToDOM(t,e){var s;this.cleanupErrorWrapper(),(s=this.pre)==null||s.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=e.shadowRoot??e.attachShadow({mode:"open"});this.errorWrapper??(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=t.message,this.errorWrapper.appendChild(i);const r=document.createElement("pre");r.dataset.errorStack="",r.innerText=t.stack??"No Error Stack",this.errorWrapper.appendChild(r)}cleanupErrorWrapper(){var t;(t=this.errorWrapper)==null||t.remove(),this.errorWrapper=void 0}},g(Vr,"LoadedCustomComponent",!0),Vr);function Gv(t){return{name:t.name,lang:t.lang,contents:t.additionLines.join("")}}function Pa(t,e){return t==null||e==null?t==null&&e==null:In(t,e)}function Wv({fileDiff:t,oldFile:e,newFile:n}){return t!=null&&t.hunks.length>0||e!=null||n!=null}function jv({fileDiff:t,oldFile:e,newFile:n}){return t!=null||e!=null||n!=null}function qv(t,e,n=!1){return!n&&t==null&&e}function Kv(t,e,n=!1){return t==null&&e&&!n}function pt(t){if(!(t==null||t.type!=="element"))return t.children??[]}function Xv({fileDiff:t,metrics:e,disableFileHeader:n,hunkSeparators:i,expandUnchanged:r,expandedHunks:s,collapsedContextThreshold:o,canHydratePartialDiff:l}){var h,f,p;let a=at(e,n),d=a;const c=r?!0:s,u=t.hunks.length-1;for(let y=0;y<t.hunks.length;y++){const v=t.hunks[y];if(v==null)throw new Error("computeEstimatedDiffHeights: invalid hunk index");const m=dt({isPartial:t.isPartial,rangeSize:v.collapsedBefore,expandedHunks:c,hunkIndex:y,collapsedContextThreshold:o}),C=(m.fromStart+m.fromEnd)*e.lineHeight;if(a+=C,d+=C,m.collapsedLines>0){const b=((h=Ln({type:i,metrics:e,hunkIndex:y,hunkSpecs:v.hunkSpecs}))==null?void 0:h.totalHeight)??0;a+=b,d+=b}a+=v.splitLineCount*e.lineHeight,d+=v.unifiedLineCount*e.lineHeight;const S=Yv(v);a+=S.split*e.lineHeight,d+=S.unified*e.lineHeight;const w=y===u?ct({fileDiff:t,hunkIndex:y,expandedHunks:c,collapsedContextThreshold:o,errorPrefix:"computeEstimatedDiffHeights"}):void 0;if(w!=null){const b=(w.fromStart+w.fromEnd)*e.lineHeight;if(a+=b,d+=b,w.collapsedLines>0){const k=((f=Rt({type:i,metrics:e}))==null?void 0:f.totalHeight)??0;a+=k,d+=k}}else if(y===u&&t.isPartial&&l){const b=((p=Rt({type:i,metrics:e}))==null?void 0:p.totalHeight)??0;a+=b,d+=b}}if(t.hunks.length>0){const y=Wi(e);a+=y,d+=y}return{splitHeight:a,unifiedHeight:d}}function Yv(t){if(!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return{split:0,unified:0};const e=t.hunkContent.at(-1);if(e==null)return{split:0,unified:0};if(e.type==="context"){const n=e.lines>0?1:0;return{split:n,unified:n}}return Qv(t,e)}function Qv(t,e){const n=(e.deletions>0&&t.noEOFCRDeletions?1:0)+(e.additions>0&&t.noEOFCRAdditions?1:0),i=e.deletions>0&&t.noEOFCRDeletions,r=e.additions>0&&t.noEOFCRAdditions;return{split:i||r?1:0,unified:n}}const bs=3e3,gi=new Map;let Zv=-1;var Jv=class extends Rc{constructor(e,n,i,r,s=!1){super(e,r,s);g(this,"__id",`little-virtualized-file-diff:${++Zv}`);g(this,"renderType","virtualized");g(this,"top");g(this,"height",0);g(this,"metrics");g(this,"cache",{heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:gi,ghostTextRowsByIndex:new Map});g(this,"isVisible",!1);g(this,"isSetup",!1);g(this,"virtualizer");g(this,"layoutDirty",!0);g(this,"forceRenderOverride");g(this,"currentCollapsed");g(this,"pendingHydratedDiff");g(this,"pendingExpansions");g(this,"pendingRender");g(this,"onRender",e=>this.fileContainer==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render()));g(this,"expandHunk",(e,n,i)=>{this.fileDiff!=null&&(this.loadFilesIfNecessary(),this.isAdvancedMode()?(this.pendingExpansions??(this.pendingExpansions=[]),this.pendingExpansions.push({hunkIndex:e,direction:n,expansionLineCountOverride:i})):(this.hunksRenderer.expandHunk(e,n,i),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))});this.virtualizer=n,this.metrics=ki(i)}setMetrics(e,n=!1){const i=ki(e);!n&&nn(this.metrics,i)||(this.metrics=i,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&(this.forceRenderOverride=!0)}syncLineAnnotations(e){return e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0?!1:(super.setLineAnnotations(e),!0)}syncEditSessionAnnotationsFromEditor(e){return super.syncEditSessionAnnotationsFromEditor(e)?(this.forceRenderOverride=!0,!0):!1}setFileAnnotationHeight(e){const n=this.cache.fileAnnotationHeight;return e===n?!1:(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-n,!0)}hasFileAnnotations(e){const n=this.getLatestAnnotations();return qd(n)?n.some(i=>i.lineNumber!==0?!1:e.type==="new"?i.side==="additions":e.type==="deleted"?i.side==="deletions":!0):!1}getLineHeight(e,n=!1){return this.getEstimatedLineHeight(n)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){const n=e?2:1;return this.metrics.lineHeight*n}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:n}=this,i=!Vs(n,e),r=i&&sC(n,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:oC(n,e)}),i&&(this.forceRenderOverride=!0),i&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}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:n=!1,resetRenderRange:i=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal=0,this.cache.ghostTextRows=gi,this.cache.ghostTextRowsByIndex.size>0&&this.cache.ghostTextRowsByIndex.clear(),this.invalidateDerivedLayoutCache(n,i),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,n=!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&&n&&(this.renderRange=void 0)}applyGhostTextRows(e,n){const{cache:{heightDeltas:i,ghostTextRows:r,ghostTextRowsByIndex:s},metrics:{lineHeight:o}}=this;if(r===n)return!1;const l=this.getDiffStyle(),a=new Map;for(const[c,u]of n){const h=this.getLineIndexForDiff(e,c+1,"additions");h!=null&&a.set(l==="split"?h[1]:h[0],u)}let d=!1;for(const c of new Set([...s.keys(),...a.keys()])){const u=((a.get(c)??0)-(s.get(c)??0))*o;if(u===0)continue;const h=(i.get(c)??0)+u;h===0?i.delete(c):i.set(c,h),this.cache.measuredHeightDeltaTotal+=u,d=!0}return this.cache.ghostTextRows=n,this.cache.ghostTextRowsByIndex=a,d}reconcileHeights(){var d;let e=!1;const{options:{overflow:n="scroll"},metrics:{lineHeight:i}}=this,r=this.placeHolder!=null?this.getLayoutDiff():this.getRenderedDiff();if(this.fileContainer==null||r==null)return this.height!==0&&(e=!0),this.height=0,e;this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(r,((d=this.editor)==null?void 0:d.__getGhostTextRows())??gi);const{ghostTextRowsByIndex:s}=this.cache,o=n!=="scroll"||this.getLatestAnnotations().length>0||this.isResizeDebuggingEnabled();if(this.placeHolder!=null||!o&&this.cache.heightDeltas.size===0&&this.cache.fileAnnotationHeight===0)return e&&(this.computeApproximateSize(!0),this.setPlaceholderHeight(this.height)),e;const l=this.getDiffStyle(),a=l==="split"?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];if(this.renderRange!=null&&or(this.renderRange)){const c=eC(a)??0;this.setFileAnnotationHeight(c)&&(e=!0)}for(const c of a){if(c==null)continue;const u=c.children[1];if(!(u instanceof HTMLElement))continue;const h=l==="split"&&c===this.codeDeletions;for(const f of u.children){if(!(f instanceof HTMLElement))continue;const p=f.dataset.lineIndex;if(p==null)continue;const y=lC(p,l),v=s.get(y)??0;if(h&&v>0)continue;const m=this.cache.heightDeltas.get(y)??0;if(!o&&m===v*i)continue;let C=f.getBoundingClientRect().height+v*i,S=!1;f.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in f.nextElementSibling.dataset||"noNewline"in f.nextElementSibling.dataset)&&("noNewline"in f.nextElementSibling.dataset&&(S=!0),C+=f.nextElementSibling.getBoundingClientRect().height);const w=this.getEstimatedLineHeight(S),b=C-w;b!==m&&(e=!0,this.cache.measuredHeightDeltaTotal+=b-m,b===0?this.cache.heightDeltas.delete(y):this.cache.heightDeltas.set(y,b))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}updateCodeViewLayout(e,n,i,r){let s=!1,o=!1;const{pendingExpansions:l,pendingHydratedDiff:a,options:{collapsed:d=!1}}=this;if(a!=null&&(this.pendingHydratedDiff=void 0,a.expectedDiff===e&&(Object.assign(e,a.nextDiff),this.setHydratedState(a.files),this.installHydratedSessionDiff(e),this.forceRenderOverride=!0,s=!0,o=!0)),l!=null){this.pendingExpansions=void 0;for(const{hunkIndex:y,direction:v,expansionLineCountOverride:m}of l)this.hunksRenderer.expandHunk(y,v,m),this.forceRenderOverride=!0,o=!0}const c=this.updateExternalDiff(e,r),{pendingRenderDiff:u,layoutDiffChanged:h,renderedDiffChanged:f,annotationsChanged:p}=this.updatePendingRender(e,r);return!this.forceRenderOverride&&(c||f||p)&&(this.forceRenderOverride=!0),((i==null?void 0:i.resetDiffLayoutCache)===!0||h)&&(s=!0),(h||(i==null?void 0:i.resetDiffLayoutCache)===!0&&i.includeEstimatedDiffHeights)&&(o=!0),(i==null?void 0:i.metrics)!=null&&(this.metrics=ki(i.metrics),s=!0,o=!0),this.currentCollapsed!==d&&(this.currentCollapsed=d,s=!0),s?this.resetLayoutCache({includeEstimatedHeights:o}):o&&this.invalidateDerivedLayoutCache(!0),this.top=n,this.computeApproximateSize(!1,u),this.height}getLinePosition(e,n="additions"){const i=this.getLayoutDiff();if(i==null||e<1)return;const r=this.getLineIndexForDiff(i,e,n);if(r==null)return;const{disableFileHeader:s=!1,expandUnchanged:o=!1,collapsed:l=!1,collapsedContextThreshold:a=1}=this.options,d=this.getDiffStyle(),c=this.getHunkSeparatorType(),u=d==="split"?r[1]:r[0];this.approximateLayoutCheckpoints(i);const h=at(this.metrics,s),f=this.getLayoutCheckpointBeforeLineIndex(u);let p=(f==null?void 0:f.top)??h+this.cache.fileAnnotationHeight;if(l)return{top:Un(this.metrics,s),height:0};let y;return Dt({diff:i,diffStyle:d,startingLine:(f==null?void 0:f.renderedLineIndex)??0,expandedHunks:o?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:a,callback:({hunkIndex:v,hunk:m,collapsedBefore:C,collapsedAfter:S,deletionLine:w,additionLine:b})=>{const k=d==="split"?(b==null?void 0:b.splitLineIndex)??(w==null?void 0:w.splitLineIndex):(b==null?void 0:b.unifiedLineIndex)??(w==null?void 0:w.unifiedLineIndex);if(k==null)throw new Error("VirtualizedFileDiff.getLinePosition: missing line index data");if(C>0){const E=Ln({type:c,metrics:this.metrics,hunkIndex:v,hunkSpecs:m==null?void 0:m.hunkSpecs});if(E!=null){if(p+=E.gapBefore,u>=k-C&&u<k)return y={top:p,height:E.height},!0;p+=E.height+E.gapAfter}}const x=this.getLineHeight(k,((b==null?void 0:b.noEOFCR)??!1)||((w==null?void 0:w.noEOFCR)??!1));if(k===u)return y={top:p,height:x},!0;if(p+=x,S>0){const E=Rt({type:c,metrics:this.metrics});if(E!=null){if(u>k&&u<=k+S)return y={top:p+E.gapBefore,height:E.height},!0;p+=E.totalHeight}}return!1}}),y}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){const n=this.getLayoutDiff();if(n==null)return;const{disableFileHeader:i=!1,expandUnchanged:r=!1,collapsed:s=!1,collapsedContextThreshold:o=1}=this.options;if(s)return;const l=this.getDiffStyle(),a=this.getHunkSeparatorType();this.approximateLayoutCheckpoints(n);const d=this.getLayoutCheckpointBeforeTop(e);let c=(d==null?void 0:d.top)??at(this.metrics,i)+this.cache.fileAnnotationHeight,u;return Dt({diff:n,diffStyle:l,startingLine:(d==null?void 0:d.renderedLineIndex)??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:h,hunk:f,collapsedBefore:p,collapsedAfter:y,deletionLine:v,additionLine:m})=>{const C=l==="split"?(m==null?void 0:m.splitLineIndex)??(v==null?void 0:v.splitLineIndex):(m==null?void 0:m.unifiedLineIndex)??(v==null?void 0:v.unifiedLineIndex);if(C==null)throw new Error("VirtualizedFileDiff.getNumericScrollAnchor: missing line index data");if(p>0){const w=Ln({type:a,metrics:this.metrics,hunkIndex:h,hunkSpecs:f==null?void 0:f.hunkSpecs});w!=null&&(c+=w.totalHeight)}if(c>=e&&(v!=null?u={lineNumber:v.lineNumber,side:"deletions",top:c}:m!=null&&(u={lineNumber:m.lineNumber,side:"additions",top:c}),u!=null))return!0;const S=this.getLineHeight(C,((m==null?void 0:m.noEOFCR)??!1)||((v==null?void 0:v.noEOFCR)??!1));if(c+=S,y>0){const w=Rt({type:a,metrics:this.metrics});w!=null&&(c+=w.totalHeight)}return!1}}),u}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){const n=this.getLayoutDiff();if(this.top==null||n==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const i=e!=null?this.computeRenderRangeFromWindow(n,this.top,e):this.renderRange;if(i==null)return;const{bufferBefore:r,bufferAfter:s,totalLines:o}=i;let l=0;if(o===0){const a=e??this.virtualizer.getWindowSpecs();this.top<a.top&&(l=s)}return{topOffset:this.top+r+l,height:this.height-(r+s)}}cleanUp(e=!1){var r;const n=this.cache.ghostTextRows.size>0;n&&(this.layoutDirty=!0);const i=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(n||!K(this.getRenderedDiff(),this.getLatestDiff()));this.fileContainer!=null&&this.isSimpleMode()&&((r=this.getSimpleVirtualizer())==null||r.disconnect(this.fileContainer)),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),i&&this.virtualizer.instanceChanged(this,!0)}async handleFilesLoaded(e,n){if(!(this.fileDiff!==e||!e.isPartial)){if(this.isAdvancedMode()){const i=fs("clone",e,n);if(await Cs(()=>this.primeHighlightCache(i)),this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:i,files:n}}else{if(fs("merge",e,n),this.setHydratedState(n),!this.installHydratedSessionDiff(e)&&(await Cs(()=>this.primeHighlightCache(e)),this.fileDiff!==e))return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}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:n}=this,i=this.getRenderedDiff();if(n==null||n.length===0||i==null)return!1;const{expansionLineCount:r=100,collapsedContextThreshold:s=1}=this.options,o=new Map(this.hunksRenderer.getExpandedHunksMap());for(const l of n){const a={...o.get(l.hunkIndex)??{fromStart:0,fromEnd:0}},d=l.expansionLineCountOverride??r;(l.direction==="up"||l.direction==="both")&&(a.fromStart+=d),(l.direction==="down"||l.direction==="both")&&(a.fromEnd+=d),o.set(l.hunkIndex,a)}return Cc({fileDiff:i,lineNumber:e,expandedHunks:o,collapsedContextThreshold:s})}invalidateEditSessionLayout(){var e,n;(e=this.getSimpleVirtualizer())==null||e.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),(n=this.getSimpleVirtualizer())==null||n.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(){if(!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null)return;const e=this.getLatestDiff(),n=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!K(this.getRenderedDiff(),n))}syncGhostTextRows(){var n;const e=this.getAdvancedVirtualizer();e!=null?(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0)):(n=this.getSimpleVirtualizer())==null||n.requestHeightReconcile(this)}applyDocumentChange(e,n,i=!1){var o,l;const{renderRange:r}=this;(o=this.getAdvancedVirtualizer())==null||o.capturePendingLayoutAnchor(),super.applyDocumentChange(e,n),(l=this.getSimpleVirtualizer())==null||l.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1});const s=this.getRenderedDiff();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(i&&r!=null&&s!=null){const a=this.virtualizer.getWindowSpecs(),d=this.computeRenderRangeFromWindow(s,this.top??0,a);d.bufferAfter!==r.bufferAfter&&this.updateBuffers(d)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,n=this.getLayoutDiff()){var l;const i=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!i)return;const r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,n==null){this.layoutDirty=!1;return}this.applyGhostTextRows(n,((l=this.editor)==null?void 0:l.__getGhostTextRows())??gi);const{disableFileHeader:s=!1,collapsed:o=!1}=this.options;if(o){this.height+=Un(this.metrics,s),this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(n)+this.cache.measuredHeightDeltaTotal,i&&!r&&this.validateComputedHeight(n),this.layoutDirty=!1}getLayoutDiff(){var e;return((e=this.pendingRender)==null?void 0:e.diff)??this.getRenderedDiff()}getActiveEstimatedHeight(e=this.getLayoutDiff()){this.ensureEstimatedDiffHeights(e);const n=this.getDiffStyle()==="split"?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(n==null)throw new Error("VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height");return n}ensureEstimatedDiffHeights(e=this.getLayoutDiff()){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:n=!1,expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:s,unifiedHeight:o}=Xv({fileDiff:e,metrics:this.metrics,disableFileHeader:n,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:i,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Fr(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=s,this.cache.estimatedUnifiedHeight=o}validateComputedHeight(e=this.getLayoutDiff()){if(this.fileContainer==null||e==null)return;const n=this.fileContainer.getBoundingClientRect();n.height!==this.height?console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:e.name,elementHeight:n.height,computedHeight:this.height}):console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}render({fileContainer:e,fileDiff:n,forceRender:i=!1,lineAnnotations:r,...s}={}){var x;const o=Ss(s,"VirtualizedFileDiff.render"),l=o!=null,a=o==null?void 0:o.oldFile,d=o==null?void 0:o.newFile,c=l&&(!Ha(a,this.deletionFile)||!Ha(d,this.additionFile));let u=n??this.fileDiff;n==null&&l&&(c||this.fileDiff==null)&&(u=Nt(o.oldFile,o.newFile,this.options.parseDiffOptions));const{forceRenderOverride:h,isSetup:f}=this;this.forceRenderOverride=void 0;const p=u!=null&&!K(this.fileDiff,u),y=p||c;if(e=this.getOrCreateFileContainer(e),u==null)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;p&&this.updateExternalDiff(u,r);const{pendingRenderDiff:v,layoutDiffChanged:m,renderedDiffChanged:C,annotationsChanged:S}=this.pendingRender!=null&&this.pendingRender.latestDiff===(this.getLatestDiff(u)??u)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(u,r);if(m&&this.resetLayoutCache({includeEstimatedHeights:!0}),f)this.top??(this.top=this.getVirtualizedTop()),this.layoutDirty&&this.isSimpleMode()&&((x=this.getSimpleVirtualizer())==null||x.markDOMDirty(),this.computeApproximateSize(!1,v));else{this.computeApproximateSize(!1,v);const E=this.getSimpleVirtualizer();if(this.top??(this.top=this.getVirtualizedTop()),this.isAdvancedMode())this.isVisible=!0;else{if(E==null)throw new Error("VirtualizedFileDiff.render: simple virtualizer is not available");E.connect(e,this),this.isVisible=E.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!y||!f))return o!=null&&(this.deletionFile=a,this.additionFile=d),p&&this.clearReusableHeader(),this.renderPlaceholder(this.height);const w=this.virtualizer.getWindowSpecs(),b=this.top??0,k=this.computeRenderRangeFromWindow(v,b,w);return super.render({fileDiff:u,fileContainer:e,renderRange:k,lineAnnotations:r,forceRender:(h??i)||S||C||p,...o,...s})}finalizeRender(){var e,n;if(!K(this.getRenderedDiff(),(e=this.pendingRender)==null?void 0:e.diff))throw new Error("VirtualizedFileDiff.render: rendered a different diff than its prepared layout");this.pendingRender=void 0,this.isSimpleMode()&&((n=this.getSimpleVirtualizer())==null||n.requestHeightReconcile(this))}updatePendingRender(e,n){const i=this.getLatestDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:s}=this,o=(s==null?void 0:s.diff)??r,l=this.hunksRenderer.getDiffForNextRender(i);return this.pendingRender={latestDiff:i,diff:l},{pendingRenderDiff:l,annotationsChanged:this.syncLineAnnotations(n),layoutDiffChanged:!K(o,l),renderedDiffChanged:!K(r,l)}}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(){var e;return((e=this.getSimpleVirtualizer())==null?void 0:e.config.resizeDebugging)??!1}getDiffStyle(){return this.options.diffStyle??"split"}getHunkSeparatorType(){return aC(this.options.hunkSeparators)}approximateLayoutCheckpoints(e){var p,y,v;if(!this.layoutDirty&&this.cache.checkpoints.length>0||e.hunks.length===0||this.options.collapsed===!0)return;const{disableFileHeader:n=!1,expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options,s=e.hunks.length-1,o=Fr(e,this.options.loadDiffFiles!=null),l=this.getDiffStyle(),a=this.getHunkSeparatorType(),d=i?!0:this.hunksRenderer.getExpandedHunksMap(),c=tC(this.cache.heightDeltas);let u=at(this.metrics,n)+this.cache.fileAnnotationHeight,h=0;const f=({rowCount:m,startLineIndex:C,preSeparatorHeight:S=0,postSeparatorHeight:w=0,metadataOffsets:b=[]})=>{if(m<=0)return;const k=h,x=h+m;let E=nC(k);for(;E<x;){const R=E-k,A=u+(R>0?S:0)+R*this.metrics.lineHeight+iC(b,R)*this.metrics.lineHeight+Ma(c,C,C+R);this.cache.checkpoints.push({renderedLineIndex:E,lineIndex:C+R,top:A}),E+=bs}u+=S+m*this.metrics.lineHeight+b.length*this.metrics.lineHeight+Ma(c,C,C+m)+w,h=x};for(let m=0;m<e.hunks.length;m++){const C=e.hunks[m];if(C==null)throw new Error("VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index");const S=dt({isPartial:e.isPartial,rangeSize:C.collapsedBefore,expandedHunks:d,hunkIndex:m,collapsedContextThreshold:r}),w=S.collapsedLines>0?((p=Ln({type:a,metrics:this.metrics,hunkIndex:m,hunkSpecs:C.hunkSpecs}))==null?void 0:p.totalHeight)??0:0;f({rowCount:S.fromStart,startLineIndex:(l==="split"?C.splitLineStart:C.unifiedLineStart)-S.rangeSize});let b=w;f({rowCount:S.fromEnd,startLineIndex:(l==="split"?C.splitLineStart:C.unifiedLineStart)-S.fromEnd,preSeparatorHeight:b}),S.fromEnd>0&&(b=0);const k=m===s?ct({fileDiff:e,hunkIndex:m,expandedHunks:d,collapsedContextThreshold:r,errorPrefix:"VirtualizedFileDiff"}):void 0,x=k!=null&&k.collapsedLines>0?((y=Rt({type:a,metrics:this.metrics}))==null?void 0:y.totalHeight)??0:m===s&&o?((v=Rt({type:a,metrics:this.metrics}))==null?void 0:v.totalHeight)??0:0,E=k!=null?k.fromStart+k.fromEnd:0,R=l==="split"?C.splitLineCount:C.unifiedLineCount,A=l==="split"?C.splitLineStart:C.unifiedLineStart;f({rowCount:R,startLineIndex:A,preSeparatorHeight:b,postSeparatorHeight:E===0?x:0,metadataOffsets:rC({diffStyle:l,hunk:C,rowCount:R})}),k!=null&&E>0&&f({rowCount:E,startLineIndex:A+R,postSeparatorHeight:x})}this.cache.totalLines=h}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let n=0,i=this.cache.checkpoints.length-1,r;for(;n<=i;){const s=n+i>>1,o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");o.lineIndex<=e?(r=o,n=s+1):i=s-1}return r}getLayoutCheckpointBeforeTop(e,n){let i=0,r=this.cache.checkpoints.length-1,s=-1;for(;i<=r;){const o=i+r>>1,l=this.cache.checkpoints[o];if(l==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");l.top<=e?(s=o,i=o+1):r=o-1}if(n==null)return s>=0?this.cache.checkpoints[s]:void 0;for(let o=s;o>=0;o--){const l=this.cache.checkpoints[o];if(l==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");if(l.renderedLineIndex%n===0)return l}}getExpandedLineCount(e,n){let i=0;if(e.isPartial){for(const a of e.hunks)i+=n==="split"?a.splitLineCount:a.unifiedLineCount;return i}const{expandUnchanged:r=!1,collapsedContextThreshold:s=1}=this.options,o=r?!0:this.hunksRenderer.getExpandedHunksMap();for(const[a,d]of e.hunks.entries()){const c=n==="split"?d.splitLineCount:d.unifiedLineCount;i+=c;const u=Math.max(d.collapsedBefore,0),{fromStart:h,fromEnd:f,renderAll:p}=dt({isPartial:e.isPartial,rangeSize:u,expandedHunks:o,hunkIndex:a,collapsedContextThreshold:s});u>0&&(i+=p?u:h+f)}const l=ct({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:o,collapsedContextThreshold:s,errorPrefix:"VirtualizedFileDiff"});return l!=null&&(i+=l.fromStart+l.fromEnd),i}getLayoutLineCount(e,n){const i=this.getExpandedLineCount(e,n),r=n==="split"?e.splitLineCount:e.unifiedLineCount;return Math.max(i,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,n,{top:i,bottom:r}){const{disableFileHeader:s=!1,expandUnchanged:o=!1,collapsedContextThreshold:l=1}=this.options,{hunkLineCount:a,lineHeight:d}=this.metrics,c=this.getDiffStyle(),u=this.getHunkSeparatorType(),h=Fr(e,this.options.loadDiffFiles!=null),f=this.height;let p=this.getLayoutLineCount(e,c);const y=at(this.metrics,s),v=e.hunks.length>0?Wi(this.metrics):0,{fileAnnotationHeight:m}=this.cache,C=y+m,S=Math.max(0,f-y-m-v),w=this.hasFileAnnotations(e),b=n+y,k=m>0&&w&&b<r&&b+m>i;if(n<i-f||n>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-y-v};if(p<=a||e.hunks.length===0)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,c);const x=Math.ceil(Math.max(r-i,0)/d),E=Math.ceil(x/a)*a+a,R=E/a,A=R,D=[],I=(i+r)/2,_=this.getLayoutCheckpointBeforeTop(Math.max(0,i-n-E*d*2),a);let H=n+((_==null?void 0:_.top)??C),U=(_==null?void 0:_.renderedLineIndex)??0,V,P,N;if(Dt({diff:e,diffStyle:c,startingLine:(_==null?void 0:_.renderedLineIndex)??0,expandedHunks:o?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:l,callback:({hunkIndex:xt,hunk:le,collapsedBefore:Ut,collapsedAfter:hn,deletionLine:Fe,additionLine:$e})=>{var gn;const fn=$e!=null?$e.splitLineIndex:Fe.splitLineIndex,pn=$e!=null?$e.unifiedLineIndex:Fe.unifiedLineIndex,G=(($e==null?void 0:$e.noEOFCR)??!1)||((Fe==null?void 0:Fe.noEOFCR)??!1),_e=xt===e.hunks.length-1&&le!=null&&(c==="split"?fn===le.splitLineStart+le.splitLineCount-1:pn===le.unifiedLineStart+le.unifiedLineCount-1),xe=((gn=Ut>0?Ln({type:u,metrics:this.metrics,hunkIndex:xt,hunkSpecs:le==null?void 0:le.hunkSpecs}):void 0)==null?void 0:gn.totalHeight)??0;H+=xe;const ut=U%a===0,ke=Math.floor(U/a);if(ut&&(D[ke]=H-(n+C+xe),N!=null)){if(N<=0)return!0;N--}const Me=this.getLineHeight(c==="split"?fn:pn,G);if(H>i-Me&&H<r&&(V??(V=ke)),P==null&&H+Me>I&&(P=ke),N==null&&H>=r&&ut&&(N=A),U++,H+=Me,hn>0||_e&&h){const pe=Rt({type:u,metrics:this.metrics});pe!=null&&(H<r&&H+pe.totalHeight>i&&(V??(V=ke)),P==null&&H+pe.totalHeight>I&&(P=ke),H+=pe.totalHeight)}return!1}}),V==null)if(k)V=0,P=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-y-v};P??(P=V);const B=Math.round(P-R/2),ae=Math.max(0,Math.ceil(p/a)-R),F=Math.max(0,Math.min(B,ae)),z=F*a,q=B<0?E+B*a:E,Y=D[F]??0,Re=z===0?0:m+Y,Ae=F+q/a,Pe=Ae<D.length?S-D[Ae]:S-(H-n-C);return{startingLine:z,totalLines:q,bufferBefore:Re,bufferAfter:Math.max(0,Pe)}}};function eC(t){let e;for(const n of t){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===jd&&(e=Math.max(e??0,r.getBoundingClientRect().height))}return e}function tC(t){const e=Array.from(t).sort((s,o)=>s[0]-o[0]),n=[],i=[0];let r=0;for(const[s,o]of e)n.push(s),r+=o,i.push(r);return{lineIndexes:n,prefixTotals:i}}function Ma({lineIndexes:t,prefixTotals:e},n,i){if(n>=i||t.length===0)return 0;const r=Da(t,n);return(e[Da(t,i)]??0)-(e[r]??0)}function Da(t,e){let n=0,i=t.length;for(;n<i;){const r=n+i>>1,s=t[r];if(s==null)throw new Error("VirtualizedFileDiff: invalid prefix index");s<e?n=r+1:i=r}return n}function nC(t){return Math.ceil(t/bs)*bs}function iC(t,e){let n=0;for(const i of t)i<e&&n++;return n}function rC({diffStyle:t,hunk:e,rowCount:n}){if(n<=0||!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return[];const i=e.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(t==="split")return r>0&&(e.noEOFCRAdditions||e.noEOFCRDeletions)?[n-1]:[];const o=[],l=n-s;return i.deletions>0&&e.noEOFCRDeletions&&o.push(l+i.deletions-1),i.additions>0&&e.noEOFCRAdditions&&o.push(n-1),o}function sC(t,e){return(t.diffStyle??"split")!==(e.diffStyle??"split")||(t.overflow??"scroll")!==(e.overflow??"scroll")||(t.collapsed??!1)!==(e.collapsed??!1)||(t.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(t.disableFileHeader??!1)!==(e.disableFileHeader??!1)||(t.diffIndicators??"bars")!==(e.diffIndicators??"bars")||(t.hunkSeparators??"line-info")!==(e.hunkSeparators??"line-info")||!!t.loadDiffFiles!=!!e.loadDiffFiles||(t.expandUnchanged??!1)!==(e.expandUnchanged??!1)||(t.collapsedContextThreshold??1)!==(e.collapsedContextThreshold??1)||t.unsafeCSS!==e.unsafeCSS}function oC(t,e){return(t.disableFileHeader??!1)!==(e.disableFileHeader??!1)||(t.hunkSeparators??"line-info")!==(e.hunkSeparators??"line-info")||!!t.loadDiffFiles!=!!e.loadDiffFiles||(t.expandUnchanged??!1)!==(e.expandUnchanged??!1)||(t.collapsedContextThreshold??1)!==(e.collapsedContextThreshold??1)}function Fr(t,e){return t.isPartial&&e&&(t.type==="change"||t.type==="rename-changed")}function aC(t){return typeof t=="function"?"custom":t??"line-info"}function Ha(t,e){return t==null||e==null?t==null&&e==null:In(t,e)}function lC(t,e){const[n,i]=t.split(",").map(Number);return e==="split"?i:n}function dC(t,e){return t==null||e==null?t===e:t.header!==e.header||t.footer!==e.footer?!1:cC(t.items,e.items)}function cC(t,e){if(t==null||e==null)return t===e;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){const i=t[n],r=e[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 uC(t,e,n){const i=document.createElement("div");return i.style.display="flow-root",t==="header"?(i.setAttribute(tu,""),e.before(i)):(i.setAttribute(nu,""),e.after(i)),n==null||n.observe(i),i}function qe(t){const e=window.devicePixelRatio??1;return Math.round(t*e)/e}const hC=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","diffStyle","diffIndicators","disableBackground","expandUnchanged","loadDiffFiles","parseDiffOptions","collapsedContextThreshold","lineDiffType","maxLineDiffLength","expansionLineCount","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],fC=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],Oa=["renderCustomHeader","renderHeaderPrefix","renderHeaderFilenameSuffix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","onPostRender","onGutterUtilityClick","onLineClick","onLineNumberClick","onLineEnter","onLineLeave","onTokenClick","onTokenEnter","onTokenLeave"],Na=["onLineSelected","onLineSelectionStart","onLineSelectionChange","onLineSelectionEnd"],_c=Symbol("CodeView.itemOptionsState");function Fa(t,e){Object.defineProperty(t,_c,{configurable:!1,enumerable:!1,value:e})}function gt(t){return t[_c]}function Ue(t,e,n){Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get(){return n(this)}})}const pC=120,$a=1,za="--diffs-overflow-override";function Tc(t,e,n){return{containerHeight:t,triggerTop:e,targetTop:n,targetBottom:t-n,threshold:t-e}}const gC=Tc(12e6,1e6,2e6),mC=Tc(2**22,5e5,1e6);function yC(t){if(t==null)throw new Error("CodeView: createEditor is required for items with edit: true")}const vC=(()=>{const{navigator:t}=globalThis,e=t.userAgent,n=/iP(?:hone|ad|od)/.test(e),i=t.platform==="MacIntel"&&t.maxTouchPoints>1;return(n||i)&&/AppleWebKit/.test(e)&&/Safari/.test(e)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(e)})();var ye,TS=(ye=class{constructor(e={theme:j},n,i=!1){g(this,"type","advanced");g(this,"config",{overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1});g(this,"items",[]);g(this,"idToItem",new Map);g(this,"selectedLines",null);g(this,"itemEditors",new Map);g(this,"attachedEditors",new Set);g(this,"instanceToItem",new Map);g(this,"layoutDirtyIndex");g(this,"pendingLayoutReset");g(this,"renderOptionsRevision",0);g(this,"slotCoordinator");g(this,"slotSnapshot");g(this,"scrollListeners",new Set);g(this,"scrollHeight",0);g(this,"containerHeight",-1);g(this,"scrollTop",0);g(this,"scrollPageOffset",0);g(this,"scrollRebaseConfig",R0()?mC:gC);g(this,"scrollDirty",!0);g(this,"scrollInteractionFixTimer");g(this,"pointerEventsDisabled",!1);g(this,"codeOverflowFix",!1);g(this,"height",0);g(this,"heightDirty",!0);g(this,"windowSpecs",{top:0,bottom:0});g(this,"renderState",{scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1});g(this,"itemMetricsCache",mn);g(this,"fileOptionsPrototype");g(this,"diffOptionsPrototype");g(this,"pendingScrollTarget");g(this,"pendingLayoutAnchor");g(this,"shouldFixContainerFocus",!1);g(this,"scrollAnimation");g(this,"root");g(this,"resizeObserver");g(this,"container",document.createElement("div"));g(this,"stickyContainer",document.createElement("div"));g(this,"stickyOffset",document.createElement("div"));g(this,"header",{element:void 0,render:void 0,height:0});g(this,"footer",{element:void 0,render:void 0,height:0});g(this,"elementPool",[]);g(this,"elementPoolVersion",0);g(this,"elementPoolTracker",new WeakMap);g(this,"pendingElementPool",[]);g(this,"options");g(this,"workerManager");g(this,"isReadySubscription");g(this,"pendingHighlighterTheme");g(this,"isContainerManaged");g(this,"restoreScrollInteractions",()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&(this.stickyContainer.style.removeProperty("pointer-events"),this.pointerEventsDisabled=!1),this.codeOverflowFix&&(this.stickyContainer.style.setProperty(za,"auto"),this.codeOverflowFix=!1)});g(this,"computeRenderRangeAndEmit",(e=performance.now())=>{if(ye.__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 x=this.resolveAnchoredScrollTop(o);if(x!=null){const E=x-r;r=x,this.scrollAnimation!=null&&(this.scrollAnimation.position+=E)}}s&&(r=this.clampScrollTop(r),this.syncContainerHeight());const l=this.computeTargetScrollTopForFrame(r,e),a=!s&&(this.renderState.scrollTop===-1||Math.abs(l-this.renderState.scrollTop)>n+this.config.overscrollSize*2);a&&(o=void 0),this.windowSpecs=ls({scrollTop:l-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:a,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let d=i;(this.pendingScrollTarget!=null&&l!==d||this.needsScrollPageUpdate(l))&&(this.applyScrollFix(l,d,this.windowSpecs),d=l);const{top:c,bottom:u}=this.windowSpecs,{firstIndex:h,lastIndex:f}=this.renderState;if(h>=0)for(let x=h;x<=f;x++){const E=this.items[x];if(E==null)throw new Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${x}`);E.top>c-E.height&&E.top<=u||this.releaseRenderedItem(E)}const p=this.reconcileHeaderFooterHosts();let y;const v=new Set,m=this.findFirstVisibleIndex(c),C=this.findLastVisibleIndex(u);for(let x=m;x<=C;x++){const E=this.items[x];if(E==null)throw new Error("CodeView.computeRenderRangeAndEmit: missing item");const{instance:R}=E;E.element==null?(E.element=this.acquireElement(),Ga(this.stickyContainer,E.element,y),R.virtualizedSetup(),Va(E,E.element)&&(E.renderedOptionsRevision=this.renderOptionsRevision,v.add(E)),y=E.element):(Ga(this.stickyContainer,E.element,y),Va(E,void 0,E.renderedOptionsRevision!==this.renderOptionsRevision)&&(E.renderedOptionsRevision=this.renderOptionsRevision,v.add(E)),y=E.element),E.item.edit===!0&&this.attachItemEditor(E)}this.renderState.firstIndex=m<=C?m:-1,this.renderState.lastIndex=C,this.flushSlotCoordinator(),this.flushManagers(v),p&&this.measureMountedHosts(),this.reconcileRenderedItems(v),this.syncContainerHeight(),this.updateStickyPositioning();const S=o!=null?this.resolveAnchoredScrollTop(o):void 0;o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);const w=S!=null?S-r:0;let b=l,k=!1;if(this.pendingScrollTarget!=null){const x=this.advanceScrollAnimation(e,w);x!=null?(b=x,k=!0):b=r}else b=S??l;b!==d&&(this.applyScrollFix(b,d,this.windowSpecs),d=b),k&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=qe(d),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),(a||this.scrollAnimation!=null)&&this.render()});g(this,"handleScroll",()=>{ye.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())});g(this,"clearPendingScroll",()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0});g(this,"handleResize",e=>{let n=!1;for(const i of e)if(i.target===this.stickyContainer){const r=i.borderBoxSize[0].blockSize;if(Math.abs(r-this.renderState.stickyHeight)>=$a){const s=this.getScrollTop(),o=this.getScrollAnchor(s);this.reconcileRenderedItems(),this.updateStickyPositioning();const l=o!=null?this.resolveAnchoredScrollTop(o):void 0;if(l!=null){const a=l-s;this.applyScrollFix(l,s,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=a)}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(),l=this.getScrollAnchor(o);this.setHostHeight(r,s);const a=l!=null?this.resolveAnchoredScrollTop(l):void 0;if(a!=null){const d=a-o;this.applyScrollFix(a,o,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=d)}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)});this.options=e,this.computeMetricsCache(e.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??ru}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:(e==null?void 0:e.hunkLineCount)??mn.hunkLineCount,lineHeight:(e==null?void 0:e.lineHeight)??mn.lineHeight,diffHeaderHeight:(e==null?void 0:e.diffHeaderHeight)??mn.diffHeaderHeight,hunkSeparatorHeight:e==null?void 0:e.hunkSeparatorHeight,spacing:(e==null?void 0:e.spacing)??mn.spacing,paddingTop:e==null?void 0:e.paddingTop,paddingBottom:e==null?void 0:e.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??su}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return qc&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(e){if(!this.shouldValidateItemHeights()||e.element==null)return;const n=e.instance.getAdvancedStickySpecs();if(n==null)return;const i=n.height,r=e.element.getBoundingClientRect().height;i!==r&&console.error("CodeView: reconciled item height does not match DOM height",{id:e.item.id,type:e.type,index:e.index,version:e.version,expectedHeight:i,actualHeight:r,delta:r-i,stickyTopOffset:n.topOffset,virtualizedHeight:e.instance.getVirtualizedHeight(),top:e.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:e.element,instance:e.instance})}validateStickyContainerHeight(){var l,a;if(!this.shouldValidateItemHeights())return;const{firstIndex:e,lastIndex:n,stickyHeight:i,stickyTop:r,stickyBottom:s}=this.renderState;if(e===-1||n===-1)return;const o=this.stickyContainer.getBoundingClientRect().height;Math.abs(o-i)<$a||console.error("CodeView: sticky container height does not match computed layout",{computedStickyHeight:i,actualStickyHeight:o,delta:o-i,stickyTop:r,stickyBottom:s,firstIndex:e,lastIndex:n,firstStickySpecs:(l=this.items[e])==null?void 0:l.instance.getAdvancedStickySpecs(),lastStickySpecs:(a=this.items[n])==null?void 0:a.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),vC&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(za,"hidden"),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,pC)}syncLayout(){var r,s;const{gap:e,paddingBottom:n,paddingTop:i}=this.getLayout();this.stickyContainer.style.gap=`${e}px`,(r=this.container)==null||r.style.setProperty("margin-top",`${i}px`),(s=this.container)==null||s.style.setProperty("margin-bottom",`${n}px`)}reconcileHeaderFooterHosts(){const e=this.reconcileHost("header"),n=this.reconcileHost("footer");return e||n}reconcileHost(e){var a;const{root:n,container:i}=this;if(n==null||i==null)return!1;const r=e==="header"?this.header:this.footer,s=e==="header"?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(s==null)return r.element==null||((a=this.resizeObserver)==null||a.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??uC(e,i,this.resizeObserver);r.element=o;const l=s();return l!=null?o.replaceChildren(l):!this.isContainerManaged&&o.children.length>0&&(o.textContent=""),r.render=s,!0}setHostHeight(e,n){e.height!==n&&(e.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(e){var n;if(this.root!=null)throw new Error("CodeView.setup: already setup");(n=this.workerManager)==null||n.subscribeToThemeChanges(this),this.root=e,this.root.style.overflowAnchor="none",this.root.hasAttribute("tabindex")||(this.root.tabIndex=-1),this.container??(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=()=>{ye.__STOP?(ye.__STOP=!1,this.scrollTo({type:"position",position:ye.__lastScrollPosition,behavior:"instant"})):(ye.__lastScrollPosition=this.getScrollTop(),ye.__STOP=!0)}}reset(){var s;Ot(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();const{items:e}=this,n=[...this.itemEditors.values()].map(o=>{const l=this.idToItem.get(o.state.id);return l!=null&&(o.state.removedItem=l.item),o});this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items=[],this.idToItem.clear(),this.instanceToItem.clear();let i=!1,r;for(const o of n)try{o.editor.cleanUp("discard")}catch(l){i||(i=!0,r=l)}for(const o of e)try{o.instance.cleanUp()}catch(l){i||(i=!0,r=l)}if(this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent="",this.stickyOffset.style.height="",(s=this.container)==null||s.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(),i)throw r}cleanUp(){var i,r,s,o,l,a,d,c,u,h,f;let e=!1,n;try{this.reset()}catch(p){e=!0,n=p}if(this.clearElementPool(),this.restoreScrollInteractions(),(i=this.workerManager)==null||i.unsubscribeToThemeChanges(this),(r=this.resizeObserver)==null||r.disconnect(),this.resizeObserver=void 0,(s=this.root)==null||s.removeEventListener("scroll",this.handleScroll),(o=this.root)==null||o.removeEventListener("wheel",this.clearPendingScroll),(l=this.root)==null||l.removeEventListener("touchstart",this.clearPendingScroll),(a=this.root)==null||a.removeEventListener("pointerdown",this.clearPendingScroll),(d=this.root)==null||d.removeEventListener("keydown",this.clearPendingScroll),(c=this.root)==null||c.style.removeProperty("overflow-anchor"),(u=this.container)==null||u.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent="",(h=this.header.element)==null||h.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,(f=this.footer.element)==null||f.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0,e)throw n}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let e=this.renderState.firstIndex;e<=this.renderState.lastIndex;e++){const n=this.items[e];if(n==null)throw new Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${e}`);this.releaseRenderedItem(n)}}primeScrollTarget(e){if(e.type==="position")return;const n=this.idToItem.get(e.id);n!=null&&n.instance.primeHighlightCache()}getElementPoolLimit(){const e=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:n}=this.itemMetricsCache;return Math.max(8,Math.ceil(e/Math.max(n,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??(e=document.createElement(al)),this.markElementPoolGenerationCurrent(e),e}releaseRenderedItem(e){const{element:n}=e;n!=null&&this.renderedItemOwnsFocus(n)&&(this.shouldFixContainerFocus=!0),e.instance.cleanUp(!0),this.attachedEditors.delete(e.item.id),e.element=void 0,n!=null&&(n.remove(),this.cleanElement(n),this.queueElementForPool(n))}renderedItemOwnsFocus(e){var i;const{activeElement:n}=document;return n===e||e.contains(n)||((i=e.shadowRoot)==null?void 0:i.activeElement)!=null}fixContainerFocus(){var e;this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,(e=this.root)==null||e.focus({preventScroll:!0}))}cleanElement(e){const{shadowRoot:n}=e;if(n!=null)for(const i of Array.from(n.children))xC(i)||i.remove();this.isContainerManaged||e.replaceChildren()}queueElementForPool(e){const n=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(e)||this.getElementPoolSize()>=n||(this.isElementClean(e)?this.elementPool.push(e):this.pendingElementPool.push(e))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;const{pendingElementPool:e}=this;this.pendingElementPool=[];const n=this.getElementPoolLimit();for(const i of e)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(e){return e.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(e){this.elementPoolTracker.set(e,this.elementPoolVersion)}isElementPoolGenerationCurrent(e){return this.elementPoolTracker.get(e)===this.elementPoolVersion}resolveEffectiveScrollBehavior(e,n){return Tm()?"instant":e.behavior!=="smooth-auto"?e.behavior??"instant":Math.abs(n-this.getScrollTop())<=this.getHeight()*10?"smooth":"instant"}scrollTo(e){if(this.root==null)return;const n=this.normalizeScrollTarget(e);if(n==null)return;const i=this.resolveScrollTargetTop(n);i!=null&&(this.primeScrollTarget(n),this.resolveEffectiveScrollBehavior(n,i)==="smooth"?this.scrollAnimation??(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(e,n){this.applySelectedLines(e,n)}getSelectedLines(){return this.selectedLines}clearSelectedLines(e){this.applySelectedLines(null,e)}getItem(e){var n;return(n=this.idToItem.get(e))==null?void 0:n.item}getEditor(e){var n;return(n=this.itemEditors.get(e))==null?void 0:n.editor}updateItem(e){const n=this.idToItem.get(e.id);return n==null?(console.error(`CodeView.updateItem: unknown item id "${e.id}"`),!1):this.syncItemRecord(n,e)?(this.markItemLayoutDirty(n),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(e,n){var s,o,l;if(e===n)return!0;const i=this.idToItem.get(e);if(i==null)return console.error(`CodeView.updateItemId: unknown item id "${e}"`),!1;if(this.idToItem.has(n))return console.error(`CodeView.updateItemId: duplicate item id "${n}"`),!1;this.idToItem.delete(e),i.item.id=n,this.idToItem.set(n,i),this.updateItemOptionsId(i.instance.options,n),((s=this.selectedLines)==null?void 0:s.id)===e&&(this.selectedLines={...this.selectedLines,id:n},(l=(o=this.options).onSelectedLinesChange)==null||l.call(o,this.selectedLines));const r=this.itemEditors.get(e);return r!=null&&(this.itemEditors.delete(e),this.itemEditors.set(n,r),this.attachedEditors.delete(e)&&this.attachedEditors.add(n)),this.renamePendingScrollTarget(e,n),this.renamePendingLayoutAnchor(e,n),this.render(),!0}addItem(e){this.addItems([e])}addItems(e){this.appendItemsInternal(e),this.syncItemEditors(),this.syncSelection()}removeItem(e){const n=this.idToItem.get(e);if(n==null)return console.error(`CodeView.removeItem: unknown item id "${e}"`),!1;const i=[];for(const r of this.items)r!==n&&i.push(r.item);return this.setItems(i),!0}setItems(e){let n;this.items.length===0?this.appendItemsInternal(e):this.tryAppendItems(e)||(n=this.reconcileItems(e));try{this.syncItemEditors(n)}finally{for(const i of(n==null?void 0:n.values())??[])i.instance.cleanUp()}this.syncSelection()}appendItemsInternal(e,n=!0){if(e.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<e.length;o++){const l=e[o];if(l==null)throw new Error("CodeView.appendItemsInternal: missing input item");if(this.idToItem.has(l.id))throw new Error(`CodeView.addItem: duplicate id "${l.id}"`);const a=this.createItem(l,this.items.length,r);this.items.push(a),this.idToItem.set(a.item.id,a),this.instanceToItem.set(a.instance,a),a.height=CC(a),r+=a.height+i.gap}this.scrollHeight=r-i.gap,this.scrollDirty=!0,n&&(this.canSkipRenderForAppend(s)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(e){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&e>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(e){if(e==null)return;this.capturePendingLayoutAnchor();const{options:n}=this,i=this.getLayout(),{itemMetricsCache:r}=this;SC(n,e)&&this.invalidateElementPool(),this.options=e;const s=this.computeMetricsCache(e.itemMetrics),o=!nn(r,s),l=!nn(i,this.getLayout());l&&this.syncLayout();const a=o||bC(n,e);if(a){const c=this.pendingLayoutReset;this.pendingLayoutReset={metrics:o?s:c==null?void 0:c.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:(c==null?void 0:c.includeEstimatedDiffHeights)===!0||o||wC(n,e)}}(l||a)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),Vs(n,e)||this.renderOptionsRevision++,this.syncItemEditors();const d=n.renderCodeViewHeader!==e.renderCodeViewHeader||n.renderCodeViewFooter!==e.renderCodeViewFooter;!this.isContainerManaged&&(this.items.length>0||d)&&this.render()}capturePendingLayoutAnchor(e=this.idToItem){this.root==null||this.items.length===0||this.pendingScrollTarget!=null||(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),e))}render(e=!1){ye.__STOP||(e?(Ot(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):de(this.computeRenderRangeAndEmit))}isReady(){const{workerManager:e}=this;return e==null||e.getStats().workersFailed?this.isSharedHighlighterReady():e.isInitialized()?(this.clearReadySubscription(),!0):(this.isReadySubscription??(this.isReadySubscription=e.subscribeToStatChanges(n=>{n.managerState!=="initialized"&&!n.workersFailed||(this.clearReadySubscription(),this.render(!0))})),e.getStats().managerState==="waiting"&&e.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0,this.pendingHighlighterTheme=void 0)}isSharedHighlighterReady(){var n;const e=((n=this.workerManager)==null?void 0:n.getFileRenderOptions().theme)??this.options.theme??j;return Em()&&Ge(e)?(this.clearReadySubscription(),!0):(zt(this.pendingHighlighterTheme,e)||this.clearReadySubscription(),this.isReadySubscription??(this.isReadySubscription=(()=>{this.pendingHighlighterTheme=e;let i=!1;return _m({themes:cn(e),langs:[],preferredHighlighter:this.options.preferredHighlighter}).then(()=>{i||(this.clearReadySubscription(),this.render(!0))},r=>{i||(this.clearReadySubscription(),console.error(r))}),()=>{i=!0}})()),!1)}instanceChanged(e,n){const i=this.instanceToItem.get(e);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:e,lastIndex:n}=this.renderState;if(e===-1||n===-1||n<e)return[];const i=[];for(let r=e;r<=n;r++){const s=this.items[r];(s==null?void 0: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(e){return e===this.slotCoordinator?!1:(this.slotCoordinator=e,this.slotSnapshot=void 0,!0)}getSlotSnapshot(e){return this.buildSlotSnapshot(e)}buildSlotSnapshot(e){const n=LC(this.getRenderedItems(),e),{element:i}=this.header,{element:r}=this.footer;if(!(n==null&&i==null&&r==null))return{items:n,header:i,footer:r}}subscribeToScroll(e){return this.scrollListeners.add(e),()=>{this.scrollListeners.delete(e)}}getLocalTopForInstance(e){const n=this.instanceToItem.get(e);if(n==null)throw new Error("CodeView.getLocalTopForInstance: unknown virtualized instance");return n.top}getTopForItem(e){const n=this.idToItem.get(e);if(n!=null)return n.top+this.getItemTopOffset()}createItem(e,n,i){const{itemMetricsCache:r}=this;if(e.type==="diff"){const o=new Jv(this.createDiffOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:"diff",item:e,version:e.version,index:n,top:i,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:o}}const s=new W0(this.createFileOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:"file",item:e,version:e.version,index:n,top:i,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:s}}applySelectedLines(e,n){var r,s;const{selectedLines:i}=this;e==null&&i==null||e!=null&&(i==null?void 0:i.id)===e.id&&zi(i.range,e.range)||(i!=null&&i.id!==(e==null?void 0:e.id)&&((r=this.idToItem.get(i.id))==null||r.instance.setSelectedLines(null,{notify:!1})),this.selectedLines=e,(s=this.idToItem.get((e==null?void 0:e.id)??""))==null||s.instance.setSelectedLines((e==null?void 0:e.range)??null,n))}syncSelection(){var n,i;if(this.selectedLines==null)return;const e=this.idToItem.get(this.selectedLines.id);if(e==null){this.selectedLines=null,(i=(n=this.options).onSelectedLinesChange)==null||i.call(n,null);return}e.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(e){return e.item.edit===!0&&e.item.collapsed!==!0}attachItemEditor(e){var o,l;const{id:n}=e.item,{createEditor:i}=this.options;if(e.element==null||this.attachedEditors.has(n)||!this.isItemInEditMode(e))return;const r=this.itemEditors.get(n);let s;try{if(r==null&&e.type==="diff"&&!e.instance.__canAttachEditor()){e.instance.__prepareForEditing();return}if(r==null){yC(i);const a=gt(e.instance.options);if(a==null)throw new Error("CodeView.attachItemEditor: instance options are missing their state");const d=u=>{var f,p;const h=this.idToItem.get(a.id);h!=null&&((p=(f=this.options).onItemEditChange)==null||p.call(f,u,h.item))},c=(l=(o=this.options).getEditStateKey)==null?void 0:l.call(o,e.item);if(e.type==="diff"){const u=i("file-diff",{onChange:d},c);s=u,this.itemEditors.set(n,{editor:u,state:a,dispose:u.edit(e.instance)})}else{const u=i("file",{onChange:d},c);s=u,this.itemEditors.set(n,{editor:u,state:a,dispose:u.edit(e.instance)})}}else e.type,r.dispose=r.editor.edit(e.instance);this.attachedEditors.add(n)}catch(a){throw s==null||s.cleanUp(),this.releaseRenderedItem(e),a}}syncItemEditors(e){if(this.itemEditors.size===0)return;const n=[];for(const[s,o]of this.itemEditors){const l=this.idToItem.get(s),a=e==null?void 0:e.get(s);if(a==null&&l!=null){const{edit:d=!1,collapsed:c=!1}=l.item;if(d){c&&this.attachedEditors.delete(s)&&o.editor.cleanUp("recycle");continue}}else a!=null&&(o.state.removedItem=a.item);this.itemEditors.delete(s),this.attachedEditors.delete(s),n.push(o)}if(n.length===0)return;let i=!1,r;for(const s of n){try{s.dispose()}catch(l){i||(i=!0,r=l)}const o=this.idToItem.get(s.state.id);o!=null&&this.markItemLayoutDirty(o)}if(this.render(),i)throw r}requireItemFromState(e){var i;const n=((i=this.idToItem.get(e.id))==null?void 0:i.item)??e.removedItem;if(n==null)throw new Error(`CodeView.onItemEditComplete: unknown item "${e.id}"`);return n}completeFileItemEdit(e,n){var s,o;const i=this.requireItemFromState(e);if(i.type!=="file")throw new Error(`CodeView.onItemEditComplete: item "${e.id}" is not a file item`);const r={...i,file:n.file,annotations:n.lineAnnotations,edit:!1,version:(i.version??0)+1};return(((o=(s=this.options).onItemEditComplete)==null?void 0:o.call(s,n,i,r))??"reject")==="reject"?"reject":(this.idToItem.has(i.id)&&this.updateItem(r),"accept")}completeDiffItemEdit(e,n){var s,o;const i=this.requireItemFromState(e);if(i.type!=="diff")throw new Error(`CodeView.onItemEditComplete: item "${e.id}" is not a diff item`);const r={...i,fileDiff:n.fileDiff,annotations:n.lineAnnotations,edit:!1,version:(i.version??0)+1};return(((o=(s=this.options).onItemEditComplete)==null?void 0:o.call(s,n,i,r))??"reject")==="reject"?"reject":(this.idToItem.has(i.id)&&this.updateItem(r),"accept")}renamePendingScrollTarget(e,n){const{pendingScrollTarget:i}=this;i==null||i.type==="position"||i.id!==e||(this.pendingScrollTarget={...i,id:n})}renamePendingLayoutAnchor(e,n){var i;((i=this.pendingLayoutAnchor)==null?void 0:i.id)===e&&(this.pendingLayoutAnchor.id=n)}createFileOptionsPrototype(){const e={};for(const n of fC)Ue(e,n,()=>this.options[n]);Ue(e,"stickyHeader",()=>this.options.stickyHeaders),Ue(e,"collapsed",n=>{var r;const i=gt(n);if(i!=null)return(r=this.getItemOptions(i,"file"))==null?void 0:r.item.collapsed}),Ue(e,"onEditComplete",n=>{if(this.options.onItemEditComplete==null)return;const i=gt(n);if(i!=null)return r=>this.completeFileItemEdit(i,r)});for(const n of Oa)this.defineItemSharedCallback(e,"file",n);for(const n of Na)this.defineItemSelectionCallback(e,"file",n);return e}createDiffOptionsPrototype(){const e={};for(const n of hC)Ue(e,n,()=>this.options[n]);Ue(e,"stickyHeader",()=>this.options.stickyHeaders),Ue(e,"hunkSeparators",()=>this.options.hunkSeparators),Ue(e,"collapsed",n=>{var r;const i=gt(n);if(i!=null)return(r=this.getItemOptions(i,"diff"))==null?void 0:r.item.collapsed}),Ue(e,"onEditComplete",n=>{if(this.options.onItemEditComplete==null)return;const i=gt(n);if(i!=null)return r=>this.completeDiffItemEdit(i,r)});for(const n of Oa)this.defineItemSharedCallback(e,"diff",n);for(const n of Na)this.defineItemSelectionCallback(e,"diff",n);return e}createFileOptions(e){const n=Object.create(this.fileOptionsPrototype);return Fa(n,{id:e}),n}createDiffOptions(e){const n=Object.create(this.diffOptionsPrototype);return Fa(n,{id:e}),n}updateItemOptionsId(e,n){const i=gt(e);if(i==null)throw new Error("CodeView.updateItemOptionsId: No valid state");i.id=n}getItemOptions(e,n){const i=this.idToItem.get(e.id);if(!(i==null||i.type!==n))return i}defineItemSharedCallback(e,n,i){Ue(e,i,r=>{if(this.options[i]==null)return;const s=gt(r);if(s==null)return;const o=s.callbackCache??(s.callbackCache={});let l=o[i];return l==null&&(l=((...a)=>{const d=this.getItemOptions(s,n);if(d==null)return;const c=this.options[i];return c==null?void 0:c(...a,d)}),o[i]=l),l})}defineItemSelectionCallback(e,n,i){Ue(e,i,r=>{const s=gt(r);if(s==null)return;const o=s.callbackCache??(s.callbackCache={});let l=o[i];return l==null&&(l=a=>{var h,f,p;const d=this.getItemOptions(s,n);if(d==null)return;const c=a==null?null:{id:d.item.id,range:a};this.options.controlledSelection!==!0&&(a!=null||((h=this.selectedLines)==null?void 0:h.id)===d.item.id)&&this.applySelectedLines(c,{notify:!1}),(p=(f=this.options).onSelectedLinesChange)==null||p.call(f,c);const u=this.options[i];return u==null?void 0:u(a,d)},o[i]=l),l})}markLayoutDirtyFromIndex(e){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??e,e)}markItemLayoutDirty(e){if(this.items[e.index]!==e)throw new Error(`CodeView.markItemLayoutDirty: unknown item id "${e.item.id}"`);this.markLayoutDirtyFromIndex(e.index)}tryAppendItems(e){if(e.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=e[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=e[n];if(r==null)throw new Error("CodeView.tryAppendItems: append candidate missing prefix item");this.syncItemRecord(i,r)&&this.markLayoutDirtyFromIndex(n)}return this.appendItemsInternal(e.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(e){const{items:n,idToItem:i}=this,r=new Set(n),s=[],o=new Map,l=new Map,a=new Map;let d;for(let c=0;c<e.length;c++){const u=e[c];if(u==null)throw new Error("CodeView.reconcileItems: missing input item");if(o.has(u.id))throw new Error(`CodeView.setItems: duplicate id "${u.id}"`);const h=i.get(u.id),f=h!=null&&h.type===u.type?h:this.createItem(u,c,0);f.index=c,h!=null&&h.type===u.type?(r.delete(h),this.syncItemRecord(f,u)&&(d=Math.min(d??c,c))):d=Math.min(d??c,c),n[c]!==f&&(d=Math.min(d??c,c)),s.push(f),o.set(u.id,f),l.set(f.instance,f)}if(d==null){if(r.size===0)return;d=Math.max(s.length-1,0)}this.capturePendingLayoutAnchor(o);for(let c=0;c<n.length;c++){const u=n[c];if(u==null||!r.has(u))continue;a.set(u.item.id,u),this.releaseRenderedItem(u);const h=Math.max(s.length-1,0);d=Math.min(d??h,h)}return this.items=s,this.idToItem=o,this.instanceToItem=l,this.renderState.firstIndex>=s.length?this.resetRenderState():this.renderState.lastIndex>=s.length&&(this.renderState.lastIndex=s.length-1),this.markLayoutDirtyFromIndex(d),this.scrollDirty=!0,this.render(),a.size>0?a:void 0}syncItemRecord(e,n){if(e.type!==n.type)throw new Error(`CodeView.syncItemRecord: type mismatch for id "${n.id}"`);return e.version===n.version?!1:(e.item=n,e.version=n.version,e.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(e){const{paddingBottom:n,paddingTop:i}=this.getLayout();return Math.max(i+this.header.height+e+this.footer.height+n-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>this.scrollRebaseConfig.threshold}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),this.scrollRebaseConfig.containerHeight):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(e){const n=this.getMaxPagedScrollTop();return Math.max(0,Math.min(e,n))}clampScrollTop(e){const n=this.getMaxScrollTop();return Math.max(0,Math.min(e,n))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(e){const n=this.getMaxScrollPageOffset();return Math.max(0,Math.min(e,n))}resolveScrollPageWindow(e,n){let i=qe(this.clampPagedScrollTop(n)),r=this.clampScrollPageOffset(e-i);return i=qe(this.clampPagedScrollTop(e-r)),r=this.clampScrollPageOffset(e-i),{pagedScrollTop:i,scrollPageOffset:r}}resolvePagedScrollPosition(e){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(e),scrollPageOffset:0};const{scrollPageOffset:n,scrollRebaseConfig:i}=this,r=this.clampScrollPageOffset(n),s=e-r,o=this.getMaxPagedScrollTop(),l=this.getMaxScrollPageOffset(),a=s>i.threshold&&r<l,d=s<i.triggerTop&&r>0;return s<0||s>o||a||d?this.resolveScrollPageWindow(e,d?Math.min(i.targetBottom,o):i.targetTop):{pagedScrollTop:qe(this.clampPagedScrollTop(s)),scrollPageOffset:r}}needsScrollPageUpdate(e){const n=qe(this.clampScrollTop(e)),{scrollPageOffset:i}=this.resolvePagedScrollPosition(n);return i!==this.scrollPageOffset}getPagedLayoutTop(e){return this.shouldRebaseScroll()?Math.max(e-this.scrollPageOffset,0):e}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(e){const n=this.idToItem.get(e.id);if(n==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type==="item")return{top:n.top,height:n.height};if(e.type==="range"){const r=this.getRangeScrollPosition(n,e);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Ua(e.range)} for item "${e.id}"`);return}return{top:n.top+r.top,height:r.height}}const i=this.getLineScrollPosition(n,e);if(i==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return{top:n.top+i.top,height:i.height}}normalizeScrollTarget(e){if(e.type==="position"||e.align!=="nearest")return e;const n=this.getScrollTargetRect(e);if(n==null)return;const i=e.offset??0,r=this.getItemTopOffset()+n.top,s=r+n.height,o=this.getScrollTop(),l=o+(e.type==="line"||e.type==="range"?this.getStickyHeaderOffset():0),a=o+this.getHeight();if(!(r-i<=l&&s+i>=a)){if(r-i<l)return{...e,align:"start"};if(s+i>a)return{...e,align:"end"}}}resolveScrollTargetTop(e){if(e.type==="position"){const r=this.clampScrollTop(e.position);return r!==e.position?r:this.clampScrollTop(e.position-this.getStickyHeaderOffset())}const n=this.idToItem.get(e.id);if(n==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type==="item")return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top,n.height,e.align,e.offset));if(e.type==="range"){const r=this.getRangeScrollPosition(n,e);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Ua(e.range)} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top+r.top,r.height,e.align,e.offset,this.getStickyHeaderOffset()))}const i=this.getLineScrollPosition(n,e);if(i==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top+i.top,i.height,e.align,e.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(e,n,i,r=0,s=0){e+=this.getItemTopOffset();const o=this.getHeight();return i==="center"&&n+r<o?e-(o-n)/2+r:i==="end"?e-(o-n)+r:e-s-r}getLineScrollPosition(e,n){return e.type==="diff"?e.instance.getLinePosition(n.lineNumber,n.side):e.instance.getLinePosition(n.lineNumber)}getRangeScrollPosition(e,n){const{range:i}=n,r=this.getLineScrollPosition(e,{type:"line",id:n.id,lineNumber:i.start,side:i.side}),s=this.getLineScrollPosition(e,{type:"line",id:n.id,lineNumber:i.end,side:i.endSide??i.side});if(r==null||s==null)return;const o=r.top,l=o+r.height,a=s.top,d=a+s.height,c=Math.min(o,a);return{top:c,height:Math.max(l,d)-c}}computeTargetScrollTopForFrame(e,n){if(this.pendingScrollTarget==null)return e;const i=this.resolveScrollTargetTop(this.pendingScrollTarget);if(i==null)return e;const{scrollAnimation:r}=this;return r==null?i:this.computeSpringStep(r,i,n).position}computeSpringStep(e,n,i){const r=Math.max(0,i-e.lastTimestamp),{omega:s}=this.getSmoothScrollSettings(),o=Math.exp(-s*r),l=e.position-n,a=e.velocity+s*l;return{position:n+(l+a*r)*o,velocity:(a*(1-s*r)-s*l)*o}}advanceScrollAnimation(e,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,e);r.lastTimestamp=e,r.position=s,r.velocity=o;const{positionEpsilon:l,velocityEpsilon:a}=this.getSmoothScrollSettings();return Math.abs(i-s)<=l&&Math.abs(o)<=a?(r.position=i,r.velocity=0,this.scrollAnimation=void 0,i):r.position}flushManagers(e){for(const n of e)n.instance.flushManagers()}syncContainerHeight(){const e=this.getPagedScrollHeight();this.container==null||this.containerHeight===e||(this.container.style.height=`${e}px`,this.containerHeight=e)}getStickyBounds(e){var o,l;const{firstIndex:n,lastIndex:i}=e!=null?{firstIndex:this.findFirstVisibleIndex(e.top),lastIndex:this.findLastVisibleIndex(e.bottom)}:this.renderState;if(n===-1||i===-1||n>i)return;const r=(o=this.items[n])==null?void 0:o.instance.getAdvancedStickySpecs(e),s=(l=this.items[i])==null?void 0:l.instance.getAdvancedStickySpecs(e);if(!(r==null||s==null))return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(s.topOffset+s.height)}}applyStickyPositioning({stickyTop:e,stickyBottom:n}){const i=this.getHeight(),{itemMetricsCache:r}=this,s=n-e;this.renderState.stickyHeight=s,this.renderState.stickyTop=e,this.renderState.stickyBottom=n,this.stickyOffset.style.height=`${e}px`;const o=(Math.random()*r.lineHeight>>0)*-1,l=-Math.max(s+o,0)+i;this.stickyContainer.style.top=`${l}px`,this.stickyContainer.style.bottom=`${l+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(e){this.syncContainerHeight();const n=this.getStickyBounds(e);if(n==null){this.stickyOffset.style.height=`${this.getPagedLayoutTop(e.top)}px`;return}this.applyStickyPositioning(n)}reconcileRenderedItems(e){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 l=this.items[o];if(l==null)throw new Error("CodeView.reconcileRenderedItems: Invalid item");r===-1?r=l.top:l.top!==r&&(l.top=r,l.instance.syncVirtualizedTop(),s=!0),(e==null?o<=i:e.has(l))&&(l.instance.reconcileHeights()&&(s=!0,l.height=l.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(l)),r+=l.instance.getVirtualizedHeight(),o<this.items.length-1&&(r+=this.getLayout().gap)}s&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){const e=this.getStickyBounds();if(e==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height="");return}const{stickyTop:n,stickyBottom:i}=e;i-n===this.renderState.stickyHeight&&n===this.renderState.stickyTop&&i===this.renderState.stickyBottom||this.applyStickyPositioning(e)}getScrollAnchorViewportTop(e,n){return e<n?n+this.getStickyHeaderOffset():n}getScrollAnchor(e,n=this.idToItem){let i;const{pendingLayoutAnchor:r}=this;if(r!=null){const c=this.idToItem.get(r.id);if(c!=null&&n.get(r.id)===c)return r;c!=null&&(i=c)}if(e<=0)return;const{firstIndex:s,lastIndex:o,stickyTop:l,stickyBottom:a}=this.renderState;if(s===-1||o===-1)return;const d=this.getHeight();if(!(l===-1||a===-1)){for(let c=s;c<=o;c++){const u=this.items[c];if(u==null)continue;const h=this.getItemTopOffset()+u.top;if(h+u.height<=e)continue;if(h>=e+d)break;if(n.get(u.item.id)!==u){i??(i=u);continue}if(h>=e)return{type:"item",id:u.item.id,viewportOffset:h-e};const f=this.getScrollAnchorViewportTop(h,e)-h,p=u.instance.getNumericScrollAnchor(f);if(p!=null){const y=h+p.top;return{type:"line",id:u.item.id,lineNumber:p.lineNumber,side:p.side,viewportOffset:y-e}}}if(i!=null)for(let c=i.index+1;c<this.items.length;c++){const u=this.items[c];if(u!=null&&n.get(u.item.id)===u)return{type:"item",id:u.item.id,viewportOffset:0}}}}resolveAnchoredScrollTop(e){const n=this.idToItem.get(e.id);if(n==null)return;const i=this.getItemTopOffset();if(e.type==="item"){const o=i+n.top;return this.clampScrollTop(o-e.viewportOffset)}const r=n.type==="diff"?n.instance.getLinePosition(e.lineNumber,e.side):n.instance.getLinePosition(e.lineNumber);if(r==null)return;const s=i+n.top+r.top;return this.clampScrollTop(s-e.viewportOffset)}applyScrollFix(e,n,i){if(this.root==null)return;const r=qe(this.clampScrollTop(e)),s=qe(n),{scrollPageOffset:o}=this,l=qe(this.clampPagedScrollTop(s-o)),{pagedScrollTop:a,scrollPageOffset:d}=this.resolvePagedScrollPosition(r),c=a,u=o!==d;r===this.renderState.scrollTop&&r===s&&c===l&&!u||(this.suspendScrollInteractions(),(c!==l||u)&&(this.scrollPageOffset=d,this.syncPagedScrollScaffolding(i)),c!==l&&this.root.scrollTo({top:c,behavior:"instant"}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(e){const n=this.resolveScrollTargetTop(e);return n==null?!0:qe(this.getScrollTop())===qe(n)}getScrollTop(){var n;if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;const e=((n=this.root)==null?void 0:n.scrollTop)??0;return this.scrollTop=this.clampScrollTop(e+this.scrollPageOffset),this.scrollTop}getHeight(){var e;return this.heightDirty?(this.heightDirty=!1,this.height=((e=this.root)==null?void 0:e.getBoundingClientRect().height)??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;const e=this.buildSlotSnapshot(this.slotCoordinator);dC(this.slotSnapshot,e)||(this.slotSnapshot=e,this.slotCoordinator.onSnapshotChange(e))}notifyScroll(){if(this.scrollListeners.size===0)return;const e=this.getScrollTop();for(const n of this.scrollListeners)n(e,this)}findFirstVisibleIndex(e){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>e?(r=s,i=s-1):n=s+1}return r}findLastVisibleIndex(e){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<=e?(r=s,n=s+1):i=s-1}return r}recomputeLayout(e=0,n){if(this.items.length===0){this.scrollHeight=0;return}const i=this.getLayout();let r=0;if(e>0){const s=this.items[e-1];if(s==null)throw new Error("CodeView.recomputeLayout: invalid dirty index");r=s.top+s.height+i.gap}for(let s=e;s<this.items.length;s++){const o=this.items[s];if(o==null)throw new Error("CodeView.recomputeLayout: invalid item index");o.top=r,o.type==="diff"?o.height=o.instance.updateCodeViewLayout(o.item.fileDiff,r,n,o.item.annotations??[]):o.height=o.instance.updateCodeViewLayout(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}},g(ye,"__STOP",!1),g(ye,"__lastScrollPosition",0),ye);function CC(t){return t.instance.cleanUp(!0),t.type==="diff"?t.instance.updateCodeViewLayout(t.item.fileDiff,t.top,void 0,t.item.annotations??[]):t.instance.updateCodeViewLayout(t.item.file,t.top,void 0,t.item.annotations??[])}function SC(t,e){return!zt(t.theme??j,e.theme??j)||(t.themeType??"system")!==(e.themeType??"system")||t.unsafeCSS!==e.unsafeCSS}function bC(t,e){return(t.overflow??"scroll")!==(e.overflow??"scroll")||(t.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(t.disableFileHeader??!1)!==(e.disableFileHeader??!1)||t.unsafeCSS!==e.unsafeCSS||(t.diffStyle??"split")!==(e.diffStyle??"split")||(t.diffIndicators??"bars")!==(e.diffIndicators??"bars")||(t.hunkSeparators??"line-info")!==(e.hunkSeparators??"line-info")||(t.expandUnchanged??!1)!==(e.expandUnchanged??!1)||(t.collapsedContextThreshold??1)!==(e.collapsedContextThreshold??1)}function wC(t,e){return(t.disableFileHeader??!1)!==(e.disableFileHeader??!1)||(t.hunkSeparators??"line-info")!==(e.hunkSeparators??"line-info")||(t.expandUnchanged??!1)!==(e.expandUnchanged??!1)||(t.collapsedContextThreshold??1)!==(e.collapsedContextThreshold??1)}function xC(t){return t instanceof SVGElement?!0:zn(t)&&(t.hasAttribute("data-core-css")||t.hasAttribute("data-theme-css")||t.hasAttribute("data-unsafe-css"))}function Ua(t){const e=Ba(t.start,t.side),n=Ba(t.end,t.endSide??t.side);return e===n?e:`${e}-${n}`}function Ba(t,e){return e==null?`${t}`:`${e==="deletions"?"D":"A"}${t}`}function Va(t,e,n=!1){return t.type==="diff"?t.instance.render({deferManagers:!0,fileContainer:e,fileDiff:t.item.fileDiff,forceRender:n,lineAnnotations:t.item.annotations??[]}):t.instance.render({deferManagers:!0,fileContainer:e,file:t.item.file,forceRender:n,lineAnnotations:t.item.annotations??[]})}function Ga(t,e,n){if(n==null){t.firstChild!==e&&t.prepend(e);return}n.nextSibling!==e&&n.after(e)}function kC(t){var e;return(((e=t.annotations)==null?void 0:e.length)??0)>0}function LC(t,{hasHeaderRenderers:e,hasAnnotationRenderer:n,hasGutterRenderer:i}){if(t.length===0)return;if(e||i)return t;if(!n)return;const r=[];for(const s of t)kC(s.item)&&r.push(s);return r.length>0?r:void 0}var EC=class Ic{constructor(e){g(this,"options");g(this,"tokensStable",[]);g(this,"tokensUnstable",[]);g(this,"lastUnstableCodeChunk","");g(this,"lastStableGrammarState");this.options=e}async enqueue(e){const n=(this.lastUnstableCodeChunk+e).split(`
317
+ `),i=[];let r=[];const s=this.tokensUnstable.length;return n.forEach((o,l)=>{const a=l===n.length-1,d=this.options.highlighter.codeToTokens(o,{...this.options,grammarState:this.lastStableGrammarState}),c=d.tokens[0];a||c.push({content:`
318
+ `,offset:0}),a?(r=c,this.lastUnstableCodeChunk=o):(this.lastStableGrammarState=d.grammarState,i.push(...c))}),rn(this.tokensStable,i),this.tokensUnstable=r,{recall:s,stable:i,unstable:r}}close(){const e=this.tokensUnstable;return this.tokensUnstable=[],this.lastUnstableCodeChunk="",this.lastStableGrammarState=void 0,{stable:e}}clear(){this.tokensStable=[],this.tokensUnstable=[],this.lastUnstableCodeChunk="",this.lastStableGrammarState=void 0}clone(){const e=new Ic(this.options);return e.lastUnstableCodeChunk=this.lastUnstableCodeChunk,e.tokensUnstable=this.tokensUnstable,e.tokensStable=this.tokensStable,e.lastStableGrammarState=this.lastStableGrammarState,e}},Wa=class extends TransformStream{constructor(e){const n=new EC(e),{allowRecalls:i=!1}=e;super({async transform(r,s){const{stable:o,unstable:l,recall:a}=await n.enqueue(r);i&&a>0&&s.enqueue({recall:a});for(const d of o)s.enqueue(d);if(i)for(const d of l)s.enqueue(d)},async flush(r){const{stable:s}=n.close();if(!i)for(const o of s)r.enqueue(o)}});g(this,"tokenizer");g(this,"options");this.tokenizer=n,this.options=e}};function RC(t){const e=document.createElement("span"),n=t.htmlStyle??Hn(t);return e.style=Di(n),e.textContent=t.content,e}let _C=-1;var IS=class{constructor(t={theme:j}){g(this,"options");g(this,"__id",`file-stream:${++_C}`);g(this,"highlighter");g(this,"stream");g(this,"abortController");g(this,"fileContainer");g(this,"pre");g(this,"code");g(this,"gutterElement");g(this,"contentElement");g(this,"themeCSSStyle");g(this,"appliedThemeCSS");g(this,"currentRowCount",0);g(this,"queuedSetupArgs");g(this,"queuedTokens",[]);g(this,"handleWrite",t=>{var e,n;"recall"in t&&this.queuedTokens.length>=t.recall?this.queuedTokens.length=this.queuedTokens.length-t.recall:this.queuedTokens.push(t),de(this.render),(n=(e=this.options).onStreamWrite)==null||n.call(e,t)});g(this,"currentLineIndex");g(this,"currentLineElement");g(this,"render",()=>{var r,s,o,l,a,d;(s=(r=this.options).onPreRender)==null||s.call(r,this);const{gutter:t,content:e}=this.getOrCreateStreamColumns(),n=document.createDocumentFragment(),i=document.createDocumentFragment();for(const c of this.queuedTokens)if("recall"in c){if(this.currentLineElement==null)throw new Error("FileStream.render: no current line element, shouldnt be possible to get here");if(c.recall>this.currentLineElement.childNodes.length)throw new Error("FileStream.render: Token recall exceed the current line, there's probably a bug...");for(let u=0;u<c.recall;u++)(o=this.currentLineElement.lastChild)==null||o.remove()}else{const u=RC(c);if(this.currentLineElement==null){const{gutterLine:h,contentLine:f}=this.createLine();n.appendChild(h),i.appendChild(f)}if((l=this.currentLineElement)==null||l.appendChild(u),c.content===`
319
+ `){this.currentLineIndex++;const{gutterLine:h,contentLine:f}=this.createLine();n.appendChild(h),i.appendChild(f)}}n.childNodes.length>0&&t.appendChild(n),i.childNodes.length>0&&e.appendChild(i),this.queuedTokens.length=0,(d=(a=this.options).onPostRender)==null||d.call(a,this)});this.options=t,this.currentLineIndex=this.options.startingLineIndex??1}cleanUp(){var t;Ot(this.render),(t=this.abortController)==null||t.abort(),this.abortController=void 0}setThemeType(t){(this.options.themeType??"system")!==t&&(this.options={...this.options,themeType:t},!(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)&&this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,t,this.appliedThemeCSS.baseThemeType))}async initializeHighlighter(){return this.highlighter=await un(Gs(this.options.lang,this.options)),this.highlighter}async setup(t,e){const n=this.queuedSetupArgs!=null;if(this.queuedSetupArgs=[t,e],n)return;this.highlighter??(this.highlighter=await this.initializeHighlighter());const[i,r]=this.queuedSetupArgs;this.queuedSetupArgs=void 0;const s=i;this.setupStream(s,r,this.highlighter)}setupStream(t,e,n){var p,y,v;const{disableLineNumbers:i=!1,overflow:r="scroll",theme:s=j,themeType:o="system"}=this.options,l=this.getOrCreateFileContainer();l.parentElement==null&&e.appendChild(l),this.pre??(this.pre=document.createElement("pre")),this.pre.parentElement==null&&((p=l.shadowRoot)==null||p.appendChild(this.pre));const a=typeof s=="string"?n.getTheme(s).type:void 0,d=Ws({theme:s,highlighter:n});this.applyThemeState(l,d,o,a);const c=Qs(this.pre,{type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:i,overflow:r,split:!1,totalLines:0});c.textContent="",this.pre=c,this.code=Tn({code:this.code,pre:c}),this.gutterElement=void 0,this.contentElement=void 0,this.currentRowCount=0,this.currentLineElement=void 0,this.currentLineIndex=this.options.startingLineIndex??1,(y=this.abortController)==null||y.abort(),this.abortController=new AbortController;const{onStreamStart:u,onStreamClose:h,onStreamAbort:f}=this.options;(v=this.stream)==null||v.cancel().catch(()=>{}),this.stream=t,this.stream.pipeThrough(typeof s=="string"?new Wa({...this.options,theme:s,highlighter:n,allowRecalls:!0,defaultColor:!1,cssVariablePrefix:he("token"),tokenizeTimeLimit:0}):new Wa({...this.options,themes:s,highlighter:n,allowRecalls:!0,defaultColor:!1,cssVariablePrefix:he("token"),tokenizeTimeLimit:0})).pipeTo(new WritableStream({start(m){u==null||u(m)},close(){h==null||h()},abort(m){f==null||f(m)},write:this.handleWrite}),{signal:this.abortController.signal}).catch(m=>{m.name!=="AbortError"&&console.error("FileStream pipe error:",m)})}getOrCreateStreamColumns(){if(this.code==null)throw new Error("FileStream: expected code element to exist");if(this.gutterElement!=null&&this.contentElement!=null)return{gutter:this.gutterElement,content:this.contentElement};const t=document.createElement("div");t.dataset.gutter="";const e=document.createElement("div");return e.dataset.content="",this.code.appendChild(t),this.code.appendChild(e),this.gutterElement=t,this.contentElement=e,{gutter:t,content:e}}updateRowSpan(){this.gutterElement!=null&&(this.gutterElement.style.gridRow=`span ${this.currentRowCount}`),this.contentElement!=null&&(this.contentElement.style.gridRow=`span ${this.currentRowCount}`)}createLine(){const t=this.currentLineIndex,e=`${t-1}`,n=document.createElement("div");n.dataset.columnNumber=`${t}`,n.dataset.lineType="context",n.dataset.lineIndex=e;const i=document.createElement("span");i.dataset.lineNumberContent="",i.textContent=`${t}`,n.appendChild(i);const r=document.createElement("div");return r.dataset.line=`${t}`,r.dataset.lineType="context",r.dataset.lineIndex=e,this.currentRowCount+=1,this.updateRowSpan(),this.currentLineElement=r,{gutterLine:n,contentLine:r}}getOrCreateFileContainer(t){return t!=null&&t===this.fileContainer||t==null&&this.fileContainer!=null?this.fileContainer:(this.fileContainer!=null&&t!=null&&t!==this.fileContainer&&(this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0),this.fileContainer=t??document.createElement("diffs-container"),this.fileContainer)}applyThemeState(t,e,n,i){var d,c;const r=t.shadowRoot??t.attachShadow({mode:"open"}),s=i??n,o=this.options.theme??j,l=typeof o=="string"?o:{...o},a=sn(r);if(((d=this.themeCSSStyle)==null?void 0:d.parentNode)===r&&((c=this.appliedThemeCSS)==null?void 0:c.themeStyles)===e&&this.appliedThemeCSS.themeType===s&&this.appliedThemeCSS.scrollbarGutter===a){this.appliedThemeCSS.theme=l;return}this.themeCSSStyle=Js({shadowRoot:r,currentNode:this.themeCSSStyle,themeCSS:Xs(e,s,a)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:l,themeStyles:e,themeType:s,baseThemeType:i,scrollbarGutter:a}:void 0}};function Ac(t,e){const{resolution:n,hunkIndex:i,startContentIndex:r,endContentIndex:s,indexesToDelete:o=new Set}=e,l=t.hunks[i];if(l==null)throw console.error({diff:t,hunkIndex:i}),new Error(`resolveRegion: Invalid hunk index: ${i}`);if(r<0||s>=l.hunkContent.length||r>s)throw new Error(`resolveRegion: Invalid content range, ${r}, ${s}`);const{hunks:a,additionLines:d,deletionLines:c}=t,u={...t,hunks:[],deletionLines:[],additionLines:[],splitLineCount:0,unifiedLineCount:0,cacheKey:t.cacheKey!=null?`${t.cacheKey}:${n[0]}-${i}:${r}-${s}`:void 0},h={nextAdditionLineIndex:0,nextDeletionLineIndex:0,nextAdditionStart:1,nextDeletionStart:1,splitLineCount:0,unifiedLineCount:0},f=i===a.length-1&&s===l.hunkContent.length-1,p=!t.isPartial;for(const[v,m]of a.entries()){TC(t,u,h,we(m.deletionStart,m.deletionCount)-m.collapsedBefore,we(m.additionStart,m.additionCount)-m.collapsedBefore,m.collapsedBefore,p);const C={...m,hunkContent:[],additionStart:h.nextAdditionStart,deletionStart:h.nextDeletionStart,additionLineIndex:h.nextAdditionLineIndex,deletionLineIndex:h.nextDeletionLineIndex,additionCount:0,deletionCount:0,deletionLines:0,additionLines:0,splitLineStart:h.splitLineCount,unifiedLineStart:h.unifiedLineCount,splitLineCount:0,unifiedLineCount:0};for(const[S,w]of m.hunkContent.entries())if(v!==i||S<r||S>s){ja(w,u,c,d);const b={...w,additionLineIndex:h.nextAdditionLineIndex,deletionLineIndex:h.nextDeletionLineIndex};C.hunkContent.push(b),$r(b,h,C)}else if(o.has(S))C.hunkContent.push({type:"context",lines:0,deletionLineIndex:h.nextDeletionLineIndex,additionLineIndex:h.nextAdditionLineIndex});else if(w.type==="context"){ja(w,u,c,d);const b={...w,deletionLineIndex:h.nextDeletionLineIndex,additionLineIndex:h.nextAdditionLineIndex};C.hunkContent.push(b),$r(b,h,C)}else{IC(n,w,u,c,d);const b={type:"context",lines:n==="deletions"?w.deletions:n==="additions"?w.additions:w.deletions+w.additions,deletionLineIndex:h.nextDeletionLineIndex,additionLineIndex:h.nextAdditionLineIndex};C.hunkContent.push(b),$r(b,h,C)}if(v===i&&f){const S=n==="deletions"?m.noEOFCRDeletions:m.noEOFCRAdditions;C.noEOFCRAdditions=S,C.noEOFCRDeletions=S}C.additionCount===0&&(C.additionStart--,t.isPartial||C.additionLineIndex--),C.deletionCount===0&&(C.deletionStart--,t.isPartial||C.deletionLineIndex--),u.hunks.push(C)}const y=a.at(-1);if(y!=null&&!t.isPartial){const v=oe(y.deletionStart,y.deletionCount),m=oe(y.additionStart,y.additionCount),C=Math.min(c.length-v,d.length-m);Pc(u,c,d,v,m,C),h.splitLineCount+=C,h.unifiedLineCount+=C}return u.splitLineCount=h.splitLineCount,u.unifiedLineCount=h.unifiedLineCount,u}function Pc(t,e,n,i,r,s){for(let o=0;o<s;o++){const l=e[i+o],a=n[r+o];if(l==null||a==null)throw new Error("pushCollapsedContextLines: missing collapsed context line");t.deletionLines.push(l),t.additionLines.push(a)}}function TC(t,e,n,i,r,s,o){s<=0||(o&&(Pc(e,t.deletionLines,t.additionLines,i,r,s),n.nextAdditionLineIndex+=s,n.nextDeletionLineIndex+=s),n.nextAdditionStart+=s,n.nextDeletionStart+=s,n.splitLineCount+=s,n.unifiedLineCount+=s)}function ja(t,e,n,i){if(t.type==="context")for(let r=0;r<t.lines;r++){const s=i[t.additionLineIndex+r];if(s==null)throw console.error({additionLines:i,content:t,i:r}),new Error("pushContentLinesToDiff: Context line does not exist");e.deletionLines.push(s),e.additionLines.push(s)}else{const r=Math.max(t.deletions,t.additions);for(let s=0;s<r;s++){if(s<t.deletions){const o=n[t.deletionLineIndex+s];if(o==null)throw console.error({deletionLines:n,content:t,i:s}),new Error("pushContentLinesToDiff: Deletion line does not exist");e.deletionLines.push(o)}if(s<t.additions){const o=i[t.additionLineIndex+s];if(o==null)throw console.error({additionLines:i,content:t,i:s}),new Error("pushContentLinesToDiff: Addition line does not exist");e.additionLines.push(o)}}}}function IC(t,e,n,i,r){if(t==="deletions"||t==="both")for(let s=0;s<e.deletions;s++){const o=i[e.deletionLineIndex+s];if(o==null)throw console.error({deletionLines:i,content:e,i:s}),new Error("pushResolveLinesToDiff: Deletion line does not exist");n.deletionLines.push(o),n.additionLines.push(o)}if(t==="additions"||t==="both")for(let s=0;s<e.additions;s++){const o=r[e.additionLineIndex+s];if(o==null)throw console.error({additionLines:r,content:e,i:s}),new Error("pushResolveLinesToDiff: Addition line does not exist");n.deletionLines.push(o),n.additionLines.push(o)}}function $r(t,e,n){t.type==="context"?(e.nextAdditionLineIndex+=t.lines,e.nextDeletionLineIndex+=t.lines,e.nextAdditionStart+=t.lines,e.nextDeletionStart+=t.lines,e.splitLineCount+=t.lines,e.unifiedLineCount+=t.lines,n.additionCount+=t.lines,n.deletionCount+=t.lines,n.splitLineCount+=t.lines,n.unifiedLineCount+=t.lines):(e.nextAdditionLineIndex+=t.additions,e.nextDeletionLineIndex+=t.deletions,e.nextAdditionStart+=t.additions,e.nextDeletionStart+=t.deletions,e.splitLineCount+=Math.max(t.deletions,t.additions),e.unifiedLineCount+=t.deletions+t.additions,n.deletionCount+=t.deletions,n.deletionLines+=t.deletions,n.additionCount+=t.additions,n.additionLines+=t.additions,n.splitLineCount+=Math.max(t.deletions,t.additions),n.unifiedLineCount+=t.deletions+t.additions)}function Mc(t){const e=typeof t=="string"?t:t.type;return e==="accept"||e==="incoming"?"additions":e==="reject"||e==="current"?"deletions":"both"}function AC(t,e,n){return Ac(t,{resolution:Mc(n),hunkIndex:e.hunkIndex,startContentIndex:e.startContentIndex,endContentIndex:e.endContentIndex,indexesToDelete:PC(e)})}function PC(t){const e=new Set;return t.baseContentIndex!=null&&e.add(t.baseContentIndex),t.endMarkerContentIndex!==t.endContentIndex&&e.add(t.endMarkerContentIndex),e}function Dc({hunkIndex:t,lineIndex:e,conflictIndex:n}){return`merge-conflict-action-${t}-${e}-${n}`}function Hc(t,e){const n=e.hunks[t.hunkIndex];if(n!=null)return{hunkIndex:t.hunkIndex,lineIndex:FC(n,t.startContentIndex)}}function qa(t,e=6){e=Math.max(e,1);const n={deletionLines:[],additionLines:[],conflictStack:[],conflictBuilders:[],actions:[],hunks:[],nextConflictIndex:0,splitLineCount:0,unifiedLineCount:0,lastHunkEnd:0,activeHunk:void 0,maxContextLines:e,maxContextLines2:e*2},i=t.contents,r=i.length;if(r>0){let u=0,h=0,f=i.indexOf(`
320
+ `,u);for(;f!==-1;)Ka(n,i.slice(u,f+1),h),u=f+1,h++,f=i.indexOf(`
321
+ `,u);u<r&&Ka(n,i.slice(u),h)}if(n.conflictStack.length>0)throw new Error("parseMergeConflictDiffFromFile: unfinished merge conflict marker stack");n.activeHunk!=null&&n.activeHunk.hunkContent.length>0&&(io(n,n.activeHunk,"trailing"),Fc(n));for(let u=0;u<n.conflictBuilders.length;u++){const h=n.conflictBuilders[u];if(h==null||!h.completed)throw new Error(`parseMergeConflictDiffFromFile: failed to build merge conflict action ${u}`)}if(n.hunks.length>0&&n.additionLines.length>0&&n.deletionLines.length>0){const u=n.hunks[n.hunks.length-1],h=Math.max(n.additionLines.length-oe(u.additionStart,u.additionCount),0);n.splitLineCount+=h,n.unifiedLineCount+=h}const s=n.deletionLines.join(""),o=n.additionLines.join(""),l=el(t,"current",s),a=el(t,"incoming",o);let d="change";o===""?d="deleted":s===""&&(d="new");const c={name:t.name,prevName:void 0,type:d,hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,isPartial:!1,deletionLines:n.deletionLines,additionLines:n.additionLines,cacheKey:t.cacheKey!=null?`${t.cacheKey}:merge-conflict-diff`:void 0};return{fileDiff:c,currentFile:l,incomingFile:a,actions:n.actions,markerRows:zc(c,n.actions)}}function Ka(t,e,n){const i=t.conflictStack[t.conflictStack.length-1];if(i==null){if(e.length>=7&&e.charCodeAt(0)===60&&Ja(e)==="start"){Qa(t,e,n);return}Xa(t,e);return}const r=Ja(e);if(r==="start"){Qa(t,e,n);return}if(r==="base"){i.stage="base",i.baseMarkerLineIndex=n,i.markerLines.base=e;return}if(r==="separator"){i.stage="incoming",i.separatorLineIndex=n,i.markerLines.separator=e;return}if(r==="end"){const s=t.conflictStack.pop();if(s==null)throw new Error("parseMergeConflictDiffFromFile: encountered end marker before start marker");HC(t,s,n,e);return}i.stage==="current"?Ya(t,"deletion",e,i.conflictIndex,"current"):i.stage==="base"?Xa(t,e,i.conflictIndex):Ya(t,"addition",e,i.conflictIndex,"incoming")}function Oc(t){return t.activeHunk??(t.activeHunk=$c(t.additionLines.length+1,t.deletionLines.length+1)),t.activeHunk}function Nc(t,e,n,i){const r=t.conflictBuilders[e];if(r==null)throw new Error(`parseMergeConflictDiffFromFile: failed to locate conflict action ${e}`);const s=r.action,o=t.hunks.length;if(s.hunkIndex<0)s.hunkIndex=o;else if(s.hunkIndex!==o)throw new Error(`parseMergeConflictDiffFromFile: conflict ${e} spans multiple hunks and cannot be anchored`);if(s.startContentIndex<0&&(s.startContentIndex=i),s.endContentIndex=i,s.endMarkerContentIndex=i,n==="current"){s.currentContentIndex??(s.currentContentIndex=i);return}if(n==="base"){s.baseContentIndex??(s.baseContentIndex=i);return}s.incomingContentIndex=i}function MC(t,e,n,i){const r=t.hunkContent,s=r[r.length-1];return(s==null?void 0:s.type)==="change"?(e==="addition"?s.additions++:s.deletions++,r.length-1):(r.push({type:"change",additions:e==="addition"?1:0,deletions:e==="deletion"?1:0,additionLineIndex:n,deletionLineIndex:i}),r.length-1)}function io(t,e,n){let i=e.contextBufferCount,r=e.contextBufferAdditionStart,s=e.contextBufferDeletionStart;if(n==="leading"&&i>t.maxContextLines){const c=i-t.maxContextLines;r+=c,s+=c,i=t.maxContextLines,e.additionStart+=c,e.deletionStart+=c,e.additionLineIndex+=c,e.deletionLineIndex+=c}if(n==="trailing"&&i>t.maxContextLines&&(i=t.maxContextLines),i===0){e.contextBufferCount=0,e.contextBufferBaseConflicts=void 0;return}const o=e.hunkContent,l=o[o.length-1];let a;(l==null?void 0:l.type)==="context"?(l.lines+=i,a=o.length-1):(o.push({type:"context",lines:i,additionLineIndex:r,deletionLineIndex:s}),a=o.length-1),e.additionCount+=i,e.deletionCount+=i;const d=e.contextBufferBaseConflicts;if(d!=null){const c=r-e.contextBufferAdditionStart;for(const[u,h]of d)u>=c&&u<c+i&&Nc(t,h,"base",a)}e.contextBufferCount=0,e.contextBufferBaseConflicts=void 0}function Fc(t){if(t.activeHunk==null)return;const e=t.activeHunk;if(t.activeHunk=void 0,e.hunkContent.length===0)return;let n=0,i=0;for(const a of e.hunkContent)a.type==="context"?(n+=a.lines,i+=a.lines):(n+=Math.max(a.additions,a.deletions),i+=a.additions+a.deletions);const r=e.additionCount===0?e.additionStart-1:e.additionStart,s=e.deletionCount===0?e.deletionStart-1:e.deletionStart,o=Math.max(we(r,e.additionCount)-t.lastHunkEnd,0),l={collapsedBefore:o,additionStart:r,additionCount:e.additionCount,additionLines:e.additionLines,additionLineIndex:e.additionLineIndex,deletionStart:s,deletionCount:e.deletionCount,deletionLines:e.deletionLines,deletionLineIndex:e.deletionLineIndex,hunkContent:e.hunkContent,hunkContext:void 0,hunkSpecs:`@@ -${Za(s,e.deletionCount)} +${Za(r,e.additionCount)} @@
322
+ `,splitLineStart:t.splitLineCount+o,splitLineCount:n,unifiedLineStart:t.unifiedLineCount+o,unifiedLineCount:i,noEOFCRAdditions:!1,noEOFCRDeletions:!1};t.hunks.push(l),t.splitLineCount+=o+n,t.unifiedLineCount+=o+i,t.lastHunkEnd=oe(r,e.additionCount)}function DC(t){if(t.activeHunk==null)return;const e=t.activeHunk,n=e.contextBufferCount,i=n-t.maxContextLines2,r=e.contextBufferAdditionStart+n-t.maxContextLines,s=e.contextBufferDeletionStart+n-t.maxContextLines;let o;if(e.contextBufferBaseConflicts!=null){const d=n-t.maxContextLines;for(const[c,u]of e.contextBufferBaseConflicts)c>=d&&(o??(o=new Map),o.set(c-d,u))}io(t,e,"trailing");const l=e.additionCount,a=e.deletionCount;Fc(t),t.activeHunk=$c(e.additionStart+l+i,e.deletionStart+a+i),t.activeHunk.contextBufferAdditionStart=r,t.activeHunk.contextBufferDeletionStart=s,t.activeHunk.contextBufferCount=t.maxContextLines,t.activeHunk.contextBufferBaseConflicts=o}function Xa(t,e,n=-1){const i=Oc(t);i.contextBufferCount===0&&(i.contextBufferAdditionStart=t.additionLines.length,i.contextBufferDeletionStart=t.deletionLines.length),t.additionLines.push(e),t.deletionLines.push(e),n>=0&&(i.contextBufferBaseConflicts??(i.contextBufferBaseConflicts=new Map),i.contextBufferBaseConflicts.set(i.contextBufferCount,n)),i.contextBufferCount++}function Ya(t,e,n,i,r){let s=Oc(t);s.hunkContent.length>0&&s.contextBufferCount>t.maxContextLines2&&(DC(t),s=t.activeHunk),io(t,s,s.hunkContent.length===0?"leading":"before-change");const o=t.additionLines.length,l=t.deletionLines.length;e==="addition"?t.additionLines.push(n):t.deletionLines.push(n);const a=MC(s,e,o,l);e==="addition"?(s.additionCount++,s.additionLines++):(s.deletionCount++,s.deletionLines++),Nc(t,i,r,a)}function HC(t,e,n,i){if(e.separatorLineIndex==null||e.markerLines.separator==null)throw new Error(`parseMergeConflictDiffFromFile: conflict ${e.conflictIndex} is missing a separator marker`);const r=t.conflictBuilders[e.conflictIndex];if(r==null)throw new Error(`parseMergeConflictDiffFromFile: failed to finalize conflict ${e.conflictIndex}`);const s=r.action;s.markerLines.separator=e.markerLines.separator,s.markerLines.end=i,e.markerLines.base!=null&&(s.markerLines.base=e.markerLines.base),s.conflict={conflictIndex:e.conflictIndex,startLineIndex:e.startLineIndex,startLineNumber:e.startLineIndex+1,separatorLineIndex:e.separatorLineIndex,separatorLineNumber:e.separatorLineIndex+1,endLineIndex:n,endLineNumber:n+1,baseMarkerLineIndex:e.baseMarkerLineIndex,baseMarkerLineNumber:e.baseMarkerLineIndex!=null?e.baseMarkerLineIndex+1:void 0};const o=s.currentContentIndex??s.incomingContentIndex;if(s.currentContentIndex??(s.currentContentIndex=o),s.incomingContentIndex??(s.incomingContentIndex=o),s.startContentIndex<0&&o!=null&&(s.startContentIndex=o),s.endContentIndex<0&&o!=null&&(s.endContentIndex=o),s.endMarkerContentIndex<0&&o!=null&&(s.endMarkerContentIndex=o),s.hunkIndex<0||s.startContentIndex<0||s.endContentIndex<0||s.endMarkerContentIndex<0)throw new Error(`parseMergeConflictDiffFromFile: failed to anchor merge conflict ${e.conflictIndex}`);t.actions[s.conflictIndex]=s,r.completed=!0}function Qa(t,e,n){const i=t.nextConflictIndex;t.nextConflictIndex++,t.conflictStack.push({conflictIndex:i,stage:"current",startLineIndex:n,markerLines:{start:e}}),t.conflictBuilders[i]={completed:!1,action:{conflict:{conflictIndex:i,startLineIndex:n,startLineNumber:n+1,separatorLineIndex:n,separatorLineNumber:n+1,endLineIndex:n,endLineNumber:n+1,baseMarkerLineIndex:void 0,baseMarkerLineNumber:void 0},conflictIndex:i,hunkIndex:-1,startContentIndex:-1,endContentIndex:-1,endMarkerContentIndex:-1,markerLines:{start:e,separator:"",end:""}}}}function $c(t,e){return{additionStart:t,deletionStart:e,additionCount:0,deletionCount:0,additionLines:0,deletionLines:0,additionLineIndex:Math.max(t-1,0),deletionLineIndex:Math.max(e-1,0),hunkContent:[],contextBufferAdditionStart:Math.max(t-1,0),contextBufferDeletionStart:Math.max(e-1,0),contextBufferCount:0,contextBufferBaseConflicts:void 0}}function Za(t,e){return e===1?`${t}`:`${t},${e}`}function Ja(t){if(t.length<7)return;const e=t.charCodeAt(0);if(e!==60&&e!==62&&e!==61&&e!==124)return;const n=OC(t);if(n<7)return;let i=1;for(;i<n&&t.charCodeAt(i)===e;)i++;if(!(i<7)){if(e===61)return i===n?"separator":void 0;if(!(i!==n&&!NC(t.charCodeAt(i))))return e===60?"start":e===62?"end":"base"}}function OC(t){let e=t.length;return e>0&&t.charCodeAt(e-1)===10&&e--,e>0&&t.charCodeAt(e-1)===13&&e--,e}function NC(t){return t===9||t===10||t===11||t===12||t===13||t===32}function el(t,e,n){return{...t,contents:n,cacheKey:t.cacheKey!=null?`${t.cacheKey}:merge-conflict-${e}`:void 0}}function zc(t,e){const n=[],i=new Array(t.hunks.length),r=(o,l)=>{const a=t.hunks[o];if(a==null)return 0;let d=i[o];if(d==null){d=new Array(a.hunkContent.length+1);let c=a.unifiedLineStart;d[0]=c;for(let u=0;u<a.hunkContent.length;u++){const h=a.hunkContent[u];c+=h.type==="context"?h.lines:h.deletions+h.additions,d[u+1]=c}i[o]=d}return d[Math.max(l,0)]??a.unifiedLineStart},s=(o,l)=>{var c;const a=r(o,l),d=((c=i[o])==null?void 0:c[Math.max(l+1,0)])??r(o,l+1);return Math.max(a,d-1)};for(const o of e){if(o==null)continue;const l=t.hunks[o.hunkIndex];if(l==null)continue;const a=r(o.hunkIndex,o.startContentIndex);if(n.push(jt(o,"marker-start",o.startContentIndex,o.markerLines.start,a)),o.baseContentIndex!=null){const f=o.currentContentIndex,p=o.incomingContentIndex;if(f==null||p==null)continue;const y=o.markerLines.base;if(y==null)continue;const v=l.hunkContent[f],m=l.hunkContent[o.baseContentIndex],C=l.hunkContent[p];if((v==null?void 0:v.type)!=="change"||(m==null?void 0:m.type)!=="context"||(C==null?void 0:C.type)!=="change")continue;const S=r(o.hunkIndex,f),w=r(o.hunkIndex,p);n.push(jt(o,"marker-base",o.baseContentIndex,y,S+v.deletions)),n.push(jt(o,"marker-separator",o.baseContentIndex,o.markerLines.separator,w),jt(o,"marker-end",o.endMarkerContentIndex,o.markerLines.end,s(o.hunkIndex,o.endMarkerContentIndex)));continue}const d=o.currentContentIndex;if(d==null)continue;const c=l.hunkContent[d];if((c==null?void 0:c.type)!=="change")continue;const u=r(o.hunkIndex,d),h=c.deletions>0?u+c.deletions:a;n.push(jt(o,"marker-separator",d,o.markerLines.separator,h),jt(o,"marker-end",o.endMarkerContentIndex,o.markerLines.end,s(o.hunkIndex,o.endMarkerContentIndex)))}return n}function jt(t,e,n,i,r){return{type:e,hunkIndex:t.hunkIndex,contentIndex:n,conflictIndex:t.conflictIndex,lineText:i,lineIndex:r}}function FC(t,e){let n=t.unifiedLineStart;for(let i=0;i<e;i++){const r=t.hunkContent[i];n+=r.type==="context"?r.lines:r.deletions+r.additions}return n}var tl=class extends Ec{constructor(e={theme:j},n,i,r){super(void 0,n,i,r);g(this,"pendingConflictActions",[]);g(this,"pendingMarkerRows",[]);g(this,"injectedRows",new Map);g(this,"options");g(this,"getUnifiedInjectedRowsForLine",e=>{const n=this.injectedRows.get(`${e.hunkIndex}:${e.lineIndex}`);if(n==null||n.length===0)return;const{mergeConflictActionsType:i}=this.getOptionsWithDefaults(),r=[],s=[];for(const o of n){if(o.type==="actions"){r.push({content:$C({row:o,includeDefaultActions:i==="default",includeSlot:!0}),gutter:rl("action")});continue}(o.type==="marker-end"?s:r).push({content:zC(o),gutter:rl("marker",o.type)})}return{before:r.length>0?r:void 0,after:s.length>0?s:void 0}});this.options=e}setConflictState(e,n,i){this.pendingConflictActions=e,this.pendingMarkerRows=n,this.syncInjectedRows(e,n,i)}syncInjectedRows(e,n,i){this.injectedRows.clear();for(const r of e){const s=r!=null?Hc(r,i):void 0;if(r==null||s==null)continue;const o={type:"actions",hunkIndex:s.hunkIndex,lineIndex:s.lineIndex,conflictIndex:r.conflictIndex};this.addInjectedRow(o)}for(const r of n)this.addInjectedRow(r)}addInjectedRow(e){const n=`${e.hunkIndex}:${e.lineIndex}`,i=this.injectedRows.get(n);i==null?this.injectedRows.set(n,[e]):i.push(e)}renderDiff(e,n=Jt){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=Jt){return this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.asyncRender(e,n)}createPreElement(e,n){return super.createPreElement(e,n,{"data-has-merge-conflict":""})}getUnifiedLineDecoration({type:e,lineType:n}){const i=e==="change"?n==="change-deletion"?"current":"incoming":void 0;return{gutterLineType:e==="change"?"context":n,gutterProperties:nl(i),contentProperties:il(e,i)}}getSplitLineDecoration({side:e,type:n}){const i=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:nl(i),contentProperties:il(n,i)}}getOptionsWithDefaults(){const e=super.getOptionsWithDefaults();return e.diffStyle="unified",e.lineDiffType="none",e.mergeConflictActionsType=this.options.mergeConflictActionsType??"default",e}};function nl(t){return t!=null?{"data-merge-conflict":t}:void 0}function il(t,e){if(e!=null){if(t==="change")return e==="current"||e==="incoming"?{"data-line-type":"context","data-merge-conflict":e}:void 0;if(e==="marker-start"||e==="marker-base"||e==="marker-separator"||e==="marker-end")return{"data-merge-conflict":e}}}function rl(t,e){const n=Le(void 0,"annotation",1);return n.properties["data-gutter-buffer"]=t==="action"?"merge-conflict-action":`merge-conflict-${e??"marker"}`,n}function $C({row:t,includeDefaultActions:e,includeSlot:n}){const i=e?UC(t.conflictIndex):[];return i.push(M({tagName:"slot",properties:{name:Dc({hunkIndex:t.hunkIndex,lineIndex:t.lineIndex,conflictIndex:t.conflictIndex}),"data-merge-conflict-action-slot":""}})),M({tagName:"div",properties:{"data-merge-conflict-actions":""},children:[M({tagName:"div",properties:{"data-merge-conflict-actions-content":""},children:i})]})}function zC(t){return M({tagName:"div",properties:{"data-merge-conflict":t.type,"data-merge-conflict-marker-row":""},children:[Se(t.lineText.replace(/(?:\r\n|\n|\r)$/,""))]})}function UC(t){return[zr({resolution:"current",label:"Accept current change",conflictIndex:t}),sl(),zr({resolution:"incoming",label:"Accept incoming change",conflictIndex:t}),sl(),zr({resolution:"both",label:"Accept both",conflictIndex:t})]}function zr({resolution:t,label:e,conflictIndex:n}){return M({tagName:"button",properties:{type:"button","data-merge-conflict-action":t,"data-merge-conflict-conflict-index":`${n}`},children:[Se(e)]})}function sl(){return M({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[Se("|")]})}function BC(t,e){return t.hunkIndex===e.hunkIndex&&t.startContentIndex===e.startContentIndex&&t.endContentIndex===e.endContentIndex&&t.currentContentIndex===e.currentContentIndex&&t.baseContentIndex===e.baseContentIndex&&t.incomingContentIndex===e.incomingContentIndex&&t.endMarkerContentIndex===e.endMarkerContentIndex&&t.conflictIndex===e.conflictIndex&&VC(t.conflict,e.conflict)}function VC(t,e){return t.conflictIndex===e.conflictIndex&&t.startLineIndex===e.startLineIndex&&t.startLineNumber===e.startLineNumber&&t.separatorLineIndex===e.separatorLineIndex&&t.separatorLineNumber===e.separatorLineNumber&&t.endLineIndex===e.endLineIndex&&t.endLineNumber===e.endLineNumber&&t.baseMarkerLineIndex===e.baseMarkerLineIndex&&t.baseMarkerLineNumber===e.baseMarkerLineNumber}let GC=-1;var AS=class extends Rc{constructor(e={theme:j},n,i=!1){super(void 0,n,i);g(this,"options");g(this,"__id",`unresolved-file:${++GC}`);g(this,"type","unresolved-file");g(this,"computedCache",{file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0});g(this,"conflictActions",[]);g(this,"markerRows",[]);g(this,"conflictActionCache",new Map);g(this,"handleMergeConflictActionClick",e=>{const n=this.conflictActions[e.conflictIndex];if(n==null)return;if(n.conflictIndex!==e.conflictIndex)throw console.error({conflictIndex:e.conflictIndex,action:n}),new Error("UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match");const i={resolution:e.resolution,conflict:n.conflict};if(this.options.onMergeConflictAction!=null){this.options.onMergeConflictAction(i,this);return}this.resolveConflictAndRender(e.conflictIndex,e.resolution)});this.options=e,this.setOptions(e)}setOptions(e){if(e!=null){if(e.onMergeConflictAction!=null&&e.onMergeConflictResolve!=null)throw new Error("UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.");this.options=e,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions()}}syncInteractionOptions(){this.interactionManager.setOptions($n(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,this.handleMergeConflictActionClick))}createHunksRenderer(e){return new tl(this.getHunksRendererOptions(e),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(e){return JC(e,this.options)}applyPreNodeAttributes(e,n){super.applyPreNodeAttributes(e,n,{"data-has-merge-conflict":""})}cleanUp(){this.emitPostRender(!0),this.clearMergeConflictActionCache(),this.computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0},this.conflictActions=[],super.cleanUp()}getOrComputeDiff({file:e,fileDiff:n,actions:i,markerRows:r}){var l;const{maxContextLines:s,onMergeConflictAction:o}=this.options;e:if(o!=null){const a=n!=null;if(a!==(i!=null)||a!==(r!=null))throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together");if(n!=null&&i!=null&&r!=null){this.computedCache={file:e??this.computedCache.file,fileDiff:n,actions:i,markerRows:r};break e}else if(e!=null||this.computedCache.file!=null){if(e!=null&&this.computedCache.file!=null&&!In(e,this.computedCache.file)&&this.computedCache.fileDiff!=null&&this.computedCache.actions!=null)throw new Error("UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.");if(e??(e=this.computedCache.file),e==null)throw new Error("UnresolvedFile.getOrComputeDiff: file is null, should be impossible");if(!In(e,this.computedCache.file)||this.computedCache.fileDiff==null||this.computedCache.actions==null){const d=qa(e,s);this.computedCache={file:e,fileDiff:d.fileDiff,actions:d.actions,markerRows:d.markerRows}}n=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}else{n=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}}else{if(n!=null||i!=null||r!=null)throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`");if(e!=null&&this.computedCache.file!=null&&!In(e,this.computedCache.file))throw new Error("UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.");if((l=this.computedCache).file??(l.file=e),this.computedCache.fileDiff==null&&this.computedCache.file!=null){const a=qa(this.computedCache.file,s);this.computedCache.fileDiff=a.fileDiff,this.computedCache.actions=a.actions,this.computedCache.markerRows=a.markerRows}n=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}if(!(n==null||i==null||r==null))return{fileDiff:n,actions:i,markerRows:r}}hydrate(e){const{file:n,fileDiff:i,actions:r,markerRows:s,lineAnnotations:o,fileContainer:l,prerenderedHTML:a,preventEmit:d=!1}=e,c=this.getOrComputeDiff({file:n,fileDiff:i,actions:r,markerRows:s});c!=null&&(this.hydrateElements(l,a),this.setActiveMergeConflictState(c.actions,c.markerRows),QC(this.pre,c.fileDiff,this.options.collapsed)||ZC(this.headerElement,c.fileDiff,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):(this.hydrationSetup({fileDiff:c.fileDiff,lineAnnotations:o}),this.pre!=null&&this.renderMergeConflictActionSlots()),d||this.emitPostRender())}rerender(){!this.enabled||this.fileDiff==null||this.render({forceRender:!0,renderRange:this.renderRange})}render(e={}){const{file:n,fileDiff:i,actions:r,markerRows:s,lineAnnotations:o,preventEmit:l=!1,...a}=e,d=this.getOrComputeDiff({file:n,fileDiff:i,actions:r,markerRows:s});if(d==null)return!1;this.setActiveMergeConflictState(d.actions,d.markerRows);const c=super.render({...a,fileDiff:d.fileDiff,lineAnnotations:o,preventEmit:!0});return c&&(this.renderMergeConflictActionSlots(),l||this.emitPostRender()),c}resolveConflict(e,n,i=this.computedCache.fileDiff){const r=this.conflictActions[e];if(i==null||r==null)return;if(r.conflictIndex!==e)throw console.error({conflictIndex:e,action:r}),new Error("UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match");const s=AC(i,r,n),o=this.computedCache.file,{file:l,actions:a,markerRows:d}=WC({fileDiff:s,previousActions:this.conflictActions,resolvedConflictIndex:e,previousFile:o,resolution:n});return{file:l,fileDiff:s,actions:a,markerRows:d}}resolveConflictAndRender(e,n){var d,c;const i=this.conflictActions[e];if(i==null)return;if(i.conflictIndex!==e)throw console.error({conflictIndex:e,action:i}),new Error("UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match");const r={resolution:n,conflict:i.conflict},{file:s,fileDiff:o,actions:l,markerRows:a}=this.resolveConflict(e,n)??{};s==null||o==null||l==null||a==null||(this.computedCache={file:s,fileDiff:o,actions:l,markerRows:a},this.setActiveMergeConflictState(l,a),this.workerManager!=null?this.hunksRenderer.renderDiff(o):this.render({forceRender:!0}),(c=(d=this.options).onMergeConflictResolve)==null||c.call(d,s,r))}setActiveMergeConflictState(e=this.conflictActions,n=this.markerRows){this.conflictActions=e,this.markerRows=n,this.computedCache.fileDiff!=null&&this.hunksRenderer instanceof tl&&this.hunksRenderer.setConflictState(this.options.mergeConflictActionsType==="none"?[]:e,n,this.computedCache.fileDiff)}renderMergeConflictActionSlots(){const{fileDiff:e}=this.computedCache;if(this.isContainerManaged||this.fileContainer==null||typeof this.options.mergeConflictActionsType!="function"||this.conflictActions.length===0||e==null){this.clearMergeConflictActionCache();return}const n=new Map(this.conflictActionCache);for(let i=0;i<this.conflictActions.length;i++){const r=this.conflictActions[i];if(r==null)continue;if(r.conflictIndex!==i)throw console.error({conflictIndex:i,action:r}),new Error("UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match");const s=Hc(r,e);if(s==null)continue;const o=r.conflictIndex,l=Dc({hunkIndex:s.hunkIndex,lineIndex:s.lineIndex,conflictIndex:o}),a=`${i}-${l}`;let d=this.conflictActionCache.get(a);if(d==null||!BC(d.action,r)){d==null||d.element.remove();const c=this.renderMergeConflictAction(r);if(c==null)continue;const u=js(l);u.appendChild(c),this.fileContainer.appendChild(u),d={element:u,action:r},this.conflictActionCache.set(a,d)}n.delete(a)}for(const[i,{element:r}]of n.entries())this.conflictActionCache.delete(i),r.remove()}renderMergeConflictAction(e){if(typeof this.options.mergeConflictActionsType!="function")return;const n=this.options.mergeConflictActionsType(e,this);if(n!=null){if(n instanceof HTMLElement)return n;if(typeof DocumentFragment<"u"&&n instanceof DocumentFragment){const i=document.createElement("div");return i.style.display="contents",i.appendChild(n),i}}}clearMergeConflictActionCache(){for(const{element:e}of this.conflictActionCache.values())e.remove();this.conflictActionCache.clear()}};function WC({fileDiff:t,previousActions:e,resolvedConflictIndex:n,previousFile:i,resolution:r}){const s=e[n];if(s==null)throw new Error("rebuildFileAndActions: missing resolved action for unresolved file rebuild");const o=KC(e,n,s,r),l=zc(t,o);return{file:jC({fileDiff:t,resolvedAction:s,resolvedConflictIndex:n,previousFile:i,resolution:r}),actions:o,markerRows:l}}function jC({resolvedAction:t,resolvedConflictIndex:e,previousFile:n,fileDiff:i,resolution:r}){const s=(n==null?void 0:n.contents)??"",o=Bn(s),{conflict:l}=t,a=qC(o,l,r),d=[...o.slice(0,l.startLineIndex),...a,...o.slice(l.endLineIndex+1)].join("");return{name:(n==null?void 0:n.name)??i.name,contents:d,cacheKey:(n==null?void 0:n.cacheKey)!=null?`${n.cacheKey}:mc-${e}-${r}`:void 0}}function qC(t,e,n){const i=t.slice(e.startLineIndex+1,e.baseMarkerLineIndex??e.separatorLineIndex),r=t.slice(e.separatorLineIndex+1,e.endLineIndex);return n==="current"?i:n==="incoming"?r:[...i,...r]}function KC(t,e,n,i){const r=XC(n.conflict,i);return t.map((s,o)=>{if(o!==e&&s!=null)return s.conflict.startLineIndex>n.conflict.endLineIndex?{...s,conflict:YC(s.conflict,r)}:s})}function XC(t,e){const n=(t.baseMarkerLineIndex??t.separatorLineIndex)-t.startLineIndex-1,i=t.endLineIndex-t.separatorLineIndex-1;return(e==="current"?n:e==="incoming"?i:n+i)-(t.endLineIndex-t.startLineIndex+1)}function YC(t,e){return{...t,startLineIndex:t.startLineIndex+e,startLineNumber:t.startLineNumber+e,separatorLineIndex:t.separatorLineIndex+e,separatorLineNumber:t.separatorLineNumber+e,endLineIndex:t.endLineIndex+e,endLineNumber:t.endLineNumber+e,baseMarkerLineIndex:t.baseMarkerLineIndex!=null?t.baseMarkerLineIndex+e:void 0,baseMarkerLineNumber:t.baseMarkerLineNumber!=null?t.baseMarkerLineNumber+e:void 0}}function QC(t,e,n=!1){return!n&&t==null&&e!=null}function ZC(t,e,n=!1){return t==null&&e!=null&&!n}function JC(t,e){const n={...e,...t};return{...n,useTokenTransformer:Zs(n),hunkSeparators:typeof(t==null?void 0:t.hunkSeparators)=="function"?"custom":t==null?void 0:t.hunkSeparators,mergeConflictActionsType:typeof(t==null?void 0:t.mergeConflictActionsType)=="function"?"custom":t==null?void 0:t.mergeConflictActionsType}}function eS(t,e){return t==null||e==null?t===e:t.top===e.top&&t.bottom===e.bottom}const Uc=1e3,tS=Uc*4,nS=[0,1e-6,.99999,1],iS={overscrollSize:Uc,intersectionObserverMargin:tS,resizeDebugging:!1};let mi=0,rS=-1;var ue,PS=(ue=class{constructor(e){g(this,"__id",`virtualizer-${++rS}`);g(this,"config");g(this,"type","simple");g(this,"intersectionObserver");g(this,"scrollTop",0);g(this,"height",0);g(this,"scrollHeight",0);g(this,"windowSpecs",{top:0,bottom:0});g(this,"root");g(this,"contentContainer");g(this,"resizeObserver");g(this,"observers",new Map);g(this,"visibleInstances",new Map);g(this,"visibleInstancesDirty",!1);g(this,"instancesChanged",new Set);g(this,"reconcileQueue",new Set);g(this,"scrollDirty",!0);g(this,"heightDirty",!0);g(this,"scrollHeightDirty",!0);g(this,"renderedObservers",0);g(this,"connectQueue",new Map);g(this,"handleContainerResize",e=>{if(this.root==null)return;let n=!1;for(const i of e){const r=i.borderBoxSize[0].blockSize;this.root instanceof Document?r!==this.scrollHeight&&(this.scrollHeightDirty=!0,n=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:r-mi,newSize:r}),mi=r)):i.target===this.root?r!==this.height&&(this.heightDirty=!0,n=!0):i.target===this.contentContainer&&(this.scrollHeightDirty=!0,n=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:r-mi,newSize:r}),mi=r))}n&&de(this.computeRenderRangeAndEmit)});g(this,"handleWindowResize",()=>{ue.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,de(this.computeRenderRangeAndEmit))});g(this,"handleWindowScroll",()=>{ue.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,de(this.computeRenderRangeAndEmit))});g(this,"handleElementScroll",()=>{ue.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,de(this.computeRenderRangeAndEmit))});g(this,"computeRenderRangeAndEmit",()=>{if(ue.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;let n=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const s=ls({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&eS(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.reconcileQueue.size===0)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const i=this.getScrollAnchor(this.height),r=new Set;for(const s of e?this.observers.values():this.visibleInstances.values())s.onRender(e)&&r.add(s);for(const s of this.instancesChanged)r.has(s)||s.onRender(e)&&r.add(s);this.scrollFix(i);for(const s of r)this.reconcileQueue.delete(s),s.reconcileHeights();for(const s of this.reconcileQueue)s.reconcileHeights()&&(n=!0);this.reconcileQueue.clear(),n||(n=this.instancesChanged.size>0),n&&this.markDOMDirty(),(n||e)&&de(this.computeRenderRangeAndEmit),r.clear(),this.instancesChanged.clear()});g(this,"handleIntersectionChange",e=>{this.scrollDirty=!0;for(const{target:n,isIntersecting:i}of e){if(!(n instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const r=this.observers.get(n);r!=null&&(i&&!this.visibleInstances.has(n)?(r.setVisibility(!0),this.visibleInstances.set(n,r),this.visibleInstancesDirty=!0):!i&&this.visibleInstances.has(n)&&(r.setVisibility(!1),this.visibleInstances.delete(n),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&de(this.computeRenderRangeAndEmit)});this.config={...iS,...e}}setup(e,n){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:nS,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(n),window.__INSTANCE=this,window.__TOGGLE=()=>{ue.__STOP?(ue.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:ue.__lastScrollPosition}),de(this.computeRenderRangeAndEmit)):(ue.__lastScrollPosition=this.getScrollTop(),ue.__STOP=!0)};for(const[i,r]of this.connectQueue.entries())this.connect(i,r);this.connectQueue.clear(),this.markDOMDirty(),de(this.computeRenderRangeAndEmit)}}instanceChanged(e,n){this.instancesChanged.add(e),n&&this.markDOMDirty(),de(this.computeRenderRangeAndEmit)}requestHeightReconcile(e){this.reconcileQueue.add(e),de(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=ls({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}getRoot(){return this.root}isInstanceVisible(e,n){const i=this.getScrollTop(),r=this.getHeight(),s=this.config.intersectionObserverMargin,o=i-s,l=i+r+s;return!(e<o-n||e>l)}setupWindow(){var e;if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),(e=this.resizeObserver)==null||e.observe(this.root.documentElement)}setupElement(e){var n,i;if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),(n=this.resizeObserver)==null||n.observe(this.root),e??(e=this.root.firstElementChild??void 0),e instanceof HTMLElement&&(this.contentContainer=e,(i=this.resizeObserver)==null||i.observe(e))}cleanUp(){var e,n,i;Ot(this.computeRenderRangeAndEmit),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0,(n=this.intersectionObserver)==null||n.disconnect(),this.intersectionObserver=void 0,(i=this.root)==null||i.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.reconcileQueue.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.scrollHeightDirty=!0}getOffsetInScrollContainer(e){return this.getScrollTop()+bn(e,this.getScrollContainerElement())}connect(e,n){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,n):(this.intersectionObserver.observe(e),this.observers.set(e,n),this.instancesChanged.add(n),this.markDOMDirty(),de(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){var i;const n=this.observers.get(e);this.connectQueue.delete(e),n!=null&&((i=this.intersectionObserver)==null||i.unobserve(e),this.observers.delete(e),this.instancesChanged.delete(n),this.reconcileQueue.delete(n),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),de(this.computeRenderRangeAndEmit))}scrollFix(e){var d;if(e==null)return;const n=this.getScrollContainerElement(),{lineIndex:i,lineOffset:r,fileElement:s,fileOffset:o,fileTypeOffset:l}=e;if(i!=null&&r!=null){const c=(d=s.shadowRoot)==null?void 0:d.querySelector(`[data-line][data-line-index="${i}"]`);if(c instanceof HTMLElement){const u=bn(c,n);if(u!==r){const h=u-r;this.applyScrollFix(h)}return}}const a=bn(s,n);if(l==="top")a!==o&&this.applyScrollFix(a-o);else{const c=a+s.getBoundingClientRect().height;c!==o&&this.applyScrollFix(c-o)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){var r;const n=this.getScrollContainerElement();let i;for(const[s]of this.visibleInstances.entries()){const o=bn(s,n),l=o+s.offsetHeight;let a,d;l<=0?(a=l,d="bottom"):(a=o,d="top");let c,u;if(l>0&&o<e)for(const f of((r=s.shadowRoot)==null?void 0:r.querySelectorAll("[data-line][data-line-index]"))??[]){if(!(f instanceof HTMLElement))continue;const p=f.dataset.lineIndex;if(p==null)continue;const y=bn(f,n);if(!(y<0)){c=p,u=y;break}}if((i==null?void 0:i.lineOffset)!=null&&u==null)continue;let h=!1;(i==null||u!=null&&(i.lineOffset==null||u<i.lineOffset)||u==null&&i.lineOffset==null&&(a>=0&&(i.fileOffset<0||a<i.fileOffset)||a<0&&i.fileOffset<0&&a>i.fileOffset))&&(h=!0),h&&(i={fileElement:s,fileTypeOffset:d,fileOffset:a,lineIndex:c,lineOffset:u})}return i}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=this.clampScrollTop(e),this.scrollTop=e,e}scrollTo({top:e,behavior:n="auto"}){const{root:i}=this;if(i==null)return;const r=this.clampScrollTop(e);i instanceof Document?window.scrollTo({top:r,behavior:n}):i.scrollTo({top:r,behavior:n}),this.scrollDirty=!0,de(this.computeRenderRangeAndEmit)}clampScrollTop(e){return Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight()))}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}},g(ue,"__STOP",!1),g(ue,"__lastScrollPosition",0),ue);function bn(t,e){const n=t.getBoundingClientRect(),i=(e==null?void 0:e.getBoundingClientRect().top)??0;return n.top-i}function MS(t){const e=[];for(const n of t){const i=wt.get(n);if(i==null)throw new Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);e.push(i)}return e}function DS(t){for(const e of Array.isArray(t)?t:[t])if(!wt.has(e))return!1;return!0}function HS(t,e,n=[]){if(t==="text"||t==="ansi")throw new Error("registerCustomLanguage: 'text' and 'ansi' are reserved language names");if(Gr.has(t)){console.error(`registerCustomLanguage: lang: ${t} is already registered`);return}Gr.set(t,e);for(const i of n)Zm(i,t)}async function OS(t){const e=[],n=[];for(const i of t){if(i==="text"||i==="ansi")continue;const r=Ed(i)??Ld(i);"then"in r?n.push(r):e.push(r)}return n.length>0&&await Promise.all(n).then(i=>{for(const r of i){if(r==null)throw new Error("resolvedLanguages: unable to resolve language");e.push(r)}}),e}function NS(t){return Ie.getResolvedThemes(t)}function sS(t,e){try{const n=Bs({name:t,load:e});Ie.registerTheme(n.name,n.load)}catch(n){if(n instanceof Td){console.error("SharedHighlight.registerCustomTheme: theme name already registered",t);return}throw n}}function FS(t,e,n=!1){const i=Jf({name:t,variablePrefix:he("global"),variableDefaults:e,fontStyle:n});sS(t,()=>Promise.resolve(i))}async function $S(t){for(const n of t)Dd(n);const e=await Ie.resolveThemes(t);for(let n=0;n<t.length;n++)Hd(t[n],e[n]);return e}function Bc(t){return"side"in t}function oS(t){return!Bc(t)}function zS(t){const e=t[0];return e==null||Bc(e)}function US(t){const e=t[0];return e==null||oS(e)}function BS(t,e){return t==null||e==null?t===e:t.busyWorkers===e.busyWorkers&&t.diffCacheSize===e.diffCacheSize&&t.fileCacheSize===e.fileCacheSize&&t.managerState===e.managerState&&t.activeTasks===e.activeTasks&&t.queuedTasks===e.queuedTasks&&t.themeSubscribers===e.themeSubscribers&&t.totalWorkers===e.totalWorkers&&t.workersFailed===e.workersFailed}function VS(t){const e=document.createElement("div");e.dataset.line=`${t}`;const n=document.createElement("div");n.dataset.columnNumber="",n.textContent=`${t}`;const i=document.createElement("div");return i.dataset.columnContent="",e.appendChild(n),e.appendChild(i),{row:e,content:i}}function GS(t,e=!1){return M({tagName:"style",children:[Se(e?x0(t):Ks(t))],properties:{[Jc]:e?"":void 0,[cl]:e?void 0:""}})}function WS(t){return M({tagName:"style",children:[Se(t)],properties:{[dl]:""}})}function jS(t,e,n){const i=t.hunks[e];if(i==null)throw console.error({hunkIndex:e,diff:t}),new Error("diffAcceptRejectHunk: Invalid hunk index");return Ac(t,{resolution:Mc(n),hunkIndex:e,...typeof n=="object"?{startContentIndex:n.changeIndex,endContentIndex:n.changeIndex}:{startContentIndex:0,endContentIndex:Math.max(0,(i.hunkContent.length??1)-1)}})}function qS(t){return t.includes(`\r
323
+ `)?"CRLF":t.includes("\r")?"CR":t.includes(`
324
+ `)?"LF":"none"}function KS(t){const e=my(t);if(e.length!==1)throw console.error(e),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=e[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function XS(t){const e=t[0];if(e!=="+"&&e!=="-"&&e!==" "&&e!=="\\"){console.error(`parseLineType: Invalid firstChar: "${e}", full line: "${t}"`);return}const n=t.substring(1);return{line:n===""?`
325
+ `:n,type:e===" "?"context":e==="\\"?"metadata":e==="+"?"addition":"deletion"}}function YS(t,e){return{...t,lang:e}}function QS(t,e=10){const n=[];let i;for(const s of t.split(`
326
+ `)){const o=s.match(Xc);if(o!=null){i!=null&&(i.hunkLines.length>0&&(yi(i,e,"trailing"),Ur(i,n)),i=void 0);const l=parseInt(o[3]),a=parseInt(o[1]),d=parseInt(o[4]??"1"),c=parseInt(o[2]??"1");isNaN(l)||isNaN(a)||isNaN(d)||isNaN(c)?n.push(s):i={additionStart:l,deletionStart:a,additionCount:0,deletionCount:0,hunkLines:[],contextLines:[]};continue}if(i==null){n.push(s);continue}if(s.startsWith(" "))i.contextLines.push(s);else if(s!==""){if(i.hunkLines.length>0&&i.contextLines.length>e*2){const l=i.contextLines.length-e*2,a=i.contextLines.slice(-e);yi(i,e,"trailing");const{additionCount:d,deletionCount:c}=i;Ur(i,n),i={additionStart:i.additionStart+d+l,deletionStart:i.deletionStart+c+l,deletionCount:0,additionCount:0,contextLines:a,hunkLines:[]}}yi(i,e,i.hunkLines.length===0?"leading":"before-change"),i.hunkLines.push(s),s.startsWith("+")?i.additionCount+=1:s.startsWith("-")&&(i.deletionCount+=1)}}i!=null&&i.hunkLines.length>0&&(yi(i,e,"trailing"),Ur(i,n));const r=n.join(`
327
+ `);return t.endsWith(`
328
+ `)?`${r}
329
+ `:r}function yi(t,e,n){if(n==="leading"&&t.contextLines.length>e){const i=t.contextLines.length-e;t.contextLines.splice(0,i),t.additionStart+=i,t.deletionStart+=i}return n==="trailing"&&t.contextLines.length>e&&(t.contextLines.length=e),t.contextLines.length>0&&(rn(t.hunkLines,t.contextLines),t.additionCount+=t.contextLines.length,t.deletionCount+=t.contextLines.length,t.contextLines.length=0),t}function Ur(t,e){e.push(`@@ -${ol(t.deletionStart,t.deletionCount)} +${ol(t.additionStart,t.additionCount)} @@`),rn(e,t.hunkLines)}function ol(t,e){return e===1?`${t}`:`${t},${e}`}export{Ri as AttachedLanguages,$i as AttachedThemes,hC as CODE_VIEW_DIFF_OPTION_KEYS,fC as CODE_VIEW_FILE_OPTION_KEYS,nu as CODE_VIEW_FOOTER_ATTRIBUTE,tu as CODE_VIEW_HEADER_ATTRIBUTE,Kc as COMMIT_METADATA_SPLIT,Jc as CORE_CSS_ATTRIBUTE,Ls as CUSTOM_HEADER_SLOT_ID,Wa as CodeToTokenTransformStream,TS as CodeView,mn as DEFAULT_CODE_VIEW_FILE_METRICS,ru as DEFAULT_CODE_VIEW_LAYOUT,mS as DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,ou as DEFAULT_EXPANDED_REGION,Jt as DEFAULT_RENDER_RANGE,su as DEFAULT_SMOOTH_SCROLL_SETTINGS,j as DEFAULT_THEMES,iu as DEFAULT_TOKENIZE_MAX_LENGTH,Es as DEFAULT_VIRTUAL_FILE_METRICS,qc as DIFFS_DEVELOPMENT_BUILD,ul as DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY,eu as DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE,al as DIFFS_TAG_NAME,Ec as DiffHunksRenderer,hl as EMPTY_RENDER_RANGE,Gt as EXTENSION_TO_FILE_FORMAT,Qc as FILENAME_HEADER_REGEX,uS as FILE_CONTEXT_BLOB,N0 as File,Rc as FileDiff,C0 as FileRenderer,IS as FileStream,ll as GIT_DIFF_FILE_BREAK_REGEX,xs as HEADER_FILENAME_SUFFIX_SLOT_ID,ks as HEADER_METADATA_SLOT_ID,ws as HEADER_PREFIX_SLOT_ID,Xc as HUNK_HEADER,Zc as INDEX_LINE_METADATA,Fd as InteractionManager,fS as MERGE_CONFLICT_BASE_MARKER_REGEX,gS as MERGE_CONFLICT_END_MARKER_REGEX,pS as MERGE_CONFLICT_SEPARATOR_MARKER_REGEX,hS as MERGE_CONFLICT_START_MARKER_REGEX,Gr as RegisteredCustomLanguages,$d as ResizeManager,wt as ResolvedLanguages,cr as ResolvingLanguages,Yc as SPLIT_WITH_NEWLINES,Yd as SVGSpriteSheet,$y as ScrollSyncManager,EC as ShikiStreamTokenizer,dl as THEME_CSS_ATTRIBUTE,cS as UNIFIED_DIFF_FILE_BREAK_REGEX,cl as UNSAFE_CSS_ATTRIBUTE,AS as UnresolvedFile,bs as VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL,W0 as VirtualizedFile,Jv as VirtualizedFileDiff,PS as Virtualizer,Nv as areDiffLineAnnotationsEqual,tt as areDiffRenderOptionsEqual,K as areDiffTargetsEqual,ht as areFileRenderOptionsEqual,In as areFilesEqual,Fv as areHunkDataEqual,An as areLanguagesAttached,S0 as areLineAnnotationsEqual,nn as areObjectsEqual,Vs as areOptionsEqual,Qd as arePrePropertiesEqual,sr as areRenderRangesEqual,zi as areSelectionsEqual,Ge as areThemesAttached,zt as areThemesEqual,eS as areVirtualWindowSpecsEqual,BS as areWorkerStatsEqual,oo as attachResolvedLanguages,Yo as attachResolvedThemes,Qe as cleanLastNewline,au as cleanUpResolvedLanguages,dm as cleanUpResolvedThemes,xS as clearRenderQueue,cc as cloneFileDiffMetadata,dc as cloneHunks,SS as codeToHtml,ds as createAnnotationElement,js as createAnnotationWrapperNode,Jf as createCSSVariablesTheme,qi as createDiffSpanDecoration,li as createEmptyRowBuffer,Bd as createFileHeaderElement,Le as createGutterGap,Nd as createGutterItem,Zd as createGutterUtilityContentNode,Am as createGutterUtilityElement,Yt as createGutterWrapper,M as createHastElement,Ui as createIconElement,di as createNoNewlineElement,Vd as createPreElement,Qm as createPreWrapperProperties,VS as createRowNodes,Wt as createSeparator,RC as createSpanFromToken,GS as createStyleElement,Se as createTextNodeElement,WS as createThemeStyleElement,Wd as createTransformerWithState,Jd as createUnsafeCSSStyleNode,ls as createWindowFromScrollPosition,Ot as dequeueRender,ee as detachString,jS as diffAcceptRejectHunk,wS as disposeHighlighter,Im as findCodeElement,he as formatCSSVariablePrefix,ES as getCustomExtensionsMap,LS as getCustomExtensionsVersion,be as getFiletypeFromFileName,tn as getHighlighterIfLoaded,Gs as getHighlighterOptions,Ws as getHighlighterThemeStyles,zy as getHunkSeparatorSlotName,Km as getIconForType,Ye as getLineAnnotationName,Ys as getLineAnnotationSource,qS as getLineEndingType,cs as getLineNodes,Tn as getOrCreateCodeNode,MS as getResolvedLanguages,Ed as getResolvedOrResolveLanguage,Lm as getResolvedOrResolveTheme,NS as getResolvedThemes,un as getSharedHighlighter,KS as getSingularPatch,cn as getThemes,Uy as getTotalLineCountFromHunks,JC as getUnresolvedDiffHunksRendererOptions,DS as hasResolvedLanguages,qm as hasResolvedThemes,fs as hydratePartialDiff,Vi as isDefaultRenderRange,Bc as isDiffAnnotation,zS as isDiffAnnotationCollection,oS as isFileAnnotation,US as isFileAnnotationCollection,Em as isHighlighterLoaded,Rm as isHighlighterLoading,bS as isHighlighterNull,fl as isWorkerContext,Nt as parseDiffFromFile,XS as parseLineType,my as parsePatchFiles,nc as patchScrollbarGutterSize,$n as pluckInteractionOptions,Tm as prefersReducedMotion,_m as preloadHighlighter,rc as prerenderHTMLIfNecessary,gy as processFile,Jm as processLine,_S as processPatch,ci as pushOrJoinSpan,de as queueRender,RS as recordLineAnnotationSource,FS as registerCustomCSSVariableTheme,HS as registerCustomLanguage,sS as registerCustomTheme,eo as releaseStringDetachBuffer,Zy as renderDiffWithHighlighter,g0 as renderFileWithHighlighter,kS as replaceCustomExtensions,AC as resolveConflict,Ld as resolveLanguage,OS as resolveLanguages,Ac as resolveRegion,km as resolveTheme,$S as resolveThemes,Zm as setCustomExtension,YS as setLanguageOverride,Qs as setPreNodeProperties,QS as trimPatchContext,x0 as wrapCoreCSS,Xs as wrapThemeCSS,Ks as wrapUnsafeCSS};