@opentig/cli 0.1.4 → 0.1.6
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.
- package/README.md +73 -17
- package/dist/bin.mjs +2 -2
- package/dist/chunks/{cli-B3AR8LUd.mjs → cli-ABzC6-gR.mjs} +232 -57
- package/dist/chunks/service-manager-DkpSHxsP.mjs +394 -0
- package/dist/client/assets/App-CBetJ5ZN.js +74 -0
- package/dist/client/assets/CreatePullRequestDialog-W82oHjYm.js +2 -0
- package/dist/client/assets/{DiffWorkspace-Dg7YI5fJ.js → DiffWorkspace-BWkTIl5n.js} +1 -1
- package/dist/client/assets/{EditableFileViewer-CmxzBnAY.js → EditableFileViewer-Cv3aNJBN.js} +1 -1
- package/dist/client/assets/{File-CYcpdoXz.js → File-DiOOsHOl.js} +1 -1
- package/dist/client/assets/{FilesView-BFCwGLC2.js → FilesView-DIqPfRbv.js} +1 -1
- package/dist/client/assets/{GitHubAvatar-BcncAgKT.js → GitHubAvatar-DBc3Vxnk.js} +1 -1
- package/dist/client/assets/HistoryView-DYxWYYVx.js +1 -0
- package/dist/client/assets/{HtmlFileViewer-jdBVtlNv.js → HtmlFileViewer-BsewwJtM.js} +1 -1
- package/dist/client/assets/{IconEdit-DQZu_Rpb.js → IconEdit-CxvzMyLV.js} +1 -1
- package/dist/client/assets/{IconFolderPlus-DvEWPQIQ.js → IconFolderPlus-1vLDIzhC.js} +1 -1
- package/dist/client/assets/{ImageFileViewer-BW1MbklH.js → ImageFileViewer-CoQZkgET.js} +1 -1
- package/dist/client/assets/{LocalRefsDialog-9ggtgVW_.js → LocalRefsDialog-sw-ROjfe.js} +1 -1
- package/dist/client/assets/{MarkdownFileViewer-Bhrr1l2Q.js → MarkdownFileViewer-BedKCXTI.js} +2 -2
- package/dist/client/assets/{PairingPage-CkRMPzli.js → PairingPage-CYJXzBZC.js} +1 -1
- package/dist/client/assets/{PierreDiffViewer-CYdNkBG9.js → PierreDiffViewer-uhTsb-F7.js} +1 -1
- package/dist/client/assets/PierreEditBoundary-Bb4dONIq.js +2 -0
- package/dist/client/assets/{PierreWorkerPool-B2iHe3DC.js → PierreWorkerPool-BuBzE8K1.js} +9 -9
- package/dist/client/assets/{PullRequestDiff-DZRDxOx9.js → PullRequestDiff-CgY4QIHC.js} +1 -1
- package/dist/client/assets/{PullRequestViewer-Bsh-F3-d.js → PullRequestViewer-KZl0osME.js} +2 -2
- package/dist/client/assets/PullRequestsView-DkN3pW33.js +1 -0
- package/dist/client/assets/{QuickOpenDialog-CtJqcFuk.js → QuickOpenDialog-Cn-aQRAS.js} +1 -1
- package/dist/client/assets/RepositoryProjectsDialog-F-EctLXx.js +1 -0
- package/dist/client/assets/SearchView-BtKBEJ7e.js +1 -0
- package/dist/client/assets/SettingsDialog-wfWhEzZY.js +9 -0
- package/dist/client/assets/Viewer-D-oFua7K.js +3 -0
- package/dist/client/assets/{abnfDiagram-N423BO3Z-DYcwdF-j.js → abnfDiagram-N423BO3Z-DLBLFOdy.js} +1 -1
- package/dist/client/assets/{arc-CZ6a8_6G.js → arc-D-Yei3Vr.js} +1 -1
- package/dist/client/assets/{architectureDiagram-T3A2C74G-CViM1eoQ.js → architectureDiagram-T3A2C74G-BOgBvzWh.js} +1 -1
- package/dist/client/assets/{base-ui-D4MeJpa3.js → base-ui-qeHDA5zu.js} +1 -1
- package/dist/client/assets/{blockDiagram-VBNYF7ZC-BzRc4Zb8.js → blockDiagram-VBNYF7ZC-BQXRJDyR.js} +1 -1
- package/dist/client/assets/{c4Diagram-5PPSVZJV-BZsdylz9.js → c4Diagram-5PPSVZJV-DTZseD56.js} +1 -1
- package/dist/client/assets/channel-DrMuSkDK.js +1 -0
- package/dist/client/assets/{checkbox-iSOOddl1.js → checkbox-BwbxYGgK.js} +1 -1
- package/dist/client/assets/{chunk-2GRJ4B5K-CsL1szop.js → chunk-2GRJ4B5K-spRCgfPY.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-Dpm-BZHi.js → chunk-2Q5K7J3B-CLVClH0M.js} +1 -1
- package/dist/client/assets/{chunk-5RXB4S5H-BNNb0lga.js → chunk-5RXB4S5H-CuQ5tYjB.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-CcXWQAK-.js → chunk-5VM5RSS4-DyOEOe90.js} +1 -1
- package/dist/client/assets/{chunk-6Q2QTUOP-BIpZKHoj.js → chunk-6Q2QTUOP-CgMtuJIx.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-CXSHzIYB.js → chunk-GF5L2VYU-BH63P4Vv.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-DxFk0X7_.js → chunk-JWPE2WC7-BANDbaPq.js} +1 -1
- package/dist/client/assets/{chunk-KBJHAD2P-WRKVeb4h.js → chunk-KBJHAD2P-Bfty2upo.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-Br5DeHdX.js → chunk-RYQCIY6F-Cvu8BZS9.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-DFCzSljb.js → chunk-XXDRQBXY-bnohf1yd.js} +1 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BKiL0hkR.js +1 -0
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BKiL0hkR.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-CE8E-qIe.js → cose-bilkent-JH36ORCC-DCTEAZwO.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-CHf3vLku.js → cynefin-VYW2F7L2-Bp2wXvdt.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-90txNnhw.js → cynefinDiagram-MW4NZA55-DRRWzuF0.js} +1 -1
- package/dist/client/assets/{dagre-VZM6K2ZE-6somveWH.js → dagre-VZM6K2ZE-DDvsotRK.js} +1 -1
- package/dist/client/assets/{diagram-7IWD3JNH-D4GP5bhO.js → diagram-7IWD3JNH-CMqhRNRq.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-Cz4bx70D.js → diagram-B4RE2ZJO-D_PYI1ut.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-BXjlhC7t.js → diagram-LBJQPF4R-BSUx7mMM.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE-B_dDT61b.js → diagram-Q27KOJAE-C8O3g6WT.js} +1 -1
- package/dist/client/assets/{diagram-UB23O5K3-BotmyDTm.js → diagram-UB23O5K3-C5-NDsgC.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-CBey4stz.js → ebnfDiagram-BXEA7PRR-D71hx4Ww.js} +1 -1
- package/dist/client/assets/{erDiagram-JOGREHBK-B2g7aHUP.js → erDiagram-JOGREHBK-yd9B5d8I.js} +1 -1
- package/dist/client/assets/{flowDiagram-UKHOOZJN-B181B3KJ.js → flowDiagram-UKHOOZJN-CWU5VVbw.js} +1 -1
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-BFslA07w.js → ganttDiagram-PKOTCBZU-D2siVjfa.js} +1 -1
- package/dist/client/assets/{gh-utils-rGdT2YZN.js → gh-utils-B0Nlmxep.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-B_uJt_Hp.js → gitGraphDiagram-DS77QQ5N-CIvIFcxR.js} +1 -1
- package/dist/client/assets/index-BOPi2b1j.js +47 -0
- package/dist/client/assets/index-CryuKDT3.css +1 -0
- package/dist/client/assets/{infoDiagram-6WML65LV-BuajoWMd.js → infoDiagram-6WML65LV-DRvl8KfO.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-CGRAyQ-L.js → ishikawaDiagram-WSZJBQD7-H5EQq6uE.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-D8bgj_4i.js → journeyDiagram-NVQOT4AX-CCwLmD-U.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-QrwKHnlk.js → kanban-definition-27J2QSJJ-DS--XHEu.js} +1 -1
- package/dist/client/assets/{linear-BSIPbUpM.js → linear-Q3JNM6CR.js} +1 -1
- package/dist/client/assets/{mermaid.core-D4_R4ZQ7.js → mermaid.core-EwS_m22C.js} +4 -4
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-DTiuF5JK.js → mindmap-definition-FAOFIHXS-D15nrwfe.js} +1 -1
- package/dist/client/assets/{pegDiagram-VL7TDLO6-yCIq1xSC.js → pegDiagram-VL7TDLO6-DOG19gxx.js} +1 -1
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-B_Vgs3pz.js → pieDiagram-7S7Q4E2Y-Bstdr7Wh.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-5Ne6-Suh.js → quadrantDiagram-CIZ2JOQS-DfKs4qZW.js} +1 -1
- package/dist/client/assets/{railroadDiagram-AXF67PYL-CRQ23Ne5.js → railroadDiagram-AXF67PYL-DJKxyuhV.js} +1 -1
- package/dist/client/assets/{render-markdown-D7BGt-zy.js → render-markdown-C7X2TwRk.js} +1 -1
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-Ctks1nFE.js → requirementDiagram-LRYGKXZP-SGJWVmBV.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-D127Ar8U.js → sankeyDiagram-W5VNT64P-CpZFct0O.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-6hK5AS2n.js → sequenceDiagram-SI44F4Z6-B7plRik9.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-GhdZlEoa.js → sizeCapture-X5ZJPWSS-CNbK285t.js} +1 -1
- package/dist/client/assets/{stateDiagram-OKZ733FA-u3G3OuQX.js → stateDiagram-OKZ733FA-BIHk9QCC.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-Cqw0H5cq.js +1 -0
- package/dist/client/assets/{swimlanes-SLNWSIFB-BIfNt9T9.js → swimlanes-SLNWSIFB-7g_XCosC.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-BzKpdiGK.js +8 -0
- package/dist/client/assets/{tanstack-Bsd5UOY4.js → tanstack-B8_amOz8.js} +1 -1
- package/dist/client/assets/{timeline-definition-Z64GVDOM-CXwiFUZq.js → timeline-definition-Z64GVDOM-B-cgSggY.js} +1 -1
- package/dist/client/assets/{vennDiagram-T6HMQDX7-D9Rhew2E.js → vennDiagram-T6HMQDX7-Bt5-8VZ2.js} +1 -1
- package/dist/client/assets/{viewer-tabs-BW5-uV6M.js → viewer-tabs-DxCOe0ut.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-CzCcAcBb.js → wardleyDiagram-T6FBY63Y-B5Imx6zh.js} +1 -1
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-BfXVbrBJ.js → xychartDiagram-ELKLHX3M-CDaY4xFS.js} +1 -1
- package/dist/client/index.html +4 -4
- package/dist/dev.mjs +4 -4
- package/dist/manifest.json +1 -1
- package/dist/server.mjs +59 -8
- package/dist/service-update.mjs +12 -10
- package/package.json +1 -1
- package/dist/chunks/cli-service-B939lTxw.mjs +0 -237
- package/dist/client/assets/App-BWpP-n84.js +0 -118
- package/dist/client/assets/CreatePullRequestDialog-CQKBUxKz.js +0 -2
- package/dist/client/assets/HistoryView-Dev4CVOY.js +0 -1
- package/dist/client/assets/PierreEditBoundary-Cu19fc5Z.js +0 -2
- package/dist/client/assets/PullRequestsView-Brg-sbGb.js +0 -1
- package/dist/client/assets/RepositoryProjectsDialog-BIUnKMb-.js +0 -1
- package/dist/client/assets/SearchView-C5_R_0ZU.js +0 -1
- package/dist/client/assets/SettingsDialog-CyJA7ajO.js +0 -9
- package/dist/client/assets/Viewer-xMTNRGDO.js +0 -3
- package/dist/client/assets/channel-DUwjky93.js +0 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BtqFLKHp.js +0 -1
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BtqFLKHp.js +0 -1
- package/dist/client/assets/index-DXR6FOp1.css +0 -1
- package/dist/client/assets/index-DaaX_e8C.js +0 -3
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-BSIBplQO.js +0 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-DGRBYdxa.js +0 -8
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/render-markdown-C7X2TwRk.js","assets/App-CBetJ5ZN.js","assets/index-BOPi2b1j.js","assets/react-rd22PHbN.js","assets/tanstack-B8_amOz8.js","assets/base-ui-qeHDA5zu.js","assets/index-CryuKDT3.css","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as z,_ as $,o as p,B as g,s as x}from"./index-BOPi2b1j.js";import{r,j as e}from"./react-rd22PHbN.js";import{C as J}from"./checkbox-BwbxYGgK.js";import{D as K,c as Q,d as X,T as O,e as Y,k as P,S as Z,C as ee,A as te,E as ae,F as se,U as ne,V as re,W as ie,G as le}from"./App-CBetJ5ZN.js";import{V as ce,a as oe,b as L}from"./viewer-tabs-DxCOe0ut.js";import{o as de,g as ue,a as he}from"./gh-utils-B0Nlmxep.js";/* empty css */import"./tanstack-B8_amOz8.js";import"./base-ui-qeHDA5zu.js";const me=[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]],M=z("outline","upload","Upload",me);function De(t){const[n,u]=r.useState(""),[c,C]=r.useState(""),[o,B]=r.useState(""),[y,T]=r.useState(!1),[w,I]=r.useState("edit"),[V,S]=r.useState(""),[i,_]=r.useState(!1),[l,E]=r.useState(null),h=r.useRef(null),N=r.useRef(0),v=t.status?.branch??null,f=t.preferences.commitMessageHarness,q=t.preferences.commitMessageModels[f]??"default",H=be(t.aiProviders,f,q),m=r.useMemo(()=>t.branches.filter(a=>a.remote&&!a.fullName.endsWith("/HEAD")&&a.name!==`origin/${v??""}`).map(a=>a.name),[v,t.branches]);r.useEffect(()=>{t.open&&B(a=>a&&m.includes(a)?a:fe(m))},[m,t.open]),r.useEffect(()=>{if(!t.open||w!=="preview")return;const a=++N.current;$(async()=>{const{renderMarkdown:s}=await import("./render-markdown-C7X2TwRk.js").then(j=>j.a);return{renderMarkdown:s}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({renderMarkdown:s})=>s(c||"_No description._")).then(s=>{a===N.current&&S(s)}).catch(()=>{a===N.current&&S("<p>Could not render the preview.</p>")})},[c,w,t.open]),r.useEffect(()=>{if(t.open)return;const a=h.current;a&&p.github.cancelDraft(a).catch(()=>{})},[t.open]);const k=t.status!==null&&!t.status.upstream,D=t.status!==null&&!!t.status.upstream&&t.status.ahead>0,b=t.status!==null&&(t.status.detached||t.status.unborn||!t.status.branch),d=t.status===null||k||D||b||m.length===0,F=async()=>{const a=h.current;a&&await p.github.cancelDraft(a).catch(()=>{})},U=async()=>{if(d||l||i||!o)return;const a=crypto.randomUUID();h.current=a,E(a);try{const s=await p.github.generateDraft({repositoryId:t.repositoryId,base:o,harness:f,model:q,requestId:a});if(h.current!==a)return;u(s.title),C(s.body),I("edit"),x.success({title:`Draft generated with ${G(s.harness)}`,description:s.contextWasTruncated?"A truncated version of the branch diff was used. Review before publishing.":"Review and edit before publishing."})}catch(s){const j=ge(s);j?.code==="AI_CANCELLED"?x.info({title:"Generation canceled"}):x.error({title:"Could not generate the draft",description:j?.message??A(s),duration:1e4})}finally{h.current===a&&(h.current=null),E(s=>s===a?null:s)}},W=async()=>{if(!(d||i||l||!n.trim()||!o)){_(!0);try{const a=await p.github.createPullRequest({repositoryId:t.repositoryId,title:n.trim(),body:c,base:o,draft:y});u(""),C(""),T(!1),x.success({title:y?"Draft pull request created":"Pull request created",description:a.url,button:{title:"Open",onClick:()=>de(a.url)}}),t.onCreated(a.number)}catch(a){const s=ue(a);x.error({title:he(s),description:s?.message??A(a),duration:1e4})}finally{_(!1)}}};return e.jsx(K,{open:t.open,onOpenChange:a=>{i||t.onOpenChange(a)},children:e.jsxs(Q,{className:"create-pr-dialog",children:[e.jsxs("div",{className:"create-pr-content",children:[e.jsxs(X,{children:[e.jsx(O,{"aria-hidden":"true"})," Create pull request"]}),e.jsx(Y,{children:v?e.jsxs(e.Fragment,{children:["From ",e.jsx("code",{children:v})," into the selected base branch on GitHub."]}):"Check out a branch to create a pull request."}),k&&e.jsxs("div",{className:"create-pr-notice",children:[e.jsx("span",{children:b?"Check out a branch with at least one commit before publishing.":"Publish this branch before creating a pull request."}),e.jsxs(g,{variant:"outline",size:"xs",disabled:t.pushBusy||b||!!t.status?.readOnly,onClick:t.onPush,children:[t.pushBusy?e.jsx(P,{className:"animate-spin"}):e.jsx(M,{})," Publish branch"]})]}),D&&e.jsxs("div",{className:"create-pr-notice",children:[e.jsxs("span",{children:["The branch has ",t.status?.ahead," unpushed ",t.status?.ahead===1?"commit":"commits",". Push them so the pull request includes your work."]}),e.jsxs(g,{variant:"outline",size:"xs",disabled:t.pushBusy,onClick:t.onPush,children:[t.pushBusy?e.jsx(P,{className:"animate-spin"}):e.jsx(M,{})," Push"]})]}),!k&&!D&&b&&e.jsx("div",{className:"create-pr-notice",children:e.jsx("span",{children:"Pull requests need a checked-out branch with commits."})}),m.length===0&&!b&&e.jsx("div",{className:"create-pr-notice",children:e.jsx("span",{children:"No remote branches are available to use as a base. Fetch the remote first."})}),e.jsxs("div",{className:"create-pr-base-row",children:[e.jsxs("div",{className:"create-pr-field",children:[e.jsx("label",{htmlFor:"create-pr-base",children:"Base branch"}),e.jsxs(Z,{value:o,onValueChange:a=>B(a??""),children:[e.jsx(ee,{id:"create-pr-base",className:"create-pr-base",disabled:d||i||!!l,children:e.jsx(te,{children:o?R(o):"Select a base"})}),e.jsx(ae,{alignItemWithTrigger:!1,children:m.map(a=>e.jsx(se,{value:a,children:R(a)},a))})]})]}),e.jsxs("label",{className:"create-pr-draft",children:[e.jsx(J,{checked:y,onCheckedChange:a=>T(a===!0),disabled:d||i||!!l}),e.jsx("span",{children:"Create as draft"})]})]}),e.jsxs("div",{className:"create-pr-field",children:[e.jsx("label",{htmlFor:"create-pr-title",children:"Title"}),e.jsx("input",{id:"create-pr-title",className:"create-pr-title",value:n,maxLength:300,placeholder:"Pull request title",disabled:d||i||!!l,onChange:a=>u(a.target.value)})]}),e.jsxs(ce,{value:w,onValueChange:a=>I(a),className:"create-pr-field create-pr-body-field",children:[e.jsxs("div",{className:"create-pr-body-header",children:[e.jsx("label",{htmlFor:"create-pr-body",children:"Description"}),e.jsx(oe,{label:"Description view",className:"markdown-viewer-tabs",items:[{value:"edit",label:"Edit"},{value:"preview",label:"Preview"}]})]}),e.jsx(L,{value:"edit",className:"create-pr-body-panel",children:e.jsx(ne,{id:"create-pr-body",value:c,rows:10,placeholder:"Describe the change (GitHub Markdown)",disabled:d||i||!!l,onChange:a=>C(a.target.value)})}),e.jsx(L,{value:"preview",className:"create-pr-preview markdown-prose",dangerouslySetInnerHTML:{__html:V}})]})]}),e.jsxs("div",{className:"create-pr-actions",children:[e.jsxs(g,{variant:"outline",className:"create-pr-generate commit-composer-generate",disabled:d||i,"aria-label":l?"Cancel generation":void 0,onClick:()=>l?void F():void U(),children:[l?e.jsx(re,{className:"text-destructive"}):e.jsx(ie,{harness:f}),l?e.jsx(le,{text:"Generating draft…"}):e.jsxs("span",{className:"commit-composer-provider",children:["Generate with ",e.jsx("span",{className:"commit-composer-harness",children:G(f)}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:"commit-composer-model",children:H})]})]}),e.jsxs("div",{className:"create-pr-submit-actions",children:[e.jsx(g,{variant:"ghost",onClick:()=>t.onOpenChange(!1),disabled:i,children:"Cancel"}),e.jsxs(g,{onClick:()=>{W()},disabled:d||i||!!l||!n.trim()||!o,children:[i?e.jsx(P,{className:"animate-spin"}):e.jsx(O,{})," ",i?"Creating…":"Create pull request"]})]})]})]})})}function fe(t){return t.find(n=>n==="origin/main")??t.find(n=>n==="origin/master")??t[0]??""}function R(t){return t.replace(/^origin\//,"")}function G(t){return t==="codex"?"Codex":t==="claude"?"Claude Code":"OpenCode"}function be(t,n,u){return t?.find(c=>c.id===n)?.models.find(c=>c.id===u)?.label??(u==="default"?"Default (CLI)":u)}function ge(t){if(!(t instanceof Error)||!("detail"in t)||!t.detail||typeof t.detail!="object")return null;const n=t.detail;return typeof n.code=="string"&&n.code.startsWith("AI_")&&typeof n.message=="string"?n:null}function A(t){return t instanceof Error?t.message:"An unexpected error occurred."}export{De as CreatePullRequestDialog};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as k,r as ee}from"./react-rd22PHbN.js";import{a7 as q,a6 as xe,a8 as gn,G as mn,a9 as Cn,aa as Sn,ab as Ze,ac as xn,ad as ve,ae as ye,$ as ge,af as ke,ag as se,a0 as Zt,q as F,a5 as Pe,ah as Ln,b as $e,g as kn,ai as ze,aj as ce,e as vn,n as yn,v as Hn,w as wn,ak as me,f as Qt,h as pt,x as En,al as An,am as Ce,an as Rn,m as V,t as bn,s as Jt,l as gt,p as Tn,y as Re,o as Mn,z as Dn,R as In,I as Fn,A as mt,B as Nn,C as Pn,ao as en,ap as zn,aq as Ct,D as Bn,E as On,Q as St,S as Un,F as Vn,H as jn,J as xt,K as $n,L as Gn,N as Lt,M as Ge,T as Wn,U as _n,d as tn,W as Kn,X as We,Y as qn,_ as Xn,Z as nn,a1 as Yn,u as Zn,a2 as Qn,a3 as kt,a4 as Jn,ar as ei,as as ti,a as ni,V as ii,O as si}from"./PierreWorkerPool-
|
|
1
|
+
import{j as k,r as ee}from"./react-rd22PHbN.js";import{a7 as q,a6 as xe,a8 as gn,G as mn,a9 as Cn,aa as Sn,ab as Ze,ac as xn,ad as ve,ae as ye,$ as ge,af as ke,ag as se,a0 as Zt,q as F,a5 as Pe,ah as Ln,b as $e,g as kn,ai as ze,aj as ce,e as vn,n as yn,v as Hn,w as wn,ak as me,f as Qt,h as pt,x as En,al as An,am as Ce,an as Rn,m as V,t as bn,s as Jt,l as gt,p as Tn,y as Re,o as Mn,z as Dn,R as In,I as Fn,A as mt,B as Nn,C as Pn,ao as en,ap as zn,aq as Ct,D as Bn,E as On,Q as St,S as Un,F as Vn,H as jn,J as xt,K as $n,L as Gn,N as Lt,M as Ge,T as Wn,U as _n,d as tn,W as Kn,X as We,Y as qn,_ as Xn,Z as nn,a1 as Yn,u as Zn,a2 as Qn,a3 as kt,a4 as Jn,ar as ei,as as ti,a as ni,V as ii,O as si}from"./PierreWorkerPool-BuBzE8K1.js";import{C as sn,g as Se,S as ri,D as re,y as oi,z as ai,a as _e,b as vt,v as li,E as di,w as hi,H as ui,c as ci,d as fi,i as pi,f as gi}from"./platform-BMNQ8V5r.js";import{t as oe}from"./one-light-CoLDteqg.js";import{u as mi,a as Ci}from"./EditContext-CvJWfVl1.js";import{c as He,T as Qe,a as Je,b as et,B as Si}from"./index-BOPi2b1j.js";import{R as yt,O as xi,a6 as Li,I as ki}from"./App-CBetJ5ZN.js";const vi=[["path",{d:"M16 4l4 0l0 4",key:"svg-0"}],["path",{d:"M14 10l6 -6",key:"svg-1"}],["path",{d:"M8 20l-4 0l0 -4",key:"svg-2"}],["path",{d:"M4 20l6 -6",key:"svg-3"}],["path",{d:"M16 20l4 0l0 -4",key:"svg-4"}],["path",{d:"M14 14l6 6",key:"svg-5"}],["path",{d:"M8 4l-4 0l0 4",key:"svg-6"}],["path",{d:"M4 4l6 6",key:"svg-7"}]],yi=He("outline","arrows-maximize","ArrowsMaximize",vi);const Hi=[["path",{d:"M5 9l4 0l0 -4",key:"svg-0"}],["path",{d:"M3 3l6 6",key:"svg-1"}],["path",{d:"M5 15l4 0l0 4",key:"svg-2"}],["path",{d:"M3 21l6 -6",key:"svg-3"}],["path",{d:"M19 9l-4 0l0 -4",key:"svg-4"}],["path",{d:"M15 9l6 -6",key:"svg-5"}],["path",{d:"M19 15l-4 0l0 4",key:"svg-6"}],["path",{d:"M15 15l6 6",key:"svg-7"}]],wi=He("outline","arrows-minimize","ArrowsMinimize",Hi);const Ei=[["path",{d:"M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12",key:"svg-0"}],["path",{d:"M12 4l0 16",key:"svg-1"}]],Ai=He("outline","layout-columns","LayoutColumns",Ei);const Ri=[["path",{d:"M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}]],bi=He("outline","layout-rows","LayoutRows",Ri);const Ti=[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 18l5 0",key:"svg-1"}],["path",{d:"M4 12h13a3 3 0 0 1 0 6h-4l2 -2m0 4l-2 -2",key:"svg-2"}]],Mi=He("outline","text-wrap","TextWrap",Ti);function Di({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function Ii(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Ui(n,e.startContentIndex)}}function kr(e,t=6){t=Math.max(t,1);const n={deletionLines:[],additionLines:[],conflictStack:[],conflictBuilders:[],actions:[],hunks:[],nextConflictIndex:0,splitLineCount:0,unifiedLineCount:0,lastHunkEnd:0,activeHunk:void 0,maxContextLines:t,maxContextLines2:t*2},i=e.contents,s=i.length;if(s>0){let u=0,c=0,f=i.indexOf(`
|
|
2
2
|
`,u);for(;f!==-1;)Ht(n,i.slice(u,f+1),c),u=f+1,c++,f=i.indexOf(`
|
|
3
3
|
`,u);u<s&&Ht(n,i.slice(u),c)}if(n.conflictStack.length>0)throw new Error("parseMergeConflictDiffFromFile: unfinished merge conflict marker stack");n.activeHunk!=null&&n.activeHunk.hunkContent.length>0&&(ut(n,n.activeHunk,"trailing"),an(n));for(let u=0;u<n.conflictBuilders.length;u++){const c=n.conflictBuilders[u];if(c==null||!c.completed)throw new Error(`parseMergeConflictDiffFromFile: failed to build merge conflict action ${u}`)}if(n.hunks.length>0&&n.additionLines.length>0&&n.deletionLines.length>0){const u=n.hunks[n.hunks.length-1],c=Math.max(n.additionLines.length-q(u.additionStart,u.additionCount),0);n.splitLineCount+=c,n.unifiedLineCount+=c}const r=n.deletionLines.join(""),o=n.additionLines.join(""),a=Tt(e,"current",r),l=Tt(e,"incoming",o);let d="change";o===""?d="deleted":r===""&&(d="new");const h={name:e.name,prevName:void 0,type:d,hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,isPartial:!1,deletionLines:n.deletionLines,additionLines:n.additionLines,cacheKey:e.cacheKey!=null?`${e.cacheKey}:merge-conflict-diff`:void 0};return{fileDiff:h,currentFile:a,incomingFile:l,actions:n.actions,markerRows:Oi(h,n.actions)}}function Ht(e,t,n){const i=e.conflictStack[e.conflictStack.length-1];if(i==null){if(t.length>=7&&t.charCodeAt(0)===60&&bt(t)==="start"){At(e,t,n);return}wt(e,t);return}const s=bt(t);if(s==="start"){At(e,t,n);return}if(s==="base"){i.stage="base",i.baseMarkerLineIndex=n,i.markerLines.base=t;return}if(s==="separator"){i.stage="incoming",i.separatorLineIndex=n,i.markerLines.separator=t;return}if(s==="end"){const r=e.conflictStack.pop();if(r==null)throw new Error("parseMergeConflictDiffFromFile: encountered end marker before start marker");Pi(e,r,n,t);return}i.stage==="current"?Et(e,"deletion",t,i.conflictIndex,"current"):i.stage==="base"?wt(e,t,i.conflictIndex):Et(e,"addition",t,i.conflictIndex,"incoming")}function rn(e){return e.activeHunk??=ln(e.additionLines.length+1,e.deletionLines.length+1),e.activeHunk}function on(e,t,n,i){const s=e.conflictBuilders[t];if(s==null)throw new Error(`parseMergeConflictDiffFromFile: failed to locate conflict action ${t}`);const r=s.action,o=e.hunks.length;if(r.hunkIndex<0)r.hunkIndex=o;else if(r.hunkIndex!==o)throw new Error(`parseMergeConflictDiffFromFile: conflict ${t} spans multiple hunks and cannot be anchored`);if(r.startContentIndex<0&&(r.startContentIndex=i),r.endContentIndex=i,r.endMarkerContentIndex=i,n==="current"){r.currentContentIndex??=i;return}if(n==="base"){r.baseContentIndex??=i;return}r.incomingContentIndex=i}function Fi(e,t,n,i){const s=e.hunkContent,r=s[s.length-1];return r?.type==="change"?(t==="addition"?r.additions++:r.deletions++,s.length-1):(s.push({type:"change",additions:t==="addition"?1:0,deletions:t==="deletion"?1:0,additionLineIndex:n,deletionLineIndex:i}),s.length-1)}function ut(e,t,n){let i=t.contextBufferCount,s=t.contextBufferAdditionStart,r=t.contextBufferDeletionStart;if(n==="leading"&&i>e.maxContextLines){const h=i-e.maxContextLines;s+=h,r+=h,i=e.maxContextLines,t.additionStart+=h,t.deletionStart+=h,t.additionLineIndex+=h,t.deletionLineIndex+=h}if(n==="trailing"&&i>e.maxContextLines&&(i=e.maxContextLines),i===0){t.contextBufferCount=0,t.contextBufferBaseConflicts=void 0;return}const o=t.hunkContent,a=o[o.length-1];let l;a?.type==="context"?(a.lines+=i,l=o.length-1):(o.push({type:"context",lines:i,additionLineIndex:s,deletionLineIndex:r}),l=o.length-1),t.additionCount+=i,t.deletionCount+=i;const d=t.contextBufferBaseConflicts;if(d!=null){const h=s-t.contextBufferAdditionStart;for(const[u,c]of d)u>=h&&u<h+i&&on(e,c,"base",l)}t.contextBufferCount=0,t.contextBufferBaseConflicts=void 0}function an(e){if(e.activeHunk==null)return;const t=e.activeHunk;if(e.activeHunk=void 0,t.hunkContent.length===0)return;let n=0,i=0;for(const l of t.hunkContent)l.type==="context"?(n+=l.lines,i+=l.lines):(n+=Math.max(l.additions,l.deletions),i+=l.additions+l.deletions);const s=t.additionCount===0?t.additionStart-1:t.additionStart,r=t.deletionCount===0?t.deletionStart-1:t.deletionStart,o=Math.max(xe(s,t.additionCount)-e.lastHunkEnd,0),a={collapsedBefore:o,additionStart:s,additionCount:t.additionCount,additionLines:t.additionLines,additionLineIndex:t.additionLineIndex,deletionStart:r,deletionCount:t.deletionCount,deletionLines:t.deletionLines,deletionLineIndex:t.deletionLineIndex,hunkContent:t.hunkContent,hunkContext:void 0,hunkSpecs:`@@ -${Rt(r,t.deletionCount)} +${Rt(s,t.additionCount)} @@
|
|
4
4
|
`,splitLineStart:e.splitLineCount+o,splitLineCount:n,unifiedLineStart:e.unifiedLineCount+o,unifiedLineCount:i,noEOFCRAdditions:!1,noEOFCRDeletions:!1};e.hunks.push(a),e.splitLineCount+=o+n,e.unifiedLineCount+=o+i,e.lastHunkEnd=q(s,t.additionCount)}function Ni(e){if(e.activeHunk==null)return;const t=e.activeHunk,n=t.contextBufferCount,i=n-e.maxContextLines2,s=t.contextBufferAdditionStart+n-e.maxContextLines,r=t.contextBufferDeletionStart+n-e.maxContextLines;let o;if(t.contextBufferBaseConflicts!=null){const d=n-e.maxContextLines;for(const[h,u]of t.contextBufferBaseConflicts)h>=d&&(o??=new Map,o.set(h-d,u))}ut(e,t,"trailing");const a=t.additionCount,l=t.deletionCount;an(e),e.activeHunk=ln(t.additionStart+a+i,t.deletionStart+l+i),e.activeHunk.contextBufferAdditionStart=s,e.activeHunk.contextBufferDeletionStart=r,e.activeHunk.contextBufferCount=e.maxContextLines,e.activeHunk.contextBufferBaseConflicts=o}function wt(e,t,n=-1){const i=rn(e);i.contextBufferCount===0&&(i.contextBufferAdditionStart=e.additionLines.length,i.contextBufferDeletionStart=e.deletionLines.length),e.additionLines.push(t),e.deletionLines.push(t),n>=0&&(i.contextBufferBaseConflicts??=new Map,i.contextBufferBaseConflicts.set(i.contextBufferCount,n)),i.contextBufferCount++}function Et(e,t,n,i,s){let r=rn(e);r.hunkContent.length>0&&r.contextBufferCount>e.maxContextLines2&&(Ni(e),r=e.activeHunk),ut(e,r,r.hunkContent.length===0?"leading":"before-change");const o=e.additionLines.length,a=e.deletionLines.length;t==="addition"?e.additionLines.push(n):e.deletionLines.push(n);const l=Fi(r,t,o,a);t==="addition"?(r.additionCount++,r.additionLines++):(r.deletionCount++,r.deletionLines++),on(e,i,s,l)}function Pi(e,t,n,i){if(t.separatorLineIndex==null||t.markerLines.separator==null)throw new Error(`parseMergeConflictDiffFromFile: conflict ${t.conflictIndex} is missing a separator marker`);const s=e.conflictBuilders[t.conflictIndex];if(s==null)throw new Error(`parseMergeConflictDiffFromFile: failed to finalize conflict ${t.conflictIndex}`);const r=s.action;r.markerLines.separator=t.markerLines.separator,r.markerLines.end=i,t.markerLines.base!=null&&(r.markerLines.base=t.markerLines.base),r.conflict={conflictIndex:t.conflictIndex,startLineIndex:t.startLineIndex,startLineNumber:t.startLineIndex+1,separatorLineIndex:t.separatorLineIndex,separatorLineNumber:t.separatorLineIndex+1,endLineIndex:n,endLineNumber:n+1,baseMarkerLineIndex:t.baseMarkerLineIndex,baseMarkerLineNumber:t.baseMarkerLineIndex!=null?t.baseMarkerLineIndex+1:void 0};const o=r.currentContentIndex??r.incomingContentIndex;if(r.currentContentIndex??=o,r.incomingContentIndex??=o,r.startContentIndex<0&&o!=null&&(r.startContentIndex=o),r.endContentIndex<0&&o!=null&&(r.endContentIndex=o),r.endMarkerContentIndex<0&&o!=null&&(r.endMarkerContentIndex=o),r.hunkIndex<0||r.startContentIndex<0||r.endContentIndex<0||r.endMarkerContentIndex<0)throw new Error(`parseMergeConflictDiffFromFile: failed to anchor merge conflict ${t.conflictIndex}`);e.actions[r.conflictIndex]=r,s.completed=!0}function At(e,t,n){const i=e.nextConflictIndex;e.nextConflictIndex++,e.conflictStack.push({conflictIndex:i,stage:"current",startLineIndex:n,markerLines:{start:t}}),e.conflictBuilders[i]={completed:!1,action:{conflict:{conflictIndex:i,startLineIndex:n,startLineNumber:n+1,separatorLineIndex:n,separatorLineNumber:n+1,endLineIndex:n,endLineNumber:n+1,baseMarkerLineIndex:void 0,baseMarkerLineNumber:void 0},conflictIndex:i,hunkIndex:-1,startContentIndex:-1,endContentIndex:-1,endMarkerContentIndex:-1,markerLines:{start:t,separator:"",end:""}}}}function ln(e,t){return{additionStart:e,deletionStart:t,additionCount:0,deletionCount:0,additionLines:0,deletionLines:0,additionLineIndex:Math.max(e-1,0),deletionLineIndex:Math.max(t-1,0),hunkContent:[],contextBufferAdditionStart:Math.max(e-1,0),contextBufferDeletionStart:Math.max(t-1,0),contextBufferCount:0,contextBufferBaseConflicts:void 0}}function Rt(e,t){return t===1?`${e}`:`${e},${t}`}function bt(e){if(e.length<7)return;const t=e.charCodeAt(0);if(t!==60&&t!==62&&t!==61&&t!==124)return;const n=zi(e);if(n<7)return;let i=1;for(;i<n&&e.charCodeAt(i)===t;)i++;if(!(i<7)){if(t===61)return i===n?"separator":void 0;if(!(i!==n&&!Bi(e.charCodeAt(i))))return t===60?"start":t===62?"end":"base"}}function zi(e){let t=e.length;return t>0&&e.charCodeAt(t-1)===10&&t--,t>0&&e.charCodeAt(t-1)===13&&t--,t}function Bi(e){return e===9||e===10||e===11||e===12||e===13||e===32}function Tt(e,t,n){return{...e,contents:n,cacheKey:e.cacheKey!=null?`${e.cacheKey}:merge-conflict-${t}`:void 0}}function Oi(e,t){const n=[],i=new Array(e.hunks.length),s=(o,a)=>{const l=e.hunks[o];if(l==null)return 0;let d=i[o];if(d==null){d=new Array(l.hunkContent.length+1);let h=l.unifiedLineStart;d[0]=h;for(let u=0;u<l.hunkContent.length;u++){const c=l.hunkContent[u];h+=c.type==="context"?c.lines:c.deletions+c.additions,d[u+1]=h}i[o]=d}return d[Math.max(a,0)]??l.unifiedLineStart},r=(o,a)=>{const l=s(o,a),d=i[o]?.[Math.max(a+1,0)]??s(o,a+1);return Math.max(l,d-1)};for(const o of t){if(o==null)continue;const a=e.hunks[o.hunkIndex];if(a==null)continue;const l=s(o.hunkIndex,o.startContentIndex);if(n.push(fe(o,"marker-start",o.startContentIndex,o.markerLines.start,l)),o.baseContentIndex!=null){const f=o.currentContentIndex,p=o.incomingContentIndex;if(f==null||p==null)continue;const g=o.markerLines.base;if(g==null)continue;const x=a.hunkContent[f],m=a.hunkContent[o.baseContentIndex],L=a.hunkContent[p];if(x?.type!=="change"||m?.type!=="context"||L?.type!=="change")continue;const v=s(o.hunkIndex,f),C=s(o.hunkIndex,p);n.push(fe(o,"marker-base",o.baseContentIndex,g,v+x.deletions)),n.push(fe(o,"marker-separator",o.baseContentIndex,o.markerLines.separator,C),fe(o,"marker-end",o.endMarkerContentIndex,o.markerLines.end,r(o.hunkIndex,o.endMarkerContentIndex)));continue}const d=o.currentContentIndex;if(d==null)continue;const h=a.hunkContent[d];if(h?.type!=="change")continue;const u=s(o.hunkIndex,d),c=h.deletions>0?u+h.deletions:l;n.push(fe(o,"marker-separator",d,o.markerLines.separator,c),fe(o,"marker-end",o.endMarkerContentIndex,o.markerLines.end,r(o.hunkIndex,o.endMarkerContentIndex)))}return n}function fe(e,t,n,i,s){return{type:t,hunkIndex:e.hunkIndex,contentIndex:n,conflictIndex:e.conflictIndex,lineText:i,lineIndex:s}}function Ui(e,t){let n=e.unifiedLineStart;for(let i=0;i<t;i++){const s=e.hunkContent[i];n+=s.type==="context"?s.lines:s.deletions+s.additions}return n}function Vi({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:i,renderHeaderFilenameSuffix:s,renderHeaderMetadata:r,renderAnnotation:o,renderGutterUtility:a,renderMergeConflictUtility:l,lineAnnotations:d,getHoveredLine:h,getInstance:u}){const c=n?.(e),f=i?.(e),p=s?.(e),g=r?.(e);return k.jsxs(k.Fragment,{children:[c!=null?k.jsx("div",{slot:sn,children:c}):k.jsxs(k.Fragment,{children:[f!=null&&k.jsx("div",{slot:"header-prefix",children:f}),p!=null&&k.jsx("div",{slot:"header-filename-suffix",children:p}),g!=null&&k.jsx("div",{slot:"header-metadata",children:g})]}),o!=null&&d?.map((x,m)=>k.jsx("div",{slot:Se(x),children:o(x)},m)),t!=null&&l!=null&&u!=null&&t.map(x=>{if(x==null)return;const m=ji(x,e);return k.jsx("div",{slot:m,style:gn,children:l(x,u)},m)}),a!=null&&k.jsx("div",{slot:"gutter-utility-slot",style:mn,children:a(h)})]})}function ji(e,t){const n=Ii(e,t);return n!=null?Di({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}class $i extends Cn{constructor(){super(...arguments),this.tokenize=Wi}equals(t,n,i){return i.ignoreWhitespace?((!i.newlineIsToken||!t.includes(`
|
package/dist/client/assets/{EditableFileViewer-CmxzBnAY.js → EditableFileViewer-Cv3aNJBN.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as l}from"./react-rd22PHbN.js";import{V as w,O as j,P as k,a as
|
|
1
|
+
import{r as n,j as l}from"./react-rd22PHbN.js";import{V as w,O as j,P as k,a as N,u as A}from"./PierreWorkerPool-BuBzE8K1.js";import{F as O}from"./File-DiOOsHOl.js";import{c as I,s as x,T as V,a as z,b as K}from"./index-BOPi2b1j.js";import{E as P}from"./edit-ready-context-D77R8XU8.js";import{a2 as M,a3 as C,a4 as D}from"./App-CBetJ5ZN.js";const U=[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M10 14a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]],q=I("outline","device-floppy","DeviceFloppy",U),b={stableFrames:3,maxFrames:60,userScrollTolerance:2};function B(e,t,r={}){const s=r.stableFrames??b.stableFrames,o=r.maxFrames??b.maxFrames,p=r.userScrollTolerance??b.userScrollTolerance,E=r.requestFrame??(i=>requestAnimationFrame(i)),T=r.cancelFrame??(i=>cancelAnimationFrame(i)),S=Number.isFinite(t)?Math.min(1,Math.max(0,t)):0;let f=null,F=0,m=0,c=null,a=null,y=!1;const R=()=>{y=!0,f!==null&&T(f),f=null},v=()=>{if(f=null,y)return;F+=1;const i=e.getContentHeight();if(a!==null&&c===i&&Math.abs(e.getScrollTop()-a)>p){R();return}const u=e.getScrollRange(),h=u>0?S*u:0;if(e.scrollTo(h),a=h,m=i>0&&c===i?m+1:0,c=i,m>=s||F>=o){R();return}f=E(v)};return v(),R}function G(e){const t=e.split("+"),r=t.pop().toLowerCase();return[...t.map(o=>o==="Ctrl"?"cmdOrCtrl":o.toLowerCase()),r].join("+")}function H(e){return[{bindings:{[G(e)]:"openSearchReplacePanel"}}]}H(M.editorSearch);const W=2e3;function $(e,t=W){let r=1;for(let s=0;s<e.length;s+=1)if(e.charCodeAt(s)===10&&(r+=1,r>t))return!0;return!1}function Y(e,t,r=M.saveFile){return D({key:e.key,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey??!1,altKey:e.altKey??!1},r)?(e.preventDefault(),t(),!0):!1}async function Z(e){if(!e.dirty||e.readOnly||!e.claim())return"skipped";try{return(await e.persist()).status==="conflict"?(e.onConflict(),"conflict"):(e.onSuccess(),"saved")}catch(t){return e.onError(t),"error"}finally{e.release()}}function J({file:e,initialContent:t,readOnly:r,messages:s,onDirtyChange:o,onDraftChange:p,onSave:E}){const T=C(),[S,f]=n.useState(t),[F,m]=n.useState(!1),c=n.useRef(!1),a=S!==e.content,y=n.useRef(e.content);n.useLayoutEffect(()=>{S===y.current&&e.content!==y.current&&f(e.content),y.current=e.content},[e.content,S]),n.useEffect(()=>{o(a)},[a,o]),n.useEffect(()=>()=>o(!1),[o]);const R=n.useCallback(u=>{f(u),o(u!==e.content),p(u)},[e.content,o,p]),v=n.useCallback(async()=>{await Z({dirty:a,readOnly:r,claim:()=>c.current?!1:(c.current=!0,m(!0),!0),release:()=>{c.current=!1,m(!1)},persist:()=>E(e.path,S,e.content),onConflict:()=>x.error({title:s.conflictTitle,description:"Your draft is still open. Copy it or reload the file before saving again.",duration:1e4}),onSuccess:()=>x.success({title:s.successTitle,description:e.path}),onError:u=>x.error({title:s.errorTitle,description:u instanceof Error?u.message:"Unknown error",duration:1e4})})},[a,S,e.content,e.path,s,E,r]),i=n.useRef(v);return n.useEffect(()=>{i.current=v},[v]),n.useEffect(()=>{const u=h=>{Y(h,()=>{i.current()},T.saveFile)};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[T.saveFile]),{draft:S,updateDraft:R,dirty:a,saving:F,save:v}}function L({dirty:e,saving:t,readOnly:r,onSave:s}){const o=C();if(!e&&!t)return null;const p=r?"Read only":t?"Saving…":`Save file (${o.saveFile})`;return l.jsxs(V,{children:[l.jsx(z,{render:l.jsx("button",{type:"button",className:"file-save-button","data-state":r?"readonly":t?"saving":"dirty",disabled:t||r,onClick:s,"aria-label":p}),children:l.jsx(q,{"aria-hidden":"true"})}),l.jsx(K,{children:p})]})}function Q({handleRef:e}){const t=A();return n.useLayoutEffect(()=>{e.current=t},[t,e]),null}function _({path:e,cacheKey:t,value:r,themeType:s,wrapLines:o,readOnly:p,onChange:E,ref:T}){const S=n.useContext(P),f=C(),[F]=n.useState(()=>$(r)),m=n.useRef(E);n.useEffect(()=>{m.current=E},[E]);const c=n.useRef(void 0),a=n.useRef(null),y=n.useMemo(()=>({name:e,contents:r,cacheKey:t}),[t,e,r]),R=n.useMemo(()=>({disableFileHeader:!0,themeType:s,theme:j,overflow:o?"wrap":"scroll",unsafeCSS:w}),[s,o]),v=n.useMemo(()=>({historyMaxEntries:500,keymap:H(f.editorSearch),onChange(h){m.current(h.contents)}}),[f.editorSearch]),i=n.useRef(null);n.useEffect(()=>()=>i.current?.(),[]),n.useImperativeHandle(T,()=>({getScrollFraction(){const h=c.current?.getRoot()??a.current;if(!(h instanceof HTMLElement))return 0;const d=h.scrollHeight-h.clientHeight;return d>0?h.scrollTop/d:0},scrollToFraction(h){i.current?.(),i.current=B({getScrollRange(){const d=c.current?.getRoot()??a.current;return d instanceof HTMLElement?Math.max(0,d.scrollHeight-d.clientHeight):0},getScrollTop(){const d=c.current?.getRoot()??a.current;return d instanceof HTMLElement?d.scrollTop:0},getContentHeight(){const d=c.current?.getRoot()??a.current;return d instanceof HTMLElement?d.scrollHeight:0},scrollTo(d){const g=c.current;g&&g.getRoot()instanceof HTMLElement?g.scrollTo({top:d}):a.current?.scrollTo({top:d})}},h)}}),[]);const u=l.jsx(O,{file:y,options:R,editorOptions:v,edit:S&&!p});return l.jsx(k,{theme:j,children:F?l.jsxs(N,{className:"source-code-editor",contentClassName:"source-code-editor-content",children:[l.jsx(Q,{handleRef:c}),u]}):l.jsx("div",{ref:a,className:"source-code-editor",children:l.jsx("div",{className:"source-code-editor-content",children:u})})})}const X={conflictTitle:"File was changed outside OpenTig",successTitle:"File saved",errorTitle:"Could not save file"};function ee({file:e,initialContent:t,themeType:r,wrapLines:s,readOnly:o,onDirtyChange:p,onDraftChange:E,onSave:T}){const{draft:S,updateDraft:f,dirty:F,saving:m,save:c}=J({file:e,initialContent:t,readOnly:o,messages:X,onDirtyChange:p,onDraftChange:E,onSave:T});return l.jsxs("div",{className:"source-file-viewer",children:[(F||m)&&l.jsx("div",{className:"source-file-toolbar",children:l.jsx(L,{dirty:F,saving:m,readOnly:o,onSave:()=>{c()}})}),l.jsx("div",{className:"source-editor-scroll",children:l.jsx(_,{path:e.path,cacheKey:e.path,value:S,themeType:r,wrapLines:s,readOnly:o||m,onChange:f})})]})}const ae=Object.freeze(Object.defineProperty({__proto__:null,EditableFileViewer:ee,FileSaveControls:L,SourceCodeEditor:_},Symbol.toStringTag,{value:"Module"}));export{ae as E,L as F,_ as S,B as s,J as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as ge,g as k,D as H,a as j,l as $,b as ee,E as xe,i as Ee,H as Fe,c as ke,d as ze,e as Ie,f as Oe}from"./platform-BMNQ8V5r.js";import{G as Pe,b as te,g as Ne,c as A,i as Y,d as R,e as Ve,f as me,h as ie,j as De,k as Be,r as Ue,s as Ce,l as _e,m as ne,n as re,o as We,p as Ge,q as se,t as je,v as $e,w as Ke,x as qe,y as oe,z as Ye,R as Xe,I as Je,A as ae,B as Qe,C as Ze,D as et,E as tt,F as it,H as nt,J as he,K as rt,L as st,M as ot,N as at,Q as le,S as ht,T as lt,U as dt,W as ct,X as ut,Y as ft,Z as Se,_ as de,$ as V,a0 as ce,a1 as pt,u as gt,a2 as mt,a3 as ue,a4 as Ct}from"./PierreWorkerPool-B2iHe3DC.js";import{j as y,r as F}from"./react-rd22PHbN.js";import{t as b}from"./one-light-CoLDteqg.js";import{u as St,a as vt}from"./EditContext-CvJWfVl1.js";function yt({file:i,renderCustomHeader:e,renderHeaderPrefix:t,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:o,renderGutterUtility:a,getHoveredLine:l}){const d=e?.(i),h=t?.(i),c=n?.(i),u=r?.(i);return y.jsxs(y.Fragment,{children:[d!=null?y.jsx("div",{slot:ge,children:d}):y.jsxs(y.Fragment,{children:[h!=null&&y.jsx("div",{slot:"header-prefix",children:h}),c!=null&&y.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&y.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&o?.map((f,m)=>y.jsx("div",{slot:k(f),children:s(f)},m)),a!=null&&y.jsx("div",{slot:"gutter-utility-slot",style:Pe,children:a(l)})]})}function D(i,e){return e.cacheKey==null?i.file===e&&i.sourceContents===e.contents:i.cacheKey===e.cacheKey}let Rt=-1;var Tt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++Rt}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;constructor(i={theme:H},e,t){this.options=i,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=te(i.theme??H)?Ne():void 0)}setOptions(i){this.options=i}mergeOptions(i){this.options={...this.options,...i}}setLineAnnotations(i){this.lineAnnotations={};for(const e of i){const t=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=t,t.push(e)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(){this.editSessionActive=!0}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){const{renderCache:i,lineCache:e}=this;i?.isDirty!==!0||e==null||!D(e,i.file)||(i.file.contents=e.lines.join(""))}hasUnkeyedFileContentsChanged(i){const{lineCache:e}=this;return i.cacheKey==null&&e!=null&&e.file===i&&e.sourceContents!==i.contents}invalidateChangedUnkeyedFile(i){this.hasUnkeyedFileContentsChanged(i)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile(),this.pendingStructuralRows=void 0;const i=this.renderCache;this.renderCache=void 0,i!=null&&i.isDirty===!0&&i.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(i.file.cacheKey)}hydrate(i){const{options:e}=this.getRenderOptions(i),t=K(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());let n=this.workerManager?.getFileResultCache(i);n!=null&&!A(e,n.options)&&(n=void 0),this.renderCache??={file:i,options:e,highlighted:!t&&!Y(i),result:t?void 0:n?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightFileAST(this,i):this.highlighter==null&&(this.computedLang=i.lang??j(i.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??H}getEffectiveCodeOptions(){const i=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:i?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(i){const e=(()=>{if(this.workerManager?.isWorkingPool()===!0){const r=this.workerManager.getFileRenderOptions();return this.editSessionActive&&r.useTokenTransformer!==!0?{...r,useTokenTransformer:!0}:r}const{tokenizeMaxLineLength:n=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:n}})(),{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!R(i,t.file)||!A(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getOrCreateLineCache(i){this.invalidateChangedUnkeyedFile(i);let{lineCache:e}=this;return(e==null||!D(e,i))&&(e={cacheKey:i.cacheKey,file:i,sourceContents:i.contents,lines:$(i.contents)}),this.lineCache=e,e.lines}getLineCount(i){const e=this.getOrCreateLineCache(i);return this.textDocumentCache.get(i)?.lineCount??e.length}updateRenderCache(i,e,t=!1){if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:n,result:r}=this.renderCache;if(r==null)return;const s=t?new Map:void 0;this.pendingStructuralRows=s;const o=this.lineCache!=null&&D(this.lineCache,n)?this.lineCache:void 0;for(const[a,l]of i){if(s===void 0&&o!=null&&a<o.lines.length){const h=l.map(c=>c[2]).join("");o.lines[a]=Ve(o.lines[a]??"",h)}const d={type:"element",tagName:"div",properties:{"data-line":a+1,"data-line-type":"context","data-line-index":a},children:l.map(([h,c,u])=>h===0&&c===""?u===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:u}:{type:"element",tagName:"span",properties:{"data-char":h,style:`color:${c};`},children:[{type:"text",value:u}]})};s!==void 0?s.set(a,d):r.code[a]=d}r.baseThemeType=e,this.renderCache.isDirty=!0}applyDocumentChange(i){const e=this.pendingStructuralRows;if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:t,result:n}=this.renderCache;if(n==null)return;const r=this.lineCache!=null&&D(this.lineCache,t)?this.lineCache.lines:$(t.contents),s=$(i.getText());if(r.length!==s.length){const o=Math.min(r.length,s.length);let a=0;for(;a<o&&r[a]===s[a];)a++;let l=0;for(;l<o-a&&r[r.length-1-l]===s[s.length-1-l];)l++;const d=n.code;n.code=new Array(s.length);for(let h=0;h<a;h++)n.code[h]=d[h];for(let h=0;h<l;h++)n.code[s.length-1-h]=d[r.length-1-h];if(e!==void 0)for(const[h,c]of e)h<s.length&&(n.code[h]=c);for(let h=a;h<s.length-l;h++)n.code[h]??={type:"element",tagName:"div",properties:{"data-line":h+1,"data-line-type":"context","data-line-index":h},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:i.getLineText(h)}]}]};for(let h=0;h<n.code.length;h++){const c=n.code[h];c?.type==="element"&&(c.properties["data-line"]=h+1,c.properties["data-line-index"]=h)}this.renderCache.isDirty=!0}this.lineCache={cacheKey:t.cacheKey,file:t,sourceContents:t.contents,lines:s},this.textDocumentCache.set(t,i)}renderFile(i=this.renderCache?.file,e=ee){if(i==null)return;this.invalidateChangedUnkeyedFile(i),this.renderCache?.isDirty===!0&&!R(i,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:t,forceHighlight:n}=this.getRenderOptions(i);this.renderCache?.isDirty===!0&&!A(t,this.renderCache.options)&&this.clearRenderCache();const r=this.getMatchingWorkerResultCache(i,t);r!=null&&!this.hasHighlightedRenderCache(i,t)&&(this.renderCache={file:i,highlighted:!0,renderRange:void 0,...r},n=!1),this.renderCache??={file:i,highlighted:!1,options:t,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(i),o=i.contents.length>0,a=!o||Y(i)||K(s.length,this.getTokenizeMaxLength()),l=!R(i,this.renderCache.file),d=!me(this.renderCache.renderRange,e);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)(a||this.renderCache.result==null||!this.renderCache.highlighted&&(l||d))&&(this.renderCache.file=i,this.renderCache.options=t,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||d||n)&&(this.renderCache.result=this.workerManager.getPlainFileAST(i,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!a&&o&&(!this.renderCache.highlighted||n)&&this.workerManager.highlightFileAST(this,i);else{this.computedLang=i.lang??j(i.name);const h=this.highlighter!=null&&te(t.theme),c=this.highlighter!=null&&ie(this.computedLang),u=!a&&c;if(this.highlighter!=null&&h&&(n||a||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:f,options:m}=this.renderFileWithHighlighter(i,this.highlighter,a||!c);this.renderCache={file:i,options:m,highlighted:u,result:f,renderRange:void 0}}(!h||!a&&!c)&&this.asyncHighlight(i).then(({result:f,options:m})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(i,f,m,!a)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(i,e=ee){const{result:t}=await this.asyncHighlight(i);return this.processFileResult(i,e,t)}async asyncHighlight(i){const e=K(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());this.computedLang=e?"text":i.lang??j(i.name);const t=this.highlighter!=null&&De(Be(this.getLocalHighlightTheme())),n=e||this.highlighter!=null&&ie(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(i,this.highlighter,e)}renderFileWithHighlighter(i,e,t=!1){const{options:n}=this.getRenderOptions(i);return{result:Ue(i,e,n,{forcePlainText:t}),options:n}}processFileResult(i,e,{code:t,themeStyles:n,baseThemeType:r}){const s=this.getLineCount(i),{disableFileHeader:o=!1}=this.options,a=[],l=oe(),d=Math.min(e.startingLine+e.totalLines,s);let h=0;const c=Ce(e)?_e(this.lineAnnotations):void 0;c!=null&&(l.children.push(ne("context","annotation",1)),a.push(re({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>k(u))})),h++);for(let u=e.startingLine;u<d;u++){const f=u+1,m=t[u];if(m==null){const C="FileRenderer.processFileResult: Line doesnt exist";throw console.error(C,{name:i.name,lineIndex:u,lineNumber:f}),new Error(C)}l.children.push(We("context",f,`${u}`)),a.push(m),h++;const g=this.lineAnnotations[f];g!=null&&(l.children.push(ne("context","annotation",1)),a.push(re({hunkIndex:0,lineIndex:f,annotations:g.map(C=>k(C))})),h++)}return l.properties.style=`grid-row: span ${h}`,{gutterAST:l.children??[],contentAST:a,preAST:this.createPreElement(s),headerAST:o?void 0:this.renderHeader(i),totalLines:s,rowCount:h,themeStyles:n,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(i){const{headerRenderMode:e="default",stickyHeader:t=!1}=this.options;return Ge({fileOrDiff:i,mode:e,stickyHeader:t})}renderFullHTML(i){return b(this.renderFullAST(i))}renderFullAST(i,e=[]){return e.push(se({tagName:"code",children:this.renderCodeAST(i),properties:{"data-code":""}})),{...i.preAST,children:e}}renderCodeAST(i){const e=oe();return e.children=i.gutterAST,e.properties.style=`grid-row: span ${i.rowCount}`,[e,je(i.contentAST,i.rowCount)]}renderPartialHTML(i,e=!1){return e?b(se({tagName:"code",children:i,properties:{"data-code":""}})):b(i)}async initializeHighlighter(){return this.highlighter=await $e(Ke(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(i,e,t,n=!0){this.editSessionActive||this.applyHighlightResult(i,e,t,n)}applyHighlightResult(i,e,t,n=!0){if(this.renderCache==null)return;const r=!R(i,this.renderCache.file)||!this.renderCache.highlighted||!A(t,this.renderCache.options);this.renderCache={file:i,options:t,highlighted:n,result:e,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(i,e){if(this.editSessionActive)return;const t=this.workerManager?.getFileResultCache(i);if(!(t==null||!A(e,t.options)))return t}hasHighlightedRenderCache(i,e){const{renderCache:t}=this;return t?.result!=null&&t.highlighted&&R(i,t.file)&&A(e,t.options)}onHighlightError(i){console.error(i)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(i){const{disableLineNumbers:e=!1,overflow:t="scroll"}=this.options;return qe({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:t,split:!1,totalLines:i})}};function K(i,e){return i>e}function Lt(i,e){return i.lineNumber===e.lineNumber&&i.metadata===e.metadata}function fe(i){return{theme:i?.theme,disableLineNumbers:i?.disableLineNumbers,overflow:i?.overflow,themeType:i?.themeType,collapsed:i?.collapsed,disableFileHeader:i?.disableFileHeader,disableVirtualizationBuffers:i?.disableVirtualizationBuffers,stickyHeader:i?.stickyHeader,preferredHighlighter:i?.preferredHighlighter,useCSSClasses:i?.useCSSClasses,useTokenTransformer:Ye(i),tokenizeMaxLineLength:i?.tokenizeMaxLineLength,tokenizeMaxLength:i?.tokenizeMaxLength,unsafeCSS:i?.unsafeCSS,headerRenderMode:i?.renderCustomHeader!=null?"custom":"default"}}const Mt=[""];let At=-1;var ve=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++At}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:H},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new Tt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new Xe,this.interactionManager=new Je("file",ae(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ae(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Qe(this.appliedThemeCSS.theme,this.options.theme??H)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e==="wrap",columnVariables:this.shouldApplyColumnVariables(e)?"apply":"measure"}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e==="scroll"&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:s,lineAnnotations:o}=e;if(!this.enabled)throw new Error("File.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw new Error("File.hydrate: hydrate can only be called before the instance has rendered or hydrated");this.hydrateElements(t,n),Ht(this.pre,s,this.options.collapsed)||bt(this.headerElement,s,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:s,lineAnnotations:o}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Ze(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(fe(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):Mt}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,s=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(o=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(o,t,n,r,s)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.fileRenderer.beginEditSession();const t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.fileRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),()=>{this.editor=void 0,this.fileRenderer.endEditSession()}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t,n){this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render(e){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");const t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:s,deferManagers:o=!1,lineAnnotations:a,renderRange:l}){this.editor?.__postponeBgTokenizeToNextFrame();const{collapsed:d=!1,themeType:h="system"}=this.options,c=d?void 0:l,u=this.renderRange,f=this.hasThemeChanged(),m=a!=null&&(a.length>0||this.lineAnnotations.length>0)?a!==this.lineAnnotations:!1,g=!R(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!d&&!n&&me(c,this.renderRange)&&!g&&!m&&!f)return this.applyCachedThemeState(h);this.renderRange=c,g&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(fe(this.options)),this.syncInteractionOptions(),a!=null&&this.setLineAnnotations(a),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:C=!1,disableFileHeader:S=!1}=this.options;if(S&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,s),this.applyCachedThemeState(h),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const p=this.fileRenderer.renderFile(e,xe);p!=null&&this.applyThemeState(t,p.themeStyles,h,p.baseThemeType),p?.headerAST!=null&&this.applyHeaderToDOM(p.headerAST,t),this.injectUnsafeCSS()}catch(p){if(C)throw p;console.error(p),p instanceof Error&&this.applyErrorToDOM(p,t)}return r||this.emitPostRender(),!0}try{const p=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,m,g||f)||!this.applyPartialRender(u,c)){const v=this.fileRenderer.renderFile(e,c);if(v==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,v.themeStyles,h,v.baseThemeType),v.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.applyFullRender(v,p)}this.applyBuffers(p,c),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,o||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(p){if(C)throw p;console.error(p),p instanceof Error&&this.applyErrorToDOM(p,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const 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(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.file){const{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Y(e))return;const n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(r=>{console.error(r)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const s=`${n}-${k(r)}`;let o=this.annotationCache.get(s);if(o==null||!Lt(r,o.annotation)){o?.element.remove();const a=t(r);if(a==null)continue;o={element:et(k(r)),annotation:r},o.element.appendChild(a),this.fileContainer.appendChild(o.element),this.annotationCache.set(s,o)}e.delete(s)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=tt();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=it(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=nt(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){const s=e.shadowRoot??e.attachShadow({mode:"open"}),o=r??n,a=this.options.theme??H,l=typeof a=="string"?a:{...a},d=he(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===o&&this.appliedThemeCSS.scrollbarGutter===d){this.appliedThemeCSS.theme=l;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:l,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:d};return}this.themeCSSStyle=rt({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:ct(t,o,d)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:l,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:d}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=st(this.themeCSSStyle.textContent??"",he(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&Ee()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);const n=this.code=ot({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();const s=()=>{if(n.childElementCount>=2)for(let o=0;o<2;o++){const a=n.children[o],l=r[o];a.innerHTML=b(l.children),a.style.cssText=l.properties.style}else n.innerHTML=b(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?at(t,s):s(),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:r}=this,s=r!=null?this.getColumns(r):void 0;if(n==null||r==null||s==null)return!1;const o=e.startingLine,a=t.startingLine,l=e.totalLines===1/0?Number.POSITIVE_INFINITY:o+e.totalLines,d=t.totalLines===1/0?Number.POSITIVE_INFINITY:a+t.totalLines,h=Math.max(o,a),c=Math.min(l,d);if(c<=h)return!1;if(!this.trimDOMToOverlap(s.gutter,h,c)||!this.trimDOMToOverlap(s.content,h,c))throw new Error("File.applyPartialRender: failed to trim to overlap");let{length:u}=s.content.children;const f=(S,p)=>{if(!(p<=0))return this.fileRenderer.renderFile(n,{startingLine:S,totalLines:p,bufferBefore:0,bufferAfter:0})},m=a<h?f(a,h-a):void 0;if(m===void 0&&a<h)return!1;const g=d===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,d-c),C=d>c?f(c,g):void 0;return C===void 0&&d>c?!1:(this.cleanupErrorWrapper(),m!=null&&(s.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(m.gutterAST)),s.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(m.contentAST)),u+=m.rowCount),C!=null&&(s.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(C.gutterAST)),s.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(C.contentAST)),u+=C.rowCount),this.lastRowCount!==u&&(s.gutter.style.setProperty("grid-row",`span ${u}`),s.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const r=this.getDOMBoundaryIndices(e,[t,n]),s=r.get(t)??e.children.length,o=r.get(n)??e.children.length;if(s>o)return!1;for(let a=e.children.length-1;a>=o;a-=1)e.children[a]?.remove();for(let a=s-1;a>=0;a-=1)e.children[a]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((l,d)=>l-d),r=new Map;if(n.length===0)return r;let s=0,o=n[s];const{children:a}=e;o===0&&(r.set(0,0),s+=1,o=n[s]);for(let l=0;l<a.length;l+=1){const d=a[l];if(!(d instanceof HTMLElement))continue;const h=this.getLineIndexFromDOMNode(d);if(h!=null){for(;o!=null&&h>=o;)r.set(o,l),s+=1,o=n[s];if(s>=n.length)break}}for(const l of n)r.has(l)||r.set(l,a.length);return r}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const r=this.cachedHeaderHTML??b(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){const d=document.createElement("div");d.innerHTML=r;const h=d.firstElementChild;if(!(h instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(h,this.headerElement):t.shadowRoot?.prepend(h),this.headerElement=h,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;const{renderHeaderPrefix:s,renderHeaderFilenameSuffix:o,renderCustomHeader:a,renderHeaderMetadata:l}=this.options;if(a!=null){const d=a(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,ge,d),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const d=s?.(n)??void 0,h=o?.(n)??void 0,c=l?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Fe,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,ke,h),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ze,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}const s=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,r),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),s=n!==r;return n!=null&&s&&this.editor?.__captureFocusForDOMReplacement(),s&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:le(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):le(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=ht;const r=n.firstChild;r instanceof SVGElement&&(this.spriteSVG=r)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,s={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};lt(s,this.appliedPreAttributes)||(dt(e,s),this.appliedPreAttributes=s)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Ht(i,e,t=!1){return!t&&i==null&&e!=null}function bt(i,e,t=!1){return i==null&&e!=null&&!t}const wt=5e3;let xt=-1;function Et(i,e){return(i.overflow??"scroll")!==(e.overflow??"scroll")||(i.collapsed??!1)!==(e.collapsed??!1)||(i.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(i.disableFileHeader??!1)!==(e.disableFileHeader??!1)||i.unsafeCSS!==e.unsafeCSS}var Ft=class extends ve{virtualizer;metrics;__id=`virtualized-file:${++xt}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(i,e,t=Ie,n,r=!1){super(i,n,r),this.virtualizer=e,this.metrics=t}setMetrics(i,e=!1){const t=ut(i);!e&&ft(this.metrics,t)||(this.metrics=t,this.resetLayoutCache())}setLineAnnotations(i){this.syncLineAnnotations(i)&&this.resetLayoutCache()}syncLineAnnotations(i){return i==null||i===this.lineAnnotations||i.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(i),!0)}hasLineAnnotations(){return this.lineAnnotations.some(i=>i.lineNumber>0)}getLineHeight(i,e=!1){const t=this.cache.heights.get(i);if(t!=null)return t;const n=e?2:1;return this.metrics.lineHeight*n}setOptions(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(i==null)return;const{options:e}=this,t=!Se(e,i),n=Et(e,i);super.setOptions(i),n&&this.resetLayoutCache(!0),t&&(this.forceRenderOverride=!0),t&&this.virtualizer.instanceChanged(this,n)}setThemeType(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(i)}resetLayoutCache(i=!1,e=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&e&&(this.renderRange=void 0),i&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let i=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(i=!0),this.height=0,i;const{overflow:e="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),e==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return i;const t=this.code.children[1];if(!(t instanceof HTMLElement))return i;const n=de(this.lineAnnotations);if(this.renderRange!=null&&n&&Ce(this.renderRange)){const r=kt(t)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,i=!0)}else!n&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,i=!0);for(const r of t.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const o=Number(s);let a=r.getBoundingClientRect().height,l=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(l=!0),a+=r.nextElementSibling.getBoundingClientRect().height);const d=this.getLineHeight(o,l);a!==d&&(i=!0,a===this.metrics.lineHeight*(l?2:1)?this.cache.heights.delete(o):this.cache.heights.set(o,a))}return(i||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),i}onRender=i=>this.fileContainer==null||this.file==null?!1:(i&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(i,e,t,n){const r=this.syncLineAnnotations(n),s=!R(this.file,i)||this.fileRenderer.hasUnkeyedFileContentsChanged(i);let o=t?.resetFileLayoutCache===!0||s||r;t?.metrics!=null&&(this.metrics=t.metrics,o=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,o=!0),o&&this.resetLayoutCache(),this.file!==i&&(this.layoutDirty=!0),this.file=i,this.top=e,this.computeApproximateSize(),this.height}getLinePosition(i){if(this.file==null||i<1)return;const{disableFileHeader:e=!1,collapsed:t=!1}=this.options,n=this.fileRenderer.getLineCount(this.file)-1;let r=V(this.metrics,e);if(t||n<0)return{top:r,height:0};const s=Math.min(Math.max(i-1,0),n),{overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics;if(r+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())return{top:r+s*a,height:a};const l=this.getLayoutCheckpointBeforeLineIndex(s);r=l?.top??r;for(let d=l?.lineIndex??0;d<s;d++)r+=this.getLineHeight(d,!1);return{top:r,height:this.getLineHeight(s,!1)}}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(i){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:e=!1,collapsed:t=!1,overflow:n="scroll"}=this.options;if(t||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=V(this.metrics,e),o=Math.min(this.renderRange.startingLine,r),a=Math.min(o+this.renderRange.totalLines-1,r);if(a<o)return;const{fileAnnotationHeight:l}=this.cache;if(n==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:h}=this.metrics,c=s+(o===0?l:this.renderRange.bufferBefore),u=o+Math.max(Math.ceil((i-c)/h),0);return u>a?void 0:{lineNumber:u+1,top:s+l+u*h}}let d=s+(o===0?l:this.renderRange.bufferBefore);for(let h=o;h<=a;h++){if(d>=i)return{lineNumber:h+1,top:d};d+=this.getLineHeight(h)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(i){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const e=i!=null?this.computeRenderRangeFromWindow(this.file,this.top,i):this.renderRange;if(e==null)return;const{bufferBefore:t,bufferAfter:n,totalLines:r}=e;let s=0;if(r===0){const o=i??this.virtualizer.getWindowSpecs();this.top<o.top&&(s=n)}return{topOffset:this.top+t+s,height:this.height-(t+n)}}cleanUp(i=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),i||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(i)}computeApproximateSize(i=!1,e=this.file){const t=this.isResizeDebuggingEnabled();if(!i&&!this.layoutDirty&&!t)return;const n=this.height===0;if(this.height=0,this.cache.checkpoints=[],e==null){this.layoutDirty=!1;return}const{disableFileHeader:r=!1,collapsed:s=!1,overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(e),d=V(this.metrics,r),h=ce(this.metrics);if(this.height+=d,s){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())this.height+=l*a;else for(let c=0;c<l;c++)this.addLayoutCheckpoint(c,this.height),this.height+=this.getLineHeight(c,!1);if(l>0&&(this.height+=h),this.fileContainer!=null&&t&&!n){const c=this.fileContainer.getBoundingClientRect();c.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:e.name,elementHeight:c.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(i){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,i&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!i&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(i,e,t=!1){const{renderRange:n}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(i,e),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),!this.isSimpleMode())this.computeApproximateSize(!0);else if(t&&n!==void 0&&this.file!==void 0){const r=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(this.file,this.top??0,r);s.bufferAfter!==n.bufferAfter&&this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}renderPreparedFile({fileContainer:i,file:e,forceRender:t=!1,lineAnnotations:n,...r}){const s=this.file==null||!R(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e),{forceRenderOverride:o,isSetup:a}=this;this.forceRenderOverride=void 0;const l=this.syncLineAnnotations(n);if(l&&this.resetLayoutCache(),i=this.getOrCreateFileContainerNode(i),e==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(a)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,e));else{this.computeApproximateSize(!1,e);const f=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(f==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");f.connect(i,this),this.isVisible=f.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!s||!a))return this.file=e,s&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);const d=this.virtualizer.getWindowSpecs(),h=this.top??0,c=this.computeRenderRangeFromWindow(e,h,d),u=super.renderPreparedFile({file:e,fileContainer:i,renderRange:c,lineAnnotations:n,forceRender:(o??t)||l||s,...r});return this.isSimpleMode()&&u&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),u}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(i,e){i%wt===0&&this.cache.checkpoints.push({lineIndex:i,top:e})}getLayoutCheckpointBeforeLineIndex(i){if(i<=0||this.cache.checkpoints.length===0)return;let e=0,t=this.cache.checkpoints.length-1,n;for(;e<=t;){const r=e+t>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=i?(n=s,e=r+1):t=r-1}return n}getLayoutCheckpointBeforeTop(i,e){let t=0,n=this.cache.checkpoints.length-1,r=-1;for(;t<=n;){const s=t+n>>1,o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");o.top<=i?(r=s,t=s+1):n=s-1}if(e==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(o.lineIndex%e===0)return o}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(i,e,{top:t,bottom:n}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:o,lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(i),d=this.height,h=V(this.metrics,r),c=l>0?ce(this.metrics):0,{fileAnnotationHeight:u}=this.cache,f=h+u,m=Math.max(0,d-h-u-c),g=de(this.lineAnnotations),C=e+h,S=u>0&&g&&C<n&&C+u>t;if(e<t-d||e>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};if(l<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};const p=Math.ceil(Math.max(n-t,0)/a),v=Math.ceil(p/o)*o+o,z=v/o,B=(t+n)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const M=e+f,N=M+m;if(!S&&!(M<n&&N>t))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};const x=Math.floor(S&&B<e+f?0:(B-(e+f))/a),L=Math.floor(x/o)-Math.floor(z/2),He=Math.ceil(l/o),E=Math.max(0,Math.min(L,He))*o,Z=L<0?v+L*o:v,be=E===0?0:u+E*a,we=Math.min(Z,l-E);return{startingLine:E,totalLines:Z,bufferBefore:be,bufferAfter:Math.max(0,(l-E-we)*a)}}const ye=z,I=[],U=this.getLayoutCheckpointBeforeTop(Math.max(0,t-e-v*a*2),o);let T=e+(U?.top??f),_=U?.lineIndex??0,O,P,w;const Re=U?.lineIndex??0;for(let M=Re;M<l;M++){const N=_%o===0,x=Math.floor(_/o);if(N&&(I[x]=T-(e+f),w!=null)){if(w<=0)break;w--}const L=this.getLineHeight(M,!1);T>t-L&&T<n&&(O??=x),T+L>B&&(P??=x),w==null&&T>=n&&N&&(w=ye),_++,T+=L}if(O==null)if(S)O=0,P=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};P??=O;const W=Math.round(P-z/2),Te=Math.max(0,Math.ceil(l/o)-z),G=Math.max(0,Math.min(W,Te)),X=G*o,J=W<0?v+W*o:v,Le=I[G]??0,Me=X===0?0:u+Le,Q=G+J/o,Ae=Q<I.length?m-I[Q]:m-(T-e-f);return{startingLine:X,totalLines:J,bufferBefore:Me,bufferAfter:Math.max(0,Ae)}}};function kt(i){let e;for(const t of i.children)t instanceof HTMLElement&&t.dataset.lineAnnotation===pt&&(e=Math.max(e??0,t.getBoundingClientRect().height));return e}const pe=typeof window>"u"?F.useEffect:F.useLayoutEffect;function zt({file:i,options:e,editorOptions:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:s,metrics:o,hasGutterRenderUtility:a,hasCustomHeader:l,disableWorkerPool:d,edit:h}){const c=gt(),u=r!==void 0,f=F.useContext(mt),m=St(),g=F.useRef(null),C=vt(S=>{if(S!=null){if(g.current!=null)throw new Error("File: An instance should not already exist when a node is created");c!=null?g.current=new Ft(q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),c,o,d?void 0:f,!0):g.current=new ve(q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),d?void 0:f,!0),g.current.hydrate({file:i,fileContainer:S,lineAnnotations:n,prerenderedHTML:s})}else{if(g.current==null)throw new Error("File: A File instance should exist when unmounting");g.current.cleanUp(),g.current=null}});return pe(()=>{if(g.current==null)return;const S=q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),p=S!==void 0&&!Se(g.current.options,S);g.current.setOptions(S),g.current.render({file:i,lineAnnotations:n,forceRender:p}),r!==void 0&&g.current.setSelectedLines(r)}),pe(()=>{if(h&&g.current!=null){if(m===void 0)throw new Error("File: EditContext is not attached");const S=m(t??{});if(S==null)throw new Error("File: EditProvider.createEditor must return an editor instance");try{return S.edit(g.current)}catch(p){throw S.cleanUp(),p}}},[h]),{ref:C,getHoveredLine:F.useCallback(()=>g.current?.getHoveredLine(),[])}}function q({options:i,controlledSelection:e,hasCustomHeader:t,hasGutterRenderUtility:n}){return e||n||t?{...i,controlledSelection:e,renderCustomHeader:t?ue:i?.renderCustomHeader,renderGutterUtility:n?ue:i?.renderGutterUtility}:i}function Bt({file:i,lineAnnotations:e,selectedLines:t,options:n,editorOptions:r,metrics:s,className:o,style:a,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderFilenameSuffix:c,renderHeaderMetadata:u,prerenderedHTML:f,renderGutterUtility:m,disableWorkerPool:g=!1,edit:C=!1}){const{ref:S,getHoveredLine:p}=zt({file:i,options:n,editorOptions:r,metrics:s,lineAnnotations:e,selectedLines:t,prerenderedHTML:f,hasGutterRenderUtility:m!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:C});return y.jsx(Oe,{ref:S,className:o,style:a,children:Ct(yt({file:i,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderFilenameSuffix:c,renderHeaderMetadata:u,renderGutterUtility:m,lineAnnotations:e,getHoveredLine:p}),f)})}export{Bt as F};
|
|
1
|
+
import{C as ge,g as k,D as H,a as j,l as $,b as ee,E as xe,i as Ee,H as Fe,c as ke,d as ze,e as Ie,f as Oe}from"./platform-BMNQ8V5r.js";import{G as Pe,b as te,g as Ne,c as A,i as Y,d as R,e as Ve,f as me,h as ie,j as De,k as Be,r as Ue,s as Ce,l as _e,m as ne,n as re,o as We,p as Ge,q as se,t as je,v as $e,w as Ke,x as qe,y as oe,z as Ye,R as Xe,I as Je,A as ae,B as Qe,C as Ze,D as et,E as tt,F as it,H as nt,J as he,K as rt,L as st,M as ot,N as at,Q as le,S as ht,T as lt,U as dt,W as ct,X as ut,Y as ft,Z as Se,_ as de,$ as V,a0 as ce,a1 as pt,u as gt,a2 as mt,a3 as ue,a4 as Ct}from"./PierreWorkerPool-BuBzE8K1.js";import{j as y,r as F}from"./react-rd22PHbN.js";import{t as b}from"./one-light-CoLDteqg.js";import{u as St,a as vt}from"./EditContext-CvJWfVl1.js";function yt({file:i,renderCustomHeader:e,renderHeaderPrefix:t,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:o,renderGutterUtility:a,getHoveredLine:l}){const d=e?.(i),h=t?.(i),c=n?.(i),u=r?.(i);return y.jsxs(y.Fragment,{children:[d!=null?y.jsx("div",{slot:ge,children:d}):y.jsxs(y.Fragment,{children:[h!=null&&y.jsx("div",{slot:"header-prefix",children:h}),c!=null&&y.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&y.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&o?.map((f,m)=>y.jsx("div",{slot:k(f),children:s(f)},m)),a!=null&&y.jsx("div",{slot:"gutter-utility-slot",style:Pe,children:a(l)})]})}function D(i,e){return e.cacheKey==null?i.file===e&&i.sourceContents===e.contents:i.cacheKey===e.cacheKey}let Rt=-1;var Tt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++Rt}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;constructor(i={theme:H},e,t){this.options=i,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=te(i.theme??H)?Ne():void 0)}setOptions(i){this.options=i}mergeOptions(i){this.options={...this.options,...i}}setLineAnnotations(i){this.lineAnnotations={};for(const e of i){const t=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=t,t.push(e)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(){this.editSessionActive=!0}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){const{renderCache:i,lineCache:e}=this;i?.isDirty!==!0||e==null||!D(e,i.file)||(i.file.contents=e.lines.join(""))}hasUnkeyedFileContentsChanged(i){const{lineCache:e}=this;return i.cacheKey==null&&e!=null&&e.file===i&&e.sourceContents!==i.contents}invalidateChangedUnkeyedFile(i){this.hasUnkeyedFileContentsChanged(i)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile(),this.pendingStructuralRows=void 0;const i=this.renderCache;this.renderCache=void 0,i!=null&&i.isDirty===!0&&i.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(i.file.cacheKey)}hydrate(i){const{options:e}=this.getRenderOptions(i),t=K(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());let n=this.workerManager?.getFileResultCache(i);n!=null&&!A(e,n.options)&&(n=void 0),this.renderCache??={file:i,options:e,highlighted:!t&&!Y(i),result:t?void 0:n?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightFileAST(this,i):this.highlighter==null&&(this.computedLang=i.lang??j(i.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??H}getEffectiveCodeOptions(){const i=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:i?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(i){const e=(()=>{if(this.workerManager?.isWorkingPool()===!0){const r=this.workerManager.getFileRenderOptions();return this.editSessionActive&&r.useTokenTransformer!==!0?{...r,useTokenTransformer:!0}:r}const{tokenizeMaxLineLength:n=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:n}})(),{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!R(i,t.file)||!A(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getOrCreateLineCache(i){this.invalidateChangedUnkeyedFile(i);let{lineCache:e}=this;return(e==null||!D(e,i))&&(e={cacheKey:i.cacheKey,file:i,sourceContents:i.contents,lines:$(i.contents)}),this.lineCache=e,e.lines}getLineCount(i){const e=this.getOrCreateLineCache(i);return this.textDocumentCache.get(i)?.lineCount??e.length}updateRenderCache(i,e,t=!1){if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:n,result:r}=this.renderCache;if(r==null)return;const s=t?new Map:void 0;this.pendingStructuralRows=s;const o=this.lineCache!=null&&D(this.lineCache,n)?this.lineCache:void 0;for(const[a,l]of i){if(s===void 0&&o!=null&&a<o.lines.length){const h=l.map(c=>c[2]).join("");o.lines[a]=Ve(o.lines[a]??"",h)}const d={type:"element",tagName:"div",properties:{"data-line":a+1,"data-line-type":"context","data-line-index":a},children:l.map(([h,c,u])=>h===0&&c===""?u===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:u}:{type:"element",tagName:"span",properties:{"data-char":h,style:`color:${c};`},children:[{type:"text",value:u}]})};s!==void 0?s.set(a,d):r.code[a]=d}r.baseThemeType=e,this.renderCache.isDirty=!0}applyDocumentChange(i){const e=this.pendingStructuralRows;if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:t,result:n}=this.renderCache;if(n==null)return;const r=this.lineCache!=null&&D(this.lineCache,t)?this.lineCache.lines:$(t.contents),s=$(i.getText());if(r.length!==s.length){const o=Math.min(r.length,s.length);let a=0;for(;a<o&&r[a]===s[a];)a++;let l=0;for(;l<o-a&&r[r.length-1-l]===s[s.length-1-l];)l++;const d=n.code;n.code=new Array(s.length);for(let h=0;h<a;h++)n.code[h]=d[h];for(let h=0;h<l;h++)n.code[s.length-1-h]=d[r.length-1-h];if(e!==void 0)for(const[h,c]of e)h<s.length&&(n.code[h]=c);for(let h=a;h<s.length-l;h++)n.code[h]??={type:"element",tagName:"div",properties:{"data-line":h+1,"data-line-type":"context","data-line-index":h},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:i.getLineText(h)}]}]};for(let h=0;h<n.code.length;h++){const c=n.code[h];c?.type==="element"&&(c.properties["data-line"]=h+1,c.properties["data-line-index"]=h)}this.renderCache.isDirty=!0}this.lineCache={cacheKey:t.cacheKey,file:t,sourceContents:t.contents,lines:s},this.textDocumentCache.set(t,i)}renderFile(i=this.renderCache?.file,e=ee){if(i==null)return;this.invalidateChangedUnkeyedFile(i),this.renderCache?.isDirty===!0&&!R(i,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:t,forceHighlight:n}=this.getRenderOptions(i);this.renderCache?.isDirty===!0&&!A(t,this.renderCache.options)&&this.clearRenderCache();const r=this.getMatchingWorkerResultCache(i,t);r!=null&&!this.hasHighlightedRenderCache(i,t)&&(this.renderCache={file:i,highlighted:!0,renderRange:void 0,...r},n=!1),this.renderCache??={file:i,highlighted:!1,options:t,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(i),o=i.contents.length>0,a=!o||Y(i)||K(s.length,this.getTokenizeMaxLength()),l=!R(i,this.renderCache.file),d=!me(this.renderCache.renderRange,e);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)(a||this.renderCache.result==null||!this.renderCache.highlighted&&(l||d))&&(this.renderCache.file=i,this.renderCache.options=t,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||d||n)&&(this.renderCache.result=this.workerManager.getPlainFileAST(i,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!a&&o&&(!this.renderCache.highlighted||n)&&this.workerManager.highlightFileAST(this,i);else{this.computedLang=i.lang??j(i.name);const h=this.highlighter!=null&&te(t.theme),c=this.highlighter!=null&&ie(this.computedLang),u=!a&&c;if(this.highlighter!=null&&h&&(n||a||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:f,options:m}=this.renderFileWithHighlighter(i,this.highlighter,a||!c);this.renderCache={file:i,options:m,highlighted:u,result:f,renderRange:void 0}}(!h||!a&&!c)&&this.asyncHighlight(i).then(({result:f,options:m})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(i,f,m,!a)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(i,e=ee){const{result:t}=await this.asyncHighlight(i);return this.processFileResult(i,e,t)}async asyncHighlight(i){const e=K(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());this.computedLang=e?"text":i.lang??j(i.name);const t=this.highlighter!=null&&De(Be(this.getLocalHighlightTheme())),n=e||this.highlighter!=null&&ie(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(i,this.highlighter,e)}renderFileWithHighlighter(i,e,t=!1){const{options:n}=this.getRenderOptions(i);return{result:Ue(i,e,n,{forcePlainText:t}),options:n}}processFileResult(i,e,{code:t,themeStyles:n,baseThemeType:r}){const s=this.getLineCount(i),{disableFileHeader:o=!1}=this.options,a=[],l=oe(),d=Math.min(e.startingLine+e.totalLines,s);let h=0;const c=Ce(e)?_e(this.lineAnnotations):void 0;c!=null&&(l.children.push(ne("context","annotation",1)),a.push(re({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>k(u))})),h++);for(let u=e.startingLine;u<d;u++){const f=u+1,m=t[u];if(m==null){const C="FileRenderer.processFileResult: Line doesnt exist";throw console.error(C,{name:i.name,lineIndex:u,lineNumber:f}),new Error(C)}l.children.push(We("context",f,`${u}`)),a.push(m),h++;const g=this.lineAnnotations[f];g!=null&&(l.children.push(ne("context","annotation",1)),a.push(re({hunkIndex:0,lineIndex:f,annotations:g.map(C=>k(C))})),h++)}return l.properties.style=`grid-row: span ${h}`,{gutterAST:l.children??[],contentAST:a,preAST:this.createPreElement(s),headerAST:o?void 0:this.renderHeader(i),totalLines:s,rowCount:h,themeStyles:n,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(i){const{headerRenderMode:e="default",stickyHeader:t=!1}=this.options;return Ge({fileOrDiff:i,mode:e,stickyHeader:t})}renderFullHTML(i){return b(this.renderFullAST(i))}renderFullAST(i,e=[]){return e.push(se({tagName:"code",children:this.renderCodeAST(i),properties:{"data-code":""}})),{...i.preAST,children:e}}renderCodeAST(i){const e=oe();return e.children=i.gutterAST,e.properties.style=`grid-row: span ${i.rowCount}`,[e,je(i.contentAST,i.rowCount)]}renderPartialHTML(i,e=!1){return e?b(se({tagName:"code",children:i,properties:{"data-code":""}})):b(i)}async initializeHighlighter(){return this.highlighter=await $e(Ke(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(i,e,t,n=!0){this.editSessionActive||this.applyHighlightResult(i,e,t,n)}applyHighlightResult(i,e,t,n=!0){if(this.renderCache==null)return;const r=!R(i,this.renderCache.file)||!this.renderCache.highlighted||!A(t,this.renderCache.options);this.renderCache={file:i,options:t,highlighted:n,result:e,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(i,e){if(this.editSessionActive)return;const t=this.workerManager?.getFileResultCache(i);if(!(t==null||!A(e,t.options)))return t}hasHighlightedRenderCache(i,e){const{renderCache:t}=this;return t?.result!=null&&t.highlighted&&R(i,t.file)&&A(e,t.options)}onHighlightError(i){console.error(i)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(i){const{disableLineNumbers:e=!1,overflow:t="scroll"}=this.options;return qe({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:t,split:!1,totalLines:i})}};function K(i,e){return i>e}function Lt(i,e){return i.lineNumber===e.lineNumber&&i.metadata===e.metadata}function fe(i){return{theme:i?.theme,disableLineNumbers:i?.disableLineNumbers,overflow:i?.overflow,themeType:i?.themeType,collapsed:i?.collapsed,disableFileHeader:i?.disableFileHeader,disableVirtualizationBuffers:i?.disableVirtualizationBuffers,stickyHeader:i?.stickyHeader,preferredHighlighter:i?.preferredHighlighter,useCSSClasses:i?.useCSSClasses,useTokenTransformer:Ye(i),tokenizeMaxLineLength:i?.tokenizeMaxLineLength,tokenizeMaxLength:i?.tokenizeMaxLength,unsafeCSS:i?.unsafeCSS,headerRenderMode:i?.renderCustomHeader!=null?"custom":"default"}}const Mt=[""];let At=-1;var ve=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++At}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:H},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new Tt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new Xe,this.interactionManager=new Je("file",ae(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ae(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Qe(this.appliedThemeCSS.theme,this.options.theme??H)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e==="wrap",columnVariables:this.shouldApplyColumnVariables(e)?"apply":"measure"}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e==="scroll"&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:s,lineAnnotations:o}=e;if(!this.enabled)throw new Error("File.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw new Error("File.hydrate: hydrate can only be called before the instance has rendered or hydrated");this.hydrateElements(t,n),Ht(this.pre,s,this.options.collapsed)||bt(this.headerElement,s,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:s,lineAnnotations:o}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Ze(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(fe(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):Mt}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,s=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(o=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(o,t,n,r,s)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.fileRenderer.beginEditSession();const t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.fileRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),()=>{this.editor=void 0,this.fileRenderer.endEditSession()}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t,n){this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render(e){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");const t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:s,deferManagers:o=!1,lineAnnotations:a,renderRange:l}){this.editor?.__postponeBgTokenizeToNextFrame();const{collapsed:d=!1,themeType:h="system"}=this.options,c=d?void 0:l,u=this.renderRange,f=this.hasThemeChanged(),m=a!=null&&(a.length>0||this.lineAnnotations.length>0)?a!==this.lineAnnotations:!1,g=!R(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!d&&!n&&me(c,this.renderRange)&&!g&&!m&&!f)return this.applyCachedThemeState(h);this.renderRange=c,g&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(fe(this.options)),this.syncInteractionOptions(),a!=null&&this.setLineAnnotations(a),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:C=!1,disableFileHeader:S=!1}=this.options;if(S&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,s),this.applyCachedThemeState(h),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const p=this.fileRenderer.renderFile(e,xe);p!=null&&this.applyThemeState(t,p.themeStyles,h,p.baseThemeType),p?.headerAST!=null&&this.applyHeaderToDOM(p.headerAST,t),this.injectUnsafeCSS()}catch(p){if(C)throw p;console.error(p),p instanceof Error&&this.applyErrorToDOM(p,t)}return r||this.emitPostRender(),!0}try{const p=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,m,g||f)||!this.applyPartialRender(u,c)){const v=this.fileRenderer.renderFile(e,c);if(v==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,v.themeStyles,h,v.baseThemeType),v.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.applyFullRender(v,p)}this.applyBuffers(p,c),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,o||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(p){if(C)throw p;console.error(p),p instanceof Error&&this.applyErrorToDOM(p,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const 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(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.file){const{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Y(e))return;const n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(r=>{console.error(r)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const s=`${n}-${k(r)}`;let o=this.annotationCache.get(s);if(o==null||!Lt(r,o.annotation)){o?.element.remove();const a=t(r);if(a==null)continue;o={element:et(k(r)),annotation:r},o.element.appendChild(a),this.fileContainer.appendChild(o.element),this.annotationCache.set(s,o)}e.delete(s)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=tt();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=it(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=nt(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){const s=e.shadowRoot??e.attachShadow({mode:"open"}),o=r??n,a=this.options.theme??H,l=typeof a=="string"?a:{...a},d=he(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===o&&this.appliedThemeCSS.scrollbarGutter===d){this.appliedThemeCSS.theme=l;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:l,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:d};return}this.themeCSSStyle=rt({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:ct(t,o,d)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:l,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:d}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=st(this.themeCSSStyle.textContent??"",he(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&Ee()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);const n=this.code=ot({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();const s=()=>{if(n.childElementCount>=2)for(let o=0;o<2;o++){const a=n.children[o],l=r[o];a.innerHTML=b(l.children),a.style.cssText=l.properties.style}else n.innerHTML=b(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?at(t,s):s(),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:r}=this,s=r!=null?this.getColumns(r):void 0;if(n==null||r==null||s==null)return!1;const o=e.startingLine,a=t.startingLine,l=e.totalLines===1/0?Number.POSITIVE_INFINITY:o+e.totalLines,d=t.totalLines===1/0?Number.POSITIVE_INFINITY:a+t.totalLines,h=Math.max(o,a),c=Math.min(l,d);if(c<=h)return!1;if(!this.trimDOMToOverlap(s.gutter,h,c)||!this.trimDOMToOverlap(s.content,h,c))throw new Error("File.applyPartialRender: failed to trim to overlap");let{length:u}=s.content.children;const f=(S,p)=>{if(!(p<=0))return this.fileRenderer.renderFile(n,{startingLine:S,totalLines:p,bufferBefore:0,bufferAfter:0})},m=a<h?f(a,h-a):void 0;if(m===void 0&&a<h)return!1;const g=d===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,d-c),C=d>c?f(c,g):void 0;return C===void 0&&d>c?!1:(this.cleanupErrorWrapper(),m!=null&&(s.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(m.gutterAST)),s.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(m.contentAST)),u+=m.rowCount),C!=null&&(s.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(C.gutterAST)),s.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(C.contentAST)),u+=C.rowCount),this.lastRowCount!==u&&(s.gutter.style.setProperty("grid-row",`span ${u}`),s.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const r=this.getDOMBoundaryIndices(e,[t,n]),s=r.get(t)??e.children.length,o=r.get(n)??e.children.length;if(s>o)return!1;for(let a=e.children.length-1;a>=o;a-=1)e.children[a]?.remove();for(let a=s-1;a>=0;a-=1)e.children[a]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((l,d)=>l-d),r=new Map;if(n.length===0)return r;let s=0,o=n[s];const{children:a}=e;o===0&&(r.set(0,0),s+=1,o=n[s]);for(let l=0;l<a.length;l+=1){const d=a[l];if(!(d instanceof HTMLElement))continue;const h=this.getLineIndexFromDOMNode(d);if(h!=null){for(;o!=null&&h>=o;)r.set(o,l),s+=1,o=n[s];if(s>=n.length)break}}for(const l of n)r.has(l)||r.set(l,a.length);return r}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const r=this.cachedHeaderHTML??b(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){const d=document.createElement("div");d.innerHTML=r;const h=d.firstElementChild;if(!(h instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(h,this.headerElement):t.shadowRoot?.prepend(h),this.headerElement=h,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;const{renderHeaderPrefix:s,renderHeaderFilenameSuffix:o,renderCustomHeader:a,renderHeaderMetadata:l}=this.options;if(a!=null){const d=a(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,ge,d),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const d=s?.(n)??void 0,h=o?.(n)??void 0,c=l?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Fe,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,ke,h),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ze,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}const s=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,r),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),s=n!==r;return n!=null&&s&&this.editor?.__captureFocusForDOMReplacement(),s&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:le(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):le(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=ht;const r=n.firstChild;r instanceof SVGElement&&(this.spriteSVG=r)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,s={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};lt(s,this.appliedPreAttributes)||(dt(e,s),this.appliedPreAttributes=s)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Ht(i,e,t=!1){return!t&&i==null&&e!=null}function bt(i,e,t=!1){return i==null&&e!=null&&!t}const wt=5e3;let xt=-1;function Et(i,e){return(i.overflow??"scroll")!==(e.overflow??"scroll")||(i.collapsed??!1)!==(e.collapsed??!1)||(i.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(i.disableFileHeader??!1)!==(e.disableFileHeader??!1)||i.unsafeCSS!==e.unsafeCSS}var Ft=class extends ve{virtualizer;metrics;__id=`virtualized-file:${++xt}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(i,e,t=Ie,n,r=!1){super(i,n,r),this.virtualizer=e,this.metrics=t}setMetrics(i,e=!1){const t=ut(i);!e&&ft(this.metrics,t)||(this.metrics=t,this.resetLayoutCache())}setLineAnnotations(i){this.syncLineAnnotations(i)&&this.resetLayoutCache()}syncLineAnnotations(i){return i==null||i===this.lineAnnotations||i.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(i),!0)}hasLineAnnotations(){return this.lineAnnotations.some(i=>i.lineNumber>0)}getLineHeight(i,e=!1){const t=this.cache.heights.get(i);if(t!=null)return t;const n=e?2:1;return this.metrics.lineHeight*n}setOptions(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(i==null)return;const{options:e}=this,t=!Se(e,i),n=Et(e,i);super.setOptions(i),n&&this.resetLayoutCache(!0),t&&(this.forceRenderOverride=!0),t&&this.virtualizer.instanceChanged(this,n)}setThemeType(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(i)}resetLayoutCache(i=!1,e=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&e&&(this.renderRange=void 0),i&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let i=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(i=!0),this.height=0,i;const{overflow:e="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),e==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return i;const t=this.code.children[1];if(!(t instanceof HTMLElement))return i;const n=de(this.lineAnnotations);if(this.renderRange!=null&&n&&Ce(this.renderRange)){const r=kt(t)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,i=!0)}else!n&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,i=!0);for(const r of t.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const o=Number(s);let a=r.getBoundingClientRect().height,l=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(l=!0),a+=r.nextElementSibling.getBoundingClientRect().height);const d=this.getLineHeight(o,l);a!==d&&(i=!0,a===this.metrics.lineHeight*(l?2:1)?this.cache.heights.delete(o):this.cache.heights.set(o,a))}return(i||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),i}onRender=i=>this.fileContainer==null||this.file==null?!1:(i&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(i,e,t,n){const r=this.syncLineAnnotations(n),s=!R(this.file,i)||this.fileRenderer.hasUnkeyedFileContentsChanged(i);let o=t?.resetFileLayoutCache===!0||s||r;t?.metrics!=null&&(this.metrics=t.metrics,o=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,o=!0),o&&this.resetLayoutCache(),this.file!==i&&(this.layoutDirty=!0),this.file=i,this.top=e,this.computeApproximateSize(),this.height}getLinePosition(i){if(this.file==null||i<1)return;const{disableFileHeader:e=!1,collapsed:t=!1}=this.options,n=this.fileRenderer.getLineCount(this.file)-1;let r=V(this.metrics,e);if(t||n<0)return{top:r,height:0};const s=Math.min(Math.max(i-1,0),n),{overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics;if(r+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())return{top:r+s*a,height:a};const l=this.getLayoutCheckpointBeforeLineIndex(s);r=l?.top??r;for(let d=l?.lineIndex??0;d<s;d++)r+=this.getLineHeight(d,!1);return{top:r,height:this.getLineHeight(s,!1)}}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(i){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:e=!1,collapsed:t=!1,overflow:n="scroll"}=this.options;if(t||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=V(this.metrics,e),o=Math.min(this.renderRange.startingLine,r),a=Math.min(o+this.renderRange.totalLines-1,r);if(a<o)return;const{fileAnnotationHeight:l}=this.cache;if(n==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:h}=this.metrics,c=s+(o===0?l:this.renderRange.bufferBefore),u=o+Math.max(Math.ceil((i-c)/h),0);return u>a?void 0:{lineNumber:u+1,top:s+l+u*h}}let d=s+(o===0?l:this.renderRange.bufferBefore);for(let h=o;h<=a;h++){if(d>=i)return{lineNumber:h+1,top:d};d+=this.getLineHeight(h)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(i){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const e=i!=null?this.computeRenderRangeFromWindow(this.file,this.top,i):this.renderRange;if(e==null)return;const{bufferBefore:t,bufferAfter:n,totalLines:r}=e;let s=0;if(r===0){const o=i??this.virtualizer.getWindowSpecs();this.top<o.top&&(s=n)}return{topOffset:this.top+t+s,height:this.height-(t+n)}}cleanUp(i=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),i||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(i)}computeApproximateSize(i=!1,e=this.file){const t=this.isResizeDebuggingEnabled();if(!i&&!this.layoutDirty&&!t)return;const n=this.height===0;if(this.height=0,this.cache.checkpoints=[],e==null){this.layoutDirty=!1;return}const{disableFileHeader:r=!1,collapsed:s=!1,overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(e),d=V(this.metrics,r),h=ce(this.metrics);if(this.height+=d,s){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())this.height+=l*a;else for(let c=0;c<l;c++)this.addLayoutCheckpoint(c,this.height),this.height+=this.getLineHeight(c,!1);if(l>0&&(this.height+=h),this.fileContainer!=null&&t&&!n){const c=this.fileContainer.getBoundingClientRect();c.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:e.name,elementHeight:c.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(i){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,i&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!i&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(i,e,t=!1){const{renderRange:n}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(i,e),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),!this.isSimpleMode())this.computeApproximateSize(!0);else if(t&&n!==void 0&&this.file!==void 0){const r=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(this.file,this.top??0,r);s.bufferAfter!==n.bufferAfter&&this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}renderPreparedFile({fileContainer:i,file:e,forceRender:t=!1,lineAnnotations:n,...r}){const s=this.file==null||!R(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e),{forceRenderOverride:o,isSetup:a}=this;this.forceRenderOverride=void 0;const l=this.syncLineAnnotations(n);if(l&&this.resetLayoutCache(),i=this.getOrCreateFileContainerNode(i),e==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(a)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,e));else{this.computeApproximateSize(!1,e);const f=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(f==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");f.connect(i,this),this.isVisible=f.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!s||!a))return this.file=e,s&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);const d=this.virtualizer.getWindowSpecs(),h=this.top??0,c=this.computeRenderRangeFromWindow(e,h,d),u=super.renderPreparedFile({file:e,fileContainer:i,renderRange:c,lineAnnotations:n,forceRender:(o??t)||l||s,...r});return this.isSimpleMode()&&u&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),u}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(i,e){i%wt===0&&this.cache.checkpoints.push({lineIndex:i,top:e})}getLayoutCheckpointBeforeLineIndex(i){if(i<=0||this.cache.checkpoints.length===0)return;let e=0,t=this.cache.checkpoints.length-1,n;for(;e<=t;){const r=e+t>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=i?(n=s,e=r+1):t=r-1}return n}getLayoutCheckpointBeforeTop(i,e){let t=0,n=this.cache.checkpoints.length-1,r=-1;for(;t<=n;){const s=t+n>>1,o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");o.top<=i?(r=s,t=s+1):n=s-1}if(e==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(o.lineIndex%e===0)return o}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(i,e,{top:t,bottom:n}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:o,lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(i),d=this.height,h=V(this.metrics,r),c=l>0?ce(this.metrics):0,{fileAnnotationHeight:u}=this.cache,f=h+u,m=Math.max(0,d-h-u-c),g=de(this.lineAnnotations),C=e+h,S=u>0&&g&&C<n&&C+u>t;if(e<t-d||e>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};if(l<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};const p=Math.ceil(Math.max(n-t,0)/a),v=Math.ceil(p/o)*o+o,z=v/o,B=(t+n)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const M=e+f,N=M+m;if(!S&&!(M<n&&N>t))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};const x=Math.floor(S&&B<e+f?0:(B-(e+f))/a),L=Math.floor(x/o)-Math.floor(z/2),He=Math.ceil(l/o),E=Math.max(0,Math.min(L,He))*o,Z=L<0?v+L*o:v,be=E===0?0:u+E*a,we=Math.min(Z,l-E);return{startingLine:E,totalLines:Z,bufferBefore:be,bufferAfter:Math.max(0,(l-E-we)*a)}}const ye=z,I=[],U=this.getLayoutCheckpointBeforeTop(Math.max(0,t-e-v*a*2),o);let T=e+(U?.top??f),_=U?.lineIndex??0,O,P,w;const Re=U?.lineIndex??0;for(let M=Re;M<l;M++){const N=_%o===0,x=Math.floor(_/o);if(N&&(I[x]=T-(e+f),w!=null)){if(w<=0)break;w--}const L=this.getLineHeight(M,!1);T>t-L&&T<n&&(O??=x),T+L>B&&(P??=x),w==null&&T>=n&&N&&(w=ye),_++,T+=L}if(O==null)if(S)O=0,P=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};P??=O;const W=Math.round(P-z/2),Te=Math.max(0,Math.ceil(l/o)-z),G=Math.max(0,Math.min(W,Te)),X=G*o,J=W<0?v+W*o:v,Le=I[G]??0,Me=X===0?0:u+Le,Q=G+J/o,Ae=Q<I.length?m-I[Q]:m-(T-e-f);return{startingLine:X,totalLines:J,bufferBefore:Me,bufferAfter:Math.max(0,Ae)}}};function kt(i){let e;for(const t of i.children)t instanceof HTMLElement&&t.dataset.lineAnnotation===pt&&(e=Math.max(e??0,t.getBoundingClientRect().height));return e}const pe=typeof window>"u"?F.useEffect:F.useLayoutEffect;function zt({file:i,options:e,editorOptions:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:s,metrics:o,hasGutterRenderUtility:a,hasCustomHeader:l,disableWorkerPool:d,edit:h}){const c=gt(),u=r!==void 0,f=F.useContext(mt),m=St(),g=F.useRef(null),C=vt(S=>{if(S!=null){if(g.current!=null)throw new Error("File: An instance should not already exist when a node is created");c!=null?g.current=new Ft(q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),c,o,d?void 0:f,!0):g.current=new ve(q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),d?void 0:f,!0),g.current.hydrate({file:i,fileContainer:S,lineAnnotations:n,prerenderedHTML:s})}else{if(g.current==null)throw new Error("File: A File instance should exist when unmounting");g.current.cleanUp(),g.current=null}});return pe(()=>{if(g.current==null)return;const S=q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),p=S!==void 0&&!Se(g.current.options,S);g.current.setOptions(S),g.current.render({file:i,lineAnnotations:n,forceRender:p}),r!==void 0&&g.current.setSelectedLines(r)}),pe(()=>{if(h&&g.current!=null){if(m===void 0)throw new Error("File: EditContext is not attached");const S=m(t??{});if(S==null)throw new Error("File: EditProvider.createEditor must return an editor instance");try{return S.edit(g.current)}catch(p){throw S.cleanUp(),p}}},[h]),{ref:C,getHoveredLine:F.useCallback(()=>g.current?.getHoveredLine(),[])}}function q({options:i,controlledSelection:e,hasCustomHeader:t,hasGutterRenderUtility:n}){return e||n||t?{...i,controlledSelection:e,renderCustomHeader:t?ue:i?.renderCustomHeader,renderGutterUtility:n?ue:i?.renderGutterUtility}:i}function Bt({file:i,lineAnnotations:e,selectedLines:t,options:n,editorOptions:r,metrics:s,className:o,style:a,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderFilenameSuffix:c,renderHeaderMetadata:u,prerenderedHTML:f,renderGutterUtility:m,disableWorkerPool:g=!1,edit:C=!1}){const{ref:S,getHoveredLine:p}=zt({file:i,options:n,editorOptions:r,metrics:s,lineAnnotations:e,selectedLines:t,prerenderedHTML:f,hasGutterRenderUtility:m!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:C});return y.jsx(Oe,{ref:S,className:o,style:a,children:Ct(yt({file:i,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderFilenameSuffix:c,renderHeaderMetadata:u,renderGutterUtility:m,lineAnnotations:e,getHoveredLine:p}),f)})}export{Bt as F};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,r as i,a as bt}from"./react-rd22PHbN.js";import{a as wt}from"./tanstack-Bsd5UOY4.js";import{a4 as Mt,a6 as vt,a8 as St,a9 as Ve,aa as Nt,Y as Rt,ab as It,ac as Et,ad as Ft,ae as Tt,af as T,H as Pt,ag as _t,j as zt,P as Ze,ah as $t,ai as Ye,aj as qe,ak as Kt,al as Lt,am as At,an as Ht,T as Bt,ao as Ut,ap as Fe,aq as Vt,ar as Yt,Z as Ge,as as qt,at as Ee,au as Xt,av as Ot,t as Zt,y as Gt,D as Wt,c as Jt,d as Qt,e as en}from"./App-BWpP-n84.js";import{c as K,d as Te,B as H,I as tn}from"./index-DaaX_e8C.js";import{m as nn,n as sn,M as on,o as rn,p as an,q as ln,S as cn}from"./base-ui-D4MeJpa3.js";import{I as We}from"./IconFolderPlus-DvEWPQIQ.js";import{I as dn}from"./IconEdit-DQZu_Rpb.js";const un=[["path",{d:"M9 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M5 10h11a4 4 0 1 1 0 8h-1",key:"svg-1"}]],hn=K("outline","arrow-back-up","ArrowBackUp",un);const pn=[["path",{d:"M15 14l4 -4l-4 -4",key:"svg-0"}],["path",{d:"M19 10h-11a4 4 0 1 0 0 8h1",key:"svg-1"}]],fn=K("outline","arrow-forward-up","ArrowForwardUp",pn);const gn=[["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"}]],Je=K("outline","clipboard","Clipboard",gn);const xn=[["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"}]],Qe=K("outline","columns-2","Columns2",xn);const mn=[["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"}]],jn=K("outline","cut","Cut",mn);const yn=[["path",{d:"M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]],Dn=K("outline","dots","Dots",yn);const kn=[["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"}]],et=K("outline","file-plus","FilePlus",kn);const Cn=[["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:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]],bn=K("outline","file-text","FileText",Cn),wn=nn,Mn=sn;function vn({className:n,children:d,...u}){return t.jsx(on,{children:t.jsx(rn,{className:"isolate z-50 outline-none",children:t.jsx(an,{"data-slot":"context-menu-content",className:Te("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",n),...u,children:d})})})}function b({className:n,...d}){return t.jsx(ln,{"data-slot":"context-menu-item",className:Te("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",n),...d})}function oe({className:n,...d}){return t.jsx(cn,{"data-slot":"context-menu-separator",className:Te("mx-1 my-1 h-px bg-border",n),...d})}const Sn=29,xe=6,tt="files-tree-root-drop",Nn=550,Rn={duration:160,easing:"cubic-bezier(0.2, 0, 0, 1)"},Xe=6,In=n=>{const d=Kt(n),u=d.length>0?d:Lt(n),g=u.find(x=>x.id!==tt);return g?[g]:u.slice(0,1)};function nt(n,d,u=0){const g=[];for(const x of n)g.push({entry:x,depth:u}),x.type==="directory"&&d.has(x.path)&&g.push(...nt(x.children,d,u+1));return g}function En(n,d,u){const g=n.findIndex(p=>p.entry.path===d),x=n.findIndex(p=>p.entry.path===u);if(g===-1||x===-1)return[u];const[l,h]=g<=x?[g,x]:[x,g];return n.slice(l,h+1).map(p=>p.entry.path)}function me(n){return n.type==="directory"?n.path:Ge(n.path)}function Vn({active:n,initialExpandedPaths:d,files:u,filesSnapshotRevision:g,showDotEnvFiles:x,activePath:l,readOnly:h,fileClipboardAvailable:p,revealAvailable:B,historyState:L,onQuickOpen:C,onUndo:A,onRedo:U,onOpenFile:j,onLoadDirectory:w,onPersistExpandedPaths:re,onCopyPath:je,onCopyEntries:ae,onCutEntries:ie,onCopyContents:ye,onPaste:O,onMoveEntries:De,onDeleteEntries:le,onReveal:ke,onRename:Ce,onCreate:be}){const we=Mt(),Z=vt(),[P,Me]=i.useState(!1),S=Z?44:Sn,ce=i.useRef(null),V=i.useRef(null),[m,R]=i.useState(new Set),[de,Y]=i.useState(l),[q,_]=i.useState(l),[N,G]=i.useState(()=>new Set(d)),[ue,W]=i.useState([]),[M,z]=i.useState(null),[J,ve]=i.useState(null),[_e,st]=i.useState(null),[ot,rt]=i.useState(!1),[at,$]=i.useState(null),[he,it]=i.useState(0),[I,pe]=i.useState(new Map),lt=St(Ve(Ht,{activationConstraint:{distance:5}}),Ve(At)),ze=i.useRef(I),Q=i.useRef(new Set),$e=i.useRef(0),E=i.useRef(null),ee=i.useRef(null),Ke=i.useRef(d.join("\0")),fe=i.useMemo(()=>new Set(I.keys()),[I]),F=i.useMemo(()=>u===null?null:Nt(u,I),[u,I]),f=i.useMemo(()=>F===null?null:x?F:Rt(F),[F,x]);i.useEffect(()=>{ze.current=I},[I]),i.useEffect(()=>{st(document.getElementById(It))},[l]),i.useEffect(()=>{const e=window.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>rt(e.matches);return s(),e.addEventListener("change",s),()=>e.removeEventListener("change",s)},[]),i.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]),i.useEffect(()=>{const e=++$e.current,s=[...ze.current.keys()];s.length!==0&&Promise.all(s.map(async o=>({path:o,children:await w(o)}))).then(o=>{if(e!==$e.current)return;const r=new Map(o.map(({path:c,children:a})=>[c,a]));pe(c=>Et(c,r))})},[g,w]),i.useEffect(()=>{if(!F){Q.current.clear(),pe(e=>e.size===0?e:new Map);return}G(e=>{const s=new Set(Ft(F,e,fe).retained);return Oe(e,s)?e:s})},[fe,F]),i.useEffect(()=>{if(!F)return;const e=Tt(F,N,fe),s=e.join("\0");s!==Ke.current&&(Ke.current=s,re(e))},[N,fe,F,re]),i.useEffect(()=>{if(!n||!f)return;let e=Math.max(0,2-Q.current.size);for(const s of N){if(e===0)break;const o=T(f,s);!o||o.type!=="directory"||o.ignored!==!0||o.children.length>0||I.has(s)||Q.current.has(s)||(Q.current.add(s),e-=1,w(s).catch(()=>[]).then(r=>{pe(c=>new Map(c).set(s,r))}).finally(()=>{Q.current.delete(s)}))}},[n,N,I,w,f]),i.useEffect(()=>{n||($(null),W([]),z(null),ve(null),E.current&&clearTimeout(E.current),E.current=null,ee.current=null)},[n]),i.useEffect(()=>{f&&(R(e=>{if(e.size===0)return e;const s=new Set([...e].filter(o=>T(f,o)));return s.size===e.size?e:s}),Y(e=>e&&T(f,e)?e:null),_(e=>e&&T(f,e)?e:l&&T(f,l)?l:null))},[l,f]);const y=i.useMemo(()=>f?nt(f,N):[],[N,f]),X=wt({enabled:n,count:y.length,getScrollElement:()=>ce.current,estimateSize:()=>S,getItemKey:e=>y[e]?.entry.path??e,overscan:12,paddingStart:xe,paddingEnd:12});i.useEffect(()=>{X.measure()},[X,S]),i.useEffect(()=>{!n||!l||!f||!T(f,l)||G(e=>{const s=new Set(e);let o=!1;const r=l.split("/");let c="";for(let a=0;a<r.length-1;a+=1)c=c?`${c}/${r[a]}`:r[a],s.has(c)||(s.add(c),o=!0);return o?s:e})},[n,l,f]),i.useEffect(()=>{if(!n)return;if(!l){V.current=null;return}if(V.current===l)return;const e=y.findIndex(s=>s.entry.path===l);e>=0&&(X.scrollToIndex(e,{align:"auto"}),V.current=l)},[n,l,y]);const Le=i.useMemo(()=>{const e=new Map;for(const s of y)e.set(s.entry.path,s);return e},[y]),te=i.useMemo(()=>{const e={headers:[],push:0};if(y.length===0||!l)return e;const s=new Set,o=l.split("/");let r="";for(let k=0;k<o.length-1;k+=1)r=r?`${r}/${o[k]}`:o[k],s.add(r);if(s.size===0)return e;const c=Math.min(y.length-1,Math.max(0,Math.floor((he-xe)/S))),a=y[c];if(!a)return e;const D=a.entry.path.split("/"),v=[];let se="";for(let k=0;k<D.length-1;k+=1){if(se=se?`${se}/${D[k]}`:D[k],!s.has(se))continue;const Ie=Le.get(se);Ie&&Ie.entry.type==="directory"&&v.push(Ie)}if(v.length>Xe&&v.splice(0,v.length-Xe),v.length===0)return e;const Dt=v[v.length-1],Be=v.length*S;let Ue=1/0;const kt=Math.ceil((he+Be-xe)/S)+2;for(let k=c;k<y.length&&k<=kt;k+=1)if(y[k].depth<=Dt.depth){Ue=xe+k*S;break}const Ct=Math.max(0,Math.min(S,Be-(Ue-he)));return{headers:v,push:Ct}},[y,Le,he,l,S]);if(f===null)return t.jsx("div",{className:"view-loading",role:"status",hidden:!n,children:t.jsx(Pt,{text:"Loading files…"})});const ct=P||m.size>0?m:l?new Set([l]):new Set,dt=m.size>0?[...m]:l?[l]:[],Se=e=>{const s=[];for(const o of e){const r=T(f,o);r&&s.push(r)}return s},Ne=e=>{R(new Set([e])),Y(e),_(e)},ut=e=>{const s=y.findIndex(o=>o.entry.path===e.path);s>=0&&X.scrollToIndex(s,{align:"start"})},ht=(e,s)=>{if(Z&&P){R(o=>{const r=new Set(o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r});return}if(s.shift&&(de||q)){const o=En(y,de??q,e.path);R(new Set(o)),_(e.path);return}if(s.ctrl){R(o=>{const r=new Set(o.size===0&&l?[l]:o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r}),Y(e.path),_(e.path),e.type==="file"&&j(e.path,"pinned");return}Ne(e.path),e.type==="file"?j(e.path):Ae(e.path)},pt=e=>{!(Z&&P)&&e.type==="file"&&j(e.path,"pinned")},ft=e=>{m.has(e.path)||Ne(e.path)},ge=e=>m.has(e.path)&&m.size>0?Se(m):[e],gt=e=>{if(Vt(e.target))return;const s=Yt(e.nativeEvent,we);if(s==="undo"&&L.canUndo&&!h){e.preventDefault(),e.repeat||A();return}if(s==="redo"&&L.canRedo&&!h){e.preventDefault(),e.repeat||U();return}const o=(e.ctrlKey||e.metaKey)&&!e.altKey,r=e.key.toLowerCase();if(o&&r==="a"){e.preventDefault(),R(new Set(y.map(D=>D.entry.path)));return}const c=Se(dt),a=q?T(f,q):null;if(o&&r==="c"&&c.length){e.preventDefault(),ae(c);return}if(o&&r==="x"&&c.length&&!h){e.preventDefault(),ie(c);return}if(o&&r==="v"&&!h&&p){e.preventDefault();const D=a?me(a):Ge(c[0]?.path??"");O(D);return}if(e.key==="F2"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h){if(m.size===1){const D=T(f,[...m][0]);D&&(e.preventDefault(),$({mode:"rename",entry:D}))}return}e.key==="Delete"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h&&c.length&&(e.preventDefault(),le(c))},xt=async(e,s)=>{const o=Se(e);o.length&&await De(o,s)},Ae=(e,s=!1)=>{const o=!s&&N.has(e),r=o&&T(f??[],e)?.ignored===!0;G(c=>{const a=new Set(c);if(s||!a.has(e)){if(a.has(e))return c;a.add(e)}else if(r)for(const D of a)Ee(e,D)&&a.delete(D);else a.delete(e);return Oe(c,a)?c:a}),o&&pe(c=>{const a=[...c.keys()].filter(v=>Ee(e,v));if(a.length===0)return c;const D=new Map(c);for(const v of a)D.delete(v);return D})},ne=()=>{E.current&&clearTimeout(E.current),E.current=null,ee.current=null},He=()=>{ne(),W([]),z(null),ve(null)},Re=e=>{const s=e.active.data.current;return s?.entry&&Array.isArray(s.sourcePaths)?{entry:s.entry,sourcePaths:s.sourcePaths}:null},mt=e=>{const s=Re(e);s&&(m.has(s.entry.path)||Ne(s.entry.path),W(s.sourcePaths),ve({entry:s.entry,sourcePaths:s.sourcePaths,count:s.sourcePaths.length}))},jt=e=>{const s=Re(e);if(e.over?.data.current?.openPinned===!0){z(null),ne();return}const o=e.over?.data.current?.targetDirectory;if(!s||typeof o!="string"||!qe(s.sourcePaths,o)){z(null),ne();return}z(o);const r=e.over?.data.current?.expandPath;if(typeof r!="string"||N.has(r)){ne();return}ee.current!==r&&(ne(),ee.current=r,E.current=setTimeout(()=>{Ae(r,!0),E.current=null,ee.current=null},Nn))},yt=e=>{const s=Re(e),o=e.over?.data.current?.openPinned===!0,r=e.over?.data.current?.targetDirectory;if(He(),s&&o&&Ye(s.entry,s.sourcePaths)){j(s.entry.path,"pinned");return}s&&typeof r=="string"&&qe(s.sourcePaths,r)&&xt(s.sourcePaths,r)};return t.jsxs(_t,{sensors:lt,collisionDetection:In,autoScroll:{enabled:!0,threshold:{x:.1,y:.16},acceleration:12},onDragStart:mt,onDragOver:jt,onDragCancel:He,onDragEnd:yt,children:[t.jsxs("div",{className:"files-mobile-tools",children:[t.jsxs(H,{variant:"ghost",size:"sm",onClick:C,children:[t.jsx(zt,{})," Find file"]}),t.jsx(H,{variant:"ghost",size:"sm","aria-pressed":P,onClick:()=>{Me(!P),R(new Set)},children:P?`Done (${m.size})`:"Select"}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-file",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(et,{})," New file"]}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-folder",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(We,{})," Folder"]}),p&&t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>{O("")},children:[t.jsx(Je,{})," Paste"]})]}),t.jsxs("div",{ref:ce,className:"files-view virtual-scroll",hidden:!n,onScroll:e=>it(e.currentTarget.scrollTop),children:[te.headers.length>0&&t.jsx("div",{className:"files-sticky",children:te.headers.map((e,s)=>{const o=s===te.headers.length-1;return t.jsxs("button",{type:"button",className:"file-tree-row files-sticky-row","aria-label":`Scroll to ${e.entry.path}`,style:{top:s*S-(o?te.push:0),paddingLeft:12+e.depth*14,zIndex:te.headers.length-s},onClick:()=>ut(e.entry),children:[t.jsx(Ze,{className:"folder-chevron open"}),t.jsx(Pe,{path:e.entry.path,type:"directory",expanded:!0}),t.jsx("span",{children:e.entry.name})]},e.entry.path)})}),f.length?t.jsx(Fn,{role:"tree","aria-label":"Files",className:`files-tree ${M===""&&ue.length>0?"root-drop-target":""}`,style:{height:X.getTotalSize()},tabIndex:0,onKeyDown:gt,onPointerDown:e=>{e.target.closest(".file-tree-row, .file-touch-actions")||(R(new Set),Y(null),_(null),e.currentTarget.focus())},children:X.getVirtualItems().map(e=>{const{entry:s,depth:o}=y[e.index],r=s.type==="directory"&&N.has(s.path),c=m.has(s.path)&&m.size>1;return t.jsx("div",{className:"virtual-row",style:{height:e.size,transform:`translateY(${e.start}px)`},children:t.jsx(_n,{entry:s,depth:o,expanded:r,pendingChildren:s.type==="directory"&&s.ignored===!0&&s.children.length===0&&!I.has(s.path),selected:ct.has(s.path),active:l===s.path,multiSelected:c,readOnly:h,fileClipboardAvailable:p,revealAvailable:B,historyState:L,onUndo:A,onRedo:U,draggedPaths:ue,dropTargetPath:M,onFocus:_,onRowClick:ht,onRowDoubleClick:pt,onRowContextMenu:ft,onOpen:a=>j(a.path),onOpenPinned:a=>j(a.path,"pinned"),onCopy:a=>{ae(ge(a))},onCut:a=>{ie(ge(a))},onPasteInto:a=>{O(me(a))},onCopyPath:a=>{je(ge(a))},onCopyContents:ye,onRename:a=>$({mode:"rename",entry:a}),onNewFile:a=>$({mode:"new-file",entry:a}),onNewFolder:a=>$({mode:"new-folder",entry:a}),onReveal:ke,onDelete:a=>{le(ge(a))},dragPaths:m.has(s.path)&&m.size>0?[...m]:[s.path]})},e.key)})}):t.jsx("p",{className:"empty-list",children:"No files."}),t.jsx(zn,{state:at,onClose:()=>$(null),onRename:Ce,onCreate:be})]}),t.jsx($t,{dropAnimation:ot?null:Rn,children:J&&t.jsx(Pn,{preview:J})}),_e&&bt.createPortal(t.jsx(Tn,{visible:!!(J&&Ye(J.entry,J.sourcePaths))}),_e)]})}function Fn(n){const{setNodeRef:d}=Fe({id:tt,data:{targetDirectory:"",expandPath:null}});return t.jsx("div",{ref:d,...n})}function Tn({visible:n}){const{isOver:d,setNodeRef:u}=Fe({id:"files-open-pinned-drop",data:{openPinned:!0}});return t.jsxs("div",{ref:u,className:`open-files-drop-target ${n?"visible":""} ${n&&d?"over":""}`,"aria-hidden":"true",children:[t.jsx(Qe,{}),t.jsx("span",{children:"Drop to open beside"})]})}function Pn({preview:n}){return t.jsxs("div",{className:"file-drag-overlay",children:[t.jsx(Pe,{path:n.entry.path,type:n.entry.type,expanded:!1}),t.jsx("span",{children:n.entry.name}),n.count>1&&t.jsx("strong",{children:n.count})]})}function Oe(n,d){if(n.size!==d.size)return!1;for(const u of n)if(!d.has(u))return!1;return!0}function _n({entry:n,depth:d,expanded:u,pendingChildren:g,selected:x,active:l,multiSelected:h,readOnly:p,fileClipboardAvailable:B,revealAvailable:L,historyState:C,onUndo:A,onRedo:U,draggedPaths:j,dropTargetPath:w,onFocus:re,onRowClick:je,onRowDoubleClick:ae,onRowContextMenu:ie,onOpen:ye,onOpenPinned:O,onCopy:De,onCut:le,onPasteInto:ke,onCopyPath:Ce,onCopyContents:be,onRename:we,onNewFile:Z,onNewFolder:P,onReveal:Me,onDelete:S,dragPaths:ce}){const V=i.useRef(null),m=me(n),{attributes:R,listeners:de,setNodeRef:Y,isDragging:q}=qt({id:`file-drag:${n.path}`,data:{sourcePaths:ce,entry:n},disabled:p}),{setNodeRef:_}=Fe({id:`file-drop:${n.path}`,data:{targetDirectory:m,expandPath:n.type==="directory"?n.path:null}}),N=M=>{V.current=M,Y(M),_(M)},G=j.length>0&&n.type==="directory"&&w===n.path,ue=j.length>0&&w!==null&&w!==""&&w!==n.path&&Ee(w,n.path),W=t.jsxs("button",{type:"button",ref:N,...R,role:"treeitem","aria-selected":x,"aria-current":l?"true":void 0,"aria-expanded":n.type==="directory"?u:void 0,className:["file-tree-row",n.ignored?"ignored-file":"",j.includes(n.path)||q?"dragging":"",G?"drop-target":"",ue?"drop-target-region":""].filter(Boolean).join(" "),style:{paddingLeft:12+d*14},...de,onClick:M=>je(n,{ctrl:M.ctrlKey||M.metaKey,shift:M.shiftKey}),onDoubleClick:()=>ae(n),onFocus:()=>re(n.path),onContextMenu:()=>ie(n),children:[n.type==="directory"?t.jsx(Ze,{className:`folder-chevron ${u?"open":""} ${n.children.length===0&&!g?"empty":""}`}):t.jsx("span",{className:"tree-spacer"}),t.jsx(Pe,{path:n.path,type:n.type,expanded:u}),t.jsx("span",{children:n.name})]});return t.jsxs(wn,{children:[t.jsx(Mn,{render:W}),t.jsx("button",{type:"button",className:"file-touch-actions","aria-label":`Actions for ${n.name}`,"aria-haspopup":"menu",onClick:M=>{M.stopPropagation();const z=M.currentTarget.getBoundingClientRect();V.current?.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:z.left,clientY:z.bottom}))},children:t.jsx(Dn,{})}),t.jsxs(vn,{children:[n.type==="file"&&t.jsxs(t.Fragment,{children:[t.jsxs(b,{onClick:()=>ye(n),children:[t.jsx(Xt,{"aria-hidden":"true"})," Open"]}),t.jsxs(b,{onClick:()=>O(n),children:[t.jsx(Qe,{"aria-hidden":"true"})," Open to the Side ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Click"})]}),t.jsx(oe,{})]}),t.jsxs(b,{disabled:p||!C.canUndo,onClick:()=>{A()},children:[t.jsx(hn,{"aria-hidden":"true"})," ",C.undoLabel?`Undo ${C.undoLabel}`:"Undo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Z"})]}),t.jsxs(b,{disabled:p||!C.canRedo,onClick:()=>{U()},children:[t.jsx(fn,{"aria-hidden":"true"})," ",C.redoLabel?`Redo ${C.redoLabel}`:"Redo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Shift+Z"})]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>De(n),children:[t.jsx(Ot,{"aria-hidden":"true"})," Copy ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+C"})]}),t.jsxs(b,{disabled:p,onClick:()=>le(n),children:[t.jsx(jn,{"aria-hidden":"true"})," Cut ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+X"})]}),B&&t.jsxs(b,{disabled:p,onClick:()=>ke(n),children:[t.jsx(Je,{"aria-hidden":"true"})," Paste ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+V"})]}),t.jsx(oe,{}),t.jsxs(b,{disabled:p||h,onClick:()=>we(n),children:[t.jsx(dn,{"aria-hidden":"true"})," Rename ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"F2"})]}),t.jsxs(b,{disabled:p||h,onClick:()=>Z(n),children:[t.jsx(et,{"aria-hidden":"true"})," New File…"]}),t.jsxs(b,{disabled:p||h,onClick:()=>P(n),children:[t.jsx(We,{"aria-hidden":"true"})," New Folder…"]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>Ce(n),children:[t.jsx(bn,{"aria-hidden":"true"})," Copy path"]}),t.jsxs(b,{disabled:n.type!=="file"||h,onClick:()=>{be(n)},children:[t.jsx(tn,{"aria-hidden":"true"})," Copy contents"]}),L&&t.jsxs(b,{disabled:h,onClick:()=>{Me(n)},children:[t.jsx(Zt,{"aria-hidden":"true"})," Reveal in File Explorer"]}),t.jsx(oe,{}),t.jsxs(b,{className:"text-destructive data-highlighted:text-destructive",disabled:p,onClick:()=>S(n),children:[t.jsx(Gt,{"aria-hidden":"true"})," Delete ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Del"})]})]})]})}function zn({state:n,onClose:d,onRename:u,onCreate:g}){const[x,l]=i.useState("");if(i.useEffect(()=>{n&&l(n.mode==="rename"?n.entry.name:"")},[n]),!n)return null;const h=n.mode==="rename",p=n.mode==="new-folder"?"directory":"file",B=me(n.entry),L=h?"Rename":p==="directory"?"New Folder":"New File",C=x.trim(),A=C.length>0&&!/[\\/]/.test(C)&&!(h&&C===n.entry.name),U=()=>{A&&(h?u(n.entry,C):g(B,C,p),d())};return t.jsx(Wt,{open:!0,onOpenChange:j=>{j||d()},children:t.jsx(Jt,{className:"name-dialog",children:t.jsxs("form",{className:"name-dialog-content",onSubmit:j=>{j.preventDefault(),U()},children:[t.jsx(Qt,{children:L}),t.jsx(en,{children:h?t.jsxs(t.Fragment,{children:["Enter a new name for ",t.jsx("code",{children:n.entry.name}),"."]}):t.jsxs(t.Fragment,{children:["Create a new ",p==="directory"?"folder":"file"," in ",t.jsx("code",{children:B||"the repository root"}),"."]})}),t.jsx("input",{autoFocus:!0,className:"name-dialog-input",value:x,maxLength:255,placeholder:h?"New name":p==="directory"?"Folder name":"File name",onChange:j=>l(j.target.value),onFocus:j=>{if(!h)return;const w=n.entry.name.lastIndexOf(".");j.target.setSelectionRange(0,w>0?w:n.entry.name.length)}}),t.jsxs("div",{className:"name-dialog-actions",children:[t.jsx(H,{type:"button",variant:"ghost",onClick:d,children:"Cancel"}),t.jsx(H,{type:"submit",disabled:!A,children:h?"Rename":"Create"})]})]})})})}function Pe({path:n,type:d,expanded:u=!1}){const g=d==="file"?Bt(n):Ut(n,u);return t.jsx("img",{className:"vscode-tree-icon",src:g,alt:"","aria-hidden":"true"})}export{Vn as FilesView};
|
|
1
|
+
import{j as t,r as i,a as bt}from"./react-rd22PHbN.js";import{a as wt}from"./tanstack-B8_amOz8.js";import{a3 as Mt,a5 as vt,a7 as St,a8 as Ve,a9 as Nt,X as Rt,aa as It,ab as Et,ac as Ft,ad as Tt,ae as T,G as Pt,af as _t,j as zt,O as Ge,ag as $t,ah as Xe,ai as Ye,aj as Kt,ak as Lt,al as At,am as Ht,R as Bt,an as Ut,ao as Fe,ap as Vt,aq as Xt,Y as We,ar as Yt,as as Ee,at as qt,au as Ot,t as Gt,y as Wt,D as Zt,c as Jt,d as Qt,e as en}from"./App-CBetJ5ZN.js";import{c as K,d as Te,B as H,I as tn}from"./index-BOPi2b1j.js";import{m as nn,n as sn,M as on,o as rn,p as an,q as ln,S as cn}from"./base-ui-qeHDA5zu.js";import{I as Ze}from"./IconFolderPlus-1vLDIzhC.js";import{I as dn}from"./IconEdit-CxvzMyLV.js";const un=[["path",{d:"M9 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M5 10h11a4 4 0 1 1 0 8h-1",key:"svg-1"}]],hn=K("outline","arrow-back-up","ArrowBackUp",un);const pn=[["path",{d:"M15 14l4 -4l-4 -4",key:"svg-0"}],["path",{d:"M19 10h-11a4 4 0 1 0 0 8h1",key:"svg-1"}]],fn=K("outline","arrow-forward-up","ArrowForwardUp",pn);const gn=[["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"}]],Je=K("outline","clipboard","Clipboard",gn);const xn=[["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"}]],Qe=K("outline","columns-2","Columns2",xn);const mn=[["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"}]],jn=K("outline","cut","Cut",mn);const yn=[["path",{d:"M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]],Dn=K("outline","dots","Dots",yn);const kn=[["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"}]],et=K("outline","file-plus","FilePlus",kn);const Cn=[["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:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]],bn=K("outline","file-text","FileText",Cn),wn=nn,Mn=sn;function vn({className:n,children:d,...u}){return t.jsx(on,{children:t.jsx(rn,{className:"isolate z-50 outline-none",children:t.jsx(an,{"data-slot":"context-menu-content",className:Te("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",n),...u,children:d})})})}function b({className:n,...d}){return t.jsx(ln,{"data-slot":"context-menu-item",className:Te("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",n),...d})}function oe({className:n,...d}){return t.jsx(cn,{"data-slot":"context-menu-separator",className:Te("mx-1 my-1 h-px bg-border",n),...d})}const Sn=29,xe=6,tt="files-tree-root-drop",Nn=550,Rn={duration:160,easing:"cubic-bezier(0.2, 0, 0, 1)"},qe=6,In=n=>{const d=Kt(n),u=d.length>0?d:Lt(n),g=u.find(x=>x.id!==tt);return g?[g]:u.slice(0,1)};function nt(n,d,u=0){const g=[];for(const x of n)g.push({entry:x,depth:u}),x.type==="directory"&&d.has(x.path)&&g.push(...nt(x.children,d,u+1));return g}function En(n,d,u){const g=n.findIndex(p=>p.entry.path===d),x=n.findIndex(p=>p.entry.path===u);if(g===-1||x===-1)return[u];const[l,h]=g<=x?[g,x]:[x,g];return n.slice(l,h+1).map(p=>p.entry.path)}function me(n){return n.type==="directory"?n.path:We(n.path)}function Vn({active:n,initialExpandedPaths:d,files:u,filesSnapshotRevision:g,showDotEnvFiles:x,activePath:l,readOnly:h,fileClipboardAvailable:p,revealAvailable:B,historyState:L,onQuickOpen:C,onUndo:A,onRedo:U,onOpenFile:j,onLoadDirectory:w,onPersistExpandedPaths:re,onCopyPath:je,onCopyEntries:ae,onCutEntries:ie,onCopyContents:ye,onPaste:O,onMoveEntries:De,onDeleteEntries:le,onReveal:ke,onRename:Ce,onCreate:be}){const we=Mt(),G=vt(),[P,Me]=i.useState(!1),S=G?44:Sn,ce=i.useRef(null),V=i.useRef(null),[m,R]=i.useState(new Set),[de,X]=i.useState(l),[Y,_]=i.useState(l),[N,W]=i.useState(()=>new Set(d)),[ue,Z]=i.useState([]),[M,z]=i.useState(null),[J,ve]=i.useState(null),[_e,st]=i.useState(null),[ot,rt]=i.useState(!1),[at,$]=i.useState(null),[he,it]=i.useState(0),[I,pe]=i.useState(new Map),lt=St(Ve(Ht,{activationConstraint:{distance:5}}),Ve(At)),ze=i.useRef(I),Q=i.useRef(new Set),$e=i.useRef(0),E=i.useRef(null),ee=i.useRef(null),Ke=i.useRef(d.join("\0")),fe=i.useMemo(()=>new Set(I.keys()),[I]),F=i.useMemo(()=>u===null?null:Nt(u,I),[u,I]),f=i.useMemo(()=>F===null?null:x?F:Rt(F),[F,x]);i.useEffect(()=>{ze.current=I},[I]),i.useEffect(()=>{st(document.getElementById(It))},[l]),i.useEffect(()=>{const e=window.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>rt(e.matches);return s(),e.addEventListener("change",s),()=>e.removeEventListener("change",s)},[]),i.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]),i.useEffect(()=>{const e=++$e.current,s=[...ze.current.keys()];s.length!==0&&Promise.all(s.map(async o=>({path:o,children:await w(o)}))).then(o=>{if(e!==$e.current)return;const r=new Map(o.map(({path:c,children:a})=>[c,a]));pe(c=>Et(c,r))})},[g,w]),i.useEffect(()=>{if(!F){Q.current.clear(),pe(e=>e.size===0?e:new Map);return}W(e=>{const s=new Set(Ft(F,e,fe).retained);return Oe(e,s)?e:s})},[fe,F]),i.useEffect(()=>{if(!F)return;const e=Tt(F,N,fe),s=e.join("\0");s!==Ke.current&&(Ke.current=s,re(e))},[N,fe,F,re]),i.useEffect(()=>{if(!n||!f)return;let e=Math.max(0,2-Q.current.size);for(const s of N){if(e===0)break;const o=T(f,s);!o||o.type!=="directory"||o.ignored!==!0||o.children.length>0||I.has(s)||Q.current.has(s)||(Q.current.add(s),e-=1,w(s).catch(()=>[]).then(r=>{pe(c=>new Map(c).set(s,r))}).finally(()=>{Q.current.delete(s)}))}},[n,N,I,w,f]),i.useEffect(()=>{n||($(null),Z([]),z(null),ve(null),E.current&&clearTimeout(E.current),E.current=null,ee.current=null)},[n]),i.useEffect(()=>{f&&(R(e=>{if(e.size===0)return e;const s=new Set([...e].filter(o=>T(f,o)));return s.size===e.size?e:s}),X(e=>e&&T(f,e)?e:null),_(e=>e&&T(f,e)?e:l&&T(f,l)?l:null))},[l,f]);const y=i.useMemo(()=>f?nt(f,N):[],[N,f]),q=wt({enabled:n,count:y.length,getScrollElement:()=>ce.current,estimateSize:()=>S,getItemKey:e=>y[e]?.entry.path??e,overscan:12,paddingStart:xe,paddingEnd:12});i.useEffect(()=>{q.measure()},[q,S]),i.useEffect(()=>{!n||!l||!f||!T(f,l)||W(e=>{const s=new Set(e);let o=!1;const r=l.split("/");let c="";for(let a=0;a<r.length-1;a+=1)c=c?`${c}/${r[a]}`:r[a],s.has(c)||(s.add(c),o=!0);return o?s:e})},[n,l,f]),i.useEffect(()=>{if(!n)return;if(!l){V.current=null;return}if(V.current===l)return;const e=y.findIndex(s=>s.entry.path===l);e>=0&&(q.scrollToIndex(e,{align:"auto"}),V.current=l)},[n,l,y]);const Le=i.useMemo(()=>{const e=new Map;for(const s of y)e.set(s.entry.path,s);return e},[y]),te=i.useMemo(()=>{const e={headers:[],push:0};if(y.length===0||!l)return e;const s=new Set,o=l.split("/");let r="";for(let k=0;k<o.length-1;k+=1)r=r?`${r}/${o[k]}`:o[k],s.add(r);if(s.size===0)return e;const c=Math.min(y.length-1,Math.max(0,Math.floor((he-xe)/S))),a=y[c];if(!a)return e;const D=a.entry.path.split("/"),v=[];let se="";for(let k=0;k<D.length-1;k+=1){if(se=se?`${se}/${D[k]}`:D[k],!s.has(se))continue;const Ie=Le.get(se);Ie&&Ie.entry.type==="directory"&&v.push(Ie)}if(v.length>qe&&v.splice(0,v.length-qe),v.length===0)return e;const Dt=v[v.length-1],Be=v.length*S;let Ue=1/0;const kt=Math.ceil((he+Be-xe)/S)+2;for(let k=c;k<y.length&&k<=kt;k+=1)if(y[k].depth<=Dt.depth){Ue=xe+k*S;break}const Ct=Math.max(0,Math.min(S,Be-(Ue-he)));return{headers:v,push:Ct}},[y,Le,he,l,S]);if(f===null)return t.jsx("div",{className:"view-loading",role:"status",hidden:!n,children:t.jsx(Pt,{text:"Loading files…"})});const ct=P||m.size>0?m:l?new Set([l]):new Set,dt=m.size>0?[...m]:l?[l]:[],Se=e=>{const s=[];for(const o of e){const r=T(f,o);r&&s.push(r)}return s},Ne=e=>{R(new Set([e])),X(e),_(e)},ut=e=>{const s=y.findIndex(o=>o.entry.path===e.path);s>=0&&q.scrollToIndex(s,{align:"start"})},ht=(e,s)=>{if(G&&P){R(o=>{const r=new Set(o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r});return}if(s.shift&&(de||Y)){const o=En(y,de??Y,e.path);R(new Set(o)),_(e.path);return}if(s.ctrl){R(o=>{const r=new Set(o.size===0&&l?[l]:o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r}),X(e.path),_(e.path),e.type==="file"&&j(e.path,"pinned");return}Ne(e.path),e.type==="file"?j(e.path):Ae(e.path)},pt=e=>{!(G&&P)&&e.type==="file"&&j(e.path,"pinned")},ft=e=>{m.has(e.path)||Ne(e.path)},ge=e=>m.has(e.path)&&m.size>0?Se(m):[e],gt=e=>{if(Vt(e.target))return;const s=Xt(e.nativeEvent,we);if(s==="undo"&&L.canUndo&&!h){e.preventDefault(),e.repeat||A();return}if(s==="redo"&&L.canRedo&&!h){e.preventDefault(),e.repeat||U();return}const o=(e.ctrlKey||e.metaKey)&&!e.altKey,r=e.key.toLowerCase();if(o&&r==="a"){e.preventDefault(),R(new Set(y.map(D=>D.entry.path)));return}const c=Se(dt),a=Y?T(f,Y):null;if(o&&r==="c"&&c.length){e.preventDefault(),ae(c);return}if(o&&r==="x"&&c.length&&!h){e.preventDefault(),ie(c);return}if(o&&r==="v"&&!h&&p){e.preventDefault();const D=a?me(a):We(c[0]?.path??"");O(D);return}if(e.key==="F2"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h){if(m.size===1){const D=T(f,[...m][0]);D&&(e.preventDefault(),$({mode:"rename",entry:D}))}return}e.key==="Delete"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h&&c.length&&(e.preventDefault(),le(c))},xt=async(e,s)=>{const o=Se(e);o.length&&await De(o,s)},Ae=(e,s=!1)=>{const o=!s&&N.has(e),r=o&&T(f??[],e)?.ignored===!0;W(c=>{const a=new Set(c);if(s||!a.has(e)){if(a.has(e))return c;a.add(e)}else if(r)for(const D of a)Ee(e,D)&&a.delete(D);else a.delete(e);return Oe(c,a)?c:a}),o&&pe(c=>{const a=[...c.keys()].filter(v=>Ee(e,v));if(a.length===0)return c;const D=new Map(c);for(const v of a)D.delete(v);return D})},ne=()=>{E.current&&clearTimeout(E.current),E.current=null,ee.current=null},He=()=>{ne(),Z([]),z(null),ve(null)},Re=e=>{const s=e.active.data.current;return s?.entry&&Array.isArray(s.sourcePaths)?{entry:s.entry,sourcePaths:s.sourcePaths}:null},mt=e=>{const s=Re(e);s&&(m.has(s.entry.path)||Ne(s.entry.path),Z(s.sourcePaths),ve({entry:s.entry,sourcePaths:s.sourcePaths,count:s.sourcePaths.length}))},jt=e=>{const s=Re(e);if(e.over?.data.current?.openPinned===!0){z(null),ne();return}const o=e.over?.data.current?.targetDirectory;if(!s||typeof o!="string"||!Ye(s.sourcePaths,o)){z(null),ne();return}z(o);const r=e.over?.data.current?.expandPath;if(typeof r!="string"||N.has(r)){ne();return}ee.current!==r&&(ne(),ee.current=r,E.current=setTimeout(()=>{Ae(r,!0),E.current=null,ee.current=null},Nn))},yt=e=>{const s=Re(e),o=e.over?.data.current?.openPinned===!0,r=e.over?.data.current?.targetDirectory;if(He(),s&&o&&Xe(s.entry,s.sourcePaths)){j(s.entry.path,"pinned");return}s&&typeof r=="string"&&Ye(s.sourcePaths,r)&&xt(s.sourcePaths,r)};return t.jsxs(_t,{sensors:lt,collisionDetection:In,autoScroll:{enabled:!0,threshold:{x:.1,y:.16},acceleration:12},onDragStart:mt,onDragOver:jt,onDragCancel:He,onDragEnd:yt,children:[t.jsxs("div",{className:"files-mobile-tools",children:[t.jsxs(H,{variant:"ghost",size:"sm",onClick:C,children:[t.jsx(zt,{})," Find file"]}),t.jsx(H,{variant:"ghost",size:"sm","aria-pressed":P,onClick:()=>{Me(!P),R(new Set)},children:P?`Done (${m.size})`:"Select"}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-file",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(et,{})," New file"]}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-folder",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(Ze,{})," Folder"]}),p&&t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>{O("")},children:[t.jsx(Je,{})," Paste"]})]}),t.jsxs("div",{ref:ce,className:"files-view virtual-scroll",hidden:!n,onScroll:e=>it(e.currentTarget.scrollTop),children:[te.headers.length>0&&t.jsx("div",{className:"files-sticky",children:te.headers.map((e,s)=>{const o=s===te.headers.length-1;return t.jsxs("button",{type:"button",className:"file-tree-row files-sticky-row","aria-label":`Scroll to ${e.entry.path}`,style:{top:s*S-(o?te.push:0),paddingLeft:12+e.depth*14,zIndex:te.headers.length-s},onClick:()=>ut(e.entry),children:[t.jsx(Ge,{className:"folder-chevron open"}),t.jsx(Pe,{path:e.entry.path,type:"directory",expanded:!0}),t.jsx("span",{children:e.entry.name})]},e.entry.path)})}),f.length?t.jsx(Fn,{role:"tree","aria-label":"Files",className:`files-tree ${M===""&&ue.length>0?"root-drop-target":""}`,style:{height:q.getTotalSize()},tabIndex:0,onKeyDown:gt,onPointerDown:e=>{e.target.closest(".file-tree-row, .file-touch-actions")||(R(new Set),X(null),_(null),e.currentTarget.focus())},children:q.getVirtualItems().map(e=>{const{entry:s,depth:o}=y[e.index],r=s.type==="directory"&&N.has(s.path),c=m.has(s.path)&&m.size>1;return t.jsx("div",{className:"virtual-row",style:{height:e.size,transform:`translateY(${e.start}px)`},children:t.jsx(_n,{entry:s,depth:o,expanded:r,pendingChildren:s.type==="directory"&&s.ignored===!0&&s.children.length===0&&!I.has(s.path),selected:ct.has(s.path),active:l===s.path,multiSelected:c,readOnly:h,fileClipboardAvailable:p,revealAvailable:B,historyState:L,onUndo:A,onRedo:U,draggedPaths:ue,dropTargetPath:M,onFocus:_,onRowClick:ht,onRowDoubleClick:pt,onRowContextMenu:ft,onOpen:a=>j(a.path),onOpenPinned:a=>j(a.path,"pinned"),onCopy:a=>{ae(ge(a))},onCut:a=>{ie(ge(a))},onPasteInto:a=>{O(me(a))},onCopyPath:a=>{je(ge(a))},onCopyContents:ye,onRename:a=>$({mode:"rename",entry:a}),onNewFile:a=>$({mode:"new-file",entry:a}),onNewFolder:a=>$({mode:"new-folder",entry:a}),onReveal:ke,onDelete:a=>{le(ge(a))},dragPaths:m.has(s.path)&&m.size>0?[...m]:[s.path]})},e.key)})}):t.jsx("p",{className:"empty-list",children:"No files."}),t.jsx(zn,{state:at,onClose:()=>$(null),onRename:Ce,onCreate:be})]}),t.jsx($t,{dropAnimation:ot?null:Rn,children:J&&t.jsx(Pn,{preview:J})}),_e&&bt.createPortal(t.jsx(Tn,{visible:!!(J&&Xe(J.entry,J.sourcePaths))}),_e)]})}function Fn(n){const{setNodeRef:d}=Fe({id:tt,data:{targetDirectory:"",expandPath:null}});return t.jsx("div",{ref:d,...n})}function Tn({visible:n}){const{isOver:d,setNodeRef:u}=Fe({id:"files-open-pinned-drop",data:{openPinned:!0}});return t.jsxs("div",{ref:u,className:`open-files-drop-target ${n?"visible":""} ${n&&d?"over":""}`,"aria-hidden":"true",children:[t.jsx(Qe,{}),t.jsx("span",{children:"Drop to open beside"})]})}function Pn({preview:n}){return t.jsxs("div",{className:"file-drag-overlay",children:[t.jsx(Pe,{path:n.entry.path,type:n.entry.type,expanded:!1}),t.jsx("span",{children:n.entry.name}),n.count>1&&t.jsx("strong",{children:n.count})]})}function Oe(n,d){if(n.size!==d.size)return!1;for(const u of n)if(!d.has(u))return!1;return!0}function _n({entry:n,depth:d,expanded:u,pendingChildren:g,selected:x,active:l,multiSelected:h,readOnly:p,fileClipboardAvailable:B,revealAvailable:L,historyState:C,onUndo:A,onRedo:U,draggedPaths:j,dropTargetPath:w,onFocus:re,onRowClick:je,onRowDoubleClick:ae,onRowContextMenu:ie,onOpen:ye,onOpenPinned:O,onCopy:De,onCut:le,onPasteInto:ke,onCopyPath:Ce,onCopyContents:be,onRename:we,onNewFile:G,onNewFolder:P,onReveal:Me,onDelete:S,dragPaths:ce}){const V=i.useRef(null),m=me(n),{attributes:R,listeners:de,setNodeRef:X,isDragging:Y}=Yt({id:`file-drag:${n.path}`,data:{sourcePaths:ce,entry:n},disabled:p}),{setNodeRef:_}=Fe({id:`file-drop:${n.path}`,data:{targetDirectory:m,expandPath:n.type==="directory"?n.path:null}}),N=M=>{V.current=M,X(M),_(M)},W=j.length>0&&n.type==="directory"&&w===n.path,ue=j.length>0&&w!==null&&w!==""&&w!==n.path&&Ee(w,n.path),Z=t.jsxs("button",{type:"button",ref:N,...R,role:"treeitem","aria-selected":x,"aria-current":l?"true":void 0,"aria-expanded":n.type==="directory"?u:void 0,className:["file-tree-row",n.ignored?"ignored-file":"",j.includes(n.path)||Y?"dragging":"",W?"drop-target":"",ue?"drop-target-region":""].filter(Boolean).join(" "),style:{paddingLeft:12+d*14},...de,onClick:M=>je(n,{ctrl:M.ctrlKey||M.metaKey,shift:M.shiftKey}),onDoubleClick:()=>ae(n),onFocus:()=>re(n.path),onContextMenu:()=>ie(n),children:[n.type==="directory"?t.jsx(Ge,{className:`folder-chevron ${u?"open":""} ${n.children.length===0&&!g?"empty":""}`}):t.jsx("span",{className:"tree-spacer"}),t.jsx(Pe,{path:n.path,type:n.type,expanded:u}),t.jsx("span",{children:n.name})]});return t.jsxs(wn,{children:[t.jsx(Mn,{render:Z}),t.jsx("button",{type:"button",className:"file-touch-actions","aria-label":`Actions for ${n.name}`,"aria-haspopup":"menu",onClick:M=>{M.stopPropagation();const z=M.currentTarget.getBoundingClientRect();V.current?.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:z.left,clientY:z.bottom}))},children:t.jsx(Dn,{})}),t.jsxs(vn,{children:[n.type==="file"&&t.jsxs(t.Fragment,{children:[t.jsxs(b,{onClick:()=>ye(n),children:[t.jsx(qt,{"aria-hidden":"true"})," Open"]}),t.jsxs(b,{onClick:()=>O(n),children:[t.jsx(Qe,{"aria-hidden":"true"})," Open to the Side ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Click"})]}),t.jsx(oe,{})]}),t.jsxs(b,{disabled:p||!C.canUndo,onClick:()=>{A()},children:[t.jsx(hn,{"aria-hidden":"true"})," ",C.undoLabel?`Undo ${C.undoLabel}`:"Undo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Z"})]}),t.jsxs(b,{disabled:p||!C.canRedo,onClick:()=>{U()},children:[t.jsx(fn,{"aria-hidden":"true"})," ",C.redoLabel?`Redo ${C.redoLabel}`:"Redo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Shift+Z"})]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>De(n),children:[t.jsx(Ot,{"aria-hidden":"true"})," Copy ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+C"})]}),t.jsxs(b,{disabled:p,onClick:()=>le(n),children:[t.jsx(jn,{"aria-hidden":"true"})," Cut ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+X"})]}),B&&t.jsxs(b,{disabled:p,onClick:()=>ke(n),children:[t.jsx(Je,{"aria-hidden":"true"})," Paste ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+V"})]}),t.jsx(oe,{}),t.jsxs(b,{disabled:p||h,onClick:()=>we(n),children:[t.jsx(dn,{"aria-hidden":"true"})," Rename ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"F2"})]}),t.jsxs(b,{disabled:p||h,onClick:()=>G(n),children:[t.jsx(et,{"aria-hidden":"true"})," New File…"]}),t.jsxs(b,{disabled:p||h,onClick:()=>P(n),children:[t.jsx(Ze,{"aria-hidden":"true"})," New Folder…"]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>Ce(n),children:[t.jsx(bn,{"aria-hidden":"true"})," Copy path"]}),t.jsxs(b,{disabled:n.type!=="file"||h,onClick:()=>{be(n)},children:[t.jsx(tn,{"aria-hidden":"true"})," Copy contents"]}),L&&t.jsxs(b,{disabled:h,onClick:()=>{Me(n)},children:[t.jsx(Gt,{"aria-hidden":"true"})," Reveal in File Explorer"]}),t.jsx(oe,{}),t.jsxs(b,{className:"text-destructive data-highlighted:text-destructive",disabled:p,onClick:()=>S(n),children:[t.jsx(Wt,{"aria-hidden":"true"})," Delete ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Del"})]})]})]})}function zn({state:n,onClose:d,onRename:u,onCreate:g}){const[x,l]=i.useState("");if(i.useEffect(()=>{n&&l(n.mode==="rename"?n.entry.name:"")},[n]),!n)return null;const h=n.mode==="rename",p=n.mode==="new-folder"?"directory":"file",B=me(n.entry),L=h?"Rename":p==="directory"?"New Folder":"New File",C=x.trim(),A=C.length>0&&!/[\\/]/.test(C)&&!(h&&C===n.entry.name),U=()=>{A&&(h?u(n.entry,C):g(B,C,p),d())};return t.jsx(Zt,{open:!0,onOpenChange:j=>{j||d()},children:t.jsx(Jt,{className:"name-dialog",children:t.jsxs("form",{className:"name-dialog-content",onSubmit:j=>{j.preventDefault(),U()},children:[t.jsx(Qt,{children:L}),t.jsx(en,{children:h?t.jsxs(t.Fragment,{children:["Enter a new name for ",t.jsx("code",{children:n.entry.name}),"."]}):t.jsxs(t.Fragment,{children:["Create a new ",p==="directory"?"folder":"file"," in ",t.jsx("code",{children:B||"the repository root"}),"."]})}),t.jsx("input",{autoFocus:!0,className:"name-dialog-input",value:x,maxLength:255,placeholder:h?"New name":p==="directory"?"Folder name":"File name",onChange:j=>l(j.target.value),onFocus:j=>{if(!h)return;const w=n.entry.name.lastIndexOf(".");j.target.setSelectionRange(0,w>0?w:n.entry.name.length)}}),t.jsxs("div",{className:"name-dialog-actions",children:[t.jsx(H,{type:"button",variant:"ghost",onClick:d,children:"Cancel"}),t.jsx(H,{type:"submit",disabled:!A,children:h?"Rename":"Create"})]})]})})})}function Pe({path:n,type:d,expanded:u=!1}){const g=d==="file"?Bt(n):Ut(n,u);return t.jsx("img",{className:"vscode-tree-icon",src:g,alt:"","aria-hidden":"true"})}export{Vn as FilesView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./index-
|
|
1
|
+
import{c as e}from"./index-BOPi2b1j.js";import{r as n,j as a}from"./react-rd22PHbN.js";const r=[["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"}]],u=e("outline","circle-check","CircleCheck",r);const i=[["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"}]],v=e("outline","circle-x","CircleX",i);const l=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 7v5l3 3",key:"svg-1"}]],C=e("outline","clock","Clock",l);const d=[["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"}]],p=e("outline","user-circle","UserCircle",d);function g({src:c,className:t}){const[o,s]=n.useState(!1);return a.jsx("span",{className:t,"aria-hidden":"true",children:c&&!o?a.jsx("img",{src:c,alt:"",onError:()=>s(!0)}):a.jsx(p,{})})}export{g as G,u as I,v as a,C as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as w,j as e}from"./react-rd22PHbN.js";import{a as V}from"./tanstack-B8_amOz8.js";import{B as H,o as _,T as y,a as v,b as $,w as z,s as P}from"./index-BOPi2b1j.js";import{k as I,G as O,M as U,N as Y,O as B,P as W,Q as X,R as K}from"./App-CBetJ5ZN.js";import"./base-ui-qeHDA5zu.js";function Q(s){let n=[],t=0,c=1;const i=new Map,r=[];for(const u of s){let o=n.indexOf(u.oid);const j=o>=0;o<0&&(o=n.length,n=[...n,u.oid]);const x=n,g=q(i,u.oid,()=>t++),m=x.filter((l,h)=>h!==o);let d=Math.min(o,m.length);u.parentOids.forEach((l,h)=>{i.has(l)||i.set(l,h===0?g:t++),!m.includes(l)&&(m.splice(d,0,l),d+=1)});const N=[];x.forEach((l,h)=>{if(h===o){j&&N.push({fromLane:h,from:"top",toLane:o,to:"node",color:i.get(l)??g});return}const b=m.indexOf(l);b>=0&&N.push({fromLane:h,from:"top",toLane:b,to:"bottom",color:i.get(l)??0})}),u.parentOids.forEach(l=>{const h=m.indexOf(l);h>=0&&N.push({fromLane:o,from:"node",toLane:h,to:"bottom",color:i.get(l)??g})}),c=Math.max(c,x.length,m.length),r.push({lane:o,color:g,segments:N,continuations:m.map((l,h)=>({lane:h,color:i.get(l)??0}))}),n=m}return{rows:r,laneCount:c}}function q(s,n,t){const c=s.get(n);if(c!==void 0)return c;const i=t();return s.set(n,i),i}function pe({repositoryId:s,upstream:n,readOnly:t,operation:c,canPublish:i,pushBusy:r,onPublish:u,commits:o,nextCursor:j,loading:x,undoing:g,onSelectCommit:m,onSelectFile:d,onUndo:N,onMore:l}){const h=w.useRef(null),[b,R]=w.useState(new Set),E=w.useMemo(()=>Q(o??[]),[o]),T=Z(E.laneCount),C=V({count:o?.length??0,getScrollElement:()=>h.current,estimateSize:()=>52,getItemKey:p=>o?.[p]?.oid??p,overscan:8});return o===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(I,{className:"spinner"})," ",e.jsx(O,{text:"Loading history…"})]}):e.jsxs("div",{className:"history-list",children:[!n&&o.length>0&&e.jsxs("div",{className:"history-upstream-notice",role:"status",children:[e.jsx("span",{children:"Publish this branch to configure an upstream and distinguish local from published commits."}),i&&e.jsx(H,{variant:"outline",size:"xs",disabled:r||t||!!c,onClick:u,children:r?"Publishing…":"Publish branch"})]}),e.jsx("div",{ref:h,className:"history-scroll",role:"list","aria-label":"Commit history",children:o.length===0?e.jsx("p",{className:"empty-list",children:"This repository has no commits yet."}):e.jsxs("div",{className:"virtual-list",style:{height:C.getTotalSize()+(j?52:0)},children:[C.getVirtualItems().map(p=>{const a=o[p.index];return e.jsx("div",{ref:C.measureElement,"data-index":p.index,className:"virtual-row",style:{transform:`translateY(${p.start}px)`},children:e.jsx(J,{repositoryId:s,upstream:n,commit:a,graphRow:E.rows[p.index],graphWidth:T,expanded:b.has(a.oid),onExpandedChange:f=>R(G=>{const A=new Set(G);return f?A.add(a.oid):A.delete(a.oid),A}),canUndo:!t&&!c&&!g&&a.upstreamState==="local-only"&&a.isHead&&a.parentCount===1,onSelectCommit:m,onSelectFile:d,onUndo:N})},p.key)}),j&&e.jsx(H,{variant:"ghost",className:"history-more",style:{top:C.getTotalSize()},disabled:x,onClick:l,children:x?"Loading…":"Load more"})]})})]})}function J({repositoryId:s,upstream:n,commit:t,graphRow:c,graphWidth:i,expanded:r,onExpandedChange:u,canUndo:o,onSelectCommit:j,onSelectFile:x,onUndo:g}){const m=`${s}:${t.oid}`,[d,N]=w.useState(()=>U(m)??null),[l,h]=w.useState(null);w.useEffect(()=>{if(!r||d||l)return;let a=!0;return _.commits.files(s,t.oid).then(f=>{a&&(Y(m,f),N(f))}).catch(f=>{a&&h(ce(f))}),()=>{a=!1}},[m,t.oid,r,d,l,s]);const b=ne(t.decorations),R=b.slice(0,3),E=b.slice(3),T=d?.reduce((a,f)=>a+f.additions,0)??0,C=d?.reduce((a,f)=>a+f.deletions,0)??0,p=async()=>{try{await z(t.oid),P.success({title:"Hash copied",description:t.oid})}catch{P.error({title:"Could not copy hash"})}};return e.jsxs("div",{className:"commit-item",role:"listitem",children:[e.jsxs("div",{className:"commit-header",children:[e.jsx(ee,{graph:c,width:i}),e.jsx("button",{className:"commit-expand","aria-expanded":r,"aria-label":r?"Collapse commit":"Expand commit",onClick:()=>u(!r),children:e.jsx(B,{className:`folder-chevron ${r?"open":""}`})}),e.jsxs("div",{className:"commit-main",children:[e.jsxs("span",{className:"commit-title-row",children:[e.jsxs(y,{children:[e.jsx(v,{render:e.jsx("button",{className:"commit-subject",onClick:()=>j(t)}),children:t.subject||"(no subject)"}),e.jsx($,{side:"right",children:"View the full commit diff"})]}),e.jsxs(y,{children:[e.jsx(v,{render:e.jsx("span",{className:"commit-date"}),children:oe(t.date)}),e.jsx($,{children:re(t.date)})]})]}),e.jsxs("span",{className:"commit-meta",children:[e.jsxs(y,{children:[e.jsx(v,{render:e.jsx("button",{className:"commit-oid",onClick:()=>{p()},"aria-label":`Copiar hash ${t.shortOid}`}),children:t.shortOid}),e.jsx($,{children:"Copy full hash"})]}),e.jsx("span",{className:"commit-author",children:t.author}),(b.length>0||t.parentCount>1||t.upstreamState==="local-only")&&e.jsxs("span",{className:"commit-refs",children:[t.upstreamState==="local-only"&&e.jsxs(y,{children:[e.jsx(v,{render:e.jsx("span",{className:"ref-chip local-only"}),children:"Local"}),e.jsx($,{children:t.isHead?`Not in ${n??"the upstream"} according to the latest known remote state.`:"Not published. To avoid rewriting multiple commits, only the latest can be undone."})]}),t.parentCount>1&&e.jsx("span",{className:"ref-chip merge",children:"merge"}),R.map(a=>e.jsx("span",{className:`ref-chip ${a.kind}`,children:a.label},`${a.kind}:${a.label}`)),E.length>0&&e.jsxs(y,{children:[e.jsxs(v,{render:e.jsx("span",{className:"ref-chip more"}),children:["+",E.length]}),e.jsx($,{children:E.map(a=>a.label).join(" · ")})]})]})]})]}),o&&e.jsxs(y,{children:[e.jsx(v,{render:e.jsx(H,{variant:"ghost",size:"icon-xs",className:"change-action-button commit-undo",onClick:a=>{a.stopPropagation(),g(t)},"aria-label":`Undo commit ${t.shortOid}`}),children:e.jsx(W,{})}),e.jsx($,{children:"Undo commit and keep its changes staged"})]})]}),r&&c.continuations.length>0&&e.jsx(se,{graph:c,width:i}),r&&e.jsxs("div",{className:"commit-files",style:{paddingLeft:i+31},children:[t.body&&e.jsx("p",{className:"commit-description",children:t.body}),l&&e.jsx("div",{className:"commit-files-message error",children:l}),!d&&!l&&e.jsxs("div",{className:"commit-files-message",children:[e.jsx(I,{className:"spinner"})," ",e.jsx(O,{text:"Loading files…"})]}),d&&d.length===0&&e.jsx("div",{className:"commit-files-message",children:"This commit does not modify its own files (merge)."}),d&&d.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"commit-files-summary",children:[d.length," ",d.length===1?"file":"files",(T>0||C>0)&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"add",children:["+",T]})," ",e.jsxs("span",{className:"del",children:["−",C]})]})]}),d.map(a=>e.jsx(te,{file:a,onSelect:()=>x(t.oid,a)},a.path))]})]})]})}const M=10,S=26,F=52,D=["var(--primary)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)"];function Z(s){return 14+Math.max(0,s-1)*M}function k(s){return 7+s*M}function L(s){return D[s%D.length]}function ee({graph:s,width:n}){return e.jsxs("svg",{className:"commit-graph",width:n,height:F,viewBox:`0 0 ${n} ${F}`,"aria-hidden":"true",children:[s.segments.map((t,c)=>{const i=k(t.fromLane),r=k(t.toLane),u=t.from==="top"?0:S,o=t.to==="node"?S:F,j=(u+o)/2,x=i===r?`M ${i} ${u} L ${r} ${o}`:`M ${i} ${u} C ${i} ${j}, ${r} ${j}, ${r} ${o}`;return e.jsx("path",{d:x,stroke:L(t.color)},`${c}:${x}`)}),e.jsx("circle",{cx:k(s.lane),cy:S,r:"4",fill:"var(--sidebar)",stroke:L(s.color)}),e.jsx("circle",{cx:k(s.lane),cy:S,r:"1.5",fill:L(s.color)})]})}function se({graph:s,width:n}){return e.jsx("svg",{className:"commit-graph-continuation",width:n,viewBox:`0 0 ${n} 100`,preserveAspectRatio:"none","aria-hidden":"true",children:s.continuations.map(t=>e.jsx("line",{x1:k(t.lane),y1:"0",x2:k(t.lane),y2:"100",stroke:L(t.color)},t.lane))})}function te({file:s,onSelect:n}){const t=w.useRef(null),c=s.path.lastIndexOf("/"),i=c<0?s.path:s.path.slice(c+1),r=s.oldPath?.split("/").pop();return e.jsxs("div",{ref:t,className:"commit-file-row",children:[e.jsxs(y,{children:[e.jsxs(v,{render:e.jsx("button",{className:"commit-file-label",onClick:n,"aria-label":`Ver el diff de ${s.path}`}),children:[e.jsx(le,{path:s.path,type:"file"}),e.jsxs("span",{className:"commit-file-text",children:[e.jsx("span",{children:i}),r&&e.jsxs("small",{className:"commit-file-rename",children:[r," →"]})]})]}),e.jsx($,{anchor:t,side:"right",sideOffset:10,children:s.oldPath?`${s.oldPath} → ${s.path}`:s.path})]}),e.jsx("span",{className:"commit-file-stats",children:s.binary?e.jsx("span",{className:"binary",children:"bin"}):e.jsxs(e.Fragment,{children:[s.additions>0&&e.jsxs("span",{className:"add",children:["+",s.additions]}),s.deletions>0&&e.jsxs("span",{className:"del",children:["−",s.deletions]})]})}),e.jsx("span",{className:"status-code","data-kind":s.kind,children:X(s.kind)})]})}function ne(s){return s.map(n=>n.startsWith("tag: ")?{label:n.slice(5),kind:"tag"}:n.startsWith("HEAD -> ")?{label:n.slice(8),kind:"head"}:n==="HEAD"?{label:"HEAD",kind:"head"}:{label:n,kind:n.includes("/")?"remote":"branch"})}const ae=new Intl.RelativeTimeFormat("en",{numeric:"auto"}),ie=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]];function oe(s){const n=new Date(s);if(Number.isNaN(n.getTime()))return s;const t=Math.round((n.getTime()-Date.now())/1e3);for(const[c,i]of ie)if(Math.abs(t)>=i)return ae.format(Math.trunc(t/i),c);return"right now"}function re(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"}).format(n)}function le({path:s}){return e.jsx("img",{className:"vscode-tree-icon",src:K(s),alt:"","aria-hidden":"true",draggable:!1})}function ce(s){return s instanceof Error?s.message:"An unexpected error occurred."}export{pe as HistoryView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as m,j as e}from"./react-rd22PHbN.js";import{V as f,a as $,b as u}from"./viewer-tabs-
|
|
1
|
+
import{r as m,j as e}from"./react-rd22PHbN.js";import{V as f,a as $,b as u}from"./viewer-tabs-DxCOe0ut.js";import{u as j,F as y,S as E}from"./EditableFileViewer-Cv3aNJBN.js";import"./index-BOPi2b1j.js";import"./tanstack-B8_amOz8.js";import"./base-ui-qeHDA5zu.js";import"./PierreWorkerPool-BuBzE8K1.js";import"./platform-BMNQ8V5r.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-DiOOsHOl.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";import"./App-CBetJ5ZN.js";const T="data-opentig-preview-scrollbar";function S(r,i){const t=i?"255 255 255":"0 0 0",c=i?"oklch(0.13 0 0)":"oklch(0.985 0 0)",o=[`<style ${T}>`,"html {",` color-scheme: ${i?"dark":"light"} !important;`,` background-color: ${c} !important;`,"}","html, body, * {"," scrollbar-width: thin !important;",` scrollbar-color: rgb(${t} / 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(${t} / 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(${t} / 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
2
|
`),s=r.search(/<\/head\s*>/i);if(s>=0)return`${r.slice(0,s)}${o}
|
|
3
3
|
${r.slice(s)}`;const l=/<head(?:\s[^>]*)?>/i.exec(r);if(l?.index!==void 0){const a=l.index+l[0].length;return`${r.slice(0,a)}
|
|
4
4
|
${o}${r.slice(a)}`}const n=/<html(?:\s[^>]*)?>/i.exec(r);if(n?.index!==void 0){const a=n.index+n[0].length;return`${r.slice(0,a)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t}from"./index-
|
|
1
|
+
import{c as t}from"./index-BOPi2b1j.js";const a=[["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"}]],o=t("outline","edit","Edit",a);export{o as I};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as o}from"./index-
|
|
1
|
+
import{c as o}from"./index-BOPi2b1j.js";const e=[["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"}]],a=o("outline","folder-plus","FolderPlus",e);export{a as I};
|