@kabmo-labs/kabmo 0.53.1 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +529 -518
  3. package/dist/client/static/js/{Body-3v975hq3.js → Body-x5grdps8.js} +1 -1
  4. package/dist/client/static/js/{CsvGrid-8xcj58sw.js → CsvGrid-248v9yzf.js} +1 -1
  5. package/dist/client/static/js/{DocxView-fwmfpsg7.js → DocxView-5we92k2h.js} +1 -1
  6. package/dist/client/static/js/{DrawioView-gdtqj2vv.js → DrawioView-c6xmw4qq.js} +1 -1
  7. package/dist/client/static/js/{HtmlPreview-g4bp5mgq.js → HtmlPreview-r3qxgqg6.js} +1 -1
  8. package/dist/client/static/js/{ImageView-5e3vdyc9.js → ImageView-cr4fea18.js} +1 -1
  9. package/dist/client/static/js/{LayoutWrapper-ssxr6q2d.js → LayoutWrapper-j12z0djx.js} +2 -2
  10. package/dist/client/static/js/MergeDiffView-y0we0194.js +1 -0
  11. package/dist/client/static/js/{Modal-px8tcv9m.js → Modal-cqceypcn.js} +11 -11
  12. package/dist/client/static/js/{PdfView-92rx0s88.js → PdfView-xdgn31cm.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-s3d9nceb.js → SessionsView-ms6z44e2.js} +1 -1
  14. package/dist/client/static/js/{SheetView-yeg7gtf9.js → SheetView-peqm9vft.js} +1 -1
  15. package/dist/client/static/js/{SvgPreview-6evr72fg.js → SvgPreview-rdf4wbzr.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-a6n0cab2.js → abnfDiagram-O67JEVCF-48z2x5vg.js} +1 -1
  17. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-z9k17qfg.js → architectureDiagram-NJMV4G6O-n1pr5s6j.js} +1 -1
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-63d683v3.js → blockDiagram-BEXU5L5S-p19shaft.js} +1 -1
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-5bk6kv13.js → c4Diagram-YGBWAQC7-qcd46ts2.js} +1 -1
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-s6rmr6vt.js → classDiagram-v2-NBCMYWYE-scyhe133.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-wd5v7q2m.js → cose-bilkent-JH36ORCC-srnnj3f7.js} +1 -1
  22. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-j71tvbhy.js → cynefinDiagram-VND7K2PF-1zfrnyay.js} +1 -1
  23. package/dist/client/static/js/{dagre-6A5THRUB-q6x3d9xb.js → dagre-6A5THRUB-hepk25pz.js} +1 -1
  24. package/dist/client/static/js/{diagram-22UHCM2B-g6e427jm.js → diagram-22UHCM2B-wy2y0323.js} +1 -1
  25. package/dist/client/static/js/{diagram-3UASUU5V-rg3nty46.js → diagram-3UASUU5V-j904f93p.js} +1 -1
  26. package/dist/client/static/js/{diagram-ATOU4E4O-m82xv6ka.js → diagram-ATOU4E4O-2mmxccm2.js} +2 -2
  27. package/dist/client/static/js/{diagram-CDSNMT55-q3aa8sv0.js → diagram-CDSNMT55-cfhk73ty.js} +3 -3
  28. package/dist/client/static/js/{diagram-MLGK6HIB-nkyd150x.js → diagram-MLGK6HIB-ryf8j6hf.js} +1 -1
  29. package/dist/client/static/js/{diagram-MPIPVDR6-1gchkss2.js → diagram-MPIPVDR6-8k5e36sd.js} +2 -2
  30. package/dist/client/static/js/{dockerfile-f51g7549.js → dockerfile-1e7deann.js} +1 -1
  31. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4dsm3p06.js → ebnfDiagram-ZINNZB2B-5kkbbbhv.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-d8wtwxae.js → elk-276RUBZZ-jqc4mzvc.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-bq865cmc.js → erDiagram-OPXOYQCR-kx15t6f0.js} +1 -1
  34. package/dist/client/static/js/flowDiagram-KWPJA3E3-dpjz82p8.js +1 -0
  35. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ndnqbbzn.js → ganttDiagram-FUAMR5RP-3hv8pej4.js} +1 -1
  36. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-d9y6fnz0.js → gitGraphDiagram-X574FWY7-a4mq8vwz.js} +2 -2
  37. package/dist/client/static/js/{index-z0vvdpkv.js → index-01rdknec.js} +1 -1
  38. package/dist/client/static/js/{index-0ccj7j87.js → index-0j5ng1qc.js} +1 -1
  39. package/dist/client/static/js/{index-gm9cqsqg.js → index-0z7kerp1.js} +1 -1
  40. package/dist/client/static/js/{index-f7sssx5h.js → index-1ye834yz.js} +1 -1
  41. package/dist/client/static/js/{index-h9p3748x.js → index-317v49ey.js} +2 -2
  42. package/dist/client/static/js/{index-046kc8ft.js → index-3kenmzbe.js} +1 -1
  43. package/dist/client/static/js/{index-k8ks184k.js → index-40fdtqvw.js} +1 -1
  44. package/dist/client/static/js/{index-8k568z0z.js → index-40ydm28n.js} +1 -1
  45. package/dist/client/static/js/{index-0fpc1h6v.js → index-51wzt3ma.js} +1 -1
  46. package/dist/client/static/js/{index-7jr49rd4.js → index-8hnem33f.js} +1 -1
  47. package/dist/client/static/js/{index-6pxh5p8g.js → index-937bn0d2.js} +1 -1
  48. package/dist/client/static/js/{index-049xtm14.js → index-9cr6p86f.js} +1 -1
  49. package/dist/client/static/js/{index-7fkdwm69.js → index-9gddw5qy.js} +1 -1
  50. package/dist/client/static/js/{index-v8fztm3w.js → index-bf54x0w8.js} +1 -1
  51. package/dist/client/static/js/{index-4pwk5cjy.js → index-br27jz2t.js} +1 -1
  52. package/dist/client/static/js/{index-w39c85k3.js → index-demg0p74.js} +1 -1
  53. package/dist/client/static/js/{index-pd4s49n5.js → index-e2y4hkps.js} +1 -1
  54. package/dist/client/static/js/{index-gr5wd7hv.js → index-eb43hnd3.js} +1 -1
  55. package/dist/client/static/js/{index-hav1hhbr.js → index-exyg9sna.js} +1 -1
  56. package/dist/client/static/js/{index-25g1ydkd.js → index-fanhvjk8.js} +1 -1
  57. package/dist/client/static/js/{index-xf662xsf.js → index-g3x4w48f.js} +1 -1
  58. package/dist/client/static/js/{index-8w69r0c4.js → index-jvn2xfpt.js} +135 -135
  59. package/dist/client/static/js/{index-mttf7ej7.js → index-k4kwrze2.js} +1 -1
  60. package/dist/client/static/js/{index-rc8f8gjk.js → index-kevqayd9.js} +1 -1
  61. package/dist/client/static/js/{index-mnadx740.js → index-kvker1ps.js} +1 -1
  62. package/dist/client/static/js/{index-vjk01ja9.js → index-kz5d00m5.js} +1 -1
  63. package/dist/client/static/js/{index-bcns8arc.js → index-m85c740p.js} +1 -1
  64. package/dist/client/static/js/{index-53hrj27y.js → index-n3cts2j1.js} +1 -1
  65. package/dist/client/static/js/{index-hn0brpdf.js → index-n4pm0hrh.js} +4 -4
  66. package/dist/client/static/js/{index-9eddntv4.js → index-n5194pe6.js} +11 -11
  67. package/dist/client/static/js/{index-6775m1pa.js → index-p8bta9ae.js} +1 -1
  68. package/dist/client/static/js/{index-stfccv2r.js → index-pszsxhjr.js} +1 -1
  69. package/dist/client/static/js/{index-79qddnbx.js → index-rtfw07hy.js} +1 -1
  70. package/dist/client/static/js/{index-xakrt0sx.js → index-v90zd3sq.js} +1 -1
  71. package/dist/client/static/js/{index-g46qcgp8.js → index-vxe4e903.js} +1 -1
  72. package/dist/client/static/js/{index-pnjnvdvb.js → index-w4dep7k6.js} +1 -1
  73. package/dist/client/static/js/{index-2jtkrmry.js → index-x5c5yxhj.js} +1 -1
  74. package/dist/client/static/js/{index-5g21qv2b.js → index-xhcbaaga.js} +2 -2
  75. package/dist/client/static/js/{infoDiagram-VRGFBTTK-t52bsrem.js → infoDiagram-VRGFBTTK-wtnqb06v.js} +1 -1
  76. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-vysv38pr.js → ishikawaDiagram-OU5B5YK6-eta0jnvr.js} +1 -1
  77. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-7222yn0y.js → journeyDiagram-ZHPQQLJL-4e572kkp.js} +1 -1
  78. package/dist/client/static/js/{kanban-definition-PNTS6WVX-9cg88rcn.js → kanban-definition-PNTS6WVX-yrtnn4zy.js} +1 -1
  79. package/dist/client/static/js/{mermaid.core-3qc3zvgb.js → mermaid.core-195b0fb6.js} +3 -3
  80. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-hdbsk349.js → mindmap-definition-NLK3R4M7-pphjnkvt.js} +1 -1
  81. package/dist/client/static/js/one-dark-pro-asy2qj2p.js +1 -0
  82. package/dist/client/static/js/one-light-fya1pbbx.js +1 -0
  83. package/dist/client/static/js/{pegDiagram-GJSIUBJH-jtqqcrhq.js → pegDiagram-GJSIUBJH-kgffb9p3.js} +1 -1
  84. package/dist/client/static/js/{pieDiagram-5QR66LMP-2c82jghr.js → pieDiagram-5QR66LMP-efech3mm.js} +2 -2
  85. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-vp2hw2a8.js → quadrantDiagram-O4NWA36T-khf9cv3t.js} +1 -1
  86. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-4168nq4f.js → railroadDiagram-XR7U4H2S-ye68kdx2.js} +1 -1
  87. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-gwqcyxag.js → requirementDiagram-PLB6GJNP-3s4smnme.js} +1 -1
  88. package/dist/client/static/js/{rust-6m8myprw.js → rust-tdrnaxp3.js} +1 -1
  89. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-y5fakn56.js → sankeyDiagram-IPEJSGJF-9pqd25mc.js} +1 -1
  90. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-z140kern.js → sequenceDiagram-PO4LG4MO-rka8ct43.js} +1 -1
  91. package/dist/client/static/js/{sizeCapture-INFHLROL-gfez373x.js → sizeCapture-INFHLROL-g5wkzry8.js} +1 -1
  92. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-1d6h03nr.js → stateDiagram-v2-GCMORJYK-gy1zab2j.js} +1 -1
  93. package/dist/client/static/js/{swimlanes-2SLR337P-75wg3n6d.js → swimlanes-2SLR337P-kr35nmd2.js} +1 -1
  94. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-18fj17m7.js → swimlanesDiagram-TC7HE7FX-qnhxxmjr.js} +1 -1
  95. package/dist/client/static/js/{timeline-definition-EJHVYXUP-q750z70f.js → timeline-definition-EJHVYXUP-sg151mkc.js} +1 -1
  96. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-9q7tg456.js → usecaseDiagram-POWQR4AR-f91g61p3.js} +1 -1
  97. package/dist/client/static/js/{vennDiagram-UO4OBE2U-010nw1kd.js → vennDiagram-UO4OBE2U-zbhr4eqf.js} +2 -2
  98. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-7n33n10f.js → wardleyDiagram-VNRHLVJA-6302414n.js} +2 -2
  99. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7q0n5vvd.js → xychartDiagram-PMCCYNJV-0a47th65.js} +2 -2
  100. package/package.json +2 -2
  101. package/src/client/App.tsx +4 -0
  102. package/src/client/bootstrap.d.ts +11 -0
  103. package/src/client/components/workspace/git-panel/index.test.ts +56 -7
  104. package/src/client/components/workspace/git-panel/index.tsx +9 -4
  105. package/src/client/components/workspace/repo-picker/index.test.tsx +29 -2
  106. package/src/client/data/settings/omp-schema.json +11 -1
  107. package/src/client/hooks/shell/last-opened-session.test.ts +166 -0
  108. package/src/client/hooks/shell/last-opened-session.ts +74 -0
  109. package/src/client/hooks/workspace/commit-box.ts +6 -1
  110. package/src/client/lib/router/open-session.test.ts +8 -0
  111. package/src/client/lib/router/open-session.ts +9 -4
  112. package/src/client/main.tsx +7 -0
  113. package/src/server/lib/db/schema.ts +10 -0
  114. package/src/server/lib/fs/fs-write-git.test.ts +17 -0
  115. package/src/server/lib/fs/git-repos.ts +32 -11
  116. package/src/server/lib/sessions/last-opened-client.server.ts +86 -0
  117. package/src/server/lib/sessions/last-opened-client.test.ts +91 -0
  118. package/src/server/lib/sessions/last-opened.server.test.ts +127 -0
  119. package/src/server/lib/sessions/last-opened.server.ts +129 -0
  120. package/src/server/plugins/ssr.ts +40 -17
  121. package/src/server/routes/sessions/index.ts +14 -0
  122. package/src/server/routes/sessions/last-opened.test.ts +139 -0
  123. package/src/server/routes/sessions/last-opened.ts +66 -0
  124. package/src/shared/lib/omp/config/schema-releases.test.ts +15 -0
  125. package/dist/client/static/js/MergeDiffView-6t5t6exc.js +0 -1
  126. package/dist/client/static/js/flowDiagram-KWPJA3E3-z01c78q6.js +0 -1
  127. package/dist/client/static/js/one-dark-pro-3570ra7e.js +0 -1
  128. package/dist/client/static/js/one-light-3v5yk200.js +0 -1
@@ -1,2 +1,2 @@
1
- import{d,n,o,i,a,e,s,B,re,Le,Ne,I,gi,Xe,Pe,Fe,h,J,Di,Jf}from"./index-8w69r0c4.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(F);function T({title:t,options:r,methodLabel:c,badge:m,icon:x,onCancel:b}){let f=Di({title:t,options:r})?Jf(t):null,v=f?`Allow ${f.tool}`:t||c;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:v}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Ne,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:b,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(h,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:c,customValue:m,onCustomChange:x,customInputRef:b,onSelect:f,onConfirmOption:v,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,y)=>{let u=c===k,g=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>v(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),g&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:g})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(re,{size:16,className:"text-ink"}):e(gi,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:b,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())v(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function P({method:t,optionsLength:r,selectedOption:c,hasCustomAnswer:m=!1,onCancel:x,onSubmit:b}){let f=t==="select"&&!c&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(h,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:b,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(Xe,{size:12,className:"opacity-70"})]})]})]})}function R({title:t,options:r}){let c=Di({title:t,options:r})?Jf(t):null;if(!c)return null;return e("div",{className:"space-y-2",children:[c.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(I,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:c.reason})]}),c.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:c.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function L({method:t,options:r,selectedOption:c,onSelectOption:m,customInputRef:x,onSubmit:b,onCancel:f}){o(()=>{let v=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u<r.length-1?u+1:0;m(r[g]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u>0?u-1:r.length-1;m(r[g]);return}if(l.key==="Enter"&&c){l.preventDefault(),b();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),b();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),b();return}}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f,b,t,r,c,m,x])}function z(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(B,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Fe,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Pe,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Le,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[c,m]=n(t.method==="editor"?t.prefill??"":""),[x,b]=n(null),[f,v]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),g=t.options??[],N=t.optionDetails??[],E=Di(t);o(()=>{let p=t.options??[];m(t.method==="editor"?t.prefill??"":""),b(p.length>0?p[0]:null),v("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((C)=>/^other\b/i.test(C.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!E)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:c})},[r,t,x,c,f,E]),O=a((p)=>{if(/^other\b/i.test(p.trim())){b(p),u.current?.focus();return}r(t,{value:p})},[r,t]),H=a((p)=>{if(b(p),/^other\b/i.test(p.trim()))u.current?.focus()},[]);L({method:t.method,options:g,selectedOption:x,onSelectOption:b,customInputRef:u,onSubmit:A,onCancel:w});let D=z(t.method,g.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center modal-safe sm:p-6 backdrop-blur-[8px]",onMouseDown:(p)=>{if(p.target===p.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(T,{title:t.title,options:g,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(R,{title:t.title,options:g}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(J,{content:t.message})}),t.method==="select"&&e(S,{options:g,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:v,customInputRef:u,onSelect:H,onConfirmOption:O,hideCustomAnswer:E}),t.method==="confirm"&&g.length>0&&e("div",{className:"space-y-2",children:g.map((p,C)=>e("button",{type:"button",onClick:()=>r(t,{optionId:t.optionIds?.[C]??p}),className:"flex w-full cursor-pointer items-center justify-between rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 text-left text-[13px] font-medium text-ink transition-colors hover:border-ink/30 hover:bg-canvas/50",children:e("span",{className:"min-w-0 break-words",children:p})},t.optionIds?.[C]??p))}),t.method==="confirm"&&g.length===0&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(re,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:k,type:t.secret===!0?"password":"text",value:c,placeholder:t.placeholder||"Type your response...",onChange:(p)=>m(p.currentTarget.value),onKeyDown:(p)=>{if(p.key==="Enter")p.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[c.split(`
1
+ import{d,n,o,i,a,e,s,B,re,Le,Ne,I,gi,Xe,Pe,Fe,h,J,Di,Jf}from"./index-jvn2xfpt.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(F);function T({title:t,options:r,methodLabel:c,badge:m,icon:x,onCancel:b}){let f=Di({title:t,options:r})?Jf(t):null,v=f?`Allow ${f.tool}`:t||c;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:v}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Ne,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:b,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(h,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:c,customValue:m,onCustomChange:x,customInputRef:b,onSelect:f,onConfirmOption:v,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,y)=>{let u=c===k,g=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>v(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),g&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:g})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(re,{size:16,className:"text-ink"}):e(gi,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:b,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())v(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function P({method:t,optionsLength:r,selectedOption:c,hasCustomAnswer:m=!1,onCancel:x,onSubmit:b}){let f=t==="select"&&!c&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(h,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:b,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(Xe,{size:12,className:"opacity-70"})]})]})]})}function R({title:t,options:r}){let c=Di({title:t,options:r})?Jf(t):null;if(!c)return null;return e("div",{className:"space-y-2",children:[c.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(I,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:c.reason})]}),c.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:c.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function L({method:t,options:r,selectedOption:c,onSelectOption:m,customInputRef:x,onSubmit:b,onCancel:f}){o(()=>{let v=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u<r.length-1?u+1:0;m(r[g]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u>0?u-1:r.length-1;m(r[g]);return}if(l.key==="Enter"&&c){l.preventDefault(),b();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),b();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),b();return}}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f,b,t,r,c,m,x])}function z(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(B,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Fe,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Pe,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Le,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[c,m]=n(t.method==="editor"?t.prefill??"":""),[x,b]=n(null),[f,v]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),g=t.options??[],N=t.optionDetails??[],E=Di(t);o(()=>{let p=t.options??[];m(t.method==="editor"?t.prefill??"":""),b(p.length>0?p[0]:null),v("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((C)=>/^other\b/i.test(C.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!E)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:c})},[r,t,x,c,f,E]),O=a((p)=>{if(/^other\b/i.test(p.trim())){b(p),u.current?.focus();return}r(t,{value:p})},[r,t]),H=a((p)=>{if(b(p),/^other\b/i.test(p.trim()))u.current?.focus()},[]);L({method:t.method,options:g,selectedOption:x,onSelectOption:b,customInputRef:u,onSubmit:A,onCancel:w});let D=z(t.method,g.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center modal-safe sm:p-6 backdrop-blur-[8px]",onMouseDown:(p)=>{if(p.target===p.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(T,{title:t.title,options:g,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(R,{title:t.title,options:g}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(J,{content:t.message})}),t.method==="select"&&e(S,{options:g,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:v,customInputRef:u,onSelect:H,onConfirmOption:O,hideCustomAnswer:E}),t.method==="confirm"&&g.length>0&&e("div",{className:"space-y-2",children:g.map((p,C)=>e("button",{type:"button",onClick:()=>r(t,{optionId:t.optionIds?.[C]??p}),className:"flex w-full cursor-pointer items-center justify-between rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 text-left text-[13px] font-medium text-ink transition-colors hover:border-ink/30 hover:bg-canvas/50",children:e("span",{className:"min-w-0 break-words",children:p})},t.optionIds?.[C]??p))}),t.method==="confirm"&&g.length===0&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(re,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:k,type:t.secret===!0?"password":"text",value:c,placeholder:t.placeholder||"Type your response...",onChange:(p)=>m(p.currentTarget.value),onKeyDown:(p)=>{if(p.key==="Enter")p.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[c.split(`
2
2
  `).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:y,value:c,onChange:(p)=>m(p.currentTarget.value),rows:8,placeholder:t.placeholder||"Enter content...",className:"w-full rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 font-mono text-[12px] leading-relaxed text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:bg-paper focus:ring-2 focus:ring-ink/15"})]})]}),e(P,{method:t.method,optionsLength:g.length,selectedOption:x,hasCustomAnswer:f.trim().length>0,onCancel:w,onSubmit:A})]})})}export{ke as ExtensionDialog};
@@ -1 +1 @@
1
- import{d,n,o,i,u,a,Dr,ze,ie,e,s,Kn,Q,dt,E,ce,Ro,ae,Ie,et,hi,bn,bi,ia,S,U,h,sr,k,yh,Te,hl,T,xr,wr,xt,nt,he,Bt,Sd,mt,ft,Dh,Nh,Mo,fs,Td,We,As}from"./index-8w69r0c4.js";import{yd,vd,di,kd,xd}from"./index-w39c85k3.js";import{Z}from"./index-8k568z0z.js";import{Tr}from"./index-gr5wd7hv.js";var Yt={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"]},Xe=s(Yt);var Jt={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"}]]},qe=s(Jt);var Zt={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"}]]},Be=s(Zt);var en={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(en);function Qe({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:g,onRefresh:v,refreshing:b}){return e("div",{className:"border-b border-ink/10",children:[e(xt,{className:"border-b-0",left:e(Tr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(nt,{label:"Refresh",onClick:v,busy:b})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(U,{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)=>g(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 Ye({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:g}){let v=f?"text-ink font-semibold":x?x.colorClass:g?g.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(E,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ce,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(mt,{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}),g&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${g.dotClass}`,title:`${g.count} changed file${g.count>1?"s":""}`})]})}var tn=28,nn=9,rn=8;function on(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:g,isArchive:v}=t,b=[],m=g>1,C=g===1?"":` ${g} items`;if(m)return b.push({kind:"item",id:"cut",label:`Cut${C}`,icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"copy",label:`Copy${C}`,icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"separator"}),b.push({kind:"item",id:"compress",label:`Compress${C} to…`,icon:e(dt,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"separator"}),b.push({kind:"item",id:"delete",label:`Delete${C}`,icon:e(Q,{size:13,className:"text-error"}),tone:"text-error"}),b;if(r){if(b.push({kind:"item",id:"new_file",label:"New File",icon:e(hi,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(bn,{size:13,className:"text-ink/60"})}),f)b.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(E,{size:13,className:"text-ink/60"})});if(x)b.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ce,{size:13,className:"text-ink/60"})});b.push({kind:"separator"})}else{if(b.push({kind:"item",id:"view",label:"View",icon:e(et,{size:13,className:"text-ink/60"})}),v)b.push({kind:"item",id:"extract",label:"Extract…",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p});if(l)b.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(bi,{size:13,className:"text-warning"}),tone:"font-medium"});b.push({kind:"separator"})}if(b.push({kind:"item",id:"cut",label:"Cut",icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"copy",label:"Copy",icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"compress",label:"Compress to…",icon:e(dt,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(qe,{size:13,className:"text-ink/60"}),disabled:p}),c)b.push({kind:"item",id:"paste",label:c,icon:e(Ro,{size:13,className:"text-ink/60"}),disabled:p});return b.push({kind:"separator"}),b.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Ie,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(ae,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(ae,{size:13,className:"text-ink/60"})}),b.push({kind:"separator"}),b.push({kind:"item",id:"history",label:"Show Git History",icon:e(Kn,{size:13,className:"text-ink/60"})}),b.push({kind:"separator"}),b.push({kind:"item",id:"rename",label:"Rename",icon:e(Xe,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"delete",label:"Delete",icon:e(Q,{size:13,className:"text-error"}),tone:"text-error"}),b}function sn(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*tn+l*nn+rn}function Je({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:g,selectionCount:v,isArchive:b,onAction:m,menuRef:C}){let N=on({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:g,chainLabel:f,foldable:x,selectionCount:v,isArchive:b}),A=sn(N),F=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,M=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-A-12)):r;return ie(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(D)=>{D.preventDefault(),m("close")},children:e("div",{ref:C,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:M,left:F},onClick:(D)=>D.stopPropagation(),children:N.map((D,w)=>D.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${w}`):e("button",{type:"button",disabled:D.disabled,onClick:()=>m(D.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${D.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${D.tone??""}`,children:[D.icon,e("span",{children:D.label})]},D.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:g}){let v=r==="folder"?"Folder":"File";return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:g,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:(b)=>f(b.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 Ze({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let g=c>1;return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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 ",g?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",g?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:g,onSubmit:v}){return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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:(b)=>x(b.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:g,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 rt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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(Kn,{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(h,{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(S,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function ot({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(Ze,{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(rt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(an);return r.some((l,c)=>l!==t[c])?r:t}function an(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 it(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((g)=>{if(g.type!=="folder")return[g];let v=Array.isArray(g.children)?p(g.children):g.children,b=v===g.children?g:{...g,children:v},m=r.has(g.path)?Me(g.path,g.name):null;if(!m)return[b];c=!0,l.set(m[0],g.path);let C={...b,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let N=m[y-1];C={name:N.split("/").pop(),path:N,type:"folder",ignored:b.ignored,children:[C]}}return[C]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(x)=>{for(let g of x){if(g.type!=="folder")continue;if(l.add(g.path),Array.isArray(g.children))c(g.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let g=p.slice(0,x+1).join("/");if(l.has(g))f.push(g)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=ft(),[x,g]=n(!1),[v,b]=n("file"),[m,C]=n(""),[y,N]=n(null),A=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let F=f.data;if(A.current===F)return;if(A.current=F,F.success&&F.path){let M=F.kind==="folder"?"folder":"file";g(!1),C(""),N(null);let D=F.path.split("/").pop()||F.path;if(c({path:F.path,name:D,kind:M}),M==="file")p?.({path:F.path,name:D})}else N(F.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:C,error:y,busy:f.state!=="idle",openDialog:(F="file")=>{b(F),C(""),N(null),g(!0)},closeDialog:()=>g(!1),submit:(F)=>{F.preventDefault();let M=m.trim();if(!M)return;N(null);let D=new FormData;if(D.append("actionType","create"),D.append("path",t),D.append("name",M),v==="folder")D.append("kind","folder");if(l&&l!==".")D.append("repo",l);if(r)D.append("root",r);f.submit(D,{method:"post",action:"/api/fs/action"})}}}function we(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function at(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 lt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function ct(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 pt(t,r){let l=ct(t,r);if(l)return l;if(r===lt(t.path))return"Already in this folder";return null}function ut(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===lt(c.path)))return"Already in this folder";for(let c of t.entries){let p=ct(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=ln(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function ln(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 $e=[{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 Oe(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return Oe(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function vt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function yt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function kt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Ct(t){if(t.length===0)return".";let r=t.map((c)=>yt(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 De(t,r){let l=dn(r);if(t.length===1){let f=t[0],x=vt(f.name),g=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:g>0?x.slice(0,g):x)||"archive"}.${l}`}let c=Ct(t.map((f)=>f.path)),p=kt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ft(t){return Ct(t.map((r)=>r.path))}function Nt(t){let r=yt(t),l=vt(kt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function wt(t){return t.toUpperCase()}function Dt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:g,clipboard:v,isFolder:b,selection:m,selected:C,archive:y}){let N=ft(),[A,F]=n(null),M=i(null),[D,w]=n(!1),[R,I]=n(!1),[_,te]=n(!1),[ne,se]=n(t.path),[H,P]=n(null),{repo:z,rootPath:G}=t,K=Ne({folderPath:t.path,rootPath:G,repo:z,onCreated:(L)=>p?p(L):c(),onOpenCreated:(L)=>l?.({...L,root:G,repo:z||"."})}),re=i(null);o(()=>{if(N.state!=="idle"||!N.data)return;let L=N.data;if(re.current===L)return;if(re.current=L,L.success&&!L.type)if(w(!1),I(!1),P(null),L.previousPath&&L.path&&f)f(L.previousPath,L.path);else c();else if(!L.success&&L.error&&D)P(L.error)},[N.state,N.data]);let q=(L)=>{if(z&&z!==".")L.append("repo",z);if(G)L.append("root",G);N.submit(L,{method:"post",action:"/api/fs/action"})},X=()=>{l?.({path:t.path,name:t.name,root:G,repo:z||"."})},J={path:t.path,name:t.name,kind:b?"folder":"file"},oe=C&&m.length>1?m:[J],ge=bt(t.name),B=v.clip&&!v.refusalFor(J)?`Paste ${we(v.clip)??"item"}`:null,fe=(L)=>{if(F(null),P(null),L==="view")X();else if(L==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:G}}));else if(L==="explorer"){let j=new FormData;j.append("actionType","open_explorer"),j.append("path",t.path),q(j)}else if(L==="copy_path")Bt(Sd(t.basePath,t.path));else if(L==="copy_relative")Bt(t.path);else if(L==="history"){te(!0);let j=new FormData;j.append("actionType","git_history"),j.append("path",t.path),q(j)}else if(L==="rename")se(t.path),w(!0);else if(L==="unfold")x?.();else if(L==="fold")g?.();else if(L==="new_file")K.openDialog("file");else if(L==="new_folder")K.openDialog("folder");else if(L==="delete")I(!0);else if(L==="cut")v.cut(oe);else if(L==="copy")v.copy(oe);else if(L==="compress")y.openCompress(oe);else if(L==="extract")y.openExtract(J);else if(L==="duplicate")v.duplicate(J);else if(L==="paste")v.paste(J)},le=(L)=>{L.preventDefault(),P(null);let j=new FormData;j.append("actionType","rename"),j.append("path",t.path),j.append("newPath",ne),q(j)},ve=()=>{let L=new FormData;if(L.append("actionType","delete"),oe.length>1)L.append("paths",JSON.stringify(oe.map((j)=>j.path)));else L.append("path",t.path);q(L)};return{contextMenu:A,contextMenuRef:M,openContextMenu:(L,j)=>F({x:L,y:j}),closeContextMenu:()=>F(null),showRenameModal:D,showDeleteModal:R,showHistoryModal:_,showCreateModal:K.open,createKind:K.kind,createError:K.error,createName:K.name,setCreateName:K.setName,renameValue:ne,setRenameValue:se,renameError:H,busy:N.state!=="idle"||K.busy||v.busy||y.busy,pasteLabel:B,selectionCount:oe.length,isArchive:ge,chainLabel:x!==void 0,foldable:g!==void 0,fetcherState:N.state,fetcherData:N.data,handleAction:fe,submitCreate:K.submit,submitRename:le,submitDelete:ve,closeCreate:K.closeDialog,closeDelete:()=>I(!1),closeRename:()=>w(!1),closeHistory:()=>te(!1)}}function Rt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let g=r?.path===t.path,v=Boolean(r)&&!g&&l.moveRefusalFor(r,t)===null,[b,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:g,acceptsDrop:v,isDropHovered:b&&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)}}}function pn(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:g,onRenamed:v,expandedPaths:b,onToggleFolder:m,gitFileMap:C,gitFolderMap:y,clipboard:N,archive:A,selection:F,selectionTargets:M,dragging:D,onDragStart:w,onDragEnd:R,onDropOn:I,onUnfold:_,onFold:te,foldRoots:ne,touch:se=!1}){let H=t.type==="folder",[P,z]=n(!1),[G,K]=n(!1),[re,q]=n(!1),[X,J]=n(!1),oe=Array.isArray(t.children)?t.children:[],ge=(t.path||"").replace(/^\/+/,""),B=!H?C?.get(ge)||C?.get(t.path):void 0,fe=B?sr(B.status,B.staged):null,le=H?y?.get(ge)||y?.get(t.path):null,ve=Boolean(fe),L=t.ignored===!0,j=b?b.has(t.path):P,de=t.forceExpanded!==void 0?t.forceExpanded:j;o(()=>{J(!0)},[]),o(()=>{if(H&&b)z(b.has(t.path))},[b,t.path,H]),o(()=>{if(H&&de&&pn(t,G,re)&&p)q(!0),K(!0),Promise.resolve(p(t.path)).finally(()=>K(!1))},[H,de,t.children,t.path,p,G,re]);let ke={path:t.path,name:t.name,kind:H?"folder":"file"},xe=F.selected.has(t.path),W=Dt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:M,selected:xe,archive:A,diff:{staged:B?.staged||(B?.status?B.status[0]!==" "&&B.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,onUnfold:_&&Ee({type:H?"folder":"file",name:t.name})?()=>_(ke):void 0,onFold:te&&ne?.has(t.path)?()=>te(ne.get(t.path)):void 0,clipboard:N,isFolder:H});he(W.contextMenuRef,W.closeContextMenu);let Y=yd({enabled:se,onLongPress:(V,be)=>W.openContextMenu(V,be)}),Ce=(V)=>{if(V.stopPropagation(),Y.consume())return;let be=F.gestureOf(V);if(be!=="plain"){F.applyGesture(be,t.path);return}if(F.applyGesture("plain",t.path),H){let ue=!de;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||"."})},ye=(V)=>{V.preventDefault(),V.stopPropagation(),F.ensureForContext(t.path),W.openContextMenu(V.clientX,V.clientY)},pe=Rt({target:ke,dragging:D,clipboard:N,onDragStart:w,onDragEnd:R,onDropOn:I,onHoverAccept:_});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${pe.isDragging?"opacity-40":""} ${pe.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":xe?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!se,onClick:Ce,onContextMenu:ye,onDragStart:pe.onDragStart,onDragEnd:pe.onDragEnd,onDragOver:pe.onDragOver,onDragLeave:pe.onDragLeave,onDrop:pe.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Ye,{name:t.name,path:t.path,isFolder:H,isOpen:de,ignored:L,selected:xe,gitStatus:fe,folderStatus:le})}),de&&G&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),de&&!G&&oe.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:oe.map((V)=>e(Pe,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,expandedPaths:b,onToggleFolder:m,gitFileMap:C,gitFolderMap:y,clipboard:N,archive:A,selection:F,selectionTargets:M,dragging:D,onDragStart:w,onDragEnd:R,onDropOn:I,onUnfold:_,onFold:te,foldRoots:ne,touch:se},V.path))}),X&&W.contextMenu&&e(Je,{x:W.contextMenu.x,y:W.contextMenu.y,isFolder:H,hasGitStatus:ve,pasteLabel:W.pasteLabel,chainLabel:W.chainLabel,foldable:W.foldable,busy:W.busy,selectionCount:W.selectionCount,isArchive:W.isArchive,onAction:W.handleAction}),X&&e(ot,{actions:W,file:t,isFolder:H,chainLabel:Ee({type:H?"folder":"file",name:t.name})?t.name:void 0})]})}function St({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let g=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,b=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-g-12)):r;return ie(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:b,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(hi,{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(bn,{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(Ro,{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 Tt({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:g,children:v}){return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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:g,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 un({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:g,onNameChange:v,onDestinationChange:b,onCancel:m,onSubmit:C}){let y=t.slice(0,4).map((A)=>A.name).join(", "),N=t.length>4?` +${t.length-4} more`:"";return e(Tt,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${N}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(A)=>{A.preventDefault(),C()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",children:"Format"}),e(Z,{ariaLabel:"Format",value:r,onChange:(A)=>g(A),placeholder:"Format",searchable:!1,allowEmpty:!1,className:"mb-3 text-xs",options:p.map((A)=>({value:A.id,label:A.available?A.label:`${A.label} — ${A.tool} not installed`,disabled:!A.available}))}),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)=>b(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 fn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:g}){return e(Tt,{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(),g()},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 Et({archive:t}){if(t.compress)return e(un,{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(fn,{archive:t.extract.archive,kindLabel:wt(Oe(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 Mt(){let[t,r]=T("files.outlineExpanded",!1),l=Dr(),c=ze(Nh,Dh),{symbols:p,total:f,truncated:x,notice:g}=xd({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,b=(m,C)=>{if(!c.path)return;if(v){let y=Td(p,C);if(y)fs({path:c.path,...y});return}Mo({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(ia,{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:g}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,C)=>e("button",{type:"button",onClick:()=>b(m,C),"aria-label":v?`${di(m.kind)} ${m.name}`:`${di(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${di(m.kind).toLowerCase()}`:`${di(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(vd,{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:kd(f)})]})})})})]})}function He(t,r){return Ae(t.map((l)=>mn(l,r)))}function mn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:He(l,r)}}function hn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function $t(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Lt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ge(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},g=f,v=null;for(let b=0;b<c.length-1;){let m=c.slice(0,b+1).join("/"),C=g.find((M)=>M.type==="folder"&&M.path===m),y=C?null:g.find((M)=>M.type==="folder"&&M.path.startsWith(`${m}/`)&&(p===M.path||p.startsWith(`${M.path}/`))),N=C??y,A=N?x[N.path]??N.children:null;if(N&&!Array.isArray(A))return{nodes:t,cache:r};if(!N){let M=gn(g,x,m);if(M){g=M;let D=g.find((R)=>R.path===m),w=Array.isArray(D?.children)?[...D.children]:[];x[m]=w,g=w,v=m,b+=1;continue}}let F=Array.isArray(A)?[...A]:[];if(N){x[N.path]=F,g=F,v=N.path,b=N.path.split("/").length;continue}g.push({name:c[b],path:m,type:"folder",ignored:!1}),x[m]=F,g=F,v=m,b+=1}if(g.push(l),v!==null)x[v]=Lt(g);return f=Lt(f),{nodes:f,cache:x}}function gn(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 g={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)g={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[g]};return t[c]={name:$t(l),path:l,type:"folder",ignored:!1,children:[g]},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=hn(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((C)=>C.path===l)).sort((m,C)=>C.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let b=r[v];return{entry:b.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:b.filter((m)=>m.path!==l)}}}function Ot(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),g=Array.isArray(f.children)?Ot(f.children,r,l):void 0;if(!x&&g===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,b=x?{...f,path:v,name:$t(v)}:{...f};if(g!==void 0)b.children=g;return b});return c?p:t}function Pt(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:Ot(f,r,l)}return c}function It(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 Ht(t){if(!k(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)=>k(r)):[],root:t.root}}async function Ke(t){try{return Ht(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Gt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,g]=n({scope:"",files:[],root:""}),[v,b]=n(!1),m=i({}),C=i([]),y=i(f);y.current=f;let N=i(""),A=i(""),F=i(c);F.current=c;let M=(P)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(P)z.set("path",P);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},D=(P,z)=>{N.current=P,A.current=z;let G=He(C.current,m.current);return g({scope:P,files:G,root:z}),G},w=async(P)=>{let z=[...F.current];if(z.length===0)return;let G=await Promise.all(z.map(async(X)=>({path:X,read:await Ke(M(X))})));if(y.current!==P)return;let K=[];for(let{path:X,read:J}of G)if(J.status==="ok")m.current[X]=J.files;else if(J.status==="missing")K.push(X);if(K.length===0)return;let re=new Set(K);for(let X of K)delete m.current[X];let q=new Set([...F.current].filter((X)=>!re.has(X)));F.current=q,p(q)},R=async()=>{if(!t)return;let P=y.current;b(!0);try{let z=await Ke(M());if(y.current!==P)return;if(z.status!=="ok")return;if(N.current!==P)m.current={};if(C.current=z.files,D(P,z.root),await w(P),y.current!==P)return;D(P,z.root)}finally{if(y.current===P)b(!1)}},I=async(P)=>{let z=y.current,G=await Ke(M(P));if(y.current!==z||G.status!=="ok")return;if(m.current[P]=G.files,N.current===z)D(z,A.current)},_=(P)=>{let z=Ht(P);if(z.status!=="ok")return;let G=y.current;if(N.current!==G)m.current={};C.current=z.files,D(G,z.root),w(G).then(()=>{if(y.current===G)D(G,z.root)})},te=()=>{m.current={},C.current=[],N.current="",A.current="",g({scope:"",files:[],root:""})},ne=(P)=>{let z=y.current;if(N.current!==z)return null;let G={name:P.path.slice(P.path.lastIndexOf("/")+1),path:P.path,type:P.kind,ignored:!1},K=Ge(C.current,m.current,G);if(K.nodes===C.current)return null;return C.current=K.nodes,m.current=K.cache,D(z,A.current)},se=(P,z)=>{let G=y.current;if(N.current!==G)return null;let K=zt(C.current,m.current,P);if(!K.entry)return null;m.current=Pt(K.cache,P,z);let re={...K.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Ge(K.nodes,m.current,re);return C.current=q.nodes,m.current=q.cache,D(G,A.current)},H=x.scope===f;return{scope:f,files:H?x.files:[],root:H?x.root:"",isLoading:v,reload:R,loadChildren:I,adoptRoot:_,insertEntry:ne,moveEntry:se,reset:te}}function Kt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=ft(),[f,x]=T("files.clipboard",null),g=ht(f),v=at(t,r),b=i(!1),m=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let F=p.data;if(m.current===F)return;m.current=F;let M=b.current;if(b.current=!1,F.success){if(M)x(null);if(F.failures?.length)c(`${F.failures.length} item(s) could not be moved: ${F.failures[0].error}`);l()}else c(F.error||"The transfer did not complete")},[p.state,p.data]);let C=a((F,M)=>{b.current=M;let D=new FormData;for(let[w,R]of Object.entries(F))D.append(w,R);if(r&&r!==".")D.append("repo",r);if(t)D.append("root",t);p.submit(D,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((F)=>ut(g,v,Le(F.path,F.kind)),[g,v]),N=a((F,M)=>pt(F,Le(M.path,M.kind)),[]),A=a((F,M,D,w)=>{let R=new FormData;R.append("actionType","paste"),R.append("mode",D),R.append("targetPath",M.path),R.append("targetKind",M.kind);for(let I of F)R.append("sourcePath",I.path);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);b.current=w,p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:g,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:N,copy:(F)=>{if(F.length===0)return;x({scope:v,entries:F.map(({path:M,name:D,kind:w})=>({path:M,name:D,kind:w})),mode:"copy"})},cut:(F)=>{if(F.length===0)return;x({scope:v,entries:F.map(({path:M,name:D,kind:w})=>({path:M,name:D,kind:w})),mode:"cut"})},duplicate:(F)=>{C({actionType:"duplicate",path:F.path},!1)},move:(F,M)=>{let D=N(F,M);if(D){c(D);return}A([F],M,"cut",Boolean(g?.mode==="cut"&&g.entries.some((w)=>w.path===F.path)))},paste:(F)=>{if(!g)return;let M=y(F);if(M){c(M);return}A(g.entries.map(({path:D,name:w,kind:R})=>({path:D,name:w,kind:R})),F,g.mode,g.mode==="cut")}}}var xn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=ft(),[p,f]=n(xn),[x,g]=n(null),[v,b]=n(null),[m,C]=n(null),y=i(null),N=i(null);o(()=>{let w=!1;return(async()=>{try{let I=await(await fetch("/api/fs/archive")).json();if(!w&&Array.isArray(I.formats)&&I.formats.length>0)f(I.formats)}catch{}})(),()=>{w=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let w=c.data;if(N.current===w)return;N.current=w;let R=y.current;if(y.current=null,w.success){if(C(null),R==="compress")g(null);if(R==="extract")b(null);l()}else if(R)C(w.error||"The archive request failed")},[c.state,c.data]);let A=a((w)=>{let R=new FormData;for(let[I,_]of Object.entries(w))R.append(I,_);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);c.submit(R,{method:"post",action:"/api/fs/action"})},[c,r,t]),F=a((w)=>{if(w.length===0)return;let R=p.find((I)=>I.id==="zip"&&I.available)?.id??p.find((I)=>I.available)?.id??"zip";C(null),b(null),g({entries:w.map(({path:I,name:_,kind:te})=>({path:I,name:_,kind:te})),format:R,name:De(w,R),destination:Ft(w)})},[p]),M=a((w)=>{C(null),g(null),b({archive:w,destination:Nt(w.path)})},[]),D=a((w)=>{g((R)=>{if(!R)return R;let I=De(R.entries,R.format),_=R.name===I?De(R.entries,w):R.name;return{...R,format:w,name:_}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:F,openExtract:M,setFormat:D,setName:(w)=>g((R)=>R&&{...R,name:w}),setCompressDestination:(w)=>g((R)=>R&&{...R,destination:w}),setExtractDestination:(w)=>b((R)=>R&&{...R,destination:w}),cancel:()=>{g(null),b(null),C(null)},submitCompress:()=>{let w=x;if(!w)return;y.current="compress",C(null),A({actionType:"compress",format:w.format,name:w.name.trim(),destination:w.destination.trim()||".",paths:JSON.stringify(w.entries.map((R)=>R.path))})},submitExtract:()=>{let w=v;if(!w)return;y.current="extract",C(null),A({actionType:"extract",path:w.archive.path,destination:w.destination.trim()||"."})}}}function vn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function yn(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 _t(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((b,m)=>{if(b==="range"){l(new Set(yn(t,c,m)));return}if(p(m),b==="toggle"){l((C)=>{let y=new Set(C);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((b)=>{l((m)=>{if(m.has(b))return m;return new Set([b])}),p(b)},[]),g=a(()=>{l(new Set),p(null)},[]),v=a(vn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:g}),[r,c,v,f,x,g])}function je(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))je(p.children,r,l+1,c);return c}function Wt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,b)=>{let m=st(b,v);if(m.length===0)return;r((C)=>{if(m.every((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.add(N);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let b=t.insertEntry(v);if(!b){c();return}f(v.path,b)},[t,c,f]),g=a((v,b)=>{p?.(v,b),r((C)=>{let y=It(C,v,b);return l(Array.from(y)),y});let m=t.moveEntry(v,b);if(!m){c();return}f(b,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:g}}var kn=new Set;function Ut({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let b=Me(v.path,v.name);if(!b)return;p((C)=>{let y=C.scope===t?C.chains:new Map;if(y.get(v.path)?.length===b.length)return C;let A=new Map(y);return A.set(v.path,b),{scope:t,chains:A}});let m=b.slice(0,-1);r((C)=>{if(m.every((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.add(N);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let b=c.scope===t?c.chains.get(v):void 0;if(!b)return;let m=b.slice(0,-1);p((C)=>{if(C.scope!==t)return C;let y=new Map(C.chains);return y.delete(v),{scope:t,chains:y}}),r((C)=>{if(!m.some((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.delete(N);return l(Array.from(y)),y})},[t,c,r,l]),g=a((v,b)=>{let m=c.scope===t?c.chains:null;if(!m)return;let C=new Map,y=[],N=!1;for(let[A,F]of m){if(F.findIndex((R,I)=>R===v&&I>0&&I<F.length-1)!==-1){N=!0;continue}let D=F.map((R)=>R===v?b:R.startsWith(`${v}/`)?`${b}${R.slice(v.length)}`:R),w=D[D.length-1];if(w!==A||D.some((R,I)=>R!==F[I]))N=!0;C.set(w,D),y.push(...D.slice(0,-1))}if(!N)return;p({scope:t,chains:C}),r((A)=>{if(y.every((M)=>A.has(M)))return A;let F=new Set(A);for(let M of y)F.add(M);return l(Array.from(F)),F})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):kn,unfold:f,fold:x,rekey:g}}function Vt(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((g)=>g!==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 Xt({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 ri({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[g,v]=T("files.searchQuery",""),[b,m,C]=T("files.expandedPaths",[]),[y,N]=n(()=>new Set(b)),{activeRepo:A,setActiveRepo:F}=xr(c),{repos:M,scanning:D,rescan:w}=wr(c,r),{fileMap:R,folderMap:I,refreshGitStatus:_}=hl(c,A,r),[te,ne]=n(null),se=i(null);o(()=>{if(!C)return;N((O)=>{let ee=new Set(b);if(O.size===ee.size&&Array.from(ee).every((me)=>O.has(me)))return O;return ee})},[C,b]);let H=Gt({enabled:r,rootPath:c,activeRepo:A,expandedPaths:y,onExpansionPruned:(O)=>{N(O),m(Array.from(O))}});o(()=>{if(!C||!l)return;H.reload()},[f,c,r,A,C,l]);let P=r&&C?yh(H.scope):null,z=Te(P);o(()=>{if(z.data)H.adoptRoot(z.data)},[z.data]);let G=(O)=>(_(),H.loadChildren(O)),K=(O,ee)=>{let me=new Set(y);if(ee)me.add(O);else me.delete(O);N(me),m(Array.from(me))},{unfolded:re,unfold:q,fold:X,rekey:J}=Ut({scope:H.scope,setExpandedPaths:N,setStoredExpandedPaths:m}),oe=H.files,ge=it(oe,re),B=Vt(ge.nodes,g),fe=je(B,(O)=>O.forceExpanded!==void 0?O.forceExpanded:y.has(O.path)),le=_t(fe.map((O)=>O.path)),ve=fe.filter((O)=>le.selected.has(O.path)).map(({path:O,name:ee,kind:me})=>({path:O,name:ee,kind:me})),L=(O)=>{if(O===A)return;H.reset(),N(new Set),m([]),le.clear(),F(O)},j=()=>{if(_(),x)x();else H.reload()},{insertCreated:de,moveRenamed:ke}=Wt({listing:H,setExpandedPaths:N,setStoredExpandedPaths:m,reload:j,onMoved:(O,ee)=>J(O,ee)}),xe=As(),{pushToast:W}=We(),Y=Kt({rootPath:c,repo:A,onComplete:j,onError:(O)=>W(O,"error")}),Ce=jt({rootPath:c,repo:A,onComplete:j}),ye={path:".",name:".",kind:"folder"},pe=Y.clip&&!Y.refusalFor(ye)?`Paste ${we(Y.clip)??"item"}`:null,[V,be]=n(null),ue=Xt({dragging:V,clipboard:Y,target:ye}),Re=Ne({folderPath:".",rootPath:c,repo:A,onCreated:de,onOpenCreated:(O)=>p?.({...O,root:c,repo:A})}),[_e,qt]=n(!1);o(()=>qt(!0),[]);let{count:Ue,clear:Ve}=le;if(o(()=>{if(!l)return;let O=(ee)=>{if(ee.key==="Escape"&&Ue>0)Ve()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[l,Ue,Ve]),!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 Qt=H.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Qe,{rootPath:c,activeRepo:A,repos:M,reposScanning:D,onRefreshRepos:w,onSelectRepo:L,searchQuery:g,onSearchChange:v,onRefresh:j,refreshing:Qt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${xe?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(O)=>{O.preventDefault(),ne({x:O.clientX,y:O.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:H.isLoading&&B.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):B.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):B.map((O)=>e(Pe,{file:O,rootPath:c,basePath:H.root,repo:A,onLoadChildren:G,onOpenFile:p,onActionComplete:j,onCreated:de,onRenamed:ke,expandedPaths:y,onToggleFolder:K,gitFileMap:R,gitFolderMap:I,clipboard:Y,archive:Ce,selection:le,selectionTargets:ve,dragging:V,onDragStart:be,onDragEnd:()=>be(null),onDropOn:(ee)=>{if(!V)return;Y.move(V,ee)},onUnfold:q,onFold:X,foldRoots:ge.roots,touch:xe},O.path))}),e(Mt,{}),_e&&e(At,{menu:te,menuRef:se,pasteLabel:pe,busy:Y.busy,create:Re,onAction:(O)=>{if(ne(null),O==="new_file")Re.openDialog("file");if(O==="new_folder")Re.openDialog("folder");if(O==="paste")Y.paste(ye)}}),_e&&e(Et,{archive:Ce})]})}export{ri as FileExplorer};
1
+ import{d,n,o,i,u,a,Dr,ze,ie,e,s,Kn,Q,dt,E,ue,Ro,ae,Ie,et,hi,bn,bi,ia,S,U,h,sr,k,yh,Te,hl,T,xr,wr,xt,nt,he,Bt,Sd,mt,ft,Dh,Nh,Mo,fs,Td,We,As}from"./index-jvn2xfpt.js";import{yd,vd,di,kd,xd}from"./index-demg0p74.js";import{Z}from"./index-40ydm28n.js";import{Tr}from"./index-eb43hnd3.js";var Yt={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"]},Xe=s(Yt);var Jt={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"}]]},qe=s(Jt);var Zt={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"}]]},Be=s(Zt);var en={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(en);function Qe({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:g,onRefresh:v,refreshing:b}){return e("div",{className:"border-b border-ink/10",children:[e(xt,{className:"border-b-0",left:e(Tr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(nt,{label:"Refresh",onClick:v,busy:b})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(U,{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)=>g(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 Ye({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:g}){let v=f?"text-ink font-semibold":x?x.colorClass:g?g.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(E,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ue,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(mt,{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}),g&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${g.dotClass}`,title:`${g.count} changed file${g.count>1?"s":""}`})]})}var tn=28,nn=9,rn=8;function on(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:g,isArchive:v}=t,b=[],m=g>1,C=g===1?"":` ${g} items`;if(m)return b.push({kind:"item",id:"cut",label:`Cut${C}`,icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"copy",label:`Copy${C}`,icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"separator"}),b.push({kind:"item",id:"compress",label:`Compress${C} to…`,icon:e(dt,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"separator"}),b.push({kind:"item",id:"delete",label:`Delete${C}`,icon:e(Q,{size:13,className:"text-error"}),tone:"text-error"}),b;if(r){if(b.push({kind:"item",id:"new_file",label:"New File",icon:e(hi,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(bn,{size:13,className:"text-ink/60"})}),f)b.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(E,{size:13,className:"text-ink/60"})});if(x)b.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ue,{size:13,className:"text-ink/60"})});b.push({kind:"separator"})}else{if(b.push({kind:"item",id:"view",label:"View",icon:e(et,{size:13,className:"text-ink/60"})}),v)b.push({kind:"item",id:"extract",label:"Extract…",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p});if(l)b.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(bi,{size:13,className:"text-warning"}),tone:"font-medium"});b.push({kind:"separator"})}if(b.push({kind:"item",id:"cut",label:"Cut",icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"copy",label:"Copy",icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"compress",label:"Compress to…",icon:e(dt,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(qe,{size:13,className:"text-ink/60"}),disabled:p}),c)b.push({kind:"item",id:"paste",label:c,icon:e(Ro,{size:13,className:"text-ink/60"}),disabled:p});return b.push({kind:"separator"}),b.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Ie,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(ae,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(ae,{size:13,className:"text-ink/60"})}),b.push({kind:"separator"}),b.push({kind:"item",id:"history",label:"Show Git History",icon:e(Kn,{size:13,className:"text-ink/60"})}),b.push({kind:"separator"}),b.push({kind:"item",id:"rename",label:"Rename",icon:e(Xe,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"delete",label:"Delete",icon:e(Q,{size:13,className:"text-error"}),tone:"text-error"}),b}function sn(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*tn+l*nn+rn}function Je({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:g,selectionCount:v,isArchive:b,onAction:m,menuRef:C}){let N=on({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:g,chainLabel:f,foldable:x,selectionCount:v,isArchive:b}),A=sn(N),F=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,M=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-A-12)):r;return ie(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(D)=>{D.preventDefault(),m("close")},children:e("div",{ref:C,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:M,left:F},onClick:(D)=>D.stopPropagation(),children:N.map((D,w)=>D.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${w}`):e("button",{type:"button",disabled:D.disabled,onClick:()=>m(D.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${D.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${D.tone??""}`,children:[D.icon,e("span",{children:D.label})]},D.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:g}){let v=r==="folder"?"Folder":"File";return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:g,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:(b)=>f(b.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 Ze({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let g=c>1;return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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 ",g?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",g?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:g,onSubmit:v}){return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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:(b)=>x(b.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:g,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 rt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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(Kn,{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(h,{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(S,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function ot({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(Ze,{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(rt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(an);return r.some((l,c)=>l!==t[c])?r:t}function an(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 it(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((g)=>{if(g.type!=="folder")return[g];let v=Array.isArray(g.children)?p(g.children):g.children,b=v===g.children?g:{...g,children:v},m=r.has(g.path)?Me(g.path,g.name):null;if(!m)return[b];c=!0,l.set(m[0],g.path);let C={...b,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let N=m[y-1];C={name:N.split("/").pop(),path:N,type:"folder",ignored:b.ignored,children:[C]}}return[C]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(x)=>{for(let g of x){if(g.type!=="folder")continue;if(l.add(g.path),Array.isArray(g.children))c(g.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let g=p.slice(0,x+1).join("/");if(l.has(g))f.push(g)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=ft(),[x,g]=n(!1),[v,b]=n("file"),[m,C]=n(""),[y,N]=n(null),A=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let F=f.data;if(A.current===F)return;if(A.current=F,F.success&&F.path){let M=F.kind==="folder"?"folder":"file";g(!1),C(""),N(null);let D=F.path.split("/").pop()||F.path;if(c({path:F.path,name:D,kind:M}),M==="file")p?.({path:F.path,name:D})}else N(F.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:C,error:y,busy:f.state!=="idle",openDialog:(F="file")=>{b(F),C(""),N(null),g(!0)},closeDialog:()=>g(!1),submit:(F)=>{F.preventDefault();let M=m.trim();if(!M)return;N(null);let D=new FormData;if(D.append("actionType","create"),D.append("path",t),D.append("name",M),v==="folder")D.append("kind","folder");if(l&&l!==".")D.append("repo",l);if(r)D.append("root",r);f.submit(D,{method:"post",action:"/api/fs/action"})}}}function we(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function at(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 lt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function ct(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 pt(t,r){let l=ct(t,r);if(l)return l;if(r===lt(t.path))return"Already in this folder";return null}function ut(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===lt(c.path)))return"Already in this folder";for(let c of t.entries){let p=ct(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=ln(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function ln(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 $e=[{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 Oe(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return Oe(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function vt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function yt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function kt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Ct(t){if(t.length===0)return".";let r=t.map((c)=>yt(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 De(t,r){let l=dn(r);if(t.length===1){let f=t[0],x=vt(f.name),g=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:g>0?x.slice(0,g):x)||"archive"}.${l}`}let c=Ct(t.map((f)=>f.path)),p=kt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ft(t){return Ct(t.map((r)=>r.path))}function Nt(t){let r=yt(t),l=vt(kt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function wt(t){return t.toUpperCase()}function Dt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:g,clipboard:v,isFolder:b,selection:m,selected:C,archive:y}){let N=ft(),[A,F]=n(null),M=i(null),[D,w]=n(!1),[R,I]=n(!1),[_,te]=n(!1),[ne,se]=n(t.path),[H,P]=n(null),{repo:z,rootPath:G}=t,K=Ne({folderPath:t.path,rootPath:G,repo:z,onCreated:(L)=>p?p(L):c(),onOpenCreated:(L)=>l?.({...L,root:G,repo:z||"."})}),re=i(null);o(()=>{if(N.state!=="idle"||!N.data)return;let L=N.data;if(re.current===L)return;if(re.current=L,L.success&&!L.type)if(w(!1),I(!1),P(null),L.previousPath&&L.path&&f)f(L.previousPath,L.path);else c();else if(!L.success&&L.error&&D)P(L.error)},[N.state,N.data]);let q=(L)=>{if(z&&z!==".")L.append("repo",z);if(G)L.append("root",G);N.submit(L,{method:"post",action:"/api/fs/action"})},X=()=>{l?.({path:t.path,name:t.name,root:G,repo:z||"."})},J={path:t.path,name:t.name,kind:b?"folder":"file"},oe=C&&m.length>1?m:[J],ge=bt(t.name),B=v.clip&&!v.refusalFor(J)?`Paste ${we(v.clip)??"item"}`:null,fe=(L)=>{if(F(null),P(null),L==="view")X();else if(L==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:G}}));else if(L==="explorer"){let j=new FormData;j.append("actionType","open_explorer"),j.append("path",t.path),q(j)}else if(L==="copy_path")Bt(Sd(t.basePath,t.path));else if(L==="copy_relative")Bt(t.path);else if(L==="history"){te(!0);let j=new FormData;j.append("actionType","git_history"),j.append("path",t.path),q(j)}else if(L==="rename")se(t.path),w(!0);else if(L==="unfold")x?.();else if(L==="fold")g?.();else if(L==="new_file")K.openDialog("file");else if(L==="new_folder")K.openDialog("folder");else if(L==="delete")I(!0);else if(L==="cut")v.cut(oe);else if(L==="copy")v.copy(oe);else if(L==="compress")y.openCompress(oe);else if(L==="extract")y.openExtract(J);else if(L==="duplicate")v.duplicate(J);else if(L==="paste")v.paste(J)},le=(L)=>{L.preventDefault(),P(null);let j=new FormData;j.append("actionType","rename"),j.append("path",t.path),j.append("newPath",ne),q(j)},ve=()=>{let L=new FormData;if(L.append("actionType","delete"),oe.length>1)L.append("paths",JSON.stringify(oe.map((j)=>j.path)));else L.append("path",t.path);q(L)};return{contextMenu:A,contextMenuRef:M,openContextMenu:(L,j)=>F({x:L,y:j}),closeContextMenu:()=>F(null),showRenameModal:D,showDeleteModal:R,showHistoryModal:_,showCreateModal:K.open,createKind:K.kind,createError:K.error,createName:K.name,setCreateName:K.setName,renameValue:ne,setRenameValue:se,renameError:H,busy:N.state!=="idle"||K.busy||v.busy||y.busy,pasteLabel:B,selectionCount:oe.length,isArchive:ge,chainLabel:x!==void 0,foldable:g!==void 0,fetcherState:N.state,fetcherData:N.data,handleAction:fe,submitCreate:K.submit,submitRename:le,submitDelete:ve,closeCreate:K.closeDialog,closeDelete:()=>I(!1),closeRename:()=>w(!1),closeHistory:()=>te(!1)}}function Rt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let g=r?.path===t.path,v=Boolean(r)&&!g&&l.moveRefusalFor(r,t)===null,[b,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:g,acceptsDrop:v,isDropHovered:b&&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)}}}function pn(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:g,onRenamed:v,expandedPaths:b,onToggleFolder:m,gitFileMap:C,gitFolderMap:y,clipboard:N,archive:A,selection:F,selectionTargets:M,dragging:D,onDragStart:w,onDragEnd:R,onDropOn:I,onUnfold:_,onFold:te,foldRoots:ne,touch:se=!1}){let H=t.type==="folder",[P,z]=n(!1),[G,K]=n(!1),[re,q]=n(!1),[X,J]=n(!1),oe=Array.isArray(t.children)?t.children:[],ge=(t.path||"").replace(/^\/+/,""),B=!H?C?.get(ge)||C?.get(t.path):void 0,fe=B?sr(B.status,B.staged):null,le=H?y?.get(ge)||y?.get(t.path):null,ve=Boolean(fe),L=t.ignored===!0,j=b?b.has(t.path):P,ce=t.forceExpanded!==void 0?t.forceExpanded:j;o(()=>{J(!0)},[]),o(()=>{if(H&&b)z(b.has(t.path))},[b,t.path,H]),o(()=>{if(H&&ce&&pn(t,G,re)&&p)q(!0),K(!0),Promise.resolve(p(t.path)).finally(()=>K(!1))},[H,ce,t.children,t.path,p,G,re]);let ke={path:t.path,name:t.name,kind:H?"folder":"file"},xe=F.selected.has(t.path),W=Dt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:M,selected:xe,archive:A,diff:{staged:B?.staged||(B?.status?B.status[0]!==" "&&B.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,onUnfold:_&&Ee({type:H?"folder":"file",name:t.name})?()=>_(ke):void 0,onFold:te&&ne?.has(t.path)?()=>te(ne.get(t.path)):void 0,clipboard:N,isFolder:H});he(W.contextMenuRef,W.closeContextMenu);let Y=yd({enabled:se,onLongPress:(V,be)=>W.openContextMenu(V,be)}),Ce=(V)=>{if(V.stopPropagation(),Y.consume())return;let be=F.gestureOf(V);if(be!=="plain"){F.applyGesture(be,t.path);return}if(F.applyGesture("plain",t.path),H){let pe=!ce;if(z(pe),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,pe),!pe)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ye=(V)=>{V.preventDefault(),V.stopPropagation(),F.ensureForContext(t.path),W.openContextMenu(V.clientX,V.clientY)},de=Rt({target:ke,dragging:D,clipboard:N,onDragStart:w,onDragEnd:R,onDropOn:I,onHoverAccept:_});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":xe?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!se,onClick:Ce,onContextMenu:ye,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(Ye,{name:t.name,path:t.path,isFolder:H,isOpen:ce,ignored:L,selected:xe,gitStatus:fe,folderStatus:le})}),ce&&G&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!G&&oe.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:oe.map((V)=>e(Pe,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,expandedPaths:b,onToggleFolder:m,gitFileMap:C,gitFolderMap:y,clipboard:N,archive:A,selection:F,selectionTargets:M,dragging:D,onDragStart:w,onDragEnd:R,onDropOn:I,onUnfold:_,onFold:te,foldRoots:ne,touch:se},V.path))}),X&&W.contextMenu&&e(Je,{x:W.contextMenu.x,y:W.contextMenu.y,isFolder:H,hasGitStatus:ve,pasteLabel:W.pasteLabel,chainLabel:W.chainLabel,foldable:W.foldable,busy:W.busy,selectionCount:W.selectionCount,isArchive:W.isArchive,onAction:W.handleAction}),X&&e(ot,{actions:W,file:t,isFolder:H,chainLabel:Ee({type:H?"folder":"file",name:t.name})?t.name:void 0})]})}function St({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let g=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,b=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-g-12)):r;return ie(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:b,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(hi,{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(bn,{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(Ro,{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 Tt({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:g,children:v}){return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe 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:g,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 un({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:g,onNameChange:v,onDestinationChange:b,onCancel:m,onSubmit:C}){let y=t.slice(0,4).map((A)=>A.name).join(", "),N=t.length>4?` +${t.length-4} more`:"";return e(Tt,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${N}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(A)=>{A.preventDefault(),C()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",children:"Format"}),e(Z,{ariaLabel:"Format",value:r,onChange:(A)=>g(A),placeholder:"Format",searchable:!1,allowEmpty:!1,className:"mb-3 text-xs",options:p.map((A)=>({value:A.id,label:A.available?A.label:`${A.label} — ${A.tool} not installed`,disabled:!A.available}))}),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)=>b(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 fn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:g}){return e(Tt,{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(),g()},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 Et({archive:t}){if(t.compress)return e(un,{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(fn,{archive:t.extract.archive,kindLabel:wt(Oe(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 Mt(){let[t,r]=T("files.outlineExpanded",!1),l=Dr(),c=ze(Nh,Dh),{symbols:p,total:f,truncated:x,notice:g}=xd({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,b=(m,C)=>{if(!c.path)return;if(v){let y=Td(p,C);if(y)fs({path:c.path,...y});return}Mo({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(ia,{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:g}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,C)=>e("button",{type:"button",onClick:()=>b(m,C),"aria-label":v?`${di(m.kind)} ${m.name}`:`${di(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${di(m.kind).toLowerCase()}`:`${di(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(vd,{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:kd(f)})]})})})})]})}function He(t,r){return Ae(t.map((l)=>mn(l,r)))}function mn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:He(l,r)}}function hn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function $t(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Lt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ge(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},g=f,v=null;for(let b=0;b<c.length-1;){let m=c.slice(0,b+1).join("/"),C=g.find((M)=>M.type==="folder"&&M.path===m),y=C?null:g.find((M)=>M.type==="folder"&&M.path.startsWith(`${m}/`)&&(p===M.path||p.startsWith(`${M.path}/`))),N=C??y,A=N?x[N.path]??N.children:null;if(N&&!Array.isArray(A))return{nodes:t,cache:r};if(!N){let M=gn(g,x,m);if(M){g=M;let D=g.find((R)=>R.path===m),w=Array.isArray(D?.children)?[...D.children]:[];x[m]=w,g=w,v=m,b+=1;continue}}let F=Array.isArray(A)?[...A]:[];if(N){x[N.path]=F,g=F,v=N.path,b=N.path.split("/").length;continue}g.push({name:c[b],path:m,type:"folder",ignored:!1}),x[m]=F,g=F,v=m,b+=1}if(g.push(l),v!==null)x[v]=Lt(g);return f=Lt(f),{nodes:f,cache:x}}function gn(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 g={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)g={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[g]};return t[c]={name:$t(l),path:l,type:"folder",ignored:!1,children:[g]},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=hn(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((C)=>C.path===l)).sort((m,C)=>C.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let b=r[v];return{entry:b.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:b.filter((m)=>m.path!==l)}}}function Ot(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),g=Array.isArray(f.children)?Ot(f.children,r,l):void 0;if(!x&&g===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,b=x?{...f,path:v,name:$t(v)}:{...f};if(g!==void 0)b.children=g;return b});return c?p:t}function Pt(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:Ot(f,r,l)}return c}function It(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 Ht(t){if(!k(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)=>k(r)):[],root:t.root}}async function Ke(t){try{return Ht(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Gt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,g]=n({scope:"",files:[],root:""}),[v,b]=n(!1),m=i({}),C=i([]),y=i(f);y.current=f;let N=i(""),A=i(""),F=i(c);F.current=c;let M=(P)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(P)z.set("path",P);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},D=(P,z)=>{N.current=P,A.current=z;let G=He(C.current,m.current);return g({scope:P,files:G,root:z}),G},w=async(P)=>{let z=[...F.current];if(z.length===0)return;let G=await Promise.all(z.map(async(X)=>({path:X,read:await Ke(M(X))})));if(y.current!==P)return;let K=[];for(let{path:X,read:J}of G)if(J.status==="ok")m.current[X]=J.files;else if(J.status==="missing")K.push(X);if(K.length===0)return;let re=new Set(K);for(let X of K)delete m.current[X];let q=new Set([...F.current].filter((X)=>!re.has(X)));F.current=q,p(q)},R=async()=>{if(!t)return;let P=y.current;b(!0);try{let z=await Ke(M());if(y.current!==P)return;if(z.status!=="ok")return;if(N.current!==P)m.current={};if(C.current=z.files,D(P,z.root),await w(P),y.current!==P)return;D(P,z.root)}finally{if(y.current===P)b(!1)}},I=async(P)=>{let z=y.current,G=await Ke(M(P));if(y.current!==z||G.status!=="ok")return;if(m.current[P]=G.files,N.current===z)D(z,A.current)},_=(P)=>{let z=Ht(P);if(z.status!=="ok")return;let G=y.current;if(N.current!==G)m.current={};C.current=z.files,D(G,z.root),w(G).then(()=>{if(y.current===G)D(G,z.root)})},te=()=>{m.current={},C.current=[],N.current="",A.current="",g({scope:"",files:[],root:""})},ne=(P)=>{let z=y.current;if(N.current!==z)return null;let G={name:P.path.slice(P.path.lastIndexOf("/")+1),path:P.path,type:P.kind,ignored:!1},K=Ge(C.current,m.current,G);if(K.nodes===C.current)return null;return C.current=K.nodes,m.current=K.cache,D(z,A.current)},se=(P,z)=>{let G=y.current;if(N.current!==G)return null;let K=zt(C.current,m.current,P);if(!K.entry)return null;m.current=Pt(K.cache,P,z);let re={...K.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Ge(K.nodes,m.current,re);return C.current=q.nodes,m.current=q.cache,D(G,A.current)},H=x.scope===f;return{scope:f,files:H?x.files:[],root:H?x.root:"",isLoading:v,reload:R,loadChildren:I,adoptRoot:_,insertEntry:ne,moveEntry:se,reset:te}}function Kt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=ft(),[f,x]=T("files.clipboard",null),g=ht(f),v=at(t,r),b=i(!1),m=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let F=p.data;if(m.current===F)return;m.current=F;let M=b.current;if(b.current=!1,F.success){if(M)x(null);if(F.failures?.length)c(`${F.failures.length} item(s) could not be moved: ${F.failures[0].error}`);l()}else c(F.error||"The transfer did not complete")},[p.state,p.data]);let C=a((F,M)=>{b.current=M;let D=new FormData;for(let[w,R]of Object.entries(F))D.append(w,R);if(r&&r!==".")D.append("repo",r);if(t)D.append("root",t);p.submit(D,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((F)=>ut(g,v,Le(F.path,F.kind)),[g,v]),N=a((F,M)=>pt(F,Le(M.path,M.kind)),[]),A=a((F,M,D,w)=>{let R=new FormData;R.append("actionType","paste"),R.append("mode",D),R.append("targetPath",M.path),R.append("targetKind",M.kind);for(let I of F)R.append("sourcePath",I.path);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);b.current=w,p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:g,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:N,copy:(F)=>{if(F.length===0)return;x({scope:v,entries:F.map(({path:M,name:D,kind:w})=>({path:M,name:D,kind:w})),mode:"copy"})},cut:(F)=>{if(F.length===0)return;x({scope:v,entries:F.map(({path:M,name:D,kind:w})=>({path:M,name:D,kind:w})),mode:"cut"})},duplicate:(F)=>{C({actionType:"duplicate",path:F.path},!1)},move:(F,M)=>{let D=N(F,M);if(D){c(D);return}A([F],M,"cut",Boolean(g?.mode==="cut"&&g.entries.some((w)=>w.path===F.path)))},paste:(F)=>{if(!g)return;let M=y(F);if(M){c(M);return}A(g.entries.map(({path:D,name:w,kind:R})=>({path:D,name:w,kind:R})),F,g.mode,g.mode==="cut")}}}var xn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=ft(),[p,f]=n(xn),[x,g]=n(null),[v,b]=n(null),[m,C]=n(null),y=i(null),N=i(null);o(()=>{let w=!1;return(async()=>{try{let I=await(await fetch("/api/fs/archive")).json();if(!w&&Array.isArray(I.formats)&&I.formats.length>0)f(I.formats)}catch{}})(),()=>{w=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let w=c.data;if(N.current===w)return;N.current=w;let R=y.current;if(y.current=null,w.success){if(C(null),R==="compress")g(null);if(R==="extract")b(null);l()}else if(R)C(w.error||"The archive request failed")},[c.state,c.data]);let A=a((w)=>{let R=new FormData;for(let[I,_]of Object.entries(w))R.append(I,_);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);c.submit(R,{method:"post",action:"/api/fs/action"})},[c,r,t]),F=a((w)=>{if(w.length===0)return;let R=p.find((I)=>I.id==="zip"&&I.available)?.id??p.find((I)=>I.available)?.id??"zip";C(null),b(null),g({entries:w.map(({path:I,name:_,kind:te})=>({path:I,name:_,kind:te})),format:R,name:De(w,R),destination:Ft(w)})},[p]),M=a((w)=>{C(null),g(null),b({archive:w,destination:Nt(w.path)})},[]),D=a((w)=>{g((R)=>{if(!R)return R;let I=De(R.entries,R.format),_=R.name===I?De(R.entries,w):R.name;return{...R,format:w,name:_}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:F,openExtract:M,setFormat:D,setName:(w)=>g((R)=>R&&{...R,name:w}),setCompressDestination:(w)=>g((R)=>R&&{...R,destination:w}),setExtractDestination:(w)=>b((R)=>R&&{...R,destination:w}),cancel:()=>{g(null),b(null),C(null)},submitCompress:()=>{let w=x;if(!w)return;y.current="compress",C(null),A({actionType:"compress",format:w.format,name:w.name.trim(),destination:w.destination.trim()||".",paths:JSON.stringify(w.entries.map((R)=>R.path))})},submitExtract:()=>{let w=v;if(!w)return;y.current="extract",C(null),A({actionType:"extract",path:w.archive.path,destination:w.destination.trim()||"."})}}}function vn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function yn(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 _t(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((b,m)=>{if(b==="range"){l(new Set(yn(t,c,m)));return}if(p(m),b==="toggle"){l((C)=>{let y=new Set(C);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((b)=>{l((m)=>{if(m.has(b))return m;return new Set([b])}),p(b)},[]),g=a(()=>{l(new Set),p(null)},[]),v=a(vn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:g}),[r,c,v,f,x,g])}function je(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))je(p.children,r,l+1,c);return c}function Wt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,b)=>{let m=st(b,v);if(m.length===0)return;r((C)=>{if(m.every((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.add(N);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let b=t.insertEntry(v);if(!b){c();return}f(v.path,b)},[t,c,f]),g=a((v,b)=>{p?.(v,b),r((C)=>{let y=It(C,v,b);return l(Array.from(y)),y});let m=t.moveEntry(v,b);if(!m){c();return}f(b,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:g}}var kn=new Set;function Ut({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let b=Me(v.path,v.name);if(!b)return;p((C)=>{let y=C.scope===t?C.chains:new Map;if(y.get(v.path)?.length===b.length)return C;let A=new Map(y);return A.set(v.path,b),{scope:t,chains:A}});let m=b.slice(0,-1);r((C)=>{if(m.every((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.add(N);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let b=c.scope===t?c.chains.get(v):void 0;if(!b)return;let m=b.slice(0,-1);p((C)=>{if(C.scope!==t)return C;let y=new Map(C.chains);return y.delete(v),{scope:t,chains:y}}),r((C)=>{if(!m.some((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.delete(N);return l(Array.from(y)),y})},[t,c,r,l]),g=a((v,b)=>{let m=c.scope===t?c.chains:null;if(!m)return;let C=new Map,y=[],N=!1;for(let[A,F]of m){if(F.findIndex((R,I)=>R===v&&I>0&&I<F.length-1)!==-1){N=!0;continue}let D=F.map((R)=>R===v?b:R.startsWith(`${v}/`)?`${b}${R.slice(v.length)}`:R),w=D[D.length-1];if(w!==A||D.some((R,I)=>R!==F[I]))N=!0;C.set(w,D),y.push(...D.slice(0,-1))}if(!N)return;p({scope:t,chains:C}),r((A)=>{if(y.every((M)=>A.has(M)))return A;let F=new Set(A);for(let M of y)F.add(M);return l(Array.from(F)),F})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):kn,unfold:f,fold:x,rekey:g}}function Vt(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((g)=>g!==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 Xt({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 ri({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[g,v]=T("files.searchQuery",""),[b,m,C]=T("files.expandedPaths",[]),[y,N]=n(()=>new Set(b)),{activeRepo:A,setActiveRepo:F}=xr(c),{repos:M,scanning:D,rescan:w}=wr(c,r),{fileMap:R,folderMap:I,refreshGitStatus:_}=hl(c,A,r),[te,ne]=n(null),se=i(null);o(()=>{if(!C)return;N((O)=>{let ee=new Set(b);if(O.size===ee.size&&Array.from(ee).every((me)=>O.has(me)))return O;return ee})},[C,b]);let H=Gt({enabled:r,rootPath:c,activeRepo:A,expandedPaths:y,onExpansionPruned:(O)=>{N(O),m(Array.from(O))}});o(()=>{if(!C||!l)return;H.reload()},[f,c,r,A,C,l]);let P=r&&C?yh(H.scope):null,z=Te(P);o(()=>{if(z.data)H.adoptRoot(z.data)},[z.data]);let G=(O)=>(_(),H.loadChildren(O)),K=(O,ee)=>{let me=new Set(y);if(ee)me.add(O);else me.delete(O);N(me),m(Array.from(me))},{unfolded:re,unfold:q,fold:X,rekey:J}=Ut({scope:H.scope,setExpandedPaths:N,setStoredExpandedPaths:m}),oe=H.files,ge=it(oe,re),B=Vt(ge.nodes,g),fe=je(B,(O)=>O.forceExpanded!==void 0?O.forceExpanded:y.has(O.path)),le=_t(fe.map((O)=>O.path)),ve=fe.filter((O)=>le.selected.has(O.path)).map(({path:O,name:ee,kind:me})=>({path:O,name:ee,kind:me})),L=(O)=>{if(O===A)return;H.reset(),N(new Set),m([]),le.clear(),F(O)},j=()=>{if(_(),x)x();else H.reload()},{insertCreated:ce,moveRenamed:ke}=Wt({listing:H,setExpandedPaths:N,setStoredExpandedPaths:m,reload:j,onMoved:(O,ee)=>J(O,ee)}),xe=As(),{pushToast:W}=We(),Y=Kt({rootPath:c,repo:A,onComplete:j,onError:(O)=>W(O,"error")}),Ce=jt({rootPath:c,repo:A,onComplete:j}),ye={path:".",name:".",kind:"folder"},de=Y.clip&&!Y.refusalFor(ye)?`Paste ${we(Y.clip)??"item"}`:null,[V,be]=n(null),pe=Xt({dragging:V,clipboard:Y,target:ye}),Re=Ne({folderPath:".",rootPath:c,repo:A,onCreated:ce,onOpenCreated:(O)=>p?.({...O,root:c,repo:A})}),[_e,qt]=n(!1);o(()=>qt(!0),[]);let{count:Ue,clear:Ve}=le;if(o(()=>{if(!l)return;let O=(ee)=>{if(ee.key==="Escape"&&Ue>0)Ve()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[l,Ue,Ve]),!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 Qt=H.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Qe,{rootPath:c,activeRepo:A,repos:M,reposScanning:D,onRefreshRepos:w,onSelectRepo:L,searchQuery:g,onSearchChange:v,onRefresh:j,refreshing:Qt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${xe?"file-tree-touch":""} ${pe.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(O)=>{O.preventDefault(),ne({x:O.clientX,y:O.clientY})},onDragEnter:pe.onDragEnter,onDragLeave:pe.onDragLeave,onDragOver:pe.onDragOver,onDrop:pe.onDrop,children:H.isLoading&&B.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):B.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):B.map((O)=>e(Pe,{file:O,rootPath:c,basePath:H.root,repo:A,onLoadChildren:G,onOpenFile:p,onActionComplete:j,onCreated:ce,onRenamed:ke,expandedPaths:y,onToggleFolder:K,gitFileMap:R,gitFolderMap:I,clipboard:Y,archive:Ce,selection:le,selectionTargets:ve,dragging:V,onDragStart:be,onDragEnd:()=>be(null),onDropOn:(ee)=>{if(!V)return;Y.move(V,ee)},onUnfold:q,onFold:X,foldRoots:ge.roots,touch:xe},O.path))}),e(Mt,{}),_e&&e(At,{menu:te,menuRef:se,pasteLabel:de,busy:Y.busy,create:Re,onAction:(O)=>{if(ne(null),O==="new_file")Re.openDialog("file");if(O==="new_folder")Re.openDialog("folder");if(O==="paste")Y.paste(ye)}}),_e&&e(Et,{archive:Ce})]})}export{ri as FileExplorer};
@@ -1,4 +1,4 @@
1
- import{n,o,i,u,a,ze,e,ao,I,S,T,tt,cr,xl,Bi,Ii,Th,Qh,Rh,Mo,Lh,Fh,gt,Dd,zh,Uh,Lt,Pa,zd,Pl,Wd,tg}from"./index-8w69r0c4.js";import{ke,Dn,jl,Br,x,P,on,Nn,D,ye,_}from"./index-4kchzh9y.js";function We(t){let r=t.split("/").pop()??"",s=r.lastIndexOf(".");return s>0&&s<r.length-1?r.slice(s).toLowerCase():""}function wA(t){let r=Lt("fileOpener"),s=Lt("sourceCodeRenderer"),l=Pa(),c=t.extension??We(t.path),d=r.find((h)=>h.registration.matches({path:t.path,extension:c}));if(d)return{kind:"opener",pluginId:d.pluginId,Component:d.registration.component,props:{...l,path:t.path,extension:c}};let f=s.find((h)=>h.registration.extensions.includes(c));if(f)return{kind:"source",pluginId:f.pluginId,Component:f.registration.component,props:{...l,path:t.path,content:t.content,language:t.language}};return null}function CA(t){let r=Lt("diffRenderer"),s=Pa(),l=We(t.path),c=r.find((d)=>{let f=d.registration.extensions;return f===void 0||f.includes(l)});if(!c)return null;return{pluginId:c.pluginId,Component:c.registration.component,props:{...s,path:t.path,diff:t.diff}}}function EA({view:t}){if(t.kind==="opener"){let s=t.Component;return e(tt,{pluginId:t.pluginId,children:e(s,{...t.props})})}let r=t.Component;return e(tt,{pluginId:t.pluginId,children:e(r,{...t.props})})}var Tt={docx:!0},Ct={xls:!0,xlsx:!0,xlsm:!0},Dt={csv:!0,tsv:!0},It={md:!0,markdown:!0,mdx:!0},Ot={html:!0,htm:!0},Pt={drawio:!0,dio:!0},Ls={image:!0,pdf:!0,docx:!0,spreadsheet:!0,code:void 0,markdown:void 0,html:void 0,svg:void 0,csv:void 0,drawio:void 0},ku={markdown:!0,html:!0,svg:!0,csv:!0,drawio:!0,code:void 0,image:void 0,pdf:void 0,docx:void 0,spreadsheet:void 0},Nt={markdown:!0,svg:!0,csv:!0,drawio:!0,html:void 0,code:void 0,image:void 0,pdf:void 0,docx:void 0,spreadsheet:void 0};function xu(t){return Nt[t]===!0}var Xo={code:"Text",markdown:"Markdown",html:"HTML",svg:"SVG",csv:"CSV",image:"Image",pdf:"PDF",docx:"Document",spreadsheet:"Spreadsheet",drawio:"Diagram"};function Fs(t){let r=Bi(t);if(!r)return"code";if(r==="svg")return"svg";if(Pt[r])return"drawio";if(It[r])return"markdown";if(Ot[r])return"html";if(Ii(t))return"image";if(r==="pdf")return"pdf";if(Tt[r])return"docx";if(Ct[r])return"spreadsheet";if(Dt[r])return"csv";return"code"}var Wt={id:"",url:null,loadBytes:null,mimeType:null};async function Le(t){let r=await t.json().catch(()=>null);return typeof r?.error==="string"&&r.error?r.error:`Could not read the file (HTTP ${t.status}).`}function Ae(t){let r=Th(t.path);if(t.rawUrl){let c=t.rawUrl;return{id:c,url:c,mimeType:r,loadBytes:async()=>{let d=await fetch(c);if(!d.ok)throw Error(await Le(d));return d.arrayBuffer()}}}let s=tg(t.handleId);if(s){let{bytes:c}=s;return{id:t.handleId,url:null,mimeType:s.mimeType??r,loadBytes:async()=>c.slice().buffer}}let l=Pl(t.handleId);if(l)return{id:t.handleId,url:null,mimeType:r,loadBytes:async()=>(await l.getFile()).arrayBuffer()};return Wt}function Be(t,r){let s=t?Fs(t.path??""):"code",l=Ls[s]===!0,c=Boolean(t?.path)&&!t?.handleId,d=c&&t?.content===void 0&&Ii(t?.path)?t.path:null,f=d!==null,h=t&&!f&&l&&c&&t.content===void 0?xl({path:t.path,root:t.root,repo:t.repo}):null,p=Ae({path:t?.path,handleId:t?.handleId,rawUrl:d?`${xl({path:d,root:t?.root,repo:t?.repo})}&v=${r}`:h});return{viewerKind:s,isBinaryViewer:l,isImage:f,imageUrl:f?p.url:null,byteSource:p}}function Ke(t){let r=t.indexOf(`
1
+ import{n,o,i,u,a,ze,e,ao,I,S,T,tt,cr,xl,Bi,Ii,Th,Qh,Rh,Mo,Lh,Fh,gt,Dd,zh,Uh,Lt,Pa,zd,Pl,Wd,tg}from"./index-jvn2xfpt.js";import{ke,Dn,jl,Br,x,P,on,Nn,D,ye,_}from"./index-4kchzh9y.js";function We(t){let r=t.split("/").pop()??"",s=r.lastIndexOf(".");return s>0&&s<r.length-1?r.slice(s).toLowerCase():""}function wA(t){let r=Lt("fileOpener"),s=Lt("sourceCodeRenderer"),l=Pa(),c=t.extension??We(t.path),d=r.find((h)=>h.registration.matches({path:t.path,extension:c}));if(d)return{kind:"opener",pluginId:d.pluginId,Component:d.registration.component,props:{...l,path:t.path,extension:c}};let f=s.find((h)=>h.registration.extensions.includes(c));if(f)return{kind:"source",pluginId:f.pluginId,Component:f.registration.component,props:{...l,path:t.path,content:t.content,language:t.language}};return null}function CA(t){let r=Lt("diffRenderer"),s=Pa(),l=We(t.path),c=r.find((d)=>{let f=d.registration.extensions;return f===void 0||f.includes(l)});if(!c)return null;return{pluginId:c.pluginId,Component:c.registration.component,props:{...s,path:t.path,diff:t.diff}}}function EA({view:t}){if(t.kind==="opener"){let s=t.Component;return e(tt,{pluginId:t.pluginId,children:e(s,{...t.props})})}let r=t.Component;return e(tt,{pluginId:t.pluginId,children:e(r,{...t.props})})}var Tt={docx:!0},Ct={xls:!0,xlsx:!0,xlsm:!0},Dt={csv:!0,tsv:!0},It={md:!0,markdown:!0,mdx:!0},Ot={html:!0,htm:!0},Pt={drawio:!0,dio:!0},Ls={image:!0,pdf:!0,docx:!0,spreadsheet:!0,code:void 0,markdown:void 0,html:void 0,svg:void 0,csv:void 0,drawio:void 0},ku={markdown:!0,html:!0,svg:!0,csv:!0,drawio:!0,code:void 0,image:void 0,pdf:void 0,docx:void 0,spreadsheet:void 0},Nt={markdown:!0,svg:!0,csv:!0,drawio:!0,html:void 0,code:void 0,image:void 0,pdf:void 0,docx:void 0,spreadsheet:void 0};function xu(t){return Nt[t]===!0}var Xo={code:"Text",markdown:"Markdown",html:"HTML",svg:"SVG",csv:"CSV",image:"Image",pdf:"PDF",docx:"Document",spreadsheet:"Spreadsheet",drawio:"Diagram"};function Fs(t){let r=Bi(t);if(!r)return"code";if(r==="svg")return"svg";if(Pt[r])return"drawio";if(It[r])return"markdown";if(Ot[r])return"html";if(Ii(t))return"image";if(r==="pdf")return"pdf";if(Tt[r])return"docx";if(Ct[r])return"spreadsheet";if(Dt[r])return"csv";return"code"}var Wt={id:"",url:null,loadBytes:null,mimeType:null};async function Le(t){let r=await t.json().catch(()=>null);return typeof r?.error==="string"&&r.error?r.error:`Could not read the file (HTTP ${t.status}).`}function Ae(t){let r=Th(t.path);if(t.rawUrl){let c=t.rawUrl;return{id:c,url:c,mimeType:r,loadBytes:async()=>{let d=await fetch(c);if(!d.ok)throw Error(await Le(d));return d.arrayBuffer()}}}let s=tg(t.handleId);if(s){let{bytes:c}=s;return{id:t.handleId,url:null,mimeType:s.mimeType??r,loadBytes:async()=>c.slice().buffer}}let l=Pl(t.handleId);if(l)return{id:t.handleId,url:null,mimeType:r,loadBytes:async()=>(await l.getFile()).arrayBuffer()};return Wt}function Be(t,r){let s=t?Fs(t.path??""):"code",l=Ls[s]===!0,c=Boolean(t?.path)&&!t?.handleId,d=c&&t?.content===void 0&&Ii(t?.path)?t.path:null,f=d!==null,h=t&&!f&&l&&c&&t.content===void 0?xl({path:t.path,root:t.root,repo:t.repo}):null,p=Ae({path:t?.path,handleId:t?.handleId,rawUrl:d?`${xl({path:d,root:t?.root,repo:t?.repo})}&v=${r}`:h});return{viewerKind:s,isBinaryViewer:l,isImage:f,imageUrl:f?p.url:null,byteSource:p}}function Ke(t){let r=t.indexOf(`
2
2
  `);return r>0&&t[r-1]==="\r"?"crlf":"lf"}function me(t){return t.includes("\r")?t.replace(/\r\n?/g,`
3
3
  `):t}function Ue(t,r){let s=me(t);return r==="crlf"?s.replace(/\n/g,`\r
4
4
  `):s}function qe(t){return String(t.id??t.path??t.name)}function Ve({target:t,key:r,isBinaryViewer:s,revision:l,loadedRef:c,contentsRef:d,baselinesRef:f,pendingRef:h,readingRef:p,remember:g}){let[v,k]=n(!1),[w,m]=n(!1),[R,y]=n(null),[E,F]=n(null);return o(()=>{if(m(!1),!t)return;let b=qe(t);if(c.current.has(b))return;if(c.current.add(b),s){y(null),F(null),k(!1);return}if(t.content!==void 0){g(b,t.content,null,null),y(null),F(null);return}if(!t.path){y("No file path supplied for this attachment."),F(null);return}let W=d.current[b]===void 0,U=!1;if(W)k(!0);y(null),F(null);let N=new URLSearchParams({path:t.path});if(t.root)N.set("root",t.root);if(t.repo&&t.repo!==".")N.set("repo",t.repo);return p.current+=1,m(!0),fetch(`/api/fs/read?${N.toString()}`).then(async(B)=>{let O=await B.json().catch(()=>null);if(!B.ok||!O||typeof O.content!=="string"){let C=Error(O?.error||`HTTP ${B.status}`);if(O?.kind)C.kind=O.kind;else if(B.status===415)C.kind="binary";throw C}return{text:O.content,mtimeMs:typeof O.mtimeMs==="number"?O.mtimeMs:null,hash:typeof O.hash==="string"?O.hash:null}}).then(({text:B,mtimeMs:O,hash:C})=>{if(U)return;let A=d.current[b];if(A!==void 0&&A!==f.current[b])return;let X=h.current;if(X&&qe(X.file)===b)return;g(b,B,O,C)}).catch((B)=>{if(U)return;if(!W)return;g(b,"",null,null);let O=B instanceof Error?B.message:"Failed to read file",C=B?.kind;F(C?O:null),y(O)}).finally(()=>{if(p.current-=1,!U)k(!1),m(!1)}),()=>{U=!0}},[r,t,g,l,s,c,d,f,h,p]),{isLoading:v,isReading:w&&!v,loadError:R,unsupported:E}}async function _e(t,r){let s=await fetch(t);if(!s.ok)throw Error(`HTTP ${s.status}`);zd(await s.blob(),r)}async function $e(t){let r=await fetch(t);if(!r.ok)throw Error(`HTTP ${r.status}`);let s=await r.blob();if(typeof ClipboardItem>"u"||!navigator.clipboard?.write)throw Error("Image clipboard unavailable");await navigator.clipboard.write([new ClipboardItem({[s.type]:s})])}function He({target:t,content:r,downloadContent:s,imageUrl:l,downloadMimeType:c,byteSource:d,byteViewer:f=!1}){let[h,p]=n(!1),g=a(()=>{p(!0),window.setTimeout(()=>p(!1),1500)},[]),v=a(()=>{if(!t)return;if(l){$e(l).then(g).catch(()=>{});return}if(f)return;if(!navigator.clipboard)return;navigator.clipboard.writeText(r).then(g).catch(()=>{})},[t,r,l,f,g]),k=a(()=>{if(!t)return;if(l){_e(l,t.name).catch(()=>{});return}if(f){let w=d?.loadBytes;if(!w)return;let m=d?.mimeType;w().then((R)=>zd(m?new Blob([R],{type:m}):new Blob([R]),t.name)).catch(()=>{});return}zd(new Blob([s],{type:c}),t.name)},[t,s,c,l,f,d]);return{copied:h,copy:v,download:k}}async function je(t){let r=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(r),(s)=>s.toString(16).padStart(2,"0")).join("")}async function Xe(t,r,s,l){if(t.handleId){let d=s==="crlf"?r.replace(/\n/g,`\r
@@ -1 +1 @@
1
- import{d,n,a,e,s,B,kh,Te,N,qe,xt,so,_c,nt}from"./index-8w69r0c4.js";import{fa,ed,WA,rl,td,nd}from"./index-6pxh5p8g.js";var P={name:"funnel",size:24,node:[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],aliases:["filter"]},v=s(P);function y(t,r){if(!t)return r;if(!r)return t;let i=Date.parse(t.generatedAt),o=Date.parse(r.generatedAt);if(Number.isNaN(i)||Number.isNaN(o))return t;return o>i?r:t}var k="usageHideEmptyProviders";function R(t){return N(k,t)!==!1}function w(){let[t,r]=n(()=>R()),i=a((o)=>{r(o),qe(k,o)},[]);return[t,i]}function Y({className:t="",active:r=!0,tabsMode:i=!1}){let{report:o,isLoading:f,error:p,reload:x}=nd(),g=Te(kh,{enabled:r}),l=y(g.data,o),u=l?rl(l):[],[c,b]=w(),h=c?u.filter((m)=>WA(m.summary)):u;if(p&&!l)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(B,{size:16,className:"text-error"}),e("p",{className:"text-error text-xs",children:p}),e("button",{type:"button",onClick:()=>x(),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Try again"})]});if(!l)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(xt,{left:e(d,{children:[e(so,{id:"usage",tabsMode:i,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 ",fa(l.generatedAt)]}),l.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(d,{children:[e(_c,{label:"Hide providers without quota",onClick:()=>b(!c),pressed:c,children:e(v,{size:14})}),e(nt,{label:"Refresh usage",onClick:()=>x({force:!0}),busy:f||g.refreshing,disabled:f})]})}),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:[p&&e("p",{className:"text-error text-xs",children:p}),h.length>0?h.map((m)=>e(ed,{summary:m.summary},m.id)):u.length>0?e(d,{children:[e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:["All ",u.length," providers with a detected credential report no quota usage, so none are shown while that filter is on."]}),e("button",{type:"button",onClick:()=>b(!1),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Show providers without quota"})]}):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(td,{})]})]})}export{Y as UsagePanel};
1
+ import{d,n,a,e,s,B,kh,Te,N,qe,xt,so,_c,nt}from"./index-jvn2xfpt.js";import{fa,ed,WA,rl,td,nd}from"./index-937bn0d2.js";var P={name:"funnel",size:24,node:[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],aliases:["filter"]},v=s(P);function y(t,r){if(!t)return r;if(!r)return t;let i=Date.parse(t.generatedAt),o=Date.parse(r.generatedAt);if(Number.isNaN(i)||Number.isNaN(o))return t;return o>i?r:t}var k="usageHideEmptyProviders";function R(t){return N(k,t)!==!1}function w(){let[t,r]=n(()=>R()),i=a((o)=>{r(o),qe(k,o)},[]);return[t,i]}function Y({className:t="",active:r=!0,tabsMode:i=!1}){let{report:o,isLoading:f,error:p,reload:x}=nd(),g=Te(kh,{enabled:r}),l=y(g.data,o),u=l?rl(l):[],[c,b]=w(),h=c?u.filter((m)=>WA(m.summary)):u;if(p&&!l)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(B,{size:16,className:"text-error"}),e("p",{className:"text-error text-xs",children:p}),e("button",{type:"button",onClick:()=>x(),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Try again"})]});if(!l)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(xt,{left:e(d,{children:[e(so,{id:"usage",tabsMode:i,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 ",fa(l.generatedAt)]}),l.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(d,{children:[e(_c,{label:"Hide providers without quota",onClick:()=>b(!c),pressed:c,children:e(v,{size:14})}),e(nt,{label:"Refresh usage",onClick:()=>x({force:!0}),busy:f||g.refreshing,disabled:f})]})}),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:[p&&e("p",{className:"text-error text-xs",children:p}),h.length>0?h.map((m)=>e(ed,{summary:m.summary},m.id)):u.length>0?e(d,{children:[e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:["All ",u.length," providers with a detected credential report no quota usage, so none are shown while that filter is on."]}),e("button",{type:"button",onClick:()=>b(!1),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Show providers without quota"})]}):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(td,{})]})]})}export{Y as UsagePanel};