@opentig/cli 0.2.1 → 0.2.2
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/dist/bin.mjs +2 -1
- package/dist/chunks/{cli-B6JTojx_.mjs → cli-DNzGBqmL.mjs} +1 -1
- package/dist/client/assets/App-BbT5H97Z.js +138 -0
- package/dist/client/assets/{CreatePullRequestDialog-CAeykZ72.js → CreatePullRequestDialog-DRLeMY4e.js} +2 -2
- package/dist/client/assets/{DiffWorkspace-BRicWHvw.js → DiffWorkspace-DJX00otP.js} +1 -1
- package/dist/client/assets/{EditableFileViewer-DWeSDnZn.js → EditableFileViewer-Cmbomx5y.js} +1 -1
- package/dist/client/assets/{File-D65shwRR.js → File-4o4egqlz.js} +1 -1
- package/dist/client/assets/FilesView-TmUF-VLr.js +1 -0
- package/dist/client/assets/{GitHubAvatar-C8R3iNoM.js → GitHubAvatar-azKPrTMv.js} +1 -1
- package/dist/client/assets/HistoryView-Go6rXO0P.js +1 -0
- package/dist/client/assets/{HtmlFileViewer-JXLHTNPm.js → HtmlFileViewer-WpYnLdMW.js} +1 -1
- package/dist/client/assets/{IconEdit-3fgBTCQ4.js → IconEdit-B8LZHB8l.js} +1 -1
- package/dist/client/assets/{IconFolderSymlink-C4ydD1eS.js → IconFolderSymlink-D29EhQPC.js} +1 -1
- package/dist/client/assets/{ImageFileViewer-YH2xhkkk.js → ImageFileViewer-1ObUacJu.js} +1 -1
- package/dist/client/assets/LocalRefsDialog-VcrlFgxR.js +1 -0
- package/dist/client/assets/{MarkdownFileViewer-BsB8WkIH.js → MarkdownFileViewer-CvsKPnvF.js} +2 -2
- package/dist/client/assets/{PairingPage-DXRyAYHn.js → PairingPage-cSoKZi8t.js} +1 -1
- package/dist/client/assets/{PierreDiffViewer-DoV3V0IW.js → PierreDiffViewer-DVTrOwX4.js} +1 -1
- package/dist/client/assets/{PierreEditBoundary-BnYZbHfi.js → PierreEditBoundary-DPtaTiUB.js} +1 -1
- package/dist/client/assets/{PierreWorkerPool-Cg9zdxiI.js → PierreWorkerPool-BxP-s6jD.js} +1 -1
- package/dist/client/assets/PullRequestDiff-DeQznd9n.js +1 -0
- package/dist/client/assets/PullRequestViewer-IhGZZs_A.js +2 -0
- package/dist/client/assets/{PullRequestsView-GStKxG7k.js → PullRequestsView-BG0xrok4.js} +1 -1
- package/dist/client/assets/QuickOpenDialog-DpmcAzTx.js +1 -0
- package/dist/client/assets/RepositoryProjectsDialog-DAzbUB3X.js +1 -0
- package/dist/client/assets/{SearchView-D5XB6wdu.js → SearchView-HoiWKG8z.js} +1 -1
- package/dist/client/assets/SettingsDialog-pmJKOaiK.js +9 -0
- package/dist/client/assets/{Viewer-Gfy3Ejyo.js → Viewer-BCk8FHrc.js} +3 -3
- package/dist/client/assets/{abnfDiagram-N423BO3Z-DdAfHevw.js → abnfDiagram-N423BO3Z-BvfKOanh.js} +1 -1
- package/dist/client/assets/{arc-C43uoeEi.js → arc-DB2nIH2Y.js} +1 -1
- package/dist/client/assets/{architectureDiagram-T3A2C74G-C7q0hhRO.js → architectureDiagram-T3A2C74G-Bqh4uY3R.js} +1 -1
- package/dist/client/assets/base-ui-DIP2rZxz.js +1 -0
- package/dist/client/assets/{blockDiagram-VBNYF7ZC-C1x9Iap4.js → blockDiagram-VBNYF7ZC-DMW415Ms.js} +1 -1
- package/dist/client/assets/{c4Diagram-5PPSVZJV-BmKaVW6q.js → c4Diagram-5PPSVZJV-BSNPes7l.js} +1 -1
- package/dist/client/assets/channel-VcDernYy.js +1 -0
- package/dist/client/assets/{checkbox-XfIUFPxh.js → checkbox-Dta4gqy2.js} +1 -1
- package/dist/client/assets/{chunk-2GRJ4B5K-kzy_H3BQ.js → chunk-2GRJ4B5K-D-86JbWu.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-BMj-FT4X.js → chunk-2Q5K7J3B-BNI-SD-k.js} +1 -1
- package/dist/client/assets/{chunk-5RXB4S5H-DmPGiCCb.js → chunk-5RXB4S5H-OFFYyML8.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-DYFL8__L.js → chunk-5VM5RSS4-DpE1dtnL.js} +1 -1
- package/dist/client/assets/{chunk-6Q2QTUOP-CI98oVdT.js → chunk-6Q2QTUOP-DxAnzBXJ.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-D9JiiMlX.js → chunk-GF5L2VYU-DNrTNRgr.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-D0THYpZl.js → chunk-JWPE2WC7-D-jfKyIh.js} +1 -1
- package/dist/client/assets/{chunk-KBJHAD2P-Z1tJfyAr.js → chunk-KBJHAD2P-CIyQl_ts.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-31aS4cD3.js → chunk-RYQCIY6F-CgCYQccM.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-ClWDHmEp.js → chunk-XXDRQBXY-B31oXtqU.js} +1 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-CUuEGRCt.js +1 -0
- package/dist/client/assets/classDiagram-v2-OCEON4UE-CUuEGRCt.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-Btg2MYLh.js → cose-bilkent-JH36ORCC-CrX-LDNw.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-Cbh4Pk6j.js → cynefin-VYW2F7L2-DnkWlsqW.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-BBqorl0u.js → cynefinDiagram-MW4NZA55-bUDQ9ElF.js} +1 -1
- package/dist/client/assets/{dagre-VZM6K2ZE-DugEItZ0.js → dagre-VZM6K2ZE-BW5Kni4n.js} +1 -1
- package/dist/client/assets/{diagram-7IWD3JNH-Biu7dmH8.js → diagram-7IWD3JNH-1EXGwguC.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-UDm4DXFS.js → diagram-B4RE2ZJO-CzpH5ieN.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-Bcku4gb-.js → diagram-LBJQPF4R-BnKszJ_B.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE-DFRjglV-.js → diagram-Q27KOJAE-DbQlD3OM.js} +1 -1
- package/dist/client/assets/{diagram-UB23O5K3-CgfMWtd0.js → diagram-UB23O5K3-BqZ-RSlm.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-CZzYOqs0.js → ebnfDiagram-BXEA7PRR-B2iPWDvr.js} +1 -1
- package/dist/client/assets/{erDiagram-JOGREHBK-Cdlbxgs6.js → erDiagram-JOGREHBK-aMqHrKCk.js} +1 -1
- package/dist/client/assets/{flowDiagram-UKHOOZJN-BgImDwpP.js → flowDiagram-UKHOOZJN-ivrTsn4D.js} +1 -1
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-SFhtiyL4.js → ganttDiagram-PKOTCBZU-IMfIqkXw.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-Bkm5ueys.js → gitGraphDiagram-DS77QQ5N-BNURRh2N.js} +1 -1
- package/dist/client/assets/{index-B5RC4THs.js → index-B3QJsvjR.js} +4 -4
- package/dist/client/assets/index-Cx9LaJW8.css +1 -0
- package/dist/client/assets/{infoDiagram-6WML65LV-pCYc-VX2.js → infoDiagram-6WML65LV-BKEENkUQ.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-BtNbG3Y6.js → ishikawaDiagram-WSZJBQD7-HrCSmiTr.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-CPW2qT3y.js → journeyDiagram-NVQOT4AX-CQIuWA6F.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-wD6JXQFs.js → kanban-definition-27J2QSJJ-h4fSAkel.js} +1 -1
- package/dist/client/assets/{linear-sj8MOkmS.js → linear-BAdz-uC9.js} +1 -1
- package/dist/client/assets/{mermaid.core-CGJtfmwb.js → mermaid.core-vLn7mMZB.js} +4 -4
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-BQwLHBVs.js → mindmap-definition-FAOFIHXS-DOrZl827.js} +1 -1
- package/dist/client/assets/{pegDiagram-VL7TDLO6-DtDsb-Z8.js → pegDiagram-VL7TDLO6-_Vs7p633.js} +1 -1
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-B3WhqNuS.js → pieDiagram-7S7Q4E2Y-7qbB_Z16.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-CPi38pp_.js → quadrantDiagram-CIZ2JOQS-DNH8SosA.js} +1 -1
- package/dist/client/assets/{railroadDiagram-AXF67PYL-Btac44Ux.js → railroadDiagram-AXF67PYL-Ctazrrpa.js} +1 -1
- package/dist/client/assets/{render-markdown-hAIWRfn0.js → render-markdown-dvHhHbC0.js} +1 -1
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-CHJgDNdg.js → requirementDiagram-LRYGKXZP-BAH8dYer.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-OYJHfmtd.js → sankeyDiagram-W5VNT64P-CuffrpdF.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-9ypa9W08.js → sequenceDiagram-SI44F4Z6-CaO4fJnS.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-5ZDUTERI.js → sizeCapture-X5ZJPWSS-B_LramBU.js} +1 -1
- package/dist/client/assets/{stateDiagram-OKZ733FA-nGHE1hN7.js → stateDiagram-OKZ733FA-bc7zBYHn.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-C-UGmA2d.js +1 -0
- package/dist/client/assets/{swimlanes-SLNWSIFB-BZFv9Zp8.js → swimlanes-SLNWSIFB-DQzg1IPn.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-DnopIiWa.js +8 -0
- package/dist/client/assets/{tanstack-CcfAJoQ7.js → tanstack-BysN2Oew.js} +1 -1
- package/dist/client/assets/{timeline-definition-Z64GVDOM-pUIcaCIE.js → timeline-definition-Z64GVDOM-CtbuIB6K.js} +1 -1
- package/dist/client/assets/{vennDiagram-T6HMQDX7-D6dEIJmP.js → vennDiagram-T6HMQDX7-pYJ0ZfFS.js} +1 -1
- package/dist/client/assets/{viewer-tabs-BjG3oKQ9.js → viewer-tabs-Cnfyd6rg.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-DZ8ro_-y.js → wardleyDiagram-T6FBY63Y-DYl_Oi-Y.js} +1 -1
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-WJ2Zfmlk.js → xychartDiagram-ELKLHX3M-Cj5YUfP5.js} +1 -1
- package/dist/client/index.html +4 -4
- package/dist/dev.mjs +2 -1
- package/dist/manifest.json +1 -1
- package/dist/server.mjs +779 -211
- package/dist/utility.mjs +1 -0
- package/package.json +1 -1
- package/dist/client/assets/App-Dfm5F199.js +0 -74
- package/dist/client/assets/FilesView-EfoU7sF-.js +0 -1
- package/dist/client/assets/HistoryView-C6T2dsBC.js +0 -1
- package/dist/client/assets/LocalRefsDialog--1NiYKYj.js +0 -1
- package/dist/client/assets/PullRequestDiff-D6QG5Anx.js +0 -1
- package/dist/client/assets/PullRequestViewer-jC3LVmiO.js +0 -2
- package/dist/client/assets/QuickOpenDialog-HvslpGQl.js +0 -1
- package/dist/client/assets/RepositoryProjectsDialog-Biqv5GO_.js +0 -1
- package/dist/client/assets/SettingsDialog-DWAunOQB.js +0 -72
- package/dist/client/assets/base-ui-CJ8ZIx3d.js +0 -1
- package/dist/client/assets/channel-Diwpee6E.js +0 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BDuo9kiS.js +0 -1
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BDuo9kiS.js +0 -1
- package/dist/client/assets/index-Dc9xVluy.css +0 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-CkCpE1Yu.js +0 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-Dxlb7bju.js +0 -8
|
@@ -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-Cnfyd6rg.js";import{u as j,F as y,S as E}from"./EditableFileViewer-Cmbomx5y.js";import"./index-B3QJsvjR.js";import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";import"./PierreWorkerPool-BxP-s6jD.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-4o4egqlz.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";import"./App-BbT5H97Z.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-B3QJsvjR.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-B3QJsvjR.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"}]],s=o("outline","folder-plus","FolderPlus",e);const a=[["path",{d:"M3 21v-4a3 3 0 0 1 3 -3h5",key:"svg-0"}],["path",{d:"M8 17l3 -3l-3 -3",key:"svg-1"}],["path",{d:"M3 11v-5a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8",key:"svg-2"}]],t=o("outline","folder-symlink","FolderSymlink",a);export{s as I,t as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,r}from"./react-rd22PHbN.js";import{c as V,B as x,T as k,b as T,d as O}from"./index-
|
|
1
|
+
import{j as t,r}from"./react-rd22PHbN.js";import{c as V,B as x,T as k,b as T,d as O}from"./index-B3QJsvjR.js";import{V as U,b as C,a as B}from"./viewer-tabs-Cnfyd6rg.js";import{u as W,S as P,F as H}from"./EditableFileViewer-Cmbomx5y.js";import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";import"./PierreWorkerPool-BxP-s6jD.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-4o4egqlz.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";import"./App-BbT5H97Z.js";const K=[["path",{d:"M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M7 10l6 0",key:"svg-1"}],["path",{d:"M10 7l0 6",key:"svg-2"}],["path",{d:"M21 21l-6 -6",key:"svg-3"}]],X=V("outline","zoom-in","ZoomIn",K);const Y=[["path",{d:"M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M7 10l6 0",key:"svg-1"}],["path",{d:"M21 21l-6 -6",key:"svg-2"}]],q=V("outline","zoom-out","ZoomOut",Y),Z=.25,S=8,D=[.25,.5,.75,1,1.25,1.5,2,3,4,6,8];function $(e){return Number.isFinite(e)?Math.min(S,Math.max(Z,e)):1}function L(e){const s=$(e);return D.find(n=>n>s+Number.EPSILON)??S}function _(e){const s=$(e);return[...D].reverse().find(n=>n<s-Number.EPSILON)??Z}const J={conflictTitle:"SVG was changed outside OpenTig",successTitle:"SVG saved",errorTitle:"Could not save SVG"};function ve({image:e}){return e.status==="unsupported"?t.jsx(y,{title:"Image format is not supported",detail:`${e.path} · ${M(e.size)}`}):e.status==="too-large"?t.jsx(y,{title:"Image is too large to preview",detail:`${e.path} · ${M(e.size)} · limit ${M(e.limit)}`}):t.jsx(Q,{path:e.path,mimeType:e.mimeType,size:e.size,data:e.data})}function Q({path:e,mimeType:s,size:n,data:d}){const c=F(d,s);return t.jsx(R,{objectUrl:c,path:e,size:n})}function fe({file:e,initialContent:s,themeType:n,wrapLines:d,readOnly:c,onDirtyChange:i,onDraftChange:o,onSave:u}){const[m,l]=r.useState("preview"),{draft:g,updateDraft:N,dirty:v,saving:f,save:j}=W({file:e,initialContent:s,readOnly:c,messages:J,onDirtyChange:i,onDraftChange:o,onSave:u}),w=F(g,"image/svg+xml");r.useEffect(()=>{l("preview")},[e.path]);const b=t.jsx(B,{label:"SVG view",className:"file-viewer-tabs image-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:t.jsxs(t.Fragment,{children:["Code ",v&&t.jsx("span",{className:"image-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),p=t.jsx(H,{dirty:v,saving:f,readOnly:c,onSave:()=>{j()}});return t.jsxs(U,{value:m,onValueChange:a=>l(a),className:"svg-file-viewer",children:[t.jsx(C,{value:"preview",className:"svg-file-panel",children:t.jsx(R,{objectUrl:w,path:e.path,size:new TextEncoder().encode(g).byteLength,toolbarStart:b,toolbarEnd:p})}),t.jsxs(C,{value:"code",className:"svg-file-panel",children:[t.jsxs("div",{className:"file-viewer-pill svg-file-toolbar",children:[b,p]}),t.jsx("div",{className:"svg-code-view",children:t.jsx(P,{path:e.path,cacheKey:e.path,value:g,themeType:n,wrapLines:d,readOnly:c||f,onChange:N})})]})]})}function R({objectUrl:e,path:s,size:n,toolbarStart:d,toolbarEnd:c}){const[i,o]=r.useState("fit"),[u,m]=r.useState(1),[l,g]=r.useState(null),[N,v]=r.useState(!1),f=r.useRef(null);r.useEffect(()=>{g(null),v(!1)},[e]),r.useEffect(()=>{const a=f.current;if(!a)return;let h=0;const z=E=>{E.preventDefault();const A=E.deltaMode===WheelEvent.DOM_DELTA_LINE?16:E.deltaMode===WheelEvent.DOM_DELTA_PAGE?100:1;if(h+=E.deltaY*A,Math.abs(h)<24)return;const G=h<0;h=0,o("actual"),m(I=>G?L(I):_(I))};return a.addEventListener("wheel",z,{passive:!1}),()=>a.removeEventListener("wheel",z)},[]);const j=l?l.width*u:void 0,w=l?l.height*u:void 0,b=[M(n),l?`${l.width} × ${l.height}`:null].filter(Boolean).join(" · "),p=a=>{o("actual"),m(h=>a==="in"?L(h):_(h))};return t.jsxs("div",{className:"image-preview-workspace",children:[t.jsxs("div",{className:"file-viewer-pill image-preview-toolbar",children:[d,t.jsx("span",{className:"image-file-details",children:b}),t.jsxs("div",{className:"image-sizing-toggle",role:"group","aria-label":"Image size",children:[t.jsx(x,{type:"button",size:"xs",variant:i==="fit"?"secondary":"ghost","aria-pressed":i==="fit",onClick:()=>o("fit"),children:"Fit"}),t.jsx(x,{type:"button",size:"xs",variant:i==="actual"&&u===1?"secondary":"ghost","aria-pressed":i==="actual"&&u===1,onClick:()=>{o("actual"),m(1)},children:"1:1"})]}),t.jsxs("div",{className:"image-zoom-controls",children:[t.jsxs(k,{children:[t.jsx(T,{render:t.jsx(x,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Zoom out",onClick:()=>p("out")}),children:t.jsx(q,{})}),t.jsx(O,{children:"Zoom out"})]}),t.jsxs(x,{type:"button",variant:"ghost",size:"xs",className:"image-zoom-value","aria-label":"Reset zoom to 100%",onClick:()=>{o("actual"),m(1)},children:[Math.round(u*100),"%"]}),t.jsxs(k,{children:[t.jsx(T,{render:t.jsx(x,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Zoom in",onClick:()=>p("in")}),children:t.jsx(X,{})}),t.jsx(O,{children:"Zoom in"})]})]}),c]}),t.jsx("div",{ref:f,className:"image-preview-canvas","data-sizing":i,"data-zoom-limit":u>=S?"max":"normal",tabIndex:0,"aria-label":`Image preview for ${s}`,onKeyDown:a=>{if(a.key==="+"||a.key==="=")p("in");else if(a.key==="-")p("out");else if(a.key==="0")o("actual"),m(1);else if(a.key.toLowerCase()==="f")o("fit");else return;a.preventDefault()},children:e?N?t.jsx(y,{title:"Could not decode this image",detail:s}):t.jsx("img",{src:e,alt:ee(s),draggable:!1,style:i==="actual"&&j&&w?{width:j,height:w,maxWidth:"none",maxHeight:"none"}:void 0,onLoad:a=>{v(!1),g({width:a.currentTarget.naturalWidth,height:a.currentTarget.naturalHeight})},onError:()=>v(!0)}):t.jsx("span",{className:"image-preview-loading",children:"Loading image…"})})]})}function y({title:e,detail:s}){return t.jsxs("div",{className:"image-viewer-message",children:[t.jsx("strong",{children:e}),t.jsx("span",{children:s})]})}function F(e,s){const[n,d]=r.useState(null);return r.useEffect(()=>{const c=typeof e=="string"?e:new Uint8Array(e),i=URL.createObjectURL(new Blob([c],{type:s}));return d(i),()=>{URL.revokeObjectURL(i),d(o=>o===i?null:o)}},[s,e]),n}function ee(e){return e.replace(/\\/g,"/").split("/").pop()||e}function M(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}export{ve as ImageFileViewer,fe as SvgFileViewer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,j as e}from"./react-rd22PHbN.js";import{l as ie,z as I,o as Ae,p as ze,F as Ke,r as de,s as Be,f as L,ab as q,e as De,af as Z,aj as Qe,ak as We,al as M,am as A,an as ye,D as He,v as Ue,w as _e,x as Ye,a9 as Ne,aa as ve,ao as te,L as Je,y as Ve,ap as Xe,q as Ze,aq as ce,ar as Fe,H as ea,as as aa,at as sa,au as ra,av as la,I as na,J as ta}from"./App-BbT5H97Z.js";import{b as ca,u as H}from"./tanstack-BysN2Oew.js";import{c as Te,B as b,q as U,T as he,b as me,d as ue,I as oa,w as ia,o as B}from"./index-B3QJsvjR.js";import{C as da}from"./checkbox-Dta4gqy2.js";import"./base-ui-DIP2rZxz.js";const ha=[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]],oe=Te("outline","cloud","Cloud",ha);const ma=[["path",{d:"M4 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M4 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M16 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M6 8v8",key:"svg-3"}],["path",{d:"M18 11v5",key:"svg-4"}],["path",{d:"M16 4l4 4m0 -4l-4 4",key:"svg-5"}]],ua=Te("outline","git-pull-request-closed","GitPullRequestClosed",ma);function ba(a){const{details:r,pullRequest:l,anyBusy:t}=a,d=r.remoteState==="missing",[p,m]=o.useState(!1),[h,f]=o.useState(r.branchName);return o.useEffect(()=>{m(!1),f(r.branchName)},[r.fullName,r.branchName]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(oe,{"aria-hidden":"true"}),e.jsxs("span",{children:[r.remote,"/",r.branchName]})]}),e.jsx("small",{className:"local-refs-remote-label",children:d?"Deleted on remote · Cached reference":`Remote branch${r.defaultBranch===r.branchName?" · Default":""}`})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Remote"}),e.jsx("dd",{children:r.remote})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Full ref"}),e.jsx("dd",{children:e.jsx("code",{className:"local-refs-selectable",children:r.fullName})})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Fetched tip"}),e.jsxs("dd",{children:[e.jsx("code",{children:r.shortOid})," ",r.subject]})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Author"}),e.jsx("dd",{children:r.author||"—"})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Last commit"}),e.jsx("dd",{children:r.date?ie(r.date):"—"})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Local branches"}),e.jsxs("dd",{children:[r.localBranches.length?r.localBranches.map(c=>e.jsxs("button",{type:"button",className:"local-refs-local-link",disabled:t,onClick:()=>a.onShowLocal(c.fullName),children:[e.jsx(I,{"aria-hidden":"true"}),c.name,c.worktreePath?" · In a worktree":""]},c.fullName)):"No local tracking branch",!d&&!p&&e.jsxs("div",{className:"local-refs-tracking-action",children:[e.jsxs("button",{type:"button",className:"local-refs-local-link",disabled:t,onClick:()=>m(!0),children:[e.jsx(I,{"aria-hidden":"true"}),r.localBranches.length?"Create another local tracking branch…":"Create local tracking branch…"]}),e.jsx("small",{children:"Work on this branch locally without switching your checkout."})]})]})]}),l&&e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"GitHub PR"}),e.jsx("dd",{children:e.jsxs("button",{type:"button",className:`local-refs-pr-link ${l.state.toLowerCase()}${l.state==="OPEN"&&l.isDraft?" draft":""}`,onClick:()=>Be(l.url),children:[l.state==="MERGED"?e.jsx(Ae,{"aria-hidden":"true"}):l.state==="CLOSED"?e.jsx(ua,{"aria-hidden":"true"}):e.jsx(ze,{"aria-hidden":"true"}),"#",l.number," · ",l.state==="MERGED"?`Merged into ${l.baseRefName}`:Ke(l),e.jsx(de,{"aria-hidden":"true"})]})})]})]}),p&&!d&&e.jsxs("form",{className:"local-refs-create-branch",onSubmit:c=>{c.preventDefault(),!t&&h.trim()&&a.onCreate(h.trim())},children:[e.jsx("label",{htmlFor:"tracking-branch-name",children:"Local branch name"}),e.jsx("input",{id:"tracking-branch-name",value:h,onChange:c=>f(c.target.value),disabled:t,autoFocus:!0,autoComplete:"off",spellCheck:!1}),e.jsx("p",{children:"Creates a tracking branch at the fetched tip. Your checkout and uncommitted changes stay intact."}),e.jsxs("div",{className:"local-refs-detail-actions",children:[e.jsxs(b,{type:"submit",variant:"outline",size:"sm",disabled:t||!h.trim(),children:[a.creating?e.jsx(L,{className:"animate-spin"}):e.jsx(I,{})," ",a.creating?"Creating…":"Create local branch"]}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>m(!1),children:"Cancel"})]})]}),e.jsx("div",{className:`local-refs-danger ${r.deletionBlockedReason?"blocked":"ready"}`,children:r.deletionBlockedReason?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:d?`This branch was already deleted from ${r.remote}. Only its cached reference remains; there is no remote branch to delete.`:r.deletionBlockedReason})]}),d&&e.jsxs(b,{variant:"outline",size:"sm",disabled:t,onClick:a.onFetch,children:[a.fetching?e.jsx(L,{className:"animate-spin"}):e.jsx(De,{}),a.fetching?"Fetching…":"Fetch and clean up"]})]}):a.confirming?e.jsxs("div",{className:"local-refs-confirm",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsxs("p",{children:["Delete ",e.jsx("strong",{children:r.branchName})," from ",e.jsx("strong",{children:r.remote}),"? This removes the branch on the remote server. Your local branches, commits and worktrees stay intact."]}),e.jsxs("span",{className:"local-refs-confirm-actions",children:[e.jsxs(b,{variant:"destructive",size:"sm",disabled:t,onClick:a.onDelete,children:[a.deleting?e.jsx(L,{className:"animate-spin"}):e.jsx(Z,{}),a.deleting?"Deleting…":`Delete from ${r.remote}`]}),e.jsx(b,{variant:"ghost",size:"sm",disabled:t,onClick:a.onCancel,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[e.jsx(oe,{"aria-hidden":"true"}),e.jsxs("span",{children:["Delete only this branch from ",r.remote,". Local branches and worktrees are kept."]})]}),e.jsxs(b,{variant:"destructive",size:"sm",disabled:t,onClick:a.onConfirm,children:[e.jsx(Z,{}),"Delete from ",r.remote]})]})})]})}function Ca(a){const{open:r,tab:l,repositoryId:t,onMutated:d,onBusyChange:p}=a,m=ca(),[h,f]=o.useState(""),[c,x]=o.useState("all"),[g,N]=o.useState(""),[z,k]=o.useState(!1),[P,v]=o.useState(null),[G,_]=o.useState(null),[ae,F]=o.useState(null),[i,be]=o.useState(null),[Y,C]=o.useState(null),[Se,J]=o.useState(!1),fe=o.useRef(null);o.useEffect(()=>{k(!1)},[r,t]);const O=H({queryKey:U.localRefs(t),queryFn:()=>B.refs.localRefsSnapshot(t),enabled:r}),w=O.data??null,V=O.isFetching,xe=O.error?X(O.error):null,T=o.useMemo(()=>Qe(w?.branches??[],h).filter(s=>(c==="all"||s.remote===(c==="remote"))&&(!s.remote||!g||s.remoteName===g)),[w,h,c,g]),Ee=o.useMemo(()=>{const s=[...new Set(T.filter(n=>n.remote).map(n=>n.remoteName??"Unmapped references"))];return[{label:"Local",branches:T.filter(n=>!n.remote)},...s.map(n=>({label:n,branches:T.filter(u=>u.remote&&(u.remoteName??"Unmapped references")===n)}))].filter(n=>n.branches.length>0)},[T]),se=o.useMemo(()=>We(w?.worktrees??[],h),[w,h]),j=T.find(s=>M(s)===P)??null,K=se.find(s=>A(s)===G)??null,je=H({queryKey:U.branchDetails(t,j?.fullName??""),queryFn:()=>B.refs.branchDetails({repositoryId:t,fullName:j.fullName}),enabled:r&&l==="branches"&&j!==null&&!j.remote}),R=je.data??null,pe=H({queryKey:U.remoteBranchDetails(t,j?.fullName??""),queryFn:()=>B.refs.remoteBranchDetails({repositoryId:t,fullName:j.fullName}),enabled:r&&l==="branches"&&j?.remote===!0,staleTime:3e4}),S=pe.data??null,re=j?.remote?S?.branchName:R?.name,Ie=H({queryKey:U.branchPullRequest(t,re??""),queryFn:()=>B.github.findPullRequestForBranch(t,re),enabled:r&&l==="branches"&&!!re&&(j?.remote?S?.remote==="origin":R!==null&&(R.deletion==="unknown"||R.deletion==="unmerged"))}),ge=j?.remote&&S?.remote!=="origin"?null:Ie.data??null,ke=H({queryKey:U.worktreeDetails(t,K?.path??""),queryFn:()=>B.refs.worktreeDetails({repositoryId:t,path:K.path}),enabled:r&&l==="worktrees"&&K!==null}),E=ke.data??null,le=l==="branches"?j?.remote?pe:je:ke,Q=le.isFetching,$=le.error?X(le.error):null,D=o.useCallback(async()=>{await O.refetch(),await Promise.all([m.invalidateQueries({queryKey:["repository",t,"branch-details"]}),m.invalidateQueries({queryKey:["repository",t,"remote-branch-details"]}),m.invalidateQueries({queryKey:["repository",t,"worktree-details"]}),m.invalidateQueries({queryKey:["repository",t,"branch-pull-request"]})])},[m,t,O]);o.useEffect(()=>{if(!w)return;const s=fe.current;fe.current=w,v(n=>ye(T.map(M),(s?.branches??[]).map(M),n)),_(n=>ye(w.worktrees.map(A),(s?.worktrees??[]).map(A),n))},[w,T]),o.useEffect(()=>{r||(f(""),x("all"),N(""),F(null),C(null),J(!1))},[r]),o.useEffect(()=>{F(null),C(null),J(!1)},[l,P,G]);const W=async(s,n)=>{be(s),p(!0),C(null);try{await n()&&F(null)}catch(u){C(X(u))}finally{be(null),p(!1)}},Le=(s,n)=>W("delete-branch",async()=>{const u=await B.refs.deleteBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,force:n});return u.status!=="deleted"?(C(ja(u.status)),await D(),!1):(d(null),await D(),!0)}),qe=s=>W("delete-remote-branch",async()=>{const n=await B.refs.deleteRemoteBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,destinationId:s.destinationId});if(n.status!=="deleted")return C(n.status==="rejected"?n.message:Ce(n.status)),await D(),!1;const u=await B.refs.fetchBranches(t);return d(null),await D(),u.status==="failed"&&C("The remote branch was deleted, but fetching failed. Fetch again to update the list."),!0}),Pe=(s,n)=>W("create-tracking-branch",async()=>{const u=await B.refs.createTrackingBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,localName:n});return u.status!=="created"?(C(u.status==="exists"?"That local branch already exists. Choose another name.":Ce(u.status)),await D(),!1):(d(null),await D(),f(""),x("local"),N(""),v(u.fullName),!0)}),we=()=>W("fetch-branches",async()=>{const s=await B.refs.fetchBranches(t);return d(null),await D(),s.status==="failed"&&C(s.message),s.status==="success"}),Ge=(s,n,u)=>W("remove-worktree",async()=>{const ne=await B.refs.removeWorktree({repositoryId:t,path:s.path,expectedOid:s.oid,force:n,deleteBranch:u});return ne.status!=="removed"?(C(pa(ne.status)),await D(),!1):(d(ne.recentRepositories),await D(),!0)}),Oe=async s=>{try{await ia(s),J(!0),window.setTimeout(()=>J(!1),1600)}catch(n){C(X(n))}},$e={branches:w?.branches.length??0,worktrees:w?.worktrees.length??0},Me=l==="branches"?T.length===0:se.length===0;return e.jsx(He,{open:r,onOpenChange:s=>{i||a.onOpenChange(s)},children:e.jsxs(Ue,{className:"local-refs-dialog",children:[e.jsxs("header",{className:"local-refs-header",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Branches and worktrees"}),e.jsx(Ye,{children:"Inspect local and remote branches, and manage this repository’s worktrees."})]}),e.jsx(Ne,{render:e.jsx(b,{variant:"ghost",size:"icon-sm","aria-label":"Close the refs manager",disabled:!!i}),children:e.jsx(ve,{})})]}),e.jsxs("div",{className:"local-refs-toolbar",children:[e.jsx("div",{className:"local-refs-tabs",role:"tablist","aria-label":"Branches and worktrees",children:["branches","worktrees"].map(s=>e.jsxs("button",{type:"button",role:"tab",id:`local-refs-tab-${s}`,"aria-selected":l===s,"aria-controls":`local-refs-panel-${s}`,className:"local-refs-tab",disabled:!!i,onClick:()=>{a.onTabChange(s),k(!1)},children:[s==="branches"?e.jsx(I,{"aria-hidden":"true"}):e.jsx(te,{"aria-hidden":"true"}),e.jsx("span",{children:s==="branches"?"Branches":"Worktrees"}),e.jsx("small",{children:$e[s]})]},s))}),e.jsxs("div",{className:"local-refs-search",children:[e.jsx(Je,{"aria-hidden":"true"}),e.jsxs("label",{className:"sr-only",htmlFor:"local-refs-search-input",children:["Search ",l]}),e.jsx("input",{id:"local-refs-search-input",value:h,disabled:!!i,onChange:s=>f(s.target.value),placeholder:l==="branches"?"Search branches…":"Search worktrees…",autoComplete:"off",spellCheck:!1}),h&&e.jsx(b,{variant:"ghost",size:"icon-xs","aria-label":"Clear search",disabled:!!i,onClick:()=>f(""),children:e.jsx(ve,{})})]}),e.jsxs(he,{children:[e.jsxs(me,{render:e.jsx(b,{variant:"outline",size:"sm",onClick:()=>l==="branches"?void we():void D(),disabled:V||!!i}),children:[V||i==="fetch-branches"?e.jsx(L,{className:"animate-spin"}):e.jsx(De,{})," ",l==="branches"?"Fetch":"Refresh"]}),e.jsx(ue,{children:l==="branches"?"Fetch branches from all remotes and remove obsolete remote references":"Refresh local worktrees"})]})]}),l==="branches"&&e.jsxs("div",{className:"local-refs-branch-filters",children:[e.jsx("div",{className:"local-refs-tabs",role:"group","aria-label":"Branch scope",children:["all","local","remote"].map(s=>e.jsx("button",{type:"button",className:"local-refs-tab","aria-pressed":c===s,disabled:!!i,onClick:()=>{x(s),k(!1)},children:s==="all"?"All":s==="local"?"Local":"Remote"},s))}),c!=="local"&&e.jsx(Ve,{label:"Filter by remote",placeholder:"Search remotes…",value:g,triggerLabel:g||"All remotes",onValueChange:s=>{N(s),k(!1)},disabled:!!i,groups:[{id:"remotes",label:"Remotes",items:[{value:"",label:"All remotes",pinned:!0},...(w?.remotes??[]).map(s=>({value:s,label:s}))]}]}),e.jsx("small",{children:"Remote refs reflect the last fetch."})]}),(xe||Y)&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:xe??Y})]}),z&&e.jsxs("button",{type:"button",className:"local-refs-mobile-back",onClick:()=>k(!1),children:["← Back to ",l]}),e.jsxs("div",{className:"local-refs-body","data-mobile-detail":z,role:"tabpanel",id:`local-refs-panel-${l}`,"aria-labelledby":`local-refs-tab-${l}`,children:[e.jsxs("div",{className:"local-refs-list",role:"listbox","aria-label":l==="branches"?"Branches":"Worktrees",tabIndex:-1,children:[V&&!w&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(L,{className:"animate-spin","aria-hidden":"true"})," Reading the repository…"]}),!V&&Me&&e.jsx("p",{className:"local-refs-placeholder",children:h||g?"No matches for these filters.":`This repository has no ${l==="branches"?`${c==="all"?"":`${c} `}branches`:"worktrees"}.`}),l==="branches"&&Ee.map(s=>e.jsxs("div",{className:"local-refs-branch-group",role:"group","aria-label":s.label,children:[e.jsxs("div",{className:"local-refs-group-heading",children:[e.jsx("span",{children:s.label}),e.jsx("small",{children:s.branches.length})]}),s.branches.map(n=>e.jsxs("button",{type:"button",role:"option","aria-selected":M(n)===P,className:"local-refs-row",disabled:!!i,onClick:()=>{v(M(n)),k(!0)},children:[e.jsxs("span",{className:"local-refs-row-head",children:[n.remote?e.jsx(oe,{"aria-hidden":"true"}):e.jsx(I,{"aria-hidden":"true"}),e.jsx("strong",{children:n.remoteBranchName??n.name}),e.jsx(ee,{badges:Xe(n)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("code",{children:n.shortOid}),n.subject&&e.jsx("span",{children:n.subject}),n.date&&e.jsx("time",{dateTime:n.date,children:Ze(n.date)})]})]},M(n)))]},s.label)),l==="worktrees"&&se.map(s=>e.jsxs("button",{type:"button",role:"option","aria-selected":A(s)===G,className:"local-refs-row",disabled:!!i,onClick:()=>{_(A(s)),k(!0)},children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(te,{"aria-hidden":"true"}),e.jsx("strong",{children:ce(s.path)}),e.jsx(ee,{badges:Fe(s)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("span",{className:"local-refs-row-branch",children:s.branch?`${s.branch}`:"Detached HEAD"}),e.jsx("span",{children:s.path})]})]},A(s)))]}),e.jsxs("div",{className:"local-refs-detail",children:[$&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:$})]}),Q&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(L,{className:"animate-spin","aria-hidden":"true"})," Loading details…"]}),!Q&&!$&&l==="branches"&&S&&j?.remote&&e.jsx(ba,{details:S,pullRequest:ge,anyBusy:!!i,deleting:i==="delete-remote-branch",creating:i==="create-tracking-branch",confirming:ae==="delete-remote-branch",onConfirm:()=>F("delete-remote-branch"),onCancel:()=>F(null),onDelete:()=>{qe(S)},onCreate:s=>{Pe(S,s)},onFetch:()=>{we()},fetching:i==="fetch-branches",onShowLocal:s=>{f(""),x("local"),N(""),v(s)}}),!Q&&!$&&l==="branches"&&R&&j&&!j.remote&&e.jsx(fa,{details:R,pullRequest:ge,busy:i==="delete-branch",anyBusy:!!i,confirming:ae==="delete-branch",actionError:Y,onConfirm:()=>F("delete-branch"),onCancel:()=>F(null),onDelete:s=>{Le(R,s)}}),!Q&&!$&&l==="worktrees"&&E&&K&&e.jsx(xa,{details:E,busy:i==="remove-worktree",anyBusy:!!i,confirming:ae==="remove-worktree",actionError:Y,copied:Se,onConfirm:()=>F("remove-worktree"),onCancel:()=>F(null),onRemove:(s,n)=>{Ge(E,s,n)},onCopyPath:()=>{Oe(E.path)},onOpen:()=>a.onOpenWorktree(E.path),onShowBranch:()=>{E.branch&&(v(`refs/heads/${E.branch}`),f(""),x("local"),N(""),a.onTabChange("branches"))}}),!Q&&!$&&!j&&!K&&e.jsxs("p",{className:"local-refs-placeholder",children:["Select a ",l==="branches"?"branch":"worktree"," to see its details."]})]})]},l),e.jsxs("footer",{className:"local-refs-footer",children:[e.jsx("small",{children:"Deleting a remote branch keeps local branches and worktrees. Removing a worktree deletes its branch only when explicitly selected."}),e.jsx(Ne,{render:e.jsx(b,{variant:"outline",size:"sm",disabled:!!i}),children:"Done"})]})]})})}function fa({details:a,pullRequest:r,busy:l,anyBusy:t,confirming:d,actionError:p,onConfirm:m,onCancel:h,onDelete:f}){const c=aa(a,r),x=c.forceAllowed===!0,g=c.allowed||x;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(I,{"aria-hidden":"true"}),e.jsxs(he,{children:[e.jsx(me,{render:e.jsx("span",{}),children:a.name}),e.jsx(ue,{children:a.name})]})]}),e.jsx(ee,{badges:sa(a)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(y,{label:"Full ref",children:e.jsx("code",{className:"local-refs-selectable",children:a.fullName})}),e.jsxs(y,{label:"Tip",children:[e.jsx("code",{children:a.shortOid})," ",a.subject]}),e.jsx(y,{label:"Author",children:a.author||"—"}),e.jsx(y,{label:"Last commit",children:a.date?ie(a.date):"—"}),e.jsx(y,{label:"Upstream",children:a.upstream?`${a.upstream} · ↑${a.ahead} ↓${a.behind}`:"Not configured"}),e.jsx(y,{label:"Compared with",children:a.comparisonBase??"Not compared"}),r&&e.jsx(y,{label:"GitHub PR",children:e.jsxs("button",{type:"button",className:"local-refs-pr-link",onClick:()=>Be(r.url),children:["#",r.number," · ",r.state==="MERGED"?`Merged into ${r.baseRefName}`:r.state==="OPEN"?"Open":"Closed"," ",e.jsx(de,{"aria-hidden":"true"})]})})]}),e.jsx(Re,{tone:c.allowed?"ready":"blocked",reason:c.reason,actionError:p,confirming:d,busy:l,anyBusy:t,actionLabel:x?"Force delete branch":"Delete branch",confirmLabel:l?"Deleting…":x?"Permanently delete":"Delete branch",allowed:g,confirmation:x?e.jsxs(e.Fragment,{children:["Force-delete the local branch ",e.jsx("strong",{children:a.name}),"? This keeps any remote branch and pull request, but commits found only on this local branch may become inaccessible. ",r?.state==="MERGED"?e.jsxs(e.Fragment,{children:["GitHub reports PR ",e.jsxs("strong",{children:["#",r.number]})," as merged into ",e.jsx("strong",{children:r.baseRefName}),", although local Git cannot verify the ancestry."]}):null]}):e.jsxs(e.Fragment,{children:["Delete the local branch ",e.jsx("strong",{children:a.name}),"? This removes only the local branch, keeping every worktree and any remote copy. Git confirmed it is fully merged into ",e.jsx("strong",{children:a.comparisonBase}),"."]}),onConfirm:m,onCancel:h,onAct:()=>f(x)})]})}function xa({details:a,busy:r,anyBusy:l,confirming:t,actionError:d,copied:p,onConfirm:m,onCancel:h,onRemove:f,onCopyPath:c,onOpen:x,onShowBranch:g}){const[N,z]=o.useState(!1),k=ra(a),P=la(a),v=k.forceAllowed===!0,G=k.allowed||v;return o.useEffect(()=>z(!1),[a.path]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(te,{"aria-hidden":"true"}),e.jsxs(he,{children:[e.jsx(me,{render:e.jsx("span",{}),children:ce(a.path)}),e.jsx(ue,{children:ce(a.path)})]})]}),e.jsx(ee,{badges:Fe(a)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(y,{label:"Folder",children:e.jsx("span",{className:"local-refs-path local-refs-selectable",children:a.path})}),e.jsx(y,{label:"Branch",children:a.branch??"Detached HEAD"}),e.jsx(y,{label:"HEAD",children:a.lastCommit?e.jsxs(e.Fragment,{children:[e.jsx("code",{children:a.lastCommit.shortOid})," ",a.lastCommit.subject]}):e.jsx("code",{children:a.oid?a.oid.slice(0,7):"—"})}),e.jsx(y,{label:"Committed",children:a.lastCommit?.date?ie(a.lastCommit.date):"—"}),e.jsx(y,{label:"Local changes",children:a.available?P??"None":"Not readable"})]}),e.jsxs("div",{className:"local-refs-detail-actions",children:[e.jsxs(b,{variant:"outline",size:"sm",onClick:c,disabled:l,children:[p?e.jsx(na,{}):e.jsx(oa,{})," ",p?"Copied":"Copy path"]}),!a.current&&a.available&&!a.locked&&e.jsxs(b,{variant:"outline",size:"sm",onClick:x,disabled:l,children:[e.jsx(de,{})," Open worktree"]}),a.branch&&e.jsxs(b,{variant:"ghost",size:"sm",onClick:g,disabled:l,children:[e.jsx(I,{})," Show branch"]})]}),a.branch&&G&&e.jsxs("label",{htmlFor:"remove-worktree-delete-branch",className:"local-refs-delete-branch",children:[e.jsx(da,{id:"remove-worktree-delete-branch",checked:N,onCheckedChange:_=>z(_===!0),disabled:l}),e.jsxs("span",{children:["Also delete branch ",e.jsx("strong",{children:a.branch})]})]}),e.jsx(Re,{tone:k.allowed?"ready":"blocked",reason:k.reason,actionError:d,confirming:t,busy:r,anyBusy:l,actionLabel:v?"Force remove worktree":"Remove worktree",confirmLabel:r?"Removing…":v?"Permanently remove":"Remove worktree",allowed:G,confirmation:e.jsxs(e.Fragment,{children:[v?e.jsxs(e.Fragment,{children:["Permanently remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:a.path}),"? ",e.jsx("strong",{children:P??`The ${a.operation??"current Git operation"}`})," and every uncommitted file will be lost. The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}):e.jsxs(e.Fragment,{children:["Remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:a.path}),"? The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}),N&&a.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:a.branch})," will also be force-deleted. Commits found only on that branch may become inaccessible."]}):a.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:a.branch})," and its commits stay in the repository."]}):"No branch is deleted."]}),onConfirm:m,onCancel:h,onAct:()=>f(v,N)})]})}function Re({tone:a,reason:r,actionError:l,confirming:t,busy:d,anyBusy:p,allowed:m,actionLabel:h,confirmLabel:f,confirmation:c,onConfirm:x,onCancel:g,onAct:N}){return e.jsxs("div",{className:`local-refs-danger ${a}`,children:[l&&e.jsxs("p",{className:"local-refs-danger-error",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:l})]}),t&&m?e.jsxs("div",{className:"local-refs-confirm",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("p",{children:c}),e.jsxs("span",{className:"local-refs-confirm-actions",children:[e.jsxs(b,{variant:"destructive",size:"sm",onClick:N,disabled:d,children:[d?e.jsx(L,{className:"animate-spin"}):e.jsx(Z,{})," ",f]}),e.jsx(b,{variant:"ghost",size:"sm",onClick:g,disabled:d,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[a==="ready"?e.jsx(ta,{"aria-hidden":"true"}):e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:r})]}),m&&e.jsxs(b,{variant:"destructive",size:"sm",onClick:x,disabled:p,children:[e.jsx(Z,{})," ",h]})]})]})}function ee({badges:a}){return a.length===0?null:e.jsx("span",{className:"local-refs-badges",children:a.map(r=>e.jsx(ea,{variant:r.tone==="current"?"default":r.tone==="warning"?"destructive":"outline",children:r.label},r.label))})}function y({label:a,children:r}){return e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:a}),e.jsx("dd",{children:r})]})}function ja(a){switch(a){case"stale":return"The branch moved since this view loaded. It was refreshed; check the new state before deleting.";case"current":return"This branch is now checked out here, so Git will not delete it.";case"checked-out":return"Another worktree now has this branch checked out.";case"unmerged":return"Git found commits that are not in the comparison base, so the branch was kept.";case"unknown":return"The comparison base is not available locally, so the branch was kept.";default:return"The branch no longer exists."}}function Ce(a){switch(a){case"stale":return"The branch changed since this view loaded. Fetch and review its new tip before trying again.";case"default":return"This is now the remote’s default branch. It was kept.";case"destination-changed":return"The remote destination changed. Review the refreshed details before trying again.";default:return"The remote branch no longer exists. Fetch to update the list."}}function pa(a){switch(a){case"stale":return"The worktree moved since this view loaded. It was refreshed; check the new state before removing.";case"main":return"Git can never remove the main worktree.";case"current":return"OpenTig has this worktree open. Switch to another one first.";case"dirty":return"The worktree has local changes or an operation in progress, so it was kept.";case"locked":return"The worktree is locked. Unlock it in Git first.";case"prunable":return"Git can no longer find this worktree on disk.";case"bare":return"This entry is a bare repository, not a removable worktree.";default:return"The worktree no longer exists."}}function X(a){return a instanceof Error?a.message:String(a)}export{Ca as LocalRefsDialog};
|
package/dist/client/assets/{MarkdownFileViewer-BsB8WkIH.js → MarkdownFileViewer-CvsKPnvF.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
2
|
-
import{r as n,j as r,a as ae}from"./react-rd22PHbN.js";import{c as X,_ as se,w as ie,s as ce,f as le,T as H,b as $,d as q,o as ue}from"./index-B5RC4THs.js";import{t as de,q as me}from"./App-Dfm5F199.js";import{V as pe,a as fe,b as B}from"./viewer-tabs-BjG3oKQ9.js";import{u as he,s as we,F as ge,S as ve}from"./EditableFileViewer-DWeSDnZn.js";import{r as be}from"./render-markdown-hAIWRfn0.js";/* empty css */import"./tanstack-CcfAJoQ7.js";import"./base-ui-CJ8ZIx3d.js";import"./PierreWorkerPool-Cg9zdxiI.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-D65shwRR.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";const ke=[["path",{d:"M3 12h7l-3 -3",key:"svg-0"}],["path",{d:"M7 15l3 -3",key:"svg-1"}],["path",{d:"M21 12h-7l3 -3",key:"svg-2"}],["path",{d:"M17 15l-3 -3",key:"svg-3"}],["path",{d:"M9 6v-1a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M9 18v1a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],ye=X("outline","viewport-narrow","ViewportNarrow",ke);const Ce=[["path",{d:"M10 12h-7l3 -3",key:"svg-0"}],["path",{d:"M6 15l-3 -3",key:"svg-1"}],["path",{d:"M14 12h7l-3 -3",key:"svg-2"}],["path",{d:"M18 15l3 -3",key:"svg-3"}],["path",{d:"M3 6v-1a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M3 18v1a2 2 0 0 0 2 2h14a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],xe=X("outline","viewport-wide","ViewportWide",Ce);function F(m,s){const p=s.trim();if(!p||p.startsWith("#")||p.startsWith("//")||/^[a-z][a-z\d+.-]*:/i.test(p))return null;const h=p.split(/[?#]/,1)[0];if(!h)return null;let c;try{c=decodeURIComponent(h).replaceAll("\\","/")}catch{return null}const l=c.startsWith("/")?[]:m.replaceAll("\\","/").split("/").slice(0,-1).filter(Boolean);for(const t of c.split("/"))if(!(!t||t===".")){if(t===".."){if(l.length===0)return null;l.pop();continue}if(Me(t))return null;l.push(t)}return l.length>0?l.join("/"):null}function Me(m){return[...m].some(s=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)}function Te(m,s,p,h,c){const l=document.createElement("template");l.innerHTML=s;const t=new Map;for(const e of l.content.querySelectorAll("img[src]")){if(e.classList.contains("markdown-code-icon"))continue;const i=e.getAttribute("src").trim();if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(i))continue;e.removeAttribute("src"),e.removeAttribute("srcset");const u=F(h,i);if(!u)continue;const v=t.get(u)??[];v.push(e),t.set(u,v)}m.replaceChildren(l.content);let g=!1;const w=[];for(const[e,i]of t)(async()=>{let u;if(de(e)){const f=await c.readFile(p,e);if(f.binary||f.tooLarge)return;u=new Blob([f.content],{type:"image/svg+xml"})}else{const f=await c.readImage(p,e);if(f.status!=="ready")return;u=new Blob([new Uint8Array(f.data)],{type:f.mimeType})}if(g)return;const v=URL.createObjectURL(u);w.push(v);for(const f of i)f.src=v})().catch(()=>{});return()=>{g=!0;for(const e of w)URL.revokeObjectURL(e)}}let Se=0;function K(){return document.documentElement.classList.contains("dark")?"dark":"default"}function Re(m,s,p){const[h,c]=n.useState(K);n.useEffect(()=>{const t=new MutationObserver(()=>c(K()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const l=n.useCallback(async t=>{if(!m.current)return;const g=Array.from(m.current.querySelectorAll(".mermaid"));if(g.length!==0)try{const{default:w}=await se(async()=>{const{default:e}=await import("./mermaid.core-CGJtfmwb.js").then(i=>i.bo);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(t()||!m.current)return;w.initialize({startOnLoad:!1,theme:h,securityLevel:"strict"});for(const e of g){const i=e.dataset.mermaidSource;if(i){e.removeAttribute("data-mermaid-error");try{const u=decodeURIComponent(i),v=`mermaid-diagram-${Se++}`,{svg:f,bindFunctions:A}=await w.render(v,u,e);if(t()||!e.isConnected)return;e.innerHTML=f,e.dataset.processed="true",A?.(e)}catch{!t()&&e.isConnected&&(e.textContent=decodeURIComponent(i),e.dataset.mermaidError="Could not render diagram")}}}}catch{for(const w of g)!t()&&w.isConnected&&(w.dataset.mermaidError="Could not load Mermaid")}},[s,m,h]);n.useEffect(()=>{let t=!1;return l(()=>t),()=>{t=!0}},[p,l])}const Y="opentig:markdown-content-width",G=/^([a-z][a-z0-9+.-]*:)?\/\//i,je={conflictTitle:"Markdown was changed outside OpenTig",successTitle:"Markdown saved",errorTitle:"Could not save Markdown"};function Ee(){try{return window.localStorage.getItem(Y)==="fit"?"fit":"reading"}catch{return"reading"}}function Ae({html:m,repositoryId:s,markdownPath:p,onClick:h,onLinkHover:c}){const l=n.useRef(null),t=n.useRef(null);n.useLayoutEffect(()=>{const e=l.current?Te(l.current,m,s,p,ue.repository):void 0;return t.current=null,c(null),e},[m,s,p,c]),Re(l,!0,m);const g=n.useCallback(e=>{const i=e.target.closest("a[href]");!i||i===t.current||(t.current=i,c(i))},[c]),w=n.useCallback(e=>{const i=t.current;if(!i)return;const u=e.relatedTarget;u&&i.contains(u)||(t.current=null,c(null))},[c]);return r.jsx("div",{ref:l,className:"markdown-prose",onClick:h,onMouseOver:g,onMouseOut:w})}function Ge({repositoryId:m,file:s,initialContent:p,revision:h,themeType:c,wrapLines:l,readOnly:t,onOpenFile:g,onDirtyChange:w,onDraftChange:e,onSave:i}){const[u,v]=n.useState("preview"),[f,A]=n.useState(Ee),[T,O]=n.useState(""),[_,I]=n.useState(!0),[J,V]=n.useState(!1),[M,k]=n.useState(null),S=n.useRef(0),C=n.useRef(null),N=n.useRef(null),L=n.useRef(null),x=n.useRef(null),R=n.useRef(null),{draft:P,updateDraft:Q,dirty:j,saving:U,save:Z}=he({file:s,initialContent:p,readOnly:t,messages:je,onDirtyChange:w,onDraftChange:e,onSave:i});n.useEffect(()=>{R.current?.(),x.current=null,v("preview")},[s.path]);const ee=n.useCallback(a=>{if(a!==u){if(R.current?.(),u==="preview"){const o=N.current,d=o?o.scrollHeight-o.clientHeight:0;x.current=o&&d>0?o.scrollTop/d:0}else x.current=L.current?.getScrollFraction()??0;v(a)}},[u]);n.useLayoutEffect(()=>{const a=x.current;if(a==null)return;if(u==="code"){x.current=null,L.current?.scrollToFraction(a);return}const o=N.current;!o||_&&!T||(x.current=null,R.current=we({getScrollRange:()=>Math.max(0,o.scrollHeight-o.clientHeight),getScrollTop:()=>o.scrollTop,getContentHeight:()=>o.scrollHeight,scrollTo:d=>{o.scrollTop=d}},a))},[T,_,u]),n.useEffect(()=>()=>R.current?.(),[]),n.useEffect(()=>{const a=++S.current;I(!0);const o=window.setTimeout(()=>{const d=window.__opentigPerformanceAutomation?performance.now():null;be(P).then(b=>{a===S.current&&(O(b),d!==null&&(window.__opentigPerformanceResults??=[],window.__opentigPerformanceResults.push({kind:"markdown-render",durationMs:Math.round((performance.now()-d)*100)/100})))}).catch(()=>{a===S.current&&O("<p>Could not render Markdown.</p>")}).finally(()=>{a===S.current&&I(!1)})},j?120:0);return()=>window.clearTimeout(o)},[j,P,s.mtimeMs,s.path,h,c]),n.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current.timer)},[]);const te=n.useCallback(async a=>{const o=a.target,d=o.closest("[data-copy-code]");if(d){const W=d.dataset.copyCode;if(!W)return;try{const ne=decodeURIComponent(W);await ie(ne);const E=C.current;E&&(window.clearTimeout(E.timer),delete E.button.dataset.copyState,E.button.setAttribute("aria-label","Copy code")),d.dataset.copyState="copied",d.setAttribute("aria-label","Copied"),V(!0);const oe=window.setTimeout(()=>{C.current?.button===d&&(delete d.dataset.copyState,d.setAttribute("aria-label","Copy code"),C.current=null,V(!1))},2e3);C.current={button:d,timer:oe}}catch{ce.error({title:"Could not copy code"})}return}const b=o.closest("a[href]"),y=b?.getAttribute("href");if(!b||!y)return;if(a.preventDefault(),y.startsWith("#")){a.currentTarget.querySelector(`#${CSS.escape(y.slice(1))}`)?.scrollIntoView({behavior:"smooth",block:"start"});return}if(G.test(y)||y.startsWith("mailto:")){try{le(y)}catch{}return}const z=F(s.path,y);z&&g(z)},[s.path,g]),re=n.useCallback(a=>{if(!a){k(null);return}const o=a.getAttribute("href");if(!o||o.startsWith("#")){k(null);return}const d=a.getBoundingClientRect(),b={top:d.bottom+6,left:d.left};if(o.startsWith("mailto:")){k({...b,label:"Open in mail app",href:o.replace(/^mailto:/,"")});return}if(G.test(o)){k({...b,label:"Open in browser",href:o});return}if(F(s.path,o)){k({...b,label:"Open file",href:o});return}k(null)},[s.path]),D=a=>{A(a);try{window.localStorage.setItem(Y,a)}catch{}};return r.jsxs(pe,{value:u,onValueChange:a=>ee(a),className:"markdown-viewer","data-content-width":f,children:[r.jsxs("div",{className:"file-viewer-pill markdown-viewer-toolbar",children:[r.jsx(fe,{label:"Markdown view",className:"file-viewer-tabs markdown-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:r.jsxs(r.Fragment,{children:["Code ",j&&r.jsx("span",{className:"markdown-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),r.jsx(ge,{dirty:j,saving:U,readOnly:t,onSave:()=>{Z()}}),r.jsxs("div",{className:"markdown-width-toggle",role:"group","aria-label":"Markdown content width",children:[r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Reading width","aria-pressed":f==="reading",onClick:()=>D("reading")}),children:r.jsx(ye,{"aria-hidden":"true"})}),r.jsx(q,{children:"Reading width"})]}),r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Fit to width","aria-pressed":f==="fit",onClick:()=>D("fit")}),children:r.jsx(xe,{"aria-hidden":"true"})}),r.jsx(q,{children:"Fit to width"})]})]})]}),r.jsxs(B,{ref:N,value:"preview",className:"markdown-preview-scroll",onScroll:()=>k(null),children:[_&&!T?r.jsx("div",{className:"viewer-message",children:r.jsx(me,{text:"Rendering Markdown…"})}):r.jsx(Ae,{repositoryId:m,markdownPath:s.path,html:T,onClick:a=>{te(a)},onLinkHover:re},`${m}:${s.path}:${h}`),r.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:J?"Code copied":""}),M?ae.createPortal(r.jsxs("div",{className:"markdown-link-tooltip",style:{top:M.top,left:M.left},role:"tooltip",children:[r.jsx("span",{className:"markdown-link-tooltip-label",children:M.label}),r.jsx("span",{className:"markdown-link-tooltip-href",children:M.href})]}),document.body):null]}),r.jsx(B,{value:"code",className:"markdown-code-view","data-theme":c,children:r.jsx(ve,{ref:L,path:s.path,cacheKey:s.path,value:P,themeType:c,wrapLines:l,readOnly:t||U,onChange:Q})})]})}export{Ge as MarkdownFileViewer};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-vLn7mMZB.js","assets/index-B3QJsvjR.js","assets/react-rd22PHbN.js","assets/tanstack-BysN2Oew.js","assets/base-ui-DIP2rZxz.js","assets/index-Cx9LaJW8.css","assets/render-markdown-dvHhHbC0.js","assets/App-BbT5H97Z.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as n,j as r,a as ae}from"./react-rd22PHbN.js";import{c as X,_ as se,w as ie,s as ce,f as le,T as H,b as $,d as q,o as ue}from"./index-B3QJsvjR.js";import{h as de,g as me}from"./App-BbT5H97Z.js";import{V as pe,a as fe,b as B}from"./viewer-tabs-Cnfyd6rg.js";import{u as he,s as we,F as ge,S as ve}from"./EditableFileViewer-Cmbomx5y.js";import{r as be}from"./render-markdown-dvHhHbC0.js";/* empty css */import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";import"./PierreWorkerPool-BxP-s6jD.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-4o4egqlz.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";const ke=[["path",{d:"M3 12h7l-3 -3",key:"svg-0"}],["path",{d:"M7 15l3 -3",key:"svg-1"}],["path",{d:"M21 12h-7l3 -3",key:"svg-2"}],["path",{d:"M17 15l-3 -3",key:"svg-3"}],["path",{d:"M9 6v-1a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M9 18v1a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],ye=X("outline","viewport-narrow","ViewportNarrow",ke);const Ce=[["path",{d:"M10 12h-7l3 -3",key:"svg-0"}],["path",{d:"M6 15l-3 -3",key:"svg-1"}],["path",{d:"M14 12h7l-3 -3",key:"svg-2"}],["path",{d:"M18 15l3 -3",key:"svg-3"}],["path",{d:"M3 6v-1a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M3 18v1a2 2 0 0 0 2 2h14a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],xe=X("outline","viewport-wide","ViewportWide",Ce);function F(m,s){const p=s.trim();if(!p||p.startsWith("#")||p.startsWith("//")||/^[a-z][a-z\d+.-]*:/i.test(p))return null;const h=p.split(/[?#]/,1)[0];if(!h)return null;let c;try{c=decodeURIComponent(h).replaceAll("\\","/")}catch{return null}const l=c.startsWith("/")?[]:m.replaceAll("\\","/").split("/").slice(0,-1).filter(Boolean);for(const t of c.split("/"))if(!(!t||t===".")){if(t===".."){if(l.length===0)return null;l.pop();continue}if(Me(t))return null;l.push(t)}return l.length>0?l.join("/"):null}function Me(m){return[...m].some(s=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)}function Te(m,s,p,h,c){const l=document.createElement("template");l.innerHTML=s;const t=new Map;for(const e of l.content.querySelectorAll("img[src]")){if(e.classList.contains("markdown-code-icon"))continue;const i=e.getAttribute("src").trim();if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(i))continue;e.removeAttribute("src"),e.removeAttribute("srcset");const u=F(h,i);if(!u)continue;const v=t.get(u)??[];v.push(e),t.set(u,v)}m.replaceChildren(l.content);let g=!1;const w=[];for(const[e,i]of t)(async()=>{let u;if(de(e)){const f=await c.readFile(p,e);if(f.binary||f.tooLarge)return;u=new Blob([f.content],{type:"image/svg+xml"})}else{const f=await c.readImage(p,e);if(f.status!=="ready")return;u=new Blob([new Uint8Array(f.data)],{type:f.mimeType})}if(g)return;const v=URL.createObjectURL(u);w.push(v);for(const f of i)f.src=v})().catch(()=>{});return()=>{g=!0;for(const e of w)URL.revokeObjectURL(e)}}let Se=0;function K(){return document.documentElement.classList.contains("dark")?"dark":"default"}function Re(m,s,p){const[h,c]=n.useState(K);n.useEffect(()=>{const t=new MutationObserver(()=>c(K()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const l=n.useCallback(async t=>{if(!m.current)return;const g=Array.from(m.current.querySelectorAll(".mermaid"));if(g.length!==0)try{const{default:w}=await se(async()=>{const{default:e}=await import("./mermaid.core-vLn7mMZB.js").then(i=>i.bo);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(t()||!m.current)return;w.initialize({startOnLoad:!1,theme:h,securityLevel:"strict"});for(const e of g){const i=e.dataset.mermaidSource;if(i){e.removeAttribute("data-mermaid-error");try{const u=decodeURIComponent(i),v=`mermaid-diagram-${Se++}`,{svg:f,bindFunctions:A}=await w.render(v,u,e);if(t()||!e.isConnected)return;e.innerHTML=f,e.dataset.processed="true",A?.(e)}catch{!t()&&e.isConnected&&(e.textContent=decodeURIComponent(i),e.dataset.mermaidError="Could not render diagram")}}}}catch{for(const w of g)!t()&&w.isConnected&&(w.dataset.mermaidError="Could not load Mermaid")}},[s,m,h]);n.useEffect(()=>{let t=!1;return l(()=>t),()=>{t=!0}},[p,l])}const Y="opentig:markdown-content-width",G=/^([a-z][a-z0-9+.-]*:)?\/\//i,je={conflictTitle:"Markdown was changed outside OpenTig",successTitle:"Markdown saved",errorTitle:"Could not save Markdown"};function Ee(){try{return window.localStorage.getItem(Y)==="fit"?"fit":"reading"}catch{return"reading"}}function Ae({html:m,repositoryId:s,markdownPath:p,onClick:h,onLinkHover:c}){const l=n.useRef(null),t=n.useRef(null);n.useLayoutEffect(()=>{const e=l.current?Te(l.current,m,s,p,ue.repository):void 0;return t.current=null,c(null),e},[m,s,p,c]),Re(l,!0,m);const g=n.useCallback(e=>{const i=e.target.closest("a[href]");!i||i===t.current||(t.current=i,c(i))},[c]),w=n.useCallback(e=>{const i=t.current;if(!i)return;const u=e.relatedTarget;u&&i.contains(u)||(t.current=null,c(null))},[c]);return r.jsx("div",{ref:l,className:"markdown-prose",onClick:h,onMouseOver:g,onMouseOut:w})}function Ge({repositoryId:m,file:s,initialContent:p,revision:h,themeType:c,wrapLines:l,readOnly:t,onOpenFile:g,onDirtyChange:w,onDraftChange:e,onSave:i}){const[u,v]=n.useState("preview"),[f,A]=n.useState(Ee),[T,O]=n.useState(""),[_,I]=n.useState(!0),[J,V]=n.useState(!1),[M,k]=n.useState(null),S=n.useRef(0),C=n.useRef(null),N=n.useRef(null),L=n.useRef(null),x=n.useRef(null),R=n.useRef(null),{draft:P,updateDraft:Q,dirty:j,saving:U,save:Z}=he({file:s,initialContent:p,readOnly:t,messages:je,onDirtyChange:w,onDraftChange:e,onSave:i});n.useEffect(()=>{R.current?.(),x.current=null,v("preview")},[s.path]);const ee=n.useCallback(a=>{if(a!==u){if(R.current?.(),u==="preview"){const o=N.current,d=o?o.scrollHeight-o.clientHeight:0;x.current=o&&d>0?o.scrollTop/d:0}else x.current=L.current?.getScrollFraction()??0;v(a)}},[u]);n.useLayoutEffect(()=>{const a=x.current;if(a==null)return;if(u==="code"){x.current=null,L.current?.scrollToFraction(a);return}const o=N.current;!o||_&&!T||(x.current=null,R.current=we({getScrollRange:()=>Math.max(0,o.scrollHeight-o.clientHeight),getScrollTop:()=>o.scrollTop,getContentHeight:()=>o.scrollHeight,scrollTo:d=>{o.scrollTop=d}},a))},[T,_,u]),n.useEffect(()=>()=>R.current?.(),[]),n.useEffect(()=>{const a=++S.current;I(!0);const o=window.setTimeout(()=>{const d=window.__opentigPerformanceAutomation?performance.now():null;be(P).then(b=>{a===S.current&&(O(b),d!==null&&(window.__opentigPerformanceResults??=[],window.__opentigPerformanceResults.push({kind:"markdown-render",durationMs:Math.round((performance.now()-d)*100)/100})))}).catch(()=>{a===S.current&&O("<p>Could not render Markdown.</p>")}).finally(()=>{a===S.current&&I(!1)})},j?120:0);return()=>window.clearTimeout(o)},[j,P,s.mtimeMs,s.path,h,c]),n.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current.timer)},[]);const te=n.useCallback(async a=>{const o=a.target,d=o.closest("[data-copy-code]");if(d){const W=d.dataset.copyCode;if(!W)return;try{const ne=decodeURIComponent(W);await ie(ne);const E=C.current;E&&(window.clearTimeout(E.timer),delete E.button.dataset.copyState,E.button.setAttribute("aria-label","Copy code")),d.dataset.copyState="copied",d.setAttribute("aria-label","Copied"),V(!0);const oe=window.setTimeout(()=>{C.current?.button===d&&(delete d.dataset.copyState,d.setAttribute("aria-label","Copy code"),C.current=null,V(!1))},2e3);C.current={button:d,timer:oe}}catch{ce.error({title:"Could not copy code"})}return}const b=o.closest("a[href]"),y=b?.getAttribute("href");if(!b||!y)return;if(a.preventDefault(),y.startsWith("#")){a.currentTarget.querySelector(`#${CSS.escape(y.slice(1))}`)?.scrollIntoView({behavior:"smooth",block:"start"});return}if(G.test(y)||y.startsWith("mailto:")){try{le(y)}catch{}return}const z=F(s.path,y);z&&g(z)},[s.path,g]),re=n.useCallback(a=>{if(!a){k(null);return}const o=a.getAttribute("href");if(!o||o.startsWith("#")){k(null);return}const d=a.getBoundingClientRect(),b={top:d.bottom+6,left:d.left};if(o.startsWith("mailto:")){k({...b,label:"Open in mail app",href:o.replace(/^mailto:/,"")});return}if(G.test(o)){k({...b,label:"Open in browser",href:o});return}if(F(s.path,o)){k({...b,label:"Open file",href:o});return}k(null)},[s.path]),D=a=>{A(a);try{window.localStorage.setItem(Y,a)}catch{}};return r.jsxs(pe,{value:u,onValueChange:a=>ee(a),className:"markdown-viewer","data-content-width":f,children:[r.jsxs("div",{className:"file-viewer-pill markdown-viewer-toolbar",children:[r.jsx(fe,{label:"Markdown view",className:"file-viewer-tabs markdown-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:r.jsxs(r.Fragment,{children:["Code ",j&&r.jsx("span",{className:"markdown-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),r.jsx(ge,{dirty:j,saving:U,readOnly:t,onSave:()=>{Z()}}),r.jsxs("div",{className:"markdown-width-toggle",role:"group","aria-label":"Markdown content width",children:[r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Reading width","aria-pressed":f==="reading",onClick:()=>D("reading")}),children:r.jsx(ye,{"aria-hidden":"true"})}),r.jsx(q,{children:"Reading width"})]}),r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Fit to width","aria-pressed":f==="fit",onClick:()=>D("fit")}),children:r.jsx(xe,{"aria-hidden":"true"})}),r.jsx(q,{children:"Fit to width"})]})]})]}),r.jsxs(B,{ref:N,value:"preview",className:"markdown-preview-scroll",onScroll:()=>k(null),children:[_&&!T?r.jsx("div",{className:"viewer-message",children:r.jsx(me,{text:"Rendering Markdown…"})}):r.jsx(Ae,{repositoryId:m,markdownPath:s.path,html:T,onClick:a=>{te(a)},onLinkHover:re},`${m}:${s.path}:${h}`),r.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:J?"Code copied":""}),M?ae.createPortal(r.jsxs("div",{className:"markdown-link-tooltip",style:{top:M.top,left:M.left},role:"tooltip",children:[r.jsx("span",{className:"markdown-link-tooltip-label",children:M.label}),r.jsx("span",{className:"markdown-link-tooltip-href",children:M.href})]}),document.body):null]}),r.jsx(B,{value:"code",className:"markdown-code-view","data-theme":c,children:r.jsx(ve,{ref:L,path:s.path,cacheKey:s.path,value:P,themeType:c,wrapLines:l,readOnly:t||U,onChange:Q})})]})}export{Ge as MarkdownFileViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./react-rd22PHbN.js";import{B as g,e as w,P as j}from"./index-
|
|
1
|
+
import{r as c,j as e}from"./react-rd22PHbN.js";import{B as g,e as w,P as j}from"./index-B3QJsvjR.js";import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";async function v(r,i=fetch){try{const a=await i("/api/auth/descriptor",{credentials:"include",cache:"no-store",signal:r});if(!a.ok)return"unavailable";const t=await a.json();return!t||typeof t!="object"||!("authenticated"in t)?"unavailable":t.authenticated===!0?"authenticated":"browserAccessEnabled"in t&&t.browserAccessEnabled===!1?"disabled":t.authenticated===!1?"unpaired":"unavailable"}catch{return"unavailable"}}function y(r,i){const a=r.hash;return i.replaceState(null,"",`${r.pathname}${r.search}`),new URLSearchParams(a.startsWith("#")?a.slice(1):a).get("token")??""}async function k(r,i,a=fetch){try{const t=await a("/api/auth/pair",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r,clientName:i})});if(t.ok)return"paired";if(t.status===403&&t.json){const n=await t.json();if(n&&typeof n=="object"&&"code"in n&&n.code==="WEB_ACCESS_DISABLED")return"disabled"}return"rejected"}catch{return"unavailable"}}function N(r){const i=[[/Edg\//,"Edge"],[/Firefox\//,"Firefox"],[/OPR\//,"Opera"],[/Chrome\//,"Chrome"],[/Safari\//,"Safari"]].find(([t])=>t.test(r))?.[1]??"Browser",a=[[/Windows NT/,"Windows"],[/Android/,"Android"],[/(?:iPhone|iPod)/,"iPhone"],[/iPad/,"iPad"],[/CrOS/,"ChromeOS"],[/Macintosh|Mac OS X/,"Mac"],[/Linux/,"Linux"]].find(([t])=>t.test(r))?.[1];return a?`${i} on ${a}`:i}const f={rejected:"This code is invalid, expired, or already used. Create a new one from OpenTig.",unavailable:"OpenTig could not complete pairing. Check the server and try again.",disabled:"Web access is paused. Enable it in Settings → Web access in the desktop app, then reload. Previously paired browsers keep their access while their session is valid; new devices need a pairing link."};function E(){const[r,i]=c.useState(()=>y(window.location,window.history)),[a,t]=c.useState(()=>N(window.navigator.userAgent)),[n,m]=c.useState("idle"),[d,h]=c.useState("checking"),[b,p]=c.useState(0);c.useEffect(()=>{const s=new AbortController;let o=!0;const l=window.setTimeout(()=>s.abort(),1e4);return v(s.signal).then(u=>{o&&(u==="authenticated"&&window.location.replace("/"),h(u))}).finally(()=>window.clearTimeout(l)),()=>{o=!1,s.abort(),window.clearTimeout(l)}},[b]);const x=async s=>{s.preventDefault();const o=a.trim(),l=r.trim();if(!o||!l||o.length>64)return;m("pairing");const u=await k(l,o);u==="paired"?window.location.replace("/"):m(u)};return d==="disabled"||n==="disabled"?e.jsx("main",{className:"access-page pairing-page flex min-h-dvh items-center justify-center bg-background px-4 py-6 text-foreground",children:e.jsxs("section",{className:"w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-sm",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Web access is paused"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",role:"status",children:f.disabled}),e.jsx(g,{className:"mt-5",onClick:()=>{m("idle"),h("checking"),p(s=>s+1)},children:"Check again"})]})}):d!=="unpaired"?e.jsx("main",{className:"access-page pairing-page flex min-h-dvh items-center justify-center bg-background px-4 py-6 text-foreground",children:e.jsxs("section",{className:"w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-sm",children:[e.jsx("h1",{className:"text-lg font-semibold",children:d==="unavailable"?"Could not check this browser":"Checking this browser…"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",role:"status",children:d==="unavailable"?"Could not verify your saved session. Check your connection and try again.":"Checking your saved session before asking you to pair again."}),d==="unavailable"&&e.jsx(g,{className:"mt-5",onClick:()=>{h("checking"),p(s=>s+1)},children:"Try again"})]})}):e.jsx("main",{className:"access-page pairing-page flex min-h-dvh items-center justify-center bg-background px-4 py-6 text-foreground",children:e.jsxs("section",{className:"w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-sm",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Pair this browser"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Enter the one-use code shown by the ",w," desktop app or generated with the command below on the server. It expires after five minutes."]}),e.jsx(j,{}),e.jsxs("form",{className:"mt-5 grid gap-4",onSubmit:s=>{x(s)},children:[e.jsxs("label",{className:"grid gap-1.5 text-sm",htmlFor:"pairing-code",children:[e.jsx("span",{className:"font-medium",children:"Pairing code"}),e.jsx("input",{id:"pairing-code",className:"h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 font-mono text-base outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",value:r,onChange:s=>i(s.target.value),autoComplete:"off",spellCheck:!1,required:!0})]}),e.jsxs("label",{className:"grid gap-1.5 text-sm",htmlFor:"device-name",children:[e.jsx("span",{className:"font-medium",children:"Device name"}),e.jsx("input",{id:"device-name",className:"h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 text-base outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",value:a,onChange:s=>t(s.target.value),maxLength:64,autoComplete:"off",required:!0})]}),e.jsx(g,{type:"submit",disabled:n==="pairing"||!r.trim()||!a.trim(),children:n==="pairing"?"Pairing…":"Pair browser"})]}),(n==="rejected"||n==="unavailable")&&e.jsx("p",{className:"mt-4 text-sm text-destructive",role:"alert",children:f[n]}),e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:"The code is removed from the address bar immediately and is never stored by the browser."}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"This browser remembers its access and renews it automatically while you use OpenTig. Pair again after 30 days without renewal, clearing cookies, or revoking access."})]})})}export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as k,j as g}from"./react-rd22PHbN.js";import{t as w,a6 as E,n as Y,a7 as j,a8 as O,B as Z,d as M,E as ee,A as ne,a3 as te,_ as ie,a4 as R,a5 as oe,P as re,a as se,V as T,O as U,r as $}from"./PierreWorkerPool-Cg9zdxiI.js";import{F as le}from"./File-D65shwRR.js";import{D as V,b as P,f as ce}from"./platform-Bqt97_Jr.js";import{a as de,g as J,b as Q,F as ae,p as b,c as ue,s as fe,r as he,D as pe}from"./DiffWorkspace-BRicWHvw.js";import{a as H}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-B5RC4THs.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-Dfm5F199.js";import"./tanstack-CcfAJoQ7.js";import"./base-ui-CJ8ZIx3d.js";var _=class extends de{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:V},n,t){super(void 0,n,t),this.options=e}setConflictState(e,n,t){this.pendingConflictActions=e,this.pendingMarkerRows=n,this.syncInjectedRows(e,n,t)}syncInjectedRows(e,n,t){this.injectedRows.clear();for(const i of e){const r=i!=null?J(i,t):void 0;if(i==null||r==null)continue;const o={type:"actions",hunkIndex:r.hunkIndex,lineIndex:r.lineIndex,conflictIndex:i.conflictIndex};this.addInjectedRow(o)}for(const i of n)this.addInjectedRow(i)}addInjectedRow(e){const n=`${e.hunkIndex}:${e.lineIndex}`,t=this.injectedRows.get(n);t==null?this.injectedRows.set(n,[e]):t.push(e)}renderDiff(e,n=P){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=P){return this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.asyncRender(e,n)}createPreElement(e,n){return super.createPreElement(e,n,{"data-has-merge-conflict":""})}getUnifiedLineDecoration({type:e,lineType:n}){const t=e==="change"?n==="change-deletion"?"current":"incoming":void 0;return{gutterLineType:e==="change"?"context":n,gutterProperties:B(t),contentProperties:W(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:B(t),contentProperties:W(n,t)}}getUnifiedInjectedRowsForLine=e=>{const n=this.injectedRows.get(`${e.hunkIndex}:${e.lineIndex}`);if(n==null||n.length===0)return;const{mergeConflictActionsType:t}=this.getOptionsWithDefaults(),i=[],r=[];for(const o of n){if(o.type==="actions"){i.push({content:Ce({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:G("action")});continue}(o.type==="marker-end"?r:i).push({content:me(o),gutter:G("marker",o.type)})}return{before:i.length>0?i:void 0,after:r.length>0?r:void 0}};getOptionsWithDefaults(){const e=super.getOptionsWithDefaults();return e.diffStyle="unified",e.lineDiffType="none",e.mergeConflictActionsType=this.options.mergeConflictActionsType??"default",e}};function B(e){return e!=null?{"data-merge-conflict":e}:void 0}function W(e,n){if(n!=null){if(e==="change")return n==="current"||n==="incoming"?{"data-line-type":"context","data-merge-conflict":n}:void 0;if(n==="marker-start"||n==="marker-base"||n==="marker-separator"||n==="marker-end")return{"data-merge-conflict":n}}}function G(e,n){const t=Y(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function Ce({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?xe(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Q({hunkIndex:e.hunkIndex,lineIndex:e.lineIndex,conflictIndex:e.conflictIndex}),"data-merge-conflict-action-slot":""}})),w({tagName:"div",properties:{"data-merge-conflict-actions":""},children:[w({tagName:"div",properties:{"data-merge-conflict-actions-content":""},children:i})]})}function me(e){return w({tagName:"div",properties:{"data-merge-conflict":e.type,"data-merge-conflict-marker-row":""},children:[E(e.lineText.replace(/(?:\r\n|\n|\r)$/,""))]})}function xe(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),K(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),K(),y({resolution:"both",label:"Accept both",conflictIndex:e})]}function y({resolution:e,label:n,conflictIndex:t}){return w({tagName:"button",properties:{type:"button","data-merge-conflict-action":e,"data-merge-conflict-conflict-index":`${t}`},children:[E(n)]})}function K(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function ge(e,n){return e.hunkIndex===n.hunkIndex&&e.startContentIndex===n.startContentIndex&&e.endContentIndex===n.endContentIndex&&e.currentContentIndex===n.currentContentIndex&&e.baseContentIndex===n.baseContentIndex&&e.incomingContentIndex===n.incomingContentIndex&&e.endMarkerContentIndex===n.endMarkerContentIndex&&e.conflictIndex===n.conflictIndex&&Le(e.conflict,n.conflict)}function Le(e,n){return e.conflictIndex===n.conflictIndex&&e.startLineIndex===n.startLineIndex&&e.startLineNumber===n.startLineNumber&&e.separatorLineIndex===n.separatorLineIndex&&e.separatorLineNumber===n.separatorLineNumber&&e.endLineIndex===n.endLineIndex&&e.endLineNumber===n.endLineNumber&&e.baseMarkerLineIndex===n.baseMarkerLineIndex&&e.baseMarkerLineNumber===n.baseMarkerLineNumber}function Ie(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function ve(e,n){const{resolution:t,hunkIndex:i,startContentIndex:r,endContentIndex:o,indexesToDelete:s=new Set}=n,l=e.hunks[i];if(l==null)throw console.error({diff:e,hunkIndex:i}),new Error(`resolveRegion: Invalid hunk index: ${i}`);if(r<0||o>=l.hunkContent.length||r>o)throw new Error(`resolveRegion: Invalid content range, ${r}, ${o}`);const{hunks:d,additionLines:a,deletionLines:f}=e,h={...e,hunks:[],deletionLines:[],additionLines:[],splitLineCount:0,unifiedLineCount:0,cacheKey:e.cacheKey!=null?`${e.cacheKey}:${t[0]}-${i}:${r}-${o}`:void 0},u={nextAdditionLineIndex:0,nextDeletionLineIndex:0,nextAdditionStart:1,nextDeletionStart:1,splitLineCount:0,unifiedLineCount:0},L=i===d.length-1&&o===l.hunkContent.length-1,A=!e.isPartial;for(const[p,x]of d.entries()){ke(e,h,u,j(x.deletionStart,x.deletionCount)-x.collapsedBefore,j(x.additionStart,x.additionCount)-x.collapsedBefore,x.collapsedBefore,A);const c={...x,hunkContent:[],additionStart:u.nextAdditionStart,deletionStart:u.nextDeletionStart,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex,additionCount:0,deletionCount:0,deletionLines:0,additionLines:0,splitLineStart:u.splitLineCount,unifiedLineStart:u.unifiedLineCount,splitLineCount:0,unifiedLineCount:0};for(const[m,C]of x.hunkContent.entries())if(p!==i||m<r||m>o){z(C,h,f,a);const v={...C,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex};c.hunkContent.push(v),S(v,u,c)}else if(s.has(m))c.hunkContent.push({type:"context",lines:0,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex});else if(C.type==="context"){z(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{Ae(t,C,h,f,a);const v={type:"context",lines:t==="deletions"?C.deletions:t==="additions"?C.additions:C.deletions+C.additions,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}if(p===i&&L){const m=t==="deletions"?x.noEOFCRDeletions:x.noEOFCRAdditions;c.noEOFCRAdditions=m,c.noEOFCRDeletions=m}c.additionCount===0&&(c.additionStart--,e.isPartial||c.additionLineIndex--),c.deletionCount===0&&(c.deletionStart--,e.isPartial||c.deletionLineIndex--),h.hunks.push(c)}const I=d.at(-1);if(I!=null&&!e.isPartial){const p=O(I.deletionStart,I.deletionCount),x=O(I.additionStart,I.additionCount),c=Math.min(f.length-p,a.length-x);X(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function X(e,n,t,i,r,o){for(let s=0;s<o;s++){const l=n[i+s],d=t[r+s];if(l==null||d==null)throw new Error("pushCollapsedContextLines: missing collapsed context line");e.deletionLines.push(l),e.additionLines.push(d)}}function ke(e,n,t,i,r,o,s){o<=0||(s&&(X(n,e.deletionLines,e.additionLines,i,r,o),t.nextAdditionLineIndex+=o,t.nextDeletionLineIndex+=o),t.nextAdditionStart+=o,t.nextDeletionStart+=o,t.splitLineCount+=o,t.unifiedLineCount+=o)}function z(e,n,t,i){if(e.type==="context")for(let r=0;r<e.lines;r++){const o=i[e.additionLineIndex+r];if(o==null)throw console.error({additionLines:i,content:e,i:r}),new Error("pushContentLinesToDiff: Context line does not exist");n.deletionLines.push(o),n.additionLines.push(o)}else{const r=Math.max(e.deletions,e.additions);for(let o=0;o<r;o++){if(o<e.deletions){const s=t[e.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:t,content:e,i:o}),new Error("pushContentLinesToDiff: Deletion line does not exist");n.deletionLines.push(s)}if(o<e.additions){const s=i[e.additionLineIndex+o];if(s==null)throw console.error({additionLines:i,content:e,i:o}),new Error("pushContentLinesToDiff: Addition line does not exist");n.additionLines.push(s)}}}}function Ae(e,n,t,i,r){if(e==="deletions"||e==="both")for(let o=0;o<n.deletions;o++){const s=i[n.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:i,content:n,i:o}),new Error("pushResolveLinesToDiff: Deletion line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}if(e==="additions"||e==="both")for(let o=0;o<n.additions;o++){const s=r[n.additionLineIndex+o];if(s==null)throw console.error({additionLines:r,content:n,i:o}),new Error("pushResolveLinesToDiff: Addition line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}}function S(e,n,t){e.type==="context"?(n.nextAdditionLineIndex+=e.lines,n.nextDeletionLineIndex+=e.lines,n.nextAdditionStart+=e.lines,n.nextDeletionStart+=e.lines,n.splitLineCount+=e.lines,n.unifiedLineCount+=e.lines,t.additionCount+=e.lines,t.deletionCount+=e.lines,t.splitLineCount+=e.lines,t.unifiedLineCount+=e.lines):(n.nextAdditionLineIndex+=e.additions,n.nextDeletionLineIndex+=e.deletions,n.nextAdditionStart+=e.additions,n.nextDeletionStart+=e.deletions,n.splitLineCount+=Math.max(e.deletions,e.additions),n.unifiedLineCount+=e.deletions+e.additions,t.deletionCount+=e.deletions,t.deletionLines+=e.deletions,t.additionCount+=e.additions,t.additionLines+=e.additions,t.splitLineCount+=Math.max(e.deletions,e.additions),t.unifiedLineCount+=e.deletions+e.additions)}function we(e,n,t){return ve(e,{resolution:Ie(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:Re(n)})}function Re(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let De=-1;var Me=class extends ae{options;__id=`unresolved-file:${++De}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:V},t,i=!1){super(void 0,t,i),this.options=n,this.setOptions(n)}setOptions(n){if(n!=null){if(n.onMergeConflictAction!=null&&n.onMergeConflictResolve!=null)throw new Error("UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.");this.options=n,this.hunksRenderer.setOptions(this.getHunksRendererOptions(n)),this.syncInteractionOptions()}}syncInteractionOptions(){this.interactionManager.setOptions(Z(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex,this.handleMergeConflictActionClick))}createHunksRenderer(n){return new _(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Te(n,this.options)}applyPreNodeAttributes(n,t){super.applyPreNodeAttributes(n,t,{"data-has-merge-conflict":""})}cleanUp(){this.emitPostRender(!0),this.clearMergeConflictActionCache(),this.computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0},this.conflictActions=[],super.cleanUp()}getOrComputeDiff({file:n,fileDiff:t,actions:i,markerRows:r}){const{maxContextLines:o,onMergeConflictAction:s}=this.options;e:if(s!=null){const l=t!=null;if(l!==(i!=null)||l!==(r!=null))throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together");if(t!=null&&i!=null&&r!=null){this.computedCache={file:n??this.computedCache.file,fileDiff:t,actions:i,markerRows:r};break e}else if(n!=null||this.computedCache.file!=null){if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file)&&this.computedCache.fileDiff!=null&&this.computedCache.actions!=null)throw new Error("UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.");if(n??=this.computedCache.file,n==null)throw new Error("UnresolvedFile.getOrComputeDiff: file is null, should be impossible");if(!M(n,this.computedCache.file)||this.computedCache.fileDiff==null||this.computedCache.actions==null){const d=b(n,o);this.computedCache={file:n,fileDiff:d.fileDiff,actions:d.actions,markerRows:d.markerRows}}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}else{t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}}else{if(t!=null||i!=null||r!=null)throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`");if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file))throw new Error("UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.");if(this.computedCache.file??=n,this.computedCache.fileDiff==null&&this.computedCache.file!=null){const l=b(this.computedCache.file,o);this.computedCache.fileDiff=l.fileDiff,this.computedCache.actions=l.actions,this.computedCache.markerRows=l.markerRows}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}if(!(t==null||i==null||r==null))return{fileDiff:t,actions:i,markerRows:r}}hydrate(n){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,fileContainer:l,prerenderedHTML:d,preventEmit:a=!1}=n,f=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});f!=null&&(this.hydrateElements(l,d),this.setActiveMergeConflictState(f.actions,f.markerRows),je(this.pre,f.fileDiff,this.options.collapsed)||Oe(this.headerElement,f.fileDiff,this.options.disableFileHeader)?this.render({...n,preventEmit:!0}):(this.hydrationSetup({fileDiff:f.fileDiff,lineAnnotations:s}),this.pre!=null&&this.renderMergeConflictActionSlots()),a||this.emitPostRender())}rerender(){!this.enabled||this.fileDiff==null||this.render({forceRender:!0,renderRange:this.renderRange})}render(n={}){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,preventEmit:l=!1,...d}=n,a=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});if(a==null)return!1;this.setActiveMergeConflictState(a.actions,a.markerRows);const f=super.render({...d,fileDiff:a.fileDiff,lineAnnotations:s,preventEmit:!0});return f&&(this.renderMergeConflictActionSlots(),l||this.emitPostRender()),f}resolveConflict(n,t,i=this.computedCache.fileDiff){const r=this.conflictActions[n];if(i==null||r==null)return;if(r.conflictIndex!==n)throw console.error({conflictIndex:n,action:r}),new Error("UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match");const o=we(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=ye({fileDiff:o,previousActions:this.conflictActions,resolvedConflictIndex:n,previousFile:s,resolution:t});return{file:l,fileDiff:o,actions:d,markerRows:a}}resolveConflictAndRender(n,t){const i=this.conflictActions[n];if(i==null)return;if(i.conflictIndex!==n)throw console.error({conflictIndex:n,action:i}),new Error("UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match");const r={resolution:t,conflict:i.conflict},{file:o,fileDiff:s,actions:l,markerRows:d}=this.resolveConflict(n,t)??{};o==null||s==null||l==null||d==null||(this.computedCache={file:o,fileDiff:s,actions:l,markerRows:d},this.setActiveMergeConflictState(l,d),this.workerManager!=null?this.hunksRenderer.renderDiff(s):this.render({forceRender:!0}),this.options.onMergeConflictResolve?.(o,r))}setActiveMergeConflictState(n=this.conflictActions,t=this.markerRows){this.conflictActions=n,this.markerRows=t,this.computedCache.fileDiff!=null&&this.hunksRenderer instanceof _&&this.hunksRenderer.setConflictState(this.options.mergeConflictActionsType==="none"?[]:n,t,this.computedCache.fileDiff)}handleMergeConflictActionClick=n=>{const t=this.conflictActions[n.conflictIndex];if(t==null)return;if(t.conflictIndex!==n.conflictIndex)throw console.error({conflictIndex:n.conflictIndex,action:t}),new Error("UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match");const i={resolution:n.resolution,conflict:t.conflict};if(this.options.onMergeConflictAction!=null){this.options.onMergeConflictAction(i,this);return}this.resolveConflictAndRender(n.conflictIndex,n.resolution)};renderMergeConflictActionSlots(){const{fileDiff:n}=this.computedCache;if(this.isContainerManaged||this.fileContainer==null||typeof this.options.mergeConflictActionsType!="function"||this.conflictActions.length===0||n==null){this.clearMergeConflictActionCache();return}const t=new Map(this.conflictActionCache);for(let i=0;i<this.conflictActions.length;i++){const r=this.conflictActions[i];if(r==null)continue;if(r.conflictIndex!==i)throw console.error({conflictIndex:i,action:r}),new Error("UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match");const o=J(r,n);if(o==null)continue;const s=r.conflictIndex,l=Q({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!ge(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=ee(l);h.appendChild(f),this.fileContainer.appendChild(h),a={element:h,action:r},this.conflictActionCache.set(d,a)}t.delete(d)}for(const[i,{element:r}]of t.entries())this.conflictActionCache.delete(i),r.remove()}renderMergeConflictAction(n){if(typeof this.options.mergeConflictActionsType!="function")return;const t=this.options.mergeConflictActionsType(n,this);if(t!=null){if(t instanceof HTMLElement)return t;if(typeof DocumentFragment<"u"&&t instanceof DocumentFragment){const i=document.createElement("div");return i.style.display="contents",i.appendChild(t),i}}}clearMergeConflictActionCache(){for(const{element:n}of this.conflictActionCache.values())n.remove();this.conflictActionCache.clear()}};function ye({fileDiff:e,previousActions:n,resolvedConflictIndex:t,previousFile:i,resolution:r}){const o=n[t];if(o==null)throw new Error("rebuildFileAndActions: missing resolved action for unresolved file rebuild");const s=Ee(n,t,o,r),l=ue(e,s);return{file:Se({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function Se({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=fe(t?.contents??""),{conflict:s}=e,l=be(o,s,r),d=[...o.slice(0,s.startLineIndex),...l,...o.slice(s.endLineIndex+1)].join("");return{name:t?.name??i.name,contents:d,cacheKey:t?.cacheKey!=null?`${t.cacheKey}:mc-${n}-${r}`:void 0}}function be(e,n,t){const i=e.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),r=e.slice(n.separatorLineIndex+1,n.endLineIndex);return t==="current"?i:t==="incoming"?r:[...i,...r]}function Ee(e,n,t,i){const r=Fe(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Ne(o.conflict,r)}:o})}function Fe(e,n){const t=(e.baseMarkerLineIndex??e.separatorLineIndex)-e.startLineIndex-1,i=e.endLineIndex-e.separatorLineIndex-1;return(n==="current"?t:n==="incoming"?i:t+i)-(e.endLineIndex-e.startLineIndex+1)}function Ne(e,n){return{...e,startLineIndex:e.startLineIndex+n,startLineNumber:e.startLineNumber+n,separatorLineIndex:e.separatorLineIndex+n,separatorLineNumber:e.separatorLineNumber+n,endLineIndex:e.endLineIndex+n,endLineNumber:e.endLineNumber+n,baseMarkerLineIndex:e.baseMarkerLineIndex!=null?e.baseMarkerLineIndex+n:void 0,baseMarkerLineNumber:e.baseMarkerLineNumber!=null?e.baseMarkerLineNumber+n:void 0}}function je(e,n,t=!1){return!t&&e==null&&n!=null}function Oe(e,n,t=!1){return e==null&&n!=null&&!t}function Te(e,n){const t={...n,...e};return{...t,useTokenTransformer:ne(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Ue=typeof window>"u"?k.useEffect:k.useLayoutEffect;function $e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:r,hasConflictUtility:o,hasGutterRenderUtility:s,hasCustomHeader:l,disableWorkerPool:d}){const[{fileDiff:a,actions:f,markerRows:h},u]=k.useState(()=>{const{fileDiff:c,actions:m,markerRows:C}=b(e,n?.maxContextLines);return{fileDiff:c,actions:m,markerRows:C}}),L=H((c,m)=>{u(C=>{const{fileDiff:v,actions:F,markerRows:N}=m.resolveConflict(c.conflict.conflictIndex,c.resolution,C.fileDiff)??{};return v==null||F==null||N==null?C:{fileDiff:v,actions:F,markerRows:N}})}),A=i!==void 0,I=k.useContext(te),p=k.useRef(null),x=H(c=>{if(c!=null){if(p.current!=null)throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");p.current=new Me(q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),d?void 0:I,!0),p.current.hydrate({fileDiff:a,actions:f,markerRows:h,fileContainer:c,lineAnnotations:t,prerenderedHTML:r})}else{if(p.current==null)throw new Error("useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting");p.current.cleanUp(),p.current=null}});return Ue(()=>{if(p.current==null)return;const c=p.current,m=q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!ie(c.options,m);c.setOptions(m),c.render({fileDiff:a,actions:f,markerRows:h,lineAnnotations:t,forceRender:C}),i!==void 0&&c.setSelectedLines(i)}),{ref:x,getHoveredLine:k.useCallback(()=>p.current?.getHoveredLine(),[]),fileDiff:a,actions:f,markerRows:h,getInstance:k.useCallback(()=>p.current??void 0,[])}}function q({options:e,controlledSelection:n,onMergeConflictAction:t,hasConflictUtility:i,hasCustomHeader:r,hasGutterRenderUtility:o}){return{...e,controlledSelection:n,onMergeConflictAction:t,hunkSeparators:e?.hunkSeparators==="custom"?R:e?.hunkSeparators,mergeConflictActionsType:i||e?.mergeConflictActionsType==="custom"?R:e?.mergeConflictActionsType,renderCustomHeader:r?R:void 0,renderGutterUtility:o?R:void 0}}function Pe({file:e,options:n,lineAnnotations:t,selectedLines:i,className:r,style:o,prerenderedHTML:s,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderGutterUtility:u,renderMergeConflictUtility:L,disableWorkerPool:A=!1}){const{ref:I,getHoveredLine:p,fileDiff:x,actions:c,getInstance:m}=$e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(ce,{ref:I,className:r,style:o,children:oe(he({fileDiff:x,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderAnnotation:l,renderGutterUtility:u,lineAnnotations:t,getHoveredLine:p,actions:c,renderMergeConflictUtility:L,getInstance:m}),s)})}function He(e){return{draft:e,persistedContent:e,revision:0}}function _e(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function Be(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function We(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function dn(e){return g.jsx(re,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(Ge,{...e}):g.jsx(Ke,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function Ge({contentKey:e,value:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f}){return g.jsx(pe,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function Ke({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>He(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=ze(h);k.useEffect(()=>{s(p=>We(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=qe(h,p,x);s(C=>_e(C,m));try{await i(e.path,m)?s(C=>Be(C,m)):s(C=>C.draft===m?c:C)}finally{d(!1)}},I=async()=>{if(!(L>0||a)){f(!0);try{await r(e.path,h)}finally{f(!1)}}};return g.jsxs("div",{className:"conflict-viewer",children:[g.jsxs("div",{className:"conflict-viewer-toolbar",children:[g.jsxs("div",{children:[g.jsx("strong",{children:"Conflict resolution"}),g.jsx("span",{children:L>0?`${L} ${L===1?"pending block":"pending blocks"}`:"All blocks are resolved"})]}),g.jsx(D,{size:"sm",disabled:L>0||a,onClick:()=>{I()},children:a?"Saving…":"Mark as resolved"})]}),g.jsx(se,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx(Pe,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:conflict:${u}`},disableWorkerPool:h.length>5e5,options:{themeType:n,theme:U,diffIndicators:"classic",overflow:t,mergeConflictActionsType:"none",unsafeCSS:T},renderMergeConflictUtility:p=>g.jsxs("div",{className:"conflict-actions",children:[g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"current")},children:"Accept current"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"incoming")},children:"Accept incoming"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"both")},children:"Accept both"})]})},`${e.path}:${u}`):g.jsx(le,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function ze(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function qe(e,n,t){const i=e.match(/[^\n]*\n|[^\n]+$/g)??[],r=i.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),o=i.slice(n.separatorLineIndex+1,n.endLineIndex),s=t==="current"?r:t==="incoming"?o:[...r,...o];return[...i.slice(0,n.startLineIndex),...s,...i.slice(n.endLineIndex+1)].join("")}export{dn as default};
|
|
1
|
+
import{r as k,j as g}from"./react-rd22PHbN.js";import{t as w,a6 as E,n as Y,a7 as j,a8 as O,B as Z,d as M,E as ee,A as ne,a3 as te,_ as ie,a4 as R,a5 as oe,P as re,a as se,V as T,O as U,r as $}from"./PierreWorkerPool-BxP-s6jD.js";import{F as le}from"./File-4o4egqlz.js";import{D as V,b as P,f as ce}from"./platform-Bqt97_Jr.js";import{a as de,g as J,b as Q,F as ae,p as b,c as ue,s as fe,r as he,D as pe}from"./DiffWorkspace-DJX00otP.js";import{a as H}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-B3QJsvjR.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-BbT5H97Z.js";import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";var _=class extends de{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:V},n,t){super(void 0,n,t),this.options=e}setConflictState(e,n,t){this.pendingConflictActions=e,this.pendingMarkerRows=n,this.syncInjectedRows(e,n,t)}syncInjectedRows(e,n,t){this.injectedRows.clear();for(const i of e){const r=i!=null?J(i,t):void 0;if(i==null||r==null)continue;const o={type:"actions",hunkIndex:r.hunkIndex,lineIndex:r.lineIndex,conflictIndex:i.conflictIndex};this.addInjectedRow(o)}for(const i of n)this.addInjectedRow(i)}addInjectedRow(e){const n=`${e.hunkIndex}:${e.lineIndex}`,t=this.injectedRows.get(n);t==null?this.injectedRows.set(n,[e]):t.push(e)}renderDiff(e,n=P){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=P){return this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.asyncRender(e,n)}createPreElement(e,n){return super.createPreElement(e,n,{"data-has-merge-conflict":""})}getUnifiedLineDecoration({type:e,lineType:n}){const t=e==="change"?n==="change-deletion"?"current":"incoming":void 0;return{gutterLineType:e==="change"?"context":n,gutterProperties:B(t),contentProperties:W(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:B(t),contentProperties:W(n,t)}}getUnifiedInjectedRowsForLine=e=>{const n=this.injectedRows.get(`${e.hunkIndex}:${e.lineIndex}`);if(n==null||n.length===0)return;const{mergeConflictActionsType:t}=this.getOptionsWithDefaults(),i=[],r=[];for(const o of n){if(o.type==="actions"){i.push({content:Ce({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:G("action")});continue}(o.type==="marker-end"?r:i).push({content:me(o),gutter:G("marker",o.type)})}return{before:i.length>0?i:void 0,after:r.length>0?r:void 0}};getOptionsWithDefaults(){const e=super.getOptionsWithDefaults();return e.diffStyle="unified",e.lineDiffType="none",e.mergeConflictActionsType=this.options.mergeConflictActionsType??"default",e}};function B(e){return e!=null?{"data-merge-conflict":e}:void 0}function W(e,n){if(n!=null){if(e==="change")return n==="current"||n==="incoming"?{"data-line-type":"context","data-merge-conflict":n}:void 0;if(n==="marker-start"||n==="marker-base"||n==="marker-separator"||n==="marker-end")return{"data-merge-conflict":n}}}function G(e,n){const t=Y(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function Ce({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?xe(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Q({hunkIndex:e.hunkIndex,lineIndex:e.lineIndex,conflictIndex:e.conflictIndex}),"data-merge-conflict-action-slot":""}})),w({tagName:"div",properties:{"data-merge-conflict-actions":""},children:[w({tagName:"div",properties:{"data-merge-conflict-actions-content":""},children:i})]})}function me(e){return w({tagName:"div",properties:{"data-merge-conflict":e.type,"data-merge-conflict-marker-row":""},children:[E(e.lineText.replace(/(?:\r\n|\n|\r)$/,""))]})}function xe(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),K(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),K(),y({resolution:"both",label:"Accept both",conflictIndex:e})]}function y({resolution:e,label:n,conflictIndex:t}){return w({tagName:"button",properties:{type:"button","data-merge-conflict-action":e,"data-merge-conflict-conflict-index":`${t}`},children:[E(n)]})}function K(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function ge(e,n){return e.hunkIndex===n.hunkIndex&&e.startContentIndex===n.startContentIndex&&e.endContentIndex===n.endContentIndex&&e.currentContentIndex===n.currentContentIndex&&e.baseContentIndex===n.baseContentIndex&&e.incomingContentIndex===n.incomingContentIndex&&e.endMarkerContentIndex===n.endMarkerContentIndex&&e.conflictIndex===n.conflictIndex&&Le(e.conflict,n.conflict)}function Le(e,n){return e.conflictIndex===n.conflictIndex&&e.startLineIndex===n.startLineIndex&&e.startLineNumber===n.startLineNumber&&e.separatorLineIndex===n.separatorLineIndex&&e.separatorLineNumber===n.separatorLineNumber&&e.endLineIndex===n.endLineIndex&&e.endLineNumber===n.endLineNumber&&e.baseMarkerLineIndex===n.baseMarkerLineIndex&&e.baseMarkerLineNumber===n.baseMarkerLineNumber}function Ie(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function ve(e,n){const{resolution:t,hunkIndex:i,startContentIndex:r,endContentIndex:o,indexesToDelete:s=new Set}=n,l=e.hunks[i];if(l==null)throw console.error({diff:e,hunkIndex:i}),new Error(`resolveRegion: Invalid hunk index: ${i}`);if(r<0||o>=l.hunkContent.length||r>o)throw new Error(`resolveRegion: Invalid content range, ${r}, ${o}`);const{hunks:d,additionLines:a,deletionLines:f}=e,h={...e,hunks:[],deletionLines:[],additionLines:[],splitLineCount:0,unifiedLineCount:0,cacheKey:e.cacheKey!=null?`${e.cacheKey}:${t[0]}-${i}:${r}-${o}`:void 0},u={nextAdditionLineIndex:0,nextDeletionLineIndex:0,nextAdditionStart:1,nextDeletionStart:1,splitLineCount:0,unifiedLineCount:0},L=i===d.length-1&&o===l.hunkContent.length-1,A=!e.isPartial;for(const[p,x]of d.entries()){ke(e,h,u,j(x.deletionStart,x.deletionCount)-x.collapsedBefore,j(x.additionStart,x.additionCount)-x.collapsedBefore,x.collapsedBefore,A);const c={...x,hunkContent:[],additionStart:u.nextAdditionStart,deletionStart:u.nextDeletionStart,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex,additionCount:0,deletionCount:0,deletionLines:0,additionLines:0,splitLineStart:u.splitLineCount,unifiedLineStart:u.unifiedLineCount,splitLineCount:0,unifiedLineCount:0};for(const[m,C]of x.hunkContent.entries())if(p!==i||m<r||m>o){z(C,h,f,a);const v={...C,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex};c.hunkContent.push(v),S(v,u,c)}else if(s.has(m))c.hunkContent.push({type:"context",lines:0,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex});else if(C.type==="context"){z(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{Ae(t,C,h,f,a);const v={type:"context",lines:t==="deletions"?C.deletions:t==="additions"?C.additions:C.deletions+C.additions,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}if(p===i&&L){const m=t==="deletions"?x.noEOFCRDeletions:x.noEOFCRAdditions;c.noEOFCRAdditions=m,c.noEOFCRDeletions=m}c.additionCount===0&&(c.additionStart--,e.isPartial||c.additionLineIndex--),c.deletionCount===0&&(c.deletionStart--,e.isPartial||c.deletionLineIndex--),h.hunks.push(c)}const I=d.at(-1);if(I!=null&&!e.isPartial){const p=O(I.deletionStart,I.deletionCount),x=O(I.additionStart,I.additionCount),c=Math.min(f.length-p,a.length-x);X(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function X(e,n,t,i,r,o){for(let s=0;s<o;s++){const l=n[i+s],d=t[r+s];if(l==null||d==null)throw new Error("pushCollapsedContextLines: missing collapsed context line");e.deletionLines.push(l),e.additionLines.push(d)}}function ke(e,n,t,i,r,o,s){o<=0||(s&&(X(n,e.deletionLines,e.additionLines,i,r,o),t.nextAdditionLineIndex+=o,t.nextDeletionLineIndex+=o),t.nextAdditionStart+=o,t.nextDeletionStart+=o,t.splitLineCount+=o,t.unifiedLineCount+=o)}function z(e,n,t,i){if(e.type==="context")for(let r=0;r<e.lines;r++){const o=i[e.additionLineIndex+r];if(o==null)throw console.error({additionLines:i,content:e,i:r}),new Error("pushContentLinesToDiff: Context line does not exist");n.deletionLines.push(o),n.additionLines.push(o)}else{const r=Math.max(e.deletions,e.additions);for(let o=0;o<r;o++){if(o<e.deletions){const s=t[e.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:t,content:e,i:o}),new Error("pushContentLinesToDiff: Deletion line does not exist");n.deletionLines.push(s)}if(o<e.additions){const s=i[e.additionLineIndex+o];if(s==null)throw console.error({additionLines:i,content:e,i:o}),new Error("pushContentLinesToDiff: Addition line does not exist");n.additionLines.push(s)}}}}function Ae(e,n,t,i,r){if(e==="deletions"||e==="both")for(let o=0;o<n.deletions;o++){const s=i[n.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:i,content:n,i:o}),new Error("pushResolveLinesToDiff: Deletion line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}if(e==="additions"||e==="both")for(let o=0;o<n.additions;o++){const s=r[n.additionLineIndex+o];if(s==null)throw console.error({additionLines:r,content:n,i:o}),new Error("pushResolveLinesToDiff: Addition line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}}function S(e,n,t){e.type==="context"?(n.nextAdditionLineIndex+=e.lines,n.nextDeletionLineIndex+=e.lines,n.nextAdditionStart+=e.lines,n.nextDeletionStart+=e.lines,n.splitLineCount+=e.lines,n.unifiedLineCount+=e.lines,t.additionCount+=e.lines,t.deletionCount+=e.lines,t.splitLineCount+=e.lines,t.unifiedLineCount+=e.lines):(n.nextAdditionLineIndex+=e.additions,n.nextDeletionLineIndex+=e.deletions,n.nextAdditionStart+=e.additions,n.nextDeletionStart+=e.deletions,n.splitLineCount+=Math.max(e.deletions,e.additions),n.unifiedLineCount+=e.deletions+e.additions,t.deletionCount+=e.deletions,t.deletionLines+=e.deletions,t.additionCount+=e.additions,t.additionLines+=e.additions,t.splitLineCount+=Math.max(e.deletions,e.additions),t.unifiedLineCount+=e.deletions+e.additions)}function we(e,n,t){return ve(e,{resolution:Ie(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:Re(n)})}function Re(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let De=-1;var Me=class extends ae{options;__id=`unresolved-file:${++De}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:V},t,i=!1){super(void 0,t,i),this.options=n,this.setOptions(n)}setOptions(n){if(n!=null){if(n.onMergeConflictAction!=null&&n.onMergeConflictResolve!=null)throw new Error("UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.");this.options=n,this.hunksRenderer.setOptions(this.getHunksRendererOptions(n)),this.syncInteractionOptions()}}syncInteractionOptions(){this.interactionManager.setOptions(Z(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex,this.handleMergeConflictActionClick))}createHunksRenderer(n){return new _(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Te(n,this.options)}applyPreNodeAttributes(n,t){super.applyPreNodeAttributes(n,t,{"data-has-merge-conflict":""})}cleanUp(){this.emitPostRender(!0),this.clearMergeConflictActionCache(),this.computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0},this.conflictActions=[],super.cleanUp()}getOrComputeDiff({file:n,fileDiff:t,actions:i,markerRows:r}){const{maxContextLines:o,onMergeConflictAction:s}=this.options;e:if(s!=null){const l=t!=null;if(l!==(i!=null)||l!==(r!=null))throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together");if(t!=null&&i!=null&&r!=null){this.computedCache={file:n??this.computedCache.file,fileDiff:t,actions:i,markerRows:r};break e}else if(n!=null||this.computedCache.file!=null){if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file)&&this.computedCache.fileDiff!=null&&this.computedCache.actions!=null)throw new Error("UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.");if(n??=this.computedCache.file,n==null)throw new Error("UnresolvedFile.getOrComputeDiff: file is null, should be impossible");if(!M(n,this.computedCache.file)||this.computedCache.fileDiff==null||this.computedCache.actions==null){const d=b(n,o);this.computedCache={file:n,fileDiff:d.fileDiff,actions:d.actions,markerRows:d.markerRows}}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}else{t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}}else{if(t!=null||i!=null||r!=null)throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`");if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file))throw new Error("UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.");if(this.computedCache.file??=n,this.computedCache.fileDiff==null&&this.computedCache.file!=null){const l=b(this.computedCache.file,o);this.computedCache.fileDiff=l.fileDiff,this.computedCache.actions=l.actions,this.computedCache.markerRows=l.markerRows}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}if(!(t==null||i==null||r==null))return{fileDiff:t,actions:i,markerRows:r}}hydrate(n){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,fileContainer:l,prerenderedHTML:d,preventEmit:a=!1}=n,f=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});f!=null&&(this.hydrateElements(l,d),this.setActiveMergeConflictState(f.actions,f.markerRows),je(this.pre,f.fileDiff,this.options.collapsed)||Oe(this.headerElement,f.fileDiff,this.options.disableFileHeader)?this.render({...n,preventEmit:!0}):(this.hydrationSetup({fileDiff:f.fileDiff,lineAnnotations:s}),this.pre!=null&&this.renderMergeConflictActionSlots()),a||this.emitPostRender())}rerender(){!this.enabled||this.fileDiff==null||this.render({forceRender:!0,renderRange:this.renderRange})}render(n={}){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,preventEmit:l=!1,...d}=n,a=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});if(a==null)return!1;this.setActiveMergeConflictState(a.actions,a.markerRows);const f=super.render({...d,fileDiff:a.fileDiff,lineAnnotations:s,preventEmit:!0});return f&&(this.renderMergeConflictActionSlots(),l||this.emitPostRender()),f}resolveConflict(n,t,i=this.computedCache.fileDiff){const r=this.conflictActions[n];if(i==null||r==null)return;if(r.conflictIndex!==n)throw console.error({conflictIndex:n,action:r}),new Error("UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match");const o=we(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=ye({fileDiff:o,previousActions:this.conflictActions,resolvedConflictIndex:n,previousFile:s,resolution:t});return{file:l,fileDiff:o,actions:d,markerRows:a}}resolveConflictAndRender(n,t){const i=this.conflictActions[n];if(i==null)return;if(i.conflictIndex!==n)throw console.error({conflictIndex:n,action:i}),new Error("UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match");const r={resolution:t,conflict:i.conflict},{file:o,fileDiff:s,actions:l,markerRows:d}=this.resolveConflict(n,t)??{};o==null||s==null||l==null||d==null||(this.computedCache={file:o,fileDiff:s,actions:l,markerRows:d},this.setActiveMergeConflictState(l,d),this.workerManager!=null?this.hunksRenderer.renderDiff(s):this.render({forceRender:!0}),this.options.onMergeConflictResolve?.(o,r))}setActiveMergeConflictState(n=this.conflictActions,t=this.markerRows){this.conflictActions=n,this.markerRows=t,this.computedCache.fileDiff!=null&&this.hunksRenderer instanceof _&&this.hunksRenderer.setConflictState(this.options.mergeConflictActionsType==="none"?[]:n,t,this.computedCache.fileDiff)}handleMergeConflictActionClick=n=>{const t=this.conflictActions[n.conflictIndex];if(t==null)return;if(t.conflictIndex!==n.conflictIndex)throw console.error({conflictIndex:n.conflictIndex,action:t}),new Error("UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match");const i={resolution:n.resolution,conflict:t.conflict};if(this.options.onMergeConflictAction!=null){this.options.onMergeConflictAction(i,this);return}this.resolveConflictAndRender(n.conflictIndex,n.resolution)};renderMergeConflictActionSlots(){const{fileDiff:n}=this.computedCache;if(this.isContainerManaged||this.fileContainer==null||typeof this.options.mergeConflictActionsType!="function"||this.conflictActions.length===0||n==null){this.clearMergeConflictActionCache();return}const t=new Map(this.conflictActionCache);for(let i=0;i<this.conflictActions.length;i++){const r=this.conflictActions[i];if(r==null)continue;if(r.conflictIndex!==i)throw console.error({conflictIndex:i,action:r}),new Error("UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match");const o=J(r,n);if(o==null)continue;const s=r.conflictIndex,l=Q({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!ge(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=ee(l);h.appendChild(f),this.fileContainer.appendChild(h),a={element:h,action:r},this.conflictActionCache.set(d,a)}t.delete(d)}for(const[i,{element:r}]of t.entries())this.conflictActionCache.delete(i),r.remove()}renderMergeConflictAction(n){if(typeof this.options.mergeConflictActionsType!="function")return;const t=this.options.mergeConflictActionsType(n,this);if(t!=null){if(t instanceof HTMLElement)return t;if(typeof DocumentFragment<"u"&&t instanceof DocumentFragment){const i=document.createElement("div");return i.style.display="contents",i.appendChild(t),i}}}clearMergeConflictActionCache(){for(const{element:n}of this.conflictActionCache.values())n.remove();this.conflictActionCache.clear()}};function ye({fileDiff:e,previousActions:n,resolvedConflictIndex:t,previousFile:i,resolution:r}){const o=n[t];if(o==null)throw new Error("rebuildFileAndActions: missing resolved action for unresolved file rebuild");const s=Ee(n,t,o,r),l=ue(e,s);return{file:Se({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function Se({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=fe(t?.contents??""),{conflict:s}=e,l=be(o,s,r),d=[...o.slice(0,s.startLineIndex),...l,...o.slice(s.endLineIndex+1)].join("");return{name:t?.name??i.name,contents:d,cacheKey:t?.cacheKey!=null?`${t.cacheKey}:mc-${n}-${r}`:void 0}}function be(e,n,t){const i=e.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),r=e.slice(n.separatorLineIndex+1,n.endLineIndex);return t==="current"?i:t==="incoming"?r:[...i,...r]}function Ee(e,n,t,i){const r=Fe(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Ne(o.conflict,r)}:o})}function Fe(e,n){const t=(e.baseMarkerLineIndex??e.separatorLineIndex)-e.startLineIndex-1,i=e.endLineIndex-e.separatorLineIndex-1;return(n==="current"?t:n==="incoming"?i:t+i)-(e.endLineIndex-e.startLineIndex+1)}function Ne(e,n){return{...e,startLineIndex:e.startLineIndex+n,startLineNumber:e.startLineNumber+n,separatorLineIndex:e.separatorLineIndex+n,separatorLineNumber:e.separatorLineNumber+n,endLineIndex:e.endLineIndex+n,endLineNumber:e.endLineNumber+n,baseMarkerLineIndex:e.baseMarkerLineIndex!=null?e.baseMarkerLineIndex+n:void 0,baseMarkerLineNumber:e.baseMarkerLineNumber!=null?e.baseMarkerLineNumber+n:void 0}}function je(e,n,t=!1){return!t&&e==null&&n!=null}function Oe(e,n,t=!1){return e==null&&n!=null&&!t}function Te(e,n){const t={...n,...e};return{...t,useTokenTransformer:ne(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Ue=typeof window>"u"?k.useEffect:k.useLayoutEffect;function $e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:r,hasConflictUtility:o,hasGutterRenderUtility:s,hasCustomHeader:l,disableWorkerPool:d}){const[{fileDiff:a,actions:f,markerRows:h},u]=k.useState(()=>{const{fileDiff:c,actions:m,markerRows:C}=b(e,n?.maxContextLines);return{fileDiff:c,actions:m,markerRows:C}}),L=H((c,m)=>{u(C=>{const{fileDiff:v,actions:F,markerRows:N}=m.resolveConflict(c.conflict.conflictIndex,c.resolution,C.fileDiff)??{};return v==null||F==null||N==null?C:{fileDiff:v,actions:F,markerRows:N}})}),A=i!==void 0,I=k.useContext(te),p=k.useRef(null),x=H(c=>{if(c!=null){if(p.current!=null)throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");p.current=new Me(q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),d?void 0:I,!0),p.current.hydrate({fileDiff:a,actions:f,markerRows:h,fileContainer:c,lineAnnotations:t,prerenderedHTML:r})}else{if(p.current==null)throw new Error("useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting");p.current.cleanUp(),p.current=null}});return Ue(()=>{if(p.current==null)return;const c=p.current,m=q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!ie(c.options,m);c.setOptions(m),c.render({fileDiff:a,actions:f,markerRows:h,lineAnnotations:t,forceRender:C}),i!==void 0&&c.setSelectedLines(i)}),{ref:x,getHoveredLine:k.useCallback(()=>p.current?.getHoveredLine(),[]),fileDiff:a,actions:f,markerRows:h,getInstance:k.useCallback(()=>p.current??void 0,[])}}function q({options:e,controlledSelection:n,onMergeConflictAction:t,hasConflictUtility:i,hasCustomHeader:r,hasGutterRenderUtility:o}){return{...e,controlledSelection:n,onMergeConflictAction:t,hunkSeparators:e?.hunkSeparators==="custom"?R:e?.hunkSeparators,mergeConflictActionsType:i||e?.mergeConflictActionsType==="custom"?R:e?.mergeConflictActionsType,renderCustomHeader:r?R:void 0,renderGutterUtility:o?R:void 0}}function Pe({file:e,options:n,lineAnnotations:t,selectedLines:i,className:r,style:o,prerenderedHTML:s,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderGutterUtility:u,renderMergeConflictUtility:L,disableWorkerPool:A=!1}){const{ref:I,getHoveredLine:p,fileDiff:x,actions:c,getInstance:m}=$e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(ce,{ref:I,className:r,style:o,children:oe(he({fileDiff:x,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderAnnotation:l,renderGutterUtility:u,lineAnnotations:t,getHoveredLine:p,actions:c,renderMergeConflictUtility:L,getInstance:m}),s)})}function He(e){return{draft:e,persistedContent:e,revision:0}}function _e(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function Be(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function We(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function dn(e){return g.jsx(re,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(Ge,{...e}):g.jsx(Ke,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function Ge({contentKey:e,value:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f}){return g.jsx(pe,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function Ke({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>He(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=ze(h);k.useEffect(()=>{s(p=>We(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=qe(h,p,x);s(C=>_e(C,m));try{await i(e.path,m)?s(C=>Be(C,m)):s(C=>C.draft===m?c:C)}finally{d(!1)}},I=async()=>{if(!(L>0||a)){f(!0);try{await r(e.path,h)}finally{f(!1)}}};return g.jsxs("div",{className:"conflict-viewer",children:[g.jsxs("div",{className:"conflict-viewer-toolbar",children:[g.jsxs("div",{children:[g.jsx("strong",{children:"Conflict resolution"}),g.jsx("span",{children:L>0?`${L} ${L===1?"pending block":"pending blocks"}`:"All blocks are resolved"})]}),g.jsx(D,{size:"sm",disabled:L>0||a,onClick:()=>{I()},children:a?"Saving…":"Mark as resolved"})]}),g.jsx(se,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx(Pe,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:conflict:${u}`},disableWorkerPool:h.length>5e5,options:{themeType:n,theme:U,diffIndicators:"classic",overflow:t,mergeConflictActionsType:"none",unsafeCSS:T},renderMergeConflictUtility:p=>g.jsxs("div",{className:"conflict-actions",children:[g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"current")},children:"Accept current"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"incoming")},children:"Accept incoming"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"both")},children:"Accept both"})]})},`${e.path}:${u}`):g.jsx(le,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function ze(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function qe(e,n,t){const i=e.match(/[^\n]*\n|[^\n]+$/g)??[],r=i.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),o=i.slice(n.separatorLineIndex+1,n.endLineIndex),s=t==="current"?r:t==="incoming"?o:[...r,...o];return[...i.slice(0,n.startLineIndex),...s,...i.slice(n.endLineIndex+1)].join("")}export{dn as default};
|
package/dist/client/assets/{PierreEditBoundary-BnYZbHfi.js → PierreEditBoundary-DPtaTiUB.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BzmFkR37.js","assets/platform-Bqt97_Jr.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as l,s as E,r as f}from"./index-
|
|
2
|
+
import{_ as l,s as E,r as f}from"./index-B3QJsvjR.js";import{r as o,j as i}from"./react-rd22PHbN.js";import{E as c}from"./EditContext-CvJWfVl1.js";import{E as d}from"./edit-ready-context-D77R8XU8.js";import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";function C({enabled:s,children:a}){const[r,n]=o.useState(null);o.useEffect(()=>{if(!s||r)return;let e=!0;return l(()=>import("./index-BzmFkR37.js"),__vite__mapDeps([0,1,2])).then(t=>{e&&n(()=>t.Editor)}).catch(t=>{e&&E.error({title:"Could not load the code editor",description:t instanceof Error?t.message:"Unknown error"})}),()=>{e=!1}},[r,s]);const u=o.useCallback(e=>{if(!r)throw new Error("Pierre edit mode has not loaded.");return new r({clipboard:{readText:()=>f()},...e})},[r]);return r?i.jsx(c,{createEditor:u,children:i.jsx(d.Provider,{value:!0,children:a})}):i.jsx(d.Provider,{value:!1,children:a})}export{C as PierreEditBoundary};
|