@opentig/cli 0.2.3 → 0.2.4

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 (174) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +14 -14
  3. package/dist/bin.mjs +25 -10
  4. package/dist/chunks/{cli-L6lvCZdX.mjs → cli-gyjD1t0O.mjs} +611 -268
  5. package/dist/chunks/network-settings-CdFeKFRB.mjs +142 -0
  6. package/dist/chunks/{server-Cz0gvydn.mjs → server-DMk8-Xxt.mjs} +557 -105
  7. package/dist/chunks/{service-manager-Jyx-MWo-.mjs → service-manager-BxSmV_8Z.mjs} +88 -14
  8. package/dist/client/assets/App-Bfw_TX8q.js +132 -0
  9. package/dist/client/assets/CreatePullRequestDialog-DyPd6SKH.js +2 -0
  10. package/dist/client/assets/DiffWorkspace-DCo89dF1.js +7 -0
  11. package/dist/client/assets/EditableFileViewer-Dotntfij.js +1 -0
  12. package/dist/client/assets/EditableFileViewer-svutjHZv.css +1 -0
  13. package/dist/client/assets/ExternalLink-jdtpN_yL.js +1 -0
  14. package/dist/client/assets/{File-BPxtFxHC.js → File-DHnVtIhS.js} +1 -1
  15. package/dist/client/assets/FilesView-D6f1hPVy.js +1 -0
  16. package/dist/client/assets/GitHubAvatar-B6vyoVlh.js +1 -0
  17. package/dist/client/assets/HistoryView-D9RhzCPY.js +1 -0
  18. package/dist/client/assets/HtmlFileViewer-Bwmj5umg.js +2 -0
  19. package/dist/client/assets/{IconAlertTriangle-C1OX2bTH.js → IconAlertTriangle-B9iDJKvP.js} +1 -1
  20. package/dist/client/assets/IconCheck-C-G-IA13.js +1 -0
  21. package/dist/client/assets/IconChevronDown-DU5i40lD.js +1 -0
  22. package/dist/client/assets/{IconEdit-BP5Emwzw.js → IconEdit-CZe-EJxX.js} +1 -1
  23. package/dist/client/assets/{IconFolderSymlink-BNWI0eXB.js → IconFolderSymlink-DkLEuUb6.js} +1 -1
  24. package/dist/client/assets/IconGitMerge-D9KEj1cE.js +1 -0
  25. package/dist/client/assets/IconGitPullRequest-ClaUqyVa.js +1 -0
  26. package/dist/client/assets/{IconLoader4-Bk6G4Bls.js → IconLoader4-D2VN7u1V.js} +1 -1
  27. package/dist/client/assets/{IconPlus-DUFNSK_i.js → IconPlus-DJCoD3wt.js} +1 -1
  28. package/dist/client/assets/{IconSearch-ZL3YVslZ.js → IconSearch-1VQ4P4kW.js} +1 -1
  29. package/dist/client/assets/{IconSelector-BGwY84R8.js → IconSelector-BVMU1PEt.js} +1 -1
  30. package/dist/client/assets/ImageFileViewer-3izbFVTw.css +1 -0
  31. package/dist/client/assets/ImageFileViewer-CdFLl_in.js +1 -0
  32. package/dist/client/assets/LinkedMarkdown-Bnc2OA63.js +1 -0
  33. package/dist/client/assets/LinkedText-BD6K3d1t.js +1 -0
  34. package/dist/client/assets/LocalRefsDialog-Bl-fddap.js +1 -0
  35. package/dist/client/assets/MarkdownFileViewer-NUAoQmv5.js +2 -0
  36. package/dist/client/assets/PairingPage-CqrxpC3_.js +1 -0
  37. package/dist/client/assets/PierreDiffViewer-CDfQ32e0.js +1 -0
  38. package/dist/client/assets/{PierreEditBoundary-Bt0q7SXc.js → PierreEditBoundary-DAdYNYZ3.js} +1 -1
  39. package/dist/client/assets/{PierreWorkerPool-DMFigp0u.js → PierreWorkerPool-mIDzTMB9.js} +3 -3
  40. package/dist/client/assets/PullRequestDiff-n1NZFHKN.js +1 -0
  41. package/dist/client/assets/PullRequestViewer-u89zl169.js +2 -0
  42. package/dist/client/assets/PullRequestsView-D6BqvB4E.js +1 -0
  43. package/dist/client/assets/QuickOpenDialog-BbEifGRi.js +1 -0
  44. package/dist/client/assets/RepositoryProjectsDialog-EGAsXL-Z.js +1 -0
  45. package/dist/client/assets/{SearchView-BYz1K1Ta.js → SearchView-BMz7qOdc.js} +1 -1
  46. package/dist/client/assets/SettingsDialog-DmD7HvhX.js +9 -0
  47. package/dist/client/assets/Viewer-CDj_vo6w.js +3 -0
  48. package/dist/client/assets/{abnfDiagram-YUKMZFIV-CpKAN_8n.js → abnfDiagram-YUKMZFIV-It6tW-4v.js} +1 -1
  49. package/dist/client/assets/{architecture-WOLXFQ4H-DrizVopY.js → architecture-WOLXFQ4H-CaOaChND.js} +1 -1
  50. package/dist/client/assets/{architectureDiagram-47P4ROYG-gvUijB3H.js → architectureDiagram-47P4ROYG-COtncecA.js} +1 -1
  51. package/dist/client/assets/{blockDiagram-E7TT5TSB-CdcXmnf_.js → blockDiagram-E7TT5TSB-NU4wFrfP.js} +1 -1
  52. package/dist/client/assets/{c4Diagram-CRA5TL53-DtoD1jKt.js → c4Diagram-CRA5TL53-0xzM4S8q.js} +1 -1
  53. package/dist/client/assets/channel-QED-4ACa.js +1 -0
  54. package/dist/client/assets/checkbox-Dh4T0bCe.js +1 -0
  55. package/dist/client/assets/{chunk-2BW5OAIV-Bxqf2dFQ.js → chunk-2BW5OAIV-BQMxlSNI.js} +1 -1
  56. package/dist/client/assets/{chunk-3YJQHVM4-BhzXJiq0.js → chunk-3YJQHVM4-CdP15KtA.js} +1 -1
  57. package/dist/client/assets/{chunk-4EA7E6EY-CvEILf8c.js → chunk-4EA7E6EY-xRPCCZLU.js} +1 -1
  58. package/dist/client/assets/{chunk-7TKQ45FW-pTEdzVz3.js → chunk-7TKQ45FW-Cr_UAObV.js} +1 -1
  59. package/dist/client/assets/{chunk-AW2ZBBNX-LVROkcXk.js → chunk-AW2ZBBNX-DBqqxF2h.js} +1 -1
  60. package/dist/client/assets/{chunk-DBDB3WZW-FCGrB-q8.js → chunk-DBDB3WZW-BonEIRP2.js} +1 -1
  61. package/dist/client/assets/{chunk-E2ZNV5FY-B3rGXPn-.js → chunk-E2ZNV5FY-DnKvxSiA.js} +1 -1
  62. package/dist/client/assets/{chunk-EU5HNXII-D6a_Ly_W.js → chunk-EU5HNXII-DLK0K3sR.js} +1 -1
  63. package/dist/client/assets/{chunk-FVRAUYC3-B5hy0Ket.js → chunk-FVRAUYC3-DmjKoYAh.js} +1 -1
  64. package/dist/client/assets/{chunk-HJ2JQQFS-CKHFz1Wl.js → chunk-HJ2JQQFS-AF4phse0.js} +1 -1
  65. package/dist/client/assets/{chunk-HTAEGDNF-CtwDuO27.js → chunk-HTAEGDNF-CG4pBnUZ.js} +1 -1
  66. package/dist/client/assets/{chunk-KQW6MTUR-BN3uxLYf.js → chunk-KQW6MTUR-Dd87yj5r.js} +1 -1
  67. package/dist/client/assets/{chunk-NTY3LDVX-CfXSvyIC.js → chunk-NTY3LDVX-OolU2PaP.js} +1 -1
  68. package/dist/client/assets/{chunk-VPRB5NB3-LAggcSji.js → chunk-VPRB5NB3-Dnr3edxV.js} +3 -3
  69. package/dist/client/assets/{chunk-XC4XBNZT-BksIPWQU.js → chunk-XC4XBNZT-CIqGRxkD.js} +1 -1
  70. package/dist/client/assets/{classDiagram-v2-K4WV4PDN-DH78Maqm.js → classDiagram-v2-K4WV4PDN-CPGawm8n.js} +1 -1
  71. package/dist/client/assets/createReactComponent-Ctub7J3a.js +1 -0
  72. package/dist/client/assets/{cynefin-EF2NZ3EQ-DozKlDV1.js → cynefin-EF2NZ3EQ-OA2R9WCH.js} +1 -1
  73. package/dist/client/assets/{cynefinDiagram-3GCD6N5R-A1yS7NKN.js → cynefinDiagram-3GCD6N5R-DqCVtoKt.js} +1 -1
  74. package/dist/client/assets/{dagre-W4DXFKR2-DRJ1mmbe.js → dagre-W4DXFKR2-kc3-tkAQ.js} +1 -1
  75. package/dist/client/assets/{diagram-2UJZ2QOL-B1sI2b2o.js → diagram-2UJZ2QOL-DoBZKT3s.js} +1 -1
  76. package/dist/client/assets/{diagram-OVF4WLC6-DLE1o4-P.js → diagram-OVF4WLC6-DGkyha_F.js} +1 -1
  77. package/dist/client/assets/{diagram-PFPMY2P6-UtIEsv14.js → diagram-PFPMY2P6-DpRDDgdV.js} +1 -1
  78. package/dist/client/assets/{diagram-UMYRVEAY-BwTyzVap.js → diagram-UMYRVEAY-DlsfhYv3.js} +1 -1
  79. package/dist/client/assets/{diagram-YEKJPTXX-DNPUQqu0.js → diagram-YEKJPTXX-BIhRZzBM.js} +1 -1
  80. package/dist/client/assets/{diagram-ZIFT7M5P-ClXykQ3I.js → diagram-ZIFT7M5P-mweJcgBZ.js} +1 -1
  81. package/dist/client/assets/diff-parse.worker-C1IFRYY9.js +13 -0
  82. package/dist/client/assets/{ebnfDiagram-VR2GEFS7-Dm8VAviu.js → ebnfDiagram-VR2GEFS7-Dn5zyIbZ.js} +1 -1
  83. package/dist/client/assets/{elk-IJKZMXRS-CEEoPARn.js → elk-IJKZMXRS-eBPlf1-o.js} +1 -1
  84. package/dist/client/assets/{erDiagram-O2IAPWRE-CaDE4obX.js → erDiagram-O2IAPWRE-WEE519yZ.js} +1 -1
  85. package/dist/client/assets/{eventmodeling-K75KTNOO-PjYgMkPC.js → eventmodeling-K75KTNOO-BgE_VmNy.js} +1 -1
  86. package/dist/client/assets/external-url-IUS7RmYD.js +1 -0
  87. package/dist/client/assets/flowDiagram-OXPTDLAJ-CHQYfkMg.js +1 -0
  88. package/dist/client/assets/{ganttDiagram-R7TSEDQI-CmkBarBi.js → ganttDiagram-R7TSEDQI-D_1KyJZU.js} +1 -1
  89. package/dist/client/assets/{gitGraph-VSP46ZUC-DeotTdHj.js → gitGraph-VSP46ZUC-CEbT7DA4.js} +1 -1
  90. package/dist/client/assets/{gitGraphDiagram-XJZIOB7I-uV1hPaZT.js → gitGraphDiagram-XJZIOB7I-QQyYc1gM.js} +1 -1
  91. package/dist/client/assets/index-DsKvWsTs.js +47 -0
  92. package/dist/client/assets/index-kyWCnbkb.css +2 -0
  93. package/dist/client/assets/{info-OHQRW6UA-BQDsGvSl.js → info-OHQRW6UA-ChHAnveo.js} +1 -1
  94. package/dist/client/assets/{infoDiagram-5W2HQ5XZ-CDfEPsgZ.js → infoDiagram-5W2HQ5XZ-BaxAE7UA.js} +1 -1
  95. package/dist/client/assets/{ishikawaDiagram-K3B6WC7H-Bb7PQGe6.js → ishikawaDiagram-K3B6WC7H-vhUflBE_.js} +1 -1
  96. package/dist/client/assets/{journeyDiagram-COXZFDF6-BDythglw.js → journeyDiagram-COXZFDF6-C8WWosVa.js} +1 -1
  97. package/dist/client/assets/{kanban-definition-P3RFRI5V-CvY5kXhh.js → kanban-definition-P3RFRI5V-CU6W9Yi3.js} +1 -1
  98. package/dist/client/assets/katex-CQfTPFh0.js +1 -0
  99. package/dist/client/assets/{line-99p2yFnB.js → line-Axq4vVX-.js} +1 -1
  100. package/dist/client/assets/{mermaid-parser.core-BjZYtoJ8.js → mermaid-parser.core-DNeaCX12.js} +3 -3
  101. package/dist/client/assets/{mermaid.core-DRcXnUox.js → mermaid.core-Dtt7rXw0.js} +4 -4
  102. package/dist/client/assets/{mindmap-definition-LZFPQGKD-t9LoCpnW.js → mindmap-definition-LZFPQGKD-D_8ZqQot.js} +1 -1
  103. package/dist/client/assets/{packet-JDAUHWVQ-BlR-5V7K.js → packet-JDAUHWVQ-6z7ujmGF.js} +1 -1
  104. package/dist/client/assets/{pegDiagram-BGZESJAR-CWeGI-T9.js → pegDiagram-BGZESJAR-3ujyk-bt.js} +1 -1
  105. package/dist/client/assets/{pie-XZMESJXO-BkvYHWgl.js → pie-XZMESJXO-DvpLy2DB.js} +1 -1
  106. package/dist/client/assets/{pieDiagram-CAPJLFHJ-CY5PPIr3.js → pieDiagram-CAPJLFHJ-BPMPWyc7.js} +1 -1
  107. package/dist/client/assets/{quadrantDiagram-GDMTTRAM-kqj-z271.js → quadrantDiagram-GDMTTRAM-BVUCR_lf.js} +1 -1
  108. package/dist/client/assets/{radar-ABXABTNO-DuEtYatv.js → radar-ABXABTNO-lu14X99R.js} +1 -1
  109. package/dist/client/assets/{railroad-I3PHUGI6-CVlnj2j9.js → railroad-I3PHUGI6-DI_WtDmt.js} +1 -1
  110. package/dist/client/assets/{railroad-abnf-LNEFI6M7-9Qiczw4d.js → railroad-abnf-LNEFI6M7-CmWAKZ2T.js} +1 -1
  111. package/dist/client/assets/{railroad-ebnf-DWYD2UWJ-BNL7TMEg.js → railroad-ebnf-DWYD2UWJ-BWKFU_UH.js} +1 -1
  112. package/dist/client/assets/{railroad-peg-JR7BVNR7-DdpRxgk6.js → railroad-peg-JR7BVNR7-9wkgzxMB.js} +1 -1
  113. package/dist/client/assets/{railroadDiagram-SM67HX2B-CDXvYNqW.js → railroadDiagram-SM67HX2B-4JnRbxl_.js} +1 -1
  114. package/dist/client/assets/{render-markdown-DF9Fy7MD.js → render-markdown-CQi2yKYQ.js} +2 -2
  115. package/dist/client/assets/{requirementDiagram-X7JNWC4A-BDdhqnZA.js → requirementDiagram-X7JNWC4A-CVJiZZsi.js} +1 -1
  116. package/dist/client/assets/{sankeyDiagram-UM26HJRW-Rkyk5oEf.js → sankeyDiagram-UM26HJRW-BmlWQdkv.js} +1 -1
  117. package/dist/client/assets/select-Dq3KDX2O.js +1 -0
  118. package/dist/client/assets/{sequenceDiagram-ZO4K6R2Y-Coj9ap7h.js → sequenceDiagram-ZO4K6R2Y-zUx3LmPj.js} +1 -1
  119. package/dist/client/assets/{stateDiagram-v2-TBUQTH76-BucWlahR.js → stateDiagram-v2-TBUQTH76-o_ci-2bu.js} +1 -1
  120. package/dist/client/assets/{swimlanes-N4OXWK64-tEECcFP9.js → swimlanes-N4OXWK64-BlI0GC5-.js} +1 -1
  121. package/dist/client/assets/swimlanesDiagram-K3J5GTZL-BEeJLN8d.js +8 -0
  122. package/dist/client/assets/tanstack-CVAt_k_T.js +1 -0
  123. package/dist/client/assets/{timeline-definition-YOQAKGHF-XvIbGO4d.js → timeline-definition-YOQAKGHF-DLnvF__o.js} +1 -1
  124. package/dist/client/assets/{treeView-D4JQ5SDB-DuhJpfXe.js → treeView-D4JQ5SDB-DPuMLQhB.js} +1 -1
  125. package/dist/client/assets/{treemap-SAJKECNS-CLiUWfZh.js → treemap-SAJKECNS-DjxqxJ8-.js} +1 -1
  126. package/dist/client/assets/{usecaseDiagram-VIAY4XPW-BuwkpV9w.js → usecaseDiagram-VIAY4XPW-BtnFNltN.js} +1 -1
  127. package/dist/client/assets/utils-D0T3A-kS.js +1 -0
  128. package/dist/client/assets/{vennDiagram-BLWOH2XV-kfza5Rxq.js → vennDiagram-BLWOH2XV-CAiF2FKz.js} +1 -1
  129. package/dist/client/assets/viewer-tabs-DkkqN9MD.js +1 -0
  130. package/dist/client/assets/{wardley-7MLQ67FV-CcbU_Ykg.js → wardley-7MLQ67FV-DAWySamq.js} +1 -1
  131. package/dist/client/assets/{wardleyDiagram-YMQ3BMBF-DnxlEg3a.js → wardleyDiagram-YMQ3BMBF-DiBCclEL.js} +1 -1
  132. package/dist/client/assets/{xychartDiagram-TAQBALBS-BzgtwtvK.js → xychartDiagram-TAQBALBS-B0NgfXz6.js} +1 -1
  133. package/dist/client/index.html +6 -4
  134. package/dist/dev.mjs +6 -6
  135. package/dist/manifest.json +1 -1
  136. package/dist/server.mjs +1 -1
  137. package/dist/service-update.mjs +11 -3
  138. package/dist/utility.mjs +25 -4
  139. package/package.json +4 -4
  140. package/dist/client/assets/App-DEIZhWJG.js +0 -132
  141. package/dist/client/assets/CreatePullRequestDialog-BceOUbYK.js +0 -2
  142. package/dist/client/assets/DiffWorkspace-BMtV4MMc.js +0 -6
  143. package/dist/client/assets/EditableFileViewer-B44TSuFu.css +0 -1
  144. package/dist/client/assets/EditableFileViewer-BE3AsnVa.js +0 -1
  145. package/dist/client/assets/FilesView-DoVhRfi1.js +0 -1
  146. package/dist/client/assets/GitHubAvatar-RiePq1Yf.js +0 -1
  147. package/dist/client/assets/HistoryView-Dl8uqmKe.js +0 -1
  148. package/dist/client/assets/HtmlFileViewer-xfjY1Swc.js +0 -2
  149. package/dist/client/assets/IconCheck-BPhxw_LS.js +0 -1
  150. package/dist/client/assets/IconChevronDown-C3FplJL8.js +0 -1
  151. package/dist/client/assets/ImageFileViewer-BJBOmpsf.css +0 -1
  152. package/dist/client/assets/ImageFileViewer-DXaIo7_d.js +0 -1
  153. package/dist/client/assets/LocalRefsDialog-C5J3kgTe.js +0 -1
  154. package/dist/client/assets/MarkdownFileViewer-18mvm0f2.js +0 -2
  155. package/dist/client/assets/PairingPage-BEUj3t0V.js +0 -1
  156. package/dist/client/assets/PierreDiffViewer-p29h7lW_.js +0 -1
  157. package/dist/client/assets/PullRequestDiff-C17JA4ko.js +0 -1
  158. package/dist/client/assets/PullRequestViewer-DaMtkESD.js +0 -2
  159. package/dist/client/assets/PullRequestsView-44f03VLC.js +0 -1
  160. package/dist/client/assets/QuickOpenDialog-Bi-L68PU.js +0 -1
  161. package/dist/client/assets/RepositoryProjectsDialog-DFGn74fe.js +0 -1
  162. package/dist/client/assets/SettingsDialog-CruoIiyN.js +0 -9
  163. package/dist/client/assets/Viewer-3WKpwRzo.js +0 -3
  164. package/dist/client/assets/channel-BqKQxg-1.js +0 -1
  165. package/dist/client/assets/checkbox-MDl2t9_3.js +0 -1
  166. package/dist/client/assets/createReactComponent-BfrD_oQK.js +0 -1
  167. package/dist/client/assets/flowDiagram-OXPTDLAJ-DSokwYKA.js +0 -1
  168. package/dist/client/assets/index-CoZCJqTQ.js +0 -47
  169. package/dist/client/assets/index-DUERTTRS.css +0 -2
  170. package/dist/client/assets/katex-C6e6EqXB.js +0 -1
  171. package/dist/client/assets/select-pZpCy7qn.js +0 -1
  172. package/dist/client/assets/swimlanesDiagram-K3J5GTZL-DEFKR6Vf.js +0 -8
  173. package/dist/client/assets/tanstack-CYi5knVJ.js +0 -1
  174. package/dist/client/assets/viewer-tabs-MMNrJqGE.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{C as r,G as i,M as a,T as o,V as s,b as c,d as l,g as u,m as d,p as f,w as p,y as m,z as h}from"./color-C1Sk4dBL.js";import{A as g,At as _,B as v,C as y,D as b,Dt as x,E as S,Et as C,F as w,G as T,H as E,I as D,It as O,J as k,K as A,L as j,M,Mt as N,N as P,Nt as F,O as ee,Ot as I,P as L,R as te,Rt as ne,S as re,St as ie,T as ae,Tt as R,U as oe,V as se,W as ce,Y as le,_ as ue,_t as de,b as fe,bt as pe,c as me,dt as z,f as he,ft as B,g as ge,h as _e,j as ve,jt as V,k as ye,kt as H,lt as be,m as xe,p as Se,q as U,s as Ce,ut as we,v as Te,vt as Ee,w as De,x as Oe,xt as ke,y as Ae,yt as je,z as Me}from"./PierreWorkerPool-DMFigp0u.js";import{s as W}from"./string-TLTPtCPs-SBynuHAV.js";import{n as Ne,r as G}from"./EditContext-rlYgrfe2.js";var K=n();function Pe({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,lineAnnotations:o,renderGutterUtility:s,getHoveredLine:c,getAnnotationSlotName:u=h}){let d=t?.(e),f=n?.(e),p=r?.(e),m=i?.(e);return(0,K.jsxs)(K.Fragment,{children:[d==null?(0,K.jsxs)(K.Fragment,{children:[f!=null&&(0,K.jsx)(`div`,{slot:`header-prefix`,children:f}),p!=null&&(0,K.jsx)(`div`,{slot:`header-filename-suffix`,children:p}),m!=null&&(0,K.jsx)(`div`,{slot:`header-metadata`,children:m})]}):(0,K.jsx)(`div`,{slot:l,children:d}),a!=null&&o?.map((e,t)=>(0,K.jsx)(`div`,{slot:u(e),children:a(e)},t)),s!=null&&(0,K.jsx)(`div`,{slot:`gutter-utility-slot`,style:O,children:s(c)})]})}function q(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var Fe=-1,Ie=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`file-renderer:${++Fe}`;highlighter;file;renderCache;pendingHighlightResult;computedLang=`text`;lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;get fileCache(){return this.renderCache?.file}constructor(e={theme:d},t=h,n,r){this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r,r?.isWorkingPool()!==!0&&(this.highlighter=V(e.theme??d)?H():void 0)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let e=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=e,e.push(t)}}cleanUp(){this.endEditSession(),this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(e,t){let{editSessionActive:n,renderCache:r}=this;if(this.editSessionActive=!0,n||(this.pendingHighlightResult=void 0),this.file=e,r==null||n&&r.file===e)return;if(n){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}let{options:i}=this.getRenderOptions(e),a=r.file===e,o=t!=null&&T(r.file,t),{result:s}=r;if(!r.highlighted||s==null||!C(r.options,i)||!a&&!o){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}if(a)return;this.renderCache={...r,file:e,result:{...s,code:[...s.code]}};let{lineCache:c}=this;this.lineCache=c!=null&&t!=null&&q(c,t)?{cacheKey:void 0,file:e,sourceContents:e.contents,lines:c.lines}:void 0}endEditSession(e){if(this.editSessionActive=!1,this.pendingHighlightResult=void 0,this.file==null){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}let{renderCache:t}=this;e!=null&&t!=null&&t.file!==e&&T(t.file,e)&&(t.file=e)}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){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,this.workerManager?.cleanUpTasks(this),this.file=void 0}clearRenderCache(){this.pendingStructuralRows=void 0,this.renderCache=void 0,this.pendingHighlightResult=void 0}hydrate(e){this.file=e;let{options:t}=this.getRenderOptions(e),n=J(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);r!=null&&!C(t,r.options)&&(r=void 0),this.renderCache??={file:e,hydrated:!0,options:t,highlighted:!n&&!R(e),result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,e):this.highlighter??(this.computedLang=e.lang??a(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??d}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getFileRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{tokenizeMaxLineLength:e=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:e}})(),{renderCache:n}=this;return n?.result==null||!T(e,n.file)||!C(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getFileForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null)return e;let{renderCache:n}=this;if(n==null)return e;if(T(n.file,e))return n.file;let r=i(e.contents),a=e.contents.length===0||R(e)||J(r.length,this.getTokenizeMaxLength());return this.canRenderFile(e,t,a)?e:n.file}canRenderFile(e,t,n){let{renderCache:r}=this;return r==null||T(r.file,e)?!0:n?r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0||this.highlighter!=null&&V(t.theme):r.result==null&&r.hydrated!==!0?!0:!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?!r.highlighted:this.highlighter!=null&&V(t.theme)}getOrCreateLineCache(e){let{lineCache:t}=this;return(t==null||!q(t,e))&&(t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:i(e.contents)}),this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t,n=!1){this.pendingStructuralRows=void 0;let{renderCache:r}=this;if(r==null)return;let{file:i,result:a}=r;if(a==null)return;let o=n?new Map:void 0;this.pendingStructuralRows=o;let s=this.lineCache!=null&&q(this.lineCache,i)?this.lineCache:void 0;for(let[t,n]of e){if(o==null&&s!=null&&t<s.lines.length){let e=n.map(e=>e[2]).join(``);s.lines[t]=D(s.lines[t]??``,e)}let e={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})};o==null?a.code[t]=e:o.set(t,e)}a.baseThemeType=t,r.isDirty=!0,o==null&&s!=null&&(i.contents=s.lines.join(``),s.sourceContents=i.contents)}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;this.pendingStructuralRows=void 0;let r=this.file??n?.file;if(r==null)return;let a=n?.result,o=this.lineCache!=null&&q(this.lineCache,r)?this.lineCache.lines:i(r.contents),s=i(e.getText());if(a!=null&&o.length!==s.length){let r=Math.min(o.length,s.length),i=0;for(;i<r&&o[i]===s[i];)i++;let c=0;for(;c<r-i&&o[o.length-1-c]===s[s.length-1-c];)c++;let l=a.code;a.code=Array(s.length);for(let e=0;e<i;e++)a.code[e]=l[e];for(let e=0;e<c;e++)a.code[s.length-1-e]=l[o.length-1-e];if(t!==void 0)for(let[e,n]of t)e<s.length&&(a.code[e]=n);for(let t=i;t<s.length-c;t++)a.code[t]??={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:e.getLineText(t)}]}]};for(let e=0;e<a.code.length;e++){let t=a.code[e];t?.type===`element`&&(t.properties[`data-line`]=e+1,t.properties[`data-line-index`]=e)}n!=null&&(n.isDirty=!0)}let c=e.getText();this.lineCache={cacheKey:r.cacheKey,file:r,sourceContents:c,lines:s},this.textDocumentCache.set(r,e),r.contents=c}renderFile(e=this.file,t=f){if(this.file=e,e==null){this.pendingHighlightResult=void 0;return}let{options:n,forceHighlight:r}=this.getRenderOptions(e),i=this.getReadyRenderResult(e,n);this.pendingHighlightResult=void 0,i!=null&&(this.renderCache={...i,file:e,renderRange:void 0},r=!1),this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let o=this.getOrCreateLineCache(e),s=e.contents.length>0,c=!s||R(e)||J(o.length,this.getTokenizeMaxLength()),l=this.canRenderFile(e,n,c),u=!T(e,this.renderCache.file),d=!j(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let i=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!u&&g(t);l&&!i&&(c||this.renderCache.result==null||!this.renderCache.highlighted&&(u||d))&&(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||d||r)&&(this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,o)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||r)&&this.workerManager.highlightFileAST(this,e)}else{this.computedLang=e.lang??a(e.name),this.highlighter??=H();let t=this.highlighter!=null&&V(n.theme),i=this.highlighter!=null&&F(this.computedLang),o=!c&&i;if(l&&this.highlighter!=null&&t&&(r||c||!this.renderCache.highlighted&&o||this.renderCache.result==null)){let{result:t,options:n}=this.renderFileWithHighlighter(e,this.highlighter,c||!i);this.renderCache={file:e,options:n,highlighted:o,result:t,renderRange:void 0}}(!t||!c&&!i)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.applyHighlightResult(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processFileResult(this.renderCache.file,t,this.renderCache.result)}async asyncRender(e,t=f){this.file=e;let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=J(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??a(e.name);let n=this.highlighter!=null&&x(N(this.getLocalHighlightTheme())),r=t||this.highlighter!=null&&F(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:Ee(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let a=this.getLineCount(e),{disableFileHeader:o=!1}=this.options,s=[],c=ke(),l=Math.min(t.startingLine+t.totalLines,a),u=0,d=ce(t)?E(this.lineAnnotations):void 0;d!=null&&(c.children.push(je(`context`,`annotation`,1)),s.push(w({type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:d.map(e=>this.annotationSlotName(e))})),u++);for(let r=t.startingLine;r<l;r++){let t=r+1,i=n[r];if(i==null){let n=`FileRenderer.processFileResult: Line doesnt exist`;throw console.error(n,{name:e.name,lineIndex:r,lineNumber:t}),Error(n)}c.children.push(pe(`context`,t,`${r}`)),s.push(i),u++;let a=this.lineAnnotations[t];a!=null&&(c.children.push(je(`context`,`annotation`,1)),s.push(w({type:`annotation`,hunkIndex:0,lineIndex:t,annotations:a.map(e=>this.annotationSlotName(e))})),u++)}return c.properties.style=`grid-row: span ${u}`,{file:e,gutterAST:c.children??[],contentAST:s,preAST:this.createPreElement(a),headerAST:o?void 0:this.renderHeader(e),totalLines:a,rowCount:u,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderHeader(e){let{headerRenderMode:t=`default`,stickyHeader:n=!1}=this.options;return P({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return W(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(ie({tagName:`code`,children:this.renderCodeAST(e),properties:{"data-code":``}})),{...e.preAST,children:t}}renderCodeAST(e){let t=ke();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,L(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){return W(t?ie({tagName:`code`,children:e,properties:{"data-code":``}}):e)}async initializeHighlighter(){return this.highlighter=await _(ve(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{file:i,renderCache:a}=this;i!=null&&a!=null&&T(e,i)&&C(n,this.getRenderOptions(i).options)&&(a.result!=null&&a.highlighted&&C(a.options,n)&&T(a.file,i)||(this.pendingHighlightResult={file:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()))}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getFileResultCache(e);if(n!=null&&C(t,n.options))return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&T(n.file,e)&&C(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(!(r==null||this.hasHighlightedRenderCache(e,t)))return{file:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&T(e,n.file)&&C(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n=`scroll`}=this.options;return M({type:`file`,diffIndicators:`none`,disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function J(e,t){return e>t}function Le(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function Re(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:ue(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}var ze=[``];function Be(e){let t={...e};return delete t.cacheKey,t}var Ve=-1,Y=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++Ve}`;type=`file`;fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;editSession;renderedFile;renderRange;enabled=!0;editor;constructor(e={theme:d},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new Ie(e,this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager),this.resizeManager=new te,this.interactionManager=new Me(`file`,v(e)),this.workerManager?.subscribeToThemeChanges(this)}getAnnotationSlotName=e=>Ae(this.editSession?.annotations,e,h);handleHighlightRender=()=>{this.rerender()};rerender(){this.enabled&&this.file!=null&&this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}getTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??d}getLatestFile(e=this.file){return this.editSession?.file??e}getRenderedFile(){return this.renderedFile}getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;return e===this.lineAnnotations?!1:t==null||e!==t.provided&&e!==t.current}updateExternalFile(e,t){if(T(this.file,e))return!1;let n=this.editSession!=null;return this.file=e,n||this.editor!=null?this.installEditSession(e,n?void 0:this.editor?.__getDocumentContents(e),!0):this.editSession=void 0,this.editSession?.annotations!=null&&t!=null&&(this.lineAnnotations=t,this.editSession.annotations=Te(t,h,this.editSession.annotations)),!0}installEditSession(e,t,n=!1){let r=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===e.contents,i=Be(t??e);this.editSession={file:i,externalReplacement:n&&r,annotations:this.editSession?.annotations??Te(this.lineAnnotations,h)},this.fileRenderer.beginEditSession(i,r?e:void 0)}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(v(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!I(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){let t=this.editSession?.annotations;t==null?this.lineAnnotations=e:this.isNewAnnotations(e)&&(this.lineAnnotations=e,fe(t,e,h))}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;return t==null||e===t.current?!1:(t.current=e,this.fileRenderer.setLineAnnotations(e),this.renderAnnotations(),!0)}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e===`wrap`,columnVariables:this.shouldApplyColumnVariables(e)?`apply`:`measure`}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e===`scroll`&&this.getLatestAnnotations().length>0}cleanUp(e=!1){let t=this.editor;this.emitPostRender(!0),t?.cleanUp(e?`recycle`:`discard`),e||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0,this.editSession=void 0,this.renderedFile=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;if(!this.enabled)throw Error(`File.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`File.hydrate: hydrate can only be called before the instance has rendered or hydrated`);this.hydrateElements(t,n);let o=this.editor!=null;o||He(this.pre,i,this.options.collapsed)||Ue(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,forceRender:o||e.forceRender,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Se(e,t);for(let t of Array.from(e.shadowRoot?.children??[]))t instanceof SVGElement?this.spriteSVG=t:t instanceof HTMLElement&&(t instanceof HTMLPreElement?(this.pre=t,this.appliedPreAttributes=void 0):t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)?this.themeCSSStyle=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)?(this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent):`diffsHeader`in t.dataset&&(this.headerElement=t,this.lastRenderedHeaderHTML=void 0));this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(Re(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderedFile=e,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.getLatestFile()){return e==null?ze:this.fileRenderer.getOrCreateLineCache(e)}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let{editor:e,fileContainer:t,renderRange:n}=this,r=this.getLatestAnnotations(),i=this.getLatestFile();if(e==null||t==null||i==null)return;let o=a=>{this.enabled&&this.editor===e&&this.fileContainer===t&&this.getLatestFile()===i&&e.__syncRenderView({highlighter:a,fileContainer:t,file:i,lineAnnotations:r,renderRange:n,externalDocument:this.editSession?.externalReplacement===!0})},s=this.getTheme(),c=i.lang??a(i.name),l=H({theme:s,lang:c});l==null?_({themes:N(s),langs:Array.from(new Set([`text`,c])),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(o):o(l)}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.externalReplacement=!1)}__acceptEditorChange(e){let{lineAnnotations:t}=e;t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(){}__attachEditor(e){if(this.editor!=null)throw Error(`File.__attachEditor: an editor is already attached`);this.editor=e;let t=()=>{this.editor=void 0,this.fileRenderer.endEditSession()};try{return this.resumeEditorRendering(e),t}catch(e){throw t(),e}}__resumeEditor(e){if(this.editor!==e)throw Error(`File.__resumeEditor: editor association changed`);this.resumeEditorRendering(e)}resumeEditorRendering(e){this.editSession==null?this.file!=null&&this.installEditSession(this.file,e.__getDocumentContents(this.file)):this.fileRenderer.beginEditSession(this.editSession.file);let t=this.editSession?.file;this.fileRenderer.editorRenderReady()?(this.fileRenderer.fileCache===t&&(this.renderedFile=t),this.syncRenderViewToEditor()):this.rerender()}__completeEditSession(e,t){this.settleEditSession(t===`install`,e)}settleEditSession(e,t){let{editSession:n,file:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{file:a,annotations:o}=n;if(this.editor!=null)throw Error(`File.__completeEditSession: detach the editor before completing the session`);let s=o?.current,c,l=!1,u;if(t==null)throw Error(`File.__completeEditSession: editor is required for completion`);let d={...a},f={file:d,editor:t,originalFile:r,lineAnnotations:s,originalLineAnnotations:i};Object.freeze(f);try{if(t.__emitEditComplete(f),this.options.onEditComplete?.(f)===`accept`){if(d.cacheKey!=null&&d.cacheKey===r.cacheKey)throw Error(`File.__completeEditSession: an accepted file must not reuse the replaced file cacheKey`);c=d}}catch(e){l=!0,u=e}e&&c!=null&&(this.file=c,s!=null&&(this.lineAnnotations=s)),this.editSession=void 0;let{renderedFile:p,file:m}=this;if(this.fileRenderer.endEditSession(m),p!=null&&m!=null&&p!==m&&T(p,m)&&(this.renderedFile=m),e&&this.fileContainer!=null&&this.rerender(),l)throw u}applyDocumentChange(e,t){let n=this.editSession?.file;if(n==null)throw Error(`File.applyDocumentChange: requires an active edit session`);this.fileRenderer.beginEditSession(n),this.fileRenderer.applyDocumentChange(e),t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}applySuspendedDocumentChange(e,t){this.editSession!=null&&(this.applyDocumentChange(e,t),this.fileRenderer.clearRenderCache())}updateRenderCache(e,t,n){let r=this.editSession?.file;if(r==null)throw Error(`File.updateRenderCache: requires an active edit session`);this.fileRenderer.beginEditSession(r),this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:a=!1,lineAnnotations:o,renderRange:s}){if(!this.enabled)throw Error(`File.render: attempting to call render after cleaned up`);this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:l=!1,themeType:u=`system`}=this.options,d=l?void 0:s,f=this.renderRange,p=this.hasThemeChanged(),m=o!=null&&(o.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(o),h=!T(this.file,e);h&&this.updateExternalFile(e,o);let g=this.getLatestFile(e)??e;if(!l&&!n&&j(d,this.renderRange)&&!h&&!m&&!p){let e=this.applyCachedThemeState(u);return e&&this.finalizeRender(),e}this.renderRange=d,h&&(this.cachedHeaderHTML=void 0),this.fileRenderer.setOptions(Re(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:_=!1,disableFileHeader:v=!1}=this.options;if(v&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(u),l){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.fileRenderer.renderFile(g,c);e!=null&&this.applyThemeState(t,e.themeStyles,u,e.baseThemeType),e?.headerAST!=null&&this.applyHeaderToDOM(e.headerAST,t,e.file),this.renderedFile=e?.file??g,this.injectUnsafeCSS()}catch(e){if(_)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return this.finalizeRender(),r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,m,h||p||!T(this.renderedFile,g))||!this.applyPartialRender(g,f,d)){let n=this.fileRenderer.renderFile(g,d);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,u,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t,n.file),this.applyFullRender(n,e),this.renderedFile=n.file}this.applyBuffers(e,d),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,a||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(_)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let 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(e)}setPlaceholderHeight(e){return this.placeHolder!=null&&(this.placeHolder.style.setProperty(`height`,`${e}px`),!0)}async primeHighlightCache(e=this.file){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||R(e))return;let n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(e=>{de(e)||console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let n=this.getAnnotationSlotName(i),a=`${r}-${n}`,o=this.annotationCache.get(a);if(o==null||!Le(i,o.annotation)){o?.element.remove();let e=t(i);if(e==null)continue;o={element:b(n),annotation:i},o.element.appendChild(e),this.fileContainer.appendChild(o.element),this.annotationCache.set(a,o)}e.delete(a)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=S();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;t!=null&&(e==null||e===``?(this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0):(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=ae(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=y(e),this.appliedUnsafeCSS=e))}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.getTheme(),s=typeof o==`string`?o:{...o},c=De(i);this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c?this.appliedThemeCSS.theme=s:this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i?(this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}):(this.themeCSSStyle=xe({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:re(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c})}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=Oe(this.themeCSSStyle.textContent??``,De(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&s()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);let n=this.code=ge({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();let i=()=>{if(n.childElementCount>=2)for(let e=0;e<2;e++){let t=n.children[e],i=r[e];t.innerHTML=W(i.children),t.style.cssText=i.properties.style}else n.innerHTML=W(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?_e(t,i):i(),this.lastRowCount=e.rowCount}applyPartialRender(e,t,n){if(t==null||n==null)return!1;let{code:r}=this,i=r==null?void 0:this.getColumns(r);if(r==null||i==null)return!1;let a=t.startingLine,o=n.startingLine,s=t.totalLines===1/0?1/0:a+t.totalLines,c=n.totalLines===1/0?1/0:o+n.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l)return!1;if(!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))throw Error(`File.applyPartialRender: failed to trim to overlap`);let{length:d}=i.content.children,f=(t,n)=>{if(!(n<=0))return this.fileRenderer.renderFile(e,{startingLine:t,totalLines:n,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&t.dataset.gutter!=null&&n.dataset.content!=null)return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;a===0&&(r.set(0,0),i+=1,a=n[i]);for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){t==null||this.shouldDisableVirtualizationBuffers()?(this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)):(t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0))}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let i=this.cachedHeaderHTML??W(e);if(this.cachedHeaderHTML=i,i!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=i;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=i}if(this.isContainerManaged)return;let{renderHeaderPrefix:a,renderHeaderFilenameSuffix:s,renderCustomHeader:c,renderHeaderMetadata:u}=this.options;if(c!=null){let e=c(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,l,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let e=a?.(n)??void 0,i=s?.(n)??void 0,c=u?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,o,e),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,r,i),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,p,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:A(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):A(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=ye;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};ee(i,this.appliedPreAttributes)||(he(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function He(e,t,n=!1){return!n&&e==null&&t!=null}function Ue(e,t,n=!1){return e==null&&t!=null&&!n}var We=5e3,X=new Map,Ge=-1;function Ke(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var qe=class extends Y{virtualizer;metrics;__id=`virtualized-file:${++Ge}`;renderType=`virtualized`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0,ghostTextRows:X};pendingRender;isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=u,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){let n=be(e);(t||!k(this.metrics,n))&&(this.metrics=n,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(){let{overflow:e=`scroll`}=this.options;return e===`scroll`&&!this.hasLineAnnotations()&&this.cache.heights.size===0}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!U(t,e),r=Ke(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.ghostTextRows=X,this.renderRange!=null&&t&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}applyGhostTextRows(e){let{heights:t,ghostTextRows:n}=this.cache;if(n===e)return!1;let{lineHeight:r}=this.metrics,i=!1;for(let a of new Set([...n.keys(),...e.keys()])){let o=n.get(a)??0,s=e.get(a)??0;if(s===o)continue;let c=(t.get(a)??r)-o*r+s*r;c===r?t.delete(a):t.set(a,c),i=!0}return this.cache.ghostTextRows=e,i}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.getLayoutFile()==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;this.top=this.getVirtualizedTop();let n=this.editor?.__getGhostTextRows()??X;e=this.applyGhostTextRows(n);let r=t!==`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;let{lineHeight:i}=this.metrics;if(this.code==null)return e;let a=this.code.children[1];if(!(a instanceof HTMLElement))return e;if(this.renderRange!=null&&ce(this.renderRange)){let t=Je(a)??0;t!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=t,e=!0)}for(let t of a.children){if(!(t instanceof HTMLElement))continue;let a=t.dataset.lineIndex;if(a==null)continue;let o=Number(a),s=(n.get(o)??0)*i,c=this.cache.heights.get(o);if(!r&&(c==null||c===i+s))continue;let l=t.getBoundingClientRect().height+s,u=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(u=!0),l+=t.nextElementSibling.getBoundingClientRect().height);let d=this.getLineHeight(o,u);l!==d&&(e=!0,l===this.metrics.lineHeight*(u?2:1)?this.cache.heights.delete(o):this.cache.heights.set(o,l))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));updateCodeViewLayout(e,t,n,r){let i=!T(this.file,e);i&&this.updateExternalFile(e,r);let{pendingRenderFile:a,layoutFileChanged:o,renderedFileChanged:s,annotationsChanged:c}=this.updatePendingRender(e,r),l=n?.resetFileLayoutCache===!0||o;n?.metrics!=null&&(this.metrics=n.metrics,l=!0);let{collapsed:u=!1}=this.options;return this.currentCollapsed!==u&&(this.currentCollapsed=u,l=!0),l&&this.resetLayoutCache(),i&&(this.layoutDirty=!0),!this.forceRenderOverride&&(i||s||c)&&(this.forceRenderOverride=!0),this.top=t,this.computeApproximateSize(!1,a),this.height}getLayoutFile(){return this.pendingRender?.file??this.getRenderedFile()}getLinePosition(e){let t=this.getLayoutFile();if(t==null||e<1)return;let{disableFileHeader:n=!1,collapsed:r=!1}=this.options,i=this.fileRenderer.getLineCount(t)-1;if(r)return{top:we(this.metrics,n),height:0};let a=z(this.metrics,n);if(i<0)return{top:a,height:0};let o=Math.min(Math.max(e-1,0),i),{lineHeight:s}=this.metrics;if(a+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())return{top:a+o*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(o);a=c?.top??a;for(let e=c?.lineIndex??0;e<o;e++)a+=this.getLineHeight(e,!1);return{top:a,height:this.getLineHeight(o,!1)}}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutFile();if(t==null||this.renderRange==null)return;let{disableFileHeader:n=!1,collapsed:r=!1}=this.options;if(r||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(t)-1;if(i<0)return;let a=z(this.metrics,n),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;let{fileAnnotationHeight:c}=this.cache;if(this.hasUniformLineHeights()){let{lineHeight:t}=this.metrics,n=a+(o===0?c:this.renderRange.bufferBefore),r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+c+r*t}}let l=a+(o===0?c:this.renderRange.bufferBefore);for(let t=o;t<=s;t++){if(l>=e)return{lineNumber:t+1,top:l};l+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutFile();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e==null?this.renderRange:this.computeRenderRangeFromWindow(t,this.top,e);if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:a}=n,o=0;if(a===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(o=i)}return{topOffset:this.top+r+o,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;t&&(this.layoutDirty=!0);let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!T(this.getRenderedFile(),this.getLatestFile()));this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache(),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n&&this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutFile()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(this.editor?.__getGhostTextRows()??X);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options,{lineHeight:o}=this.metrics,s=this.fileRenderer.getLineCount(t);if(a){this.height+=we(this.metrics,i),this.layoutDirty=!1;return}let c=z(this.metrics,i),l=B(this.metrics);if(this.height+=c,this.height+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())this.height+=s*o;else for(let e=0;e<s;e++)this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1);if(s>0&&(this.height+=l),this.fileContainer!=null&&n&&!r){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:t.name,elementHeight:e.height,computedHeight:this.height})}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;let e=this.getLatestFile(),t=e==null?void 0:this.fileRenderer.getFileForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!T(this.getRenderedFile(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();e==null?this.getSimpleVirtualizer()?.requestHeightReconcile(this):(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1);let i=this.getRenderedFile();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(i,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}render({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let a=!T(this.file,t);a&&(this.updateExternalFile(t,r),this.cachedHeaderHTML=void 0);let{pendingRenderFile:o,layoutFileChanged:s,renderedFileChanged:c,annotationsChanged:l}=this.pendingRender!=null&&this.pendingRender.latestFile===(this.getLatestFile(t)??t)?{pendingRenderFile:this.pendingRender.file,layoutFileChanged:!1,renderedFileChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(t,r),{forceRenderOverride:u,isSetup:d}=this;if(this.forceRenderOverride=void 0,s&&this.resetLayoutCache(),e=this.getOrCreateFileContainerNode(e),d)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,o));else{this.computeApproximateSize(!1,o);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!a||!d))return this.renderPlaceholder(this.height);let f=this.virtualizer.getWindowSpecs(),p=this.top??0,m=this.computeRenderRangeFromWindow(o,p,f);return super.render({file:t,fileContainer:e,renderRange:m,lineAnnotations:r,forceRender:(u??n)||l||c||a,...i})}finalizeRender(){if(this.getRenderedFile()!==this.pendingRender?.file)throw Error(`VirtualizedFile.render: rendered a different file than its prepared layout`);this.pendingRender=void 0,this.isSimpleMode()&&this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestFile(e)??e,r=this.getRenderedFile(),i=this.pendingRender?.file??r,a=this.fileRenderer.getFileForNextRender(n);return this.pendingRender={latestFile:n,file:a},{pendingRenderFile:a,annotationsChanged:this.syncLineAnnotations(t),layoutFileChanged:!T(i,a),renderedFileChanged:!T(r,a)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}addLayoutCheckpoint(e,t){e%We===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1}=this.options,{hunkLineCount:a,lineHeight:o}=this.metrics,s=this.fileRenderer.getLineCount(e),c=this.height,l=z(this.metrics,i),u=s>0?B(this.metrics):0,{fileAnnotationHeight:d}=this.cache,f=l+d,p=Math.max(0,c-l-d-u),m=oe(this.getLatestAnnotations()),h=t+l,g=d>0&&m&&h<r&&h+d>n;if(t<n-c||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:c-l-u};if(s<=a)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};let _=Math.ceil(Math.max(r-n,0)/o),v=Math.ceil(_/a)*a+a,y=v/a,b=(n+r)/2;if(this.hasUniformLineHeights()){let e=t+f,i=e+p;if(!g&&!(e<r&&i>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:c-l-u};let m=Math.floor(g&&b<t+f?0:(b-(t+f))/o),h=Math.floor(m/a)-Math.floor(y/2),_=Math.ceil(s/a),x=Math.max(0,Math.min(h,_))*a,S=h<0?v+h*a:v,C=x===0?0:d+x*o,w=Math.min(S,s-x);return{startingLine:x,totalLines:S,bufferBefore:C,bufferAfter:Math.max(0,(s-x-w)*o)}}let x=y,S=[],C=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-v*o*2),a),w=t+(C?.top??f),T=C?.lineIndex??0,E,D,O,k=C?.lineIndex??0;for(let e=k;e<s;e++){let i=T%a===0,o=Math.floor(T/a);if(i&&(S[o]=w-(t+f),O!=null)){if(O<=0)break;O--}let s=this.getLineHeight(e,!1);w>n-s&&w<r&&(E??=o),w+s>b&&(D??=o),O==null&&w>=r&&i&&(O=x),T++,w+=s}if(E==null){if(g)E=0,D=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:c-l-u}}D??=E;let A=Math.round(D-y/2),j=Math.max(0,Math.ceil(s/a)-y),M=Math.max(0,Math.min(A,j)),N=M*a,P=A<0?v+A*a:v,F=S[M]??0,ee=N===0?0:d+F,I=M+P/a,L=I<S.length?p-S[I]:p-(w-t-f);return{startingLine:N,totalLines:P,bufferBefore:ee,bufferAfter:Math.max(0,L)}}};function Je(e){let t;for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===se&&(t=Math.max(t??0,n.getBoundingClientRect().height));return t}var Z=e(t(),1),Ye=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function Xe({file:e,options:t,editorOptions:n,editStateKey:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:o,metrics:s,hasGutterRenderUtility:c,hasCustomHeader:l,disableWorkerPool:u,edit:d,onEditChange:f,onEditComplete:p}){let m=Ce(),g=a!==void 0,_=(0,Z.useContext)(le),v=Ne(),y=G(e=>f?.(e)),b=f==null?void 0:y,x=(0,Z.useRef)(null),S=G(e=>{let t=p?.(e)??`reject`;return t===`accept`&&(x.current={file:{installed:e.file,stale:e.originalFile},annotations:{installed:e.lineAnnotations,stale:e.originalLineAnnotations}}),t}),C=p==null?void 0:S,w=(0,Z.useRef)(null),T=(0,Z.useRef)(null),E=G(()=>{if(v==null)throw Error(`File: EditContext is not attached`);return v(`file`,n??{},r)}),D=G(n=>{if(n!=null){if(w.current!=null)throw Error(`File: An instance should not already exist when a node is created`);m==null?w.current=new Y(Q({controlledSelection:g,hasCustomHeader:l,hasGutterRenderUtility:c,onEditChange:b,onEditComplete:C,options:t}),u?void 0:_,!0):w.current=new qe(Q({controlledSelection:g,hasCustomHeader:l,hasGutterRenderUtility:c,onEditChange:b,onEditComplete:C,options:t}),m,s,u?void 0:_,!0),d&&T.current==null&&(T.current=$(w.current,E)),w.current.hydrate({file:e,fileContainer:n,lineAnnotations:i,prerenderedHTML:o})}else{if(w.current==null)throw Error(`File: A File instance should exist when unmounting`);w.current.cleanUp(),w.current=null,T.current=null}});return Ye(()=>{let{current:n}=w;if(n==null)return;let r=Q({controlledSelection:g,hasCustomHeader:l,hasGutterRenderUtility:c,onEditChange:b,onEditComplete:C,options:t}),o=r!==void 0&&!U(n.options,r);if(n.setOptions(r),!d&&T.current!=null){let{current:e}=T;T.current=null,e()}let s=Ze(e,i,x);n.render({file:s.file,lineAnnotations:s.lineAnnotations,forceRender:o}),a!==void 0&&n.setSelectedLines(a),d&&T.current==null&&(T.current=$(n,E))}),{ref:D,getHoveredLine:(0,Z.useCallback)(()=>w.current?.getHoveredLine(),[]),getAnnotationSlotName:(0,Z.useCallback)(e=>w.current?.getAnnotationSlotName(e)??h(e),[])}}function Ze(e,t,n){let{current:r}=n;if(r==null)return{file:e,lineAnnotations:t};let{file:i,annotations:a}=r,o=e;i!=null&&(T(e,i.stale)?o=i.installed:r.file=null);let s=t;return a!=null&&(t===a.stale?s=a.installed:r.annotations=null),r.file==null&&r.annotations==null&&(n.current=null),{file:o,lineAnnotations:s}}function Q({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return t||r||n||i!=null||a!=null?{...e,controlledSelection:t,renderCustomHeader:n?ne:e?.renderCustomHeader,renderGutterUtility:r?ne:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}:e}function $(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function Qe({file:e,lineAnnotations:t,selectedLines:n,options:r,editorOptions:i,editStateKey:a,metrics:o,className:s,style:c,renderAnnotation:l,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,prerenderedHTML:h,renderGutterUtility:g,disableWorkerPool:_=!1,edit:v=!1,onEditChange:y,onEditComplete:b}){let{ref:x,getHoveredLine:S,getAnnotationSlotName:C}=Xe({file:e,options:r,editorOptions:i,editStateKey:a,metrics:o,lineAnnotations:t,selectedLines:n,prerenderedHTML:h,hasGutterRenderUtility:g!=null,hasCustomHeader:u!=null,disableWorkerPool:_,edit:v,onEditChange:y,onEditComplete:b}),w=Pe({file:e,renderAnnotation:l,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderGutterUtility:g,lineAnnotations:t,getHoveredLine:S,getAnnotationSlotName:C});return(0,K.jsx)(m,{ref:x,className:s,style:c,children:me(w,h)})}export{Qe as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{C as r,G as i,M as a,T as o,V as s,b as c,d as l,g as u,m as d,p as f,w as p,y as m,z as h}from"./color-C1Sk4dBL.js";import{A as g,At as _,B as v,C as y,D as b,Dt as x,E as S,Et as C,F as w,G as T,H as E,I as D,It as O,J as k,K as A,L as j,M,Mt as N,N as P,Nt as F,O as ee,Ot as I,P as L,R as te,Rt as ne,S as re,St as ie,T as ae,Tt as R,U as oe,V as se,W as ce,Y as le,_ as ue,_t as de,b as fe,bt as pe,c as me,dt as z,f as he,ft as B,g as ge,h as _e,j as ve,jt as V,k as ye,kt as H,lt as be,m as xe,p as Se,q as U,s as Ce,ut as we,v as Te,vt as Ee,w as De,x as Oe,xt as ke,y as Ae,yt as je,z as Me}from"./PierreWorkerPool-mIDzTMB9.js";import{s as W}from"./string-TLTPtCPs-SBynuHAV.js";import{n as Ne,r as G}from"./EditContext-rlYgrfe2.js";var K=n();function Pe({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,lineAnnotations:o,renderGutterUtility:s,getHoveredLine:c,getAnnotationSlotName:u=h}){let d=t?.(e),f=n?.(e),p=r?.(e),m=i?.(e);return(0,K.jsxs)(K.Fragment,{children:[d==null?(0,K.jsxs)(K.Fragment,{children:[f!=null&&(0,K.jsx)(`div`,{slot:`header-prefix`,children:f}),p!=null&&(0,K.jsx)(`div`,{slot:`header-filename-suffix`,children:p}),m!=null&&(0,K.jsx)(`div`,{slot:`header-metadata`,children:m})]}):(0,K.jsx)(`div`,{slot:l,children:d}),a!=null&&o?.map((e,t)=>(0,K.jsx)(`div`,{slot:u(e),children:a(e)},t)),s!=null&&(0,K.jsx)(`div`,{slot:`gutter-utility-slot`,style:O,children:s(c)})]})}function q(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var Fe=-1,Ie=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`file-renderer:${++Fe}`;highlighter;file;renderCache;pendingHighlightResult;computedLang=`text`;lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;get fileCache(){return this.renderCache?.file}constructor(e={theme:d},t=h,n,r){this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r,r?.isWorkingPool()!==!0&&(this.highlighter=V(e.theme??d)?H():void 0)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let e=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=e,e.push(t)}}cleanUp(){this.endEditSession(),this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(e,t){let{editSessionActive:n,renderCache:r}=this;if(this.editSessionActive=!0,n||(this.pendingHighlightResult=void 0),this.file=e,r==null||n&&r.file===e)return;if(n){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}let{options:i}=this.getRenderOptions(e),a=r.file===e,o=t!=null&&T(r.file,t),{result:s}=r;if(!r.highlighted||s==null||!C(r.options,i)||!a&&!o){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}if(a)return;this.renderCache={...r,file:e,result:{...s,code:[...s.code]}};let{lineCache:c}=this;this.lineCache=c!=null&&t!=null&&q(c,t)?{cacheKey:void 0,file:e,sourceContents:e.contents,lines:c.lines}:void 0}endEditSession(e){if(this.editSessionActive=!1,this.pendingHighlightResult=void 0,this.file==null){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}let{renderCache:t}=this;e!=null&&t!=null&&t.file!==e&&T(t.file,e)&&(t.file=e)}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){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,this.workerManager?.cleanUpTasks(this),this.file=void 0}clearRenderCache(){this.pendingStructuralRows=void 0,this.renderCache=void 0,this.pendingHighlightResult=void 0}hydrate(e){this.file=e;let{options:t}=this.getRenderOptions(e),n=J(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);r!=null&&!C(t,r.options)&&(r=void 0),this.renderCache??={file:e,hydrated:!0,options:t,highlighted:!n&&!R(e),result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,e):this.highlighter??(this.computedLang=e.lang??a(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??d}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getFileRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{tokenizeMaxLineLength:e=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:e}})(),{renderCache:n}=this;return n?.result==null||!T(e,n.file)||!C(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getFileForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null)return e;let{renderCache:n}=this;if(n==null)return e;if(T(n.file,e))return n.file;let r=i(e.contents),a=e.contents.length===0||R(e)||J(r.length,this.getTokenizeMaxLength());return this.canRenderFile(e,t,a)?e:n.file}canRenderFile(e,t,n){let{renderCache:r}=this;return r==null||T(r.file,e)?!0:n?r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0||this.highlighter!=null&&V(t.theme):r.result==null&&r.hydrated!==!0?!0:!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?!r.highlighted:this.highlighter!=null&&V(t.theme)}getOrCreateLineCache(e){let{lineCache:t}=this;return(t==null||!q(t,e))&&(t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:i(e.contents)}),this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t,n=!1){this.pendingStructuralRows=void 0;let{renderCache:r}=this;if(r==null)return;let{file:i,result:a}=r;if(a==null)return;let o=n?new Map:void 0;this.pendingStructuralRows=o;let s=this.lineCache!=null&&q(this.lineCache,i)?this.lineCache:void 0;for(let[t,n]of e){if(o==null&&s!=null&&t<s.lines.length){let e=n.map(e=>e[2]).join(``);s.lines[t]=D(s.lines[t]??``,e)}let e={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})};o==null?a.code[t]=e:o.set(t,e)}a.baseThemeType=t,r.isDirty=!0,o==null&&s!=null&&(i.contents=s.lines.join(``),s.sourceContents=i.contents)}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;this.pendingStructuralRows=void 0;let r=this.file??n?.file;if(r==null)return;let a=n?.result,o=this.lineCache!=null&&q(this.lineCache,r)?this.lineCache.lines:i(r.contents),s=i(e.getText());if(a!=null&&o.length!==s.length){let r=Math.min(o.length,s.length),i=0;for(;i<r&&o[i]===s[i];)i++;let c=0;for(;c<r-i&&o[o.length-1-c]===s[s.length-1-c];)c++;let l=a.code;a.code=Array(s.length);for(let e=0;e<i;e++)a.code[e]=l[e];for(let e=0;e<c;e++)a.code[s.length-1-e]=l[o.length-1-e];if(t!==void 0)for(let[e,n]of t)e<s.length&&(a.code[e]=n);for(let t=i;t<s.length-c;t++)a.code[t]??={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:e.getLineText(t)}]}]};for(let e=0;e<a.code.length;e++){let t=a.code[e];t?.type===`element`&&(t.properties[`data-line`]=e+1,t.properties[`data-line-index`]=e)}n!=null&&(n.isDirty=!0)}let c=e.getText();this.lineCache={cacheKey:r.cacheKey,file:r,sourceContents:c,lines:s},this.textDocumentCache.set(r,e),r.contents=c}renderFile(e=this.file,t=f){if(this.file=e,e==null){this.pendingHighlightResult=void 0;return}let{options:n,forceHighlight:r}=this.getRenderOptions(e),i=this.getReadyRenderResult(e,n);this.pendingHighlightResult=void 0,i!=null&&(this.renderCache={...i,file:e,renderRange:void 0},r=!1),this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let o=this.getOrCreateLineCache(e),s=e.contents.length>0,c=!s||R(e)||J(o.length,this.getTokenizeMaxLength()),l=this.canRenderFile(e,n,c),u=!T(e,this.renderCache.file),d=!j(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let i=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!u&&g(t);l&&!i&&(c||this.renderCache.result==null||!this.renderCache.highlighted&&(u||d))&&(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||d||r)&&(this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,o)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||r)&&this.workerManager.highlightFileAST(this,e)}else{this.computedLang=e.lang??a(e.name),this.highlighter??=H();let t=this.highlighter!=null&&V(n.theme),i=this.highlighter!=null&&F(this.computedLang),o=!c&&i;if(l&&this.highlighter!=null&&t&&(r||c||!this.renderCache.highlighted&&o||this.renderCache.result==null)){let{result:t,options:n}=this.renderFileWithHighlighter(e,this.highlighter,c||!i);this.renderCache={file:e,options:n,highlighted:o,result:t,renderRange:void 0}}(!t||!c&&!i)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.applyHighlightResult(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processFileResult(this.renderCache.file,t,this.renderCache.result)}async asyncRender(e,t=f){this.file=e;let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=J(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??a(e.name);let n=this.highlighter!=null&&x(N(this.getLocalHighlightTheme())),r=t||this.highlighter!=null&&F(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:Ee(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let a=this.getLineCount(e),{disableFileHeader:o=!1}=this.options,s=[],c=ke(),l=Math.min(t.startingLine+t.totalLines,a),u=0,d=ce(t)?E(this.lineAnnotations):void 0;d!=null&&(c.children.push(je(`context`,`annotation`,1)),s.push(w({type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:d.map(e=>this.annotationSlotName(e))})),u++);for(let r=t.startingLine;r<l;r++){let t=r+1,i=n[r];if(i==null){let n=`FileRenderer.processFileResult: Line doesnt exist`;throw console.error(n,{name:e.name,lineIndex:r,lineNumber:t}),Error(n)}c.children.push(pe(`context`,t,`${r}`)),s.push(i),u++;let a=this.lineAnnotations[t];a!=null&&(c.children.push(je(`context`,`annotation`,1)),s.push(w({type:`annotation`,hunkIndex:0,lineIndex:t,annotations:a.map(e=>this.annotationSlotName(e))})),u++)}return c.properties.style=`grid-row: span ${u}`,{file:e,gutterAST:c.children??[],contentAST:s,preAST:this.createPreElement(a),headerAST:o?void 0:this.renderHeader(e),totalLines:a,rowCount:u,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderHeader(e){let{headerRenderMode:t=`default`,stickyHeader:n=!1}=this.options;return P({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return W(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(ie({tagName:`code`,children:this.renderCodeAST(e),properties:{"data-code":``}})),{...e.preAST,children:t}}renderCodeAST(e){let t=ke();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,L(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){return W(t?ie({tagName:`code`,children:e,properties:{"data-code":``}}):e)}async initializeHighlighter(){return this.highlighter=await _(ve(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{file:i,renderCache:a}=this;i!=null&&a!=null&&T(e,i)&&C(n,this.getRenderOptions(i).options)&&(a.result!=null&&a.highlighted&&C(a.options,n)&&T(a.file,i)||(this.pendingHighlightResult={file:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()))}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getFileResultCache(e);if(n!=null&&C(t,n.options))return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&T(n.file,e)&&C(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(!(r==null||this.hasHighlightedRenderCache(e,t)))return{file:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&T(e,n.file)&&C(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n=`scroll`}=this.options;return M({type:`file`,diffIndicators:`none`,disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function J(e,t){return e>t}function Le(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function Re(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:ue(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}var ze=[``];function Be(e){let t={...e};return delete t.cacheKey,t}var Ve=-1,Y=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++Ve}`;type=`file`;fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;editSession;renderedFile;renderRange;enabled=!0;editor;constructor(e={theme:d},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new Ie(e,this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager),this.resizeManager=new te,this.interactionManager=new Me(`file`,v(e)),this.workerManager?.subscribeToThemeChanges(this)}getAnnotationSlotName=e=>Ae(this.editSession?.annotations,e,h);handleHighlightRender=()=>{this.rerender()};rerender(){this.enabled&&this.file!=null&&this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}getTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??d}getLatestFile(e=this.file){return this.editSession?.file??e}getRenderedFile(){return this.renderedFile}getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;return e===this.lineAnnotations?!1:t==null||e!==t.provided&&e!==t.current}updateExternalFile(e,t){if(T(this.file,e))return!1;let n=this.editSession!=null;return this.file=e,n||this.editor!=null?this.installEditSession(e,n?void 0:this.editor?.__getDocumentContents(e),!0):this.editSession=void 0,this.editSession?.annotations!=null&&t!=null&&(this.lineAnnotations=t,this.editSession.annotations=Te(t,h,this.editSession.annotations)),!0}installEditSession(e,t,n=!1){let r=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===e.contents,i=Be(t??e);this.editSession={file:i,externalReplacement:n&&r,annotations:this.editSession?.annotations??Te(this.lineAnnotations,h)},this.fileRenderer.beginEditSession(i,r?e:void 0)}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(v(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!I(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){let t=this.editSession?.annotations;t==null?this.lineAnnotations=e:this.isNewAnnotations(e)&&(this.lineAnnotations=e,fe(t,e,h))}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;return t==null||e===t.current?!1:(t.current=e,this.fileRenderer.setLineAnnotations(e),this.renderAnnotations(),!0)}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e===`wrap`,columnVariables:this.shouldApplyColumnVariables(e)?`apply`:`measure`}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e===`scroll`&&this.getLatestAnnotations().length>0}cleanUp(e=!1){let t=this.editor;this.emitPostRender(!0),t?.cleanUp(e?`recycle`:`discard`),e||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0,this.editSession=void 0,this.renderedFile=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;if(!this.enabled)throw Error(`File.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`File.hydrate: hydrate can only be called before the instance has rendered or hydrated`);this.hydrateElements(t,n);let o=this.editor!=null;o||He(this.pre,i,this.options.collapsed)||Ue(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,forceRender:o||e.forceRender,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Se(e,t);for(let t of Array.from(e.shadowRoot?.children??[]))t instanceof SVGElement?this.spriteSVG=t:t instanceof HTMLElement&&(t instanceof HTMLPreElement?(this.pre=t,this.appliedPreAttributes=void 0):t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)?this.themeCSSStyle=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)?(this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent):`diffsHeader`in t.dataset&&(this.headerElement=t,this.lastRenderedHeaderHTML=void 0));this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(Re(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderedFile=e,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.getLatestFile()){return e==null?ze:this.fileRenderer.getOrCreateLineCache(e)}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let{editor:e,fileContainer:t,renderRange:n}=this,r=this.getLatestAnnotations(),i=this.getLatestFile();if(e==null||t==null||i==null)return;let o=a=>{this.enabled&&this.editor===e&&this.fileContainer===t&&this.getLatestFile()===i&&e.__syncRenderView({highlighter:a,fileContainer:t,file:i,lineAnnotations:r,renderRange:n,externalDocument:this.editSession?.externalReplacement===!0})},s=this.getTheme(),c=i.lang??a(i.name),l=H({theme:s,lang:c});l==null?_({themes:N(s),langs:Array.from(new Set([`text`,c])),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(o):o(l)}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.externalReplacement=!1)}__acceptEditorChange(e){let{lineAnnotations:t}=e;t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(){}__attachEditor(e){if(this.editor!=null)throw Error(`File.__attachEditor: an editor is already attached`);this.editor=e;let t=()=>{this.editor=void 0,this.fileRenderer.endEditSession()};try{return this.resumeEditorRendering(e),t}catch(e){throw t(),e}}__resumeEditor(e){if(this.editor!==e)throw Error(`File.__resumeEditor: editor association changed`);this.resumeEditorRendering(e)}resumeEditorRendering(e){this.editSession==null?this.file!=null&&this.installEditSession(this.file,e.__getDocumentContents(this.file)):this.fileRenderer.beginEditSession(this.editSession.file);let t=this.editSession?.file;this.fileRenderer.editorRenderReady()?(this.fileRenderer.fileCache===t&&(this.renderedFile=t),this.syncRenderViewToEditor()):this.rerender()}__completeEditSession(e,t){this.settleEditSession(t===`install`,e)}settleEditSession(e,t){let{editSession:n,file:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{file:a,annotations:o}=n;if(this.editor!=null)throw Error(`File.__completeEditSession: detach the editor before completing the session`);let s=o?.current,c,l=!1,u;if(t==null)throw Error(`File.__completeEditSession: editor is required for completion`);let d={...a},f={file:d,editor:t,originalFile:r,lineAnnotations:s,originalLineAnnotations:i};Object.freeze(f);try{if(t.__emitEditComplete(f),this.options.onEditComplete?.(f)===`accept`){if(d.cacheKey!=null&&d.cacheKey===r.cacheKey)throw Error(`File.__completeEditSession: an accepted file must not reuse the replaced file cacheKey`);c=d}}catch(e){l=!0,u=e}e&&c!=null&&(this.file=c,s!=null&&(this.lineAnnotations=s)),this.editSession=void 0;let{renderedFile:p,file:m}=this;if(this.fileRenderer.endEditSession(m),p!=null&&m!=null&&p!==m&&T(p,m)&&(this.renderedFile=m),e&&this.fileContainer!=null&&this.rerender(),l)throw u}applyDocumentChange(e,t){let n=this.editSession?.file;if(n==null)throw Error(`File.applyDocumentChange: requires an active edit session`);this.fileRenderer.beginEditSession(n),this.fileRenderer.applyDocumentChange(e),t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}applySuspendedDocumentChange(e,t){this.editSession!=null&&(this.applyDocumentChange(e,t),this.fileRenderer.clearRenderCache())}updateRenderCache(e,t,n){let r=this.editSession?.file;if(r==null)throw Error(`File.updateRenderCache: requires an active edit session`);this.fileRenderer.beginEditSession(r),this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:a=!1,lineAnnotations:o,renderRange:s}){if(!this.enabled)throw Error(`File.render: attempting to call render after cleaned up`);this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:l=!1,themeType:u=`system`}=this.options,d=l?void 0:s,f=this.renderRange,p=this.hasThemeChanged(),m=o!=null&&(o.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(o),h=!T(this.file,e);h&&this.updateExternalFile(e,o);let g=this.getLatestFile(e)??e;if(!l&&!n&&j(d,this.renderRange)&&!h&&!m&&!p){let e=this.applyCachedThemeState(u);return e&&this.finalizeRender(),e}this.renderRange=d,h&&(this.cachedHeaderHTML=void 0),this.fileRenderer.setOptions(Re(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:_=!1,disableFileHeader:v=!1}=this.options;if(v&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(u),l){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.fileRenderer.renderFile(g,c);e!=null&&this.applyThemeState(t,e.themeStyles,u,e.baseThemeType),e?.headerAST!=null&&this.applyHeaderToDOM(e.headerAST,t,e.file),this.renderedFile=e?.file??g,this.injectUnsafeCSS()}catch(e){if(_)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return this.finalizeRender(),r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,m,h||p||!T(this.renderedFile,g))||!this.applyPartialRender(g,f,d)){let n=this.fileRenderer.renderFile(g,d);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,u,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t,n.file),this.applyFullRender(n,e),this.renderedFile=n.file}this.applyBuffers(e,d),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,a||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(_)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let 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(e)}setPlaceholderHeight(e){return this.placeHolder!=null&&(this.placeHolder.style.setProperty(`height`,`${e}px`),!0)}async primeHighlightCache(e=this.file){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||R(e))return;let n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(e=>{de(e)||console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let n=this.getAnnotationSlotName(i),a=`${r}-${n}`,o=this.annotationCache.get(a);if(o==null||!Le(i,o.annotation)){o?.element.remove();let e=t(i);if(e==null)continue;o={element:b(n),annotation:i},o.element.appendChild(e),this.fileContainer.appendChild(o.element),this.annotationCache.set(a,o)}e.delete(a)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=S();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;t!=null&&(e==null||e===``?(this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0):(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=ae(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=y(e),this.appliedUnsafeCSS=e))}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.getTheme(),s=typeof o==`string`?o:{...o},c=De(i);this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c?this.appliedThemeCSS.theme=s:this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i?(this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}):(this.themeCSSStyle=xe({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:re(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c})}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=Oe(this.themeCSSStyle.textContent??``,De(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&s()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);let n=this.code=ge({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();let i=()=>{if(n.childElementCount>=2)for(let e=0;e<2;e++){let t=n.children[e],i=r[e];t.innerHTML=W(i.children),t.style.cssText=i.properties.style}else n.innerHTML=W(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?_e(t,i):i(),this.lastRowCount=e.rowCount}applyPartialRender(e,t,n){if(t==null||n==null)return!1;let{code:r}=this,i=r==null?void 0:this.getColumns(r);if(r==null||i==null)return!1;let a=t.startingLine,o=n.startingLine,s=t.totalLines===1/0?1/0:a+t.totalLines,c=n.totalLines===1/0?1/0:o+n.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l)return!1;if(!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))throw Error(`File.applyPartialRender: failed to trim to overlap`);let{length:d}=i.content.children,f=(t,n)=>{if(!(n<=0))return this.fileRenderer.renderFile(e,{startingLine:t,totalLines:n,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&t.dataset.gutter!=null&&n.dataset.content!=null)return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;a===0&&(r.set(0,0),i+=1,a=n[i]);for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){t==null||this.shouldDisableVirtualizationBuffers()?(this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)):(t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0))}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let i=this.cachedHeaderHTML??W(e);if(this.cachedHeaderHTML=i,i!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=i;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=i}if(this.isContainerManaged)return;let{renderHeaderPrefix:a,renderHeaderFilenameSuffix:s,renderCustomHeader:c,renderHeaderMetadata:u}=this.options;if(c!=null){let e=c(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,l,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let e=a?.(n)??void 0,i=s?.(n)??void 0,c=u?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,o,e),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,r,i),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,p,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:A(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):A(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=ye;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};ee(i,this.appliedPreAttributes)||(he(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function He(e,t,n=!1){return!n&&e==null&&t!=null}function Ue(e,t,n=!1){return e==null&&t!=null&&!n}var We=5e3,X=new Map,Ge=-1;function Ke(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var qe=class extends Y{virtualizer;metrics;__id=`virtualized-file:${++Ge}`;renderType=`virtualized`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0,ghostTextRows:X};pendingRender;isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=u,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){let n=be(e);(t||!k(this.metrics,n))&&(this.metrics=n,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(){let{overflow:e=`scroll`}=this.options;return e===`scroll`&&!this.hasLineAnnotations()&&this.cache.heights.size===0}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!U(t,e),r=Ke(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.ghostTextRows=X,this.renderRange!=null&&t&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}applyGhostTextRows(e){let{heights:t,ghostTextRows:n}=this.cache;if(n===e)return!1;let{lineHeight:r}=this.metrics,i=!1;for(let a of new Set([...n.keys(),...e.keys()])){let o=n.get(a)??0,s=e.get(a)??0;if(s===o)continue;let c=(t.get(a)??r)-o*r+s*r;c===r?t.delete(a):t.set(a,c),i=!0}return this.cache.ghostTextRows=e,i}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.getLayoutFile()==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;this.top=this.getVirtualizedTop();let n=this.editor?.__getGhostTextRows()??X;e=this.applyGhostTextRows(n);let r=t!==`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;let{lineHeight:i}=this.metrics;if(this.code==null)return e;let a=this.code.children[1];if(!(a instanceof HTMLElement))return e;if(this.renderRange!=null&&ce(this.renderRange)){let t=Je(a)??0;t!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=t,e=!0)}for(let t of a.children){if(!(t instanceof HTMLElement))continue;let a=t.dataset.lineIndex;if(a==null)continue;let o=Number(a),s=(n.get(o)??0)*i,c=this.cache.heights.get(o);if(!r&&(c==null||c===i+s))continue;let l=t.getBoundingClientRect().height+s,u=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(u=!0),l+=t.nextElementSibling.getBoundingClientRect().height);let d=this.getLineHeight(o,u);l!==d&&(e=!0,l===this.metrics.lineHeight*(u?2:1)?this.cache.heights.delete(o):this.cache.heights.set(o,l))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));updateCodeViewLayout(e,t,n,r){let i=!T(this.file,e);i&&this.updateExternalFile(e,r);let{pendingRenderFile:a,layoutFileChanged:o,renderedFileChanged:s,annotationsChanged:c}=this.updatePendingRender(e,r),l=n?.resetFileLayoutCache===!0||o;n?.metrics!=null&&(this.metrics=n.metrics,l=!0);let{collapsed:u=!1}=this.options;return this.currentCollapsed!==u&&(this.currentCollapsed=u,l=!0),l&&this.resetLayoutCache(),i&&(this.layoutDirty=!0),!this.forceRenderOverride&&(i||s||c)&&(this.forceRenderOverride=!0),this.top=t,this.computeApproximateSize(!1,a),this.height}getLayoutFile(){return this.pendingRender?.file??this.getRenderedFile()}getLinePosition(e){let t=this.getLayoutFile();if(t==null||e<1)return;let{disableFileHeader:n=!1,collapsed:r=!1}=this.options,i=this.fileRenderer.getLineCount(t)-1;if(r)return{top:we(this.metrics,n),height:0};let a=z(this.metrics,n);if(i<0)return{top:a,height:0};let o=Math.min(Math.max(e-1,0),i),{lineHeight:s}=this.metrics;if(a+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())return{top:a+o*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(o);a=c?.top??a;for(let e=c?.lineIndex??0;e<o;e++)a+=this.getLineHeight(e,!1);return{top:a,height:this.getLineHeight(o,!1)}}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutFile();if(t==null||this.renderRange==null)return;let{disableFileHeader:n=!1,collapsed:r=!1}=this.options;if(r||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(t)-1;if(i<0)return;let a=z(this.metrics,n),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;let{fileAnnotationHeight:c}=this.cache;if(this.hasUniformLineHeights()){let{lineHeight:t}=this.metrics,n=a+(o===0?c:this.renderRange.bufferBefore),r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+c+r*t}}let l=a+(o===0?c:this.renderRange.bufferBefore);for(let t=o;t<=s;t++){if(l>=e)return{lineNumber:t+1,top:l};l+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutFile();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e==null?this.renderRange:this.computeRenderRangeFromWindow(t,this.top,e);if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:a}=n,o=0;if(a===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(o=i)}return{topOffset:this.top+r+o,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;t&&(this.layoutDirty=!0);let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!T(this.getRenderedFile(),this.getLatestFile()));this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache(),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n&&this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutFile()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(this.editor?.__getGhostTextRows()??X);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options,{lineHeight:o}=this.metrics,s=this.fileRenderer.getLineCount(t);if(a){this.height+=we(this.metrics,i),this.layoutDirty=!1;return}let c=z(this.metrics,i),l=B(this.metrics);if(this.height+=c,this.height+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())this.height+=s*o;else for(let e=0;e<s;e++)this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1);if(s>0&&(this.height+=l),this.fileContainer!=null&&n&&!r){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:t.name,elementHeight:e.height,computedHeight:this.height})}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;let e=this.getLatestFile(),t=e==null?void 0:this.fileRenderer.getFileForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!T(this.getRenderedFile(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();e==null?this.getSimpleVirtualizer()?.requestHeightReconcile(this):(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1);let i=this.getRenderedFile();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(i,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}render({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let a=!T(this.file,t);a&&(this.updateExternalFile(t,r),this.cachedHeaderHTML=void 0);let{pendingRenderFile:o,layoutFileChanged:s,renderedFileChanged:c,annotationsChanged:l}=this.pendingRender!=null&&this.pendingRender.latestFile===(this.getLatestFile(t)??t)?{pendingRenderFile:this.pendingRender.file,layoutFileChanged:!1,renderedFileChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(t,r),{forceRenderOverride:u,isSetup:d}=this;if(this.forceRenderOverride=void 0,s&&this.resetLayoutCache(),e=this.getOrCreateFileContainerNode(e),d)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,o));else{this.computeApproximateSize(!1,o);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!a||!d))return this.renderPlaceholder(this.height);let f=this.virtualizer.getWindowSpecs(),p=this.top??0,m=this.computeRenderRangeFromWindow(o,p,f);return super.render({file:t,fileContainer:e,renderRange:m,lineAnnotations:r,forceRender:(u??n)||l||c||a,...i})}finalizeRender(){if(this.getRenderedFile()!==this.pendingRender?.file)throw Error(`VirtualizedFile.render: rendered a different file than its prepared layout`);this.pendingRender=void 0,this.isSimpleMode()&&this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestFile(e)??e,r=this.getRenderedFile(),i=this.pendingRender?.file??r,a=this.fileRenderer.getFileForNextRender(n);return this.pendingRender={latestFile:n,file:a},{pendingRenderFile:a,annotationsChanged:this.syncLineAnnotations(t),layoutFileChanged:!T(i,a),renderedFileChanged:!T(r,a)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}addLayoutCheckpoint(e,t){e%We===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1}=this.options,{hunkLineCount:a,lineHeight:o}=this.metrics,s=this.fileRenderer.getLineCount(e),c=this.height,l=z(this.metrics,i),u=s>0?B(this.metrics):0,{fileAnnotationHeight:d}=this.cache,f=l+d,p=Math.max(0,c-l-d-u),m=oe(this.getLatestAnnotations()),h=t+l,g=d>0&&m&&h<r&&h+d>n;if(t<n-c||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:c-l-u};if(s<=a)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};let _=Math.ceil(Math.max(r-n,0)/o),v=Math.ceil(_/a)*a+a,y=v/a,b=(n+r)/2;if(this.hasUniformLineHeights()){let e=t+f,i=e+p;if(!g&&!(e<r&&i>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:c-l-u};let m=Math.floor(g&&b<t+f?0:(b-(t+f))/o),h=Math.floor(m/a)-Math.floor(y/2),_=Math.ceil(s/a),x=Math.max(0,Math.min(h,_))*a,S=h<0?v+h*a:v,C=x===0?0:d+x*o,w=Math.min(S,s-x);return{startingLine:x,totalLines:S,bufferBefore:C,bufferAfter:Math.max(0,(s-x-w)*o)}}let x=y,S=[],C=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-v*o*2),a),w=t+(C?.top??f),T=C?.lineIndex??0,E,D,O,k=C?.lineIndex??0;for(let e=k;e<s;e++){let i=T%a===0,o=Math.floor(T/a);if(i&&(S[o]=w-(t+f),O!=null)){if(O<=0)break;O--}let s=this.getLineHeight(e,!1);w>n-s&&w<r&&(E??=o),w+s>b&&(D??=o),O==null&&w>=r&&i&&(O=x),T++,w+=s}if(E==null){if(g)E=0,D=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:c-l-u}}D??=E;let A=Math.round(D-y/2),j=Math.max(0,Math.ceil(s/a)-y),M=Math.max(0,Math.min(A,j)),N=M*a,P=A<0?v+A*a:v,F=S[M]??0,ee=N===0?0:d+F,I=M+P/a,L=I<S.length?p-S[I]:p-(w-t-f);return{startingLine:N,totalLines:P,bufferBefore:ee,bufferAfter:Math.max(0,L)}}};function Je(e){let t;for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===se&&(t=Math.max(t??0,n.getBoundingClientRect().height));return t}var Z=e(t(),1),Ye=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function Xe({file:e,options:t,editorOptions:n,editStateKey:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:o,metrics:s,hasGutterRenderUtility:c,hasCustomHeader:l,disableWorkerPool:u,edit:d,onEditChange:f,onEditComplete:p}){let m=Ce(),g=a!==void 0,_=(0,Z.useContext)(le),v=Ne(),y=G(e=>f?.(e)),b=f==null?void 0:y,x=(0,Z.useRef)(null),S=G(e=>{let t=p?.(e)??`reject`;return t===`accept`&&(x.current={file:{installed:e.file,stale:e.originalFile},annotations:{installed:e.lineAnnotations,stale:e.originalLineAnnotations}}),t}),C=p==null?void 0:S,w=(0,Z.useRef)(null),T=(0,Z.useRef)(null),E=G(()=>{if(v==null)throw Error(`File: EditContext is not attached`);return v(`file`,n??{},r)}),D=G(n=>{if(n!=null){if(w.current!=null)throw Error(`File: An instance should not already exist when a node is created`);m==null?w.current=new Y(Q({controlledSelection:g,hasCustomHeader:l,hasGutterRenderUtility:c,onEditChange:b,onEditComplete:C,options:t}),u?void 0:_,!0):w.current=new qe(Q({controlledSelection:g,hasCustomHeader:l,hasGutterRenderUtility:c,onEditChange:b,onEditComplete:C,options:t}),m,s,u?void 0:_,!0),d&&T.current==null&&(T.current=$(w.current,E)),w.current.hydrate({file:e,fileContainer:n,lineAnnotations:i,prerenderedHTML:o})}else{if(w.current==null)throw Error(`File: A File instance should exist when unmounting`);w.current.cleanUp(),w.current=null,T.current=null}});return Ye(()=>{let{current:n}=w;if(n==null)return;let r=Q({controlledSelection:g,hasCustomHeader:l,hasGutterRenderUtility:c,onEditChange:b,onEditComplete:C,options:t}),o=r!==void 0&&!U(n.options,r);if(n.setOptions(r),!d&&T.current!=null){let{current:e}=T;T.current=null,e()}let s=Ze(e,i,x);n.render({file:s.file,lineAnnotations:s.lineAnnotations,forceRender:o}),a!==void 0&&n.setSelectedLines(a),d&&T.current==null&&(T.current=$(n,E))}),{ref:D,getHoveredLine:(0,Z.useCallback)(()=>w.current?.getHoveredLine(),[]),getAnnotationSlotName:(0,Z.useCallback)(e=>w.current?.getAnnotationSlotName(e)??h(e),[])}}function Ze(e,t,n){let{current:r}=n;if(r==null)return{file:e,lineAnnotations:t};let{file:i,annotations:a}=r,o=e;i!=null&&(T(e,i.stale)?o=i.installed:r.file=null);let s=t;return a!=null&&(t===a.stale?s=a.installed:r.annotations=null),r.file==null&&r.annotations==null&&(n.current=null),{file:o,lineAnnotations:s}}function Q({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return t||r||n||i!=null||a!=null?{...e,controlledSelection:t,renderCustomHeader:n?ne:e?.renderCustomHeader,renderGutterUtility:r?ne:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}:e}function $(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function Qe({file:e,lineAnnotations:t,selectedLines:n,options:r,editorOptions:i,editStateKey:a,metrics:o,className:s,style:c,renderAnnotation:l,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,prerenderedHTML:h,renderGutterUtility:g,disableWorkerPool:_=!1,edit:v=!1,onEditChange:y,onEditComplete:b}){let{ref:x,getHoveredLine:S,getAnnotationSlotName:C}=Xe({file:e,options:r,editorOptions:i,editStateKey:a,metrics:o,lineAnnotations:t,selectedLines:n,prerenderedHTML:h,hasGutterRenderUtility:g!=null,hasCustomHeader:u!=null,disableWorkerPool:_,edit:v,onEditChange:y,onEditComplete:b}),w=Pe({file:e,renderAnnotation:l,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderGutterUtility:g,lineAnnotations:t,getHoveredLine:S,getAnnotationSlotName:C});return(0,K.jsx)(m,{ref:x,className:s,style:c,children:me(w,h)})}export{Qe as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,St as n,_ as r,d as i,f as a,p as o,u as s,v as c,xt as l,y as u}from"./base-ui-DDpgJXgO.js";import{o as d}from"./tanstack-CVAt_k_T.js";import{t as f}from"./utils-D0T3A-kS.js";import{n as p,t as m}from"./createReactComponent-Ctub7J3a.js";import{t as h}from"./IconCheck-C-G-IA13.js";import{t as g}from"./IconEdit-CZe-EJxX.js";import{n as ee,t as _}from"./IconFolderSymlink-DkLEuUb6.js";import{t as te}from"./IconLoader4-D2VN7u1V.js";import{t as ne}from"./IconSearch-1VQ4P4kW.js";import{T as v,w as y}from"./index-DsKvWsTs.js";import{$ as b,$t as re,C as ie,Ft as ae,Gt as oe,J as x,Jt as S,Kt as se,Mt as C,Nt as ce,Q as w,S as le,U as T,X as ue,Xt as de,Y as fe,Yt as pe,_t as E,at as D,bt as O,ct as k,dt as me,et as A,gt as he,ht as j,jt as ge,kt as M,lt as _e,m as N,mt as ve,nt as ye,ot as be,p as xe,qt as P,rt as Se,st as Ce,tn as F,tt as I,ut as L,vt as we,x as R,yt as Te}from"./App-Bfw_TX8q.js";var z=m(`outline`,`arrow-back-up`,`ArrowBackUp`,[[`path`,{d:`M9 14l-4 -4l4 -4`,key:`svg-0`}],[`path`,{d:`M5 10h11a4 4 0 1 1 0 8h-1`,key:`svg-1`}]]),B=m(`outline`,`arrow-forward-up`,`ArrowForwardUp`,[[`path`,{d:`M15 14l4 -4l-4 -4`,key:`svg-0`}],[`path`,{d:`M19 10h-11a4 4 0 1 0 0 8h1`,key:`svg-1`}]]),Ee=m(`outline`,`clipboard`,`Clipboard`,[[`path`,{d:`M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2`,key:`svg-0`}],[`path`,{d:`M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2`,key:`svg-1`}]]),V=m(`outline`,`columns-2`,`Columns2`,[[`path`,{d:`M3 4a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-16`,key:`svg-0`}],[`path`,{d:`M12 3v18`,key:`svg-1`}]]),H=m(`outline`,`cut`,`Cut`,[[`path`,{d:`M4 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-0`}],[`path`,{d:`M14 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-1`}],[`path`,{d:`M9.15 14.85l8.85 -10.85`,key:`svg-2`}],[`path`,{d:`M6 4l8.85 10.85`,key:`svg-3`}]]),De=m(`outline`,`file-plus`,`FilePlus`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2`,key:`svg-1`}],[`path`,{d:`M12 11l0 6`,key:`svg-2`}],[`path`,{d:`M9 14l6 0`,key:`svg-3`}]]),U=e(t()),Oe=e(n()),W=l(),ke=a,Ae=i;function je({className:e,children:t,...n}){return(0,W.jsx)(r,{children:(0,W.jsx)(s,{className:`isolate z-50 outline-none`,children:(0,W.jsx)(c,{"data-slot":`context-menu-content`,className:f(`min-w-44 origin-(--transform-origin) rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n,children:t})})})}function G({className:e,...t}){return(0,W.jsx)(u,{"data-slot":`context-menu-item`,className:f(`flex h-8 cursor-default items-center gap-2 rounded-md px-2 text-xs outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0`,e),...t})}function K({className:e,...t}){return(0,W.jsx)(o,{"data-slot":`context-menu-separator`,className:f(`mx-1 my-1 h-px bg-border`,e),...t})}function Me({state:e,onClose:t,onRename:n,onCreate:r}){let[i,a]=(0,U.useState)(``);if((0,U.useEffect)(()=>{e&&a(e.mode===`rename`?e.entry.name:``)},[e]),!e)return null;let o=e.mode===`rename`,s=e.mode===`new-folder`?`directory`:`file`,c=e.entry.type===`directory`?e.entry.path:j(e.entry.path),l=o?`Rename`:s===`directory`?`New Folder`:`New File`,u=i.trim(),d=u.length>0&&!/[\\/]/.test(u)&&!(o&&u===e.entry.name),f=()=>{d&&(o?n(e.entry,u):r(c,u,s),t())};return(0,W.jsx)(M,{open:!0,onOpenChange:e=>{e||t()},children:(0,W.jsx)(C,{className:`name-dialog`,children:(0,W.jsxs)(`form`,{className:`name-dialog-content`,onSubmit:e=>{e.preventDefault(),f()},children:[(0,W.jsx)(ce,{children:l}),(0,W.jsx)(ge,{children:o?(0,W.jsxs)(W.Fragment,{children:[`Enter a new name for `,(0,W.jsx)(`code`,{children:e.entry.name}),`.`]}):(0,W.jsxs)(W.Fragment,{children:[`Create a new `,s===`directory`?`folder`:`file`,` in `,(0,W.jsx)(`code`,{children:c||`the repository root`}),`.`]})}),(0,W.jsx)(`input`,{autoFocus:!0,className:`name-dialog-input`,value:i,maxLength:255,placeholder:o?`New name`:s===`directory`?`Folder name`:`File name`,onChange:e=>a(e.target.value),onFocus:t=>{if(!o)return;let n=e.entry.name.lastIndexOf(`.`);t.target.setSelectionRange(0,n>0?n:e.entry.name.length)}}),(0,W.jsxs)(`div`,{className:`name-dialog-actions`,children:[(0,W.jsx)(v,{type:`button`,variant:`ghost`,onClick:t,children:`Cancel`}),(0,W.jsx)(v,{type:`submit`,disabled:!d,children:o?`Rename`:`Create`})]})]})})})}function Ne(e,t,n,r=!0){let[i,a]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(!r)return;let i=!1;return n(e).then(n=>{i||a({path:e,revision:t,entries:n,failed:!1})},()=>{i||a({path:e,revision:t,entries:[],failed:!0})}),()=>{i=!0}},[e,t,n,r]);let o=r&&i?.path===e;return{entries:o?i.entries:null,failed:o&&i.failed,refreshing:!o||i.revision!==t}}function Pe({entries:e,initialDirectory:t,revision:n,readOnly:r,onLoadDirectory:i,onMove:a,onClose:o}){let[s,c]=(0,U.useState)(t),[l,u]=(0,U.useState)(!1),{entries:d,failed:f,refreshing:m}=Ne(s,n,i),h=e.map(e=>e.path),g=d?.filter(e=>e.type===`directory`&&!h.some(t=>he(t,e.path)))??[],ee=!r&&!l&&!m&&d!==null&&!f&&be(h,s),_=async()=>{if(ee){u(!0);try{await a(e,s),o()}finally{u(!1)}}};return(0,W.jsxs)(R,{open:!0,onOpenChange:e=>{!e&&!l&&o()},title:`Move to…`,description:`${e.length} selected ${e.length===1?`item`:`items`}. Choose a destination folder.`,children:[(0,W.jsxs)(`div`,{className:`mobile-folder-location`,children:[s&&(0,W.jsx)(v,{variant:`ghost`,size:`icon`,"aria-label":`Parent folder`,disabled:l,onClick:()=>c(j(s)),children:(0,W.jsx)(F,{})}),(0,W.jsx)(`span`,{children:s||`Repository root`})]}),(0,W.jsx)(`div`,{className:`mobile-destination-list`,children:d===null?(0,W.jsxs)(`p`,{className:`mobile-list-message`,role:`status`,children:[(0,W.jsx)(te,{className:`animate-spin`,"aria-hidden":`true`}),(0,W.jsx)(p,{text:`Loading folders…`})]}):f?(0,W.jsx)(`p`,{className:`mobile-list-message`,role:`alert`,children:`Could not read this folder.`}):g.length===0?(0,W.jsx)(`p`,{className:`mobile-list-message`,children:`No subfolders. You can choose this folder below.`}):g.map(e=>(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:l,onClick:()=>c(e.path),children:[(0,W.jsx)(`img`,{src:N(e.path,!1),alt:``,"aria-hidden":`true`,draggable:!1}),(0,W.jsx)(`span`,{children:e.name}),(0,W.jsx)(re,{})]},e.path))}),(0,W.jsxs)(`div`,{className:`mobile-sheet-footer`,children:[(0,W.jsx)(v,{variant:`ghost`,disabled:l,onClick:o,children:`Cancel`}),(0,W.jsxs)(v,{disabled:!ee,onClick:()=>void _(),children:[l&&(0,W.jsx)(te,{className:`animate-spin`}),` Move here`]})]})]})}var Fe=56;function Ie(e){let[t,n]=(0,U.useState)(()=>j(e.activePath??``)),[r,i]=(0,U.useState)(``),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(new Map),[l,u]=(0,U.useState)(null),[f,m]=(0,U.useState)(null),[b,ie]=(0,U.useState)(null),x=(0,U.useRef)(null),S=(0,U.useRef)(new Map),se=(0,U.useRef)(e.activePath),{entries:C,failed:ce}=Ne(t,e.filesSnapshotRevision,e.onLoadDirectory,e.active),w=(0,U.useMemo)(()=>(C??[]).filter(t=>(e.showDotEnvFiles||!t.ignored)&&t.name.toLocaleLowerCase().includes(r.toLocaleLowerCase())),[C,e.showDotEnvFiles,r]),le=d({count:w.length,enabled:e.active&&C!==null,getScrollElement:()=>x.current,estimateSize:()=>Fe,getItemKey:e=>w[e].path,overscan:8,paddingEnd:12});(0,U.useEffect)(()=>{e.activePath!==se.current&&(se.current=e.activePath,e.activePath&&(n(j(e.activePath)),i(``)))},[e.activePath]),(0,U.useEffect)(()=>{if(!C)return;let e=new Set(C.map(e=>e.path));c(t=>{let n=new Map([...t].filter(([t])=>e.has(t)));return n.size===t.size?t:n})},[C]),(0,U.useEffect)(()=>{C&&x.current&&(x.current.scrollTop=S.current.get(t)??0)},[t,C]),(0,U.useEffect)(()=>{if(!e.files||!t||O(e.files,t)!==`missing`)return;let r=j(t);for(;r&&O(e.files,r)===`missing`;)r=j(r);n(r),i(``),c(new Map)},[e.files,t]);let T=e=>{n(e),i(``),c(new Map)},ue=e=>c(t=>{let n=new Map(t);return n.has(e.path)?n.delete(e.path):n.set(e.path,e),n}),fe={type:`directory`,path:t,name:t.split(`/`).pop()??``,children:[]},E=[...s.values()],D=l&&l!==`tools`?l:null,k=e=>{u(null),e()};return(0,W.jsxs)(`div`,{className:`mobile-files-view`,children:[(0,W.jsxs)(`div`,{className:`mobile-view-heading`,children:[(0,W.jsxs)(`h2`,{children:[a?`Select items`:`Files`,a&&(0,W.jsx)(`small`,{children:s.size})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(v,{variant:`ghost`,size:`sm`,"aria-pressed":a,onClick:()=>{o(!a),c(new Map)},children:a?`Cancel`:`Select`}),(0,W.jsx)(v,{variant:`ghost`,size:`icon`,"aria-label":`File browser actions`,onClick:()=>u(`tools`),children:(0,W.jsx)(de,{})})]})]}),(0,W.jsxs)(`label`,{className:`mobile-file-filter`,children:[(0,W.jsx)(ne,{"aria-hidden":`true`}),(0,W.jsx)(`input`,{type:`search`,value:r,placeholder:`Filter this folder…`,"aria-label":`Filter this folder`,onChange:e=>{i(e.target.value),S.current.set(t,0),x.current?.scrollTo({top:0})}})]}),(0,W.jsxs)(`nav`,{className:`mobile-file-breadcrumb`,"aria-label":`Folder location`,children:[(0,W.jsxs)(`button`,{onClick:()=>T(``),"aria-current":t===``?`location`:void 0,children:[(0,W.jsx)(oe,{"aria-hidden":`true`}),` Root`]}),t.split(`/`).filter(Boolean).map((e,n,r)=>{let i=r.slice(0,n+1).join(`/`);return(0,W.jsxs)(`span`,{children:[(0,W.jsx)(re,{"aria-hidden":`true`}),(0,W.jsx)(`button`,{"aria-current":i===t?`location`:void 0,onClick:()=>T(i),children:e})]},i)})]}),(0,W.jsx)(`div`,{className:`mobile-files-scroll`,ref:x,onScroll:e=>S.current.set(t,e.currentTarget.scrollTop),children:C===null?(0,W.jsxs)(`p`,{className:`mobile-list-message`,role:`status`,children:[(0,W.jsx)(te,{className:`animate-spin`,"aria-hidden":`true`}),(0,W.jsx)(p,{text:`Loading files…`})]}):ce?(0,W.jsx)(`p`,{className:`mobile-list-message`,role:`alert`,children:`Could not read this folder.`}):w.length===0?(0,W.jsx)(`p`,{className:`mobile-list-message`,children:r?`No matching files in this folder.`:`This folder is empty.`}):(0,W.jsx)(`div`,{className:`virtual-list`,role:`list`,"aria-label":`Files in this folder`,style:{height:le.getTotalSize()},children:le.getVirtualItems().map(t=>{let n=w[t.index],r=s.has(n.path);return(0,W.jsxs)(`div`,{role:`listitem`,className:`mobile-file-row ${r?`selected`:``}`,style:{height:t.size,transform:`translateY(${t.start}px)`},children:[(0,W.jsxs)(`button`,{className:`mobile-file-open`,"aria-pressed":a?r:void 0,"aria-current":e.activePath===n.path?`true`:void 0,onClick:()=>a?ue(n):n.type===`directory`?T(n.path):e.onOpenFile(n.path),children:[a?(0,W.jsx)(`span`,{className:`mobile-file-check ${r?`checked`:``}`,children:r&&(0,W.jsx)(h,{"aria-hidden":`true`})}):(0,W.jsx)(`img`,{src:n.type===`directory`?N(n.path,!1):xe(n.path),alt:``,"aria-hidden":`true`,draggable:!1}),(0,W.jsxs)(`span`,{className:`mobile-file-copy`,children:[(0,W.jsx)(`strong`,{children:n.name}),(0,W.jsx)(`small`,{children:n.type===`directory`?n.ignored?`Ignored folder`:`Folder`:`${n.ignored?`Ignored · `:``}${Math.max(1,Math.ceil(n.size/1024))} KB`})]}),!a&&n.type===`directory`&&(0,W.jsx)(re,{"aria-hidden":`true`})]}),!a&&(0,W.jsx)(v,{variant:`ghost`,size:`icon`,className:`mobile-file-menu`,"aria-label":`Actions for ${n.name}`,onClick:()=>u(n),children:(0,W.jsx)(de,{})})]},n.path)})})}),a&&(0,W.jsxs)(`div`,{className:`mobile-file-selection-actions`,children:[(0,W.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:e.readOnly||s.size===0,onClick:()=>ie(E),children:[(0,W.jsx)(_,{}),` Move to…`]}),(0,W.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:s.size===0,onClick:()=>void(e.fileClipboardAvailable?e.onCopyEntries(E):e.onCopyPath(E)),children:[(0,W.jsx)(y,{}),` `,e.fileClipboardAvailable?`Copy`:`Copy paths`]}),e.fileClipboardAvailable&&(0,W.jsx)(v,{variant:`ghost`,size:`icon`,"aria-label":`Cut selected items`,disabled:e.readOnly||s.size===0,onClick:()=>void e.onCutEntries(E),children:(0,W.jsx)(H,{})}),(0,W.jsx)(v,{variant:`ghost`,size:`icon`,"aria-label":`Delete selected items`,disabled:e.readOnly||s.size===0,onClick:()=>void e.onDeleteEntries(E),children:(0,W.jsx)(ae,{})})]}),(0,W.jsx)(R,{open:l!==null,onOpenChange:e=>{e||u(null)},title:D?.name??`File browser actions`,description:D?.path??`Actions for the current folder.`,children:D?(0,W.jsxs)(W.Fragment,{children:[D.type===`file`&&(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>k(()=>e.onOpenFile(D.path,`pinned`)),children:[(0,W.jsx)(De,{}),(0,W.jsx)(`span`,{children:`Keep file open`})]}),D.type===`directory`&&(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>k(()=>T(D.path)),children:[(0,W.jsx)(oe,{}),(0,W.jsx)(`span`,{children:`Open folder`})]}),(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>k(()=>ie([D])),children:[(0,W.jsx)(_,{}),(0,W.jsx)(`span`,{children:`Move to…`})]}),(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>k(()=>m({mode:`rename`,entry:D})),children:[(0,W.jsx)(g,{}),(0,W.jsx)(`span`,{children:`Rename`})]}),e.fileClipboardAvailable&&(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>k(()=>{e.onCopyEntries([D])}),children:[(0,W.jsx)(y,{}),(0,W.jsx)(`span`,{children:`Copy`})]}),e.fileClipboardAvailable&&(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>k(()=>{e.onCutEntries([D])}),children:[(0,W.jsx)(H,{}),(0,W.jsx)(`span`,{children:`Cut`})]}),(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>k(()=>{e.onCopyPath([D])}),children:[(0,W.jsx)(y,{}),(0,W.jsx)(`span`,{children:`Copy path`})]}),D.type===`file`&&(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>k(()=>{e.onCopyContents(D)}),children:[(0,W.jsx)(y,{}),(0,W.jsx)(`span`,{children:`Copy contents`})]}),e.revealAvailable&&(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>k(()=>{e.onReveal(D)}),children:[(0,W.jsx)(pe,{}),(0,W.jsx)(`span`,{children:`Reveal in file manager`})]}),e.fileClipboardAvailable&&(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>k(()=>{e.onPaste(D.type===`directory`?D.path:j(D.path))}),children:[(0,W.jsx)(Ee,{}),(0,W.jsx)(`span`,{children:`Paste here`})]}),(0,W.jsxs)(`button`,{className:`mobile-sheet-action destructive`,disabled:e.readOnly,onClick:()=>k(()=>{e.onDeleteEntries([D])}),children:[(0,W.jsx)(ae,{}),(0,W.jsx)(`span`,{children:`Delete`})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>k(e.onQuickOpen),children:[(0,W.jsx)(ne,{}),(0,W.jsx)(`span`,{children:`Find file in repository`})]}),(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>k(()=>m({mode:`new-file`,entry:fe})),children:[(0,W.jsx)(De,{}),(0,W.jsx)(`span`,{children:`New file`})]}),(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>k(()=>m({mode:`new-folder`,entry:fe})),children:[(0,W.jsx)(ee,{}),(0,W.jsx)(`span`,{children:`New folder`})]}),e.fileClipboardAvailable&&(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>k(()=>{e.onPaste(t)}),children:[(0,W.jsx)(Ee,{}),(0,W.jsx)(`span`,{children:`Paste here`})]}),(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly||!e.historyState.canUndo,onClick:()=>k(()=>{e.onUndo()}),children:[(0,W.jsx)(z,{}),(0,W.jsx)(`span`,{children:e.historyState.undoLabel?`Undo ${e.historyState.undoLabel}`:`Undo`})]}),(0,W.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly||!e.historyState.canRedo,onClick:()=>k(()=>{e.onRedo()}),children:[(0,W.jsx)(B,{}),(0,W.jsx)(`span`,{children:e.historyState.redoLabel?`Redo ${e.historyState.redoLabel}`:`Redo`})]})]})}),(0,W.jsx)(Me,{state:f,onClose:()=>m(null),onRename:e.onRename,onCreate:e.onCreate}),b&&(0,W.jsx)(Pe,{entries:b,initialDirectory:t,revision:e.filesSnapshotRevision,readOnly:e.readOnly,onLoadDirectory:e.onLoadDirectory,onMove:e.onMoveEntries,onClose:()=>{ie(null),c(new Map)}})]})}function Le(e){return le()?(0,W.jsx)(Ie,{...e}):(0,W.jsx)(q,{...e})}var Re=29,ze=6,Be=`files-tree-root-drop`,Ve=550,He={duration:160,easing:`cubic-bezier(0.2, 0, 0, 1)`},Ue=6,We=e=>{let t=b(e),n=t.length>0?t:w(e),r=n.find(e=>e.id!==Be);return r?[r]:n.slice(0,1)};function Ge(e,t,n=0){let r=[];for(let i of e)r.push({entry:i,depth:n}),i.type===`directory`&&t.has(i.path)&&r.push(...Ge(i.children,t,n+1));return r}function Ke(e,t,n){let r=e.findIndex(e=>e.entry.path===t),i=e.findIndex(e=>e.entry.path===n);if(r===-1||i===-1)return[n];let[a,o]=r<=i?[r,i]:[i,r];return e.slice(a,o+1).map(e=>e.entry.path)}function qe(e){return e.type===`directory`?e.path:j(e.path)}function q({active:e,initialExpandedPaths:t,files:n,filesSnapshotRevision:r,showDotEnvFiles:i,activePath:a,readOnly:o,fileClipboardAvailable:s,revealAvailable:c,historyState:l,onQuickOpen:u,onUndo:f,onRedo:m,onOpenFile:h,onLoadDirectory:g,onPersistExpandedPaths:_,onCopyPath:y,onCopyEntries:b,onCutEntries:ae,onCopyContents:oe,onPaste:S,onMoveEntries:se,onDeleteEntries:C,onReveal:ce,onRename:w,onCreate:de}){let pe=ie(),O=le(),[A,ge]=(0,U.useState)(!1),M=O?44:Re,N=(0,U.useRef)(null),xe=(0,U.useRef)(null),[P,F]=(0,U.useState)(new Set),[I,R]=(0,U.useState)(a),[z,B]=(0,U.useState)(a),[V,H]=(0,U.useState)(()=>new Set(t)),[ke,Ae]=(0,U.useState)([]),[je,G]=(0,U.useState)(null),[K,Ne]=(0,U.useState)(null),[Pe,Fe]=(0,U.useState)(null),[Ie,Le]=(0,U.useState)(!1),[Be,q]=(0,U.useState)(null),[et,tt]=(0,U.useState)(0),[J,nt]=(0,U.useState)(new Map),rt=Se(ye(T,{activationConstraint:{distance:5}}),ye(ue)),it=(0,U.useRef)(J),at=(0,U.useRef)(new Set),ot=(0,U.useRef)(0),Y=(0,U.useRef)(null),st=(0,U.useRef)(null),ct=(0,U.useRef)(t.join(`\0`)),lt=(0,U.useMemo)(()=>new Set(J.keys()),[J]),X=(0,U.useMemo)(()=>n===null?null:ve(n,J),[n,J]),Z=(0,U.useMemo)(()=>X===null?null:i?X:_e(X),[X,i]);(0,U.useEffect)(()=>{it.current=J},[J]),(0,U.useEffect)(()=>{Fe(document.getElementById(D))},[a]),(0,U.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>Le(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,U.useEffect)(()=>()=>{Y.current&&clearTimeout(Y.current)},[]),(0,U.useEffect)(()=>{let e=++ot.current,t=[...it.current.keys()];t.length!==0&&Promise.all(t.map(async e=>({path:e,children:await g(e)}))).then(t=>{if(e!==ot.current)return;let n=new Map(t.map(({path:e,children:t})=>[e,t]));nt(e=>Te(e,n))})},[r,g]),(0,U.useEffect)(()=>{X?H(e=>{let t=new Set(we(X,e,lt).retained);return Ze(e,t)?e:t}):(at.current.clear(),nt(e=>e.size===0?e:new Map))},[lt,X]),(0,U.useEffect)(()=>{if(!X)return;let e=E(X,V,lt),t=e.join(`\0`);t!==ct.current&&(ct.current=t,_(e))},[V,lt,X,_]),(0,U.useEffect)(()=>{if(!e||!Z)return;let t=Math.max(0,2-at.current.size);for(let e of V){if(t===0)break;let n=L(Z,e);n&&n.type===`directory`&&n.ignored===!0&&(n.children.length>0||J.has(e)||at.current.has(e)||(at.current.add(e),--t,g(e).catch(()=>[]).then(t=>{nt(n=>new Map(n).set(e,t))}).finally(()=>{at.current.delete(e)})))}},[e,V,J,g,Z]),(0,U.useEffect)(()=>{e||(q(null),Ae([]),G(null),Ne(null),Y.current&&clearTimeout(Y.current),Y.current=null,st.current=null)},[e]),(0,U.useEffect)(()=>{Z&&(F(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>L(Z,e)));return t.size===e.size?e:t}),R(e=>e&&L(Z,e)?e:null),B(e=>e&&L(Z,e)?e:a&&L(Z,a)?a:null))},[a,Z]);let Q=(0,U.useMemo)(()=>Z?Ge(Z,V):[],[V,Z]),$=d({enabled:e,count:Q.length,getScrollElement:()=>N.current,estimateSize:()=>M,getItemKey:e=>Q[e]?.entry.path??e,overscan:12,paddingStart:ze,paddingEnd:12});(0,U.useEffect)(()=>{$.measure()},[$,M]),(0,U.useEffect)(()=>{e&&a&&Z&&L(Z,a)&&H(e=>{let t=new Set(e),n=!1,r=a.split(`/`),i=``;for(let e=0;e<r.length-1;e+=1)i=i?`${i}/${r[e]}`:r[e],t.has(i)||(t.add(i),n=!0);return n?t:e})},[e,a,Z]),(0,U.useEffect)(()=>{if(!e)return;if(!a){xe.current=null;return}if(xe.current===a)return;let t=Q.findIndex(e=>e.entry.path===a);t>=0&&($.scrollToIndex(t,{align:`auto`}),xe.current=a)},[e,a,Q]);let ut=(0,U.useMemo)(()=>{let e=new Map;for(let t of Q)e.set(t.entry.path,t);return e},[Q]),dt=(0,U.useMemo)(()=>{let e={headers:[],push:0};if(Q.length===0||!a)return e;let t=new Set,n=a.split(`/`),r=``;for(let e=0;e<n.length-1;e+=1)r=r?`${r}/${n[e]}`:n[e],t.add(r);if(t.size===0)return e;let i=Math.min(Q.length-1,Math.max(0,Math.floor((et-ze)/M))),o=Q[i];if(!o)return e;let s=o.entry.path.split(`/`),c=[],l=``;for(let e=0;e<s.length-1;e+=1){if(l=l?`${l}/${s[e]}`:s[e],!t.has(l))continue;let n=ut.get(l);n&&n.entry.type===`directory`&&c.push(n)}if(c.length>Ue&&c.splice(0,c.length-Ue),c.length===0)return e;let u=c[c.length-1],d=c.length*M,f=1/0,p=Math.ceil((et+d-ze)/M)+2;for(let e=i;e<Q.length&&e<=p;e+=1)if(Q[e].depth<=u.depth){f=ze+e*M;break}return{headers:c,push:Math.max(0,Math.min(M,d-(f-et)))}},[Q,ut,et,a,M]);if(Z===null)return(0,W.jsxs)(`div`,{className:`view-loading`,role:`status`,hidden:!e,children:[(0,W.jsx)(te,{className:`spinner`,"aria-hidden":`true`}),(0,W.jsx)(p,{text:`Loading files…`})]});let ft=A||P.size>0?P:a?new Set([a]):new Set,pt=P.size>0?[...P]:a?[a]:[],mt=e=>{let t=[];for(let n of e){let e=L(Z,n);e&&t.push(e)}return t},ht=e=>{F(new Set([e])),R(e),B(e)},gt=e=>{let t=Q.findIndex(t=>t.entry.path===e.path);t>=0&&$.scrollToIndex(t,{align:`start`})},_t=(e,t)=>{if(O&&A)F(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n});else if(t.shift&&(I||z)){let t=Ke(Q,I??z,e.path);F(new Set(t)),B(e.path)}else t.ctrl?(F(t=>{let n=new Set(t.size===0&&a?[a]:t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),R(e.path),B(e.path),e.type===`file`&&h(e.path,`pinned`)):(ht(e.path),e.type===`file`?h(e.path):Ct(e.path))},vt=e=>{!(O&&A)&&e.type===`file`&&h(e.path,`pinned`)},yt=e=>{P.has(e.path)||ht(e.path)},bt=e=>P.has(e.path)&&P.size>0?mt(P):[e],xt=e=>{if(me(e.target))return;let t=k(e.nativeEvent,pe);if(t===`undo`&&l.canUndo&&!o){e.preventDefault(),e.repeat||f();return}if(t===`redo`&&l.canRedo&&!o){e.preventDefault(),e.repeat||m();return}let n=(e.ctrlKey||e.metaKey)&&!e.altKey,r=e.key.toLowerCase();if(n&&r===`a`){e.preventDefault(),F(new Set(Q.map(e=>e.entry.path)));return}let i=mt(pt),a=z?L(Z,z):null;if(n&&r===`c`&&i.length)e.preventDefault(),b(i);else if(n&&r===`x`&&i.length&&!o)e.preventDefault(),ae(i);else if(n&&r===`v`&&!o&&s)e.preventDefault(),S(a?qe(a):j(i[0]?.path??``));else if(e.key===`F2`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!o){if(P.size===1){let t=L(Z,[...P][0]);t&&(e.preventDefault(),q({mode:`rename`,entry:t}))}}else e.key===`Delete`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!o&&i.length&&(e.preventDefault(),C(i))},St=async(e,t)=>{let n=mt(e);n.length&&await se(n,t)},Ct=(e,t=!1)=>{let n=!t&&V.has(e),r=n&&L(Z??[],e)?.ignored===!0;H(n=>{let i=new Set(n);if(t||!i.has(e)){if(i.has(e))return n;i.add(e)}else if(r)for(let t of i)he(e,t)&&i.delete(t);else i.delete(e);return Ze(n,i)?n:i}),n&&nt(t=>{let n=[...t.keys()].filter(t=>he(e,t));if(n.length===0)return t;let r=new Map(t);for(let e of n)r.delete(e);return r})},wt=()=>{Y.current&&clearTimeout(Y.current),Y.current=null,st.current=null},Tt=()=>{wt(),Ae([]),G(null),Ne(null)},Et=e=>{let t=e.active.data.current;return t?.entry&&Array.isArray(t.sourcePaths)?{entry:t.entry,sourcePaths:t.sourcePaths}:null};return(0,W.jsxs)(x,{sensors:rt,collisionDetection:We,autoScroll:{enabled:!0,threshold:{x:.1,y:.16},acceleration:12},onDragStart:e=>{let t=Et(e);t&&(P.has(t.entry.path)||ht(t.entry.path),Ae(t.sourcePaths),Ne({entry:t.entry,sourcePaths:t.sourcePaths,count:t.sourcePaths.length}))},onDragOver:e=>{let t=Et(e);if(e.over?.data.current?.openPinned===!0){G(null),wt();return}let n=e.over?.data.current?.targetDirectory;if(!t||typeof n!=`string`||!be(t.sourcePaths,n)){G(null),wt();return}G(n);let r=e.over?.data.current?.expandPath;typeof r!=`string`||V.has(r)?wt():st.current!==r&&(wt(),st.current=r,Y.current=setTimeout(()=>{Ct(r,!0),Y.current=null,st.current=null},Ve))},onDragCancel:Tt,onDragEnd:e=>{let t=Et(e),n=e.over?.data.current?.openPinned===!0,r=e.over?.data.current?.targetDirectory;Tt(),t&&n&&Ce(t.entry,t.sourcePaths)?h(t.entry.path,`pinned`):t&&typeof r==`string`&&be(t.sourcePaths,r)&&St(t.sourcePaths,r)},children:[(0,W.jsxs)(`div`,{className:`files-mobile-tools`,children:[(0,W.jsxs)(v,{variant:`ghost`,size:`sm`,onClick:u,children:[(0,W.jsx)(ne,{}),` Find file`]}),(0,W.jsx)(v,{variant:`ghost`,size:`sm`,"aria-pressed":A,onClick:()=>{ge(!A),F(new Set)},children:A?`Done (${P.size})`:`Select`}),(0,W.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:o,onClick:()=>q({mode:`new-file`,entry:{type:`directory`,path:``,name:``,children:[]}}),children:[(0,W.jsx)(De,{}),` New file`]}),(0,W.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:o,onClick:()=>q({mode:`new-folder`,entry:{type:`directory`,path:``,name:``,children:[]}}),children:[(0,W.jsx)(ee,{}),` Folder`]}),s&&(0,W.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:o,onClick:()=>void S(``),children:[(0,W.jsx)(Ee,{}),` Paste`]})]}),(0,W.jsxs)(`div`,{ref:N,className:`files-view virtual-scroll`,hidden:!e,onScroll:e=>tt(e.currentTarget.scrollTop),children:[dt.headers.length>0&&(0,W.jsx)(`div`,{className:`files-sticky`,children:dt.headers.map((e,t)=>{let n=t===dt.headers.length-1;return(0,W.jsxs)(`button`,{type:`button`,className:`file-tree-row files-sticky-row`,"aria-label":`Scroll to ${e.entry.path}`,style:{top:t*M-(n?dt.push:0),paddingLeft:12+e.depth*14,zIndex:dt.headers.length-t},onClick:()=>gt(e.entry),children:[(0,W.jsx)(re,{className:`folder-chevron open`}),(0,W.jsx)($e,{path:e.entry.path,type:`directory`,expanded:!0}),(0,W.jsx)(`span`,{children:e.entry.name})]},e.entry.path)})}),Z.length?(0,W.jsx)(Je,{role:`tree`,"aria-label":`Files`,className:`files-tree ${je===``&&ke.length>0?`root-drop-target`:``}`,style:{height:$.getTotalSize()},tabIndex:0,onKeyDown:xt,onPointerDown:e=>{e.target.closest(`.file-tree-row, .file-touch-actions`)||(F(new Set),R(null),B(null),e.currentTarget.focus())},children:$.getVirtualItems().map(e=>{let{entry:t,depth:n}=Q[e.index],r=t.type===`directory`&&V.has(t.path),i=P.has(t.path)&&P.size>1;return(0,W.jsx)(`div`,{className:`virtual-row`,style:{height:e.size,transform:`translateY(${e.start}px)`},children:(0,W.jsx)(Qe,{entry:t,depth:n,expanded:r,pendingChildren:t.type===`directory`&&t.ignored===!0&&t.children.length===0&&!J.has(t.path),selected:ft.has(t.path),active:a===t.path,multiSelected:i,readOnly:o,fileClipboardAvailable:s,revealAvailable:c,historyState:l,onUndo:f,onRedo:m,draggedPaths:ke,dropTargetPath:je,onFocus:B,onRowClick:_t,onRowDoubleClick:vt,onRowContextMenu:yt,onOpen:e=>h(e.path),onOpenPinned:e=>h(e.path,`pinned`),onCopy:e=>void b(bt(e)),onCut:e=>void ae(bt(e)),onPasteInto:e=>void S(qe(e)),onCopyPath:e=>void y(bt(e)),onCopyContents:oe,onRename:e=>q({mode:`rename`,entry:e}),onNewFile:e=>q({mode:`new-file`,entry:e}),onNewFolder:e=>q({mode:`new-folder`,entry:e}),onReveal:ce,onDelete:e=>void C(bt(e)),dragPaths:P.has(t.path)&&P.size>0?[...P]:[t.path]})},e.key)})}):(0,W.jsx)(`p`,{className:`empty-list`,children:`No files.`}),(0,W.jsx)(Me,{state:Be,onClose:()=>q(null),onRename:w,onCreate:de})]}),(0,W.jsx)(fe,{dropAnimation:Ie?null:He,children:K&&(0,W.jsx)(Xe,{preview:K})}),Pe&&(0,Oe.createPortal)((0,W.jsx)(Ye,{visible:!!(K&&Ce(K.entry,K.sourcePaths))}),Pe)]})}function Je(e){let{setNodeRef:t}=I({id:Be,data:{targetDirectory:``,expandPath:null}});return(0,W.jsx)(`div`,{ref:t,...e})}function Ye({visible:e}){let{isOver:t,setNodeRef:n}=I({id:`files-open-pinned-drop`,data:{openPinned:!0}});return(0,W.jsxs)(`div`,{ref:n,className:`open-files-drop-target ${e?`visible`:``} ${e&&t?`over`:``}`,"aria-hidden":`true`,children:[(0,W.jsx)(V,{}),(0,W.jsx)(`span`,{children:`Drop to open beside`})]})}function Xe({preview:e}){return(0,W.jsxs)(`div`,{className:`file-drag-overlay`,children:[(0,W.jsx)($e,{path:e.entry.path,type:e.entry.type,expanded:!1}),(0,W.jsx)(`span`,{children:e.entry.name}),e.count>1&&(0,W.jsx)(`strong`,{children:e.count})]})}function Ze(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Qe({entry:e,depth:t,expanded:n,pendingChildren:r,selected:i,active:a,multiSelected:o,readOnly:s,fileClipboardAvailable:c,revealAvailable:l,historyState:u,onUndo:d,onRedo:f,draggedPaths:p,dropTargetPath:m,onFocus:h,onRowClick:_,onRowDoubleClick:te,onRowContextMenu:ne,onOpen:v,onOpenPinned:b,onCopy:ie,onCut:oe,onPasteInto:x,onCopyPath:C,onCopyContents:ce,onRename:w,onNewFile:le,onNewFolder:T,onReveal:ue,onDelete:fe,dragPaths:E}){let D=(0,U.useRef)(null),O=qe(e),{attributes:k,listeners:me,setNodeRef:j,isDragging:ge}=A({id:`file-drag:${e.path}`,data:{sourcePaths:E,entry:e},disabled:s}),{setNodeRef:M}=I({id:`file-drop:${e.path}`,data:{targetDirectory:O,expandPath:e.type===`directory`?e.path:null}}),_e=e=>{D.current=e,j(e),M(e)},N=p.length>0&&e.type===`directory`&&m===e.path,ve=p.length>0&&m!==null&&m!==``&&m!==e.path&&he(m,e.path),ye=(0,W.jsxs)(`button`,{type:`button`,ref:_e,...k,role:`treeitem`,"aria-selected":i,"aria-current":a?`true`:void 0,"aria-expanded":e.type===`directory`?n:void 0,className:[`file-tree-row`,e.ignored?`ignored-file`:``,p.includes(e.path)||ge?`dragging`:``,N?`drop-target`:``,ve?`drop-target-region`:``].filter(Boolean).join(` `),style:{paddingLeft:12+t*14},...me,onClick:t=>_(e,{ctrl:t.ctrlKey||t.metaKey,shift:t.shiftKey}),onDoubleClick:()=>te(e),onFocus:()=>h(e.path),onContextMenu:()=>ne(e),children:[e.type===`directory`?(0,W.jsx)(re,{className:`folder-chevron ${n?`open`:``} ${e.children.length===0&&!r?`empty`:``}`}):(0,W.jsx)(`span`,{className:`tree-spacer`}),(0,W.jsx)($e,{path:e.path,type:e.type,expanded:n}),(0,W.jsx)(`span`,{children:e.name})]});return(0,W.jsxs)(ke,{children:[(0,W.jsx)(Ae,{render:ye}),(0,W.jsx)(`button`,{type:`button`,className:`file-touch-actions`,"aria-label":`Actions for ${e.name}`,"aria-haspopup":`menu`,onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();D.current?.dispatchEvent(new MouseEvent(`contextmenu`,{bubbles:!0,cancelable:!0,clientX:t.left,clientY:t.bottom}))},children:(0,W.jsx)(de,{})}),(0,W.jsxs)(je,{children:[e.type===`file`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(G,{onClick:()=>v(e),children:[(0,W.jsx)(S,{"aria-hidden":`true`}),` Open`]}),(0,W.jsxs)(G,{onClick:()=>b(e),children:[(0,W.jsx)(V,{"aria-hidden":`true`}),` Open to the Side `,(0,W.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+Click`})]}),(0,W.jsx)(K,{})]}),(0,W.jsxs)(G,{disabled:s||!u.canUndo,onClick:()=>void d(),children:[(0,W.jsx)(z,{"aria-hidden":`true`}),` `,u.undoLabel?`Undo ${u.undoLabel}`:`Undo`,` `,(0,W.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+Z`})]}),(0,W.jsxs)(G,{disabled:s||!u.canRedo,onClick:()=>void f(),children:[(0,W.jsx)(B,{"aria-hidden":`true`}),` `,u.redoLabel?`Redo ${u.redoLabel}`:`Redo`,` `,(0,W.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+Shift+Z`})]}),(0,W.jsx)(K,{}),(0,W.jsxs)(G,{onClick:()=>ie(e),children:[(0,W.jsx)(se,{"aria-hidden":`true`}),` Copy `,(0,W.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+C`})]}),(0,W.jsxs)(G,{disabled:s,onClick:()=>oe(e),children:[(0,W.jsx)(H,{"aria-hidden":`true`}),` Cut `,(0,W.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+X`})]}),c&&(0,W.jsxs)(G,{disabled:s,onClick:()=>x(e),children:[(0,W.jsx)(Ee,{"aria-hidden":`true`}),` Paste `,(0,W.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+V`})]}),(0,W.jsx)(K,{}),(0,W.jsxs)(G,{disabled:s||o,onClick:()=>w(e),children:[(0,W.jsx)(g,{"aria-hidden":`true`}),` Rename `,(0,W.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`F2`})]}),(0,W.jsxs)(G,{disabled:s||o,onClick:()=>le(e),children:[(0,W.jsx)(De,{"aria-hidden":`true`}),` New File…`]}),(0,W.jsxs)(G,{disabled:s||o,onClick:()=>T(e),children:[(0,W.jsx)(ee,{"aria-hidden":`true`}),` New Folder…`]}),(0,W.jsx)(K,{}),(0,W.jsxs)(G,{onClick:()=>C(e),children:[(0,W.jsx)(P,{"aria-hidden":`true`}),` Copy path`]}),(0,W.jsxs)(G,{disabled:e.type!==`file`||o,onClick:()=>void ce(e),children:[(0,W.jsx)(y,{"aria-hidden":`true`}),` Copy contents`]}),l&&(0,W.jsxs)(G,{disabled:o,onClick:()=>void ue(e),children:[(0,W.jsx)(pe,{"aria-hidden":`true`}),` Reveal in File Explorer`]}),(0,W.jsx)(K,{}),(0,W.jsxs)(G,{className:`text-destructive data-highlighted:text-destructive`,disabled:s,onClick:()=>fe(e),children:[(0,W.jsx)(ae,{"aria-hidden":`true`}),` Delete `,(0,W.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Del`})]})]})]})}function $e({path:e,type:t,expanded:n=!1}){let r=t===`file`?xe(e):N(e,n);return(0,W.jsx)(`img`,{className:`vscode-tree-icon`,src:r,alt:``,"aria-hidden":`true`})}export{Le as FilesView};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{t as r}from"./createReactComponent-Ctub7J3a.js";var i=r(`outline`,`circle-check`,`CircleCheck`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 12l2 2l4 -4`,key:`svg-1`}]]),a=r(`outline`,`circle-x`,`CircleX`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M10 10l4 4m0 -4l-4 4`,key:`svg-1`}]]),o=r(`outline`,`user-circle`,`UserCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 10a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-1`}],[`path`,{d:`M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855`,key:`svg-2`}]]),s=e(t()),c=n();function l({src:e,className:t}){let[n,r]=(0,s.useState)(!1);return(0,c.jsx)(`span`,{className:t,"aria-hidden":`true`,children:e&&!n?(0,c.jsx)(`img`,{src:e,alt:``,onError:()=>r(!0)}):(0,c.jsx)(o,{})})}export{a as n,i as r,l as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{o as r}from"./tanstack-CVAt_k_T.js";import{n as i}from"./createReactComponent-Ctub7J3a.js";import{t as a}from"./IconGitPullRequest-ClaUqyVa.js";import{t as o}from"./IconLoader4-D2VN7u1V.js";import{t as s}from"./IconSearch-1VQ4P4kW.js";import{S as c,T as l,g as u,h as d,k as f,l as p,v as m}from"./index-DsKvWsTs.js";import{$t as h,Dt as g,Et as _,Lt as v,S as y,a as b,i as x,l as S,nn as C,p as w}from"./App-Bfw_TX8q.js";import{t as ee}from"./LinkedText-BD6K3d1t.js";var T=e(t());function E(e){let t=[],n=e.some(e=>e.color!==void 0)?3:0,r=1,i=new Map,a=[],o=new Map(e.map(e=>[e.oid,e])),s=new Set,c=e[0];for(;c&&!s.has(c.oid);)s.add(c.oid),c.color!==void 0&&i.set(c.oid,c.color),c=o.get(c.parentOids[0]??``);for(let o of e){let e=t.indexOf(o.oid),s=e>=0;e<0&&(e=t.length,t=[...t,o.oid]);let c=t,l=D(i,o.oid,()=>o.color??n++),u=l<3?o.color??l:l;i.set(o.oid,u);let d=c.filter((t,n)=>n!==e),f=Math.min(e,d.length);o.parentOids.forEach((e,t)=>{i.has(e)||i.set(e,t===0?u:n++),!d.includes(e)&&(d.splice(f,0,e),f+=1)});let p=[];c.forEach((t,n)=>{if(n===e){s&&p.push({fromLane:n,from:`top`,toLane:e,to:`node`,color:l});return}let r=d.indexOf(t);r>=0&&p.push({fromLane:n,from:`top`,toLane:r,to:`bottom`,color:i.get(t)??0})}),o.parentOids.forEach(t=>{let n=d.indexOf(t);n>=0&&p.push({fromLane:e,from:`node`,toLane:n,to:`bottom`,color:i.get(t)??u})}),r=Math.max(r,c.length,d.length),a.push({lane:e,color:u,segments:p,continuations:d.map((e,t)=>({lane:t,color:i.get(e)??0}))}),t=d}return{rows:a,laneCount:r}}function D(e,t,n){let r=e.get(t);if(r!==void 0)return r;let i=n();return e.set(t,i),i}function O(e){let t=e.parentCount>1&&/^Merge pull request #(\d+)\b/i.exec(e.subject),n=/\(#(\d+)\)\s*$/.exec(e.subject),r=t||n;if(!r)return null;let i=Number(r[1]);return Number.isSafeInteger(i)&&i>0?{number:i,source:t?`merge`:`subject`}:null}function k(e){if(e.upstreamState===`local-only`)return 0;if(e.baseState===`included`)return 2;if(e.upstreamState===`published`)return 1}function A(e,t){if(!t)return e.map(e=>({commit:e,parentOids:e.parentOids,grouped:[]}));let n=new Map(e.map(e=>[e.oid,e])),r=new Map;e.forEach(e=>e.parentOids.forEach(t=>{let n=r.get(t)??new Set;n.add(e.oid),r.set(t,n)}));let i=new Set,a=[];for(let t of e){if(i.has(t.oid))continue;let e={commit:t,parentOids:t.parentOids,grouped:[]};if(a.push(e),t.parentOids.length!==2)continue;let o=new Set,s=n.get(t.parentOids[0]);for(;s&&!o.has(s.oid);)o.add(s.oid),s=n.get(s.parentOids[0]??``);let c=t.parentOids[1],l=[],u=new Set;for(;!o.has(c);){let e=n.get(c);if(!e||u.has(c)||i.has(c)||e.isHead||e.parentOids.length!==1)break;u.add(c),l.push(e),c=e.parentOids[0]}if(!o.has(c)||l.length===0)continue;let d=new Set([t.oid,...l.map(e=>e.oid)]);l.some(e=>[...r.get(e.oid)??[]].some(e=>!d.has(e)))||l.some(e=>a.some(t=>t.commit.oid===e.oid))||(e.grouped=l,e.parentOids=[t.parentOids[0]],l.forEach(e=>i.add(e.oid)))}return a}function j(e,t){let n=t.trim().toLocaleLowerCase();return n.length>0&&[e.subject,e.author,e.oid,...e.decorations].some(e=>e.toLocaleLowerCase().includes(n))}var M=n();function N({repositoryId:e,upstream:t,readOnly:n,operation:a,canPublish:c,pushBusy:f,onPublish:p,commits:h,nextCursor:g,loading:_,undoing:v,baseRef:b,activeOid:x,onSelectReference:S,onSelectCommit:w,onSelectFile:ee,onUndo:D,onMore:O}){let N=y(),F=(0,T.useRef)(null),[I,R]=(0,T.useState)(new Set),[z,B]=(0,T.useState)(!0),[V,H]=(0,T.useState)(!1),[U,W]=(0,T.useState)(``),[te,G]=(0,T.useState)(-1),K=N?52:z?42:56,q=(0,T.useMemo)(()=>A(h??[],V&&!U.trim()),[h,V,U]),J=(0,T.useMemo)(()=>E(q.map(({commit:e,parentOids:t})=>({oid:e.oid,parentOids:t,color:k(e)}))),[q]),Y=(0,T.useMemo)(()=>q.flatMap(({commit:e},t)=>j(e,U)?[t]:[]),[q,U]),X=L(J.laneCount),Z=r({count:q.length,getScrollElement:()=>F.current,estimateSize:()=>K,getItemKey:e=>q[e].commit.oid,overscan:8});(0,T.useEffect)(()=>{Z.measure()},[Z,K]);let Q=()=>{if(!Y.length)return;let e=(te+1)%Y.length;G(e),Z.scrollToIndex(Y[e],{align:`center`})};if(h===null)return(0,M.jsxs)(`div`,{className:`view-loading`,role:`status`,children:[(0,M.jsx)(o,{className:`spinner`}),` `,(0,M.jsx)(i,{text:`Loading history…`})]});let $=h.filter(e=>e.upstreamState===`local-only`).length;return(0,M.jsxs)(`div`,{className:`history-list`,style:{"--history-row-height":`${K}px`},children:[(0,M.jsxs)(`div`,{className:`history-toolbar`,children:[(0,M.jsxs)(`label`,{className:`history-search`,children:[(0,M.jsx)(s,{"aria-hidden":`true`}),(0,M.jsx)(`input`,{type:`search`,"aria-label":`Search loaded commits`,placeholder:`Find commit…`,value:U,onChange:e=>{W(e.target.value),G(-1)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Q())}})]}),U&&(0,M.jsxs)(d,{children:[(0,M.jsx)(m,{render:(0,M.jsx)(`button`,{className:`history-next-match`,onClick:Q,disabled:!Y.length,"aria-label":`Next matching commit`}),children:(0,M.jsx)(C,{})}),(0,M.jsx)(u,{children:`Next match in loaded history (Enter)`})]}),(0,M.jsxs)(d,{children:[(0,M.jsx)(m,{render:(0,M.jsx)(`button`,{className:`history-option`,"aria-pressed":V,disabled:!h.some(e=>e.parentCount>1),onClick:()=>H(!V)}),children:`Group merges`}),(0,M.jsx)(u,{children:`Collapse complete merge branches. Searching reveals their commits.`})]}),!N&&(0,M.jsxs)(d,{children:[(0,M.jsx)(m,{render:(0,M.jsx)(`button`,{className:`history-option`,"aria-pressed":z,onClick:()=>B(!z)}),children:z?`Compact`:`Comfortable`}),(0,M.jsx)(u,{children:`Change row density without moving the diff viewer`})]})]}),!t&&h.length>0&&(0,M.jsxs)(`div`,{className:`history-upstream-notice`,role:`status`,children:[(0,M.jsx)(`span`,{children:`Publish this branch to configure an upstream and distinguish local from published commits.`}),c&&(0,M.jsx)(l,{variant:`outline`,size:`xs`,disabled:f||n||!!a,onClick:p,children:f?(0,M.jsx)(i,{text:`Publishing…`}):`Publish branch`})]}),t&&$>0&&(0,M.jsxs)(`div`,{className:`history-local-summary`,children:[`↑ `,$,` `,$===1?`local commit`:`local commits`,` in loaded history`]}),(0,M.jsx)(`div`,{ref:F,className:`history-scroll`,role:`list`,"aria-label":`Commit history`,children:q.length===0?(0,M.jsx)(`p`,{className:`empty-list`,children:`This repository has no commits yet.`}):(0,M.jsxs)(`div`,{className:`virtual-list`,style:{height:Z.getTotalSize()+(g?52:0)},children:[Z.getVirtualItems().map(r=>{let{commit:i,grouped:o}=q[r.index];return(0,M.jsx)(`div`,{ref:Z.measureElement,"data-index":r.index,className:`virtual-row`,style:{transform:`translateY(${r.start}px)`},children:(0,M.jsx)(P,{repositoryId:e,upstream:t,baseRef:b,commit:i,graphRow:J.rows[r.index],graphWidth:X,rowHeight:K,active:x===i.oid||o.some(e=>e.oid===x),match:j(i,U),groupedCount:o.length,onRevealGroup:()=>H(!1),onSelectReference:S,expanded:I.has(i.oid),onExpandedChange:e=>R(t=>{let n=new Set(t);return e?n.add(i.oid):n.delete(i.oid),n}),canUndo:!n&&!a&&!v&&i.upstreamState===`local-only`&&i.isHead&&i.parentCount===1,onSelectCommit:w,onSelectFile:ee,onUndo:D})},r.key)}),g&&(0,M.jsx)(l,{variant:`ghost`,className:`history-more`,style:{top:Z.getTotalSize()},disabled:_,onClick:O,children:_?(0,M.jsx)(i,{text:`Loading…`}):`Load more`})]})}),h.length>0&&(0,M.jsxs)(`div`,{className:`history-legend`,children:[(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`i`,{"data-color":`local`}),`Local`]}),(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`i`,{"data-color":`published`}),`Published`]}),b&&(0,M.jsxs)(d,{children:[(0,M.jsxs)(m,{render:(0,M.jsx)(`span`,{className:`history-base-label`}),children:[(0,M.jsx)(`i`,{"data-color":`base`}),b]}),(0,M.jsxs)(u,{children:[`Primary-line commits reachable from `,b,`, using the latest known local refs. Side branches use the published color.`]})]}),(0,M.jsx)(`span`,{className:`history-count`,role:`status`,children:U?`${Y.length} matches in ${h.length} loaded`:`${h.length} loaded`})]})]})}function P({repositoryId:e,upstream:t,baseRef:n,commit:r,graphRow:s,graphWidth:y,rowHeight:S,active:C,match:w,groupedCount:E,onRevealGroup:D,onSelectReference:k,expanded:A,onExpandedChange:j,canUndo:N,onSelectCommit:P,onSelectFile:F,onUndo:I}){let L=`${e}:${r.oid}`,[R,z]=(0,T.useState)(()=>x(L)??null),[W,G]=(0,T.useState)(null);(0,T.useEffect)(()=>{if(!A||R||W)return;let t=!0;return p.commits.files(e,r.oid).then(e=>{t&&(b(L,e),z(e))}).catch(e=>{t&&G(te(e))}),()=>{t=!1}},[L,r.oid,A,R,W,e]);let K=O(r),q=U(r.decorations),J=q.slice(0,3),Y=q.slice(3),X=R?.reduce((e,t)=>e+t.additions,0)??0,Z=R?.reduce((e,t)=>e+t.deletions,0)??0,Q=async()=>{try{await c(r.oid),f.success({title:`Hash copied`,description:r.oid})}catch{f.error({title:`Could not copy hash`})}};return(0,M.jsxs)(`div`,{className:`commit-item${C?` active`:``}${w?` commit-search-match`:``}`,role:`listitem`,children:[(0,M.jsxs)(`div`,{className:`commit-header`,children:[(0,M.jsx)(B,{graph:s,width:y,height:S,merge:r.parentCount>1,head:r.isHead}),(0,M.jsx)(`button`,{className:`commit-expand`,"aria-expanded":A,"aria-label":A?`Collapse commit`:`Expand commit`,onClick:()=>j(!A),children:(0,M.jsx)(h,{className:`folder-chevron ${A?`open`:``}`})}),(0,M.jsxs)(`div`,{className:`commit-main`,children:[(0,M.jsxs)(`span`,{className:`commit-title-row`,children:[(0,M.jsx)(`button`,{className:`commit-subject`,"aria-pressed":C,onClick:()=>P(r),children:r.subject||`(no subject)`}),K&&(0,M.jsxs)(d,{children:[(0,M.jsxs)(m,{render:k?(0,M.jsx)(`button`,{className:`ref-chip commit-pr`,onClick:()=>k(K.number),"aria-label":`Open pull request #${K.number}`}):(0,M.jsx)(`span`,{className:`ref-chip commit-pr`}),children:[(0,M.jsx)(a,{"aria-hidden":`true`}),`#`,K.number]}),(0,M.jsxs)(u,{children:[K.source===`merge`?`Pull request reference from the merge message.`:`Reference from the commit subject; it may identify a pull request or issue.`,k?` Open as a pull request in the right-hand viewer.`:``,` No merge method is inferred from the number.`]})]}),(0,M.jsxs)(d,{children:[(0,M.jsx)(m,{render:(0,M.jsx)(`time`,{className:`commit-date`,dateTime:r.date}),children:_(r.date)}),(0,M.jsx)(u,{children:g(r.date)})]})]}),(0,M.jsxs)(`span`,{className:`commit-meta`,children:[(q.length>0||r.parentCount>1||r.upstreamState===`local-only`)&&(0,M.jsxs)(`span`,{className:`commit-refs`,children:[r.upstreamState===`local-only`&&(0,M.jsxs)(d,{children:[(0,M.jsx)(m,{render:(0,M.jsx)(`span`,{className:`ref-chip local-only`}),children:`Local`}),(0,M.jsx)(u,{children:r.isHead?`Not in ${t??`the upstream`} according to the latest known remote state.`:`Not published. To avoid rewriting multiple commits, only the latest can be undone.`})]}),r.parentCount>1&&(0,M.jsx)(`span`,{className:`ref-chip merge`,children:`merge`}),J.map(e=>(0,M.jsxs)(d,{children:[(0,M.jsx)(m,{render:(0,M.jsx)(`span`,{className:`ref-chip ${e.kind}`,"data-base":e.label===n||e.label.endsWith(`/HEAD`)&&r.baseState===`included`}),children:e.label}),(0,M.jsx)(u,{children:e.label})]},`${e.kind}:${e.label}`)),Y.length>0&&(0,M.jsxs)(d,{children:[(0,M.jsxs)(m,{render:(0,M.jsx)(`span`,{className:`ref-chip more`}),children:[`+`,Y.length]}),(0,M.jsx)(u,{children:Y.map(e=>e.label).join(` · `)})]})]}),(0,M.jsxs)(d,{children:[(0,M.jsx)(m,{render:(0,M.jsx)(`button`,{className:`commit-oid`,onClick:()=>void Q(),"aria-label":`Copiar hash ${r.shortOid}`}),children:r.shortOid}),(0,M.jsx)(u,{children:`Copy full hash`})]}),(0,M.jsxs)(d,{children:[(0,M.jsx)(m,{render:(0,M.jsx)(`span`,{className:`commit-author`}),children:r.author}),(0,M.jsx)(u,{children:r.author})]}),E>0&&(0,M.jsxs)(d,{children:[(0,M.jsxs)(m,{render:(0,M.jsx)(`button`,{className:`commit-group-count`,onClick:D}),children:[E,` grouped`]}),(0,M.jsxs)(u,{children:[`Show the `,E,` commits in this merge branch`]})]})]})]}),N&&(0,M.jsxs)(d,{children:[(0,M.jsx)(m,{render:(0,M.jsx)(l,{variant:`ghost`,size:`icon-xs`,className:`change-action-button commit-undo`,onClick:e=>{e.stopPropagation(),I(r)},"aria-label":`Undo commit ${r.shortOid}`}),children:(0,M.jsx)(v,{})}),(0,M.jsx)(u,{children:`Undo commit and keep its changes staged`})]})]}),A&&s.continuations.length>0&&(0,M.jsx)(V,{graph:s,width:y}),A&&(0,M.jsxs)(`div`,{className:`commit-files`,style:{paddingLeft:y+31},children:[r.body&&(0,M.jsx)(`p`,{className:`commit-description`,children:(0,M.jsx)(ee,{text:r.body})}),W&&(0,M.jsx)(`div`,{className:`commit-files-message error`,children:W}),!R&&!W&&(0,M.jsxs)(`div`,{className:`commit-files-message`,children:[(0,M.jsx)(o,{className:`spinner`}),` `,(0,M.jsx)(i,{text:`Loading files…`})]}),R&&R.length===0&&(0,M.jsx)(`div`,{className:`commit-files-message`,children:r.parentCount>1?`This merge commit has no changes of its own.`:`This commit has no file changes.`}),R&&R.length>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`commit-files-summary`,children:[R.length,` `,R.length===1?`file`:`files`,(X>0||Z>0)&&(0,M.jsxs)(M.Fragment,{children:[` · `,(0,M.jsxs)(`span`,{className:`add`,children:[`+`,X]}),` `,(0,M.jsxs)(`span`,{className:`del`,children:[`−`,Z]})]})]}),R.map(e=>(0,M.jsx)(H,{file:e,onSelect:()=>F(r.oid,e)},e.path))]})]})]})}var F=14,I=[`var(--history-local)`,`var(--history-published)`,`var(--history-base)`];function L(e){return 14+Math.max(0,e-1)*F}function R(e){return 7+e*F}function z(e){return I[e]??`var(--history-published)`}function B({graph:e,width:t,height:n,merge:r,head:i}){let a=n/2;return(0,M.jsxs)(`svg`,{className:`commit-graph`,width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":`true`,children:[e.segments.map((e,t)=>{let r=R(e.fromLane),i=R(e.toLane),o=e.from===`top`?0:a,s=e.to===`node`?a:n,c=(o+s)/2,l=r===i?`M ${r} ${o} L ${i} ${s}`:`M ${r} ${o} C ${r} ${c}, ${i} ${c}, ${i} ${s}`;return(0,M.jsx)(`path`,{d:l,stroke:z(e.color)},`${t}:${l}`)}),(0,M.jsx)(`circle`,{cx:R(e.lane),cy:a,r:r||i?4.5:3,fill:r||i?`var(--sidebar)`:z(e.color),stroke:z(e.color)}),r&&(0,M.jsx)(`circle`,{cx:R(e.lane),cy:a,r:`1.6`,fill:z(e.color)})]})}function V({graph:e,width:t}){return(0,M.jsx)(`svg`,{className:`commit-graph-continuation`,width:t,viewBox:`0 0 ${t} 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:e.continuations.map(e=>(0,M.jsx)(`line`,{x1:R(e.lane),y1:`0`,x2:R(e.lane),y2:`100`,stroke:z(e.color)},e.lane))})}function H({file:e,onSelect:t}){let n=(0,T.useRef)(null),r=e.path.lastIndexOf(`/`),i=r<0?e.path:e.path.slice(r+1),a=e.oldPath?.split(`/`).pop();return(0,M.jsxs)(`div`,{ref:n,className:`commit-file-row`,children:[(0,M.jsxs)(d,{children:[(0,M.jsxs)(m,{render:(0,M.jsx)(`button`,{className:`commit-file-label`,onClick:t,"aria-label":`Ver el diff de ${e.path}`}),children:[(0,M.jsx)(W,{path:e.path,type:`file`}),(0,M.jsxs)(`span`,{className:`commit-file-text`,children:[(0,M.jsx)(`span`,{children:i}),a&&(0,M.jsxs)(`small`,{className:`commit-file-rename`,children:[a,` →`]})]})]}),(0,M.jsx)(u,{anchor:n,side:`right`,sideOffset:10,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path})]}),(0,M.jsx)(`span`,{className:`commit-file-stats`,children:e.binary?(0,M.jsx)(`span`,{className:`binary`,children:`bin`}):(0,M.jsxs)(M.Fragment,{children:[e.additions>0&&(0,M.jsxs)(`span`,{className:`add`,children:[`+`,e.additions]}),e.deletions>0&&(0,M.jsxs)(`span`,{className:`del`,children:[`−`,e.deletions]})]})}),(0,M.jsx)(`span`,{className:`status-code`,"data-kind":e.kind,children:S(e.kind)})]})}function U(e){return e.map(e=>e.startsWith(`tag: `)?{label:e.slice(5),kind:`tag`}:e.startsWith(`HEAD -> `)?{label:e.slice(8),kind:`head`}:e===`HEAD`?{label:`HEAD`,kind:`head`}:{label:e,kind:e.includes(`/`)?`remote`:`branch`})}function W({path:e}){return(0,M.jsx)(`img`,{className:`vscode-tree-icon`,src:w(e),alt:``,"aria-hidden":`true`,draggable:!1})}function te(e){return e instanceof Error?e.message:`An unexpected error occurred.`}export{N as HistoryView};
@@ -0,0 +1,2 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{n as r,r as i,t as a}from"./viewer-tabs-DkkqN9MD.js";import{FileSaveControls as o,FileViewerChrome as s,SourceCodeEditor as c,t as l}from"./EditableFileViewer-Dotntfij.js";var u=e(t()),d=`data-opentig-preview-scrollbar`;function f(e,t){let n=t?`255 255 255`:`0 0 0`,r=[`<style ${d}>`,`html {`,` color-scheme: ${t?`dark`:`light`} !important;`,` background-color: ${t?`oklch(0.13 0 0)`:`oklch(0.985 0 0)`} !important;`,`}`,`html, body, * {`,` scrollbar-width: thin !important;`,` scrollbar-color: rgb(${n} / 18%) transparent !important;`,`}`,`html::-webkit-scrollbar, body::-webkit-scrollbar, *::-webkit-scrollbar { width: 10px !important; height: 10px !important; }`,`html::-webkit-scrollbar-track, body::-webkit-scrollbar-track, *::-webkit-scrollbar-track,`,`html::-webkit-scrollbar-corner, body::-webkit-scrollbar-corner, *::-webkit-scrollbar-corner { background: transparent !important; }`,`html::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb, *::-webkit-scrollbar-thumb {`,` background-color: rgb(${n} / 18%) !important;`,` background-clip: content-box !important;`,` border: 3px solid transparent !important;`,` border-radius: 999px !important;`,`}`,`html::-webkit-scrollbar-thumb:hover, body::-webkit-scrollbar-thumb:hover, *::-webkit-scrollbar-thumb:hover { background-color: rgb(${n} / 28%) !important; }`,`html::-webkit-scrollbar-button, body::-webkit-scrollbar-button, *::-webkit-scrollbar-button { display: none !important; width: 0 !important; height: 0 !important; }`,`</style>`].join(`
2
+ `),i=e.search(/<\/head\s*>/i);if(i>=0)return`${e.slice(0,i)}${r}\n${e.slice(i)}`;let a=/<head(?:\s[^>]*)?>/i.exec(e);if(a?.index!==void 0){let t=a.index+a[0].length;return`${e.slice(0,t)}\n${r}${e.slice(t)}`}let o=/<html(?:\s[^>]*)?>/i.exec(e);if(o?.index!==void 0){let t=o.index+o[0].length;return`${e.slice(0,t)}\n<head>${r}</head>${e.slice(t)}`}return`${r}\n${e}`}var p=n();function m({document:e,path:t,active:n}){let r=(0,u.useRef)(null),i=`html-preview-${(0,u.useId)().replace(/:/g,``)}`;return(0,u.useEffect)(()=>{n&&r.current?.requestSubmit()},[e,n]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`iframe`,{className:`html-preview-frame`,name:i,title:`Preview of ${t}`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`}),(0,p.jsx)(`form`,{ref:r,className:`html-preview-form`,method:`post`,action:`/api/html-preview`,target:i,encType:`application/x-www-form-urlencoded`,children:(0,p.jsx)(`input`,{type:`hidden`,name:`document`,value:e})})]})}var h={conflictTitle:`HTML was changed outside OpenTig`,successTitle:`HTML saved`,errorTitle:`Could not save HTML`};function g({file:e,initialContent:t,themeType:n,wrapLines:d,readOnly:g,onDirtyChange:_,onDraftChange:v,onSave:y}){let[b,x]=(0,u.useState)(`preview`),{draft:S,updateDraft:C,dirty:w,saving:T,save:E}=l({file:e,initialContent:t,readOnly:g,messages:h,onDirtyChange:_,onDraftChange:v,onSave:y}),D=n===`dark`||n===`system`&&document.documentElement.classList.contains(`dark`),O=(0,u.useMemo)(()=>f(S,D),[D,S]);return(0,u.useEffect)(()=>{x(`preview`)},[e.path]),(0,p.jsxs)(a,{value:b,onValueChange:e=>x(e),className:`markdown-viewer html-file-viewer`,children:[(0,p.jsx)(s,{save:(0,p.jsx)(o,{dirty:w,saving:T,readOnly:g,onSave:()=>void E()}),children:(0,p.jsx)(`div`,{className:`file-viewer-pill markdown-viewer-toolbar`,children:(0,p.jsx)(r,{label:`HTML view`,className:`file-viewer-tabs markdown-viewer-tabs`,items:[{value:`preview`,label:`Preview`},{value:`code`,label:(0,p.jsxs)(p.Fragment,{children:[`Code `,w&&(0,p.jsx)(`span`,{className:`markdown-unsaved-dot`,"aria-label":`Unsaved changes`})]})}]})})}),(0,p.jsx)(i,{value:`preview`,className:`html-preview-panel`,children:(0,p.jsx)(m,{document:O,path:e.path,active:b===`preview`})}),(0,p.jsx)(i,{value:`code`,className:`markdown-code-view`,"data-theme":n,children:(0,p.jsx)(c,{path:e.path,cacheKey:e.path,value:S,themeType:n,wrapLines:d,readOnly:g||T,onChange:C})})]})}export{g as HtmlFileViewer};
@@ -1 +1 @@
1
- import{t as e}from"./createReactComponent-BfrD_oQK.js";var t=e(`outline`,`alert-triangle`,`AlertTriangle`,[[`path`,{d:`M12 9v4`,key:`svg-0`}],[`path`,{d:`M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0`,key:`svg-1`}],[`path`,{d:`M12 16h.01`,key:`svg-2`}]]);export{t};
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`alert-triangle`,`AlertTriangle`,[[`path`,{d:`M12 9v4`,key:`svg-0`}],[`path`,{d:`M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0`,key:`svg-1`}],[`path`,{d:`M12 16h.01`,key:`svg-2`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`chevron-down`,`ChevronDown`,[[`path`,{d:`M6 9l6 6l6 -6`,key:`svg-0`}]]);export{t};
@@ -1 +1 @@
1
- import{t as e}from"./createReactComponent-BfrD_oQK.js";var t=e(`outline`,`edit`,`Edit`,[[`path`,{d:`M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1`,key:`svg-0`}],[`path`,{d:`M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415`,key:`svg-1`}],[`path`,{d:`M16 5l3 3`,key:`svg-2`}]]);export{t};
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`edit`,`Edit`,[[`path`,{d:`M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1`,key:`svg-0`}],[`path`,{d:`M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415`,key:`svg-1`}],[`path`,{d:`M16 5l3 3`,key:`svg-2`}]]);export{t};
@@ -1 +1 @@
1
- import{t as e}from"./createReactComponent-BfrD_oQK.js";var t=e(`outline`,`folder-plus`,`FolderPlus`,[[`path`,{d:`M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5`,key:`svg-0`}],[`path`,{d:`M16 19h6`,key:`svg-1`}],[`path`,{d:`M19 16v6`,key:`svg-2`}]]),n=e(`outline`,`folder-symlink`,`FolderSymlink`,[[`path`,{d:`M3 21v-4a3 3 0 0 1 3 -3h5`,key:`svg-0`}],[`path`,{d:`M8 17l3 -3l-3 -3`,key:`svg-1`}],[`path`,{d:`M3 11v-5a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8`,key:`svg-2`}]]);export{t as n,n as t};
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`folder-plus`,`FolderPlus`,[[`path`,{d:`M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5`,key:`svg-0`}],[`path`,{d:`M16 19h6`,key:`svg-1`}],[`path`,{d:`M19 16v6`,key:`svg-2`}]]),n=e(`outline`,`folder-symlink`,`FolderSymlink`,[[`path`,{d:`M3 21v-4a3 3 0 0 1 3 -3h5`,key:`svg-0`}],[`path`,{d:`M8 17l3 -3l-3 -3`,key:`svg-1`}],[`path`,{d:`M3 11v-5a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8`,key:`svg-2`}]]);export{t as n,n as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`git-merge`,`GitMerge`,[[`path`,{d:`M5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-0`}],[`path`,{d:`M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-1`}],[`path`,{d:`M15 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-2`}],[`path`,{d:`M7 8l0 8`,key:`svg-3`}],[`path`,{d:`M7 8a4 4 0 0 0 4 4h4`,key:`svg-4`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`git-pull-request`,`GitPullRequest`,[[`path`,{d:`M4 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-0`}],[`path`,{d:`M4 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-1`}],[`path`,{d:`M16 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-2`}],[`path`,{d:`M6 8l0 8`,key:`svg-3`}],[`path`,{d:`M11 6h5a2 2 0 0 1 2 2v8`,key:`svg-4`}],[`path`,{d:`M14 9l-3 -3l3 -3`,key:`svg-5`}]]);export{t};
@@ -1 +1 @@
1
- import{t as e}from"./createReactComponent-BfrD_oQK.js";var t=e(`outline`,`loader-4`,`Loader4`,[[`path`,{d:`M12 21v-3m6.36 .36l-2.12 -2.12m4.76 -4.24h-3m.36 -6.36l-2.12 2.12m-4.24 -4.76v3m-6.36 -.36l2.12 2.12m-3.76 4.24h2m1 4.95l.71 -.71`,key:`svg-0`}]]);export{t};
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`loader-4`,`Loader4`,[[`path`,{d:`M12 21v-3m6.36 .36l-2.12 -2.12m4.76 -4.24h-3m.36 -6.36l-2.12 2.12m-4.24 -4.76v3m-6.36 -.36l2.12 2.12m-3.76 4.24h2m1 4.95l.71 -.71`,key:`svg-0`}]]);export{t};
@@ -1 +1 @@
1
- import{t as e}from"./createReactComponent-BfrD_oQK.js";var t=e(`outline`,`brand-github`,`BrandGithub`,[[`path`,{d:`M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5`,key:`svg-0`}]]),n=e(`outline`,`plus`,`Plus`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M5 12l14 0`,key:`svg-1`}]]);export{t as n,n as t};
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`brand-github`,`BrandGithub`,[[`path`,{d:`M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5`,key:`svg-0`}]]),n=e(`outline`,`plus`,`Plus`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M5 12l14 0`,key:`svg-1`}]]);export{t as n,n as t};
@@ -1 +1 @@
1
- import{t as e}from"./createReactComponent-BfrD_oQK.js";var t=e(`outline`,`search`,`Search`,[[`path`,{d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`,key:`svg-0`}],[`path`,{d:`M21 21l-6 -6`,key:`svg-1`}]]);export{t};
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`search`,`Search`,[[`path`,{d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`,key:`svg-0`}],[`path`,{d:`M21 21l-6 -6`,key:`svg-1`}]]);export{t};
@@ -1 +1 @@
1
- import{t as e}from"./createReactComponent-BfrD_oQK.js";var t=e(`outline`,`selector`,`Selector`,[[`path`,{d:`M8 9l4 -4l4 4`,key:`svg-0`}],[`path`,{d:`M16 15l-4 4l-4 -4`,key:`svg-1`}]]);export{t};
1
+ import{t as e}from"./createReactComponent-Ctub7J3a.js";var t=e(`outline`,`selector`,`Selector`,[[`path`,{d:`M8 9l4 -4l4 4`,key:`svg-0`}],[`path`,{d:`M16 15l-4 4l-4 -4`,key:`svg-1`}]]);export{t};
@@ -0,0 +1 @@
1
+ .image-preview-workspace,.svg-file-viewer{background:var(--background);flex-direction:column;flex:1;height:100%;min-height:0;display:flex;position:relative}.svg-file-panel{flex-direction:column;flex:1;min-height:0;display:flex;position:relative}.image-file-details{color:var(--muted-foreground);font-family:var(--font-mono);white-space:nowrap;flex:none;padding:0 7px;font-size:10px}.image-sizing-toggle,.image-zoom-controls{flex:none;align-items:center;gap:2px;display:inline-flex}.image-sizing-toggle{border-left:1px solid var(--border);border-right:1px solid var(--border);padding:0 6px}.image-preview-toolbar [data-slot=button]{border-radius:999px}.image-zoom-value{min-width:47px;font-family:var(--font-mono);font-size:10px}.image-preview-canvas{background-color:var(--background);background-image:linear-gradient(45deg, color-mix(in oklch, var(--muted) 62%, transparent) 25%, transparent 25%), linear-gradient(-45deg, color-mix(in oklch, var(--muted) 62%, transparent) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, color-mix(in oklch, var(--muted) 62%, transparent) 75%), linear-gradient(-45deg, transparent 75%, color-mix(in oklch, var(--muted) 62%, transparent) 75%);cursor:zoom-in;background-position:0 0,0 8px,8px -8px,-8px 0;background-size:16px 16px;outline:none;flex:1;justify-content:center;align-items:center;min-height:0;display:flex;overflow:auto}.image-preview-canvas[data-zoom-limit=max]{cursor:zoom-out}.image-preview-canvas:focus-visible{box-shadow:inset 0 0 0 2px var(--ring)}.image-preview-canvas[data-sizing=fit]{padding:24px}.image-preview-canvas[data-sizing=fit] img{object-fit:contain;width:auto;max-width:100%;height:auto;max-height:100%}.image-preview-canvas[data-sizing=actual] img{flex:none;margin:auto}.image-preview-canvas[data-sizing=actual]{justify-content:flex-start;align-items:flex-start}.image-preview-canvas img{-webkit-user-select:none;user-select:none;-webkit-user-drag:none;display:block}.image-preview-loading{border-radius:var(--radius-md);background:color-mix(in oklch, var(--background) 86%, transparent);color:var(--muted-foreground);align-items:center;gap:8px;padding:8px 12px;font-size:11px;display:flex}.image-preview-loading svg{width:15px;height:15px;color:var(--primary);flex:none}.image-viewer-message{background:var(--background);text-align:center;flex-direction:column;justify-content:center;align-items:center;gap:5px;height:100%;min-height:120px;padding:24px;display:flex}.image-viewer-message strong{color:var(--foreground);font-size:13px}.image-viewer-message span{max-width:min(680px,90%);color:var(--muted-foreground);font-family:var(--font-mono);text-overflow:ellipsis;white-space:nowrap;font-size:10px;overflow:hidden}.image-viewer-tabs{border-right:1px solid var(--border);flex:none;gap:2px;padding-right:4px}.image-viewer-tabs button{height:28px;color:var(--muted-foreground);border-radius:999px;align-items:center;gap:5px;padding:0 9px;font-size:11px;font-weight:650;transition:background-color .12s,color .12s;display:inline-flex}.image-viewer-tabs button:hover:not([aria-selected=true]){background:color-mix(in oklch, var(--muted) 78%, transparent);color:var(--foreground)}.image-viewer-tabs button[aria-selected=true]{color:var(--foreground);box-shadow:none;background:0 0}.image-unsaved-dot{background:var(--warning);border-radius:50%;width:6px;height:6px}.svg-code-view{flex:1;min-height:0;overflow:hidden}@media (width<=760px){.image-file-details{display:none}.image-sizing-toggle{margin-left:auto}}
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{n as r,t as i}from"./createReactComponent-Ctub7J3a.js";import{t as a}from"./IconLoader4-D2VN7u1V.js";import{T as o,g as s,h as c,v as l}from"./index-DsKvWsTs.js";import{n as u,r as d,t as f}from"./viewer-tabs-DkkqN9MD.js";import{FileSaveControls as p,FileViewerChrome as m,SourceCodeEditor as h,t as g}from"./EditableFileViewer-Dotntfij.js";var _=i(`outline`,`zoom-in`,`ZoomIn`,[[`path`,{d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`,key:`svg-0`}],[`path`,{d:`M7 10l6 0`,key:`svg-1`}],[`path`,{d:`M10 7l0 6`,key:`svg-2`}],[`path`,{d:`M21 21l-6 -6`,key:`svg-3`}]]),v=i(`outline`,`zoom-out`,`ZoomOut`,[[`path`,{d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`,key:`svg-0`}],[`path`,{d:`M7 10l6 0`,key:`svg-1`}],[`path`,{d:`M21 21l-6 -6`,key:`svg-2`}]]),y=e(t()),b=.25,x=[.25,.5,.75,1,1.25,1.5,2,3,4,6,8];function S(e){return Number.isFinite(e)?Math.min(8,Math.max(b,e)):1}function C(e){let t=S(e);return x.find(e=>e>t+2**-52)??8}function w(e){let t=S(e);return[...x].reverse().find(e=>e<t-2**-52)??.25}var T=n(),E={conflictTitle:`SVG was changed outside OpenTig`,successTitle:`SVG saved`,errorTitle:`Could not save SVG`};function D({image:e}){return e.status===`unsupported`?(0,T.jsx)(j,{title:`Image format is not supported`,detail:`${e.path} · ${P(e.size)}`}):e.status===`too-large`?(0,T.jsx)(j,{title:`Image is too large to preview`,detail:`${e.path} · ${P(e.size)} · limit ${P(e.limit)}`}):(0,T.jsx)(O,{path:e.path,mimeType:e.mimeType,size:e.size,data:e.data})}function O({path:e,mimeType:t,size:n,data:r}){let i=M(r,t);return(0,T.jsx)(A,{objectUrl:i,path:e,size:n})}function k({file:e,initialContent:t,themeType:n,wrapLines:r,readOnly:i,onDirtyChange:a,onDraftChange:o,onSave:s}){let[c,l]=(0,y.useState)(`preview`),{draft:_,updateDraft:v,dirty:b,saving:x,save:S}=g({file:e,initialContent:t,readOnly:i,messages:E,onDirtyChange:a,onDraftChange:o,onSave:s}),C=M(_,`image/svg+xml`);(0,y.useEffect)(()=>{l(`preview`)},[e.path]);let w=(0,T.jsx)(u,{label:`SVG view`,className:`file-viewer-tabs image-viewer-tabs`,items:[{value:`preview`,label:`Preview`},{value:`code`,label:(0,T.jsxs)(T.Fragment,{children:[`Code `,b&&(0,T.jsx)(`span`,{className:`image-unsaved-dot`,"aria-label":`Unsaved changes`})]})}]}),D=(0,T.jsx)(p,{dirty:b,saving:x,readOnly:i,onSave:()=>void S()});return(0,T.jsxs)(f,{value:c,onValueChange:e=>l(e),className:`svg-file-viewer`,children:[(0,T.jsx)(d,{value:`preview`,className:`svg-file-panel`,children:(0,T.jsx)(A,{objectUrl:C,path:e.path,size:new TextEncoder().encode(_).byteLength,toolbarStart:w,toolbarEnd:D})}),(0,T.jsxs)(d,{value:`code`,className:`svg-file-panel`,children:[(0,T.jsx)(m,{save:D,children:(0,T.jsx)(`div`,{className:`file-viewer-pill svg-file-toolbar`,children:w})}),(0,T.jsx)(`div`,{className:`svg-code-view`,children:(0,T.jsx)(h,{path:e.path,cacheKey:e.path,value:_,themeType:n,wrapLines:r,readOnly:i||x,onChange:v})})]})]})}function A({objectUrl:e,path:t,size:n,toolbarStart:i,toolbarEnd:u}){let[d,f]=(0,y.useState)(`fit`),[p,h]=(0,y.useState)(1),[g,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(!1),E=(0,y.useRef)(null);(0,y.useEffect)(()=>{b(null),S(!1)},[e]),(0,y.useEffect)(()=>{let e=E.current;if(!e)return;let t=0,n=e=>{e.preventDefault();let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?100:1;if(t+=e.deltaY*n,Math.abs(t)<24)return;let r=t<0;t=0,f(`actual`),h(e=>r?C(e):w(e))};return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},[]);let D=g?g.width*p:void 0,O=g?g.height*p:void 0,k=[P(n),g?`${g.width} × ${g.height}`:null].filter(Boolean).join(` · `),A=e=>{f(`actual`),h(t=>e===`in`?C(t):w(t))};return(0,T.jsxs)(`div`,{className:`image-preview-workspace`,children:[(0,T.jsx)(m,{save:u,children:(0,T.jsxs)(`div`,{className:`file-viewer-pill image-preview-toolbar`,children:[i,(0,T.jsx)(`span`,{className:`image-file-details`,children:k}),(0,T.jsxs)(`div`,{className:`image-sizing-toggle`,role:`group`,"aria-label":`Image size`,children:[(0,T.jsx)(o,{type:`button`,size:`xs`,variant:d===`fit`?`secondary`:`ghost`,"aria-pressed":d===`fit`,onClick:()=>f(`fit`),children:`Fit`}),(0,T.jsx)(o,{type:`button`,size:`xs`,variant:d===`actual`&&p===1?`secondary`:`ghost`,"aria-pressed":d===`actual`&&p===1,onClick:()=>{f(`actual`),h(1)},children:`1:1`})]}),(0,T.jsxs)(`div`,{className:`image-zoom-controls`,children:[(0,T.jsxs)(c,{children:[(0,T.jsx)(l,{render:(0,T.jsx)(o,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Zoom out`,onClick:()=>A(`out`)}),children:(0,T.jsx)(v,{})}),(0,T.jsx)(s,{children:`Zoom out`})]}),(0,T.jsxs)(o,{type:`button`,variant:`ghost`,size:`xs`,className:`image-zoom-value`,"aria-label":`Reset zoom to 100%`,onClick:()=>{f(`actual`),h(1)},children:[Math.round(p*100),`%`]}),(0,T.jsxs)(c,{children:[(0,T.jsx)(l,{render:(0,T.jsx)(o,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Zoom in`,onClick:()=>A(`in`)}),children:(0,T.jsx)(_,{})}),(0,T.jsx)(s,{children:`Zoom in`})]})]})]})}),(0,T.jsx)(`div`,{ref:E,className:`image-preview-canvas`,"data-sizing":d,"data-zoom-limit":p>=8?`max`:`normal`,tabIndex:0,"aria-label":`Image preview for ${t}`,onKeyDown:e=>{if(e.key===`+`||e.key===`=`)A(`in`);else if(e.key===`-`)A(`out`);else if(e.key===`0`)f(`actual`),h(1);else if(e.key.toLowerCase()===`f`)f(`fit`);else return;e.preventDefault()},children:e?x?(0,T.jsx)(j,{title:`Could not decode this image`,detail:t}):(0,T.jsx)(`img`,{src:e,alt:N(t),draggable:!1,style:d===`actual`&&D&&O?{width:D,height:O,maxWidth:`none`,maxHeight:`none`}:void 0,onLoad:e=>{S(!1),b({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight})},onError:()=>S(!0)}):(0,T.jsxs)(`span`,{className:`image-preview-loading`,children:[(0,T.jsx)(a,{className:`animate-spin`,"aria-hidden":`true`}),(0,T.jsx)(r,{text:`Loading image…`})]})})]})}function j({title:e,detail:t}){return(0,T.jsxs)(`div`,{className:`image-viewer-message`,children:[(0,T.jsx)(`strong`,{children:e}),(0,T.jsx)(`span`,{children:t})]})}function M(e,t){let[n,r]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let n=typeof e==`string`?e:new Uint8Array(e),i=URL.createObjectURL(new Blob([n],{type:t}));return r(i),()=>{URL.revokeObjectURL(i),r(e=>e===i?null:e)}},[t,e]),n}function N(e){return e.replace(/\\/g,`/`).split(`/`).pop()||e}function P(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}export{D as ImageFileViewer,k as SvgFileViewer};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,St as n,xt as r}from"./base-ui-DDpgJXgO.js";import{t as i}from"./external-url-IUS7RmYD.js";import{t as a}from"./ExternalLink-jdtpN_yL.js";var o=e(t()),s=e(n()),c=r();function l({html:e,className:t=`markdown-prose`}){let n=(0,o.useRef)(null),[r,l]=(0,o.useState)([]);return(0,o.useLayoutEffect)(()=>{let t=n.current;if(!t)return;t.innerHTML=e;let r=[];for(let e of t.querySelectorAll(`a[href]`)){e.removeAttribute(`title`);let t=e.getAttribute(`href`)??``;if(!i(t))continue;let n=document.createElement(`span`);n.style.display=`contents`,r.push({mount:n,href:t,html:e.innerHTML,className:e.className,id:e.id}),e.replaceWith(n)}l(r)},[e]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`div`,{ref:n,className:t}),r.map((e,t)=>(0,s.createPortal)((0,c.jsx)(a,{href:e.href,className:e.className,id:e.id,dangerouslySetInnerHTML:{__html:e.html}}),e.mount,String(t)))]})}export{l as t};
@@ -0,0 +1 @@
1
+ import{xt as e}from"./base-ui-DDpgJXgO.js";import{t}from"./external-url-IUS7RmYD.js";import{D as n}from"./App-Bfw_TX8q.js";import{t as r}from"./ExternalLink-jdtpN_yL.js";var i=e();function a({text:e}){return(0,i.jsx)(i.Fragment,{children:n.lexInline(e,{gfm:!0}).map((e,n)=>e.type===`link`&&t(e.href)?(0,i.jsx)(r,{href:e.href,children:e.text},n):e.raw)})}export{a as t};