@kabmo-labs/kabmo 0.60.0 → 0.61.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 (106) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +1 -1
  3. package/dist/client/static/js/{Body-p82s28sj.js → Body-ab8wswhm.js} +1 -1
  4. package/dist/client/static/js/{CsvGrid-erc5mcvc.js → CsvGrid-czssywvz.js} +1 -1
  5. package/dist/client/static/js/{DocxView-x3faj0jv.js → DocxView-ke0dwdmt.js} +1 -1
  6. package/dist/client/static/js/{DrawioView-t7fh3ens.js → DrawioView-a1whhy84.js} +1 -1
  7. package/dist/client/static/js/{HtmlPreview-zy7x7jmm.js → HtmlPreview-dr32dwjy.js} +1 -1
  8. package/dist/client/static/js/{ImageView-xc90jc1c.js → ImageView-zf4kh5wp.js} +1 -1
  9. package/dist/client/static/js/{LayoutWrapper-wyqe98kf.js → LayoutWrapper-dncbzcea.js} +1 -1
  10. package/dist/client/static/js/MergeDiffView-btdx9yb9.js +1 -0
  11. package/dist/client/static/js/{Modal-89jk7wff.js → Modal-5cxfw2rv.js} +1 -1
  12. package/dist/client/static/js/{PdfView-kqx472q7.js → PdfView-2kdn91f9.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-6bpz1faj.js → SessionsView-vbn0nvx4.js} +1 -1
  14. package/dist/client/static/js/{SheetView-0n9fze50.js → SheetView-ettr9pdw.js} +1 -1
  15. package/dist/client/static/js/{SvgPreview-6xc6ts46.js → SvgPreview-hzcejjry.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-2xdkkqwg.js → abnfDiagram-O67JEVCF-kdmv4y72.js} +1 -1
  17. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-ja8cx19z.js → architectureDiagram-NJMV4G6O-qyrwaq0x.js} +1 -1
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-ytf7s99c.js → blockDiagram-BEXU5L5S-tszxy2g7.js} +1 -1
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-5a0kdx0z.js → c4Diagram-YGBWAQC7-0ye36hhv.js} +1 -1
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-hd98dvjw.js → classDiagram-v2-NBCMYWYE-szgk1shv.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-man3fqcj.js → cose-bilkent-JH36ORCC-0s9s4mmv.js} +1 -1
  22. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-2f0kbbv2.js → cynefinDiagram-VND7K2PF-664g28ze.js} +1 -1
  23. package/dist/client/static/js/{dagre-6A5THRUB-k7pyhgzn.js → dagre-6A5THRUB-ga4rp1jx.js} +1 -1
  24. package/dist/client/static/js/{diagram-22UHCM2B-qx0afa2m.js → diagram-22UHCM2B-aagj46ty.js} +1 -1
  25. package/dist/client/static/js/{diagram-3UASUU5V-ydpe77sv.js → diagram-3UASUU5V-20qk6whk.js} +1 -1
  26. package/dist/client/static/js/{diagram-ATOU4E4O-e63v984n.js → diagram-ATOU4E4O-1vg1tfca.js} +1 -1
  27. package/dist/client/static/js/{diagram-CDSNMT55-8c765h3a.js → diagram-CDSNMT55-90d6jrqs.js} +1 -1
  28. package/dist/client/static/js/{diagram-MLGK6HIB-3pq0n7v8.js → diagram-MLGK6HIB-8je4z8m1.js} +1 -1
  29. package/dist/client/static/js/{diagram-MPIPVDR6-638atzxz.js → diagram-MPIPVDR6-0kzpexsj.js} +1 -1
  30. package/dist/client/static/js/{dockerfile-yehc914q.js → dockerfile-5nrbr0ef.js} +1 -1
  31. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-3gv43zvm.js → ebnfDiagram-ZINNZB2B-47yg36zx.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-6s5pggfc.js → elk-276RUBZZ-5hqp6r2d.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-x7cqyb89.js → erDiagram-OPXOYQCR-bt9te7r0.js} +1 -1
  34. package/dist/client/static/js/flowDiagram-KWPJA3E3-500fcx2a.js +1 -0
  35. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-g97te4v1.js → ganttDiagram-FUAMR5RP-kzc13swm.js} +1 -1
  36. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-sw4f94tc.js → gitGraphDiagram-X574FWY7-bjf8aa3j.js} +1 -1
  37. package/dist/client/static/js/{index-9pw441wc.js → index-0kcnghxn.js} +2 -2
  38. package/dist/client/static/js/{index-vejz38qt.js → index-1fmjhm2d.js} +1 -1
  39. package/dist/client/static/js/{index-qkqkygrf.js → index-24a40rw8.js} +1 -1
  40. package/dist/client/static/js/{index-ddkjgv5h.js → index-2zhmmtye.js} +1 -1
  41. package/dist/client/static/js/{index-9rz6kzsv.js → index-3x7cbxwq.js} +1 -1
  42. package/dist/client/static/js/{index-cfvc1zpk.js → index-475dc6h9.js} +1 -1
  43. package/dist/client/static/js/{index-95jfphx5.js → index-4vtc4xct.js} +7 -7
  44. package/dist/client/static/js/{index-bqapt2e8.js → index-5srvxsht.js} +1 -1
  45. package/dist/client/static/js/{index-z8k42dwz.js → index-653x8zdq.js} +1 -1
  46. package/dist/client/static/js/{index-qkyy563e.js → index-6c1s0v4b.js} +1 -1
  47. package/dist/client/static/js/{index-0ze5bwvw.js → index-776n5n29.js} +1 -1
  48. package/dist/client/static/js/{index-cf69bhjx.js → index-85jfn1fz.js} +1 -1
  49. package/dist/client/static/js/{index-vcq6zfxx.js → index-9g2nzgpx.js} +1 -1
  50. package/dist/client/static/js/{index-6qn9kygb.js → index-bq9f0mxp.js} +1 -1
  51. package/dist/client/static/js/{index-bjz54ht6.js → index-cvm2ha01.js} +1 -1
  52. package/dist/client/static/js/{index-hxsqw7sz.js → index-d11mbz2q.js} +1 -1
  53. package/dist/client/static/js/{index-jfqd838j.js → index-dabnbvbc.js} +1 -1
  54. package/dist/client/static/js/{index-h65zrhva.js → index-fen0x3qh.js} +1 -1
  55. package/dist/client/static/js/{index-dekvtt2a.js → index-gwgh27h3.js} +2 -2
  56. package/dist/client/static/js/{index-pdgc9ccr.js → index-h7agc069.js} +1 -1
  57. package/dist/client/static/js/{index-111bq6rs.js → index-jz4012t5.js} +1 -1
  58. package/dist/client/static/js/{index-pdz6j2g2.js → index-k9yf2txw.js} +1 -1
  59. package/dist/client/static/js/{index-bpcg34jp.js → index-kj70d2q9.js} +1 -1
  60. package/dist/client/static/js/{index-hwdkxe4n.js → index-krdz5vby.js} +1 -1
  61. package/dist/client/static/js/{index-4xbc0j7t.js → index-kyr612aa.js} +1 -1
  62. package/dist/client/static/js/{index-hgfyx8dt.js → index-m24sebb0.js} +1 -1
  63. package/dist/client/static/js/{index-4h2zkrk1.js → index-pg87cgpy.js} +1 -1
  64. package/dist/client/static/js/{index-wrk99kks.js → index-q1a40v20.js} +1 -1
  65. package/dist/client/static/js/{index-fnwaxc6r.js → index-qmvstmvh.js} +1 -1
  66. package/dist/client/static/js/{index-vec7m1yd.js → index-r38e0rya.js} +1 -1
  67. package/dist/client/static/js/{index-2n2evsg0.js → index-sr14vwn5.js} +1 -1
  68. package/dist/client/static/js/{index-ywp0sd1e.js → index-vgcw01yk.js} +1 -1
  69. package/dist/client/static/js/{index-dv01prse.js → index-vn59zz0k.js} +1 -1
  70. package/dist/client/static/js/{index-ja0ajnvq.js → index-wf5j0009.js} +1 -1
  71. package/dist/client/static/js/{index-8zct30zd.js → index-xy0m8te9.js} +1 -1
  72. package/dist/client/static/js/{index-5nm8hm4k.js → index-y6zbkh4p.js} +1 -1
  73. package/dist/client/static/js/{index-37apvxgj.js → index-z5s9tmj8.js} +1 -1
  74. package/dist/client/static/js/{index-43gmn7yb.js → index-zr3965k9.js} +1 -1
  75. package/dist/client/static/js/{infoDiagram-VRGFBTTK-pw2qaa27.js → infoDiagram-VRGFBTTK-jy5zvvj8.js} +1 -1
  76. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-d13jhvxy.js → ishikawaDiagram-OU5B5YK6-pfky1nnf.js} +1 -1
  77. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-20gb8a04.js → journeyDiagram-ZHPQQLJL-mvaf7rfh.js} +1 -1
  78. package/dist/client/static/js/{kanban-definition-PNTS6WVX-s78e158c.js → kanban-definition-PNTS6WVX-hw2xwe6e.js} +1 -1
  79. package/dist/client/static/js/{mermaid.core-xbm27k28.js → mermaid.core-hsw87hmq.js} +2 -2
  80. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-6y7xe2zm.js → mindmap-definition-NLK3R4M7-wfe4d846.js} +1 -1
  81. package/dist/client/static/js/one-dark-pro-ckq5capv.js +1 -0
  82. package/dist/client/static/js/one-light-a908z398.js +1 -0
  83. package/dist/client/static/js/{pegDiagram-GJSIUBJH-dmvewetf.js → pegDiagram-GJSIUBJH-cvnmxgst.js} +1 -1
  84. package/dist/client/static/js/{pieDiagram-5QR66LMP-1q9e7rcm.js → pieDiagram-5QR66LMP-0n3gz7sv.js} +1 -1
  85. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-mvrem3n6.js → quadrantDiagram-O4NWA36T-9qqh6xvv.js} +1 -1
  86. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-axttcfhw.js → railroadDiagram-XR7U4H2S-5f3x3762.js} +1 -1
  87. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-5qx7erta.js → requirementDiagram-PLB6GJNP-a68bv6kh.js} +1 -1
  88. package/dist/client/static/js/{rust-b3ckax3e.js → rust-qjhdt4b0.js} +1 -1
  89. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-es87a3j6.js → sankeyDiagram-IPEJSGJF-ry7xcphh.js} +1 -1
  90. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-dgpnjrtk.js → sequenceDiagram-PO4LG4MO-mekzzhet.js} +1 -1
  91. package/dist/client/static/js/{sizeCapture-INFHLROL-kyw0p86n.js → sizeCapture-INFHLROL-pvc16ame.js} +1 -1
  92. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-vnsbw8y9.js → stateDiagram-v2-GCMORJYK-3ytxby83.js} +1 -1
  93. package/dist/client/static/js/{swimlanes-2SLR337P-060q1rep.js → swimlanes-2SLR337P-c2zfp416.js} +1 -1
  94. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-y77g9dq0.js → swimlanesDiagram-TC7HE7FX-9gm67sq4.js} +1 -1
  95. package/dist/client/static/js/{timeline-definition-EJHVYXUP-8a3yqmx0.js → timeline-definition-EJHVYXUP-xtvv4za2.js} +1 -1
  96. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-18sp73v7.js → usecaseDiagram-POWQR4AR-sz6b7bnv.js} +1 -1
  97. package/dist/client/static/js/{vennDiagram-UO4OBE2U-gf4y1r3s.js → vennDiagram-UO4OBE2U-56q0qs51.js} +1 -1
  98. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-q0kwmbzh.js → wardleyDiagram-VNRHLVJA-xvtyvde9.js} +1 -1
  99. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-y0gpmg6m.js → xychartDiagram-PMCCYNJV-jcs20s84.js} +1 -1
  100. package/package.json +1 -1
  101. package/src/client/components/workspace/panel-tabs/TabChip.tsx +17 -15
  102. package/src/client/components/workspace/panel-tabs/TabStrip.connected.test.tsx +14 -5
  103. package/dist/client/static/js/MergeDiffView-bng34cpr.js +0 -1
  104. package/dist/client/static/js/flowDiagram-KWPJA3E3-7sn6nwjv.js +0 -1
  105. package/dist/client/static/js/one-dark-pro-7bgqnyhm.js +0 -1
  106. package/dist/client/static/js/one-light-47y6etng.js +0 -1
@@ -1,2 +1,2 @@
1
- import{t}from"./index-dekvtt2a.js";function xe(c,e){if(c.accDescr)e.setAccDescription?.(c.accDescr);if(c.accTitle)e.setAccTitle?.(c.accTitle);if(c.title)e.setDiagramTitle?.(c.title)}t(xe,"populateCommonDb");
1
+ import{t}from"./index-gwgh27h3.js";function xe(c,e){if(c.accDescr)e.setAccDescription?.(c.accDescr);if(c.accTitle)e.setAccTitle?.(c.accTitle);if(c.title)e.setDiagramTitle?.(c.title)}t(xe,"populateCommonDb");
2
2
  export{xe};
@@ -1,4 +1,4 @@
1
- import{t,l,xt,Ea,w,F,z,j,U,H,W,q,m,Ba,rs,b,hr,br,V,Fn,wt,mt,ft,or,Dc,zt,Ut,qn,Gt,Ct}from"./index-dekvtt2a.js";import{Kt}from"./index-95jfphx5.js";import{ro}from"./index-bpcg34jp.js";var h1="flowchart-",d1=class{constructor(){this.vertexCounter=0,this.config=m(),this.diagramId="",this.vertices=new Map,this.edges=[],this.classes=new Map,this.subGraphs=[],this.subGraphLookup=new Map,this.tooltips=new Map,this.subCount=0,this.firstGraphFlag=!0,this.secCount=-1,this.posCrossRef=[],this.funs=[],this.setAccTitle=z,this.setAccDescription=U,this.setDiagramTitle=W,this.getAccTitle=j,this.getAccDescription=H,this.getDiagramTitle=q,this.funs.push(this.setupToolTips.bind(this)),this.addVertex=this.addVertex.bind(this),this.firstGraph=this.firstGraph.bind(this),this.setDirection=this.setDirection.bind(this),this.addSubGraph=this.addSubGraph.bind(this),this.addLink=this.addLink.bind(this),this.setLink=this.setLink.bind(this),this.updateLink=this.updateLink.bind(this),this.addClass=this.addClass.bind(this),this.setClass=this.setClass.bind(this),this.destructLink=this.destructLink.bind(this),this.setClickEvent=this.setClickEvent.bind(this),this.setTooltip=this.setTooltip.bind(this),this.updateLinkInterpolate=this.updateLinkInterpolate.bind(this),this.setClickFun=this.setClickFun.bind(this),this.bindFunctions=this.bindFunctions.bind(this),this.lex={firstGraph:this.firstGraph.bind(this)},this.clear(),this.setGen("gen-2")}static{t(this,"FlowDB")}sanitizeText(e){return w.sanitizeText(e,this.config)}sanitizeNodeLabelType(e){switch(e){case"markdown":case"string":case"text":return e;default:return"markdown"}}setDiagramId(e){this.diagramId=e}lookUpDomId(e){for(let r of this.vertices.values())if(r.id===e)return this.diagramId?`${this.diagramId}-${r.domId}`:r.domId;return this.diagramId?`${this.diagramId}-${e}`:e}addVertex(e,r,a,n,o,f,c={},g){if(!e||e.trim().length===0)return;let d;if(g!==void 0){let T;if(!g.includes(`
1
+ import{t,l,xt,Ea,w,F,z,j,U,H,W,q,m,Ba,rs,b,hr,br,V,Fn,wt,mt,ft,or,Dc,zt,Ut,qn,Gt,Ct}from"./index-gwgh27h3.js";import{Kt}from"./index-4vtc4xct.js";import{ro}from"./index-kj70d2q9.js";var h1="flowchart-",d1=class{constructor(){this.vertexCounter=0,this.config=m(),this.diagramId="",this.vertices=new Map,this.edges=[],this.classes=new Map,this.subGraphs=[],this.subGraphLookup=new Map,this.tooltips=new Map,this.subCount=0,this.firstGraphFlag=!0,this.secCount=-1,this.posCrossRef=[],this.funs=[],this.setAccTitle=z,this.setAccDescription=U,this.setDiagramTitle=W,this.getAccTitle=j,this.getAccDescription=H,this.getDiagramTitle=q,this.funs.push(this.setupToolTips.bind(this)),this.addVertex=this.addVertex.bind(this),this.firstGraph=this.firstGraph.bind(this),this.setDirection=this.setDirection.bind(this),this.addSubGraph=this.addSubGraph.bind(this),this.addLink=this.addLink.bind(this),this.setLink=this.setLink.bind(this),this.updateLink=this.updateLink.bind(this),this.addClass=this.addClass.bind(this),this.setClass=this.setClass.bind(this),this.destructLink=this.destructLink.bind(this),this.setClickEvent=this.setClickEvent.bind(this),this.setTooltip=this.setTooltip.bind(this),this.updateLinkInterpolate=this.updateLinkInterpolate.bind(this),this.setClickFun=this.setClickFun.bind(this),this.bindFunctions=this.bindFunctions.bind(this),this.lex={firstGraph:this.firstGraph.bind(this)},this.clear(),this.setGen("gen-2")}static{t(this,"FlowDB")}sanitizeText(e){return w.sanitizeText(e,this.config)}sanitizeNodeLabelType(e){switch(e){case"markdown":case"string":case"text":return e;default:return"markdown"}}setDiagramId(e){this.diagramId=e}lookUpDomId(e){for(let r of this.vertices.values())if(r.id===e)return this.diagramId?`${this.diagramId}-${r.domId}`:r.domId;return this.diagramId?`${this.diagramId}-${e}`:e}addVertex(e,r,a,n,o,f,c={},g){if(!e||e.trim().length===0)return;let d;if(g!==void 0){let T;if(!g.includes(`
2
2
  `))T=`{
3
3
  `+g+`
4
4
  }`;else T=g+`
@@ -1 +1 @@
1
- import{d,n,o,O,i,u,a,dn,e,S,vr,kr,Ie,ps,f,ms,fs,gs,G,hs,h,Bt,fo,$e,Qi,Sl,ut,bt,yt,Ud,Pc}from"./index-95jfphx5.js";import{Rr}from"./index-2n2evsg0.js";var fe=2000,z=new Map;function me(s){if(s.length===0)return"";let r="";for(let t of s)r+=`${t.start}-${t.end},`;return r}function ee(s,r,t){let c=Qi(r),m=`${r}\x00${me(t)}\x00${s}`;if(c){let v=z.get(m);if(v!==void 0)return z.delete(m),z.set(m,v),v}let l=Sl(s,r,{marks:t});if(!c)return l;if(z.set(m,l),z.size>fe){let v=z.keys().next();if(!v.done)z.delete(v.value)}return l}function te(s,r,t){let c=[],m=0;for(let l of r){if(l.start<m||l.end<=l.start||l.end>s.length)continue;if(l.start>m)c.push({text:s.slice(m,l.start),kind:"plain"});if(c.push({text:s.slice(l.start,l.end),kind:"removed"}),t)c.push({text:t,kind:"inserted"});m=l.end}if(m<s.length)c.push({text:s.slice(m),kind:"plain"});return c}function ge({file:s,result:r,replacement:t,showReplacePreview:c,onOpen:m}){let l=r.ranges??[],v=c&&t.length>0;return e("button",{type:"button",onClick:()=>m(r),className:"flex w-full items-start gap-2 rounded px-1 py-0.5 text-left hover:bg-ink/5 cursor-pointer",title:`Open ${s}:${r.line}`,children:[e("span",{className:"w-6 flex-shrink-0 text-right font-mono text-ink/40",children:r.line}),v?e("span",{className:"min-w-0 truncate font-mono text-ink",children:te(r.content,l,t).map((R,b)=>R.kind==="plain"?e("span",{children:R.text},b):R.kind==="removed"?e("del",{className:"search-replace-old",children:R.text},b):e("ins",{className:"search-replace-new",children:R.text},b))}):e("span",{className:"min-w-0 truncate font-mono text-ink",dangerouslySetInnerHTML:{__html:ee(r.content,yt(s),l)}})]})}var re=dn(ge);var Z={header:4,hit:4,group:16},ne={headerBox:16,hitBox:20},se=5000;function oe(s){let r=[],t=null;for(let c of s){if(!t||t.file!==c.file)t={file:c.file,results:[]},r.push(t);t.results.push(c)}return r}function ie(s){let r=[];for(let t of s){r.push({kind:"group",file:t.file,count:t.results.length});for(let c=0;c<t.results.length;c++)r.push({kind:"hit",file:t.file,result:t.results[c],last:c===t.results.length-1})}return r}function be(s,r){if(s.kind==="group")return r.headerBox+Z.header;return r.hitBox+(s.last?Z.group:Z.hit)}function ae(s,r){let t=Array(s.length),c=Array(s.length),m=0;for(let l=0;l<s.length;l++){let v=be(s[l],r);t[l]=m,c[l]=v,m+=v}return{offsets:t,heights:c,total:m}}function le(s,r,t,c,m=240){if(s.length===0)return{start:0,end:0};let l=Math.max(0,t),v=l-m,R=l+c+m,b=0,x=s.length-1;while(b<x){let g=b+x>>1;if(s[g]+r[g]>v)x=g;else b=g+1}let M=b;b=M,x=s.length;while(b<x){let g=b+x>>1;if(s[g]>=R)x=g;else b=g+1}return{start:M,end:b}}var xe=8,Se=8;function ce({groups:s,replacement:r,showReplacePreview:t,onOpen:c,onReplaceFile:m,replaceBusy:l}){let v=i(null),R=i(null),b=u(()=>ie(s),[s]),[x,M]=n(ne),g=u(()=>ae(b,x),[b,x]),[A,w]=n(()=>({start:0,end:Math.min(b.length,60)})),L=a((p)=>{v.current=p},[]),k=a(()=>{let p=v.current;if(!p)return;let N=le(g.offsets,g.heights,p.scrollTop,p.clientHeight);w((I)=>I.start===N.start&&I.end===N.end?I:N)},[g]),y=a(()=>{k()},[k]);O(()=>{let p=R.current;if(!p)return;let N=p.querySelector("[data-search-header] > div")?.offsetHeight??0,I=p.querySelector("[data-search-hit] > button")?.offsetHeight??0;if(N>0&&N!==x.headerBox)M((C)=>({...C,headerBox:N}));if(I>0&&I!==x.hitBox)M((C)=>({...C,hitBox:I}))},[A,x,b]),O(()=>{k()},[k]),O(()=>{let p=v.current;if(!p||typeof ResizeObserver>"u")return;let N=new ResizeObserver(()=>k());return N.observe(p),()=>N.disconnect()},[k]);let P=b.length===0?0:Math.min(A.start,b.length-1),F=Math.min(A.end,b.length),H=b.slice(P,F),D=F<b.length?g.total-g.offsets[F]:0;return e("div",{ref:L,onScroll:y,className:"flex-1 scrollbar-overlay-container px-3 text-xs",style:{overflowAnchor:"none"},children:[e("div",{style:{height:xe+(g.offsets[P]??0)},"aria-hidden":"true"}),e("div",{ref:R,children:H.map((p,N)=>{let I=P+N,C=g.heights[I];if(p.kind==="group")return e("div",{"data-search-header":"",style:{height:C},children:e("div",{className:"font-semibold text-ink/80 flex items-center justify-between group",children:[e("div",{className:"flex items-center min-w-0",children:[e(ut,{name:p.file,size:12,className:"mr-1.5 flex-shrink-0"}),e("span",{className:"truncate",children:p.file}),e("span",{className:"ml-2 bg-ink/10 text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",children:p.count})]}),e("button",{onClick:()=>m(p.file),disabled:l,className:"touch-visible opacity-0 group-hover:opacity-100 p-1 text-ink/40 hover:text-ink rounded hover:bg-ink/5 disabled:opacity-50 flex-shrink-0",title:"Replace in this file",children:e(gs,{size:12})})]})},`group:${p.file}`);return e("div",{"data-search-hit":"",style:{height:C},children:e(re,{file:p.file,result:p.result,replacement:r,showReplacePreview:t,onOpen:c})},`hit:${p.file}:${p.result.line}:${I}`)})}),e("div",{style:{height:Se+D},"aria-hidden":"true"})]})}function ue({className:s,query:r,setQuery:t,replaceQuery:c,setReplaceQuery:m,matchCase:l,setMatchCase:v,wholeWord:R,setWholeWord:b,useRegex:x,setUseRegex:M,includeFiles:g,setIncludeFiles:A,showIncludeField:w,setShowIncludeField:L,showMenu:k,setShowMenu:y,menuRef:P,rootPath:F,activeRepo:H,setActiveRepo:D,repos:p,reposScanning:N,rescanRepos:I,results:C,isSearching:q,truncated:J,error:T,onOpenFile:B,handleReplace:U,replaceBusy:Q,tabsMode:Y=!1}){let X=u(()=>oe(C),[C]),W=i(null),K=i(null),_=a(()=>{t(""),W.current?.focus()},[t]),j=a(()=>{m(""),K.current?.focus()},[m]),V=u(()=>({matchCase:l,wholeWord:R,isRegex:x,inSelection:!1}),[l,R,x]),he=a((E)=>{Ud({path:E.file,line:Number(E.line),query:r,options:V}),B?.({path:E.file,name:E.file.split("/").pop()||E.file,root:F,repo:H})},[r,V,F,H,B]),de=a((E)=>U(E),[U]);return e("div",{className:`flex flex-col h-full bg-paper ${s}`,children:[e(Bt,{left:e(d,{children:[e(fo,{id:"search",tabsMode:Y,children:e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Search"})}),e(Rr,{rootPath:F,activeRepo:H,onSelectRepo:D,repos:p,scanning:N,onRefreshRepos:I})]}),right:e("div",{className:"relative",ref:P,children:[e("button",{onClick:()=>y(!k),className:`p-1 rounded hover:bg-ink/5 transition-colors ${k||w?"text-ink":"text-ink/40"}`,title:"Search Options",children:e(Ie,{size:14})}),k&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-48 bg-paper border border-ink/10 rounded shadow-lg z-10 py-1",children:e("button",{onClick:()=>{if(L(!w),w)A("");y(!1)},className:"w-full px-3 py-1.5 text-left text-xs text-ink hover:bg-ink/5 flex items-center justify-between",children:[e("span",{children:"Files to include"}),w&&e(f,{size:12,className:"text-ink/60"})]})})]})}),e("div",{className:"p-3 flex flex-col gap-2.5 border-b border-ink/10",children:[e("div",{className:"relative",children:e("div",{className:"flex items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e(G,{size:14,className:"ml-2 text-ink/40 flex-shrink-0"}),e("input",{ref:W,type:"text",placeholder:"Search",value:r,onChange:(E)=>t(E.currentTarget.value),className:"w-full bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35 min-w-0"}),r&&e("button",{type:"button",onClick:_,title:"Clear search","aria-label":"Clear search",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(h,{size:12})}),e("div",{className:"flex items-center space-x-0.5 pr-1 text-ink/40 flex-shrink-0",children:[e("button",{onClick:()=>v(!l),className:`p-1 rounded hover:text-ink ${l?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Case",children:e(ps,{size:14})}),e("button",{onClick:()=>b(!R),className:`p-1 rounded hover:text-ink ${R?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Whole Word",children:e(hs,{size:14})}),e("button",{onClick:()=>M(!x),className:`p-1 rounded hover:text-ink ${x?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Use Regular Expression",children:e(ms,{size:14})})]})]})}),e("div",{className:"relative flex items-center space-x-1",children:[e("div",{className:"flex flex-1 min-w-0 items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e("input",{ref:K,type:"text",placeholder:"Replace",value:c,onChange:(E)=>m(E.currentTarget.value),className:"flex-1 min-w-0 bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35"}),c&&e("button",{type:"button",onClick:j,title:"Clear replace","aria-label":"Clear replace",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(h,{size:12})})]}),e("button",{onClick:()=>U(),disabled:C.length===0||Q,className:"p-1.5 rounded border border-ink/20 text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-50 disabled:cursor-not-allowed bg-paper",title:"Replace All",children:e(fs,{size:14})})]}),w&&e("div",{className:"relative",children:e("input",{type:"text",value:g,onChange:(E)=>A(E.currentTarget.value),placeholder:"Files to include (e.g. *.js, src/*)",className:"w-full bg-paper border border-ink/20 rounded text-xs px-2 py-1.5 focus:outline-none focus:border-ink/40 focus:ring-1 focus:ring-ink/10 transition-all text-ink placeholder-ink/40"})})]}),T&&C.length===0?e("div",{className:"flex-1 px-3 py-3",role:"alert",children:e("div",{className:"rounded border border-error/30 bg-error/5 px-2.5 py-2",children:[e("div",{className:"text-[11px] font-semibold text-error-text",children:"Search failed"}),e("div",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-[10.5px] text-ink/70",children:T}),x&&e("div",{className:"mt-1 text-[10.5px] text-ink/50",children:["Regex is on — escape metacharacters such as ",e("code",{className:"font-mono",children:"( ) [ ] * ? +"})," or turn it off to search literally."]})]})}):q&&C.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4 text-[11px]",children:"Searching..."}):r.trim().length<=2?e("div",{className:"flex-1 text-ink/40 italic text-center py-4 text-[11px]",children:"Type at least 3 characters to search."}):C.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4 text-[11px]",children:"No results found."}):e(d,{children:[T&&e("div",{className:"px-3 pt-2 text-[10.5px] text-error-text",role:"alert",children:["Search failed: ",e("span",{className:"font-mono",children:T})]}),q&&e("div",{className:"px-3 pt-2 text-ink/40 italic",children:"Searching…"}),J&&e("div",{className:"px-3 pt-2 text-ink/50 italic",children:["Showing the first ",se," matches — refine the query to see the rest."]}),e(ce,{groups:X,replacement:c,showReplacePreview:c.length>0,onOpen:he,onReplaceFile:de,replaceBusy:Q})]})]})}function pe(s){let[r,t]=n({scope:s,results:[],truncated:!1,error:null}),[c,m]=n(!1),l=i(null),v=i(!0),R=i(s);R.current=s,o(()=>(v.current=!0,()=>{v.current=!1,l.current?.abort(),l.current=null}),[]);let b=a(async(x)=>{l.current?.abort();let M=new AbortController;l.current=M;let g=R.current;t({scope:g,results:[],truncated:!1,error:null}),m(!0);try{let A=await fetch("/api/fs/search",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams(x),signal:M.signal});await Pc(A,(w,L)=>{if(R.current!==g)return;if(w==="done"){let k=!1;try{k=JSON.parse(L)?.truncated===!0}catch{}t((y)=>y.scope===g?{...y,truncated:k}:y);return}if(w==="error"){let k="Search failed";try{k=JSON.parse(L)?.error||k}catch{}t((y)=>y.scope===g?{...y,error:k}:y);return}if(w!=="matches")return;try{let k=JSON.parse(L);if(Array.isArray(k))t((y)=>y.scope===g?{...y,results:[...y.results,...k]}:y)}catch{}},M.signal)}catch{}finally{if(v.current&&l.current===M)l.current=null,m(!1)}},[]);return{results:r.scope===s?r.results:[],isSearching:c&&r.scope===s,truncated:r.scope===s&&r.truncated,error:r.scope===s?r.error:null,start:b}}function it({className:s="",enabled:r=!0,rootPath:t,onOpenFile:c,tabsMode:m=!1}){let[l,v]=S("search.query",""),[R,b]=S("search.replaceQuery",""),[x,M]=S("search.matchCase",!1),[g,A]=S("search.wholeWord",!1),[w,L]=S("search.useRegex",!1),[k,y]=S("search.includeFiles",""),[P,F]=n(!1),[H,D]=S("search.showIncludeField",!1),{activeRepo:p,setActiveRepo:N}=vr(t),{repos:I,scanning:C,rescan:q}=kr(t,r),J=i(null),T=bt(),{results:B,isSearching:U,truncated:Q,error:Y,start:X}=pe(`${t??""}\x00${p}`);$e(J,()=>F(!1));let W=a(()=>{if(!r)return;if(l.trim().length>2)return X({q:l,matchCase:String(x),wholeWord:String(g),useRegex:String(w),includeFiles:H?k:"",...t?{root:t}:{},...p!=="."?{repo:p}:{}})},[r,l,x,g,w,H,k,t,p,X]);o(()=>{let _=setTimeout(()=>{W()},300);return()=>clearTimeout(_)},[W]);let K=a((_)=>{if(!l)return;let j=_?[_]:Array.from(new Set(B.map((V)=>V.file)));if(j.length===0)return;T.submit({q:l,replaceWith:R,matchCase:String(x),wholeWord:String(g),useRegex:String(w),files:JSON.stringify(j),...t?{root:t}:{},...p!=="."?{repo:p}:{}},{method:"POST",action:"/api/fs/replace"})},[l,R,x,g,w,B,t,p,T]);if(o(()=>{if(T.state==="idle"&&T.data?.success)W()},[T.state,T.data,W]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${s}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e(ue,{className:s,tabsMode:m,query:l,setQuery:v,replaceQuery:R,setReplaceQuery:b,matchCase:x,setMatchCase:M,wholeWord:g,setWholeWord:A,useRegex:w,setUseRegex:L,includeFiles:k,setIncludeFiles:y,showIncludeField:H,setShowIncludeField:D,showMenu:P,setShowMenu:F,menuRef:J,rootPath:t,activeRepo:p,setActiveRepo:N,repos:I,reposScanning:C,rescanRepos:q,results:B,isSearching:U,truncated:Q,error:Y,onOpenFile:c,handleReplace:K,replaceBusy:T.state!=="idle"})}export{it as SearchPanel};
1
+ import{d,n,o,O,i,u,a,dn,e,S,vr,kr,Ie,ps,f,ms,fs,gs,G,hs,h,Bt,fo,$e,Qi,Sl,ut,bt,yt,Ud,Pc}from"./index-4vtc4xct.js";import{Rr}from"./index-sr14vwn5.js";var fe=2000,z=new Map;function me(s){if(s.length===0)return"";let r="";for(let t of s)r+=`${t.start}-${t.end},`;return r}function ee(s,r,t){let c=Qi(r),m=`${r}\x00${me(t)}\x00${s}`;if(c){let v=z.get(m);if(v!==void 0)return z.delete(m),z.set(m,v),v}let l=Sl(s,r,{marks:t});if(!c)return l;if(z.set(m,l),z.size>fe){let v=z.keys().next();if(!v.done)z.delete(v.value)}return l}function te(s,r,t){let c=[],m=0;for(let l of r){if(l.start<m||l.end<=l.start||l.end>s.length)continue;if(l.start>m)c.push({text:s.slice(m,l.start),kind:"plain"});if(c.push({text:s.slice(l.start,l.end),kind:"removed"}),t)c.push({text:t,kind:"inserted"});m=l.end}if(m<s.length)c.push({text:s.slice(m),kind:"plain"});return c}function ge({file:s,result:r,replacement:t,showReplacePreview:c,onOpen:m}){let l=r.ranges??[],v=c&&t.length>0;return e("button",{type:"button",onClick:()=>m(r),className:"flex w-full items-start gap-2 rounded px-1 py-0.5 text-left hover:bg-ink/5 cursor-pointer",title:`Open ${s}:${r.line}`,children:[e("span",{className:"w-6 flex-shrink-0 text-right font-mono text-ink/40",children:r.line}),v?e("span",{className:"min-w-0 truncate font-mono text-ink",children:te(r.content,l,t).map((R,b)=>R.kind==="plain"?e("span",{children:R.text},b):R.kind==="removed"?e("del",{className:"search-replace-old",children:R.text},b):e("ins",{className:"search-replace-new",children:R.text},b))}):e("span",{className:"min-w-0 truncate font-mono text-ink",dangerouslySetInnerHTML:{__html:ee(r.content,yt(s),l)}})]})}var re=dn(ge);var Z={header:4,hit:4,group:16},ne={headerBox:16,hitBox:20},se=5000;function oe(s){let r=[],t=null;for(let c of s){if(!t||t.file!==c.file)t={file:c.file,results:[]},r.push(t);t.results.push(c)}return r}function ie(s){let r=[];for(let t of s){r.push({kind:"group",file:t.file,count:t.results.length});for(let c=0;c<t.results.length;c++)r.push({kind:"hit",file:t.file,result:t.results[c],last:c===t.results.length-1})}return r}function be(s,r){if(s.kind==="group")return r.headerBox+Z.header;return r.hitBox+(s.last?Z.group:Z.hit)}function ae(s,r){let t=Array(s.length),c=Array(s.length),m=0;for(let l=0;l<s.length;l++){let v=be(s[l],r);t[l]=m,c[l]=v,m+=v}return{offsets:t,heights:c,total:m}}function le(s,r,t,c,m=240){if(s.length===0)return{start:0,end:0};let l=Math.max(0,t),v=l-m,R=l+c+m,b=0,x=s.length-1;while(b<x){let g=b+x>>1;if(s[g]+r[g]>v)x=g;else b=g+1}let M=b;b=M,x=s.length;while(b<x){let g=b+x>>1;if(s[g]>=R)x=g;else b=g+1}return{start:M,end:b}}var xe=8,Se=8;function ce({groups:s,replacement:r,showReplacePreview:t,onOpen:c,onReplaceFile:m,replaceBusy:l}){let v=i(null),R=i(null),b=u(()=>ie(s),[s]),[x,M]=n(ne),g=u(()=>ae(b,x),[b,x]),[A,w]=n(()=>({start:0,end:Math.min(b.length,60)})),L=a((p)=>{v.current=p},[]),k=a(()=>{let p=v.current;if(!p)return;let N=le(g.offsets,g.heights,p.scrollTop,p.clientHeight);w((I)=>I.start===N.start&&I.end===N.end?I:N)},[g]),y=a(()=>{k()},[k]);O(()=>{let p=R.current;if(!p)return;let N=p.querySelector("[data-search-header] > div")?.offsetHeight??0,I=p.querySelector("[data-search-hit] > button")?.offsetHeight??0;if(N>0&&N!==x.headerBox)M((C)=>({...C,headerBox:N}));if(I>0&&I!==x.hitBox)M((C)=>({...C,hitBox:I}))},[A,x,b]),O(()=>{k()},[k]),O(()=>{let p=v.current;if(!p||typeof ResizeObserver>"u")return;let N=new ResizeObserver(()=>k());return N.observe(p),()=>N.disconnect()},[k]);let P=b.length===0?0:Math.min(A.start,b.length-1),F=Math.min(A.end,b.length),H=b.slice(P,F),D=F<b.length?g.total-g.offsets[F]:0;return e("div",{ref:L,onScroll:y,className:"flex-1 scrollbar-overlay-container px-3 text-xs",style:{overflowAnchor:"none"},children:[e("div",{style:{height:xe+(g.offsets[P]??0)},"aria-hidden":"true"}),e("div",{ref:R,children:H.map((p,N)=>{let I=P+N,C=g.heights[I];if(p.kind==="group")return e("div",{"data-search-header":"",style:{height:C},children:e("div",{className:"font-semibold text-ink/80 flex items-center justify-between group",children:[e("div",{className:"flex items-center min-w-0",children:[e(ut,{name:p.file,size:12,className:"mr-1.5 flex-shrink-0"}),e("span",{className:"truncate",children:p.file}),e("span",{className:"ml-2 bg-ink/10 text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",children:p.count})]}),e("button",{onClick:()=>m(p.file),disabled:l,className:"touch-visible opacity-0 group-hover:opacity-100 p-1 text-ink/40 hover:text-ink rounded hover:bg-ink/5 disabled:opacity-50 flex-shrink-0",title:"Replace in this file",children:e(gs,{size:12})})]})},`group:${p.file}`);return e("div",{"data-search-hit":"",style:{height:C},children:e(re,{file:p.file,result:p.result,replacement:r,showReplacePreview:t,onOpen:c})},`hit:${p.file}:${p.result.line}:${I}`)})}),e("div",{style:{height:Se+D},"aria-hidden":"true"})]})}function ue({className:s,query:r,setQuery:t,replaceQuery:c,setReplaceQuery:m,matchCase:l,setMatchCase:v,wholeWord:R,setWholeWord:b,useRegex:x,setUseRegex:M,includeFiles:g,setIncludeFiles:A,showIncludeField:w,setShowIncludeField:L,showMenu:k,setShowMenu:y,menuRef:P,rootPath:F,activeRepo:H,setActiveRepo:D,repos:p,reposScanning:N,rescanRepos:I,results:C,isSearching:q,truncated:J,error:T,onOpenFile:B,handleReplace:U,replaceBusy:Q,tabsMode:Y=!1}){let X=u(()=>oe(C),[C]),W=i(null),K=i(null),_=a(()=>{t(""),W.current?.focus()},[t]),j=a(()=>{m(""),K.current?.focus()},[m]),V=u(()=>({matchCase:l,wholeWord:R,isRegex:x,inSelection:!1}),[l,R,x]),he=a((E)=>{Ud({path:E.file,line:Number(E.line),query:r,options:V}),B?.({path:E.file,name:E.file.split("/").pop()||E.file,root:F,repo:H})},[r,V,F,H,B]),de=a((E)=>U(E),[U]);return e("div",{className:`flex flex-col h-full bg-paper ${s}`,children:[e(Bt,{left:e(d,{children:[e(fo,{id:"search",tabsMode:Y,children:e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Search"})}),e(Rr,{rootPath:F,activeRepo:H,onSelectRepo:D,repos:p,scanning:N,onRefreshRepos:I})]}),right:e("div",{className:"relative",ref:P,children:[e("button",{onClick:()=>y(!k),className:`p-1 rounded hover:bg-ink/5 transition-colors ${k||w?"text-ink":"text-ink/40"}`,title:"Search Options",children:e(Ie,{size:14})}),k&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-48 bg-paper border border-ink/10 rounded shadow-lg z-10 py-1",children:e("button",{onClick:()=>{if(L(!w),w)A("");y(!1)},className:"w-full px-3 py-1.5 text-left text-xs text-ink hover:bg-ink/5 flex items-center justify-between",children:[e("span",{children:"Files to include"}),w&&e(f,{size:12,className:"text-ink/60"})]})})]})}),e("div",{className:"p-3 flex flex-col gap-2.5 border-b border-ink/10",children:[e("div",{className:"relative",children:e("div",{className:"flex items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e(G,{size:14,className:"ml-2 text-ink/40 flex-shrink-0"}),e("input",{ref:W,type:"text",placeholder:"Search",value:r,onChange:(E)=>t(E.currentTarget.value),className:"w-full bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35 min-w-0"}),r&&e("button",{type:"button",onClick:_,title:"Clear search","aria-label":"Clear search",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(h,{size:12})}),e("div",{className:"flex items-center space-x-0.5 pr-1 text-ink/40 flex-shrink-0",children:[e("button",{onClick:()=>v(!l),className:`p-1 rounded hover:text-ink ${l?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Case",children:e(ps,{size:14})}),e("button",{onClick:()=>b(!R),className:`p-1 rounded hover:text-ink ${R?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Whole Word",children:e(hs,{size:14})}),e("button",{onClick:()=>M(!x),className:`p-1 rounded hover:text-ink ${x?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Use Regular Expression",children:e(ms,{size:14})})]})]})}),e("div",{className:"relative flex items-center space-x-1",children:[e("div",{className:"flex flex-1 min-w-0 items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e("input",{ref:K,type:"text",placeholder:"Replace",value:c,onChange:(E)=>m(E.currentTarget.value),className:"flex-1 min-w-0 bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35"}),c&&e("button",{type:"button",onClick:j,title:"Clear replace","aria-label":"Clear replace",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(h,{size:12})})]}),e("button",{onClick:()=>U(),disabled:C.length===0||Q,className:"p-1.5 rounded border border-ink/20 text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-50 disabled:cursor-not-allowed bg-paper",title:"Replace All",children:e(fs,{size:14})})]}),w&&e("div",{className:"relative",children:e("input",{type:"text",value:g,onChange:(E)=>A(E.currentTarget.value),placeholder:"Files to include (e.g. *.js, src/*)",className:"w-full bg-paper border border-ink/20 rounded text-xs px-2 py-1.5 focus:outline-none focus:border-ink/40 focus:ring-1 focus:ring-ink/10 transition-all text-ink placeholder-ink/40"})})]}),T&&C.length===0?e("div",{className:"flex-1 px-3 py-3",role:"alert",children:e("div",{className:"rounded border border-error/30 bg-error/5 px-2.5 py-2",children:[e("div",{className:"text-[11px] font-semibold text-error-text",children:"Search failed"}),e("div",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-[10.5px] text-ink/70",children:T}),x&&e("div",{className:"mt-1 text-[10.5px] text-ink/50",children:["Regex is on — escape metacharacters such as ",e("code",{className:"font-mono",children:"( ) [ ] * ? +"})," or turn it off to search literally."]})]})}):q&&C.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4 text-[11px]",children:"Searching..."}):r.trim().length<=2?e("div",{className:"flex-1 text-ink/40 italic text-center py-4 text-[11px]",children:"Type at least 3 characters to search."}):C.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4 text-[11px]",children:"No results found."}):e(d,{children:[T&&e("div",{className:"px-3 pt-2 text-[10.5px] text-error-text",role:"alert",children:["Search failed: ",e("span",{className:"font-mono",children:T})]}),q&&e("div",{className:"px-3 pt-2 text-ink/40 italic",children:"Searching…"}),J&&e("div",{className:"px-3 pt-2 text-ink/50 italic",children:["Showing the first ",se," matches — refine the query to see the rest."]}),e(ce,{groups:X,replacement:c,showReplacePreview:c.length>0,onOpen:he,onReplaceFile:de,replaceBusy:Q})]})]})}function pe(s){let[r,t]=n({scope:s,results:[],truncated:!1,error:null}),[c,m]=n(!1),l=i(null),v=i(!0),R=i(s);R.current=s,o(()=>(v.current=!0,()=>{v.current=!1,l.current?.abort(),l.current=null}),[]);let b=a(async(x)=>{l.current?.abort();let M=new AbortController;l.current=M;let g=R.current;t({scope:g,results:[],truncated:!1,error:null}),m(!0);try{let A=await fetch("/api/fs/search",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams(x),signal:M.signal});await Pc(A,(w,L)=>{if(R.current!==g)return;if(w==="done"){let k=!1;try{k=JSON.parse(L)?.truncated===!0}catch{}t((y)=>y.scope===g?{...y,truncated:k}:y);return}if(w==="error"){let k="Search failed";try{k=JSON.parse(L)?.error||k}catch{}t((y)=>y.scope===g?{...y,error:k}:y);return}if(w!=="matches")return;try{let k=JSON.parse(L);if(Array.isArray(k))t((y)=>y.scope===g?{...y,results:[...y.results,...k]}:y)}catch{}},M.signal)}catch{}finally{if(v.current&&l.current===M)l.current=null,m(!1)}},[]);return{results:r.scope===s?r.results:[],isSearching:c&&r.scope===s,truncated:r.scope===s&&r.truncated,error:r.scope===s?r.error:null,start:b}}function it({className:s="",enabled:r=!0,rootPath:t,onOpenFile:c,tabsMode:m=!1}){let[l,v]=S("search.query",""),[R,b]=S("search.replaceQuery",""),[x,M]=S("search.matchCase",!1),[g,A]=S("search.wholeWord",!1),[w,L]=S("search.useRegex",!1),[k,y]=S("search.includeFiles",""),[P,F]=n(!1),[H,D]=S("search.showIncludeField",!1),{activeRepo:p,setActiveRepo:N}=vr(t),{repos:I,scanning:C,rescan:q}=kr(t,r),J=i(null),T=bt(),{results:B,isSearching:U,truncated:Q,error:Y,start:X}=pe(`${t??""}\x00${p}`);$e(J,()=>F(!1));let W=a(()=>{if(!r)return;if(l.trim().length>2)return X({q:l,matchCase:String(x),wholeWord:String(g),useRegex:String(w),includeFiles:H?k:"",...t?{root:t}:{},...p!=="."?{repo:p}:{}})},[r,l,x,g,w,H,k,t,p,X]);o(()=>{let _=setTimeout(()=>{W()},300);return()=>clearTimeout(_)},[W]);let K=a((_)=>{if(!l)return;let j=_?[_]:Array.from(new Set(B.map((V)=>V.file)));if(j.length===0)return;T.submit({q:l,replaceWith:R,matchCase:String(x),wholeWord:String(g),useRegex:String(w),files:JSON.stringify(j),...t?{root:t}:{},...p!=="."?{repo:p}:{}},{method:"POST",action:"/api/fs/replace"})},[l,R,x,g,w,B,t,p,T]);if(o(()=>{if(T.state==="idle"&&T.data?.success)W()},[T.state,T.data,W]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${s}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e(ue,{className:s,tabsMode:m,query:l,setQuery:v,replaceQuery:R,setReplaceQuery:b,matchCase:x,setMatchCase:M,wholeWord:g,setWholeWord:A,useRegex:w,setUseRegex:L,includeFiles:k,setIncludeFiles:y,showIncludeField:H,setShowIncludeField:D,showMenu:P,setShowMenu:F,menuRef:J,rootPath:t,activeRepo:p,setActiveRepo:N,repos:I,reposScanning:C,rescanRepos:q,results:B,isSearching:U,truncated:Q,error:Y,onOpenFile:c,handleReplace:K,replaceBusy:T.state!=="idle"})}export{it as SearchPanel};
@@ -1,4 +1,4 @@
1
- import{n,o,i,u,a,dn,e,f,oe,Tt}from"./index-95jfphx5.js";function j(t,s){return{top:Math.min(t.row,s.row),left:Math.min(t.col,s.col),bottom:Math.max(t.row,s.row),right:Math.max(t.col,s.col)}}function q(t){return t.bottom-t.top+1}function z(t){return t.right-t.left+1}function H(t){let s=t+1,r="";while(s>0){let d=(s-1)%26;r=String.fromCharCode(65+d)+r,s=Math.floor((s-1)/26)}return r}function X(t){return`${H(t.col)}${t.row+1}`}function F(t){let s=X({row:t.top,col:t.left}),r=X({row:t.bottom,col:t.right});return s===r?s:`${s}:${r}`}function I(t,s,r){return{row:Math.min(Math.max(t.row,0),Math.max(s-1,0)),col:Math.min(Math.max(t.col,0),Math.max(r-1,0))}}function U(t,s,r,d,p){return I({row:t.row+s,col:t.col+r},d,p)}function W(t,s){if(t<=0||s<=0)return null;return{top:0,left:0,bottom:t-1,right:s-1}}function K(t,s){let r=[];for(let d=s.top;d<=s.bottom;d+=1){let p=[];for(let c=s.left;c<=s.right;c+=1){let g=t[d]?.[c]??"";p.push(/[\t\r\n"]/.test(g)?`"${g.replace(/"/g,'""')}"`:g)}r.push(p.join("\t"))}return r.join(`\r
1
+ import{n,o,i,u,a,dn,e,f,oe,Tt}from"./index-4vtc4xct.js";function j(t,s){return{top:Math.min(t.row,s.row),left:Math.min(t.col,s.col),bottom:Math.max(t.row,s.row),right:Math.max(t.col,s.col)}}function q(t){return t.bottom-t.top+1}function z(t){return t.right-t.left+1}function H(t){let s=t+1,r="";while(s>0){let d=(s-1)%26;r=String.fromCharCode(65+d)+r,s=Math.floor((s-1)/26)}return r}function X(t){return`${H(t.col)}${t.row+1}`}function F(t){let s=X({row:t.top,col:t.left}),r=X({row:t.bottom,col:t.right});return s===r?s:`${s}:${r}`}function I(t,s,r){return{row:Math.min(Math.max(t.row,0),Math.max(s-1,0)),col:Math.min(Math.max(t.col,0),Math.max(r-1,0))}}function U(t,s,r,d,p){return I({row:t.row+s,col:t.col+r},d,p)}function W(t,s){if(t<=0||s<=0)return null;return{top:0,left:0,bottom:t-1,right:s-1}}function K(t,s){let r=[];for(let d=s.top;d<=s.bottom;d+=1){let p=[];for(let c=s.left;c<=s.right;c+=1){let g=t[d]?.[c]??"";p.push(/[\t\r\n"]/.test(g)?`"${g.replace(/"/g,'""')}"`:g)}r.push(p.join("\t"))}return r.join(`\r
2
2
  `)}function B(t,s){let[r,d]=n(null),[p,c]=n(null),[g,C]=n(!1),b=i(!1),m=a((v)=>I(v,t,s),[t,s]),y=a((v,E)=>{let G=m(v);if(E&&r)c(G);else d(G),c(G);b.current=!0,C(!0)},[r,m]),k=a((v)=>{if(!b.current)return;c(m(v))},[m]),N=a(()=>{b.current=!1,C(!1)},[]),T=a((v,E,G)=>{let S=U(p??{row:0,col:0},v,E,t,s);if(G&&r)c(S);else d(S),c(S)},[r,p,t,s]),A=a(()=>{let v=W(t,s);if(!v)return;d({row:v.top,col:v.left}),c({row:v.bottom,col:v.right})},[t,s]),L=a((v,E)=>{let G=m({row:t-1,col:v});if(E&&r)c(G);else d(m({row:0,col:v})),c(G)},[r,m,t]),P=a((v,E)=>{let G=m({row:v,col:s-1});if(E&&r)c(G);else d(m({row:v,col:0})),c(G)},[r,m,s]),l=a(()=>{d(null),c(null)},[]),x=u(()=>{if(!r||!p)return null;return j(m(r),m(p))},[r,p,m]),R=u(()=>p?m(p):null,[p,m]);return{range:x,active:R,dragging:g,begin:y,extendTo:k,endDrag:N,move:T,selectAll:A,selectColumn:L,selectRow:P,clear:l}}function Y(t){let[s,r]=n(null),d=a((C,b,m,y)=>{r({section:C,row:b,col:m,value:y,initial:y})},[]),p=a((C)=>{r((b)=>b?{...b,value:C}:b)},[]),c=a(()=>{if(s&&s.value!==s.initial)t(s);r(null)},[s,t]),g=a(()=>r(null),[]);return{edit:s,begin:d,change:p,commit:c,cancel:g}}function V(t){let s=t.target?.closest?.("[data-row][data-col]");if(!s)return null;return{row:Number(s.dataset.row),col:Number(s.dataset.col)}}function J({cells:t,width:s,selection:r,editor:d,scrollerRef:p,startEdit:c,onEditCell:g,setCopyState:C}){let b=d.edit,m=r.active;return{onPointerDown:(l)=>{if(l.button!==0)return;let x=l.target;if(x?.closest?.("[data-edit-input]"))return;if(b)d.commit();let R=V(l);if(R){p.current?.focus(),r.begin(R,l.shiftKey),l.preventDefault();return}let v=x?.closest?.("[data-col-header]");if(v){p.current?.focus(),r.selectColumn(Number(v.dataset.colHeader),l.shiftKey),l.preventDefault();return}let E=x?.closest?.("[data-row-header]");if(E){p.current?.focus(),r.selectRow(Number(E.dataset.rowHeader),l.shiftKey),l.preventDefault();return}if(x?.closest?.("[data-corner]"))p.current?.focus(),r.selectAll(),l.preventDefault()},onPointerOver:(l)=>{let x=V(l);if(x)r.extendTo(x)},onDoubleClick:(l)=>{let x=V(l);if(x){c("data",x.row,x.col);return}let R=l.target?.closest?.("[data-col-header]");if(R)c("header",0,Number(R.dataset.colHeader))},onInput:(l)=>{let x=l.target;if(x.matches?.("[data-edit-input]"))d.change(x.value)},onKeyDown:(l)=>{if(b){if(l.key==="Enter"){l.preventDefault(),d.commit(),r.move(l.shiftKey?-1:1,0,!1);return}if(l.key==="Tab"){l.preventDefault(),d.commit(),r.move(0,l.shiftKey?-1:1,!1);return}if(l.key==="Escape"){l.preventDefault(),d.cancel();return}return}let x=l.metaKey||l.ctrlKey;if(x&&l.key.toLowerCase()==="a"){l.preventDefault(),r.selectAll();return}if(l.key==="Escape"){r.clear();return}if(l.key==="Enter"||l.key==="F2"){if(!g||!m)return;l.preventDefault(),c("data",m.row,m.col);return}if(l.key==="Delete"||l.key==="Backspace"){if(!g||!m)return;l.preventDefault(),g(m.row,m.col,"");return}if(l.key.length===1&&!x&&!l.altKey){if(!g||!m)return;l.preventDefault(),c("data",m.row,m.col,l.key);return}let v={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]}[l.key];if(v){l.preventDefault(),r.move(v[0],v[1],l.shiftKey);return}if(l.key==="Home"||l.key==="End"){l.preventDefault();let E=l.key==="Home"?0:s-1,G=x?l.key==="Home"?0:t.length-1:m?.row??0;r.move(G-(m?.row??0),E-(m?.col??0),l.shiftKey)}},onCopy:(l)=>{if(b)return;if(!r.range)return;l.clipboardData?.setData("text/plain",K(t,r.range)),l.preventDefault(),C("copied")},onPaste:(l)=>{if(b)return;l.preventDefault(),C("refused")}}}var Q=dn(function({cells:s,rowIndex:r,selectedLeft:d,selectedRight:p,activeCol:c,editingCol:g,editingValue:C}){let b=d>=0;return e("tr",{className:"odd:bg-ink/[0.02]",children:[e("th",{"data-row-header":r,className:`cursor-pointer border-b border-r border-ink/10 px-2 py-0.5 text-right font-normal tabular-nums ${b?"bg-info/10 text-ink/60":"text-ink/30"}`,title:`Select row ${r+1}`,children:r+1}),s.map((m,y)=>{let k=b&&y>=d&&y<=p;return e("td",{"data-row":r,"data-col":y,title:m,className:`cursor-cell border-b border-ink/10 px-2 py-0.5 text-ink ${k?"bg-info/10":""} ${y===c?"ring-1 ring-inset ring-info":""}`,children:y===g?e("input",{"data-edit-input":"true",value:C,spellcheck:!1,className:"w-full min-w-0 bg-transparent font-mono text-[11px] text-ink outline-none"}):e("span",{className:"block truncate",children:m})},y)})]})});function Z({status:t,tone:s="muted",actions:r,canCopy:d,copyState:p,onCopy:c}){return e("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-ink/10 bg-canvas px-2 py-1 font-sans text-[11px]",children:[e("span",{className:`truncate ${s==="warning"?"text-warning-text":"text-ink/50"}`,children:t}),e("div",{className:"flex shrink-0 items-center gap-2",children:[r,e("button",{type:"button",onClick:c,disabled:!d,title:"Copy the selected cells as tab-separated text",className:`flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors ${d?"text-ink/60 hover:bg-ink/5 hover:text-ink":"cursor-default text-ink/25"} ${p==="failed"?"text-error-text":""}`,children:[p==="copied"?e(f,{size:12}):e(oe,{size:12}),e("span",{children:p==="copied"?"Copied":p==="failed"?"Copy failed":"Copy"})]})]})]})}var ne=44,re=1600;function Su({header:t,rows:s,truncated:r,label:d,readOnlyNote:p,onEditCell:c,onEditHeader:g,actions:C}){let b=u(()=>s.reduce((h,w)=>Math.max(h,w.length),t.length),[t,s]),m=u(()=>Array.from({length:b},(h,w)=>t[w]??H(w)),[t,b]),y=u(()=>s.map((h)=>h.length===b?h:Array.from({length:b},(w,M)=>h[M]??"")),[s,b]),k=B(y.length,b),N=i(null),[T,A]=n("idle"),L=a((h)=>{if(h.section==="header")g?.(h.col,h.value);else c?.(h.row,h.col,h.value)},[c,g]),P=Y(L),l=P.edit,x=a((h,w,M,_)=>{if(h==="header"?!g:!c)return;let te=h==="header"?m[M]??"":y[w]?.[M]??"";P.begin(h,w,M,_??te)},[y,P,m,c,g]),R=a(async()=>{if(!k.range)return;let h=await Tt(K(y,k.range));A(h?"copied":"failed")},[y,k.range]);o(()=>{if(T==="idle")return;let h=setTimeout(()=>A("idle"),re);return()=>clearTimeout(h)},[T]);let{dragging:v,endDrag:E}=k;o(()=>{if(!v)return;let h=()=>E();return window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h),()=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)}},[v,E]);let G=k.active;o(()=>{if(!G)return;N.current?.querySelector(`[data-row="${G.row}"][data-col="${G.col}"]`)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[G]);let O=l?`${l.section}:${l.row}:${l.col}`:"";o(()=>{if(!O)return;let h=N.current?.querySelector("[data-edit-input]");h?.focus(),h?.select()},[O]);let S=J({cells:y,width:b,selection:k,editor:P,scrollerRef:N,startEdit:x,onEditCell:c,setCopyState:A});if(b===0&&y.length===0)return e("div",{className:"flex flex-1 items-center justify-center px-6 text-center text-xs text-ink/50",children:"This file has no rows."});let D=k.range,ee=T==="refused"?p??"This grid is read-only.":D?`${F(D)} · ${q(D)}×${z(D)}`:"Click a cell, drag to select a block";return e("div",{className:"flex min-h-0 flex-1 flex-col",children:[r&&e("div",{className:"shrink-0 border-b border-warning/30 bg-warning/10 px-3 py-1 font-sans text-[11px] text-warning-text",children:["Showing the first ",y.length.toLocaleString()," rows."]}),e(Z,{status:ee,tone:T==="refused"?"warning":"muted",actions:C,canCopy:D!==null,copyState:T,onCopy:()=>void R()}),e("div",{ref:N,tabIndex:0,role:"grid","aria-label":d??"Spreadsheet",className:"flex-1 overflow-auto outline-none",onPointerDown:S.onPointerDown,onPointerOver:S.onPointerOver,onDblClick:S.onDoubleClick,onInput:S.onInput,onKeyDown:S.onKeyDown,onCopy:S.onCopy,onPaste:S.onPaste,children:e("table",{className:"w-full table-fixed select-none border-collapse font-mono text-[11px]",children:[e("colgroup",{children:[e("col",{style:{width:`${ne}px`}}),m.map((h,w)=>e("col",{},w))]}),e("thead",{className:"sticky top-0 z-10 bg-canvas",children:e("tr",{children:[e("th",{"data-corner":!0,title:"Select all",className:"cursor-pointer border-b border-r border-ink/10 px-2 py-1 text-right font-normal text-ink/30",children:"#"}),m.map((h,w)=>{let M=D!==null&&w>=D.left&&w<=D.right,_=l?.section==="header"&&l.col===w;return e("th",{"data-col-header":w,title:h,className:`cursor-pointer border-b border-ink/10 px-2 py-1 text-left font-semibold ${M?"bg-info/10 text-ink":"text-ink/80"}`,children:_?e("input",{"data-edit-input":"true",value:l.value,spellcheck:!1,className:"w-full min-w-0 bg-transparent font-mono text-[11px] font-semibold text-ink outline-none"}):e("span",{className:"block truncate",children:h})},w)})]})}),e("tbody",{children:y.map((h,w)=>{let M=D!==null&&w>=D.top&&w<=D.bottom;return e(Q,{cells:h,rowIndex:w,selectedLeft:M?D.left:-1,selectedRight:M?D.right:-1,activeCol:G?.row===w?G.col:-1,editingCol:l?.section==="data"&&l.row===w?l.col:-1,editingValue:l?.section==="data"&&l.row===w?l.value:""},w)})})]})})]})}var _g=2000,Sg=100;function ie(t,s){if(/\.tsv$/i.test(s??""))return"\t";let r=t.slice(0,t.indexOf(`
3
3
  `)===-1?t.length:t.indexOf(`
4
4
  `)),d=0,p=0,c=!1;for(let g=0;g<r.length;g+=1){let C=r[g];if(C==='"')c=!c;else if(!c&&C==="\t")d+=1;else if(!c&&C===",")p+=1}return d>p?"\t":","}function le(t,s,r){let d=[],p=[],c="",g=!1,C=0,b=()=>{if(C<r)p.push(c);c="",C+=1},m=()=>{b(),d.push(p),p=[],C=0};for(let y=0;y<t.length;y+=1){let k=t[y];if(g){if(k==='"')if(t[y+1]==='"')c+='"',y+=1;else g=!1;else c+=k;continue}if(k==='"'&&c.length===0){g=!0;continue}if(k===s){b();continue}if(k==="\r"){if(t[y+1]===`
@@ -1,2 +1,2 @@
1
- import{t,l,C,m,V,ee,_a,Sa,Qh,la,Fo,Rh,fl,rn,Lh,cA,Ta,Po,Al}from"./index-dekvtt2a.js";import{et}from"./index-hxy1sadd.js";function zp(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),c=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:c,rootGroups:n}}t(zp,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await ee(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function Up(e,r,n){let i=await Sa(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(Up,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new et({multigraph:!0,compound:!0}),s=[...r.edges],o=m(),c=zp(e),{edgeLabels:f,nodes:a}=c,d=new Map,b=new Map(r.nodes.map((u)=>[u.id,u])),y=r.direction,h=e.node()!=null;await Promise.all(r.nodes.map(async(u)=>{if(u.isGroup){if(h){let p=n.unwrapGroupLabels&&u.labelType!=="markdown";await L(a,u,p?Number.POSITIVE_INFINITY:void 0)}i.setNode(u.id,{...u})}else{if(h){let p=await Up(a,u,{config:o,dir:D(u,b,y)});d.set(u.id,p)}i.setNode(u.id,{...u})}}));for(let u of s){if(h&&cA(u))await Ta(f,u);if(i.setEdge(u.start,u.end,{...u},u.id),!r.edges.some((v)=>v.id===u.id))r.edges.push(u)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:u}=await import("./sizeCapture-INFHLROL-kyw0p86n.js");u(e,r)}return{graph:i,groups:c,nodeElements:d}}t(S,"createGraphWithElements");var ve=new Map,g=new Map,P=new Map,W=t(()=>{g.clear(),P.clear(),ve.clear()},"clear"),w=t((e,r)=>{let n=g.get(r)||[];return l.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),Y=t((e,r)=>{let n=g.get(r)||[];if(l.info("Descendants of ",r," is ",n),l.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return l.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||w(e.v,r)||w(e.w,r)||n.includes(e.w)},"edgeInCluster"),k=t((e,r,n,i)=>{l.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);l.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)k(o,r,n,i);else{let c=r.node(o);if(l.info("cp ",o," to ",i," with parent ",e),n.setNode(o,c),i!==r.parent(o))l.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)l.debug("Setting parent",o,e),n.setParent(o,e);else l.info("In copy ",e,"root",i,"data",r.node(e),i),l.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let f=r.edges(o);l.debug("Copying Edges",f),f.forEach((a)=>{l.info("Edge",a);let d=r.edge(a.v,a.w,a.name);l.info("Edge data",d,i);try{if(Y(a,i))l.info("Copying as ",a.v,a.w,d,a.name),n.setEdge(a.v,a.w,d,a.name),l.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else l.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",i," clusterId:",e)}catch(b){l.error(b)}})}l.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)P.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),q=t((e,r,n)=>{let i=e.edges().filter((a)=>a.v===r||a.w===r),s=e.edges().filter((a)=>a.v===n||a.w===n),o=i.map((a)=>({v:a.v===r?n:a.v,w:a.w===r?r:a.w})),c=s.map((a)=>({v:a.v,w:a.w}));return o.filter((a)=>c.some((d)=>a.v===d.v&&a.w===d.w))},"findCommonEdges"),cl=t((e,r,n)=>{let i=r.children(e);if(l.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let c=cl(o,r,n),f=q(r,n,c);if(c)if(f.length>0)s=c;else return c}return s},"findNonClusterChild"),N=t((e)=>{if(!ve.has(e))return e;if(!ve.get(e).externalConnections)return e;if(ve.has(e))return ve.get(e).id;return e},"getAnchorId"),vh=t((e,r)=>{if(!e||r>10){l.debug("Opting out, no graph ");return}else l.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)l.debug("Cluster identified",n," Replacement id in edges: ",cl(n,e,n)),g.set(n,T(n,e)),ve.set(n,{id:cl(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)l.debug("Cluster identified",n,g),s.forEach((o)=>{let c=w(o.v,n),f=w(o.w,n);if(c^f)l.debug("Edge: ",o," leaves cluster ",n),l.debug("Descendants of XXX ",n,": ",g.get(n)),ve.get(n).externalConnections=!0});else l.debug("Not a cluster ",n,g)});for(let n of ve.keys()){let i=ve.get(n).id,s=e.parent(i);if(s!==n&&ve.has(s)&&!ve.get(s).externalConnections)ve.get(n).id=s;let o=e.edges().some((c)=>c.v===n);if(i&&ve.get(n)?.externalConnections&&o&&M(e,i,n)){let c=K(e,n,e.parent(i));if(c)ve.get(n).id=c}}e.edges().forEach(function(n){let i=e.edge(n);l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(l.debug("Fix XXX",ve,"ids:",n.v,n.w,"Translating: ",ve.get(n.v)," --- ",ve.get(n.w)),ve.get(n.v)||ve.get(n.w)){if(l.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=N(n.v),o=N(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let c=e.parent(s);ve.get(c).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let c=e.parent(o);ve.get(c).externalConnections=!0,i.toCluster=n.w}l.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),R(e,0),l.trace(ve)},"adjustClustersAndEdges"),R=t((e,r)=>{if(r>10){l.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){l.debug("Done, no node has children",e.nodes());return}l.debug("Nodes = ",n,r);for(let s of n)if(l.debug("Extracting node",s,ve,ve.has(s)&&!ve.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!ve.has(s))l.debug("Not a cluster",s,r);else if(!ve.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){l.debug("Cluster without external connections, without a parent and with children",s,r);let c=e.graph().rankdir==="TB"?"LR":"TB";if(ve.get(s)?.clusterData?.dir)c=ve.get(s).clusterData.dir,l.debug("Fixing dir",ve.get(s).clusterData.dir,c);let f=new et({multigraph:!0,compound:!0}).setGraph({rankdir:c,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});k(s,e,f,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:ve.get(s).clusterData,label:ve.get(s).label,graph:f})}else l.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!ve.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),l.debug(ve);n=e.nodes(),l.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(l.debug(" Now next level",s,o),o?.clusterNode)R(o.graph,r+1)}},"extractor"),B=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=B(e,s);n=[...n,...o]}),n},"sorter"),Gp=t((e)=>B(e,e.children()),"sortNodesByHierarchy"),M=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=ve.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),K=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||w(s,n))continue;let o=cl(s,e,r);if(!o)continue;if(!M(e,o,r))return o}return null},"findSafeAnchorNode");function gi({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let c=r??jp;return t(async function(a,d,b,y){let h=d.select("g");(b?.insertMarkers??Al)(h,a.markers,a.type,a.diagramId),X();let u={element:h,helpers:b,options:y};u.preparedLayout=await e?.(a,u);let p=await c(a,u),v=await n(a,u),E={...u,measure:p};if(i)await i(a,E,v);else await G(a,E,o);await s?.(a,E,v)},"render")}t(gi,"createCommonLayoutRenderer");function X(){Qh(),Lh(),Rh(),W()}t(X,"clearLayoutRenderState");async function jp(e,{element:r},n){return await S(r,e,n)}t(jp,"defaultMeasureLayout");async function G(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let c of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(c,r))continue;await _(s,c,r,n)}let o=O(e.nodes);for(let c of e.edges){if(F(c,n))continue;await j(s,c,o,e,n,r)}}t(G,"paintLayoutData");async function _(e,r,n,i){if(r.clusterNode)la(r);else if(A(r,n,i))await Fo(e.clusters,r);else la(r)}t(_,"paintLayoutNode");function A(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(A,"shouldPaintAsCluster");function O(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(O,"buildNodeLookup");function F(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(F,"shouldSkipPaintEdge");async function j(e,r,n,i,s,o){let c=Po(e.edgePaths,{...r},s.clusterDb??new Map,i.type,x(r.start,r,n,o,s),x(r.end,r,n,o,s),i.diagramId,H(r,s));if(cA(r)){if(!fl.has(r.id))await Ta(e.edgeLabels,r);z(r,c)}}t(j,"paintLayoutEdge");function x(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(x,"getRenderedNode");function H(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(H,"shouldSkipIntersect");function z(e,r){let n=r?.updatedPath??r?.originalPath,i=C(),{subGraphTitleTotalMargin:s}=_a({flowchart:i.flowchart??{}});if(e.label){let o=fl.get(e.id),{x:c,y:f}=e;if(n){let a=V.calcLabelPosition(n);if(l.debug("Moving label "+e.label+" from (",c,",",f,") to (",a.x,",",a.y,") abc88"),r?.updatedPath)c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f+s/2})`)}if(e?.startLabelLeft){let o=rn.get(e.id).startLeft,c=e?.x,f=e?.y;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.startLabelRight){let o=rn.get(e.id).startRight,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelLeft){let o=rn.get(e.id).endLeft,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelRight){let o=rn.get(e.id).endRight,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}}t(z,"positionRenderedEdgeLabel");
1
+ import{t,l,C,m,V,ee,_a,Sa,Qh,la,Fo,Rh,fl,rn,Lh,cA,Ta,Po,Al}from"./index-gwgh27h3.js";import{et}from"./index-hxy1sadd.js";function zp(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),c=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:c,rootGroups:n}}t(zp,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await ee(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function Up(e,r,n){let i=await Sa(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(Up,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new et({multigraph:!0,compound:!0}),s=[...r.edges],o=m(),c=zp(e),{edgeLabels:f,nodes:a}=c,d=new Map,b=new Map(r.nodes.map((u)=>[u.id,u])),y=r.direction,h=e.node()!=null;await Promise.all(r.nodes.map(async(u)=>{if(u.isGroup){if(h){let p=n.unwrapGroupLabels&&u.labelType!=="markdown";await L(a,u,p?Number.POSITIVE_INFINITY:void 0)}i.setNode(u.id,{...u})}else{if(h){let p=await Up(a,u,{config:o,dir:D(u,b,y)});d.set(u.id,p)}i.setNode(u.id,{...u})}}));for(let u of s){if(h&&cA(u))await Ta(f,u);if(i.setEdge(u.start,u.end,{...u},u.id),!r.edges.some((v)=>v.id===u.id))r.edges.push(u)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:u}=await import("./sizeCapture-INFHLROL-pvc16ame.js");u(e,r)}return{graph:i,groups:c,nodeElements:d}}t(S,"createGraphWithElements");var ve=new Map,g=new Map,P=new Map,W=t(()=>{g.clear(),P.clear(),ve.clear()},"clear"),w=t((e,r)=>{let n=g.get(r)||[];return l.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),Y=t((e,r)=>{let n=g.get(r)||[];if(l.info("Descendants of ",r," is ",n),l.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return l.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||w(e.v,r)||w(e.w,r)||n.includes(e.w)},"edgeInCluster"),k=t((e,r,n,i)=>{l.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);l.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)k(o,r,n,i);else{let c=r.node(o);if(l.info("cp ",o," to ",i," with parent ",e),n.setNode(o,c),i!==r.parent(o))l.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)l.debug("Setting parent",o,e),n.setParent(o,e);else l.info("In copy ",e,"root",i,"data",r.node(e),i),l.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let f=r.edges(o);l.debug("Copying Edges",f),f.forEach((a)=>{l.info("Edge",a);let d=r.edge(a.v,a.w,a.name);l.info("Edge data",d,i);try{if(Y(a,i))l.info("Copying as ",a.v,a.w,d,a.name),n.setEdge(a.v,a.w,d,a.name),l.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else l.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",i," clusterId:",e)}catch(b){l.error(b)}})}l.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)P.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),q=t((e,r,n)=>{let i=e.edges().filter((a)=>a.v===r||a.w===r),s=e.edges().filter((a)=>a.v===n||a.w===n),o=i.map((a)=>({v:a.v===r?n:a.v,w:a.w===r?r:a.w})),c=s.map((a)=>({v:a.v,w:a.w}));return o.filter((a)=>c.some((d)=>a.v===d.v&&a.w===d.w))},"findCommonEdges"),cl=t((e,r,n)=>{let i=r.children(e);if(l.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let c=cl(o,r,n),f=q(r,n,c);if(c)if(f.length>0)s=c;else return c}return s},"findNonClusterChild"),N=t((e)=>{if(!ve.has(e))return e;if(!ve.get(e).externalConnections)return e;if(ve.has(e))return ve.get(e).id;return e},"getAnchorId"),vh=t((e,r)=>{if(!e||r>10){l.debug("Opting out, no graph ");return}else l.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)l.debug("Cluster identified",n," Replacement id in edges: ",cl(n,e,n)),g.set(n,T(n,e)),ve.set(n,{id:cl(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)l.debug("Cluster identified",n,g),s.forEach((o)=>{let c=w(o.v,n),f=w(o.w,n);if(c^f)l.debug("Edge: ",o," leaves cluster ",n),l.debug("Descendants of XXX ",n,": ",g.get(n)),ve.get(n).externalConnections=!0});else l.debug("Not a cluster ",n,g)});for(let n of ve.keys()){let i=ve.get(n).id,s=e.parent(i);if(s!==n&&ve.has(s)&&!ve.get(s).externalConnections)ve.get(n).id=s;let o=e.edges().some((c)=>c.v===n);if(i&&ve.get(n)?.externalConnections&&o&&M(e,i,n)){let c=K(e,n,e.parent(i));if(c)ve.get(n).id=c}}e.edges().forEach(function(n){let i=e.edge(n);l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(l.debug("Fix XXX",ve,"ids:",n.v,n.w,"Translating: ",ve.get(n.v)," --- ",ve.get(n.w)),ve.get(n.v)||ve.get(n.w)){if(l.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=N(n.v),o=N(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let c=e.parent(s);ve.get(c).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let c=e.parent(o);ve.get(c).externalConnections=!0,i.toCluster=n.w}l.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),R(e,0),l.trace(ve)},"adjustClustersAndEdges"),R=t((e,r)=>{if(r>10){l.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){l.debug("Done, no node has children",e.nodes());return}l.debug("Nodes = ",n,r);for(let s of n)if(l.debug("Extracting node",s,ve,ve.has(s)&&!ve.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!ve.has(s))l.debug("Not a cluster",s,r);else if(!ve.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){l.debug("Cluster without external connections, without a parent and with children",s,r);let c=e.graph().rankdir==="TB"?"LR":"TB";if(ve.get(s)?.clusterData?.dir)c=ve.get(s).clusterData.dir,l.debug("Fixing dir",ve.get(s).clusterData.dir,c);let f=new et({multigraph:!0,compound:!0}).setGraph({rankdir:c,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});k(s,e,f,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:ve.get(s).clusterData,label:ve.get(s).label,graph:f})}else l.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!ve.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),l.debug(ve);n=e.nodes(),l.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(l.debug(" Now next level",s,o),o?.clusterNode)R(o.graph,r+1)}},"extractor"),B=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=B(e,s);n=[...n,...o]}),n},"sorter"),Gp=t((e)=>B(e,e.children()),"sortNodesByHierarchy"),M=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=ve.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),K=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||w(s,n))continue;let o=cl(s,e,r);if(!o)continue;if(!M(e,o,r))return o}return null},"findSafeAnchorNode");function gi({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let c=r??jp;return t(async function(a,d,b,y){let h=d.select("g");(b?.insertMarkers??Al)(h,a.markers,a.type,a.diagramId),X();let u={element:h,helpers:b,options:y};u.preparedLayout=await e?.(a,u);let p=await c(a,u),v=await n(a,u),E={...u,measure:p};if(i)await i(a,E,v);else await G(a,E,o);await s?.(a,E,v)},"render")}t(gi,"createCommonLayoutRenderer");function X(){Qh(),Lh(),Rh(),W()}t(X,"clearLayoutRenderState");async function jp(e,{element:r},n){return await S(r,e,n)}t(jp,"defaultMeasureLayout");async function G(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let c of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(c,r))continue;await _(s,c,r,n)}let o=O(e.nodes);for(let c of e.edges){if(F(c,n))continue;await j(s,c,o,e,n,r)}}t(G,"paintLayoutData");async function _(e,r,n,i){if(r.clusterNode)la(r);else if(A(r,n,i))await Fo(e.clusters,r);else la(r)}t(_,"paintLayoutNode");function A(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(A,"shouldPaintAsCluster");function O(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(O,"buildNodeLookup");function F(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(F,"shouldSkipPaintEdge");async function j(e,r,n,i,s,o){let c=Po(e.edgePaths,{...r},s.clusterDb??new Map,i.type,x(r.start,r,n,o,s),x(r.end,r,n,o,s),i.diagramId,H(r,s));if(cA(r)){if(!fl.has(r.id))await Ta(e.edgeLabels,r);z(r,c)}}t(j,"paintLayoutEdge");function x(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(x,"getRenderedNode");function H(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(H,"shouldSkipIntersect");function z(e,r){let n=r?.updatedPath??r?.originalPath,i=C(),{subGraphTitleTotalMargin:s}=_a({flowchart:i.flowchart??{}});if(e.label){let o=fl.get(e.id),{x:c,y:f}=e;if(n){let a=V.calcLabelPosition(n);if(l.debug("Moving label "+e.label+" from (",c,",",f,") to (",a.x,",",a.y,") abc88"),r?.updatedPath)c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f+s/2})`)}if(e?.startLabelLeft){let o=rn.get(e.id).startLeft,c=e?.x,f=e?.y;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.startLabelRight){let o=rn.get(e.id).startRight,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelLeft){let o=rn.get(e.id).endLeft,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelRight){let o=rn.get(e.id).endRight,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}}t(z,"positionRenderedEdgeLabel");
2
2
  export{zp,Up,ve,cl,vh,Gp,gi,jp};
@@ -1,4 +1,4 @@
1
- import{d,n,o,O,i,u,a,Lr,e,Mr,zo,sr,zm,Se,S,Gm,vA,vr,kr,s,lo,Ie,co,p,Yn,Ne,Q,E,At,f,I,le,ht,oe,fe,de,Xn,gn,In,L,D,Oa,G,$a,vn,h,Bt,it,$e,Od,Ri,X,ut,bt,$n,sn,yt,Dl,Ue,be,J}from"./index-95jfphx5.js";import{Pm,Rr}from"./index-2n2evsg0.js";var jt={name:"folder-tree",size:24,node:[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]},Ve=s(jt);var Ut={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]},Ye=s(Ut);function Xe({message:t,hasStagedChanges:l,isBusy:c=!1,amend:r=!1,seeded:m=!1,isGenerating:g=!1,suggestion:x=null,generated:v=!1,onToggleAmend:N,onChangeMessage:M,onCommit:w,onGenerate:C,onUseSuggestion:R,onDismissSuggestion:P}){let T=t.trim().length>0&&!c&&(r||l),k=(r||l)&&!c&&!g,b=r?"Rewrite the previous commit with this message":l?"Commit staged changes":"Stage changes first",y=g?"Generating…":r||l?"Generate a commit message from the staged changes":"Stage changes first";return e("div",{className:"border-t border-ink/10 bg-canvas/50 p-3 flex flex-col gap-2",children:[x&&e("div",{className:"rounded border border-ink/20 bg-paper p-2.5 space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Generated message"}),e("div",{className:"flex items-center gap-1",children:[e("button",{type:"button",onClick:R,className:"px-2 py-0.5 rounded bg-ink text-canvas text-[10px] font-medium hover:bg-ink/90 transition-colors cursor-pointer",children:"Use"}),e("button",{type:"button",onClick:P,className:"px-2 py-0.5 rounded border border-ink/20 text-ink/70 text-[10px] font-medium hover:bg-ink/5 transition-colors cursor-pointer",children:"Dismiss"})]})]}),e("pre",{className:"whitespace-pre-wrap break-words text-[11px] text-ink/80 font-mono max-h-32 overflow-y-auto",children:x})]}),e("textarea",{value:t,onChange:(A)=>M(A.currentTarget.value),onKeyDown:(A)=>{if(A.key==="Enter"&&(A.metaKey||A.ctrlKey)&&T)A.preventDefault(),w()},placeholder:r?"New message for the previous commit (⌘/Ctrl+Enter to commit)":"Commit message (⌘/Ctrl+Enter to commit)",rows:5,className:"w-full resize-y min-h-[100px] max-h-[200px] bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),v&&t.trim().length>0&&e("div",{className:"flex items-center gap-1 text-[10px] text-ink/40",children:[e(Ne,{size:10})," Generated from staged changes"]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("label",{className:"flex items-center gap-1.5 text-[11px] text-ink/70 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:r,onChange:(A)=>N?.(A.currentTarget.checked),className:`${be} accent-ink cursor-pointer`}),"Amend"]}),r&&m&&e("span",{className:"text-[10px] text-ink/40",title:"The previous commit's message, loaded as an editable starting point",children:"previous message loaded"}),e("button",{type:"button",onClick:C,disabled:!k,title:y,"aria-label":"Generate commit message with AI",className:"ml-auto flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[g?e(p,{size:12,className:"animate-spin"}):e(Ne,{size:12}),g?"Generating…":"Generate"]}),e("button",{type:"button",onClick:w,disabled:!T,title:b,className:"flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(f,{size:12}),r?"Amend commit":"Commit"]})]})]})}function Qe({operation:t,conflicts:l,isBusy:c,onAbort:r,onContinue:m}){let g=zo[t],x=l.length,v=x===0,N=t!=="stash-pop";return e("div",{className:"border-t border-warning/30 bg-warning/5 p-3 flex flex-col gap-2",children:[e("div",{className:"flex items-center gap-2 text-xs text-ink",children:[e(E,{size:13,className:"text-warning-text flex-shrink-0"}),e("span",{className:"font-medium",children:[g.charAt(0).toUpperCase()+g.slice(1)," in progress"]}),e("span",{className:`font-mono tabular-nums text-[10px] ${v?"text-success-text":"text-warning-text"}`,children:v?"all conflicts resolved":`${x} conflict${x===1?"":"s"} left`})]}),!v&&e("div",{className:"max-h-20 overflow-y-auto scrollbar-overlay-container font-mono text-[10px] text-warning-text space-y-0.5",children:l.map((M)=>e("div",{className:"truncate",title:M,children:M},M))}),e("div",{className:"flex items-stretch gap-2",children:[e("button",{type:"button",onClick:r,disabled:c,title:`Abort the ${g} and restore the previous state`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-error/40 text-error-text hover:bg-error/10 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(vn,{size:12}),"Abort ",g]}),N&&e("button",{type:"button",onClick:m,disabled:c||!v,title:v?`Conclude the ${g}`:`Resolve all ${x} conflict(s) first`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-transparent bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Xn,{size:12}),"Continue ",g]})]})]})}function Ze({branchRef:t,showBranchMenu:l,setShowBranchMenu:c,branch:r,branches:m,remoteBranches:g,onCheckout:x,onMerge:v,onOpenBranchPrompt:N,onManageBranches:M,optionsRef:w,showOptions:C,setShowOptions:R,onHistory:P,onGraph:T,viewMode:k,setViewMode:b,isBusy:y=!1,syncCount:A={ahead:0,behind:0},syncing:H=!1,onSync:_,onFetch:K,detached:B=!1}){let[V,Y]=n("");o(()=>{if(!l)Y("")},[l]);let U=V.trim(),z=u(()=>m.filter((F)=>sn(F,U)),[m,U]),j=u(()=>g.filter((F)=>sn(F,U)),[g,U]);return e("div",{className:"p-3 border-b border-ink/10 bg-canvas/50 flex items-center justify-between",children:[e("div",{className:"relative",ref:t,children:[e("button",{onClick:()=>c(!l),className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 -ml-2 rounded transition-colors text-[11px] text-ink/80 font-medium",title:B?`Detached HEAD at ${r}`:`On branch ${r}`,children:[e(de,{size:12,className:B?"text-warning-text":"text-ink/60"}),e("span",{className:`truncate max-w-[140px] ${B?"font-mono text-warning-text":""}`,children:r}),e(I,{size:12,className:"text-ink/40"})]}),l&&e("div",{className:"glass-popover absolute top-full left-0 mt-1 w-64 bg-paper border border-ink/20 rounded-md shadow-lg z-50 flex flex-col overflow-hidden text-xs",children:[e($n,{value:V,onChange:Y,ariaLabel:"Search branches",placeholder:"Search branches…"}),e("div",{className:"max-h-48 scrollbar-overlay-container py-1",children:[z.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Local"}),z.map((F)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{x(F),c(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:F}),r===F&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==F&&e("button",{type:"button",onClick:()=>{v(F),c(!1)},title:`Merge ${F} into ${r}`,"aria-label":`Merge ${F} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Xn,{size:12})})]},F))]}),j.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Remote"}),j.map((F)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{x(F),c(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:F}),r===F&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==F&&e("button",{type:"button",onClick:()=>{v(F),c(!1)},title:`Merge ${F} into ${r}`,"aria-label":`Merge ${F} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Xn,{size:12})})]},F))]}),z.length===0&&j.length===0&&e("div",{className:"px-3 py-2 text-ink/40 italic",children:["No match for “",U,"”"]}),e("div",{className:"w-full h-px bg-ink/10 my-1"}),e("button",{onClick:()=>{N(),c(!1)},className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80 italic",children:[e(L,{size:12}),e("span",{children:"Create new branch..."})]}),e("button",{onClick:M,className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80",children:[e($a,{size:12}),e("span",{children:"Manage branches..."})]})]})]})]}),e("div",{className:"flex items-center space-x-2 text-ink/40 relative",ref:w,children:[e("button",{type:"button",onClick:K,disabled:y,title:"Fetch from all remotes and prune deleted branches","aria-label":"Fetch",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e(lo,{size:13})}),e("button",{type:"button",onClick:_,disabled:y,title:H?"Syncing with upstream…":A.ahead>0&&A.behind>0?`Pull ${A.behind} then push ${A.ahead} commit(s)`:A.ahead>0?`Push ${A.ahead} commit(s)`:A.behind>0?`Pull ${A.behind} commit(s)`:"Up to date — sync anyway","aria-label":"Sync with upstream","aria-busy":H,className:`flex items-center gap-1 p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:cursor-not-allowed ${H?"":"disabled:opacity-40"}`,children:[e(D,{size:13,className:H?"animate-spin":"","aria-hidden":"true"}),e("span",{className:"font-mono tabular-nums text-[10px]",children:["↑",A.ahead," ↓",A.behind]})]}),e("button",{type:"button",onClick:P,title:"Commit History","aria-label":"Commit History",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Yn,{size:13})}),e("button",{type:"button",onClick:T,title:"Git Graph","aria-label":"Git Graph",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Xn,{size:13})}),e("button",{type:"button",onClick:()=>R(!C),title:"View Options","aria-label":"View Options","aria-expanded":C,className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Ie,{size:13})}),C&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-36 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 font-mono text-xs",children:[e("button",{type:"button",onClick:()=>{b("flat"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Ye,{size:12,className:"text-ink/60"}),e("span",{children:"View as List"})]}),k==="flat"&&e(f,{size:12,className:"text-ink"})]}),e("button",{type:"button",onClick:()=>{b("tree"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Ve,{size:12,className:"text-ink/60"}),e("span",{children:"View as Tree"})]}),k==="tree"&&e(f,{size:12,className:"text-ink"})]})]})]})]})}function Je({activeRepo:t,repos:l,isRefreshing:c,rootPath:r,reposScanning:m,onSelectRepo:g,onRefresh:x,onRefreshRepos:v}){return e(Bt,{left:e(d,{children:[e(Pm,{size:12,className:"text-ink/50 flex-shrink-0","aria-hidden":!0}),e(Rr,{rootPath:r,activeRepo:t,onSelectRepo:g,repos:l,scanning:m,onRefreshRepos:v})]}),right:e(it,{label:"Refresh",onClick:x,busy:c})})}function Fe({change:t,isStaged:l,repo:c,rootPath:r,onAction:m}){let g=sr(t.status,l),{charStatus:x,colorClass:v}=g,N=t.file.split("/"),M=N.pop()||t.file,w=N.length>0?N.join("/"):"";return e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-ink/5 cursor-pointer group text-[11px] transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:l,status:x,repo:c||".",root:r}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e("span",{className:`font-bold font-mono text-[10px] w-3 flex-shrink-0 text-center ${v}`,title:`Status: ${g.label}`,children:x}),e(ut,{name:M,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${v}`,title:t.file,children:M}),w&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:w})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:[!l&&e(d,{children:[e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),m("revert",t.file)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error-text hover:bg-error/10 cursor-pointer transition-colors",children:e(vn,{size:11})}),e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),m("stage",t.file)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(L,{size:11})})]}),l&&e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),m("unstage",t.file)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(gn,{size:11})})]})})]})}function et({change:t,repo:l,rootPath:c,onResolve:r}){let[m,g]=n(!1),[x,v]=n(null),N=t.file.split("/"),M=N.pop()||t.file,w=N.length>0?N.join("/"):"",C=()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:!1,status:t.status,repo:l,root:c}}))},R=async()=>{let k=!m;if(g(k),k&&x===null){let b=new URLSearchParams({conflictMarkers:"1",file:t.file,repo:l||"."});if(c)b.set("root",c);try{let A=await(await fetch(`/api/fs/git?${b.toString()}`)).json();v(A.markers??{})}catch{v({})}}},P=x?.ours||"ours",T=x?.theirs||"theirs";return e("div",{className:"border-b border-warning/20 last:border-b-0",children:[e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-warning/5 cursor-pointer group text-[11px] transition-colors",onClick:C,children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e(co,{size:11,className:"text-warning-text flex-shrink-0"}),e(ut,{name:M,size:12,className:"flex-shrink-0"}),e("span",{className:"truncate text-warning-text",title:t.file,children:M}),w&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:w}),Mr(t.status)&&e("span",{className:"text-[10px] text-warning-text font-mono flex-shrink-0",children:t.status})]}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),R()},title:m?"Hide resolve actions":"Show resolve actions","aria-label":m?"Hide resolve actions":"Show resolve actions","aria-expanded":m,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors flex-shrink-0",children:m?e(ht,{size:11}):e(I,{size:11})})]}),m&&e("div",{className:"px-3 pb-2 pt-0.5 flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>r(t.file,"ours"),title:`Take ${P} — \`git checkout --ours\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",P]}),e("button",{type:"button",onClick:()=>r(t.file,"theirs"),title:`Take ${T} — \`git checkout --theirs\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",T]}),e("button",{type:"button",onClick:()=>r(t.file,""),title:"Mark resolved: the file was edited by hand, this stages it",className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer flex items-center gap-1",children:[e(f,{size:10}),"mark resolved"]})]})]})}function Wt(t){let l={id:"",name:"",path:"",type:"folder",children:[],changeCount:0};for(let r of t){let m=r.file.replace(/^[./]+/,""),g=m.endsWith("/"),x=m.replace(/\/$/,"").split("/").filter(Boolean),v=l,N="";for(let M=0;M<x.length;M++){let w=x[M];N=N?`${N}/${w}`:w;let C=M===x.length-1;if(C&&!g)v.children.push({id:N,name:w,path:N,type:"file",change:r,children:[],changeCount:1});else{let P=v.children.find((T)=>T.type==="folder"&&T.name===w);if(!P)P={id:N,name:w,path:N,type:"folder",children:[],changeCount:0,change:C&&g?r:void 0},v.children.push(P);v=P}}}function c(r){if(r.type==="file")return 1;let m=r.change?1:0;for(let g of r.children)m+=c(g);return r.changeCount=m,r.children.sort((g,x)=>{if(g.type==="folder"&&x.type==="file")return-1;if(g.type==="file"&&x.type==="folder")return 1;return g.name.localeCompare(x.name)}),m}return c(l),l.children}function tt(t){let{sessionId:l,ready:c,read:r}=Gm(),m=u(()=>Wt(t),[t]),g=u(()=>{let R=new Set;function P(T){for(let k of T)if(k.type==="folder"){if(R.add(k.id),k.children&&k.children.length>0)P(k.children)}}return P(m),R},[m]),[x,v]=S("git.expandedFolders",[]),N=u(()=>new Set(x),[x]),M=i(null);o(()=>{if(!c||M.current===l)return;if(g.size===0)return;if(M.current=l,r("git.expandedFolders",[]).length>0)return;v(Array.from(g))},[c,l,g,r,v]);let w=a((R)=>{v((P)=>{let T=new Set(P);if(T.has(R))T.delete(R);else T.add(R);return Array.from(T)})},[v]),C=a((R)=>N.has(R),[N]);return{tree:m,expandedFolders:N,toggleFolder:w,isFolderOpen:C,expandAll:()=>v(Array.from(g)),collapseAll:()=>v([])}}function He({node:t,isStaged:l,isFolderOpen:c,toggleFolder:r,onAction:m,repo:g,rootPath:x}){let v=t.type==="folder",N=v?c(t.id):!1;if(v)return e("div",{className:"select-none",children:[e("div",{className:"flex items-center justify-between px-2 py-1 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>r(t.id),children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center text-ink/40 flex-shrink-0",children:N?e(I,{size:12}):e(le,{size:12})}),e(ut,{name:t.name,isFolder:!0,isOpen:N,size:13,className:"flex-shrink-0"}),e("span",{className:"font-medium text-ink truncate",children:t.name}),e("span",{className:"text-[10px] text-ink/40 font-normal px-1 py-0.2 bg-ink/5 rounded-full ml-1",children:t.changeCount})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!l?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("revert",t.path)},title:`Discard changes in ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-error-text hover:bg-error/10 cursor-pointer transition-colors",children:e(vn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("stage",t.path)},title:`Stage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(L,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("unstage",t.path)},title:`Unstage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(gn,{size:11})})})})]}),N&&t.children&&t.children.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:t.children.map((k)=>e(He,{node:k,isStaged:l,isFolderOpen:c,toggleFolder:r,onAction:m,repo:g,rootPath:x},k.id))})]});let M=t.change,w=sr(M?.status||"M",l),{charStatus:C,colorClass:R}=w,P=M?M.file:t.path;return e("div",{className:"flex items-center justify-between px-2 py-0.5 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:P,staged:l,status:C,repo:g||".",root:x}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center flex-shrink-0",children:e("span",{className:`font-bold font-mono text-[10px] ${R}`,title:`Status: ${w.label}`,children:C})}),e(ut,{name:t.name,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${R}`,title:P,children:t.name})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!l?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("revert",P)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error-text hover:bg-error/10 cursor-pointer transition-colors",children:e(vn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("stage",P)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(L,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("unstage",P)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(gn,{size:11})})})})]})}function ze({changes:t,isStaged:l,repo:c,rootPath:r,onAction:m}){let{tree:g,isFolderOpen:x,toggleFolder:v}=tt(t);if(g.length===0)return null;return e("div",{className:"py-0.5",children:g.map((N)=>e(He,{node:N,isStaged:l,isFolderOpen:x,toggleFolder:v,onAction:m,repo:c,rootPath:r},N.id))})}function nt({changes:t,isLoading:l,viewMode:c,repo:r,rootPath:m,onAction:g,onResolve:x}){let[v,N]=S("git.stagedExpanded",!0),[M,w]=S("git.unstagedExpanded",!0),[C,R]=S("git.conflictsExpanded",!0),P=t.filter((b)=>Mr(b.status)),T=t.filter((b)=>{if(Mr(b.status))return!1;let y=b.status;return y&&y[0]!==" "&&y[0]!=="?"}),k=t.filter((b)=>{if(Mr(b.status))return!1;let y=b.status;return y&&y[1]!==" "&&y[1]!=="?"||y==="??"});if(l&&t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"Loading..."})});if(t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"No changes found."})});return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"py-1",children:[P.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-warning/5 cursor-pointer transition-colors",onClick:()=>R(!C),children:e("div",{className:"flex items-center space-x-1 font-semibold text-warning-text text-xs",children:[e("span",{className:"w-3 text-center",children:C?"▾":"▸"}),e("span",{children:"Conflicts"}),e("span",{className:"text-warning-text font-normal ml-1 border border-warning/30 rounded-full px-1.5 text-[10px] bg-paper",children:P.length})]})}),C&&P.map((b)=>e(et,{change:b,repo:r,rootPath:m,onResolve:x??(()=>{})},`conflict-${b.file}`))]}),T.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>N(!v),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:v?"▾":"▸"}),e("span",{children:"Staged Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:T.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("button",{type:"button",onClick:(b)=>{b.stopPropagation(),g("unstage_all")},title:"Unstage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(gn,{size:12})})})]}),v&&(c==="tree"?e(ze,{changes:T,isStaged:!0,repo:r,rootPath:m,onAction:g}):T.map((b)=>e(Fe,{change:b,isStaged:!0,repo:r,rootPath:m,onAction:g},b.file+"staged")))]}),k.length>0&&e("div",{children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>w(!M),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:M?"▾":"▸"}),e("span",{children:"Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:k.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:[e("button",{type:"button",onClick:(b)=>{b.stopPropagation(),g("revert_all")},title:"Discard All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error-text hover:bg-error/10 cursor-pointer transition-colors",children:e(vn,{size:12})}),e("button",{type:"button",onClick:(b)=>{b.stopPropagation(),g("stage_all")},title:"Stage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(L,{size:12})})]})]}),M&&(c==="tree"?e(ze,{changes:k,isStaged:!1,repo:r,rootPath:m,onAction:g}):k.map((b)=>e(Fe,{change:b,isStaged:!1,repo:r,rootPath:m,onAction:g},b.file+"unstaged")))]})]})})}function ot({matches:t,loaded:l,total:c,hasMore:r,isFiltering:m}){if(m)return`${t} of ${l} loaded`;if(typeof c==="number"&&c>0)return r||l<c?`${l} of ${c}`:`${c} commits`;return r?`${l}+ commits`:`${l} commits`}function st({isGraphMode:t,onToggleMode:l,searchQuery:c,onSearchChange:r,onRefresh:m,onClose:g,isRefreshing:x,totalCommits:v,loadedCount:N,totalCount:M,hasMore:w}){let C=ot({matches:v,loaded:N,total:M,hasMore:w,isFiltering:c.trim().length>0});return e("div",{className:`flex flex-col gap-2 px-3 lg:px-5 py-3 border-b border-ink/10 bg-paper select-none
1
+ import{d,n,o,O,i,u,a,Lr,e,Mr,zo,sr,zm,Se,S,Gm,vA,vr,kr,s,lo,Ie,co,p,Yn,Ne,Q,E,At,f,I,le,ht,oe,fe,de,Xn,gn,In,L,D,Oa,G,$a,vn,h,Bt,it,$e,Od,Ri,X,ut,bt,$n,sn,yt,Dl,Ue,be,J}from"./index-4vtc4xct.js";import{Pm,Rr}from"./index-sr14vwn5.js";var jt={name:"folder-tree",size:24,node:[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]},Ve=s(jt);var Ut={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]},Ye=s(Ut);function Xe({message:t,hasStagedChanges:l,isBusy:c=!1,amend:r=!1,seeded:m=!1,isGenerating:g=!1,suggestion:x=null,generated:v=!1,onToggleAmend:N,onChangeMessage:M,onCommit:w,onGenerate:C,onUseSuggestion:R,onDismissSuggestion:P}){let T=t.trim().length>0&&!c&&(r||l),k=(r||l)&&!c&&!g,b=r?"Rewrite the previous commit with this message":l?"Commit staged changes":"Stage changes first",y=g?"Generating…":r||l?"Generate a commit message from the staged changes":"Stage changes first";return e("div",{className:"border-t border-ink/10 bg-canvas/50 p-3 flex flex-col gap-2",children:[x&&e("div",{className:"rounded border border-ink/20 bg-paper p-2.5 space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Generated message"}),e("div",{className:"flex items-center gap-1",children:[e("button",{type:"button",onClick:R,className:"px-2 py-0.5 rounded bg-ink text-canvas text-[10px] font-medium hover:bg-ink/90 transition-colors cursor-pointer",children:"Use"}),e("button",{type:"button",onClick:P,className:"px-2 py-0.5 rounded border border-ink/20 text-ink/70 text-[10px] font-medium hover:bg-ink/5 transition-colors cursor-pointer",children:"Dismiss"})]})]}),e("pre",{className:"whitespace-pre-wrap break-words text-[11px] text-ink/80 font-mono max-h-32 overflow-y-auto",children:x})]}),e("textarea",{value:t,onChange:(A)=>M(A.currentTarget.value),onKeyDown:(A)=>{if(A.key==="Enter"&&(A.metaKey||A.ctrlKey)&&T)A.preventDefault(),w()},placeholder:r?"New message for the previous commit (⌘/Ctrl+Enter to commit)":"Commit message (⌘/Ctrl+Enter to commit)",rows:5,className:"w-full resize-y min-h-[100px] max-h-[200px] bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),v&&t.trim().length>0&&e("div",{className:"flex items-center gap-1 text-[10px] text-ink/40",children:[e(Ne,{size:10})," Generated from staged changes"]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("label",{className:"flex items-center gap-1.5 text-[11px] text-ink/70 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:r,onChange:(A)=>N?.(A.currentTarget.checked),className:`${be} accent-ink cursor-pointer`}),"Amend"]}),r&&m&&e("span",{className:"text-[10px] text-ink/40",title:"The previous commit's message, loaded as an editable starting point",children:"previous message loaded"}),e("button",{type:"button",onClick:C,disabled:!k,title:y,"aria-label":"Generate commit message with AI",className:"ml-auto flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[g?e(p,{size:12,className:"animate-spin"}):e(Ne,{size:12}),g?"Generating…":"Generate"]}),e("button",{type:"button",onClick:w,disabled:!T,title:b,className:"flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(f,{size:12}),r?"Amend commit":"Commit"]})]})]})}function Qe({operation:t,conflicts:l,isBusy:c,onAbort:r,onContinue:m}){let g=zo[t],x=l.length,v=x===0,N=t!=="stash-pop";return e("div",{className:"border-t border-warning/30 bg-warning/5 p-3 flex flex-col gap-2",children:[e("div",{className:"flex items-center gap-2 text-xs text-ink",children:[e(E,{size:13,className:"text-warning-text flex-shrink-0"}),e("span",{className:"font-medium",children:[g.charAt(0).toUpperCase()+g.slice(1)," in progress"]}),e("span",{className:`font-mono tabular-nums text-[10px] ${v?"text-success-text":"text-warning-text"}`,children:v?"all conflicts resolved":`${x} conflict${x===1?"":"s"} left`})]}),!v&&e("div",{className:"max-h-20 overflow-y-auto scrollbar-overlay-container font-mono text-[10px] text-warning-text space-y-0.5",children:l.map((M)=>e("div",{className:"truncate",title:M,children:M},M))}),e("div",{className:"flex items-stretch gap-2",children:[e("button",{type:"button",onClick:r,disabled:c,title:`Abort the ${g} and restore the previous state`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-error/40 text-error-text hover:bg-error/10 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(vn,{size:12}),"Abort ",g]}),N&&e("button",{type:"button",onClick:m,disabled:c||!v,title:v?`Conclude the ${g}`:`Resolve all ${x} conflict(s) first`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-transparent bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Xn,{size:12}),"Continue ",g]})]})]})}function Ze({branchRef:t,showBranchMenu:l,setShowBranchMenu:c,branch:r,branches:m,remoteBranches:g,onCheckout:x,onMerge:v,onOpenBranchPrompt:N,onManageBranches:M,optionsRef:w,showOptions:C,setShowOptions:R,onHistory:P,onGraph:T,viewMode:k,setViewMode:b,isBusy:y=!1,syncCount:A={ahead:0,behind:0},syncing:H=!1,onSync:_,onFetch:K,detached:B=!1}){let[V,Y]=n("");o(()=>{if(!l)Y("")},[l]);let U=V.trim(),z=u(()=>m.filter((F)=>sn(F,U)),[m,U]),j=u(()=>g.filter((F)=>sn(F,U)),[g,U]);return e("div",{className:"p-3 border-b border-ink/10 bg-canvas/50 flex items-center justify-between",children:[e("div",{className:"relative",ref:t,children:[e("button",{onClick:()=>c(!l),className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 -ml-2 rounded transition-colors text-[11px] text-ink/80 font-medium",title:B?`Detached HEAD at ${r}`:`On branch ${r}`,children:[e(de,{size:12,className:B?"text-warning-text":"text-ink/60"}),e("span",{className:`truncate max-w-[140px] ${B?"font-mono text-warning-text":""}`,children:r}),e(I,{size:12,className:"text-ink/40"})]}),l&&e("div",{className:"glass-popover absolute top-full left-0 mt-1 w-64 bg-paper border border-ink/20 rounded-md shadow-lg z-50 flex flex-col overflow-hidden text-xs",children:[e($n,{value:V,onChange:Y,ariaLabel:"Search branches",placeholder:"Search branches…"}),e("div",{className:"max-h-48 scrollbar-overlay-container py-1",children:[z.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Local"}),z.map((F)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{x(F),c(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:F}),r===F&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==F&&e("button",{type:"button",onClick:()=>{v(F),c(!1)},title:`Merge ${F} into ${r}`,"aria-label":`Merge ${F} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Xn,{size:12})})]},F))]}),j.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Remote"}),j.map((F)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{x(F),c(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:F}),r===F&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==F&&e("button",{type:"button",onClick:()=>{v(F),c(!1)},title:`Merge ${F} into ${r}`,"aria-label":`Merge ${F} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Xn,{size:12})})]},F))]}),z.length===0&&j.length===0&&e("div",{className:"px-3 py-2 text-ink/40 italic",children:["No match for “",U,"”"]}),e("div",{className:"w-full h-px bg-ink/10 my-1"}),e("button",{onClick:()=>{N(),c(!1)},className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80 italic",children:[e(L,{size:12}),e("span",{children:"Create new branch..."})]}),e("button",{onClick:M,className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80",children:[e($a,{size:12}),e("span",{children:"Manage branches..."})]})]})]})]}),e("div",{className:"flex items-center space-x-2 text-ink/40 relative",ref:w,children:[e("button",{type:"button",onClick:K,disabled:y,title:"Fetch from all remotes and prune deleted branches","aria-label":"Fetch",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e(lo,{size:13})}),e("button",{type:"button",onClick:_,disabled:y,title:H?"Syncing with upstream…":A.ahead>0&&A.behind>0?`Pull ${A.behind} then push ${A.ahead} commit(s)`:A.ahead>0?`Push ${A.ahead} commit(s)`:A.behind>0?`Pull ${A.behind} commit(s)`:"Up to date — sync anyway","aria-label":"Sync with upstream","aria-busy":H,className:`flex items-center gap-1 p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:cursor-not-allowed ${H?"":"disabled:opacity-40"}`,children:[e(D,{size:13,className:H?"animate-spin":"","aria-hidden":"true"}),e("span",{className:"font-mono tabular-nums text-[10px]",children:["↑",A.ahead," ↓",A.behind]})]}),e("button",{type:"button",onClick:P,title:"Commit History","aria-label":"Commit History",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Yn,{size:13})}),e("button",{type:"button",onClick:T,title:"Git Graph","aria-label":"Git Graph",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Xn,{size:13})}),e("button",{type:"button",onClick:()=>R(!C),title:"View Options","aria-label":"View Options","aria-expanded":C,className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Ie,{size:13})}),C&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-36 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 font-mono text-xs",children:[e("button",{type:"button",onClick:()=>{b("flat"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Ye,{size:12,className:"text-ink/60"}),e("span",{children:"View as List"})]}),k==="flat"&&e(f,{size:12,className:"text-ink"})]}),e("button",{type:"button",onClick:()=>{b("tree"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Ve,{size:12,className:"text-ink/60"}),e("span",{children:"View as Tree"})]}),k==="tree"&&e(f,{size:12,className:"text-ink"})]})]})]})]})}function Je({activeRepo:t,repos:l,isRefreshing:c,rootPath:r,reposScanning:m,onSelectRepo:g,onRefresh:x,onRefreshRepos:v}){return e(Bt,{left:e(d,{children:[e(Pm,{size:12,className:"text-ink/50 flex-shrink-0","aria-hidden":!0}),e(Rr,{rootPath:r,activeRepo:t,onSelectRepo:g,repos:l,scanning:m,onRefreshRepos:v})]}),right:e(it,{label:"Refresh",onClick:x,busy:c})})}function Fe({change:t,isStaged:l,repo:c,rootPath:r,onAction:m}){let g=sr(t.status,l),{charStatus:x,colorClass:v}=g,N=t.file.split("/"),M=N.pop()||t.file,w=N.length>0?N.join("/"):"";return e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-ink/5 cursor-pointer group text-[11px] transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:l,status:x,repo:c||".",root:r}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e("span",{className:`font-bold font-mono text-[10px] w-3 flex-shrink-0 text-center ${v}`,title:`Status: ${g.label}`,children:x}),e(ut,{name:M,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${v}`,title:t.file,children:M}),w&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:w})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:[!l&&e(d,{children:[e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),m("revert",t.file)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error-text hover:bg-error/10 cursor-pointer transition-colors",children:e(vn,{size:11})}),e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),m("stage",t.file)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(L,{size:11})})]}),l&&e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),m("unstage",t.file)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(gn,{size:11})})]})})]})}function et({change:t,repo:l,rootPath:c,onResolve:r}){let[m,g]=n(!1),[x,v]=n(null),N=t.file.split("/"),M=N.pop()||t.file,w=N.length>0?N.join("/"):"",C=()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:!1,status:t.status,repo:l,root:c}}))},R=async()=>{let k=!m;if(g(k),k&&x===null){let b=new URLSearchParams({conflictMarkers:"1",file:t.file,repo:l||"."});if(c)b.set("root",c);try{let A=await(await fetch(`/api/fs/git?${b.toString()}`)).json();v(A.markers??{})}catch{v({})}}},P=x?.ours||"ours",T=x?.theirs||"theirs";return e("div",{className:"border-b border-warning/20 last:border-b-0",children:[e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-warning/5 cursor-pointer group text-[11px] transition-colors",onClick:C,children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e(co,{size:11,className:"text-warning-text flex-shrink-0"}),e(ut,{name:M,size:12,className:"flex-shrink-0"}),e("span",{className:"truncate text-warning-text",title:t.file,children:M}),w&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:w}),Mr(t.status)&&e("span",{className:"text-[10px] text-warning-text font-mono flex-shrink-0",children:t.status})]}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),R()},title:m?"Hide resolve actions":"Show resolve actions","aria-label":m?"Hide resolve actions":"Show resolve actions","aria-expanded":m,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors flex-shrink-0",children:m?e(ht,{size:11}):e(I,{size:11})})]}),m&&e("div",{className:"px-3 pb-2 pt-0.5 flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>r(t.file,"ours"),title:`Take ${P} — \`git checkout --ours\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",P]}),e("button",{type:"button",onClick:()=>r(t.file,"theirs"),title:`Take ${T} — \`git checkout --theirs\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",T]}),e("button",{type:"button",onClick:()=>r(t.file,""),title:"Mark resolved: the file was edited by hand, this stages it",className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer flex items-center gap-1",children:[e(f,{size:10}),"mark resolved"]})]})]})}function Wt(t){let l={id:"",name:"",path:"",type:"folder",children:[],changeCount:0};for(let r of t){let m=r.file.replace(/^[./]+/,""),g=m.endsWith("/"),x=m.replace(/\/$/,"").split("/").filter(Boolean),v=l,N="";for(let M=0;M<x.length;M++){let w=x[M];N=N?`${N}/${w}`:w;let C=M===x.length-1;if(C&&!g)v.children.push({id:N,name:w,path:N,type:"file",change:r,children:[],changeCount:1});else{let P=v.children.find((T)=>T.type==="folder"&&T.name===w);if(!P)P={id:N,name:w,path:N,type:"folder",children:[],changeCount:0,change:C&&g?r:void 0},v.children.push(P);v=P}}}function c(r){if(r.type==="file")return 1;let m=r.change?1:0;for(let g of r.children)m+=c(g);return r.changeCount=m,r.children.sort((g,x)=>{if(g.type==="folder"&&x.type==="file")return-1;if(g.type==="file"&&x.type==="folder")return 1;return g.name.localeCompare(x.name)}),m}return c(l),l.children}function tt(t){let{sessionId:l,ready:c,read:r}=Gm(),m=u(()=>Wt(t),[t]),g=u(()=>{let R=new Set;function P(T){for(let k of T)if(k.type==="folder"){if(R.add(k.id),k.children&&k.children.length>0)P(k.children)}}return P(m),R},[m]),[x,v]=S("git.expandedFolders",[]),N=u(()=>new Set(x),[x]),M=i(null);o(()=>{if(!c||M.current===l)return;if(g.size===0)return;if(M.current=l,r("git.expandedFolders",[]).length>0)return;v(Array.from(g))},[c,l,g,r,v]);let w=a((R)=>{v((P)=>{let T=new Set(P);if(T.has(R))T.delete(R);else T.add(R);return Array.from(T)})},[v]),C=a((R)=>N.has(R),[N]);return{tree:m,expandedFolders:N,toggleFolder:w,isFolderOpen:C,expandAll:()=>v(Array.from(g)),collapseAll:()=>v([])}}function He({node:t,isStaged:l,isFolderOpen:c,toggleFolder:r,onAction:m,repo:g,rootPath:x}){let v=t.type==="folder",N=v?c(t.id):!1;if(v)return e("div",{className:"select-none",children:[e("div",{className:"flex items-center justify-between px-2 py-1 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>r(t.id),children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center text-ink/40 flex-shrink-0",children:N?e(I,{size:12}):e(le,{size:12})}),e(ut,{name:t.name,isFolder:!0,isOpen:N,size:13,className:"flex-shrink-0"}),e("span",{className:"font-medium text-ink truncate",children:t.name}),e("span",{className:"text-[10px] text-ink/40 font-normal px-1 py-0.2 bg-ink/5 rounded-full ml-1",children:t.changeCount})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!l?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("revert",t.path)},title:`Discard changes in ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-error-text hover:bg-error/10 cursor-pointer transition-colors",children:e(vn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("stage",t.path)},title:`Stage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(L,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("unstage",t.path)},title:`Unstage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(gn,{size:11})})})})]}),N&&t.children&&t.children.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:t.children.map((k)=>e(He,{node:k,isStaged:l,isFolderOpen:c,toggleFolder:r,onAction:m,repo:g,rootPath:x},k.id))})]});let M=t.change,w=sr(M?.status||"M",l),{charStatus:C,colorClass:R}=w,P=M?M.file:t.path;return e("div",{className:"flex items-center justify-between px-2 py-0.5 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:P,staged:l,status:C,repo:g||".",root:x}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center flex-shrink-0",children:e("span",{className:`font-bold font-mono text-[10px] ${R}`,title:`Status: ${w.label}`,children:C})}),e(ut,{name:t.name,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${R}`,title:P,children:t.name})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!l?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("revert",P)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error-text hover:bg-error/10 cursor-pointer transition-colors",children:e(vn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("stage",P)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(L,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),m("unstage",P)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(gn,{size:11})})})})]})}function ze({changes:t,isStaged:l,repo:c,rootPath:r,onAction:m}){let{tree:g,isFolderOpen:x,toggleFolder:v}=tt(t);if(g.length===0)return null;return e("div",{className:"py-0.5",children:g.map((N)=>e(He,{node:N,isStaged:l,isFolderOpen:x,toggleFolder:v,onAction:m,repo:c,rootPath:r},N.id))})}function nt({changes:t,isLoading:l,viewMode:c,repo:r,rootPath:m,onAction:g,onResolve:x}){let[v,N]=S("git.stagedExpanded",!0),[M,w]=S("git.unstagedExpanded",!0),[C,R]=S("git.conflictsExpanded",!0),P=t.filter((b)=>Mr(b.status)),T=t.filter((b)=>{if(Mr(b.status))return!1;let y=b.status;return y&&y[0]!==" "&&y[0]!=="?"}),k=t.filter((b)=>{if(Mr(b.status))return!1;let y=b.status;return y&&y[1]!==" "&&y[1]!=="?"||y==="??"});if(l&&t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"Loading..."})});if(t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"No changes found."})});return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"py-1",children:[P.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-warning/5 cursor-pointer transition-colors",onClick:()=>R(!C),children:e("div",{className:"flex items-center space-x-1 font-semibold text-warning-text text-xs",children:[e("span",{className:"w-3 text-center",children:C?"▾":"▸"}),e("span",{children:"Conflicts"}),e("span",{className:"text-warning-text font-normal ml-1 border border-warning/30 rounded-full px-1.5 text-[10px] bg-paper",children:P.length})]})}),C&&P.map((b)=>e(et,{change:b,repo:r,rootPath:m,onResolve:x??(()=>{})},`conflict-${b.file}`))]}),T.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>N(!v),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:v?"▾":"▸"}),e("span",{children:"Staged Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:T.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("button",{type:"button",onClick:(b)=>{b.stopPropagation(),g("unstage_all")},title:"Unstage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(gn,{size:12})})})]}),v&&(c==="tree"?e(ze,{changes:T,isStaged:!0,repo:r,rootPath:m,onAction:g}):T.map((b)=>e(Fe,{change:b,isStaged:!0,repo:r,rootPath:m,onAction:g},b.file+"staged")))]}),k.length>0&&e("div",{children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>w(!M),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:M?"▾":"▸"}),e("span",{children:"Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:k.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:[e("button",{type:"button",onClick:(b)=>{b.stopPropagation(),g("revert_all")},title:"Discard All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error-text hover:bg-error/10 cursor-pointer transition-colors",children:e(vn,{size:12})}),e("button",{type:"button",onClick:(b)=>{b.stopPropagation(),g("stage_all")},title:"Stage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(L,{size:12})})]})]}),M&&(c==="tree"?e(ze,{changes:k,isStaged:!1,repo:r,rootPath:m,onAction:g}):k.map((b)=>e(Fe,{change:b,isStaged:!1,repo:r,rootPath:m,onAction:g},b.file+"unstaged")))]})]})})}function ot({matches:t,loaded:l,total:c,hasMore:r,isFiltering:m}){if(m)return`${t} of ${l} loaded`;if(typeof c==="number"&&c>0)return r||l<c?`${l} of ${c}`:`${c} commits`;return r?`${l}+ commits`:`${l} commits`}function st({isGraphMode:t,onToggleMode:l,searchQuery:c,onSearchChange:r,onRefresh:m,onClose:g,isRefreshing:x,totalCommits:v,loadedCount:N,totalCount:M,hasMore:w}){let C=ot({matches:v,loaded:N,total:M,hasMore:w,isFiltering:c.trim().length>0});return e("div",{className:`flex flex-col gap-2 px-3 lg:px-5 py-3 border-b border-ink/10 bg-paper select-none
2
2
  pl-[max(0.75rem,env(safe-area-inset-left,0px))] pr-[max(0.75rem,env(safe-area-inset-right,0px))]`,children:[e("div",{className:"flex items-center justify-between gap-2 lg:gap-4",children:[e("div",{className:"flex flex-col min-w-0",children:[e("div",{className:"flex items-center gap-2.5 min-w-0",children:[e("h2",{className:"text-base font-semibold text-ink tracking-tight",children:t?"Graph":"History"}),e("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-ink/5 text-ink/80 border border-ink/10 whitespace-nowrap",children:C})]}),e("p",{className:"text-xs text-muted mt-0.5 hidden lg:block",children:t?"Follow branch topology and inspect commits.":"Browse recent commits and inspect changed files."})]}),e("div",{className:"flex items-center gap-1.5 lg:gap-2 flex-shrink-0",children:[e("div",{className:"flex items-center text-xs lg:bg-ink/5 lg:p-0.5 lg:rounded-lg lg:border lg:border-ink/10",children:[e("button",{type:"button",onClick:()=>l(!1),title:"History view","aria-label":"History view","aria-pressed":!t,className:`tap-target flex items-center justify-center gap-1.5 p-2 rounded-md font-medium transition-colors cursor-pointer lg:px-2.5 lg:py-1 ${!t?"bg-ink/5 text-ink lg:bg-paper lg:shadow-xs":"text-ink/80 lg:hover:text-ink lg:hover:bg-ink/5"}`,children:[e(Yn,{size:13,"aria-hidden":"true"}),e("span",{className:"hidden lg:inline",children:"History"})]}),e("button",{type:"button",onClick:()=>l(!0),title:"Graph view","aria-label":"Graph view","aria-pressed":t,className:`tap-target flex items-center justify-center gap-1.5 p-2 rounded-md font-medium transition-colors cursor-pointer lg:px-2.5 lg:py-1 ${t?"bg-ink/5 text-ink lg:bg-paper lg:shadow-xs":"text-ink/80 lg:hover:text-ink lg:hover:bg-ink/5"}`,children:[e(Xn,{size:13,"aria-hidden":"true"}),e("span",{className:"hidden lg:inline",children:"Graph"})]})]}),e("button",{type:"button",onClick:m,disabled:x,className:"tap-target flex items-center justify-center gap-1.5 p-2 rounded-md text-ink/70 transition-colors cursor-pointer text-xs disabled:opacity-40 lg:px-2.5 lg:py-1.5 lg:border lg:border-ink/15 lg:hover:bg-ink/5 lg:hover:text-ink",title:"Refresh commit history","aria-label":"Refresh commit history",children:[e(Oa,{size:13,className:x?"animate-spin text-ink":"","aria-hidden":"true"}),e("span",{className:"hidden lg:inline",children:"Refresh"})]}),e("button",{type:"button",onClick:g,className:"tap-target p-2 -mr-1 rounded-md hover:bg-ink/5 text-muted hover:text-ink transition-colors cursor-pointer",title:"Close modal","aria-label":"Close commit history",children:e(h,{size:16,"aria-hidden":"true"})})]})]}),e("div",{className:"relative mt-1",children:[e(G,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/55","aria-hidden":"true"}),e("input",{type:"text",value:c,onChange:(R)=>r(R.currentTarget.value),placeholder:"Filter commits by message, author, or hash...","aria-label":"Filter commits",className:"w-full bg-ink/[0.03] border border-ink/15 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),c&&e("button",{type:"button",onClick:()=>r(""),"aria-label":"Clear filter",className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-ink/55 hover:text-ink cursor-pointer",children:e(h,{size:12,"aria-hidden":"true"})})]})]})}var ce=["#38bdf8","#f97316","#a855f7","#10b981","#ec4899","#eab308","#06b6d4","#6366f1"];function Oe(t,l){if(!t||!l)return!1;if(t===l)return!0;let c=Math.min(t.length,l.length);if(c>=4)return t.substring(0,c)===l.substring(0,c);return!1}function Re(t){let l=new Map,c=[];for(let r of t){if(typeof r.lane==="number"){l.set(r.hash,r.lane);continue}let m=c.findIndex((x)=>Oe(x,r.hash)||Oe(x,r.shortHash));if(m===-1)if(m=c.indexOf(null),m===-1)m=c.length,c.push(r.hash);else c[m]=r.hash;l.set(r.hash,m);let g=r.parents&&r.parents[0];if(g)c[m]=g;else c[m]=null;if(r.parents&&r.parents.length>1)for(let x=1;x<r.parents.length;x++){let v=r.parents[x];if(!c.some((M)=>Oe(M,v))){let M=c.indexOf(null);if(M===-1)c.push(v);else c[M]=v}}}return l}function rt(t,l,c,r){let m=[],g=new Map;t.forEach((x,v)=>{if(g.set(x.hash,v),x.shortHash)g.set(x.shortHash,v);if(x.hash.length>=7)g.set(x.hash.substring(0,7),v)});for(let x of t){let v=l.get(x.hash)??0,N=c[x.hash]??0,M=ce[v%ce.length];if(!x.parents||x.parents.length===0)continue;for(let w of x.parents){let C=g.get(w);if(typeof C!=="number"&&w.length>=7)C=g.get(w.substring(0,7));if(typeof C==="number"){let R=t[C],P=l.get(R.hash)??v,T=c[R.hash]??N+60;m.push({fromHash:x.hash,toHash:R.hash,fromLane:v,toLane:P,fromY:N,toY:T,color:ce[v%ce.length]})}else m.push({fromHash:x.hash,toHash:"tail-"+x.hash,fromLane:v,toLane:v,fromY:N,toY:Math.max(N+80,r),color:M})}}return m}function at(t,l,c,r){if(Math.abs(t-c)<1)return`M ${t} ${l} L ${c} ${r}`;let m=r-l,g=l+m*0.45,x=r-m*0.45;return`M ${t} ${l} C ${t} ${g}, ${c} ${x}, ${c} ${r}`}function lt({commits:t,nodePositions:l,expandedHash:c,hoveredHash:r,isGraphMode:m,laneWidth:g=18,paddingLeft:x=16,totalHeight:v}){let N=u(()=>{if(!m){let R=new Map;return t.forEach((P)=>R.set(P.hash,0)),R}return Re(t)},[t,m]),M=u(()=>{let R=0;return N.forEach((P)=>{if(P>R)R=P}),R},[N]),w=m?(M+1)*g+x*2:36,C=u(()=>{if(!m){let R=[];for(let P=0;P<t.length-1;P++){let T=l[t[P].hash]??P*60+20,k=l[t[P+1].hash]??(P+1)*60+20;R.push({fromHash:t[P].hash,toHash:t[P+1].hash,fromLane:0,toLane:0,fromY:T,toY:k,color:"var(--theme-ink)"})}return R}return rt(t,N,l,v)},[t,N,l,v,m]);return e("div",{className:"absolute top-0 left-0 pointer-events-none z-10",style:{width:w,height:v},"aria-hidden":"true",children:e("svg",{className:"w-full h-full overflow-visible",style:{width:w,height:v},children:[C.map((R)=>{let P=m?x+R.fromLane*g:16,T=m?x+R.toLane*g:16,k=m?R.color:"currentColor",b=m?0.95:0.25,y=at(P,R.fromY,T,R.toY);return e("path",{d:y,fill:"none",stroke:k,strokeWidth:m?2.25:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:b},`${R.fromHash}->${R.toHash}`)}),t.map((R)=>{let P=N.get(R.hash)??0,T=m?x+P*g:16,k=l[R.hash]??20,b=c===R.hash||c===R.shortHash,y=r===R.hash||r===R.shortHash,A=m?ce[P%ce.length]:"var(--theme-success)";return e("g",{"data-commit-node":R.hash,children:[(b||y)&&e("circle",{cx:T,cy:k,r:8,fill:A,fillOpacity:b?0.35:0.2,stroke:A,strokeWidth:1}),e("circle",{"data-commit-dot":"",cx:T,cy:k,r:m?4:4.5,fill:m?"var(--theme-paper)":A,stroke:A,strokeWidth:m?2.5:1.5}),m&&e("circle",{cx:T,cy:k,r:1.8,fill:A})]},`node-${R.hash}`)})]})})}var qt=[{action:"checkout",label:"checkout"},{action:"create_branch_here",label:"create branch here"},{action:"cherry_pick",label:"cherry-pick"},{action:"revert",label:"revert"},{action:"reset",label:"reset..."},{action:"merge",label:"merge into current"},{action:"rebase",label:"rebase onto this"}];function ct({commit:t,onAction:l}){return e("div",{className:"flex flex-wrap items-center gap-1.5 pt-1.5 pb-2",children:qt.map(({action:c,label:r})=>e("button",{type:"button",onClick:(m)=>{m.stopPropagation(),l(c,t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer",children:r},c))})}var Ge=3;function Kt(t){let l=[];for(let c=0;c<t.length;c+=1){if(t[c].type!=="context"){l.push({row:t[c],index:c});continue}let r=c;while(r<t.length&&t[r].type==="context")r+=1;let m=r-c;if(m>Ge*2+1){for(let g=c;g<c+Ge;g+=1)l.push({row:t[g],index:g});l.push({row:{type:"elided",count:m-Ge*2},index:-1});for(let g=r-Ge;g<r;g+=1)l.push({row:t[g],index:g})}else for(let g=c;g<r;g+=1)l.push({row:t[g],index:g});c=r-1}return l}function dt({diffText:t,isLoading:l,filePath:c,fullContext:r=!1,onToggleContext:m}){let g=Ri(),x=u(()=>{if(!t)return[];let w=[],C=1,R=1,P=t.split(/\r?\n/),k=P.some((b)=>b.startsWith("@@"))?P:[`@@ -0,0 +1,${P.length} @@`,...P.map((b)=>b.startsWith("+")||b.startsWith("-")?b:`+${b}`)];for(let b of k){if(b.startsWith("diff --git")||b.startsWith("index ")||b.startsWith("---")||b.startsWith("+++")||b.startsWith("new file mode")||b.startsWith("deleted file mode")||b.startsWith("similarity index")||b.startsWith("old mode")||b.startsWith("new mode")||b.startsWith("\\ No newline"))continue;if(b.startsWith("@@")){let y=b.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(y)C=parseInt(y[1],10),R=parseInt(y[2],10);w.push({type:"meta",text:b})}else if(b.startsWith("+"))w.push({type:"add",text:b.slice(1),newNum:R++});else if(b.startsWith("-"))w.push({type:"del",text:b.slice(1),oldNum:C++});else{let y=b.startsWith(" ")?b.slice(1):b;w.push({type:"context",text:y,oldNum:C++,newNum:R++})}}return w},[t]),v=yt(c),N=u(()=>{let w=Array(x.length).fill(""),C=-1,R=(P)=>{if(C<0)return;let T=Od(x.slice(C,P).map((k)=>k.text).join(`
3
3
  `),v);for(let k=C;k<P;k++)w[k]=T[k-C]??"";C=-1};return x.forEach((P,T)=>{if(P.type==="meta")R(T);else if(C<0)C=T}),R(x.length),w},[x,v,g]),M=u(()=>r?x.map((w,C)=>({row:w,index:C})):Kt(x),[x,r]);if(l)return e("div",{className:"my-2 p-4 rounded bg-canvas border border-ink/10 text-muted font-mono text-xs flex items-center justify-center",children:"Loading commit diff..."});if(!t||x.length===0)return e("div",{className:"my-2 p-3 rounded bg-canvas border border-ink/10 text-muted font-mono text-xs text-center",children:"No diff content available for this file."});return e("div",{className:"my-2 rounded border border-ink/15 bg-paper overflow-hidden text-[11px] font-mono leading-relaxed text-ink",children:[e("div",{className:"flex items-center justify-between px-3 py-1.5 bg-canvas border-b border-ink/10 text-ink/70 text-[10.5px]",children:[e("span",{className:"font-semibold text-muted",children:"Diff preview"}),e("button",{type:"button",onClick:m,disabled:!m,className:"hover:text-ink flex items-center gap-1 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-default",title:r?"Show only the changed hunks":"Read the whole file around the change","aria-pressed":r,children:r?e(d,{children:[e(ht,{size:12,"aria-hidden":"true"})," Collapse context"]}):e(d,{children:[e(I,{size:12,"aria-hidden":"true"})," Expand all context"]})})]}),e("div",{className:"overflow-x-auto max-h-72 select-text",children:e("div",{className:"w-max min-w-full divide-y divide-ink/[0.04]",children:M.map(({row:w,index:C},R)=>{if(w.type==="elided")return e("div",{className:"px-3 py-1 bg-canvas text-muted text-[10px] text-center select-none",title:`${w.count} unchanged line(s) hidden`,children:["⋯ ",w.count," unchanged line",w.count===1?"":"s"," hidden ⋯"]},`elided-${R}`);let P=w,T=C;if(P.type==="meta")return e("div",{className:"flex items-center gap-2 px-3 py-1 bg-canvas border-y border-ink/10 text-muted text-[10px] font-semibold",children:[e("span",{children:"↕"}),e("span",{children:P.text})]},T);let k=P.type==="add",b=P.type==="del";return e("div",{className:`flex items-start font-mono ${k?"bg-success/10 hover:bg-success/15":b?"bg-error/10 hover:bg-error/15":"text-ink hover:bg-ink/[0.02]"}`,children:[e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${b?"bg-error/15 text-ink/80 font-semibold":k?"bg-success/15 text-ink/80":"bg-canvas/50 text-muted"}`,children:P.oldNum??(k?"+":"")}),e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${k?"bg-success/15 text-ink/80 font-semibold":b?"bg-error/15 text-ink/80":"bg-canvas/50 text-muted"}`,children:P.newNum??(b?"-":"")}),e("div",{className:`w-4 flex-shrink-0 text-center py-0.5 select-none font-bold ${k||b?"text-ink/80":"opacity-0"}`,children:k?"+":b?"-":" "}),e("div",{className:"flex-1 py-0.5 pr-3 whitespace-pre text-ink",children:P.text?e("span",{className:"shiki",dangerouslySetInnerHTML:{__html:N[T]}}):" "})]},T)})})})]})}function mt({commit:t,isExpanded:l,onToggleExpand:c,onAction:r,onToggleFile:m,isExpandedFile:g,isLoadingFile:x,isFullContextFile:v,onToggleContext:N,fileDiffs:M,headerRef:w}){let[C,R]=n(!1),P=t.body?.trim()??"",T=P.length>0,k=t.files??[],b=k.length,y=b>0,A=T||y,H=(B)=>{B.stopPropagation(),navigator.clipboard.writeText(t.hash),R(!0),setTimeout(()=>R(!1),2000)},_=(B,V)=>{B.stopPropagation(),m(t.hash,V)},K=A?"border-b border-ink/5 transition-colors cursor-pointer hover:bg-ink/[0.015]":"border-b border-ink/5";return e("div",{onClick:A?c:void 0,"data-testid":"commit-row","data-commit-hash":t.hash,className:K,children:e("div",{className:"py-2.5 flex flex-col",children:[e("div",{className:"flex flex-col gap-1",children:[t.refs&&t.refs.length>0&&e("div",{className:"flex flex-wrap items-center gap-1.5 pb-0.5",children:t.refs.map((B,V)=>{let Y=B.includes("stash"),U=B.includes("HEAD")||B.includes("main")||B.includes("master");return e("span",{className:`px-2 py-0.5 rounded text-[10px] font-mono border ${Y?"bg-warning/10 text-ink/80 border-warning/25 font-semibold":U?"bg-ink/10 text-ink font-semibold border-ink/20":"bg-canvas text-muted border-ink/10 font-medium"}`,children:B},V)})}),e("div",{ref:w,className:"flex items-start gap-1.5",children:e("button",{type:"button",onClick:A?(B)=>{B.stopPropagation(),c()}:void 0,"aria-expanded":A?l:void 0,className:"flex flex-1 min-w-0 items-start gap-1.5 text-left cursor-pointer rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20",children:[e("span",{"data-commit-title":"",className:"text-[13px] font-semibold text-ink leading-snug break-words flex-1 min-w-0",children:t.message}),A&&e("span",{className:"text-ink/55 flex-shrink-0 mt-0.5","aria-hidden":"true",children:l?e(I,{size:13}):e(le,{size:13})})]})}),T&&l&&e("div",{className:"border-l-2 border-ink/15 pl-3 py-1",children:e(J,{content:P,className:"text-ink/70"})}),e("div",{className:"flex items-center gap-x-2 gap-y-0.5 text-[11px] text-muted font-mono flex-wrap",children:[e("span",{children:t.author}),e("span",{children:t.date}),e("button",{type:"button",onClick:H,title:"Copy commit hash","aria-label":`Copy commit hash ${t.shortHash}`,className:"inline-flex items-center gap-1 hover:text-ink transition-colors cursor-pointer text-ink/70",children:[e("span",{children:t.shortHash}),C?e(f,{size:11,className:"text-success-text","aria-hidden":"true"}):e(oe,{size:11,"aria-hidden":"true"})]}),y&&e("span",{children:[b," ",b===1?"file":"files"]})]})]}),l&&e("div",{className:"mt-2",children:e(ct,{commit:t,onAction:r})}),y&&l&&e("div",{className:"mt-2 flex flex-col gap-1",children:k.map((B,V)=>{let Y=g(t.hash,B.file),U=`${t.hash}:${B.file}`,z=M[U]!==void 0?M[U]:B.diff,j=x(t.hash,B.file),F=B.status==="A"?"text-success-text font-bold":B.status==="D"?"text-error-text font-bold":B.status==="R"?"text-meta-text font-bold":"text-info-text font-bold";return e("div",{className:"flex flex-col",children:[e("button",{type:"button",onClick:(se)=>_(se,B),"aria-expanded":Y,className:"flex w-full items-center gap-2 py-1 px-2 rounded text-[11.5px] font-mono text-ink/80 transition-colors group cursor-pointer border border-transparent hover:border-ink/10 text-left",children:[e("span",{className:`w-3.5 text-center flex-shrink-0 text-[11px] ${F}`,children:B.status||"M"}),e("span",{className:"truncate flex-1 min-w-0 text-ink/90 group-hover:text-ink font-medium",children:B.file}),e("span",{className:"flex items-center gap-1 text-[10.5px] tabular-nums flex-shrink-0 font-medium",children:[e("span",{className:"text-success-text",children:["+",B.additions]}),e("span",{className:"text-ink/30",children:"/"}),e("span",{className:"text-error-text",children:["-",B.deletions]})]}),e("span",{className:"text-ink/55 group-hover:text-ink flex-shrink-0",children:Y?e(I,{size:13,"aria-hidden":"true"}):e(le,{size:13,"aria-hidden":"true"})})]}),Y&&e("div",{className:"pl-4 pr-1",children:e(dt,{diffText:z,isLoading:j,filePath:B.file,fullContext:v(t.hash,B.file),onToggleContext:()=>N(t.hash,B)})})]},V)})})]})})}var ge=50;function Vt(t){if(!Array.isArray(t))return[];let l=[];for(let c of t){if(!c||typeof c!=="object")continue;let r=c;if(typeof r.file!=="string"||!r.file)continue;l.push({file:r.file,status:typeof r.status==="string"?r.status:"M",additions:typeof r.additions==="number"&&Number.isFinite(r.additions)?r.additions:0,deletions:typeof r.deletions==="number"&&Number.isFinite(r.deletions)?r.deletions:0,diff:typeof r.diff==="string"?r.diff:void 0})}return l}function _e(t){if(!Array.isArray(t))return[];let l=[];for(let c of t){if(!c||typeof c!=="object")continue;let r=c,m=typeof r.hash==="string"&&r.hash?r.hash:"";if(!m)continue;l.push({hash:m,shortHash:typeof r.shortHash==="string"&&r.shortHash?r.shortHash:m.slice(0,8),author:typeof r.author==="string"?r.author:"Unknown",date:typeof r.date==="string"?r.date:typeof r.time==="string"?r.time:"",message:typeof r.message==="string"?r.message:"",body:typeof r.body==="string"?r.body:void 0,parents:Array.isArray(r.parents)?r.parents.filter((g)=>typeof g==="string"):[],refs:Array.isArray(r.refs)?r.refs.filter((g)=>typeof g==="string"):[],files:Vt(r.files),lane:typeof r.lane==="number"?r.lane:void 0})}return l}function pt({output:t,isGraphMode:l,rootPath:c,activeRepo:r}){let[m,g]=n(!1),[x,v]=n(t?.hasMore??t?.data?.length===ge),[N,M]=n(t?.total),w=u(()=>_e(t?.data),[t?.data]),C=Array.isArray(t?.data)?t.data.length:0,[R,P]=n(w),[T,k]=n(C);o(()=>{if(P(w),k(C),v(t?.hasMore??C===ge),typeof t?.total==="number")M(t.total)},[w,C,t?.hasMore,t?.total]);let b=a(async()=>{if(m||!x)return;g(!0);try{let y=new FormData;if(y.set("actionType",l?"graph":"history"),y.set("limit",String(ge)),y.set("skip",String(T)),c)y.set("root",c);if(r)y.set("repo",r);let H=await(await fetch("/api/fs/git",{method:"POST",body:y})).json();if(H.success&&Array.isArray(H.data)){let _=_e(H.data),K=H.data.length;if(P((B)=>{let V=new Set(B.map((U)=>U.hash)),Y=_.filter((U)=>!V.has(U.hash));return[...B,...Y]}),k((B)=>B+K),v(Boolean(H.hasMore??K===ge)),typeof H.total==="number")M(H.total)}else v(!1)}catch(y){console.error("Failed to load more commits:",y)}finally{g(!1)}},[m,x,l,T,c,r]);return{commits:R,hasMore:x,totalCount:N,isLoadingMore:m,handleLoadMore:b}}function ft({onExecuteAction:t,rootPath:l,activeRepo:c}){let[r,m]=n({}),[g,x]=n(new Set),[v,N]=n(new Set),[M,w]=n(new Set),C=a(async(k,b,y)=>{let A=`${k}:${b.file}`;N((H)=>new Set(H).add(A));try{let H=new FormData;if(H.set("actionType","commit_diff"),H.set("hash",k),H.set("file",b.file),y)H.set("full","1");if(l)H.set("root",l);if(c&&c!==".")H.set("repo",c);let K=await(await fetch("/api/fs/git",{method:"POST",body:H})).json();if(K&&typeof K.diff==="string")m((B)=>({...B,[A]:K.diff}));else if(K&&K.error)m((B)=>({...B,[A]:`// Error: ${K.error}`}))}catch(H){console.error("Failed to load file diff:",H);let _=H instanceof Error?H.message:"Network error";m((K)=>({...K,[A]:`// Error loading diff: ${_}`}))}finally{N((H)=>{let _=new Set(H);return _.delete(A),_})}},[l,c]),R=a(async(k,b)=>{let y=`${k}:${b.file}`,A=!g.has(y);if(x((H)=>{let _=new Set(H);if(_.has(y))_.delete(y);else _.add(y);return _}),A&&r[y]===void 0&&!b.diff)await C(k,b,!1)},[g,r,C]),P=a(async(k,b)=>{let y=`${k}:${b.file}`,A=!M.has(y);w((H)=>{let _=new Set(H);if(_.has(y))_.delete(y);else _.add(y);return _}),await C(k,b,A)},[M,C]),T=a((k,b)=>{if(!t)return;if(k==="checkout")t("checkout",void 0,{branch:b.hash});else if(k==="create_branch_here"){let y=window.prompt(`Create new branch at commit ${b.shortHash}:`,`branch-${b.shortHash}`);if(y?.trim())t("create_branch_at",void 0,{branch:y.trim(),hash:b.hash})}else if(k==="cherry_pick"){if(window.confirm(`Cherry-pick commit ${b.shortHash} onto current branch?`))t("cherry_pick",void 0,{hash:b.hash})}else if(k==="revert"){if(window.confirm(`Revert commit ${b.shortHash}?`))t("revert_commit",void 0,{hash:b.hash})}else if(k==="reset"){let y=window.prompt(`Reset current branch to ${b.shortHash} (soft, mixed, hard):`,"soft");if(y&&["soft","mixed","hard"].includes(y.toLowerCase()))t("reset_commit",void 0,{hash:b.hash,mode:y.toLowerCase()})}else if(k==="merge"){if(window.confirm(`Merge commit ${b.shortHash} into current branch?`))t("merge_commit",void 0,{hash:b.hash})}else if(k==="rebase"){if(window.confirm(`Rebase current branch onto commit ${b.shortHash}?`))t("rebase_commit",void 0,{hash:b.hash})}},[t]);return{fileDiffs:r,expandedFiles:g,loadingFiles:v,fullContextFiles:M,handleToggleFile:R,handleToggleContext:P,handleCommitAction:T}}function gt(t){let[l,c]=n({page:t,hash:""}),r=l.page===t?l.hash:"",m=a((g)=>{c((x)=>{let v=x.page===t&&x.hash===g;return{page:t,hash:v?"":g}})},[t]);return{expandedHash:r,toggleExpanded:m}}function je({output:t,onClose:l,onRefresh:c,onExecuteAction:r,rootPath:m,activeRepo:g}){if(o(()=>{if(!t)return;let W=(q)=>{if(q.key==="Escape")l()};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[t,l]),!t)return null;let[x,v]=n(()=>({title:t.title,graph:t.title.toLowerCase().includes("graph")}));if(x.title!==t.title)v({title:t.title,graph:t.title.toLowerCase().includes("graph")});let N=x.graph,M=(W)=>v((q)=>({...q,graph:W})),[w,C]=n(""),{expandedHash:R,toggleExpanded:P}=gt(t),[T,k]=n(!1),{commits:b,hasMore:y,totalCount:A,isLoadingMore:H,handleLoadMore:_}=pt({output:t,isGraphMode:N,rootPath:m,activeRepo:g}),{fileDiffs:K,expandedFiles:B,loadingFiles:V,fullContextFiles:Y,handleToggleFile:U,handleToggleContext:z,handleCommitAction:j}=ft({onExecuteAction:r,rootPath:m,activeRepo:g}),F=u(()=>{if(!w.trim())return b;let W=w.toLowerCase().trim();return b.filter((q)=>q.message.toLowerCase().includes(W)||q.author.toLowerCase().includes(W)||q.shortHash.toLowerCase().includes(W)||q.hash.toLowerCase().includes(W)||q.refs?.some((ne)=>ne.toLowerCase().includes(W)))},[b,w]),se=i(null),re=i(null),xe=i(null),pe=i({}),[ue,ve]=n({}),[Pe,Me]=n(800);o(()=>{let W=xe.current;if(!W||!y||H||w.trim())return;let q=new IntersectionObserver((ne)=>{if(ne[0].isIntersecting)_()},{root:se.current,threshold:0.1});return q.observe(W),()=>q.disconnect()},[y,H,w,_]);let ie=a(()=>{if(!se.current||!re.current)return;let W=se.current.getBoundingClientRect(),q=se.current.scrollTop,ne={};F.forEach((he,Ee)=>{let Ce=pe.current[he.hash];if(Ce){let me=Ce.getBoundingClientRect();ne[he.hash]=me.top+me.height/2-W.top+q}else ne[he.hash]=Ee*60+20}),ve(ne);let De=re.current.offsetHeight;Me(Math.max(De,se.current.clientHeight,600))},[F]);O(()=>{ie();let W=requestAnimationFrame(()=>{ie()});return()=>cancelAnimationFrame(W)},[ie,F,K,B,N,R]),o(()=>{let W=re.current;if(!W)return;let q=new ResizeObserver(()=>{ie()});q.observe(W);for(let ne of Array.from(W.children))q.observe(ne);return()=>q.disconnect()},[ie,F]);let ee=u(()=>Re(F),[F]),Te=u(()=>{let W=0;return ee.forEach((q)=>{if(q>W)W=q}),W},[ee]),ke=18,ye=16,Le=N?(Te+1)*ke+ye*2:36,Ae=()=>{k(!0),c?.(),setTimeout(()=>k(!1),600)};return e("div",{className:"fixed inset-0 z-50 modal-scrim backdrop-blur-xs flex items-center justify-center p-0 lg:p-5",onClick:l,role:"dialog","aria-modal":"true","aria-label":t.title,children:e("div",{className:`glass-overlay bg-paper border-ink/20 shadow-2xl flex flex-col overflow-hidden
4
4
  w-full h-full rounded-none border-0