@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
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PullRequestDiff-DhKTXyIF.js","assets/react-rd22PHbN.js","assets/tanstack-B0Sf7wNU.js","assets/base-ui-CJ8ZIx3d.js","assets/index-DAUK3rnz.js","assets/index-BfA4tAc1.css","assets/App-BXZLGT86.js","assets/DiffWorkspace-RDG_Y70N.js","assets/PierreWorkerPool-Col4k7qz.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-BtCybfvQ.js"])))=>i.map(i=>d[i]);
2
+ import{c as H,B as b,T as D,a as V,b as $,_ as q,o as g,q as w}from"./index-DAUK3rnz.js";import{r as u,j as e}from"./react-rd22PHbN.js";import{l as F,k as o,Q as d,a3 as O,a4 as B,B as y,u as k,h as M,v as Q,x as z,E as K,Z as U}from"./App-BXZLGT86.js";import{G as C,P as X,a as Z,b as J}from"./GitHubAvatar-CnBaloV0.js";import{u as T}from"./tanstack-B0Sf7wNU.js";import{V as W,a as Y,b as m}from"./viewer-tabs-D-T0xQaq.js";/* empty css */import"./base-ui-CJ8ZIx3d.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=H("outline","tag","Tag",ee),ae=u.lazy(()=>q(()=>import("./PullRequestDiff-DhKTXyIF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function ue({repositoryId:r,prNumber:i,diffView:t,themeType:_,wrapLines:L,onDiffViewChange:P,onWrapLinesChange:R,onClose:A,onSelectPullRequest:E}){const[h,I]=u.useState("summary"),l=T({queryKey:w.pullRequest(r,i),queryFn:async()=>{const a=await g.github.getPullRequest(r,i),S=a.body.trim()?await q(async()=>{const{renderMarkdown:c}=await import("./render-markdown-BtCybfvQ.js").then(G=>G.a);return{renderMarkdown:c}},__vite__mapDeps([14,6,4,1,2,3,5,10,11])).then(({renderMarkdown:c})=>c(a.body)).catch(()=>"<p>Could not render the description.</p>"):"";return{details:a,bodyHtml:S}}}),s=l.data?.details??null,p=l.data?.bodyHtml??"",x=l.error instanceof Error?l.error.message:l.error?"Could not load the pull request.":null,n=T({queryKey:w.pullRequestDiff(r,i),queryFn:()=>g.github.getPullRequestDiff(r,i),enabled:h==="diff"&&s!==null}),j=n.data??null,v=n.error instanceof Error?n.error.message:n.error?"Could not load the diff.":null;if(x)return e.jsxs("div",{className:"viewer-message flex-col gap-3",children:[e.jsx("p",{className:"text-destructive",children:x}),e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>{l.refetch()},children:[e.jsx(F,{})," Try again"]})]});if(!s)return e.jsxs("div",{className:"viewer-message",children:[e.jsx(o,{className:"spinner"})," ",e.jsx(d,{text:`Loading pull request #${i}…`})]});const f=O(s),N=B(s.reviewDecision);return e.jsxs(W,{value:h,onValueChange:a=>I(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(y,{variant:s.state==="OPEN"&&!s.isDraft?"default":"secondary",className:`pr-state-badge ${f.toLowerCase().replace(/\s+/g,"-")}`,children:f}),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(C,{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 ",e.jsx("time",{dateTime:s.updatedAt,children:k(s.updatedAt)})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-branches",children:[e.jsx(M,{"aria-hidden":"true"})," ",s.headRefName," → ",s.baseRefName]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"pr-counters",children:[s.changedFiles," ",s.changedFiles===1?"file":"files"," ",e.jsxs("span",{className:"add",children:["+",s.additions]})," ",e.jsxs("span",{className:"del",children:["−",s.deletions]})]}),e.jsx(re,{state:s.checksState}),N&&e.jsx(y,{variant:"outline",className:"pr-review-badge",children:N}),s.stack&&e.jsx(X,{repositoryId:r,number:i,membership:s.stack,onSelect:E}),e.jsx("span",{className:"pr-viewer-actions",children:e.jsxs(b,{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(Y,{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(m,{value:"summary",className:"markdown-preview-scroll pr-description-scroll",children:e.jsx("section",{className:"pr-summary-section",children:p?e.jsx("div",{className:"markdown-prose",dangerouslySetInnerHTML:{__html:p}}):e.jsx("p",{className:"pr-empty-description",children:"This pull request has no description."})})}),e.jsx(m,{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(K,{"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(C,{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 ",e.jsx("time",{dateTime:a.authoredAt,children:k(a.authoredAt)})]})]}),e.jsxs(D,{children:[e.jsx(V,{render:e.jsx("code",{}),children:a.oid.slice(0,7)}),e.jsx($,{children:a.oid})]})]},a.oid)):e.jsx("p",{className:"pr-empty-description",children:"No commits were returned by GitHub."})]})}),e.jsx(m,{value:"diff",className:"pr-diff-panel",children:v?e.jsx("div",{className:"viewer-message text-destructive",children:v}):j?e.jsx(u.Suspense,{fallback:e.jsxs("div",{className:"viewer-message",children:[e.jsx(o,{className:"spinner"})," ",e.jsx(d,{text:"Loading diff viewer…"})]}),children:e.jsx(ae,{diff:j,prNumber:s.number,repositoryId:r,commits:s.commits,diffView:t,themeType:_,wrapLines:L,onDiffViewChange:P,onWrapLinesChange:R,onClose:A})}):e.jsxs("div",{className:"viewer-message",children:[e.jsx(o,{className:"spinner"})," ",e.jsx(d,{text:"Loading diff…"})]})})]})}function re({state:r}){if(r==="NONE")return null;const i=r==="PASSING"?Z:r==="FAILING"?J:U,t=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"})," ",t]})}export{ue as PullRequestViewer};
@@ -0,0 +1 @@
1
+ import{j as e,r as b}from"./react-rd22PHbN.js";import{k as h,Q as m,W as c,l as j,X as v,Y as p,p as k,v as I,x as P,Z as S}from"./App-BXZLGT86.js";import{I as G,G as R,P as w,a as y,b as L}from"./GitHubAvatar-CnBaloV0.js";import{a as O}from"./tanstack-B0Sf7wNU.js";import{c as E,B as t,I as N,T as o,a as u,b as d}from"./index-DAUK3rnz.js";import{C as q}from"./checkbox-BRH0ZNIC.js";import{P as D,b as z,c as T,d as $,e as H}from"./base-ui-CJ8ZIx3d.js";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"}]],F=E("outline","filter","Filter",A);function Z(s){return s.info===null?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(m,{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(m,{text:"Checking GitHub CLI…"})]}):s.ghStatus.installed?s.ghStatus.authStatus==="unauthenticated"?e.jsxs(x,{icon:e.jsx(c,{}),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(M,{...s,nameWithOwner:s.info.nameWithOwner??""}):e.jsxs(x,{icon:e.jsx(c,{}),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(x,{icon:e.jsx(c,{}),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 M(s){const a=b.useRef(null),n=s.pulls,i=O({count:n?.length??0,getScrollElement:()=>a.current,estimateSize:()=>68,getItemKey:l=>n?.[l]?.number??l,overscan:8});return e.jsxs("div",{className:"pulls-view",children:[e.jsxs("div",{className:"pulls-toolbar",children:[e.jsxs(o,{children:[e.jsxs(u,{render:e.jsx("span",{className:"pulls-repo"}),children:[e.jsx(c,{"aria-hidden":"true"})," ",s.nameWithOwner]}),e.jsx(d,{children:s.nameWithOwner})]}),e.jsxs(o,{children:[e.jsx(u,{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(d,{children:"Refresh pull requests"})]}),e.jsxs(D,{children:[e.jsx(z,{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(F,{})}),e.jsx(T,{children:e.jsx($,{side:"bottom",align:"end",sideOffset:4,className:"isolate z-50 outline-none",children:e.jsxs(H,{className:"pulls-filter-popup",children:[e.jsx("span",{className:"pulls-filter-title",children:"State"}),["OPEN","CLOSED","MERGED"].map(l=>e.jsxs("label",{htmlFor:`pulls-state-${l.toLowerCase()}`,className:"pulls-filter-option",children:[e.jsx(q,{id:`pulls-state-${l.toLowerCase()}`,checked:s.states.includes(l),onCheckedChange:r=>s.onStateChange(l,r===!0)}),e.jsx(C,{state:l,className:l.toLowerCase()}),e.jsx("span",{children:l==="OPEN"?"Open":l==="CLOSED"?"Closed":"Merged"})]},l))]})})})]}),e.jsxs(o,{children:[e.jsxs(u,{render:e.jsx(t,{variant:"outline",size:"xs",disabled:!!s.createDisabledReason||s.loading,onClick:s.onCreate,"aria-label":"Create pull request"}),children:[e.jsx(v,{})," New"]}),e.jsx(d,{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:n===null&&!s.error?e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(h,{className:"spinner"})," ",e.jsx(m,{text:"Loading pull requests…"})]}):n!==null&&n.length===0?e.jsx("p",{className:"empty-list",children:s.states.length?`No ${s.states.map(l=>g(l).toLowerCase()).join(", ")} pull requests.`:"Select at least one PR state."}):n!==null&&e.jsx("div",{className:"virtual-list",style:{height:i.getTotalSize()},children:i.getVirtualItems().map(l=>{const r=n[l.index];return e.jsx("div",{ref:i.measureElement,"data-index":l.index,className:"virtual-row",style:{transform:`translateY(${l.start}px)`},children:e.jsx(W,{repositoryId:s.repositoryId,pr:r,active:s.activeNumber===r.number,onSelect:s.onSelect})},l.key)})})})]})}function W({repositoryId:s,pr:a,active:n,onSelect:i}){const l=a.state.toLowerCase();return e.jsxs("div",{className:`pull-item ${n?"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 ${l}${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(R,{src:a.authorAvatarUrl,className:"pull-avatar"}),e.jsx("span",{className:"pull-author",children:a.author}),e.jsx(B,{state:a.checksState}),a.isDraft&&e.jsx("span",{className:"pull-draft-label",children:"Draft"})]})]}),e.jsxs("span",{className:"pull-row-aside",children:[e.jsx("time",{dateTime:a.updatedAt,children:k(a.updatedAt)}),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(w,{repositoryId:s,number:a.number,membership:a.stack,onSelect:i}),e.jsxs(o,{children:[e.jsx(u,{render:e.jsx(t,{variant:"ghost",size:"icon-xs",className:"change-action-button pull-open-external",onClick:()=>P(a.url),"aria-label":`Open #${a.number} on GitHub`}),children:e.jsx(I,{})}),e.jsx(d,{children:"Open on GitHub"})]})]})}function C({state:s,className:a}){return s==="MERGED"?e.jsx(G,{"aria-hidden":"true",className:a}):e.jsx(p,{"aria-hidden":"true",className:a})}function B({state:s}){if(s==="NONE")return null;const a=s==="PASSING"?"Checks passing":s==="FAILING"?"Checks failing":"Checks pending",n=s==="PASSING"?y:s==="FAILING"?L:S;return e.jsx("span",{className:`pull-checks ${s.toLowerCase()}`,"aria-label":a,children:e.jsx(n,{"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 x({icon:s,title:a,children:n}){return e.jsxs("div",{className:"pulls-notice",children:[e.jsx("span",{className:"pulls-notice-icon","aria-hidden":"true",children:s}),e.jsx("strong",{children:a}),e.jsx("p",{children:n})]})}export{Z as PullRequestsView};
@@ -0,0 +1 @@
1
+ import{r as f,j as e}from"./react-rd22PHbN.js";import{ad as y,ae as N,D as v,c as R,d as C,e as D,j as F,k as S,Q as b,ac as I}from"./App-BXZLGT86.js";import{c as M}from"./index-DAUK3rnz.js";import{A as q,j as Q,k as w,l as z}from"./base-ui-CJ8ZIx3d.js";import"./tanstack-B0Sf7wNU.js";const L=[["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"}]],O=M("outline","file-search","FileSearch",L);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 W({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(Q,{ref:u,"aria-label":"Search files by name or path",autoComplete:"off",spellCheck:!1,placeholder:"Search files by name or path"})]}),e.jsx(w,{"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(O,{"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(z,{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{W as QuickOpenDialog};
@@ -0,0 +1 @@
1
+ import{r as o,j as e}from"./react-rd22PHbN.js";import{D as W,c as Y,d as q,e as Q,g as I,I as Z,m as w,M as z,k as O,F as C,G as ee,C as E,H as se,S as ne,O as ae}from"./App-BXZLGT86.js";import{B as r,T as k,a as B,b as R,o as h}from"./index-DAUK3rnz.js";import{I as ie,a as re}from"./IconFolderSymlink-BZSLX1ez.js";import"./tanstack-B0Sf7wNU.js";import"./base-ui-CJ8ZIx3d.js";const D="__opentig_no_project__";function he({open:l,projects:c,repositories:x,onOpenChange:_,onOrganizationChange:M,onForgetRepository:L,onRelocateRepository:P}){const[A,g]=o.useState(null),[p,f]=o.useState(null),[b,T]=o.useState(""),[y,d]=o.useState(null),[N,$]=o.useState(""),[G,j]=o.useState(null),[n,v]=o.useState(null),[S,m]=o.useState(null),H=o.useMemo(()=>new Map(c.flatMap(s=>s.repositoryKeys.map(a=>[a,s.id]))),[c]);o.useEffect(()=>{l||(g(null),f(null),d(null),j(null),m(null))},[l]);const u=async(s,a)=>{v(s),m(null);try{const t=await a();return M(t),!0}catch(t){return m(F(t)),!1}finally{v(null)}},J=async s=>{s.preventDefault();const a=b.trim();!a||n||await u("create",()=>h.projects.create(a))&&T("")},K=async s=>{s.preventDefault();const a=N.trim();!y||!a||n||await u(`rename:${y}`,()=>h.projects.rename(y,a))&&d(null)},X=async s=>{n||await u(`remove:${s}`,()=>h.projects.remove(s))&&j(null)},U=async(s,a)=>{n||await u(`assign:${s}`,()=>h.projects.assign(s,a))},V=async s=>{if(!n){if(m(null),!window.opentigDesktop){f(s);return}v(`relocate:${s.key}`);try{const a=await h.repository.select(`Relocate ${s.name}`);a&&await P(s,a)}catch(a){m(F(a))}finally{v(null)}}};return e.jsxs(W,{open:l,onOpenChange:s=>{n||_(s)},children:[e.jsxs(Y,{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(Q,{children:"Group repositories, update their locations, or remove them from OpenTig. Files stay on disk."})]}),e.jsx(I,{render:e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":"Close project management",disabled:!!n}),children:e.jsx(Z,{})})]}),e.jsxs("div",{className:"repository-projects-body",children:[S&&e.jsxs("div",{className:"repository-projects-error",role:"alert",children:[e.jsx(w,{"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=>{J(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=>T(s.target.value),placeholder:"New project name",disabled:!!n}),e.jsxs(r,{type:"submit",size:"sm",disabled:!b.trim()||!!n,children:[n==="create"?e.jsx(O,{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:y===s.id?e.jsxs("form",{className:"repository-inline-form",onSubmit:i=>{K(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=>$(i.target.value),disabled:!!n}),e.jsx(r,{type:"submit",size:"xs",disabled:!N.trim()||!!n,children:"Save"}),e.jsx(r,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(null),disabled:!!n,children:"Cancel"})]}):G===s.id?e.jsxs("div",{className:"repository-project-confirm",role:"alert",children:[e.jsx(w,{"aria-hidden":"true"}),e.jsxs("span",{children:["Delete ",e.jsx("strong",{children:s.name}),"? Its repositories stay available, just ungrouped."]}),e.jsx(r,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{X(s.id)},children:"Delete"}),e.jsx(r,{variant:"ghost",size:"xs",disabled:!!n,onClick:()=>j(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"repository-project-icon","aria-hidden":"true",children:e.jsx(C,{})}),e.jsxs("span",{className:"repository-project-copy",children:[e.jsx("strong",{children:s.name}),e.jsxs("small",{children:[a," ",a===1?"repository":"repositories"]})]}),e.jsxs("span",{className:"repository-row-actions",children:[e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${s.name}`,disabled:!!n,onClick:()=>{d(s.id),$(s.name),j(null)},children:e.jsx(ee,{})}),e.jsx(r,{variant:"ghost",size:"icon-sm",className:"repository-row-delete","aria-label":`Delete ${s.name}`,disabled:!!n,onClick:()=>{j(s.id),d(null)},children:e.jsx(E,{})})]})]})},s.id)})]})]}),e.jsxs("section",{className:"repository-projects-section","aria-labelledby":"repository-assignments-heading",children:[e.jsxs("div",{className:"repository-projects-section-heading",children:[e.jsxs("h3",{id:"repository-assignments-heading",children:["Repositories ",e.jsx("span",{children:x.length})]}),e.jsx("p",{children:"One project per repository"})]}),e.jsxs("div",{className:"repository-assignment-list",children:[x.length===0&&e.jsx("p",{className:"repository-projects-empty",children:"No recent repositories to assign yet."}),x.map(s=>{const a=H.get(s.key)??D,t=n?.endsWith(`:${s.key}`);return e.jsx("div",{className:"repository-assignment-row","aria-busy":t||void 0,children:A===s.key?e.jsxs("div",{className:"repository-project-confirm",role:"alert",children:[e.jsx(w,{"aria-hidden":"true"}),e.jsxs("span",{children:["Remove ",e.jsx("strong",{children:s.name})," and its worktrees from OpenTig? Their folders and files stay on disk. You can open them again later."]}),e.jsx(r,{variant:"destructive",size:"xs",disabled:!!n,onClick:()=>{u(`forget:${s.key}`,()=>L(s)).then(i=>{i&&g(null)})},children:"Remove"}),e.jsx(r,{variant:"ghost",size:"xs",disabled:!!n,onClick:()=>g(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{"aria-hidden":"true"}),e.jsxs("span",{className:"repository-assignment-copy",children:[e.jsx("strong",{children:s.name}),e.jsxs(k,{children:[e.jsx(B,{render:e.jsx("small",{}),children:se(s.rootPath,4)}),e.jsx(R,{children:s.rootPath})]})]}),t&&e.jsx(O,{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(C,{})}))}],value:a,onValueChange:i=>{U(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(k,{children:[e.jsx(B,{render:e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":`Relocate ${s.name}`,disabled:!!n,onClick:()=>{V(s)}}),children:e.jsx(re,{})}),e.jsx(R,{children:"Relocate repository"})]}),e.jsxs(k,{children:[e.jsx(B,{render:e.jsx(r,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${s.name} from OpenTig`,disabled:!!n,onClick:()=>{g(s.key),m(null)}}),children:e.jsx(E,{})}),e.jsx(R,{children:"Remove from OpenTig"})]})]})]})},s.key)})]})]})]}),e.jsx("footer",{className:"repository-projects-footer",children:e.jsx(I,{render:e.jsx(r,{variant:"outline",size:"sm",disabled:!!n}),children:"Done"})})]}),e.jsx(ae,{open:p!==null,onOpenChange:s=>{s||f(null)},title:"Relocate repository",description:`Choose the existing server folder for ${p?.name??"this repository"}. This updates its saved location; it does not move files.`,confirmLabel:"Use this folder",initialPath:p?.recent.path,recent:x.map(s=>s.recent),onBrowse:h.repository.browseDirectories,onOpen:async s=>{p&&await P(p,s)}})]})}function F(l){return l instanceof Error?l.message:String(l)}export{he as RepositoryProjectsDialog};
@@ -0,0 +1 @@
1
+ import{r as t,j as e}from"./react-rd22PHbN.js";import{a5 as pe,ai as A,a9 as P,j as fe,Q as Y,k as me}from"./App-BXZLGT86.js";import{u as xe,a as ve}from"./tanstack-B0Sf7wNU.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-DAUK3rnz.js";import"./base-ui-CJ8ZIx3d.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),[$,Q]=t.useState(!1),[oe,he]=t.useState(0),[L,G]=t.useState(()=>new Set),K=t.useRef(null),V=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&&K.current?.focus()},[c]),t.useEffect(()=>{d.data&&G(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:()=>V.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=>G(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}Q(!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{Q(!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:K,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:V,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};
@@ -0,0 +1,9 @@
1
+ import{r as u,j as e}from"./react-rd22PHbN.js";import{M as Os,i as fe,u as ns,g as as,h as Ps,j as Ls,L as Fs,k as _s,l as zs,p as Ds,c as $,d as B,B as v,o as oe,s as M,T as _,a as z,b as D,I as Le,w as Fe,m as _e}from"./index-DAUK3rnz.js";import{ai as Bs,aO as ae,D as Y,c as X,d as J,e as Z,k as ee,l as ce,C as Ne,g as Q,I as Ce,Q as Se,B as ie,u as me,aP as is,F as ze,i as Us,J as Me,L as Ee,K as Ae,N as Re,P as le,aQ as De,aR as Be,aS as Ue,A as Hs,aT as Vs,aU as xe,aV as He,aa as rs,aW as ls,aX as os,aY as Gs,aZ as Ve,a_ as Ws,a$ as Ks,m as Ie,b0 as qs,b1 as Ys,b2 as Xs,a0 as Js,S as Zs,b3 as Qs}from"./App-BXZLGT86.js";import{r as et,s as st,t as tt,u as nt,v as at}from"./base-ui-CJ8ZIx3d.js";import{b as cs,t as ds,c as hs,r as us,d as gs}from"./tanstack-B0Sf7wNU.js";import{I as it}from"./IconEdit-Cg8S2wqW.js";function Ge(s,t){if(typeof s=="function")return s(t);s!=null&&(s.current=t)}function rt(...s){return t=>{let n=!1;const a=s.map(i=>{const r=Ge(i,t);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<a.length;i++){const r=a[i];typeof r=="function"?r():Ge(s[i],null)}}}}function lt(...s){return u.useCallback(rt(...s),s)}class ot extends u.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(fe(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const a=n.offsetParent,i=fe(a)&&a.offsetWidth||0,r=fe(a)&&a.offsetHeight||0,l=getComputedStyle(n),c=this.props.sizeRef.current;c.height=parseFloat(l.height),c.width=parseFloat(l.width),c.top=n.offsetTop,c.left=n.offsetLeft,c.right=i-c.width-c.left,c.bottom=r-c.height-c.top,c.direction=l.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function ct({children:s,isPresent:t,anchorX:n,anchorY:a,root:i,pop:r}){const l=u.useId(),c=u.useRef(null),d=u.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:p}=u.useContext(Os),h=r!==!1?s.props?.ref??s?.ref:void 0,m=lt(c,h);return u.useInsertionEffect(()=>{const{width:o,height:x,top:f,left:b,right:y,bottom:E,direction:P}=d.current;if(t||r===!1||!c.current||!o||!x)return;const w=P==="rtl",C=n==="left"?w?`right: ${y}`:`left: ${b}`:w?`left: ${b}`:`right: ${y}`,S=a==="bottom"?`bottom: ${E}`:`top: ${f}`;c.current.dataset.motionPopId=l;const A=document.createElement("style");p&&(A.nonce=p);const O=i??document.head;return O.appendChild(A),A.sheet&&A.sheet.insertRule(`
2
+ [data-motion-pop-id="${l}"] {
3
+ position: absolute !important;
4
+ width: ${o}px !important;
5
+ height: ${x}px !important;
6
+ ${C}px !important;
7
+ ${S}px !important;
8
+ }
9
+ `),()=>{c.current?.removeAttribute("data-motion-pop-id"),O.contains(A)&&O.removeChild(A)}},[t]),e.jsx(ot,{isPresent:t,childRef:c,sizeRef:d,pop:r,children:r===!1?s:u.cloneElement(s,{ref:m})})}const dt=({children:s,initial:t,isPresent:n,onExitComplete:a,custom:i,presenceAffectsLayout:r,mode:l,anchorX:c,anchorY:d,root:p})=>{const h=ns(ht),m=u.useId(),o=u.useRef(n),x=u.useRef(a);as(()=>{o.current=n,x.current=a});let f=!0,b=u.useMemo(()=>(f=!1,{id:m,initial:t,isPresent:n,custom:i,onExitComplete:y=>{h.set(y,!0);for(const E of h.values())if(!E)return;a&&a()},register:y=>(h.set(y,!1),()=>{h.delete(y),!o.current&&!h.size&&x.current?.()})}),[n,h,a]);return r&&f&&(b={...b}),u.useMemo(()=>{h.forEach((y,E)=>h.set(E,!1))},[n]),u.useEffect(()=>{!n&&!h.size&&a&&a()},[n]),s=e.jsx(ct,{pop:l==="popLayout",isPresent:n,anchorX:c,anchorY:d,root:p,children:s}),e.jsx(Ps.Provider,{value:b,children:s})};function ht(){return new Map}const de=s=>s.key||"";function We(s){const t=[];return u.Children.forEach(s,n=>{u.isValidElement(n)&&t.push(n)}),t}const Ke=({children:s,custom:t,initial:n=!0,onExitComplete:a,presenceAffectsLayout:i=!0,mode:r="sync",propagate:l=!1,anchorX:c="left",anchorY:d="top",root:p})=>{const[h,m]=Ls(l),o=u.useMemo(()=>We(s),[s]),x=l&&!h?[]:o.map(de),f=u.useRef(!0),b=u.useRef(o),y=ns(()=>new Map),E=u.useRef(new Set),[P,w]=u.useState(o),[C,S]=u.useState(o);as(()=>{f.current=!1,b.current=o;for(let R=0;R<C.length;R++){const N=de(C[R]);x.includes(N)?(y.delete(N),E.current.delete(N)):y.get(N)!==!0&&y.set(N,!1)}},[C,x.length,x.join("-")]);const A=[];if(o!==P){let R=[...o];for(let N=0;N<C.length;N++){const L=C[N],K=de(L);x.includes(K)||(R.splice(N,0,L),A.push(L))}return r==="wait"&&A.length&&(R=A),S(We(R)),w(o),null}const{forceRender:O}=u.useContext(Fs);return e.jsx(e.Fragment,{children:C.map(R=>{const N=de(R),L=l&&!h?!1:o===C||x.includes(N),K=()=>{if(E.current.has(N))return;if(y.has(N))E.current.add(N),y.set(N,!0);else return;let j=!0;y.forEach(k=>{k||(j=!1)}),j&&(O?.(),S(b.current),l&&m?.(),a&&a())};return e.jsx(dt,{isPresent:L,initial:!f.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:r,root:p,onExitComplete:L?void 0:K,anchorX:c,anchorY:d,children:R},N)})})};function ut(){!_s.current&&zs();const[s]=u.useState(Ds.current);return s}const gt=[["path",{d:"M4 10a2 2 0 1 0 4 0a2 2 0 0 0 -4 0",key:"svg-0"}],["path",{d:"M6 4v4",key:"svg-1"}],["path",{d:"M6 12v8",key:"svg-2"}],["path",{d:"M10 16a2 2 0 1 0 4 0a2 2 0 0 0 -4 0",key:"svg-3"}],["path",{d:"M12 4v10",key:"svg-4"}],["path",{d:"M12 18v2",key:"svg-5"}],["path",{d:"M16 7a2 2 0 1 0 4 0a2 2 0 0 0 -4 0",key:"svg-6"}],["path",{d:"M18 4v1",key:"svg-7"}],["path",{d:"M18 9v11",key:"svg-8"}]],mt=$("outline","adjustments","Adjustments",gt);const pt=[["path",{d:"M3 9l4 -4l4 4m-4 -4v14",key:"svg-0"}],["path",{d:"M21 15l-4 4l-4 -4m4 4v-14",key:"svg-1"}]],ms=$("outline","arrows-sort","ArrowsSort",pt);const ft=[["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"}]],xt=$("outline","browser","Browser",ft);const jt=[["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"}]],bt=$("outline","keyboard","Keyboard",jt);const vt=[["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"}]],yt=$("outline","link","Link",vt);const wt=[["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"}]],kt=$("outline","list","List",wt);const Nt=[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454l0 .008",key:"svg-0"}]],Ct=$("outline","moon","Moon",Nt);const St=[["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"}]],Mt=$("outline","network","Network",St);const Et=[["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"}]],At=$("outline","qrcode","Qrcode",Et);const Rt=[["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"}]],qe=$("outline","shield-lock","ShieldLock",Rt);const It=[["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"}]],ps=$("outline","sort-ascending","SortAscending",It);const Tt=[["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"}]],fs=$("outline","sort-descending","SortDescending",Tt);const $t=[["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"}]],xs=$("outline","sparkles","Sparkles",$t);const Ot=[["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"}]],js=$("outline","sun","Sun",Ot);const Pt=[["path",{d:"M4 20l3 0",key:"svg-0"}],["path",{d:"M14 20l7 0",key:"svg-1"}],["path",{d:"M6.9 15l6.9 0",key:"svg-2"}],["path",{d:"M10.2 6.3l5.8 13.7",key:"svg-3"}],["path",{d:"M5 20l6 -16l2 0l7 16",key:"svg-4"}]],Lt=$("outline","typography","Typography",Pt);function Ft({className:s,...t}){return e.jsx(et,{"data-slot":"accordion",className:B("w-full overflow-hidden rounded-xl border border-border",s),...t})}function _t({className:s,...t}){return e.jsx(st,{"data-slot":"accordion-item",className:B("not-last:border-b",s),...t})}function zt({className:s,children:t,...n}){return e.jsx(tt,{className:"flex",children:e.jsxs(nt,{"data-slot":"accordion-trigger",className:B("group flex flex-1 items-center justify-between gap-4 rounded-lg p-4 text-left text-xs font-semibold outline-none transition-colors hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-disabled:pointer-events-none aria-disabled:opacity-50",s),...n,children:[t,e.jsx(Bs,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground transition-transform group-aria-expanded:rotate-180 motion-reduce:transition-none"})]})})}function Dt({className:s,children:t,...n}){return e.jsx(at,{"data-slot":"accordion-content",className:"accordion-content",...n,children:e.jsx("div",{className:B("px-4 pb-4",s),children:t})})}function Bt({harness:s,preferences:t,status:n,onPreference:a}){const i=t.aiExecutablePaths[s]??"",[r,l]=u.useState(i),[c,d]=u.useState(!1),p=async h=>{d(!0);try{await a({aiExecutablePaths:{...t.aiExecutablePaths,[s]:h}})!==!1&&l(h)}finally{d(!1)}};return e.jsx(Ft,{className:"ai-executable-settings",children:e.jsxs(_t,{value:"cli-detection",children:[e.jsx(zt,{className:"ai-executable-trigger",children:e.jsxs("span",{className:"ai-executable-heading",children:[e.jsx(mt,{"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Advanced CLI detection"}),e.jsx("small",{children:"Executable path and diagnostics"})]})]})}),e.jsx(Dt,{className:"ai-executable-content",children:e.jsxs("div",{className:"settings-field",children:[e.jsxs("label",{className:"settings-field-label",htmlFor:"ai-executable-path",children:[e.jsxs("strong",{children:[ae(s)," executable"]}),e.jsx("span",{children:"Leave on Automatic, or enter an absolute executable path without arguments. For web access, use a path on the server."})]}),e.jsxs("div",{className:"ai-executable-editor",children:[e.jsx("input",{className:"ai-executable-input",id:"ai-executable-path",value:r,onChange:h=>l(h.target.value),placeholder:"Automatic",maxLength:4096,spellCheck:!1,autoComplete:"off",disabled:c}),e.jsxs("div",{className:"ai-executable-actions",children:[e.jsx(v,{size:"sm",onClick:()=>{p(r)},disabled:c||r===i,children:"Save path"}),e.jsx(v,{size:"sm",variant:"outline",onClick:()=>{p("")},disabled:c||!i&&!r,children:"Reset to Automatic"})]})]}),n?.executablePath&&e.jsxs("div",{className:"ai-executable-diagnostic",children:[e.jsx("strong",{children:"Detected executable"}),e.jsx("code",{children:n.executablePath}),e.jsxs("span",{children:["Source: ",Ut(n.executableSource)]})]}),n?.discoveryWarning&&e.jsx("p",{className:"ai-login-hint",children:n.discoveryWarning})]})})]})})}function Ut(s){return s==="configured"?"Configured path":s==="process-path"?"Inherited PATH":s==="user-path"?"Refreshed user PATH":"Known installation location"}function bs({className:s,...t}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full",children:e.jsx("table",{"data-slot":"table",className:B("w-full caption-bottom text-xs",s),...t})})}function vs({className:s,...t}){return e.jsx("thead",{"data-slot":"table-header",className:B("[&_tr]:border-b",s),...t})}function ys({className:s,...t}){return e.jsx("tbody",{"data-slot":"table-body",className:B("[&_tr:last-child]:border-0",s),...t})}function pe({className:s,...t}){return e.jsx("tr",{"data-slot":"table-row",className:B("border-b border-border transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",s),...t})}function ws({className:s,...t}){return e.jsx("th",{"data-slot":"table-head",className:B("h-8 whitespace-nowrap px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...t})}function ks({className:s,...t}){return e.jsx("td",{"data-slot":"table-cell",className:B("px-2 py-1.5 align-middle [&:has([role=checkbox])]:pr-0",s),...t})}const Ht={"commit-message":"commit message","pull-request-draft":"pull request draft"};function V({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(ps,{size:13}),n==="desc"&&e.jsx(fs,{size:13}),!n&&e.jsx(ms,{size:13,className:"ai-log-sort-idle"})]})}const Vt=ds({rowSortingFeature:us,sortedRowModel:gs()}),F=hs(),Gt=F.columns([F.accessor("status",{header:({column:s})=>e.jsx(V,{column:s,label:"Status"}),cell:({getValue:s})=>{const t=s();return e.jsx(ie,{variant:t==="success"?"secondary":t==="cancelled"?"outline":"destructive",children:t})}}),F.accessor("harness",{header:({column:s})=>e.jsx(V,{column:s,label:"Harness"}),cell:({getValue:s})=>e.jsx("strong",{children:s()})}),F.accessor("model",{header:({column:s})=>e.jsx(V,{column:s,label:"Model"}),cell:({getValue:s})=>e.jsx("span",{className:"ai-log-model",children:s()})}),F.accessor("operation",{header:({column:s})=>e.jsx(V,{column:s,label:"Task"}),cell:({getValue:s})=>Ht[s()]}),F.accessor(s=>new Date(s.at).getTime(),{id:"at",header:({column:s})=>e.jsx(V,{column:s,label:"Date"}),cell:({row:s})=>e.jsx("time",{dateTime:s.original.at,children:me(s.original.at,{seconds:!0})})}),F.accessor("durationMs",{header:({column:s})=>e.jsx(V,{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(V,{column:s,label:"Usage"}),cell:({row:s})=>qt(s.original)}),F.accessor("stagedFileCount",{header:({column:s})=>e.jsx(V,{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(Kt,{text:a.text,tone:a.tone,detail:a.detail},a.key))})}})]);function Wt({open:s,onOpenChange:t}){const[n,a]=u.useState([]),[i,r]=u.useState(!1),[l,c]=u.useState([]),d=u.useCallback(async()=>{r(!0);try{a(await oe.ai.log())}catch(o){M.error({title:"Could not read the AI history",description:Xe(o)})}finally{r(!1)}},[]);u.useEffect(()=>{s&&d()},[d,s]);const p=u.useMemo(()=>{const o=n.filter(x=>x.status==="failed").length;return{runs:n.length,failed:o,tokens:n.reduce((x,f)=>x+(f.usage.inputTokens??0)+(f.usage.outputTokens??0),0),cost:n.reduce((x,f)=>x+(f.usage.costUsd??0),0),costed:n.filter(x=>x.usage.costUsd!==null).length}},[n]),h=cs({features:Vt,data:n,columns:Gt,onSortingChange:c,state:{sorting:l}}),m=async()=>{if(window.confirm("Delete the whole AI history? This cannot be undone."))try{await oe.ai.clearLog(),a([])}catch(o){M.error({title:"Could not clear the AI history",description:Xe(o)})}};return e.jsx(Y,{open:s,onOpenChange:t,children:e.jsxs(X,{className:"ai-log-dialog",children:[e.jsxs("header",{className:"ai-log-header",children:[e.jsxs("div",{children:[e.jsx(J,{children:"AI history"}),e.jsx(Z,{children:"Recent generations on this machine. Prompts and file contents are never recorded."})]}),e.jsxs("div",{className:"ai-log-header-actions",children:[e.jsxs(v,{variant:"outline",size:"sm",disabled:i,onClick:()=>{d()},children:[i?e.jsx(ee,{className:"animate-spin"}):e.jsx(ce,{})," Refresh"]}),e.jsxs(v,{variant:"ghost",size:"sm",disabled:n.length===0,onClick:()=>{m()},children:[e.jsx(Ne,{})," Clear"]}),e.jsx(Q,{render:e.jsx(v,{variant:"ghost",size:"icon-sm","aria-label":"Close AI history"}),children:e.jsx(Ce,{})})]})]}),n.length>0&&e.jsxs("div",{className:"ai-log-totals",children:[e.jsxs("span",{children:[e.jsx("strong",{children:p.runs})," runs"]}),e.jsxs("span",{children:[e.jsx("strong",{children:p.failed})," failed"]}),e.jsxs("span",{children:[e.jsx("strong",{children:ye(p.tokens)})," tokens"]}),p.costed>0&&e.jsxs("span",{children:[e.jsxs("strong",{children:["$",p.cost.toFixed(4)]})," reported by ",p.costed," of ",p.runs]})]}),e.jsxs("div",{className:"ai-log-body",children:[i&&n.length===0&&e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(ee,{className:"spinner"})," ",e.jsx(Se,{text:"Reading history…"})]}),!i&&n.length===0&&e.jsx("p",{className:"ai-log-empty",children:"No generations recorded yet. Generate a commit message and it will show up here."}),n.length>0&&e.jsx("div",{className:"ai-log-table-wrap",children:e.jsxs(bs,{children:[e.jsx(vs,{children:h.getHeaderGroups().map(o=>e.jsx(pe,{children:o.headers.map(x=>e.jsx(ws,{children:x.isPlaceholder?null:e.jsx(h.FlexRender,{header:x})},x.id))},o.id))}),e.jsx(ys,{children:h.getRowModel().rows.map(o=>e.jsx(pe,{className:o.original.status==="failed"?"ai-log-row-failed":void 0,children:o.getAllCells().map(x=>e.jsx(ks,{children:e.jsx(h.FlexRender,{cell:x})},x.id))},o.id))})]})})]})]})})}const Ye=140;function Kt({text:s,tone:t,detail:n}){const[a,i]=u.useState(!1),r=s.length>Ye?`${s.slice(0,Ye-1)}…`:s,l=`ai-log-note ${t??""}`;return n?e.jsxs(e.Fragment,{children:[e.jsxs(_,{children:[e.jsx(z,{render:e.jsx("button",{type:"button",className:l,onClick:()=>i(!0),"aria-label":"Read generation details"}),children:r}),e.jsx(D,{className:"max-w-md",children:n})]}),e.jsx(Y,{open:a,onOpenChange:i,children:e.jsx(X,{className:"name-dialog",children:e.jsxs("div",{className:"name-dialog-content",children:[e.jsx(J,{children:"Generation details"}),e.jsx(Z,{className:"whitespace-pre-wrap break-words",children:n}),e.jsx("div",{className:"name-dialog-actions",children:e.jsx(Q,{render:e.jsx(v,{variant:"outline"}),children:"Close"})})]})})})]}):e.jsx("span",{className:l,children:r})}function qt(s){const{inputTokens:t,outputTokens:n,costUsd:a}=s.usage;if(t===null&&n===null)return"no usage reported";const i=`${ye(t??0)} in · ${ye(n??0)} out`;return a===null?i:`${i} · $${a.toFixed(4)}`}function ye(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}function Xe(s){return s instanceof Error?s.message:"An unexpected error occurred."}const Yt=[{value:"system",label:"System",icon:is},{value:"light",label:"Light",icon:js},{value:"dark",label:"Dark",icon:Ct}],Xt=[{value:"tree",label:"Tree",icon:Us},{value:"list",label:"List",icon:kt}],Jt=[{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"}],Zt=[{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"}],je=[0,15,30,60,120,300];function G({label:s,description:t,children:n,toggle:a=!1}){return e.jsxs("div",{className:`settings-general-row${a?" settings-general-toggle":""}`,children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:s}),e.jsx("span",{children:t})]}),e.jsx("div",{className:"settings-general-control",children:n})]})}function Je({label:s,options:t,value:n,onChange:a}){return e.jsx("div",{className:"settings-theme-options",role:"radiogroup","aria-label":s,children:t.map(({value:i,label:r,icon:l},c)=>e.jsxs("button",{type:"button",role:"radio","aria-checked":n===i,tabIndex:n===i?0:-1,className:`settings-theme-option${n===i?" active":""}`,onClick:()=>a(i),onKeyDown:d=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(d.key))return;d.preventDefault();const p=d.key==="Home"?0:d.key==="End"?t.length-1:(c+(["ArrowLeft","ArrowUp"].includes(d.key)?-1:1)+t.length)%t.length,h=t[p];h&&(a(h.value),d.currentTarget.parentElement?.querySelectorAll("button")[p]?.focus())},children:[e.jsx(l,{"aria-hidden":"true"}),e.jsx("span",{children:r})]},i))})}function Ze({label:s,options:t,value:n,onChange:a}){const i=t.find(r=>r.value===n);return e.jsxs(Me,{value:n,onValueChange:r=>{const l=t.find(c=>c.value===r);l&&a(l.value)},children:[e.jsxs(_,{children:[e.jsx(z,{render:e.jsx(Ee,{className:"settings-general-select w-[220px] text-[11px] font-normal","aria-label":s,style:{fontFamily:i?.family}}),children:e.jsx(Ae,{children:i?.label??n})}),e.jsx(D,{children:i?.label})]}),e.jsx(Re,{align:"end",alignItemWithTrigger:!1,className:"settings-general-font-menu min-w-[14rem]",children:t.map(r=>e.jsx(le,{value:r.value,className:"min-h-8 text-xs font-normal",children:e.jsx("span",{style:{fontFamily:r.family},children:r.label})},r.value))})]})}function be(s){return s===0?"Off":s>=60&&s%60===0?`${s/60} ${s===60?"minute":"minutes"}`:`${s} seconds`}function Qt({preferences:s,onPreference:t}){const n=u.useId(),a=u.useRef(null),[i,r]=u.useState(null),[l,c]=u.useState(!1),[d,p]=u.useState(!1),[h,m]=u.useState(!1),o=s.remoteFetchIntervalSeconds,x=()=>{r(null),c(!1),a.current?.focus()};return e.jsxs("div",{className:"settings-general",children:[e.jsxs("div",{className:"settings-general-content",children:[e.jsxs("section",{className:"settings-general-group","aria-labelledby":`${n}-appearance`,children:[e.jsxs("h3",{id:`${n}-appearance`,children:[e.jsx(js,{"aria-hidden":"true"}),"Appearance"]}),e.jsx(G,{label:"Theme",description:"Follow your system or choose a theme.",children:e.jsx(Je,{label:"Theme",options:Yt,value:s.theme,onChange:f=>t({theme:f})})}),e.jsx(G,{label:"Interface font",description:"Menus, labels and navigation.",children:e.jsx(Ze,{label:"Interface font",options:Jt,value:s.uiFont,onChange:f=>t({uiFont:f})})}),e.jsx(G,{label:"Code font",description:"Code, diffs and the file viewer.",children:e.jsx(Ze,{label:"Code font",options:Zt,value:s.monoFont,onChange:f=>t({monoFont:f})})}),e.jsx(G,{label:"Interface size",description:"Scale text, icons and controls.",children:e.jsxs("div",{className:"settings-zoom-control",children:[e.jsx("input",{type:"range",min:"80",max:"130",step:"10",value:s.uiZoom,onChange:f=>t({uiZoom:Number(f.target.value)}),"aria-label":"Interface zoom"}),e.jsxs("output",{"aria-live":"off",children:[s.uiZoom,"%"]})]})}),h&&e.jsxs("div",{id:`${n}-preview`,className:"settings-general-preview",children:[e.jsxs("span",{children:[e.jsx(ze,{"aria-hidden":"true"}),"src / components / Button.tsx"]}),e.jsxs("code",{children:[e.jsx("span",{children:"const"})," changes = files.filter(isModified);"]})]})]}),e.jsxs("section",{className:"settings-general-group","aria-labelledby":`${n}-files`,children:[e.jsxs("h3",{id:`${n}-files`,children:[e.jsx(ze,{"aria-hidden":"true"}),"Files & viewer"]}),e.jsx(G,{label:"Changes layout",description:"Folders or a flat list.",children:e.jsx(Je,{label:"Changes layout",options:Xt,value:s.changesLayout,onChange:f=>t({changesLayout:f})})}),e.jsxs(G,{label:"Wrap long lines",description:"Fit lines to the viewer width.",toggle:!0,children:[e.jsx("span",{className:"settings-general-switch-state","aria-hidden":"true",children:s.wrapLines?"On":"Off"}),e.jsx("button",{type:"button",role:"switch","aria-label":"Wrap long lines","aria-checked":s.wrapLines,className:"settings-switch",onClick:()=>t({wrapLines:!s.wrapLines}),children:e.jsx("span",{})})]}),e.jsxs(G,{label:"Show ignored files",description:e.jsxs(e.Fragment,{children:["Include files excluded by ",e.jsx("code",{children:".gitignore"}),"."]}),toggle:!0,children:[e.jsx("span",{className:"settings-general-switch-state","aria-hidden":"true",children:s.showDotEnvFiles?"On":"Off"}),e.jsx("button",{type:"button",role:"switch","aria-label":"Show ignored files","aria-checked":s.showDotEnvFiles,className:"settings-switch",onClick:()=>t({showDotEnvFiles:!s.showDotEnvFiles}),children:e.jsx("span",{})})]})]}),e.jsxs("section",{className:"settings-general-group","aria-labelledby":`${n}-sync`,children:[e.jsxs("h3",{id:`${n}-sync`,children:[e.jsx(ce,{"aria-hidden":"true"}),"Repository sync"]}),e.jsx(G,{label:"Remote check interval",description:"Keep ahead / behind counts current.",children:e.jsxs(Me,{value:String(o),onValueChange:f=>{c(!1),f==="custom"?r(String(o||30)):f!==null&&je.includes(Number(f))&&(r(null),t({remoteFetchIntervalSeconds:Number(f)}))},children:[e.jsx(Ee,{ref:a,className:"settings-general-select settings-general-interval w-[174px] text-[11px] font-normal","aria-label":"Remote check interval",children:e.jsx(Ae,{children:be(o)})}),e.jsxs(Re,{align:"end",alignItemWithTrigger:!1,className:"min-w-[14rem]",children:[je.map(f=>e.jsxs(le,{value:String(f),className:"min-h-8 text-xs font-normal",children:[be(f),f===30&&e.jsx("small",{className:"settings-general-option-note",children:"Default"})]},f)),!je.includes(o)&&e.jsxs(le,{value:String(o),className:"min-h-8 text-xs font-normal",children:[be(o),e.jsx("small",{className:"settings-general-option-note",children:"Custom"})]}),e.jsxs(le,{value:"custom",className:"min-h-8 text-xs font-normal",children:["Custom…",e.jsx("small",{className:"settings-general-option-note",children:"5–300 seconds"})]})]})]})}),e.jsxs("div",{className:"settings-general-help",children:[e.jsx("span",{children:o===0?"Periodic fetch is off.":`Checks every ${o} seconds.`}),e.jsx("button",{type:"button","aria-expanded":d,"aria-controls":`${n}-interval-help`,onClick:()=>p(!d),children:"What does Off do?"})]}),d&&e.jsx("p",{id:`${n}-interval-help`,className:"settings-general-help-detail",children:"Off disables periodic fetch. Remote checks still run when you pull or push."}),i!==null&&e.jsxs("form",{className:"settings-general-custom",noValidate:!0,onSubmit:f=>{f.preventDefault();const b=Number(i);if(!Number.isFinite(b)||b<Ue||b>Be||b%De!==0){c(!0);return}t({remoteFetchIntervalSeconds:b}),x()},children:[e.jsxs("div",{className:"settings-general-custom-controls",children:[e.jsx("label",{htmlFor:`${n}-custom-interval`,children:"Every"}),e.jsx("input",{id:`${n}-custom-interval`,type:"number",min:Ue,max:Be,step:De,required:!0,autoFocus:!0,value:i,"aria-label":"Custom interval in seconds","aria-invalid":l,"aria-describedby":`${n}-interval-range`,onChange:f=>{r(f.target.value),c(!1)},onKeyDown:f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),x())}}),e.jsx("span",{children:"seconds"}),e.jsx(v,{type:"submit",variant:"outline",size:"sm",children:"Apply"}),e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:x,children:"Cancel"})]}),e.jsx("p",{id:`${n}-interval-range`,className:l?"settings-general-error":"settings-general-help-detail",role:l?"alert":void 0,children:"Choose 5–300 seconds, in steps of 5."})]})]})]}),e.jsxs("footer",{className:"settings-general-footer",children:[e.jsxs("span",{children:[e.jsx(Hs,{"aria-hidden":"true"}),"Changes apply immediately"]}),e.jsxs("button",{type:"button","aria-expanded":h,"aria-controls":`${n}-preview`,onClick:()=>m(!h),children:[e.jsx(Lt,{"aria-hidden":"true"}),"Text preview"]})]})]})}function re({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(ps,{size:13}),n==="desc"&&e.jsx(fs,{size:13}),!n&&e.jsx(ms,{size:13,className:"ai-log-sort-idle"})]})}const en=ds({rowSortingFeature:us,sortedRowModel:gs()}),ne=hs(),sn=ne.columns([ne.accessor("level",{header:({column:s})=>e.jsx(re,{column:s,label:"Level"}),cell:({getValue:s})=>{const t=s();return e.jsx(ie,{variant:t==="warn"?"outline":"destructive",children:t})}}),ne.accessor("operation",{header:({column:s})=>e.jsx(re,{column:s,label:"Operation"}),cell:({getValue:s})=>e.jsx("strong",{children:s()})}),ne.accessor("code",{header:({column:s})=>e.jsx(re,{column:s,label:"Code"}),cell:({getValue:s})=>s()??"—"}),ne.accessor(s=>new Date(s.at).getTime(),{id:"at",header:({column:s})=>e.jsx(re,{column:s,label:"Date"}),cell:({row:s})=>e.jsx("time",{dateTime:s.original.at,children:me(s.original.at,{seconds:!0})})}),ne.accessor("message",{header:({column:s})=>e.jsx(re,{column:s,label:"Message"}),cell:({getValue:s})=>e.jsx("span",{className:"ai-log-model",children:s()})})]);function Qe(s){return s instanceof Error?s.message:"An unexpected error occurred."}function tn({open:s,onOpenChange:t}){const[n,a]=u.useState([]),[i,r]=u.useState(!1),[l,c]=u.useState([]),d=u.useCallback(async()=>{r(!0);try{a(await oe.diagnostics.list())}catch(o){M.error({title:"Could not read local problems",description:Qe(o)})}finally{r(!1)}},[]);u.useEffect(()=>{s&&d()},[d,s]);const p=u.useMemo(()=>({all:n.length,errors:n.filter(o=>o.level==="error").length}),[n]),h=cs({features:en,data:n,columns:sn,onSortingChange:c,state:{sorting:l}}),m=async()=>{if(window.confirm("Delete the local problem history? This cannot be undone."))try{await oe.diagnostics.clear(),a([])}catch(o){M.error({title:"Could not clear local problems",description:Qe(o)})}};return e.jsx(Y,{open:s,onOpenChange:t,children:e.jsxs(X,{className:"ai-log-dialog",children:[e.jsxs("header",{className:"ai-log-header",children:[e.jsxs("div",{children:[e.jsx(J,{children:"Problem history"}),e.jsx(Z,{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(v,{variant:"outline",size:"sm",disabled:i,onClick:()=>{d()},children:[i?e.jsx(ee,{className:"animate-spin"}):e.jsx(ce,{})," Refresh"]}),e.jsxs(v,{variant:"ghost",size:"sm",disabled:n.length===0,onClick:()=>{m()},children:[e.jsx(Ne,{})," Clear"]}),e.jsx(Q,{render:e.jsx(v,{variant:"ghost",size:"icon-sm","aria-label":"Close problem history"}),children:e.jsx(Ce,{})})]})]}),n.length>0&&e.jsxs("div",{className:"ai-log-totals",children:[e.jsxs("span",{children:[e.jsx("strong",{children:p.all})," recorded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:p.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(ee,{className:"spinner"})," ",e.jsx(Se,{text:"Reading problems…"})]}),!i&&n.length===0&&e.jsx("p",{className:"ai-log-empty",children:"No local problems recorded yet. Failed Git, file, and network operations will show up here."}),n.length>0&&e.jsx("div",{className:"ai-log-table-wrap",children:e.jsxs(bs,{children:[e.jsx(vs,{children:h.getHeaderGroups().map(o=>e.jsx(pe,{children:o.headers.map(x=>e.jsx(ws,{children:x.isPlaceholder?null:e.jsx(h.FlexRender,{header:x})},x.id))},o.id))}),e.jsx(ys,{children:h.getRowModel().rows.map(o=>e.jsx(pe,{className:o.original.level==="error"?"ai-log-row-failed":void 0,children:o.getAllCells().map(x=>e.jsx(ks,{children:e.jsx(h.FlexRender,{cell:x})},x.id))},o.id))})]})})]})]})})}const nn=new Set(["Control","Shift","Alt","Meta"]);function an({preferences:s,onPreference:t}){const n=u.useMemo(()=>Vs(s.shortcutOverrides),[s.shortcutOverrides]),[a,i]=u.useState(null),r=Object.keys(s.shortcutOverrides).length>0,l=u.useMemo(()=>["General","Commit","Editor","Tabs"].map(m=>({category:m,definitions:xe.filter(o=>o.category===m)})),[]),c=u.useMemo(()=>[...new Set(He.map(m=>m.category))].map(m=>({category:m,items:He.filter(o=>o.category===m)})),[]),d=(h,m)=>{if(m===n[h]){i(null);return}const o=Gs(h,m,n);if(o){const b=o==="reserved"?`${Ve(m)} is reserved for a fixed shortcut.`:`${Ve(m)} is already used by "${xe.find(y=>y.id===o).label}".`;i({id:h,message:b});return}i(null);const x=xe.find(b=>b.id===h),f={...s.shortcutOverrides};m===x.defaultCombo?delete f[h]:f[h]=m,t({shortcutOverrides:f})},p=h=>{i(null);const m={...s.shortcutOverrides};delete m[h],t({shortcutOverrides:m})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-field settings-toggle-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Show and focus from anywhere"}),e.jsx("span",{children:"Double-tap Control to bring OpenTig to the front, even while another app is focused."})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"Show and focus from anywhere","aria-checked":s.doubleControlShortcutEnabled,className:"settings-switch",onClick:()=>t({doubleControlShortcutEnabled:!s.doubleControlShortcutEnabled}),children:e.jsx("span",{})})]}),e.jsxs("div",{className:"settings-field settings-field-separated",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"Keyboard shortcuts"}),e.jsx("span",{children:"Click a shortcut, then press a new key combination. Press Escape to cancel."})]}),r&&e.jsxs(v,{variant:"outline",size:"sm",className:"shortcuts-reset-all",onClick:()=>{i(null),t({shortcutOverrides:{}})},children:[e.jsx(rs,{})," Reset all to defaults"]}),l.map(({category:h,definitions:m})=>e.jsxs("div",{className:"shortcuts-group",children:[e.jsx("div",{className:"shortcuts-group-heading",children:h}),m.map(o=>e.jsxs("div",{className:"shortcuts-row",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:o.label}),e.jsx("span",{children:o.description})]}),e.jsx(rn,{combo:n[o.id],allowBare:o.allowBare,isCustom:s.shortcutOverrides[o.id]!==void 0,error:a?.id===o.id?a.message:null,onCapture:x=>d(o.id,x),onReset:()=>p(o.id)})]},o.id))]},h))]}),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:h,items:m})=>e.jsxs("div",{className:"shortcuts-group",children:[e.jsx("div",{className:"shortcuts-group-heading",children:h}),m.map(o=>e.jsxs("div",{className:"shortcuts-fixed-row",children:[e.jsx("span",{children:o.label}),e.jsx(ls,{children:o.combo.split(" / ").flatMap((x,f)=>[...f>0?[e.jsx("span",{className:"shortcuts-fixed-sep",children:" / "},`sep-${x}`)]:[],...x.split(" + ").map((b,y)=>e.jsx(os,{children:b},`${x}-${y}`))])})]},o.combo+o.label))]},h))]})]})}function rn({combo:s,allowBare:t,isCustom:n,error:a,onCapture:i,onReset:r}){const[l,c]=u.useState(!1);return u.useEffect(()=>{if(!l)return;const d=p=>{if(p.preventDefault(),p.stopPropagation(),p.key==="Escape"){c(!1);return}if(nn.has(p.key))return;const h=Ws(p);c(!1),h&&Ks(h,t)&&i(h)};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[l,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 ${l?"listening":""} ${a?"error":""}`,onClick:()=>c(!0),onBlur:()=>c(!1),children:l?"Press a key…":e.jsx(ls,{children:s.split("+").map(d=>e.jsx(os,{children:d},d))})}),n&&e.jsxs(_,{children:[e.jsx(z,{render:e.jsx(v,{variant:"ghost",size:"icon-xs","aria-label":"Reset to default",onClick:r}),children:e.jsx(rs,{})}),e.jsx(D,{children:"Reset to default"})]})]})}var q=(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))(q||{});const ln=[0,1],Ns=[1,0],Cs=[2,3],Ss=[3,2],on={L:ln,M:Ns,Q:Cs,H:Ss},cn=/^\d*$/,dn=/^[A-Z0-9 $%*+./:-]*$/,ve="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Te=1,$e=40,es=3,hn=3,he=40,un=10,Ms=[[-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]],Es=[[-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 gn{constructor(t,n,a,i){if(this.version=t,this.ecc=n,t<Te||t>$e)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const r=Array.from({length:this.size}).fill(!1);for(let c=0;c<this.size;c++)this.modules.push(r.slice()),this.types.push(r.map(()=>0));this.drawFunctionPatterns();const l=this.addEccAndInterleave(a);if(this.drawCodewords(l),i===-1){let c=1e9;for(let d=0;d<8;d++){this.applyMask(d),this.drawFormatBits(d);const p=this.getPenaltyScore();p<c&&(i=d,c=p),this.applyMask(d)}}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,q.Timing),this.setFunctionModule(a,6,a%2===0,q.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),n=t.length;for(let a=0;a<n;a++)for(let i=0;i<n;i++)a===0&&i===0||a===0&&i===n-1||a===n-1&&i===0||this.drawAlignmentPattern(t[a],t[i]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.ecc[1]<<3|t;let a=n;for(let r=0;r<10;r++)a=a<<1^(a>>>9)*1335;const i=(n<<10|a)^21522;for(let r=0;r<=5;r++)this.setFunctionModule(8,r,U(i,r));this.setFunctionModule(8,7,U(i,6)),this.setFunctionModule(8,8,U(i,7)),this.setFunctionModule(7,8,U(i,8));for(let r=9;r<15;r++)this.setFunctionModule(14-r,8,U(i,r));for(let r=0;r<8;r++)this.setFunctionModule(this.size-1-r,8,U(i,r));for(let r=8;r<15;r++)this.setFunctionModule(8,this.size-15+r,U(i,r));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let a=0;a<12;a++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;for(let a=0;a<18;a++){const i=U(n,a),r=this.size-11+a%3,l=Math.floor(a/3);this.setFunctionModule(r,l,i),this.setFunctionModule(l,r,i)}}drawFinderPattern(t,n){for(let a=-4;a<=4;a++)for(let i=-4;i<=4;i++){const r=Math.max(Math.abs(i),Math.abs(a)),l=t+i,c=n+a;l>=0&&l<this.size&&c>=0&&c<this.size&&this.setFunctionModule(l,c,r!==2&&r!==4,q.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,q.Alignment)}setFunctionModule(t,n,a,i=q.Function){this.modules[n][t]=a,this.types[n][t]=i}addEccAndInterleave(t){const n=this.version,a=this.ecc;if(t.length!==ge(n,a))throw new RangeError("Invalid argument");const i=Es[a[0]][n],r=Ms[a[0]][n],l=Math.floor(we(n)/8),c=i-l%i,d=Math.floor(l/i),p=[],h=wn(r);for(let o=0,x=0;o<i;o++){const f=t.slice(x,x+d-r+(o<c?0:1));x+=f.length;const b=kn(f,h);o<c&&f.push(0),p.push(f.concat(b))}const m=[];for(let o=0;o<p[0].length;o++)p.forEach((x,f)=>{(o!==d-r||f>=c)&&m.push(x[o])});return m}drawCodewords(t){if(t.length!==Math.floor(we(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let a=this.size-1;a>=1;a-=2){a===6&&(a=5);for(let i=0;i<this.size;i++)for(let r=0;r<2;r++){const l=a-r,d=(a+1&2)===0?this.size-1-i:i;!this.types[d][l]&&n<t.length*8&&(this.modules[d][l]=U(t[n>>>3],7-(n&7)),n++)}}}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let a=0;a<this.size;a++){let i;switch(t){case 0:i=(a+n)%2===0;break;case 1:i=n%2===0;break;case 2:i=a%3===0;break;case 3:i=(a+n)%3===0;break;case 4:i=(Math.floor(a/3)+Math.floor(n/2))%2===0;break;case 5:i=a*n%2+a*n%3===0;break;case 6:i=(a*n%2+a*n%3)%2===0;break;case 7:i=((a+n)%2+a*n%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[n][a]&&i&&(this.modules[n][a]=!this.modules[n][a])}}getPenaltyScore(){let t=0;for(let r=0;r<this.size;r++){let l=!1,c=0;const d=[0,0,0,0,0,0,0];for(let p=0;p<this.size;p++)this.modules[r][p]===l?(c++,c===5?t+=es:c>5&&t++):(this.finderPenaltyAddHistory(c,d),l||(t+=this.finderPenaltyCountPatterns(d)*he),l=this.modules[r][p],c=1);t+=this.finderPenaltyTerminateAndCount(l,c,d)*he}for(let r=0;r<this.size;r++){let l=!1,c=0;const d=[0,0,0,0,0,0,0];for(let p=0;p<this.size;p++)this.modules[p][r]===l?(c++,c===5?t+=es:c>5&&t++):(this.finderPenaltyAddHistory(c,d),l||(t+=this.finderPenaltyCountPatterns(d)*he),l=this.modules[p][r],c=1);t+=this.finderPenaltyTerminateAndCount(l,c,d)*he}for(let r=0;r<this.size-1;r++)for(let l=0;l<this.size-1;l++){const c=this.modules[r][l];c===this.modules[r][l+1]&&c===this.modules[r+1][l]&&c===this.modules[r+1][l+1]&&(t+=hn)}let n=0;for(const r of this.modules)n=r.reduce((l,c)=>l+(c?1:0),n);const a=this.size*this.size,i=Math.ceil(Math.abs(n*20-a*10)/a)-1;return t+=i*un,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 H(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 U(s,t){return(s>>>t&1)!==0}class Oe{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 mn=[1,10,12,14],pn=[2,9,11,13],fn=[4,8,16,16];function As(s,t){return s[Math.floor((t+7)/17)+1]}function Rs(s){const t=[];for(const n of s)H(n,8,t);return new Oe(fn,s.length,t)}function xn(s){if(!Is(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);H(Number.parseInt(s.substring(n,n+a),10),a*3+1,t),n+=a}return new Oe(mn,s.length,t)}function jn(s){if(!Ts(s))throw new RangeError("String contains unencodable characters in alphanumeric mode");const t=[];let n;for(n=0;n+2<=s.length;n+=2){let a=ve.indexOf(s.charAt(n))*45;a+=ve.indexOf(s.charAt(n+1)),H(a,11,t)}return n<s.length&&H(ve.indexOf(s.charAt(n)),6,t),new Oe(pn,s.length,t)}function bn(s){return s===""?[]:Is(s)?[xn(s)]:Ts(s)?[jn(s)]:[Rs(yn(s))]}function Is(s){return cn.test(s)}function Ts(s){return dn.test(s)}function vn(s,t){let n=0;for(const a of s){const i=As(a.mode,t);if(a.numChars>=1<<i)return Number.POSITIVE_INFINITY;n+=4+i+a.bitData.length}return n}function yn(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 we(s){if(s<Te||s>$e)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 ge(s,t){return Math.floor(we(s)/8)-Ms[t[0]][s]*Es[t[0]][s]}function wn(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]=ke(t[i],n),i+1<t.length&&(t[i]^=t[i+1]);n=ke(n,2)}return t}function kn(s,t){const n=t.map(a=>0);for(const a of s){const i=a^n.shift();n.push(0),t.forEach((r,l)=>n[l]^=ke(r,i))}return n}function ke(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 Nn(s,t,n=1,a=40,i=-1,r=!0){if(!(Te<=n&&n<=a&&a<=$e)||i<-1||i>7)throw new RangeError("Invalid value");let l,c;for(l=n;;l++){const m=ge(l,t)*8,o=vn(s,l);if(o<=m){c=o;break}if(l>=a)throw new RangeError("Data too long")}for(const m of[Ns,Cs,Ss])r&&c<=ge(l,m)*8&&(t=m);const d=[];for(const m of s){H(m.mode[0],4,d),H(m.numChars,As(m.mode,l),d);for(const o of m.getData())d.push(o)}const p=ge(l,t)*8;H(0,Math.min(4,p-d.length),d),H(0,(8-d.length%8)%8,d);for(let m=236;d.length<p;m^=253)H(m,8,d);const h=Array.from({length:Math.ceil(d.length/8)},()=>0);return d.forEach((m,o)=>h[o>>>3]|=m<<7-(o&7)),new gn(l,t,h,i)}function Cn(s,t){const{ecc:n="L",boostEcc:a=!1,minVersion:i=1,maxVersion:r=40,maskPattern:l=-1,border:c=1}=t||{},d=typeof s=="string"?bn(s):Array.isArray(s)?[Rs(s)]:void 0;if(!d)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof s}`);const p=Nn(d,on[n],i,r,l,a),h=Sn({version:p.version,maskPattern:p.mask,size:p.size,data:p.modules,types:p.types},c);return t?.invert&&(h.data=h.data.map(m=>m.map(o=>!o))),t?.onEncoded?.(h),h}function Sn(s,t=1){if(!t)return s;const{size:n}=s,a=n+t*2;s.size=a,s.data.forEach(r=>{for(let l=0;l<t;l++)r.unshift(!1),r.push(!1)});for(let r=0;r<t;r++)s.data.unshift(Array.from({length:a},l=>!1)),s.data.push(Array.from({length:a},l=>!1));const i=q.Border;s.types.forEach(r=>{for(let l=0;l<t;l++)r.unshift(i),r.push(i)});for(let r=0;r<t;r++)s.types.unshift(Array.from({length:a},l=>i)),s.types.push(Array.from({length:a},l=>i));return s}function ss(s){return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Mn(s,t={}){const n=Cn(s,t),{pixelSize:a=10,whiteColor:i="white",blackColor:r="black"}=t,l=n.size*a,c=n.size*a;let d=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${l}">`;const p=[];for(let h=0;h<n.size;h++)for(let m=0;m<n.size;m++){const o=m*a,x=h*a;n.data[h][m]&&p.push(`M${o},${x}h${a}v${a}h-${a}z`)}return d+=`<rect fill="${ss(i)}" width="${c}" height="${l}"/>`,d+=`<path fill="${ss(r)}" d="${p.join("")}"/>`,d+="</svg>",d}async function En(){const s=await fetch("/api/auth/sessions",{credentials:"include"});if(!s.ok)throw new Error(await Pe(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 An(s){return $s("/api/auth/sessions/revoke",{sessionId:s})}async function Rn(){return $s("/api/auth/sessions/revoke-all",{})}async function In(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 Pe(n,"Could not rename the browser session."))}async function $s(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 Pe(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 Pe(s,t){try{const n=await s.json();return typeof n.error=="string"?n.error:t}catch{return t}}const Tn={starting:"Starting",ready:"Ready",restarting:"Restarting",failed:"Failed",stopped:"Stopped"};function $n(){const s=window.opentigDesktop?.webAccess,[t,n]=u.useState(null),[a,i]=u.useState([]),[r,l]=u.useState(null),[c,d]=u.useState(""),[p,h]=u.useState(!0),[m,o]=u.useState(null),[x,f]=u.useState(!1),[b,y]=u.useState(null),[E,P]=u.useState(null),[w,C]=u.useState(""),S=u.useCallback(async(g=!0)=>{const I=await Promise.allSettled([s?.getStatus()??Promise.resolve(null),En()]);I[0].status==="fulfilled"?n(I[0].value):g&&M.error({title:"Could not read web access status",description:W(I[0].reason)}),I[1].status==="fulfilled"?i(I[1].value):g&&M.error({title:"Could not read owner sessions",description:W(I[1].reason)}),h(!1)},[s]);u.useEffect(()=>{S();const g=window.setInterval(()=>{S(!1)},2e3);return()=>window.clearInterval(g)},[S]),u.useEffect(()=>{t&&(t.pairingEndpoints.length?t.pairingEndpoints.includes(c)||d(t.pairingEndpoints[0]):d(""))},[c,t]);const A=u.useMemo(()=>r?`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(Mn(r.url,{ecc:"M",border:2}))}`:null,[r]),O=u.useMemo(()=>r?new URLSearchParams(new URL(r.url).hash.slice(1)).get("token")??"":"",[r]);if(p&&(!s||!t)&&a.length===0)return e.jsxs("div",{className:"web-access-loading",role:"status",children:[e.jsx(ee,{className:"animate-spin"})," Loading web access…"]});const R=async g=>{if(s){o("toggle"),l(null);try{n(await s.setEnabled(g)),M.success({title:g?"LAN access enabled":"LAN access disabled"})}catch(I){M.error({title:"Could not restart web access",description:W(I)}),await S(!1)}finally{o(null),f(!1)}}},N=async()=>{if(s){o("pair");try{l(await s.createPairingLink(c))}catch(g){M.error({title:"Could not create pairing link",description:W(g)})}finally{o(null)}}},L=async()=>{if(r)try{await Fe(r.url),M.success({title:"Pairing link copied"})}catch(g){M.error({title:"Could not copy pairing link",description:W(g)})}},K=async()=>{if(O)try{await Fe(O),M.success({title:"Pairing code copied"})}catch(g){M.error({title:"Could not copy pairing code",description:W(g)})}},j=async()=>{const g=E,I=w.trim();if(!(!g||!I||I.length>64)){o(`rename:${g.id}`);try{await In(g.id,I),M.success({title:"Device renamed"}),await S(!1),P(null)}catch(te){M.error({title:"Could not rename device",description:W(te)})}finally{o(null)}}},k=async()=>{const g=b;if(!g)return;const I=g==="all"?"revoke-all":`revoke:${g.id}`;o(I);try{const te=g==="all"?await Rn():await An(g.id);l(null),M.success({title:`${te} browser ${te===1?"session":"sessions"} revoked`}),await S(!1)}catch(te){M.error({title:"Could not revoke session",description:W(te)})}finally{o(null),y(null)}},T=t?.serverState==="ready",se=a.filter(g=>g.kind!=="desktop");return e.jsxs("div",{className:"web-access-settings",children:[s&&t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"web-access-summary",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsx("strong",{children:"LAN access"}),e.jsx("span",{children:"Listen on this computer's network interfaces for trusted local devices."})]}),e.jsx("button",{type:"button",role:"switch","aria-label":"LAN access","aria-checked":t.enabled,className:"settings-switch",disabled:m==="toggle"||!T,onClick:()=>t.enabled?void R(!1):f(!0),children:e.jsx("span",{})})]}),e.jsxs("div",{className:"web-access-facts","aria-live":"polite",children:[e.jsx(ue,{label:"Server status",children:e.jsx(ie,{variant:T?"secondary":"outline",children:Tn[t.serverState]})}),e.jsx(ue,{label:"Actual port",children:e.jsx("code",{children:t.actualPort??"Unavailable"})}),e.jsx(ue,{label:"Local endpoint",children:e.jsx(ts,{value:t.localEndpoint})}),e.jsx(ue,{label:"LAN endpoints",children:e.jsx("div",{className:"web-access-endpoints",children:t.networkEndpoints.length===0?e.jsx("span",{children:"None detected"}):t.networkEndpoints.map(g=>e.jsx(ts,{value:g,muted:!t.enabled},g))})})]}),t.restartError&&e.jsxs("div",{className:"web-access-error",role:"alert",children:[e.jsx(Ie,{})," ",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(v,{size:"sm",onClick:()=>{N()},disabled:!T||!c||m!==null,children:[m==="pair"?e.jsx(ee,{className:"animate-spin"}):e.jsx(yt,{})," 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(Me,{value:c,onValueChange:g=>{g&&(d(g),l(null))},disabled:m!==null,children:[e.jsx(Ee,{id:"web-access-endpoint",className:"w-full",children:e.jsx(Ae,{children:c})}),e.jsx(Re,{alignItemWithTrigger:!1,children:e.jsx(qs,{children:t.pairingEndpoints.map(g=>e.jsx(le,{value:g,children:g},g))})})]})]}),r&&e.jsxs("div",{className:"web-access-pairing",role:"status",children:[e.jsxs("div",{className:"web-access-pairing-copy",children:[e.jsx(At,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Pairing link ready"}),e.jsxs("span",{children:["Expires ",me(r.expiresAt,{seconds:!0}),"."]})]})]}),A&&e.jsx("img",{src:A,alt:"QR code for the one-use OpenTig pairing link"}),e.jsxs("div",{className:"web-access-link-row",children:[e.jsxs(_,{children:[e.jsx(z,{render:e.jsx("code",{className:"web-access-link"}),children:r.url}),e.jsx(D,{side:"bottom",children:"One-use link; do not share publicly"})]}),e.jsxs(_,{children:[e.jsx(z,{render:e.jsx(v,{variant:"outline",size:"icon-sm","aria-label":"Copy pairing link",onClick:()=>{L()}}),children:e.jsx(Le,{})}),e.jsx(D,{children:"Copy pairing link"})]})]}),e.jsxs("div",{className:"web-access-link-row",children:[e.jsxs(_,{children:[e.jsx(z,{render:e.jsx("code",{className:"web-access-link"}),children:O}),e.jsx(D,{side:"bottom",children:"Paste this code on any /pair page served by this OpenTig instance"})]}),e.jsxs(_,{children:[e.jsx(z,{render:e.jsx(v,{variant:"outline",size:"icon-sm","aria-label":"Copy pairing code",onClick:()=>{K()}}),children:e.jsx(Le,{})}),e.jsx(D,{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(v,{variant:"destructive",size:"sm",onClick:()=>y("all"),disabled:se.length===0||m!==null,children:[e.jsx(qe,{})," Revoke browsers"]})]}),e.jsx("div",{className:"web-access-session-list","aria-live":"polite",children:a.length===0?e.jsx("div",{className:"web-access-empty-session",children:"No owner sessions found."}):a.map(g=>e.jsxs("div",{className:"web-access-session",children:[e.jsx("div",{className:`web-access-session-icon ${g.connected?"connected":""}`,children:g.kind==="desktop"?e.jsx(is,{}):e.jsx(xt,{})}),e.jsxs("div",{className:"web-access-session-copy",children:[e.jsxs("div",{children:[e.jsx("strong",{children:g.clientName}),g.current&&e.jsx(ie,{variant:"secondary",children:"This session"}),g.kind==="desktop"&&e.jsx(ie,{variant:"outline",children:"Desktop"})]}),e.jsxs("span",{children:[g.connected?`Connected${g.connectionCount>1?` (${g.connectionCount} tabs)`:""}`:g.lastConnectedAt?`Last connected ${me(g.lastConnectedAt,{seconds:!0})}`:"Not yet connected"," · ",g.browser&&g.os?`${g.browser} on ${g.os}`:g.browser??g.os??On(g.deviceType),g.viaProxy?" · Via proxy":"",g.remoteAddress?` · ${g.remoteAddress}`:""]})]}),g.kind!=="desktop"&&e.jsxs("div",{className:"web-access-session-controls",children:[e.jsxs(_,{children:[e.jsx(z,{render:e.jsx(v,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${g.clientName}`,onClick:()=>{P(g),C(g.clientName)},disabled:m!==null}),children:e.jsx(it,{})}),e.jsx(D,{children:"Rename this device"})]}),e.jsxs(_,{children:[e.jsx(z,{render:e.jsx(v,{variant:"ghost",size:"icon-sm","aria-label":`Revoke ${g.clientName} session`,onClick:()=>y(g),disabled:m!==null}),children:e.jsx(Ne,{})}),e.jsx(D,{children:"Revoke this browser session"})]})]})]},g.id))}),!s&&e.jsx("p",{className:"web-access-hint",children:"Listener addresses and new pairing links are controlled by the OpenTig desktop app or CLI running the server."}),e.jsx(Y,{open:x,onOpenChange:f,children:e.jsxs(X,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(J,{children:"Enable owner-level LAN access?"}),e.jsx(Z,{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(Q,{render:e.jsx(v,{variant:"ghost"}),children:"Cancel"}),e.jsx(v,{onClick:()=>{R(!0)},disabled:m!==null,children:"Enable LAN access"})]})]})}),e.jsx(Y,{open:b!==null,onOpenChange:g=>{g||y(null)},children:e.jsxs(X,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(J,{children:b==="all"?"Revoke all browser sessions?":"Revoke this browser session?"}),e.jsx(Z,{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(Q,{render:e.jsx(v,{variant:"ghost"}),children:"Cancel"}),e.jsxs(v,{variant:"destructive",onClick:()=>{k()},disabled:m!==null,children:[e.jsx(qe,{})," Revoke"]})]})]})}),e.jsx(Y,{open:E!==null,onOpenChange:g=>{g||P(null)},children:e.jsxs(X,{className:"undo-commit-dialog",children:[e.jsxs("div",{className:"undo-commit-content",children:[e.jsx(J,{children:"Rename paired device"}),e.jsx(Z,{children:"Use a name that makes this browser easy to identify later."}),e.jsx("input",{className:"web-access-rename-input",value:w,onChange:g=>C(g.target.value),maxLength:64,"aria-label":"Device name",autoComplete:"off"})]}),e.jsxs("div",{className:"undo-commit-actions",children:[e.jsx(Q,{render:e.jsx(v,{variant:"ghost"}),children:"Cancel"}),e.jsx(v,{onClick:()=>{j()},disabled:m!==null||!w.trim(),children:"Save"})]})]})})]})}function ue({label:s,children:t}){return e.jsxs("div",{className:"web-access-fact",children:[e.jsx("span",{children:s}),e.jsx("div",{children:t})]})}function ts({value:s,muted:t=!1}){return s?e.jsxs(_,{children:[e.jsx(z,{render:e.jsx("code",{className:t?"muted":void 0}),children:s}),e.jsx(D,{side:"bottom",children:t?"Enable LAN access to use this endpoint":s})]}):e.jsx("span",{children:"Unavailable"})}function On(s){return s==="desktop"?"Desktop browser":s==="mobile"?"Mobile browser":s==="tablet"?"Tablet browser":s==="bot"?"Automated client":"Unknown browser"}function W(s){return s instanceof Error?s.message:String(s)}const Pn=[{id:"general",label:"General",icon:Ys},{id:"updates",label:"Updates",icon:ce},{id:"shortcuts",label:"Shortcuts",icon:bt},{id:"ai",label:"AI assistance",icon:xs},{id:"diagnostics",label:"Diagnostics",icon:Ie},{id:"webAccess",label:"Web access",icon:Mt}],Ln={updates:{title:"Updates",description:"Check, download, and install new OpenTig releases."},general:{title:"General",description:"Appearance, files and repository 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."}};function Kn({preferences:s,onPreference:t,open:n,onOpenChange:a,section:i,onSectionChange:r}){const[l,c]=u.useState([]),[d,p]=u.useState(!1),[h,m]=u.useState(!1),[o,x]=u.useState(!1),f=u.useRef(null),b=ut(),y=b?{duration:0}:{duration:.16,ease:[.22,1,.36,1]},E=u.useRef(0),P=u.useCallback(async(j=!1)=>{const k=++E.current;p(!0);try{const T=await oe.ai.statuses(j);k===E.current&&c(T)}catch(T){M.error({title:"Could not check local AI",description:Dn(T)})}finally{k===E.current&&p(!1)}},[]);u.useEffect(()=>{n&&i==="ai"&&P();const j=E;return()=>{j.current++}},[P,n,i,s.aiExecutablePaths]),u.useLayoutEffect(()=>{n&&f.current&&(f.current.scrollTop=0)},[n,i]);const w=s.commitMessageHarness,C=l.find(j=>j.id===w),S=s.commitMessageModels[w]??"default",A=C?.models??[{id:"default",label:"Default (CLI)"}],O=A.some(j=>j.id===S)?A:[...A,{id:S,label:`${S} (unavailable)`}],R=[];for(const j of O){const k=w==="opencode"?j.id.indexOf("/"):-1,T=k>0?j.id.slice(0,k):w,se=j.id==="default"?"default":`provider:${T}`;let g=R.find(I=>I.id===se);g||(g={id:se,label:j.id==="default"?"":k>0?T:ae(w),items:[]},R.push(g)),g.items.push({value:j.id,label:k>0&&j.label===j.id?j.id.slice(k+1):j.label,search:j.id,tooltip:j.id==="default"||j.label===j.id?j.label:`${j.label} · ${j.id}`,pinned:j.id==="default",icon:e.jsx(xs,{})})}const N=O.find(j=>j.id===S)?.label??S,{title:L,description:K}=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."}:Ln[i];return e.jsx(Y,{open:n,onOpenChange:a,children:e.jsx(X,{className:`settings-dialog${i==="general"?" settings-dialog-general":i==="ai"?" settings-dialog-ai w-[min(1000px,calc((100vw-48px)/var(--settings-ui-scale,1)))]":""}`,style:{"--settings-ui-scale":window.opentigDesktop||window.matchMedia("(max-width: 767px)").matches?1:s.uiZoom/100},children:e.jsxs("div",{className:"settings-shell",children:[e.jsxs("aside",{className:"settings-nav",children:[e.jsx("div",{className:"settings-nav-title",children:"Settings"}),Pn.map(({id:j,label:k,icon:T})=>e.jsxs("button",{className:`settings-nav-item ${i===j?"active":""}`,onClick:()=>r(j),"aria-current":i===j,children:[e.jsx(T,{})," ",k]},j))]}),e.jsxs("section",{className:"settings-panel",children:[e.jsxs("header",{className:"settings-panel-header",children:[e.jsx(Ke,{initial:!1,mode:"wait",children:e.jsxs(_e.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(J,{children:L}),e.jsx(Z,{children:K})]},i)}),e.jsx(Q,{render:e.jsx(v,{variant:"ghost",size:"icon-sm","aria-label":"Close settings"}),children:e.jsx(Ce,{})})]}),e.jsx("div",{ref:f,className:`settings-panel-body${i==="general"?" settings-panel-body-general":""}`,children:e.jsx(Ke,{initial:!1,mode:"wait",children:e.jsx(_e.div,{className:`settings-panel-section${i==="general"?" settings-panel-section-general":""}`,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.jsx(Qt,{preferences:s,onPreference:t}):i==="updates"?e.jsx(Xs,{}):i==="shortcuts"?e.jsx(an,{preferences:s,onPreference:t}):i==="webAccess"?e.jsx($n,{}):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(v,{variant:"outline",size:"sm",onClick:()=>x(!0),children:[e.jsx(Ie,{})," View problems"]})]}),e.jsx(tn,{open:o,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(v,{variant:"outline",size:"sm",onClick:()=>{P(!0)},disabled:d,children:[d?e.jsx(ee,{className:"animate-spin"}):e.jsx(ce,{})," ",d?e.jsx(Se,{text:"Checking…"}):"Check again"]})]}),e.jsx("div",{className:"ai-harness-list",role:"radiogroup","aria-label":"Harness for AI assistance",children:["codex","claude","opencode","grok"].map(j=>{const k=l.find(se=>se.id===j),T=w===j;return e.jsxs("button",{type:"button",role:"radio","aria-checked":T,className:`ai-harness-card ${T?"active":""}`,onClick:()=>t({commitMessageHarness:j}),children:[e.jsxs("span",{className:"ai-harness-card-main",children:[e.jsx(Js,{harness:j}),e.jsxs("span",{className:"ai-harness-card-copy",children:[e.jsx("strong",{children:ae(j)}),e.jsx("small",{children:d?"Checking…":k?.version||(k?k.installationStatus==="inspection-failed"?"Inspection unavailable":k.installed?"Version unavailable":"Executable not found":"Status not checked")})]})]}),e.jsx(ie,{variant:_n(k),className:`ai-status-badge ${k?.availability??"unknown"}`,children:Fn(k)}),k?.message&&e.jsx("span",{className:"ai-harness-message",children:k.message})]},j)})}),e.jsxs("div",{className:"settings-field settings-field-separated ai-model-field",children:[e.jsxs("div",{className:"settings-field-label",children:[e.jsxs("strong",{children:[ae(w)," model"]}),e.jsx("span",{children:w==="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(Zs,{groups:R,value:S,onValueChange:j=>t({commitMessageModels:{...s.commitMessageModels,[w]:j}}),label:`${ae(w)} model`,triggerLabel:N,triggerClassName:"ai-model-select",contentClassName:"ai-model-picker",size:"default",align:"end",placeholder:"Search models…"},w),C?.authStatus==="unauthenticated"&&e.jsxs("p",{className:"ai-login-hint",children:["Sign in from a terminal with ",e.jsx("code",{children:zn(w,C.cliName)})," and check again."]}),C&&!C.installed&&C.installationStatus!=="inspection-failed"&&e.jsxs("p",{className:"ai-login-hint",children:["Install ",ae(w)," and check its availability again."]})]}),e.jsx(Bt,{harness:w,preferences:s,status:C,onPreference:t},w),e.jsxs("div",{className:"settings-field settings-field-separated ai-history-field",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(v,{variant:"outline",size:"sm",onClick:()=>m(!0),children:[e.jsx(Qs,{})," 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(Wt,{open:h,onOpenChange:m})]})},i)})})]})]})})})}function Fn(s){return s?s.installationStatus==="inspection-failed"?"Check failed":s.installationStatus==="not-executable"?"Cannot run":s.installationStatus==="incompatible"?"Incompatible":s.installed?s.authStatus==="unauthenticated"?"Not authenticated":s.availability==="ready"?"Available":"Check":"Not found":"Not checked"}function _n(s){return s?!s.installed||s.authStatus==="unauthenticated"||s.availability==="error"?"destructive":s.availability==="ready"?"default":"secondary":"outline"}function zn(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 Dn(s){return s instanceof Error?s.message:"An unexpected error occurred."}export{Kn as SettingsDialog};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PierreDiffViewer-eAcugmoF.js","assets/react-rd22PHbN.js","assets/PierreWorkerPool-Col4k7qz.js","assets/platform-Bqt97_Jr.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js","assets/index-DAUK3rnz.js","assets/tanstack-B0Sf7wNU.js","assets/base-ui-CJ8ZIx3d.js","assets/index-BfA4tAc1.css","assets/index-CtEztN1P.js","assets/File-CHjvYpb2.js","assets/EditContext-CvJWfVl1.js","assets/DiffWorkspace-RDG_Y70N.js","assets/App-BXZLGT86.js","assets/PierreEditBoundary-DlGd1pqO.js","assets/edit-ready-context-D77R8XU8.js","assets/MarkdownFileViewer-kLiduag6.js","assets/viewer-tabs-D-T0xQaq.js","assets/viewer-tabs-D8o-L3pM.css","assets/EditableFileViewer-CsbifqBO.js","assets/EditableFileViewer-B2G3Xa33.css","assets/render-markdown-BtCybfvQ.js","assets/markdown-BpzjXclZ.css","assets/PullRequestViewer-BgI8HFMe.js","assets/GitHubAvatar-CnBaloV0.js","assets/HtmlFileViewer-h8ULU8Gy.js","assets/HtmlFileViewer-D6UPnZvW.css","assets/ImageFileViewer-Cjw58ckv.js","assets/ImageFileViewer-D8TdwFTO.css"])))=>i.map(i=>d[i]);
2
+ import{o as _,B as Q,_ as x,T as ae,a as ne,b as le}from"./index-DAUK3rnz.js";import{r as n,j as t}from"./react-rd22PHbN.js";import{R as re,T as oe,U as ue,k as F,V as fe,Q as Z,u as G}from"./App-BXZLGT86.js";import"./tanstack-B0Sf7wNU.js";import"./base-ui-CJ8ZIx3d.js";class ce{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=de(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 de(i){if(!Number.isFinite(i)||i<0)throw new RangeError("sizeOf must return a finite, non-negative number.");return Math.ceil(i)}const J=n.lazy(()=>x(()=>import("./PierreDiffViewer-eAcugmoF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),me=n.lazy(()=>x(()=>import("./PierreEditBoundary-DlGd1pqO.js"),__vite__mapDeps([15,6,1,7,8,9,12,16])).then(i=>({default:i.PierreEditBoundary}))),he=n.lazy(()=>x(()=>import("./MarkdownFileViewer-kLiduag6.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}))),pe=n.lazy(()=>x(()=>import("./PullRequestViewer-BgI8HFMe.js"),__vite__mapDeps([24,6,1,7,8,9,14,25,18,19,23])).then(i=>({default:i.PullRequestViewer}))),xe=n.lazy(()=>x(()=>import("./EditableFileViewer-CsbifqBO.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}))),ve=n.lazy(()=>x(()=>import("./HtmlFileViewer-h8ULU8Gy.js"),__vite__mapDeps([26,1,18,6,7,8,9,19,20,2,3,4,5,10,11,12,16,14,21,27])).then(i=>({default:i.HtmlFileViewer}))),ye=n.lazy(()=>x(()=>import("./ImageFileViewer-Cjw58ckv.js"),__vite__mapDeps([28,1,6,7,8,9,18,19,20,2,3,4,5,10,11,12,16,14,21,29])).then(i=>({default:i.ImageFileViewer}))),ge=n.lazy(()=>x(()=>import("./ImageFileViewer-Cjw58ckv.js"),__vite__mapDeps([28,1,6,7,8,9,18,19,20,2,3,4,5,10,11,12,16,14,21,29])).then(i=>({default:i.SvgFileViewer}))),R=new ce({maxEntries:8,maxBytes:16*1024*1024,sizeOf:i=>i.patch.length*2+i.path.length*2+256});let X=null;function ke({repositoryId:i,selection:e,diffView:o,wrapLines:f,theme:v,revision:y,readOnly:g,commits:$,draftFor:E,onSelect:C,onOpenFile:W,onDiffViewChange:K,onWrapLinesChange:M,onDraftChange:O,onDraftSaved:A,onUpdateConflict:I,onResolveConflict:ee}){const[a,w]=n.useState(null),[te,D]=n.useState(!1),[V,q]=n.useState(null),[P,H]=n.useState(!1),b=n.useRef(0),N=n.useRef(!1),d=we(i,e);n.useEffect(()=>{H(!1),N.current=!1},[e]),n.useEffect(()=>{X!==i&&(R.clear(),X=i);const s=++b.current;if(q(null),!e||e.type==="pull-request"){w(null),D(!1);return}D(!0),(async()=>{try{if(e.type==="file"||e.type==="conflict"){if(e.type==="file"&&fe(e.path)){const l=await _.repository.readImage(i,e.path);if(s!==b.current)return;w({docKey:d,type:"image",value:l});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(l=>l&&l.docKey===d&&l.type==="file"&&N.current||l&&l.docKey===d&&l.type==="file"&&l.value.content===u.content&&l.value.size===u.size&&l.value.binary===u.binary&&l.value.tooLarge===u.tooLarge?l:{docKey:d,type:"file",value:u})}else{const u=e.type!=="diff";let l=u?R.get(d):void 0;if(l||(l=e.type==="commit"?await _.diff.getCommit(i,e.oid):e.type==="commit-file"?await _.diff.getCommitFile(i,e.oid,e.path,e.oldPath):await _.diff.get({repositoryId:i,path:e.path,kind:e.kind}),u&&R.set(d,l)),s!==b.current)return;const p=l;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&&D(!1)}})()},[P,d,i,y,e]);const j=v==="system"?"system":v,ie=f?"wrap":"scroll",B=n.useCallback(s=>{N.current=s},[]),k=n.useCallback(async(s,h,u)=>{const l=E(s),p=await _.repository.writeFile(i,s,h,l?.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]),S=n.useCallback(s=>s.path,[]),T=n.useCallback(s=>E(s.path)?.content??s.content,[E]),z=n.useCallback(s=>h=>O(s.path,h,s.content,s.mtimeMs),[O]),se=te&&a!==null&&!V;let r,L=null;if(!e)r=t.jsx(be,{});else if(e.type==="pull-request")r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(pe,{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(V)r=t.jsx("div",{className:"viewer-message text-destructive",children:V});else if(!a)r=t.jsxs("div",{className:"viewer-message",children:[t.jsx(F,{className:"spinner"})," ",t.jsx(Z,{text:"Loading…"})]});else if(a.type==="image")r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ye,{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 · ",Y(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 ",Y(a.value.size),". Preview is limited to protect performance."]}),t.jsx(Q,{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,L=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(J,{kind:"conflict",contentKey:a.docKey,file:a.value,themeType:j,overflow:ie,onUpdate:I,onResolve:ee})});else if(a.type==="file"&&re(a.value.path)){const s=a.value;r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(he,{repositoryId:i,file:s,initialContent:T(s),revision:y,themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onOpenFile:W,onDirtyChange:B,onDraftChange:z(s),onSave:k},S(s))})}else if(a.type==="file"&&oe(a.value.path)){const s=a.value;r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ge,{file:s,initialContent:T(s),themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onDirtyChange:B,onDraftChange:z(s),onSave:k},S(s))})}else if(a.type==="file"&&ue(a.value.path)){const s=a.value;r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(ve,{file:s,initialContent:T(s),themeType:j,wrapLines:f,readOnly:g||s.tooLarge,onDirtyChange:B,onDraftChange:z(s),onSave:k},S(s))})}else if(a.type==="file"){const s=a.value;r=t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(xe,{file:s,initialContent:T(s),themeType:j,wrapLines:f,readOnly:g,onDirtyChange:B,onDraftChange:z(s),onSave:k},S(s))})}else if(a.type==="diff"&&a.value.patch){const s=e.type==="commit"||e.type==="commit-file"?e:null,h=s?$.find(l=>l.oid===s.oid):void 0,u=e.type==="commit-file"?t.jsx(Q,{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,L=t.jsxs("div",{className:s?"commit-diff-viewer":"standalone-diff-viewer",children:[s&&t.jsx(je,{commit:h,fallbackSubject:"subject"in s?s.subject:""},s.oid),t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(J,{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 U=t.jsxs(t.Fragment,{children:[L??t.jsx("div",{className:"viewer-transition",children:r},a?a.docKey:d),se&&t.jsx("span",{className:"viewer-reloading","aria-hidden":"true",children:t.jsx(F,{className:"spinner"})})]});return a?.type!=="file"?U:t.jsx(n.Suspense,{fallback:t.jsx(m,{}),children:t.jsx(me,{enabled:!0,children:U})})}function je({commit:i,fallbackSubject:e}){const o=i?.date,[f,v]=n.useState(!1),y=i?.body??"",g=y.length>240||y.split(`
3
+ `).length>3;return t.jsxs("header",{className:"commit-diff-header",children:[t.jsx("h2",{children:i?.subject||e||"(no subject)"}),y&&t.jsxs("div",{className:"commit-diff-description-wrap",children:[t.jsx("p",{className:`commit-diff-description ${g&&!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(new Date(o).getTime())&&t.jsxs(ae,{children:[t.jsx(ne,{render:t.jsx("time",{dateTime:i?.date}),children:G(o,{seconds:!0})}),t.jsx(le,{children:G(o,{seconds:!0})})]}),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 we(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(Z,{text:"Loading viewer…"})]})}function be(){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 Y(i){return i?i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/1024/1024).toFixed(1)} MB`:"unknown size"}export{ke as default};
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-DfGlvPVm.js";import{p as f}from"./chunk-JWPE2WC7-CFRTGh8r.js";import{_ as n,l as s}from"./mermaid.core-C0FKucv-.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-DwLwbeoe.js";import"./index-CQcx9aRt.js";import"./react-rd22PHbN.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./render-markdown-2GjhuGA-.js";import"./App-9EfSdZB8.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,o]=e.split("*"),m=t?parseInt(t,10):0,l=o?parseInt(o,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:o}=b(e.repeat);return t===0&&o===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:o}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),s.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;s.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),s.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},$={parser:R,db:a,renderer:u,styles:p};export{$ as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-DxahInnA.js";import{p as f}from"./chunk-JWPE2WC7-BrLmjbVP.js";import{_ as n,l as s}from"./mermaid.core-9dt2ugQA.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-B4M1t9lL.js";import"./index-DAUK3rnz.js";import"./react-rd22PHbN.js";import"./tanstack-B0Sf7wNU.js";import"./base-ui-CJ8ZIx3d.js";import"./render-markdown-BtCybfvQ.js";import"./App-BXZLGT86.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,o]=e.split("*"),m=t?parseInt(t,10):0,l=o?parseInt(o,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:o}=b(e.repeat);return t===0&&o===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:o}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),s.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;s.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),s.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},$={parser:R,db:a,renderer:u,styles:p};export{$ as diagram};
@@ -1 +1 @@
1
- import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-C0FKucv-.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};
1
+ import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-9dt2ugQA.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};