@kabmo-labs/kabmo 0.53.0 → 0.53.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 (147) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +183 -183
  3. package/dist/client/static/js/{Body-sdq2yhmp.js → Body-3v975hq3.js} +3 -3
  4. package/dist/client/static/js/{CsvGrid-afz6vr3m.js → CsvGrid-8xcj58sw.js} +1 -1
  5. package/dist/client/static/js/{DocxView-xwjgt7qq.js → DocxView-fwmfpsg7.js} +1 -1
  6. package/dist/client/static/js/{DrawioView-7m4e8zcm.js → DrawioView-gdtqj2vv.js} +1 -1
  7. package/dist/client/static/js/{HtmlPreview-tad0dezn.js → HtmlPreview-g4bp5mgq.js} +1 -1
  8. package/dist/client/static/js/{ImageView-7bpm4xhb.js → ImageView-5e3vdyc9.js} +1 -1
  9. package/dist/client/static/js/{LayoutWrapper-ehxhj6t3.js → LayoutWrapper-ssxr6q2d.js} +2 -2
  10. package/dist/client/static/js/MergeDiffView-6t5t6exc.js +1 -0
  11. package/dist/client/static/js/{Modal-5qt3v5gn.js → Modal-px8tcv9m.js} +9 -9
  12. package/dist/client/static/js/{PdfView-hbgnnana.js → PdfView-92rx0s88.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-rv9jmr2e.js → SessionsView-s3d9nceb.js} +1 -1
  14. package/dist/client/static/js/{SheetView-55e0a8as.js → SheetView-yeg7gtf9.js} +1 -1
  15. package/dist/client/static/js/{SvgPreview-10fa6mj1.js → SvgPreview-6evr72fg.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-9w4p3dhe.js → abnfDiagram-O67JEVCF-a6n0cab2.js} +1 -1
  17. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-5x6sb253.js → architectureDiagram-NJMV4G6O-z9k17qfg.js} +2 -2
  18. package/dist/client/static/js/{astro-m3fcq2sa.js → astro-asmathwv.js} +1 -1
  19. package/dist/client/static/js/{blockDiagram-BEXU5L5S-2c6y4pkn.js → blockDiagram-BEXU5L5S-63d683v3.js} +2 -2
  20. package/dist/client/static/js/c-20y64hcp.js +1 -0
  21. package/dist/client/static/js/{c4Diagram-YGBWAQC7-45rtm401.js → c4Diagram-YGBWAQC7-5bk6kv13.js} +2 -2
  22. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-rksw3aw9.js → classDiagram-v2-NBCMYWYE-s6rmr6vt.js} +2 -2
  23. package/dist/client/static/js/{cose-bilkent-JH36ORCC-4hxtttt5.js → cose-bilkent-JH36ORCC-wd5v7q2m.js} +1 -1
  24. package/dist/client/static/js/cpp-ty6n0dg9.js +1 -0
  25. package/dist/client/static/js/css-ncvxaxt0.js +1 -0
  26. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-5dhexpf2.js → cynefinDiagram-VND7K2PF-j71tvbhy.js} +1 -1
  27. package/dist/client/static/js/{dagre-6A5THRUB-1k3w4qm9.js → dagre-6A5THRUB-q6x3d9xb.js} +2 -2
  28. package/dist/client/static/js/{diagram-22UHCM2B-fw76k272.js → diagram-22UHCM2B-g6e427jm.js} +2 -2
  29. package/dist/client/static/js/{diagram-3UASUU5V-qnb2gn31.js → diagram-3UASUU5V-rg3nty46.js} +1 -1
  30. package/dist/client/static/js/{diagram-ATOU4E4O-cavnxzpf.js → diagram-ATOU4E4O-m82xv6ka.js} +2 -2
  31. package/dist/client/static/js/{diagram-CDSNMT55-6dxaj054.js → diagram-CDSNMT55-q3aa8sv0.js} +2 -2
  32. package/dist/client/static/js/{diagram-MLGK6HIB-f16fv9ay.js → diagram-MLGK6HIB-nkyd150x.js} +1 -1
  33. package/dist/client/static/js/{diagram-MPIPVDR6-zsryj72g.js → diagram-MPIPVDR6-1gchkss2.js} +1 -1
  34. package/dist/client/static/js/{dockerfile-frznktsa.js → dockerfile-f51g7549.js} +1 -1
  35. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-1zz5h7sw.js → ebnfDiagram-ZINNZB2B-4dsm3p06.js} +1 -1
  36. package/dist/client/static/js/{elk-276RUBZZ-25pehy1p.js → elk-276RUBZZ-d8wtwxae.js} +1 -1
  37. package/dist/client/static/js/{erDiagram-OPXOYQCR-ezpjhgzw.js → erDiagram-OPXOYQCR-bq865cmc.js} +2 -2
  38. package/dist/client/static/js/flowDiagram-KWPJA3E3-z01c78q6.js +1 -0
  39. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-n11hq4ag.js → ganttDiagram-FUAMR5RP-ndnqbbzn.js} +1 -1
  40. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-3znkxh7y.js → gitGraphDiagram-X574FWY7-d9y6fnz0.js} +1 -1
  41. package/dist/client/static/js/{index-acpn178r.js → index-046kc8ft.js} +1 -1
  42. package/dist/client/static/js/{index-s78f7j47.js → index-049xtm14.js} +1 -1
  43. package/dist/client/static/js/{index-y79ebmam.js → index-0ccj7j87.js} +1 -1
  44. package/dist/client/static/js/{index-vjmy9r20.js → index-0fpc1h6v.js} +1 -1
  45. package/dist/client/static/js/{index-j97qmbbv.js → index-25g1ydkd.js} +1 -1
  46. package/dist/client/static/js/{index-4nvcwtvr.js → index-25zpywv7.js} +1 -1
  47. package/dist/client/static/js/{index-1qjxg7mh.js → index-2jtkrmry.js} +1 -1
  48. package/dist/client/static/js/{index-scmtzcv1.js → index-396g4zz4.js} +2 -2
  49. package/dist/client/static/js/{index-qrpx4sk1.js → index-3x88t8g9.js} +2 -2
  50. package/dist/client/static/js/{index-7ag37ghj.js → index-4kchzh9y.js} +8 -8
  51. package/dist/client/static/js/{index-5z7f6bq4.js → index-4pwk5cjy.js} +1 -1
  52. package/dist/client/static/js/{index-ht164kw9.js → index-53hrj27y.js} +1 -1
  53. package/dist/client/static/js/{index-2k6wyyds.js → index-5g21qv2b.js} +4 -4
  54. package/dist/client/static/js/{index-wvw70pgd.js → index-668fc1df.js} +2 -2
  55. package/dist/client/static/js/{index-gmea6fjd.js → index-6775m1pa.js} +5 -5
  56. package/dist/client/static/js/{index-5j0wejvq.js → index-6pxh5p8g.js} +2 -2
  57. package/dist/client/static/js/{index-4faphth3.js → index-79qddnbx.js} +1 -1
  58. package/dist/client/static/js/{index-tnhnysj1.js → index-7fkdwm69.js} +1 -1
  59. package/dist/client/static/js/index-7jr49rd4.js +2 -0
  60. package/dist/client/static/js/{index-ey0ckd66.js → index-8k568z0z.js} +2 -2
  61. package/dist/client/static/js/{index-dzp9rwy0.js → index-8w69r0c4.js} +161 -161
  62. package/dist/client/static/js/{index-m1hd7ska.js → index-9eddntv4.js} +25 -25
  63. package/dist/client/static/js/{index-zkkttvtx.js → index-bcns8arc.js} +2 -2
  64. package/dist/client/static/js/{index-8972fxm9.js → index-f7sssx5h.js} +1 -1
  65. package/dist/client/static/js/{index-1w92sjkm.js → index-g46qcgp8.js} +2 -2
  66. package/dist/client/static/js/{index-hqc2cazc.js → index-gm9cqsqg.js} +4 -4
  67. package/dist/client/static/js/{index-02skcm4d.js → index-gr5wd7hv.js} +1 -1
  68. package/dist/client/static/js/{index-5pbf6dcz.js → index-h9p3748x.js} +3 -3
  69. package/dist/client/static/js/{index-me7ag6sy.js → index-hav1hhbr.js} +1 -1
  70. package/dist/client/static/js/{index-58kgkwxt.js → index-hn0brpdf.js} +4 -4
  71. package/dist/client/static/js/{index-qj6b15r4.js → index-k8ks184k.js} +2 -2
  72. package/dist/client/static/js/{index-er7pj5k6.js → index-m6eh5g1q.js} +1 -1
  73. package/dist/client/static/js/{index-kyarw08m.js → index-mnadx740.js} +2 -2
  74. package/dist/client/static/js/{index-5hqjscys.js → index-mttf7ej7.js} +2 -2
  75. package/dist/client/static/js/{index-10cxm9ty.js → index-pd4s49n5.js} +2 -2
  76. package/dist/client/static/js/{index-32gh2645.js → index-pnjnvdvb.js} +1 -1
  77. package/dist/client/static/js/index-rc8f8gjk.js +1 -0
  78. package/dist/client/static/js/{index-ej1va073.js → index-rsyqf691.js} +2 -2
  79. package/dist/client/static/js/{index-e0h6xkpv.js → index-stfccv2r.js} +1 -1
  80. package/dist/client/static/js/{index-1e7fek0v.js → index-v8fztm3w.js} +1 -1
  81. package/dist/client/static/js/{index-z9msykm1.js → index-vjk01ja9.js} +1 -1
  82. package/dist/client/static/js/{index-b039ef9w.js → index-w39c85k3.js} +2 -2
  83. package/dist/client/static/js/{index-899yw6fh.js → index-x3g8fwkc.js} +2 -2
  84. package/dist/client/static/js/{index-dkz8d77n.js → index-xakrt0sx.js} +1 -1
  85. package/dist/client/static/js/{index-dzsjyzht.js → index-xf662xsf.js} +2 -2
  86. package/dist/client/static/js/{index-9n1cg95f.js → index-z0vvdpkv.js} +1 -1
  87. package/dist/client/static/js/{infoDiagram-VRGFBTTK-kmv3jtrd.js → infoDiagram-VRGFBTTK-t52bsrem.js} +1 -1
  88. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-5kp6geeh.js → ishikawaDiagram-OU5B5YK6-vysv38pr.js} +1 -1
  89. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-6w5f1ddc.js → journeyDiagram-ZHPQQLJL-7222yn0y.js} +2 -2
  90. package/dist/client/static/js/json-xha2drny.js +1 -0
  91. package/dist/client/static/js/{julia-nwh5w343.js → julia-d18zhpyp.js} +1 -1
  92. package/dist/client/static/js/{kanban-definition-PNTS6WVX-6esn6xqn.js → kanban-definition-PNTS6WVX-9cg88rcn.js} +2 -2
  93. package/dist/client/static/js/lua-njwwdj4s.js +1 -0
  94. package/dist/client/static/js/{mermaid.core-z83pf8ch.js → mermaid.core-3qc3zvgb.js} +7 -7
  95. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-0h1nhw66.js → mindmap-definition-NLK3R4M7-hdbsk349.js} +1 -1
  96. package/dist/client/static/js/one-dark-pro-3570ra7e.js +1 -0
  97. package/dist/client/static/js/one-light-3v5yk200.js +1 -0
  98. package/dist/client/static/js/{pegDiagram-GJSIUBJH-xdcpr8my.js → pegDiagram-GJSIUBJH-jtqqcrhq.js} +1 -1
  99. package/dist/client/static/js/{perl-wb4wtc9x.js → perl-sns2qvmf.js} +1 -1
  100. package/dist/client/static/js/{php-9g594k9f.js → php-3q6v9eey.js} +1 -1
  101. package/dist/client/static/js/{pieDiagram-5QR66LMP-0210zd5b.js → pieDiagram-5QR66LMP-2c82jghr.js} +1 -1
  102. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-j0rtvvcm.js → quadrantDiagram-O4NWA36T-vp2hw2a8.js} +1 -1
  103. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-mzxat5g5.js → railroadDiagram-XR7U4H2S-4168nq4f.js} +1 -1
  104. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-zq5b9ts2.js → requirementDiagram-PLB6GJNP-gwqcyxag.js} +2 -2
  105. package/dist/client/static/js/{ruby-c4hxsegh.js → ruby-f9k99tfq.js} +1 -1
  106. package/dist/client/static/js/{rust-vmn352hx.js → rust-6m8myprw.js} +1 -1
  107. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-06s3r7bv.js → sankeyDiagram-IPEJSGJF-y5fakn56.js} +2 -2
  108. package/dist/client/static/js/{sass-6yxywx7t.js → sass-2syegq28.js} +1 -1
  109. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-7s4gz4t5.js → sequenceDiagram-PO4LG4MO-z140kern.js} +3 -3
  110. package/dist/client/static/js/{sizeCapture-INFHLROL-yensh9k2.js → sizeCapture-INFHLROL-gfez373x.js} +1 -1
  111. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-1q8p06fk.js → stateDiagram-v2-GCMORJYK-1d6h03nr.js} +1 -1
  112. package/dist/client/static/js/{swimlanes-2SLR337P-2mfxddzf.js → swimlanes-2SLR337P-75wg3n6d.js} +1 -1
  113. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-k2xf0gby.js → swimlanesDiagram-TC7HE7FX-18fj17m7.js} +1 -1
  114. package/dist/client/static/js/{timeline-definition-EJHVYXUP-xrk07evk.js → timeline-definition-EJHVYXUP-q750z70f.js} +2 -2
  115. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ca9h5skn.js → usecaseDiagram-POWQR4AR-9q7tg456.js} +1 -1
  116. package/dist/client/static/js/{vennDiagram-UO4OBE2U-c0y47znt.js → vennDiagram-UO4OBE2U-010nw1kd.js} +1 -1
  117. package/dist/client/static/js/{vue-rcdqpz7q.js → vue-e8e3q3hj.js} +1 -1
  118. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-mfk1ck3n.js → wardleyDiagram-VNRHLVJA-7n33n10f.js} +1 -1
  119. package/dist/client/static/js/xml-8516fzfp.js +1 -0
  120. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-6f8xt89k.js → xychartDiagram-PMCCYNJV-7q0n5vvd.js} +2 -2
  121. package/package.json +1 -1
  122. package/src/client/hooks/chat/timeline/new-chat-open.ts +5 -3
  123. package/src/client/hooks/chat/timeline/new-chat.test.ts +18 -2
  124. package/src/client/hooks/chat/timeline/new-chat.ts +13 -12
  125. package/src/client/hooks/chat/timeline/scope.test.ts +100 -0
  126. package/src/client/hooks/chat/timeline/scope.ts +9 -9
  127. package/src/client/lib/tts/gapless.ts +205 -0
  128. package/src/client/lib/tts/player.test.ts +83 -64
  129. package/src/client/lib/tts/player.ts +48 -98
  130. package/src/server/lib/fs/fs-write-git.test.ts +2 -51
  131. package/src/server/lib/fs/git-ignore.test.ts +101 -0
  132. package/src/server/lib/fs/git-ignore.ts +38 -1
  133. package/src/server/lib/fs/listing.test.ts +19 -0
  134. package/src/shared/lib/workspace/active-project.test.ts +45 -0
  135. package/src/shared/lib/workspace/active-project.ts +21 -0
  136. package/dist/client/static/js/MergeDiffView-28xkyts9.js +0 -1
  137. package/dist/client/static/js/c-ypdp030b.js +0 -1
  138. package/dist/client/static/js/cpp-cxwev3gs.js +0 -1
  139. package/dist/client/static/js/css-6mxcqf8c.js +0 -1
  140. package/dist/client/static/js/flowDiagram-KWPJA3E3-zh6hmn6g.js +0 -1
  141. package/dist/client/static/js/index-qva2vqbh.js +0 -2
  142. package/dist/client/static/js/index-xvh25zer.js +0 -1
  143. package/dist/client/static/js/json-mb8k0b1n.js +0 -1
  144. package/dist/client/static/js/lua-nxnqww9z.js +0 -1
  145. package/dist/client/static/js/one-dark-pro-wsgaqq27.js +0 -1
  146. package/dist/client/static/js/one-light-w8zdrvyc.js +0 -1
  147. package/dist/client/static/js/xml-vtrdnrn6.js +0 -1
@@ -1 +1 @@
1
- import{d,n,o,i,u,a,Dr,ze,ie,e,s,Kn,Q,dt,E,ce,Lo,ae,Ie,et,bi,bn,yi,ia,S,U,h,sr,k,yh,Te,bl,T,xr,wr,xt,nt,he,Bt,Sd,mt,ft,Dh,Nh,Po,gs,Td,We,hs}from"./index-dzp9rwy0.js";import{yd,vd,pi,kd,xd}from"./index-b039ef9w.js";import{Z}from"./index-ey0ckd66.js";import{Tr}from"./index-02skcm4d.js";var Yt={name:"pen",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],aliases:["edit-2"]},Xe=s(Yt);var Jt={name:"copy-plus",size:24,node:[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]},qe=s(Jt);var Zt={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Be=s(Zt);var en={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]},Se=s(en);function Qe({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:g,onRefresh:v,refreshing:b}){return e("div",{className:"border-b border-ink/10",children:[e(xt,{className:"border-b-0",left:e(Tr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(nt,{label:"Refresh",onClick:v,busy:b})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(U,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:x,onChange:(m)=>g(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})})]})}function Ye({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:g}){let v=f?"text-ink font-semibold":x?x.colorClass:g?g.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(E,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ce,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(mt,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),g&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${g.dotClass}`,title:`${g.count} changed file${g.count>1?"s":""}`})]})}var tn=28,nn=9,rn=8;function on(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:g,isArchive:v}=t,b=[],m=g>1,C=g===1?"":` ${g} items`;if(m)return b.push({kind:"item",id:"cut",label:`Cut${C}`,icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"copy",label:`Copy${C}`,icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"separator"}),b.push({kind:"item",id:"compress",label:`Compress${C} to…`,icon:e(dt,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"separator"}),b.push({kind:"item",id:"delete",label:`Delete${C}`,icon:e(Q,{size:13,className:"text-error"}),tone:"text-error"}),b;if(r){if(b.push({kind:"item",id:"new_file",label:"New File",icon:e(bi,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(bn,{size:13,className:"text-ink/60"})}),f)b.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(E,{size:13,className:"text-ink/60"})});if(x)b.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ce,{size:13,className:"text-ink/60"})});b.push({kind:"separator"})}else{if(b.push({kind:"item",id:"view",label:"View",icon:e(et,{size:13,className:"text-ink/60"})}),v)b.push({kind:"item",id:"extract",label:"Extract…",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p});if(l)b.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(yi,{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(Lo,{size:13,className:"text-ink/60"}),disabled:p});return b.push({kind:"separator"}),b.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Ie,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(ae,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(ae,{size:13,className:"text-ink/60"})}),b.push({kind:"separator"}),b.push({kind:"item",id:"history",label:"Show Git History",icon:e(Kn,{size:13,className:"text-ink/60"})}),b.push({kind:"separator"}),b.push({kind:"item",id:"rename",label:"Rename",icon:e(Xe,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"delete",label:"Delete",icon:e(Q,{size:13,className:"text-error"}),tone:"text-error"}),b}function sn(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*tn+l*nn+rn}function Je({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:g,selectionCount:v,isArchive:b,onAction:m,menuRef:C}){let N=on({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:g,chainLabel:f,foldable:x,selectionCount:v,isArchive:b}),A=sn(N),F=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,M=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-A-12)):r;return ie(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(D)=>{D.preventDefault(),m("close")},children:e("div",{ref:C,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:M,left:F},onClick:(D)=>D.stopPropagation(),children:N.map((D,w)=>D.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${w}`):e("button",{type:"button",disabled:D.disabled,onClick:()=>m(D.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${D.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${D.tone??""}`,children:[D.icon,e("span",{children:D.label})]},D.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:g}){let v=r==="folder"?"Folder":"File";return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:g,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",v]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(b)=>f(b.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${v.toLowerCase()} name`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${c?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Nested paths create the folders they need — ",e("span",{className:"font-mono",children:"lib/parse.ts"}),"."]}),c&&e("p",{className:"text-[11px] text-error mb-2",children:c}),e("div",{className:"flex justify-end space-x-2 mt-2",children:[e("button",{type:"button",onClick:x,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function Ze({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let g=c>1;return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",g?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",g?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:x,className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 transition-colors flex items-center",disabled:p,children:p?"Deleting...":"Delete"})]})]})}),document.body)}function tt({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:g,onSubmit:v}){return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(b)=>x(b.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:g,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function rt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Kn,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(h,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,x)=>e("tr",{className:"hover:bg-ink/[0.03] transition-colors group",children:[e("td",{className:"px-3 py-2 text-ink",children:f.message?e("span",{className:"font-medium text-ink/90 group-hover:text-ink",children:f.message}):null}),e("td",{className:"px-3 py-2 text-ink/60 whitespace-nowrap font-mono text-[10.5px]",children:f.time}),e("td",{className:"px-3 py-2 text-ink/70 whitespace-nowrap truncate max-w-[120px]",children:f.author}),e("td",{className:"px-3 py-2 text-right",children:f.hash?e("span",{className:"font-mono text-ink/50 group-hover:text-ink font-semibold transition-colors bg-canvas px-1.5 py-0.5 rounded border border-ink/10",children:f.hash}):null})]},x))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(S,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function ot({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(Ze,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(tt,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(rt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(an);return r.some((l,c)=>l!==t[c])?r:t}function an(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Ee(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,x)=>[...p,...l.slice(0,x+1)].join("/"))}function it(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((g)=>{if(g.type!=="folder")return[g];let v=Array.isArray(g.children)?p(g.children):g.children,b=v===g.children?g:{...g,children:v},m=r.has(g.path)?Me(g.path,g.name):null;if(!m)return[b];c=!0,l.set(m[0],g.path);let C={...b,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let N=m[y-1];C={name:N.split("/").pop(),path:N,type:"folder",ignored:b.ignored,children:[C]}}return[C]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(x)=>{for(let g of x){if(g.type!=="folder")continue;if(l.add(g.path),Array.isArray(g.children))c(g.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let g=p.slice(0,x+1).join("/");if(l.has(g))f.push(g)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=ft(),[x,g]=n(!1),[v,b]=n("file"),[m,C]=n(""),[y,N]=n(null),A=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let F=f.data;if(A.current===F)return;if(A.current=F,F.success&&F.path){let M=F.kind==="folder"?"folder":"file";g(!1),C(""),N(null);let D=F.path.split("/").pop()||F.path;if(c({path:F.path,name:D,kind:M}),M==="file")p?.({path:F.path,name:D})}else N(F.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:C,error:y,busy:f.state!=="idle",openDialog:(F="file")=>{b(F),C(""),N(null),g(!0)},closeDialog:()=>g(!1),submit:(F)=>{F.preventDefault();let M=m.trim();if(!M)return;N(null);let D=new FormData;if(D.append("actionType","create"),D.append("path",t),D.append("name",M),v==="folder")D.append("kind","folder");if(l&&l!==".")D.append("repo",l);if(r)D.append("root",r);f.submit(D,{method:"post",action:"/api/fs/action"})}}}function we(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function at(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function lt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function ct(t,r){if(t.path===""||t.path===".")return"The workspace root cannot be moved or copied";if(t.kind==="folder"&&(r===t.path||r.startsWith(`${t.path}/`)))return"Cannot paste a folder into itself";return null}function pt(t,r){let l=ct(t,r);if(l)return l;if(r===lt(t.path))return"Already in this folder";return null}function ut(t,r,l){if(!t||t.entries.length===0)return"Nothing to paste";if(t.scope!==r)return"The clipboard holds an entry from another workspace";if(t.mode==="cut"&&t.entries.some((c)=>l===lt(c.path)))return"Already in this folder";for(let c of t.entries){let p=ct(c,l);if(p)return p}return null}function ht(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.scope!=="string")return null;if(r.mode!=="copy"&&r.mode!=="cut")return null;let l=Array.isArray(r.entries)?r.entries:typeof r.path==="string"?[{path:r.path,name:r.name,kind:r.kind}]:[],c=[];for(let p of l){let f=ln(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function ln(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.path!=="string"||typeof r.name!=="string")return null;if(r.kind!=="file"&&r.kind!=="folder")return null;let l=r.path.split("/");if(r.path===""||r.path.startsWith("/")||l.some((c)=>c===""||c==="."||c===".."))return null;return{path:r.path,name:r.name,kind:r.kind}}var $e=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],gt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function Oe(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return Oe(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function vt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function yt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function kt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Ct(t){if(t.length===0)return".";let r=t.map((c)=>yt(c).split("/").filter((p)=>p!==".")),l=r[0]??[];for(let c of r.slice(1)){let p=0;while(p<l.length&&p<c.length&&l[p]===c[p])p+=1;l=l.slice(0,p)}return l.length===0?".":l.join("/")}function De(t,r){let l=dn(r);if(t.length===1){let f=t[0],x=vt(f.name),g=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:g>0?x.slice(0,g):x)||"archive"}.${l}`}let c=Ct(t.map((f)=>f.path)),p=kt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ft(t){return Ct(t.map((r)=>r.path))}function Nt(t){let r=yt(t),l=vt(kt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function wt(t){return t.toUpperCase()}function Dt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:g,clipboard:v,isFolder:b,selection:m,selected:C,archive:y}){let N=ft(),[A,F]=n(null),M=i(null),[D,w]=n(!1),[R,I]=n(!1),[_,te]=n(!1),[ne,se]=n(t.path),[H,P]=n(null),{repo:z,rootPath:G}=t,K=Ne({folderPath:t.path,rootPath:G,repo:z,onCreated:(L)=>p?p(L):c(),onOpenCreated:(L)=>l?.({...L,root:G,repo:z||"."})}),re=i(null);o(()=>{if(N.state!=="idle"||!N.data)return;let L=N.data;if(re.current===L)return;if(re.current=L,L.success&&!L.type)if(w(!1),I(!1),P(null),L.previousPath&&L.path&&f)f(L.previousPath,L.path);else c();else if(!L.success&&L.error&&D)P(L.error)},[N.state,N.data]);let q=(L)=>{if(z&&z!==".")L.append("repo",z);if(G)L.append("root",G);N.submit(L,{method:"post",action:"/api/fs/action"})},X=()=>{l?.({path:t.path,name:t.name,root:G,repo:z||"."})},J={path:t.path,name:t.name,kind:b?"folder":"file"},oe=C&&m.length>1?m:[J],ge=bt(t.name),B=v.clip&&!v.refusalFor(J)?`Paste ${we(v.clip)??"item"}`:null,fe=(L)=>{if(F(null),P(null),L==="view")X();else if(L==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:G}}));else if(L==="explorer"){let j=new FormData;j.append("actionType","open_explorer"),j.append("path",t.path),q(j)}else if(L==="copy_path")Bt(Sd(t.basePath,t.path));else if(L==="copy_relative")Bt(t.path);else if(L==="history"){te(!0);let j=new FormData;j.append("actionType","git_history"),j.append("path",t.path),q(j)}else if(L==="rename")se(t.path),w(!0);else if(L==="unfold")x?.();else if(L==="fold")g?.();else if(L==="new_file")K.openDialog("file");else if(L==="new_folder")K.openDialog("folder");else if(L==="delete")I(!0);else if(L==="cut")v.cut(oe);else if(L==="copy")v.copy(oe);else if(L==="compress")y.openCompress(oe);else if(L==="extract")y.openExtract(J);else if(L==="duplicate")v.duplicate(J);else if(L==="paste")v.paste(J)},le=(L)=>{L.preventDefault(),P(null);let j=new FormData;j.append("actionType","rename"),j.append("path",t.path),j.append("newPath",ne),q(j)},ve=()=>{let L=new FormData;if(L.append("actionType","delete"),oe.length>1)L.append("paths",JSON.stringify(oe.map((j)=>j.path)));else L.append("path",t.path);q(L)};return{contextMenu:A,contextMenuRef:M,openContextMenu:(L,j)=>F({x:L,y:j}),closeContextMenu:()=>F(null),showRenameModal:D,showDeleteModal:R,showHistoryModal:_,showCreateModal:K.open,createKind:K.kind,createError:K.error,createName:K.name,setCreateName:K.setName,renameValue:ne,setRenameValue:se,renameError:H,busy:N.state!=="idle"||K.busy||v.busy||y.busy,pasteLabel:B,selectionCount:oe.length,isArchive:ge,chainLabel:x!==void 0,foldable:g!==void 0,fetcherState:N.state,fetcherData:N.data,handleAction:fe,submitCreate:K.submit,submitRename:le,submitDelete:ve,closeCreate:K.closeDialog,closeDelete:()=>I(!1),closeRename:()=>w(!1),closeHistory:()=>te(!1)}}function Rt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let g=r?.path===t.path,v=Boolean(r)&&!g&&l.moveRefusalFor(r,t)===null,[b,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:g,acceptsDrop:v,isDropHovered:b&&v,onDragStart:(y)=>{if(y.dataTransfer?.setData("text/plain",t.path),y.dataTransfer)y.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(y)=>{if(!r)return;if(y.stopPropagation(),m(v),!v)return;if(y.preventDefault(),y.dataTransfer)y.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>m(!1),onDrop:(y)=>{if(!r)return;if(y.stopPropagation(),!v)return;y.preventDefault(),f(t)}}}function pn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Pe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,expandedPaths:b,onToggleFolder:m,gitFileMap:C,gitFolderMap:y,clipboard:N,archive:A,selection:F,selectionTargets:M,dragging:D,onDragStart:w,onDragEnd:R,onDropOn:I,onUnfold:_,onFold:te,foldRoots:ne,touch:se=!1}){let H=t.type==="folder",[P,z]=n(!1),[G,K]=n(!1),[re,q]=n(!1),[X,J]=n(!1),oe=Array.isArray(t.children)?t.children:[],ge=(t.path||"").replace(/^\/+/,""),B=!H?C?.get(ge)||C?.get(t.path):void 0,fe=B?sr(B.status,B.staged):null,le=H?y?.get(ge)||y?.get(t.path):null,ve=Boolean(fe),L=t.ignored===!0,j=b?b.has(t.path):P,de=t.forceExpanded!==void 0?t.forceExpanded:j;o(()=>{J(!0)},[]),o(()=>{if(H&&b)z(b.has(t.path))},[b,t.path,H]),o(()=>{if(H&&de&&pn(t,G,re)&&p)q(!0),K(!0),Promise.resolve(p(t.path)).finally(()=>K(!1))},[H,de,t.children,t.path,p,G,re]);let ke={path:t.path,name:t.name,kind:H?"folder":"file"},xe=F.selected.has(t.path),W=Dt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:M,selected:xe,archive:A,diff:{staged:B?.staged||(B?.status?B.status[0]!==" "&&B.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,onUnfold:_&&Ee({type:H?"folder":"file",name:t.name})?()=>_(ke):void 0,onFold:te&&ne?.has(t.path)?()=>te(ne.get(t.path)):void 0,clipboard:N,isFolder:H});he(W.contextMenuRef,W.closeContextMenu);let Y=yd({enabled:se,onLongPress:(V,be)=>W.openContextMenu(V,be)}),Ce=(V)=>{if(V.stopPropagation(),Y.consume())return;let be=F.gestureOf(V);if(be!=="plain"){F.applyGesture(be,t.path);return}if(F.applyGesture("plain",t.path),H){let ue=!de;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ye=(V)=>{V.preventDefault(),V.stopPropagation(),F.ensureForContext(t.path),W.openContextMenu(V.clientX,V.clientY)},pe=Rt({target:ke,dragging:D,clipboard:N,onDragStart:w,onDragEnd:R,onDropOn:I,onHoverAccept:_});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${pe.isDragging?"opacity-40":""} ${pe.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":xe?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!se,onClick:Ce,onContextMenu:ye,onDragStart:pe.onDragStart,onDragEnd:pe.onDragEnd,onDragOver:pe.onDragOver,onDragLeave:pe.onDragLeave,onDrop:pe.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Ye,{name:t.name,path:t.path,isFolder:H,isOpen:de,ignored:L,selected:xe,gitStatus:fe,folderStatus:le})}),de&&G&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),de&&!G&&oe.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:oe.map((V)=>e(Pe,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,expandedPaths:b,onToggleFolder:m,gitFileMap:C,gitFolderMap:y,clipboard:N,archive:A,selection:F,selectionTargets:M,dragging:D,onDragStart:w,onDragEnd:R,onDropOn:I,onUnfold:_,onFold:te,foldRoots:ne,touch:se},V.path))}),X&&W.contextMenu&&e(Je,{x:W.contextMenu.x,y:W.contextMenu.y,isFolder:H,hasGitStatus:ve,pasteLabel:W.pasteLabel,chainLabel:W.chainLabel,foldable:W.foldable,busy:W.busy,selectionCount:W.selectionCount,isArchive:W.isArchive,onAction:W.handleAction}),X&&e(ot,{actions:W,file:t,isFolder:H,chainLabel:Ee({type:H?"folder":"file",name:t.name})?t.name:void 0})]})}function St({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let g=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,b=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-g-12)):r;return ie(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:b,left:v},onClick:(m)=>m.stopPropagation(),children:[e("button",{type:"button",onClick:()=>p("new_file"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(bi,{size:13,className:"text-ink/60"}),e("span",{children:"New File"})]}),e("button",{type:"button",onClick:()=>p("new_folder"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(bn,{size:13,className:"text-ink/60"}),e("span",{children:"New Folder"})]}),l&&e("button",{type:"button",disabled:c,onClick:()=>p("paste"),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${c?"opacity-40 cursor-default":"hover:bg-ink/5"}`,children:[e(Lo,{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)gs({path:c.path,...y});return}Po({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?`${pi(m.kind)} ${m.name}`:`${pi(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${pi(m.kind).toLowerCase()}`:`${pi(m.kind)} · line ${m.line}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors hover:bg-ink/5 active:bg-ink/10",style:{paddingLeft:`${4+m.depth*12}px`},children:[e(vd,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!v&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),x&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:kd(f)})]})})})})]})}function He(t,r){return Ae(t.map((l)=>mn(l,r)))}function mn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:He(l,r)}}function hn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function $t(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Lt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ge(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},g=f,v=null;for(let b=0;b<c.length-1;){let m=c.slice(0,b+1).join("/"),C=g.find((M)=>M.type==="folder"&&M.path===m),y=C?null:g.find((M)=>M.type==="folder"&&M.path.startsWith(`${m}/`)&&(p===M.path||p.startsWith(`${M.path}/`))),N=C??y,A=N?x[N.path]??N.children:null;if(N&&!Array.isArray(A))return{nodes:t,cache:r};if(!N){let M=gn(g,x,m);if(M){g=M;let D=g.find((R)=>R.path===m),w=Array.isArray(D?.children)?[...D.children]:[];x[m]=w,g=w,v=m,b+=1;continue}}let F=Array.isArray(A)?[...A]:[];if(N){x[N.path]=F,g=F,v=N.path,b=N.path.split("/").length;continue}g.push({name:c[b],path:m,type:"folder",ignored:!1}),x[m]=F,g=F,v=m,b+=1}if(g.push(l),v!==null)x[v]=Lt(g);return f=Lt(f),{nodes:f,cache:x}}function gn(t,r,l){let c=t.findIndex((v)=>v.type==="folder"&&v.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),x=r[p.path]??p.children;if(Array.isArray(x))r[p.path]=x;let g={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let v=f.length-2;v>=0;v-=1)g={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[g]};return t[c]={name:$t(l),path:l,type:"folder",ignored:!1,children:[g]},t}function zt(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=hn(l),f=r[p],x=f?.find((m)=>m.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let v=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((C)=>C.path===l)).sort((m,C)=>C.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let b=r[v];return{entry:b.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:b.filter((m)=>m.path!==l)}}}function Ot(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),g=Array.isArray(f.children)?Ot(f.children,r,l):void 0;if(!x&&g===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,b=x?{...f,path:v,name:$t(v)}:{...f};if(g!==void 0)b.children=g;return b});return c?p:t}function Pt(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let x=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[x]=x===p?f:Ot(f,r,l)}return c}function It(t,r,l){let c=new Set;for(let p of t)if(p===r)c.add(l);else if(p.startsWith(`${r}/`))c.add(`${l}${p.slice(r.length)}`);else c.add(p);return c}function Ht(t){if(!k(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>k(r)):[],root:t.root}}async function Ke(t){try{return Ht(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Gt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,g]=n({scope:"",files:[],root:""}),[v,b]=n(!1),m=i({}),C=i([]),y=i(f);y.current=f;let N=i(""),A=i(""),F=i(c);F.current=c;let M=(P)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(P)z.set("path",P);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},D=(P,z)=>{N.current=P,A.current=z;let G=He(C.current,m.current);return g({scope:P,files:G,root:z}),G},w=async(P)=>{let z=[...F.current];if(z.length===0)return;let G=await Promise.all(z.map(async(X)=>({path:X,read:await Ke(M(X))})));if(y.current!==P)return;let K=[];for(let{path:X,read:J}of G)if(J.status==="ok")m.current[X]=J.files;else if(J.status==="missing")K.push(X);if(K.length===0)return;let re=new Set(K);for(let X of K)delete m.current[X];let q=new Set([...F.current].filter((X)=>!re.has(X)));F.current=q,p(q)},R=async()=>{if(!t)return;let P=y.current;b(!0);try{let z=await Ke(M());if(y.current!==P)return;if(z.status!=="ok")return;if(N.current!==P)m.current={};if(C.current=z.files,D(P,z.root),await w(P),y.current!==P)return;D(P,z.root)}finally{if(y.current===P)b(!1)}},I=async(P)=>{let z=y.current,G=await Ke(M(P));if(y.current!==z||G.status!=="ok")return;if(m.current[P]=G.files,N.current===z)D(z,A.current)},_=(P)=>{let z=Ht(P);if(z.status!=="ok")return;let G=y.current;if(N.current!==G)m.current={};C.current=z.files,D(G,z.root),w(G).then(()=>{if(y.current===G)D(G,z.root)})},te=()=>{m.current={},C.current=[],N.current="",A.current="",g({scope:"",files:[],root:""})},ne=(P)=>{let z=y.current;if(N.current!==z)return null;let G={name:P.path.slice(P.path.lastIndexOf("/")+1),path:P.path,type:P.kind,ignored:!1},K=Ge(C.current,m.current,G);if(K.nodes===C.current)return null;return C.current=K.nodes,m.current=K.cache,D(z,A.current)},se=(P,z)=>{let G=y.current;if(N.current!==G)return null;let K=zt(C.current,m.current,P);if(!K.entry)return null;m.current=Pt(K.cache,P,z);let re={...K.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Ge(K.nodes,m.current,re);return C.current=q.nodes,m.current=q.cache,D(G,A.current)},H=x.scope===f;return{scope:f,files:H?x.files:[],root:H?x.root:"",isLoading:v,reload:R,loadChildren:I,adoptRoot:_,insertEntry:ne,moveEntry:se,reset:te}}function Kt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=ft(),[f,x]=T("files.clipboard",null),g=ht(f),v=at(t,r),b=i(!1),m=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let F=p.data;if(m.current===F)return;m.current=F;let M=b.current;if(b.current=!1,F.success){if(M)x(null);if(F.failures?.length)c(`${F.failures.length} item(s) could not be moved: ${F.failures[0].error}`);l()}else c(F.error||"The transfer did not complete")},[p.state,p.data]);let C=a((F,M)=>{b.current=M;let D=new FormData;for(let[w,R]of Object.entries(F))D.append(w,R);if(r&&r!==".")D.append("repo",r);if(t)D.append("root",t);p.submit(D,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((F)=>ut(g,v,Le(F.path,F.kind)),[g,v]),N=a((F,M)=>pt(F,Le(M.path,M.kind)),[]),A=a((F,M,D,w)=>{let R=new FormData;R.append("actionType","paste"),R.append("mode",D),R.append("targetPath",M.path),R.append("targetKind",M.kind);for(let I of F)R.append("sourcePath",I.path);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);b.current=w,p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:g,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:N,copy:(F)=>{if(F.length===0)return;x({scope:v,entries:F.map(({path:M,name:D,kind:w})=>({path:M,name:D,kind:w})),mode:"copy"})},cut:(F)=>{if(F.length===0)return;x({scope:v,entries:F.map(({path:M,name:D,kind:w})=>({path:M,name:D,kind:w})),mode:"cut"})},duplicate:(F)=>{C({actionType:"duplicate",path:F.path},!1)},move:(F,M)=>{let D=N(F,M);if(D){c(D);return}A([F],M,"cut",Boolean(g?.mode==="cut"&&g.entries.some((w)=>w.path===F.path)))},paste:(F)=>{if(!g)return;let M=y(F);if(M){c(M);return}A(g.entries.map(({path:D,name:w,kind:R})=>({path:D,name:w,kind:R})),F,g.mode,g.mode==="cut")}}}var xn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=ft(),[p,f]=n(xn),[x,g]=n(null),[v,b]=n(null),[m,C]=n(null),y=i(null),N=i(null);o(()=>{let w=!1;return(async()=>{try{let I=await(await fetch("/api/fs/archive")).json();if(!w&&Array.isArray(I.formats)&&I.formats.length>0)f(I.formats)}catch{}})(),()=>{w=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let w=c.data;if(N.current===w)return;N.current=w;let R=y.current;if(y.current=null,w.success){if(C(null),R==="compress")g(null);if(R==="extract")b(null);l()}else if(R)C(w.error||"The archive request failed")},[c.state,c.data]);let A=a((w)=>{let R=new FormData;for(let[I,_]of Object.entries(w))R.append(I,_);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);c.submit(R,{method:"post",action:"/api/fs/action"})},[c,r,t]),F=a((w)=>{if(w.length===0)return;let R=p.find((I)=>I.id==="zip"&&I.available)?.id??p.find((I)=>I.available)?.id??"zip";C(null),b(null),g({entries:w.map(({path:I,name:_,kind:te})=>({path:I,name:_,kind:te})),format:R,name:De(w,R),destination:Ft(w)})},[p]),M=a((w)=>{C(null),g(null),b({archive:w,destination:Nt(w.path)})},[]),D=a((w)=>{g((R)=>{if(!R)return R;let I=De(R.entries,R.format),_=R.name===I?De(R.entries,w):R.name;return{...R,format:w,name:_}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:F,openExtract:M,setFormat:D,setName:(w)=>g((R)=>R&&{...R,name:w}),setCompressDestination:(w)=>g((R)=>R&&{...R,destination:w}),setExtractDestination:(w)=>b((R)=>R&&{...R,destination:w}),cancel:()=>{g(null),b(null),C(null)},submitCompress:()=>{let w=x;if(!w)return;y.current="compress",C(null),A({actionType:"compress",format:w.format,name:w.name.trim(),destination:w.destination.trim()||".",paths:JSON.stringify(w.entries.map((R)=>R.path))})},submitExtract:()=>{let w=v;if(!w)return;y.current="extract",C(null),A({actionType:"extract",path:w.archive.path,destination:w.destination.trim()||"."})}}}function vn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function yn(t,r,l){if(!r)return[l];let c=t.indexOf(r),p=t.indexOf(l);if(c===-1||p===-1)return[l];let f=Math.min(c,p),x=Math.max(c,p);return t.slice(f,x+1)}function _t(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((b,m)=>{if(b==="range"){l(new Set(yn(t,c,m)));return}if(p(m),b==="toggle"){l((C)=>{let y=new Set(C);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((b)=>{l((m)=>{if(m.has(b))return m;return new Set([b])}),p(b)},[]),g=a(()=>{l(new Set),p(null)},[]),v=a(vn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:g}),[r,c,v,f,x,g])}function je(t,r,l=0,c=[]){for(let p of t)if(c.push({path:p.path,name:p.name,kind:p.type==="folder"?"folder":"file",depth:l}),p.type==="folder"&&r(p)&&Array.isArray(p.children))je(p.children,r,l+1,c);return c}function Wt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,b)=>{let m=st(b,v);if(m.length===0)return;r((C)=>{if(m.every((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.add(N);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let b=t.insertEntry(v);if(!b){c();return}f(v.path,b)},[t,c,f]),g=a((v,b)=>{p?.(v,b),r((C)=>{let y=It(C,v,b);return l(Array.from(y)),y});let m=t.moveEntry(v,b);if(!m){c();return}f(b,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:g}}var kn=new Set;function Ut({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let b=Me(v.path,v.name);if(!b)return;p((C)=>{let y=C.scope===t?C.chains:new Map;if(y.get(v.path)?.length===b.length)return C;let A=new Map(y);return A.set(v.path,b),{scope:t,chains:A}});let m=b.slice(0,-1);r((C)=>{if(m.every((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.add(N);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let b=c.scope===t?c.chains.get(v):void 0;if(!b)return;let m=b.slice(0,-1);p((C)=>{if(C.scope!==t)return C;let y=new Map(C.chains);return y.delete(v),{scope:t,chains:y}}),r((C)=>{if(!m.some((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.delete(N);return l(Array.from(y)),y})},[t,c,r,l]),g=a((v,b)=>{let m=c.scope===t?c.chains:null;if(!m)return;let C=new Map,y=[],N=!1;for(let[A,F]of m){if(F.findIndex((R,I)=>R===v&&I>0&&I<F.length-1)!==-1){N=!0;continue}let D=F.map((R)=>R===v?b:R.startsWith(`${v}/`)?`${b}${R.slice(v.length)}`:R),w=D[D.length-1];if(w!==A||D.some((R,I)=>R!==F[I]))N=!0;C.set(w,D),y.push(...D.slice(0,-1))}if(!N)return;p({scope:t,chains:C}),r((A)=>{if(y.every((M)=>A.has(M)))return A;let F=new Set(A);for(let M of y)F.add(M);return l(Array.from(F)),F})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):kn,unfold:f,fold:x,rekey:g}}function Vt(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let x=(p.children||[]).map(c).filter((g)=>g!==null);if(f||x.length>0)return{...p,children:f&&x.length===0?p.children:x,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Xt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return o(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(x)=>{if(!x.currentTarget.contains(x.relatedTarget))f(!1)},onDragOver:(x)=>{if(!c)return;if(x.preventDefault(),x.dataTransfer)x.dataTransfer.dropEffect="move"},onDrop:(x)=>{if(!c)return;x.preventDefault(),f(!1),r.move(t,l)}}}function ri({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[g,v]=T("files.searchQuery",""),[b,m,C]=T("files.expandedPaths",[]),[y,N]=n(()=>new Set(b)),{activeRepo:A,setActiveRepo:F}=xr(c),{repos:M,scanning:D,rescan:w}=wr(c,r),{fileMap:R,folderMap:I,refreshGitStatus:_}=bl(c,A,r),[te,ne]=n(null),se=i(null);o(()=>{if(!C)return;N((O)=>{let ee=new Set(b);if(O.size===ee.size&&Array.from(ee).every((me)=>O.has(me)))return O;return ee})},[C,b]);let H=Gt({enabled:r,rootPath:c,activeRepo:A,expandedPaths:y,onExpansionPruned:(O)=>{N(O),m(Array.from(O))}});o(()=>{if(!C||!l)return;H.reload()},[f,c,r,A,C,l]);let P=r&&C?yh(H.scope):null,z=Te(P);o(()=>{if(z.data)H.adoptRoot(z.data)},[z.data]);let G=(O)=>(_(),H.loadChildren(O)),K=(O,ee)=>{let me=new Set(y);if(ee)me.add(O);else me.delete(O);N(me),m(Array.from(me))},{unfolded:re,unfold:q,fold:X,rekey:J}=Ut({scope:H.scope,setExpandedPaths:N,setStoredExpandedPaths:m}),oe=H.files,ge=it(oe,re),B=Vt(ge.nodes,g),fe=je(B,(O)=>O.forceExpanded!==void 0?O.forceExpanded:y.has(O.path)),le=_t(fe.map((O)=>O.path)),ve=fe.filter((O)=>le.selected.has(O.path)).map(({path:O,name:ee,kind:me})=>({path:O,name:ee,kind:me})),L=(O)=>{if(O===A)return;H.reset(),N(new Set),m([]),le.clear(),F(O)},j=()=>{if(_(),x)x();else H.reload()},{insertCreated:de,moveRenamed:ke}=Wt({listing:H,setExpandedPaths:N,setStoredExpandedPaths:m,reload:j,onMoved:(O,ee)=>J(O,ee)}),xe=hs(),{pushToast:W}=We(),Y=Kt({rootPath:c,repo:A,onComplete:j,onError:(O)=>W(O,"error")}),Ce=jt({rootPath:c,repo:A,onComplete:j}),ye={path:".",name:".",kind:"folder"},pe=Y.clip&&!Y.refusalFor(ye)?`Paste ${we(Y.clip)??"item"}`:null,[V,be]=n(null),ue=Xt({dragging:V,clipboard:Y,target:ye}),Re=Ne({folderPath:".",rootPath:c,repo:A,onCreated:de,onOpenCreated:(O)=>p?.({...O,root:c,repo:A})}),[_e,qt]=n(!1);o(()=>qt(!0),[]);let{count:Ue,clear:Ve}=le;if(o(()=>{if(!l)return;let O=(ee)=>{if(ee.key==="Escape"&&Ue>0)Ve()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[l,Ue,Ve]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let Qt=H.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Qe,{rootPath:c,activeRepo:A,repos:M,reposScanning:D,onRefreshRepos:w,onSelectRepo:L,searchQuery:g,onSearchChange:v,onRefresh:j,refreshing:Qt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${xe?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(O)=>{O.preventDefault(),ne({x:O.clientX,y:O.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:H.isLoading&&B.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):B.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):B.map((O)=>e(Pe,{file:O,rootPath:c,basePath:H.root,repo:A,onLoadChildren:G,onOpenFile:p,onActionComplete:j,onCreated:de,onRenamed:ke,expandedPaths:y,onToggleFolder:K,gitFileMap:R,gitFolderMap:I,clipboard:Y,archive:Ce,selection:le,selectionTargets:ve,dragging:V,onDragStart:be,onDragEnd:()=>be(null),onDropOn:(ee)=>{if(!V)return;Y.move(V,ee)},onUnfold:q,onFold:X,foldRoots:ge.roots,touch:xe},O.path))}),e(Mt,{}),_e&&e(At,{menu:te,menuRef:se,pasteLabel:pe,busy:Y.busy,create:Re,onAction:(O)=>{if(ne(null),O==="new_file")Re.openDialog("file");if(O==="new_folder")Re.openDialog("folder");if(O==="paste")Y.paste(ye)}}),_e&&e(Et,{archive:Ce})]})}export{ri as FileExplorer};
1
+ import{d,n,o,i,u,a,Dr,ze,ie,e,s,Kn,Q,dt,E,ce,Ro,ae,Ie,et,hi,bn,bi,ia,S,U,h,sr,k,yh,Te,hl,T,xr,wr,xt,nt,he,Bt,Sd,mt,ft,Dh,Nh,Mo,fs,Td,We,As}from"./index-8w69r0c4.js";import{yd,vd,di,kd,xd}from"./index-w39c85k3.js";import{Z}from"./index-8k568z0z.js";import{Tr}from"./index-gr5wd7hv.js";var Yt={name:"pen",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],aliases:["edit-2"]},Xe=s(Yt);var Jt={name:"copy-plus",size:24,node:[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]},qe=s(Jt);var Zt={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Be=s(Zt);var en={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]},Se=s(en);function Qe({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:x,onSearchChange:g,onRefresh:v,refreshing:b}){return e("div",{className:"border-b border-ink/10",children:[e(xt,{className:"border-b-0",left:e(Tr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(nt,{label:"Refresh",onClick:v,busy:b})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(U,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:x,onChange:(m)=>g(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})})]})}function Ye({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:x,folderStatus:g}){let v=f?"text-ink font-semibold":x?x.colorClass:g?g.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(E,{size:12,className:"flex-shrink-0 text-ink/40"}):e(ce,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(mt,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${v}`,title:p?`${r} — git-ignored`:void 0,children:t}),x&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${x.colorClass}`,title:`Git: ${x.label}`,children:x.charStatus}),g&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${g.dotClass}`,title:`${g.count} changed file${g.count>1?"s":""}`})]})}var tn=28,nn=9,rn=8;function on(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:x,selectionCount:g,isArchive:v}=t,b=[],m=g>1,C=g===1?"":` ${g} items`;if(m)return b.push({kind:"item",id:"cut",label:`Cut${C}`,icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"copy",label:`Copy${C}`,icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"separator"}),b.push({kind:"item",id:"compress",label:`Compress${C} to…`,icon:e(dt,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"separator"}),b.push({kind:"item",id:"delete",label:`Delete${C}`,icon:e(Q,{size:13,className:"text-error"}),tone:"text-error"}),b;if(r){if(b.push({kind:"item",id:"new_file",label:"New File",icon:e(hi,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(bn,{size:13,className:"text-ink/60"})}),f)b.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(E,{size:13,className:"text-ink/60"})});if(x)b.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(ce,{size:13,className:"text-ink/60"})});b.push({kind:"separator"})}else{if(b.push({kind:"item",id:"view",label:"View",icon:e(et,{size:13,className:"text-ink/60"})}),v)b.push({kind:"item",id:"extract",label:"Extract…",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p});if(l)b.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(bi,{size:13,className:"text-warning"}),tone:"font-medium"});b.push({kind:"separator"})}if(b.push({kind:"item",id:"cut",label:"Cut",icon:e(Se,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"copy",label:"Copy",icon:e(ae,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"compress",label:"Compress to…",icon:e(dt,{size:13,className:"text-ink/60"}),disabled:p}),b.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(qe,{size:13,className:"text-ink/60"}),disabled:p}),c)b.push({kind:"item",id:"paste",label:c,icon:e(Ro,{size:13,className:"text-ink/60"}),disabled:p});return b.push({kind:"separator"}),b.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Ie,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(ae,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(ae,{size:13,className:"text-ink/60"})}),b.push({kind:"separator"}),b.push({kind:"item",id:"history",label:"Show Git History",icon:e(Kn,{size:13,className:"text-ink/60"})}),b.push({kind:"separator"}),b.push({kind:"item",id:"rename",label:"Rename",icon:e(Xe,{size:13,className:"text-ink/60"})}),b.push({kind:"item",id:"delete",label:"Delete",icon:e(Q,{size:13,className:"text-error"}),tone:"text-error"}),b}function sn(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*tn+l*nn+rn}function Je({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:x,busy:g,selectionCount:v,isArchive:b,onAction:m,menuRef:C}){let N=on({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:g,chainLabel:f,foldable:x,selectionCount:v,isArchive:b}),A=sn(N),F=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-210-12)):t,M=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-A-12)):r;return ie(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(D)=>{D.preventDefault(),m("close")},children:e("div",{ref:C,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:M,left:F},onClick:(D)=>D.stopPropagation(),children:N.map((D,w)=>D.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${w}`):e("button",{type:"button",disabled:D.disabled,onClick:()=>m(D.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${D.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${D.tone??""}`,children:[D.icon,e("span",{children:D.label})]},D.id))})}),document.body)}function Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:x,onSubmit:g}){let v=r==="folder"?"Folder":"File";return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:g,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",v]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(b)=>f(b.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${v.toLowerCase()} name`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${c?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Nested paths create the folders they need — ",e("span",{className:"font-mono",children:"lib/parse.ts"}),"."]}),c&&e("p",{className:"text-[11px] text-error mb-2",children:c}),e("div",{className:"flex justify-end space-x-2 mt-2",children:[e("button",{type:"button",onClick:x,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function Ze({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:x}){let g=c>1;return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",g?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",g?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:x,className:"px-3 py-1.5 text-xs bg-error text-white rounded hover:bg-error/90 transition-colors flex items-center",disabled:p,children:p?"Deleting...":"Delete"})]})]})}),document.body)}function tt({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:x,onCancel:g,onSubmit:v}){return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(b)=>x(b.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:g,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function rt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Kn,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(h,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,x)=>e("tr",{className:"hover:bg-ink/[0.03] transition-colors group",children:[e("td",{className:"px-3 py-2 text-ink",children:f.message?e("span",{className:"font-medium text-ink/90 group-hover:text-ink",children:f.message}):null}),e("td",{className:"px-3 py-2 text-ink/60 whitespace-nowrap font-mono text-[10.5px]",children:f.time}),e("td",{className:"px-3 py-2 text-ink/70 whitespace-nowrap truncate max-w-[120px]",children:f.author}),e("td",{className:"px-3 py-2 text-right",children:f.hash?e("span",{className:"font-mono text-ink/50 group-hover:text-ink font-semibold transition-colors bg-canvas px-1.5 py-0.5 rounded border border-ink/10",children:f.hash}):null})]},x))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(S,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function ot({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(Ze,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(tt,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(rt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(t){let r=t.map(an);return r.some((l,c)=>l!==t[c])?r:t}function an(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Ee(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,x)=>[...p,...l.slice(0,x+1)].join("/"))}function it(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(x)=>x.flatMap((g)=>{if(g.type!=="folder")return[g];let v=Array.isArray(g.children)?p(g.children):g.children,b=v===g.children?g:{...g,children:v},m=r.has(g.path)?Me(g.path,g.name):null;if(!m)return[b];c=!0,l.set(m[0],g.path);let C={...b,name:m[m.length-1].split("/").pop()};for(let y=m.length-1;y>0;y-=1){let N=m[y-1];C={name:N.split("/").pop(),path:N,type:"folder",ignored:b.ignored,children:[C]}}return[C]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(x)=>{for(let g of x){if(g.type!=="folder")continue;if(l.add(g.path),Array.isArray(g.children))c(g.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let x=0;x<p.length;x+=1){let g=p.slice(0,x+1).join("/");if(l.has(g))f.push(g)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=ft(),[x,g]=n(!1),[v,b]=n("file"),[m,C]=n(""),[y,N]=n(null),A=i(null);return o(()=>{if(f.state!=="idle"||!f.data)return;let F=f.data;if(A.current===F)return;if(A.current=F,F.success&&F.path){let M=F.kind==="folder"?"folder":"file";g(!1),C(""),N(null);let D=F.path.split("/").pop()||F.path;if(c({path:F.path,name:D,kind:M}),M==="file")p?.({path:F.path,name:D})}else N(F.error||`Could not create the ${v}`)},[f.state,f.data]),{open:x,kind:v,name:m,setName:C,error:y,busy:f.state!=="idle",openDialog:(F="file")=>{b(F),C(""),N(null),g(!0)},closeDialog:()=>g(!1),submit:(F)=>{F.preventDefault();let M=m.trim();if(!M)return;N(null);let D=new FormData;if(D.append("actionType","create"),D.append("path",t),D.append("name",M),v==="folder")D.append("kind","folder");if(l&&l!==".")D.append("repo",l);if(r)D.append("root",r);f.submit(D,{method:"post",action:"/api/fs/action"})}}}function we(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function at(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function lt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function ct(t,r){if(t.path===""||t.path===".")return"The workspace root cannot be moved or copied";if(t.kind==="folder"&&(r===t.path||r.startsWith(`${t.path}/`)))return"Cannot paste a folder into itself";return null}function pt(t,r){let l=ct(t,r);if(l)return l;if(r===lt(t.path))return"Already in this folder";return null}function ut(t,r,l){if(!t||t.entries.length===0)return"Nothing to paste";if(t.scope!==r)return"The clipboard holds an entry from another workspace";if(t.mode==="cut"&&t.entries.some((c)=>l===lt(c.path)))return"Already in this folder";for(let c of t.entries){let p=ct(c,l);if(p)return p}return null}function ht(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.scope!=="string")return null;if(r.mode!=="copy"&&r.mode!=="cut")return null;let l=Array.isArray(r.entries)?r.entries:typeof r.path==="string"?[{path:r.path,name:r.name,kind:r.kind}]:[],c=[];for(let p of l){let f=ln(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function ln(t){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.path!=="string"||typeof r.name!=="string")return null;if(r.kind!=="file"&&r.kind!=="folder")return null;let l=r.path.split("/");if(r.path===""||r.path.startsWith("/")||l.some((c)=>c===""||c==="."||c===".."))return null;return{path:r.path,name:r.name,kind:r.kind}}var $e=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],gt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function Oe(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return Oe(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function vt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function yt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function kt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Ct(t){if(t.length===0)return".";let r=t.map((c)=>yt(c).split("/").filter((p)=>p!==".")),l=r[0]??[];for(let c of r.slice(1)){let p=0;while(p<l.length&&p<c.length&&l[p]===c[p])p+=1;l=l.slice(0,p)}return l.length===0?".":l.join("/")}function De(t,r){let l=dn(r);if(t.length===1){let f=t[0],x=vt(f.name),g=x.lastIndexOf(".");return`${(f.kind==="folder"?f.name:g>0?x.slice(0,g):x)||"archive"}.${l}`}let c=Ct(t.map((f)=>f.path)),p=kt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ft(t){return Ct(t.map((r)=>r.path))}function Nt(t){let r=yt(t),l=vt(kt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function wt(t){return t.toUpperCase()}function Dt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:x,onFold:g,clipboard:v,isFolder:b,selection:m,selected:C,archive:y}){let N=ft(),[A,F]=n(null),M=i(null),[D,w]=n(!1),[R,I]=n(!1),[_,te]=n(!1),[ne,se]=n(t.path),[H,P]=n(null),{repo:z,rootPath:G}=t,K=Ne({folderPath:t.path,rootPath:G,repo:z,onCreated:(L)=>p?p(L):c(),onOpenCreated:(L)=>l?.({...L,root:G,repo:z||"."})}),re=i(null);o(()=>{if(N.state!=="idle"||!N.data)return;let L=N.data;if(re.current===L)return;if(re.current=L,L.success&&!L.type)if(w(!1),I(!1),P(null),L.previousPath&&L.path&&f)f(L.previousPath,L.path);else c();else if(!L.success&&L.error&&D)P(L.error)},[N.state,N.data]);let q=(L)=>{if(z&&z!==".")L.append("repo",z);if(G)L.append("root",G);N.submit(L,{method:"post",action:"/api/fs/action"})},X=()=>{l?.({path:t.path,name:t.name,root:G,repo:z||"."})},J={path:t.path,name:t.name,kind:b?"folder":"file"},oe=C&&m.length>1?m:[J],ge=bt(t.name),B=v.clip&&!v.refusalFor(J)?`Paste ${we(v.clip)??"item"}`:null,fe=(L)=>{if(F(null),P(null),L==="view")X();else if(L==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:G}}));else if(L==="explorer"){let j=new FormData;j.append("actionType","open_explorer"),j.append("path",t.path),q(j)}else if(L==="copy_path")Bt(Sd(t.basePath,t.path));else if(L==="copy_relative")Bt(t.path);else if(L==="history"){te(!0);let j=new FormData;j.append("actionType","git_history"),j.append("path",t.path),q(j)}else if(L==="rename")se(t.path),w(!0);else if(L==="unfold")x?.();else if(L==="fold")g?.();else if(L==="new_file")K.openDialog("file");else if(L==="new_folder")K.openDialog("folder");else if(L==="delete")I(!0);else if(L==="cut")v.cut(oe);else if(L==="copy")v.copy(oe);else if(L==="compress")y.openCompress(oe);else if(L==="extract")y.openExtract(J);else if(L==="duplicate")v.duplicate(J);else if(L==="paste")v.paste(J)},le=(L)=>{L.preventDefault(),P(null);let j=new FormData;j.append("actionType","rename"),j.append("path",t.path),j.append("newPath",ne),q(j)},ve=()=>{let L=new FormData;if(L.append("actionType","delete"),oe.length>1)L.append("paths",JSON.stringify(oe.map((j)=>j.path)));else L.append("path",t.path);q(L)};return{contextMenu:A,contextMenuRef:M,openContextMenu:(L,j)=>F({x:L,y:j}),closeContextMenu:()=>F(null),showRenameModal:D,showDeleteModal:R,showHistoryModal:_,showCreateModal:K.open,createKind:K.kind,createError:K.error,createName:K.name,setCreateName:K.setName,renameValue:ne,setRenameValue:se,renameError:H,busy:N.state!=="idle"||K.busy||v.busy||y.busy,pasteLabel:B,selectionCount:oe.length,isArchive:ge,chainLabel:x!==void 0,foldable:g!==void 0,fetcherState:N.state,fetcherData:N.data,handleAction:fe,submitCreate:K.submit,submitRename:le,submitDelete:ve,closeCreate:K.closeDialog,closeDelete:()=>I(!1),closeRename:()=>w(!1),closeHistory:()=>te(!1)}}function Rt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:x}){let g=r?.path===t.path,v=Boolean(r)&&!g&&l.moveRefusalFor(r,t)===null,[b,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:g,acceptsDrop:v,isDropHovered:b&&v,onDragStart:(y)=>{if(y.dataTransfer?.setData("text/plain",t.path),y.dataTransfer)y.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(y)=>{if(!r)return;if(y.stopPropagation(),m(v),!v)return;if(y.preventDefault(),y.dataTransfer)y.dataTransfer.dropEffect="move";x?.(t)},onDragLeave:()=>m(!1),onDrop:(y)=>{if(!r)return;if(y.stopPropagation(),!v)return;y.preventDefault(),f(t)}}}function pn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Pe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,expandedPaths:b,onToggleFolder:m,gitFileMap:C,gitFolderMap:y,clipboard:N,archive:A,selection:F,selectionTargets:M,dragging:D,onDragStart:w,onDragEnd:R,onDropOn:I,onUnfold:_,onFold:te,foldRoots:ne,touch:se=!1}){let H=t.type==="folder",[P,z]=n(!1),[G,K]=n(!1),[re,q]=n(!1),[X,J]=n(!1),oe=Array.isArray(t.children)?t.children:[],ge=(t.path||"").replace(/^\/+/,""),B=!H?C?.get(ge)||C?.get(t.path):void 0,fe=B?sr(B.status,B.staged):null,le=H?y?.get(ge)||y?.get(t.path):null,ve=Boolean(fe),L=t.ignored===!0,j=b?b.has(t.path):P,de=t.forceExpanded!==void 0?t.forceExpanded:j;o(()=>{J(!0)},[]),o(()=>{if(H&&b)z(b.has(t.path))},[b,t.path,H]),o(()=>{if(H&&de&&pn(t,G,re)&&p)q(!0),K(!0),Promise.resolve(p(t.path)).finally(()=>K(!1))},[H,de,t.children,t.path,p,G,re]);let ke={path:t.path,name:t.name,kind:H?"folder":"file"},xe=F.selected.has(t.path),W=Dt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:M,selected:xe,archive:A,diff:{staged:B?.staged||(B?.status?B.status[0]!==" "&&B.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,onUnfold:_&&Ee({type:H?"folder":"file",name:t.name})?()=>_(ke):void 0,onFold:te&&ne?.has(t.path)?()=>te(ne.get(t.path)):void 0,clipboard:N,isFolder:H});he(W.contextMenuRef,W.closeContextMenu);let Y=yd({enabled:se,onLongPress:(V,be)=>W.openContextMenu(V,be)}),Ce=(V)=>{if(V.stopPropagation(),Y.consume())return;let be=F.gestureOf(V);if(be!=="plain"){F.applyGesture(be,t.path);return}if(F.applyGesture("plain",t.path),H){let ue=!de;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ye=(V)=>{V.preventDefault(),V.stopPropagation(),F.ensureForContext(t.path),W.openContextMenu(V.clientX,V.clientY)},pe=Rt({target:ke,dragging:D,clipboard:N,onDragStart:w,onDragEnd:R,onDropOn:I,onHoverAccept:_});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${pe.isDragging?"opacity-40":""} ${pe.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":xe?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!se,onClick:Ce,onContextMenu:ye,onDragStart:pe.onDragStart,onDragEnd:pe.onDragEnd,onDragOver:pe.onDragOver,onDragLeave:pe.onDragLeave,onDrop:pe.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Ye,{name:t.name,path:t.path,isFolder:H,isOpen:de,ignored:L,selected:xe,gitStatus:fe,folderStatus:le})}),de&&G&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),de&&!G&&oe.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:oe.map((V)=>e(Pe,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:x,onCreated:g,onRenamed:v,expandedPaths:b,onToggleFolder:m,gitFileMap:C,gitFolderMap:y,clipboard:N,archive:A,selection:F,selectionTargets:M,dragging:D,onDragStart:w,onDragEnd:R,onDropOn:I,onUnfold:_,onFold:te,foldRoots:ne,touch:se},V.path))}),X&&W.contextMenu&&e(Je,{x:W.contextMenu.x,y:W.contextMenu.y,isFolder:H,hasGitStatus:ve,pasteLabel:W.pasteLabel,chainLabel:W.chainLabel,foldable:W.foldable,busy:W.busy,selectionCount:W.selectionCount,isArchive:W.isArchive,onAction:W.handleAction}),X&&e(ot,{actions:W,file:t,isFolder:H,chainLabel:Ee({type:H?"folder":"file",name:t.name})?t.name:void 0})]})}function St({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let g=l?104:76,v=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,b=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-g-12)):r;return ie(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:b,left:v},onClick:(m)=>m.stopPropagation(),children:[e("button",{type:"button",onClick:()=>p("new_file"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(hi,{size:13,className:"text-ink/60"}),e("span",{children:"New File"})]}),e("button",{type:"button",onClick:()=>p("new_folder"),className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center space-x-2 transition-colors",children:[e(bn,{size:13,className:"text-ink/60"}),e("span",{children:"New Folder"})]}),l&&e("button",{type:"button",disabled:c,onClick:()=>p("paste"),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${c?"opacity-40 cursor-default":"hover:bg-ink/5"}`,children:[e(Ro,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function At({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(St,{x:t.x,y:t.y,menuRef:r,pasteLabel:l,busy:c,onAction:p}),f.open&&e(Fe,{folderPath:".",kind:f.kind,value:f.name,error:f.error,isLoading:f.busy,onChange:f.setName,onCancel:f.closeDialog,onSubmit:f.submit})]})}function Tt({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:x,onCancel:g,children:v}){return ie(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center modal-safe backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),v,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:g,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function un({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:x,onFormatChange:g,onNameChange:v,onDestinationChange:b,onCancel:m,onSubmit:C}){let y=t.slice(0,4).map((A)=>A.name).join(", "),N=t.length>4?` +${t.length-4} more`:"";return e(Tt,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${y}${N}`,error:f,busy:x,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(A)=>{A.preventDefault(),C()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",children:"Format"}),e(Z,{ariaLabel:"Format",value:r,onChange:(A)=>g(A),placeholder:"Format",searchable:!1,allowEmpty:!1,className:"mb-3 text-xs",options:p.map((A)=>({value:A.id,label:A.available?A.label:`${A.label} — ${A.tool} not installed`,disabled:!A.available}))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(A)=>v(A.currentTarget.value),"aria-label":"Archive name",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-3 ${f?"border-error":"border-ink/20 focus:border-ink"}`}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-destination",children:"Destination folder"}),e("input",{id:"archive-destination",type:"text",value:c,onChange:(A)=>b(A.currentTarget.value),"aria-label":"Archive destination",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink"})]})}function fn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:x,onSubmit:g}){return e(Tt,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:x,onSubmit:(v)=>{v.preventDefault(),g()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"extract-destination",children:"Extract to folder"}),e("input",{id:"extract-destination",autoFocus:!0,type:"text",value:l,onChange:(v)=>f(v.currentTarget.value),"aria-label":"Extract destination",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none ${c?"border-error":"border-ink/20 focus:border-ink"}`})]})}function Et({archive:t}){if(t.compress)return e(un,{entries:t.compress.entries,format:t.compress.format,name:t.compress.name,destination:t.compress.destination,formats:t.formats,error:t.error,busy:t.busy,onFormatChange:t.setFormat,onNameChange:t.setName,onDestinationChange:t.setCompressDestination,onCancel:t.cancel,onSubmit:t.submitCompress});if(t.extract)return e(fn,{archive:t.extract.archive,kindLabel:wt(Oe(t.extract.archive.name)??"zip"),destination:t.extract.destination,error:t.error,busy:t.busy,onDestinationChange:t.setExtractDestination,onCancel:t.cancel,onSubmit:t.submitExtract});return null}function Mt(){let[t,r]=T("files.outlineExpanded",!1),l=Dr(),c=ze(Nh,Dh),{symbols:p,total:f,truncated:x,notice:g}=xd({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let v=c.preview,b=(m,C)=>{if(!c.path)return;if(v){let y=Td(p,C);if(y)fs({path:c.path,...y});return}Mo({path:c.path,line:m.line,column:m.column,length:m.name.length})};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:e("button",{type:"button",onClick:()=>r(!t),"aria-expanded":t,"aria-controls":l,"aria-label":"Outline",title:t?"Hide outline":"Show outline",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:t?"▾":"▸"}),e(ia,{size:12}),e("span",{children:"Outline"}),f>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:x?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:g}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,C)=>e("button",{type:"button",onClick:()=>b(m,C),"aria-label":v?`${di(m.kind)} ${m.name}`:`${di(m.kind)} ${m.name}, line ${m.line}`,title:v?`Jump to ${di(m.kind).toLowerCase()}`:`${di(m.kind)} · line ${m.line}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors hover:bg-ink/5 active:bg-ink/10",style:{paddingLeft:`${4+m.depth*12}px`},children:[e(vd,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!v&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),x&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:kd(f)})]})})})})]})}function He(t,r){return Ae(t.map((l)=>mn(l,r)))}function mn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:He(l,r)}}function hn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function $t(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Lt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ge(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],x={...r},g=f,v=null;for(let b=0;b<c.length-1;){let m=c.slice(0,b+1).join("/"),C=g.find((M)=>M.type==="folder"&&M.path===m),y=C?null:g.find((M)=>M.type==="folder"&&M.path.startsWith(`${m}/`)&&(p===M.path||p.startsWith(`${M.path}/`))),N=C??y,A=N?x[N.path]??N.children:null;if(N&&!Array.isArray(A))return{nodes:t,cache:r};if(!N){let M=gn(g,x,m);if(M){g=M;let D=g.find((R)=>R.path===m),w=Array.isArray(D?.children)?[...D.children]:[];x[m]=w,g=w,v=m,b+=1;continue}}let F=Array.isArray(A)?[...A]:[];if(N){x[N.path]=F,g=F,v=N.path,b=N.path.split("/").length;continue}g.push({name:c[b],path:m,type:"folder",ignored:!1}),x[m]=F,g=F,v=m,b+=1}if(g.push(l),v!==null)x[v]=Lt(g);return f=Lt(f),{nodes:f,cache:x}}function gn(t,r,l){let c=t.findIndex((v)=>v.type==="folder"&&v.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),x=r[p.path]??p.children;if(Array.isArray(x))r[p.path]=x;let g={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(x)?{children:x}:{}};for(let v=f.length-2;v>=0;v-=1)g={name:f[v],path:`${l}/${f.slice(0,v+1).join("/")}`,type:"folder",ignored:!1,children:[g]};return t[c]={name:$t(l),path:l,type:"folder",ignored:!1,children:[g]},t}function zt(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=hn(l),f=r[p],x=f?.find((m)=>m.path===l);if(f&&x)return{entry:x,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let v=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((C)=>C.path===l)).sort((m,C)=>C.length-m.length)[0];if(!v)return{entry:null,nodes:t,cache:r};let b=r[v];return{entry:b.find((m)=>m.path===l),nodes:t,cache:{...r,[v]:b.filter((m)=>m.path!==l)}}}function Ot(t,r,l){let c=!1,p=t.map((f)=>{let x=f.path===r||f.path.startsWith(`${r}/`),g=Array.isArray(f.children)?Ot(f.children,r,l):void 0;if(!x&&g===f.children)return f;c=!0;let v=x?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,b=x?{...f,path:v,name:$t(v)}:{...f};if(g!==void 0)b.children=g;return b});return c?p:t}function Pt(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let x=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[x]=x===p?f:Ot(f,r,l)}return c}function It(t,r,l){let c=new Set;for(let p of t)if(p===r)c.add(l);else if(p.startsWith(`${r}/`))c.add(`${l}${p.slice(r.length)}`);else c.add(p);return c}function Ht(t){if(!k(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>k(r)):[],root:t.root}}async function Ke(t){try{return Ht(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Gt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[x,g]=n({scope:"",files:[],root:""}),[v,b]=n(!1),m=i({}),C=i([]),y=i(f);y.current=f;let N=i(""),A=i(""),F=i(c);F.current=c;let M=(P)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(P)z.set("path",P);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},D=(P,z)=>{N.current=P,A.current=z;let G=He(C.current,m.current);return g({scope:P,files:G,root:z}),G},w=async(P)=>{let z=[...F.current];if(z.length===0)return;let G=await Promise.all(z.map(async(X)=>({path:X,read:await Ke(M(X))})));if(y.current!==P)return;let K=[];for(let{path:X,read:J}of G)if(J.status==="ok")m.current[X]=J.files;else if(J.status==="missing")K.push(X);if(K.length===0)return;let re=new Set(K);for(let X of K)delete m.current[X];let q=new Set([...F.current].filter((X)=>!re.has(X)));F.current=q,p(q)},R=async()=>{if(!t)return;let P=y.current;b(!0);try{let z=await Ke(M());if(y.current!==P)return;if(z.status!=="ok")return;if(N.current!==P)m.current={};if(C.current=z.files,D(P,z.root),await w(P),y.current!==P)return;D(P,z.root)}finally{if(y.current===P)b(!1)}},I=async(P)=>{let z=y.current,G=await Ke(M(P));if(y.current!==z||G.status!=="ok")return;if(m.current[P]=G.files,N.current===z)D(z,A.current)},_=(P)=>{let z=Ht(P);if(z.status!=="ok")return;let G=y.current;if(N.current!==G)m.current={};C.current=z.files,D(G,z.root),w(G).then(()=>{if(y.current===G)D(G,z.root)})},te=()=>{m.current={},C.current=[],N.current="",A.current="",g({scope:"",files:[],root:""})},ne=(P)=>{let z=y.current;if(N.current!==z)return null;let G={name:P.path.slice(P.path.lastIndexOf("/")+1),path:P.path,type:P.kind,ignored:!1},K=Ge(C.current,m.current,G);if(K.nodes===C.current)return null;return C.current=K.nodes,m.current=K.cache,D(z,A.current)},se=(P,z)=>{let G=y.current;if(N.current!==G)return null;let K=zt(C.current,m.current,P);if(!K.entry)return null;m.current=Pt(K.cache,P,z);let re={...K.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Ge(K.nodes,m.current,re);return C.current=q.nodes,m.current=q.cache,D(G,A.current)},H=x.scope===f;return{scope:f,files:H?x.files:[],root:H?x.root:"",isLoading:v,reload:R,loadChildren:I,adoptRoot:_,insertEntry:ne,moveEntry:se,reset:te}}function Kt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=ft(),[f,x]=T("files.clipboard",null),g=ht(f),v=at(t,r),b=i(!1),m=i(null);o(()=>{if(p.state!=="idle"||!p.data)return;let F=p.data;if(m.current===F)return;m.current=F;let M=b.current;if(b.current=!1,F.success){if(M)x(null);if(F.failures?.length)c(`${F.failures.length} item(s) could not be moved: ${F.failures[0].error}`);l()}else c(F.error||"The transfer did not complete")},[p.state,p.data]);let C=a((F,M)=>{b.current=M;let D=new FormData;for(let[w,R]of Object.entries(F))D.append(w,R);if(r&&r!==".")D.append("repo",r);if(t)D.append("root",t);p.submit(D,{method:"post",action:"/api/fs/action"})},[p,r,t]),y=a((F)=>ut(g,v,Le(F.path,F.kind)),[g,v]),N=a((F,M)=>pt(F,Le(M.path,M.kind)),[]),A=a((F,M,D,w)=>{let R=new FormData;R.append("actionType","paste"),R.append("mode",D),R.append("targetPath",M.path),R.append("targetKind",M.kind);for(let I of F)R.append("sourcePath",I.path);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);b.current=w,p.submit(R,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:g,busy:p.state!=="idle",refusalFor:y,moveRefusalFor:N,copy:(F)=>{if(F.length===0)return;x({scope:v,entries:F.map(({path:M,name:D,kind:w})=>({path:M,name:D,kind:w})),mode:"copy"})},cut:(F)=>{if(F.length===0)return;x({scope:v,entries:F.map(({path:M,name:D,kind:w})=>({path:M,name:D,kind:w})),mode:"cut"})},duplicate:(F)=>{C({actionType:"duplicate",path:F.path},!1)},move:(F,M)=>{let D=N(F,M);if(D){c(D);return}A([F],M,"cut",Boolean(g?.mode==="cut"&&g.entries.some((w)=>w.path===F.path)))},paste:(F)=>{if(!g)return;let M=y(F);if(M){c(M);return}A(g.entries.map(({path:D,name:w,kind:R})=>({path:D,name:w,kind:R})),F,g.mode,g.mode==="cut")}}}var xn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=ft(),[p,f]=n(xn),[x,g]=n(null),[v,b]=n(null),[m,C]=n(null),y=i(null),N=i(null);o(()=>{let w=!1;return(async()=>{try{let I=await(await fetch("/api/fs/archive")).json();if(!w&&Array.isArray(I.formats)&&I.formats.length>0)f(I.formats)}catch{}})(),()=>{w=!0}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let w=c.data;if(N.current===w)return;N.current=w;let R=y.current;if(y.current=null,w.success){if(C(null),R==="compress")g(null);if(R==="extract")b(null);l()}else if(R)C(w.error||"The archive request failed")},[c.state,c.data]);let A=a((w)=>{let R=new FormData;for(let[I,_]of Object.entries(w))R.append(I,_);if(r&&r!==".")R.append("repo",r);if(t)R.append("root",t);c.submit(R,{method:"post",action:"/api/fs/action"})},[c,r,t]),F=a((w)=>{if(w.length===0)return;let R=p.find((I)=>I.id==="zip"&&I.available)?.id??p.find((I)=>I.available)?.id??"zip";C(null),b(null),g({entries:w.map(({path:I,name:_,kind:te})=>({path:I,name:_,kind:te})),format:R,name:De(w,R),destination:Ft(w)})},[p]),M=a((w)=>{C(null),g(null),b({archive:w,destination:Nt(w.path)})},[]),D=a((w)=>{g((R)=>{if(!R)return R;let I=De(R.entries,R.format),_=R.name===I?De(R.entries,w):R.name;return{...R,format:w,name:_}})},[]);return{formats:p,compress:x,extract:v,error:m,busy:c.state!=="idle",openCompress:F,openExtract:M,setFormat:D,setName:(w)=>g((R)=>R&&{...R,name:w}),setCompressDestination:(w)=>g((R)=>R&&{...R,destination:w}),setExtractDestination:(w)=>b((R)=>R&&{...R,destination:w}),cancel:()=>{g(null),b(null),C(null)},submitCompress:()=>{let w=x;if(!w)return;y.current="compress",C(null),A({actionType:"compress",format:w.format,name:w.name.trim(),destination:w.destination.trim()||".",paths:JSON.stringify(w.entries.map((R)=>R.path))})},submitExtract:()=>{let w=v;if(!w)return;y.current="extract",C(null),A({actionType:"extract",path:w.archive.path,destination:w.destination.trim()||"."})}}}function vn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function yn(t,r,l){if(!r)return[l];let c=t.indexOf(r),p=t.indexOf(l);if(c===-1||p===-1)return[l];let f=Math.min(c,p),x=Math.max(c,p);return t.slice(f,x+1)}function _t(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((b,m)=>{if(b==="range"){l(new Set(yn(t,c,m)));return}if(p(m),b==="toggle"){l((C)=>{let y=new Set(C);if(y.has(m))y.delete(m);else y.add(m);return y});return}l(new Set([m]))},[c,t]),x=a((b)=>{l((m)=>{if(m.has(b))return m;return new Set([b])}),p(b)},[]),g=a(()=>{l(new Set),p(null)},[]),v=a(vn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:v,applyGesture:f,ensureForContext:x,clear:g}),[r,c,v,f,x,g])}function je(t,r,l=0,c=[]){for(let p of t)if(c.push({path:p.path,name:p.name,kind:p.type==="folder"?"folder":"file",depth:l}),p.type==="folder"&&r(p)&&Array.isArray(p.children))je(p.children,r,l+1,c);return c}function Wt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((v,b)=>{let m=st(b,v);if(m.length===0)return;r((C)=>{if(m.every((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.add(N);return l(Array.from(y)),y})},[r,l]),x=a((v)=>{let b=t.insertEntry(v);if(!b){c();return}f(v.path,b)},[t,c,f]),g=a((v,b)=>{p?.(v,b),r((C)=>{let y=It(C,v,b);return l(Array.from(y)),y});let m=t.moveEntry(v,b);if(!m){c();return}f(b,m)},[t,c,f,r,l,p]);return{insertCreated:x,moveRenamed:g}}var kn=new Set;function Ut({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((v)=>{let b=Me(v.path,v.name);if(!b)return;p((C)=>{let y=C.scope===t?C.chains:new Map;if(y.get(v.path)?.length===b.length)return C;let A=new Map(y);return A.set(v.path,b),{scope:t,chains:A}});let m=b.slice(0,-1);r((C)=>{if(m.every((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.add(N);return l(Array.from(y)),y})},[t,r,l]),x=a((v)=>{let b=c.scope===t?c.chains.get(v):void 0;if(!b)return;let m=b.slice(0,-1);p((C)=>{if(C.scope!==t)return C;let y=new Map(C.chains);return y.delete(v),{scope:t,chains:y}}),r((C)=>{if(!m.some((N)=>C.has(N)))return C;let y=new Set(C);for(let N of m)y.delete(N);return l(Array.from(y)),y})},[t,c,r,l]),g=a((v,b)=>{let m=c.scope===t?c.chains:null;if(!m)return;let C=new Map,y=[],N=!1;for(let[A,F]of m){if(F.findIndex((R,I)=>R===v&&I>0&&I<F.length-1)!==-1){N=!0;continue}let D=F.map((R)=>R===v?b:R.startsWith(`${v}/`)?`${b}${R.slice(v.length)}`:R),w=D[D.length-1];if(w!==A||D.some((R,I)=>R!==F[I]))N=!0;C.set(w,D),y.push(...D.slice(0,-1))}if(!N)return;p({scope:t,chains:C}),r((A)=>{if(y.every((M)=>A.has(M)))return A;let F=new Set(A);for(let M of y)F.add(M);return l(Array.from(F)),F})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):kn,unfold:f,fold:x,rekey:g}}function Vt(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let x=(p.children||[]).map(c).filter((g)=>g!==null);if(f||x.length>0)return{...p,children:f&&x.length===0?p.children:x,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Xt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return o(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(x)=>{if(!x.currentTarget.contains(x.relatedTarget))f(!1)},onDragOver:(x)=>{if(!c)return;if(x.preventDefault(),x.dataTransfer)x.dataTransfer.dropEffect="move"},onDrop:(x)=>{if(!c)return;x.preventDefault(),f(!1),r.move(t,l)}}}function ri({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:x}){let[g,v]=T("files.searchQuery",""),[b,m,C]=T("files.expandedPaths",[]),[y,N]=n(()=>new Set(b)),{activeRepo:A,setActiveRepo:F}=xr(c),{repos:M,scanning:D,rescan:w}=wr(c,r),{fileMap:R,folderMap:I,refreshGitStatus:_}=hl(c,A,r),[te,ne]=n(null),se=i(null);o(()=>{if(!C)return;N((O)=>{let ee=new Set(b);if(O.size===ee.size&&Array.from(ee).every((me)=>O.has(me)))return O;return ee})},[C,b]);let H=Gt({enabled:r,rootPath:c,activeRepo:A,expandedPaths:y,onExpansionPruned:(O)=>{N(O),m(Array.from(O))}});o(()=>{if(!C||!l)return;H.reload()},[f,c,r,A,C,l]);let P=r&&C?yh(H.scope):null,z=Te(P);o(()=>{if(z.data)H.adoptRoot(z.data)},[z.data]);let G=(O)=>(_(),H.loadChildren(O)),K=(O,ee)=>{let me=new Set(y);if(ee)me.add(O);else me.delete(O);N(me),m(Array.from(me))},{unfolded:re,unfold:q,fold:X,rekey:J}=Ut({scope:H.scope,setExpandedPaths:N,setStoredExpandedPaths:m}),oe=H.files,ge=it(oe,re),B=Vt(ge.nodes,g),fe=je(B,(O)=>O.forceExpanded!==void 0?O.forceExpanded:y.has(O.path)),le=_t(fe.map((O)=>O.path)),ve=fe.filter((O)=>le.selected.has(O.path)).map(({path:O,name:ee,kind:me})=>({path:O,name:ee,kind:me})),L=(O)=>{if(O===A)return;H.reset(),N(new Set),m([]),le.clear(),F(O)},j=()=>{if(_(),x)x();else H.reload()},{insertCreated:de,moveRenamed:ke}=Wt({listing:H,setExpandedPaths:N,setStoredExpandedPaths:m,reload:j,onMoved:(O,ee)=>J(O,ee)}),xe=As(),{pushToast:W}=We(),Y=Kt({rootPath:c,repo:A,onComplete:j,onError:(O)=>W(O,"error")}),Ce=jt({rootPath:c,repo:A,onComplete:j}),ye={path:".",name:".",kind:"folder"},pe=Y.clip&&!Y.refusalFor(ye)?`Paste ${we(Y.clip)??"item"}`:null,[V,be]=n(null),ue=Xt({dragging:V,clipboard:Y,target:ye}),Re=Ne({folderPath:".",rootPath:c,repo:A,onCreated:de,onOpenCreated:(O)=>p?.({...O,root:c,repo:A})}),[_e,qt]=n(!1);o(()=>qt(!0),[]);let{count:Ue,clear:Ve}=le;if(o(()=>{if(!l)return;let O=(ee)=>{if(ee.key==="Escape"&&Ue>0)Ve()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[l,Ue,Ve]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let Qt=H.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Qe,{rootPath:c,activeRepo:A,repos:M,reposScanning:D,onRefreshRepos:w,onSelectRepo:L,searchQuery:g,onSearchChange:v,onRefresh:j,refreshing:Qt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${xe?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(O)=>{O.preventDefault(),ne({x:O.clientX,y:O.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:H.isLoading&&B.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):B.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):B.map((O)=>e(Pe,{file:O,rootPath:c,basePath:H.root,repo:A,onLoadChildren:G,onOpenFile:p,onActionComplete:j,onCreated:de,onRenamed:ke,expandedPaths:y,onToggleFolder:K,gitFileMap:R,gitFolderMap:I,clipboard:Y,archive:Ce,selection:le,selectionTargets:ve,dragging:V,onDragStart:be,onDragEnd:()=>be(null),onDropOn:(ee)=>{if(!V)return;Y.move(V,ee)},onUnfold:q,onFold:X,foldRoots:ge.roots,touch:xe},O.path))}),e(Mt,{}),_e&&e(At,{menu:te,menuRef:se,pasteLabel:pe,busy:Y.busy,create:Re,onAction:(O)=>{if(ne(null),O==="new_file")Re.openDialog("file");if(O==="new_folder")Re.openDialog("folder");if(O==="paste")Y.paste(ye)}}),_e&&e(Et,{archive:Ce})]})}export{ri as FileExplorer};
@@ -1 +1 @@
1
- import{d,u,ue,e,B,E,ce,Lr,hh,Te,vl,xt,Xg,nt,Qd,Vm,Xh,Ym,Jm}from"./index-dzp9rwy0.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(ce,{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]=ue(),i=f.get("sessionId"),[m,x]=vl("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,ue,e,B,E,ce,Lr,hh,Te,yl,xt,Xg,nt,Qd,Vm,Xh,Ym,Jm}from"./index-8w69r0c4.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(ce,{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]=ue(),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,u,ue,e,B,p,dn,Pe,U,bh,Te,vl,xt,so,nt,J}from"./index-dzp9rwy0.js";function F(a){if(!Number.isFinite(a)||a<=0)return"";return new Date(a).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}function P({files:a,selected:h,onSelect:b}){let[i,l]=n(""),r=u(()=>{let t=i.trim().toLowerCase();if(!t)return a;return a.filter((c)=>c.title.toLowerCase().includes(t))},[a,i]);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-canvas/40",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2 py-1.5",children:[e(U,{size:12,className:"flex-shrink-0 text-ink/40"}),e("input",{type:"search",value:i,onChange:(t)=>l(t.target.value),placeholder:"Filter plans…","aria-label":"Filter plans",className:"min-w-0 flex-1 bg-transparent text-[11px] text-ink outline-none placeholder:text-ink/35"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:r.length===0?e("p",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:a.length===0?"No plan yet":"No plan matches the filter"}):e("ul",{className:"py-1",children:r.map((t)=>{let c=t.path===h,m=F(t.modifiedAt);return e("li",{children:e("button",{type:"button",onClick:()=>b(t.path),"aria-current":c?"true":void 0,title:`${t.path}${m?` · ${m}`:""}`,className:`flex w-full items-start gap-1.5 px-2.5 py-1.5 text-left transition-colors ${c?"bg-ink/10 font-semibold text-ink":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e(Pe,{size:12,className:`mt-0.5 flex-shrink-0 ${c?"text-ink":"text-ink/40"}`}),e("span",{className:"min-w-0 flex-1",children:[e("span",{className:"block truncate text-[11.5px]",children:t.title}),m&&e("span",{className:"block truncate font-mono text-[10px] text-ink/40",children:m})]})]})},t.path)})})})]})}function y({file:a,content:h,isLoading:b,error:i,truncated:l,onBack:r}){return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-paper",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2.5 py-1.5",children:[e("button",{type:"button",onClick:r,title:"Back to the plan list","aria-label":"Back to the plan list",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink @[520px]:hidden",children:e(dn,{size:13})}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] text-ink/50",title:a?.path??"",children:a?.path??"Plan"}),b&&e(p,{size:12,className:"flex-shrink-0 animate-spin text-ink/40"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:i?e("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[e(B,{size:16,className:"text-error"}),e("p",{className:"text-xs text-error",children:i})]}):!h?e("div",{className:"px-6 py-8 text-center text-xs text-ink/40",children:b?"Reading the plan…":"This plan is empty."}):e("article",{className:"mx-auto max-w-4xl px-5 py-4",children:[e(J,{content:h,className:"max-w-none"}),l&&e("p",{className:"mt-4 border-t border-ink/10 pt-2 text-[11px] text-ink/50",children:"This plan is longer than the reader's budget and was cut off."})]})})]})}function X({className:a="",active:h=!0,tabsMode:b=!1}){let[i]=ue(),l=i.get("sessionId"),[r,t]=vl("plan.selectedFile",null),[c,m]=n(!1),k=r&&r.sessionId===l?r.path:null,s=Te(l?bh(l):null,{enabled:h}),x=s.data?.files??[],v=s.data?.current??null,f=u(()=>{if(k&&x.some((g)=>g.path===k))return k;return v},[k,x,v]),w=u(()=>x.find((g)=>g.path===f)??null,[x,f]);o(()=>{if(!l||!f||f===k)return;t({sessionId:l,path:f})},[l,f,k,t]),o(()=>{m(!1)},[l]);let S=(g)=>{if(l)t({sessionId:l,path:g});m(!0)};if(!l)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${a}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let N=x.length>0;return e("div",{className:`@container flex h-full min-h-0 w-full flex-col bg-paper text-xs text-ink ${a}`,children:[e(xt,{left:e(d,{children:[e(Pe,{size:12,className:"flex-shrink-0 text-ink/50"}),e(so,{id:"plan",tabsMode:b,children:e("span",{className:"truncate text-[11px] font-medium text-ink/70",children:"Plan mode"})}),N&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] text-ink/60",children:x.length})]}),right:e(nt,{label:"Re-read the plan",onClick:s.refresh,busy:s.isLoading||s.refreshing,disabled:s.isLoading})}),s.stale&&!s.data?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(B,{size:16,className:"text-error"}),e("p",{className:"text-error",children:"The plan could not be read."}),e("button",{type:"button",onClick:s.refresh,className:"text-[11px] font-semibold text-ink/70 underline underline-offset-2 hover:text-ink",children:"Try again"})]}):!s.data?e("div",{className:"flex flex-1 items-center justify-center gap-2 text-ink/40",children:[e(p,{size:14,className:"animate-spin"}),e("span",{children:"Reading the plan…"})]}):!N?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(Pe,{size:18,className:"text-ink/30"}),e("p",{className:"max-w-sm text-[11px] leading-relaxed text-ink/60",children:"No plan yet. Turn on Plan mode in the composer, and the plan this session writes will appear here."})]}):e("div",{className:"flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse",children:[e("div",{className:`min-h-0 w-full @[520px]:w-52 @[520px]:flex-shrink-0 border-b border-ink/10 @[520px]:border-b-0 @[520px]:border-l ${c?"hidden @[520px]:flex":"flex"} flex-col`,children:e(P,{files:x,selected:f,onSelect:S})}),e("div",{className:`min-w-0 min-h-0 flex-1 ${c?"flex":"hidden @[520px]:flex"} flex-col`,children:e(y,{file:w,content:s.data.content,isLoading:s.isLoading,error:s.stale?"The plan could not be read.":null,truncated:s.data.truncated,onBack:()=>m(!1)})})]})]})}export{X as PlanPanel};
1
+ import{d,n,o,u,ue,e,B,p,dn,Pe,U,bh,Te,yl,xt,so,nt,J}from"./index-8w69r0c4.js";function F(a){if(!Number.isFinite(a)||a<=0)return"";return new Date(a).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}function P({files:a,selected:h,onSelect:b}){let[i,l]=n(""),r=u(()=>{let t=i.trim().toLowerCase();if(!t)return a;return a.filter((c)=>c.title.toLowerCase().includes(t))},[a,i]);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-canvas/40",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2 py-1.5",children:[e(U,{size:12,className:"flex-shrink-0 text-ink/40"}),e("input",{type:"search",value:i,onChange:(t)=>l(t.target.value),placeholder:"Filter plans…","aria-label":"Filter plans",className:"min-w-0 flex-1 bg-transparent text-[11px] text-ink outline-none placeholder:text-ink/35"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:r.length===0?e("p",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:a.length===0?"No plan yet":"No plan matches the filter"}):e("ul",{className:"py-1",children:r.map((t)=>{let c=t.path===h,m=F(t.modifiedAt);return e("li",{children:e("button",{type:"button",onClick:()=>b(t.path),"aria-current":c?"true":void 0,title:`${t.path}${m?` · ${m}`:""}`,className:`flex w-full items-start gap-1.5 px-2.5 py-1.5 text-left transition-colors ${c?"bg-ink/10 font-semibold text-ink":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e(Pe,{size:12,className:`mt-0.5 flex-shrink-0 ${c?"text-ink":"text-ink/40"}`}),e("span",{className:"min-w-0 flex-1",children:[e("span",{className:"block truncate text-[11.5px]",children:t.title}),m&&e("span",{className:"block truncate font-mono text-[10px] text-ink/40",children:m})]})]})},t.path)})})})]})}function y({file:a,content:h,isLoading:b,error:i,truncated:l,onBack:r}){return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-paper",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2.5 py-1.5",children:[e("button",{type:"button",onClick:r,title:"Back to the plan list","aria-label":"Back to the plan list",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink @[520px]:hidden",children:e(dn,{size:13})}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] text-ink/50",title:a?.path??"",children:a?.path??"Plan"}),b&&e(p,{size:12,className:"flex-shrink-0 animate-spin text-ink/40"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:i?e("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[e(B,{size:16,className:"text-error"}),e("p",{className:"text-xs text-error",children:i})]}):!h?e("div",{className:"px-6 py-8 text-center text-xs text-ink/40",children:b?"Reading the plan…":"This plan is empty."}):e("article",{className:"mx-auto max-w-4xl px-5 py-4",children:[e(J,{content:h,className:"max-w-none"}),l&&e("p",{className:"mt-4 border-t border-ink/10 pt-2 text-[11px] text-ink/50",children:"This plan is longer than the reader's budget and was cut off."})]})})]})}function X({className:a="",active:h=!0,tabsMode:b=!1}){let[i]=ue(),l=i.get("sessionId"),[r,t]=yl("plan.selectedFile",null),[c,m]=n(!1),k=r&&r.sessionId===l?r.path:null,s=Te(l?bh(l):null,{enabled:h}),x=s.data?.files??[],v=s.data?.current??null,f=u(()=>{if(k&&x.some((g)=>g.path===k))return k;return v},[k,x,v]),w=u(()=>x.find((g)=>g.path===f)??null,[x,f]);o(()=>{if(!l||!f||f===k)return;t({sessionId:l,path:f})},[l,f,k,t]),o(()=>{m(!1)},[l]);let S=(g)=>{if(l)t({sessionId:l,path:g});m(!0)};if(!l)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${a}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});let N=x.length>0;return e("div",{className:`@container flex h-full min-h-0 w-full flex-col bg-paper text-xs text-ink ${a}`,children:[e(xt,{left:e(d,{children:[e(Pe,{size:12,className:"flex-shrink-0 text-ink/50"}),e(so,{id:"plan",tabsMode:b,children:e("span",{className:"truncate text-[11px] font-medium text-ink/70",children:"Plan mode"})}),N&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] text-ink/60",children:x.length})]}),right:e(nt,{label:"Re-read the plan",onClick:s.refresh,busy:s.isLoading||s.refreshing,disabled:s.isLoading})}),s.stale&&!s.data?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(B,{size:16,className:"text-error"}),e("p",{className:"text-error",children:"The plan could not be read."}),e("button",{type:"button",onClick:s.refresh,className:"text-[11px] font-semibold text-ink/70 underline underline-offset-2 hover:text-ink",children:"Try again"})]}):!s.data?e("div",{className:"flex flex-1 items-center justify-center gap-2 text-ink/40",children:[e(p,{size:14,className:"animate-spin"}),e("span",{children:"Reading the plan…"})]}):!N?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(Pe,{size:18,className:"text-ink/30"}),e("p",{className:"max-w-sm text-[11px] leading-relaxed text-ink/60",children:"No plan yet. Turn on Plan mode in the composer, and the plan this session writes will appear here."})]}):e("div",{className:"flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse",children:[e("div",{className:`min-h-0 w-full @[520px]:w-52 @[520px]:flex-shrink-0 border-b border-ink/10 @[520px]:border-b-0 @[520px]:border-l ${c?"hidden @[520px]:flex":"flex"} flex-col`,children:e(P,{files:x,selected:f,onSelect:S})}),e("div",{className:`min-w-0 min-h-0 flex-1 ${c?"flex":"hidden @[520px]:flex"} flex-col`,children:e(y,{file:w,content:s.data.content,isLoading:s.isLoading,error:s.stale?"The plan could not be read.":null,truncated:s.data.truncated,onBack:()=>m(!1)})})]})]})}export{X as PlanPanel};
@@ -1,2 +1,2 @@
1
- import{mi}from"./index-scmtzcv1.js";var e=Object.freeze(JSON.parse(`{"displayName":"Lua","name":"lua","patterns":[{"begin":"\\\\b(?:(local)\\\\s+)?(function)\\\\b(?![,:])","beginCaptures":{"1":{"name":"keyword.local.lua"},"2":{"name":"keyword.control.lua"}},"end":"(?<=[-\\\\]\\"')\\\\[{}])","name":"meta.function.lua","patterns":[{"include":"#comment"},{"begin":"(\\\\()","beginCaptures":{"1":{"name":"punctuation.definition.parameters.begin.lua"}},"end":"(\\\\))|(?=[-\\\\]\\"'\\\\[{}])|(?<!\\\\.)\\\\.(?!\\\\.)","endCaptures":{"1":{"name":"punctuation.definition.parameters.finish.lua"}},"name":"meta.parameter.lua","patterns":[{"include":"#comment"},{"captures":{"1":{"name":"constant.language.lua"},"2":{"name":"variable.parameter.function.lua"}},"match":"(\\\\.{3})\\\\s*([A-Z_a-z][0-9A-Z_a-z]*)"},{"match":"[A-Z_a-z][0-9A-Z_a-z]*","name":"variable.parameter.function.lua"},{"match":",","name":"punctuation.separator.arguments.lua"},{"begin":":","beginCaptures":{"0":{"name":"punctuation.separator.arguments.lua"}},"end":"(?=[),])","patterns":[{"include":"#emmydoc.type"}]}]},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b\\\\s*(?=:)","name":"entity.name.class.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b","name":"entity.name.function.lua"}]},{"match":"(?<![.\\\\w\\\\d])0[Xx]\\\\h+(\\\\.\\\\h*)?([Ee]-?\\\\d*)?([Pp][-+]\\\\d+)?","name":"constant.numeric.float.hexadecimal.lua"},{"match":"(?<![.\\\\w\\\\d])0[Xx]\\\\.\\\\h+([Ee]-?\\\\d*)?([Pp][-+]\\\\d+)?","name":"constant.numeric.float.hexadecimal.lua"},{"match":"(?<![.\\\\w\\\\d])0[Xx]\\\\h+(?![.0-9EPep])","name":"constant.numeric.integer.hexadecimal.lua"},{"match":"(?<![.\\\\w\\\\d])\\\\d+(\\\\.\\\\d*)?([Ee]-?\\\\d*)?","name":"constant.numeric.float.lua"},{"match":"(?<![.\\\\w\\\\d])\\\\.\\\\d+([Ee]-?\\\\d*)?","name":"constant.numeric.float.lua"},{"match":"(?<![.\\\\w\\\\d])\\\\d+(?![.0-9EPep])","name":"constant.numeric.integer.lua"},{"include":"#string"},{"captures":{"1":{"name":"punctuation.definition.comment.lua"}},"match":"\\\\A(#!).*$\\\\n?","name":"comment.line.shebang.lua"},{"include":"#comment"},{"captures":{"1":{"name":"keyword.control.goto.lua"},"2":{"name":"string.tag.lua"}},"match":"\\\\b(goto)\\\\s+([A-Z_a-z][0-9A-Z_a-z]*)"},{"captures":{"1":{"name":"punctuation.section.embedded.begin.lua"},"2":{"name":"punctuation.section.embedded.end.lua"}},"match":"(::)\\\\s*[A-Z_a-z][0-9A-Z_a-z]*\\\\s*(::)","name":"string.tag.lua"},{"captures":{"0":{"name":"storage.type.attribute.lua"}},"match":"<\\\\s*(c(?:onst|lose))\\\\s*>"},{"match":"<[*A-Z_a-z][-*.0-9A-Z_a-z]*>","name":"storage.type.generic.lua"},{"match":"\\\\b(break|do|else|for|if|elseif|goto|return|then|repeat|while|until|end|in)\\\\b","name":"keyword.control.lua"},{"match":"\\\\b(local)\\\\b","name":"keyword.local.lua"},{"captures":{"1":{"name":"keyword.global.lua"}},"match":"^\\\\s*(global)\\\\b(?!\\\\s*=)"},{"match":"\\\\b(function)\\\\b(?![,:])","name":"keyword.control.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(false|nil(?!:)|true|_ENV|_G|_VERSION|math\\\\.(pi|huge|maxinteger|mininteger)|utf8\\\\.charpattern|io\\\\.(std(?:in|out|err))|package\\\\.(config|cpath|loaded|loaders|path|preload|searchers))\\\\b|(?<!\\\\.)\\\\.{3}(?!\\\\.)","name":"constant.language.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(self)\\\\b","name":"variable.language.self.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\\\b(?!\\\\s*=(?!=))","name":"support.function.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(async)\\\\b(?!\\\\s*=(?!=))","name":"entity.name.tag.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(coroutine\\\\.(create|isyieldable|close|resume|running|status|wrap|yield)|string\\\\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)|table\\\\.(concat|create|insert|maxn|move|pack|remove|sort|unpack)|math\\\\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?|tointeger|type)|io\\\\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\\\\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\\\\.(loadlib|seeall|searchpath)|debug\\\\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|[gs]etuservalue|set[Cc]stacklimit|traceback|upvalueid|upvaluejoin)|bit32\\\\.(arshift|band|bnot|bor|btest|bxor|extract|replace|lrotate|lshift|rrotate|rshift)|utf8\\\\.(char|codes|codepoint|len|offset))\\\\b(?!\\\\s*=(?!=))","name":"support.function.library.lua"},{"match":"\\\\b(\\\\|\\\\||&&|!)\\\\b","name":"keyword.operator.lua"},{"match":"\\\\b(and|or|not)\\\\b","name":"keyword.operator.logical.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?=\\\\s*(?:[\\"'({]|\\\\[\\\\[))","name":"support.function.any-method.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?=\\\\s*\\\\??:)","name":"entity.name.class.lua"},{"match":"(?<=[^.]\\\\.|:)\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?!\\\\s*=\\\\s*\\\\b(function)\\\\b)","name":"entity.other.attribute.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?!\\\\s*=\\\\s*\\\\b(function)\\\\b)","name":"variable.other.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?=\\\\s*=\\\\s*\\\\b(function)\\\\b)","name":"entity.name.function.lua"},{"match":"[-#%*+/^]|==?|~=|!=|<=?|>=?|(?<!\\\\.)\\\\.{2}(?!\\\\.)","name":"keyword.operator.lua"}],"repository":{"comment":{"patterns":[{"begin":"(^[\\\\t ]+)?(?=--)","beginCaptures":{"1":{"name":"punctuation.whitespace.comment.leading.lua"}},"end":"(?!\\\\G)((?!^)[\\\\t ]+\\\\n)?","endCaptures":{"1":{"name":"punctuation.whitespace.comment.trailing.lua"}},"patterns":[{"begin":"--\\\\[(=*)\\\\[@@@","beginCaptures":{"0":{"name":"punctuation.definition.comment.begin.lua"}},"end":"(--)?]\\\\1]","endCaptures":{"0":{"name":"punctuation.definition.comment.end.lua"}},"name":"","patterns":[{"include":"source.lua"}]},{"begin":"--\\\\[(=*)\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.comment.begin.lua"}},"end":"(--)?]\\\\1]","endCaptures":{"0":{"name":"punctuation.definition.comment.end.lua"}},"name":"comment.block.lua","patterns":[{"include":"#emmydoc"},{"include":"#ldoc_tag"}]},{"begin":"----","beginCaptures":{"0":{"name":"punctuation.definition.comment.lua"}},"end":"\\\\n","name":"comment.line.double-dash.lua"},{"begin":"---","beginCaptures":{"0":{"name":"punctuation.definition.comment.lua"}},"end":"\\\\n","name":"comment.line.double-dash.documentation.lua","patterns":[{"include":"#emmydoc"},{"include":"#ldoc_tag"}]},{"begin":"--","beginCaptures":{"0":{"name":"punctuation.definition.comment.lua"}},"end":"\\\\n","name":"comment.line.double-dash.lua","patterns":[{"include":"#ldoc_tag"}]}]},{"begin":"/\\\\*","beginCaptures":{"0":{"name":"punctuation.definition.comment.begin.lua"}},"end":"\\\\*/","endCaptures":{"0":{"name":"punctuation.definition.comment.end.lua"}},"name":"comment.block.lua","patterns":[{"include":"#emmydoc"},{"include":"#ldoc_tag"}]}]},"emmydoc":{"patterns":[{"begin":"(?<=---)[\\\\t ]*@class","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"match":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","name":"support.class.lua"},{"match":"[,:]","name":"keyword.operator.lua"}]},{"begin":"(?<=---)[\\\\t ]*@enum","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","beginCaptures":{"0":{"name":"variable.lua"}},"end":"(?=\\\\n)"}]},{"begin":"(?<=---)[\\\\t ]*@type","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@alias","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","beginCaptures":{"0":{"name":"variable.lua"}},"end":"(?=[\\\\n#])","patterns":[{"include":"#emmydoc.type"}]}]},{"begin":"(?<=---)[\\\\t ]*(@operator)\\\\s*(\\\\b[a-z]+)?","beginCaptures":{"1":{"name":"storage.type.annotation.lua"},"2":{"name":"support.function.library.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@cast","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","beginCaptures":{"0":{"name":"variable.other.lua"}},"end":"(?=\\\\n)","patterns":[{"include":"#emmydoc.type"},{"match":"([+-|])","name":"keyword.operator.lua"}]}]},{"begin":"(?<=---)[\\\\t ]*@param","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(\\\\??)","beginCaptures":{"1":{"name":"entity.name.variable.lua"},"2":{"name":"keyword.operator.lua"}},"end":"(?=[\\\\n#])","patterns":[{"include":"#emmydoc.type"}]}]},{"begin":"(?<=---)[\\\\t ]*@return","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"match":"\\\\?","name":"keyword.operator.lua"},{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@field","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"(\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b|(\\\\[))(\\\\??)","beginCaptures":{"2":{"name":"entity.name.variable.lua"},"3":{"name":"keyword.operator.lua"}},"end":"(?=[\\\\n#])","patterns":[{"include":"#string"},{"include":"#emmydoc.type"},{"match":"]","name":"keyword.operator.lua"}]}]},{"begin":"(?<=---)[\\\\t ]*@generic","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b","beginCaptures":{"0":{"name":"storage.type.generic.lua"}},"end":"(?=\\\\n)|(,)","endCaptures":{"0":{"name":"keyword.operator.lua"}},"patterns":[{"match":":","name":"keyword.operator.lua"},{"include":"#emmydoc.type"}]}]},{"begin":"(?<=---)[\\\\t ]*@vararg","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@overload","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@deprecated","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@meta","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@private","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@protected","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@package","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@version","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"match":"\\\\b(5\\\\.1|5\\\\.2|5\\\\.3|5\\\\.4|JIT)\\\\b","name":"support.class.lua"},{"match":"[,<>]","name":"keyword.operator.lua"}]},{"begin":"(?<=---)[\\\\t ]*@see","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"match":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","name":"support.class.lua"},{"match":"#","name":"keyword.operator.lua"}]},{"begin":"(?<=---)[\\\\t ]*@diagnostic","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"([-0-9A-Z_a-z]+)[\\\\t ]*(:)?","beginCaptures":{"1":{"name":"keyword.other.unit"},"2":{"name":"keyword.operator.unit"}},"end":"(?=\\\\n)","patterns":[{"match":"\\\\b([*A-Z_a-z][-0-9A-Z_a-z]*)","name":"support.class.lua"},{"match":",","name":"keyword.operator.lua"}]}]},{"begin":"(?<=---)[\\\\t ]*@module","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#string"}]},{"match":"(?<=---)[\\\\t ]*@(async|nodiscard)","name":"storage.type.annotation.lua"},{"begin":"(?<=---)\\\\|\\\\s*[+>]?","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#string"}]}]},"emmydoc.type":{"patterns":[{"begin":"\\\\bfun\\\\b","beginCaptures":{"0":{"name":"keyword.control.lua"}},"end":"(?=[#\\\\s])","patterns":[{"match":"[](),:<>?\\\\[][\\\\t ]*","name":"keyword.operator.lua"},{"match":"([A-Z_a-z][-*.0-9A-Z_a-z]*)(?<!,)[\\\\t ]*(?=\\\\??:)","name":"entity.name.variable.lua"},{"include":"#emmydoc.type"},{"include":"#string"}]},{"match":"<[*A-Z_a-z][-*.0-9A-Z_a-z]*>","name":"storage.type.generic.lua"},{"match":"\\\\basync\\\\b","name":"entity.name.tag.lua"},{"match":"[,:?\`{|}][\\\\t ]*","name":"keyword.operator.lua"},{"begin":"(?=[\\"'*.A-\\\\[_a-z])","end":"(?=[#),:?|}\\\\s])","patterns":[{"match":"([-\\\\]*,.0-9<>A-\\\\[_a-z]+)(?<!,)[\\\\t ]*","name":"support.type.lua"},{"match":"(\\\\.\\\\.\\\\.)[\\\\t ]*","name":"constant.language.lua"},{"include":"#string"}]}]},"escaped_char":{"patterns":[{"match":"\\\\\\\\[\\\\n\\"'\\\\\\\\abfnrtv]","name":"constant.character.escape.lua"},{"match":"\\\\\\\\z[\\\\t\\\\n ]*","name":"constant.character.escape.lua"},{"match":"\\\\\\\\\\\\d{1,3}","name":"constant.character.escape.byte.lua"},{"match":"\\\\\\\\x\\\\h\\\\h","name":"constant.character.escape.byte.lua"},{"match":"\\\\\\\\u\\\\{\\\\h+}","name":"constant.character.escape.unicode.lua"},{"match":"\\\\\\\\.","name":"invalid.illegal.character.escape.lua"}]},"ldoc_tag":{"captures":{"1":{"name":"punctuation.definition.block.tag.ldoc"},"2":{"name":"storage.type.class.ldoc"}},"match":"\\\\G[\\\\t ]*(@)(alias|annotation|author|charset|class|classmod|comment|constructor|copyright|description|example|export|factory|field|file|fixme|function|include|lfunction|license|local|module|name|param|pragma|private|raise|release|return|script|section|see|set|static|submodule|summary|tfield|thread|tparam|treturn|todo|topic|type|usage|warning|within)\\\\b"},"string":{"patterns":[{"begin":"'","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.lua"}},"end":"'[\\\\t ]*|(?=\\\\n)","endCaptures":{"0":{"name":"punctuation.definition.string.end.lua"}},"name":"string.quoted.single.lua","patterns":[{"include":"#escaped_char"}]},{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.lua"}},"end":"\\"[\\\\t ]*|(?=\\\\n)","endCaptures":{"0":{"name":"punctuation.definition.string.end.lua"}},"name":"string.quoted.double.lua","patterns":[{"include":"#escaped_char"}]},{"begin":"\`","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.lua"}},"end":"\`[\\\\t ]*|(?=\\\\n)","endCaptures":{"0":{"name":"punctuation.definition.string.end.lua"}},"name":"string.quoted.double.lua"},{"begin":"(?<=\\\\.cdef)\\\\s*(\\\\[(=*)\\\\[)","beginCaptures":{"0":{"name":"string.quoted.other.multiline.lua"},"1":{"name":"punctuation.definition.string.begin.lua"}},"contentName":"meta.embedded.lua","end":"(]\\\\2])[\\\\t ]*","endCaptures":{"0":{"name":"string.quoted.other.multiline.lua"},"1":{"name":"punctuation.definition.string.end.lua"}},"patterns":[{"include":"source.c"}]},{"begin":"(?<!--)\\\\[(=*)\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.lua"}},"end":"]\\\\1][\\\\t ]*","endCaptures":{"0":{"name":"punctuation.definition.string.end.lua"}},"name":"string.quoted.other.multiline.lua"}]}},"scopeName":"source.lua","embeddedLangs":["c"]}`)),qg=[...mi,e];
1
+ import{pi}from"./index-396g4zz4.js";var e=Object.freeze(JSON.parse(`{"displayName":"Lua","name":"lua","patterns":[{"begin":"\\\\b(?:(local)\\\\s+)?(function)\\\\b(?![,:])","beginCaptures":{"1":{"name":"keyword.local.lua"},"2":{"name":"keyword.control.lua"}},"end":"(?<=[-\\\\]\\"')\\\\[{}])","name":"meta.function.lua","patterns":[{"include":"#comment"},{"begin":"(\\\\()","beginCaptures":{"1":{"name":"punctuation.definition.parameters.begin.lua"}},"end":"(\\\\))|(?=[-\\\\]\\"'\\\\[{}])|(?<!\\\\.)\\\\.(?!\\\\.)","endCaptures":{"1":{"name":"punctuation.definition.parameters.finish.lua"}},"name":"meta.parameter.lua","patterns":[{"include":"#comment"},{"captures":{"1":{"name":"constant.language.lua"},"2":{"name":"variable.parameter.function.lua"}},"match":"(\\\\.{3})\\\\s*([A-Z_a-z][0-9A-Z_a-z]*)"},{"match":"[A-Z_a-z][0-9A-Z_a-z]*","name":"variable.parameter.function.lua"},{"match":",","name":"punctuation.separator.arguments.lua"},{"begin":":","beginCaptures":{"0":{"name":"punctuation.separator.arguments.lua"}},"end":"(?=[),])","patterns":[{"include":"#emmydoc.type"}]}]},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b\\\\s*(?=:)","name":"entity.name.class.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b","name":"entity.name.function.lua"}]},{"match":"(?<![.\\\\w\\\\d])0[Xx]\\\\h+(\\\\.\\\\h*)?([Ee]-?\\\\d*)?([Pp][-+]\\\\d+)?","name":"constant.numeric.float.hexadecimal.lua"},{"match":"(?<![.\\\\w\\\\d])0[Xx]\\\\.\\\\h+([Ee]-?\\\\d*)?([Pp][-+]\\\\d+)?","name":"constant.numeric.float.hexadecimal.lua"},{"match":"(?<![.\\\\w\\\\d])0[Xx]\\\\h+(?![.0-9EPep])","name":"constant.numeric.integer.hexadecimal.lua"},{"match":"(?<![.\\\\w\\\\d])\\\\d+(\\\\.\\\\d*)?([Ee]-?\\\\d*)?","name":"constant.numeric.float.lua"},{"match":"(?<![.\\\\w\\\\d])\\\\.\\\\d+([Ee]-?\\\\d*)?","name":"constant.numeric.float.lua"},{"match":"(?<![.\\\\w\\\\d])\\\\d+(?![.0-9EPep])","name":"constant.numeric.integer.lua"},{"include":"#string"},{"captures":{"1":{"name":"punctuation.definition.comment.lua"}},"match":"\\\\A(#!).*$\\\\n?","name":"comment.line.shebang.lua"},{"include":"#comment"},{"captures":{"1":{"name":"keyword.control.goto.lua"},"2":{"name":"string.tag.lua"}},"match":"\\\\b(goto)\\\\s+([A-Z_a-z][0-9A-Z_a-z]*)"},{"captures":{"1":{"name":"punctuation.section.embedded.begin.lua"},"2":{"name":"punctuation.section.embedded.end.lua"}},"match":"(::)\\\\s*[A-Z_a-z][0-9A-Z_a-z]*\\\\s*(::)","name":"string.tag.lua"},{"captures":{"0":{"name":"storage.type.attribute.lua"}},"match":"<\\\\s*(c(?:onst|lose))\\\\s*>"},{"match":"<[*A-Z_a-z][-*.0-9A-Z_a-z]*>","name":"storage.type.generic.lua"},{"match":"\\\\b(break|do|else|for|if|elseif|goto|return|then|repeat|while|until|end|in)\\\\b","name":"keyword.control.lua"},{"match":"\\\\b(local)\\\\b","name":"keyword.local.lua"},{"captures":{"1":{"name":"keyword.global.lua"}},"match":"^\\\\s*(global)\\\\b(?!\\\\s*=)"},{"match":"\\\\b(function)\\\\b(?![,:])","name":"keyword.control.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(false|nil(?!:)|true|_ENV|_G|_VERSION|math\\\\.(pi|huge|maxinteger|mininteger)|utf8\\\\.charpattern|io\\\\.(std(?:in|out|err))|package\\\\.(config|cpath|loaded|loaders|path|preload|searchers))\\\\b|(?<!\\\\.)\\\\.{3}(?!\\\\.)","name":"constant.language.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(self)\\\\b","name":"variable.language.self.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\\\b(?!\\\\s*=(?!=))","name":"support.function.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(async)\\\\b(?!\\\\s*=(?!=))","name":"entity.name.tag.lua"},{"match":"(?<![^.]\\\\.|:)\\\\b(coroutine\\\\.(create|isyieldable|close|resume|running|status|wrap|yield)|string\\\\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)|table\\\\.(concat|create|insert|maxn|move|pack|remove|sort|unpack)|math\\\\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?|tointeger|type)|io\\\\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\\\\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\\\\.(loadlib|seeall|searchpath)|debug\\\\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|[gs]etuservalue|set[Cc]stacklimit|traceback|upvalueid|upvaluejoin)|bit32\\\\.(arshift|band|bnot|bor|btest|bxor|extract|replace|lrotate|lshift|rrotate|rshift)|utf8\\\\.(char|codes|codepoint|len|offset))\\\\b(?!\\\\s*=(?!=))","name":"support.function.library.lua"},{"match":"\\\\b(\\\\|\\\\||&&|!)\\\\b","name":"keyword.operator.lua"},{"match":"\\\\b(and|or|not)\\\\b","name":"keyword.operator.logical.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?=\\\\s*(?:[\\"'({]|\\\\[\\\\[))","name":"support.function.any-method.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?=\\\\s*\\\\??:)","name":"entity.name.class.lua"},{"match":"(?<=[^.]\\\\.|:)\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?!\\\\s*=\\\\s*\\\\b(function)\\\\b)","name":"entity.other.attribute.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?!\\\\s*=\\\\s*\\\\b(function)\\\\b)","name":"variable.other.lua"},{"match":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(?=\\\\s*=\\\\s*\\\\b(function)\\\\b)","name":"entity.name.function.lua"},{"match":"[-#%*+/^]|==?|~=|!=|<=?|>=?|(?<!\\\\.)\\\\.{2}(?!\\\\.)","name":"keyword.operator.lua"}],"repository":{"comment":{"patterns":[{"begin":"(^[\\\\t ]+)?(?=--)","beginCaptures":{"1":{"name":"punctuation.whitespace.comment.leading.lua"}},"end":"(?!\\\\G)((?!^)[\\\\t ]+\\\\n)?","endCaptures":{"1":{"name":"punctuation.whitespace.comment.trailing.lua"}},"patterns":[{"begin":"--\\\\[(=*)\\\\[@@@","beginCaptures":{"0":{"name":"punctuation.definition.comment.begin.lua"}},"end":"(--)?]\\\\1]","endCaptures":{"0":{"name":"punctuation.definition.comment.end.lua"}},"name":"","patterns":[{"include":"source.lua"}]},{"begin":"--\\\\[(=*)\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.comment.begin.lua"}},"end":"(--)?]\\\\1]","endCaptures":{"0":{"name":"punctuation.definition.comment.end.lua"}},"name":"comment.block.lua","patterns":[{"include":"#emmydoc"},{"include":"#ldoc_tag"}]},{"begin":"----","beginCaptures":{"0":{"name":"punctuation.definition.comment.lua"}},"end":"\\\\n","name":"comment.line.double-dash.lua"},{"begin":"---","beginCaptures":{"0":{"name":"punctuation.definition.comment.lua"}},"end":"\\\\n","name":"comment.line.double-dash.documentation.lua","patterns":[{"include":"#emmydoc"},{"include":"#ldoc_tag"}]},{"begin":"--","beginCaptures":{"0":{"name":"punctuation.definition.comment.lua"}},"end":"\\\\n","name":"comment.line.double-dash.lua","patterns":[{"include":"#ldoc_tag"}]}]},{"begin":"/\\\\*","beginCaptures":{"0":{"name":"punctuation.definition.comment.begin.lua"}},"end":"\\\\*/","endCaptures":{"0":{"name":"punctuation.definition.comment.end.lua"}},"name":"comment.block.lua","patterns":[{"include":"#emmydoc"},{"include":"#ldoc_tag"}]}]},"emmydoc":{"patterns":[{"begin":"(?<=---)[\\\\t ]*@class","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"match":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","name":"support.class.lua"},{"match":"[,:]","name":"keyword.operator.lua"}]},{"begin":"(?<=---)[\\\\t ]*@enum","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","beginCaptures":{"0":{"name":"variable.lua"}},"end":"(?=\\\\n)"}]},{"begin":"(?<=---)[\\\\t ]*@type","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@alias","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","beginCaptures":{"0":{"name":"variable.lua"}},"end":"(?=[\\\\n#])","patterns":[{"include":"#emmydoc.type"}]}]},{"begin":"(?<=---)[\\\\t ]*(@operator)\\\\s*(\\\\b[a-z]+)?","beginCaptures":{"1":{"name":"storage.type.annotation.lua"},"2":{"name":"support.function.library.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@cast","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","beginCaptures":{"0":{"name":"variable.other.lua"}},"end":"(?=\\\\n)","patterns":[{"include":"#emmydoc.type"},{"match":"([+-|])","name":"keyword.operator.lua"}]}]},{"begin":"(?<=---)[\\\\t ]*@param","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b(\\\\??)","beginCaptures":{"1":{"name":"entity.name.variable.lua"},"2":{"name":"keyword.operator.lua"}},"end":"(?=[\\\\n#])","patterns":[{"include":"#emmydoc.type"}]}]},{"begin":"(?<=---)[\\\\t ]*@return","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"match":"\\\\?","name":"keyword.operator.lua"},{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@field","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"(\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b|(\\\\[))(\\\\??)","beginCaptures":{"2":{"name":"entity.name.variable.lua"},"3":{"name":"keyword.operator.lua"}},"end":"(?=[\\\\n#])","patterns":[{"include":"#string"},{"include":"#emmydoc.type"},{"match":"]","name":"keyword.operator.lua"}]}]},{"begin":"(?<=---)[\\\\t ]*@generic","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"\\\\b([A-Z_a-z][0-9A-Z_a-z]*)\\\\b","beginCaptures":{"0":{"name":"storage.type.generic.lua"}},"end":"(?=\\\\n)|(,)","endCaptures":{"0":{"name":"keyword.operator.lua"}},"patterns":[{"match":":","name":"keyword.operator.lua"},{"include":"#emmydoc.type"}]}]},{"begin":"(?<=---)[\\\\t ]*@vararg","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@overload","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#emmydoc.type"}]},{"begin":"(?<=---)[\\\\t ]*@deprecated","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@meta","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@private","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@protected","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@package","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])"},{"begin":"(?<=---)[\\\\t ]*@version","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"match":"\\\\b(5\\\\.1|5\\\\.2|5\\\\.3|5\\\\.4|JIT)\\\\b","name":"support.class.lua"},{"match":"[,<>]","name":"keyword.operator.lua"}]},{"begin":"(?<=---)[\\\\t ]*@see","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"match":"\\\\b([*A-Z_a-z][-*.0-9A-Z_a-z]*)","name":"support.class.lua"},{"match":"#","name":"keyword.operator.lua"}]},{"begin":"(?<=---)[\\\\t ]*@diagnostic","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"begin":"([-0-9A-Z_a-z]+)[\\\\t ]*(:)?","beginCaptures":{"1":{"name":"keyword.other.unit"},"2":{"name":"keyword.operator.unit"}},"end":"(?=\\\\n)","patterns":[{"match":"\\\\b([*A-Z_a-z][-0-9A-Z_a-z]*)","name":"support.class.lua"},{"match":",","name":"keyword.operator.lua"}]}]},{"begin":"(?<=---)[\\\\t ]*@module","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#string"}]},{"match":"(?<=---)[\\\\t ]*@(async|nodiscard)","name":"storage.type.annotation.lua"},{"begin":"(?<=---)\\\\|\\\\s*[+>]?","beginCaptures":{"0":{"name":"storage.type.annotation.lua"}},"end":"(?=[\\\\n#@])","patterns":[{"include":"#string"}]}]},"emmydoc.type":{"patterns":[{"begin":"\\\\bfun\\\\b","beginCaptures":{"0":{"name":"keyword.control.lua"}},"end":"(?=[#\\\\s])","patterns":[{"match":"[](),:<>?\\\\[][\\\\t ]*","name":"keyword.operator.lua"},{"match":"([A-Z_a-z][-*.0-9A-Z_a-z]*)(?<!,)[\\\\t ]*(?=\\\\??:)","name":"entity.name.variable.lua"},{"include":"#emmydoc.type"},{"include":"#string"}]},{"match":"<[*A-Z_a-z][-*.0-9A-Z_a-z]*>","name":"storage.type.generic.lua"},{"match":"\\\\basync\\\\b","name":"entity.name.tag.lua"},{"match":"[,:?\`{|}][\\\\t ]*","name":"keyword.operator.lua"},{"begin":"(?=[\\"'*.A-\\\\[_a-z])","end":"(?=[#),:?|}\\\\s])","patterns":[{"match":"([-\\\\]*,.0-9<>A-\\\\[_a-z]+)(?<!,)[\\\\t ]*","name":"support.type.lua"},{"match":"(\\\\.\\\\.\\\\.)[\\\\t ]*","name":"constant.language.lua"},{"include":"#string"}]}]},"escaped_char":{"patterns":[{"match":"\\\\\\\\[\\\\n\\"'\\\\\\\\abfnrtv]","name":"constant.character.escape.lua"},{"match":"\\\\\\\\z[\\\\t\\\\n ]*","name":"constant.character.escape.lua"},{"match":"\\\\\\\\\\\\d{1,3}","name":"constant.character.escape.byte.lua"},{"match":"\\\\\\\\x\\\\h\\\\h","name":"constant.character.escape.byte.lua"},{"match":"\\\\\\\\u\\\\{\\\\h+}","name":"constant.character.escape.unicode.lua"},{"match":"\\\\\\\\.","name":"invalid.illegal.character.escape.lua"}]},"ldoc_tag":{"captures":{"1":{"name":"punctuation.definition.block.tag.ldoc"},"2":{"name":"storage.type.class.ldoc"}},"match":"\\\\G[\\\\t ]*(@)(alias|annotation|author|charset|class|classmod|comment|constructor|copyright|description|example|export|factory|field|file|fixme|function|include|lfunction|license|local|module|name|param|pragma|private|raise|release|return|script|section|see|set|static|submodule|summary|tfield|thread|tparam|treturn|todo|topic|type|usage|warning|within)\\\\b"},"string":{"patterns":[{"begin":"'","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.lua"}},"end":"'[\\\\t ]*|(?=\\\\n)","endCaptures":{"0":{"name":"punctuation.definition.string.end.lua"}},"name":"string.quoted.single.lua","patterns":[{"include":"#escaped_char"}]},{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.lua"}},"end":"\\"[\\\\t ]*|(?=\\\\n)","endCaptures":{"0":{"name":"punctuation.definition.string.end.lua"}},"name":"string.quoted.double.lua","patterns":[{"include":"#escaped_char"}]},{"begin":"\`","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.lua"}},"end":"\`[\\\\t ]*|(?=\\\\n)","endCaptures":{"0":{"name":"punctuation.definition.string.end.lua"}},"name":"string.quoted.double.lua"},{"begin":"(?<=\\\\.cdef)\\\\s*(\\\\[(=*)\\\\[)","beginCaptures":{"0":{"name":"string.quoted.other.multiline.lua"},"1":{"name":"punctuation.definition.string.begin.lua"}},"contentName":"meta.embedded.lua","end":"(]\\\\2])[\\\\t ]*","endCaptures":{"0":{"name":"string.quoted.other.multiline.lua"},"1":{"name":"punctuation.definition.string.end.lua"}},"patterns":[{"include":"source.c"}]},{"begin":"(?<!--)\\\\[(=*)\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.lua"}},"end":"]\\\\1][\\\\t ]*","endCaptures":{"0":{"name":"punctuation.definition.string.end.lua"}},"name":"string.quoted.other.multiline.lua"}]}},"scopeName":"source.lua","embeddedLangs":["c"]}`)),qg=[...pi,e];
2
2
  export{qg};
@@ -1 +1 @@
1
- import{d,n,o,K,i,u,a,ln,e,_e,os,f,is,ss,ls,U,us,h,T,xr,wr,xt,so,he,Ei,xl,mt,ft,gt,Dd,Tc}from"./index-dzp9rwy0.js";import{Tr}from"./index-02skcm4d.js";var me=2000,W=new Map;function ge(s){if(s.length===0)return"";let r="";for(let t of s)r+=`${t.start}-${t.end},`;return r}function ee(s,r,t){let c=Ei(r),m=`${r}\x00${ge(t)}\x00${s}`;if(c){let S=W.get(m);if(S!==void 0)return W.delete(m),W.set(m,S),S}let l=xl(s,r,{marks:t});if(!c)return l;if(W.set(m,l),W.size>me){let S=W.keys().next();if(!S.done)W.delete(S.value)}return l}function te(s,r,t){let c=[],m=0;for(let l of r){if(l.start<m||l.end<=l.start||l.end>s.length)continue;if(l.start>m)c.push({text:s.slice(m,l.start),kind:"plain"});if(c.push({text:s.slice(l.start,l.end),kind:"removed"}),t)c.push({text:t,kind:"inserted"});m=l.end}if(m<s.length)c.push({text:s.slice(m),kind:"plain"});return c}function be({file:s,result:r,replacement:t,showReplacePreview:c,onOpen:m}){let l=r.ranges??[],S=c&&t.length>0;return e("button",{type:"button",onClick:()=>m(r),className:"flex w-full items-start gap-2 rounded px-1 py-0.5 text-left hover:bg-ink/5 cursor-pointer",title:`Open ${s}:${r.line}`,children:[e("span",{className:"w-6 flex-shrink-0 text-right font-mono text-ink/40",children:r.line}),S?e("span",{className:"min-w-0 truncate font-mono text-ink",children:te(r.content,l,t).map((k,b)=>k.kind==="plain"?e("span",{children:k.text},b):k.kind==="removed"?e("del",{className:"search-replace-old",children:k.text},b):e("ins",{className:"search-replace-new",children:k.text},b))}):e("span",{className:"min-w-0 truncate font-mono text-ink",dangerouslySetInnerHTML:{__html:ee(r.content,gt(s),l)}})]})}var re=ln(be);var Z={header:4,hit:4,group:16},ne={headerBox:16,hitBox:20},se=5000;function oe(s){let r=[],t=null;for(let c of s){if(!t||t.file!==c.file)t={file:c.file,results:[]},r.push(t);t.results.push(c)}return r}function ie(s){let r=[];for(let t of s){r.push({kind:"group",file:t.file,count:t.results.length});for(let c=0;c<t.results.length;c++)r.push({kind:"hit",file:t.file,result:t.results[c],last:c===t.results.length-1})}return r}function xe(s,r){if(s.kind==="group")return r.headerBox+Z.header;return r.hitBox+(s.last?Z.group:Z.hit)}function ae(s,r){let t=Array(s.length),c=Array(s.length),m=0;for(let l=0;l<s.length;l++){let S=xe(s[l],r);t[l]=m,c[l]=S,m+=S}return{offsets:t,heights:c,total:m}}function le(s,r,t,c,m=240){if(s.length===0)return{start:0,end:0};let l=Math.max(0,t),S=l-m,k=l+c+m,b=0,x=s.length-1;while(b<x){let g=b+x>>1;if(s[g]+r[g]>S)x=g;else b=g+1}let C=b;b=C,x=s.length;while(b<x){let g=b+x>>1;if(s[g]>=k)x=g;else b=g+1}return{start:C,end:b}}var Se=8,ve=8;function ce({groups:s,replacement:r,showReplacePreview:t,onOpen:c,onReplaceFile:m,replaceBusy:l}){let S=i(null),k=i(null),b=u(()=>ie(s),[s]),[x,C]=n(ne),g=u(()=>ae(b,x),[b,x]),[O,y]=n(()=>({start:0,end:Math.min(b.length,60)})),F=a((p)=>{S.current=p},[]),v=a(()=>{let p=S.current;if(!p)return;let w=le(g.offsets,g.heights,p.scrollTop,p.clientHeight);y((M)=>M.start===w.start&&M.end===w.end?M:w)},[g]),R=a(()=>{v()},[v]);K(()=>{let p=k.current;if(!p)return;let w=p.querySelector("[data-search-header] > div")?.offsetHeight??0,M=p.querySelector("[data-search-hit] > button")?.offsetHeight??0;if(w>0&&w!==x.headerBox)C((N)=>({...N,headerBox:w}));if(M>0&&M!==x.hitBox)C((N)=>({...N,hitBox:M}))},[O,x,b]),K(()=>{v()},[v]),K(()=>{let p=S.current;if(!p||typeof ResizeObserver>"u")return;let w=new ResizeObserver(()=>v());return w.observe(p),()=>w.disconnect()},[v]);let H=b.length===0?0:Math.min(O.start,b.length-1),A=Math.min(O.end,b.length),L=b.slice(H,A),_=A<b.length?g.total-g.offsets[A]:0;return e("div",{ref:F,onScroll:R,className:"flex-1 scrollbar-overlay-container px-3 text-xs",style:{overflowAnchor:"none"},children:[e("div",{style:{height:Se+(g.offsets[H]??0)},"aria-hidden":"true"}),e("div",{ref:k,children:L.map((p,w)=>{let M=H+w,N=g.heights[M];if(p.kind==="group")return e("div",{"data-search-header":"",style:{height:N},children:e("div",{className:"font-semibold text-ink/80 flex items-center justify-between group",children:[e("div",{className:"flex items-center min-w-0",children:[e(mt,{name:p.file,size:12,className:"mr-1.5 flex-shrink-0"}),e("span",{className:"truncate",children:p.file}),e("span",{className:"ml-2 bg-ink/10 text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",children:p.count})]}),e("button",{onClick:()=>m(p.file),disabled:l,className:"touch-visible opacity-0 group-hover:opacity-100 p-1 text-ink/40 hover:text-ink rounded hover:bg-ink/5 disabled:opacity-50 flex-shrink-0",title:"Replace in this file",children:e(ls,{size:12})})]})},`group:${p.file}`);return e("div",{"data-search-hit":"",style:{height:N},children:e(re,{file:p.file,result:p.result,replacement:r,showReplacePreview:t,onOpen:c})},`hit:${p.file}:${p.result.line}:${M}`)})}),e("div",{style:{height:ve+_},"aria-hidden":"true"})]})}function ue({className:s,query:r,setQuery:t,replaceQuery:c,setReplaceQuery:m,matchCase:l,setMatchCase:S,wholeWord:k,setWholeWord:b,useRegex:x,setUseRegex:C,includeFiles:g,setIncludeFiles:O,showIncludeField:y,setShowIncludeField:F,showMenu:v,setShowMenu:R,menuRef:H,rootPath:A,activeRepo:L,setActiveRepo:_,repos:p,reposScanning:w,rescanRepos:M,results:N,isSearching:G,truncated:q,error:E,onOpenFile:z,handleReplace:D,replaceBusy:J,tabsMode:Y=!1}){let Q=u(()=>oe(N),[N]),P=i(null),X=i(null),B=a(()=>{t(""),P.current?.focus()},[t]),j=a(()=>{m(""),X.current?.focus()},[m]),V=u(()=>({matchCase:l,wholeWord:k,isRegex:x,inSelection:!1}),[l,k,x]),de=a((I)=>{Dd({path:I.file,line:Number(I.line),query:r,options:V}),z?.({path:I.file,name:I.file.split("/").pop()||I.file,root:A,repo:L})},[r,V,A,L,z]),fe=a((I)=>D(I),[D]);return e("div",{className:`flex flex-col h-full bg-paper ${s}`,children:[e(xt,{left:e(d,{children:[e(so,{id:"search",tabsMode:Y,children:e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Search"})}),e(Tr,{rootPath:A,activeRepo:L,onSelectRepo:_,repos:p,scanning:w,onRefreshRepos:M})]}),right:e("div",{className:"relative",ref:H,children:[e("button",{onClick:()=>R(!v),className:`p-1 rounded hover:bg-ink/5 transition-colors ${v||y?"text-ink":"text-ink/40"}`,title:"Search Options",children:e(_e,{size:14})}),v&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-48 bg-paper border border-ink/10 rounded shadow-lg z-10 py-1",children:e("button",{onClick:()=>{if(F(!y),y)O("");R(!1)},className:"w-full px-3 py-1.5 text-left text-xs text-ink hover:bg-ink/5 flex items-center justify-between",children:[e("span",{children:"Files to include"}),y&&e(f,{size:12,className:"text-ink/60"})]})})]})}),e("div",{className:"p-3 flex flex-col gap-2.5 border-b border-ink/10",children:[e("div",{className:"relative",children:e("div",{className:"flex items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e(U,{size:14,className:"ml-2 text-ink/40 flex-shrink-0"}),e("input",{ref:P,type:"text",placeholder:"Search",value:r,onChange:(I)=>t(I.currentTarget.value),className:"w-full bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35 min-w-0"}),r&&e("button",{type:"button",onClick:B,title:"Clear search","aria-label":"Clear search",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(h,{size:12})}),e("div",{className:"flex items-center space-x-0.5 pr-1 text-ink/40 flex-shrink-0",children:[e("button",{onClick:()=>S(!l),className:`p-1 rounded hover:text-ink ${l?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Case",children:e(os,{size:14})}),e("button",{onClick:()=>b(!k),className:`p-1 rounded hover:text-ink ${k?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Whole Word",children:e(us,{size:14})}),e("button",{onClick:()=>C(!x),className:`p-1 rounded hover:text-ink ${x?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Use Regular Expression",children:e(is,{size:14})})]})]})}),e("div",{className:"relative flex items-center space-x-1",children:[e("div",{className:"flex flex-1 min-w-0 items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e("input",{ref:X,type:"text",placeholder:"Replace",value:c,onChange:(I)=>m(I.currentTarget.value),className:"flex-1 min-w-0 bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35"}),c&&e("button",{type:"button",onClick:j,title:"Clear replace","aria-label":"Clear replace",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(h,{size:12})})]}),e("button",{onClick:()=>D(),disabled:N.length===0||J,className:"p-1.5 rounded border border-ink/20 text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-50 disabled:cursor-not-allowed bg-paper",title:"Replace All",children:e(ss,{size:14})})]}),y&&e("div",{className:"relative",children:e("input",{type:"text",value:g,onChange:(I)=>O(I.currentTarget.value),placeholder:"Files to include (e.g. *.js, src/*)",className:"w-full bg-paper border border-ink/20 rounded text-xs px-2 py-1.5 focus:outline-none focus:border-ink/40 focus:ring-1 focus:ring-ink/10 transition-all text-ink placeholder-ink/40"})})]}),E&&N.length===0?e("div",{className:"flex-1 px-3 py-3",role:"alert",children:e("div",{className:"rounded border border-error/30 bg-error/5 px-2.5 py-2",children:[e("div",{className:"text-[11px] font-semibold text-error",children:"Search failed"}),e("div",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-[10.5px] text-ink/70",children:E}),x&&e("div",{className:"mt-1 text-[10.5px] text-ink/50",children:["Regex is on — escape metacharacters such as ",e("code",{className:"font-mono",children:"( ) [ ] * ? +"})," or turn it off to search literally."]})]})}):G&&N.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"Searching..."}):r.trim().length<=2?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"Type at least 3 characters to search."}):N.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"No results found."}):e(d,{children:[E&&e("div",{className:"px-3 pt-2 text-[10.5px] text-error",role:"alert",children:["Search failed: ",e("span",{className:"font-mono",children:E})]}),G&&e("div",{className:"px-3 pt-2 text-ink/40 italic",children:"Searching…"}),q&&e("div",{className:"px-3 pt-2 text-ink/50 italic",children:["Showing the first ",se," matches — refine the query to see the rest."]}),e(ce,{groups:Q,replacement:c,showReplacePreview:c.length>0,onOpen:de,onReplaceFile:fe,replaceBusy:J})]})]})}function pe(s){let[r,t]=n({scope:s,results:[],truncated:!1,error:null}),[c,m]=n(!1),l=i(null),S=i(!0),k=i(s);k.current=s,o(()=>(S.current=!0,()=>{S.current=!1,l.current?.abort(),l.current=null}),[]);let b=a(async(x)=>{l.current?.abort();let C=new AbortController;l.current=C;let g=k.current;t({scope:g,results:[],truncated:!1,error:null}),m(!0);try{let O=await fetch("/api/fs/search",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams(x),signal:C.signal});await Tc(O,(y,F)=>{if(k.current!==g)return;if(y==="done"){let v=!1;try{v=JSON.parse(F)?.truncated===!0}catch{}t((R)=>R.scope===g?{...R,truncated:v}:R);return}if(y==="error"){let v="Search failed";try{v=JSON.parse(F)?.error||v}catch{}t((R)=>R.scope===g?{...R,error:v}:R);return}if(y!=="matches")return;try{let v=JSON.parse(F);if(Array.isArray(v))t((R)=>R.scope===g?{...R,results:[...R.results,...v]}:R)}catch{}},C.signal)}catch{}finally{if(S.current&&l.current===C)l.current=null,m(!1)}},[]);return{results:r.scope===s?r.results:[],isSearching:c&&r.scope===s,truncated:r.scope===s&&r.truncated,error:r.scope===s?r.error:null,start:b}}function it({className:s="",enabled:r=!0,rootPath:t,onOpenFile:c,tabsMode:m=!1}){let[l,S]=T("search.query",""),[k,b]=T("search.replaceQuery",""),[x,C]=T("search.matchCase",!1),[g,O]=T("search.wholeWord",!1),[y,F]=T("search.useRegex",!1),[v,R]=T("search.includeFiles",""),[H,A]=n(!1),[L,_]=T("search.showIncludeField",!1),{activeRepo:p,setActiveRepo:w}=xr(t),{repos:M,scanning:N,rescan:G}=wr(t,r),q=i(null),E=ft(),{results:z,isSearching:D,truncated:J,error:Y,start:Q}=pe(`${t??""}\x00${p}`);he(q,()=>A(!1));let P=a(()=>{if(!r)return;if(l.trim().length>2)return Q({q:l,matchCase:String(x),wholeWord:String(g),useRegex:String(y),includeFiles:L?v:"",...t?{root:t}:{},...p!=="."?{repo:p}:{}})},[r,l,x,g,y,L,v,t,p,Q]);o(()=>{let B=setTimeout(()=>{P()},300);return()=>clearTimeout(B)},[P]);let X=a((B)=>{if(!l)return;let j=B?[B]:Array.from(new Set(z.map((V)=>V.file)));if(j.length===0)return;E.submit({q:l,replaceWith:k,matchCase:String(x),wholeWord:String(g),useRegex:String(y),files:JSON.stringify(j),...t?{root:t}:{},...p!=="."?{repo:p}:{}},{method:"POST",action:"/api/fs/replace"})},[l,k,x,g,y,z,t,p,E]);if(o(()=>{if(E.state==="idle"&&E.data?.success)P()},[E.state,E.data,P]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${s}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e(ue,{className:s,tabsMode:m,query:l,setQuery:S,replaceQuery:k,setReplaceQuery:b,matchCase:x,setMatchCase:C,wholeWord:g,setWholeWord:O,useRegex:y,setUseRegex:F,includeFiles:v,setIncludeFiles:R,showIncludeField:L,setShowIncludeField:_,showMenu:H,setShowMenu:A,menuRef:q,rootPath:t,activeRepo:p,setActiveRepo:w,repos:M,reposScanning:N,rescanRepos:G,results:z,isSearching:D,truncated:J,error:Y,onOpenFile:c,handleReplace:X,replaceBusy:E.state!=="idle"})}export{it as SearchPanel};
1
+ import{d,n,o,K,i,u,a,ln,e,_e,as,f,os,is,ss,U,cs,h,T,xr,wr,xt,so,he,Ci,kl,mt,ft,gt,Dd,Tc}from"./index-8w69r0c4.js";import{Tr}from"./index-gr5wd7hv.js";var me=2000,W=new Map;function ge(s){if(s.length===0)return"";let r="";for(let t of s)r+=`${t.start}-${t.end},`;return r}function ee(s,r,t){let c=Ci(r),m=`${r}\x00${ge(t)}\x00${s}`;if(c){let S=W.get(m);if(S!==void 0)return W.delete(m),W.set(m,S),S}let l=kl(s,r,{marks:t});if(!c)return l;if(W.set(m,l),W.size>me){let S=W.keys().next();if(!S.done)W.delete(S.value)}return l}function te(s,r,t){let c=[],m=0;for(let l of r){if(l.start<m||l.end<=l.start||l.end>s.length)continue;if(l.start>m)c.push({text:s.slice(m,l.start),kind:"plain"});if(c.push({text:s.slice(l.start,l.end),kind:"removed"}),t)c.push({text:t,kind:"inserted"});m=l.end}if(m<s.length)c.push({text:s.slice(m),kind:"plain"});return c}function be({file:s,result:r,replacement:t,showReplacePreview:c,onOpen:m}){let l=r.ranges??[],S=c&&t.length>0;return e("button",{type:"button",onClick:()=>m(r),className:"flex w-full items-start gap-2 rounded px-1 py-0.5 text-left hover:bg-ink/5 cursor-pointer",title:`Open ${s}:${r.line}`,children:[e("span",{className:"w-6 flex-shrink-0 text-right font-mono text-ink/40",children:r.line}),S?e("span",{className:"min-w-0 truncate font-mono text-ink",children:te(r.content,l,t).map((k,b)=>k.kind==="plain"?e("span",{children:k.text},b):k.kind==="removed"?e("del",{className:"search-replace-old",children:k.text},b):e("ins",{className:"search-replace-new",children:k.text},b))}):e("span",{className:"min-w-0 truncate font-mono text-ink",dangerouslySetInnerHTML:{__html:ee(r.content,gt(s),l)}})]})}var re=ln(be);var Z={header:4,hit:4,group:16},ne={headerBox:16,hitBox:20},se=5000;function oe(s){let r=[],t=null;for(let c of s){if(!t||t.file!==c.file)t={file:c.file,results:[]},r.push(t);t.results.push(c)}return r}function ie(s){let r=[];for(let t of s){r.push({kind:"group",file:t.file,count:t.results.length});for(let c=0;c<t.results.length;c++)r.push({kind:"hit",file:t.file,result:t.results[c],last:c===t.results.length-1})}return r}function xe(s,r){if(s.kind==="group")return r.headerBox+Z.header;return r.hitBox+(s.last?Z.group:Z.hit)}function ae(s,r){let t=Array(s.length),c=Array(s.length),m=0;for(let l=0;l<s.length;l++){let S=xe(s[l],r);t[l]=m,c[l]=S,m+=S}return{offsets:t,heights:c,total:m}}function le(s,r,t,c,m=240){if(s.length===0)return{start:0,end:0};let l=Math.max(0,t),S=l-m,k=l+c+m,b=0,x=s.length-1;while(b<x){let g=b+x>>1;if(s[g]+r[g]>S)x=g;else b=g+1}let C=b;b=C,x=s.length;while(b<x){let g=b+x>>1;if(s[g]>=k)x=g;else b=g+1}return{start:C,end:b}}var Se=8,ve=8;function ce({groups:s,replacement:r,showReplacePreview:t,onOpen:c,onReplaceFile:m,replaceBusy:l}){let S=i(null),k=i(null),b=u(()=>ie(s),[s]),[x,C]=n(ne),g=u(()=>ae(b,x),[b,x]),[O,y]=n(()=>({start:0,end:Math.min(b.length,60)})),F=a((p)=>{S.current=p},[]),v=a(()=>{let p=S.current;if(!p)return;let w=le(g.offsets,g.heights,p.scrollTop,p.clientHeight);y((M)=>M.start===w.start&&M.end===w.end?M:w)},[g]),R=a(()=>{v()},[v]);K(()=>{let p=k.current;if(!p)return;let w=p.querySelector("[data-search-header] > div")?.offsetHeight??0,M=p.querySelector("[data-search-hit] > button")?.offsetHeight??0;if(w>0&&w!==x.headerBox)C((N)=>({...N,headerBox:w}));if(M>0&&M!==x.hitBox)C((N)=>({...N,hitBox:M}))},[O,x,b]),K(()=>{v()},[v]),K(()=>{let p=S.current;if(!p||typeof ResizeObserver>"u")return;let w=new ResizeObserver(()=>v());return w.observe(p),()=>w.disconnect()},[v]);let H=b.length===0?0:Math.min(O.start,b.length-1),A=Math.min(O.end,b.length),L=b.slice(H,A),_=A<b.length?g.total-g.offsets[A]:0;return e("div",{ref:F,onScroll:R,className:"flex-1 scrollbar-overlay-container px-3 text-xs",style:{overflowAnchor:"none"},children:[e("div",{style:{height:Se+(g.offsets[H]??0)},"aria-hidden":"true"}),e("div",{ref:k,children:L.map((p,w)=>{let M=H+w,N=g.heights[M];if(p.kind==="group")return e("div",{"data-search-header":"",style:{height:N},children:e("div",{className:"font-semibold text-ink/80 flex items-center justify-between group",children:[e("div",{className:"flex items-center min-w-0",children:[e(mt,{name:p.file,size:12,className:"mr-1.5 flex-shrink-0"}),e("span",{className:"truncate",children:p.file}),e("span",{className:"ml-2 bg-ink/10 text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",children:p.count})]}),e("button",{onClick:()=>m(p.file),disabled:l,className:"touch-visible opacity-0 group-hover:opacity-100 p-1 text-ink/40 hover:text-ink rounded hover:bg-ink/5 disabled:opacity-50 flex-shrink-0",title:"Replace in this file",children:e(ss,{size:12})})]})},`group:${p.file}`);return e("div",{"data-search-hit":"",style:{height:N},children:e(re,{file:p.file,result:p.result,replacement:r,showReplacePreview:t,onOpen:c})},`hit:${p.file}:${p.result.line}:${M}`)})}),e("div",{style:{height:ve+_},"aria-hidden":"true"})]})}function ue({className:s,query:r,setQuery:t,replaceQuery:c,setReplaceQuery:m,matchCase:l,setMatchCase:S,wholeWord:k,setWholeWord:b,useRegex:x,setUseRegex:C,includeFiles:g,setIncludeFiles:O,showIncludeField:y,setShowIncludeField:F,showMenu:v,setShowMenu:R,menuRef:H,rootPath:A,activeRepo:L,setActiveRepo:_,repos:p,reposScanning:w,rescanRepos:M,results:N,isSearching:G,truncated:q,error:E,onOpenFile:z,handleReplace:D,replaceBusy:J,tabsMode:Y=!1}){let Q=u(()=>oe(N),[N]),P=i(null),X=i(null),B=a(()=>{t(""),P.current?.focus()},[t]),j=a(()=>{m(""),X.current?.focus()},[m]),V=u(()=>({matchCase:l,wholeWord:k,isRegex:x,inSelection:!1}),[l,k,x]),de=a((I)=>{Dd({path:I.file,line:Number(I.line),query:r,options:V}),z?.({path:I.file,name:I.file.split("/").pop()||I.file,root:A,repo:L})},[r,V,A,L,z]),fe=a((I)=>D(I),[D]);return e("div",{className:`flex flex-col h-full bg-paper ${s}`,children:[e(xt,{left:e(d,{children:[e(so,{id:"search",tabsMode:Y,children:e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Search"})}),e(Tr,{rootPath:A,activeRepo:L,onSelectRepo:_,repos:p,scanning:w,onRefreshRepos:M})]}),right:e("div",{className:"relative",ref:H,children:[e("button",{onClick:()=>R(!v),className:`p-1 rounded hover:bg-ink/5 transition-colors ${v||y?"text-ink":"text-ink/40"}`,title:"Search Options",children:e(_e,{size:14})}),v&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-48 bg-paper border border-ink/10 rounded shadow-lg z-10 py-1",children:e("button",{onClick:()=>{if(F(!y),y)O("");R(!1)},className:"w-full px-3 py-1.5 text-left text-xs text-ink hover:bg-ink/5 flex items-center justify-between",children:[e("span",{children:"Files to include"}),y&&e(f,{size:12,className:"text-ink/60"})]})})]})}),e("div",{className:"p-3 flex flex-col gap-2.5 border-b border-ink/10",children:[e("div",{className:"relative",children:e("div",{className:"flex items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e(U,{size:14,className:"ml-2 text-ink/40 flex-shrink-0"}),e("input",{ref:P,type:"text",placeholder:"Search",value:r,onChange:(I)=>t(I.currentTarget.value),className:"w-full bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35 min-w-0"}),r&&e("button",{type:"button",onClick:B,title:"Clear search","aria-label":"Clear search",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(h,{size:12})}),e("div",{className:"flex items-center space-x-0.5 pr-1 text-ink/40 flex-shrink-0",children:[e("button",{onClick:()=>S(!l),className:`p-1 rounded hover:text-ink ${l?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Case",children:e(as,{size:14})}),e("button",{onClick:()=>b(!k),className:`p-1 rounded hover:text-ink ${k?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Whole Word",children:e(cs,{size:14})}),e("button",{onClick:()=>C(!x),className:`p-1 rounded hover:text-ink ${x?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Use Regular Expression",children:e(os,{size:14})})]})]})}),e("div",{className:"relative flex items-center space-x-1",children:[e("div",{className:"flex flex-1 min-w-0 items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e("input",{ref:X,type:"text",placeholder:"Replace",value:c,onChange:(I)=>m(I.currentTarget.value),className:"flex-1 min-w-0 bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35"}),c&&e("button",{type:"button",onClick:j,title:"Clear replace","aria-label":"Clear replace",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(h,{size:12})})]}),e("button",{onClick:()=>D(),disabled:N.length===0||J,className:"p-1.5 rounded border border-ink/20 text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-50 disabled:cursor-not-allowed bg-paper",title:"Replace All",children:e(is,{size:14})})]}),y&&e("div",{className:"relative",children:e("input",{type:"text",value:g,onChange:(I)=>O(I.currentTarget.value),placeholder:"Files to include (e.g. *.js, src/*)",className:"w-full bg-paper border border-ink/20 rounded text-xs px-2 py-1.5 focus:outline-none focus:border-ink/40 focus:ring-1 focus:ring-ink/10 transition-all text-ink placeholder-ink/40"})})]}),E&&N.length===0?e("div",{className:"flex-1 px-3 py-3",role:"alert",children:e("div",{className:"rounded border border-error/30 bg-error/5 px-2.5 py-2",children:[e("div",{className:"text-[11px] font-semibold text-error",children:"Search failed"}),e("div",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-[10.5px] text-ink/70",children:E}),x&&e("div",{className:"mt-1 text-[10.5px] text-ink/50",children:["Regex is on — escape metacharacters such as ",e("code",{className:"font-mono",children:"( ) [ ] * ? +"})," or turn it off to search literally."]})]})}):G&&N.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"Searching..."}):r.trim().length<=2?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"Type at least 3 characters to search."}):N.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4",children:"No results found."}):e(d,{children:[E&&e("div",{className:"px-3 pt-2 text-[10.5px] text-error",role:"alert",children:["Search failed: ",e("span",{className:"font-mono",children:E})]}),G&&e("div",{className:"px-3 pt-2 text-ink/40 italic",children:"Searching…"}),q&&e("div",{className:"px-3 pt-2 text-ink/50 italic",children:["Showing the first ",se," matches — refine the query to see the rest."]}),e(ce,{groups:Q,replacement:c,showReplacePreview:c.length>0,onOpen:de,onReplaceFile:fe,replaceBusy:J})]})]})}function pe(s){let[r,t]=n({scope:s,results:[],truncated:!1,error:null}),[c,m]=n(!1),l=i(null),S=i(!0),k=i(s);k.current=s,o(()=>(S.current=!0,()=>{S.current=!1,l.current?.abort(),l.current=null}),[]);let b=a(async(x)=>{l.current?.abort();let C=new AbortController;l.current=C;let g=k.current;t({scope:g,results:[],truncated:!1,error:null}),m(!0);try{let O=await fetch("/api/fs/search",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams(x),signal:C.signal});await Tc(O,(y,F)=>{if(k.current!==g)return;if(y==="done"){let v=!1;try{v=JSON.parse(F)?.truncated===!0}catch{}t((R)=>R.scope===g?{...R,truncated:v}:R);return}if(y==="error"){let v="Search failed";try{v=JSON.parse(F)?.error||v}catch{}t((R)=>R.scope===g?{...R,error:v}:R);return}if(y!=="matches")return;try{let v=JSON.parse(F);if(Array.isArray(v))t((R)=>R.scope===g?{...R,results:[...R.results,...v]}:R)}catch{}},C.signal)}catch{}finally{if(S.current&&l.current===C)l.current=null,m(!1)}},[]);return{results:r.scope===s?r.results:[],isSearching:c&&r.scope===s,truncated:r.scope===s&&r.truncated,error:r.scope===s?r.error:null,start:b}}function it({className:s="",enabled:r=!0,rootPath:t,onOpenFile:c,tabsMode:m=!1}){let[l,S]=T("search.query",""),[k,b]=T("search.replaceQuery",""),[x,C]=T("search.matchCase",!1),[g,O]=T("search.wholeWord",!1),[y,F]=T("search.useRegex",!1),[v,R]=T("search.includeFiles",""),[H,A]=n(!1),[L,_]=T("search.showIncludeField",!1),{activeRepo:p,setActiveRepo:w}=xr(t),{repos:M,scanning:N,rescan:G}=wr(t,r),q=i(null),E=ft(),{results:z,isSearching:D,truncated:J,error:Y,start:Q}=pe(`${t??""}\x00${p}`);he(q,()=>A(!1));let P=a(()=>{if(!r)return;if(l.trim().length>2)return Q({q:l,matchCase:String(x),wholeWord:String(g),useRegex:String(y),includeFiles:L?v:"",...t?{root:t}:{},...p!=="."?{repo:p}:{}})},[r,l,x,g,y,L,v,t,p,Q]);o(()=>{let B=setTimeout(()=>{P()},300);return()=>clearTimeout(B)},[P]);let X=a((B)=>{if(!l)return;let j=B?[B]:Array.from(new Set(z.map((V)=>V.file)));if(j.length===0)return;E.submit({q:l,replaceWith:k,matchCase:String(x),wholeWord:String(g),useRegex:String(y),files:JSON.stringify(j),...t?{root:t}:{},...p!=="."?{repo:p}:{}},{method:"POST",action:"/api/fs/replace"})},[l,k,x,g,y,z,t,p,E]);if(o(()=>{if(E.state==="idle"&&E.data?.success)P()},[E.state,E.data,P]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${s}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e(ue,{className:s,tabsMode:m,query:l,setQuery:S,replaceQuery:k,setReplaceQuery:b,matchCase:x,setMatchCase:C,wholeWord:g,setWholeWord:O,useRegex:y,setUseRegex:F,includeFiles:v,setIncludeFiles:R,showIncludeField:L,setShowIncludeField:_,showMenu:H,setShowMenu:A,menuRef:q,rootPath:t,activeRepo:p,setActiveRepo:w,repos:M,reposScanning:N,rescanRepos:G,results:z,isSearching:D,truncated:J,error:Y,onOpenFile:c,handleReplace:X,replaceBusy:E.state!=="idle"})}export{it as SearchPanel};