@opentig/cli 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/bin.mjs +1 -4
  2. package/dist/chunks/{cli-ABzC6-gR.mjs → cli-BgNif2D1.mjs} +1 -1
  3. package/dist/client/assets/App-9EfSdZB8.js +74 -0
  4. package/dist/client/assets/CreatePullRequestDialog-BgVrWdkH.js +2 -0
  5. package/dist/client/assets/DiffWorkspace-Ca2ZUlVn.js +26 -0
  6. package/dist/client/assets/EditableFileViewer-85aEeMBK.js +1 -0
  7. package/dist/client/assets/File-DTtWrbYf.js +1 -0
  8. package/dist/client/assets/{FilesView-DIqPfRbv.js → FilesView-rT5hzb7y.js} +1 -1
  9. package/dist/client/assets/GitHubAvatar-EO1TD_1z.js +1 -0
  10. package/dist/client/assets/HistoryView-C4c0CqMC.js +1 -0
  11. package/dist/client/assets/{HtmlFileViewer-BsewwJtM.js → HtmlFileViewer-bL6T57PQ.js} +1 -1
  12. package/dist/client/assets/{IconEdit-CxvzMyLV.js → IconEdit-DePJMGIi.js} +1 -1
  13. package/dist/client/assets/{IconFolderPlus-1vLDIzhC.js → IconFolderPlus-ByGyA0Di.js} +1 -1
  14. package/dist/client/assets/{ImageFileViewer-CoQZkgET.js → ImageFileViewer-DJaHH3hJ.js} +1 -1
  15. package/dist/client/assets/{LocalRefsDialog-sw-ROjfe.js → LocalRefsDialog-D9wYZWBg.js} +1 -1
  16. package/dist/client/assets/MarkdownFileViewer-BNPb9v8u.js +2 -0
  17. package/dist/client/assets/{PairingPage-CYJXzBZC.js → PairingPage-D9oguvKU.js} +1 -1
  18. package/dist/client/assets/PierreDiffViewer-8wTLYd5-.js +1 -0
  19. package/dist/client/assets/{PierreEditBoundary-Bb4dONIq.js → PierreEditBoundary-KzU3HDc2.js} +2 -2
  20. package/dist/client/assets/{PierreWorkerPool-BuBzE8K1.js → PierreWorkerPool-DH2jp9oe.js} +18 -18
  21. package/dist/client/assets/{PullRequestDiff-CgY4QIHC.js → PullRequestDiff-DK-m07ZP.js} +1 -1
  22. package/dist/client/assets/PullRequestViewer-CpLwq4o2.js +2 -0
  23. package/dist/client/assets/PullRequestsView-DnvXaJ4t.js +1 -0
  24. package/dist/client/assets/{QuickOpenDialog-Cn-aQRAS.js → QuickOpenDialog-DIWjfUkt.js} +1 -1
  25. package/dist/client/assets/RepositoryProjectsDialog-BsQn5Yjr.js +1 -0
  26. package/dist/client/assets/{SearchView-BtKBEJ7e.js → SearchView-D-91dtSv.js} +1 -1
  27. package/dist/client/assets/SettingsDialog-dJUYk2cP.js +9 -0
  28. package/dist/client/assets/Viewer-GH-5bJW4.js +3 -0
  29. package/dist/client/assets/{abnfDiagram-N423BO3Z-DLBLFOdy.js → abnfDiagram-N423BO3Z-CkHOGdAl.js} +1 -1
  30. package/dist/client/assets/{arc-D-Yei3Vr.js → arc-Dj8F8CO5.js} +1 -1
  31. package/dist/client/assets/{architectureDiagram-T3A2C74G-BOgBvzWh.js → architectureDiagram-T3A2C74G-g87Y5LXk.js} +1 -1
  32. package/dist/client/assets/base-ui-DT3JsyND.js +1 -0
  33. package/dist/client/assets/{blockDiagram-VBNYF7ZC-BQXRJDyR.js → blockDiagram-VBNYF7ZC-D6efB7jD.js} +1 -1
  34. package/dist/client/assets/{c4Diagram-5PPSVZJV-DTZseD56.js → c4Diagram-5PPSVZJV-DoZEC2xg.js} +1 -1
  35. package/dist/client/assets/channel-Dsy2VD23.js +1 -0
  36. package/dist/client/assets/{checkbox-BwbxYGgK.js → checkbox-DYwmgDPS.js} +1 -1
  37. package/dist/client/assets/{chunk-2GRJ4B5K-spRCgfPY.js → chunk-2GRJ4B5K-Dr44hDNV.js} +1 -1
  38. package/dist/client/assets/{chunk-2Q5K7J3B-CLVClH0M.js → chunk-2Q5K7J3B-YIEyVOOL.js} +1 -1
  39. package/dist/client/assets/{chunk-5RXB4S5H-CuQ5tYjB.js → chunk-5RXB4S5H-gjmGBtkE.js} +1 -1
  40. package/dist/client/assets/{chunk-5VM5RSS4-DyOEOe90.js → chunk-5VM5RSS4-DCOQko4g.js} +1 -1
  41. package/dist/client/assets/{chunk-6Q2QTUOP-CgMtuJIx.js → chunk-6Q2QTUOP-DfGlvPVm.js} +1 -1
  42. package/dist/client/assets/{chunk-GF5L2VYU-BH63P4Vv.js → chunk-GF5L2VYU-CCWOLPVL.js} +1 -1
  43. package/dist/client/assets/{chunk-JWPE2WC7-BANDbaPq.js → chunk-JWPE2WC7-CFRTGh8r.js} +1 -1
  44. package/dist/client/assets/{chunk-KBJHAD2P-Bfty2upo.js → chunk-KBJHAD2P-By3wsJVD.js} +1 -1
  45. package/dist/client/assets/{chunk-RYQCIY6F-Cvu8BZS9.js → chunk-RYQCIY6F-C0wmsHmy.js} +1 -1
  46. package/dist/client/assets/{chunk-XXDRQBXY-bnohf1yd.js → chunk-XXDRQBXY-t3SnJvV_.js} +1 -1
  47. package/dist/client/assets/classDiagram-JCYQIIEL-BBQJgoWd.js +1 -0
  48. package/dist/client/assets/classDiagram-v2-OCEON4UE-BBQJgoWd.js +1 -0
  49. package/dist/client/assets/{vb-D17OF-Vu.js → cmd-BW5THilD.js} +1 -1
  50. package/dist/client/assets/{cose-bilkent-JH36ORCC-DCTEAZwO.js → cose-bilkent-JH36ORCC-D3VltoVk.js} +1 -1
  51. package/dist/client/assets/{cynefin-VYW2F7L2-Bp2wXvdt.js → cynefin-VYW2F7L2-DwLwbeoe.js} +1 -1
  52. package/dist/client/assets/{cynefinDiagram-MW4NZA55-DRRWzuF0.js → cynefinDiagram-MW4NZA55-B23kuaQF.js} +1 -1
  53. package/dist/client/assets/{dagre-VZM6K2ZE-DDvsotRK.js → dagre-VZM6K2ZE-SgMrTr2p.js} +1 -1
  54. package/dist/client/assets/{diagram-7IWD3JNH-CMqhRNRq.js → diagram-7IWD3JNH-C7cQN4aD.js} +1 -1
  55. package/dist/client/assets/{diagram-B4RE2ZJO-D_PYI1ut.js → diagram-B4RE2ZJO-CzeI3yOw.js} +1 -1
  56. package/dist/client/assets/{diagram-LBJQPF4R-BSUx7mMM.js → diagram-LBJQPF4R-DhKm4hlI.js} +1 -1
  57. package/dist/client/assets/{diagram-Q27KOJAE-C8O3g6WT.js → diagram-Q27KOJAE-BXlU6Wp3.js} +1 -1
  58. package/dist/client/assets/{diagram-UB23O5K3-C5-NDsgC.js → diagram-UB23O5K3-BOwY_YwR.js} +1 -1
  59. package/dist/client/assets/{ebnfDiagram-BXEA7PRR-D71hx4Ww.js → ebnfDiagram-BXEA7PRR-CuIQuYPa.js} +1 -1
  60. package/dist/client/assets/{erDiagram-JOGREHBK-yd9B5d8I.js → erDiagram-JOGREHBK-d45NhKfk.js} +1 -1
  61. package/dist/client/assets/{flowDiagram-UKHOOZJN-CWU5VVbw.js → flowDiagram-UKHOOZJN-Dzq-6qo7.js} +1 -1
  62. package/dist/client/assets/{ganttDiagram-PKOTCBZU-D2siVjfa.js → ganttDiagram-PKOTCBZU-RVlL9mX2.js} +1 -1
  63. package/dist/client/assets/{gh-utils-B0Nlmxep.js → gh-utils-LsOSydCg.js} +1 -1
  64. package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-CIvIFcxR.js → gitGraphDiagram-DS77QQ5N-8kEJVUFH.js} +1 -1
  65. package/dist/client/assets/{index-DDbUjVD9.js → index-BzmFkR37.js} +1 -1
  66. package/dist/client/assets/{index-BOPi2b1j.js → index-CQcx9aRt.js} +4 -4
  67. package/dist/client/assets/index-DMbFAH51.css +1 -0
  68. package/dist/client/assets/{infoDiagram-6WML65LV-DRvl8KfO.js → infoDiagram-6WML65LV-Co21Ql9M.js} +1 -1
  69. package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-H5EQq6uE.js → ishikawaDiagram-WSZJBQD7-BvPB_G97.js} +1 -1
  70. package/dist/client/assets/{journeyDiagram-NVQOT4AX-CCwLmD-U.js → journeyDiagram-NVQOT4AX-k7x89IE9.js} +1 -1
  71. package/dist/client/assets/{kanban-definition-27J2QSJJ-DS--XHEu.js → kanban-definition-27J2QSJJ-BjrgN30t.js} +1 -1
  72. package/dist/client/assets/{linear-Q3JNM6CR.js → linear-m158kske.js} +1 -1
  73. package/dist/client/assets/{mermaid.core-EwS_m22C.js → mermaid.core-C0FKucv-.js} +4 -4
  74. package/dist/client/assets/{mindmap-definition-FAOFIHXS-D15nrwfe.js → mindmap-definition-FAOFIHXS-CF8noycK.js} +1 -1
  75. package/dist/client/assets/{pegDiagram-VL7TDLO6-DOG19gxx.js → pegDiagram-VL7TDLO6-_y7nfJFV.js} +1 -1
  76. package/dist/client/assets/{pieDiagram-7S7Q4E2Y-Bstdr7Wh.js → pieDiagram-7S7Q4E2Y-DhdWHi45.js} +1 -1
  77. package/dist/client/assets/{platform-BMNQ8V5r.js → platform-Bqt97_Jr.js} +2 -2
  78. package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-DfKs4qZW.js → quadrantDiagram-CIZ2JOQS-BRvEIECQ.js} +1 -1
  79. package/dist/client/assets/{railroadDiagram-AXF67PYL-DJKxyuhV.js → railroadDiagram-AXF67PYL-BgLZ8XU1.js} +1 -1
  80. package/dist/client/assets/render-markdown-2GjhuGA-.js +280 -0
  81. package/dist/client/assets/repository-grammars-ixqpb0uW.js +1 -0
  82. package/dist/client/assets/{requirementDiagram-LRYGKXZP-SGJWVmBV.js → requirementDiagram-LRYGKXZP-CX-gxyGF.js} +1 -1
  83. package/dist/client/assets/{sankeyDiagram-W5VNT64P-CpZFct0O.js → sankeyDiagram-W5VNT64P-CLSjSU_X.js} +1 -1
  84. package/dist/client/assets/{sequenceDiagram-SI44F4Z6-B7plRik9.js → sequenceDiagram-SI44F4Z6-dGlHyZRB.js} +1 -1
  85. package/dist/client/assets/{sizeCapture-X5ZJPWSS-CNbK285t.js → sizeCapture-X5ZJPWSS-BH3qO9T3.js} +1 -1
  86. package/dist/client/assets/{stateDiagram-OKZ733FA-BIHk9QCC.js → stateDiagram-OKZ733FA-FXxo1iIM.js} +1 -1
  87. package/dist/client/assets/stateDiagram-v2-UEYNNEHI-DqxQ14yP.js +1 -0
  88. package/dist/client/assets/{swimlanes-SLNWSIFB-7g_XCosC.js → swimlanes-SLNWSIFB-VJGIuM4S.js} +2 -2
  89. package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-No0dCAkd.js +8 -0
  90. package/dist/client/assets/{tanstack-B8_amOz8.js → tanstack-CtfgE41X.js} +1 -1
  91. package/dist/client/assets/{timeline-definition-Z64GVDOM-B-cgSggY.js → timeline-definition-Z64GVDOM-BXNTAanY.js} +1 -1
  92. package/dist/client/assets/{vennDiagram-T6HMQDX7-Bt5-8VZ2.js → vennDiagram-T6HMQDX7-D9nXAts5.js} +1 -1
  93. package/dist/client/assets/{viewer-tabs-DxCOe0ut.js → viewer-tabs-DkLmDzFg.js} +1 -1
  94. package/dist/client/assets/{wardleyDiagram-T6FBY63Y-B5Imx6zh.js → wardleyDiagram-T6FBY63Y-D89EaEfa.js} +1 -1
  95. package/dist/client/assets/{xychartDiagram-ELKLHX3M-CDaY4xFS.js → xychartDiagram-ELKLHX3M-B_xFDiIh.js} +1 -1
  96. package/dist/client/index.html +4 -4
  97. package/dist/dev.mjs +1 -4
  98. package/dist/manifest.json +1 -1
  99. package/dist/server.mjs +791 -2553
  100. package/dist/utility.mjs +0 -3
  101. package/package.json +1 -1
  102. package/dist/client/assets/App-CBetJ5ZN.js +0 -74
  103. package/dist/client/assets/CreatePullRequestDialog-W82oHjYm.js +0 -2
  104. package/dist/client/assets/DiffWorkspace-BWkTIl5n.js +0 -26
  105. package/dist/client/assets/EditableFileViewer-Cv3aNJBN.js +0 -1
  106. package/dist/client/assets/File-DiOOsHOl.js +0 -1
  107. package/dist/client/assets/GitHubAvatar-DBc3Vxnk.js +0 -1
  108. package/dist/client/assets/HistoryView-DYxWYYVx.js +0 -1
  109. package/dist/client/assets/MarkdownFileViewer-BedKCXTI.js +0 -2
  110. package/dist/client/assets/PierreDiffViewer-uhTsb-F7.js +0 -1
  111. package/dist/client/assets/PullRequestViewer-KZl0osME.js +0 -2
  112. package/dist/client/assets/PullRequestsView-DkN3pW33.js +0 -1
  113. package/dist/client/assets/RepositoryProjectsDialog-F-EctLXx.js +0 -1
  114. package/dist/client/assets/SettingsDialog-wfWhEzZY.js +0 -9
  115. package/dist/client/assets/Viewer-D-oFua7K.js +0 -3
  116. package/dist/client/assets/base-ui-qeHDA5zu.js +0 -1
  117. package/dist/client/assets/channel-DrMuSkDK.js +0 -1
  118. package/dist/client/assets/classDiagram-JCYQIIEL-BKiL0hkR.js +0 -1
  119. package/dist/client/assets/classDiagram-v2-OCEON4UE-BKiL0hkR.js +0 -1
  120. package/dist/client/assets/index-CryuKDT3.css +0 -1
  121. package/dist/client/assets/render-markdown-C7X2TwRk.js +0 -280
  122. package/dist/client/assets/stateDiagram-v2-UEYNNEHI-Cqw0H5cq.js +0 -1
  123. package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-BzKpdiGK.js +0 -8
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-EwS_m22C.js","assets/index-BOPi2b1j.js","assets/react-rd22PHbN.js","assets/tanstack-B8_amOz8.js","assets/base-ui-qeHDA5zu.js","assets/index-CryuKDT3.css","assets/render-markdown-C7X2TwRk.js","assets/App-CBetJ5ZN.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
2
- import{r as t,j as e,a as oe}from"./react-rd22PHbN.js";import{c as B,_ as ae,w as se,s as ie,e as le,T as H,a as U,b as z}from"./index-BOPi2b1j.js";import{G as ce}from"./App-CBetJ5ZN.js";import{V as ue,a as de,b as K}from"./viewer-tabs-DxCOe0ut.js";import{u as pe,s as me,F as fe,S as he}from"./EditableFileViewer-Cv3aNJBN.js";import{r as we}from"./render-markdown-C7X2TwRk.js";/* empty css */import"./tanstack-B8_amOz8.js";import"./base-ui-qeHDA5zu.js";import"./PierreWorkerPool-BuBzE8K1.js";import"./platform-BMNQ8V5r.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-DiOOsHOl.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";const ge=[["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"}]],ve=B("outline","viewport-narrow","ViewportNarrow",ge);const be=[["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"}]],ke=B("outline","viewport-wide","ViewportWide",be);function q(o,f){const l=f.trim();if(!l||l.startsWith("#")||l.startsWith("//")||/^[a-z][a-z\d+.-]*:/i.test(l))return null;const u=l.split(/[?#]/,1)[0];if(!u)return null;let p;try{p=decodeURIComponent(u).replaceAll("\\","/")}catch{return null}const d=p.startsWith("/")?[]:o.replaceAll("\\","/").split("/").slice(0,-1).filter(Boolean);for(const a of p.split("/"))if(!(!a||a===".")){if(a===".."){if(d.length===0)return null;d.pop();continue}if(Ce(a))return null;d.push(a)}return d.length>0?d.join("/"):null}function Ce(o){return[...o].some(f=>f.charCodeAt(0)<32||f.charCodeAt(0)===127)}let ye=0;function G(){return document.documentElement.classList.contains("dark")?"dark":"default"}function xe(o,f,l){const[u,p]=t.useState(G);t.useEffect(()=>{const a=new MutationObserver(()=>p(G()));return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]);const d=t.useCallback(async a=>{if(!o.current)return;const h=Array.from(o.current.querySelectorAll(".mermaid"));if(h.length!==0)try{const{default:c}=await ae(async()=>{const{default:i}=await import("./mermaid.core-EwS_m22C.js").then(m=>m.bo);return{default:i}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(a()||!o.current)return;c.initialize({startOnLoad:!1,theme:u,securityLevel:"strict"});for(const i of h){const m=i.dataset.mermaidSource;if(m){i.removeAttribute("data-mermaid-error");try{const T=decodeURIComponent(m),y=`mermaid-diagram-${ye++}`,{svg:R,bindFunctions:b}=await c.render(y,T,i);if(a()||!i.isConnected)return;i.innerHTML=R,i.dataset.processed="true",b?.(i)}catch{!a()&&i.isConnected&&(i.textContent=decodeURIComponent(m),i.dataset.mermaidError="Could not render diagram")}}}}catch{for(const c of h)!a()&&c.isConnected&&(c.dataset.mermaidError="Could not load Mermaid")}},[f,o,u]);t.useEffect(()=>{let a=!1;return d(()=>a),()=>{a=!0}},[l,d])}const X="opentig:markdown-content-width",$=/^([a-z][a-z0-9+.-]*:)?\/\//i,Te={conflictTitle:"Markdown was changed outside OpenTig",successTitle:"Markdown saved",errorTitle:"Could not save Markdown"};function Me(){try{return window.localStorage.getItem(X)==="fit"?"fit":"reading"}catch{return"reading"}}function Se({html:o,onClick:f,onLinkHover:l}){const u=t.useRef(null),p=t.useRef(null);t.useLayoutEffect(()=>{u.current&&(u.current.innerHTML=o),p.current=null,l(null)},[o,l]),xe(u,!0,o);const d=t.useCallback(h=>{const c=h.target.closest("a[href]");!c||c===p.current||(p.current=c,l(c))},[l]),a=t.useCallback(h=>{const c=p.current;if(!c)return;const i=h.relatedTarget;i&&c.contains(i)||(p.current=null,l(null))},[l]);return e.jsx("div",{ref:u,className:"markdown-prose",onClick:f,onMouseOver:d,onMouseOut:a})}function Ke({file:o,initialContent:f,revision:l,themeType:u,wrapLines:p,readOnly:d,onOpenFile:a,onDirtyChange:h,onDraftChange:c,onSave:i}){const[m,T]=t.useState("preview"),[y,R]=t.useState(Me),[b,I]=t.useState(""),[_,F]=t.useState(!0),[Y,V]=t.useState(!1),[x,g]=t.useState(null),M=t.useRef(0),k=t.useRef(null),N=t.useRef(null),A=t.useRef(null),C=t.useRef(null),S=t.useRef(null),{draft:P,updateDraft:J,dirty:j,saving:O,save:Q}=pe({file:o,initialContent:f,readOnly:d,messages:Te,onDirtyChange:h,onDraftChange:c,onSave:i});t.useEffect(()=>{S.current?.(),C.current=null,T("preview")},[o.path]);const Z=t.useCallback(n=>{if(n!==m){if(S.current?.(),m==="preview"){const r=N.current,s=r?r.scrollHeight-r.clientHeight:0;C.current=r&&s>0?r.scrollTop/s:0}else C.current=A.current?.getScrollFraction()??0;T(n)}},[m]);t.useLayoutEffect(()=>{const n=C.current;if(n==null)return;if(m==="code"){C.current=null,A.current?.scrollToFraction(n);return}const r=N.current;!r||_&&!b||(C.current=null,S.current=me({getScrollRange:()=>Math.max(0,r.scrollHeight-r.clientHeight),getScrollTop:()=>r.scrollTop,getContentHeight:()=>r.scrollHeight,scrollTo:s=>{r.scrollTop=s}},n))},[b,_,m]),t.useEffect(()=>()=>S.current?.(),[]),t.useEffect(()=>{const n=++M.current;F(!0);const r=window.setTimeout(()=>{const s=window.__opentigPerformanceAutomation?performance.now():null;we(P).then(w=>{n===M.current&&(I(w),s!==null&&(window.__opentigPerformanceResults??=[],window.__opentigPerformanceResults.push({kind:"markdown-render",durationMs:Math.round((performance.now()-s)*100)/100})))}).catch(()=>{n===M.current&&I("<p>Could not render Markdown.</p>")}).finally(()=>{n===M.current&&F(!1)})},j?120:0);return()=>window.clearTimeout(r)},[j,P,o.mtimeMs,o.path,l,u]),t.useEffect(()=>()=>{k.current&&window.clearTimeout(k.current.timer)},[]);const ee=t.useCallback(async n=>{const r=n.target,s=r.closest("[data-copy-code]");if(s){const W=s.dataset.copyCode;if(!W)return;try{const re=decodeURIComponent(W);await se(re);const E=k.current;E&&(window.clearTimeout(E.timer),delete E.button.dataset.copyState,E.button.setAttribute("aria-label","Copy code")),s.dataset.copyState="copied",s.setAttribute("aria-label","Copied"),V(!0);const ne=window.setTimeout(()=>{k.current?.button===s&&(delete s.dataset.copyState,s.setAttribute("aria-label","Copy code"),k.current=null,V(!1))},2e3);k.current={button:s,timer:ne}}catch{ie.error({title:"Could not copy code"})}return}const w=r.closest("a[href]"),v=w?.getAttribute("href");if(!w||!v)return;if(n.preventDefault(),v.startsWith("#")){n.currentTarget.querySelector(`#${CSS.escape(v.slice(1))}`)?.scrollIntoView({behavior:"smooth",block:"start"});return}if($.test(v)||v.startsWith("mailto:")){try{le(v)}catch{}return}const D=q(o.path,v);D&&a(D)},[o.path,a]),te=t.useCallback(n=>{if(!n){g(null);return}const r=n.getAttribute("href");if(!r||r.startsWith("#")){g(null);return}const s=n.getBoundingClientRect(),w={top:s.bottom+6,left:s.left};if(r.startsWith("mailto:")){g({...w,label:"Open in mail app",href:r.replace(/^mailto:/,"")});return}if($.test(r)){g({...w,label:"Open in browser",href:r});return}if(q(o.path,r)){g({...w,label:"Open file",href:r});return}g(null)},[o.path]),L=n=>{R(n);try{window.localStorage.setItem(X,n)}catch{}};return e.jsxs(ue,{value:m,onValueChange:n=>Z(n),className:"markdown-viewer","data-content-width":y,children:[e.jsxs("div",{className:"file-viewer-pill markdown-viewer-toolbar",children:[e.jsx(de,{label:"Markdown view",className:"file-viewer-tabs markdown-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:e.jsxs(e.Fragment,{children:["Code ",j&&e.jsx("span",{className:"markdown-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),e.jsx(fe,{dirty:j,saving:O,readOnly:d,onSave:()=>{Q()}}),e.jsxs("div",{className:"markdown-width-toggle",role:"group","aria-label":"Markdown content width",children:[e.jsxs(H,{children:[e.jsx(U,{render:e.jsx("button",{type:"button","aria-label":"Reading width","aria-pressed":y==="reading",onClick:()=>L("reading")}),children:e.jsx(ve,{"aria-hidden":"true"})}),e.jsx(z,{children:"Reading width"})]}),e.jsxs(H,{children:[e.jsx(U,{render:e.jsx("button",{type:"button","aria-label":"Fit to width","aria-pressed":y==="fit",onClick:()=>L("fit")}),children:e.jsx(ke,{"aria-hidden":"true"})}),e.jsx(z,{children:"Fit to width"})]})]})]}),e.jsxs(K,{ref:N,value:"preview",className:"markdown-preview-scroll",onScroll:()=>g(null),children:[_&&!b?e.jsx("div",{className:"viewer-message",children:e.jsx(ce,{text:"Rendering Markdown…"})}):e.jsx(Se,{html:b,onClick:n=>{ee(n)},onLinkHover:te}),e.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:Y?"Code copied":""}),x?oe.createPortal(e.jsxs("div",{className:"markdown-link-tooltip",style:{top:x.top,left:x.left},role:"tooltip",children:[e.jsx("span",{className:"markdown-link-tooltip-label",children:x.label}),e.jsx("span",{className:"markdown-link-tooltip-href",children:x.href})]}),document.body):null]}),e.jsx(K,{value:"code",className:"markdown-code-view","data-theme":u,children:e.jsx(he,{ref:A,path:o.path,cacheKey:o.path,value:P,themeType:u,wrapLines:p,readOnly:d||O,onChange:J})})]})}export{Ke as MarkdownFileViewer};
@@ -1 +0,0 @@
1
- import{r as k,j as g}from"./react-rd22PHbN.js";import{q as w,a5 as E,m as Q,a6 as j,a7 as O,A as X,d as M,D as Y,z as ee,a2 as ne,Z as te,a3 as R,a4 as ie,P as oe,a as re,V as T,O as U}from"./PierreWorkerPool-BuBzE8K1.js";import{F as se}from"./File-DiOOsHOl.js";import{D as q,b as $,f as le}from"./platform-BMNQ8V5r.js";import{a as ce,g as V,b as Z,F as de,p as b,c as ae,s as ue,r as fe,D as he}from"./DiffWorkspace-BWkTIl5n.js";import{a as P}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-BOPi2b1j.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-CBetJ5ZN.js";import"./tanstack-B8_amOz8.js";import"./base-ui-qeHDA5zu.js";var H=class extends ce{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:q},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?V(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=$){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=$){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:_(t),contentProperties:B(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:_(t),contentProperties:B(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:pe({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:W("action")});continue}(o.type==="marker-end"?r:i).push({content:Ce(o),gutter:W("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 _(e){return e!=null?{"data-merge-conflict":e}:void 0}function B(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 W(e,n){const t=Q(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function pe({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?me(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Z({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 Ce(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 me(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),z(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),z(),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 z(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function xe(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&&ge(e.conflict,n.conflict)}function ge(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 Le(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function Ie(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()){ve(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){G(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"){G(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{ke(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);J(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function J(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 ve(e,n,t,i,r,o,s){o<=0||(s&&(J(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 G(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 ke(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 Ae(e,n,t){return Ie(e,{resolution:Le(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:we(n)})}function we(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let Re=-1;var De=class extends de{options;__id=`unresolved-file:${++Re}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:q},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(X(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 H(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Oe(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),Ne(this.pre,f.fileDiff,this.options.collapsed)||je(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=Ae(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=Me({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 H&&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=V(r,n);if(o==null)continue;const s=r.conflictIndex,l=Z({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!xe(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=Y(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 Me({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=be(n,t,o,r),l=ae(e,s);return{file:ye({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function ye({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=ue(t?.contents??""),{conflict:s}=e,l=Se(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 Se(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 be(e,n,t,i){const r=Ee(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Fe(o.conflict,r)}:o})}function Ee(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 Fe(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 Ne(e,n,t=!1){return!t&&e==null&&n!=null}function je(e,n,t=!1){return e==null&&n!=null&&!t}function Oe(e,n){const t={...n,...e};return{...t,useTokenTransformer:ee(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Te=typeof window>"u"?k.useEffect:k.useLayoutEffect;function Ue({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=P((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(ne),p=k.useRef(null),x=P(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 De(K({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 Te(()=>{if(p.current==null)return;const c=p.current,m=K({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!te(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 K({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 $e({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}=Ue({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(le,{ref:I,className:r,style:o,children:ie(fe({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 Pe(e){return{draft:e,persistedContent:e,revision:0}}function He(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function _e(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function Be(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function cn(e){return g.jsx(oe,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(We,{...e}):g.jsx(ze,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function We({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(he,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function ze({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>Pe(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=Ge(h);k.useEffect(()=>{s(p=>Be(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=Ke(h,p,x);s(C=>He(C,m));try{await i(e.path,m)?s(C=>_e(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(re,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx($e,{file:{name: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(se,{file:{name:e.path,contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function Ge(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function Ke(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{cn as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PullRequestDiff-CgY4QIHC.js","assets/react-rd22PHbN.js","assets/tanstack-B8_amOz8.js","assets/base-ui-qeHDA5zu.js","assets/index-BOPi2b1j.js","assets/index-CryuKDT3.css","assets/App-CBetJ5ZN.js","assets/DiffWorkspace-BWkTIl5n.js","assets/PierreWorkerPool-BuBzE8K1.js","assets/platform-BMNQ8V5r.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-CtEztN1P.js","assets/EditContext-CvJWfVl1.js","assets/render-markdown-C7X2TwRk.js"])))=>i.map(i=>d[i]);
2
- import{c as D,B as C,T as S,a as H,b as F,_ as R,o as k,q as T}from"./index-BOPi2b1j.js";import{r as j,j as e}from"./react-rd22PHbN.js";import{u as q}from"./tanstack-B8_amOz8.js";import{l as V,k as h,G as p,B as I,h as M,t as $,z as O}from"./App-CBetJ5ZN.js";import{V as B,a as z,b as x}from"./viewer-tabs-DxCOe0ut.js";import{p as K,r as Q,o as U}from"./gh-utils-B0Nlmxep.js";import{G as _,I as X,a as J,b as W}from"./GitHubAvatar-DBc3Vxnk.js";/* empty css */import"./base-ui-qeHDA5zu.js";const Y=[["path",{d:"M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3",key:"svg-1"}]],Z=D("outline","tag","Tag",Y),ee=j.lazy(()=>R(()=>import("./PullRequestDiff-CgY4QIHC.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function me({repositoryId:r,prNumber:i,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:o,onClose:P}){const[v,E]=j.useState("summary"),t=q({queryKey:T.pullRequest(r,i),queryFn:async()=>{const a=await k.github.getPullRequest(r,i),A=a.body.trim()?await R(async()=>{const{renderMarkdown:u}=await import("./render-markdown-C7X2TwRk.js").then(G=>G.a);return{renderMarkdown:u}},__vite__mapDeps([14,6,4,1,2,3,5,10,11])).then(({renderMarkdown:u})=>u(a.body)).catch(()=>"<p>Could not render the description.</p>"):"";return{details:a,bodyHtml:A}}}),s=t.data?.details??null,f=t.data?.bodyHtml??"",N=t.error instanceof Error?t.error.message:t.error?"Could not load the pull request.":null,c=q({queryKey:T.pullRequestDiff(r,i),queryFn:()=>k.github.getPullRequestDiff(r,i),enabled:v==="diff"&&s!==null}),b=c.data??null,g=c.error instanceof Error?c.error.message:c.error?"Could not load the diff.":null;if(N)return e.jsxs("div",{className:"viewer-message flex-col gap-3",children:[e.jsx("p",{className:"text-destructive",children:N}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{t.refetch()},children:[e.jsx(V,{})," Try again"]})]});if(!s)return e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:`Loading pull request #${i}…`})]});const w=K(s),y=Q(s.reviewDecision);return e.jsxs(B,{value:v,onValueChange:a=>E(a),className:"pr-viewer",children:[e.jsxs("header",{className:"pr-viewer-header",children:[e.jsxs("div",{className:"pr-viewer-overview",children:[e.jsxs("div",{className:"pr-viewer-title",children:[e.jsx(I,{variant:s.state==="OPEN"&&!s.isDraft?"default":"secondary",className:`pr-state-badge ${w.toLowerCase().replace(/\s+/g,"-")}`,children:w}),e.jsxs("h2",{children:[s.title||"(no title)"," ",e.jsxs("span",{className:"pr-number",children:["#",s.number]})]})]}),e.jsxs("div",{className:"pr-viewer-meta",children:[e.jsxs("span",{className:"pr-author-with-avatar",children:[e.jsx(_,{src:s.authorAvatarUrl,className:"pr-author-avatar"},s.authorAvatarUrl),e.jsx("span",{className:"pr-author",children:s.author})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:["updated ",L(s.updatedAt)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-branches",children:[e.jsx(M,{"aria-hidden":"true"})," ",s.headRefName," → ",s.baseRefName]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-counters",children:[s.changedFiles," ",s.changedFiles===1?"file":"files"," ",e.jsxs("span",{className:"add",children:["+",s.additions]})," ",e.jsxs("span",{className:"del",children:["−",s.deletions]})]}),e.jsx(se,{state:s.checksState}),y&&e.jsx(I,{variant:"outline",className:"pr-review-badge",children:y}),e.jsx("span",{className:"pr-viewer-actions",children:e.jsxs(C,{variant:"outline",size:"xs",onClick:()=>U(s.url),children:[e.jsx($,{})," Open on GitHub"]})})]}),s.labels.length>0&&e.jsxs("div",{className:"pr-labels","aria-label":"Pull request labels",children:[e.jsx(Z,{"aria-hidden":"true"}),s.labels.map(a=>e.jsx("span",{className:"pr-label",style:{borderColor:`#${a.color}`,backgroundColor:`#${a.color}22`},children:a.name},`${a.name}-${a.color}`))]})]}),e.jsx(z,{label:"Pull request view",className:"markdown-viewer-tabs pr-viewer-tabs",items:[{value:"summary",label:"Summary"},{value:"timeline",label:"Timeline"},{value:"diff",label:"Code"}]})]}),e.jsx(x,{value:"summary",className:"markdown-preview-scroll pr-description-scroll",children:e.jsx("section",{className:"pr-summary-section",children:f?e.jsx("div",{className:"markdown-prose",dangerouslySetInnerHTML:{__html:f}}):e.jsx("p",{className:"pr-empty-description",children:"This pull request has no description."})})}),e.jsx(x,{value:"timeline",className:"markdown-preview-scroll pr-description-scroll",children:e.jsxs("section",{className:"pr-timeline standalone","aria-label":"Commit timeline",children:[e.jsxs("h3",{children:[e.jsx(O,{"aria-hidden":"true"})," Commits ",e.jsx("span",{children:s.commits.length})]}),s.commits.length?s.commits.map(a=>e.jsxs("article",{className:"pr-timeline-item",children:[e.jsx("span",{className:"pr-timeline-rail",children:e.jsx("span",{})}),e.jsx(_,{src:a.authorAvatarUrl,className:"pr-commit-avatar"}),e.jsxs("span",{className:"pr-commit-content",children:[e.jsx("strong",{children:a.messageHeadline||"(no commit message)"}),e.jsxs("span",{children:[e.jsx("b",{children:a.author})," committed ",L(a.authoredAt)]})]}),e.jsxs(S,{children:[e.jsx(H,{render:e.jsx("code",{}),children:a.oid.slice(0,7)}),e.jsx(F,{children:a.oid})]})]},a.oid)):e.jsx("p",{className:"pr-empty-description",children:"No commits were returned by GitHub."})]})}),e.jsx(x,{value:"diff",className:"pr-diff-panel",children:g?e.jsx("div",{className:"viewer-message text-destructive",children:g}):b?e.jsx(j.Suspense,{fallback:e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:"Loading diff viewer…"})]}),children:e.jsx(ee,{diff:b,prNumber:s.number,repositoryId:r,commits:s.commits,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:o,onClose:P})}):e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:"Loading diff…"})]})})]})}function se({state:r}){if(r==="NONE")return null;const i=r==="PASSING"?X:r==="FAILING"?J:W,n=r==="PASSING"?"Checks passing":r==="FAILING"?"Checks failing":"Checks pending";return e.jsxs("span",{className:`pr-checks ${r.toLowerCase()}`,children:[e.jsx(i,{"aria-hidden":"true"})," ",n]})}function L(r){const i=Date.parse(r);if(!Number.isFinite(i))return r;const n=Math.round((i-Date.now())/1e3),d=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]],l=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});for(const[m,o]of d)if(Math.abs(n)>=o)return l.format(Math.round(n/o),m);return l.format(n,"second")}export{me as PullRequestViewer};
@@ -1 +0,0 @@
1
- import{j as e,r as b}from"./react-rd22PHbN.js";import{a as p}from"./tanstack-B8_amOz8.js";import{c as N,B as t,I as f,T as c,a as o,b as u}from"./index-BOPi2b1j.js";import{C as k}from"./checkbox-BwbxYGgK.js";import{k as h,G as x,l as j,a1 as I,T as y,t as S}from"./App-CBetJ5ZN.js";import{o as w}from"./gh-utils-B0Nlmxep.js";import{G,I as P,a as R,b as E}from"./GitHubAvatar-DBc3Vxnk.js";import{P as L,i as O,j as T,k as D,l as M}from"./base-ui-qeHDA5zu.js";const z=[["path",{d:"M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5",key:"svg-0"}]],d=N("outline","brand-github","BrandGithub",z);const q=[["path",{d:"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227",key:"svg-0"}]],$=N("outline","filter","Filter",q);const A=[["path",{d:"M5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M15 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M7 8l0 8",key:"svg-3"}],["path",{d:"M7 8a4 4 0 0 0 4 4h4",key:"svg-4"}]],H=N("outline","git-merge","GitMerge",A);function ae(s){return s.info===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Checking repository…"})]}):s.info.isGitHub?s.ghStatus===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Checking GitHub CLI…"})]}):s.ghStatus.installed?s.ghStatus.authStatus==="unauthenticated"?e.jsxs(m,{icon:e.jsx(d,{}),title:"Sign in to GitHub CLI",children:["Run ",e.jsx("code",{children:"gh auth login"})," in a terminal to authenticate, then check again.",e.jsxs("span",{className:"pulls-notice-actions",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>s.onCopyCommand("gh auth login"),children:[e.jsx(f,{})," Copy command"]}),e.jsxs(t,{variant:"ghost",size:"sm",onClick:s.onRefresh,children:[e.jsx(j,{})," Check again"]})]})]}):e.jsx(F,{...s,nameWithOwner:s.info.nameWithOwner??""}):e.jsxs(m,{icon:e.jsx(d,{}),title:"GitHub CLI is required",children:["OpenTig uses your local ",e.jsx("code",{children:"gh"})," session to read and create pull requests. It does not copy or store credentials.",e.jsxs("span",{className:"pulls-notice-actions",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>s.onCopyCommand("winget install GitHub.cli"),children:[e.jsx(f,{})," Copy install command"]}),e.jsxs(t,{variant:"ghost",size:"sm",onClick:s.onRefresh,children:[e.jsx(j,{})," Check again"]})]}),e.jsx("small",{children:"Download from cli.github.com, then check again."})]}):e.jsxs(m,{icon:e.jsx(d,{}),title:"Not a GitHub repository",children:["The ",e.jsx("code",{children:"origin"})," remote does not point to github.com, so pull requests are unavailable here."]})}function F(s){const l=b.useRef(null),n=s.pulls,i=p({count:n?.length??0,getScrollElement:()=>l.current,estimateSize:()=>68,getItemKey:a=>n?.[a]?.number??a,overscan:8});return e.jsxs("div",{className:"pulls-view",children:[e.jsxs("div",{className:"pulls-toolbar",children:[e.jsxs(c,{children:[e.jsxs(o,{render:e.jsx("span",{className:"pulls-repo"}),children:[e.jsx(d,{"aria-hidden":"true"})," ",s.nameWithOwner]}),e.jsx(u,{children:s.nameWithOwner})]}),e.jsxs(c,{children:[e.jsx(o,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button",disabled:s.loading,onClick:s.onRefresh,"aria-label":"Refresh pull requests"}),children:s.loading?e.jsx(h,{className:"animate-spin"}):e.jsx(j,{})}),e.jsx(u,{children:"Refresh pull requests"})]}),e.jsxs(L,{children:[e.jsx(O,{render:e.jsx(t,{variant:v(s.states)?"ghost":"secondary",size:"icon-xs",className:"change-action-button","aria-label":"Filter pull requests","aria-pressed":!v(s.states)}),children:e.jsx($,{})}),e.jsx(T,{children:e.jsx(D,{side:"bottom",align:"end",sideOffset:4,className:"isolate z-50 outline-none",children:e.jsxs(M,{className:"pulls-filter-popup",children:[e.jsx("span",{className:"pulls-filter-title",children:"State"}),["OPEN","CLOSED","MERGED"].map(a=>e.jsxs("label",{htmlFor:`pulls-state-${a.toLowerCase()}`,className:"pulls-filter-option",children:[e.jsx(k,{id:`pulls-state-${a.toLowerCase()}`,checked:s.states.includes(a),onCheckedChange:r=>s.onStateChange(a,r===!0)}),e.jsx(C,{state:a,className:a.toLowerCase()}),e.jsx("span",{children:a==="OPEN"?"Open":a==="CLOSED"?"Closed":"Merged"})]},a))]})})})]}),e.jsxs(c,{children:[e.jsxs(o,{render:e.jsx(t,{variant:"outline",size:"xs",disabled:!!s.createDisabledReason||s.loading,onClick:s.onCreate,"aria-label":"Create pull request"}),children:[e.jsx(I,{})," New"]}),e.jsx(u,{children:s.createDisabledReason??"Create a pull request from the current branch"})]})]}),s.error&&e.jsxs("div",{className:"pulls-error",role:"alert",children:[e.jsx("span",{children:s.error}),e.jsx(t,{variant:"ghost",size:"xs",onClick:s.onRefresh,children:"Retry"})]}),e.jsx("div",{ref:l,className:"pulls-scroll",role:"list","aria-label":`${s.states.map(g).join(", ")||"No"} pull requests`,children:n===null&&!s.error?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Loading pull requests…"})]}):n!==null&&n.length===0?e.jsx("p",{className:"empty-list",children:s.states.length?`No ${s.states.map(a=>g(a).toLowerCase()).join(", ")} pull requests.`:"Select at least one PR state."}):n!==null&&e.jsx("div",{className:"virtual-list",style:{height:i.getTotalSize()},children:i.getVirtualItems().map(a=>{const r=n[a.index];return e.jsx("div",{ref:i.measureElement,"data-index":a.index,className:"virtual-row",style:{transform:`translateY(${a.start}px)`},children:e.jsx(_,{pr:r,active:s.activeNumber===r.number,onSelect:s.onSelect})},a.key)})})})]})}function _({pr:s,active:l,onSelect:n}){const i=s.state.toLowerCase(),a=W(s.updatedAt);return e.jsxs("div",{className:`pull-item ${l?"active":""}`,role:"listitem",children:[e.jsxs("button",{className:"pull-main",onClick:()=>n(s),"aria-label":`View pull request #${s.number}`,children:[e.jsx("span",{className:`pull-state-icon ${i}${s.isDraft?" draft":""}`,"aria-label":s.isDraft?"Draft":g(s.state),children:e.jsx(C,{state:s.state})}),e.jsxs("span",{className:"pull-content",children:[e.jsx("span",{className:"pull-title",children:s.title||"(no title)"}),e.jsxs("span",{className:"pull-meta",children:[e.jsxs("span",{className:"pull-number",children:["#",s.number]}),e.jsx(G,{src:s.authorAvatarUrl,className:"pull-avatar"}),e.jsx("span",{className:"pull-author",children:s.author}),e.jsx(V,{state:s.checksState}),s.isDraft&&e.jsx("span",{className:"pull-draft-label",children:"Draft"})]})]}),e.jsxs("span",{className:"pull-row-aside",children:[a&&e.jsx("span",{children:a}),e.jsxs("span",{className:"pull-line-stats",children:[e.jsxs("span",{className:"add",children:["+",s.additions]})," ",e.jsxs("span",{className:"del",children:["−",s.deletions]})]})]})]}),e.jsxs(c,{children:[e.jsx(o,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button pull-open-external",onClick:()=>w(s.url),"aria-label":`Open #${s.number} on GitHub`}),children:e.jsx(S,{})}),e.jsx(u,{children:"Open on GitHub"})]})]})}function C({state:s,className:l}){return s==="MERGED"?e.jsx(H,{"aria-hidden":"true",className:l}):e.jsx(y,{"aria-hidden":"true",className:l})}function V({state:s}){if(s==="NONE")return null;const l=s==="PASSING"?"Checks passing":s==="FAILING"?"Checks failing":"Checks pending",n=s==="PASSING"?P:s==="FAILING"?R:E;return e.jsx("span",{className:`pull-checks ${s.toLowerCase()}`,"aria-label":l,children:e.jsx(n,{"aria-hidden":"true"})})}function g(s){return s==="OPEN"?"Open":s==="CLOSED"?"Closed":"Merged"}function v(s){return s.length===1&&s[0]==="OPEN"}function m({icon:s,title:l,children:n}){return e.jsxs("div",{className:"pulls-notice",children:[e.jsx("span",{className:"pulls-notice-icon","aria-hidden":"true",children:s}),e.jsx("strong",{children:l}),e.jsx("p",{children:n})]})}const B=new Intl.RelativeTimeFormat("en",{numeric:"auto"}),U=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]];function W(s){const l=new Date(s);if(Number.isNaN(l.getTime()))return null;const n=Math.round((l.getTime()-Date.now())/1e3);for(const[i,a]of U)if(Math.abs(n)>=a)return B.format(Math.trunc(n/a),i);return"right now"}export{ae as PullRequestsView};
@@ -1 +0,0 @@
1
- import{r as o,j as e}from"./react-rd22PHbN.js";import{D as Z,c as q,d as Q,e as ee,g as I,I as se,m as k,Z as P,k as z,_,y as E,$ as ne,S as ae,C as ie,A as re,E as oe,F as O,a0 as te}from"./App-CBetJ5ZN.js";import{c as M,B as r,T as w,a as C,b as R,o as h}from"./index-BOPi2b1j.js";import{I as le}from"./IconFolderPlus-1vLDIzhC.js";import"./tanstack-B8_amOz8.js";import"./base-ui-qeHDA5zu.js";const ce=[["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"}]],de=M("outline","folder-symlink","FolderSymlink",ce);const me=[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]],he=M("outline","pencil","Pencil",me),B="__opentig_no_project__";function ve({open:l,projects:c,repositories:v,onOpenChange:L,onOrganizationChange:A,onForgetRepository:G,onRelocateRepository:S}){const[J,u]=o.useState(null),[x,f]=o.useState(null),[N,D]=o.useState(""),[g,d]=o.useState(null),[b,T]=o.useState(""),[K,p]=o.useState(null),[n,y]=o.useState(null),[$,m]=o.useState(null),V=o.useMemo(()=>new Map(c.flatMap(s=>s.repositoryKeys.map(a=>[a,s.id]))),[c]);o.useEffect(()=>{l||(u(null),f(null),d(null),p(null),m(null))},[l]);const j=async(s,a)=>{y(s),m(null);try{const t=await a();return A(t),!0}catch(t){return m(F(t)),!1}finally{y(null)}},W=async s=>{s.preventDefault();const a=N.trim();!a||n||await j("create",()=>h.projects.create(a))&&D("")},X=async s=>{s.preventDefault();const a=b.trim();!g||!a||n||await j(`rename:${g}`,()=>h.projects.rename(g,a))&&d(null)},H=async s=>{n||await j(`remove:${s}`,()=>h.projects.remove(s))&&p(null)},U=async(s,a)=>{n||await j(`assign:${s}`,()=>h.projects.assign(s,a))},Y=async s=>{if(!n){if(m(null),!window.opentigDesktop){f(s);return}y(`relocate:${s.key}`);try{const a=await h.repository.select(`Relocate ${s.name}`);a&&await S(s,a)}catch(a){m(F(a))}finally{y(null)}}};return e.jsxs(Z,{open:l,onOpenChange:s=>{n||L(s)},children:[e.jsxs(q,{className:"repository-projects-dialog w-[min(660px,calc(100vw-2.5rem))]",children:[e.jsxs("header",{className:"repository-projects-header",children:[e.jsxs("div",{children:[e.jsx(Q,{children:"Manage projects"}),e.jsx(ee,{children:"Group repositories, update their locations, or remove them from OpenTig. Files stay on disk."})]}),e.jsx(I,{render:e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":"Close project management",disabled:!!n}),children:e.jsx(se,{})})]}),e.jsxs("div",{className:"repository-projects-body",children:[$&&e.jsxs("div",{className:"repository-projects-error",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsx("span",{children:$})]}),e.jsxs("section",{className:"repository-projects-section","aria-labelledby":"projects-heading",children:[e.jsxs("div",{className:"repository-projects-section-heading",children:[e.jsxs("h3",{id:"projects-heading",children:["Projects ",e.jsx("span",{children:c.length})]}),e.jsxs("form",{className:"repository-project-create",onSubmit:s=>{W(s)},children:[e.jsx("label",{className:"sr-only",htmlFor:"new-project-name",children:"Project name"}),e.jsx("input",{id:"new-project-name",value:N,maxLength:P,onChange:s=>D(s.target.value),placeholder:"New project name",disabled:!!n}),e.jsxs(r,{type:"submit",size:"sm",disabled:!N.trim()||!!n,children:[n==="create"?e.jsx(z,{className:"animate-spin"}):e.jsx(le,{})," Create"]})]})]}),e.jsxs("div",{className:"repository-project-list",children:[c.length===0&&e.jsx("p",{className:"repository-projects-empty",children:"No projects yet. Create one to group related repositories."}),c.map(s=>{const a=s.repositoryKeys.length,t=n===`rename:${s.id}`||n===`remove:${s.id}`;return e.jsx("div",{className:"repository-project-row","aria-busy":t||void 0,children:g===s.id?e.jsxs("form",{className:"repository-inline-form",onSubmit:i=>{X(i)},onKeyDown:i=>{i.key==="Escape"&&d(null)},children:[e.jsxs("label",{className:"sr-only",htmlFor:`rename-project-${s.id}`,children:["Rename ",s.name]}),e.jsx("input",{id:`rename-project-${s.id}`,autoFocus:!0,value:b,maxLength:P,onChange:i=>T(i.target.value),disabled:!!n}),e.jsx(r,{type:"submit",size:"xs",disabled:!b.trim()||!!n,children:"Save"}),e.jsx(r,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(null),disabled:!!n,children:"Cancel"})]}):K===s.id?e.jsxs("div",{className:"repository-project-confirm",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsxs("span",{children:["Delete ",e.jsx("strong",{children:s.name}),"? Its repositories stay available, just ungrouped."]}),e.jsx(r,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{H(s.id)},children:"Delete"}),e.jsx(r,{variant:"ghost",size:"xs",disabled:!!n,onClick:()=>p(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"repository-project-icon","aria-hidden":"true",children:e.jsx(_,{})}),e.jsxs("span",{className:"repository-project-copy",children:[e.jsx("strong",{children:s.name}),e.jsxs("small",{children:[a," ",a===1?"repository":"repositories"]})]}),e.jsxs("span",{className:"repository-row-actions",children:[e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${s.name}`,disabled:!!n,onClick:()=>{d(s.id),T(s.name),p(null)},children:e.jsx(he,{})}),e.jsx(r,{variant:"ghost",size:"icon-sm",className:"repository-row-delete","aria-label":`Delete ${s.name}`,disabled:!!n,onClick:()=>{p(s.id),d(null)},children:e.jsx(E,{})})]})]})},s.id)})]})]}),e.jsxs("section",{className:"repository-projects-section","aria-labelledby":"repository-assignments-heading",children:[e.jsxs("div",{className:"repository-projects-section-heading",children:[e.jsxs("h3",{id:"repository-assignments-heading",children:["Repositories ",e.jsx("span",{children:v.length})]}),e.jsx("p",{children:"One project per repository"})]}),e.jsxs("div",{className:"repository-assignment-list",children:[v.length===0&&e.jsx("p",{className:"repository-projects-empty",children:"No recent repositories to assign yet."}),v.map(s=>{const a=V.get(s.key)??B,t=n?.endsWith(`:${s.key}`);return e.jsx("div",{className:"repository-assignment-row","aria-busy":t||void 0,children:J===s.key?e.jsxs("div",{className:"repository-project-confirm",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsxs("span",{children:["Remove ",e.jsx("strong",{children:s.name})," and its worktrees from OpenTig? Their folders and files stay on disk. You can open them again later."]}),e.jsx(r,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{j(`forget:${s.key}`,()=>G(s)).then(i=>{i&&u(null)})},children:"Remove"}),e.jsx(r,{variant:"ghost",size:"xs",disabled:!!n,onClick:()=>u(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx(_,{"aria-hidden":"true"}),e.jsxs("span",{className:"repository-assignment-copy",children:[e.jsx("strong",{children:s.name}),e.jsxs(w,{children:[e.jsx(C,{render:e.jsx("small",{}),children:ne(s.rootPath,4)}),e.jsx(R,{children:s.rootPath})]})]}),t&&e.jsx(z,{className:"repository-assignment-busy animate-spin","aria-hidden":"true"}),e.jsxs(ae,{value:a,onValueChange:i=>{U(s.key,i===B?null:i)},disabled:!!n,children:[e.jsx(ie,{size:"sm","aria-label":`Project for ${s.name}`,children:e.jsx(re,{children:c.find(i=>i.id===a)?.name??"No project"})}),e.jsxs(oe,{align:"end",alignItemWithTrigger:!1,children:[e.jsx(O,{value:B,children:"No project"}),c.map(i=>e.jsx(O,{value:i.id,children:i.name},i.id))]})]}),e.jsxs("span",{className:"repository-management-actions",children:[e.jsxs(w,{children:[e.jsx(C,{render:e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":`Relocate ${s.name}`,disabled:!!n,onClick:()=>{Y(s)}}),children:e.jsx(de,{})}),e.jsx(R,{children:"Relocate repository"})]}),e.jsxs(w,{children:[e.jsx(C,{render:e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${s.name} from OpenTig`,disabled:!!n,onClick:()=>{u(s.key),m(null)}}),children:e.jsx(E,{})}),e.jsx(R,{children:"Remove from OpenTig"})]})]})]})},s.key)})]})]})]}),e.jsx("footer",{className:"repository-projects-footer",children:e.jsx(I,{render:e.jsx(r,{variant:"outline",size:"sm",disabled:!!n}),children:"Done"})})]}),e.jsx(te,{open:x!==null,onOpenChange:s=>{s||f(null)},title:"Relocate repository",description:`Choose the existing server folder for ${x?.name??"this repository"}. This updates its saved location; it does not move files.`,confirmLabel:"Use this folder",onBrowse:h.repository.browseDirectories,onOpen:async s=>{x&&await S(x,s)}})]})}function F(l){return l instanceof Error?l.message:String(l)}export{ve as RepositoryProjectsDialog};
@@ -1,9 +0,0 @@
1
- import{r as m,j as e}from"./react-rd22PHbN.js";import{M as Ns,i as fe,u as Ye,g as qe,h as Cs,j as Ms,L as Ss,k as Es,l as Rs,p as As,c as O,d as ee,o as te,s as N,B as w,T as F,a as z,b as _,I as Oe,w as Le,m as Pe}from"./index-BOPi2b1j.js";import{D as H,c as V,d as W,e as K,k as q,l as ge,y as Ce,g as Y,I as Me,G as Se,B as Q,ax as Is,ay as xe,az as $e,P as Xe,aA as Je,aB as Ze,aC as Ts,aD as Fe,aE as Os,aF as Ls,m as Ee,S as re,C as oe,A as le,E as ce,aG as Ps,F as de,aH as $s,i as Fs,aI as zs,aJ as _s,aK as Ds,aL as Bs,W as Us,aM as je,aN as Gs}from"./App-CBetJ5ZN.js";import{b as Qe,t as es,c as ss,r as ts,d as ns}from"./tanstack-B8_amOz8.js";import{I as Hs}from"./IconEdit-CxvzMyLV.js";import"./base-ui-qeHDA5zu.js";function ze(s,t){if(typeof s=="function")return s(t);s!=null&&(s.current=t)}function Vs(...s){return t=>{let n=!1;const a=s.map(i=>{const r=ze(i,t);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<a.length;i++){const r=a[i];typeof r=="function"?r():ze(s[i],null)}}}}function Ws(...s){return m.useCallback(Vs(...s),s)}class Ks extends m.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(fe(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const a=n.offsetParent,i=fe(a)&&a.offsetWidth||0,r=fe(a)&&a.offsetHeight||0,o=getComputedStyle(n),c=this.props.sizeRef.current;c.height=parseFloat(o.height),c.width=parseFloat(o.width),c.top=n.offsetTop,c.left=n.offsetLeft,c.right=i-c.width-c.left,c.bottom=r-c.height-c.top,c.direction=o.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Ys({children:s,isPresent:t,anchorX:n,anchorY:a,root:i,pop:r}){const o=m.useId(),c=m.useRef(null),h=m.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:f}=m.useContext(Ns),p=r!==!1?s.props?.ref??s?.ref:void 0,u=Ws(c,p);return m.useInsertionEffect(()=>{const{width:l,height:x,top:j,left:v,right:y,bottom:M,direction:S}=h.current;if(t||r===!1||!c.current||!l||!x)return;const I=S==="rtl",C=n==="left"?I?`right: ${y}`:`left: ${v}`:I?`left: ${v}`:`right: ${y}`,E=a==="bottom"?`bottom: ${M}`:`top: ${j}`;c.current.dataset.motionPopId=o;const R=document.createElement("style");f&&(R.nonce=f);const L=i??document.head;return L.appendChild(R),R.sheet&&R.sheet.insertRule(`
2
- [data-motion-pop-id="${o}"] {
3
- position: absolute !important;
4
- width: ${l}px !important;
5
- height: ${x}px !important;
6
- ${C}px !important;
7
- ${E}px !important;
8
- }
9
- `),()=>{c.current?.removeAttribute("data-motion-pop-id"),L.contains(R)&&L.removeChild(R)}},[t]),e.jsx(Ks,{isPresent:t,childRef:c,sizeRef:h,pop:r,children:r===!1?s:m.cloneElement(s,{ref:u})})}const qs=({children:s,initial:t,isPresent:n,onExitComplete:a,custom:i,presenceAffectsLayout:r,mode:o,anchorX:c,anchorY:h,root:f})=>{const p=Ye(Xs),u=m.useId(),l=m.useRef(n),x=m.useRef(a);qe(()=>{l.current=n,x.current=a});let j=!0,v=m.useMemo(()=>(j=!1,{id:u,initial:t,isPresent:n,custom:i,onExitComplete:y=>{p.set(y,!0);for(const M of p.values())if(!M)return;a&&a()},register:y=>(p.set(y,!1),()=>{p.delete(y),!l.current&&!p.size&&x.current?.()})}),[n,p,a]);return r&&j&&(v={...v}),m.useMemo(()=>{p.forEach((y,M)=>p.set(M,!1))},[n]),m.useEffect(()=>{!n&&!p.size&&a&&a()},[n]),s=e.jsx(Ys,{pop:o==="popLayout",isPresent:n,anchorX:c,anchorY:h,root:f,children:s}),e.jsx(Cs.Provider,{value:v,children:s})};function Xs(){return new Map}const ne=s=>s.key||"";function _e(s){const t=[];return m.Children.forEach(s,n=>{m.isValidElement(n)&&t.push(n)}),t}const De=({children:s,custom:t,initial:n=!0,onExitComplete:a,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:c="left",anchorY:h="top",root:f})=>{const[p,u]=Ms(o),l=m.useMemo(()=>_e(s),[s]),x=o&&!p?[]:l.map(ne),j=m.useRef(!0),v=m.useRef(l),y=Ye(()=>new Map),M=m.useRef(new Set),[S,I]=m.useState(l),[C,E]=m.useState(l);qe(()=>{j.current=!1,v.current=l;for(let A=0;A<C.length;A++){const d=ne(C[A]);x.includes(d)?(y.delete(d),M.current.delete(d)):y.get(d)!==!0&&y.set(d,!1)}},[C,x.length,x.join("-")]);const R=[];if(l!==S){let A=[...l];for(let d=0;d<C.length;d++){const b=C[d],k=ne(b);x.includes(k)||(A.splice(d,0,b),R.push(b))}return r==="wait"&&R.length&&(A=R),E(_e(A)),I(l),null}const{forceRender:L}=m.useContext(Ss);return e.jsx(e.Fragment,{children:C.map(A=>{const d=ne(A),b=o&&!p?!1:l===C||x.includes(d),k=()=>{if(M.current.has(d))return;if(y.has(d))M.current.add(d),y.set(d,!0);else return;let X=!0;y.forEach(me=>{me||(X=!1)}),X&&(L?.(),E(v.current),o&&u?.(),a&&a())};return e.jsx(qs,{isPresent:b,initial:!j.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:r,root:f,onExitComplete:b?void 0:k,anchorX:c,anchorY:h,children:A},d)})})};function Js(){!Es.current&&Rs();const[s]=m.useState(As.current);return s}const Zs=[["path",{d:"M3 9l4 -4l4 4m-4 -4v14",key:"svg-0"}],["path",{d:"M21 15l-4 4l-4 -4m4 4v-14",key:"svg-1"}]],as=O("outline","arrows-sort","ArrowsSort",Zs);const Qs=[["path",{d:"M4 8h16",key:"svg-0"}],["path",{d:"M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12",key:"svg-1"}],["path",{d:"M8 4v4",key:"svg-2"}]],et=O("outline","browser","Browser",Qs);const st=[["path",{d:"M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10",key:"svg-0"}],["path",{d:"M7 20h10",key:"svg-1"}],["path",{d:"M9 16v4",key:"svg-2"}],["path",{d:"M15 16v4",key:"svg-3"}]],is=O("outline","device-desktop","DeviceDesktop",st);const tt=[["path",{d:"M2 8a2 2 0 0 1 2 -2h16a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-16a2 2 0 0 1 -2 -2l0 -8",key:"svg-0"}],["path",{d:"M6 10l0 .01",key:"svg-1"}],["path",{d:"M10 10l0 .01",key:"svg-2"}],["path",{d:"M14 10l0 .01",key:"svg-3"}],["path",{d:"M18 10l0 .01",key:"svg-4"}],["path",{d:"M6 14l0 .01",key:"svg-5"}],["path",{d:"M18 14l0 .01",key:"svg-6"}],["path",{d:"M10 14l4 .01",key:"svg-7"}]],nt=O("outline","keyboard","Keyboard",tt);const at=[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]],it=O("outline","link","Link",at);const rt=[["path",{d:"M9 6l11 0",key:"svg-0"}],["path",{d:"M9 12l11 0",key:"svg-1"}],["path",{d:"M9 18l11 0",key:"svg-2"}],["path",{d:"M5 6l0 .01",key:"svg-3"}],["path",{d:"M5 12l0 .01",key:"svg-4"}],["path",{d:"M5 18l0 .01",key:"svg-5"}]],ot=O("outline","list","List",rt);const lt=[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454l0 .008",key:"svg-0"}]],ct=O("outline","moon","Moon",lt);const dt=[["path",{d:"M6 9a6 6 0 1 0 12 0a6 6 0 0 0 -12 0",key:"svg-0"}],["path",{d:"M12 3c1.333 .333 2 2.333 2 6s-.667 5.667 -2 6",key:"svg-1"}],["path",{d:"M12 3c-1.333 .333 -2 2.333 -2 6s.667 5.667 2 6",key:"svg-2"}],["path",{d:"M6 9h12",key:"svg-3"}],["path",{d:"M3 20h7",key:"svg-4"}],["path",{d:"M14 20h7",key:"svg-5"}],["path",{d:"M10 20a2 2 0 1 0 4 0a2 2 0 0 0 -4 0",key:"svg-6"}],["path",{d:"M12 15v3",key:"svg-7"}]],ht=O("outline","network","Network",dt);const ut=[["path",{d:"M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-0"}],["path",{d:"M7 17l0 .01",key:"svg-1"}],["path",{d:"M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-2"}],["path",{d:"M7 7l0 .01",key:"svg-3"}],["path",{d:"M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-4"}],["path",{d:"M17 7l0 .01",key:"svg-5"}],["path",{d:"M14 14l3 0",key:"svg-6"}],["path",{d:"M20 14l0 .01",key:"svg-7"}],["path",{d:"M14 14l0 3",key:"svg-8"}],["path",{d:"M14 20l3 0",key:"svg-9"}],["path",{d:"M17 17l3 0",key:"svg-10"}],["path",{d:"M20 17l0 3",key:"svg-11"}]],gt=O("outline","qrcode","Qrcode",ut);const mt=[["path",{d:"M12 3a12 12 0 0 0 8.5 3a12 12 0 0 1 -8.5 15a12 12 0 0 1 -8.5 -15a12 12 0 0 0 8.5 -3",key:"svg-0"}],["path",{d:"M11 11a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 12l0 2.5",key:"svg-2"}]],Be=O("outline","shield-lock","ShieldLock",mt);const pt=[["path",{d:"M4 6l7 0",key:"svg-0"}],["path",{d:"M4 12l7 0",key:"svg-1"}],["path",{d:"M4 18l9 0",key:"svg-2"}],["path",{d:"M15 9l3 -3l3 3",key:"svg-3"}],["path",{d:"M18 6l0 12",key:"svg-4"}]],rs=O("outline","sort-ascending","SortAscending",pt);const ft=[["path",{d:"M4 6l9 0",key:"svg-0"}],["path",{d:"M4 12l7 0",key:"svg-1"}],["path",{d:"M4 18l7 0",key:"svg-2"}],["path",{d:"M15 15l3 3l3 -3",key:"svg-3"}],["path",{d:"M18 6l0 12",key:"svg-4"}]],os=O("outline","sort-descending","SortDescending",ft);const xt=[["path",{d:"M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6",key:"svg-0"}]],jt=O("outline","sparkles","Sparkles",xt);const vt=[["path",{d:"M8 12a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]],bt=O("outline","sun","Sun",vt);function ls({className:s,...t}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full",children:e.jsx("table",{"data-slot":"table",className:ee("w-full caption-bottom text-xs",s),...t})})}function cs({className:s,...t}){return e.jsx("thead",{"data-slot":"table-header",className:ee("[&_tr]:border-b",s),...t})}function ds({className:s,...t}){return e.jsx("tbody",{"data-slot":"table-body",className:ee("[&_tr:last-child]:border-0",s),...t})}function ue({className:s,...t}){return e.jsx("tr",{"data-slot":"table-row",className:ee("border-b border-border transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",s),...t})}function hs({className:s,...t}){return e.jsx("th",{"data-slot":"table-head",className:ee("h-8 whitespace-nowrap px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...t})}function us({className:s,...t}){return e.jsx("td",{"data-slot":"table-cell",className:ee("px-2 py-1.5 align-middle [&:has([role=checkbox])]:pr-0",s),...t})}const yt={"commit-message":"commit message","pull-request-draft":"pull request draft"};function B({column:s,label:t}){const n=s.getIsSorted();return e.jsxs("button",{type:"button",className:"ai-log-sort-button",onClick:()=>s.toggleSorting(n==="asc"),children:[t,n==="asc"&&e.jsx(rs,{size:13}),n==="desc"&&e.jsx(os,{size:13}),!n&&e.jsx(as,{size:13,className:"ai-log-sort-idle"})]})}const wt=es({rowSortingFeature:ts,sortedRowModel:ns()}),P=ss(),kt=P.columns([P.accessor("status",{header:({column:s})=>e.jsx(B,{column:s,label:"Status"}),cell:({getValue:s})=>{const t=s();return e.jsx(Q,{variant:t==="success"?"secondary":t==="cancelled"?"outline":"destructive",children:t})}}),P.accessor("harness",{header:({column:s})=>e.jsx(B,{column:s,label:"Harness"}),cell:({getValue:s})=>e.jsx("strong",{children:s()})}),P.accessor("model",{header:({column:s})=>e.jsx(B,{column:s,label:"Model"}),cell:({getValue:s})=>e.jsx("span",{className:"ai-log-model",children:s()})}),P.accessor("operation",{header:({column:s})=>e.jsx(B,{column:s,label:"Task"}),cell:({getValue:s})=>yt[s()]}),P.accessor(s=>new Date(s.at).getTime(),{id:"at",header:({column:s})=>e.jsx(B,{column:s,label:"Date"}),cell:({row:s})=>e.jsx("time",{dateTime:s.original.at,children:new Date(s.original.at).toLocaleString()})}),P.accessor("durationMs",{header:({column:s})=>e.jsx(B,{column:s,label:"Duration"}),cell:({getValue:s})=>`${(s()/1e3).toFixed(1)}s`}),P.accessor(s=>(s.usage.inputTokens??0)+(s.usage.outputTokens??0),{id:"usage",header:({column:s})=>e.jsx(B,{column:s,label:"Usage"}),cell:({row:s})=>Mt(s.original)}),P.accessor("stagedFileCount",{header:({column:s})=>e.jsx(B,{column:s,label:"Staged"}),cell:({getValue:s})=>s()??"—"}),P.display({id:"notes",header:"Notes",cell:({row:s})=>{const t=s.original,n=[];return t.errorCode&&n.push({key:"error",text:t.errorCode,tone:"error"}),t.errorMessage&&n.push({key:"error-message",text:t.errorMessage,tone:"error",detail:t.errorMessage}),t.splitOffered===!0&&n.push({key:"split",text:`split: ${t.splitGroups} commits`}),t.splitRejectedReason&&n.push({key:"rejected",text:`split refused: ${t.splitRejectedReason}`,tone:"warn",detail:t.splitRejectedReason}),t.splitBlockedReason&&n.push({key:"blocked",text:`no split: ${t.splitBlockedReason}`,detail:t.splitBlockedReason}),t.contextTruncated===!0&&n.push({key:"truncated",text:"context trimmed"}),n.length===0?null:e.jsx("div",{className:"ai-log-row-notes",children:n.map(a=>e.jsx(Ct,{text:a.text,tone:a.tone,detail:a.detail},a.key))})}})]);function Nt({open:s,onOpenChange:t}){const[n,a]=m.useState([]),[i,r]=m.useState(!1),[o,c]=m.useState([]),h=m.useCallback(async()=>{r(!0);try{a(await te.ai.log())}catch(l){N.error({title:"Could not read the AI history",description:Ge(l)})}finally{r(!1)}},[]);m.useEffect(()=>{s&&h()},[h,s]);const f=m.useMemo(()=>{const l=n.filter(x=>x.status==="failed").length;return{runs:n.length,failed:l,tokens:n.reduce((x,j)=>x+(j.usage.inputTokens??0)+(j.usage.outputTokens??0),0),cost:n.reduce((x,j)=>x+(j.usage.costUsd??0),0),costed:n.filter(x=>x.usage.costUsd!==null).length}},[n]),p=Qe({features:wt,data:n,columns:kt,onSortingChange:c,state:{sorting:o}}),u=async()=>{if(window.confirm("Delete the whole AI history? This cannot be undone."))try{await te.ai.clearLog(),a([])}catch(l){N.error({title:"Could not clear the AI history",description:Ge(l)})}};return e.jsx(H,{open:s,onOpenChange:t,children:e.jsxs(V,{className:"ai-log-dialog",children:[e.jsxs("header",{className:"ai-log-header",children:[e.jsxs("div",{children:[e.jsx(W,{children:"AI history"}),e.jsx(K,{children:"Recent generations on this machine. Prompts and file contents are never recorded."})]}),e.jsxs("div",{className:"ai-log-header-actions",children:[e.jsxs(w,{variant:"outline",size:"sm",disabled:i,onClick:()=>{h()},children:[i?e.jsx(q,{className:"animate-spin"}):e.jsx(ge,{})," Refresh"]}),e.jsxs(w,{variant:"ghost",size:"sm",disabled:n.length===0,onClick:()=>{u()},children:[e.jsx(Ce,{})," Clear"]}),e.jsx(Y,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":"Close AI history"}),children:e.jsx(Me,{})})]})]}),n.length>0&&e.jsxs("div",{className:"ai-log-totals",children:[e.jsxs("span",{children:[e.jsx("strong",{children:f.runs})," runs"]}),e.jsxs("span",{children:[e.jsx("strong",{children:f.failed})," failed"]}),e.jsxs("span",{children:[e.jsx("strong",{children:we(f.tokens)})," tokens"]}),f.costed>0&&e.jsxs("span",{children:[e.jsxs("strong",{children:["$",f.cost.toFixed(4)]})," reported by ",f.costed," of ",f.runs]})]}),e.jsxs("div",{className:"ai-log-body",children:[i&&n.length===0&&e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(q,{className:"spinner"})," ",e.jsx(Se,{text:"Reading history…"})]}),!i&&n.length===0&&e.jsx("p",{className:"ai-log-empty",children:"No generations recorded yet. Generate a commit message and it will show up here."}),n.length>0&&e.jsx("div",{className:"ai-log-table-wrap",children:e.jsxs(ls,{children:[e.jsx(cs,{children:p.getHeaderGroups().map(l=>e.jsx(ue,{children:l.headers.map(x=>e.jsx(hs,{children:x.isPlaceholder?null:e.jsx(p.FlexRender,{header:x})},x.id))},l.id))}),e.jsx(ds,{children:p.getRowModel().rows.map(l=>e.jsx(ue,{className:l.original.status==="failed"?"ai-log-row-failed":void 0,children:l.getAllCells().map(x=>e.jsx(us,{children:e.jsx(p.FlexRender,{cell:x})},x.id))},l.id))})]})})]})]})})}const Ue=140;function Ct({text:s,tone:t,detail:n}){const[a,i]=m.useState(!1),r=s.length>Ue?`${s.slice(0,Ue-1)}…`:s,o=`ai-log-note ${t??""}`;return n?e.jsxs(e.Fragment,{children:[e.jsxs(F,{children:[e.jsx(z,{render:e.jsx("button",{type:"button",className:o,onClick:()=>i(!0),"aria-label":"Read generation details"}),children:r}),e.jsx(_,{className:"max-w-md",children:n})]}),e.jsx(H,{open:a,onOpenChange:i,children:e.jsx(V,{className:"name-dialog",children:e.jsxs("div",{className:"name-dialog-content",children:[e.jsx(W,{children:"Generation details"}),e.jsx(K,{className:"whitespace-pre-wrap break-words",children:n}),e.jsx("div",{className:"name-dialog-actions",children:e.jsx(Y,{render:e.jsx(w,{variant:"outline"}),children:"Close"})})]})})})]}):e.jsx("span",{className:o,children:r})}function Mt(s){const{inputTokens:t,outputTokens:n,costUsd:a}=s.usage;if(t===null&&n===null)return"no usage reported";const i=`${we(t??0)} in · ${we(n??0)} out`;return a===null?i:`${i} · $${a.toFixed(4)}`}function we(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}function Ge(s){return s instanceof Error?s.message:"An unexpected error occurred."}function se({column:s,label:t}){const n=s.getIsSorted();return e.jsxs("button",{type:"button",className:"ai-log-sort-button",onClick:()=>s.toggleSorting(n==="asc"),children:[t,n==="asc"&&e.jsx(rs,{size:13}),n==="desc"&&e.jsx(os,{size:13}),!n&&e.jsx(as,{size:13,className:"ai-log-sort-idle"})]})}const St=es({rowSortingFeature:ts,sortedRowModel:ns()}),Z=ss(),Et=Z.columns([Z.accessor("level",{header:({column:s})=>e.jsx(se,{column:s,label:"Level"}),cell:({getValue:s})=>{const t=s();return e.jsx(Q,{variant:t==="warn"?"outline":"destructive",children:t})}}),Z.accessor("operation",{header:({column:s})=>e.jsx(se,{column:s,label:"Operation"}),cell:({getValue:s})=>e.jsx("strong",{children:s()})}),Z.accessor("code",{header:({column:s})=>e.jsx(se,{column:s,label:"Code"}),cell:({getValue:s})=>s()??"—"}),Z.accessor(s=>new Date(s.at).getTime(),{id:"at",header:({column:s})=>e.jsx(se,{column:s,label:"Date"}),cell:({row:s})=>e.jsx("time",{dateTime:s.original.at,children:new Date(s.original.at).toLocaleString()})}),Z.accessor("message",{header:({column:s})=>e.jsx(se,{column:s,label:"Message"}),cell:({getValue:s})=>e.jsx("span",{className:"ai-log-model",children:s()})})]);function He(s){return s instanceof Error?s.message:"An unexpected error occurred."}function Rt({open:s,onOpenChange:t}){const[n,a]=m.useState([]),[i,r]=m.useState(!1),[o,c]=m.useState([]),h=m.useCallback(async()=>{r(!0);try{a(await te.diagnostics.list())}catch(l){N.error({title:"Could not read local problems",description:He(l)})}finally{r(!1)}},[]);m.useEffect(()=>{s&&h()},[h,s]);const f=m.useMemo(()=>({all:n.length,errors:n.filter(l=>l.level==="error").length}),[n]),p=Qe({features:St,data:n,columns:Et,onSortingChange:c,state:{sorting:o}}),u=async()=>{if(window.confirm("Delete the local problem history? This cannot be undone."))try{await te.diagnostics.clear(),a([])}catch(l){N.error({title:"Could not clear local problems",description:He(l)})}};return e.jsx(H,{open:s,onOpenChange:t,children:e.jsxs(V,{className:"ai-log-dialog",children:[e.jsxs("header",{className:"ai-log-header",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Problem history"}),e.jsx(K,{children:"Recent local failures on this machine. Prompts and file contents are never recorded."})]}),e.jsxs("div",{className:"ai-log-header-actions",children:[e.jsxs(w,{variant:"outline",size:"sm",disabled:i,onClick:()=>{h()},children:[i?e.jsx(q,{className:"animate-spin"}):e.jsx(ge,{})," Refresh"]}),e.jsxs(w,{variant:"ghost",size:"sm",disabled:n.length===0,onClick:()=>{u()},children:[e.jsx(Ce,{})," Clear"]}),e.jsx(Y,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":"Close problem history"}),children:e.jsx(Me,{})})]})]}),n.length>0&&e.jsxs("div",{className:"ai-log-totals",children:[e.jsxs("span",{children:[e.jsx("strong",{children:f.all})," recorded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:f.errors})," errors"]})]}),e.jsxs("div",{className:"ai-log-body",children:[i&&n.length===0&&e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(q,{className:"spinner"})," ",e.jsx(Se,{text:"Reading problems…"})]}),!i&&n.length===0&&e.jsx("p",{className:"ai-log-empty",children:"No local problems recorded yet. Failed Git, file, and network operations will show up here."}),n.length>0&&e.jsx("div",{className:"ai-log-table-wrap",children:e.jsxs(ls,{children:[e.jsx(cs,{children:p.getHeaderGroups().map(l=>e.jsx(ue,{children:l.headers.map(x=>e.jsx(hs,{children:x.isPlaceholder?null:e.jsx(p.FlexRender,{header:x})},x.id))},l.id))}),e.jsx(ds,{children:p.getRowModel().rows.map(l=>e.jsx(ue,{className:l.original.level==="error"?"ai-log-row-failed":void 0,children:l.getAllCells().map(x=>e.jsx(us,{children:e.jsx(p.FlexRender,{cell:x})},x.id))},l.id))})]})})]})]})})}const At=new Set(["Control","Shift","Alt","Meta"]);function It({preferences:s,onPreference:t}){const n=m.useMemo(()=>Is(s.shortcutOverrides),[s.shortcutOverrides]),[a,i]=m.useState(null),r=Object.keys(s.shortcutOverrides).length>0,o=m.useMemo(()=>["General","Commit","Editor","Tabs"].map(u=>({category:u,definitions:xe.filter(l=>l.category===u)})),[]),c=m.useMemo(()=>[...new Set($e.map(u=>u.category))].map(u=>({category:u,items:$e.filter(l=>l.category===u)})),[]),h=(p,u)=>{if(u===n[p]){i(null);return}const l=Ts(p,u,n);if(l){const v=l==="reserved"?`${Fe(u)} is reserved for a fixed shortcut.`:`${Fe(u)} is already used by "${xe.find(y=>y.id===l).label}".`;i({id:p,message:v});return}i(null);const x=xe.find(v=>v.id===p),j={...s.shortcutOverrides};u===x.defaultCombo?delete j[p]:j[p]=u,t({shortcutOverrides:j})},f=p=>{i(null);const u={...s.shortcutOverrides};delete u[p],t({shortcutOverrides:u})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-field settings-toggle-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Show and focus from anywhere"}),e.jsx("span",{children:"Double-tap Control to bring OpenTig to the front, even while another app is focused."})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"Show and focus from anywhere","aria-checked":s.doubleControlShortcutEnabled,className:"settings-switch",onClick:()=>t({doubleControlShortcutEnabled:!s.doubleControlShortcutEnabled}),children:e.jsx("span",{})})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Keyboard shortcuts"}),e.jsx("span",{children:"Click a shortcut, then press a new key combination. Press Escape to cancel."})]}),r&&e.jsxs(w,{variant:"outline",size:"sm",className:"shortcuts-reset-all",onClick:()=>{i(null),t({shortcutOverrides:{}})},children:[e.jsx(Xe,{})," Reset all to defaults"]}),o.map(({category:p,definitions:u})=>e.jsxs("div",{className:"shortcuts-group",children:[e.jsx("div",{className:"shortcuts-group-heading",children:p}),u.map(l=>e.jsxs("div",{className:"shortcuts-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:l.label}),e.jsx("span",{children:l.description})]}),e.jsx(Tt,{combo:n[l.id],allowBare:l.allowBare,isCustom:s.shortcutOverrides[l.id]!==void 0,error:a?.id===l.id?a.message:null,onCapture:x=>h(l.id,x),onReset:()=>f(l.id)})]},l.id))]},p))]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Fixed shortcuts"}),e.jsx("span",{children:"These follow platform and file-manager conventions and cannot be changed."})]}),c.map(({category:p,items:u})=>e.jsxs("div",{className:"shortcuts-group",children:[e.jsx("div",{className:"shortcuts-group-heading",children:p}),u.map(l=>e.jsxs("div",{className:"shortcuts-fixed-row",children:[e.jsx("span",{children:l.label}),e.jsx(Je,{children:l.combo.split(" / ").flatMap((x,j)=>[...j>0?[e.jsx("span",{className:"shortcuts-fixed-sep",children:" / "},`sep-${x}`)]:[],...x.split(" + ").map((v,y)=>e.jsx(Ze,{children:v},`${x}-${y}`))])})]},l.combo+l.label))]},p))]})]})}function Tt({combo:s,allowBare:t,isCustom:n,error:a,onCapture:i,onReset:r}){const[o,c]=m.useState(!1);return m.useEffect(()=>{if(!o)return;const h=f=>{if(f.preventDefault(),f.stopPropagation(),f.key==="Escape"){c(!1);return}if(At.has(f.key))return;const p=Os(f);c(!1),p&&Ls(p,t)&&i(p)};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[o,t,i]),e.jsxs("div",{className:"shortcut-recorder",children:[a&&e.jsx("span",{className:"shortcut-recorder-error",children:a}),e.jsx("button",{type:"button",className:`shortcut-recorder-button ${o?"listening":""} ${a?"error":""}`,onClick:()=>c(!0),onBlur:()=>c(!1),children:o?"Press a key…":e.jsx(Je,{children:s.split("+").map(h=>e.jsx(Ze,{children:h},h))})}),n&&e.jsxs(F,{children:[e.jsx(z,{render:e.jsx(w,{variant:"ghost",size:"icon-xs","aria-label":"Reset to default",onClick:r}),children:e.jsx(Xe,{})}),e.jsx(_,{children:"Reset to default"})]})]})}var G=(s=>(s[s.Border=-1]="Border",s[s.Data=0]="Data",s[s.Function=1]="Function",s[s.Position=2]="Position",s[s.Timing=3]="Timing",s[s.Alignment=4]="Alignment",s))(G||{});const Ot=[0,1],gs=[1,0],ms=[2,3],ps=[3,2],Lt={L:Ot,M:gs,Q:ms,H:ps},Pt=/^\d*$/,$t=/^[A-Z0-9 $%*+./:-]*$/,ve="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Re=1,Ae=40,Ve=3,Ft=3,ae=40,zt=10,fs=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],xs=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class _t{constructor(t,n,a,i){if(this.version=t,this.ecc=n,t<Re||t>Ae)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const r=Array.from({length:this.size}).fill(!1);for(let c=0;c<this.size;c++)this.modules.push(r.slice()),this.types.push(r.map(()=>0));this.drawFunctionPatterns();const o=this.addEccAndInterleave(a);if(this.drawCodewords(o),i===-1){let c=1e9;for(let h=0;h<8;h++){this.applyMask(h),this.drawFormatBits(h);const f=this.getPenaltyScore();f<c&&(i=h,c=f),this.applyMask(h)}}this.mask=i,this.applyMask(i),this.drawFormatBits(i)}size;mask;modules=[];types=[];getModule(t,n){return t>=0&&t<this.size&&n>=0&&n<this.size&&this.modules[n][t]}drawFunctionPatterns(){for(let a=0;a<this.size;a++)this.setFunctionModule(6,a,a%2===0,G.Timing),this.setFunctionModule(a,6,a%2===0,G.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),n=t.length;for(let a=0;a<n;a++)for(let i=0;i<n;i++)a===0&&i===0||a===0&&i===n-1||a===n-1&&i===0||this.drawAlignmentPattern(t[a],t[i]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.ecc[1]<<3|t;let a=n;for(let r=0;r<10;r++)a=a<<1^(a>>>9)*1335;const i=(n<<10|a)^21522;for(let r=0;r<=5;r++)this.setFunctionModule(8,r,$(i,r));this.setFunctionModule(8,7,$(i,6)),this.setFunctionModule(8,8,$(i,7)),this.setFunctionModule(7,8,$(i,8));for(let r=9;r<15;r++)this.setFunctionModule(14-r,8,$(i,r));for(let r=0;r<8;r++)this.setFunctionModule(this.size-1-r,8,$(i,r));for(let r=8;r<15;r++)this.setFunctionModule(8,this.size-15+r,$(i,r));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let a=0;a<12;a++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;for(let a=0;a<18;a++){const i=$(n,a),r=this.size-11+a%3,o=Math.floor(a/3);this.setFunctionModule(r,o,i),this.setFunctionModule(o,r,i)}}drawFinderPattern(t,n){for(let a=-4;a<=4;a++)for(let i=-4;i<=4;i++){const r=Math.max(Math.abs(i),Math.abs(a)),o=t+i,c=n+a;o>=0&&o<this.size&&c>=0&&c<this.size&&this.setFunctionModule(o,c,r!==2&&r!==4,G.Position)}}drawAlignmentPattern(t,n){for(let a=-2;a<=2;a++)for(let i=-2;i<=2;i++)this.setFunctionModule(t+i,n+a,Math.max(Math.abs(i),Math.abs(a))!==1,G.Alignment)}setFunctionModule(t,n,a,i=G.Function){this.modules[n][t]=a,this.types[n][t]=i}addEccAndInterleave(t){const n=this.version,a=this.ecc;if(t.length!==he(n,a))throw new RangeError("Invalid argument");const i=xs[a[0]][n],r=fs[a[0]][n],o=Math.floor(ke(n)/8),c=i-o%i,h=Math.floor(o/i),f=[],p=Yt(r);for(let l=0,x=0;l<i;l++){const j=t.slice(x,x+h-r+(l<c?0:1));x+=j.length;const v=qt(j,p);l<c&&j.push(0),f.push(j.concat(v))}const u=[];for(let l=0;l<f[0].length;l++)f.forEach((x,j)=>{(l!==h-r||j>=c)&&u.push(x[l])});return u}drawCodewords(t){if(t.length!==Math.floor(ke(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let a=this.size-1;a>=1;a-=2){a===6&&(a=5);for(let i=0;i<this.size;i++)for(let r=0;r<2;r++){const o=a-r,h=(a+1&2)===0?this.size-1-i:i;!this.types[h][o]&&n<t.length*8&&(this.modules[h][o]=$(t[n>>>3],7-(n&7)),n++)}}}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let a=0;a<this.size;a++){let i;switch(t){case 0:i=(a+n)%2===0;break;case 1:i=n%2===0;break;case 2:i=a%3===0;break;case 3:i=(a+n)%3===0;break;case 4:i=(Math.floor(a/3)+Math.floor(n/2))%2===0;break;case 5:i=a*n%2+a*n%3===0;break;case 6:i=(a*n%2+a*n%3)%2===0;break;case 7:i=((a+n)%2+a*n%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[n][a]&&i&&(this.modules[n][a]=!this.modules[n][a])}}getPenaltyScore(){let t=0;for(let r=0;r<this.size;r++){let o=!1,c=0;const h=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[r][f]===o?(c++,c===5?t+=Ve:c>5&&t++):(this.finderPenaltyAddHistory(c,h),o||(t+=this.finderPenaltyCountPatterns(h)*ae),o=this.modules[r][f],c=1);t+=this.finderPenaltyTerminateAndCount(o,c,h)*ae}for(let r=0;r<this.size;r++){let o=!1,c=0;const h=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[f][r]===o?(c++,c===5?t+=Ve:c>5&&t++):(this.finderPenaltyAddHistory(c,h),o||(t+=this.finderPenaltyCountPatterns(h)*ae),o=this.modules[f][r],c=1);t+=this.finderPenaltyTerminateAndCount(o,c,h)*ae}for(let r=0;r<this.size-1;r++)for(let o=0;o<this.size-1;o++){const c=this.modules[r][o];c===this.modules[r][o+1]&&c===this.modules[r+1][o]&&c===this.modules[r+1][o+1]&&(t+=Ft)}let n=0;for(const r of this.modules)n=r.reduce((o,c)=>o+(c?1:0),n);const a=this.size*this.size,i=Math.ceil(Math.abs(n*20-a*10)/a)-1;return t+=i*zt,t}getAlignmentPatternPositions(){if(this.version===1)return[];{const t=Math.floor(this.version/7)+2,n=this.version===32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,a=[6];for(let i=this.size-7;a.length<t;i-=n)a.splice(1,0,i);return a}}finderPenaltyCountPatterns(t){const n=t[1],a=n>0&&t[2]===n&&t[3]===n*3&&t[4]===n&&t[5]===n;return(a&&t[0]>=n*4&&t[6]>=n?1:0)+(a&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,a){return t&&(this.finderPenaltyAddHistory(n,a),n=0),n+=this.size,this.finderPenaltyAddHistory(n,a),this.finderPenaltyCountPatterns(a)}finderPenaltyAddHistory(t,n){n[0]===0&&(t+=this.size),n.pop(),n.unshift(t)}}function D(s,t,n){if(t<0||t>31||s>>>t)throw new RangeError("Value out of range");for(let a=t-1;a>=0;a--)n.push(s>>>a&1)}function $(s,t){return(s>>>t&1)!==0}class Ie{constructor(t,n,a){if(this.mode=t,this.numChars=n,this.bitData=a,n<0)throw new RangeError("Invalid argument");this.bitData=a.slice()}getData(){return this.bitData.slice()}}const Dt=[1,10,12,14],Bt=[2,9,11,13],Ut=[4,8,16,16];function js(s,t){return s[Math.floor((t+7)/17)+1]}function vs(s){const t=[];for(const n of s)D(n,8,t);return new Ie(Ut,s.length,t)}function Gt(s){if(!bs(s))throw new RangeError("String contains non-numeric characters");const t=[];for(let n=0;n<s.length;){const a=Math.min(s.length-n,3);D(Number.parseInt(s.substring(n,n+a),10),a*3+1,t),n+=a}return new Ie(Dt,s.length,t)}function Ht(s){if(!ys(s))throw new RangeError("String contains unencodable characters in alphanumeric mode");const t=[];let n;for(n=0;n+2<=s.length;n+=2){let a=ve.indexOf(s.charAt(n))*45;a+=ve.indexOf(s.charAt(n+1)),D(a,11,t)}return n<s.length&&D(ve.indexOf(s.charAt(n)),6,t),new Ie(Bt,s.length,t)}function Vt(s){return s===""?[]:bs(s)?[Gt(s)]:ys(s)?[Ht(s)]:[vs(Kt(s))]}function bs(s){return Pt.test(s)}function ys(s){return $t.test(s)}function Wt(s,t){let n=0;for(const a of s){const i=js(a.mode,t);if(a.numChars>=1<<i)return Number.POSITIVE_INFINITY;n+=4+i+a.bitData.length}return n}function Kt(s){s=encodeURI(s);const t=[];for(let n=0;n<s.length;n++)s.charAt(n)!=="%"?t.push(s.charCodeAt(n)):(t.push(Number.parseInt(s.substring(n+1,n+3),16)),n+=2);return t}function ke(s){if(s<Re||s>Ae)throw new RangeError("Version number out of range");let t=(16*s+128)*s+64;if(s>=2){const n=Math.floor(s/7)+2;t-=(25*n-10)*n-55,s>=7&&(t-=36)}return t}function he(s,t){return Math.floor(ke(s)/8)-fs[t[0]][s]*xs[t[0]][s]}function Yt(s){if(s<1||s>255)throw new RangeError("Degree out of range");const t=[];for(let a=0;a<s-1;a++)t.push(0);t.push(1);let n=1;for(let a=0;a<s;a++){for(let i=0;i<t.length;i++)t[i]=Ne(t[i],n),i+1<t.length&&(t[i]^=t[i+1]);n=Ne(n,2)}return t}function qt(s,t){const n=t.map(a=>0);for(const a of s){const i=a^n.shift();n.push(0),t.forEach((r,o)=>n[o]^=Ne(r,i))}return n}function Ne(s,t){if(s>>>8||t>>>8)throw new RangeError("Byte out of range");let n=0;for(let a=7;a>=0;a--)n=n<<1^(n>>>7)*285,n^=(t>>>a&1)*s;return n}function Xt(s,t,n=1,a=40,i=-1,r=!0){if(!(Re<=n&&n<=a&&a<=Ae)||i<-1||i>7)throw new RangeError("Invalid value");let o,c;for(o=n;;o++){const u=he(o,t)*8,l=Wt(s,o);if(l<=u){c=l;break}if(o>=a)throw new RangeError("Data too long")}for(const u of[gs,ms,ps])r&&c<=he(o,u)*8&&(t=u);const h=[];for(const u of s){D(u.mode[0],4,h),D(u.numChars,js(u.mode,o),h);for(const l of u.getData())h.push(l)}const f=he(o,t)*8;D(0,Math.min(4,f-h.length),h),D(0,(8-h.length%8)%8,h);for(let u=236;h.length<f;u^=253)D(u,8,h);const p=Array.from({length:Math.ceil(h.length/8)},()=>0);return h.forEach((u,l)=>p[l>>>3]|=u<<7-(l&7)),new _t(o,t,p,i)}function Jt(s,t){const{ecc:n="L",boostEcc:a=!1,minVersion:i=1,maxVersion:r=40,maskPattern:o=-1,border:c=1}=t||{},h=typeof s=="string"?Vt(s):Array.isArray(s)?[vs(s)]:void 0;if(!h)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof s}`);const f=Xt(h,Lt[n],i,r,o,a),p=Zt({version:f.version,maskPattern:f.mask,size:f.size,data:f.modules,types:f.types},c);return t?.invert&&(p.data=p.data.map(u=>u.map(l=>!l))),t?.onEncoded?.(p),p}function Zt(s,t=1){if(!t)return s;const{size:n}=s,a=n+t*2;s.size=a,s.data.forEach(r=>{for(let o=0;o<t;o++)r.unshift(!1),r.push(!1)});for(let r=0;r<t;r++)s.data.unshift(Array.from({length:a},o=>!1)),s.data.push(Array.from({length:a},o=>!1));const i=G.Border;s.types.forEach(r=>{for(let o=0;o<t;o++)r.unshift(i),r.push(i)});for(let r=0;r<t;r++)s.types.unshift(Array.from({length:a},o=>i)),s.types.push(Array.from({length:a},o=>i));return s}function We(s){return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qt(s,t={}){const n=Jt(s,t),{pixelSize:a=10,whiteColor:i="white",blackColor:r="black"}=t,o=n.size*a,c=n.size*a;let h=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${o}">`;const f=[];for(let p=0;p<n.size;p++)for(let u=0;u<n.size;u++){const l=u*a,x=p*a;n.data[p][u]&&f.push(`M${l},${x}h${a}v${a}h-${a}z`)}return h+=`<rect fill="${We(i)}" width="${c}" height="${o}"/>`,h+=`<path fill="${We(r)}" d="${f.join("")}"/>`,h+="</svg>",h}async function en(){const s=await fetch("/api/auth/sessions",{credentials:"include"});if(!s.ok)throw new Error(await Te(s,"Could not load owner sessions."));const t=await s.json();if(!Array.isArray(t.sessions))throw new Error("OpenTig returned an invalid session list.");return t.sessions}async function sn(s){return ws("/api/auth/sessions/revoke",{sessionId:s})}async function tn(){return ws("/api/auth/sessions/revoke-all",{})}async function nn(s,t){const n=await fetch("/api/auth/sessions/rename",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,clientName:t})});if(!n.ok)throw new Error(await Te(n,"Could not rename the browser session."))}async function ws(s,t){const n=await fetch(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(await Te(n,"Could not revoke the browser session."));const a=await n.json();if(!Number.isSafeInteger(a.revokedCount)||Number(a.revokedCount)<0)throw new Error("OpenTig returned an invalid revocation result.");return Number(a.revokedCount)}async function Te(s,t){try{const n=await s.json();return typeof n.error=="string"?n.error:t}catch{return t}}const an={starting:"Starting",ready:"Ready",restarting:"Restarting",failed:"Failed",stopped:"Stopped"};function rn(){const s=window.opentigDesktop?.webAccess,[t,n]=m.useState(null),[a,i]=m.useState([]),[r,o]=m.useState(null),[c,h]=m.useState(""),[f,p]=m.useState(!0),[u,l]=m.useState(null),[x,j]=m.useState(!1),[v,y]=m.useState(null),[M,S]=m.useState(null),[I,C]=m.useState(""),E=m.useCallback(async(g=!0)=>{const T=await Promise.allSettled([s?.getStatus()??Promise.resolve(null),en()]);T[0].status==="fulfilled"?n(T[0].value):g&&N.error({title:"Could not read web access status",description:U(T[0].reason)}),T[1].status==="fulfilled"?i(T[1].value):g&&N.error({title:"Could not read owner sessions",description:U(T[1].reason)}),p(!1)},[s]);m.useEffect(()=>{E();const g=window.setInterval(()=>{E(!1)},2e3);return()=>window.clearInterval(g)},[E]),m.useEffect(()=>{t&&(t.pairingEndpoints.length?t.pairingEndpoints.includes(c)||h(t.pairingEndpoints[0]):h(""))},[c,t]);const R=m.useMemo(()=>r?`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(Qt(r.url,{ecc:"M",border:2}))}`:null,[r]),L=m.useMemo(()=>r?new URLSearchParams(new URL(r.url).hash.slice(1)).get("token")??"":"",[r]);if(f&&(!s||!t)&&a.length===0)return e.jsxs("div",{className:"web-access-loading",role:"status",children:[e.jsx(q,{className:"animate-spin"})," Loading web access…"]});const A=async g=>{if(s){l("toggle"),o(null);try{n(await s.setEnabled(g)),N.success({title:g?"LAN access enabled":"LAN access disabled"})}catch(T){N.error({title:"Could not restart web access",description:U(T)}),await E(!1)}finally{l(null),j(!1)}}},d=async()=>{if(s){l("pair");try{o(await s.createPairingLink(c))}catch(g){N.error({title:"Could not create pairing link",description:U(g)})}finally{l(null)}}},b=async()=>{if(r)try{await Le(r.url),N.success({title:"Pairing link copied"})}catch(g){N.error({title:"Could not copy pairing link",description:U(g)})}},k=async()=>{if(L)try{await Le(L),N.success({title:"Pairing code copied"})}catch(g){N.error({title:"Could not copy pairing code",description:U(g)})}},X=async()=>{const g=M,T=I.trim();if(!(!g||!T||T.length>64)){l(`rename:${g.id}`);try{await nn(g.id,T),N.success({title:"Device renamed"}),await E(!1),S(null)}catch(J){N.error({title:"Could not rename device",description:U(J)})}finally{l(null)}}},me=async()=>{const g=v;if(!g)return;const T=g==="all"?"revoke-all":`revoke:${g.id}`;l(T);try{const J=g==="all"?await tn():await sn(g.id);o(null),N.success({title:`${J} browser ${J===1?"session":"sessions"} revoked`}),await E(!1)}catch(J){N.error({title:"Could not revoke session",description:U(J)})}finally{l(null),y(null)}},pe=t?.serverState==="ready",ks=a.filter(g=>g.kind!=="desktop");return e.jsxs("div",{className:"web-access-settings",children:[s&&t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"web-access-summary",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"LAN access"}),e.jsx("span",{children:"Listen on this computer's network interfaces for trusted local devices."})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"LAN access","aria-checked":t.enabled,className:"settings-switch",disabled:u==="toggle"||!pe,onClick:()=>t.enabled?void A(!1):j(!0),children:e.jsx("span",{})})]}),e.jsxs("div",{className:"web-access-facts","aria-live":"polite",children:[e.jsx(ie,{label:"Server status",children:e.jsx(Q,{variant:pe?"secondary":"outline",children:an[t.serverState]})}),e.jsx(ie,{label:"Actual port",children:e.jsx("code",{children:t.actualPort??"Unavailable"})}),e.jsx(ie,{label:"Local endpoint",children:e.jsx(Ke,{value:t.localEndpoint})}),e.jsx(ie,{label:"LAN endpoints",children:e.jsx("div",{className:"web-access-endpoints",children:t.networkEndpoints.length===0?e.jsx("span",{children:"None detected"}):t.networkEndpoints.map(g=>e.jsx(Ke,{value:g,muted:!t.enabled},g))})})]}),t.restartError&&e.jsxs("div",{className:"web-access-error",role:"alert",children:[e.jsx(Ee,{})," ",e.jsx("span",{children:t.restartError})]}),e.jsxs("div",{className:"web-access-actions settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Pair a browser"}),e.jsx("span",{children:"Create a five-minute, one-use link for this computer or a LAN device. The pairing code also works through a same-machine HTTPS tunnel."})]}),e.jsxs(w,{size:"sm",onClick:()=>{d()},disabled:!pe||!c||u!==null,children:[u==="pair"?e.jsx(q,{className:"animate-spin"}):e.jsx(it,{})," Create pairing link"]})]}),t.pairingEndpoints.length>0&&e.jsxs("div",{className:"web-access-endpoint-select",children:[e.jsx("label",{htmlFor:"web-access-endpoint",children:"Address to place in the pairing link"}),e.jsxs(re,{value:c,onValueChange:g=>{g&&(h(g),o(null))},disabled:u!==null,children:[e.jsx(oe,{id:"web-access-endpoint",className:"w-full",children:e.jsx(le,{children:c})}),e.jsx(ce,{alignItemWithTrigger:!1,children:e.jsx(Ps,{children:t.pairingEndpoints.map(g=>e.jsx(de,{value:g,children:g},g))})})]})]}),r&&e.jsxs("div",{className:"web-access-pairing",role:"status",children:[e.jsxs("div",{className:"web-access-pairing-copy",children:[e.jsx(gt,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Pairing link ready"}),e.jsxs("span",{children:["Expires ",new Date(r.expiresAt).toLocaleString(),"."]})]})]}),R&&e.jsx("img",{src:R,alt:"QR code for the one-use OpenTig pairing link"}),e.jsxs("div",{className:"web-access-link-row",children:[e.jsxs(F,{children:[e.jsx(z,{render:e.jsx("code",{className:"web-access-link"}),children:r.url}),e.jsx(_,{side:"bottom",children:"One-use link; do not share publicly"})]}),e.jsxs(F,{children:[e.jsx(z,{render:e.jsx(w,{variant:"outline",size:"icon-sm","aria-label":"Copy pairing link",onClick:()=>{b()}}),children:e.jsx(Oe,{})}),e.jsx(_,{children:"Copy pairing link"})]})]}),e.jsxs("div",{className:"web-access-link-row",children:[e.jsxs(F,{children:[e.jsx(z,{render:e.jsx("code",{className:"web-access-link"}),children:L}),e.jsx(_,{side:"bottom",children:"Paste this code on any /pair page served by this OpenTig instance"})]}),e.jsxs(F,{children:[e.jsx(z,{render:e.jsx(w,{variant:"outline",size:"icon-sm","aria-label":"Copy pairing code",onClick:()=>{k()}}),children:e.jsx(Oe,{})}),e.jsx(_,{children:"Copy pairing code"})]})]})]})]}),e.jsxs("div",{className:`web-access-session-heading ${s?"settings-field-separated":""}`,children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Owner sessions"}),e.jsx("span",{children:"Desktop authentication stays private. Paired browsers can be disconnected individually."})]}),e.jsxs(w,{variant:"destructive",size:"sm",onClick:()=>y("all"),disabled:ks.length===0||u!==null,children:[e.jsx(Be,{})," Revoke browsers"]})]}),e.jsx("div",{className:"web-access-session-list","aria-live":"polite",children:a.length===0?e.jsx("div",{className:"web-access-empty-session",children:"No owner sessions found."}):a.map(g=>e.jsxs("div",{className:"web-access-session",children:[e.jsx("div",{className:`web-access-session-icon ${g.connected?"connected":""}`,children:g.kind==="desktop"?e.jsx(is,{}):e.jsx(et,{})}),e.jsxs("div",{className:"web-access-session-copy",children:[e.jsxs("div",{children:[e.jsx("strong",{children:g.clientName}),g.current&&e.jsx(Q,{variant:"secondary",children:"This session"}),g.kind==="desktop"&&e.jsx(Q,{variant:"outline",children:"Desktop"})]}),e.jsxs("span",{children:[g.connected?`Connected${g.connectionCount>1?` (${g.connectionCount} tabs)`:""}`:g.lastConnectedAt?`Last connected ${on(g.lastConnectedAt)}`:"Not yet connected"," · ",g.browser&&g.os?`${g.browser} on ${g.os}`:g.browser??g.os??ln(g.deviceType),g.viaProxy?" · Via proxy":"",g.remoteAddress?` · ${g.remoteAddress}`:""]})]}),g.kind!=="desktop"&&e.jsxs("div",{className:"web-access-session-controls",children:[e.jsxs(F,{children:[e.jsx(z,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${g.clientName}`,onClick:()=>{S(g),C(g.clientName)},disabled:u!==null}),children:e.jsx(Hs,{})}),e.jsx(_,{children:"Rename this device"})]}),e.jsxs(F,{children:[e.jsx(z,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":`Revoke ${g.clientName} session`,onClick:()=>y(g),disabled:u!==null}),children:e.jsx(Ce,{})}),e.jsx(_,{children:"Revoke this browser session"})]})]})]},g.id))}),!s&&e.jsx("p",{className:"web-access-hint",children:"Listener addresses and new pairing links are controlled by the OpenTig desktop app or CLI running the server."}),e.jsx(H,{open:x,onOpenChange:j,children:e.jsxs(V,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(W,{children:"Enable owner-level LAN access?"}),e.jsx(K,{children:"Any paired browser can edit or delete files and act with your OS user permissions. Use only a trusted LAN or VPN."})]}),e.jsxs("div",{className:"undo-commit-actions",children:[e.jsx(Y,{render:e.jsx(w,{variant:"ghost"}),children:"Cancel"}),e.jsx(w,{onClick:()=>{A(!0)},disabled:u!==null,children:"Enable LAN access"})]})]})}),e.jsx(H,{open:v!==null,onOpenChange:g=>{g||y(null)},children:e.jsxs(V,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(W,{children:v==="all"?"Revoke all browser sessions?":"Revoke this browser session?"}),e.jsx(K,{children:v==="all"?"Every paired browser disconnects immediately. The private desktop session remains signed in.":v?.current?"This browser will disconnect immediately and require a new pairing link.":"That browser disconnects immediately and will require a new pairing link."}),v&&v!=="all"&&e.jsx("div",{className:"undo-commit-summary",children:e.jsx("strong",{children:v.clientName})})]}),e.jsxs("div",{className:"undo-commit-actions",children:[e.jsx(Y,{render:e.jsx(w,{variant:"ghost"}),children:"Cancel"}),e.jsxs(w,{variant:"destructive",onClick:()=>{me()},disabled:u!==null,children:[e.jsx(Be,{})," Revoke"]})]})]})}),e.jsx(H,{open:M!==null,onOpenChange:g=>{g||S(null)},children:e.jsxs(V,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(W,{children:"Rename paired device"}),e.jsx(K,{children:"Use a name that makes this browser easy to identify later."}),e.jsx("input",{className:"web-access-rename-input",value:I,onChange:g=>C(g.target.value),maxLength:64,"aria-label":"Device name",autoComplete:"off"})]}),e.jsxs("div",{className:"undo-commit-actions",children:[e.jsx(Y,{render:e.jsx(w,{variant:"ghost"}),children:"Cancel"}),e.jsx(w,{onClick:()=>{X()},disabled:u!==null||!I.trim(),children:"Save"})]})]})})]})}function ie({label:s,children:t}){return e.jsxs("div",{className:"web-access-fact",children:[e.jsx("span",{children:s}),e.jsx("div",{children:t})]})}function Ke({value:s,muted:t=!1}){return s?e.jsxs(F,{children:[e.jsx(z,{render:e.jsx("code",{className:t?"muted":void 0}),children:s}),e.jsx(_,{side:"bottom",children:t?"Enable LAN access to use this endpoint":s})]}):e.jsx("span",{children:"Unavailable"})}function on(s){const t=new Date(s);return Number.isNaN(t.getTime())?"unknown":t.toLocaleString()}function ln(s){return s==="desktop"?"Desktop browser":s==="mobile"?"Mobile browser":s==="tablet"?"Tablet browser":s==="bot"?"Automated client":"Unknown browser"}function U(s){return s instanceof Error?s.message:String(s)}const cn=[{id:"general",label:"General",icon:$s},{id:"updates",label:"Updates",icon:ge},{id:"shortcuts",label:"Shortcuts",icon:nt},{id:"ai",label:"AI assistance",icon:jt},{id:"diagnostics",label:"Diagnostics",icon:Ee},{id:"webAccess",label:"Web access",icon:ht}],dn={updates:{title:"Updates",description:"Check, download, and install new OpenTig releases."},general:{title:"General",description:"OpenTig appearance and behavior."},shortcuts:{title:"Shortcuts",description:"Rebind commands or review the shortcuts that stay fixed."},ai:{title:"AI assistance",description:"Local harness and model used to suggest commit messages and pull-request drafts."},diagnostics:{title:"Diagnostics",description:"Recent local failures on this machine. Prompts and file contents are never recorded."}},hn=[{value:"system",label:"System",icon:is},{value:"light",label:"Light",icon:bt},{value:"dark",label:"Dark",icon:ct}],be=[{value:"geist",label:"Geist",family:"'Geist Variable', sans-serif"},{value:"plus-jakarta-sans",label:"Plus Jakarta Sans",family:"'Plus Jakarta Sans Variable', sans-serif"},{value:"space-grotesk",label:"Space Grotesk",family:"'Space Grotesk Variable', sans-serif"}],ye=[{value:"geist-mono",label:"Geist Mono",family:"'Geist Mono Variable', ui-monospace, monospace"},{value:"jetbrains-mono",label:"JetBrains Mono",family:"'JetBrains Mono Variable', ui-monospace, monospace"},{value:"inconsolata",label:"Inconsolata",family:"'Inconsolata Variable', ui-monospace, monospace"},{value:"departure",label:"Departure Mono",family:"'Departure Mono', ui-monospace, monospace"},{value:"space-grotesk",label:"Space Grotesk",family:"'Space Grotesk Variable', sans-serif"}],un=[{value:"tree",label:"Tree",icon:Fs},{value:"list",label:"List",icon:ot}];function kn({preferences:s,onPreference:t,open:n,onOpenChange:a,section:i,onSectionChange:r}){const[o,c]=m.useState([]),[h,f]=m.useState(!1),[p,u]=m.useState(!1),[l,x]=m.useState(!1),j=m.useRef(null),v=Js(),y=v?{duration:0}:{duration:.16,ease:[.22,1,.36,1]},M=m.useCallback(async(d=!1)=>{f(!0);try{c(await te.ai.statuses(d))}catch(b){N.error({title:"Could not check local AI",description:fn(b)})}finally{f(!1)}},[]);m.useEffect(()=>{n&&i==="ai"&&o.length===0&&M()},[M,n,i,o.length]),m.useLayoutEffect(()=>{n&&j.current&&(j.current.scrollTop=0)},[n,i]);const S=s.commitMessageHarness,I=o.find(d=>d.id===S),C=s.commitMessageModels[S]??"default",E=I?.models??[{id:"default",label:"Default (CLI)"}],R=E.some(d=>d.id===C)?E:[...E,{id:C,label:`${C} (unavailable)`}],{title:L,description:A}=i==="webAccess"?{title:"Web access",description:window.opentigDesktop?"Connect trusted browsers locally, over your LAN, or through an HTTPS tunnel.":"Review and disconnect browsers authorised to use this OpenTig server."}:dn[i];return e.jsx(H,{open:n,onOpenChange:a,children:e.jsx(V,{className:"settings-dialog",children:e.jsxs("div",{className:"settings-shell",children:[e.jsxs("aside",{className:"settings-nav",children:[e.jsx("div",{className:"settings-nav-title",children:"Settings"}),cn.map(({id:d,label:b,icon:k})=>e.jsxs("button",{className:`settings-nav-item ${i===d?"active":""}`,onClick:()=>r(d),"aria-current":i===d,children:[e.jsx(k,{})," ",b]},d))]}),e.jsxs("section",{className:"settings-panel",children:[e.jsxs("header",{className:"settings-panel-header",children:[e.jsx(De,{initial:!1,mode:"wait",children:e.jsxs(Pe.div,{initial:v?!1:{opacity:0,y:4},animate:{opacity:1,y:0},exit:v?{opacity:1}:{opacity:0,y:-3},transition:y,children:[e.jsx(W,{children:L}),e.jsx(K,{children:A})]},i)}),e.jsx(Y,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":"Close settings"}),children:e.jsx(Me,{})})]}),e.jsx("div",{ref:j,className:"settings-panel-body",children:e.jsx(De,{initial:!1,mode:"wait",children:e.jsx(Pe.div,{className:"settings-panel-section",initial:v?!1:{opacity:0,y:7},animate:{opacity:1,y:0},exit:v?{opacity:1}:{opacity:0,y:-5},transition:y,children:i==="general"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-field",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Theme"}),e.jsx("span",{children:"Choose a light, dark, or system appearance."})]}),e.jsx("div",{className:"settings-theme-options",role:"radiogroup","aria-label":"Theme",children:hn.map(({value:d,label:b,icon:k})=>e.jsxs("button",{type:"button",role:"radio","aria-checked":s.theme===d,className:`settings-theme-option ${s.theme===d?"active":""}`,onClick:()=>t({theme:d}),children:[e.jsx(k,{})," ",e.jsx("span",{children:b})]},d))})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Fonts"}),e.jsx("span",{children:"Interface chrome and code, chosen independently. Space Grotesk appears in both lists."})]}),e.jsxs("div",{className:"settings-font-pickers",children:[e.jsxs("label",{className:"settings-font-picker",children:[e.jsx("span",{children:"Interface"}),e.jsxs(re,{value:s.uiFont,onValueChange:d=>{const b=be.find(k=>k.value===d);b&&t({uiFont:b.value})},children:[e.jsx(oe,{className:"settings-font-select","aria-label":"Interface font",style:{fontFamily:be.find(d=>d.value===s.uiFont)?.family},children:e.jsx(le,{})}),e.jsx(ce,{align:"start",alignItemWithTrigger:!1,className:"w-max min-w-[16rem]",children:be.map(d=>e.jsx(de,{value:d.value,children:e.jsx("span",{style:{fontFamily:d.family},children:d.label})},d.value))})]})]}),e.jsxs("label",{className:"settings-font-picker",children:[e.jsx("span",{children:"Code"}),e.jsxs(re,{value:s.monoFont,onValueChange:d=>{const b=ye.find(k=>k.value===d);b&&t({monoFont:b.value})},children:[e.jsx(oe,{className:"settings-font-select","aria-label":"Code font",style:{fontFamily:ye.find(d=>d.value===s.monoFont)?.family},children:e.jsx(le,{})}),e.jsx(ce,{align:"start",alignItemWithTrigger:!1,className:"w-max min-w-[16rem]",children:ye.map(d=>e.jsx(de,{value:d.value,children:e.jsx("span",{style:{fontFamily:d.family},children:d.label})},d.value))})]})]})]})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Interface size"}),e.jsx("span",{children:"Adjust the zoom for text, icons, and the rest of the application."})]}),e.jsxs("div",{className:"settings-zoom-control",children:[e.jsx("input",{type:"range",min:"80",max:"130",step:"10",value:s.uiZoom,onChange:d=>t({uiZoom:Number(d.target.value)}),"aria-label":"Interface zoom"}),e.jsxs("output",{children:[s.uiZoom,"%"]})]})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Changes layout"}),e.jsx("span",{children:"Group changed files by folder or show them as a flat list."})]}),e.jsx("div",{className:"settings-theme-options",role:"radiogroup","aria-label":"Changes layout",children:un.map(({value:d,label:b,icon:k})=>e.jsxs("button",{type:"button",role:"radio","aria-checked":s.changesLayout===d,className:`settings-theme-option ${s.changesLayout===d?"active":""}`,onClick:()=>t({changesLayout:d}),children:[e.jsx(k,{})," ",e.jsx("span",{children:b})]},d))})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Remote check interval"}),e.jsx("span",{children:"How often OpenTig fetches remotes so ahead and behind counts stay current. Set to Off to check only when you pull or push."})]}),e.jsxs("div",{className:"settings-zoom-control",children:[e.jsx("input",{type:"range",min:"0",max:_s,step:zs,value:s.remoteFetchIntervalSeconds,onChange:d=>t({remoteFetchIntervalSeconds:Number(d.target.value)}),"aria-label":"Remote check interval"}),e.jsx("output",{children:Ds(s.remoteFetchIntervalSeconds)})]})]}),e.jsxs("div",{className:"settings-field settings-field-separated settings-toggle-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Wrap lines in viewer"}),e.jsx("span",{children:"Wrap long lines to fit the available width."})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"Wrap lines in viewer","aria-checked":s.wrapLines,className:"settings-switch",onClick:()=>t({wrapLines:!s.wrapLines}),children:e.jsx("span",{})})]}),e.jsxs("div",{className:"settings-field settings-field-separated settings-toggle-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Show files ignored by Git"}),e.jsxs("span",{children:["Include files excluded by ",e.jsx("code",{children:".gitignore"})," rules in the Files view."]})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"Show files ignored by Git","aria-checked":s.showDotEnvFiles,className:"settings-switch",onClick:()=>t({showDotEnvFiles:!s.showDotEnvFiles}),children:e.jsx("span",{})})]})]}):i==="updates"?e.jsx(Bs,{}):i==="shortcuts"?e.jsx(It,{preferences:s,onPreference:t}):i==="webAccess"?e.jsx(rn,{}):i==="diagnostics"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-field",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Problem history"}),e.jsx("span",{children:"Failed Git, file, and network operations recorded locally. Prompts and file contents are never stored."})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>x(!0),children:[e.jsx(Ee,{})," View problems"]})]}),e.jsx(Rt,{open:l,onOpenChange:x})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"ai-settings-heading",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Local harness"}),e.jsx("span",{children:"OpenTig uses the selected CLI session. It does not copy or store credentials."})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{M(!0)},disabled:h,children:[h?e.jsx(q,{className:"animate-spin"}):e.jsx(ge,{})," ",h?e.jsx(Se,{text:"Checking…"}):"Check again"]})]}),e.jsx("div",{className:"ai-harness-list",role:"radiogroup","aria-label":"Harness for AI assistance",children:["codex","claude","opencode"].map(d=>{const b=o.find(X=>X.id===d),k=S===d;return e.jsxs("button",{type:"button",role:"radio","aria-checked":k,className:`ai-harness-card ${k?"active":""}`,onClick:()=>t({commitMessageHarness:d}),children:[e.jsxs("span",{className:"ai-harness-card-main",children:[e.jsx(Us,{harness:d}),e.jsxs("span",{className:"ai-harness-card-copy",children:[e.jsx("strong",{children:je(d)}),e.jsx("small",{children:h?"Checking…":b?.version||(b?b.installed?"Version unavailable":"Executable not found":"Status not checked")})]})]}),e.jsx(Q,{variant:mn(b),className:`ai-status-badge ${b?.availability??"unknown"}`,children:gn(b)}),b?.message&&e.jsx("span",{className:"ai-harness-message",children:b.message})]},d)})}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsxs("strong",{children:[je(S)," model"]}),e.jsx("span",{children:"Default lets the CLI choose. OpenTig remembers a separate selection for each harness."})]}),e.jsxs(re,{value:C,onValueChange:d=>t({commitMessageModels:{...s.commitMessageModels,[S]:d}}),children:[e.jsx(oe,{className:"ai-model-select",children:e.jsx(le,{})}),e.jsx(ce,{children:R.map(d=>e.jsx(de,{value:d.id,children:d.label},d.id))})]}),I?.authStatus==="unauthenticated"&&e.jsxs("p",{className:"ai-login-hint",children:["Sign in from a terminal with ",e.jsx("code",{children:pn(S,I.cliName)})," and check again."]}),I&&!I.installed&&e.jsxs("p",{className:"ai-login-hint",children:["Install ",je(S)," and check its availability again."]})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Generation history"}),e.jsx("span",{children:"Outcome, duration, tokens, and cost of recent runs, kept locally for diagnostics."})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>u(!0),children:[e.jsx(Gs,{})," View history"]})]}),e.jsx("p",{className:"ai-privacy-note",children:"Only the staged diff, its summary, the branch, and recent subjects are sent to the selected harness. The generated message always remains pending your review, and the history records metadata only."}),e.jsx(Nt,{open:p,onOpenChange:u})]})},i)})})]})]})})})}function gn(s){return s?s.installed?s.authStatus==="unauthenticated"?"Not authenticated":s.availability==="ready"?"Available":"Check":"Not installed":"Not checked"}function mn(s){return s?!s.installed||s.authStatus==="unauthenticated"||s.availability==="error"?"destructive":s.availability==="ready"?"default":"secondary":"outline"}function pn(s,t){return s==="codex"?"codex login":s==="claude"?"claude auth login":t==="opencode2"?"opencode2 auth login":"opencode auth login"}function fn(s){return s instanceof Error?s.message:"An unexpected error occurred."}export{kn as SettingsDialog};
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PierreDiffViewer-uhTsb-F7.js","assets/react-rd22PHbN.js","assets/PierreWorkerPool-BuBzE8K1.js","assets/platform-BMNQ8V5r.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-BOPi2b1j.js","assets/tanstack-B8_amOz8.js","assets/base-ui-qeHDA5zu.js","assets/index-CryuKDT3.css","assets/index-CtEztN1P.js","assets/File-DiOOsHOl.js","assets/EditContext-CvJWfVl1.js","assets/DiffWorkspace-BWkTIl5n.js","assets/App-CBetJ5ZN.js","assets/PierreEditBoundary-Bb4dONIq.js","assets/edit-ready-context-D77R8XU8.js","assets/MarkdownFileViewer-BedKCXTI.js","assets/viewer-tabs-DxCOe0ut.js","assets/viewer-tabs-D8o-L3pM.css","assets/EditableFileViewer-Cv3aNJBN.js","assets/EditableFileViewer-B2G3Xa33.css","assets/render-markdown-C7X2TwRk.js","assets/markdown-BpzjXclZ.css","assets/PullRequestViewer-KZl0osME.js","assets/gh-utils-B0Nlmxep.js","assets/GitHubAvatar-DBc3Vxnk.js","assets/HtmlFileViewer-BsewwJtM.js","assets/HtmlFileViewer-D6UPnZvW.css","assets/ImageFileViewer-CoQZkgET.js","assets/ImageFileViewer-D8TdwFTO.css"])))=>i.map(i=>d[i]);
2
- import{o as _,B as J,_ as x,T as se,a as ae,b as ne}from"./index-BOPi2b1j.js";import{r as n,j as t}from"./react-rd22PHbN.js";import{H as le,J as re,K as oe,k as R,L as fe,G as Y}from"./App-CBetJ5ZN.js";import"./tanstack-B8_amOz8.js";import"./base-ui-qeHDA5zu.js";class de{constructor(e){if(this.options=e,!Number.isInteger(e.maxEntries)||e.maxEntries<1)throw new RangeError("maxEntries must be a positive integer.");if(!Number.isFinite(e.maxBytes)||e.maxBytes<1)throw new RangeError("maxBytes must be a positive number.")}options;entries=new Map;totalBytes=0;get size(){return this.entries.size}get bytes(){return this.totalBytes}get(e){const o=this.entries.get(e);if(o)return this.entries.delete(e),this.entries.set(e,o),o.value}set(e,o){const d=ce(this.options.sizeOf(o)),v=this.entries.get(e);return v&&(this.entries.delete(e),this.totalBytes-=v.bytes),d>this.options.maxBytes?!1:(this.entries.set(e,{value:o,bytes:d}),this.totalBytes+=d,this.evictToBudget(),this.entries.has(e))}delete(e){const o=this.entries.get(e);return o?(this.entries.delete(e),this.totalBytes-=o.bytes,!0):!1}clear(){this.entries.clear(),this.totalBytes=0}evictToBudget(){for(;this.entries.size>this.options.maxEntries||this.totalBytes>this.options.maxBytes;){const e=this.entries.keys().next();if(e.done)break;this.delete(e.value)}}}function ce(i){if(!Number.isFinite(i)||i<0)throw new RangeError("sizeOf must return a finite, non-negative number.");return Math.ceil(i)}const U=n.lazy(()=>x(()=>import("./PierreDiffViewer-uhTsb-F7.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),ue=n.lazy(()=>x(()=>import("./PierreEditBoundary-Bb4dONIq.js"),__vite__mapDeps([15,6,1,7,8,9,12,16])).then(i=>({default:i.PierreEditBoundary}))),me=n.lazy(()=>x(()=>import("./MarkdownFileViewer-BedKCXTI.js"),__vite__mapDeps([17,1,6,7,8,9,14,18,19,20,2,3,4,5,10,11,12,16,21,22,23])).then(i=>({default:i.MarkdownFileViewer}))),he=n.lazy(()=>x(()=>import("./PullRequestViewer-KZl0osME.js"),__vite__mapDeps([24,6,1,7,8,9,14,18,19,25,26,23])).then(i=>({default:i.PullRequestViewer}))),pe=n.lazy(()=>x(()=>import("./EditableFileViewer-Cv3aNJBN.js").then(i=>i.E),__vite__mapDeps([20,1,2,3,4,5,6,7,8,9,10,11,12,16,14,21])).then(i=>({default:i.EditableFileViewer}))),xe=n.lazy(()=>x(()=>import("./HtmlFileViewer-BsewwJtM.js"),__vite__mapDeps([27,1,18,6,7,8,9,19,20,2,3,4,5,10,11,12,16,14,21,28])).then(i=>({default:i.HtmlFileViewer}))),ve=n.lazy(()=>x(()=>import("./ImageFileViewer-CoQZkgET.js"),__vite__mapDeps([29,1,6,7,8,9,18,19,20,2,3,4,5,10,11,12,16,14,21,30])).then(i=>({default:i.ImageFileViewer}))),ye=n.lazy(()=>x(()=>import("./ImageFileViewer-CoQZkgET.js"),__vite__mapDeps([29,1,6,7,8,9,18,19,20,2,3,4,5,10,11,12,16,14,21,30])).then(i=>({default:i.SvgFileViewer}))),F=new de({maxEntries:8,maxBytes:16*1024*1024,sizeOf:i=>i.patch.length*2+i.path.length*2+256});let Q=null;function Se({repositoryId:i,selection:e,diffView:o,wrapLines:d,theme:v,revision:y,readOnly:g,commits:T,draftFor:E,onSelect:$,onOpenFile:Z,onDiffViewChange:K,onWrapLinesChange:M,onDraftChange:O,onDraftSaved:A,onUpdateConflict:W,onResolveConflict:I}){const[a,w]=n.useState(null),[ee,L]=n.useState(!1),[D,q]=n.useState(null),[V,H]=n.useState(!1),b=n.useRef(0),C=n.useRef(!1),u=je(i,e);n.useEffect(()=>{H(!1),C.current=!1},[e]),n.useEffect(()=>{Q!==i&&(F.clear(),Q=i);const s=++b.current;if(q(null),!e||e.type==="pull-request"){w(null),L(!1);return}L(!0),(async()=>{try{if(e.type==="file"||e.type==="conflict"){if(e.type==="file"&&fe(e.path)){const l=await _.repository.readImage(i,e.path);if(s!==b.current)return;w({docKey:u,type:"image",value:l});return}const f=await _.repository.readFile(i,e.path,e.type==="conflict"?!0:V);if(s!==b.current)return;if(e.type==="conflict"){w({docKey:u,type:"conflict",value:f});return}w(l=>l&&l.docKey===u&&l.type==="file"&&C.current||l&&l.docKey===u&&l.type==="file"&&l.value.content===f.content&&l.value.size===f.size&&l.value.binary===f.binary&&l.value.tooLarge===f.tooLarge?l:{docKey:u,type:"file",value:f})}else{const f=e.type!=="diff";let l=f?F.get(u):void 0;if(l||(l=e.type==="commit"?await _.diff.getCommit(i,e.oid):e.type==="commit-file"?await _.diff.getCommitFile(i,e.oid,e.path,e.oldPath):await _.diff.get({repositoryId:i,path:e.path,kind:e.kind}),f&&F.set(u,l)),s!==b.current)return;const p=l;w(c=>c&&c.docKey===u&&c.type==="diff"&&c.value.patch===p.patch&&c.value.binary===p.binary?c:{docKey:u,type:"diff",value:p})}}catch(f){s===b.current&&q(f instanceof Error?f.message:"Could not load the viewer.")}finally{s===b.current&&L(!1)}})()},[V,u,i,y,e]);const j=v==="system"?"system":v,te=d?"wrap":"scroll",N=n.useCallback(s=>{C.current=s},[]),S=n.useCallback(async(s,h,f)=>{const l=E(s),p=await _.repository.writeFile(i,s,h,l?.expectedContent??f);return p.status==="saved"&&(C.current=!1,A(s),w(c=>c?.type==="file"&&c.value.path===s?{...c,value:{...c.value,content:h,binary:!1,tooLarge:!1,size:p.size,mtimeMs:p.mtimeMs}}:c)),p},[E,A,i]),B=n.useCallback(s=>s.path,[]),k=n.useCallback(s=>E(s.path)?.content??s.content,[E]),z=n.useCallback(s=>h=>O(s.path,h,s.content,s.mtimeMs),[O]),ie=ee&&a!==null&&!D;let r,P=null;if(!e)r=t.jsx(we,{});else if(e.type==="pull-request")r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(he,{repositoryId:i,prNumber:e.number,diffView:o,themeType:j,wrapLines:d,onDiffViewChange:K,onWrapLinesChange:M,onClose:()=>$(null)},`${i}:${e.number}`)});else if(D)r=t.jsx("div",{className:"viewer-message text-destructive",children:D});else if(!a)r=t.jsxs("div",{className:"viewer-message",children:[t.jsx(R,{className:"spinner"})," ",t.jsx(Y,{text:"Loading…"})]});else if(a.type==="image")r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ve,{image:a.value},`${a.value.path}:${a.value.mtimeMs}`)});else if(a.type!=="diff"&&a.value.binary)r=t.jsxs("div",{className:"viewer-message",children:["Binary file · ",X(a.value.size)]});else if(a.type==="file"&&a.value.tooLarge&&!V)r=t.jsxs("div",{className:"viewer-message flex-col gap-3",children:[t.jsxs("p",{children:["The file is ",X(a.value.size),". Preview is limited to protect performance."]}),t.jsx(J,{variant:"outline",onClick:()=>H(!0),children:"Load preview"})]});else if(a.type==="file"&&a.value.tooLarge)r=t.jsx("div",{className:"viewer-message text-destructive",children:"The file exceeds the built-in editor's 8 MB safety limit."});else if(a.type==="conflict"&&a.value.tooLarge)r=t.jsx("div",{className:"viewer-message text-destructive",children:"The conflicted file exceeds the viewer's safe limit. Open it in an external editor to resolve it."});else if(a.type==="conflict")r=null,P=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(U,{kind:"conflict",contentKey:a.docKey,file:a.value,themeType:j,overflow:te,onUpdate:W,onResolve:I})});else if(a.type==="file"&&le(a.value.path)){const s=a.value;r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(me,{file:s,initialContent:k(s),revision:y,themeType:j,wrapLines:d,readOnly:g||s.tooLarge,onOpenFile:Z,onDirtyChange:N,onDraftChange:z(s),onSave:S},B(s))})}else if(a.type==="file"&&re(a.value.path)){const s=a.value;r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ye,{file:s,initialContent:k(s),themeType:j,wrapLines:d,readOnly:g||s.tooLarge,onDirtyChange:N,onDraftChange:z(s),onSave:S},B(s))})}else if(a.type==="file"&&oe(a.value.path)){const s=a.value;r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(xe,{file:s,initialContent:k(s),themeType:j,wrapLines:d,readOnly:g||s.tooLarge,onDirtyChange:N,onDraftChange:z(s),onSave:S},B(s))})}else if(a.type==="file"){const s=a.value;r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(pe,{file:s,initialContent:k(s),themeType:j,wrapLines:d,readOnly:g,onDirtyChange:N,onDraftChange:z(s),onSave:S},B(s))})}else if(a.type==="diff"&&a.value.patch){const s=e.type==="commit"||e.type==="commit-file"?e:null,h=s?T.find(l=>l.oid===s.oid):void 0,f=e.type==="commit-file"?t.jsx(J,{type:"button",variant:"outline",size:"xs",onClick:()=>$({type:"commit",oid:e.oid,subject:h?.subject??e.oid.slice(0,8)}),children:"All files"}):void 0;r=null,P=t.jsxs("div",{className:s?"commit-diff-viewer":"standalone-diff-viewer",children:[s&&t.jsx(ge,{commit:h,fallbackSubject:"subject"in s?s.subject:""},s.oid),t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(U,{kind:"diff",contentKey:a.docKey,value:a.value,diffView:o,themeType:j,wrapLines:d,initiallyCollapsed:e.type==="commit",compact:e.type==="diff",scopeControl:f,onDiffViewChange:K,onWrapLinesChange:M,onClose:()=>$(null)})})]})}else a.type==="diff"?r=t.jsx("div",{className:"viewer-message",children:"No differences to show."}):r=t.jsx("div",{className:"viewer-message",children:"This file cannot be edited."});const G=t.jsxs(t.Fragment,{children:[P??t.jsx("div",{className:"viewer-transition",children:r},a?a.docKey:u),ie&&t.jsx("span",{className:"viewer-reloading","aria-hidden":"true",children:t.jsx(R,{className:"spinner"})})]});return a?.type!=="file"?G:t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ue,{enabled:!0,children:G})})}function ge({commit:i,fallbackSubject:e}){const o=i?.date?new Date(i.date):null,[d,v]=n.useState(!1),y=i?.body??"",g=y.length>240||y.split(`
3
- `).length>3;return t.jsxs("header",{className:"commit-diff-header",children:[t.jsx("h2",{children:i?.subject||e||"(no subject)"}),y&&t.jsxs("div",{className:"commit-diff-description-wrap",children:[t.jsx("p",{className:`commit-diff-description ${g&&!d?"collapsed":""}`,children:y}),g&&t.jsx("button",{type:"button",className:"commit-description-toggle","aria-expanded":d,onClick:()=>v(T=>!T),children:d?"Show less":"Show full description"})]}),t.jsxs("div",{className:"commit-diff-meta",children:[t.jsx("code",{children:i?.shortOid??"commit"}),i?.author&&t.jsxs("span",{children:[i.author,i.email?` <${i.email}>`:""]}),o&&Number.isFinite(o.getTime())&&t.jsxs(se,{children:[t.jsx(ae,{render:t.jsx("time",{dateTime:i?.date}),children:o.toLocaleString()}),t.jsx(ne,{children:o.toLocaleString()})]}),i?.parentCount&&i.parentCount>1?t.jsx("span",{children:"Merge commit"}):null,i?.upstreamState==="local-only"&&t.jsx("span",{className:"commit-local-label",children:"Local only"})]})]})}function je(i,e){return e?e.type==="pull-request"?`${i}:pull:${e.number}`:e.type==="commit"?`${i}:commit:${e.oid}`:e.type==="commit-file"?`${i}:commit-file:${e.oid}:${e.oldPath??""}:${e.path}`:e.type==="diff"?`${i}:diff:${e.kind}:${e.path}`:`${i}:${e.type}:${e.path}`:`${i}:empty`}function m(){return t.jsxs("div",{className:"viewer-message",children:[t.jsx(R,{className:"spinner"})," ",t.jsx(Y,{text:"Loading viewer…"})]})}function we(){return t.jsxs("div",{className:"viewer-empty",children:[t.jsx("h2",{children:"Nothing selected"}),t.jsx("p",{children:"Select a change, file, commit, or pull request."})]})}function X(i){return i?i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/1024/1024).toFixed(1)} MB`:"unknown size"}export{Se as default};