@kabmo-labs/kabmo 0.56.0 → 0.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +3 -3
  3. package/dist/client/static/js/{Body-jfy4bhk2.js → Body-p6zwk0nx.js} +1 -1
  4. package/dist/client/static/js/{CsvGrid-4c5t668z.js → CsvGrid-563qmmmr.js} +1 -1
  5. package/dist/client/static/js/{DocxView-3x7whtvq.js → DocxView-5j69q3s0.js} +1 -1
  6. package/dist/client/static/js/{DrawioView-tbkc5dfz.js → DrawioView-gd6k3hvn.js} +1 -1
  7. package/dist/client/static/js/{HtmlPreview-egxkayya.js → HtmlPreview-6gnktzzp.js} +1 -1
  8. package/dist/client/static/js/{ImageView-swhzvw2p.js → ImageView-fkfq3fwv.js} +1 -1
  9. package/dist/client/static/js/{LayoutWrapper-sangsrt5.js → LayoutWrapper-mdb1qm26.js} +1 -1
  10. package/dist/client/static/js/MergeDiffView-7kpjxcg9.js +1 -0
  11. package/dist/client/static/js/{Modal-1fj8kvme.js → Modal-0p9cr2tn.js} +12 -12
  12. package/dist/client/static/js/{PdfView-0k2egsbz.js → PdfView-n1zq27td.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-t547rqeb.js → SessionsView-gptt0rq8.js} +1 -1
  14. package/dist/client/static/js/{SheetView-anb3gavm.js → SheetView-nes7j86v.js} +1 -1
  15. package/dist/client/static/js/{SvgPreview-e2wrj2hj.js → SvgPreview-vv0qzkt7.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-0rs86b68.js → abnfDiagram-O67JEVCF-02g96sn6.js} +1 -1
  17. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-0k3zzxz1.js → architectureDiagram-NJMV4G6O-7qj2fpwt.js} +1 -1
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-t1n1fx96.js → blockDiagram-BEXU5L5S-grdr1j2h.js} +3 -3
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-93b7eds9.js → c4Diagram-YGBWAQC7-7y980xpx.js} +2 -2
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-bnf85z0f.js → classDiagram-v2-NBCMYWYE-29ag4js1.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-e290161f.js → cose-bilkent-JH36ORCC-e5dvgehd.js} +1 -1
  22. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-s13ra9ag.js → cynefinDiagram-VND7K2PF-eq6fmx0b.js} +1 -1
  23. package/dist/client/static/js/{dagre-6A5THRUB-83wshh5e.js → dagre-6A5THRUB-xfhwp8ha.js} +1 -1
  24. package/dist/client/static/js/{diagram-22UHCM2B-ywh4wqna.js → diagram-22UHCM2B-1bw6x6zt.js} +1 -1
  25. package/dist/client/static/js/{diagram-3UASUU5V-cb53z698.js → diagram-3UASUU5V-076ej5n5.js} +1 -1
  26. package/dist/client/static/js/{diagram-ATOU4E4O-btf55c44.js → diagram-ATOU4E4O-cvf9fhdq.js} +1 -1
  27. package/dist/client/static/js/{diagram-CDSNMT55-p6tbbm1n.js → diagram-CDSNMT55-hn1wdx54.js} +3 -3
  28. package/dist/client/static/js/{diagram-MLGK6HIB-6kzssf4y.js → diagram-MLGK6HIB-76gk27b5.js} +1 -1
  29. package/dist/client/static/js/{diagram-MPIPVDR6-4v0yncvv.js → diagram-MPIPVDR6-0cbajhpx.js} +1 -1
  30. package/dist/client/static/js/{dockerfile-r422htmd.js → dockerfile-7atfjhnf.js} +1 -1
  31. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-mw1gh30z.js → ebnfDiagram-ZINNZB2B-n0g3b9m2.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-1pe786ap.js → elk-276RUBZZ-f6wrjcv9.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-x7rk70q6.js → erDiagram-OPXOYQCR-jz622yrg.js} +1 -1
  34. package/dist/client/static/js/flowDiagram-KWPJA3E3-5bvd5k2t.js +1 -0
  35. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-j3m5km4p.js → ganttDiagram-FUAMR5RP-2ex4nxyg.js} +2 -2
  36. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fd1kebdy.js → gitGraphDiagram-X574FWY7-38eyay6g.js} +1 -1
  37. package/dist/client/static/js/{index-zkef5q39.js → index-1q934wfk.js} +1 -1
  38. package/dist/client/static/js/{index-5fxm2tpg.js → index-28wv94gz.js} +1 -1
  39. package/dist/client/static/js/{index-4jg10xtp.js → index-3wgjtp2k.js} +1 -1
  40. package/dist/client/static/js/{index-29b1ysz6.js → index-4cff0zg2.js} +1 -1
  41. package/dist/client/static/js/{index-8e66p2a7.js → index-55v3qv04.js} +1 -1
  42. package/dist/client/static/js/{index-s4v3vcsn.js → index-63mk2qk6.js} +1 -1
  43. package/dist/client/static/js/{index-4dzvjfkd.js → index-6z30g3ha.js} +1 -1
  44. package/dist/client/static/js/{index-473wm10a.js → index-7trfm17d.js} +1 -1
  45. package/dist/client/static/js/{index-drsy400d.js → index-8444mec5.js} +1 -1
  46. package/dist/client/static/js/{index-j1prebvy.js → index-9gfn1a3h.js} +1 -1
  47. package/dist/client/static/js/{index-qdabc51h.js → index-ays8t3t3.js} +2 -2
  48. package/dist/client/static/js/{index-q4t5j3x7.js → index-cxe75e06.js} +1 -1
  49. package/dist/client/static/js/{index-22frp78d.js → index-db7vsjkd.js} +1 -1
  50. package/dist/client/static/js/{index-7tsdw8wt.js → index-dmb1pykr.js} +1 -1
  51. package/dist/client/static/js/{index-tcp5cp53.js → index-ep99arz1.js} +1 -1
  52. package/dist/client/static/js/{index-0mhxw0a1.js → index-ewst55j2.js} +1 -1
  53. package/dist/client/static/js/{index-hgsjynb0.js → index-fqc1snjw.js} +1 -1
  54. package/dist/client/static/js/{index-rm5b3kn8.js → index-g2e0m757.js} +3 -3
  55. package/dist/client/static/js/{index-3k45gspr.js → index-jaxhfk9x.js} +1 -1
  56. package/dist/client/static/js/{index-satnfvaz.js → index-jsn2kedv.js} +1 -1
  57. package/dist/client/static/js/{index-bxhszdcz.js → index-n1xmkf2g.js} +1 -1
  58. package/dist/client/static/js/{index-004x0a3p.js → index-pe4d9wht.js} +1 -1
  59. package/dist/client/static/js/{index-cbbwq25c.js → index-pjf5wak8.js} +1 -1
  60. package/dist/client/static/js/{index-8n4qwd64.js → index-sm8gpk3g.js} +2 -2
  61. package/dist/client/static/js/{index-qrwjxqdh.js → index-st6a8q5z.js} +176 -176
  62. package/dist/client/static/js/{index-dfha2z56.js → index-stmwbavz.js} +1 -1
  63. package/dist/client/static/js/index-swaveqxg.css +1 -0
  64. package/dist/client/static/js/{index-3hrvhyym.js → index-t82q5t6m.js} +1 -1
  65. package/dist/client/static/js/{index-s6nv35dv.js → index-t9zjfxvc.js} +1 -1
  66. package/dist/client/static/js/{index-jbaceghb.js → index-tdbcp70z.js} +1 -1
  67. package/dist/client/static/js/{index-kbk0vmex.js → index-tdryzzy9.js} +1 -1
  68. package/dist/client/static/js/{index-jtyzeynv.js → index-tksrpqkh.js} +1 -1
  69. package/dist/client/static/js/{index-g84dwmvr.js → index-v38j2zxn.js} +1 -1
  70. package/dist/client/static/js/{index-4nyajpeg.js → index-x17y7xdr.js} +1 -1
  71. package/dist/client/static/js/{index-4fpyzg5e.js → index-xfnjwhan.js} +20 -20
  72. package/dist/client/static/js/{index-72v57e07.js → index-xrb4kjr3.js} +1 -1
  73. package/dist/client/static/js/{index-4acka5fn.js → index-zv8wrvha.js} +1 -1
  74. package/dist/client/static/js/{index-q178zgxp.js → index-zynbvm7x.js} +1 -1
  75. package/dist/client/static/js/{index-bnamrpm6.js → index-zzggk17b.js} +1 -1
  76. package/dist/client/static/js/{infoDiagram-VRGFBTTK-1m0br602.js → infoDiagram-VRGFBTTK-c55t0tvd.js} +2 -2
  77. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-zryzhpq6.js → ishikawaDiagram-OU5B5YK6-r9kg5kg5.js} +2 -2
  78. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-6apqr7h4.js → journeyDiagram-ZHPQQLJL-zmmst4v8.js} +2 -2
  79. package/dist/client/static/js/{kanban-definition-PNTS6WVX-am385c1e.js → kanban-definition-PNTS6WVX-3tt6sc9a.js} +1 -1
  80. package/dist/client/static/js/{mermaid.core-k937exrm.js → mermaid.core-pkrs8zp5.js} +2 -2
  81. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-hx8qq866.js → mindmap-definition-NLK3R4M7-b4c6gxg4.js} +1 -1
  82. package/dist/client/static/js/one-dark-pro-sstqnzcf.js +1 -0
  83. package/dist/client/static/js/one-light-6fpxxq2j.js +1 -0
  84. package/dist/client/static/js/{pegDiagram-GJSIUBJH-1hasj2h7.js → pegDiagram-GJSIUBJH-9jkat1mz.js} +1 -1
  85. package/dist/client/static/js/{pieDiagram-5QR66LMP-x5nwff8r.js → pieDiagram-5QR66LMP-6pbchjh7.js} +2 -2
  86. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-gmrcr5jb.js → quadrantDiagram-O4NWA36T-p9brea19.js} +2 -2
  87. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-rdznfhfb.js → railroadDiagram-XR7U4H2S-3cep8css.js} +1 -1
  88. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-v9wb3ppf.js → requirementDiagram-PLB6GJNP-x1yjgsrr.js} +1 -1
  89. package/dist/client/static/js/{rust-9cgnbbcs.js → rust-yy8gekx8.js} +1 -1
  90. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-3p4ddd2h.js → sankeyDiagram-IPEJSGJF-23wzf4aj.js} +1 -1
  91. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-wfcqxjfq.js → sequenceDiagram-PO4LG4MO-w4wr3zzr.js} +4 -4
  92. package/dist/client/static/js/{sizeCapture-INFHLROL-g02k0k8x.js → sizeCapture-INFHLROL-aabfesnr.js} +1 -1
  93. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-7k449yvg.js → stateDiagram-v2-GCMORJYK-t0n288xw.js} +1 -1
  94. package/dist/client/static/js/{swimlanes-2SLR337P-zkf2bgm8.js → swimlanes-2SLR337P-1nnm0p7h.js} +1 -1
  95. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-yex8g4fx.js → swimlanesDiagram-TC7HE7FX-cx3f29mq.js} +1 -1
  96. package/dist/client/static/js/{timeline-definition-EJHVYXUP-qsfpjr1c.js → timeline-definition-EJHVYXUP-8pyssn0q.js} +1 -1
  97. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-b2vprhsr.js → usecaseDiagram-POWQR4AR-vveepvt6.js} +1 -1
  98. package/dist/client/static/js/{vennDiagram-UO4OBE2U-x0ffeg2t.js → vennDiagram-UO4OBE2U-tqyvmqxc.js} +4 -4
  99. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-hsnhaf4f.js → wardleyDiagram-VNRHLVJA-p8rs34em.js} +2 -2
  100. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-90f9aadp.js → xychartDiagram-PMCCYNJV-pgnvxtps.js} +3 -3
  101. package/package.json +3 -3
  102. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.tsx +25 -62
  103. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormDialog.test.tsx +40 -0
  104. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormDialog.tsx +41 -2
  105. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionList.tsx +117 -0
  106. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/SwipeDeck.tsx +220 -0
  107. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +10 -8
  108. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.test.ts +37 -0
  109. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +17 -1
  110. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +18 -15
  111. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +7 -8
  112. package/src/client/data/settings/omp-schema.json +59 -7
  113. package/src/client/hooks/chat/timeline/ask-frames-form.test.ts +29 -0
  114. package/src/server/lib/dictation/capability.server.test.ts +9 -6
  115. package/src/server/lib/dictation/worker-process.ts +9 -2
  116. package/src/shared/lib/chat/ask-form/data.ts +25 -6
  117. package/src/shared/lib/chat/ask-form/deck.ts +80 -0
  118. package/src/shared/lib/chat/ask-form/fields.ts +26 -1
  119. package/src/shared/lib/chat/ask-form/index.ts +18 -310
  120. package/src/shared/lib/chat/ask-form/types.ts +14 -2
  121. package/src/shared/lib/chat/ask-form/walker.ts +350 -0
  122. package/src/shared/lib/chat/ask-form.test.ts +41 -0
  123. package/src/shared/lib/omp/config/schema-releases-19-4.test.ts +47 -0
  124. package/src/shared/lib/omp/config/schema-releases.test.ts +4 -2
  125. package/dist/client/static/js/MergeDiffView-bv00y63x.js +0 -1
  126. package/dist/client/static/js/flowDiagram-KWPJA3E3-kfwaac44.js +0 -1
  127. package/dist/client/static/js/index-gedsa0z7.css +0 -1
  128. package/dist/client/static/js/one-dark-pro-phxqe9mx.js +0 -1
  129. package/dist/client/static/js/one-light-vhwh499y.js +0 -1
@@ -1,2 +1,2 @@
1
- import{d,n,o,i,u,a,e,s,p,I,ra,rs,f,ae,en,de,S,U,Lo,Nm,X,Bt,eA,Mm,Sd}from"./index-qrwjxqdh.js";var q={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},wm=s(q);function O({row:t,active:r,name:l,loading:h,onSelect:c,onCopyPath:g,onReveal:N}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:c,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(de,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:l})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:g,disabled:h,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-default",children:e(ae,{size:11})}),e("button",{type:"button",onClick:N,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(en,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(Q,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function Q({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${Lo[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(I,{size:9}),Lo[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.conflicts} conflicted path(s)`,children:[e(I,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(rs,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(ra,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function H(t){let{open:r,rootPath:l,scanning:h}=t,[c,g]=n([]),[N,k]=n(!1),[C,A]=n(!1),[z,y]=n(null),[D,E]=n(0),j=t.repos.join("\x00"),G=i(!0),b=i(null);o(()=>(G.current=!0,()=>{G.current=!1,b.current?.abort(),b.current=null}),[]);let M=a(async()=>{b.current?.abort();let v=new AbortController;b.current=v,A(!0),k(!0);try{let R=new URLSearchParams({repoDetails:"1"});if(l)R.set("root",l);let w=await fetch(`/api/fs/git?${R.toString()}`,{signal:v.signal}),F=await w.json();if(!G.current||b.current!==v)return;if(!w.ok||!Array.isArray(F.details)){y(F.error||`Failed to read repositories (HTTP ${w.status})`);return}g(F.details),y(null)}catch(R){if(!G.current||b.current!==v)return;if(R instanceof Error&&R.name==="AbortError")return;y(R instanceof Error?R.message:"Failed to read repositories")}finally{if(G.current&&b.current===v)b.current=null,A(!1),k(!1)}},[l]);o(()=>{if(!r){g([]),y(null),k(!1);return}M()},[r,M,j,h,D]);let L=a(()=>E((v)=>v+1),[]);return{details:c,loading:N,reading:C,error:z,refresh:L}}function B(t){let r=new Map;for(let l of t){if(!l||l==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let h=l.indexOf("/"),c=h===-1?"":l.slice(0,h),g=r.get(c);if(!g)g={key:c,label:c===""?null:c,paths:[]},r.set(c,g);g.paths.push(l)}for(let l of r.values())l.paths.sort((h,c)=>h==="."?-1:c==="."?1:h.localeCompare(c));return[...r.values()].sort((l,h)=>{if(l.key==="")return-1;if(h.key==="")return 1;return l.key.localeCompare(h.key)})}function _(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function W({isOpen:t,rootPath:r,activeRepo:l,repos:h,scanning:c,onSelectRepo:g,onRefreshRepos:N,onClose:k}){let[C,A]=n(""),[z,y]=n(null),{details:D,loading:E,reading:j,error:G,refresh:b}=H({open:t,rootPath:r,repos:h,scanning:c});o(()=>{if(!t)A(""),y(null)},[t]);let M=u(()=>{let x=C.trim().toLowerCase();if(!x)return D;return D.filter((m)=>m.path.toLowerCase().includes(x))},[D,C]),L=u(()=>B(M.map((x)=>x.path)),[M]),v=u(()=>{let x=new Map;for(let m of D)x.set(m.path,m);return x},[D]),R=a(()=>{N(),b()},[N,b]),w=a(async(x)=>{let m=r?Sd(r,x==="."?"":x):x,P=await Bt(m);y(P?{text:`Copied ${m}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),F=a(async(x)=>{let m=new FormData;if(m.append("actionType","open_explorer"),m.append("path","."),m.append("repo",x),r)m.append("root",r);try{let P=await fetch("/api/fs/action",{method:"POST",body:m}),T=await P.json();if(!P.ok||T.error)y({text:T.error||"Could not open the file manager",kind:"error"})}catch{y({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(X,{onClose:k,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(wm,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[h.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(U,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:C,onChange:(x)=>A(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:R,disabled:j||c,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(S,{size:12,className:j||c?"animate-spin":""})})]}),c&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(p,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),z&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${z.kind==="error"?"text-error":"text-ink/60"}`,title:z.text,role:"status",children:z.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:E&&D.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(p,{size:14,className:"animate-spin text-info"}),"Reading repositories…"]}):G?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:G}):M.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:C.trim()?"No matching repositories.":"No repositories in this workspace."}):L.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??eA(".",r)}),x.paths.map((m)=>{let P=v.get(m);if(!P)return null;return e(O,{row:P,active:m===l,name:_(m,x.key),loading:j,onSelect:()=>{g(m),k()},onCopyPath:()=>void w(m),onReveal:()=>void F(m)},m)})]},x.key))})]})}function Tr({rootPath:t,activeRepo:r,onSelectRepo:l,repos:h,scanning:c,onRefreshRepos:g}){let[N,k]=n(!1),C=u(()=>({root:t??null,repo:r,rows:Mm(t,h),scanning:c,ready:!0,setRepo:l,refresh:g}),[t,r,h,c,l,g]),A=a(()=>k(!0),[]);return e("div",{className:"relative min-w-0",children:[e(Nm,{scope:C,onManage:A}),e(W,{isOpen:N,rootPath:t,activeRepo:r,repos:h,scanning:c,onSelectRepo:l,onRefreshRepos:g,onClose:()=>k(!1)})]})}
1
+ import{d,n,o,i,u,a,e,s,p,I,ra,rs,f,ae,en,de,S,U,Lo,Nm,X,Bt,eA,Mm,Sd}from"./index-st6a8q5z.js";var q={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},wm=s(q);function O({row:t,active:r,name:l,loading:h,onSelect:c,onCopyPath:g,onReveal:N}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:c,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(de,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:l})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:g,disabled:h,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-default",children:e(ae,{size:11})}),e("button",{type:"button",onClick:N,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(en,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(Q,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function Q({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${Lo[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(I,{size:9}),Lo[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.conflicts} conflicted path(s)`,children:[e(I,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(rs,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(ra,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function H(t){let{open:r,rootPath:l,scanning:h}=t,[c,g]=n([]),[N,k]=n(!1),[C,A]=n(!1),[z,y]=n(null),[D,E]=n(0),j=t.repos.join("\x00"),G=i(!0),b=i(null);o(()=>(G.current=!0,()=>{G.current=!1,b.current?.abort(),b.current=null}),[]);let M=a(async()=>{b.current?.abort();let v=new AbortController;b.current=v,A(!0),k(!0);try{let R=new URLSearchParams({repoDetails:"1"});if(l)R.set("root",l);let w=await fetch(`/api/fs/git?${R.toString()}`,{signal:v.signal}),F=await w.json();if(!G.current||b.current!==v)return;if(!w.ok||!Array.isArray(F.details)){y(F.error||`Failed to read repositories (HTTP ${w.status})`);return}g(F.details),y(null)}catch(R){if(!G.current||b.current!==v)return;if(R instanceof Error&&R.name==="AbortError")return;y(R instanceof Error?R.message:"Failed to read repositories")}finally{if(G.current&&b.current===v)b.current=null,A(!1),k(!1)}},[l]);o(()=>{if(!r){g([]),y(null),k(!1);return}M()},[r,M,j,h,D]);let L=a(()=>E((v)=>v+1),[]);return{details:c,loading:N,reading:C,error:z,refresh:L}}function B(t){let r=new Map;for(let l of t){if(!l||l==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let h=l.indexOf("/"),c=h===-1?"":l.slice(0,h),g=r.get(c);if(!g)g={key:c,label:c===""?null:c,paths:[]},r.set(c,g);g.paths.push(l)}for(let l of r.values())l.paths.sort((h,c)=>h==="."?-1:c==="."?1:h.localeCompare(c));return[...r.values()].sort((l,h)=>{if(l.key==="")return-1;if(h.key==="")return 1;return l.key.localeCompare(h.key)})}function _(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function W({isOpen:t,rootPath:r,activeRepo:l,repos:h,scanning:c,onSelectRepo:g,onRefreshRepos:N,onClose:k}){let[C,A]=n(""),[z,y]=n(null),{details:D,loading:E,reading:j,error:G,refresh:b}=H({open:t,rootPath:r,repos:h,scanning:c});o(()=>{if(!t)A(""),y(null)},[t]);let M=u(()=>{let x=C.trim().toLowerCase();if(!x)return D;return D.filter((m)=>m.path.toLowerCase().includes(x))},[D,C]),L=u(()=>B(M.map((x)=>x.path)),[M]),v=u(()=>{let x=new Map;for(let m of D)x.set(m.path,m);return x},[D]),R=a(()=>{N(),b()},[N,b]),w=a(async(x)=>{let m=r?Sd(r,x==="."?"":x):x,P=await Bt(m);y(P?{text:`Copied ${m}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),F=a(async(x)=>{let m=new FormData;if(m.append("actionType","open_explorer"),m.append("path","."),m.append("repo",x),r)m.append("root",r);try{let P=await fetch("/api/fs/action",{method:"POST",body:m}),T=await P.json();if(!P.ok||T.error)y({text:T.error||"Could not open the file manager",kind:"error"})}catch{y({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(X,{onClose:k,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(wm,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[h.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(U,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:C,onChange:(x)=>A(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:R,disabled:j||c,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(S,{size:12,className:j||c?"animate-spin":""})})]}),c&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(p,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),z&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${z.kind==="error"?"text-error":"text-ink/60"}`,title:z.text,role:"status",children:z.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:E&&D.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(p,{size:14,className:"animate-spin text-info"}),"Reading repositories…"]}):G?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:G}):M.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:C.trim()?"No matching repositories.":"No repositories in this workspace."}):L.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??eA(".",r)}),x.paths.map((m)=>{let P=v.get(m);if(!P)return null;return e(O,{row:P,active:m===l,name:_(m,x.key),loading:j,onSelect:()=>{g(m),k()},onCopyPath:()=>void w(m),onReveal:()=>void F(m)},m)})]},x.key))})]})}function Tr({rootPath:t,activeRepo:r,onSelectRepo:l,repos:h,scanning:c,onRefreshRepos:g}){let[N,k]=n(!1),C=u(()=>({root:t??null,repo:r,rows:Mm(t,h),scanning:c,ready:!0,setRepo:l,refresh:g}),[t,r,h,c,l,g]),A=a(()=>k(!0),[]);return e("div",{className:"relative min-w-0",children:[e(Nm,{scope:C,onManage:A}),e(W,{isOpen:N,rootPath:t,activeRepo:r,repos:h,scanning:c,onSelectRepo:l,onRefreshRepos:g,onClose:()=>k(!1)})]})}
2
2
  export{wm,Tr};
@@ -1 +1 @@
1
- import{d,u,le,e,B,E,ue,Lr,hh,Te,yl,xt,Xg,nt,Qd,Vm,Xh,Ym,Jm}from"./index-qrwjxqdh.js";function k({phase:o,index:s,collapsed:r,currentKey:f,onToggle:i}){let m=Ym(o),x=o.tasks.length>0&&m===o.tasks.length;return e("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[e("button",{type:"button",onClick:i,"aria-expanded":!r,className:"flex w-full items-center gap-1.5 border-b border-ink/8 bg-canvas/40 px-2.5 py-1.5 text-left hover:bg-ink/5",children:[r?e(ue,{size:12,className:"shrink-0 text-ink/40"}):e(E,{size:12,className:"shrink-0 text-ink/40"}),e("span",{className:`min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wider ${x?"text-ink/35":"text-ink/60"}`,title:o.name,children:[s+1,". ",o.name]}),e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:[m,"/",o.tasks.length]})]}),!r&&e("div",{className:"divide-y divide-ink/[0.05] p-0.5",children:o.tasks.length===0?e("div",{className:"px-2.5 py-1.5 text-[11px] text-ink/40",children:"No tasks in this phase"}):o.tasks.map((n,l)=>e(Jm,{task:n,current:f===`${s}:${l}`},`${l}-${n.content}`))})]})}function q({className:o="",active:s=!0,tabsMode:r=!1}){let[f]=le(),i=f.get("sessionId"),[m,x]=yl("todo.collapsedPhases",{}),{data:n,isLoading:l,refreshing:g,stale:b,refresh:v}=Te(i?hh(i):null,{enabled:s}),t=n?.snapshot??null,p=n?.progress??null,N=u(()=>{let a=Xh(t?.phases??[]);return a?`${a.phase}:${a.task}`:null},[t]);if(!i)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${o}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`flex h-full w-full min-w-0 flex-col overflow-hidden bg-paper text-ink ${o}`,children:[Xg("todo",r)?e(xt,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold uppercase tracking-wider text-ink",children:"Todos"}),t&&e("span",{className:"truncate font-mono text-[10.5px] text-ink/50",title:Qd(p),children:Qd(p)}),n?.isMock&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",children:"Mock"})]}),right:e(nt,{label:"Refresh todos",onClick:v,busy:l||g,disabled:l})}):null,p&&p.total>0&&e("div",{className:"flex-shrink-0 border-b border-ink/10 px-3.5 py-2.5",children:e("div",{className:"h-1.5 overflow-hidden rounded-full bg-ink/8",children:e("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${Vm(p)}%`}})})}),e("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto scrollbar-overlay-container p-3.5",children:[b&&e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/60",children:[e(B,{size:13,className:"mt-[1px] shrink-0"}),e("span",{className:"min-w-0 break-words",children:"Reconnecting: this list may be out of date."})]}),!t?e("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-ink/40",children:[e(Lr,{size:20}),e("p",{className:"max-w-[240px] text-[11.5px] leading-relaxed",children:["No todo list in this session. The agent writes one with the ",e("span",{className:"font-mono",children:"todo"})," tool when a task is worth planning."]})]}):e(d,{children:[t.phases.map((a,c)=>e(k,{phase:a,index:c,collapsed:Boolean(m[String(c)]),currentKey:N,onToggle:()=>x((h)=>({...h,[String(c)]:!h[String(c)]}))},`${c}-${a.name}`)),e("p",{className:"pt-1 text-[10.5px] leading-relaxed text-ink/35",children:["Read from this session's transcript",t.updatedAt?` · updated ${y(t.updatedAt)}`:"",t.source==="custom"?" · edited by hand":"","."]})]})]})]})}function y(o){let s=new Date(o);if(Number.isNaN(s.getTime()))return o;return s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}export{q as TodoPanel};
1
+ import{d,u,le,e,B,E,ue,Lr,hh,Te,yl,xt,Xg,nt,Qd,Vm,Xh,Ym,Jm}from"./index-st6a8q5z.js";function k({phase:o,index:s,collapsed:r,currentKey:f,onToggle:i}){let m=Ym(o),x=o.tasks.length>0&&m===o.tasks.length;return e("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[e("button",{type:"button",onClick:i,"aria-expanded":!r,className:"flex w-full items-center gap-1.5 border-b border-ink/8 bg-canvas/40 px-2.5 py-1.5 text-left hover:bg-ink/5",children:[r?e(ue,{size:12,className:"shrink-0 text-ink/40"}):e(E,{size:12,className:"shrink-0 text-ink/40"}),e("span",{className:`min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wider ${x?"text-ink/35":"text-ink/60"}`,title:o.name,children:[s+1,". ",o.name]}),e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:[m,"/",o.tasks.length]})]}),!r&&e("div",{className:"divide-y divide-ink/[0.05] p-0.5",children:o.tasks.length===0?e("div",{className:"px-2.5 py-1.5 text-[11px] text-ink/40",children:"No tasks in this phase"}):o.tasks.map((n,l)=>e(Jm,{task:n,current:f===`${s}:${l}`},`${l}-${n.content}`))})]})}function q({className:o="",active:s=!0,tabsMode:r=!1}){let[f]=le(),i=f.get("sessionId"),[m,x]=yl("todo.collapsedPhases",{}),{data:n,isLoading:l,refreshing:g,stale:b,refresh:v}=Te(i?hh(i):null,{enabled:s}),t=n?.snapshot??null,p=n?.progress??null,N=u(()=>{let a=Xh(t?.phases??[]);return a?`${a.phase}:${a.task}`:null},[t]);if(!i)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${o}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`flex h-full w-full min-w-0 flex-col overflow-hidden bg-paper text-ink ${o}`,children:[Xg("todo",r)?e(xt,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold uppercase tracking-wider text-ink",children:"Todos"}),t&&e("span",{className:"truncate font-mono text-[10.5px] text-ink/50",title:Qd(p),children:Qd(p)}),n?.isMock&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",children:"Mock"})]}),right:e(nt,{label:"Refresh todos",onClick:v,busy:l||g,disabled:l})}):null,p&&p.total>0&&e("div",{className:"flex-shrink-0 border-b border-ink/10 px-3.5 py-2.5",children:e("div",{className:"h-1.5 overflow-hidden rounded-full bg-ink/8",children:e("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${Vm(p)}%`}})})}),e("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto scrollbar-overlay-container p-3.5",children:[b&&e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/60",children:[e(B,{size:13,className:"mt-[1px] shrink-0"}),e("span",{className:"min-w-0 break-words",children:"Reconnecting: this list may be out of date."})]}),!t?e("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-ink/40",children:[e(Lr,{size:20}),e("p",{className:"max-w-[240px] text-[11.5px] leading-relaxed",children:["No todo list in this session. The agent writes one with the ",e("span",{className:"font-mono",children:"todo"})," tool when a task is worth planning."]})]}):e(d,{children:[t.phases.map((a,c)=>e(k,{phase:a,index:c,collapsed:Boolean(m[String(c)]),currentKey:N,onToggle:()=>x((h)=>({...h,[String(c)]:!h[String(c)]}))},`${c}-${a.name}`)),e("p",{className:"pt-1 text-[10.5px] leading-relaxed text-ink/35",children:["Read from this session's transcript",t.updatedAt?` · updated ${y(t.updatedAt)}`:"",t.source==="custom"?" · edited by hand":"","."]})]})]})]})}function y(o){let s=new Date(o);if(Number.isNaN(s.getTime()))return o;return s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}export{q as TodoPanel};
@@ -1 +1 @@
1
- import{d,n,o,i,u,a,Dr,ze,ie,e,s,Kn,Q,dt,E,ue,Ro,ae,Ie,et,hi,yn,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-qrwjxqdh.js";import{yd,vd,di,kd,xd}from"./index-4acka5fn.js";import{Z}from"./index-4dzvjfkd.js";import{Tr}from"./index-q4t5j3x7.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(yn,{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(yn,{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 bn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=ft(),[p,f]=n(bn),[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 xn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function vn(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(vn(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(xn,[]);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
+ import{d,n,o,i,u,a,Dr,ze,ie,e,s,Kn,Q,dt,E,ue,Ro,ae,Ie,et,hi,yn,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-st6a8q5z.js";import{yd,vd,di,kd,xd}from"./index-zv8wrvha.js";import{Z}from"./index-6z30g3ha.js";import{Tr}from"./index-cxe75e06.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(yn,{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(yn,{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 bn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=ft(),[p,f]=n(bn),[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 xn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function vn(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(vn(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(xn,[]);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,2 +1,2 @@
1
- import{t,l,C,m,V,ee,xa,wa,lh,na,So,ch,cl,Xt,uh,Ug,Ca,To,dl}from"./index-4fpyzg5e.js";import{Je}from"./index-hge0y4vn.js";function Bp(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),c=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:c,rootGroups:n}}t(Bp,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await ee(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function Ip(e,r,n){let i=await wa(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(Ip,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new Je({multigraph:!0,compound:!0}),s=[...r.edges],o=m(),c=Bp(e),{edgeLabels:f,nodes:a}=c,d=new Map,b=new Map(r.nodes.map((u)=>[u.id,u])),y=r.direction,h=e.node()!=null;await Promise.all(r.nodes.map(async(u)=>{if(u.isGroup){if(h){let p=n.unwrapGroupLabels&&u.labelType!=="markdown";await L(a,u,p?Number.POSITIVE_INFINITY:void 0)}i.setNode(u.id,{...u})}else{if(h){let p=await Ip(a,u,{config:o,dir:D(u,b,y)});d.set(u.id,p)}i.setNode(u.id,{...u})}}));for(let u of s){if(h&&Ug(u))await Ca(f,u);if(i.setEdge(u.start,u.end,{...u},u.id),!r.edges.some((v)=>v.id===u.id))r.edges.push(u)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:u}=await import("./sizeCapture-INFHLROL-g02k0k8x.js");u(e,r)}return{graph:i,groups:c,nodeElements:d}}t(S,"createGraphWithElements");var ve=new Map,g=new Map,P=new Map,W=t(()=>{g.clear(),P.clear(),ve.clear()},"clear"),w=t((e,r)=>{let n=g.get(r)||[];return l.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),Y=t((e,r)=>{let n=g.get(r)||[];if(l.info("Descendants of ",r," is ",n),l.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return l.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||w(e.v,r)||w(e.w,r)||n.includes(e.w)},"edgeInCluster"),k=t((e,r,n,i)=>{l.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);l.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)k(o,r,n,i);else{let c=r.node(o);if(l.info("cp ",o," to ",i," with parent ",e),n.setNode(o,c),i!==r.parent(o))l.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)l.debug("Setting parent",o,e),n.setParent(o,e);else l.info("In copy ",e,"root",i,"data",r.node(e),i),l.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let f=r.edges(o);l.debug("Copying Edges",f),f.forEach((a)=>{l.info("Edge",a);let d=r.edge(a.v,a.w,a.name);l.info("Edge data",d,i);try{if(Y(a,i))l.info("Copying as ",a.v,a.w,d,a.name),n.setEdge(a.v,a.w,d,a.name),l.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else l.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",i," clusterId:",e)}catch(b){l.error(b)}})}l.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)P.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),q=t((e,r,n)=>{let i=e.edges().filter((a)=>a.v===r||a.w===r),s=e.edges().filter((a)=>a.v===n||a.w===n),o=i.map((a)=>({v:a.v===r?n:a.v,w:a.w===r?r:a.w})),c=s.map((a)=>({v:a.v,w:a.w}));return o.filter((a)=>c.some((d)=>a.v===d.v&&a.w===d.w))},"findCommonEdges"),al=t((e,r,n)=>{let i=r.children(e);if(l.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let c=al(o,r,n),f=q(r,n,c);if(c)if(f.length>0)s=c;else return c}return s},"findNonClusterChild"),N=t((e)=>{if(!ve.has(e))return e;if(!ve.get(e).externalConnections)return e;if(ve.has(e))return ve.get(e).id;return e},"getAnchorId"),VA=t((e,r)=>{if(!e||r>10){l.debug("Opting out, no graph ");return}else l.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)l.debug("Cluster identified",n," Replacement id in edges: ",al(n,e,n)),g.set(n,T(n,e)),ve.set(n,{id:al(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)l.debug("Cluster identified",n,g),s.forEach((o)=>{let c=w(o.v,n),f=w(o.w,n);if(c^f)l.debug("Edge: ",o," leaves cluster ",n),l.debug("Descendants of XXX ",n,": ",g.get(n)),ve.get(n).externalConnections=!0});else l.debug("Not a cluster ",n,g)});for(let n of ve.keys()){let i=ve.get(n).id,s=e.parent(i);if(s!==n&&ve.has(s)&&!ve.get(s).externalConnections)ve.get(n).id=s;let o=e.edges().some((c)=>c.v===n);if(i&&ve.get(n)?.externalConnections&&o&&M(e,i,n)){let c=K(e,n,e.parent(i));if(c)ve.get(n).id=c}}e.edges().forEach(function(n){let i=e.edge(n);l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(l.debug("Fix XXX",ve,"ids:",n.v,n.w,"Translating: ",ve.get(n.v)," --- ",ve.get(n.w)),ve.get(n.v)||ve.get(n.w)){if(l.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=N(n.v),o=N(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let c=e.parent(s);ve.get(c).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let c=e.parent(o);ve.get(c).externalConnections=!0,i.toCluster=n.w}l.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),R(e,0),l.trace(ve)},"adjustClustersAndEdges"),R=t((e,r)=>{if(r>10){l.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){l.debug("Done, no node has children",e.nodes());return}l.debug("Nodes = ",n,r);for(let s of n)if(l.debug("Extracting node",s,ve,ve.has(s)&&!ve.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!ve.has(s))l.debug("Not a cluster",s,r);else if(!ve.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){l.debug("Cluster without external connections, without a parent and with children",s,r);let c=e.graph().rankdir==="TB"?"LR":"TB";if(ve.get(s)?.clusterData?.dir)c=ve.get(s).clusterData.dir,l.debug("Fixing dir",ve.get(s).clusterData.dir,c);let f=new Je({multigraph:!0,compound:!0}).setGraph({rankdir:c,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});k(s,e,f,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:ve.get(s).clusterData,label:ve.get(s).label,graph:f})}else l.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!ve.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),l.debug(ve);n=e.nodes(),l.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(l.debug(" Now next level",s,o),o?.clusterNode)R(o.graph,r+1)}},"extractor"),B=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=B(e,s);n=[...n,...o]}),n},"sorter"),_p=t((e)=>B(e,e.children()),"sortNodesByHierarchy"),M=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=ve.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),K=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||w(s,n))continue;let o=al(s,e,r);if(!o)continue;if(!M(e,o,r))return o}return null},"findSafeAnchorNode");function oi({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let c=r??Sp;return t(async function(a,d,b,y){let h=d.select("g");(b?.insertMarkers??dl)(h,a.markers,a.type,a.diagramId),X();let u={element:h,helpers:b,options:y};u.preparedLayout=await e?.(a,u);let p=await c(a,u),v=await n(a,u),E={...u,measure:p};if(i)await i(a,E,v);else await G(a,E,o);await s?.(a,E,v)},"render")}t(oi,"createCommonLayoutRenderer");function X(){lh(),uh(),ch(),W()}t(X,"clearLayoutRenderState");async function Sp(e,{element:r},n){return await S(r,e,n)}t(Sp,"defaultMeasureLayout");async function G(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let c of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(c,r))continue;await _(s,c,r,n)}let o=O(e.nodes);for(let c of e.edges){if(F(c,n))continue;await j(s,c,o,e,n,r)}}t(G,"paintLayoutData");async function _(e,r,n,i){if(r.clusterNode)na(r);else if(A(r,n,i))await So(e.clusters,r);else na(r)}t(_,"paintLayoutNode");function A(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(A,"shouldPaintAsCluster");function O(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(O,"buildNodeLookup");function F(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(F,"shouldSkipPaintEdge");async function j(e,r,n,i,s,o){let c=To(e.edgePaths,{...r},s.clusterDb??new Map,i.type,x(r.start,r,n,o,s),x(r.end,r,n,o,s),i.diagramId,H(r,s));if(Ug(r)){if(!cl.has(r.id))await Ca(e.edgeLabels,r);z(r,c)}}t(j,"paintLayoutEdge");function x(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(x,"getRenderedNode");function H(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(H,"shouldSkipIntersect");function z(e,r){let n=r?.updatedPath??r?.originalPath,i=C(),{subGraphTitleTotalMargin:s}=xa({flowchart:i.flowchart??{}});if(e.label){let o=cl.get(e.id),{x:c,y:f}=e;if(n){let a=V.calcLabelPosition(n);if(l.debug("Moving label "+e.label+" from (",c,",",f,") to (",a.x,",",a.y,") abc88"),r?.updatedPath)c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f+s/2})`)}if(e?.startLabelLeft){let o=Xt.get(e.id).startLeft,c=e?.x,f=e?.y;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.startLabelRight){let o=Xt.get(e.id).startRight,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelLeft){let o=Xt.get(e.id).endLeft,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelRight){let o=Xt.get(e.id).endRight,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}}t(z,"positionRenderedEdgeLabel");
1
+ import{t,l,C,m,V,ee,xa,wa,lh,na,So,ch,cl,Xt,uh,Ug,Ca,To,dl}from"./index-xfnjwhan.js";import{Je}from"./index-hge0y4vn.js";function Bp(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),c=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:c,rootGroups:n}}t(Bp,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await ee(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function Ip(e,r,n){let i=await wa(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(Ip,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new Je({multigraph:!0,compound:!0}),s=[...r.edges],o=m(),c=Bp(e),{edgeLabels:f,nodes:a}=c,d=new Map,b=new Map(r.nodes.map((u)=>[u.id,u])),y=r.direction,h=e.node()!=null;await Promise.all(r.nodes.map(async(u)=>{if(u.isGroup){if(h){let p=n.unwrapGroupLabels&&u.labelType!=="markdown";await L(a,u,p?Number.POSITIVE_INFINITY:void 0)}i.setNode(u.id,{...u})}else{if(h){let p=await Ip(a,u,{config:o,dir:D(u,b,y)});d.set(u.id,p)}i.setNode(u.id,{...u})}}));for(let u of s){if(h&&Ug(u))await Ca(f,u);if(i.setEdge(u.start,u.end,{...u},u.id),!r.edges.some((v)=>v.id===u.id))r.edges.push(u)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:u}=await import("./sizeCapture-INFHLROL-aabfesnr.js");u(e,r)}return{graph:i,groups:c,nodeElements:d}}t(S,"createGraphWithElements");var ve=new Map,g=new Map,P=new Map,W=t(()=>{g.clear(),P.clear(),ve.clear()},"clear"),w=t((e,r)=>{let n=g.get(r)||[];return l.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),Y=t((e,r)=>{let n=g.get(r)||[];if(l.info("Descendants of ",r," is ",n),l.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return l.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||w(e.v,r)||w(e.w,r)||n.includes(e.w)},"edgeInCluster"),k=t((e,r,n,i)=>{l.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);l.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)k(o,r,n,i);else{let c=r.node(o);if(l.info("cp ",o," to ",i," with parent ",e),n.setNode(o,c),i!==r.parent(o))l.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)l.debug("Setting parent",o,e),n.setParent(o,e);else l.info("In copy ",e,"root",i,"data",r.node(e),i),l.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let f=r.edges(o);l.debug("Copying Edges",f),f.forEach((a)=>{l.info("Edge",a);let d=r.edge(a.v,a.w,a.name);l.info("Edge data",d,i);try{if(Y(a,i))l.info("Copying as ",a.v,a.w,d,a.name),n.setEdge(a.v,a.w,d,a.name),l.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else l.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",i," clusterId:",e)}catch(b){l.error(b)}})}l.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)P.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),q=t((e,r,n)=>{let i=e.edges().filter((a)=>a.v===r||a.w===r),s=e.edges().filter((a)=>a.v===n||a.w===n),o=i.map((a)=>({v:a.v===r?n:a.v,w:a.w===r?r:a.w})),c=s.map((a)=>({v:a.v,w:a.w}));return o.filter((a)=>c.some((d)=>a.v===d.v&&a.w===d.w))},"findCommonEdges"),al=t((e,r,n)=>{let i=r.children(e);if(l.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let c=al(o,r,n),f=q(r,n,c);if(c)if(f.length>0)s=c;else return c}return s},"findNonClusterChild"),N=t((e)=>{if(!ve.has(e))return e;if(!ve.get(e).externalConnections)return e;if(ve.has(e))return ve.get(e).id;return e},"getAnchorId"),VA=t((e,r)=>{if(!e||r>10){l.debug("Opting out, no graph ");return}else l.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)l.debug("Cluster identified",n," Replacement id in edges: ",al(n,e,n)),g.set(n,T(n,e)),ve.set(n,{id:al(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)l.debug("Cluster identified",n,g),s.forEach((o)=>{let c=w(o.v,n),f=w(o.w,n);if(c^f)l.debug("Edge: ",o," leaves cluster ",n),l.debug("Descendants of XXX ",n,": ",g.get(n)),ve.get(n).externalConnections=!0});else l.debug("Not a cluster ",n,g)});for(let n of ve.keys()){let i=ve.get(n).id,s=e.parent(i);if(s!==n&&ve.has(s)&&!ve.get(s).externalConnections)ve.get(n).id=s;let o=e.edges().some((c)=>c.v===n);if(i&&ve.get(n)?.externalConnections&&o&&M(e,i,n)){let c=K(e,n,e.parent(i));if(c)ve.get(n).id=c}}e.edges().forEach(function(n){let i=e.edge(n);l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(l.debug("Fix XXX",ve,"ids:",n.v,n.w,"Translating: ",ve.get(n.v)," --- ",ve.get(n.w)),ve.get(n.v)||ve.get(n.w)){if(l.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=N(n.v),o=N(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let c=e.parent(s);ve.get(c).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let c=e.parent(o);ve.get(c).externalConnections=!0,i.toCluster=n.w}l.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),R(e,0),l.trace(ve)},"adjustClustersAndEdges"),R=t((e,r)=>{if(r>10){l.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){l.debug("Done, no node has children",e.nodes());return}l.debug("Nodes = ",n,r);for(let s of n)if(l.debug("Extracting node",s,ve,ve.has(s)&&!ve.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!ve.has(s))l.debug("Not a cluster",s,r);else if(!ve.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){l.debug("Cluster without external connections, without a parent and with children",s,r);let c=e.graph().rankdir==="TB"?"LR":"TB";if(ve.get(s)?.clusterData?.dir)c=ve.get(s).clusterData.dir,l.debug("Fixing dir",ve.get(s).clusterData.dir,c);let f=new Je({multigraph:!0,compound:!0}).setGraph({rankdir:c,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});k(s,e,f,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:ve.get(s).clusterData,label:ve.get(s).label,graph:f})}else l.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!ve.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),l.debug(ve);n=e.nodes(),l.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(l.debug(" Now next level",s,o),o?.clusterNode)R(o.graph,r+1)}},"extractor"),B=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=B(e,s);n=[...n,...o]}),n},"sorter"),_p=t((e)=>B(e,e.children()),"sortNodesByHierarchy"),M=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=ve.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),K=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||w(s,n))continue;let o=al(s,e,r);if(!o)continue;if(!M(e,o,r))return o}return null},"findSafeAnchorNode");function oi({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let c=r??Sp;return t(async function(a,d,b,y){let h=d.select("g");(b?.insertMarkers??dl)(h,a.markers,a.type,a.diagramId),X();let u={element:h,helpers:b,options:y};u.preparedLayout=await e?.(a,u);let p=await c(a,u),v=await n(a,u),E={...u,measure:p};if(i)await i(a,E,v);else await G(a,E,o);await s?.(a,E,v)},"render")}t(oi,"createCommonLayoutRenderer");function X(){lh(),uh(),ch(),W()}t(X,"clearLayoutRenderState");async function Sp(e,{element:r},n){return await S(r,e,n)}t(Sp,"defaultMeasureLayout");async function G(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let c of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(c,r))continue;await _(s,c,r,n)}let o=O(e.nodes);for(let c of e.edges){if(F(c,n))continue;await j(s,c,o,e,n,r)}}t(G,"paintLayoutData");async function _(e,r,n,i){if(r.clusterNode)na(r);else if(A(r,n,i))await So(e.clusters,r);else na(r)}t(_,"paintLayoutNode");function A(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(A,"shouldPaintAsCluster");function O(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(O,"buildNodeLookup");function F(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(F,"shouldSkipPaintEdge");async function j(e,r,n,i,s,o){let c=To(e.edgePaths,{...r},s.clusterDb??new Map,i.type,x(r.start,r,n,o,s),x(r.end,r,n,o,s),i.diagramId,H(r,s));if(Ug(r)){if(!cl.has(r.id))await Ca(e.edgeLabels,r);z(r,c)}}t(j,"paintLayoutEdge");function x(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(x,"getRenderedNode");function H(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(H,"shouldSkipIntersect");function z(e,r){let n=r?.updatedPath??r?.originalPath,i=C(),{subGraphTitleTotalMargin:s}=xa({flowchart:i.flowchart??{}});if(e.label){let o=cl.get(e.id),{x:c,y:f}=e;if(n){let a=V.calcLabelPosition(n);if(l.debug("Moving label "+e.label+" from (",c,",",f,") to (",a.x,",",a.y,") abc88"),r?.updatedPath)c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f+s/2})`)}if(e?.startLabelLeft){let o=Xt.get(e.id).startLeft,c=e?.x,f=e?.y;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.startLabelRight){let o=Xt.get(e.id).startRight,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelLeft){let o=Xt.get(e.id).endLeft,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelRight){let o=Xt.get(e.id).endRight,{x:c,y:f}=e;if(n){let a=V.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}}t(z,"positionRenderedEdgeLabel");
2
2
  export{Bp,Ip,ve,al,VA,_p,oi,Sp};