@opentig/cli 0.1.8 → 0.2.0

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 (120) hide show
  1. package/THIRD_PARTY_NOTICES.md +3 -1
  2. package/dist/bin.mjs +2 -2
  3. package/dist/chunks/{cli-BgNif2D1.mjs → cli-Bi6ET5UT.mjs} +15 -2
  4. package/dist/client/assets/App-BXZLGT86.js +74 -0
  5. package/dist/client/assets/CreatePullRequestDialog-DFonMYEx.js +2 -0
  6. package/dist/client/assets/{DiffWorkspace-Ca2ZUlVn.js → DiffWorkspace-RDG_Y70N.js} +5 -5
  7. package/dist/client/assets/{EditableFileViewer-85aEeMBK.js → EditableFileViewer-CsbifqBO.js} +1 -1
  8. package/dist/client/assets/{File-DTtWrbYf.js → File-CHjvYpb2.js} +1 -1
  9. package/dist/client/assets/FilesView-Dl8QFbFA.js +1 -0
  10. package/dist/client/assets/GitHubAvatar-CnBaloV0.js +1 -0
  11. package/dist/client/assets/HistoryView-BgCZU2JO.js +1 -0
  12. package/dist/client/assets/{HtmlFileViewer-bL6T57PQ.js → HtmlFileViewer-h8ULU8Gy.js} +1 -1
  13. package/dist/client/assets/{IconEdit-DePJMGIi.js → IconEdit-Cg8S2wqW.js} +1 -1
  14. package/dist/client/assets/IconFolderSymlink-BZSLX1ez.js +1 -0
  15. package/dist/client/assets/{ImageFileViewer-DJaHH3hJ.js → ImageFileViewer-Cjw58ckv.js} +1 -1
  16. package/dist/client/assets/LocalRefsDialog-DNgrd7Qp.js +1 -0
  17. package/dist/client/assets/{MarkdownFileViewer-BNPb9v8u.js → MarkdownFileViewer-kLiduag6.js} +2 -2
  18. package/dist/client/assets/{PairingPage-D9oguvKU.js → PairingPage-C97sv-8s.js} +1 -1
  19. package/dist/client/assets/{PierreDiffViewer-8wTLYd5-.js → PierreDiffViewer-eAcugmoF.js} +1 -1
  20. package/dist/client/assets/{PierreEditBoundary-KzU3HDc2.js → PierreEditBoundary-DlGd1pqO.js} +1 -1
  21. package/dist/client/assets/{PierreWorkerPool-DH2jp9oe.js → PierreWorkerPool-Col4k7qz.js} +1 -1
  22. package/dist/client/assets/{PullRequestDiff-DK-m07ZP.js → PullRequestDiff-DhKTXyIF.js} +1 -1
  23. package/dist/client/assets/PullRequestViewer-BgI8HFMe.js +2 -0
  24. package/dist/client/assets/PullRequestsView-PYWLy8We.js +1 -0
  25. package/dist/client/assets/QuickOpenDialog-BFDDZVCL.js +1 -0
  26. package/dist/client/assets/RepositoryProjectsDialog-CvB8KcFp.js +1 -0
  27. package/dist/client/assets/SearchView-BwF_MsxK.js +1 -0
  28. package/dist/client/assets/SettingsDialog-DIcLmXSE.js +9 -0
  29. package/dist/client/assets/Viewer-o1hDU33O.js +3 -0
  30. package/dist/client/assets/{abnfDiagram-N423BO3Z-CkHOGdAl.js → abnfDiagram-N423BO3Z-BvrnK_R-.js} +1 -1
  31. package/dist/client/assets/{arc-Dj8F8CO5.js → arc-DLa3_7ua.js} +1 -1
  32. package/dist/client/assets/{architectureDiagram-T3A2C74G-g87Y5LXk.js → architectureDiagram-T3A2C74G-BexwhnyX.js} +1 -1
  33. package/dist/client/assets/base-ui-CJ8ZIx3d.js +1 -0
  34. package/dist/client/assets/{blockDiagram-VBNYF7ZC-D6efB7jD.js → blockDiagram-VBNYF7ZC-CoOttUUo.js} +1 -1
  35. package/dist/client/assets/{c4Diagram-5PPSVZJV-DoZEC2xg.js → c4Diagram-5PPSVZJV-Bgp6ppUh.js} +1 -1
  36. package/dist/client/assets/channel-1k1AYpyV.js +1 -0
  37. package/dist/client/assets/{checkbox-DYwmgDPS.js → checkbox-BRH0ZNIC.js} +1 -1
  38. package/dist/client/assets/{chunk-2GRJ4B5K-Dr44hDNV.js → chunk-2GRJ4B5K-C_kzp38w.js} +1 -1
  39. package/dist/client/assets/{chunk-2Q5K7J3B-YIEyVOOL.js → chunk-2Q5K7J3B-CysYnRkJ.js} +1 -1
  40. package/dist/client/assets/{chunk-5RXB4S5H-gjmGBtkE.js → chunk-5RXB4S5H-oMS6x_ag.js} +1 -1
  41. package/dist/client/assets/{chunk-5VM5RSS4-DCOQko4g.js → chunk-5VM5RSS4-C5-dW5wf.js} +1 -1
  42. package/dist/client/assets/{chunk-6Q2QTUOP-DfGlvPVm.js → chunk-6Q2QTUOP-DxahInnA.js} +1 -1
  43. package/dist/client/assets/{chunk-GF5L2VYU-CCWOLPVL.js → chunk-GF5L2VYU-D7V-3eRg.js} +1 -1
  44. package/dist/client/assets/{chunk-JWPE2WC7-CFRTGh8r.js → chunk-JWPE2WC7-BrLmjbVP.js} +1 -1
  45. package/dist/client/assets/{chunk-KBJHAD2P-By3wsJVD.js → chunk-KBJHAD2P-CyOvijwM.js} +1 -1
  46. package/dist/client/assets/{chunk-RYQCIY6F-C0wmsHmy.js → chunk-RYQCIY6F-BvEjVjQs.js} +1 -1
  47. package/dist/client/assets/{chunk-XXDRQBXY-t3SnJvV_.js → chunk-XXDRQBXY-C_IY9A64.js} +1 -1
  48. package/dist/client/assets/classDiagram-JCYQIIEL-ChyNFpay.js +1 -0
  49. package/dist/client/assets/classDiagram-v2-OCEON4UE-ChyNFpay.js +1 -0
  50. package/dist/client/assets/{cose-bilkent-JH36ORCC-D3VltoVk.js → cose-bilkent-JH36ORCC-Cu7qZi7h.js} +1 -1
  51. package/dist/client/assets/{cynefin-VYW2F7L2-DwLwbeoe.js → cynefin-VYW2F7L2-B4M1t9lL.js} +1 -1
  52. package/dist/client/assets/{cynefinDiagram-MW4NZA55-B23kuaQF.js → cynefinDiagram-MW4NZA55-CAosOLmT.js} +1 -1
  53. package/dist/client/assets/{dagre-VZM6K2ZE-SgMrTr2p.js → dagre-VZM6K2ZE-q354V538.js} +1 -1
  54. package/dist/client/assets/{diagram-7IWD3JNH-C7cQN4aD.js → diagram-7IWD3JNH-C_CzkBPt.js} +1 -1
  55. package/dist/client/assets/{diagram-B4RE2ZJO-CzeI3yOw.js → diagram-B4RE2ZJO-VvvYHE9c.js} +1 -1
  56. package/dist/client/assets/{diagram-LBJQPF4R-DhKm4hlI.js → diagram-LBJQPF4R-D8vRQwb5.js} +1 -1
  57. package/dist/client/assets/{diagram-Q27KOJAE-BXlU6Wp3.js → diagram-Q27KOJAE-Bul4aDKg.js} +1 -1
  58. package/dist/client/assets/{diagram-UB23O5K3-BOwY_YwR.js → diagram-UB23O5K3-DNadEE58.js} +1 -1
  59. package/dist/client/assets/{ebnfDiagram-BXEA7PRR-CuIQuYPa.js → ebnfDiagram-BXEA7PRR-Bf-68MMZ.js} +1 -1
  60. package/dist/client/assets/{erDiagram-JOGREHBK-d45NhKfk.js → erDiagram-JOGREHBK-CJ-jHFsf.js} +1 -1
  61. package/dist/client/assets/{flowDiagram-UKHOOZJN-Dzq-6qo7.js → flowDiagram-UKHOOZJN-DMOdinBU.js} +1 -1
  62. package/dist/client/assets/{ganttDiagram-PKOTCBZU-RVlL9mX2.js → ganttDiagram-PKOTCBZU-DzezS3Zy.js} +1 -1
  63. package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-8kEJVUFH.js → gitGraphDiagram-DS77QQ5N-Dftpvns8.js} +1 -1
  64. package/dist/client/assets/index-BfA4tAc1.css +1 -0
  65. package/dist/client/assets/{index-CQcx9aRt.js → index-DAUK3rnz.js} +4 -4
  66. package/dist/client/assets/{infoDiagram-6WML65LV-Co21Ql9M.js → infoDiagram-6WML65LV-DmgUBq17.js} +1 -1
  67. package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-BvPB_G97.js → ishikawaDiagram-WSZJBQD7-CL0PQhpQ.js} +1 -1
  68. package/dist/client/assets/{journeyDiagram-NVQOT4AX-k7x89IE9.js → journeyDiagram-NVQOT4AX-Ck4pQx_A.js} +1 -1
  69. package/dist/client/assets/{kanban-definition-27J2QSJJ-BjrgN30t.js → kanban-definition-27J2QSJJ-DuRZxBql.js} +1 -1
  70. package/dist/client/assets/{linear-m158kske.js → linear-C2JDCaz4.js} +1 -1
  71. package/dist/client/assets/{mermaid.core-C0FKucv-.js → mermaid.core-9dt2ugQA.js} +4 -4
  72. package/dist/client/assets/{mindmap-definition-FAOFIHXS-CF8noycK.js → mindmap-definition-FAOFIHXS-vy0fdDF0.js} +1 -1
  73. package/dist/client/assets/{pegDiagram-VL7TDLO6-_y7nfJFV.js → pegDiagram-VL7TDLO6-DjVJy-Gm.js} +1 -1
  74. package/dist/client/assets/{pieDiagram-7S7Q4E2Y-DhdWHi45.js → pieDiagram-7S7Q4E2Y-ATbd_8vw.js} +1 -1
  75. package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-BRvEIECQ.js → quadrantDiagram-CIZ2JOQS-C8o6ofcl.js} +1 -1
  76. package/dist/client/assets/{railroadDiagram-AXF67PYL-BgLZ8XU1.js → railroadDiagram-AXF67PYL-Qvij9Ubo.js} +1 -1
  77. package/dist/client/assets/{render-markdown-2GjhuGA-.js → render-markdown-BtCybfvQ.js} +6 -6
  78. package/dist/client/assets/{requirementDiagram-LRYGKXZP-CX-gxyGF.js → requirementDiagram-LRYGKXZP-yLfrba2h.js} +1 -1
  79. package/dist/client/assets/{sankeyDiagram-W5VNT64P-CLSjSU_X.js → sankeyDiagram-W5VNT64P-BTXRtTyG.js} +1 -1
  80. package/dist/client/assets/{sequenceDiagram-SI44F4Z6-dGlHyZRB.js → sequenceDiagram-SI44F4Z6-BN1CCZIX.js} +1 -1
  81. package/dist/client/assets/{sizeCapture-X5ZJPWSS-BH3qO9T3.js → sizeCapture-X5ZJPWSS-BfXjBBYo.js} +1 -1
  82. package/dist/client/assets/{stateDiagram-OKZ733FA-FXxo1iIM.js → stateDiagram-OKZ733FA-DMAWiBsP.js} +1 -1
  83. package/dist/client/assets/stateDiagram-v2-UEYNNEHI-D_ofZeaa.js +1 -0
  84. package/dist/client/assets/{swimlanes-SLNWSIFB-VJGIuM4S.js → swimlanes-SLNWSIFB-BD20m5cw.js} +2 -2
  85. package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-CF9m5JSB.js +8 -0
  86. package/dist/client/assets/{tanstack-CtfgE41X.js → tanstack-B0Sf7wNU.js} +1 -1
  87. package/dist/client/assets/{timeline-definition-Z64GVDOM-BXNTAanY.js → timeline-definition-Z64GVDOM-gtc0-AHB.js} +1 -1
  88. package/dist/client/assets/{vennDiagram-T6HMQDX7-D9nXAts5.js → vennDiagram-T6HMQDX7-Cdr4AXTp.js} +1 -1
  89. package/dist/client/assets/viewer-tabs-D-T0xQaq.js +1 -0
  90. package/dist/client/assets/{wardleyDiagram-T6FBY63Y-D89EaEfa.js → wardleyDiagram-T6FBY63Y-BcU4vxO8.js} +1 -1
  91. package/dist/client/assets/{xychartDiagram-ELKLHX3M-B_xFDiIh.js → xychartDiagram-ELKLHX3M-B3Zuadj8.js} +1 -1
  92. package/dist/client/index.html +4 -4
  93. package/dist/dev.mjs +1 -1
  94. package/dist/manifest.json +1 -1
  95. package/dist/server.mjs +526 -127
  96. package/dist/utility.mjs +1 -1
  97. package/package.json +2 -2
  98. package/dist/client/assets/App-9EfSdZB8.js +0 -74
  99. package/dist/client/assets/CreatePullRequestDialog-BgVrWdkH.js +0 -2
  100. package/dist/client/assets/FilesView-rT5hzb7y.js +0 -1
  101. package/dist/client/assets/GitHubAvatar-EO1TD_1z.js +0 -1
  102. package/dist/client/assets/HistoryView-C4c0CqMC.js +0 -1
  103. package/dist/client/assets/IconFolderPlus-ByGyA0Di.js +0 -1
  104. package/dist/client/assets/LocalRefsDialog-D9wYZWBg.js +0 -1
  105. package/dist/client/assets/PullRequestViewer-CpLwq4o2.js +0 -2
  106. package/dist/client/assets/PullRequestsView-DnvXaJ4t.js +0 -1
  107. package/dist/client/assets/QuickOpenDialog-DIWjfUkt.js +0 -1
  108. package/dist/client/assets/RepositoryProjectsDialog-BsQn5Yjr.js +0 -1
  109. package/dist/client/assets/SearchView-D-91dtSv.js +0 -1
  110. package/dist/client/assets/SettingsDialog-dJUYk2cP.js +0 -9
  111. package/dist/client/assets/Viewer-GH-5bJW4.js +0 -3
  112. package/dist/client/assets/base-ui-DT3JsyND.js +0 -1
  113. package/dist/client/assets/channel-Dsy2VD23.js +0 -1
  114. package/dist/client/assets/classDiagram-JCYQIIEL-BBQJgoWd.js +0 -1
  115. package/dist/client/assets/classDiagram-v2-OCEON4UE-BBQJgoWd.js +0 -1
  116. package/dist/client/assets/gh-utils-LsOSydCg.js +0 -1
  117. package/dist/client/assets/index-DMbFAH51.css +0 -1
  118. package/dist/client/assets/stateDiagram-v2-UEYNNEHI-DqxQ14yP.js +0 -1
  119. package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-No0dCAkd.js +0 -8
  120. package/dist/client/assets/viewer-tabs-DkLmDzFg.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/render-markdown-2GjhuGA-.js","assets/App-9EfSdZB8.js","assets/index-CQcx9aRt.js","assets/react-rd22PHbN.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-DMbFAH51.css","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
2
- import{c as W,_ as $,o as j,B as g,s as x}from"./index-CQcx9aRt.js";import{r as n,j as t}from"./react-rd22PHbN.js";import{C as J}from"./checkbox-DYwmgDPS.js";import{D as K,c as Q,d as X,M as O,e as Y,k as D,N as Z,h as ee,T as te,O as ae,P as se,G as re}from"./App-9EfSdZB8.js";import{V as ne,a as ie,b as L}from"./viewer-tabs-DkLmDzFg.js";import{o as le,g as ce,a as oe}from"./gh-utils-LsOSydCg.js";/* empty css */import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";const de=[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]],M=W("outline","upload","Upload",de);function Ne(e){const[r,u]=n.useState(""),[c,C]=n.useState(""),[o,B]=n.useState(""),[y,I]=n.useState(!1),[N,T]=n.useState("edit"),[H,_]=n.useState(""),[i,q]=n.useState(!1),[l,E]=n.useState(null),h=n.useRef(null),w=n.useRef(0),v=e.status?.branch??null,b=e.preferences.commitMessageHarness,S=e.preferences.commitMessageModels[b]??"default",V=he(e.aiProviders,b,S),m=n.useMemo(()=>e.branches.filter(a=>a.remote&&!a.fullName.endsWith("/HEAD")&&a.name!==`origin/${v??""}`).map(a=>a.name),[v,e.branches]);n.useEffect(()=>{e.open&&B(a=>a&&m.includes(a)?a:ue(m))},[m,e.open]),n.useEffect(()=>{if(!e.open||N!=="preview")return;const a=++w.current;$(async()=>{const{renderMarkdown:s}=await import("./render-markdown-2GjhuGA-.js").then(p=>p.a);return{renderMarkdown:s}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({renderMarkdown:s})=>s(c||"_No description._")).then(s=>{a===w.current&&_(s)}).catch(()=>{a===w.current&&_("<p>Could not render the preview.</p>")})},[c,N,e.open]),n.useEffect(()=>{if(e.open)return;const a=h.current;a&&j.github.cancelDraft(a).catch(()=>{})},[e.open]);const k=e.status!==null&&!e.status.upstream,P=e.status!==null&&!!e.status.upstream&&e.status.ahead>0,f=e.status!==null&&(e.status.detached||e.status.unborn||!e.status.branch),d=e.status===null||k||P||f||m.length===0,F=async()=>{const a=h.current;a&&await j.github.cancelDraft(a).catch(()=>{})},U=async()=>{if(d||l||i||!o)return;const a=crypto.randomUUID();h.current=a,E(a);try{const s=await j.github.generateDraft({repositoryId:e.repositoryId,base:o,harness:b,model:S,requestId:a});if(h.current!==a)return;u(s.title),C(s.body),T("edit"),x.success({title:`Draft generated with ${R(s.harness)}`,description:s.contextWasTruncated?"A truncated version of the branch diff was used. Review before publishing.":"Review and edit before publishing."})}catch(s){const p=me(s);p?.code==="AI_CANCELLED"?x.info({title:"Generation canceled"}):x.error({title:"Could not generate the draft",description:p?.message??A(s),duration:1e4})}finally{h.current===a&&(h.current=null),E(s=>s===a?null:s)}},z=async()=>{if(!(d||i||l||!r.trim()||!o)){q(!0);try{const a=await j.github.createPullRequest({repositoryId:e.repositoryId,title:r.trim(),body:c,base:o,draft:y});u(""),C(""),I(!1),x.success({title:y?"Draft pull request created":"Pull request created",description:a.url,button:{title:"Open",onClick:()=>le(a.url)}}),e.onCreated(a.number)}catch(a){const s=ce(a);x.error({title:oe(s),description:s?.message??A(a),duration:1e4})}finally{q(!1)}}};return t.jsx(K,{open:e.open,onOpenChange:a=>{i||e.onOpenChange(a)},children:t.jsxs(Q,{className:"create-pr-dialog",children:[t.jsxs("div",{className:"create-pr-content",children:[t.jsxs(X,{children:[t.jsx(O,{"aria-hidden":"true"})," Create pull request"]}),t.jsx(Y,{children:v?t.jsxs(t.Fragment,{children:["From ",t.jsx("code",{children:v})," into the selected base branch on GitHub."]}):"Check out a branch to create a pull request."}),k&&t.jsxs("div",{className:"create-pr-notice",children:[t.jsx("span",{children:f?"Check out a branch with at least one commit before publishing.":"Publish this branch before creating a pull request."}),t.jsxs(g,{variant:"outline",size:"xs",disabled:e.pushBusy||f||!!e.status?.readOnly,onClick:e.onPush,children:[e.pushBusy?t.jsx(D,{className:"animate-spin"}):t.jsx(M,{})," Publish branch"]})]}),P&&t.jsxs("div",{className:"create-pr-notice",children:[t.jsxs("span",{children:["The branch has ",e.status?.ahead," unpushed ",e.status?.ahead===1?"commit":"commits",". Push them so the pull request includes your work."]}),t.jsxs(g,{variant:"outline",size:"xs",disabled:e.pushBusy,onClick:e.onPush,children:[e.pushBusy?t.jsx(D,{className:"animate-spin"}):t.jsx(M,{})," Push"]})]}),!k&&!P&&f&&t.jsx("div",{className:"create-pr-notice",children:t.jsx("span",{children:"Pull requests need a checked-out branch with commits."})}),m.length===0&&!f&&t.jsx("div",{className:"create-pr-notice",children:t.jsx("span",{children:"No remote branches are available to use as a base. Fetch the remote first."})}),t.jsxs("div",{className:"create-pr-base-row",children:[t.jsxs("div",{className:"create-pr-field",children:[t.jsx("label",{htmlFor:"create-pr-base",children:"Base branch"}),t.jsx(Z,{groups:[{id:"branches",label:"",items:m.map(a=>({value:a,label:G(a),search:a,icon:t.jsx(ee,{})}))}],value:o,onValueChange:B,label:"Base branch",triggerId:"create-pr-base",triggerLabel:o?G(o):"Select a base",triggerClassName:"create-pr-base",size:"default",align:"start",placeholder:"Search base branches…",disabled:d||i||!!l})]}),t.jsxs("label",{className:"create-pr-draft",children:[t.jsx(J,{checked:y,onCheckedChange:a=>I(a===!0),disabled:d||i||!!l}),t.jsx("span",{children:"Create as draft"})]})]}),t.jsxs("div",{className:"create-pr-field",children:[t.jsx("label",{htmlFor:"create-pr-title",children:"Title"}),t.jsx("input",{id:"create-pr-title",className:"create-pr-title",value:r,maxLength:300,placeholder:"Pull request title",disabled:d||i||!!l,onChange:a=>u(a.target.value)})]}),t.jsxs(ne,{value:N,onValueChange:a=>T(a),className:"create-pr-field create-pr-body-field",children:[t.jsxs("div",{className:"create-pr-body-header",children:[t.jsx("label",{htmlFor:"create-pr-body",children:"Description"}),t.jsx(ie,{label:"Description view",className:"markdown-viewer-tabs",items:[{value:"edit",label:"Edit"},{value:"preview",label:"Preview"}]})]}),t.jsx(L,{value:"edit",className:"create-pr-body-panel",children:t.jsx(te,{id:"create-pr-body",value:c,rows:10,placeholder:"Describe the change (GitHub Markdown)",disabled:d||i||!!l,onChange:a=>C(a.target.value)})}),t.jsx(L,{value:"preview",className:"create-pr-preview markdown-prose",dangerouslySetInnerHTML:{__html:H}})]})]}),t.jsxs("div",{className:"create-pr-actions",children:[t.jsxs(g,{variant:"outline",className:"create-pr-generate commit-composer-generate",disabled:d||i,"aria-label":l?"Cancel generation":void 0,onClick:()=>l?void F():void U(),children:[l?t.jsx(ae,{className:"text-destructive"}):t.jsx(se,{harness:b}),l?t.jsx(re,{text:"Generating draft…"}):t.jsxs("span",{className:"commit-composer-provider",children:["Generate with ",t.jsx("span",{className:"commit-composer-harness",children:R(b)}),t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{className:"commit-composer-model",children:V})]})]}),t.jsxs("div",{className:"create-pr-submit-actions",children:[t.jsx(g,{variant:"ghost",onClick:()=>e.onOpenChange(!1),disabled:i,children:"Cancel"}),t.jsxs(g,{onClick:()=>{z()},disabled:d||i||!!l||!r.trim()||!o,children:[i?t.jsx(D,{className:"animate-spin"}):t.jsx(O,{})," ",i?"Creating…":"Create pull request"]})]})]})]})})}function ue(e){return e.find(r=>r==="origin/main")??e.find(r=>r==="origin/master")??e[0]??""}function G(e){return e.replace(/^origin\//,"")}function R(e){return e==="codex"?"Codex":e==="claude"?"Claude Code":"OpenCode"}function he(e,r,u){return e?.find(c=>c.id===r)?.models.find(c=>c.id===u)?.label??(u==="default"?"Default (CLI)":u)}function me(e){if(!(e instanceof Error)||!("detail"in e)||!e.detail||typeof e.detail!="object")return null;const r=e.detail;return typeof r.code=="string"&&r.code.startsWith("AI_")&&typeof r.message=="string"?r:null}function A(e){return e instanceof Error?e.message:"An unexpected error occurred."}export{Ne as CreatePullRequestDialog};
@@ -1 +0,0 @@
1
- import{j as t,r as i,a as bt}from"./react-rd22PHbN.js";import{a as wt}from"./tanstack-CtfgE41X.js";import{a5 as Mt,a7 as vt,a9 as St,aa as Ue,ab as Nt,_ as Rt,ac as It,ad as Et,ae as Ft,af as Tt,ag as T,G as Pt,ah as _t,j as zt,V as Oe,ai as $t,aj as Ye,ak as qe,al as Kt,am as Lt,an as At,ao as Ht,Y as Vt,ap as Bt,aq as Fe,ar as Ut,as as Yt,$ as We,at as qt,au as Ee,av as Xt,aw as Gt,t as Ot,y as Wt,D as Zt,c as Jt,d as Qt,e as en}from"./App-9EfSdZB8.js";import{c as K,d as Te,B as H,I as tn}from"./index-CQcx9aRt.js";import{m as nn,n as sn,M as on,o as rn,p as an,q as ln,S as cn}from"./base-ui-DT3JsyND.js";import{I as Ze}from"./IconFolderPlus-ByGyA0Di.js";import{I as dn}from"./IconEdit-DePJMGIi.js";const un=[["path",{d:"M9 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M5 10h11a4 4 0 1 1 0 8h-1",key:"svg-1"}]],hn=K("outline","arrow-back-up","ArrowBackUp",un);const pn=[["path",{d:"M15 14l4 -4l-4 -4",key:"svg-0"}],["path",{d:"M19 10h-11a4 4 0 1 0 0 8h1",key:"svg-1"}]],fn=K("outline","arrow-forward-up","ArrowForwardUp",pn);const gn=[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2",key:"svg-1"}]],Je=K("outline","clipboard","Clipboard",gn);const xn=[["path",{d:"M3 4a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-16",key:"svg-0"}],["path",{d:"M12 3v18",key:"svg-1"}]],Qe=K("outline","columns-2","Columns2",xn);const mn=[["path",{d:"M4 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-0"}],["path",{d:"M14 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-1"}],["path",{d:"M9.15 14.85l8.85 -10.85",key:"svg-2"}],["path",{d:"M6 4l8.85 10.85",key:"svg-3"}]],jn=K("outline","cut","Cut",mn);const yn=[["path",{d:"M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]],Dn=K("outline","dots","Dots",yn);const kn=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M12 11l0 6",key:"svg-2"}],["path",{d:"M9 14l6 0",key:"svg-3"}]],et=K("outline","file-plus","FilePlus",kn);const Cn=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]],bn=K("outline","file-text","FileText",Cn),wn=nn,Mn=sn;function vn({className:n,children:d,...u}){return t.jsx(on,{children:t.jsx(rn,{className:"isolate z-50 outline-none",children:t.jsx(an,{"data-slot":"context-menu-content",className:Te("min-w-44 origin-(--transform-origin) rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",n),...u,children:d})})})}function b({className:n,...d}){return t.jsx(ln,{"data-slot":"context-menu-item",className:Te("flex h-8 cursor-default items-center gap-2 rounded-md px-2 text-xs outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",n),...d})}function oe({className:n,...d}){return t.jsx(cn,{"data-slot":"context-menu-separator",className:Te("mx-1 my-1 h-px bg-border",n),...d})}const Sn=29,xe=6,tt="files-tree-root-drop",Nn=550,Rn={duration:160,easing:"cubic-bezier(0.2, 0, 0, 1)"},Xe=6,In=n=>{const d=Kt(n),u=d.length>0?d:Lt(n),g=u.find(x=>x.id!==tt);return g?[g]:u.slice(0,1)};function nt(n,d,u=0){const g=[];for(const x of n)g.push({entry:x,depth:u}),x.type==="directory"&&d.has(x.path)&&g.push(...nt(x.children,d,u+1));return g}function En(n,d,u){const g=n.findIndex(p=>p.entry.path===d),x=n.findIndex(p=>p.entry.path===u);if(g===-1||x===-1)return[u];const[l,h]=g<=x?[g,x]:[x,g];return n.slice(l,h+1).map(p=>p.entry.path)}function me(n){return n.type==="directory"?n.path:We(n.path)}function Un({active:n,initialExpandedPaths:d,files:u,filesSnapshotRevision:g,showDotEnvFiles:x,activePath:l,readOnly:h,fileClipboardAvailable:p,revealAvailable:V,historyState:L,onQuickOpen:C,onUndo:A,onRedo:B,onOpenFile:j,onLoadDirectory:w,onPersistExpandedPaths:re,onCopyPath:je,onCopyEntries:ae,onCutEntries:ie,onCopyContents:ye,onPaste:G,onMoveEntries:De,onDeleteEntries:le,onReveal:ke,onRename:Ce,onCreate:be}){const we=Mt(),O=vt(),[P,Me]=i.useState(!1),S=O?44:Sn,ce=i.useRef(null),U=i.useRef(null),[m,R]=i.useState(new Set),[de,Y]=i.useState(l),[q,_]=i.useState(l),[N,W]=i.useState(()=>new Set(d)),[ue,Z]=i.useState([]),[M,z]=i.useState(null),[J,ve]=i.useState(null),[_e,st]=i.useState(null),[ot,rt]=i.useState(!1),[at,$]=i.useState(null),[he,it]=i.useState(0),[I,pe]=i.useState(new Map),lt=St(Ue(Ht,{activationConstraint:{distance:5}}),Ue(At)),ze=i.useRef(I),Q=i.useRef(new Set),$e=i.useRef(0),E=i.useRef(null),ee=i.useRef(null),Ke=i.useRef(d.join("\0")),fe=i.useMemo(()=>new Set(I.keys()),[I]),F=i.useMemo(()=>u===null?null:Nt(u,I),[u,I]),f=i.useMemo(()=>F===null?null:x?F:Rt(F),[F,x]);i.useEffect(()=>{ze.current=I},[I]),i.useEffect(()=>{st(document.getElementById(It))},[l]),i.useEffect(()=>{const e=window.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>rt(e.matches);return s(),e.addEventListener("change",s),()=>e.removeEventListener("change",s)},[]),i.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]),i.useEffect(()=>{const e=++$e.current,s=[...ze.current.keys()];s.length!==0&&Promise.all(s.map(async o=>({path:o,children:await w(o)}))).then(o=>{if(e!==$e.current)return;const r=new Map(o.map(({path:c,children:a})=>[c,a]));pe(c=>Et(c,r))})},[g,w]),i.useEffect(()=>{if(!F){Q.current.clear(),pe(e=>e.size===0?e:new Map);return}W(e=>{const s=new Set(Ft(F,e,fe).retained);return Ge(e,s)?e:s})},[fe,F]),i.useEffect(()=>{if(!F)return;const e=Tt(F,N,fe),s=e.join("\0");s!==Ke.current&&(Ke.current=s,re(e))},[N,fe,F,re]),i.useEffect(()=>{if(!n||!f)return;let e=Math.max(0,2-Q.current.size);for(const s of N){if(e===0)break;const o=T(f,s);!o||o.type!=="directory"||o.ignored!==!0||o.children.length>0||I.has(s)||Q.current.has(s)||(Q.current.add(s),e-=1,w(s).catch(()=>[]).then(r=>{pe(c=>new Map(c).set(s,r))}).finally(()=>{Q.current.delete(s)}))}},[n,N,I,w,f]),i.useEffect(()=>{n||($(null),Z([]),z(null),ve(null),E.current&&clearTimeout(E.current),E.current=null,ee.current=null)},[n]),i.useEffect(()=>{f&&(R(e=>{if(e.size===0)return e;const s=new Set([...e].filter(o=>T(f,o)));return s.size===e.size?e:s}),Y(e=>e&&T(f,e)?e:null),_(e=>e&&T(f,e)?e:l&&T(f,l)?l:null))},[l,f]);const y=i.useMemo(()=>f?nt(f,N):[],[N,f]),X=wt({enabled:n,count:y.length,getScrollElement:()=>ce.current,estimateSize:()=>S,getItemKey:e=>y[e]?.entry.path??e,overscan:12,paddingStart:xe,paddingEnd:12});i.useEffect(()=>{X.measure()},[X,S]),i.useEffect(()=>{!n||!l||!f||!T(f,l)||W(e=>{const s=new Set(e);let o=!1;const r=l.split("/");let c="";for(let a=0;a<r.length-1;a+=1)c=c?`${c}/${r[a]}`:r[a],s.has(c)||(s.add(c),o=!0);return o?s:e})},[n,l,f]),i.useEffect(()=>{if(!n)return;if(!l){U.current=null;return}if(U.current===l)return;const e=y.findIndex(s=>s.entry.path===l);e>=0&&(X.scrollToIndex(e,{align:"auto"}),U.current=l)},[n,l,y]);const Le=i.useMemo(()=>{const e=new Map;for(const s of y)e.set(s.entry.path,s);return e},[y]),te=i.useMemo(()=>{const e={headers:[],push:0};if(y.length===0||!l)return e;const s=new Set,o=l.split("/");let r="";for(let k=0;k<o.length-1;k+=1)r=r?`${r}/${o[k]}`:o[k],s.add(r);if(s.size===0)return e;const c=Math.min(y.length-1,Math.max(0,Math.floor((he-xe)/S))),a=y[c];if(!a)return e;const D=a.entry.path.split("/"),v=[];let se="";for(let k=0;k<D.length-1;k+=1){if(se=se?`${se}/${D[k]}`:D[k],!s.has(se))continue;const Ie=Le.get(se);Ie&&Ie.entry.type==="directory"&&v.push(Ie)}if(v.length>Xe&&v.splice(0,v.length-Xe),v.length===0)return e;const Dt=v[v.length-1],Ve=v.length*S;let Be=1/0;const kt=Math.ceil((he+Ve-xe)/S)+2;for(let k=c;k<y.length&&k<=kt;k+=1)if(y[k].depth<=Dt.depth){Be=xe+k*S;break}const Ct=Math.max(0,Math.min(S,Ve-(Be-he)));return{headers:v,push:Ct}},[y,Le,he,l,S]);if(f===null)return t.jsx("div",{className:"view-loading",role:"status",hidden:!n,children:t.jsx(Pt,{text:"Loading files…"})});const ct=P||m.size>0?m:l?new Set([l]):new Set,dt=m.size>0?[...m]:l?[l]:[],Se=e=>{const s=[];for(const o of e){const r=T(f,o);r&&s.push(r)}return s},Ne=e=>{R(new Set([e])),Y(e),_(e)},ut=e=>{const s=y.findIndex(o=>o.entry.path===e.path);s>=0&&X.scrollToIndex(s,{align:"start"})},ht=(e,s)=>{if(O&&P){R(o=>{const r=new Set(o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r});return}if(s.shift&&(de||q)){const o=En(y,de??q,e.path);R(new Set(o)),_(e.path);return}if(s.ctrl){R(o=>{const r=new Set(o.size===0&&l?[l]:o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r}),Y(e.path),_(e.path),e.type==="file"&&j(e.path,"pinned");return}Ne(e.path),e.type==="file"?j(e.path):Ae(e.path)},pt=e=>{!(O&&P)&&e.type==="file"&&j(e.path,"pinned")},ft=e=>{m.has(e.path)||Ne(e.path)},ge=e=>m.has(e.path)&&m.size>0?Se(m):[e],gt=e=>{if(Ut(e.target))return;const s=Yt(e.nativeEvent,we);if(s==="undo"&&L.canUndo&&!h){e.preventDefault(),e.repeat||A();return}if(s==="redo"&&L.canRedo&&!h){e.preventDefault(),e.repeat||B();return}const o=(e.ctrlKey||e.metaKey)&&!e.altKey,r=e.key.toLowerCase();if(o&&r==="a"){e.preventDefault(),R(new Set(y.map(D=>D.entry.path)));return}const c=Se(dt),a=q?T(f,q):null;if(o&&r==="c"&&c.length){e.preventDefault(),ae(c);return}if(o&&r==="x"&&c.length&&!h){e.preventDefault(),ie(c);return}if(o&&r==="v"&&!h&&p){e.preventDefault();const D=a?me(a):We(c[0]?.path??"");G(D);return}if(e.key==="F2"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h){if(m.size===1){const D=T(f,[...m][0]);D&&(e.preventDefault(),$({mode:"rename",entry:D}))}return}e.key==="Delete"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h&&c.length&&(e.preventDefault(),le(c))},xt=async(e,s)=>{const o=Se(e);o.length&&await De(o,s)},Ae=(e,s=!1)=>{const o=!s&&N.has(e),r=o&&T(f??[],e)?.ignored===!0;W(c=>{const a=new Set(c);if(s||!a.has(e)){if(a.has(e))return c;a.add(e)}else if(r)for(const D of a)Ee(e,D)&&a.delete(D);else a.delete(e);return Ge(c,a)?c:a}),o&&pe(c=>{const a=[...c.keys()].filter(v=>Ee(e,v));if(a.length===0)return c;const D=new Map(c);for(const v of a)D.delete(v);return D})},ne=()=>{E.current&&clearTimeout(E.current),E.current=null,ee.current=null},He=()=>{ne(),Z([]),z(null),ve(null)},Re=e=>{const s=e.active.data.current;return s?.entry&&Array.isArray(s.sourcePaths)?{entry:s.entry,sourcePaths:s.sourcePaths}:null},mt=e=>{const s=Re(e);s&&(m.has(s.entry.path)||Ne(s.entry.path),Z(s.sourcePaths),ve({entry:s.entry,sourcePaths:s.sourcePaths,count:s.sourcePaths.length}))},jt=e=>{const s=Re(e);if(e.over?.data.current?.openPinned===!0){z(null),ne();return}const o=e.over?.data.current?.targetDirectory;if(!s||typeof o!="string"||!qe(s.sourcePaths,o)){z(null),ne();return}z(o);const r=e.over?.data.current?.expandPath;if(typeof r!="string"||N.has(r)){ne();return}ee.current!==r&&(ne(),ee.current=r,E.current=setTimeout(()=>{Ae(r,!0),E.current=null,ee.current=null},Nn))},yt=e=>{const s=Re(e),o=e.over?.data.current?.openPinned===!0,r=e.over?.data.current?.targetDirectory;if(He(),s&&o&&Ye(s.entry,s.sourcePaths)){j(s.entry.path,"pinned");return}s&&typeof r=="string"&&qe(s.sourcePaths,r)&&xt(s.sourcePaths,r)};return t.jsxs(_t,{sensors:lt,collisionDetection:In,autoScroll:{enabled:!0,threshold:{x:.1,y:.16},acceleration:12},onDragStart:mt,onDragOver:jt,onDragCancel:He,onDragEnd:yt,children:[t.jsxs("div",{className:"files-mobile-tools",children:[t.jsxs(H,{variant:"ghost",size:"sm",onClick:C,children:[t.jsx(zt,{})," Find file"]}),t.jsx(H,{variant:"ghost",size:"sm","aria-pressed":P,onClick:()=>{Me(!P),R(new Set)},children:P?`Done (${m.size})`:"Select"}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-file",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(et,{})," New file"]}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-folder",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(Ze,{})," Folder"]}),p&&t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>{G("")},children:[t.jsx(Je,{})," Paste"]})]}),t.jsxs("div",{ref:ce,className:"files-view virtual-scroll",hidden:!n,onScroll:e=>it(e.currentTarget.scrollTop),children:[te.headers.length>0&&t.jsx("div",{className:"files-sticky",children:te.headers.map((e,s)=>{const o=s===te.headers.length-1;return t.jsxs("button",{type:"button",className:"file-tree-row files-sticky-row","aria-label":`Scroll to ${e.entry.path}`,style:{top:s*S-(o?te.push:0),paddingLeft:12+e.depth*14,zIndex:te.headers.length-s},onClick:()=>ut(e.entry),children:[t.jsx(Oe,{className:"folder-chevron open"}),t.jsx(Pe,{path:e.entry.path,type:"directory",expanded:!0}),t.jsx("span",{children:e.entry.name})]},e.entry.path)})}),f.length?t.jsx(Fn,{role:"tree","aria-label":"Files",className:`files-tree ${M===""&&ue.length>0?"root-drop-target":""}`,style:{height:X.getTotalSize()},tabIndex:0,onKeyDown:gt,onPointerDown:e=>{e.target.closest(".file-tree-row, .file-touch-actions")||(R(new Set),Y(null),_(null),e.currentTarget.focus())},children:X.getVirtualItems().map(e=>{const{entry:s,depth:o}=y[e.index],r=s.type==="directory"&&N.has(s.path),c=m.has(s.path)&&m.size>1;return t.jsx("div",{className:"virtual-row",style:{height:e.size,transform:`translateY(${e.start}px)`},children:t.jsx(_n,{entry:s,depth:o,expanded:r,pendingChildren:s.type==="directory"&&s.ignored===!0&&s.children.length===0&&!I.has(s.path),selected:ct.has(s.path),active:l===s.path,multiSelected:c,readOnly:h,fileClipboardAvailable:p,revealAvailable:V,historyState:L,onUndo:A,onRedo:B,draggedPaths:ue,dropTargetPath:M,onFocus:_,onRowClick:ht,onRowDoubleClick:pt,onRowContextMenu:ft,onOpen:a=>j(a.path),onOpenPinned:a=>j(a.path,"pinned"),onCopy:a=>{ae(ge(a))},onCut:a=>{ie(ge(a))},onPasteInto:a=>{G(me(a))},onCopyPath:a=>{je(ge(a))},onCopyContents:ye,onRename:a=>$({mode:"rename",entry:a}),onNewFile:a=>$({mode:"new-file",entry:a}),onNewFolder:a=>$({mode:"new-folder",entry:a}),onReveal:ke,onDelete:a=>{le(ge(a))},dragPaths:m.has(s.path)&&m.size>0?[...m]:[s.path]})},e.key)})}):t.jsx("p",{className:"empty-list",children:"No files."}),t.jsx(zn,{state:at,onClose:()=>$(null),onRename:Ce,onCreate:be})]}),t.jsx($t,{dropAnimation:ot?null:Rn,children:J&&t.jsx(Pn,{preview:J})}),_e&&bt.createPortal(t.jsx(Tn,{visible:!!(J&&Ye(J.entry,J.sourcePaths))}),_e)]})}function Fn(n){const{setNodeRef:d}=Fe({id:tt,data:{targetDirectory:"",expandPath:null}});return t.jsx("div",{ref:d,...n})}function Tn({visible:n}){const{isOver:d,setNodeRef:u}=Fe({id:"files-open-pinned-drop",data:{openPinned:!0}});return t.jsxs("div",{ref:u,className:`open-files-drop-target ${n?"visible":""} ${n&&d?"over":""}`,"aria-hidden":"true",children:[t.jsx(Qe,{}),t.jsx("span",{children:"Drop to open beside"})]})}function Pn({preview:n}){return t.jsxs("div",{className:"file-drag-overlay",children:[t.jsx(Pe,{path:n.entry.path,type:n.entry.type,expanded:!1}),t.jsx("span",{children:n.entry.name}),n.count>1&&t.jsx("strong",{children:n.count})]})}function Ge(n,d){if(n.size!==d.size)return!1;for(const u of n)if(!d.has(u))return!1;return!0}function _n({entry:n,depth:d,expanded:u,pendingChildren:g,selected:x,active:l,multiSelected:h,readOnly:p,fileClipboardAvailable:V,revealAvailable:L,historyState:C,onUndo:A,onRedo:B,draggedPaths:j,dropTargetPath:w,onFocus:re,onRowClick:je,onRowDoubleClick:ae,onRowContextMenu:ie,onOpen:ye,onOpenPinned:G,onCopy:De,onCut:le,onPasteInto:ke,onCopyPath:Ce,onCopyContents:be,onRename:we,onNewFile:O,onNewFolder:P,onReveal:Me,onDelete:S,dragPaths:ce}){const U=i.useRef(null),m=me(n),{attributes:R,listeners:de,setNodeRef:Y,isDragging:q}=qt({id:`file-drag:${n.path}`,data:{sourcePaths:ce,entry:n},disabled:p}),{setNodeRef:_}=Fe({id:`file-drop:${n.path}`,data:{targetDirectory:m,expandPath:n.type==="directory"?n.path:null}}),N=M=>{U.current=M,Y(M),_(M)},W=j.length>0&&n.type==="directory"&&w===n.path,ue=j.length>0&&w!==null&&w!==""&&w!==n.path&&Ee(w,n.path),Z=t.jsxs("button",{type:"button",ref:N,...R,role:"treeitem","aria-selected":x,"aria-current":l?"true":void 0,"aria-expanded":n.type==="directory"?u:void 0,className:["file-tree-row",n.ignored?"ignored-file":"",j.includes(n.path)||q?"dragging":"",W?"drop-target":"",ue?"drop-target-region":""].filter(Boolean).join(" "),style:{paddingLeft:12+d*14},...de,onClick:M=>je(n,{ctrl:M.ctrlKey||M.metaKey,shift:M.shiftKey}),onDoubleClick:()=>ae(n),onFocus:()=>re(n.path),onContextMenu:()=>ie(n),children:[n.type==="directory"?t.jsx(Oe,{className:`folder-chevron ${u?"open":""} ${n.children.length===0&&!g?"empty":""}`}):t.jsx("span",{className:"tree-spacer"}),t.jsx(Pe,{path:n.path,type:n.type,expanded:u}),t.jsx("span",{children:n.name})]});return t.jsxs(wn,{children:[t.jsx(Mn,{render:Z}),t.jsx("button",{type:"button",className:"file-touch-actions","aria-label":`Actions for ${n.name}`,"aria-haspopup":"menu",onClick:M=>{M.stopPropagation();const z=M.currentTarget.getBoundingClientRect();U.current?.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:z.left,clientY:z.bottom}))},children:t.jsx(Dn,{})}),t.jsxs(vn,{children:[n.type==="file"&&t.jsxs(t.Fragment,{children:[t.jsxs(b,{onClick:()=>ye(n),children:[t.jsx(Xt,{"aria-hidden":"true"})," Open"]}),t.jsxs(b,{onClick:()=>G(n),children:[t.jsx(Qe,{"aria-hidden":"true"})," Open to the Side ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Click"})]}),t.jsx(oe,{})]}),t.jsxs(b,{disabled:p||!C.canUndo,onClick:()=>{A()},children:[t.jsx(hn,{"aria-hidden":"true"})," ",C.undoLabel?`Undo ${C.undoLabel}`:"Undo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Z"})]}),t.jsxs(b,{disabled:p||!C.canRedo,onClick:()=>{B()},children:[t.jsx(fn,{"aria-hidden":"true"})," ",C.redoLabel?`Redo ${C.redoLabel}`:"Redo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Shift+Z"})]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>De(n),children:[t.jsx(Gt,{"aria-hidden":"true"})," Copy ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+C"})]}),t.jsxs(b,{disabled:p,onClick:()=>le(n),children:[t.jsx(jn,{"aria-hidden":"true"})," Cut ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+X"})]}),V&&t.jsxs(b,{disabled:p,onClick:()=>ke(n),children:[t.jsx(Je,{"aria-hidden":"true"})," Paste ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+V"})]}),t.jsx(oe,{}),t.jsxs(b,{disabled:p||h,onClick:()=>we(n),children:[t.jsx(dn,{"aria-hidden":"true"})," Rename ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"F2"})]}),t.jsxs(b,{disabled:p||h,onClick:()=>O(n),children:[t.jsx(et,{"aria-hidden":"true"})," New File…"]}),t.jsxs(b,{disabled:p||h,onClick:()=>P(n),children:[t.jsx(Ze,{"aria-hidden":"true"})," New Folder…"]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>Ce(n),children:[t.jsx(bn,{"aria-hidden":"true"})," Copy path"]}),t.jsxs(b,{disabled:n.type!=="file"||h,onClick:()=>{be(n)},children:[t.jsx(tn,{"aria-hidden":"true"})," Copy contents"]}),L&&t.jsxs(b,{disabled:h,onClick:()=>{Me(n)},children:[t.jsx(Ot,{"aria-hidden":"true"})," Reveal in File Explorer"]}),t.jsx(oe,{}),t.jsxs(b,{className:"text-destructive data-highlighted:text-destructive",disabled:p,onClick:()=>S(n),children:[t.jsx(Wt,{"aria-hidden":"true"})," Delete ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Del"})]})]})]})}function zn({state:n,onClose:d,onRename:u,onCreate:g}){const[x,l]=i.useState("");if(i.useEffect(()=>{n&&l(n.mode==="rename"?n.entry.name:"")},[n]),!n)return null;const h=n.mode==="rename",p=n.mode==="new-folder"?"directory":"file",V=me(n.entry),L=h?"Rename":p==="directory"?"New Folder":"New File",C=x.trim(),A=C.length>0&&!/[\\/]/.test(C)&&!(h&&C===n.entry.name),B=()=>{A&&(h?u(n.entry,C):g(V,C,p),d())};return t.jsx(Zt,{open:!0,onOpenChange:j=>{j||d()},children:t.jsx(Jt,{className:"name-dialog",children:t.jsxs("form",{className:"name-dialog-content",onSubmit:j=>{j.preventDefault(),B()},children:[t.jsx(Qt,{children:L}),t.jsx(en,{children:h?t.jsxs(t.Fragment,{children:["Enter a new name for ",t.jsx("code",{children:n.entry.name}),"."]}):t.jsxs(t.Fragment,{children:["Create a new ",p==="directory"?"folder":"file"," in ",t.jsx("code",{children:V||"the repository root"}),"."]})}),t.jsx("input",{autoFocus:!0,className:"name-dialog-input",value:x,maxLength:255,placeholder:h?"New name":p==="directory"?"Folder name":"File name",onChange:j=>l(j.target.value),onFocus:j=>{if(!h)return;const w=n.entry.name.lastIndexOf(".");j.target.setSelectionRange(0,w>0?w:n.entry.name.length)}}),t.jsxs("div",{className:"name-dialog-actions",children:[t.jsx(H,{type:"button",variant:"ghost",onClick:d,children:"Cancel"}),t.jsx(H,{type:"submit",disabled:!A,children:h?"Rename":"Create"})]})]})})})}function Pe({path:n,type:d,expanded:u=!1}){const g=d==="file"?Vt(n):Bt(n,u);return t.jsx("img",{className:"vscode-tree-icon",src:g,alt:"","aria-hidden":"true"})}export{Un as FilesView};
@@ -1 +0,0 @@
1
- import{c as r,T as g,a as x,b as v,B as j,o as M,q as C}from"./index-CQcx9aRt.js";import{r as m,j as e}from"./react-rd22PHbN.js";import{u as N}from"./tanstack-CtfgE41X.js";import{M as y,x as b}from"./App-9EfSdZB8.js";import{P,f as R,g as S,h as _,i as E}from"./base-ui-DT3JsyND.js";const I=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]],X=r("outline","circle-check","CircleCheck",I);const $=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M10 10l4 4m0 -4l-4 4",key:"svg-1"}]],A=r("outline","circle-x","CircleX",$);const q=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 7v5l3 3",key:"svg-1"}]],H=r("outline","clock","Clock",q);const T=[["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"}]],G=r("outline","git-merge","GitMerge",T);const F=[["path",{d:"M12 4l-8 4l8 4l8 -4l-8 -4",key:"svg-0"}],["path",{d:"M4 12l8 4l8 -4",key:"svg-1"}],["path",{d:"M4 16l8 4l8 -4",key:"svg-2"}]],O=r("outline","stack-2","Stack2",F);const z=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 10a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-1"}],["path",{d:"M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855",key:"svg-2"}]],D=r("outline","user-circle","UserCircle",z);function Q({repositoryId:c,number:n,membership:o,onSelect:l}){const[d,k]=m.useState(!1),a=N({queryKey:C.pullRequestStack(c,n),queryFn:()=>M.github.getPullRequestStack(c,n),enabled:d,staleTime:0}),t=a.data,h=t?t.layers.findIndex(s=>s.number===n)+1:o.position,u=t?.layers.length??o.size,i=t?.number??o.number;return a.isSuccess&&t===null&&!d?null:e.jsxs(P,{open:d,onOpenChange:k,children:[e.jsxs(g,{children:[e.jsxs(x,{render:e.jsx(R,{render:e.jsx("button",{className:"pr-stack-trigger","aria-label":`Stack ${i}, layer ${h} of ${u}`})}),children:[e.jsx(O,{"aria-hidden":"true"})," ",h,"/",u]}),e.jsxs(v,{children:["View stack #",i," · layer ",h," of ",u]})]}),e.jsx(S,{children:e.jsx(_,{side:"bottom",align:"start",sideOffset:6,className:"isolate z-50 outline-none",children:e.jsxs(E,{className:"pr-stack-popup","aria-label":`Stack #${i}`,children:[e.jsxs("div",{className:"pr-stack-heading",children:[e.jsxs("strong",{children:["Stack #",i]}),e.jsx(j,{variant:"ghost",size:"xs",disabled:a.isFetching,onClick:()=>{a.refetch()},children:"Refresh"})]}),a.isFetching&&e.jsx("p",{className:"pr-stack-notice",role:"status",children:t?"Refreshing stack…":"Loading stack…"}),a.isError&&e.jsxs("div",{className:"pr-stack-notice",role:"status",children:[e.jsx("p",{children:t?"Could not refresh. Showing saved layers.":"Could not load the stack."}),e.jsx(j,{variant:"outline",size:"xs",onClick:()=>{a.refetch()},children:"Retry"})]}),t===null&&!a.isFetching&&!a.isError&&e.jsx("p",{className:"pr-stack-notice",children:"This PR is no longer in a stack, or stack data is unavailable."}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pr-stack-layers",children:[...t.layers].reverse().map(s=>{const p=s.isDraft&&s.state==="OPEN"?"Draft":s.state==="MERGED"?"Merged":s.state==="CLOSED"?"Closed":"Open",f=s.state==="MERGED"?G:y;return e.jsxs(g,{children:[e.jsxs(x,{render:e.jsx("button",{className:"pr-stack-layer","aria-current":s.number===n?"true":void 0,onClick:()=>{k(!1),l(s.number)}}),children:[e.jsx(f,{className:`pr-stack-state ${p.toLowerCase()}`,"aria-hidden":"true"}),e.jsxs("span",{className:"pr-stack-layer-text",children:[e.jsx("strong",{children:s.title}),e.jsxs("small",{children:["#",s.number," · ",s.headRefName," · ",p]})]}),s.number===n&&e.jsx(b,{"aria-hidden":"true"})]}),e.jsxs(v,{children:[s.title," · ",s.headRefName," · ",p]})]},s.number)})}),e.jsxs("div",{className:"pr-stack-base",children:["↳ ",t.base]})]})]})})})]})}function V({src:c,className:n}){const[o,l]=m.useState(!1);return e.jsx("span",{className:n,"aria-hidden":"true",children:c&&!o?e.jsx("img",{src:c,alt:"",onError:()=>l(!0)}):e.jsx(D,{})})}export{V as G,X as I,Q as P,A as a,H as b,G as c};
@@ -1 +0,0 @@
1
- import{r as w,j as e}from"./react-rd22PHbN.js";import{a as te}from"./tanstack-CtfgE41X.js";import{T as N,a as y,b as C,B as _,o as ne,w as ae,s as X}from"./index-CQcx9aRt.js";import{k as Q,G as J,j as re,Q as oe,R as ie,U as le,V as ce,M as de,W as he,X as ue,Y as me}from"./App-9EfSdZB8.js";import"./base-ui-DT3JsyND.js";function pe(s){let n=[],a=s.some(i=>i.color!==void 0)?3:0,t=1;const r=new Map,j=[],l=new Map(s.map(i=>[i.oid,i])),u=new Set;let d=s[0];for(;d&&!u.has(d.oid);)u.add(d.oid),d.color!==void 0&&r.set(d.oid,d.color),d=l.get(d.parentOids[0]??"");for(const i of s){let h=n.indexOf(i.oid);const p=h>=0;h<0&&(h=n.length,n=[...n,i.oid]);const f=n,v=xe(r,i.oid,()=>i.color??a++),x=v<3?i.color??v:v;r.set(i.oid,x);const b=f.filter((g,c)=>c!==h);let M=Math.min(h,b.length);i.parentOids.forEach((g,c)=>{r.has(g)||r.set(g,c===0?x:a++),!b.includes(g)&&(b.splice(M,0,g),M+=1)});const L=[];f.forEach((g,c)=>{if(c===h){p&&L.push({fromLane:c,from:"top",toLane:h,to:"node",color:v});return}const I=b.indexOf(g);I>=0&&L.push({fromLane:c,from:"top",toLane:I,to:"bottom",color:r.get(g)??0})}),i.parentOids.forEach(g=>{const c=b.indexOf(g);c>=0&&L.push({fromLane:h,from:"node",toLane:c,to:"bottom",color:r.get(g)??x})}),t=Math.max(t,f.length,b.length),j.push({lane:h,color:x,segments:L,continuations:b.map((g,c)=>({lane:c,color:r.get(g)??0}))}),n=b}return{rows:j,laneCount:t}}function xe(s,n,a){const t=s.get(n);if(t!==void 0)return t;const r=a();return s.set(n,r),r}function je(s){const n=s.parentCount>1&&/^Merge pull request #(\d+)\b/i.exec(s.subject),a=/\(#(\d+)\)\s*$/.exec(s.subject),t=n||a;if(!t)return null;const r=Number(t[1]);return Number.isSafeInteger(r)&&r>0?{number:r,source:n?"merge":"subject"}:null}function fe(s){if(s.upstreamState==="local-only")return 0;if(s.baseState==="included")return 2;if(s.upstreamState==="published")return 1}function ge(s,n){if(!n)return s.map(l=>({commit:l,parentOids:l.parentOids,grouped:[]}));const a=new Map(s.map(l=>[l.oid,l])),t=new Map;s.forEach(l=>l.parentOids.forEach(u=>{const d=t.get(u)??new Set;d.add(l.oid),t.set(u,d)}));const r=new Set,j=[];for(const l of s){if(r.has(l.oid))continue;const u={commit:l,parentOids:l.parentOids,grouped:[]};if(j.push(u),l.parentOids.length!==2)continue;const d=new Set;let i=a.get(l.parentOids[0]);for(;i&&!d.has(i.oid);)d.add(i.oid),i=a.get(i.parentOids[0]??"");let h=l.parentOids[1];const p=[],f=new Set;for(;!d.has(h);){const x=a.get(h);if(!x||f.has(h)||r.has(h)||x.isHead||x.parentOids.length!==1)break;f.add(h),p.push(x),h=x.parentOids[0]}if(!d.has(h)||p.length===0)continue;const v=new Set([l.oid,...p.map(x=>x.oid)]);p.some(x=>[...t.get(x.oid)??[]].some(b=>!v.has(b)))||p.some(x=>j.some(b=>b.commit.oid===x.oid))||(u.grouped=p,u.parentOids=[l.parentOids[0]],p.forEach(x=>r.add(x.oid)))}return j}function K(s,n){const a=n.trim().toLocaleLowerCase();return a.length>0&&[s.subject,s.author,s.oid,...s.decorations].some(t=>t.toLocaleLowerCase().includes(a))}function Fe({repositoryId:s,upstream:n,readOnly:a,operation:t,canPublish:r,pushBusy:j,onPublish:l,commits:u,nextCursor:d,loading:i,undoing:h,baseRef:p,activeOid:f,onSelectReference:v,onSelectCommit:x,onSelectFile:b,onUndo:M,onMore:L}){const g=w.useRef(null),[c,I]=w.useState(new Set),[$,z]=w.useState(!0),[k,A]=w.useState(!1),[E,R]=w.useState(""),[V,F]=w.useState(-1),H=$?42:56,o=w.useMemo(()=>ge(u??[],k&&!E.trim()),[u,k,E]),O=w.useMemo(()=>pe(o.map(({commit:m,parentOids:S})=>({oid:m.oid,parentOids:S,color:fe(m)}))),[o]),P=w.useMemo(()=>o.flatMap(({commit:m},S)=>K(m,E)?[S]:[]),[o,E]),ee=ye(O.laneCount),T=te({count:o.length,getScrollElement:()=>g.current,estimateSize:()=>H,getItemKey:m=>o[m].commit.oid,overscan:8});w.useEffect(()=>{T.measure()},[T,$,k,E]);const B=()=>{if(!P.length)return;const m=(V+1)%P.length;F(m),T.scrollToIndex(P[m],{align:"center"})};if(u===null)return e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(Q,{className:"spinner"})," ",e.jsx(J,{text:"Loading history…"})]});const q=u.filter(m=>m.upstreamState==="local-only").length;return e.jsxs("div",{className:"history-list",style:{"--history-row-height":`${H}px`},children:[e.jsxs("div",{className:"history-toolbar",children:[e.jsxs("label",{className:"history-search",children:[e.jsx(re,{"aria-hidden":"true"}),e.jsx("input",{type:"search","aria-label":"Search loaded commits",placeholder:"Find commit…",value:E,onChange:m=>{R(m.target.value),F(-1)},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),B())}})]}),E&&e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"history-next-match",onClick:B,disabled:!P.length,"aria-label":"Next matching commit"}),children:e.jsx(oe,{})}),e.jsx(C,{children:"Next match in loaded history (Enter)"})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"history-option","aria-pressed":k,disabled:!u.some(m=>m.parentCount>1),onClick:()=>A(!k)}),children:"Group merges"}),e.jsx(C,{children:"Collapse complete merge branches. Searching reveals their commits."})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"history-option","aria-pressed":$,onClick:()=>z(!$)}),children:$?"Compact":"Comfortable"}),e.jsx(C,{children:"Change row density without moving the diff viewer"})]})]}),!n&&u.length>0&&e.jsxs("div",{className:"history-upstream-notice",role:"status",children:[e.jsx("span",{children:"Publish this branch to configure an upstream and distinguish local from published commits."}),r&&e.jsx(_,{variant:"outline",size:"xs",disabled:j||a||!!t,onClick:l,children:j?"Publishing…":"Publish branch"})]}),n&&q>0&&e.jsxs("div",{className:"history-local-summary",children:["↑ ",q," ",q===1?"local commit":"local commits"," in loaded history"]}),e.jsx("div",{ref:g,className:"history-scroll",role:"list","aria-label":"Commit history",children:o.length===0?e.jsx("p",{className:"empty-list",children:"This repository has no commits yet."}):e.jsxs("div",{className:"virtual-list",style:{height:T.getTotalSize()+(d?52:0)},children:[T.getVirtualItems().map(m=>{const{commit:S,grouped:W}=o[m.index];return e.jsx("div",{ref:T.measureElement,"data-index":m.index,className:"virtual-row",style:{transform:`translateY(${m.start}px)`},children:e.jsx(be,{repositoryId:s,upstream:n,baseRef:p,commit:S,graphRow:O.rows[m.index],graphWidth:ee,rowHeight:H,active:f===S.oid||W.some(U=>U.oid===f),match:K(S,E),groupedCount:W.length,onRevealGroup:()=>A(!1),onSelectReference:v,expanded:c.has(S.oid),onExpandedChange:U=>I(se=>{const Y=new Set(se);return U?Y.add(S.oid):Y.delete(S.oid),Y}),canUndo:!a&&!t&&!h&&S.upstreamState==="local-only"&&S.isHead&&S.parentCount===1,onSelectCommit:x,onSelectFile:b,onUndo:M})},m.key)}),d&&e.jsx(_,{variant:"ghost",className:"history-more",style:{top:T.getTotalSize()},disabled:i,onClick:L,children:i?"Loading…":"Load more"})]})}),u.length>0&&e.jsxs("div",{className:"history-legend",children:[e.jsxs("span",{children:[e.jsx("i",{"data-color":"local"}),"Local"]}),e.jsxs("span",{children:[e.jsx("i",{"data-color":"published"}),"Published"]}),p&&e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("span",{className:"history-base-label"}),children:[e.jsx("i",{"data-color":"base"}),p]}),e.jsxs(C,{children:["Primary-line commits reachable from ",p,", using the latest known local refs. Side branches use the published color."]})]}),e.jsx("span",{className:"history-count",role:"status",children:E?`${P.length} matches in ${u.length} loaded`:`${u.length} loaded`})]})]})}function be({repositoryId:s,upstream:n,baseRef:a,commit:t,graphRow:r,graphWidth:j,rowHeight:l,active:u,match:d,groupedCount:i,onRevealGroup:h,onSelectReference:p,expanded:f,onExpandedChange:v,canUndo:x,onSelectCommit:b,onSelectFile:M,onUndo:L}){const g=`${s}:${t.oid}`,[c,I]=w.useState(()=>ie(g)??null),[$,z]=w.useState(null);w.useEffect(()=>{if(!f||c||$)return;let o=!0;return ne.commits.files(s,t.oid).then(O=>{o&&(le(g,O),I(O))}).catch(O=>{o&&z(Te(O))}),()=>{o=!1}},[g,t.oid,f,c,$,s]);const k=je(t),A=Se(t.decorations),E=A.slice(0,3),R=A.slice(3),V=c?.reduce((o,O)=>o+O.additions,0)??0,F=c?.reduce((o,O)=>o+O.deletions,0)??0,H=async()=>{try{await ae(t.oid),X.success({title:"Hash copied",description:t.oid})}catch{X.error({title:"Could not copy hash"})}};return e.jsxs("div",{className:`commit-item${u?" active":""}${d?" search-match":""}`,role:"listitem",children:[e.jsxs("div",{className:"commit-header",children:[e.jsx(Ce,{graph:r,width:j,height:l,merge:t.parentCount>1,head:t.isHead}),e.jsx("button",{className:"commit-expand","aria-expanded":f,"aria-label":f?"Collapse commit":"Expand commit",onClick:()=>v(!f),children:e.jsx(ce,{className:`folder-chevron ${f?"open":""}`})}),e.jsxs("div",{className:"commit-main",children:[e.jsxs("span",{className:"commit-title-row",children:[e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"commit-subject","aria-pressed":u,onClick:()=>b(t)}),children:t.subject||"(no subject)"}),e.jsxs(C,{side:"right",children:[t.subject||"(no subject)",e.jsx("br",{}),"Open the full commit diff"]})]}),k&&e.jsxs(N,{children:[e.jsxs(y,{render:p?e.jsx("button",{className:"ref-chip commit-pr",onClick:()=>p(k.number),"aria-label":`Open pull request #${k.number}`}):e.jsx("span",{className:"ref-chip commit-pr"}),children:[e.jsx(de,{"aria-hidden":"true"}),"#",k.number]}),e.jsxs(C,{children:[k.source==="merge"?"Pull request reference from the merge message.":"Reference from the commit subject; it may identify a pull request or issue.",p?" Open as a pull request in the right-hand viewer.":""," No merge method is inferred from the number."]})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:"commit-date"}),children:Ee(t.date)}),e.jsx(C,{children:Oe(t.date)})]})]}),e.jsxs("span",{className:"commit-meta",children:[(A.length>0||t.parentCount>1||t.upstreamState==="local-only")&&e.jsxs("span",{className:"commit-refs",children:[t.upstreamState==="local-only"&&e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:"ref-chip local-only"}),children:"Local"}),e.jsx(C,{children:t.isHead?`Not in ${n??"the upstream"} according to the latest known remote state.`:"Not published. To avoid rewriting multiple commits, only the latest can be undone."})]}),t.parentCount>1&&e.jsx("span",{className:"ref-chip merge",children:"merge"}),E.map(o=>e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:`ref-chip ${o.kind}`,"data-base":o.label===a||o.label.endsWith("/HEAD")&&t.baseState==="included"}),children:o.label}),e.jsx(C,{children:o.label})]},`${o.kind}:${o.label}`)),R.length>0&&e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("span",{className:"ref-chip more"}),children:["+",R.length]}),e.jsx(C,{children:R.map(o=>o.label).join(" · ")})]})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"commit-oid",onClick:()=>{H()},"aria-label":`Copiar hash ${t.shortOid}`}),children:t.shortOid}),e.jsx(C,{children:"Copy full hash"})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:"commit-author"}),children:t.author}),e.jsx(C,{children:t.author})]}),i>0&&e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("button",{className:"commit-group-count",onClick:h}),children:[i," grouped"]}),e.jsxs(C,{children:["Show the ",i," commits in this merge branch"]})]})]})]}),x&&e.jsxs(N,{children:[e.jsx(y,{render:e.jsx(_,{variant:"ghost",size:"icon-xs",className:"change-action-button commit-undo",onClick:o=>{o.stopPropagation(),L(t)},"aria-label":`Undo commit ${t.shortOid}`}),children:e.jsx(he,{})}),e.jsx(C,{children:"Undo commit and keep its changes staged"})]})]}),f&&r.continuations.length>0&&e.jsx(we,{graph:r,width:j}),f&&e.jsxs("div",{className:"commit-files",style:{paddingLeft:j+31},children:[t.body&&e.jsx("p",{className:"commit-description",children:t.body}),$&&e.jsx("div",{className:"commit-files-message error",children:$}),!c&&!$&&e.jsxs("div",{className:"commit-files-message",children:[e.jsx(Q,{className:"spinner"})," ",e.jsx(J,{text:"Loading files…"})]}),c&&c.length===0&&e.jsx("div",{className:"commit-files-message",children:"This commit does not modify its own files (merge)."}),c&&c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"commit-files-summary",children:[c.length," ",c.length===1?"file":"files",(V>0||F>0)&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"add",children:["+",V]})," ",e.jsxs("span",{className:"del",children:["−",F]})]})]}),c.map(o=>e.jsx(ve,{file:o,onSelect:()=>M(t.oid,o)},o.path))]})]})]})}const Z=14,Ne=["var(--history-local)","var(--history-published)","var(--history-base)"];function ye(s){return 14+Math.max(0,s-1)*Z}function D(s){return 7+s*Z}function G(s){return Ne[s]??"var(--history-published)"}function Ce({graph:s,width:n,height:a,merge:t,head:r}){const j=a/2;return e.jsxs("svg",{className:"commit-graph",width:n,height:a,viewBox:`0 0 ${n} ${a}`,"aria-hidden":"true",children:[s.segments.map((l,u)=>{const d=D(l.fromLane),i=D(l.toLane),h=l.from==="top"?0:j,p=l.to==="node"?j:a,f=(h+p)/2,v=d===i?`M ${d} ${h} L ${i} ${p}`:`M ${d} ${h} C ${d} ${f}, ${i} ${f}, ${i} ${p}`;return e.jsx("path",{d:v,stroke:G(l.color)},`${u}:${v}`)}),e.jsx("circle",{cx:D(s.lane),cy:j,r:t||r?4.5:3,fill:t||r?"var(--sidebar)":G(s.color),stroke:G(s.color)}),t&&e.jsx("circle",{cx:D(s.lane),cy:j,r:"1.6",fill:G(s.color)})]})}function we({graph:s,width:n}){return e.jsx("svg",{className:"commit-graph-continuation",width:n,viewBox:`0 0 ${n} 100`,preserveAspectRatio:"none","aria-hidden":"true",children:s.continuations.map(a=>e.jsx("line",{x1:D(a.lane),y1:"0",x2:D(a.lane),y2:"100",stroke:G(a.color)},a.lane))})}function ve({file:s,onSelect:n}){const a=w.useRef(null),t=s.path.lastIndexOf("/"),r=t<0?s.path:s.path.slice(t+1),j=s.oldPath?.split("/").pop();return e.jsxs("div",{ref:a,className:"commit-file-row",children:[e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("button",{className:"commit-file-label",onClick:n,"aria-label":`Ver el diff de ${s.path}`}),children:[e.jsx(Le,{path:s.path,type:"file"}),e.jsxs("span",{className:"commit-file-text",children:[e.jsx("span",{children:r}),j&&e.jsxs("small",{className:"commit-file-rename",children:[j," →"]})]})]}),e.jsx(C,{anchor:a,side:"right",sideOffset:10,children:s.oldPath?`${s.oldPath} → ${s.path}`:s.path})]}),e.jsx("span",{className:"commit-file-stats",children:s.binary?e.jsx("span",{className:"binary",children:"bin"}):e.jsxs(e.Fragment,{children:[s.additions>0&&e.jsxs("span",{className:"add",children:["+",s.additions]}),s.deletions>0&&e.jsxs("span",{className:"del",children:["−",s.deletions]})]})}),e.jsx("span",{className:"status-code","data-kind":s.kind,children:ue(s.kind)})]})}function Se(s){return s.map(n=>n.startsWith("tag: ")?{label:n.slice(5),kind:"tag"}:n.startsWith("HEAD -> ")?{label:n.slice(8),kind:"head"}:n==="HEAD"?{label:"HEAD",kind:"head"}:{label:n,kind:n.includes("/")?"remote":"branch"})}const $e=new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"narrow"}),ke=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]];function Ee(s){const n=new Date(s);if(Number.isNaN(n.getTime()))return s;const a=Math.round((n.getTime()-Date.now())/1e3);for(const[t,r]of ke)if(Math.abs(a)>=r)return $e.format(Math.trunc(a/r),t);return"right now"}function Oe(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"}).format(n)}function Le({path:s}){return e.jsx("img",{className:"vscode-tree-icon",src:me(s),alt:"","aria-hidden":"true",draggable:!1})}function Te(s){return s instanceof Error?s.message:"An unexpected error occurred."}export{Fe as HistoryView};
@@ -1 +0,0 @@
1
- import{c as o}from"./index-CQcx9aRt.js";const e=[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]],a=o("outline","folder-plus","FolderPlus",e);export{a as I};
@@ -1 +0,0 @@
1
- import{r as l,j as e}from"./react-rd22PHbN.js";import{u as W}from"./tanstack-CtfgE41X.js";import{f as ve,a as Ne,b as F,w as B,n as ie,D as Ce,c as De,d as Te,e as Fe,g as he,I as de,h as M,i as se,j as Be,k as H,l as Se,m as O,o as Ee,p as U,q as ue,B as Ie,r as Re,s as Ge,t as be,u as Pe,v as Ae,x as Oe,y as me,z as Le}from"./App-9EfSdZB8.js";import{q as K,B as f,T as X,a as J,b as V,I as $e,w as ze,o as S}from"./index-CQcx9aRt.js";import{C as qe}from"./checkbox-DYwmgDPS.js";import{o as We}from"./gh-utils-LsOSydCg.js";import"./base-ui-DT3JsyND.js";function rr(r){const{open:n,tab:a,repositoryId:t,onMutated:b,onBusyChange:j}=r,[o,p]=l.useState(""),[k,c]=l.useState(!1),[i,w]=l.useState(null),[g,E]=l.useState(null),[v,x]=l.useState(null),[d,I]=l.useState(null),[L,N]=l.useState(null),[fe,$]=l.useState(!1),ne=l.useRef(null);l.useEffect(()=>{c(!1)},[n,t]);const D=W({queryKey:K.localRefs(t),queryFn:()=>S.refs.localRefsSnapshot(t),enabled:n}),m=D.data??null,z=D.isFetching,le=D.error?Q(D.error):null,Z=l.useMemo(()=>ve(m?.branches??[],o),[m,o]),_=l.useMemo(()=>Ne(m?.worktrees??[],o),[m,o]),R=Z.find(s=>F(s)===i)??null,G=_.find(s=>B(s)===g)??null,te=W({queryKey:K.branchDetails(t,R?.fullName??""),queryFn:()=>S.refs.branchDetails({repositoryId:t,fullName:R.fullName}),enabled:n&&a==="branches"&&R!==null}),y=te.data??null,je=W({queryKey:K.branchPullRequest(t,y?.name??""),queryFn:()=>S.github.findPullRequestForBranch(t,y.name),enabled:n&&a==="branches"&&y!==null&&(y.deletion==="unknown"||y.deletion==="unmerged")}).data??null,oe=W({queryKey:K.worktreeDetails(t,G?.path??""),queryFn:()=>S.refs.worktreeDetails({repositoryId:t,path:G.path}),enabled:n&&a==="worktrees"&&G!==null}),C=oe.data??null,ee=a==="branches"?te:oe,q=ee.isFetching,P=ee.error?Q(ee.error):null,A=l.useCallback(async()=>{await D.refetch()},[D]);l.useEffect(()=>{if(!m)return;const s=ne.current;ne.current=m,w(h=>ie(m.branches.map(F),(s?.branches??[]).map(F),h)),E(h=>ie(m.worktrees.map(B),(s?.worktrees??[]).map(B),h))},[m]),l.useEffect(()=>{n||(p(""),x(null),N(null),$(!1))},[n]),l.useEffect(()=>{x(null),N(null),$(!1)},[a,i,g]);const ce=async(s,h)=>{I(s),j(!0),N(null);try{await h()&&x(null)}catch(T){N(Q(T))}finally{I(null),j(!1)}},pe=(s,h)=>ce("delete-branch",async()=>{const T=await S.refs.deleteBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,force:h});return T.status!=="deleted"?(N(He(T.status)),await A(),!1):(b(null),await A(),!0)}),we=(s,h,T)=>ce("remove-worktree",async()=>{const re=await S.refs.removeWorktree({repositoryId:t,path:s.path,expectedOid:s.oid,force:h,deleteBranch:T});return re.status!=="removed"?(N(Me(re.status)),await A(),!1):(b(re.recentRepositories),await A(),!0)}),ge=async s=>{try{await ze(s),$(!0),window.setTimeout(()=>$(!1),1600)}catch(h){N(Q(h))}},ke={branches:m?.branches.length??0,worktrees:m?.worktrees.length??0},ye=a==="branches"?Z.length===0:_.length===0;return e.jsx(Ce,{open:n,onOpenChange:r.onOpenChange,children:e.jsxs(De,{className:"local-refs-dialog",children:[e.jsxs("header",{className:"local-refs-header",children:[e.jsxs("div",{children:[e.jsx(Te,{children:"Local branches and worktrees"}),e.jsx(Fe,{children:"Inspect what this repository holds locally, and retire what Git can safely remove."})]}),e.jsx(he,{render:e.jsx(f,{variant:"ghost",size:"icon-sm","aria-label":"Close the local refs manager"}),children:e.jsx(de,{})})]}),e.jsxs("div",{className:"local-refs-toolbar",children:[e.jsx("div",{className:"local-refs-tabs",role:"tablist","aria-label":"Local refs",children:["branches","worktrees"].map(s=>e.jsxs("button",{type:"button",role:"tab",id:`local-refs-tab-${s}`,"aria-selected":a===s,"aria-controls":`local-refs-panel-${s}`,className:"local-refs-tab",onClick:()=>{r.onTabChange(s),c(!1)},children:[s==="branches"?e.jsx(M,{"aria-hidden":"true"}):e.jsx(se,{"aria-hidden":"true"}),e.jsx("span",{children:s==="branches"?"Branches":"Worktrees"}),e.jsx("small",{children:ke[s]})]},s))}),e.jsxs("div",{className:"local-refs-search",children:[e.jsx(Be,{"aria-hidden":"true"}),e.jsxs("label",{className:"sr-only",htmlFor:"local-refs-search-input",children:["Search ",a]}),e.jsx("input",{id:"local-refs-search-input",value:o,onChange:s=>p(s.target.value),placeholder:a==="branches"?"Search branches…":"Search worktrees…",autoComplete:"off",spellCheck:!1}),o&&e.jsx(f,{variant:"ghost",size:"icon-xs","aria-label":"Clear search",onClick:()=>p(""),children:e.jsx(de,{})})]}),e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{A()},disabled:z||!!d,children:[z?e.jsx(H,{className:"animate-spin"}):e.jsx(Se,{})," Refresh"]})]}),le&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:le})]}),k&&e.jsxs("button",{type:"button",className:"local-refs-mobile-back",onClick:()=>c(!1),children:["← Back to ",a]}),e.jsxs("div",{className:"local-refs-body","data-mobile-detail":k,role:"tabpanel",id:`local-refs-panel-${a}`,"aria-labelledby":`local-refs-tab-${a}`,children:[e.jsxs("div",{className:"local-refs-list",role:"listbox","aria-label":a==="branches"?"Local branches":"Worktrees",tabIndex:-1,children:[z&&!m&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(H,{className:"animate-spin","aria-hidden":"true"})," Reading the repository…"]}),!z&&ye&&e.jsx("p",{className:"local-refs-placeholder",children:o?"No matches for this search.":`This repository has no ${a==="branches"?"local branches":"worktrees"}.`}),a==="branches"&&Z.map(s=>e.jsxs(X,{children:[e.jsxs(J,{render:e.jsx("button",{type:"button",role:"option","aria-selected":F(s)===i,className:"local-refs-row",onClick:()=>{w(F(s)),c(!0)}}),children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(M,{"aria-hidden":"true"}),e.jsx("strong",{children:s.name}),e.jsx(Y,{badges:Ee(s)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("code",{children:s.shortOid}),s.subject&&e.jsx("span",{children:s.subject}),s.date&&e.jsx("time",{dateTime:s.date,children:ae(s.date)})]})]}),e.jsxs(V,{children:[s.name,s.subject?` — ${s.subject}`:""]})]},F(s))),a==="worktrees"&&_.map(s=>e.jsxs(X,{children:[e.jsxs(J,{render:e.jsx("button",{type:"button",role:"option","aria-selected":B(s)===g,className:"local-refs-row",onClick:()=>{E(B(s)),c(!0)}}),children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(se,{"aria-hidden":"true"}),e.jsx("strong",{children:U(s.path)}),e.jsx(Y,{badges:ue(s)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("span",{className:"local-refs-row-branch",children:s.branch?`${s.branch}`:"Detached HEAD"}),e.jsx("span",{children:s.path})]})]}),e.jsxs(V,{children:[U(s.path)," — ",s.path]})]},B(s)))]}),e.jsxs("div",{className:"local-refs-detail",children:[P&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:P})]}),q&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(H,{className:"animate-spin","aria-hidden":"true"})," Loading details…"]}),!q&&!P&&a==="branches"&&y&&R&&e.jsx(Ke,{details:y,pullRequest:je,busy:d==="delete-branch",anyBusy:!!d,confirming:v==="delete-branch",actionError:L,onConfirm:()=>x("delete-branch"),onCancel:()=>x(null),onDelete:s=>{pe(y,s)}}),!q&&!P&&a==="worktrees"&&C&&G&&e.jsx(Qe,{details:C,busy:d==="remove-worktree",anyBusy:!!d,confirming:v==="remove-worktree",actionError:L,copied:fe,onConfirm:()=>x("remove-worktree"),onCancel:()=>x(null),onRemove:(s,h)=>{we(C,s,h)},onCopyPath:()=>{ge(C.path)},onOpen:()=>r.onOpenWorktree(C.path),onShowBranch:()=>{C.branch&&(w(`refs/heads/${C.branch}`),r.onTabChange("branches"))}}),!q&&!P&&!R&&!G&&e.jsxs("p",{className:"local-refs-placeholder",children:["Select a ",a==="branches"?"branch":"worktree"," to see its details."]})]})]},a),e.jsxs("footer",{className:"local-refs-footer",children:[e.jsx("small",{children:"Deleting a branch and removing a worktree are separate actions. A worktree removes its branch only when explicitly selected."}),e.jsx(he,{render:e.jsx(f,{variant:"outline",size:"sm",disabled:!!d}),children:"Done"})]})]})})}function Ke({details:r,pullRequest:n,busy:a,anyBusy:t,confirming:b,actionError:j,onConfirm:o,onCancel:p,onDelete:k}){const c=Re(r,n),i=c.forceAllowed===!0,w=c.allowed||i;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(M,{"aria-hidden":"true"}),e.jsxs(X,{children:[e.jsx(J,{render:e.jsx("span",{}),children:r.name}),e.jsx(V,{children:r.name})]})]}),e.jsx(Y,{badges:Ge(r)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(u,{label:"Full ref",children:e.jsx("code",{className:"local-refs-selectable",children:r.fullName})}),e.jsxs(u,{label:"Tip",children:[e.jsx("code",{children:r.shortOid})," ",r.subject]}),e.jsx(u,{label:"Author",children:r.author||"—"}),e.jsx(u,{label:"Last commit",children:r.date?ae(r.date,!0):"—"}),e.jsx(u,{label:"Upstream",children:r.upstream?`${r.upstream} · ↑${r.ahead} ↓${r.behind}`:"Not configured"}),e.jsx(u,{label:"Compared with",children:r.comparisonBase??"Not compared"}),n&&e.jsx(u,{label:"GitHub PR",children:e.jsxs("button",{type:"button",className:"local-refs-pr-link",onClick:()=>We(n.url),children:["#",n.number," · ",n.state==="MERGED"?`Merged into ${n.baseRefName}`:n.state==="OPEN"?"Open":"Closed"," ",e.jsx(be,{"aria-hidden":"true"})]})})]}),e.jsx(xe,{tone:c.allowed?"ready":"blocked",reason:c.reason,actionError:j,confirming:b,busy:a,anyBusy:t,actionLabel:i?"Force delete branch":"Delete branch",confirmLabel:a?"Deleting…":i?"Permanently delete":"Delete branch",allowed:w,confirmation:i?e.jsxs(e.Fragment,{children:["Force-delete the local branch ",e.jsx("strong",{children:r.name}),"? This keeps any remote branch and pull request, but commits found only on this local branch may become inaccessible. ",n?.state==="MERGED"?e.jsxs(e.Fragment,{children:["GitHub reports PR ",e.jsxs("strong",{children:["#",n.number]})," as merged into ",e.jsx("strong",{children:n.baseRefName}),", although local Git cannot verify the ancestry."]}):null]}):e.jsxs(e.Fragment,{children:["Delete the local branch ",e.jsx("strong",{children:r.name}),"? This removes only the local branch, keeping every worktree and any remote copy. Git confirmed it is fully merged into ",e.jsx("strong",{children:r.comparisonBase}),"."]}),onConfirm:o,onCancel:p,onAct:()=>k(i)})]})}function Qe({details:r,busy:n,anyBusy:a,confirming:t,actionError:b,copied:j,onConfirm:o,onCancel:p,onRemove:k,onCopyPath:c,onOpen:i,onShowBranch:w}){const[g,E]=l.useState(!1),v=Pe(r),x=Ae(r),d=v.forceAllowed===!0,I=v.allowed||d;return l.useEffect(()=>E(!1),[r.path]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(se,{"aria-hidden":"true"}),e.jsxs(X,{children:[e.jsx(J,{render:e.jsx("span",{}),children:U(r.path)}),e.jsx(V,{children:U(r.path)})]})]}),e.jsx(Y,{badges:ue(r)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(u,{label:"Folder",children:e.jsx("span",{className:"local-refs-path local-refs-selectable",children:r.path})}),e.jsx(u,{label:"Branch",children:r.branch??"Detached HEAD"}),e.jsx(u,{label:"HEAD",children:r.lastCommit?e.jsxs(e.Fragment,{children:[e.jsx("code",{children:r.lastCommit.shortOid})," ",r.lastCommit.subject]}):e.jsx("code",{children:r.oid?r.oid.slice(0,7):"—"})}),e.jsx(u,{label:"Committed",children:r.lastCommit?.date?ae(r.lastCommit.date,!0):"—"}),e.jsx(u,{label:"Local changes",children:r.available?x??"None":"Not readable"})]}),e.jsxs("div",{className:"local-refs-detail-actions",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:c,disabled:a,children:[j?e.jsx(Oe,{}):e.jsx($e,{})," ",j?"Copied":"Copy path"]}),!r.current&&r.available&&!r.locked&&e.jsxs(f,{variant:"outline",size:"sm",onClick:i,disabled:a,children:[e.jsx(be,{})," Open worktree"]}),r.branch&&e.jsxs(f,{variant:"ghost",size:"sm",onClick:w,disabled:a,children:[e.jsx(M,{})," Show branch"]})]}),r.branch&&I&&e.jsxs("label",{htmlFor:"remove-worktree-delete-branch",className:"local-refs-delete-branch",children:[e.jsx(qe,{id:"remove-worktree-delete-branch",checked:g,onCheckedChange:L=>E(L===!0),disabled:a}),e.jsxs("span",{children:["Also delete branch ",e.jsx("strong",{children:r.branch})]})]}),e.jsx(xe,{tone:v.allowed?"ready":"blocked",reason:v.reason,actionError:b,confirming:t,busy:n,anyBusy:a,actionLabel:d?"Force remove worktree":"Remove worktree",confirmLabel:n?"Removing…":d?"Permanently remove":"Remove worktree",allowed:I,confirmation:e.jsxs(e.Fragment,{children:[d?e.jsxs(e.Fragment,{children:["Permanently remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:r.path}),"? ",e.jsx("strong",{children:x??`The ${r.operation??"current Git operation"}`})," and every uncommitted file will be lost. The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}):e.jsxs(e.Fragment,{children:["Remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:r.path}),"? The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}),g&&r.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:r.branch})," will also be force-deleted. Commits found only on that branch may become inaccessible."]}):r.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:r.branch})," and its commits stay in the repository."]}):"No branch is deleted."]}),onConfirm:o,onCancel:p,onAct:()=>k(d,g)})]})}function xe({tone:r,reason:n,actionError:a,confirming:t,busy:b,anyBusy:j,allowed:o,actionLabel:p,confirmLabel:k,confirmation:c,onConfirm:i,onCancel:w,onAct:g}){return e.jsxs("div",{className:`local-refs-danger ${r}`,children:[a&&e.jsxs("p",{className:"local-refs-danger-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:a})]}),t&&o?e.jsxs("div",{className:"local-refs-confirm",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("p",{children:c}),e.jsxs("span",{className:"local-refs-confirm-actions",children:[e.jsxs(f,{variant:"destructive",size:"sm",onClick:g,disabled:b,children:[b?e.jsx(H,{className:"animate-spin"}):e.jsx(me,{})," ",k]}),e.jsx(f,{variant:"ghost",size:"sm",onClick:w,disabled:b,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[r==="ready"?e.jsx(Le,{"aria-hidden":"true"}):e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:n})]}),o&&e.jsxs(f,{variant:"destructive",size:"sm",onClick:i,disabled:j,children:[e.jsx(me,{})," ",p]})]})]})}function Y({badges:r}){return r.length===0?null:e.jsx("span",{className:"local-refs-badges",children:r.map(n=>e.jsx(Ie,{variant:n.tone==="current"?"default":n.tone==="warning"?"destructive":"outline",children:n.label},n.label))})}function u({label:r,children:n}){return e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:r}),e.jsx("dd",{children:n})]})}function He(r){switch(r){case"stale":return"The branch moved since this view loaded. It was refreshed; check the new state before deleting.";case"current":return"This branch is now checked out here, so Git will not delete it.";case"checked-out":return"Another worktree now has this branch checked out.";case"unmerged":return"Git found commits that are not in the comparison base, so the branch was kept.";case"unknown":return"The comparison base is not available locally, so the branch was kept.";default:return"The branch no longer exists."}}function Me(r){switch(r){case"stale":return"The worktree moved since this view loaded. It was refreshed; check the new state before removing.";case"main":return"Git can never remove the main worktree.";case"current":return"OpenTig has this worktree open. Switch to another one first.";case"dirty":return"The worktree has local changes or an operation in progress, so it was kept.";case"locked":return"The worktree is locked. Unlock it in Git first.";case"prunable":return"Git can no longer find this worktree on disk.";case"bare":return"This entry is a bare repository, not a removable worktree.";default:return"The worktree no longer exists."}}function Q(r){return r instanceof Error?r.message:String(r)}function ae(r,n=!1){const a=new Date(r);return Number.isNaN(a.getTime())?r:new Intl.DateTimeFormat("en",n?{dateStyle:"medium",timeStyle:"short"}:{dateStyle:"medium"}).format(a)}export{rr as LocalRefsDialog};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PullRequestDiff-DK-m07ZP.js","assets/react-rd22PHbN.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-CQcx9aRt.js","assets/index-DMbFAH51.css","assets/App-9EfSdZB8.js","assets/DiffWorkspace-Ca2ZUlVn.js","assets/PierreWorkerPool-DH2jp9oe.js","assets/platform-Bqt97_Jr.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-CtEztN1P.js","assets/EditContext-CvJWfVl1.js","assets/render-markdown-2GjhuGA-.js"])))=>i.map(i=>d[i]);
2
- import{c as D,B as k,T as H,a as F,b as M,_ as L,o as C,q}from"./index-CQcx9aRt.js";import{r as j,j as e}from"./react-rd22PHbN.js";import{G as T,P as V,I as $,a as O,b as B}from"./GitHubAvatar-EO1TD_1z.js";import{u as R}from"./tanstack-CtfgE41X.js";import{l as z,k as h,G as p,B as _,h as K,t as Q,z as U}from"./App-9EfSdZB8.js";import{V as X,a as J,b as x}from"./viewer-tabs-DkLmDzFg.js";import{p as W,r as Y,o as Z}from"./gh-utils-LsOSydCg.js";/* empty css */import"./base-ui-DT3JsyND.js";const ee=[["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"}]],se=D("outline","tag","Tag",ee),ae=j.lazy(()=>L(()=>import("./PullRequestDiff-DK-m07ZP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function he({repositoryId:r,prNumber:i,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:c,onClose:P,onSelectPullRequest:E}){const[v,S]=j.useState("summary"),t=R({queryKey:q.pullRequest(r,i),queryFn:async()=>{const a=await C.github.getPullRequest(r,i),A=a.body.trim()?await L(async()=>{const{renderMarkdown:u}=await import("./render-markdown-2GjhuGA-.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,o=R({queryKey:q.pullRequestDiff(r,i),queryFn:()=>C.github.getPullRequestDiff(r,i),enabled:v==="diff"&&s!==null}),b=o.data??null,g=o.error instanceof Error?o.error.message:o.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(k,{variant:"outline",size:"sm",onClick:()=>{t.refetch()},children:[e.jsx(z,{})," 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=W(s),y=Y(s.reviewDecision);return e.jsxs(X,{value:v,onValueChange:a=>S(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(_,{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(T,{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 ",I(s.updatedAt)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-branches",children:[e.jsx(K,{"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(re,{state:s.checksState}),y&&e.jsx(_,{variant:"outline",className:"pr-review-badge",children:y}),s.stack&&e.jsx(V,{repositoryId:r,number:i,membership:s.stack,onSelect:E}),e.jsx("span",{className:"pr-viewer-actions",children:e.jsxs(k,{variant:"outline",size:"xs",onClick:()=>Z(s.url),children:[e.jsx(Q,{})," Open on GitHub"]})})]}),s.labels.length>0&&e.jsxs("div",{className:"pr-labels","aria-label":"Pull request labels",children:[e.jsx(se,{"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(J,{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(U,{"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(T,{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 ",I(a.authoredAt)]})]}),e.jsxs(H,{children:[e.jsx(F,{render:e.jsx("code",{}),children:a.oid.slice(0,7)}),e.jsx(M,{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(ae,{diff:b,prNumber:s.number,repositoryId:r,commits:s.commits,diffView:n,themeType:d,wrapLines:l,onDiffViewChange:m,onWrapLinesChange:c,onClose:P})}):e.jsxs("div",{className:"viewer-message",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(p,{text:"Loading diff…"})]})})]})}function re({state:r}){if(r==="NONE")return null;const i=r==="PASSING"?$:r==="FAILING"?O:B,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 I(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,c]of d)if(Math.abs(n)>=c)return l.format(Math.round(n/c),m);return l.format(n,"second")}export{he as PullRequestViewer};
@@ -1 +0,0 @@
1
- import{j as e,r as v}from"./react-rd22PHbN.js";import{c as p,G as k,P as I,I as P,a as S,b as w}from"./GitHubAvatar-EO1TD_1z.js";import{a as R}from"./tanstack-CtfgE41X.js";import{c as b,B as t,I as N,T as c,a as o,b as u}from"./index-CQcx9aRt.js";import{C as y}from"./checkbox-DYwmgDPS.js";import{k as h,G as x,l as j,Z as E,M as G,t as L}from"./App-9EfSdZB8.js";import{o as O}from"./gh-utils-LsOSydCg.js";import{P as D,f as T,g as q,h as z,i as M}from"./base-ui-DT3JsyND.js";const $=[["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=b("outline","brand-github","BrandGithub",$);const A=[["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"}]],H=b("outline","filter","Filter",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(N,{})," 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(N,{})," 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 a=v.useRef(null),l=s.pulls,i=R({count:l?.length??0,getScrollElement:()=>a.current,estimateSize:()=>68,getItemKey:n=>l?.[n]?.number??n,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(D,{children:[e.jsx(T,{render:e.jsx(t,{variant:f(s.states)?"ghost":"secondary",size:"icon-xs",className:"change-action-button","aria-label":"Filter pull requests","aria-pressed":!f(s.states)}),children:e.jsx(H,{})}),e.jsx(q,{children:e.jsx(z,{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(n=>e.jsxs("label",{htmlFor:`pulls-state-${n.toLowerCase()}`,className:"pulls-filter-option",children:[e.jsx(y,{id:`pulls-state-${n.toLowerCase()}`,checked:s.states.includes(n),onCheckedChange:r=>s.onStateChange(n,r===!0)}),e.jsx(C,{state:n,className:n.toLowerCase()}),e.jsx("span",{children:n==="OPEN"?"Open":n==="CLOSED"?"Closed":"Merged"})]},n))]})})})]}),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(E,{})," 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:a,className:"pulls-scroll",role:"list","aria-label":`${s.states.map(g).join(", ")||"No"} pull requests`,children:l===null&&!s.error?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(x,{text:"Loading pull requests…"})]}):l!==null&&l.length===0?e.jsx("p",{className:"empty-list",children:s.states.length?`No ${s.states.map(n=>g(n).toLowerCase()).join(", ")} pull requests.`:"Select at least one PR state."}):l!==null&&e.jsx("div",{className:"virtual-list",style:{height:i.getTotalSize()},children:i.getVirtualItems().map(n=>{const r=l[n.index];return e.jsx("div",{ref:i.measureElement,"data-index":n.index,className:"virtual-row",style:{transform:`translateY(${n.start}px)`},children:e.jsx(V,{repositoryId:s.repositoryId,pr:r,active:s.activeNumber===r.number,onSelect:s.onSelect})},n.key)})})})]})}function V({repositoryId:s,pr:a,active:l,onSelect:i}){const n=a.state.toLowerCase(),r=W(a.updatedAt);return e.jsxs("div",{className:`pull-item ${l?"active":""}`,role:"listitem",children:[e.jsxs("button",{className:"pull-main",onClick:()=>i(a.number),"aria-label":`View pull request #${a.number}`,children:[e.jsx("span",{className:`pull-state-icon ${n}${a.isDraft?" draft":""}`,"aria-label":a.isDraft?"Draft":g(a.state),children:e.jsx(C,{state:a.state})}),e.jsxs("span",{className:"pull-content",children:[e.jsx("span",{className:"pull-title",children:a.title||"(no title)"}),e.jsxs("span",{className:"pull-meta",children:[e.jsxs("span",{className:"pull-number",children:["#",a.number]}),e.jsx(k,{src:a.authorAvatarUrl,className:"pull-avatar"}),e.jsx("span",{className:"pull-author",children:a.author}),e.jsx(_,{state:a.checksState}),a.isDraft&&e.jsx("span",{className:"pull-draft-label",children:"Draft"})]})]}),e.jsxs("span",{className:"pull-row-aside",children:[r&&e.jsx("span",{children:r}),e.jsxs("span",{className:"pull-line-stats",children:[e.jsxs("span",{className:"add",children:["+",a.additions]})," ",e.jsxs("span",{className:"del",children:["−",a.deletions]})]})]})]}),a.stack&&e.jsx(I,{repositoryId:s,number:a.number,membership:a.stack,onSelect:i}),e.jsxs(c,{children:[e.jsx(o,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button pull-open-external",onClick:()=>O(a.url),"aria-label":`Open #${a.number} on GitHub`}),children:e.jsx(L,{})}),e.jsx(u,{children:"Open on GitHub"})]})]})}function C({state:s,className:a}){return s==="MERGED"?e.jsx(p,{"aria-hidden":"true",className:a}):e.jsx(G,{"aria-hidden":"true",className:a})}function _({state:s}){if(s==="NONE")return null;const a=s==="PASSING"?"Checks passing":s==="FAILING"?"Checks failing":"Checks pending",l=s==="PASSING"?P:s==="FAILING"?S:w;return e.jsx("span",{className:`pull-checks ${s.toLowerCase()}`,"aria-label":a,children:e.jsx(l,{"aria-hidden":"true"})})}function g(s){return s==="OPEN"?"Open":s==="CLOSED"?"Closed":"Merged"}function f(s){return s.length===1&&s[0]==="OPEN"}function m({icon:s,title:a,children:l}){return e.jsxs("div",{className:"pulls-notice",children:[e.jsx("span",{className:"pulls-notice-icon","aria-hidden":"true",children:s}),e.jsx("strong",{children:a}),e.jsx("p",{children:l})]})}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 a=new Date(s);if(Number.isNaN(a.getTime()))return null;const l=Math.round((a.getTime()-Date.now())/1e3);for(const[i,n]of U)if(Math.abs(l)>=n)return B.format(Math.trunc(l/n),i);return"right now"}export{ae as PullRequestsView};
@@ -1 +0,0 @@
1
- import{r as f,j as e}from"./react-rd22PHbN.js";import{_ as y,$ as N,D as v,c as R,d as C,e as D,j as F,k as S,G as b,Y as I}from"./App-9EfSdZB8.js";import{c as M}from"./index-CQcx9aRt.js";import{A as q,j as w,k as z,l as L}from"./base-ui-DT3JsyND.js";import"./tanstack-CtfgE41X.js";const O=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M12 21h-5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v4.5",key:"svg-1"}],["path",{d:"M14 17.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0",key:"svg-2"}],["path",{d:"M18.5 19.5l2.5 2.5",key:"svg-3"}]],Q=M("outline","file-search","FileSearch",O);function E(t,s){const n=[],r=c=>{for(const i of c)i.type==="directory"?r(i.children):n.push({path:i.path,name:i.name,parentPath:N(i.path)})};return r(s?t:y(t)),n}function T(t,s,{includeIgnored:n,activePath:r=null,limit:c=100}){const i=E(t,n),h=x(s).trim(),l=Math.max(0,Math.floor(c));if(!h)return i.sort((a,p)=>a.path===r?-1:p.path===r?1:k(a.path,p.path)).slice(0,l);const u=h.replace(/\s+/g,"");return i.map(a=>{const p=x(a.name),m=x(a.path),o=A(p,m,h,u);return o?{...a,rank:o}:null}).filter(a=>a!==null).sort((a,p)=>P(a.rank,p.rank)||j(a.path)-j(p.path)||k(a.path,p.path)).slice(0,l).map(a=>({path:a.path,name:a.name,parentPath:a.parentPath}))}function A(t,s,n,r){if(t===n)return[0,0,0,0];if(t.startsWith(n))return[1,0,t.length-n.length,0];const c=t.indexOf(n);if(c>=0)return[2,c,t.length-n.length,0];const i=s.indexOf(n);if(i>=0)return[3,i,s.length-n.length,0];const h=g(t,r);if(h)return[4,...h];const l=g(s,r);return l?[5,...l]:null}function g(t,s){if(!s)return null;let n=-1,r=-1,c=0,i=0;for(const h of s){const l=t.indexOf(h,n+1);if(l<0)return null;r<0&&(r=l),n>=0&&(c+=l-n-1,l===n+1&&(i+=1)),n=l}return[c,-i,r,t.length-s.length]}function P(t,s){for(let n=0;n<Math.max(t.length,s.length);n+=1){const r=(t[n]??0)-(s[n]??0);if(r!==0)return r}return 0}function x(t){return t.replace(/\\/g,"/").toLocaleLowerCase()}function j(t){return t.split("/").length}function k(t,s){return t.localeCompare(s,void 0,{sensitivity:"base"})||t.localeCompare(s)}function U({open:t,files:s,includeIgnored:n,activePath:r,onOpenChange:c,onOpenFile:i}){const[h,l]=f.useState(""),u=f.useRef(null),a=f.useMemo(()=>s?T(s,h,{includeIgnored:n,activePath:r,limit:100}):[],[r,s,n,h]);f.useEffect(()=>{t&&(l(""),window.requestAnimationFrame(()=>u.current?.focus()))},[t]);const p=o=>{i(o)&&c(!1)},m=h.trim();return e.jsx(v,{open:t,onOpenChange:c,children:e.jsxs(R,{className:"quick-open-dialog top-[max(64px,12vh)] w-[min(640px,calc(100vw-2.5rem))] -translate-y-0",children:[e.jsx(C,{className:"sr-only",children:"Open file"}),e.jsx(D,{className:"sr-only",children:"Search files in the current repository."}),e.jsxs(q,{items:a,value:h,onValueChange:l,itemToStringValue:o=>o.path,mode:"none",inline:!0,open:t,autoHighlight:"always",onOpenChange:(o,d)=>{!o&&d.reason!=="item-press"&&c(!1)},children:[e.jsxs("div",{className:"quick-open-input-shell",children:[e.jsx(F,{"aria-hidden":"true"}),e.jsx(w,{ref:u,"aria-label":"Search files by name or path",autoComplete:"off",spellCheck:!1,placeholder:"Search files by name or path"})]}),e.jsx(z,{"aria-label":"Repository files",className:"quick-open-results",children:s===null?e.jsxs("div",{className:"quick-open-status loading",role:"status",children:[e.jsx(S,{className:"spinner","aria-hidden":"true"})," ",e.jsx(b,{text:"Loading files…"})]}):a.length===0?e.jsxs("div",{className:"quick-open-status",role:"status",children:[e.jsx(Q,{"aria-hidden":"true"}),e.jsx("strong",{children:"No matching files"}),e.jsx("p",{children:m?e.jsxs(e.Fragment,{children:["Nothing matches ",e.jsx("em",{children:m})," in this repository."]}):"This repository has no files to open."})]}):a.map((o,d)=>e.jsxs(L,{value:o,index:d,className:"quick-open-result",onClick:()=>p(o.path),children:[e.jsx("img",{className:"quick-open-icon",src:I(o.path),alt:"","aria-hidden":"true",draggable:!1}),e.jsx("span",{className:"quick-open-name",children:o.name}),e.jsx("span",{className:"quick-open-parent",children:o.parentPath||"Repository root"})]},o.path))})]}),e.jsxs("footer",{className:"quick-open-footer",children:[e.jsxs("span",{className:"quick-open-hints",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"↑"}),e.jsx("kbd",{children:"↓"})," navigate"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"↵"})," open"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"Esc"})," close"]})]}),s!==null&&e.jsx("span",{className:"quick-open-count",children:a.length===100?"Top 100 matches":`${a.length} ${a.length===1?"file":"files"}`})]})]})})}export{U as QuickOpenDialog};
@@ -1 +0,0 @@
1
- import{r,j as e}from"./react-rd22PHbN.js";import{D as Y,c as q,d as Q,e as Z,g as I,I as ee,m as k,a0 as z,k as _,a1 as w,y as O,a2 as se,N as ne,a3 as ae}from"./App-9EfSdZB8.js";import{c as M,B as o,T as C,a as R,b as B,o as h}from"./index-CQcx9aRt.js";import{I as ie}from"./IconFolderPlus-ByGyA0Di.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";const oe=[["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"}]],re=M("outline","folder-symlink","FolderSymlink",oe);const te=[["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"}]],le=M("outline","pencil","Pencil",te),D="__opentig_no_project__";function ue({open:l,projects:c,repositories:v,onOpenChange:F,onOrganizationChange:L,onForgetRepository:A,onRelocateRepository:P}){const[G,u]=r.useState(null),[x,f]=r.useState(null),[b,$]=r.useState(""),[g,d]=r.useState(null),[N,T]=r.useState(""),[J,p]=r.useState(null),[n,y]=r.useState(null),[S,m]=r.useState(null),K=r.useMemo(()=>new Map(c.flatMap(s=>s.repositoryKeys.map(a=>[a,s.id]))),[c]);r.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 L(t),!0}catch(t){return m(E(t)),!1}finally{y(null)}},X=async s=>{s.preventDefault();const a=b.trim();!a||n||await j("create",()=>h.projects.create(a))&&$("")},H=async s=>{s.preventDefault();const a=N.trim();!g||!a||n||await j(`rename:${g}`,()=>h.projects.rename(g,a))&&d(null)},U=async s=>{n||await j(`remove:${s}`,()=>h.projects.remove(s))&&p(null)},V=async(s,a)=>{n||await j(`assign:${s}`,()=>h.projects.assign(s,a))},W=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 P(s,a)}catch(a){m(E(a))}finally{y(null)}}};return e.jsxs(Y,{open:l,onOpenChange:s=>{n||F(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(Z,{children:"Group repositories, update their locations, or remove them from OpenTig. Files stay on disk."})]}),e.jsx(I,{render:e.jsx(o,{variant:"ghost",size:"icon-sm","aria-label":"Close project management",disabled:!!n}),children:e.jsx(ee,{})})]}),e.jsxs("div",{className:"repository-projects-body",children:[S&&e.jsxs("div",{className:"repository-projects-error",role:"alert",children:[e.jsx(k,{"aria-hidden":"true"}),e.jsx("span",{children:S})]}),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=>{X(s)},children:[e.jsx("label",{className:"sr-only",htmlFor:"new-project-name",children:"Project name"}),e.jsx("input",{id:"new-project-name",value:b,maxLength:z,onChange:s=>$(s.target.value),placeholder:"New project name",disabled:!!n}),e.jsxs(o,{type:"submit",size:"sm",disabled:!b.trim()||!!n,children:[n==="create"?e.jsx(_,{className:"animate-spin"}):e.jsx(ie,{})," 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=>{H(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:N,maxLength:z,onChange:i=>T(i.target.value),disabled:!!n}),e.jsx(o,{type:"submit",size:"xs",disabled:!N.trim()||!!n,children:"Save"}),e.jsx(o,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(null),disabled:!!n,children:"Cancel"})]}):J===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(o,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{U(s.id)},children:"Delete"}),e.jsx(o,{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(w,{})}),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(o,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${s.name}`,disabled:!!n,onClick:()=>{d(s.id),T(s.name),p(null)},children:e.jsx(le,{})}),e.jsx(o,{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(O,{})})]})]})},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=K.get(s.key)??D,t=n?.endsWith(`:${s.key}`);return e.jsx("div",{className:"repository-assignment-row","aria-busy":t||void 0,children:G===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(o,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{j(`forget:${s.key}`,()=>A(s)).then(i=>{i&&u(null)})},children:"Remove"}),e.jsx(o,{variant:"ghost",size:"xs",disabled:!!n,onClick:()=>u(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{"aria-hidden":"true"}),e.jsxs("span",{className:"repository-assignment-copy",children:[e.jsx("strong",{children:s.name}),e.jsxs(C,{children:[e.jsx(R,{render:e.jsx("small",{}),children:se(s.rootPath,4)}),e.jsx(B,{children:s.rootPath})]})]}),t&&e.jsx(_,{className:"repository-assignment-busy animate-spin","aria-hidden":"true"}),e.jsx(ne,{groups:[{id:"none",label:"",items:[{value:D,label:"No project",pinned:!0}]},{id:"projects",label:"Projects",items:c.map(i=>({value:i.id,label:i.name,icon:e.jsx(w,{})}))}],value:a,onValueChange:i=>{V(s.key,i===D?null:i)},label:`Project for ${s.name}`,triggerLabel:c.find(i=>i.id===a)?.name??"No project",placeholder:"Search projects…",disabled:!!n}),e.jsxs("span",{className:"repository-management-actions",children:[e.jsxs(C,{children:[e.jsx(R,{render:e.jsx(o,{variant:"ghost",size:"icon-sm","aria-label":`Relocate ${s.name}`,disabled:!!n,onClick:()=>{W(s)}}),children:e.jsx(re,{})}),e.jsx(B,{children:"Relocate repository"})]}),e.jsxs(C,{children:[e.jsx(R,{render:e.jsx(o,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${s.name} from OpenTig`,disabled:!!n,onClick:()=>{u(s.key),m(null)}}),children:e.jsx(O,{})}),e.jsx(B,{children:"Remove from OpenTig"})]})]})]})},s.key)})]})]})]}),e.jsx("footer",{className:"repository-projects-footer",children:e.jsx(I,{render:e.jsx(o,{variant:"outline",size:"sm",disabled:!!n}),children:"Done"})})]}),e.jsx(ae,{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 P(x,s)}})]})}function E(l){return l instanceof Error?l.message:String(l)}export{ue as RepositoryProjectsDialog};
@@ -1 +0,0 @@
1
- import{r as t,j as e}from"./react-rd22PHbN.js";import{a7 as pe,a8 as A,V as P,j as fe,G as Y,k as me}from"./App-9EfSdZB8.js";import{u as xe,a as ve}from"./tanstack-CtfgE41X.js";import{c as x,B as k,T as W,a as D,b as O,s as m,o as J,q as je}from"./index-CQcx9aRt.js";import"./base-ui-DT3JsyND.js";const ye=[["path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828",key:"svg-0"}],["path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87",key:"svg-1"}],["path",{d:"M3 3l18 18",key:"svg-2"}]],X=x("outline","eye-off","EyeOff",ye);const ke=[["path",{d:"M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0 -7 0",key:"svg-0"}],["path",{d:"M3 19v-10.5a3.5 3.5 0 0 1 7 0v10.5",key:"svg-1"}],["path",{d:"M3 13h7",key:"svg-2"}],["path",{d:"M21 12v7",key:"svg-3"}]],Me=x("outline","letter-case","LetterCase",ke);const Ne=[["path",{d:"M6.5 15a2.5 2.5 0 1 1 0 5a2.5 2.5 0 0 1 0 -5",key:"svg-0"}],["path",{d:"M17 7.875l3 -1.687",key:"svg-1"}],["path",{d:"M17 7.875v3.375",key:"svg-2"}],["path",{d:"M17 7.875l-3 -1.687",key:"svg-3"}],["path",{d:"M17 7.875l3 1.688",key:"svg-4"}],["path",{d:"M17 4.5v3.375",key:"svg-5"}],["path",{d:"M17 7.875l-3 1.688",key:"svg-6"}]],be=x("outline","regex","Regex",Ne);const we=[["path",{d:"M3 4a1 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:"M15 16a1 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-1"}],["path",{d:"M21 11v-3a2 2 0 0 0 -2 -2h-6l3 3m0 -6l-3 3",key:"svg-2"}],["path",{d:"M3 13v3a2 2 0 0 0 2 2h6l-3 -3m0 6l3 -3",key:"svg-3"}]],Z=x("outline","replace","Replace",we);const Se=[["path",{d:"M4 6l10 0",key:"svg-0"}],["path",{d:"M4 18l10 0",key:"svg-1"}],["path",{d:"M4 12h17l-3 -3m0 6l3 -3",key:"svg-2"}]],$e=x("outline","text-wrap-disabled","TextWrapDisabled",Se);const Re=[["path",{d:"M8 2h-4a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2z",key:"svg-0"}],["path",{d:"M20 14h-4a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2z",key:"svg-1"}],["path",{d:"M16.707 2.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.293 1.293h3.586a3 3 0 0 1 2.995 2.824l.005 .176v3a1 1 0 0 1 -1.993 .117l-.007 -.117v-3a1 1 0 0 0 -.883 -.993l-.117 -.007h-3.585l1.292 1.293a1 1 0 0 1 -1.32 1.497l-.094 -.083l-3 -3a.98 .98 0 0 1 -.28 -.872l.036 -.146l.04 -.104c.058 -.126 .14 -.24 .245 -.334l2.959 -2.958a1 1 0 0 1 1.414 0z",key:"svg-2"}],["path",{d:"M3 12a1 1 0 0 1 .993 .883l.007 .117v3a1 1 0 0 0 .883 .993l.117 .007h3.585l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083l.094 .083l3 3a.98 .98 0 0 1 .28 .872l-.036 .146l-.04 .104a1.02 1.02 0 0 1 -.245 .334l-2.959 2.958a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.291 -1.293h-3.584a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-3a1 1 0 0 1 1 -1z",key:"svg-3"}]],ee=x("filled","replace-filled","ReplaceFilled",Re);function Ce(l){return l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(l){if(!l.query)return null;const c=l.regex?l.query:Ce(l.query),i=l.wholeWord?`\\b(?:${c})\\b`:c;try{return new RegExp(i,l.matchCase?"g":"gi")}catch{return null}}const Te=250,Ee=28,_e=24;function He({repositoryId:l,active:c,revision:i,onOpenFile:h,unsavedPathsAmong:g,onReplaced:o}){const B=pe(),[f,ae]=t.useState(""),[M,se]=t.useState(!1),[N,te]=t.useState(!1),[b,le]=t.useState(!1),[p,ne]=t.useState(!1),[H,re]=t.useState(""),[w,ce]=t.useState(!1),[S,ie]=t.useState(!1),[$,G]=t.useState(!1),[oe,he]=t.useState(0),[L,Q]=t.useState(()=>new Set),V=t.useRef(null),K=t.useRef(null),R=t.useMemo(()=>({query:f,matchCase:M,wholeWord:N,regex:b,includeIgnored:w}),[f,M,N,b,w]),de=t.useMemo(()=>Ie(R),[R]),v=f.trim(),C=ze(v,Te),d=xe({queryKey:je.search(l,{query:C,matchCase:M,wholeWord:N,regex:b,includeIgnored:w,revision:i,replaceRevision:oe}),queryFn:()=>J.repository.search(l,{...R,query:C}),enabled:c&&C.length>0,placeholderData:(a,s)=>s?.queryKey[1]===l?a:void 0}),n=v?d.data??null:null,z=!!v&&(C!==v||d.isFetching),U=v&&d.error?d.error instanceof Error?d.error.message:"The search failed.":null;t.useEffect(()=>{c&&V.current?.focus()},[c]),t.useEffect(()=>{d.data&&Q(new Set(d.data.files.filter(a=>a.ignored).map(a=>a.path)))},[d.data]);const I=t.useMemo(()=>{if(!n)return[];const a=[];for(const s of n.files){const u=!L.has(s.path);if(a.push({kind:"file",file:s,open:u}),u)for(const E of s.matches)a.push({kind:"match",file:s,match:E})}return a},[L,n]),T=ve({count:I.length,getScrollElement:()=>K.current,estimateSize:a=>B?44:I[a]?.kind==="file"?Ee:_e,getItemKey:a=>{const s=I[a];return s?s.kind==="file"?`file:${s.file.path}`:`match:${s.file.path}:${s.match.line}:${s.match.column??1}`:a},overscan:12});t.useEffect(()=>{T.measure()},[T,B]);const ue=a=>Q(s=>{const u=new Set(s);return u.delete(a)||u.add(a),u}),j=n?.files.filter(a=>a.ignored).length??0,y=n?.files.filter(a=>!!a.revision&&(S||!a.ignored))??[],q=async a=>{if(!n||$)return;const s=a==="all"?{kind:"all",files:y.map(r=>({path:r.path,revision:r.revision}))}:"match"in a?{kind:"match",path:a.file.path,revision:a.file.revision,line:a.match.line,column:a.match.column}:{kind:"file",path:a.path,revision:a.revision};if(s.kind==="all"){if(n.truncated){m.info({title:"Narrow the search before replacing all",description:"The current result set is truncated."});return}const r=y.reduce((F,ge)=>F+ge.matches.length,0);if(!r||!window.confirm(`Replace ${r} ${r===1?"occurrence":"occurrences"} in ${y.length} ${y.length===1?"file":"files"}?`))return}else if(s.kind==="file"&&a!=="all"&&!("match"in a)&&a.truncatedMatches&&!window.confirm(`${a.path} has more matches than the ${a.matches.length} listed. Replace every occurrence in the file?`))return;const u=s.kind==="all"?s.files.map(r=>r.path):[s.path],E=g(u);if(E.length>0){m.error({title:"Save open files before replacing in them",description:E.join(", "),duration:1e4});return}G(!0);try{const r=await J.repository.replaceSearch(l,{options:{...R,query:f.trim()},replacement:H,scope:s});r.status==="stale"?m.error({title:"Files changed before replacement",description:"Search results were refreshed without overwriting anything."}):r.status==="no-match"?m.info({title:"No matching text to replace"}):(m.success({title:`Replaced ${r.replacements} ${r.replacements===1?"occurrence":"occurrences"}`,description:`${r.files.length} ${r.files.length===1?"file":"files"} changed`}),o(r.files)),he(F=>F+1)}catch(r){m.error({title:"Could not replace search results",description:r instanceof Error?r.message:"Unknown error",duration:1e4})}finally{G(!1)}};return e.jsxs("div",{className:"search-view",children:[e.jsxs("div",{className:"search-controls",children:[e.jsxs("div",{className:"search-query-row",children:[e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-toggle","aria-label":p?"Hide replace":"Show replace","aria-expanded":p,onClick:()=>ne(a=>!a),children:p?e.jsx(A,{}):e.jsx(P,{})}),e.jsxs("div",{className:"search-input",children:[e.jsx(fe,{"aria-hidden":"true"}),e.jsx("input",{ref:V,type:"text",value:f,spellCheck:!1,placeholder:"Search in repository","aria-label":"Search in repository",onChange:a=>ae(a.target.value)}),e.jsxs("span",{className:"search-toggles",children:[e.jsx(_,{label:"Match case",active:M,onToggle:()=>se(a=>!a),children:e.jsx(Me,{})}),e.jsx(_,{label:"Match whole word",active:N,onToggle:()=>te(a=>!a),children:e.jsx($e,{})}),e.jsx(_,{label:"Use regular expression",active:b,onToggle:()=>le(a=>!a),children:e.jsx(be,{})}),e.jsx(_,{label:"Search Git-ignored files",active:w,onToggle:()=>ce(a=>!a),children:e.jsx(X,{})})]})]})]}),p&&e.jsxs("div",{className:"search-replace-row",children:[e.jsx(Z,{"aria-hidden":"true"}),e.jsx("input",{value:H,spellCheck:!1,placeholder:"Replace","aria-label":"Replace with",onChange:a=>re(a.target.value)}),e.jsxs(W,{children:[e.jsx(D,{render:e.jsx(k,{variant:"ghost",size:"icon-xs",disabled:$||y.length===0||!!n?.truncated,"aria-label":"Replace all search results",onClick:()=>{q("all")}}),children:e.jsx(ee,{})}),e.jsx(O,{children:n?.truncated?"Narrow the search to replace all":"Replace all"})]})]}),p&&j>0&&e.jsxs("label",{className:"search-include-ignored",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:a=>ie(a.target.checked)})," Include ignored files when replacing"]}),f.trim()!==""&&(n!==null||!z)&&e.jsx("div",{className:"search-summary",children:z?e.jsx(Y,{text:"Searching…"}):U?e.jsx("span",{className:"search-error",children:U}):n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:n.totalMatches===0?"No results":`${n.totalMatches-n.ignoredMatches}${n.truncated?"+":""} ${n.totalMatches-n.ignoredMatches===1?"result":"results"} in ${n.files.length-j} ${n.files.length-j===1?"file":"files"}`}),n.ignoredMatches>0&&e.jsxs("span",{className:"search-summary-ignored",children:["· ",n.ignoredMatches," in ",j," ignored ",j===1?"file":"files"]})]})})]}),e.jsxs("div",{ref:K,className:"search-results",children:[z&&!n&&e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(me,{className:"spinner"})," ",e.jsx(Y,{text:"Searching…"})]}),e.jsx("div",{className:"search-rows virtual-list",style:{height:T.getTotalSize()},children:T.getVirtualItems().map(a=>{const s=I[a.index];return s?e.jsx("div",{className:"virtual-row",style:{height:a.size,transform:`translateY(${a.start}px)`},children:s.kind==="file"?e.jsxs("div",{className:`search-file-heading ${s.file.ignored?"ignored":""}`,children:[e.jsxs("button",{className:"search-file-toggle",onClick:()=>ue(s.file.path),"aria-expanded":s.open,children:[s.open?e.jsx(A,{}):e.jsx(P,{}),e.jsx("span",{className:"search-file-name",children:s.file.path}),s.file.ignored&&e.jsxs(W,{children:[e.jsx(D,{render:e.jsx("span",{className:"search-file-ignored-badge"}),children:e.jsx(X,{})}),e.jsx(O,{children:"Ignored by Git"})]}),e.jsx("span",{className:"search-file-count",children:s.file.matches.length})]}),p&&s.file.revision&&(!s.file.ignored||S)&&e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-action",disabled:$,"aria-label":`Replace all in ${s.file.path}`,onClick:()=>{q(s.file)},children:e.jsx(ee,{})})]}):e.jsxs("div",{className:"search-match",children:[e.jsxs("button",{className:"search-match-open",onClick:()=>h(s.file.path),children:[e.jsxs("span",{className:"search-match-line",children:[s.match.line,":",s.match.column??1]}),e.jsx("span",{className:"search-match-text",children:qe(s.match.text,de)})]}),p&&s.file.revision&&s.match.column&&(!s.file.ignored||S)&&e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-replace-action",disabled:$,"aria-label":`Replace match on line ${s.match.line}`,onClick:()=>{q({file:s.file,match:s.match})},children:e.jsx(Z,{})})]})},a.key):null})})]})]})}function ze(l,c){const[i,h]=t.useState(l);return t.useEffect(()=>{const g=window.setTimeout(()=>h(l),c);return()=>window.clearTimeout(g)},[c,l]),i}function _({label:l,active:c,onToggle:i,children:h}){return e.jsxs(W,{children:[e.jsx(D,{render:e.jsx(k,{variant:"ghost",size:"icon-xs",className:"search-toggle","aria-label":l,"aria-pressed":c,onClick:i}),children:h}),e.jsx(O,{children:l})]})}function qe(l,c){const i=l.replace(/^\s+/,"");if(!c)return i;c.lastIndex=0;const h=[];let g=0;for(let o=c.exec(i);o!==null;o=c.exec(i)){if(o[0]===""){c.lastIndex+=1;continue}h.push(e.jsx(t.Fragment,{children:i.slice(g,o.index)},`${o.index}-plain`),e.jsx("mark",{children:o[0]},`${o.index}-hit`)),g=o.index+o[0].length}return h.length===0?i:(h.push(e.jsx(t.Fragment,{children:i.slice(g)},"tail")),h)}export{He as SearchView};
@@ -1,9 +0,0 @@
1
- import{r as m,j as e}from"./react-rd22PHbN.js";import{M as Cs,i as ge,u as qe,g as Xe,h as Ss,j as Ms,L as Es,k as Rs,l as Is,p as As,c as L,d as ne,o as oe,s as M,B as w,T as _,a as D,b as B,I as Le,w as $e,m as Pe}from"./index-CQcx9aRt.js";import{D as K,c as Y,d as q,e as X,k as Z,l as ue,y as Se,g as J,I as Me,G as Ee,B as te,az as Ts,aA as me,aB as Fe,W as Je,aC as Ze,aD as Qe,aE as Os,aF as ze,aG as Ls,aH as $s,m as Re,S as je,C as ve,A as be,E as ye,aI as Ps,F as we,aJ as ae,aK as Fs,i as zs,aL as _s,aM as Ds,aN as Bs,aO as Gs,P as Us,N as Hs,aP as Vs}from"./App-9EfSdZB8.js";import{b as es,t as ss,c as ts,r as ns,d as as}from"./tanstack-CtfgE41X.js";import{I as Ws}from"./IconEdit-DePJMGIi.js";import"./base-ui-DT3JsyND.js";function _e(s,t){if(typeof s=="function")return s(t);s!=null&&(s.current=t)}function Ks(...s){return t=>{let n=!1;const a=s.map(i=>{const o=_e(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<a.length;i++){const o=a[i];typeof o=="function"?o():_e(s[i],null)}}}}function Ys(...s){return m.useCallback(Ks(...s),s)}class qs extends m.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(ge(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const a=n.offsetParent,i=ge(a)&&a.offsetWidth||0,o=ge(a)&&a.offsetHeight||0,r=getComputedStyle(n),c=this.props.sizeRef.current;c.height=parseFloat(r.height),c.width=parseFloat(r.width),c.top=n.offsetTop,c.left=n.offsetLeft,c.right=i-c.width-c.left,c.bottom=o-c.height-c.top,c.direction=r.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Xs({children:s,isPresent:t,anchorX:n,anchorY:a,root:i,pop:o}){const r=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(Cs),p=o!==!1?s.props?.ref??s?.ref:void 0,g=Ys(c,p);return m.useInsertionEffect(()=>{const{width:l,height:x,top:j,left:b,right:y,bottom:E,direction:k}=h.current;if(t||o===!1||!c.current||!l||!x)return;const T=k==="rtl",C=n==="left"?T?`right: ${y}`:`left: ${b}`:T?`left: ${b}`:`right: ${y}`,I=a==="bottom"?`bottom: ${E}`:`top: ${j}`;c.current.dataset.motionPopId=r;const R=document.createElement("style");f&&(R.nonce=f);const $=i??document.head;return $.appendChild(R),R.sheet&&R.sheet.insertRule(`
2
- [data-motion-pop-id="${r}"] {
3
- position: absolute !important;
4
- width: ${l}px !important;
5
- height: ${x}px !important;
6
- ${C}px !important;
7
- ${I}px !important;
8
- }
9
- `),()=>{c.current?.removeAttribute("data-motion-pop-id"),$.contains(R)&&$.removeChild(R)}},[t]),e.jsx(qs,{isPresent:t,childRef:c,sizeRef:h,pop:o,children:o===!1?s:m.cloneElement(s,{ref:g})})}const Js=({children:s,initial:t,isPresent:n,onExitComplete:a,custom:i,presenceAffectsLayout:o,mode:r,anchorX:c,anchorY:h,root:f})=>{const p=qe(Zs),g=m.useId(),l=m.useRef(n),x=m.useRef(a);Xe(()=>{l.current=n,x.current=a});let j=!0,b=m.useMemo(()=>(j=!1,{id:g,initial:t,isPresent:n,custom:i,onExitComplete:y=>{p.set(y,!0);for(const E of p.values())if(!E)return;a&&a()},register:y=>(p.set(y,!1),()=>{p.delete(y),!l.current&&!p.size&&x.current?.()})}),[n,p,a]);return o&&j&&(b={...b}),m.useMemo(()=>{p.forEach((y,E)=>p.set(E,!1))},[n]),m.useEffect(()=>{!n&&!p.size&&a&&a()},[n]),s=e.jsx(Xs,{pop:r==="popLayout",isPresent:n,anchorX:c,anchorY:h,root:f,children:s}),e.jsx(Ss.Provider,{value:b,children:s})};function Zs(){return new Map}const re=s=>s.key||"";function De(s){const t=[];return m.Children.forEach(s,n=>{m.isValidElement(n)&&t.push(n)}),t}const Be=({children:s,custom:t,initial:n=!0,onExitComplete:a,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:c="left",anchorY:h="top",root:f})=>{const[p,g]=Ms(r),l=m.useMemo(()=>De(s),[s]),x=r&&!p?[]:l.map(re),j=m.useRef(!0),b=m.useRef(l),y=qe(()=>new Map),E=m.useRef(new Set),[k,T]=m.useState(l),[C,I]=m.useState(l);Xe(()=>{j.current=!1,b.current=l;for(let A=0;A<C.length;A++){const N=re(C[A]);x.includes(N)?(y.delete(N),E.current.delete(N)):y.get(N)!==!0&&y.set(N,!1)}},[C,x.length,x.join("-")]);const R=[];if(l!==k){let A=[...l];for(let N=0;N<C.length;N++){const P=C[N],d=re(P);x.includes(d)||(A.splice(N,0,P),R.push(P))}return o==="wait"&&R.length&&(A=R),I(De(A)),T(l),null}const{forceRender:$}=m.useContext(Es);return e.jsx(e.Fragment,{children:C.map(A=>{const N=re(A),P=r&&!p?!1:l===C||x.includes(N),d=()=>{if(E.current.has(N))return;if(y.has(N))E.current.add(N),y.set(N,!0);else return;let v=!0;y.forEach(S=>{S||(v=!1)}),v&&($?.(),I(b.current),r&&g?.(),a&&a())};return e.jsx(Js,{isPresent:P,initial:!j.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:o,root:f,onExitComplete:P?void 0:d,anchorX:c,anchorY:h,children:A},N)})})};function Qs(){!Rs.current&&Is();const[s]=m.useState(As.current);return s}const et=[["path",{d:"M3 9l4 -4l4 4m-4 -4v14",key:"svg-0"}],["path",{d:"M21 15l-4 4l-4 -4m4 4v-14",key:"svg-1"}]],is=L("outline","arrows-sort","ArrowsSort",et);const st=[["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"}]],tt=L("outline","browser","Browser",st);const nt=[["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"}]],os=L("outline","device-desktop","DeviceDesktop",nt);const at=[["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"}]],it=L("outline","keyboard","Keyboard",at);const ot=[["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"}]],rt=L("outline","link","Link",ot);const lt=[["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"}]],ct=L("outline","list","List",lt);const dt=[["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"}]],ht=L("outline","moon","Moon",dt);const ut=[["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"}]],gt=L("outline","network","Network",ut);const mt=[["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"}]],pt=L("outline","qrcode","Qrcode",mt);const ft=[["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"}]],Ge=L("outline","shield-lock","ShieldLock",ft);const xt=[["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=L("outline","sort-ascending","SortAscending",xt);const jt=[["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"}]],ls=L("outline","sort-descending","SortDescending",jt);const vt=[["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"}]],cs=L("outline","sparkles","Sparkles",vt);const bt=[["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"}]],yt=L("outline","sun","Sun",bt);function ds({className:s,...t}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full",children:e.jsx("table",{"data-slot":"table",className:ne("w-full caption-bottom text-xs",s),...t})})}function hs({className:s,...t}){return e.jsx("thead",{"data-slot":"table-header",className:ne("[&_tr]:border-b",s),...t})}function us({className:s,...t}){return e.jsx("tbody",{"data-slot":"table-body",className:ne("[&_tr:last-child]:border-0",s),...t})}function he({className:s,...t}){return e.jsx("tr",{"data-slot":"table-row",className:ne("border-b border-border transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",s),...t})}function gs({className:s,...t}){return e.jsx("th",{"data-slot":"table-head",className:ne("h-8 whitespace-nowrap px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...t})}function ms({className:s,...t}){return e.jsx("td",{"data-slot":"table-cell",className:ne("px-2 py-1.5 align-middle [&:has([role=checkbox])]:pr-0",s),...t})}const wt={"commit-message":"commit message","pull-request-draft":"pull request draft"};function H({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(ls,{size:13}),!n&&e.jsx(is,{size:13,className:"ai-log-sort-idle"})]})}const kt=ss({rowSortingFeature:ns,sortedRowModel:as()}),F=ts(),Nt=F.columns([F.accessor("status",{header:({column:s})=>e.jsx(H,{column:s,label:"Status"}),cell:({getValue:s})=>{const t=s();return e.jsx(te,{variant:t==="success"?"secondary":t==="cancelled"?"outline":"destructive",children:t})}}),F.accessor("harness",{header:({column:s})=>e.jsx(H,{column:s,label:"Harness"}),cell:({getValue:s})=>e.jsx("strong",{children:s()})}),F.accessor("model",{header:({column:s})=>e.jsx(H,{column:s,label:"Model"}),cell:({getValue:s})=>e.jsx("span",{className:"ai-log-model",children:s()})}),F.accessor("operation",{header:({column:s})=>e.jsx(H,{column:s,label:"Task"}),cell:({getValue:s})=>wt[s()]}),F.accessor(s=>new Date(s.at).getTime(),{id:"at",header:({column:s})=>e.jsx(H,{column:s,label:"Date"}),cell:({row:s})=>e.jsx("time",{dateTime:s.original.at,children:new Date(s.original.at).toLocaleString()})}),F.accessor("durationMs",{header:({column:s})=>e.jsx(H,{column:s,label:"Duration"}),cell:({getValue:s})=>`${(s()/1e3).toFixed(1)}s`}),F.accessor(s=>(s.usage.inputTokens??0)+(s.usage.outputTokens??0),{id:"usage",header:({column:s})=>e.jsx(H,{column:s,label:"Usage"}),cell:({row:s})=>Mt(s.original)}),F.accessor("stagedFileCount",{header:({column:s})=>e.jsx(H,{column:s,label:"Staged"}),cell:({getValue:s})=>s()??"—"}),F.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(St,{text:a.text,tone:a.tone,detail:a.detail},a.key))})}})]);function Ct({open:s,onOpenChange:t}){const[n,a]=m.useState([]),[i,o]=m.useState(!1),[r,c]=m.useState([]),h=m.useCallback(async()=>{o(!0);try{a(await oe.ai.log())}catch(l){M.error({title:"Could not read the AI history",description:He(l)})}finally{o(!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=es({features:kt,data:n,columns:Nt,onSortingChange:c,state:{sorting:r}}),g=async()=>{if(window.confirm("Delete the whole AI history? This cannot be undone."))try{await oe.ai.clearLog(),a([])}catch(l){M.error({title:"Could not clear the AI history",description:He(l)})}};return e.jsx(K,{open:s,onOpenChange:t,children:e.jsxs(Y,{className:"ai-log-dialog",children:[e.jsxs("header",{className:"ai-log-header",children:[e.jsxs("div",{children:[e.jsx(q,{children:"AI history"}),e.jsx(X,{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(Z,{className:"animate-spin"}):e.jsx(ue,{})," Refresh"]}),e.jsxs(w,{variant:"ghost",size:"sm",disabled:n.length===0,onClick:()=>{g()},children:[e.jsx(Se,{})," Clear"]}),e.jsx(J,{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:ke(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(Z,{className:"spinner"})," ",e.jsx(Ee,{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(ds,{children:[e.jsx(hs,{children:p.getHeaderGroups().map(l=>e.jsx(he,{children:l.headers.map(x=>e.jsx(gs,{children:x.isPlaceholder?null:e.jsx(p.FlexRender,{header:x})},x.id))},l.id))}),e.jsx(us,{children:p.getRowModel().rows.map(l=>e.jsx(he,{className:l.original.status==="failed"?"ai-log-row-failed":void 0,children:l.getAllCells().map(x=>e.jsx(ms,{children:e.jsx(p.FlexRender,{cell:x})},x.id))},l.id))})]})})]})]})})}const Ue=140;function St({text:s,tone:t,detail:n}){const[a,i]=m.useState(!1),o=s.length>Ue?`${s.slice(0,Ue-1)}…`:s,r=`ai-log-note ${t??""}`;return n?e.jsxs(e.Fragment,{children:[e.jsxs(_,{children:[e.jsx(D,{render:e.jsx("button",{type:"button",className:r,onClick:()=>i(!0),"aria-label":"Read generation details"}),children:o}),e.jsx(B,{className:"max-w-md",children:n})]}),e.jsx(K,{open:a,onOpenChange:i,children:e.jsx(Y,{className:"name-dialog",children:e.jsxs("div",{className:"name-dialog-content",children:[e.jsx(q,{children:"Generation details"}),e.jsx(X,{className:"whitespace-pre-wrap break-words",children:n}),e.jsx("div",{className:"name-dialog-actions",children:e.jsx(J,{render:e.jsx(w,{variant:"outline"}),children:"Close"})})]})})})]}):e.jsx("span",{className:r,children:o})}function Mt(s){const{inputTokens:t,outputTokens:n,costUsd:a}=s.usage;if(t===null&&n===null)return"no usage reported";const i=`${ke(t??0)} in · ${ke(n??0)} out`;return a===null?i:`${i} · $${a.toFixed(4)}`}function ke(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}function He(s){return s instanceof Error?s.message:"An unexpected error occurred."}function ie({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(ls,{size:13}),!n&&e.jsx(is,{size:13,className:"ai-log-sort-idle"})]})}const Et=ss({rowSortingFeature:ns,sortedRowModel:as()}),se=ts(),Rt=se.columns([se.accessor("level",{header:({column:s})=>e.jsx(ie,{column:s,label:"Level"}),cell:({getValue:s})=>{const t=s();return e.jsx(te,{variant:t==="warn"?"outline":"destructive",children:t})}}),se.accessor("operation",{header:({column:s})=>e.jsx(ie,{column:s,label:"Operation"}),cell:({getValue:s})=>e.jsx("strong",{children:s()})}),se.accessor("code",{header:({column:s})=>e.jsx(ie,{column:s,label:"Code"}),cell:({getValue:s})=>s()??"—"}),se.accessor(s=>new Date(s.at).getTime(),{id:"at",header:({column:s})=>e.jsx(ie,{column:s,label:"Date"}),cell:({row:s})=>e.jsx("time",{dateTime:s.original.at,children:new Date(s.original.at).toLocaleString()})}),se.accessor("message",{header:({column:s})=>e.jsx(ie,{column:s,label:"Message"}),cell:({getValue:s})=>e.jsx("span",{className:"ai-log-model",children:s()})})]);function Ve(s){return s instanceof Error?s.message:"An unexpected error occurred."}function It({open:s,onOpenChange:t}){const[n,a]=m.useState([]),[i,o]=m.useState(!1),[r,c]=m.useState([]),h=m.useCallback(async()=>{o(!0);try{a(await oe.diagnostics.list())}catch(l){M.error({title:"Could not read local problems",description:Ve(l)})}finally{o(!1)}},[]);m.useEffect(()=>{s&&h()},[h,s]);const f=m.useMemo(()=>({all:n.length,errors:n.filter(l=>l.level==="error").length}),[n]),p=es({features:Et,data:n,columns:Rt,onSortingChange:c,state:{sorting:r}}),g=async()=>{if(window.confirm("Delete the local problem history? This cannot be undone."))try{await oe.diagnostics.clear(),a([])}catch(l){M.error({title:"Could not clear local problems",description:Ve(l)})}};return e.jsx(K,{open:s,onOpenChange:t,children:e.jsxs(Y,{className:"ai-log-dialog",children:[e.jsxs("header",{className:"ai-log-header",children:[e.jsxs("div",{children:[e.jsx(q,{children:"Problem history"}),e.jsx(X,{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(Z,{className:"animate-spin"}):e.jsx(ue,{})," Refresh"]}),e.jsxs(w,{variant:"ghost",size:"sm",disabled:n.length===0,onClick:()=>{g()},children:[e.jsx(Se,{})," Clear"]}),e.jsx(J,{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(Z,{className:"spinner"})," ",e.jsx(Ee,{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(ds,{children:[e.jsx(hs,{children:p.getHeaderGroups().map(l=>e.jsx(he,{children:l.headers.map(x=>e.jsx(gs,{children:x.isPlaceholder?null:e.jsx(p.FlexRender,{header:x})},x.id))},l.id))}),e.jsx(us,{children:p.getRowModel().rows.map(l=>e.jsx(he,{className:l.original.level==="error"?"ai-log-row-failed":void 0,children:l.getAllCells().map(x=>e.jsx(ms,{children:e.jsx(p.FlexRender,{cell:x})},x.id))},l.id))})]})})]})]})})}const At=new Set(["Control","Shift","Alt","Meta"]);function Tt({preferences:s,onPreference:t}){const n=m.useMemo(()=>Ts(s.shortcutOverrides),[s.shortcutOverrides]),[a,i]=m.useState(null),o=Object.keys(s.shortcutOverrides).length>0,r=m.useMemo(()=>["General","Commit","Editor","Tabs"].map(g=>({category:g,definitions:me.filter(l=>l.category===g)})),[]),c=m.useMemo(()=>[...new Set(Fe.map(g=>g.category))].map(g=>({category:g,items:Fe.filter(l=>l.category===g)})),[]),h=(p,g)=>{if(g===n[p]){i(null);return}const l=Os(p,g,n);if(l){const b=l==="reserved"?`${ze(g)} is reserved for a fixed shortcut.`:`${ze(g)} is already used by "${me.find(y=>y.id===l).label}".`;i({id:p,message:b});return}i(null);const x=me.find(b=>b.id===p),j={...s.shortcutOverrides};g===x.defaultCombo?delete j[p]:j[p]=g,t({shortcutOverrides:j})},f=p=>{i(null);const g={...s.shortcutOverrides};delete g[p],t({shortcutOverrides:g})};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."})]}),o&&e.jsxs(w,{variant:"outline",size:"sm",className:"shortcuts-reset-all",onClick:()=>{i(null),t({shortcutOverrides:{}})},children:[e.jsx(Je,{})," Reset all to defaults"]}),r.map(({category:p,definitions:g})=>e.jsxs("div",{className:"shortcuts-group",children:[e.jsx("div",{className:"shortcuts-group-heading",children:p}),g.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(Ot,{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:g})=>e.jsxs("div",{className:"shortcuts-group",children:[e.jsx("div",{className:"shortcuts-group-heading",children:p}),g.map(l=>e.jsxs("div",{className:"shortcuts-fixed-row",children:[e.jsx("span",{children:l.label}),e.jsx(Ze,{children:l.combo.split(" / ").flatMap((x,j)=>[...j>0?[e.jsx("span",{className:"shortcuts-fixed-sep",children:" / "},`sep-${x}`)]:[],...x.split(" + ").map((b,y)=>e.jsx(Qe,{children:b},`${x}-${y}`))])})]},l.combo+l.label))]},p))]})]})}function Ot({combo:s,allowBare:t,isCustom:n,error:a,onCapture:i,onReset:o}){const[r,c]=m.useState(!1);return m.useEffect(()=>{if(!r)return;const h=f=>{if(f.preventDefault(),f.stopPropagation(),f.key==="Escape"){c(!1);return}if(At.has(f.key))return;const p=Ls(f);c(!1),p&&$s(p,t)&&i(p)};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[r,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 ${r?"listening":""} ${a?"error":""}`,onClick:()=>c(!0),onBlur:()=>c(!1),children:r?"Press a key…":e.jsx(Ze,{children:s.split("+").map(h=>e.jsx(Qe,{children:h},h))})}),n&&e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"ghost",size:"icon-xs","aria-label":"Reset to default",onClick:o}),children:e.jsx(Je,{})}),e.jsx(B,{children:"Reset to default"})]})]})}var W=(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))(W||{});const Lt=[0,1],ps=[1,0],fs=[2,3],xs=[3,2],$t={L:Lt,M:ps,Q:fs,H:xs},Pt=/^\d*$/,Ft=/^[A-Z0-9 $%*+./:-]*$/,pe="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Ie=1,Ae=40,We=3,zt=3,le=40,_t=10,js=[[-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]],vs=[[-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 Dt{constructor(t,n,a,i){if(this.version=t,this.ecc=n,t<Ie||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 o=Array.from({length:this.size}).fill(!1);for(let c=0;c<this.size;c++)this.modules.push(o.slice()),this.types.push(o.map(()=>0));this.drawFunctionPatterns();const r=this.addEccAndInterleave(a);if(this.drawCodewords(r),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,W.Timing),this.setFunctionModule(a,6,a%2===0,W.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 o=0;o<10;o++)a=a<<1^(a>>>9)*1335;const i=(n<<10|a)^21522;for(let o=0;o<=5;o++)this.setFunctionModule(8,o,z(i,o));this.setFunctionModule(8,7,z(i,6)),this.setFunctionModule(8,8,z(i,7)),this.setFunctionModule(7,8,z(i,8));for(let o=9;o<15;o++)this.setFunctionModule(14-o,8,z(i,o));for(let o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,z(i,o));for(let o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,z(i,o));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=z(n,a),o=this.size-11+a%3,r=Math.floor(a/3);this.setFunctionModule(o,r,i),this.setFunctionModule(r,o,i)}}drawFinderPattern(t,n){for(let a=-4;a<=4;a++)for(let i=-4;i<=4;i++){const o=Math.max(Math.abs(i),Math.abs(a)),r=t+i,c=n+a;r>=0&&r<this.size&&c>=0&&c<this.size&&this.setFunctionModule(r,c,o!==2&&o!==4,W.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,W.Alignment)}setFunctionModule(t,n,a,i=W.Function){this.modules[n][t]=a,this.types[n][t]=i}addEccAndInterleave(t){const n=this.version,a=this.ecc;if(t.length!==de(n,a))throw new RangeError("Invalid argument");const i=vs[a[0]][n],o=js[a[0]][n],r=Math.floor(Ne(n)/8),c=i-r%i,h=Math.floor(r/i),f=[],p=qt(o);for(let l=0,x=0;l<i;l++){const j=t.slice(x,x+h-o+(l<c?0:1));x+=j.length;const b=Xt(j,p);l<c&&j.push(0),f.push(j.concat(b))}const g=[];for(let l=0;l<f[0].length;l++)f.forEach((x,j)=>{(l!==h-o||j>=c)&&g.push(x[l])});return g}drawCodewords(t){if(t.length!==Math.floor(Ne(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 o=0;o<2;o++){const r=a-o,h=(a+1&2)===0?this.size-1-i:i;!this.types[h][r]&&n<t.length*8&&(this.modules[h][r]=z(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 o=0;o<this.size;o++){let r=!1,c=0;const h=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[o][f]===r?(c++,c===5?t+=We:c>5&&t++):(this.finderPenaltyAddHistory(c,h),r||(t+=this.finderPenaltyCountPatterns(h)*le),r=this.modules[o][f],c=1);t+=this.finderPenaltyTerminateAndCount(r,c,h)*le}for(let o=0;o<this.size;o++){let r=!1,c=0;const h=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[f][o]===r?(c++,c===5?t+=We:c>5&&t++):(this.finderPenaltyAddHistory(c,h),r||(t+=this.finderPenaltyCountPatterns(h)*le),r=this.modules[f][o],c=1);t+=this.finderPenaltyTerminateAndCount(r,c,h)*le}for(let o=0;o<this.size-1;o++)for(let r=0;r<this.size-1;r++){const c=this.modules[o][r];c===this.modules[o][r+1]&&c===this.modules[o+1][r]&&c===this.modules[o+1][r+1]&&(t+=zt)}let n=0;for(const o of this.modules)n=o.reduce((r,c)=>r+(c?1:0),n);const a=this.size*this.size,i=Math.ceil(Math.abs(n*20-a*10)/a)-1;return t+=i*_t,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 G(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 z(s,t){return(s>>>t&1)!==0}class Te{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 Bt=[1,10,12,14],Gt=[2,9,11,13],Ut=[4,8,16,16];function bs(s,t){return s[Math.floor((t+7)/17)+1]}function ys(s){const t=[];for(const n of s)G(n,8,t);return new Te(Ut,s.length,t)}function Ht(s){if(!ws(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);G(Number.parseInt(s.substring(n,n+a),10),a*3+1,t),n+=a}return new Te(Bt,s.length,t)}function Vt(s){if(!ks(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=pe.indexOf(s.charAt(n))*45;a+=pe.indexOf(s.charAt(n+1)),G(a,11,t)}return n<s.length&&G(pe.indexOf(s.charAt(n)),6,t),new Te(Gt,s.length,t)}function Wt(s){return s===""?[]:ws(s)?[Ht(s)]:ks(s)?[Vt(s)]:[ys(Yt(s))]}function ws(s){return Pt.test(s)}function ks(s){return Ft.test(s)}function Kt(s,t){let n=0;for(const a of s){const i=bs(a.mode,t);if(a.numChars>=1<<i)return Number.POSITIVE_INFINITY;n+=4+i+a.bitData.length}return n}function Yt(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 Ne(s){if(s<Ie||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 de(s,t){return Math.floor(Ne(s)/8)-js[t[0]][s]*vs[t[0]][s]}function qt(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]=Ce(t[i],n),i+1<t.length&&(t[i]^=t[i+1]);n=Ce(n,2)}return t}function Xt(s,t){const n=t.map(a=>0);for(const a of s){const i=a^n.shift();n.push(0),t.forEach((o,r)=>n[r]^=Ce(o,i))}return n}function Ce(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 Jt(s,t,n=1,a=40,i=-1,o=!0){if(!(Ie<=n&&n<=a&&a<=Ae)||i<-1||i>7)throw new RangeError("Invalid value");let r,c;for(r=n;;r++){const g=de(r,t)*8,l=Kt(s,r);if(l<=g){c=l;break}if(r>=a)throw new RangeError("Data too long")}for(const g of[ps,fs,xs])o&&c<=de(r,g)*8&&(t=g);const h=[];for(const g of s){G(g.mode[0],4,h),G(g.numChars,bs(g.mode,r),h);for(const l of g.getData())h.push(l)}const f=de(r,t)*8;G(0,Math.min(4,f-h.length),h),G(0,(8-h.length%8)%8,h);for(let g=236;h.length<f;g^=253)G(g,8,h);const p=Array.from({length:Math.ceil(h.length/8)},()=>0);return h.forEach((g,l)=>p[l>>>3]|=g<<7-(l&7)),new Dt(r,t,p,i)}function Zt(s,t){const{ecc:n="L",boostEcc:a=!1,minVersion:i=1,maxVersion:o=40,maskPattern:r=-1,border:c=1}=t||{},h=typeof s=="string"?Wt(s):Array.isArray(s)?[ys(s)]:void 0;if(!h)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof s}`);const f=Jt(h,$t[n],i,o,r,a),p=Qt({version:f.version,maskPattern:f.mask,size:f.size,data:f.modules,types:f.types},c);return t?.invert&&(p.data=p.data.map(g=>g.map(l=>!l))),t?.onEncoded?.(p),p}function Qt(s,t=1){if(!t)return s;const{size:n}=s,a=n+t*2;s.size=a,s.data.forEach(o=>{for(let r=0;r<t;r++)o.unshift(!1),o.push(!1)});for(let o=0;o<t;o++)s.data.unshift(Array.from({length:a},r=>!1)),s.data.push(Array.from({length:a},r=>!1));const i=W.Border;s.types.forEach(o=>{for(let r=0;r<t;r++)o.unshift(i),o.push(i)});for(let o=0;o<t;o++)s.types.unshift(Array.from({length:a},r=>i)),s.types.push(Array.from({length:a},r=>i));return s}function Ke(s){return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function en(s,t={}){const n=Zt(s,t),{pixelSize:a=10,whiteColor:i="white",blackColor:o="black"}=t,r=n.size*a,c=n.size*a;let h=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${r}">`;const f=[];for(let p=0;p<n.size;p++)for(let g=0;g<n.size;g++){const l=g*a,x=p*a;n.data[p][g]&&f.push(`M${l},${x}h${a}v${a}h-${a}z`)}return h+=`<rect fill="${Ke(i)}" width="${c}" height="${r}"/>`,h+=`<path fill="${Ke(o)}" d="${f.join("")}"/>`,h+="</svg>",h}async function sn(){const s=await fetch("/api/auth/sessions",{credentials:"include"});if(!s.ok)throw new Error(await Oe(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 tn(s){return Ns("/api/auth/sessions/revoke",{sessionId:s})}async function nn(){return Ns("/api/auth/sessions/revoke-all",{})}async function an(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 Oe(n,"Could not rename the browser session."))}async function Ns(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 Oe(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 Oe(s,t){try{const n=await s.json();return typeof n.error=="string"?n.error:t}catch{return t}}const on={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([]),[o,r]=m.useState(null),[c,h]=m.useState(""),[f,p]=m.useState(!0),[g,l]=m.useState(null),[x,j]=m.useState(!1),[b,y]=m.useState(null),[E,k]=m.useState(null),[T,C]=m.useState(""),I=m.useCallback(async(u=!0)=>{const O=await Promise.allSettled([s?.getStatus()??Promise.resolve(null),sn()]);O[0].status==="fulfilled"?n(O[0].value):u&&M.error({title:"Could not read web access status",description:V(O[0].reason)}),O[1].status==="fulfilled"?i(O[1].value):u&&M.error({title:"Could not read owner sessions",description:V(O[1].reason)}),p(!1)},[s]);m.useEffect(()=>{I();const u=window.setInterval(()=>{I(!1)},2e3);return()=>window.clearInterval(u)},[I]),m.useEffect(()=>{t&&(t.pairingEndpoints.length?t.pairingEndpoints.includes(c)||h(t.pairingEndpoints[0]):h(""))},[c,t]);const R=m.useMemo(()=>o?`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(en(o.url,{ecc:"M",border:2}))}`:null,[o]),$=m.useMemo(()=>o?new URLSearchParams(new URL(o.url).hash.slice(1)).get("token")??"":"",[o]);if(f&&(!s||!t)&&a.length===0)return e.jsxs("div",{className:"web-access-loading",role:"status",children:[e.jsx(Z,{className:"animate-spin"})," Loading web access…"]});const A=async u=>{if(s){l("toggle"),r(null);try{n(await s.setEnabled(u)),M.success({title:u?"LAN access enabled":"LAN access disabled"})}catch(O){M.error({title:"Could not restart web access",description:V(O)}),await I(!1)}finally{l(null),j(!1)}}},N=async()=>{if(s){l("pair");try{r(await s.createPairingLink(c))}catch(u){M.error({title:"Could not create pairing link",description:V(u)})}finally{l(null)}}},P=async()=>{if(o)try{await $e(o.url),M.success({title:"Pairing link copied"})}catch(u){M.error({title:"Could not copy pairing link",description:V(u)})}},d=async()=>{if($)try{await $e($),M.success({title:"Pairing code copied"})}catch(u){M.error({title:"Could not copy pairing code",description:V(u)})}},v=async()=>{const u=E,O=T.trim();if(!(!u||!O||O.length>64)){l(`rename:${u.id}`);try{await an(u.id,O),M.success({title:"Device renamed"}),await I(!1),k(null)}catch(ee){M.error({title:"Could not rename device",description:V(ee)})}finally{l(null)}}},S=async()=>{const u=b;if(!u)return;const O=u==="all"?"revoke-all":`revoke:${u.id}`;l(O);try{const ee=u==="all"?await nn():await tn(u.id);r(null),M.success({title:`${ee} browser ${ee===1?"session":"sessions"} revoked`}),await I(!1)}catch(ee){M.error({title:"Could not revoke session",description:V(ee)})}finally{l(null),y(null)}},U=t?.serverState==="ready",Q=a.filter(u=>u.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:g==="toggle"||!U,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(ce,{label:"Server status",children:e.jsx(te,{variant:U?"secondary":"outline",children:on[t.serverState]})}),e.jsx(ce,{label:"Actual port",children:e.jsx("code",{children:t.actualPort??"Unavailable"})}),e.jsx(ce,{label:"Local endpoint",children:e.jsx(Ye,{value:t.localEndpoint})}),e.jsx(ce,{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(u=>e.jsx(Ye,{value:u,muted:!t.enabled},u))})})]}),t.restartError&&e.jsxs("div",{className:"web-access-error",role:"alert",children:[e.jsx(Re,{})," ",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:()=>{N()},disabled:!U||!c||g!==null,children:[g==="pair"?e.jsx(Z,{className:"animate-spin"}):e.jsx(rt,{})," 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(je,{value:c,onValueChange:u=>{u&&(h(u),r(null))},disabled:g!==null,children:[e.jsx(ve,{id:"web-access-endpoint",className:"w-full",children:e.jsx(be,{children:c})}),e.jsx(ye,{alignItemWithTrigger:!1,children:e.jsx(Ps,{children:t.pairingEndpoints.map(u=>e.jsx(we,{value:u,children:u},u))})})]})]}),o&&e.jsxs("div",{className:"web-access-pairing",role:"status",children:[e.jsxs("div",{className:"web-access-pairing-copy",children:[e.jsx(pt,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Pairing link ready"}),e.jsxs("span",{children:["Expires ",new Date(o.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(_,{children:[e.jsx(D,{render:e.jsx("code",{className:"web-access-link"}),children:o.url}),e.jsx(B,{side:"bottom",children:"One-use link; do not share publicly"})]}),e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"outline",size:"icon-sm","aria-label":"Copy pairing link",onClick:()=>{P()}}),children:e.jsx(Le,{})}),e.jsx(B,{children:"Copy pairing link"})]})]}),e.jsxs("div",{className:"web-access-link-row",children:[e.jsxs(_,{children:[e.jsx(D,{render:e.jsx("code",{className:"web-access-link"}),children:$}),e.jsx(B,{side:"bottom",children:"Paste this code on any /pair page served by this OpenTig instance"})]}),e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"outline",size:"icon-sm","aria-label":"Copy pairing code",onClick:()=>{d()}}),children:e.jsx(Le,{})}),e.jsx(B,{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:Q.length===0||g!==null,children:[e.jsx(Ge,{})," 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(u=>e.jsxs("div",{className:"web-access-session",children:[e.jsx("div",{className:`web-access-session-icon ${u.connected?"connected":""}`,children:u.kind==="desktop"?e.jsx(os,{}):e.jsx(tt,{})}),e.jsxs("div",{className:"web-access-session-copy",children:[e.jsxs("div",{children:[e.jsx("strong",{children:u.clientName}),u.current&&e.jsx(te,{variant:"secondary",children:"This session"}),u.kind==="desktop"&&e.jsx(te,{variant:"outline",children:"Desktop"})]}),e.jsxs("span",{children:[u.connected?`Connected${u.connectionCount>1?` (${u.connectionCount} tabs)`:""}`:u.lastConnectedAt?`Last connected ${ln(u.lastConnectedAt)}`:"Not yet connected"," · ",u.browser&&u.os?`${u.browser} on ${u.os}`:u.browser??u.os??cn(u.deviceType),u.viaProxy?" · Via proxy":"",u.remoteAddress?` · ${u.remoteAddress}`:""]})]}),u.kind!=="desktop"&&e.jsxs("div",{className:"web-access-session-controls",children:[e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${u.clientName}`,onClick:()=>{k(u),C(u.clientName)},disabled:g!==null}),children:e.jsx(Ws,{})}),e.jsx(B,{children:"Rename this device"})]}),e.jsxs(_,{children:[e.jsx(D,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":`Revoke ${u.clientName} session`,onClick:()=>y(u),disabled:g!==null}),children:e.jsx(Se,{})}),e.jsx(B,{children:"Revoke this browser session"})]})]})]},u.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(K,{open:x,onOpenChange:j,children:e.jsxs(Y,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(q,{children:"Enable owner-level LAN access?"}),e.jsx(X,{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(J,{render:e.jsx(w,{variant:"ghost"}),children:"Cancel"}),e.jsx(w,{onClick:()=>{A(!0)},disabled:g!==null,children:"Enable LAN access"})]})]})}),e.jsx(K,{open:b!==null,onOpenChange:u=>{u||y(null)},children:e.jsxs(Y,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(q,{children:b==="all"?"Revoke all browser sessions?":"Revoke this browser session?"}),e.jsx(X,{children:b==="all"?"Every paired browser disconnects immediately. The private desktop session remains signed in.":b?.current?"This browser will disconnect immediately and require a new pairing link.":"That browser disconnects immediately and will require a new pairing link."}),b&&b!=="all"&&e.jsx("div",{className:"undo-commit-summary",children:e.jsx("strong",{children:b.clientName})})]}),e.jsxs("div",{className:"undo-commit-actions",children:[e.jsx(J,{render:e.jsx(w,{variant:"ghost"}),children:"Cancel"}),e.jsxs(w,{variant:"destructive",onClick:()=>{S()},disabled:g!==null,children:[e.jsx(Ge,{})," Revoke"]})]})]})}),e.jsx(K,{open:E!==null,onOpenChange:u=>{u||k(null)},children:e.jsxs(Y,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(q,{children:"Rename paired device"}),e.jsx(X,{children:"Use a name that makes this browser easy to identify later."}),e.jsx("input",{className:"web-access-rename-input",value:T,onChange:u=>C(u.target.value),maxLength:64,"aria-label":"Device name",autoComplete:"off"})]}),e.jsxs("div",{className:"undo-commit-actions",children:[e.jsx(J,{render:e.jsx(w,{variant:"ghost"}),children:"Cancel"}),e.jsx(w,{onClick:()=>{v()},disabled:g!==null||!T.trim(),children:"Save"})]})]})})]})}function ce({label:s,children:t}){return e.jsxs("div",{className:"web-access-fact",children:[e.jsx("span",{children:s}),e.jsx("div",{children:t})]})}function Ye({value:s,muted:t=!1}){return s?e.jsxs(_,{children:[e.jsx(D,{render:e.jsx("code",{className:t?"muted":void 0}),children:s}),e.jsx(B,{side:"bottom",children:t?"Enable LAN access to use this endpoint":s})]}):e.jsx("span",{children:"Unavailable"})}function ln(s){const t=new Date(s);return Number.isNaN(t.getTime())?"unknown":t.toLocaleString()}function cn(s){return s==="desktop"?"Desktop browser":s==="mobile"?"Mobile browser":s==="tablet"?"Tablet browser":s==="bot"?"Automated client":"Unknown browser"}function V(s){return s instanceof Error?s.message:String(s)}const dn=[{id:"general",label:"General",icon:Fs},{id:"updates",label:"Updates",icon:ue},{id:"shortcuts",label:"Shortcuts",icon:it},{id:"ai",label:"AI assistance",icon:cs},{id:"diagnostics",label:"Diagnostics",icon:Re},{id:"webAccess",label:"Web access",icon:gt}],hn={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."}},un=[{value:"system",label:"System",icon:os},{value:"light",label:"Light",icon:yt},{value:"dark",label:"Dark",icon:ht}],fe=[{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"}],xe=[{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"}],gn=[{value:"tree",label:"Tree",icon:zs},{value:"list",label:"List",icon:ct}];function Nn({preferences:s,onPreference:t,open:n,onOpenChange:a,section:i,onSectionChange:o}){const[r,c]=m.useState([]),[h,f]=m.useState(!1),[p,g]=m.useState(!1),[l,x]=m.useState(!1),j=m.useRef(null),b=Qs(),y=b?{duration:0}:{duration:.16,ease:[.22,1,.36,1]},E=m.useCallback(async(d=!1)=>{f(!0);try{c(await oe.ai.statuses(d))}catch(v){M.error({title:"Could not check local AI",description:xn(v)})}finally{f(!1)}},[]);m.useEffect(()=>{n&&i==="ai"&&r.length===0&&E()},[E,n,i,r.length]),m.useLayoutEffect(()=>{n&&j.current&&(j.current.scrollTop=0)},[n,i]);const k=s.commitMessageHarness,T=r.find(d=>d.id===k),C=s.commitMessageModels[k]??"default",I=T?.models??[{id:"default",label:"Default (CLI)"}],R=I.some(d=>d.id===C)?I:[...I,{id:C,label:`${C} (unavailable)`}],$=[];for(const d of R){const v=k==="opencode"?d.id.indexOf("/"):-1,S=v>0?d.id.slice(0,v):k,U=d.id==="default"?"default":`provider:${S}`;let Q=$.find(u=>u.id===U);Q||(Q={id:U,label:d.id==="default"?"":v>0?S:ae(k),items:[]},$.push(Q)),Q.items.push({value:d.id,label:v>0&&d.label===d.id?d.id.slice(v+1):d.label,search:d.id,tooltip:d.id==="default"||d.label===d.id?d.label:`${d.label} · ${d.id}`,pinned:d.id==="default",icon:e.jsx(cs,{})})}const A=R.find(d=>d.id===C)?.label??C,{title:N,description:P}=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."}:hn[i];return e.jsx(K,{open:n,onOpenChange:a,children:e.jsx(Y,{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"}),dn.map(({id:d,label:v,icon:S})=>e.jsxs("button",{className:`settings-nav-item ${i===d?"active":""}`,onClick:()=>o(d),"aria-current":i===d,children:[e.jsx(S,{})," ",v]},d))]}),e.jsxs("section",{className:"settings-panel",children:[e.jsxs("header",{className:"settings-panel-header",children:[e.jsx(Be,{initial:!1,mode:"wait",children:e.jsxs(Pe.div,{initial:b?!1:{opacity:0,y:4},animate:{opacity:1,y:0},exit:b?{opacity:1}:{opacity:0,y:-3},transition:y,children:[e.jsx(q,{children:N}),e.jsx(X,{children:P})]},i)}),e.jsx(J,{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(Be,{initial:!1,mode:"wait",children:e.jsx(Pe.div,{className:"settings-panel-section",initial:b?!1:{opacity:0,y:7},animate:{opacity:1,y:0},exit:b?{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:un.map(({value:d,label:v,icon:S})=>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(S,{})," ",e.jsx("span",{children:v})]},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(je,{value:s.uiFont,onValueChange:d=>{const v=fe.find(S=>S.value===d);v&&t({uiFont:v.value})},children:[e.jsx(ve,{className:"settings-font-select","aria-label":"Interface font",style:{fontFamily:fe.find(d=>d.value===s.uiFont)?.family},children:e.jsx(be,{})}),e.jsx(ye,{align:"start",alignItemWithTrigger:!1,className:"w-max min-w-[16rem]",children:fe.map(d=>e.jsx(we,{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(je,{value:s.monoFont,onValueChange:d=>{const v=xe.find(S=>S.value===d);v&&t({monoFont:v.value})},children:[e.jsx(ve,{className:"settings-font-select","aria-label":"Code font",style:{fontFamily:xe.find(d=>d.value===s.monoFont)?.family},children:e.jsx(be,{})}),e.jsx(ye,{align:"start",alignItemWithTrigger:!1,className:"w-max min-w-[16rem]",children:xe.map(d=>e.jsx(we,{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:gn.map(({value:d,label:v,icon:S})=>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(S,{})," ",e.jsx("span",{children:v})]},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:Ds,step:_s,value:s.remoteFetchIntervalSeconds,onChange:d=>t({remoteFetchIntervalSeconds:Number(d.target.value)}),"aria-label":"Remote check interval"}),e.jsx("output",{children:Bs(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(Gs,{}):i==="shortcuts"?e.jsx(Tt,{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(Re,{})," View problems"]})]}),e.jsx(It,{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:()=>{E(!0)},disabled:h,children:[h?e.jsx(Z,{className:"animate-spin"}):e.jsx(ue,{})," ",h?e.jsx(Ee,{text:"Checking…"}):"Check again"]})]}),e.jsx("div",{className:"ai-harness-list",role:"radiogroup","aria-label":"Harness for AI assistance",children:["codex","claude","opencode","grok"].map(d=>{const v=r.find(U=>U.id===d),S=k===d;return e.jsxs("button",{type:"button",role:"radio","aria-checked":S,className:`ai-harness-card ${S?"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:ae(d)}),e.jsx("small",{children:h?"Checking…":v?.version||(v?v.installed?"Version unavailable":"Executable not found":"Status not checked")})]})]}),e.jsx(te,{variant:pn(v),className:`ai-status-badge ${v?.availability??"unknown"}`,children:mn(v)}),v?.message&&e.jsx("span",{className:"ai-harness-message",children:v.message})]},d)})}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsxs("strong",{children:[ae(k)," model"]}),e.jsx("span",{children:k==="grok"?"Default uses Grok’s built-in default. Custom CLI models and configuration are not loaded.":"Default lets the CLI choose. OpenTig remembers a separate selection for each harness."})]}),e.jsx(Hs,{groups:$,value:C,onValueChange:d=>t({commitMessageModels:{...s.commitMessageModels,[k]:d}}),label:`${ae(k)} model`,triggerLabel:A,triggerClassName:"ai-model-select",contentClassName:"ai-model-picker",size:"default",align:"start",placeholder:"Search models…"},k),T?.authStatus==="unauthenticated"&&e.jsxs("p",{className:"ai-login-hint",children:["Sign in from a terminal with ",e.jsx("code",{children:fn(k,T.cliName)})," and check again."]}),T&&!T.installed&&e.jsxs("p",{className:"ai-login-hint",children:["Install ",ae(k)," 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:()=>g(!0),children:[e.jsx(Vs,{})," 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(Ct,{open:p,onOpenChange:g})]})},i)})})]})]})})})}function mn(s){return s?s.installed?s.authStatus==="unauthenticated"?"Not authenticated":s.availability==="ready"?"Available":"Check":"Not installed":"Not checked"}function pn(s){return s?!s.installed||s.authStatus==="unauthenticated"||s.availability==="error"?"destructive":s.availability==="ready"?"default":"secondary":"outline"}function fn(s,t){return s==="codex"?"codex login":s==="claude"?"claude auth login":s==="grok"?"grok login":t==="opencode2"?"opencode2 auth login":"opencode auth login"}function xn(s){return s instanceof Error?s.message:"An unexpected error occurred."}export{Nn as SettingsDialog};
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PierreDiffViewer-8wTLYd5-.js","assets/react-rd22PHbN.js","assets/PierreWorkerPool-DH2jp9oe.js","assets/platform-Bqt97_Jr.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-CQcx9aRt.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-DMbFAH51.css","assets/index-CtEztN1P.js","assets/File-DTtWrbYf.js","assets/EditContext-CvJWfVl1.js","assets/DiffWorkspace-Ca2ZUlVn.js","assets/App-9EfSdZB8.js","assets/PierreEditBoundary-KzU3HDc2.js","assets/edit-ready-context-D77R8XU8.js","assets/MarkdownFileViewer-BNPb9v8u.js","assets/viewer-tabs-DkLmDzFg.js","assets/viewer-tabs-D8o-L3pM.css","assets/EditableFileViewer-85aEeMBK.js","assets/EditableFileViewer-B2G3Xa33.css","assets/render-markdown-2GjhuGA-.js","assets/markdown-BpzjXclZ.css","assets/PullRequestViewer-CpLwq4o2.js","assets/GitHubAvatar-EO1TD_1z.js","assets/gh-utils-LsOSydCg.js","assets/HtmlFileViewer-bL6T57PQ.js","assets/HtmlFileViewer-D6UPnZvW.css","assets/ImageFileViewer-DJaHH3hJ.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 le}from"./index-CQcx9aRt.js";import{r as l,j as t}from"./react-rd22PHbN.js";import{H as ne,J as re,K as oe,k as F,L as ue,G as Y}from"./App-9EfSdZB8.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";class fe{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 f=ce(this.options.sizeOf(o)),v=this.entries.get(e);return v&&(this.entries.delete(e),this.totalBytes-=v.bytes),f>this.options.maxBytes?!1:(this.entries.set(e,{value:o,bytes:f}),this.totalBytes+=f,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=l.lazy(()=>x(()=>import("./PierreDiffViewer-8wTLYd5-.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),de=l.lazy(()=>x(()=>import("./PierreEditBoundary-KzU3HDc2.js"),__vite__mapDeps([15,6,1,7,8,9,12,16])).then(i=>({default:i.PierreEditBoundary}))),me=l.lazy(()=>x(()=>import("./MarkdownFileViewer-BNPb9v8u.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=l.lazy(()=>x(()=>import("./PullRequestViewer-CpLwq4o2.js"),__vite__mapDeps([24,6,1,7,8,9,25,14,18,19,26,23])).then(i=>({default:i.PullRequestViewer}))),pe=l.lazy(()=>x(()=>import("./EditableFileViewer-85aEeMBK.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=l.lazy(()=>x(()=>import("./HtmlFileViewer-bL6T57PQ.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=l.lazy(()=>x(()=>import("./ImageFileViewer-DJaHH3hJ.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=l.lazy(()=>x(()=>import("./ImageFileViewer-DJaHH3hJ.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}))),R=new fe({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:f,theme:v,revision:y,readOnly:g,commits:$,draftFor:E,onSelect:C,onOpenFile:Z,onDiffViewChange:K,onWrapLinesChange:M,onDraftChange:O,onDraftSaved:A,onUpdateConflict:W,onResolveConflict:I}){const[a,w]=l.useState(null),[ee,L]=l.useState(!1),[D,q]=l.useState(null),[P,H]=l.useState(!1),b=l.useRef(0),N=l.useRef(!1),d=je(i,e);l.useEffect(()=>{H(!1),N.current=!1},[e]),l.useEffect(()=>{Q!==i&&(R.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"&&ue(e.path)){const n=await _.repository.readImage(i,e.path);if(s!==b.current)return;w({docKey:d,type:"image",value:n});return}const u=await _.repository.readFile(i,e.path,e.type==="conflict"?!0:P);if(s!==b.current)return;if(e.type==="conflict"){w({docKey:d,type:"conflict",value:u});return}w(n=>n&&n.docKey===d&&n.type==="file"&&N.current||n&&n.docKey===d&&n.type==="file"&&n.value.content===u.content&&n.value.size===u.size&&n.value.binary===u.binary&&n.value.tooLarge===u.tooLarge?n:{docKey:d,type:"file",value:u})}else{const u=e.type!=="diff";let n=u?R.get(d):void 0;if(n||(n=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}),u&&R.set(d,n)),s!==b.current)return;const p=n;w(c=>c&&c.docKey===d&&c.type==="diff"&&c.value.patch===p.patch&&c.value.binary===p.binary?c:{docKey:d,type:"diff",value:p})}}catch(u){s===b.current&&q(u instanceof Error?u.message:"Could not load the viewer.")}finally{s===b.current&&L(!1)}})()},[P,d,i,y,e]);const j=v==="system"?"system":v,te=f?"wrap":"scroll",S=l.useCallback(s=>{N.current=s},[]),B=l.useCallback(async(s,h,u)=>{const n=E(s),p=await _.repository.writeFile(i,s,h,n?.expectedContent??u);return p.status==="saved"&&(N.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]),k=l.useCallback(s=>s.path,[]),z=l.useCallback(s=>E(s.path)?.content??s.content,[E]),T=l.useCallback(s=>h=>O(s.path,h,s.content,s.mtimeMs),[O]),ie=ee&&a!==null&&!D;let r,V=null;if(!e)r=t.jsx(we,{});else if(e.type==="pull-request")r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(he,{repositoryId:i,prNumber:e.number,onSelectPullRequest:s=>C({type:"pull-request",number:s}),diffView:o,themeType:j,wrapLines:f,onDiffViewChange:K,onWrapLinesChange:M,onClose:()=>C(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(F,{className:"spinner"})," ",t.jsx(Y,{text:"Loading…"})]});else if(a.type==="image")r=t.jsx(l.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&&!P)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,V=t.jsx(l.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"&&ne(a.value.path)){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(me,{repositoryId:i,file:s,initialContent:z(s),revision:y,themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onOpenFile:Z,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="file"&&re(a.value.path)){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ye,{file:s,initialContent:z(s),themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="file"&&oe(a.value.path)){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(xe,{file:s,initialContent:z(s),themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="file"){const s=a.value;r=t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(pe,{file:s,initialContent:z(s),themeType:j,wrapLines:f,readOnly:g,onDirtyChange:S,onDraftChange:T(s),onSave:B},k(s))})}else if(a.type==="diff"&&a.value.patch){const s=e.type==="commit"||e.type==="commit-file"?e:null,h=s?$.find(n=>n.oid===s.oid):void 0,u=e.type==="commit-file"?t.jsx(J,{type:"button",variant:"outline",size:"xs",onClick:()=>C({type:"commit",oid:e.oid,subject:h?.subject??e.oid.slice(0,8)}),children:"All files"}):void 0;r=null,V=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(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(U,{kind:"diff",contentKey:a.docKey,value:a.value,diffView:o,themeType:j,wrapLines:f,initiallyCollapsed:e.type==="commit",compact:e.type==="diff",scopeControl:u,onDiffViewChange:K,onWrapLinesChange:M,onClose:()=>C(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:[V??t.jsx("div",{className:"viewer-transition",children:r},a?a.docKey:d),ie&&t.jsx("span",{className:"viewer-reloading","aria-hidden":"true",children:t.jsx(F,{className:"spinner"})})]});return a?.type!=="file"?G:t.jsx(l.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(de,{enabled:!0,children:G})})}function ge({commit:i,fallbackSubject:e}){const o=i?.date?new Date(i.date):null,[f,v]=l.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&&!f?"collapsed":""}`,children:y}),g&&t.jsx("button",{type:"button",className:"commit-description-toggle","aria-expanded":f,onClick:()=>v($=>!$),children:f?"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(le,{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(F,{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};