@kabmo-labs/kabmo 0.39.0 → 0.39.1

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 (99) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +270 -270
  3. package/dist/client/static/js/{CsvGrid-kfcp4sd6.js → CsvGrid-7synegzg.js} +1 -1
  4. package/dist/client/static/js/{DocxView-atff5w38.js → DocxView-v5d9n5yw.js} +1 -1
  5. package/dist/client/static/js/{DrawioView-yfnq4c99.js → DrawioView-ww7y98tt.js} +1 -1
  6. package/dist/client/static/js/{ImageView-nreh25s0.js → ImageView-t3rkypzs.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-0x1q1q5z.js → LayoutWrapper-th2pd4yt.js} +1 -1
  8. package/dist/client/static/js/{Modal-2xqd3sss.js → Modal-qj39shgb.js} +1 -1
  9. package/dist/client/static/js/{PdfView-mk8paxt1.js → PdfView-t9v4datp.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-ner25qxn.js → SessionsView-yqy0a1xg.js} +1 -1
  11. package/dist/client/static/js/{SheetView-s6n3fawm.js → SheetView-6zkxbjd4.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-8bxvz3ez.js → SvgPreview-7rt2p1y1.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-tvvz9fha.js → abnfDiagram-O67JEVCF-888zn5zg.js} +1 -1
  14. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-bybv3wg4.js → architectureDiagram-NJMV4G6O-b04e26rb.js} +1 -1
  15. package/dist/client/static/js/{blockDiagram-BEXU5L5S-h3fs79x6.js → blockDiagram-BEXU5L5S-32ph2m52.js} +1 -1
  16. package/dist/client/static/js/{c4Diagram-YGBWAQC7-h8p3h54v.js → c4Diagram-YGBWAQC7-hwnaa333.js} +1 -1
  17. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-q645r4q6.js → classDiagram-v2-NBCMYWYE-2kg7dqeb.js} +1 -1
  18. package/dist/client/static/js/{cose-bilkent-JH36ORCC-p4mm1zcv.js → cose-bilkent-JH36ORCC-tj2sbtyv.js} +1 -1
  19. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-v2hbc3aq.js → cynefinDiagram-VND7K2PF-wx2y8dhm.js} +1 -1
  20. package/dist/client/static/js/{dagre-6A5THRUB-4edpda33.js → dagre-6A5THRUB-5v3rzdxd.js} +1 -1
  21. package/dist/client/static/js/{diagram-22UHCM2B-b6gp813w.js → diagram-22UHCM2B-7er2jwy1.js} +1 -1
  22. package/dist/client/static/js/{diagram-3UASUU5V-s1f3b0ng.js → diagram-3UASUU5V-2b7nmdha.js} +1 -1
  23. package/dist/client/static/js/{diagram-ATOU4E4O-ga06kjp5.js → diagram-ATOU4E4O-yf61ftn0.js} +1 -1
  24. package/dist/client/static/js/{diagram-CDSNMT55-wdbmv4td.js → diagram-CDSNMT55-cn3rs9xn.js} +1 -1
  25. package/dist/client/static/js/{diagram-MLGK6HIB-fkntefcq.js → diagram-MLGK6HIB-7kvtsj6c.js} +1 -1
  26. package/dist/client/static/js/{diagram-MPIPVDR6-k2zh7edp.js → diagram-MPIPVDR6-g3zg3r5e.js} +1 -1
  27. package/dist/client/static/js/{dockerfile-srcym0bs.js → dockerfile-f9j396wm.js} +1 -1
  28. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4vc4vz9c.js → ebnfDiagram-ZINNZB2B-ft02nzne.js} +1 -1
  29. package/dist/client/static/js/{elk-276RUBZZ-g2ppf1by.js → elk-276RUBZZ-87fvkn2k.js} +1 -1
  30. package/dist/client/static/js/{erDiagram-OPXOYQCR-rmnwkb5q.js → erDiagram-OPXOYQCR-gh9mp6j8.js} +1 -1
  31. package/dist/client/static/js/flowDiagram-KWPJA3E3-6gc6gd1d.js +1 -0
  32. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ptfvae64.js → ganttDiagram-FUAMR5RP-227xs61z.js} +1 -1
  33. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ne9n3cyf.js → gitGraphDiagram-X574FWY7-4671gdym.js} +1 -1
  34. package/dist/client/static/js/{index-a7qccdq2.js → index-28a5kf88.js} +1 -1
  35. package/dist/client/static/js/{index-ymp2wqtc.js → index-35mh9kbs.js} +1 -1
  36. package/dist/client/static/js/{index-3fw3sd10.js → index-4c2zcvem.js} +7 -7
  37. package/dist/client/static/js/{index-jkph8wqq.js → index-4ry8kz8h.js} +1 -1
  38. package/dist/client/static/js/{index-v8vjh5jj.js → index-668chrpq.js} +1 -1
  39. package/dist/client/static/js/{index-8qgwj6m8.js → index-6rs8e8ng.js} +1 -1
  40. package/dist/client/static/js/{index-56w8m083.js → index-7qc2avfy.js} +1 -1
  41. package/dist/client/static/js/{index-5kvvb0zm.js → index-87qandgr.js} +1 -1
  42. package/dist/client/static/js/{index-ntx3bbmb.js → index-8xasfxf3.js} +1 -1
  43. package/dist/client/static/js/{index-gvkc9e32.js → index-d3prrt2q.js} +1 -1
  44. package/dist/client/static/js/{index-4pehdq5h.js → index-f1nqk6z6.js} +1 -1
  45. package/dist/client/static/js/{index-pzqsp5jw.js → index-f73v86a3.js} +1 -1
  46. package/dist/client/static/js/{index-270y5r9k.js → index-fjqp03xe.js} +1 -1
  47. package/dist/client/static/js/{index-mmsszqvn.js → index-fs3pbqwn.js} +1 -1
  48. package/dist/client/static/js/{index-xdqsqhnn.js → index-h8rr48px.js} +1 -1
  49. package/dist/client/static/js/{index-dmd26a1y.js → index-hdd8nqz8.js} +1 -1
  50. package/dist/client/static/js/{index-me7m3516.js → index-j2g39xq7.js} +1 -1
  51. package/dist/client/static/js/{index-dt22v9ns.js → index-jze0zg3z.js} +1 -1
  52. package/dist/client/static/js/{index-m3r0j562.js → index-kkfbd1db.js} +1 -1
  53. package/dist/client/static/js/{index-7h5n5rz4.js → index-m847wafq.js} +1 -1
  54. package/dist/client/static/js/{index-y2prm0xm.js → index-mtadrbxt.js} +1 -1
  55. package/dist/client/static/js/{index-7z63xr1s.js → index-phm1zb8m.js} +1 -1
  56. package/dist/client/static/js/{index-p89z1qmj.js → index-qbnd827h.js} +1 -1
  57. package/dist/client/static/js/{index-8w2tx2k9.js → index-s80x8d58.js} +1 -1
  58. package/dist/client/static/js/{index-ywpdhntc.js → index-tmnnafht.js} +1 -1
  59. package/dist/client/static/js/{index-hh05xd1d.js → index-vb3srfyc.js} +1 -1
  60. package/dist/client/static/js/{index-k61tdd4a.js → index-w0rbyw47.js} +1 -1
  61. package/dist/client/static/js/{index-5a4w58r2.js → index-w0xvdda9.js} +1 -1
  62. package/dist/client/static/js/{index-878d61js.js → index-wfcgqjzr.js} +1 -1
  63. package/dist/client/static/js/{index-pr7gk5eq.js → index-wgvysmnr.js} +1 -1
  64. package/dist/client/static/js/{index-mdxnhndy.js → index-xfr6r539.js} +1 -1
  65. package/dist/client/static/js/{index-k3c3n69j.js → index-xnk1500f.js} +2 -2
  66. package/dist/client/static/js/{index-61qjr1k0.js → index-y5ymgp20.js} +2 -2
  67. package/dist/client/static/js/{index-k5a6r25s.js → index-y91j4t1q.js} +1 -1
  68. package/dist/client/static/js/{infoDiagram-VRGFBTTK-ctfwcm3n.js → infoDiagram-VRGFBTTK-k1jnhhbp.js} +1 -1
  69. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-b0b0pn4y.js → ishikawaDiagram-OU5B5YK6-ar94x2gr.js} +1 -1
  70. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kdq12drs.js → journeyDiagram-ZHPQQLJL-ntfp0w54.js} +1 -1
  71. package/dist/client/static/js/{kanban-definition-PNTS6WVX-65x6xn2q.js → kanban-definition-PNTS6WVX-q5rsr6j3.js} +1 -1
  72. package/dist/client/static/js/{mermaid.core-0fq63jpa.js → mermaid.core-0gafsqrm.js} +2 -2
  73. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-p86myex3.js → mindmap-definition-NLK3R4M7-jgz6nyhk.js} +1 -1
  74. package/dist/client/static/js/one-dark-pro-n0as47q7.js +1 -0
  75. package/dist/client/static/js/one-light-05nw3mzj.js +1 -0
  76. package/dist/client/static/js/{pegDiagram-GJSIUBJH-p2hkk9xb.js → pegDiagram-GJSIUBJH-b3e9ma2c.js} +1 -1
  77. package/dist/client/static/js/{pieDiagram-5QR66LMP-bza19wkx.js → pieDiagram-5QR66LMP-66mn2qnt.js} +1 -1
  78. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-bxqec9w1.js → quadrantDiagram-O4NWA36T-n7warg0e.js} +1 -1
  79. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-1g3hx3sm.js → railroadDiagram-XR7U4H2S-k8j43rxj.js} +1 -1
  80. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-qbjjm48v.js → requirementDiagram-PLB6GJNP-ef2v7nyq.js} +1 -1
  81. package/dist/client/static/js/{rust-jatm47v6.js → rust-jvkbr060.js} +1 -1
  82. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-t2ythbh7.js → sankeyDiagram-IPEJSGJF-3njbd1yd.js} +1 -1
  83. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-mqsfek2j.js → sequenceDiagram-PO4LG4MO-k2wqc0qt.js} +1 -1
  84. package/dist/client/static/js/{sizeCapture-INFHLROL-xj67pgds.js → sizeCapture-INFHLROL-cpnd12ee.js} +1 -1
  85. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-gj4fezak.js → stateDiagram-v2-GCMORJYK-1ydpxaeg.js} +1 -1
  86. package/dist/client/static/js/{swimlanes-2SLR337P-pgtdd1pk.js → swimlanes-2SLR337P-4md43da2.js} +1 -1
  87. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-zk37paj9.js → swimlanesDiagram-TC7HE7FX-d48g5gjf.js} +1 -1
  88. package/dist/client/static/js/{timeline-definition-EJHVYXUP-q013vdd1.js → timeline-definition-EJHVYXUP-sp32bf3e.js} +1 -1
  89. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-7swsbqnq.js → usecaseDiagram-POWQR4AR-p2ssettn.js} +1 -1
  90. package/dist/client/static/js/{vennDiagram-UO4OBE2U-9dygxdxf.js → vennDiagram-UO4OBE2U-ejqq8b82.js} +1 -1
  91. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-aaaa9kj3.js → wardleyDiagram-VNRHLVJA-tkk79rsn.js} +1 -1
  92. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-tamf39gx.js → xychartDiagram-PMCCYNJV-zhgrsqpb.js} +1 -1
  93. package/package.json +1 -1
  94. package/src/server/lib/terminal/attach-replay.test.ts +80 -17
  95. package/src/server/plugins/static.test.ts +23 -1
  96. package/src/server/plugins/static.ts +24 -1
  97. package/dist/client/static/js/flowDiagram-KWPJA3E3-jvrvhb9d.js +0 -1
  98. package/dist/client/static/js/one-dark-pro-c4q810z4.js +0 -1
  99. package/dist/client/static/js/one-light-czk9dzya.js +0 -1
@@ -1 +1 @@
1
- import{d,e,Gg,we,E,mt,at}from"./index-3fw3sd10.js";import{ra,pu,Cs,mu,fu}from"./index-5kvvb0zm.js";function u(t,r){if(!t)return r;if(!r)return t;let n=Date.parse(t.generatedAt),s=Date.parse(r.generatedAt);if(Number.isNaN(n)||Number.isNaN(s))return t;return s>n?r:t}function R({className:t="",active:r=!0}){let{report:n,isLoading:s,error:o,reload:i}=fu(),l=we(Gg,{enabled:r}),a=u(l.data,n),p=a?Cs(a):[];if(o&&!a)return e("div",{className:`flex h-full w-full flex-col items-center justify-center gap-2 p-8 text-center text-xs ${t}`,children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-error text-xs",children:o}),e("button",{type:"button",onClick:()=>i(),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Try again"})]});if(!a)return e("div",{className:`flex h-full w-full items-center justify-center text-ink/40 text-xs ${t}`,children:"Loading provider usage..."});return e("div",{className:`flex h-full w-full min-w-0 min-h-0 flex-col overflow-hidden bg-paper text-xs text-ink ${t}`,children:[e(mt,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Usage"}),e("span",{className:"text-[11px] text-ink/50 truncate",children:["Updated ",ra(a.generatedAt)]}),a.isMock&&e("span",{className:"text-[10px] font-mono uppercase tracking-wider bg-ink/5 border border-ink/15 rounded px-1.5 py-0.5 text-ink/60",children:"Mock"})]}),right:e(at,{label:"Refresh usage",onClick:()=>i({force:!0}),busy:s||l.refreshing,disabled:s})}),e("div",{className:"flex-1 min-w-0 min-h-0 w-full overflow-y-auto scrollbar-overlay-container p-3.5 space-y-4",children:[o&&e("p",{className:"text-error text-xs",children:o}),p.length>0?p.map((m)=>e(pu,{summary:m.summary},m.id)):e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:"No provider credentials detected. Add an API key in Settings → Providers and it will appear here."}),e(mu,{})]})]})}export{R as UsagePanel};
1
+ import{d,e,Gg,we,E,mt,at}from"./index-4c2zcvem.js";import{ra,pu,Cs,mu,fu}from"./index-87qandgr.js";function u(t,r){if(!t)return r;if(!r)return t;let n=Date.parse(t.generatedAt),s=Date.parse(r.generatedAt);if(Number.isNaN(n)||Number.isNaN(s))return t;return s>n?r:t}function R({className:t="",active:r=!0}){let{report:n,isLoading:s,error:o,reload:i}=fu(),l=we(Gg,{enabled:r}),a=u(l.data,n),p=a?Cs(a):[];if(o&&!a)return e("div",{className:`flex h-full w-full flex-col items-center justify-center gap-2 p-8 text-center text-xs ${t}`,children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-error text-xs",children:o}),e("button",{type:"button",onClick:()=>i(),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Try again"})]});if(!a)return e("div",{className:`flex h-full w-full items-center justify-center text-ink/40 text-xs ${t}`,children:"Loading provider usage..."});return e("div",{className:`flex h-full w-full min-w-0 min-h-0 flex-col overflow-hidden bg-paper text-xs text-ink ${t}`,children:[e(mt,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Usage"}),e("span",{className:"text-[11px] text-ink/50 truncate",children:["Updated ",ra(a.generatedAt)]}),a.isMock&&e("span",{className:"text-[10px] font-mono uppercase tracking-wider bg-ink/5 border border-ink/15 rounded px-1.5 py-0.5 text-ink/60",children:"Mock"})]}),right:e(at,{label:"Refresh usage",onClick:()=>i({force:!0}),busy:s||l.refreshing,disabled:s})}),e("div",{className:"flex-1 min-w-0 min-h-0 w-full overflow-y-auto scrollbar-overlay-container p-3.5 space-y-4",children:[o&&e("p",{className:"text-error text-xs",children:o}),p.length>0?p.map((m)=>e(pu,{summary:m.summary},m.id)):e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:"No provider credentials detected. Add an API key in Settings → Providers and it will appear here."}),e(mu,{})]})]})}export{R as UsagePanel};
@@ -1,2 +1,2 @@
1
- import{t,Ut}from"./index-61qjr1k0.js";var N=5,R=0.00001,X=2,Y=0.6,w=0.000001;function P(n){let o=[];for(let r=0;r<n.length-1;r++)o.push({a:n[r],b:n[r+1]});return o}t(P,"buildSegmentList");function T(n,o,r,a){let c=o.x-n.x,s=o.y-n.y,u=a.x-r.x,f=a.y-r.y,d=c*f-s*u;if(d===0)return null;let e=r.x-n.x,i=r.y-n.y,h=(e*f-i*u)/d,p=(e*s-i*c)/d;if(h<=w||h>=1-w||p<=w||p>=1-w)return null;return{point:{x:n.x+h*c,y:n.y+h*s},tA:h,tB:p}}t(T,"segmentIntersection");function v(n){return Math.abs(n.b.x-n.a.x)>=Math.abs(n.b.y-n.a.y)}t(v,"isHorizontalSeg");function B(n,o,r){if(n.curve!=="rounded")return!1;let a=n.points,c=a[o],s=a[o+1];if(!c||!s)return!1;let u=Math.hypot(s.x-c.x,s.y-c.y),f=r*u,d=o>0?L(a[o-1],c,s,N):null;if(d&&f<d.cutLen)return!0;let e=o+2<a.length?L(c,s,a[o+2],N):null;return e!==null&&u-f<e.cutLen}t(B,"crossingSitsInRoundedCorner");function C(n){let o=[];for(let r=0;r<n.length;r++){let a=n[r],c=P(a.points);for(let s=r+1;s<n.length;s++){let u=n[s],f=P(u.points);for(let[d,e]of c.entries())for(let[i,h]of f.entries()){let p=T(e.a,e.b,h.a,h.b);if(!p)continue;if(B(a,d,p.tA)||B(u,i,p.tB))continue;let g=v(e),S=v(h);if(g!==S?g:!1)o.push({jumpEdgeId:a.id,otherEdgeId:u.id,segIndex:d,t:p.tA,point:p.point});else o.push({jumpEdgeId:u.id,otherEdgeId:a.id,segIndex:i,t:p.tB,point:p.point})}}}return o}t(C,"findEdgeIntersections");function M(n){let o=Math.round(n*1000)/1000;return Number.isInteger(o)?`${o}`:`${o}`}t(M,"fmt");function A(n){return`${M(n.x)},${M(n.y)}`}t(A,"pointToString");function D(n){let o=n.b.x-n.a.x,r=n.b.y-n.a.y;if(Math.abs(o)>=Math.abs(r))return o>=0?1:0;return r>=0?1:0}t(D,"getArcSweepFlag");function _(n,o){if(n.length<2)return n.map((s)=>({...s}));let r=n.map((s)=>({...s})),a=o.arrowTypeStart&&Ut[o.arrowTypeStart];if(a){let s=n[0],u=n[1],f=Math.atan2(u.y-s.y,u.x-s.x);r[0].x=s.x+a*Math.cos(f),r[0].y=s.y+a*Math.sin(f)}let c=o.arrowTypeEnd&&Ut[o.arrowTypeEnd];if(c){let s=n.length,u=n[s-2],f=n[s-1],d=Math.atan2(f.y-u.y,f.x-u.x);r[s-1].x=f.x-c*Math.cos(d),r[s-1].y=f.y-c*Math.sin(d)}return r}t(_,"applyMarkerOffsets");function k(n,o,r,a,c){let s=n.point.x,u=n.point.y,f={x:s-o*n.r,y:u-r*n.r},d={x:s+o*n.r,y:u+r*n.r},e=[`L${A(f)}`];if(c==="arc")e.push(`A${M(n.r)},${M(n.r)} 0 0 ${a} ${A(d)}`);else e.push(`M${A(d)}`);return e}t(k,"emitJump");function L(n,o,r,a){let c=o.x-n.x,s=o.y-n.y,u=r.x-o.x,f=r.y-o.y,d=Math.hypot(c,s),e=Math.hypot(u,f);if(d<R||e<R)return null;let i=c/d,h=s/d,p=u/e,g=f/e,S=i*p+h*g,b=Math.max(-1,Math.min(1,S)),x=Math.acos(b);if(x<R||Math.abs(Math.PI-x)<R)return null;let y=Math.min(a/Math.sin(x/2),d/2,e/2);return{startX:o.x-i*y,startY:o.y-h*y,endX:o.x+p*y,endY:o.y+g*y,ctrlX:o.x,ctrlY:o.y,cutLen:y}}t(L,"computeRoundedCorner");function H(n,o,r){let a=n.points;if(a.length<2)return"";let c=_(a,n),s=n.curve==="rounded",u=P(c),f=new Map;for(let e of o){let i=u[e.segIndex];if(!i)continue;let h=Math.hypot(i.b.x-i.a.x,i.b.y-i.a.y),p=f.get(e.segIndex)??[];p.push({t:e.t,point:e.point,d:e.t*h,r:r.jumpRadius}),f.set(e.segIndex,p)}let d=[`M${A(c[0])}`];for(let e=0;e<u.length;e++){let i=u[e],h=Math.hypot(i.b.x-i.a.x,i.b.y-i.a.y),p=h===0?0:(i.b.x-i.a.x)/h,g=h===0?0:(i.b.y-i.a.y)/h,S=D(i),b=0;if(s&&e>0){let l=L(c[e-1],c[e],c[e+1]??c[e],N);if(l)b=l.cutLen}let x=h,y=null;if(s&&e<u.length-1){if(y=L(c[e],c[e+1],c[e+2]??c[e+1],N),y)x=h-y.cutLen}let I=r.jumpRadius*Y,m=[...f.get(e)??[]].sort((l,E)=>l.t-E.t).filter((l)=>{let E=Math.min(l.d-b,x-l.d)-X;return l.r=Math.min(l.r,E),l.r>=I});for(let l=0;l<m.length-1;l++){let E=m[l+1].d-m[l].d;if(m[l].r+m[l+1].r>E){let O=E/2;m[l].r=Math.min(m[l].r,O),m[l+1].r=Math.min(m[l+1].r,O)}}for(let l of m){if(l.r<I)continue;d.push(...k(l,p,g,S,r.jumpStyle))}if(s&&y)d.push(`L${M(y.startX)},${M(y.startY)}`),d.push(`Q${M(y.ctrlX)},${M(y.ctrlY)} ${M(y.endX)},${M(y.endY)}`);else d.push(`L${A(i.b)}`)}return d.join(" ")}t(H,"rewriteEdgePath");function J(n){return/^[\d\s+,.LMelm-]*$/.test(n)}t(J,"isStraightPath");function U(n){if(!n)return!0;return n==="linear"||n==="rounded"||n==="step"||n==="stepBefore"||n==="stepAfter"}t(U,"curveSupportsLineHops");function j(n){if(!n)return null;try{let o=typeof atob==="function"?atob(n):Buffer.from(n,"base64").toString(),r=JSON.parse(o);if(!Array.isArray(r))return null;let a=[];for(let c of r)if(c&&typeof c.x==="number"&&typeof c.y==="number")a.push({x:c.x,y:c.y});return a.length>=2?a:null}catch{return null}}t(j,"decodeDataPoints");function vl(n,o,r){if(!r.enabled)return;let a=n.node();if(!a)return;let c=new Map;for(let e of o)c.set(e.id,e);let s=new Map;for(let e of a.querySelectorAll("path[data-id]")){let i=e.getAttribute("data-id");if(i!==null&&!s.has(i))s.set(i,e)}let u=[];for(let e of o){let i=s.get(e.id);if(!i)continue;let p=j(i.getAttribute("data-points"))??e.points;u.push({...e,points:p})}let f=C(u);if(f.length===0)return;let d=new Map;for(let e of f){let i=d.get(e.jumpEdgeId)??[];i.push(e),d.set(e.jumpEdgeId,i)}for(let e of u){let i=d.get(e.id);if(!i||i.length===0)continue;let p=c.get(e.id)?.curve;if(p!==void 0&&!U(p))continue;let g=s.get(e.id);if(!g)continue;if(p===void 0){let m=g.getAttribute("d")??"";if(!J(m))continue}let S=g.getAttribute("style")??"",b=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(S),x=b?Number.parseFloat(b[1]):null,y=b?Number.parseFloat(b[2]):null,I=H(e,i,r);if(g.setAttribute("d",I),x!==null&&y!==null&&typeof g.getTotalLength==="function"){let m=g.getTotalLength(),l=Math.max(0,m-x-y),E=`0 ${x} ${l} ${y}`,O=S.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${E};`).replace(/;\s*;+/g,";");g.setAttribute("style",O)}}}t(vl,"applyLineJumpsToSvg");
1
+ import{t,Ut}from"./index-y5ymgp20.js";var N=5,R=0.00001,X=2,Y=0.6,w=0.000001;function P(n){let o=[];for(let r=0;r<n.length-1;r++)o.push({a:n[r],b:n[r+1]});return o}t(P,"buildSegmentList");function T(n,o,r,a){let c=o.x-n.x,s=o.y-n.y,u=a.x-r.x,f=a.y-r.y,d=c*f-s*u;if(d===0)return null;let e=r.x-n.x,i=r.y-n.y,h=(e*f-i*u)/d,p=(e*s-i*c)/d;if(h<=w||h>=1-w||p<=w||p>=1-w)return null;return{point:{x:n.x+h*c,y:n.y+h*s},tA:h,tB:p}}t(T,"segmentIntersection");function v(n){return Math.abs(n.b.x-n.a.x)>=Math.abs(n.b.y-n.a.y)}t(v,"isHorizontalSeg");function B(n,o,r){if(n.curve!=="rounded")return!1;let a=n.points,c=a[o],s=a[o+1];if(!c||!s)return!1;let u=Math.hypot(s.x-c.x,s.y-c.y),f=r*u,d=o>0?L(a[o-1],c,s,N):null;if(d&&f<d.cutLen)return!0;let e=o+2<a.length?L(c,s,a[o+2],N):null;return e!==null&&u-f<e.cutLen}t(B,"crossingSitsInRoundedCorner");function C(n){let o=[];for(let r=0;r<n.length;r++){let a=n[r],c=P(a.points);for(let s=r+1;s<n.length;s++){let u=n[s],f=P(u.points);for(let[d,e]of c.entries())for(let[i,h]of f.entries()){let p=T(e.a,e.b,h.a,h.b);if(!p)continue;if(B(a,d,p.tA)||B(u,i,p.tB))continue;let g=v(e),S=v(h);if(g!==S?g:!1)o.push({jumpEdgeId:a.id,otherEdgeId:u.id,segIndex:d,t:p.tA,point:p.point});else o.push({jumpEdgeId:u.id,otherEdgeId:a.id,segIndex:i,t:p.tB,point:p.point})}}}return o}t(C,"findEdgeIntersections");function M(n){let o=Math.round(n*1000)/1000;return Number.isInteger(o)?`${o}`:`${o}`}t(M,"fmt");function A(n){return`${M(n.x)},${M(n.y)}`}t(A,"pointToString");function D(n){let o=n.b.x-n.a.x,r=n.b.y-n.a.y;if(Math.abs(o)>=Math.abs(r))return o>=0?1:0;return r>=0?1:0}t(D,"getArcSweepFlag");function _(n,o){if(n.length<2)return n.map((s)=>({...s}));let r=n.map((s)=>({...s})),a=o.arrowTypeStart&&Ut[o.arrowTypeStart];if(a){let s=n[0],u=n[1],f=Math.atan2(u.y-s.y,u.x-s.x);r[0].x=s.x+a*Math.cos(f),r[0].y=s.y+a*Math.sin(f)}let c=o.arrowTypeEnd&&Ut[o.arrowTypeEnd];if(c){let s=n.length,u=n[s-2],f=n[s-1],d=Math.atan2(f.y-u.y,f.x-u.x);r[s-1].x=f.x-c*Math.cos(d),r[s-1].y=f.y-c*Math.sin(d)}return r}t(_,"applyMarkerOffsets");function k(n,o,r,a,c){let s=n.point.x,u=n.point.y,f={x:s-o*n.r,y:u-r*n.r},d={x:s+o*n.r,y:u+r*n.r},e=[`L${A(f)}`];if(c==="arc")e.push(`A${M(n.r)},${M(n.r)} 0 0 ${a} ${A(d)}`);else e.push(`M${A(d)}`);return e}t(k,"emitJump");function L(n,o,r,a){let c=o.x-n.x,s=o.y-n.y,u=r.x-o.x,f=r.y-o.y,d=Math.hypot(c,s),e=Math.hypot(u,f);if(d<R||e<R)return null;let i=c/d,h=s/d,p=u/e,g=f/e,S=i*p+h*g,b=Math.max(-1,Math.min(1,S)),x=Math.acos(b);if(x<R||Math.abs(Math.PI-x)<R)return null;let y=Math.min(a/Math.sin(x/2),d/2,e/2);return{startX:o.x-i*y,startY:o.y-h*y,endX:o.x+p*y,endY:o.y+g*y,ctrlX:o.x,ctrlY:o.y,cutLen:y}}t(L,"computeRoundedCorner");function H(n,o,r){let a=n.points;if(a.length<2)return"";let c=_(a,n),s=n.curve==="rounded",u=P(c),f=new Map;for(let e of o){let i=u[e.segIndex];if(!i)continue;let h=Math.hypot(i.b.x-i.a.x,i.b.y-i.a.y),p=f.get(e.segIndex)??[];p.push({t:e.t,point:e.point,d:e.t*h,r:r.jumpRadius}),f.set(e.segIndex,p)}let d=[`M${A(c[0])}`];for(let e=0;e<u.length;e++){let i=u[e],h=Math.hypot(i.b.x-i.a.x,i.b.y-i.a.y),p=h===0?0:(i.b.x-i.a.x)/h,g=h===0?0:(i.b.y-i.a.y)/h,S=D(i),b=0;if(s&&e>0){let l=L(c[e-1],c[e],c[e+1]??c[e],N);if(l)b=l.cutLen}let x=h,y=null;if(s&&e<u.length-1){if(y=L(c[e],c[e+1],c[e+2]??c[e+1],N),y)x=h-y.cutLen}let I=r.jumpRadius*Y,m=[...f.get(e)??[]].sort((l,E)=>l.t-E.t).filter((l)=>{let E=Math.min(l.d-b,x-l.d)-X;return l.r=Math.min(l.r,E),l.r>=I});for(let l=0;l<m.length-1;l++){let E=m[l+1].d-m[l].d;if(m[l].r+m[l+1].r>E){let O=E/2;m[l].r=Math.min(m[l].r,O),m[l+1].r=Math.min(m[l+1].r,O)}}for(let l of m){if(l.r<I)continue;d.push(...k(l,p,g,S,r.jumpStyle))}if(s&&y)d.push(`L${M(y.startX)},${M(y.startY)}`),d.push(`Q${M(y.ctrlX)},${M(y.ctrlY)} ${M(y.endX)},${M(y.endY)}`);else d.push(`L${A(i.b)}`)}return d.join(" ")}t(H,"rewriteEdgePath");function J(n){return/^[\d\s+,.LMelm-]*$/.test(n)}t(J,"isStraightPath");function U(n){if(!n)return!0;return n==="linear"||n==="rounded"||n==="step"||n==="stepBefore"||n==="stepAfter"}t(U,"curveSupportsLineHops");function j(n){if(!n)return null;try{let o=typeof atob==="function"?atob(n):Buffer.from(n,"base64").toString(),r=JSON.parse(o);if(!Array.isArray(r))return null;let a=[];for(let c of r)if(c&&typeof c.x==="number"&&typeof c.y==="number")a.push({x:c.x,y:c.y});return a.length>=2?a:null}catch{return null}}t(j,"decodeDataPoints");function vl(n,o,r){if(!r.enabled)return;let a=n.node();if(!a)return;let c=new Map;for(let e of o)c.set(e.id,e);let s=new Map;for(let e of a.querySelectorAll("path[data-id]")){let i=e.getAttribute("data-id");if(i!==null&&!s.has(i))s.set(i,e)}let u=[];for(let e of o){let i=s.get(e.id);if(!i)continue;let p=j(i.getAttribute("data-points"))??e.points;u.push({...e,points:p})}let f=C(u);if(f.length===0)return;let d=new Map;for(let e of f){let i=d.get(e.jumpEdgeId)??[];i.push(e),d.set(e.jumpEdgeId,i)}for(let e of u){let i=d.get(e.id);if(!i||i.length===0)continue;let p=c.get(e.id)?.curve;if(p!==void 0&&!U(p))continue;let g=s.get(e.id);if(!g)continue;if(p===void 0){let m=g.getAttribute("d")??"";if(!J(m))continue}let S=g.getAttribute("style")??"",b=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(S),x=b?Number.parseFloat(b[1]):null,y=b?Number.parseFloat(b[2]):null,I=H(e,i,r);if(g.setAttribute("d",I),x!==null&&y!==null&&typeof g.getTotalLength==="function"){let m=g.getTotalLength(),l=Math.max(0,m-x-y),E=`0 ${x} ${l} ${y}`,O=S.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${E};`).replace(/;\s*;+/g,";");g.setAttribute("style",O)}}}t(vl,"applyLineJumpsToSvg");
2
2
  export{vl};
@@ -1 +1 @@
1
- import{d,n,o,i,u,a,le,e,Cp,we,S,s,f,B,ie,ba,re,de,b,mt,at,pe,ot,Yg,ii}from"./index-3fw3sd10.js";var se={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},H=s(se);function O(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function J({used:l,limit:r,percent:c}){let x=l.toLocaleString(),m=r.toLocaleString(),t=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[x," / ",m]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${t}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[t.toFixed(1),"% used"]})]})}function L(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function Z({open:l,onClose:r,breakdown:c,costFormatted:x}){let m=i(null);if(pe(m,r),!l)return null;let t=c?[{label:"Total Cost",value:L(c.total),strong:!0},{label:"Input (cache miss)",value:L(c.input)},{label:"Output",value:L(c.output)},{label:"Cache Read (cache hit)",value:L(c.cacheRead)},{label:"Cache Write",value:L(c.cacheWrite)}]:[{label:"Total Cost",value:x??"$0.01",strong:!0}];return e("div",{ref:m,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:t.map((h)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:h.label}),e("span",{className:`${h.strong?"font-semibold text-ink":"text-ink/80"}`,children:h.value})]},h.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:x,cacheHitAverage:m,costBreakdown:t}){let[h,g]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(ot,{variant:"compact",label:"Messages",value:l}),e(ot,{variant:"compact",label:"User",value:r}),e(ot,{variant:"compact",label:"Assistant",value:c}),e(ot,{variant:"compact",label:"Cache Hit",value:m!==void 0?`${m.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>g(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(de,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:x}),e(Z,{open:h,onClose:()=>g(!1),breakdown:t,costFormatted:x})]})]})]})}function z({input:l,output:r,reasoning:c,cacheRead:x,cacheWrite:m,cacheHitPercent:t}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(ot,{variant:"compact",label:"In",value:l.toLocaleString()}),e(ot,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(ot,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(ot,{variant:"compact",label:"Cache",value:`${x.toLocaleString()}/${m.toLocaleString()}`}),e(ot,{variant:"compact",label:"Hit",value:`${t.toFixed(1)}%`})]})]})}function Q({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:x}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${x}%`},title:`Other: ${x}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",x,"%"]})]})]})]})}function G({data:l}){ii();let[r,c]=n(!1),x=i(null),m=i(null),t=JSON.stringify(l,null,2),h=Yg(t),g=a((y)=>{let v=m.current;if(!v)return;v.scrollLeft=y.currentTarget.scrollLeft,v.scrollTop=y.currentTarget.scrollTop},[]),w=a(async(y)=>{y.stopPropagation();try{await navigator.clipboard.writeText(t)}catch{let v=document.createElement("textarea");v.value=t,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v)}c(!0),setTimeout(()=>c(!1),2000)},[t]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",t.length," chars"]}),e("button",{type:"button",onClick:w,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(re,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:h}}),e("pre",{ref:x,onScroll:g,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:t})})]})]})}var D=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],_=20;function K(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function q(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,x=r>0?l.slice(r+1):"";return x?`${c} · ${x}`:c}function Y(l,r){if(r<=7)return Array.from({length:r},(h,g)=>g+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((h)=>c.add(h));if(l>=r-2)[r-3,r-2,r-1].forEach((h)=>c.add(h));let x=[...c].filter((h)=>h>=1&&h<=r).sort((h,g)=>h-g),m=[],t=0;for(let h of x){if(h-t>1)m.push("…");m.push(h),t=h}return m}function X({sessionId:l,refreshKey:r=0}){let[c,x]=S("context.rawExpandedIds",{}),[m,t]=S("context.rawFilterRole","all"),[h,g]=n(1),[w,y]=n([]),[v,I]=n(0),[R,C]=n(!1),W=i(0),E=i(!1),j=a((p)=>{if(typeof window>"u")return;let k=++W.current;if(!p?.silent)C(!0);let P=new URLSearchParams({page:String(h),pageSize:String(_),role:m});if(l)P.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${P.toString()}`).then((N)=>N.ok?N.json():null).then((N)=>{if(E.current||k!==W.current)return;y(N&&Array.isArray(N.items)?N.items:[]),I(N&&Number.isFinite(N.filteredTotal)?N.filteredTotal:0)}).catch(()=>{if(E.current||k!==W.current)return;y([]),I(0)}).finally(()=>{if(!p?.silent&&k===W.current)C(!1)})},[l,h,m]);o(()=>(E.current=!1,j(),()=>{E.current=!0}),[j,r]);let T=Math.max(1,Math.ceil(v/_)),M=Math.min(h,T),U=(p)=>g(Math.min(Math.max(1,p),T)),ee=(p)=>{x((k)=>({...k,[p]:!k[p]}))},te=()=>{if(w.every((k)=>c[k.id]))x({});else{let k={};w.forEach((P)=>{k[P.id]=!0}),x(k)}},A=u(()=>{let p=[];for(let k of w){let P=k.info.modelID;if(!P||p.includes(P))continue;p.push(P)}return p},[w]),F=(p)=>p?D[K(p)%D.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[A.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:A.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p)}`}),e("span",{children:q(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:v})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{t("all"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{t("assistant"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{t("user"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:te,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(H,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!R&&w.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):w.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${R?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>ee(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(ie,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(G,{data:p.rawPayload})})]},p.id)})}),T>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(M-1)*_+1,"–",Math.min(M*_,v)," of ",v]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:M<=1,onClick:()=>U(M-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(ba,{size:14})}),Y(M,T).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>U(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===M?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:M>=T,onClick:()=>U(M+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(ie,{size:14})})]})]})]})}function pt({className:l="",enabled:r=!0,refreshKey:c=0}){let[x]=le(),m=x.get("sessionId"),[t,h]=n(()=>O(m||"default","Session not started")),g=i(!1),w=a(()=>{if(typeof window>"u")return;let R=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${R}`).then((C)=>C.ok?C.json():null).then((C)=>{if(!g.current&&C&&C.telemetry)h(C.telemetry)}).catch((C)=>{if(!g.current)console.warn("Failed to fetch context telemetry:",C)})},[m]);o(()=>{if(g.current=!1,!r)return;return w(),()=>{g.current=!0}},[r,c,w]);let y=we(m?Cp(m):null,{enabled:r}),[v,I]=n(0);if(o(()=>{if(y.data)h(y.data),I((R)=>R+1)},[y.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e(mt,{left:e(d,{children:[e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle}),e("span",{className:"text-[11px] text-ink/50 truncate font-mono",children:t.timestamp})]}),right:e(at,{label:"Refresh context telemetry",onClick:()=>{y.refresh(),w()},busy:y.refreshing,disabled:!r})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(J,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(z,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(Q,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(X,{sessionId:m,refreshKey:c+v})]})]})}export{pt as ContextPanel};
1
+ import{d,n,o,i,u,a,le,e,Cp,we,S,s,f,B,ie,ba,re,de,b,mt,at,pe,ot,Yg,ii}from"./index-4c2zcvem.js";var se={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},H=s(se);function O(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function J({used:l,limit:r,percent:c}){let x=l.toLocaleString(),m=r.toLocaleString(),t=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[x," / ",m]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${t}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[t.toFixed(1),"% used"]})]})}function L(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function Z({open:l,onClose:r,breakdown:c,costFormatted:x}){let m=i(null);if(pe(m,r),!l)return null;let t=c?[{label:"Total Cost",value:L(c.total),strong:!0},{label:"Input (cache miss)",value:L(c.input)},{label:"Output",value:L(c.output)},{label:"Cache Read (cache hit)",value:L(c.cacheRead)},{label:"Cache Write",value:L(c.cacheWrite)}]:[{label:"Total Cost",value:x??"$0.01",strong:!0}];return e("div",{ref:m,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:t.map((h)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:h.label}),e("span",{className:`${h.strong?"font-semibold text-ink":"text-ink/80"}`,children:h.value})]},h.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:x,cacheHitAverage:m,costBreakdown:t}){let[h,g]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(ot,{variant:"compact",label:"Messages",value:l}),e(ot,{variant:"compact",label:"User",value:r}),e(ot,{variant:"compact",label:"Assistant",value:c}),e(ot,{variant:"compact",label:"Cache Hit",value:m!==void 0?`${m.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>g(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(de,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:x}),e(Z,{open:h,onClose:()=>g(!1),breakdown:t,costFormatted:x})]})]})]})}function z({input:l,output:r,reasoning:c,cacheRead:x,cacheWrite:m,cacheHitPercent:t}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(ot,{variant:"compact",label:"In",value:l.toLocaleString()}),e(ot,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(ot,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(ot,{variant:"compact",label:"Cache",value:`${x.toLocaleString()}/${m.toLocaleString()}`}),e(ot,{variant:"compact",label:"Hit",value:`${t.toFixed(1)}%`})]})]})}function Q({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:x}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${x}%`},title:`Other: ${x}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",x,"%"]})]})]})]})}function G({data:l}){ii();let[r,c]=n(!1),x=i(null),m=i(null),t=JSON.stringify(l,null,2),h=Yg(t),g=a((y)=>{let v=m.current;if(!v)return;v.scrollLeft=y.currentTarget.scrollLeft,v.scrollTop=y.currentTarget.scrollTop},[]),w=a(async(y)=>{y.stopPropagation();try{await navigator.clipboard.writeText(t)}catch{let v=document.createElement("textarea");v.value=t,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v)}c(!0),setTimeout(()=>c(!1),2000)},[t]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",t.length," chars"]}),e("button",{type:"button",onClick:w,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(re,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:h}}),e("pre",{ref:x,onScroll:g,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:t})})]})]})}var D=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],_=20;function K(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function q(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,x=r>0?l.slice(r+1):"";return x?`${c} · ${x}`:c}function Y(l,r){if(r<=7)return Array.from({length:r},(h,g)=>g+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((h)=>c.add(h));if(l>=r-2)[r-3,r-2,r-1].forEach((h)=>c.add(h));let x=[...c].filter((h)=>h>=1&&h<=r).sort((h,g)=>h-g),m=[],t=0;for(let h of x){if(h-t>1)m.push("…");m.push(h),t=h}return m}function X({sessionId:l,refreshKey:r=0}){let[c,x]=S("context.rawExpandedIds",{}),[m,t]=S("context.rawFilterRole","all"),[h,g]=n(1),[w,y]=n([]),[v,I]=n(0),[R,C]=n(!1),W=i(0),E=i(!1),j=a((p)=>{if(typeof window>"u")return;let k=++W.current;if(!p?.silent)C(!0);let P=new URLSearchParams({page:String(h),pageSize:String(_),role:m});if(l)P.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${P.toString()}`).then((N)=>N.ok?N.json():null).then((N)=>{if(E.current||k!==W.current)return;y(N&&Array.isArray(N.items)?N.items:[]),I(N&&Number.isFinite(N.filteredTotal)?N.filteredTotal:0)}).catch(()=>{if(E.current||k!==W.current)return;y([]),I(0)}).finally(()=>{if(!p?.silent&&k===W.current)C(!1)})},[l,h,m]);o(()=>(E.current=!1,j(),()=>{E.current=!0}),[j,r]);let T=Math.max(1,Math.ceil(v/_)),M=Math.min(h,T),U=(p)=>g(Math.min(Math.max(1,p),T)),ee=(p)=>{x((k)=>({...k,[p]:!k[p]}))},te=()=>{if(w.every((k)=>c[k.id]))x({});else{let k={};w.forEach((P)=>{k[P.id]=!0}),x(k)}},A=u(()=>{let p=[];for(let k of w){let P=k.info.modelID;if(!P||p.includes(P))continue;p.push(P)}return p},[w]),F=(p)=>p?D[K(p)%D.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[A.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:A.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p)}`}),e("span",{children:q(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:v})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{t("all"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{t("assistant"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{t("user"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:te,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(H,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!R&&w.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):w.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${R?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>ee(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(ie,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(G,{data:p.rawPayload})})]},p.id)})}),T>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(M-1)*_+1,"–",Math.min(M*_,v)," of ",v]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:M<=1,onClick:()=>U(M-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(ba,{size:14})}),Y(M,T).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>U(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===M?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:M>=T,onClick:()=>U(M+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(ie,{size:14})})]})]})]})}function pt({className:l="",enabled:r=!0,refreshKey:c=0}){let[x]=le(),m=x.get("sessionId"),[t,h]=n(()=>O(m||"default","Session not started")),g=i(!1),w=a(()=>{if(typeof window>"u")return;let R=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${R}`).then((C)=>C.ok?C.json():null).then((C)=>{if(!g.current&&C&&C.telemetry)h(C.telemetry)}).catch((C)=>{if(!g.current)console.warn("Failed to fetch context telemetry:",C)})},[m]);o(()=>{if(g.current=!1,!r)return;return w(),()=>{g.current=!0}},[r,c,w]);let y=we(m?Cp(m):null,{enabled:r}),[v,I]=n(0);if(o(()=>{if(y.data)h(y.data),I((R)=>R+1)},[y.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e(mt,{left:e(d,{children:[e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle}),e("span",{className:"text-[11px] text-ink/50 truncate font-mono",children:t.timestamp})]}),right:e(at,{label:"Refresh context telemetry",onClick:()=>{y.refresh(),w()},busy:y.refreshing,disabled:!r})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(J,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(z,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(Q,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(X,{sessionId:m,refreshKey:c+v})]})]})}export{pt as ContextPanel};
@@ -1,2 +1,2 @@
1
- import{n,o,W,i,oe,e,s,Be}from"./index-3fw3sd10.js";var _={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]},Da=s(_);var M={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]},Qa=s(M);function O({widths:r,pinned:a,available:c}){if(!(c>0)||r.length===0)return r.map(()=>!0);if(r.reduce((d,u)=>d+u,0)+4*(r.length-1)<=c)return r.map(()=>!0);let m=r.map(()=>!1),v=0,f=0;r.forEach((d,u)=>{if(!a[u])return;v+=d+(f>0?4:0),f+=1,m[u]=!0});let t=c-v-30-4;return r.forEach((d,u)=>{if(a[u])return;let x=d+(f>0?4:0);if(x>t)return;t-=x,f+=1,m[u]=!0}),m}function R(r){return r.some((a)=>!a)}function Ai({clusters:r,className:a="",available:c}){let b=i(null),[m,v]=n(null),[f,t]=n(0),[d,u]=n(0),x=c??f,y=r.map((l)=>`${l.id}:${l.pinned?1:0}`).join("|"),h=m?.signature===y,g=h?m.widths:[],k=r.map((l)=>l.pinned===!0),w=c===0?r.map(()=>!1):g.length>0?O({widths:g,pinned:k,available:x}):r.map(()=>!0);W(()=>{let l=b.current;if(!l)return;if(!h){let p=[...l.querySelectorAll("[data-toolbar-cluster]")];if(p.length===r.length){let T=p.map((E)=>E.getBoundingClientRect().width);if(T.some((E)=>E>0))v({signature:y,widths:T})}}if(c===void 0)t(l.clientWidth)},[c,h,y,r.length,d]),o(()=>{let l=b.current;if(!l||typeof ResizeObserver>"u")return;let p=new ResizeObserver(()=>{t(l.clientWidth),u((T)=>T+1)});return p.observe(l),()=>p.disconnect()},[]);let L=r.filter((l,p)=>!w[p]).flatMap((l)=>l.actions);return e("div",{ref:b,style:c===void 0?void 0:{maxWidth:`${c}px`},className:`flex ${c===void 0?"flex-1":"flex-none"} min-w-0 flex-nowrap items-center justify-end gap-x-1 overflow-hidden ${a}`,children:[r.map((l,p)=>w[p]?e("div",{"data-toolbar-cluster":"",className:"flex items-center flex-shrink-0",children:l.children},l.id):null),R(w)&&e(A,{actions:L})]})}function A({actions:r}){let[a,c]=n(!1),[b,m]=n(null),v=i(null),f=i(null);return o(()=>{if(!a)return;let t=(d)=>{let u=d.target;if(v.current?.contains(u)||f.current?.contains(u))return;c(!1)};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}},[a]),o(()=>{if(!a)return;let t=(d)=>{if(d.key==="Escape")c(!1)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[a]),W(()=>{if(!a)return;let t=v.current?.firstElementChild,d=f.current;if(!t||!d)return;let u=t.getBoundingClientRect(),{width:x,height:y}=d.getBoundingClientRect(),h=8,g=u.bottom+4,k=g+y+h<=window.innerHeight?g:Math.max(h,u.top-y-4),w=Math.max(h,Math.min(u.right-x,window.innerWidth-x-h));m({top:k,left:w})},[a,r.length]),e("div",{className:"relative flex-shrink-0",ref:v,children:[e("button",{type:"button",title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":a,onClick:()=>{m(null),c(!a)},className:`flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer ${a?"bg-ink/10 text-ink":"text-ink/50 hover:text-ink hover:bg-ink/5"}`,children:e(Be,{size:14})}),a&&oe(e("div",{ref:f,role:"menu",style:{top:b?.top??0,left:b?.left??0,visibility:b?"visible":"hidden"},className:"glass-popover fixed z-[80] w-52 bg-paper border border-ink/15 rounded-lg shadow-lg py-1 text-xs",children:r.map((t)=>e("button",{type:"button",role:"menuitem",disabled:t.disabled,"aria-pressed":t.active,onClick:()=>{c(!1),t.onSelect()},className:`w-full text-left flex items-center gap-2 px-3 py-1.5 transition-colors disabled:cursor-default disabled:opacity-40 ${t.active?"bg-ink/5 text-ink font-medium":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e(t.icon,{size:13,className:"flex-shrink-0"}),e("span",{className:"truncate",children:t.label})]},t.label))}),document.body)]})}
1
+ import{n,o,W,i,oe,e,s,Be}from"./index-4c2zcvem.js";var _={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]},Da=s(_);var M={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]},Qa=s(M);function O({widths:r,pinned:a,available:c}){if(!(c>0)||r.length===0)return r.map(()=>!0);if(r.reduce((d,u)=>d+u,0)+4*(r.length-1)<=c)return r.map(()=>!0);let m=r.map(()=>!1),v=0,f=0;r.forEach((d,u)=>{if(!a[u])return;v+=d+(f>0?4:0),f+=1,m[u]=!0});let t=c-v-30-4;return r.forEach((d,u)=>{if(a[u])return;let x=d+(f>0?4:0);if(x>t)return;t-=x,f+=1,m[u]=!0}),m}function R(r){return r.some((a)=>!a)}function Ai({clusters:r,className:a="",available:c}){let b=i(null),[m,v]=n(null),[f,t]=n(0),[d,u]=n(0),x=c??f,y=r.map((l)=>`${l.id}:${l.pinned?1:0}`).join("|"),h=m?.signature===y,g=h?m.widths:[],k=r.map((l)=>l.pinned===!0),w=c===0?r.map(()=>!1):g.length>0?O({widths:g,pinned:k,available:x}):r.map(()=>!0);W(()=>{let l=b.current;if(!l)return;if(!h){let p=[...l.querySelectorAll("[data-toolbar-cluster]")];if(p.length===r.length){let T=p.map((E)=>E.getBoundingClientRect().width);if(T.some((E)=>E>0))v({signature:y,widths:T})}}if(c===void 0)t(l.clientWidth)},[c,h,y,r.length,d]),o(()=>{let l=b.current;if(!l||typeof ResizeObserver>"u")return;let p=new ResizeObserver(()=>{t(l.clientWidth),u((T)=>T+1)});return p.observe(l),()=>p.disconnect()},[]);let L=r.filter((l,p)=>!w[p]).flatMap((l)=>l.actions);return e("div",{ref:b,style:c===void 0?void 0:{maxWidth:`${c}px`},className:`flex ${c===void 0?"flex-1":"flex-none"} min-w-0 flex-nowrap items-center justify-end gap-x-1 overflow-hidden ${a}`,children:[r.map((l,p)=>w[p]?e("div",{"data-toolbar-cluster":"",className:"flex items-center flex-shrink-0",children:l.children},l.id):null),R(w)&&e(A,{actions:L})]})}function A({actions:r}){let[a,c]=n(!1),[b,m]=n(null),v=i(null),f=i(null);return o(()=>{if(!a)return;let t=(d)=>{let u=d.target;if(v.current?.contains(u)||f.current?.contains(u))return;c(!1)};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}},[a]),o(()=>{if(!a)return;let t=(d)=>{if(d.key==="Escape")c(!1)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[a]),W(()=>{if(!a)return;let t=v.current?.firstElementChild,d=f.current;if(!t||!d)return;let u=t.getBoundingClientRect(),{width:x,height:y}=d.getBoundingClientRect(),h=8,g=u.bottom+4,k=g+y+h<=window.innerHeight?g:Math.max(h,u.top-y-4),w=Math.max(h,Math.min(u.right-x,window.innerWidth-x-h));m({top:k,left:w})},[a,r.length]),e("div",{className:"relative flex-shrink-0",ref:v,children:[e("button",{type:"button",title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":a,onClick:()=>{m(null),c(!a)},className:`flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer ${a?"bg-ink/10 text-ink":"text-ink/50 hover:text-ink hover:bg-ink/5"}`,children:e(Be,{size:14})}),a&&oe(e("div",{ref:f,role:"menu",style:{top:b?.top??0,left:b?.left??0,visibility:b?"visible":"hidden"},className:"glass-popover fixed z-[80] w-52 bg-paper border border-ink/15 rounded-lg shadow-lg py-1 text-xs",children:r.map((t)=>e("button",{type:"button",role:"menuitem",disabled:t.disabled,"aria-pressed":t.active,onClick:()=>{c(!1),t.onSelect()},className:`w-full text-left flex items-center gap-2 px-3 py-1.5 transition-colors disabled:cursor-default disabled:opacity-40 ${t.active?"bg-ink/5 text-ink font-medium":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e(t.icon,{size:13,className:"flex-shrink-0"}),e("span",{className:"truncate",children:t.label})]},t.label))}),document.body)]})}
2
2
  export{Da,Qa,Ai};
@@ -1,2 +1,2 @@
1
- import{d,n,W,i,e,s,f,B,re,Ce,ja,va,Rt,wa,mr,Ht,Wt}from"./index-3fw3sd10.js";import{Da,Qa,Ai}from"./index-hh05xd1d.js";var J={name:"square-pen",size:24,node:[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],aliases:["pen-box","edit","pen-square"]},y=s(J);var K={name:"laptop",size:24,node:[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]},Z=s(K);var Q={name:"ratio",size:24,node:[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]},w=s(Q);var Y={name:"tablet",size:24,node:[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]},C=s(Y);var k=[{id:"responsive",label:"Responsive (100% Fluid)",category:"responsive",icon:va},{id:"desktop-16-9",label:"Desktop 16:9 (Auto H:W)",category:"responsive",icon:w},{id:"laptop",label:"Laptop (1024 × 768)",category:"responsive",icon:Z},{id:"tablet",label:"Tablet (768 × 1024)",category:"mobile",icon:C},{id:"mobile",label:"Mobile Phone (375 × 667)",category:"mobile",icon:mr},{id:"mobile-lg",label:"Mobile Large (414 × 896)",category:"mobile",icon:mr}];function j(t){switch(t){case"desktop-16-9":return"Desktop 16:9";case"laptop":return"Laptop 1024p";case"tablet":return"Tablet 768p";case"mobile":return"Mobile 375p";case"mobile-lg":return"Mobile Lg 414p";case"responsive":default:return"Responsive"}}function z({viewportMode:t,onChangeViewport:r,zoomLevel:a=100,onSetZoom:l}){let[p,c]=n(null);return e("div",{className:"flex items-center space-x-1.5 flex-shrink-0",children:[e("div",{className:"hidden sm:flex items-center bg-canvas border border-ink/10 rounded-md p-0.5",children:[e("button",{type:"button",onClick:()=>r("responsive"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="responsive"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Responsive (100% Fluid)",children:e(va,{size:12})}),e("button",{type:"button",onClick:()=>r("desktop-16-9"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="desktop-16-9"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Desktop 16:9 (Auto Height following Width)",children:e(w,{size:12})}),e("button",{type:"button",onClick:()=>r("tablet"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="tablet"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Tablet (768px)",children:e(C,{size:12})}),e("button",{type:"button",onClick:()=>r("mobile"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="mobile"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Mobile (375px)",children:e(mr,{size:12})})]}),e("button",{type:"button","aria-haspopup":"menu","aria-expanded":p!==null,onClick:(o)=>c(p?null:Ht(o.currentTarget)),className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas border border-ink/15 hover:border-ink/30 text-ink text-[11px] font-mono transition-colors cursor-pointer",title:"Device & Responsive Testing Menu",children:[e("span",{className:"hidden md:inline text-[10px] font-medium",children:j(t)}),e(B,{size:11,className:"text-ink/60"})]}),e(Wt,{anchor:p,ariaLabel:"Device & Responsive Testing Menu",className:"w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs font-mono",onClose:()=>c(null),children:[e("div",{className:"px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Responsive Testing"}),k.filter((o)=>o.category==="responsive").map((o)=>{let u=o.icon,b=t===o.id;return e("button",{type:"button",onClick:()=>{r(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),b&&e(f,{size:12,className:"text-success"})]},o.id)}),e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Mobile Testing"}),k.filter((o)=>o.category==="mobile").map((o)=>{let u=o.icon,b=t===o.id;return e("button",{type:"button",onClick:()=>{r(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),b&&e(f,{size:12,className:"text-success"})]},o.id)}),l&&e(d,{children:[e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:["Zoom Scale (",a,"%)"]}),e("div",{className:"grid grid-cols-3 gap-1 px-2 py-1",children:[50,75,100,125,150,200].map((o)=>e("button",{type:"button",onClick:()=>{l(o),c(null)},className:`px-1.5 py-1 text-center rounded text-[11px] font-mono cursor-pointer transition-colors ${a===o?"bg-ink text-canvas font-semibold":"bg-canvas border border-ink/10 text-ink/75 hover:bg-ink/5"}`,children:[o,"%"]},o))})]})]})]})}function L({zoomLevel:t,onZoomIn:r,onZoomOut:a,onResetZoom:l}){return e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 text-xs font-mono",children:[e("button",{type:"button",onClick:a,disabled:t<=50,"aria-label":"Perkecil tampilan",title:"Zoom Out (-10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Qa,{size:12})}),e("button",{type:"button",onClick:l,className:"px-1 text-[10px] font-medium text-ink/75 hover:text-ink hover:underline cursor-pointer select-none",title:"Reset Zoom (100%)",children:[t,"%"]}),e("button",{type:"button",onClick:r,disabled:t>=200,"aria-label":"Perbesar tampilan",title:"Zoom In (+10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Da,{size:12})})]})}var h="p-1.5 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:cursor-not-allowed";function O(t){let r=[],{url:a,zoomLevel:l,copied:p,included:c}=t;if(t.viewportMode&&t.onChangeViewport){let{viewportMode:o,onChangeViewport:u,onSetZoom:b}=t;r.push({id:"viewport",actions:k.map((m)=>({label:m.label,icon:m.icon,onSelect:()=>u(m.id),active:o===m.id})),children:e(z,{viewportMode:o,onChangeViewport:u,zoomLevel:l,onSetZoom:b})})}if(r.push({id:"zoom",actions:[{label:"Zoom in (+10%)",icon:Da,onSelect:t.onZoomIn,disabled:l>=200},{label:"Zoom out (-10%)",icon:Qa,onSelect:t.onZoomOut,disabled:l<=50},{label:"Reset zoom (100%)",icon:Rt,onSelect:t.onResetZoom,active:l===100}],children:e(L,{zoomLevel:l,onZoomIn:t.onZoomIn,onZoomOut:t.onZoomOut,onResetZoom:t.onResetZoom})}),r.push({id:"include",actions:[{label:c?"Page context added to the draft":"Include this page in the chat draft",icon:ja,onSelect:t.onIncludeInChat,disabled:!a}],children:e("button",{type:"button",onClick:t.onIncludeInChat,disabled:!a,"aria-label":"Include this page in the chat draft",title:c?"Page context added to the draft":"Include this page in the chat draft",className:h,children:c?e(f,{size:14,className:"text-success"}):e(ja,{size:14})})}),t.annotate){let o=t.annotate;r.push({id:"annotate",actions:[{label:o.count>0?`${o.active?"Tutup mode anotasi":"Buka mode anotasi"} (${o.count})`:"Mark a part of the page, then send it to the chat",icon:y,onSelect:o.onToggle,active:o.active,disabled:!a}],children:e("button",{type:"button",onClick:o.onToggle,disabled:!a,"aria-label":"Page annotation mode","aria-pressed":o.active,title:o.active?"Tutup mode anotasi":o.count>0?`Anotasi (${o.count}) — buka lagi`:"Mark a part of the page, then send it to the chat",className:`${h} relative ${o.active?"bg-ink/10 text-ink":""}`,children:[e(y,{size:14}),o.count>0&&e("span",{className:"absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] px-0.5 rounded-full bg-error text-paper text-[10px] leading-[13px] font-mono text-center",children:o.count})]})})}if(r.push({id:"copy",actions:[{label:p?"Copied URL!":"Copy URL",icon:re,onSelect:t.onCopy,disabled:!a}],children:e("button",{type:"button",onClick:t.onCopy,disabled:!a,"aria-label":"Salin URL",title:p?"Copied URL!":"Copy URL",className:h,children:p?e(f,{size:14,className:"text-success"}):e(re,{size:14})})}),t.onReconnect){let o=t.onReconnect;r.push({id:"reconnect",actions:[{label:"Sambungkan ulang live view",icon:wa,onSelect:o}],children:e("button",{type:"button",onClick:o,"aria-label":"Sambungkan ulang live view",title:"Reconnect live view",className:h,children:e(wa,{size:14})})})}return r.push({id:"open-external",actions:[{label:t.openExternalLabel,icon:Ce,onSelect:t.onOpenExternal,disabled:!a}],children:e("button",{type:"button",onClick:t.onOpenExternal,disabled:!a,"aria-label":t.openExternalLabel,title:t.openExternalTitle,className:h,children:e(Ce,{size:14})})}),r}var P=108,ee=280,oe=18,te=140,ne=36;function gu({url:t,statusDotClass:r,statusLabel:a,viewportMode:l,zoomLevel:p,onChangeViewport:c,onZoomIn:o,onZoomOut:u,onResetZoom:b,onSetZoom:m,annotate:A,onIncludeInChat:V,onOpenExternal:E,onReconnect:D,openExternalLabel:_,openExternalTitle:U,children:H}){let[X,T]=n(!1),[q,N]=n(!1),g=i(null),[x,R]=n(0),F=O({url:t,zoomLevel:p,copied:X,included:q,viewportMode:l,onChangeViewport:c,annotate:A,onReconnect:D,onIncludeInChat:()=>{V(),N(!0),setTimeout(()=>N(!1),2500)},onCopy:()=>{if(!t)return;navigator.clipboard.writeText(t).then(()=>{T(!0),setTimeout(()=>T(!1),2000)}).catch(()=>{})},onOpenExternal:E,onZoomIn:o,onZoomOut:u,onResetZoom:b,onSetZoom:m,openExternalLabel:_,openExternalTitle:U});W(()=>{let v=g.current;if(!v)return;R(v.clientWidth)}),W(()=>{let v=g.current;if(!v||typeof ResizeObserver>"u")return;let M=new ResizeObserver(()=>R(v.clientWidth));return M.observe(v),()=>M.disconnect()},[]);let I=x===0||x>=ee,S=I?x>0?Math.min(P,x*0.25):P:oe,G=x>0?Math.max(0,x-S-te-ne):void 0;return e("div",{ref:g,"data-browser-toolbar":"",className:"h-10 px-2.5 border-b border-ink/10 bg-paper flex items-center gap-x-2 flex-shrink-0 select-none",children:[e("div",{className:"flex items-center space-x-1.5 flex-shrink-0 min-w-0",style:{maxWidth:`${S}px`},title:a,children:[e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${r}`}),I&&e("span",{className:"text-[10px] font-mono uppercase tracking-wide text-ink/60 truncate",children:a})]}),e("div",{className:"flex flex-1 min-w-0 items-center",children:H}),e(Ai,{clusters:F,available:G})]})}
1
+ import{d,n,W,i,e,s,f,B,re,Ce,ja,va,Rt,wa,mr,Ht,Wt}from"./index-4c2zcvem.js";import{Da,Qa,Ai}from"./index-vb3srfyc.js";var J={name:"square-pen",size:24,node:[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],aliases:["pen-box","edit","pen-square"]},y=s(J);var K={name:"laptop",size:24,node:[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]},Z=s(K);var Q={name:"ratio",size:24,node:[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]},w=s(Q);var Y={name:"tablet",size:24,node:[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]},C=s(Y);var k=[{id:"responsive",label:"Responsive (100% Fluid)",category:"responsive",icon:va},{id:"desktop-16-9",label:"Desktop 16:9 (Auto H:W)",category:"responsive",icon:w},{id:"laptop",label:"Laptop (1024 × 768)",category:"responsive",icon:Z},{id:"tablet",label:"Tablet (768 × 1024)",category:"mobile",icon:C},{id:"mobile",label:"Mobile Phone (375 × 667)",category:"mobile",icon:mr},{id:"mobile-lg",label:"Mobile Large (414 × 896)",category:"mobile",icon:mr}];function j(t){switch(t){case"desktop-16-9":return"Desktop 16:9";case"laptop":return"Laptop 1024p";case"tablet":return"Tablet 768p";case"mobile":return"Mobile 375p";case"mobile-lg":return"Mobile Lg 414p";case"responsive":default:return"Responsive"}}function z({viewportMode:t,onChangeViewport:r,zoomLevel:a=100,onSetZoom:l}){let[p,c]=n(null);return e("div",{className:"flex items-center space-x-1.5 flex-shrink-0",children:[e("div",{className:"hidden sm:flex items-center bg-canvas border border-ink/10 rounded-md p-0.5",children:[e("button",{type:"button",onClick:()=>r("responsive"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="responsive"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Responsive (100% Fluid)",children:e(va,{size:12})}),e("button",{type:"button",onClick:()=>r("desktop-16-9"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="desktop-16-9"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Desktop 16:9 (Auto Height following Width)",children:e(w,{size:12})}),e("button",{type:"button",onClick:()=>r("tablet"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="tablet"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Tablet (768px)",children:e(C,{size:12})}),e("button",{type:"button",onClick:()=>r("mobile"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="mobile"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Mobile (375px)",children:e(mr,{size:12})})]}),e("button",{type:"button","aria-haspopup":"menu","aria-expanded":p!==null,onClick:(o)=>c(p?null:Ht(o.currentTarget)),className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas border border-ink/15 hover:border-ink/30 text-ink text-[11px] font-mono transition-colors cursor-pointer",title:"Device & Responsive Testing Menu",children:[e("span",{className:"hidden md:inline text-[10px] font-medium",children:j(t)}),e(B,{size:11,className:"text-ink/60"})]}),e(Wt,{anchor:p,ariaLabel:"Device & Responsive Testing Menu",className:"w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs font-mono",onClose:()=>c(null),children:[e("div",{className:"px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Responsive Testing"}),k.filter((o)=>o.category==="responsive").map((o)=>{let u=o.icon,b=t===o.id;return e("button",{type:"button",onClick:()=>{r(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),b&&e(f,{size:12,className:"text-success"})]},o.id)}),e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Mobile Testing"}),k.filter((o)=>o.category==="mobile").map((o)=>{let u=o.icon,b=t===o.id;return e("button",{type:"button",onClick:()=>{r(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${b?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(u,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),b&&e(f,{size:12,className:"text-success"})]},o.id)}),l&&e(d,{children:[e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:["Zoom Scale (",a,"%)"]}),e("div",{className:"grid grid-cols-3 gap-1 px-2 py-1",children:[50,75,100,125,150,200].map((o)=>e("button",{type:"button",onClick:()=>{l(o),c(null)},className:`px-1.5 py-1 text-center rounded text-[11px] font-mono cursor-pointer transition-colors ${a===o?"bg-ink text-canvas font-semibold":"bg-canvas border border-ink/10 text-ink/75 hover:bg-ink/5"}`,children:[o,"%"]},o))})]})]})]})}function L({zoomLevel:t,onZoomIn:r,onZoomOut:a,onResetZoom:l}){return e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 text-xs font-mono",children:[e("button",{type:"button",onClick:a,disabled:t<=50,"aria-label":"Perkecil tampilan",title:"Zoom Out (-10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Qa,{size:12})}),e("button",{type:"button",onClick:l,className:"px-1 text-[10px] font-medium text-ink/75 hover:text-ink hover:underline cursor-pointer select-none",title:"Reset Zoom (100%)",children:[t,"%"]}),e("button",{type:"button",onClick:r,disabled:t>=200,"aria-label":"Perbesar tampilan",title:"Zoom In (+10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Da,{size:12})})]})}var h="p-1.5 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:cursor-not-allowed";function O(t){let r=[],{url:a,zoomLevel:l,copied:p,included:c}=t;if(t.viewportMode&&t.onChangeViewport){let{viewportMode:o,onChangeViewport:u,onSetZoom:b}=t;r.push({id:"viewport",actions:k.map((m)=>({label:m.label,icon:m.icon,onSelect:()=>u(m.id),active:o===m.id})),children:e(z,{viewportMode:o,onChangeViewport:u,zoomLevel:l,onSetZoom:b})})}if(r.push({id:"zoom",actions:[{label:"Zoom in (+10%)",icon:Da,onSelect:t.onZoomIn,disabled:l>=200},{label:"Zoom out (-10%)",icon:Qa,onSelect:t.onZoomOut,disabled:l<=50},{label:"Reset zoom (100%)",icon:Rt,onSelect:t.onResetZoom,active:l===100}],children:e(L,{zoomLevel:l,onZoomIn:t.onZoomIn,onZoomOut:t.onZoomOut,onResetZoom:t.onResetZoom})}),r.push({id:"include",actions:[{label:c?"Page context added to the draft":"Include this page in the chat draft",icon:ja,onSelect:t.onIncludeInChat,disabled:!a}],children:e("button",{type:"button",onClick:t.onIncludeInChat,disabled:!a,"aria-label":"Include this page in the chat draft",title:c?"Page context added to the draft":"Include this page in the chat draft",className:h,children:c?e(f,{size:14,className:"text-success"}):e(ja,{size:14})})}),t.annotate){let o=t.annotate;r.push({id:"annotate",actions:[{label:o.count>0?`${o.active?"Tutup mode anotasi":"Buka mode anotasi"} (${o.count})`:"Mark a part of the page, then send it to the chat",icon:y,onSelect:o.onToggle,active:o.active,disabled:!a}],children:e("button",{type:"button",onClick:o.onToggle,disabled:!a,"aria-label":"Page annotation mode","aria-pressed":o.active,title:o.active?"Tutup mode anotasi":o.count>0?`Anotasi (${o.count}) — buka lagi`:"Mark a part of the page, then send it to the chat",className:`${h} relative ${o.active?"bg-ink/10 text-ink":""}`,children:[e(y,{size:14}),o.count>0&&e("span",{className:"absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] px-0.5 rounded-full bg-error text-paper text-[10px] leading-[13px] font-mono text-center",children:o.count})]})})}if(r.push({id:"copy",actions:[{label:p?"Copied URL!":"Copy URL",icon:re,onSelect:t.onCopy,disabled:!a}],children:e("button",{type:"button",onClick:t.onCopy,disabled:!a,"aria-label":"Salin URL",title:p?"Copied URL!":"Copy URL",className:h,children:p?e(f,{size:14,className:"text-success"}):e(re,{size:14})})}),t.onReconnect){let o=t.onReconnect;r.push({id:"reconnect",actions:[{label:"Sambungkan ulang live view",icon:wa,onSelect:o}],children:e("button",{type:"button",onClick:o,"aria-label":"Sambungkan ulang live view",title:"Reconnect live view",className:h,children:e(wa,{size:14})})})}return r.push({id:"open-external",actions:[{label:t.openExternalLabel,icon:Ce,onSelect:t.onOpenExternal,disabled:!a}],children:e("button",{type:"button",onClick:t.onOpenExternal,disabled:!a,"aria-label":t.openExternalLabel,title:t.openExternalTitle,className:h,children:e(Ce,{size:14})})}),r}var P=108,ee=280,oe=18,te=140,ne=36;function gu({url:t,statusDotClass:r,statusLabel:a,viewportMode:l,zoomLevel:p,onChangeViewport:c,onZoomIn:o,onZoomOut:u,onResetZoom:b,onSetZoom:m,annotate:A,onIncludeInChat:V,onOpenExternal:E,onReconnect:D,openExternalLabel:_,openExternalTitle:U,children:H}){let[X,T]=n(!1),[q,N]=n(!1),g=i(null),[x,R]=n(0),F=O({url:t,zoomLevel:p,copied:X,included:q,viewportMode:l,onChangeViewport:c,annotate:A,onReconnect:D,onIncludeInChat:()=>{V(),N(!0),setTimeout(()=>N(!1),2500)},onCopy:()=>{if(!t)return;navigator.clipboard.writeText(t).then(()=>{T(!0),setTimeout(()=>T(!1),2000)}).catch(()=>{})},onOpenExternal:E,onZoomIn:o,onZoomOut:u,onResetZoom:b,onSetZoom:m,openExternalLabel:_,openExternalTitle:U});W(()=>{let v=g.current;if(!v)return;R(v.clientWidth)}),W(()=>{let v=g.current;if(!v||typeof ResizeObserver>"u")return;let M=new ResizeObserver(()=>R(v.clientWidth));return M.observe(v),()=>M.disconnect()},[]);let I=x===0||x>=ee,S=I?x>0?Math.min(P,x*0.25):P:oe,G=x>0?Math.max(0,x-S-te-ne):void 0;return e("div",{ref:g,"data-browser-toolbar":"",className:"h-10 px-2.5 border-b border-ink/10 bg-paper flex items-center gap-x-2 flex-shrink-0 select-none",children:[e("div",{className:"flex items-center space-x-1.5 flex-shrink-0 min-w-0",style:{maxWidth:`${S}px`},title:a,children:[e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${r}`}),I&&e("span",{className:"text-[10px] font-mono uppercase tracking-wide text-ink/60 truncate",children:a})]}),e("div",{className:"flex flex-1 min-w-0 items-center",children:H}),e(Ai,{clusters:F,available:G})]})}
2
2
  export{gu};
@@ -1 +1 @@
1
- import{d,n,o,i,u,a,br,$e,oe,e,Wn,w,zg,we,Fs,S,lr,cr,s,Dn,L,Xe,B,ie,re,Ce,qe,ei,on,ti,Wr,D,O,b,mt,at,pe,jt,Pu,it,st,Xg,eA,Hi,Wi,Ou,je}from"./index-3fw3sd10.js";import{Du,Ko,Qu,Nu}from"./index-jkph8wqq.js";import{Ns,hr,Ru}from"./index-270y5r9k.js";var Jt={name:"pen",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],aliases:["edit-2"]},Ve=s(Jt);var Zt={name:"copy-plus",size:24,node:[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]},Be=s(Zt);var en={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Qe=s(en);var tn={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]},Se=s(tn);function Ye({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:h,onRefresh:v,refreshing:g}){return e("div",{className:"border-b border-ink/10",children:[e(mt,{className:"border-b-0",left:e(hr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(at,{label:"Refresh",onClick:v,busy:g})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(O,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:x,onChange:(m)=>h(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})})]})}function Je({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:h}){let v=f?"text-ink font-semibold":x?x.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(B,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ie,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(it,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var nn=28,rn=9,sn=8;function an(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:h,isArchive:v}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${k} to…`,icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${k}`,icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(ei,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(on,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(B,{size:13,className:"text-ink/60"})});if(x)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ie,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(qe,{size:13,className:"text-ink/60"})}),v)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Qe,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(ti,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(Ns,{size:13,className:"text-ink/60"}),disabled:p});return g.push({kind:"separator"}),g.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Ce,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Dn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ve,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g}function ln(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*nn+l*rn+sn}function Ze({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:h,selectionCount:v,isArchive:g,onAction:m,menuRef:k}){let F=an({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:x,selectionCount:v,isArchive:g}),A=ln(F),C=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,E=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-A-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(R)=>{R.preventDefault(),m("close")},children:e("div",{ref:k,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:E,left:C},onClick:(R)=>R.stopPropagation(),children:F.map((R,N)=>R.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${N}`):e("button",{type:"button",disabled:R.disabled,onClick:()=>m(R.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${R.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${R.tone??""}`,children:[R.icon,e("span",{children:R.label})]},R.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:h}){let v=r==="folder"?"Folder":"File";return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",v]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(g)=>f(g.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${v.toLowerCase()} name`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${c?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Nested paths create the folders they need — ",e("span",{className:"font-mono",children:"lib/parse.ts"}),"."]}),c&&e("p",{className:"text-[11px] text-error mb-2",children:c}),e("div",{className:"flex justify-end space-x-2 mt-2",children:[e("button",{type:"button",onClick:x,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function et({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let h=c>1;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:x,className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 transition-colors flex items-center",disabled:p,children:p?"Deleting...":"Delete"})]})]})}),document.body)}function tt({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:h,onSubmit:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>x(g.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function nt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Dn,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,x)=>e("tr",{className:"hover:bg-ink/[0.03] transition-colors group",children:[e("td",{className:"px-3 py-2 text-ink",children:f.message?e("span",{className:"font-medium text-ink/90 group-hover:text-ink",children:f.message}):null}),e("td",{className:"px-3 py-2 text-ink/60 whitespace-nowrap font-mono text-[10.5px]",children:f.time}),e("td",{className:"px-3 py-2 text-ink/70 whitespace-nowrap truncate max-w-[120px]",children:f.author}),e("td",{className:"px-3 py-2 text-right",children:f.hash?e("span",{className:"font-mono text-ink/50 group-hover:text-ink font-semibold transition-colors bg-canvas px-1.5 py-0.5 rounded border border-ink/10",children:f.hash}):null})]},x))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(D,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function rt({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(et,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(tt,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(nt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(cn);return r.some((l,c)=>l!==t[c])?r:t}function cn(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Ee(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,x)=>[...p,...l.slice(0,x+1)].join("/"))}function ot(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((h)=>{if(h.type!=="folder")return[h];let v=Array.isArray(h.children)?p(h.children):h.children,g=v===h.children?h:{...h,children:v},m=r.has(h.path)?Me(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let k={...g,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let F=m[y-1];k={name:F.split("/").pop(),path:F,type:"folder",ignored:g.ignored,children:[k]}}return[k]}),f=p(t);return{nodes:c?f:t,roots:l}}function lt(t,r){let l=new Set,c=(x)=>{for(let h of x){if(h.type!=="folder")continue;if(l.add(h.path),Array.isArray(h.children))c(h.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let h=p.slice(0,x+1).join("/");if(l.has(h))f.push(h)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=st(),[x,h]=n(!1),[v,g]=n("file"),[m,k]=n(""),[y,F]=n(null),A=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let C=f.data;if(A.current===C)return;if(A.current=C,C.success&&C.path){let E=C.kind==="folder"?"folder":"file";h(!1),k(""),F(null);let R=C.path.split("/").pop()||C.path;if(c({path:C.path,name:R,kind:E}),E==="file")p?.({path:C.path,name:R})}else F(C.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:k,error:y,busy:f.state!=="idle",openDialog:(C="file")=>{g(C),k(""),F(null),h(!0)},closeDialog:()=>h(!1),submit:(C)=>{C.preventDefault();let E=m.trim();if(!E)return;F(null);let R=new FormData;if(R.append("actionType","create"),R.append("path",t),R.append("name",E),v==="folder")R.append("kind","folder");if(l&&l!==".")R.append("repo",l);if(r)R.append("root",r);f.submit(R,{method:"post",action:"/api/fs/action"})}}}function De(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function ct(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function dt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function pt(t,r){if(t.path===""||t.path===".")return"The workspace root cannot be moved or copied";if(t.kind==="folder"&&(r===t.path||r.startsWith(`${t.path}/`)))return"Cannot paste a folder into itself";return null}function ut(t,r){let l=pt(t,r);if(l)return l;if(r===dt(t.path))return"Already in this folder";return null}function ft(t,r,l){if(!t||t.entries.length===0)return"Nothing to paste";if(t.scope!==r)return"The clipboard holds an entry from another workspace";if(t.mode==="cut"&&t.entries.some((c)=>l===dt(c.path)))return"Already in this folder";for(let c of t.entries){let p=pt(c,l);if(p)return p}return null}function ht(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.scope!=="string")return null;if(r.mode!=="copy"&&r.mode!=="cut")return null;let l=Array.isArray(r.entries)?r.entries:typeof r.path==="string"?[{path:r.path,name:r.name,kind:r.kind}]:[],c=[];for(let p of l){let f=dn(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function dn(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.path!=="string"||typeof r.name!=="string")return null;if(r.kind!=="file"&&r.kind!=="folder")return null;let l=r.path.split("/");if(r.path===""||r.path.startsWith("/")||l.some((c)=>c===""||c==="."||c===".."))return null;return{path:r.path,name:r.name,kind:r.kind}}var Oe=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],gt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function ze(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return ze(t)!==null}function pn(t){return Oe.find((r)=>r.id===t)}function un(t){return pn(t)?.extension??"zip"}function xt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function vt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function yt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function kt(t){if(t.length===0)return".";let r=t.map((c)=>vt(c).split("/").filter((p)=>p!==".")),l=r[0]??[];for(let c of r.slice(1)){let p=0;while(p<l.length&&p<c.length&&l[p]===c[p])p+=1;l=l.slice(0,p)}return l.length===0?".":l.join("/")}function Re(t,r){let l=un(r);if(t.length===1){let f=t[0],x=xt(f.name),h=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?x.slice(0,h):x)||"archive"}.${l}`}let c=kt(t.map((f)=>f.path)),p=yt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ct(t){return kt(t.map((r)=>r.path))}function Ft(t){let r=vt(t),l=xt(yt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function Nt(t){return t.toUpperCase()}function wt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:h,clipboard:v,isFolder:g,selection:m,selected:k,archive:y}){let F=st(),[A,C]=n(null),E=i(null),[R,N]=n(!1),[T,H]=n(!1),[W,ee]=n(!1),[te,ae]=n(t.path),[G,I]=n(null),{repo:z,rootPath:K}=t,j=Ne({folderPath:t.path,rootPath:K,repo:z,onCreated:(M)=>p?p(M):c(),onOpenCreated:(M)=>l?.({...M,root:K,repo:z||"."})}),ne=i(null);o(()=>{if(F.state!=="idle"||!F.data)return;let M=F.data;if(ne.current===M)return;if(ne.current=M,M.success&&!M.type)if(N(!1),H(!1),I(null),M.previousPath&&M.path&&f)f(M.previousPath,M.path);else c();else if(!M.success&&M.error&&R)I(M.error)},[F.state,F.data]);let q=(M)=>{if(z&&z!==".")M.append("repo",z);if(K)M.append("root",K);F.submit(M,{method:"post",action:"/api/fs/action"})},V=()=>{l?.({path:t.path,name:t.name,root:K,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},se=k&&m.length>1?m:[J],he=bt(t.name),Q=v.clip&&!v.refusalFor(J)?`Paste ${De(v.clip)??"item"}`:null,fe=(M)=>{if(C(null),I(null),M==="view")V();else if(M==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:K}}));else if(M==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),q(_)}else if(M==="copy_path")jt(Pu(t.basePath,t.path));else if(M==="copy_relative")jt(t.path);else if(M==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),q(_)}else if(M==="rename")ae(t.path),N(!0);else if(M==="unfold")x?.();else if(M==="fold")h?.();else if(M==="new_file")j.openDialog("file");else if(M==="new_folder")j.openDialog("folder");else if(M==="delete")H(!0);else if(M==="cut")v.cut(se);else if(M==="copy")v.copy(se);else if(M==="compress")y.openCompress(se);else if(M==="extract")y.openExtract(J);else if(M==="duplicate")v.duplicate(J);else if(M==="paste")v.paste(J)},le=(M)=>{M.preventDefault(),I(null);let _=new FormData;_.append("actionType","rename"),_.append("path",t.path),_.append("newPath",te),q(_)},xe=()=>{let M=new FormData;if(M.append("actionType","delete"),se.length>1)M.append("paths",JSON.stringify(se.map((_)=>_.path)));else M.append("path",t.path);q(M)};return{contextMenu:A,contextMenuRef:E,openContextMenu:(M,_)=>C({x:M,y:_}),closeContextMenu:()=>C(null),showRenameModal:R,showDeleteModal:T,showHistoryModal:W,showCreateModal:j.open,createKind:j.kind,createError:j.error,createName:j.name,setCreateName:j.setName,renameValue:te,setRenameValue:ae,renameError:G,busy:F.state!=="idle"||j.busy||v.busy||y.busy,pasteLabel:Q,selectionCount:se.length,isArchive:he,chainLabel:x!==void 0,foldable:h!==void 0,fetcherState:F.state,fetcherData:F.data,handleAction:fe,submitCreate:j.submit,submitRename:le,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>N(!1),closeHistory:()=>ee(!1)}}function Dt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let h=r?.path===t.path,v=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:v,isDropHovered:g&&v,onDragStart:(y)=>{if(y.dataTransfer?.setData("text/plain",t.path),y.dataTransfer)y.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(y)=>{if(!r)return;if(y.stopPropagation(),m(v),!v)return;if(y.preventDefault(),y.dataTransfer)y.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>m(!1),onDrop:(y)=>{if(!r)return;if(y.stopPropagation(),!v)return;y.preventDefault(),f(t)}}}var fn=450,Rt=8,mn=700;function Tt({enabled:t,onLongPress:r}){let l=i(null),c=i(null),p=i(0),f=i(r);f.current=r;let x=a(()=>{if(l.current!==null)clearTimeout(l.current),l.current=null;c.current=null},[]);return o(()=>x,[x]),{onTouchStart:(h)=>{if(!t)return;let v=h.touches[0];if(!v)return;x(),c.current={x:v.clientX,y:v.clientY},l.current=setTimeout(()=>{l.current=null;let g=c.current;if(c.current=null,!g)return;p.current=Date.now(),f.current(g.x,g.y)},fn)},onTouchMove:(h)=>{let v=c.current,g=h.touches[0];if(!v||!g)return;if(Math.abs(g.clientX-v.x)>Rt||Math.abs(g.clientY-v.y)>Rt)x()},onTouchEnd:x,onTouchCancel:x,consume:()=>{if(p.current===0)return!1;let h=Date.now()-p.current<mn;return p.current=0,h}}}function hn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Pe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae=!1}){let G=t.type==="folder",[I,z]=n(!1),[K,j]=n(!1),[ne,q]=n(!1),[V,J]=n(!1),se=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!G?k?.get(he)||k?.get(t.path):void 0,fe=Q?Wn(Q.status,Q.staged):null,le=G?y?.get(he)||y?.get(t.path):null,xe=Boolean(fe),M=t.ignored===!0,_=g?g.has(t.path):I,ce=t.forceExpanded!==void 0?t.forceExpanded:_;o(()=>{J(!0)},[]),o(()=>{if(G&&g)z(g.has(t.path))},[g,t.path,G]),o(()=>{if(G&&ce&&hn(t,K,ne)&&p)q(!0),j(!0),Promise.resolve(p(t.path)).finally(()=>j(!1))},[G,ce,t.children,t.path,p,K,ne]);let ye={path:t.path,name:t.name,kind:G?"folder":"file"},be=C.selected.has(t.path),U=wt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:E,selected:be,archive:A,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,onUnfold:W&&Ee({type:G?"folder":"file",name:t.name})?()=>W(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:F,isFolder:G});pe(U.contextMenuRef,U.closeContextMenu);let Y=Tt({enabled:ae,onLongPress:(X,ge)=>U.openContextMenu(X,ge)}),ke=(X)=>{if(X.stopPropagation(),Y.consume())return;let ge=C.gestureOf(X);if(ge!=="plain"){C.applyGesture(ge,t.path);return}if(C.applyGesture("plain",t.path),G){let ue=!ce;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(X)=>{X.preventDefault(),X.stopPropagation(),C.ensureForContext(t.path),U.openContextMenu(X.clientX,X.clientY)},de=Dt({target:ye,dragging:R,clipboard:F,onDragStart:N,onDragEnd:T,onDropOn:H,onHoverAccept:W});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${de.isDragging?"opacity-40":""} ${de.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":be?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!ae,onClick:ke,onContextMenu:ve,onDragStart:de.onDragStart,onDragEnd:de.onDragEnd,onDragOver:de.onDragOver,onDragLeave:de.onDragLeave,onDrop:de.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Je,{name:t.name,path:t.path,isFolder:G,isOpen:ce,ignored:M,selected:be,gitStatus:fe,folderStatus:le})}),ce&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!K&&se.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:se.map((X)=>e(Pe,{file:X,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae},X.path))}),V&&U.contextMenu&&e(Ze,{x:U.contextMenu.x,y:U.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:U.pasteLabel,chainLabel:U.chainLabel,foldable:U.foldable,busy:U.busy,selectionCount:U.selectionCount,isArchive:U.isArchive,onAction:U.handleAction}),V&&e(rt,{actions:U,file:t,isFolder:G,chainLabel:Ee({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function St({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:v},onClick:(m)=>m.stopPropagation(),children:[e("button",{type:"button",onClick:()=>p("new_file"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(ei,{size:13,className:"text-ink/60"}),e("span",{children:"New File"})]}),e("button",{type:"button",onClick:()=>p("new_folder"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(on,{size:13,className:"text-ink/60"}),e("span",{children:"New Folder"})]}),l&&e("button",{type:"button",disabled:c,onClick:()=>p("paste"),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${c?"opacity-40 cursor-default":"hover:bg-ink/5"}`,children:[e(Ns,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function At({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(St,{x:t.x,y:t.y,menuRef:r,pasteLabel:l,busy:c,onAction:p}),f.open&&e(Fe,{folderPath:".",kind:f.kind,value:f.name,error:f.error,isLoading:f.busy,onChange:f.setName,onCancel:f.closeDialog,onSubmit:f.submit})]})}function Et({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:h,children:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),v,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function gn({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:h,onNameChange:v,onDestinationChange:g,onCancel:m,onSubmit:k}){let y=t.slice(0,4).map((A)=>A.name).join(", "),F=t.length>4?` +${t.length-4} more`:"";return e(Et,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${F}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(A)=>{A.preventDefault(),k()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-format",children:"Format"}),e("select",{id:"archive-format",value:r,onChange:(A)=>h(A.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink mb-3",children:p.map((A)=>e("option",{value:A.id,disabled:!A.available,children:[A.label,A.available?"":` — ${A.tool} not installed`]},A.id))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(A)=>v(A.currentTarget.value),"aria-label":"Archive name",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-3 ${f?"border-error":"border-ink/20 focus:border-ink"}`}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-destination",children:"Destination folder"}),e("input",{id:"archive-destination",type:"text",value:c,onChange:(A)=>g(A.currentTarget.value),"aria-label":"Archive destination",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink"})]})}function bn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:h}){return e(Et,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:x,onSubmit:(v)=>{v.preventDefault(),h()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"extract-destination",children:"Extract to folder"}),e("input",{id:"extract-destination",autoFocus:!0,type:"text",value:l,onChange:(v)=>f(v.currentTarget.value),"aria-label":"Extract destination",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none ${c?"border-error":"border-ink/20 focus:border-ink"}`})]})}function Mt({archive:t}){if(t.compress)return e(gn,{entries:t.compress.entries,format:t.compress.format,name:t.compress.name,destination:t.compress.destination,formats:t.formats,error:t.error,busy:t.busy,onFormatChange:t.setFormat,onNameChange:t.setName,onDestinationChange:t.setCompressDestination,onCancel:t.cancel,onSubmit:t.submitCompress});if(t.extract)return e(bn,{archive:t.extract.archive,kindLabel:Nt(ze(t.extract.archive.name)??"zip"),destination:t.extract.destination,error:t.error,busy:t.busy,onDestinationChange:t.setExtractDestination,onCancel:t.cancel,onSubmit:t.submitExtract});return null}function Lt(){let[t,r]=S("files.outlineExpanded",!1),l=br(),c=$e(eA,Xg),{symbols:p,total:f,truncated:x,notice:h}=Nu({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let v=c.preview,g=(m,k)=>{if(!c.path)return;if(v){let y=Ou(p,k);if(y)Wi({path:c.path,...y});return}Hi({path:c.path,line:m.line,column:m.column,length:m.name.length})};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:e("button",{type:"button",onClick:()=>r(!t),"aria-expanded":t,"aria-controls":l,"aria-label":"Outline",title:t?"Hide outline":"Show outline",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:t?"▾":"▸"}),e(Wr,{size:12}),e("span",{children:"Outline"}),f>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:x?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:h}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,k)=>e("button",{type:"button",onClick:()=>g(m,k),"aria-label":v?`${Ko(m.kind)} ${m.name}`:`${Ko(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${Ko(m.kind).toLowerCase()}`:`${Ko(m.kind)} · line ${m.line}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors hover:bg-ink/5 active:bg-ink/10",style:{paddingLeft:`${4+m.depth*12}px`},children:[e(Du,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!v&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),x&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Qu(f)})]})})})})]})}function Ie(t,r){return Ae(t.map((l)=>xn(l,r)))}function xn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Ie(l,r)}}function vn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function Ot(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function $t(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function He(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},h=f,v=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),k=h.find((E)=>E.type==="folder"&&E.path===m),y=k?null:h.find((E)=>E.type==="folder"&&E.path.startsWith(`${m}/`)&&(p===E.path||p.startsWith(`${E.path}/`))),F=k??y,A=F?x[F.path]??F.children:null;if(F&&!Array.isArray(A))return{nodes:t,cache:r};if(!F){let E=yn(h,x,m);if(E){h=E;let R=h.find((T)=>T.path===m),N=Array.isArray(R?.children)?[...R.children]:[];x[m]=N,h=N,v=m,g+=1;continue}}let C=Array.isArray(A)?[...A]:[];if(F){x[F.path]=C,h=C,v=F.path,g=F.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),x[m]=C,h=C,v=m,g+=1}if(h.push(l),v!==null)x[v]=$t(h);return f=$t(f),{nodes:f,cache:x}}function yn(t,r,l){let c=t.findIndex((v)=>v.type==="folder"&&v.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),x=r[p.path]??p.children;if(Array.isArray(x))r[p.path]=x;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let v=f.length-2;v>=0;v-=1)h={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:Ot(l),path:l,type:"folder",ignored:!1,children:[h]},t}function zt(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=vn(l),f=r[p],x=f?.find((m)=>m.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let v=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let g=r[v];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:g.filter((m)=>m.path!==l)}}}function Pt(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?Pt(f.children,r,l):void 0;if(!x&&h===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=x?{...f,path:v,name:Ot(v)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function It(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let x=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[x]=x===p?f:Pt(f,r,l)}return c}function Ht(t,r,l){let c=new Set;for(let p of t)if(p===r)c.add(l);else if(p.startsWith(`${r}/`))c.add(`${l}${p.slice(r.length)}`);else c.add(p);return c}function Gt(t){if(!w(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>w(r)):[],root:t.root}}async function Ge(t){try{return Gt(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Kt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,h]=n({scope:"",files:[],root:""}),[v,g]=n(!1),m=i({}),k=i([]),y=i(f);y.current=f;let F=i(""),A=i(""),C=i(c);C.current=c;let E=(I)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(I)z.set("path",I);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},R=(I,z)=>{F.current=I,A.current=z;let K=Ie(k.current,m.current);return h({scope:I,files:K,root:z}),K},N=async(I)=>{let z=[...C.current];if(z.length===0)return;let K=await Promise.all(z.map(async(V)=>({path:V,read:await Ge(E(V))})));if(y.current!==I)return;let j=[];for(let{path:V,read:J}of K)if(J.status==="ok")m.current[V]=J.files;else if(J.status==="missing")j.push(V);if(j.length===0)return;let ne=new Set(j);for(let V of j)delete m.current[V];let q=new Set([...C.current].filter((V)=>!ne.has(V)));C.current=q,p(q)},T=async()=>{if(!t)return;let I=y.current;g(!0);try{let z=await Ge(E());if(y.current!==I)return;if(z.status!=="ok")return;if(F.current!==I)m.current={};if(k.current=z.files,R(I,z.root),await N(I),y.current!==I)return;R(I,z.root)}finally{if(y.current===I)g(!1)}},H=async(I)=>{let z=y.current,K=await Ge(E(I));if(y.current!==z||K.status!=="ok")return;if(m.current[I]=K.files,F.current===z)R(z,A.current)},W=(I)=>{let z=Gt(I);if(z.status!=="ok")return;let K=y.current;if(F.current!==K)m.current={};k.current=z.files,R(K,z.root),N(K).then(()=>{if(y.current===K)R(K,z.root)})},ee=()=>{m.current={},k.current=[],F.current="",A.current="",h({scope:"",files:[],root:""})},te=(I)=>{let z=y.current;if(F.current!==z)return null;let K={name:I.path.slice(I.path.lastIndexOf("/")+1),path:I.path,type:I.kind,ignored:!1},j=He(k.current,m.current,K);if(j.nodes===k.current)return null;return k.current=j.nodes,m.current=j.cache,R(z,A.current)},ae=(I,z)=>{let K=y.current;if(F.current!==K)return null;let j=zt(k.current,m.current,I);if(!j.entry)return null;m.current=It(j.cache,I,z);let ne={...j.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=He(j.nodes,m.current,ne);return k.current=q.nodes,m.current=q.cache,R(K,A.current)},G=x.scope===f;return{scope:f,files:G?x.files:[],root:G?x.root:"",isLoading:v,reload:T,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:ae,reset:ee}}function _t({rootPath:t,repo:r,onComplete:l,onError:c}){let p=st(),[f,x]=S("files.clipboard",null),h=ht(f),v=ct(t,r),g=i(!1),m=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let C=p.data;if(m.current===C)return;m.current=C;let E=g.current;if(g.current=!1,C.success){if(E)x(null);if(C.failures?.length)c(`${C.failures.length} item(s) could not be moved: ${C.failures[0].error}`);l()}else c(C.error||"The transfer did not complete")},[p.state,p.data]);let k=a((C,E)=>{g.current=E;let R=new FormData;for(let[N,T]of Object.entries(C))R.append(N,T);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((C)=>ft(h,v,Le(C.path,C.kind)),[h,v]),F=a((C,E)=>ut(C,Le(E.path,E.kind)),[]),A=a((C,E,R,N)=>{let T=new FormData;T.append("actionType","paste"),T.append("mode",R),T.append("targetPath",E.path),T.append("targetKind",E.kind);for(let H of C)T.append("sourcePath",H.path);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);g.current=N,p.submit(T,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:h,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:F,copy:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"copy"})},cut:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"cut"})},duplicate:(C)=>{k({actionType:"duplicate",path:C.path},!1)},move:(C,E)=>{let R=F(C,E);if(R){c(R);return}A([C],E,"cut",Boolean(h?.mode==="cut"&&h.entries.some((N)=>N.path===C.path)))},paste:(C)=>{if(!h)return;let E=y(C);if(E){c(E);return}A(h.entries.map(({path:R,name:N,kind:T})=>({path:R,name:N,kind:T})),C,h.mode,h.mode==="cut")}}}var kn=Oe.map((t)=>({...t,available:!0,tool:t.id}));function Wt({rootPath:t,repo:r,onComplete:l}){let c=st(),[p,f]=n(kn),[x,h]=n(null),[v,g]=n(null),[m,k]=n(null),y=i(null),F=i(null);o(()=>{let N=!1;return(async()=>{try{let H=await(await fetch("/api/fs/archive")).json();if(!N&&Array.isArray(H.formats)&&H.formats.length>0)f(H.formats)}catch{}})(),()=>{N=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let N=c.data;if(F.current===N)return;F.current=N;let T=y.current;if(y.current=null,N.success){if(k(null),T==="compress")h(null);if(T==="extract")g(null);l()}else if(T)k(N.error||"The archive request failed")},[c.state,c.data]);let A=a((N)=>{let T=new FormData;for(let[H,W]of Object.entries(N))T.append(H,W);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);c.submit(T,{method:"post",action:"/api/fs/action"})},[c,r,t]),C=a((N)=>{if(N.length===0)return;let T=p.find((H)=>H.id==="zip"&&H.available)?.id??p.find((H)=>H.available)?.id??"zip";k(null),g(null),h({entries:N.map(({path:H,name:W,kind:ee})=>({path:H,name:W,kind:ee})),format:T,name:Re(N,T),destination:Ct(N)})},[p]),E=a((N)=>{k(null),h(null),g({archive:N,destination:Ft(N.path)})},[]),R=a((N)=>{h((T)=>{if(!T)return T;let H=Re(T.entries,T.format),W=T.name===H?Re(T.entries,N):T.name;return{...T,format:N,name:W}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:C,openExtract:E,setFormat:R,setName:(N)=>h((T)=>T&&{...T,name:N}),setCompressDestination:(N)=>h((T)=>T&&{...T,destination:N}),setExtractDestination:(N)=>g((T)=>T&&{...T,destination:N}),cancel:()=>{h(null),g(null),k(null)},submitCompress:()=>{let N=x;if(!N)return;y.current="compress",k(null),A({actionType:"compress",format:N.format,name:N.name.trim(),destination:N.destination.trim()||".",paths:JSON.stringify(N.entries.map((T)=>T.path))})},submitExtract:()=>{let N=v;if(!N)return;y.current="extract",k(null),A({actionType:"extract",path:N.archive.path,destination:N.destination.trim()||"."})}}}function Cn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function Fn(t,r,l){if(!r)return[l];let c=t.indexOf(r),p=t.indexOf(l);if(c===-1||p===-1)return[l];let f=Math.min(c,p),x=Math.max(c,p);return t.slice(f,x+1)}function Ut(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(Fn(t,c,m)));return}if(p(m),g==="toggle"){l((k)=>{let y=new Set(k);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),v=a(Cn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:h}),[r,c,v,f,x,h])}function Ke(t,r,l=0,c=[]){for(let p of t)if(c.push({path:p.path,name:p.name,kind:p.type==="folder"?"folder":"file",depth:l}),p.type==="folder"&&r(p)&&Array.isArray(p.children))Ke(p.children,r,l+1,c);return c}function Xt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,g)=>{let m=lt(g,v);if(m.length===0)return;r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let g=t.insertEntry(v);if(!g){c();return}f(v.path,g)},[t,c,f]),h=a((v,g)=>{p?.(v,g),r((k)=>{let y=Ht(k,v,g);return l(Array.from(y)),y});let m=t.moveEntry(v,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:h}}var Nn=new Set;function Vt({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let g=Me(v.path,v.name);if(!g)return;p((k)=>{let y=k.scope===t?k.chains:new Map;if(y.get(v.path)?.length===g.length)return k;let A=new Map(y);return A.set(v.path,g),{scope:t,chains:A}});let m=g.slice(0,-1);r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let g=c.scope===t?c.chains.get(v):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let y=new Map(k.chains);return y.delete(v),{scope:t,chains:y}}),r((k)=>{if(!m.some((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.delete(F);return l(Array.from(y)),y})},[t,c,r,l]),h=a((v,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,y=[],F=!1;for(let[A,C]of m){if(C.findIndex((T,H)=>T===v&&H>0&&H<C.length-1)!==-1){F=!0;continue}let R=C.map((T)=>T===v?g:T.startsWith(`${v}/`)?`${g}${T.slice(v.length)}`:T),N=R[R.length-1];if(N!==A||R.some((T,H)=>T!==C[H]))F=!0;k.set(N,R),y.push(...R.slice(0,-1))}if(!F)return;p({scope:t,chains:k}),r((A)=>{if(y.every((E)=>A.has(E)))return A;let C=new Set(A);for(let E of y)C.add(E);return l(Array.from(C)),C})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):Nn,unfold:f,fold:x,rekey:h}}function qt(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let x=(p.children||[]).map(c).filter((h)=>h!==null);if(f||x.length>0)return{...p,children:f&&x.length===0?p.children:x,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Bt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return o(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(x)=>{if(!x.currentTarget.contains(x.relatedTarget))f(!1)},onDragOver:(x)=>{if(!c)return;if(x.preventDefault(),x.dataTransfer)x.dataTransfer.dropEffect="move"},onDrop:(x)=>{if(!c)return;x.preventDefault(),f(!1),r.move(t,l)}}}function ci({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[h,v]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[y,F]=n(()=>new Set(g)),{activeRepo:A,setActiveRepo:C}=lr(c),{repos:E,scanning:R,rescan:N}=cr(c,r),{fileMap:T,folderMap:H,refreshGitStatus:W}=Fs(c,A,r),[ee,te]=n(null),ae=i(null);o(()=>{if(!k)return;F((P)=>{let Z=new Set(g);if(P.size===Z.size&&Array.from(Z).every((me)=>P.has(me)))return P;return Z})},[k,g]);let G=Kt({enabled:r,rootPath:c,activeRepo:A,expandedPaths:y,onExpansionPruned:(P)=>{F(P),m(Array.from(P))}});o(()=>{if(!k||!l)return;G.reload()},[f,c,r,A,k,l]);let I=r&&k?zg(G.scope):null,z=we(I);o(()=>{if(z.data)G.adoptRoot(z.data)},[z.data]);let K=(P)=>(W(),G.loadChildren(P)),j=(P,Z)=>{let me=new Set(y);if(Z)me.add(P);else me.delete(P);F(me),m(Array.from(me))},{unfolded:ne,unfold:q,fold:V,rekey:J}=Vt({scope:G.scope,setExpandedPaths:F,setStoredExpandedPaths:m}),se=G.files,he=ot(se,ne),Q=qt(he.nodes,h),fe=Ke(Q,(P)=>P.forceExpanded!==void 0?P.forceExpanded:y.has(P.path)),le=Ut(fe.map((P)=>P.path)),xe=fe.filter((P)=>le.selected.has(P.path)).map(({path:P,name:Z,kind:me})=>({path:P,name:Z,kind:me})),M=(P)=>{if(P===A)return;G.reset(),F(new Set),m([]),le.clear(),C(P)},_=()=>{if(W(),x)x();else G.reload()},{insertCreated:ce,moveRenamed:ye}=Xt({listing:G,setExpandedPaths:F,setStoredExpandedPaths:m,reload:_,onMoved:(P,Z)=>J(P,Z)}),be=Ru(),{pushToast:U}=je(),Y=_t({rootPath:c,repo:A,onComplete:_,onError:(P)=>U(P,"error")}),ke=Wt({rootPath:c,repo:A,onComplete:_}),ve={path:".",name:".",kind:"folder"},de=Y.clip&&!Y.refusalFor(ve)?`Paste ${De(Y.clip)??"item"}`:null,[X,ge]=n(null),ue=Bt({dragging:X,clipboard:Y,target:ve}),Te=Ne({folderPath:".",rootPath:c,repo:A,onCreated:ce,onOpenCreated:(P)=>p?.({...P,root:c,repo:A})}),[_e,Qt]=n(!1);o(()=>Qt(!0),[]);let{count:We,clear:Ue}=le;if(o(()=>{if(!l)return;let P=(Z)=>{if(Z.key==="Escape"&&We>0)Ue()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[l,We,Ue]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let Yt=G.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Ye,{rootPath:c,activeRepo:A,repos:E,reposScanning:R,onRefreshRepos:N,onSelectRepo:M,searchQuery:h,onSearchChange:v,onRefresh:_,refreshing:Yt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(P)=>{P.preventDefault(),te({x:P.clientX,y:P.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:G.isLoading&&Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Q.map((P)=>e(Pe,{file:P,rootPath:c,basePath:G.root,repo:A,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:ce,onRenamed:ye,expandedPaths:y,onToggleFolder:j,gitFileMap:T,gitFolderMap:H,clipboard:Y,archive:ke,selection:le,selectionTargets:xe,dragging:X,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!X)return;Y.move(X,Z)},onUnfold:q,onFold:V,foldRoots:he.roots,touch:be},P.path))}),e(Lt,{}),_e&&e(At,{menu:ee,menuRef:ae,pasteLabel:de,busy:Y.busy,create:Te,onAction:(P)=>{if(te(null),P==="new_file")Te.openDialog("file");if(P==="new_folder")Te.openDialog("folder");if(P==="paste")Y.paste(ve)}}),_e&&e(Mt,{archive:ke})]})}export{ci as FileExplorer};
1
+ import{d,n,o,i,u,a,br,$e,oe,e,Wn,w,zg,we,Fs,S,lr,cr,s,Dn,L,Xe,B,ie,re,Ce,qe,ei,on,ti,Wr,D,O,b,mt,at,pe,jt,Pu,it,st,Xg,eA,Hi,Wi,Ou,je}from"./index-4c2zcvem.js";import{Du,Ko,Qu,Nu}from"./index-4ry8kz8h.js";import{Ns,hr,Ru}from"./index-fjqp03xe.js";var Jt={name:"pen",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],aliases:["edit-2"]},Ve=s(Jt);var Zt={name:"copy-plus",size:24,node:[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]},Be=s(Zt);var en={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Qe=s(en);var tn={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]},Se=s(tn);function Ye({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:h,onRefresh:v,refreshing:g}){return e("div",{className:"border-b border-ink/10",children:[e(mt,{className:"border-b-0",left:e(hr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(at,{label:"Refresh",onClick:v,busy:g})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(O,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:x,onChange:(m)=>h(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})})]})}function Je({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:h}){let v=f?"text-ink font-semibold":x?x.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(B,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ie,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(it,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var nn=28,rn=9,sn=8;function an(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:h,isArchive:v}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${k} to…`,icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${k}`,icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(ei,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(on,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(B,{size:13,className:"text-ink/60"})});if(x)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ie,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(qe,{size:13,className:"text-ink/60"})}),v)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Qe,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(ti,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(Ns,{size:13,className:"text-ink/60"}),disabled:p});return g.push({kind:"separator"}),g.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Ce,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Dn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ve,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(L,{size:13,className:"text-error"}),tone:"text-error"}),g}function ln(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*nn+l*rn+sn}function Ze({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:h,selectionCount:v,isArchive:g,onAction:m,menuRef:k}){let F=an({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:x,selectionCount:v,isArchive:g}),A=ln(F),C=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,E=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-A-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(R)=>{R.preventDefault(),m("close")},children:e("div",{ref:k,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:E,left:C},onClick:(R)=>R.stopPropagation(),children:F.map((R,N)=>R.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${N}`):e("button",{type:"button",disabled:R.disabled,onClick:()=>m(R.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${R.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${R.tone??""}`,children:[R.icon,e("span",{children:R.label})]},R.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:h}){let v=r==="folder"?"Folder":"File";return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",v]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(g)=>f(g.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${v.toLowerCase()} name`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${c?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Nested paths create the folders they need — ",e("span",{className:"font-mono",children:"lib/parse.ts"}),"."]}),c&&e("p",{className:"text-[11px] text-error mb-2",children:c}),e("div",{className:"flex justify-end space-x-2 mt-2",children:[e("button",{type:"button",onClick:x,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function et({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let h=c>1;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:x,className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 transition-colors flex items-center",disabled:p,children:p?"Deleting...":"Delete"})]})]})}),document.body)}function tt({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:h,onSubmit:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>x(g.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function nt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Dn,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,x)=>e("tr",{className:"hover:bg-ink/[0.03] transition-colors group",children:[e("td",{className:"px-3 py-2 text-ink",children:f.message?e("span",{className:"font-medium text-ink/90 group-hover:text-ink",children:f.message}):null}),e("td",{className:"px-3 py-2 text-ink/60 whitespace-nowrap font-mono text-[10.5px]",children:f.time}),e("td",{className:"px-3 py-2 text-ink/70 whitespace-nowrap truncate max-w-[120px]",children:f.author}),e("td",{className:"px-3 py-2 text-right",children:f.hash?e("span",{className:"font-mono text-ink/50 group-hover:text-ink font-semibold transition-colors bg-canvas px-1.5 py-0.5 rounded border border-ink/10",children:f.hash}):null})]},x))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(D,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function rt({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(et,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(tt,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(nt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(cn);return r.some((l,c)=>l!==t[c])?r:t}function cn(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Ee(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,x)=>[...p,...l.slice(0,x+1)].join("/"))}function ot(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((h)=>{if(h.type!=="folder")return[h];let v=Array.isArray(h.children)?p(h.children):h.children,g=v===h.children?h:{...h,children:v},m=r.has(h.path)?Me(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let k={...g,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let F=m[y-1];k={name:F.split("/").pop(),path:F,type:"folder",ignored:g.ignored,children:[k]}}return[k]}),f=p(t);return{nodes:c?f:t,roots:l}}function lt(t,r){let l=new Set,c=(x)=>{for(let h of x){if(h.type!=="folder")continue;if(l.add(h.path),Array.isArray(h.children))c(h.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let h=p.slice(0,x+1).join("/");if(l.has(h))f.push(h)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=st(),[x,h]=n(!1),[v,g]=n("file"),[m,k]=n(""),[y,F]=n(null),A=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let C=f.data;if(A.current===C)return;if(A.current=C,C.success&&C.path){let E=C.kind==="folder"?"folder":"file";h(!1),k(""),F(null);let R=C.path.split("/").pop()||C.path;if(c({path:C.path,name:R,kind:E}),E==="file")p?.({path:C.path,name:R})}else F(C.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:k,error:y,busy:f.state!=="idle",openDialog:(C="file")=>{g(C),k(""),F(null),h(!0)},closeDialog:()=>h(!1),submit:(C)=>{C.preventDefault();let E=m.trim();if(!E)return;F(null);let R=new FormData;if(R.append("actionType","create"),R.append("path",t),R.append("name",E),v==="folder")R.append("kind","folder");if(l&&l!==".")R.append("repo",l);if(r)R.append("root",r);f.submit(R,{method:"post",action:"/api/fs/action"})}}}function De(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function ct(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function dt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function pt(t,r){if(t.path===""||t.path===".")return"The workspace root cannot be moved or copied";if(t.kind==="folder"&&(r===t.path||r.startsWith(`${t.path}/`)))return"Cannot paste a folder into itself";return null}function ut(t,r){let l=pt(t,r);if(l)return l;if(r===dt(t.path))return"Already in this folder";return null}function ft(t,r,l){if(!t||t.entries.length===0)return"Nothing to paste";if(t.scope!==r)return"The clipboard holds an entry from another workspace";if(t.mode==="cut"&&t.entries.some((c)=>l===dt(c.path)))return"Already in this folder";for(let c of t.entries){let p=pt(c,l);if(p)return p}return null}function ht(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.scope!=="string")return null;if(r.mode!=="copy"&&r.mode!=="cut")return null;let l=Array.isArray(r.entries)?r.entries:typeof r.path==="string"?[{path:r.path,name:r.name,kind:r.kind}]:[],c=[];for(let p of l){let f=dn(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function dn(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.path!=="string"||typeof r.name!=="string")return null;if(r.kind!=="file"&&r.kind!=="folder")return null;let l=r.path.split("/");if(r.path===""||r.path.startsWith("/")||l.some((c)=>c===""||c==="."||c===".."))return null;return{path:r.path,name:r.name,kind:r.kind}}var Oe=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],gt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function ze(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return ze(t)!==null}function pn(t){return Oe.find((r)=>r.id===t)}function un(t){return pn(t)?.extension??"zip"}function xt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function vt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function yt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function kt(t){if(t.length===0)return".";let r=t.map((c)=>vt(c).split("/").filter((p)=>p!==".")),l=r[0]??[];for(let c of r.slice(1)){let p=0;while(p<l.length&&p<c.length&&l[p]===c[p])p+=1;l=l.slice(0,p)}return l.length===0?".":l.join("/")}function Re(t,r){let l=un(r);if(t.length===1){let f=t[0],x=xt(f.name),h=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?x.slice(0,h):x)||"archive"}.${l}`}let c=kt(t.map((f)=>f.path)),p=yt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ct(t){return kt(t.map((r)=>r.path))}function Ft(t){let r=vt(t),l=xt(yt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function Nt(t){return t.toUpperCase()}function wt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:h,clipboard:v,isFolder:g,selection:m,selected:k,archive:y}){let F=st(),[A,C]=n(null),E=i(null),[R,N]=n(!1),[T,H]=n(!1),[W,ee]=n(!1),[te,ae]=n(t.path),[G,I]=n(null),{repo:z,rootPath:K}=t,j=Ne({folderPath:t.path,rootPath:K,repo:z,onCreated:(M)=>p?p(M):c(),onOpenCreated:(M)=>l?.({...M,root:K,repo:z||"."})}),ne=i(null);o(()=>{if(F.state!=="idle"||!F.data)return;let M=F.data;if(ne.current===M)return;if(ne.current=M,M.success&&!M.type)if(N(!1),H(!1),I(null),M.previousPath&&M.path&&f)f(M.previousPath,M.path);else c();else if(!M.success&&M.error&&R)I(M.error)},[F.state,F.data]);let q=(M)=>{if(z&&z!==".")M.append("repo",z);if(K)M.append("root",K);F.submit(M,{method:"post",action:"/api/fs/action"})},V=()=>{l?.({path:t.path,name:t.name,root:K,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},se=k&&m.length>1?m:[J],he=bt(t.name),Q=v.clip&&!v.refusalFor(J)?`Paste ${De(v.clip)??"item"}`:null,fe=(M)=>{if(C(null),I(null),M==="view")V();else if(M==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:K}}));else if(M==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),q(_)}else if(M==="copy_path")jt(Pu(t.basePath,t.path));else if(M==="copy_relative")jt(t.path);else if(M==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),q(_)}else if(M==="rename")ae(t.path),N(!0);else if(M==="unfold")x?.();else if(M==="fold")h?.();else if(M==="new_file")j.openDialog("file");else if(M==="new_folder")j.openDialog("folder");else if(M==="delete")H(!0);else if(M==="cut")v.cut(se);else if(M==="copy")v.copy(se);else if(M==="compress")y.openCompress(se);else if(M==="extract")y.openExtract(J);else if(M==="duplicate")v.duplicate(J);else if(M==="paste")v.paste(J)},le=(M)=>{M.preventDefault(),I(null);let _=new FormData;_.append("actionType","rename"),_.append("path",t.path),_.append("newPath",te),q(_)},xe=()=>{let M=new FormData;if(M.append("actionType","delete"),se.length>1)M.append("paths",JSON.stringify(se.map((_)=>_.path)));else M.append("path",t.path);q(M)};return{contextMenu:A,contextMenuRef:E,openContextMenu:(M,_)=>C({x:M,y:_}),closeContextMenu:()=>C(null),showRenameModal:R,showDeleteModal:T,showHistoryModal:W,showCreateModal:j.open,createKind:j.kind,createError:j.error,createName:j.name,setCreateName:j.setName,renameValue:te,setRenameValue:ae,renameError:G,busy:F.state!=="idle"||j.busy||v.busy||y.busy,pasteLabel:Q,selectionCount:se.length,isArchive:he,chainLabel:x!==void 0,foldable:h!==void 0,fetcherState:F.state,fetcherData:F.data,handleAction:fe,submitCreate:j.submit,submitRename:le,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>N(!1),closeHistory:()=>ee(!1)}}function Dt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let h=r?.path===t.path,v=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:v,isDropHovered:g&&v,onDragStart:(y)=>{if(y.dataTransfer?.setData("text/plain",t.path),y.dataTransfer)y.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(y)=>{if(!r)return;if(y.stopPropagation(),m(v),!v)return;if(y.preventDefault(),y.dataTransfer)y.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>m(!1),onDrop:(y)=>{if(!r)return;if(y.stopPropagation(),!v)return;y.preventDefault(),f(t)}}}var fn=450,Rt=8,mn=700;function Tt({enabled:t,onLongPress:r}){let l=i(null),c=i(null),p=i(0),f=i(r);f.current=r;let x=a(()=>{if(l.current!==null)clearTimeout(l.current),l.current=null;c.current=null},[]);return o(()=>x,[x]),{onTouchStart:(h)=>{if(!t)return;let v=h.touches[0];if(!v)return;x(),c.current={x:v.clientX,y:v.clientY},l.current=setTimeout(()=>{l.current=null;let g=c.current;if(c.current=null,!g)return;p.current=Date.now(),f.current(g.x,g.y)},fn)},onTouchMove:(h)=>{let v=c.current,g=h.touches[0];if(!v||!g)return;if(Math.abs(g.clientX-v.x)>Rt||Math.abs(g.clientY-v.y)>Rt)x()},onTouchEnd:x,onTouchCancel:x,consume:()=>{if(p.current===0)return!1;let h=Date.now()-p.current<mn;return p.current=0,h}}}function hn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Pe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae=!1}){let G=t.type==="folder",[I,z]=n(!1),[K,j]=n(!1),[ne,q]=n(!1),[V,J]=n(!1),se=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!G?k?.get(he)||k?.get(t.path):void 0,fe=Q?Wn(Q.status,Q.staged):null,le=G?y?.get(he)||y?.get(t.path):null,xe=Boolean(fe),M=t.ignored===!0,_=g?g.has(t.path):I,ce=t.forceExpanded!==void 0?t.forceExpanded:_;o(()=>{J(!0)},[]),o(()=>{if(G&&g)z(g.has(t.path))},[g,t.path,G]),o(()=>{if(G&&ce&&hn(t,K,ne)&&p)q(!0),j(!0),Promise.resolve(p(t.path)).finally(()=>j(!1))},[G,ce,t.children,t.path,p,K,ne]);let ye={path:t.path,name:t.name,kind:G?"folder":"file"},be=C.selected.has(t.path),U=wt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:E,selected:be,archive:A,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,onUnfold:W&&Ee({type:G?"folder":"file",name:t.name})?()=>W(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:F,isFolder:G});pe(U.contextMenuRef,U.closeContextMenu);let Y=Tt({enabled:ae,onLongPress:(X,ge)=>U.openContextMenu(X,ge)}),ke=(X)=>{if(X.stopPropagation(),Y.consume())return;let ge=C.gestureOf(X);if(ge!=="plain"){C.applyGesture(ge,t.path);return}if(C.applyGesture("plain",t.path),G){let ue=!ce;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(X)=>{X.preventDefault(),X.stopPropagation(),C.ensureForContext(t.path),U.openContextMenu(X.clientX,X.clientY)},de=Dt({target:ye,dragging:R,clipboard:F,onDragStart:N,onDragEnd:T,onDropOn:H,onHoverAccept:W});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${de.isDragging?"opacity-40":""} ${de.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":be?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!ae,onClick:ke,onContextMenu:ve,onDragStart:de.onDragStart,onDragEnd:de.onDragEnd,onDragOver:de.onDragOver,onDragLeave:de.onDragLeave,onDrop:de.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Je,{name:t.name,path:t.path,isFolder:G,isOpen:ce,ignored:M,selected:be,gitStatus:fe,folderStatus:le})}),ce&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!K&&se.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:se.map((X)=>e(Pe,{file:X,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:h,onRenamed:v,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:y,clipboard:F,archive:A,selection:C,selectionTargets:E,dragging:R,onDragStart:N,onDragEnd:T,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae},X.path))}),V&&U.contextMenu&&e(Ze,{x:U.contextMenu.x,y:U.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:U.pasteLabel,chainLabel:U.chainLabel,foldable:U.foldable,busy:U.busy,selectionCount:U.selectionCount,isArchive:U.isArchive,onAction:U.handleAction}),V&&e(rt,{actions:U,file:t,isFolder:G,chainLabel:Ee({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function St({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:v},onClick:(m)=>m.stopPropagation(),children:[e("button",{type:"button",onClick:()=>p("new_file"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(ei,{size:13,className:"text-ink/60"}),e("span",{children:"New File"})]}),e("button",{type:"button",onClick:()=>p("new_folder"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(on,{size:13,className:"text-ink/60"}),e("span",{children:"New Folder"})]}),l&&e("button",{type:"button",disabled:c,onClick:()=>p("paste"),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${c?"opacity-40 cursor-default":"hover:bg-ink/5"}`,children:[e(Ns,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function At({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(St,{x:t.x,y:t.y,menuRef:r,pasteLabel:l,busy:c,onAction:p}),f.open&&e(Fe,{folderPath:".",kind:f.kind,value:f.name,error:f.error,isLoading:f.busy,onChange:f.setName,onCancel:f.closeDialog,onSubmit:f.submit})]})}function Et({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:h,children:v}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),v,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function gn({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:h,onNameChange:v,onDestinationChange:g,onCancel:m,onSubmit:k}){let y=t.slice(0,4).map((A)=>A.name).join(", "),F=t.length>4?` +${t.length-4} more`:"";return e(Et,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${F}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(A)=>{A.preventDefault(),k()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-format",children:"Format"}),e("select",{id:"archive-format",value:r,onChange:(A)=>h(A.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink mb-3",children:p.map((A)=>e("option",{value:A.id,disabled:!A.available,children:[A.label,A.available?"":` — ${A.tool} not installed`]},A.id))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(A)=>v(A.currentTarget.value),"aria-label":"Archive name",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-3 ${f?"border-error":"border-ink/20 focus:border-ink"}`}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-destination",children:"Destination folder"}),e("input",{id:"archive-destination",type:"text",value:c,onChange:(A)=>g(A.currentTarget.value),"aria-label":"Archive destination",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink"})]})}function bn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:h}){return e(Et,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:x,onSubmit:(v)=>{v.preventDefault(),h()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"extract-destination",children:"Extract to folder"}),e("input",{id:"extract-destination",autoFocus:!0,type:"text",value:l,onChange:(v)=>f(v.currentTarget.value),"aria-label":"Extract destination",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none ${c?"border-error":"border-ink/20 focus:border-ink"}`})]})}function Mt({archive:t}){if(t.compress)return e(gn,{entries:t.compress.entries,format:t.compress.format,name:t.compress.name,destination:t.compress.destination,formats:t.formats,error:t.error,busy:t.busy,onFormatChange:t.setFormat,onNameChange:t.setName,onDestinationChange:t.setCompressDestination,onCancel:t.cancel,onSubmit:t.submitCompress});if(t.extract)return e(bn,{archive:t.extract.archive,kindLabel:Nt(ze(t.extract.archive.name)??"zip"),destination:t.extract.destination,error:t.error,busy:t.busy,onDestinationChange:t.setExtractDestination,onCancel:t.cancel,onSubmit:t.submitExtract});return null}function Lt(){let[t,r]=S("files.outlineExpanded",!1),l=br(),c=$e(eA,Xg),{symbols:p,total:f,truncated:x,notice:h}=Nu({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let v=c.preview,g=(m,k)=>{if(!c.path)return;if(v){let y=Ou(p,k);if(y)Wi({path:c.path,...y});return}Hi({path:c.path,line:m.line,column:m.column,length:m.name.length})};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:e("button",{type:"button",onClick:()=>r(!t),"aria-expanded":t,"aria-controls":l,"aria-label":"Outline",title:t?"Hide outline":"Show outline",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:t?"▾":"▸"}),e(Wr,{size:12}),e("span",{children:"Outline"}),f>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:x?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:h}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,k)=>e("button",{type:"button",onClick:()=>g(m,k),"aria-label":v?`${Ko(m.kind)} ${m.name}`:`${Ko(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${Ko(m.kind).toLowerCase()}`:`${Ko(m.kind)} · line ${m.line}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors hover:bg-ink/5 active:bg-ink/10",style:{paddingLeft:`${4+m.depth*12}px`},children:[e(Du,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!v&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),x&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Qu(f)})]})})})})]})}function Ie(t,r){return Ae(t.map((l)=>xn(l,r)))}function xn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Ie(l,r)}}function vn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function Ot(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function $t(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function He(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},h=f,v=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),k=h.find((E)=>E.type==="folder"&&E.path===m),y=k?null:h.find((E)=>E.type==="folder"&&E.path.startsWith(`${m}/`)&&(p===E.path||p.startsWith(`${E.path}/`))),F=k??y,A=F?x[F.path]??F.children:null;if(F&&!Array.isArray(A))return{nodes:t,cache:r};if(!F){let E=yn(h,x,m);if(E){h=E;let R=h.find((T)=>T.path===m),N=Array.isArray(R?.children)?[...R.children]:[];x[m]=N,h=N,v=m,g+=1;continue}}let C=Array.isArray(A)?[...A]:[];if(F){x[F.path]=C,h=C,v=F.path,g=F.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),x[m]=C,h=C,v=m,g+=1}if(h.push(l),v!==null)x[v]=$t(h);return f=$t(f),{nodes:f,cache:x}}function yn(t,r,l){let c=t.findIndex((v)=>v.type==="folder"&&v.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),x=r[p.path]??p.children;if(Array.isArray(x))r[p.path]=x;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let v=f.length-2;v>=0;v-=1)h={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:Ot(l),path:l,type:"folder",ignored:!1,children:[h]},t}function zt(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=vn(l),f=r[p],x=f?.find((m)=>m.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let v=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let g=r[v];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:g.filter((m)=>m.path!==l)}}}function Pt(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?Pt(f.children,r,l):void 0;if(!x&&h===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=x?{...f,path:v,name:Ot(v)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function It(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let x=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[x]=x===p?f:Pt(f,r,l)}return c}function Ht(t,r,l){let c=new Set;for(let p of t)if(p===r)c.add(l);else if(p.startsWith(`${r}/`))c.add(`${l}${p.slice(r.length)}`);else c.add(p);return c}function Gt(t){if(!w(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>w(r)):[],root:t.root}}async function Ge(t){try{return Gt(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Kt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,h]=n({scope:"",files:[],root:""}),[v,g]=n(!1),m=i({}),k=i([]),y=i(f);y.current=f;let F=i(""),A=i(""),C=i(c);C.current=c;let E=(I)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(I)z.set("path",I);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},R=(I,z)=>{F.current=I,A.current=z;let K=Ie(k.current,m.current);return h({scope:I,files:K,root:z}),K},N=async(I)=>{let z=[...C.current];if(z.length===0)return;let K=await Promise.all(z.map(async(V)=>({path:V,read:await Ge(E(V))})));if(y.current!==I)return;let j=[];for(let{path:V,read:J}of K)if(J.status==="ok")m.current[V]=J.files;else if(J.status==="missing")j.push(V);if(j.length===0)return;let ne=new Set(j);for(let V of j)delete m.current[V];let q=new Set([...C.current].filter((V)=>!ne.has(V)));C.current=q,p(q)},T=async()=>{if(!t)return;let I=y.current;g(!0);try{let z=await Ge(E());if(y.current!==I)return;if(z.status!=="ok")return;if(F.current!==I)m.current={};if(k.current=z.files,R(I,z.root),await N(I),y.current!==I)return;R(I,z.root)}finally{if(y.current===I)g(!1)}},H=async(I)=>{let z=y.current,K=await Ge(E(I));if(y.current!==z||K.status!=="ok")return;if(m.current[I]=K.files,F.current===z)R(z,A.current)},W=(I)=>{let z=Gt(I);if(z.status!=="ok")return;let K=y.current;if(F.current!==K)m.current={};k.current=z.files,R(K,z.root),N(K).then(()=>{if(y.current===K)R(K,z.root)})},ee=()=>{m.current={},k.current=[],F.current="",A.current="",h({scope:"",files:[],root:""})},te=(I)=>{let z=y.current;if(F.current!==z)return null;let K={name:I.path.slice(I.path.lastIndexOf("/")+1),path:I.path,type:I.kind,ignored:!1},j=He(k.current,m.current,K);if(j.nodes===k.current)return null;return k.current=j.nodes,m.current=j.cache,R(z,A.current)},ae=(I,z)=>{let K=y.current;if(F.current!==K)return null;let j=zt(k.current,m.current,I);if(!j.entry)return null;m.current=It(j.cache,I,z);let ne={...j.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=He(j.nodes,m.current,ne);return k.current=q.nodes,m.current=q.cache,R(K,A.current)},G=x.scope===f;return{scope:f,files:G?x.files:[],root:G?x.root:"",isLoading:v,reload:T,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:ae,reset:ee}}function _t({rootPath:t,repo:r,onComplete:l,onError:c}){let p=st(),[f,x]=S("files.clipboard",null),h=ht(f),v=ct(t,r),g=i(!1),m=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let C=p.data;if(m.current===C)return;m.current=C;let E=g.current;if(g.current=!1,C.success){if(E)x(null);if(C.failures?.length)c(`${C.failures.length} item(s) could not be moved: ${C.failures[0].error}`);l()}else c(C.error||"The transfer did not complete")},[p.state,p.data]);let k=a((C,E)=>{g.current=E;let R=new FormData;for(let[N,T]of Object.entries(C))R.append(N,T);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((C)=>ft(h,v,Le(C.path,C.kind)),[h,v]),F=a((C,E)=>ut(C,Le(E.path,E.kind)),[]),A=a((C,E,R,N)=>{let T=new FormData;T.append("actionType","paste"),T.append("mode",R),T.append("targetPath",E.path),T.append("targetKind",E.kind);for(let H of C)T.append("sourcePath",H.path);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);g.current=N,p.submit(T,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:h,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:F,copy:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"copy"})},cut:(C)=>{if(C.length===0)return;x({scope:v,entries:C.map(({path:E,name:R,kind:N})=>({path:E,name:R,kind:N})),mode:"cut"})},duplicate:(C)=>{k({actionType:"duplicate",path:C.path},!1)},move:(C,E)=>{let R=F(C,E);if(R){c(R);return}A([C],E,"cut",Boolean(h?.mode==="cut"&&h.entries.some((N)=>N.path===C.path)))},paste:(C)=>{if(!h)return;let E=y(C);if(E){c(E);return}A(h.entries.map(({path:R,name:N,kind:T})=>({path:R,name:N,kind:T})),C,h.mode,h.mode==="cut")}}}var kn=Oe.map((t)=>({...t,available:!0,tool:t.id}));function Wt({rootPath:t,repo:r,onComplete:l}){let c=st(),[p,f]=n(kn),[x,h]=n(null),[v,g]=n(null),[m,k]=n(null),y=i(null),F=i(null);o(()=>{let N=!1;return(async()=>{try{let H=await(await fetch("/api/fs/archive")).json();if(!N&&Array.isArray(H.formats)&&H.formats.length>0)f(H.formats)}catch{}})(),()=>{N=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let N=c.data;if(F.current===N)return;F.current=N;let T=y.current;if(y.current=null,N.success){if(k(null),T==="compress")h(null);if(T==="extract")g(null);l()}else if(T)k(N.error||"The archive request failed")},[c.state,c.data]);let A=a((N)=>{let T=new FormData;for(let[H,W]of Object.entries(N))T.append(H,W);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);c.submit(T,{method:"post",action:"/api/fs/action"})},[c,r,t]),C=a((N)=>{if(N.length===0)return;let T=p.find((H)=>H.id==="zip"&&H.available)?.id??p.find((H)=>H.available)?.id??"zip";k(null),g(null),h({entries:N.map(({path:H,name:W,kind:ee})=>({path:H,name:W,kind:ee})),format:T,name:Re(N,T),destination:Ct(N)})},[p]),E=a((N)=>{k(null),h(null),g({archive:N,destination:Ft(N.path)})},[]),R=a((N)=>{h((T)=>{if(!T)return T;let H=Re(T.entries,T.format),W=T.name===H?Re(T.entries,N):T.name;return{...T,format:N,name:W}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:C,openExtract:E,setFormat:R,setName:(N)=>h((T)=>T&&{...T,name:N}),setCompressDestination:(N)=>h((T)=>T&&{...T,destination:N}),setExtractDestination:(N)=>g((T)=>T&&{...T,destination:N}),cancel:()=>{h(null),g(null),k(null)},submitCompress:()=>{let N=x;if(!N)return;y.current="compress",k(null),A({actionType:"compress",format:N.format,name:N.name.trim(),destination:N.destination.trim()||".",paths:JSON.stringify(N.entries.map((T)=>T.path))})},submitExtract:()=>{let N=v;if(!N)return;y.current="extract",k(null),A({actionType:"extract",path:N.archive.path,destination:N.destination.trim()||"."})}}}function Cn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function Fn(t,r,l){if(!r)return[l];let c=t.indexOf(r),p=t.indexOf(l);if(c===-1||p===-1)return[l];let f=Math.min(c,p),x=Math.max(c,p);return t.slice(f,x+1)}function Ut(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(Fn(t,c,m)));return}if(p(m),g==="toggle"){l((k)=>{let y=new Set(k);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),v=a(Cn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:h}),[r,c,v,f,x,h])}function Ke(t,r,l=0,c=[]){for(let p of t)if(c.push({path:p.path,name:p.name,kind:p.type==="folder"?"folder":"file",depth:l}),p.type==="folder"&&r(p)&&Array.isArray(p.children))Ke(p.children,r,l+1,c);return c}function Xt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,g)=>{let m=lt(g,v);if(m.length===0)return;r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let g=t.insertEntry(v);if(!g){c();return}f(v.path,g)},[t,c,f]),h=a((v,g)=>{p?.(v,g),r((k)=>{let y=Ht(k,v,g);return l(Array.from(y)),y});let m=t.moveEntry(v,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:h}}var Nn=new Set;function Vt({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let g=Me(v.path,v.name);if(!g)return;p((k)=>{let y=k.scope===t?k.chains:new Map;if(y.get(v.path)?.length===g.length)return k;let A=new Map(y);return A.set(v.path,g),{scope:t,chains:A}});let m=g.slice(0,-1);r((k)=>{if(m.every((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.add(F);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let g=c.scope===t?c.chains.get(v):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let y=new Map(k.chains);return y.delete(v),{scope:t,chains:y}}),r((k)=>{if(!m.some((F)=>k.has(F)))return k;let y=new Set(k);for(let F of m)y.delete(F);return l(Array.from(y)),y})},[t,c,r,l]),h=a((v,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,y=[],F=!1;for(let[A,C]of m){if(C.findIndex((T,H)=>T===v&&H>0&&H<C.length-1)!==-1){F=!0;continue}let R=C.map((T)=>T===v?g:T.startsWith(`${v}/`)?`${g}${T.slice(v.length)}`:T),N=R[R.length-1];if(N!==A||R.some((T,H)=>T!==C[H]))F=!0;k.set(N,R),y.push(...R.slice(0,-1))}if(!F)return;p({scope:t,chains:k}),r((A)=>{if(y.every((E)=>A.has(E)))return A;let C=new Set(A);for(let E of y)C.add(E);return l(Array.from(C)),C})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):Nn,unfold:f,fold:x,rekey:h}}function qt(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let x=(p.children||[]).map(c).filter((h)=>h!==null);if(f||x.length>0)return{...p,children:f&&x.length===0?p.children:x,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Bt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return o(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(x)=>{if(!x.currentTarget.contains(x.relatedTarget))f(!1)},onDragOver:(x)=>{if(!c)return;if(x.preventDefault(),x.dataTransfer)x.dataTransfer.dropEffect="move"},onDrop:(x)=>{if(!c)return;x.preventDefault(),f(!1),r.move(t,l)}}}function ci({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[h,v]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[y,F]=n(()=>new Set(g)),{activeRepo:A,setActiveRepo:C}=lr(c),{repos:E,scanning:R,rescan:N}=cr(c,r),{fileMap:T,folderMap:H,refreshGitStatus:W}=Fs(c,A,r),[ee,te]=n(null),ae=i(null);o(()=>{if(!k)return;F((P)=>{let Z=new Set(g);if(P.size===Z.size&&Array.from(Z).every((me)=>P.has(me)))return P;return Z})},[k,g]);let G=Kt({enabled:r,rootPath:c,activeRepo:A,expandedPaths:y,onExpansionPruned:(P)=>{F(P),m(Array.from(P))}});o(()=>{if(!k||!l)return;G.reload()},[f,c,r,A,k,l]);let I=r&&k?zg(G.scope):null,z=we(I);o(()=>{if(z.data)G.adoptRoot(z.data)},[z.data]);let K=(P)=>(W(),G.loadChildren(P)),j=(P,Z)=>{let me=new Set(y);if(Z)me.add(P);else me.delete(P);F(me),m(Array.from(me))},{unfolded:ne,unfold:q,fold:V,rekey:J}=Vt({scope:G.scope,setExpandedPaths:F,setStoredExpandedPaths:m}),se=G.files,he=ot(se,ne),Q=qt(he.nodes,h),fe=Ke(Q,(P)=>P.forceExpanded!==void 0?P.forceExpanded:y.has(P.path)),le=Ut(fe.map((P)=>P.path)),xe=fe.filter((P)=>le.selected.has(P.path)).map(({path:P,name:Z,kind:me})=>({path:P,name:Z,kind:me})),M=(P)=>{if(P===A)return;G.reset(),F(new Set),m([]),le.clear(),C(P)},_=()=>{if(W(),x)x();else G.reload()},{insertCreated:ce,moveRenamed:ye}=Xt({listing:G,setExpandedPaths:F,setStoredExpandedPaths:m,reload:_,onMoved:(P,Z)=>J(P,Z)}),be=Ru(),{pushToast:U}=je(),Y=_t({rootPath:c,repo:A,onComplete:_,onError:(P)=>U(P,"error")}),ke=Wt({rootPath:c,repo:A,onComplete:_}),ve={path:".",name:".",kind:"folder"},de=Y.clip&&!Y.refusalFor(ve)?`Paste ${De(Y.clip)??"item"}`:null,[X,ge]=n(null),ue=Bt({dragging:X,clipboard:Y,target:ve}),Te=Ne({folderPath:".",rootPath:c,repo:A,onCreated:ce,onOpenCreated:(P)=>p?.({...P,root:c,repo:A})}),[_e,Qt]=n(!1);o(()=>Qt(!0),[]);let{count:We,clear:Ue}=le;if(o(()=>{if(!l)return;let P=(Z)=>{if(Z.key==="Escape"&&We>0)Ue()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[l,We,Ue]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let Yt=G.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Ye,{rootPath:c,activeRepo:A,repos:E,reposScanning:R,onRefreshRepos:N,onSelectRepo:M,searchQuery:h,onSearchChange:v,onRefresh:_,refreshing:Yt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(P)=>{P.preventDefault(),te({x:P.clientX,y:P.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:G.isLoading&&Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Q.map((P)=>e(Pe,{file:P,rootPath:c,basePath:G.root,repo:A,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:ce,onRenamed:ye,expandedPaths:y,onToggleFolder:j,gitFileMap:T,gitFolderMap:H,clipboard:Y,archive:ke,selection:le,selectionTargets:xe,dragging:X,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!X)return;Y.move(X,Z)},onUnfold:q,onFold:V,foldRoots:he.roots,touch:be},P.path))}),e(Lt,{}),_e&&e(At,{menu:ee,menuRef:ae,pasteLabel:de,busy:Y.busy,create:Te,onAction:(P)=>{if(te(null),P==="new_file")Te.openDialog("file");if(P==="new_folder")Te.openDialog("folder");if(P==="paste")Y.paste(ve)}}),_e&&e(Mt,{archive:ke})]})}export{ci as FileExplorer};
@@ -1 +1 @@
1
- import{zn,Po,Om,as,ci,nl,Xu,rl,rg,ed,$m,zm,Um,Gm,ch,al,td,uh,nd,Tr,dh}from"./index-3fw3sd10.js";export{rl as IndentContext,dh as StreamLanguage,nd as bracketMatching,al as codeFolding,Um as foldAll,$m as foldCode,td as foldGutter,ch as foldKeymap,ed as foldService,ci as getIndentUnit,Xu as getIndentation,uh as highlightingFor,rg as indentOnInput,Om as indentService,nl as indentString,as as indentUnit,Po as language,Tr as matchBrackets,zn as syntaxTree,Gm as unfoldAll,zm as unfoldCode};
1
+ import{zn,Po,Om,as,ci,nl,Xu,rl,rg,ed,$m,zm,Um,Gm,ch,al,td,uh,nd,Tr,dh}from"./index-4c2zcvem.js";export{rl as IndentContext,dh as StreamLanguage,nd as bracketMatching,al as codeFolding,Um as foldAll,$m as foldCode,td as foldGutter,ch as foldKeymap,ed as foldService,ci as getIndentUnit,Xu as getIndentation,uh as highlightingFor,rg as indentOnInput,Om as indentService,nl as indentString,as as indentUnit,Po as language,Tr as matchBrackets,zn as syntaxTree,Gm as unfoldAll,zm as unfoldCode};
@@ -1,4 +1,4 @@
1
- import{t,l,ut,la,x,R,F,z,P,U,q,j,p,ca,_i,h,or,ir,K,kn,dt,Ye,Je,qn,jl,Tt,Dt,In,Qt,pt}from"./index-61qjr1k0.js";import{Lt}from"./index-3fw3sd10.js";import{La}from"./index-4pehdq5h.js";var h1="flowchart-",d1=class{constructor(){this.vertexCounter=0,this.config=p(),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=F,this.setAccDescription=P,this.setDiagramTitle=q,this.getAccTitle=z,this.getAccDescription=U,this.getDiagramTitle=j,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 x.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,k,c={},A){if(!e||e.trim().length===0)return;let f;if(A!==void 0){let T;if(!A.includes(`
1
+ import{t,l,ut,la,x,R,F,z,P,U,q,j,p,ca,_i,h,or,ir,K,kn,dt,Ye,Je,qn,jl,Tt,Dt,In,Qt,pt}from"./index-y5ymgp20.js";import{Lt}from"./index-4c2zcvem.js";import{La}from"./index-f1nqk6z6.js";var h1="flowchart-",d1=class{constructor(){this.vertexCounter=0,this.config=p(),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=F,this.setAccDescription=P,this.setDiagramTitle=q,this.getAccTitle=z,this.getAccDescription=U,this.getDiagramTitle=j,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 x.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,k,c={},A){if(!e||e.trim().length===0)return;let f;if(A!==void 0){let T;if(!A.includes(`
2
2
  `))T=`{
3
3
  `+A+`
4
4
  }`;else T=A+`