@kabmo-labs/kabmo 0.32.0 → 0.32.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 (224) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +308 -308
  3. package/dist/client/static/js/{CsvGrid-amafmq3z.js → CsvGrid-4gx0jevc.js} +2 -2
  4. package/dist/client/static/js/{DocxView-851ps9t0.js → DocxView-0667nr8h.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-kw1vy3r2.js → DrawioView-522v0d0r.js} +2 -2
  6. package/dist/client/static/js/ImageView-t8xp60hm.js +1 -0
  7. package/dist/client/static/js/LayoutWrapper-xjnveecv.js +2 -0
  8. package/dist/client/static/js/{Modal-f8x3j3be.js → Modal-k2jr9hc4.js} +14 -14
  9. package/dist/client/static/js/{PdfView-f5jkm0rs.js → PdfView-3fx172xh.js} +1 -1
  10. package/dist/client/static/js/SessionsView-n3agmf5t.js +1 -0
  11. package/dist/client/static/js/{SheetView-23zxy30b.js → SheetView-nmrdb1b8.js} +23 -23
  12. package/dist/client/static/js/{SvgPreview-c341y50e.js → SvgPreview-0xsc6xam.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-2dc3mpk6.js → abnfDiagram-O67JEVCF-jj31rs62.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-1y9zvsyt.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-7jmrr5ja.js → architectureDiagram-NJMV4G6O-ay3yr7pf.js} +3 -3
  16. package/dist/client/static/js/{astro-sjtf954j.js → astro-qgx1r159.js} +1 -1
  17. package/dist/client/static/js/bash-m0qjsyy0.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-jrk2m0ea.js → blockDiagram-BEXU5L5S-4x33e16k.js} +3 -3
  19. package/dist/client/static/js/c-wkgxb1t1.js +1 -0
  20. package/dist/client/static/js/{c4Diagram-YGBWAQC7-48cyncjd.js → c4Diagram-YGBWAQC7-dtb81cgz.js} +2 -2
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-gm7jt1cd.js → classDiagram-v2-NBCMYWYE-vk5a2n9w.js} +3 -3
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-g0g3z0xp.js → cose-bilkent-JH36ORCC-6rbjbe19.js} +1 -1
  23. package/dist/client/static/js/cpp-y0t6mynx.js +1 -0
  24. package/dist/client/static/js/css-t4ngafan.js +1 -0
  25. package/dist/client/static/js/cynefin-OW5HDTMX-k2188qcq.js +1 -0
  26. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-6vjde6am.js → cynefinDiagram-VND7K2PF-vyjksedr.js} +2 -2
  27. package/dist/client/static/js/{dagre-6A5THRUB-q6k8bx1j.js → dagre-6A5THRUB-7hey38z5.js} +2 -2
  28. package/dist/client/static/js/{diagram-22UHCM2B-87cmze2n.js → diagram-22UHCM2B-aes06jde.js} +11 -11
  29. package/dist/client/static/js/{diagram-3UASUU5V-1ejbr2p4.js → diagram-3UASUU5V-3cfkgm3x.js} +1 -1
  30. package/dist/client/static/js/{diagram-ATOU4E4O-vaw1r6k2.js → diagram-ATOU4E4O-z8mfhwpy.js} +3 -3
  31. package/dist/client/static/js/{diagram-CDSNMT55-gxm9zv7d.js → diagram-CDSNMT55-t4821ctz.js} +2 -2
  32. package/dist/client/static/js/{diagram-MLGK6HIB-x010xswm.js → diagram-MLGK6HIB-23yxbfrx.js} +1 -1
  33. package/dist/client/static/js/{diagram-MPIPVDR6-qtcq7e6c.js → diagram-MPIPVDR6-chhtf7v0.js} +2 -2
  34. package/dist/client/static/js/{dockerfile-k5xbramm.js → dockerfile-5b87ghm7.js} +1 -1
  35. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-nwwbasfh.js → ebnfDiagram-ZINNZB2B-9jejcvfr.js} +1 -1
  36. package/dist/client/static/js/{elk-276RUBZZ-xcp7thax.js → elk-276RUBZZ-xhhtkf58.js} +1 -1
  37. package/dist/client/static/js/{erDiagram-OPXOYQCR-xj1tp716.js → erDiagram-OPXOYQCR-mt2apjjb.js} +5 -5
  38. package/dist/client/static/js/{erlang-rz1g9mxy.js → erlang-6m6tpt72.js} +1 -1
  39. package/dist/client/static/js/eventmodeling-NTZA5JFV-pdr0qn0n.js +1 -0
  40. package/dist/client/static/js/flowDiagram-KWPJA3E3-zvz0mxne.js +1 -0
  41. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-f7q96bea.js → ganttDiagram-FUAMR5RP-8cm7a29w.js} +3 -3
  42. package/dist/client/static/js/gitGraph-4MIJSDKK-wmqf046s.js +1 -0
  43. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-1rydkyq9.js → gitGraphDiagram-X574FWY7-5s0gbnx2.js} +2 -2
  44. package/dist/client/static/js/graphql-692h0n2x.js +1 -0
  45. package/dist/client/static/js/{index-52bgxh6f.js → index-2gfc25tq.js} +1 -1
  46. package/dist/client/static/js/{index-x64kqgen.js → index-2xj14800.js} +2 -2
  47. package/dist/client/static/js/{index-8m3q2zpb.js → index-360d7j0d.js} +1 -1
  48. package/dist/client/static/js/{index-123e8tqq.js → index-3vhznzgr.js} +1 -1
  49. package/dist/client/static/js/{index-y139vc12.js → index-4s8ttfxj.js} +175 -175
  50. package/dist/client/static/js/{index-9nbxb421.js → index-532btjmp.js} +2 -2
  51. package/dist/client/static/js/{index-c8jzx6b0.js → index-59jb53v3.js} +1 -1
  52. package/dist/client/static/js/{index-2t2tnc3x.js → index-5x95n3hx.js} +1 -1
  53. package/dist/client/static/js/{index-f63y3mjj.js → index-5y7c62sm.js} +4 -4
  54. package/dist/client/static/js/index-61tm0v57.js +1 -0
  55. package/dist/client/static/js/{index-fc2j6bq2.js → index-629kfbcb.js} +2 -2
  56. package/dist/client/static/js/{index-0n9c85ke.js → index-6q80csr0.js} +2 -2
  57. package/dist/client/static/js/{index-6sdctwv2.js → index-7fdp9c7m.js} +2 -2
  58. package/dist/client/static/js/index-7n68yx6m.js +2 -0
  59. package/dist/client/static/js/{index-pe9j88d4.js → index-9sd0vjmh.js} +2 -2
  60. package/dist/client/static/js/{index-m6wwc5h6.js → index-9t82sx0w.js} +2 -2
  61. package/dist/client/static/js/{index-xa7nrnda.js → index-a0bdavdr.js} +2 -2
  62. package/dist/client/static/js/{index-xpf2ra60.js → index-a6k2hqke.js} +1 -1
  63. package/dist/client/static/js/{index-e26rd868.js → index-a733k69t.js} +2 -2
  64. package/dist/client/static/js/{index-31jrebvn.js → index-ay34b398.js} +6 -6
  65. package/dist/client/static/js/{index-w4re5r8w.js → index-bbggh3f8.js} +2 -2
  66. package/dist/client/static/js/{index-73xfkyea.js → index-brj8qwa6.js} +2 -2
  67. package/dist/client/static/js/{index-fmxn1rzs.js → index-c0x6s6f7.js} +2 -2
  68. package/dist/client/static/js/{index-vmvcse63.js → index-c93sp4yh.js} +1 -1
  69. package/dist/client/static/js/{index-e7a3fkvv.js → index-dnp07j57.js} +1 -1
  70. package/dist/client/static/js/{index-pkyrkkbt.js → index-dq1kdt03.js} +2 -2
  71. package/dist/client/static/js/{index-ggaqh9rt.js → index-dt7e1328.js} +2 -2
  72. package/dist/client/static/js/{index-hkq0y3pn.js → index-ehcpzk5b.js} +2 -2
  73. package/dist/client/static/js/{index-tr8754r0.js → index-ejgd8w3s.js} +45 -45
  74. package/dist/client/static/js/{index-0a1ekhqf.js → index-fdbfzshx.js} +2 -2
  75. package/dist/client/static/js/{index-c20a46ww.js → index-g33knza2.js} +2 -2
  76. package/dist/client/static/js/{index-hhm62nfj.js → index-gbfg0anm.js} +2 -2
  77. package/dist/client/static/js/{index-2n5wy1sh.js → index-h06bcfds.js} +1 -1
  78. package/dist/client/static/js/{index-22jaxtz1.js → index-h7pn9qw6.js} +2 -2
  79. package/dist/client/static/js/{index-qmh0h87h.js → index-hc2jmzpx.js} +48 -48
  80. package/dist/client/static/js/{index-nsrnyqcm.js → index-jppt5mgc.js} +2 -2
  81. package/dist/client/static/js/{index-deex10rz.js → index-jz9fpznk.js} +5 -5
  82. package/dist/client/static/js/{index-r416e9dt.js → index-kg86e3sy.js} +11 -11
  83. package/dist/client/static/js/{index-e6rar25v.js → index-kpspnztv.js} +2 -2
  84. package/dist/client/static/js/index-nmmxb4va.js +2 -0
  85. package/dist/client/static/js/{index-zca66d5d.js → index-p7btwjvj.js} +3 -3
  86. package/dist/client/static/js/{index-gvwqjpcr.js → index-pf5sbesf.js} +2 -2
  87. package/dist/client/static/js/{index-ynqnbvn2.js → index-pf7syd7t.js} +3 -3
  88. package/dist/client/static/js/{index-3anc30zh.js → index-qkscve6n.js} +2 -2
  89. package/dist/client/static/js/index-qnwqaczk.js +4 -0
  90. package/dist/client/static/js/{index-5zd1jx9r.js → index-rg8jpbsw.js} +2 -2
  91. package/dist/client/static/js/{index-hyry1n8x.js → index-sa9cp6km.js} +2 -2
  92. package/dist/client/static/js/{index-f519m6s3.js → index-vd0e25p0.js} +1 -1
  93. package/dist/client/static/js/{index-cwaz6geq.js → index-vtbbfwx0.js} +2 -2
  94. package/dist/client/static/js/{index-14wppnkx.js → index-wzma5n54.js} +2 -2
  95. package/dist/client/static/js/{index-s9vp6p70.js → index-x07kp3jz.js} +2 -2
  96. package/dist/client/static/js/{index-8a3tmm1h.js → index-xj9649ac.js} +7 -7
  97. package/dist/client/static/js/{index-vrbcj11n.js → index-xya34x4v.js} +2 -2
  98. package/dist/client/static/js/{index-yvcpdk5f.js → index-ye3sr7db.js} +2 -2
  99. package/dist/client/static/js/{index-w5131mtt.js → index-z4v1xmh1.js} +2 -2
  100. package/dist/client/static/js/{index-0g25yrc0.js → index-z5s27s26.js} +1 -1
  101. package/dist/client/static/js/info-A6RAGUB7-zg3twte6.js +1 -0
  102. package/dist/client/static/js/{infoDiagram-VRGFBTTK-ptg07tp2.js → infoDiagram-VRGFBTTK-3w1yz32c.js} +1 -1
  103. package/dist/client/static/js/ini-cg0a5wm3.js +1 -0
  104. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-bdk2dkf5.js → ishikawaDiagram-OU5B5YK6-ckt471dy.js} +1 -1
  105. package/dist/client/static/js/java-vcck089n.js +1 -0
  106. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kez0ha4c.js → journeyDiagram-ZHPQQLJL-kfvn4w7e.js} +2 -2
  107. package/dist/client/static/js/json-j5q8nt57.js +1 -0
  108. package/dist/client/static/js/jsx-ht9zyzwa.js +1 -0
  109. package/dist/client/static/js/{julia-nmr85k8z.js → julia-0j0gsjvc.js} +1 -1
  110. package/dist/client/static/js/{kanban-definition-PNTS6WVX-dhzp3qg5.js → kanban-definition-PNTS6WVX-0q36cm83.js} +3 -3
  111. package/dist/client/static/js/lua-ke895s2q.js +1 -0
  112. package/dist/client/static/js/markdown-gwmsh53r.js +1 -0
  113. package/dist/client/static/js/{mermaid.core-h7wttbss.js → mermaid.core-b1ssa824.js} +7 -7
  114. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-tq5dd1em.js → mindmap-definition-NLK3R4M7-e2ym5en8.js} +4 -4
  115. package/dist/client/static/js/one-dark-pro-4geyzhjj.js +1 -0
  116. package/dist/client/static/js/one-light-tqssjm9t.js +1 -0
  117. package/dist/client/static/js/packet-AYTQ26CC-3pav51g0.js +1 -0
  118. package/dist/client/static/js/{pegDiagram-GJSIUBJH-e5hrdfzv.js → pegDiagram-GJSIUBJH-t8bbdyhe.js} +1 -1
  119. package/dist/client/static/js/{perl-prxcva8r.js → perl-7n7e9ncg.js} +1 -1
  120. package/dist/client/static/js/{php-m9kcctzs.js → php-32vy69vd.js} +1 -1
  121. package/dist/client/static/js/pie-WAS4IAKB-wqfh7zdk.js +1 -0
  122. package/dist/client/static/js/{pieDiagram-5QR66LMP-axvbvnz8.js → pieDiagram-5QR66LMP-envv4brj.js} +2 -2
  123. package/dist/client/static/js/properties-mzvvbqg5.js +1 -0
  124. package/dist/client/static/js/python-3w64wsyd.js +1 -0
  125. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-wtn28cfm.js → quadrantDiagram-O4NWA36T-72rk137a.js} +3 -3
  126. package/dist/client/static/js/r-32re2zwb.js +1 -0
  127. package/dist/client/static/js/radar-RG4KPBEZ-w7qjdr2g.js +1 -0
  128. package/dist/client/static/js/railroad-74A4TZTK-rhr99kkj.js +1 -0
  129. package/dist/client/static/js/railroad-abnf-HS5TGJTU-c4jeea3m.js +1 -0
  130. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-x2ee66ex.js +1 -0
  131. package/dist/client/static/js/railroad-peg-WCYAUIDC-yw8wjfwg.js +1 -0
  132. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-avjkq945.js → railroadDiagram-XR7U4H2S-1ej0f5hr.js} +1 -1
  133. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bntx7r6q.js → requirementDiagram-PLB6GJNP-rvdaknpd.js} +3 -3
  134. package/dist/client/static/js/{ruby-t06c0e7g.js → ruby-5ty7fys7.js} +1 -1
  135. package/dist/client/static/js/{rust-6gqjxyf0.js → rust-2geezrcs.js} +1 -1
  136. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-ps8nkdm2.js → sankeyDiagram-IPEJSGJF-nxvhtdaw.js} +3 -3
  137. package/dist/client/static/js/{sass-gsbyn3wh.js → sass-mey5150f.js} +1 -1
  138. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3ckf1q6z.js → sequenceDiagram-PO4LG4MO-n5cn5qrt.js} +6 -6
  139. package/dist/client/static/js/{sizeCapture-INFHLROL-akvcr1x7.js → sizeCapture-INFHLROL-r074kj7s.js} +1 -1
  140. package/dist/client/static/js/sql-g8wcshpc.js +1 -0
  141. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-c82914fz.js → stateDiagram-v2-GCMORJYK-vxghxdb0.js} +3 -3
  142. package/dist/client/static/js/{svelte-j54gfrvq.js → svelte-3ewx0hzx.js} +1 -1
  143. package/dist/client/static/js/{swimlanes-2SLR337P-scgdefh4.js → swimlanes-2SLR337P-qkkv894p.js} +1 -1
  144. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-y81h9n27.js +8 -0
  145. package/dist/client/static/js/{timeline-definition-EJHVYXUP-z2ha1rhq.js → timeline-definition-EJHVYXUP-5tbq4ex2.js} +2 -2
  146. package/dist/client/static/js/treeView-Q6P3EWNA-ekz05ccs.js +1 -0
  147. package/dist/client/static/js/treemap-WGGIJYW6-aq6qymjr.js +1 -0
  148. package/dist/client/static/js/tsx-0p183w2f.js +1 -0
  149. package/dist/client/static/js/typescript-t9a5jyvv.js +1 -0
  150. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-3wdmrfmk.js → usecaseDiagram-POWQR4AR-6p8hf0b7.js} +15 -15
  151. package/dist/client/static/js/{vennDiagram-UO4OBE2U-7m5tatzv.js → vennDiagram-UO4OBE2U-7k5jsxf9.js} +1 -1
  152. package/dist/client/static/js/{vue-y8bb5f3h.js → vue-06rdf4wh.js} +1 -1
  153. package/dist/client/static/js/wardley-WFR3VGLG-z34tj4y3.js +1 -0
  154. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-55ps9s4z.js → wardleyDiagram-VNRHLVJA-km2x4er8.js} +3 -3
  155. package/dist/client/static/js/xml-81hxjjt4.js +1 -0
  156. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-8bsjtm4t.js → xychartDiagram-PMCCYNJV-kr3sgr4m.js} +2 -2
  157. package/dist/client/static/js/yaml-yssayv8a.js +1 -0
  158. package/package.json +1 -1
  159. package/src/client/components/common/session-actions-menu/index.tsx +6 -1
  160. package/src/client/components/layout/session-sidebar/SessionsView.tsx +20 -33
  161. package/src/client/components/mobile/LayoutWrapper.tsx +16 -26
  162. package/src/client/components/mobile/worktree-session.ts +4 -1
  163. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +16 -15
  164. package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +11 -0
  165. package/src/client/hooks/chat/btw/mode.ts +5 -1
  166. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +9 -3
  167. package/src/client/hooks/chat/timeline/new-chat.ts +4 -1
  168. package/src/client/hooks/chat/timeline/pending-dispatch.ts +6 -10
  169. package/src/client/hooks/chat/waiting/dispatch.ts +4 -1
  170. package/src/client/hooks/workspace/batch-delete-run.ts +5 -1
  171. package/src/client/hooks/workspace/session-delete.ts +5 -1
  172. package/src/client/lib/router/branch-params.test.ts +62 -0
  173. package/src/client/lib/router/branch-params.ts +48 -0
  174. package/src/server/lib/assets/shell-settings.server.test.ts +35 -0
  175. package/src/server/lib/assets/shell-settings.server.ts +33 -0
  176. package/src/server/lib/realtime/topics/peer-relay.server.test.ts +1 -11
  177. package/src/server/plugins/ssr.ts +20 -8
  178. package/src/test-support/peer-harness.ts +13 -5
  179. package/dist/client/static/js/ImageView-ksx9bbct.js +0 -1
  180. package/dist/client/static/js/LayoutWrapper-9ftz050x.js +0 -2
  181. package/dist/client/static/js/SessionsView-wzdf1cp6.js +0 -1
  182. package/dist/client/static/js/architecture-7GRP2DOG-4wsd6vk0.js +0 -1
  183. package/dist/client/static/js/bash-h6pkqvth.js +0 -1
  184. package/dist/client/static/js/c-thbdzmwv.js +0 -1
  185. package/dist/client/static/js/cpp-r1za1kke.js +0 -1
  186. package/dist/client/static/js/css-qsv4vvke.js +0 -1
  187. package/dist/client/static/js/cynefin-OW5HDTMX-eycwde8c.js +0 -1
  188. package/dist/client/static/js/eventmodeling-NTZA5JFV-srqbnmey.js +0 -1
  189. package/dist/client/static/js/flowDiagram-KWPJA3E3-yj98317w.js +0 -1
  190. package/dist/client/static/js/gitGraph-4MIJSDKK-5jcrvn94.js +0 -1
  191. package/dist/client/static/js/graphql-275pg7ya.js +0 -1
  192. package/dist/client/static/js/index-b08zd4eq.js +0 -1
  193. package/dist/client/static/js/index-g0pkzanm.js +0 -2
  194. package/dist/client/static/js/index-ga2xdef3.js +0 -2
  195. package/dist/client/static/js/index-xzfsaqyz.js +0 -4
  196. package/dist/client/static/js/info-A6RAGUB7-mbt0ryx5.js +0 -1
  197. package/dist/client/static/js/ini-jqdrx98c.js +0 -1
  198. package/dist/client/static/js/java-70zqqrkr.js +0 -1
  199. package/dist/client/static/js/json-kxk8gfet.js +0 -1
  200. package/dist/client/static/js/jsx-h1035eqk.js +0 -1
  201. package/dist/client/static/js/lua-j2356waf.js +0 -1
  202. package/dist/client/static/js/markdown-ffw6rgk6.js +0 -1
  203. package/dist/client/static/js/one-dark-pro-8acf6cn2.js +0 -1
  204. package/dist/client/static/js/one-light-ysc1knem.js +0 -1
  205. package/dist/client/static/js/packet-AYTQ26CC-a5yw789s.js +0 -1
  206. package/dist/client/static/js/pie-WAS4IAKB-x0y4v4r2.js +0 -1
  207. package/dist/client/static/js/properties-55mrarxr.js +0 -1
  208. package/dist/client/static/js/python-dhypc3j4.js +0 -1
  209. package/dist/client/static/js/r-6b8dt1wp.js +0 -1
  210. package/dist/client/static/js/radar-RG4KPBEZ-trrc3ta1.js +0 -1
  211. package/dist/client/static/js/railroad-74A4TZTK-dxgvx21w.js +0 -1
  212. package/dist/client/static/js/railroad-abnf-HS5TGJTU-rbgkd8sk.js +0 -1
  213. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-exgw7j47.js +0 -1
  214. package/dist/client/static/js/railroad-peg-WCYAUIDC-28tpamzk.js +0 -1
  215. package/dist/client/static/js/sql-9dq913c8.js +0 -1
  216. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-0x2ashav.js +0 -8
  217. package/dist/client/static/js/treeView-Q6P3EWNA-1a00b6kc.js +0 -1
  218. package/dist/client/static/js/treemap-WGGIJYW6-2q4f2f7m.js +0 -1
  219. package/dist/client/static/js/tsx-wh5xgm7f.js +0 -1
  220. package/dist/client/static/js/typescript-ge85req5.js +0 -1
  221. package/dist/client/static/js/wardley-WFR3VGLG-x9v91the.js +0 -1
  222. package/dist/client/static/js/xml-7bgz40qa.js +0 -1
  223. package/dist/client/static/js/yaml-4ht9416k.js +0 -1
  224. package/src/client/components/layout/session-sidebar/new-session-context.test.ts +0 -55
@@ -1,2 +1,2 @@
1
- import{d,n,i,o,a,e,s,B,ne,ze,Fe,D,Wi,ft,Se,Ie,y,ee,ao,Cm}from"./index-y139vc12.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(F);function I({title:t,options:r,methodLabel:p,badge:m,icon:x,onCancel:g}){let f=ao({title:t,options:r})?Cm(t):null,v=f?`Allow ${f.tool}`:t||p;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:v}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Fe,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:g,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(y,{size:14})})]})}function T({options:t,optionDetails:r,selectedOption:p,customValue:m,onCustomChange:x,customInputRef:g,onSelect:f,onConfirmOption:v,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((b,h)=>{let u=p===b,k=r[h]?.description;return e("button",{type:"button",onClick:()=>f(b),onDblClick:()=>v(b),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:h+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:b})}),k&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:k})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(Wi,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},b)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:g,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(b)=>x(b.currentTarget.value),onKeyDown:(b)=>{if(b.key==="Enter"){if(b.preventDefault(),b.stopPropagation(),m.trim())v(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function S({method:t,optionsLength:r,selectedOption:p,hasCustomAnswer:m=!1,onCancel:x,onSubmit:g}){let f=t==="select"&&!p&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(y,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:g,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(ft,{size:12,className:"opacity-70"})]})]})]})}function P({title:t,options:r}){let p=ao({title:t,options:r})?Cm(t):null;if(!p)return null;return e("div",{className:"space-y-2",children:[p.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(D,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:p.reason})]}),p.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:p.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function R({method:t,options:r,selectedOption:p,onSelectOption:m,customInputRef:x,onSubmit:g,onCancel:f}){i(()=>{let v=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let h=parseInt(l.key,10);if(!isNaN(h)&&h>=1&&h<=r.length){l.preventDefault(),m(r[h-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===p),k=u<r.length-1?u+1:0;m(r[k]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===p),k=u>0?u-1:r.length-1;m(r[k]);return}if(l.key==="Enter"&&p){l.preventDefault(),g();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),g();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),g();return}}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f,g,t,r,p,m,x])}function L(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(B,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Ie,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Se,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(ze,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[p,m]=n(t.method==="editor"?t.prefill??"":""),[x,g]=n(null),[f,v]=n(""),l=o(null),b=o(null),h=o(null),u=o(null),k=t.options??[],N=t.optionDetails??[],E=ao(t);i(()=>{let c=t.options??[];m(t.method==="editor"?t.prefill??"":""),g(c.length>0?c[0]:null),v("")},[t]),i(()=>{if(l.current?.focus(),t.method==="input")b.current?.focus();else if(t.method==="editor")h.current?.focus();else if(t.method==="select"){if((t.options??[]).some((H)=>/^other\b/i.test(H.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!E)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:p})},[r,t,x,p,f,E]),O=a((c)=>{if(/^other\b/i.test(c.trim())){g(c),u.current?.focus();return}r(t,{value:c})},[r,t]),z=a((c)=>{if(g(c),/^other\b/i.test(c.trim()))u.current?.focus()},[]);R({method:t.method,options:k,selectedOption:x,onSelectOption:g,customInputRef:u,onSubmit:A,onCancel:w});let C=L(t.method,k.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 backdrop-blur-[8px]",onMouseDown:(c)=>{if(c.target===c.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||C.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(I,{title:t.title,options:k,methodLabel:C.label,badge:C.badge,icon:C.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(P,{title:t.title,options:k}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(ee,{content:t.message})}),t.method==="select"&&e(T,{options:k,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:v,customInputRef:u,onSelect:z,onConfirmOption:O,hideCustomAnswer:E}),t.method==="confirm"&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:b,type:t.secret===!0?"password":"text",value:p,placeholder:t.placeholder||"Type your response...",onChange:(c)=>m(c.currentTarget.value),onKeyDown:(c)=>{if(c.key==="Enter")c.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[p.split(`
1
+ import{d,n,i,o,a,e,s,B,ne,ze,Fe,D,Ki,ft,Se,Ie,y,ee,io,Bm}from"./index-4s8ttfxj.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},M=s(F);function I({title:t,options:r,methodLabel:p,badge:m,icon:x,onCancel:g}){let f=io({title:t,options:r})?Bm(t):null,v=f?`Allow ${f.tool}`:t||p;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:v}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Fe,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:g,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(y,{size:14})})]})}function T({options:t,optionDetails:r,selectedOption:p,customValue:m,onCustomChange:x,customInputRef:g,onSelect:f,onConfirmOption:v,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((b,h)=>{let u=p===b,k=r[h]?.description;return e("button",{type:"button",onClick:()=>f(b),onDblClick:()=>v(b),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:h+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:b})}),k&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:k})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(Ki,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},b)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:g,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(b)=>x(b.currentTarget.value),onKeyDown:(b)=>{if(b.key==="Enter"){if(b.preventDefault(),b.stopPropagation(),m.trim())v(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function S({method:t,optionsLength:r,selectedOption:p,hasCustomAnswer:m=!1,onCancel:x,onSubmit:g}){let f=t==="select"&&!p&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(y,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:g,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(ft,{size:12,className:"opacity-70"})]})]})]})}function P({title:t,options:r}){let p=io({title:t,options:r})?Bm(t):null;if(!p)return null;return e("div",{className:"space-y-2",children:[p.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(D,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:p.reason})]}),p.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:p.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function R({method:t,options:r,selectedOption:p,onSelectOption:m,customInputRef:x,onSubmit:g,onCancel:f}){i(()=>{let v=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let h=parseInt(l.key,10);if(!isNaN(h)&&h>=1&&h<=r.length){l.preventDefault(),m(r[h-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===p),k=u<r.length-1?u+1:0;m(r[k]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===p),k=u>0?u-1:r.length-1;m(r[k]);return}if(l.key==="Enter"&&p){l.preventDefault(),g();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),g();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),g();return}}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f,g,t,r,p,m,x])}function L(t,r){switch(t){case"select":return{icon:e(M,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(B,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Ie,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Se,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(ze,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[p,m]=n(t.method==="editor"?t.prefill??"":""),[x,g]=n(null),[f,v]=n(""),l=o(null),b=o(null),h=o(null),u=o(null),k=t.options??[],N=t.optionDetails??[],E=io(t);i(()=>{let c=t.options??[];m(t.method==="editor"?t.prefill??"":""),g(c.length>0?c[0]:null),v("")},[t]),i(()=>{if(l.current?.focus(),t.method==="input")b.current?.focus();else if(t.method==="editor")h.current?.focus();else if(t.method==="select"){if((t.options??[]).some((H)=>/^other\b/i.test(H.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),A=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!E)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:p})},[r,t,x,p,f,E]),O=a((c)=>{if(/^other\b/i.test(c.trim())){g(c),u.current?.focus();return}r(t,{value:c})},[r,t]),z=a((c)=>{if(g(c),/^other\b/i.test(c.trim()))u.current?.focus()},[]);R({method:t.method,options:k,selectedOption:x,onSelectOption:g,customInputRef:u,onSubmit:A,onCancel:w});let C=L(t.method,k.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 backdrop-blur-[8px]",onMouseDown:(c)=>{if(c.target===c.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||C.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(I,{title:t.title,options:k,methodLabel:C.label,badge:C.badge,icon:C.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(P,{title:t.title,options:k}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(ee,{content:t.message})}),t.method==="select"&&e(T,{options:k,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:v,customInputRef:u,onSelect:z,onConfirmOption:O,hideCustomAnswer:E}),t.method==="confirm"&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:b,type:t.secret===!0?"password":"text",value:p,placeholder:t.placeholder||"Type your response...",onChange:(c)=>m(c.currentTarget.value),onKeyDown:(c)=>{if(c.key==="Enter")c.preventDefault(),A()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[p.split(`
2
2
  `).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:h,value:p,onChange:(c)=>m(c.currentTarget.value),rows:8,placeholder:t.placeholder||"Enter content...",className:"w-full rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 font-mono text-[12px] leading-relaxed text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:bg-paper focus:ring-2 focus:ring-ink/15"})]})]}),e(S,{method:t.method,optionsLength:k.length,selectedOption:x,hasCustomAnswer:f.trim().length>0,onCancel:w,onSubmit:A})]})})}export{ke as ExtensionDialog};
@@ -1 +1 @@
1
- import{d,n,i,o,u,a,fr,He,de,e,Gn,w,IA,we,Ds,S,ar,ir,s,Bn,U,Xe,I,se,ie,Be,Ge,Vi,Zt,Yi,zr,C,F,y,le,gn,_u,rt,at,OA,$A,Go,jo,Su,Ve}from"./index-y139vc12.js";import{xu,Gi,wu,Cu}from"./index-zca66d5d.js";import{Ss,mr,Eu}from"./index-e26rd868.js";var Qt={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"]},Ue=s(Qt);var Yt={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(Yt);var Bt={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Qe=s(Bt);var Jt={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"}]]},Te=s(Jt);function Ye({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:b,onSearchChange:h,onRefresh:x,refreshing:g}){return e("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-2",children:[e("div",{className:"flex items-center justify-between",children:[e(mr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),e("button",{onClick:x,className:"p-1.5 text-ink/40 hover:text-ink hover:bg-ink/5 rounded transition-colors",title:"Refresh",children:e(C,{size:14,className:g?"animate-spin":""})})]}),e("div",{className:"relative",children:[e(F,{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:b,onChange:(m)=>h(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})]})}function Je({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:b,folderStatus:h}){let x=f?"text-ink font-semibold":b?b.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(I,{size:12,className:"flex-shrink-0 text-ink/40"}):e(se,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(rt,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${x}`,title:p?`${r} — git-ignored`:void 0,children:t}),b&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${b.colorClass}`,title:`Git: ${b.label}`,children:b.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var en=28,tn=9,nn=8;function rn(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:b,selectionCount:h,isArchive:x}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(ie,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${k} to…`,icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${k}`,icon:e(U,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(Vi,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(Zt,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(I,{size:13,className:"text-ink/60"})});if(b)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(se,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(Ge,{size:13,className:"text-ink/60"})}),x)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Qe,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(Yi,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(ie,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(qe,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(Ss,{size:13,className:"text-ink/60"}),disabled:p});return g.push({kind:"separator"}),g.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Be,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(ie,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(ie,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Bn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ue,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(U,{size:13,className:"text-error"}),tone:"text-error"}),g}function on(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*en+l*tn+nn}function Ze({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:b,busy:h,selectionCount:x,isArchive:g,onAction:m,menuRef:k}){let D=rn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:b,selectionCount:x,isArchive:g}),E=on(D),N=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-E-12)):r;return de(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(T)=>{T.preventDefault(),m("close")},children:e("div",{ref:k,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:M,left:N},onClick:(T)=>T.stopPropagation(),children:D.map((T,R)=>T.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${R}`):e("button",{type:"button",disabled:T.disabled,onClick:()=>m(T.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${T.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${T.tone??""}`,children:[T.icon,e("span",{children:T.label})]},T.id))})}),document.body)}function Ce({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:b,onSubmit:h}){let x=r==="folder"?"Folder":"File";return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",x]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(g)=>f(g.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${x.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:b,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function et({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:b}){let h=c>1;return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:b,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:b,onCancel:h,onSubmit:x}){return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>b(g.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function nt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Bn,{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(y,{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,b)=>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})]},b))})]}):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(C,{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(Ce,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(et,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(tt,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(nt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Se(t){let r=t.map(sn);return r.some((l,c)=>l!==t[c])?r:t}function sn(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Se(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 Ae(t){return t.type==="folder"&&t.name.includes("/")}function Ee(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,b)=>[...p,...l.slice(0,b+1)].join("/"))}function it(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(b)=>b.flatMap((h)=>{if(h.type!=="folder")return[h];let x=Array.isArray(h.children)?p(h.children):h.children,g=x===h.children?h:{...h,children:x},m=r.has(h.path)?Ee(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let k={...g,name:m[m.length-1].split("/").pop()};for(let v=m.length-1;v>0;v-=1){let D=m[v-1];k={name:D.split("/").pop(),path:D,type:"folder",ignored:g.ignored,children:[k]}}return[k]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(b)=>{for(let h of b){if(h.type!=="folder")continue;if(l.add(h.path),Array.isArray(h.children))c(h.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let b=0;b<p.length;b+=1){let h=p.slice(0,b+1).join("/");if(l.has(h))f.push(h)}return f}function Fe({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=at(),[b,h]=n(!1),[x,g]=n("file"),[m,k]=n(""),[v,D]=n(null),E=o(null);return i(()=>{if(f.state!=="idle"||!f.data)return;let N=f.data;if(E.current===N)return;if(E.current=N,N.success&&N.path){let M=N.kind==="folder"?"folder":"file";h(!1),k(""),D(null);let T=N.path.split("/").pop()||N.path;if(c({path:N.path,name:T,kind:M}),M==="file")p?.({path:N.path,name:T})}else D(N.error||`Could not create the ${x}`)},[f.state,f.data]),{open:b,kind:x,name:m,setName:k,error:v,busy:f.state!=="idle",openDialog:(N="file")=>{g(N),k(""),D(null),h(!0)},closeDialog:()=>h(!1),submit:(N)=>{N.preventDefault();let M=m.trim();if(!M)return;D(null);let T=new FormData;if(T.append("actionType","create"),T.append("path",t),T.append("name",M),x==="folder")T.append("kind","folder");if(l&&l!==".")T.append("repo",l);if(r)T.append("root",r);f.submit(T,{method:"post",action:"/api/fs/action"})}}}function Ne(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function lt(t,r){return`${t??""}\x00${r}`}function Me(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function ct(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function dt(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=dt(t,r);if(l)return l;if(r===ct(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===ct(c.path)))return"Already in this folder";for(let c of t.entries){let p=dt(c,l);if(p)return p}return null}function ft(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=an(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function an(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 Le=[{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"}],mt=[[".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 $e(t){let r=t.toLowerCase();for(let[l,c]of mt)if(r.endsWith(l))return c;return null}function ht(t){return $e(t)!==null}function ln(t){return Le.find((r)=>r.id===t)}function cn(t){return ln(t)?.extension??"zip"}function gt(t){let r=t.toLowerCase();for(let[l]of mt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function bt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function xt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function vt(t){if(t.length===0)return".";let r=t.map((c)=>bt(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=cn(r);if(t.length===1){let f=t[0],b=gt(f.name),h=b.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?b.slice(0,h):b)||"archive"}.${l}`}let c=vt(t.map((f)=>f.path)),p=xt(c);return`${p==="."||p===""?"archive":p}.${l}`}function yt(t){return vt(t.map((r)=>r.path))}function kt(t){let r=bt(t),l=gt(xt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function Ct(t){return t.toUpperCase()}function Ft({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:b,onFold:h,clipboard:x,isFolder:g,selection:m,selected:k,archive:v}){let D=at(),[E,N]=n(null),M=o(null),[T,R]=n(!1),[A,H]=n(!1),[W,ee]=n(!1),[te,oe]=n(t.path),[G,P]=n(null),{repo:z,rootPath:K}=t,j=Fe({folderPath:t.path,rootPath:K,repo:z,onCreated:(L)=>p?p(L):c(),onOpenCreated:(L)=>l?.({...L,root:K,repo:z||"."})}),ne=o(null);i(()=>{if(D.state!=="idle"||!D.data)return;let L=D.data;if(ne.current===L)return;if(ne.current=L,L.success&&!L.type)if(R(!1),H(!1),P(null),L.previousPath&&L.path&&f)f(L.previousPath,L.path);else c();else if(!L.success&&L.error&&T)P(L.error)},[D.state,D.data]);let Q=(L)=>{if(z&&z!==".")L.append("repo",z);if(K)L.append("root",K);D.submit(L,{method:"post",action:"/api/fs/action"})},q=()=>{l?.({path:t.path,name:t.name,root:K,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},re=k&&m.length>1?m:[J],he=ht(t.name),Y=x.clip&&!x.refusalFor(J)?`Paste ${Ne(x.clip)??"item"}`:null,fe=(L)=>{if(N(null),P(null),L==="view")q();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:K}}));else if(L==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),Q(_)}else if(L==="copy_path")gn(_u(t.basePath,t.path));else if(L==="copy_relative")gn(t.path);else if(L==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),Q(_)}else if(L==="rename")oe(t.path),R(!0);else if(L==="unfold")b?.();else if(L==="fold")h?.();else if(L==="new_file")j.openDialog("file");else if(L==="new_folder")j.openDialog("folder");else if(L==="delete")H(!0);else if(L==="cut")x.cut(re);else if(L==="copy")x.copy(re);else if(L==="compress")v.openCompress(re);else if(L==="extract")v.openExtract(J);else if(L==="duplicate")x.duplicate(J);else if(L==="paste")x.paste(J)},ae=(L)=>{L.preventDefault(),P(null);let _=new FormData;_.append("actionType","rename"),_.append("path",t.path),_.append("newPath",te),Q(_)},xe=()=>{let L=new FormData;if(L.append("actionType","delete"),re.length>1)L.append("paths",JSON.stringify(re.map((_)=>_.path)));else L.append("path",t.path);Q(L)};return{contextMenu:E,contextMenuRef:M,openContextMenu:(L,_)=>N({x:L,y:_}),closeContextMenu:()=>N(null),showRenameModal:T,showDeleteModal:A,showHistoryModal:W,showCreateModal:j.open,createKind:j.kind,createError:j.error,createName:j.name,setCreateName:j.setName,renameValue:te,setRenameValue:oe,renameError:G,busy:D.state!=="idle"||j.busy||x.busy||v.busy,pasteLabel:Y,selectionCount:re.length,isArchive:he,chainLabel:b!==void 0,foldable:h!==void 0,fetcherState:D.state,fetcherData:D.data,handleAction:fe,submitCreate:j.submit,submitRename:ae,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>R(!1),closeHistory:()=>ee(!1)}}function Nt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:b}){let h=r?.path===t.path,x=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return i(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:x,isDropHovered:g&&x,onDragStart:(v)=>{if(v.dataTransfer?.setData("text/plain",t.path),v.dataTransfer)v.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(v)=>{if(!r)return;if(v.stopPropagation(),m(x),!x)return;if(v.preventDefault(),v.dataTransfer)v.dataTransfer.dropEffect="move";b?.(t)},onDragLeave:()=>m(!1),onDrop:(v)=>{if(!r)return;if(v.stopPropagation(),!x)return;v.preventDefault(),f(t)}}}var dn=450,wt=8,pn=700;function Dt({enabled:t,onLongPress:r}){let l=o(null),c=o(null),p=o(0),f=o(r);f.current=r;let b=a(()=>{if(l.current!==null)clearTimeout(l.current),l.current=null;c.current=null},[]);return i(()=>b,[b]),{onTouchStart:(h)=>{if(!t)return;let x=h.touches[0];if(!x)return;b(),c.current={x:x.clientX,y:x.clientY},l.current=setTimeout(()=>{l.current=null;let g=c.current;if(c.current=null,!g)return;p.current=Date.now(),f.current(g.x,g.y)},dn)},onTouchMove:(h)=>{let x=c.current,g=h.touches[0];if(!x||!g)return;if(Math.abs(g.clientX-x.x)>wt||Math.abs(g.clientY-x.y)>wt)b()},onTouchEnd:b,onTouchCancel:b,consume:()=>{if(p.current===0)return!1;let h=Date.now()-p.current<pn;return p.current=0,h}}}function un(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function ze({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:b,onCreated:h,onRenamed:x,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:v,clipboard:D,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:oe=!1}){let G=t.type==="folder",[P,z]=n(!1),[K,j]=n(!1),[ne,Q]=n(!1),[q,J]=n(!1),re=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Y=!G?k?.get(he)||k?.get(t.path):void 0,fe=Y?Gn(Y.status,Y.staged):null,ae=G?v?.get(he)||v?.get(t.path):null,xe=Boolean(fe),L=t.ignored===!0,_=g?g.has(t.path):P,ce=t.forceExpanded!==void 0?t.forceExpanded:_;i(()=>{J(!0)},[]),i(()=>{if(G&&g)z(g.has(t.path))},[g,t.path,G]),i(()=>{if(G&&ce&&un(t,K,ne)&&p)Q(!0),j(!0),Promise.resolve(p(t.path)).finally(()=>j(!1))},[G,ce,t.children,t.path,p,K,ne]);let ye={path:t.path,name:t.name,kind:G?"folder":"file"},be=N.selected.has(t.path),X=Ft({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:M,selected:be,archive:E,diff:{staged:Y?.staged||(Y?.status?Y.status[0]!==" "&&Y.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:b,onCreated:h,onRenamed:x,onUnfold:W&&Ae({type:G?"folder":"file",name:t.name})?()=>W(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:D,isFolder:G});le(X.contextMenuRef,X.closeContextMenu);let B=Dt({enabled:oe,onLongPress:(V,ge)=>X.openContextMenu(V,ge)}),ke=(V)=>{if(V.stopPropagation(),B.consume())return;let ge=N.gestureOf(V);if(ge!=="plain"){N.applyGesture(ge,t.path);return}if(N.applyGesture("plain",t.path),G){let ue=!ce;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)Q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(V)=>{V.preventDefault(),V.stopPropagation(),N.ensureForContext(t.path),X.openContextMenu(V.clientX,V.clientY)},pe=Nt({target:ye,dragging:T,clipboard:D,onDragStart:R,onDragEnd:A,onDropOn:H,onHoverAccept:W});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${pe.isDragging?"opacity-40":""} ${pe.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":be?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!oe,onClick:ke,onContextMenu:ve,onDragStart:pe.onDragStart,onDragEnd:pe.onDragEnd,onDragOver:pe.onDragOver,onDragLeave:pe.onDragLeave,onDrop:pe.onDrop,onTouchStart:B.onTouchStart,onTouchMove:B.onTouchMove,onTouchEnd:B.onTouchEnd,onTouchCancel:B.onTouchCancel,children:e(Je,{name:t.name,path:t.path,isFolder:G,isOpen:ce,ignored:L,selected:be,gitStatus:fe,folderStatus:ae})}),ce&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!K&&re.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:re.map((V)=>e(ze,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:b,onCreated:h,onRenamed:x,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:v,clipboard:D,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:oe},V.path))}),q&&X.contextMenu&&e(Ze,{x:X.contextMenu.x,y:X.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:X.pasteLabel,chainLabel:X.chainLabel,foldable:X.foldable,busy:X.busy,selectionCount:X.selectionCount,isArchive:X.isArchive,onAction:X.handleAction}),q&&e(ot,{actions:X,file:t,isFolder:G,chainLabel:Ae({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function Rt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,x=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return de(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:x},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(Vi,{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(Zt,{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(Ss,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function Tt({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(Rt,{x:t.x,y:t.y,menuRef:r,pasteLabel:l,busy:c,onAction:p}),f.open&&e(Ce,{folderPath:".",kind:f.kind,value:f.name,error:f.error,isLoading:f.busy,onChange:f.setName,onCancel:f.closeDialog,onSubmit:f.submit})]})}function St({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:b,onCancel:h,children:x}){return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:b,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}),x,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function fn({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:b,onFormatChange:h,onNameChange:x,onDestinationChange:g,onCancel:m,onSubmit:k}){let v=t.slice(0,4).map((E)=>E.name).join(", "),D=t.length>4?` +${t.length-4} more`:"";return e(St,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${v}${D}`,error:f,busy:b,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(E)=>{E.preventDefault(),k()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-format",children:"Format"}),e("select",{id:"archive-format",value:r,onChange:(E)=>h(E.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink mb-3",children:p.map((E)=>e("option",{value:E.id,disabled:!E.available,children:[E.label,E.available?"":` — ${E.tool} not installed`]},E.id))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(E)=>x(E.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:(E)=>g(E.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 mn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:b,onSubmit:h}){return e(St,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:b,onSubmit:(x)=>{x.preventDefault(),h()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"extract-destination",children:"Extract to folder"}),e("input",{id:"extract-destination",autoFocus:!0,type:"text",value:l,onChange:(x)=>f(x.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 At({archive:t}){if(t.compress)return e(fn,{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(mn,{archive:t.extract.archive,kindLabel:Ct($e(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 Et(){let[t,r]=S("files.outlineExpanded",!1),l=fr(),c=He($A,OA),{symbols:p,total:f,truncated:b,notice:h}=Cu({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let x=c.preview,g=(m,k)=>{if(!c.path)return;if(x){let v=Su(p,k);if(v)jo({path:c.path,...v});return}Go({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(zr,{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:b?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:h}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,k)=>e("button",{type:"button",onClick:()=>g(m,k),"aria-label":x?`${Gi(m.kind)} ${m.name}`:`${Gi(m.kind)} ${m.name}, line ${m.line}`,title:x?`Jump to ${Gi(m.kind).toLowerCase()}`:`${Gi(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(xu,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!x&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),b&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:wu(f)})]})})})})]})}function Oe(t,r){return Se(t.map((l)=>hn(l,r)))}function hn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Oe(l,r)}}function bn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function Lt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Mt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Pe(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],b={...r},h=f,x=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),k=h.find((M)=>M.type==="folder"&&M.path===m),v=k?null:h.find((M)=>M.type==="folder"&&M.path.startsWith(`${m}/`)&&(p===M.path||p.startsWith(`${M.path}/`))),D=k??v,E=D?b[D.path]??D.children:null;if(D&&!Array.isArray(E))return{nodes:t,cache:r};if(!D){let M=xn(h,b,m);if(M){h=M;let T=h.find((A)=>A.path===m),R=Array.isArray(T?.children)?[...T.children]:[];b[m]=R,h=R,x=m,g+=1;continue}}let N=Array.isArray(E)?[...E]:[];if(D){b[D.path]=N,h=N,x=D.path,g=D.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),b[m]=N,h=N,x=m,g+=1}if(h.push(l),x!==null)b[x]=Mt(h);return f=Mt(f),{nodes:f,cache:b}}function xn(t,r,l){let c=t.findIndex((x)=>x.type==="folder"&&x.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),b=r[p.path]??p.children;if(Array.isArray(b))r[p.path]=b;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(b)?{children:b}:{}};for(let x=f.length-2;x>=0;x-=1)h={name:f[x],path:`${l}/${f.slice(0,x+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:Lt(l),path:l,type:"folder",ignored:!1,children:[h]},t}function $t(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=bn(l),f=r[p],b=f?.find((m)=>m.path===l);if(f&&b)return{entry:b,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let x=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!x)return{entry:null,nodes:t,cache:r};let g=r[x];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[x]:g.filter((m)=>m.path!==l)}}}function zt(t,r,l){let c=!1,p=t.map((f)=>{let b=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?zt(f.children,r,l):void 0;if(!b&&h===f.children)return f;c=!0;let x=b?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=b?{...f,path:x,name:Lt(x)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function Ot(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let b=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[b]=b===p?f:zt(f,r,l)}return c}function Pt(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 It(t){if(!w(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>w(r)):[],root:t.root}}async function Ie(t){try{return It(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Ht({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[b,h]=n({scope:"",files:[],root:""}),[x,g]=n(!1),m=o({}),k=o([]),v=o(f);v.current=f;let D=o(""),E=o(""),N=o(c);N.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()}`},T=(P,z)=>{D.current=P,E.current=z;let K=Oe(k.current,m.current);return h({scope:P,files:K,root:z}),K},R=async(P)=>{let z=[...N.current];if(z.length===0)return;let K=await Promise.all(z.map(async(q)=>({path:q,read:await Ie(M(q))})));if(v.current!==P)return;let j=[];for(let{path:q,read:J}of K)if(J.status==="ok")m.current[q]=J.files;else if(J.status==="missing")j.push(q);if(j.length===0)return;let ne=new Set(j);for(let q of j)delete m.current[q];let Q=new Set([...N.current].filter((q)=>!ne.has(q)));N.current=Q,p(Q)},A=async()=>{if(!t)return;let P=v.current;g(!0);try{let z=await Ie(M());if(v.current!==P)return;if(z.status!=="ok")return;if(D.current!==P)m.current={};if(k.current=z.files,T(P,z.root),await R(P),v.current!==P)return;T(P,z.root)}finally{if(v.current===P)g(!1)}},H=async(P)=>{let z=v.current,K=await Ie(M(P));if(v.current!==z||K.status!=="ok")return;if(m.current[P]=K.files,D.current===z)T(z,E.current)},W=(P)=>{let z=It(P);if(z.status!=="ok")return;let K=v.current;if(D.current!==K)m.current={};k.current=z.files,T(K,z.root),R(K).then(()=>{if(v.current===K)T(K,z.root)})},ee=()=>{m.current={},k.current=[],D.current="",E.current="",h({scope:"",files:[],root:""})},te=(P)=>{let z=v.current;if(D.current!==z)return null;let K={name:P.path.slice(P.path.lastIndexOf("/")+1),path:P.path,type:P.kind,ignored:!1},j=Pe(k.current,m.current,K);if(j.nodes===k.current)return null;return k.current=j.nodes,m.current=j.cache,T(z,E.current)},oe=(P,z)=>{let K=v.current;if(D.current!==K)return null;let j=$t(k.current,m.current,P);if(!j.entry)return null;m.current=Ot(j.cache,P,z);let ne={...j.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},Q=Pe(j.nodes,m.current,ne);return k.current=Q.nodes,m.current=Q.cache,T(K,E.current)},G=b.scope===f;return{scope:f,files:G?b.files:[],root:G?b.root:"",isLoading:x,reload:A,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:oe,reset:ee}}function Gt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=at(),[f,b]=S("files.clipboard",null),h=ft(f),x=lt(t,r),g=o(!1),m=o(null);i(()=>{if(p.state!=="idle"||!p.data)return;let N=p.data;if(m.current===N)return;m.current=N;let M=g.current;if(g.current=!1,N.success){if(M)b(null);if(N.failures?.length)c(`${N.failures.length} item(s) could not be moved: ${N.failures[0].error}`);l()}else c(N.error||"The transfer did not complete")},[p.state,p.data]);let k=a((N,M)=>{g.current=M;let T=new FormData;for(let[R,A]of Object.entries(N))T.append(R,A);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);p.submit(T,{method:"post",action:"/api/fs/action"})},[p,r,t]),v=a((N)=>ut(h,x,Me(N.path,N.kind)),[h,x]),D=a((N,M)=>pt(N,Me(M.path,M.kind)),[]),E=a((N,M,T,R)=>{let A=new FormData;A.append("actionType","paste"),A.append("mode",T),A.append("targetPath",M.path),A.append("targetKind",M.kind);for(let H of N)A.append("sourcePath",H.path);if(r&&r!==".")A.append("repo",r);if(t)A.append("root",t);g.current=R,p.submit(A,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:h,busy:p.state!=="idle",refusalFor:v,moveRefusalFor:D,copy:(N)=>{if(N.length===0)return;b({scope:x,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"copy"})},cut:(N)=>{if(N.length===0)return;b({scope:x,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"cut"})},duplicate:(N)=>{k({actionType:"duplicate",path:N.path},!1)},move:(N,M)=>{let T=D(N,M);if(T){c(T);return}E([N],M,"cut",Boolean(h?.mode==="cut"&&h.entries.some((R)=>R.path===N.path)))},paste:(N)=>{if(!h)return;let M=v(N);if(M){c(M);return}E(h.entries.map(({path:T,name:R,kind:A})=>({path:T,name:R,kind:A})),N,h.mode,h.mode==="cut")}}}var vn=Le.map((t)=>({...t,available:!0,tool:t.id}));function Kt({rootPath:t,repo:r,onComplete:l}){let c=at(),[p,f]=n(vn),[b,h]=n(null),[x,g]=n(null),[m,k]=n(null),v=o(null),D=o(null);i(()=>{let R=!1;return(async()=>{try{let H=await(await fetch("/api/fs/archive")).json();if(!R&&Array.isArray(H.formats)&&H.formats.length>0)f(H.formats)}catch{}})(),()=>{R=!0}},[]),i(()=>{if(c.state!=="idle"||!c.data)return;let R=c.data;if(D.current===R)return;D.current=R;let A=v.current;if(v.current=null,R.success){if(k(null),A==="compress")h(null);if(A==="extract")g(null);l()}else if(A)k(R.error||"The archive request failed")},[c.state,c.data]);let E=a((R)=>{let A=new FormData;for(let[H,W]of Object.entries(R))A.append(H,W);if(r&&r!==".")A.append("repo",r);if(t)A.append("root",t);c.submit(A,{method:"post",action:"/api/fs/action"})},[c,r,t]),N=a((R)=>{if(R.length===0)return;let A=p.find((H)=>H.id==="zip"&&H.available)?.id??p.find((H)=>H.available)?.id??"zip";k(null),g(null),h({entries:R.map(({path:H,name:W,kind:ee})=>({path:H,name:W,kind:ee})),format:A,name:De(R,A),destination:yt(R)})},[p]),M=a((R)=>{k(null),h(null),g({archive:R,destination:kt(R.path)})},[]),T=a((R)=>{h((A)=>{if(!A)return A;let H=De(A.entries,A.format),W=A.name===H?De(A.entries,R):A.name;return{...A,format:R,name:W}})},[]);return{formats:p,compress:b,extract:x,error:m,busy:c.state!=="idle",openCompress:N,openExtract:M,setFormat:T,setName:(R)=>h((A)=>A&&{...A,name:R}),setCompressDestination:(R)=>h((A)=>A&&{...A,destination:R}),setExtractDestination:(R)=>g((A)=>A&&{...A,destination:R}),cancel:()=>{h(null),g(null),k(null)},submitCompress:()=>{let R=b;if(!R)return;v.current="compress",k(null),E({actionType:"compress",format:R.format,name:R.name.trim(),destination:R.destination.trim()||".",paths:JSON.stringify(R.entries.map((A)=>A.path))})},submitExtract:()=>{let R=x;if(!R)return;v.current="extract",k(null),E({actionType:"extract",path:R.archive.path,destination:R.destination.trim()||"."})}}}function yn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function kn(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),b=Math.max(c,p);return t.slice(f,b+1)}function jt(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(kn(t,c,m)));return}if(p(m),g==="toggle"){l((k)=>{let v=new Set(k);if(v.has(m))v.delete(m);else v.add(m);return v});return}l(new Set([m]))},[c,t]),b=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),x=a(yn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:x,applyGesture:f,ensureForContext:b,clear:h}),[r,c,x,f,b,h])}function Ke(t,r,l=0,c=[]){for(let p of t)if(c.push({path:p.path,name:p.name,kind:p.type==="folder"?"folder":"file",depth:l}),p.type==="folder"&&r(p)&&Array.isArray(p.children))Ke(p.children,r,l+1,c);return c}function _t({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((x,g)=>{let m=st(g,x);if(m.length===0)return;r((k)=>{if(m.every((D)=>k.has(D)))return k;let v=new Set(k);for(let D of m)v.add(D);return l(Array.from(v)),v})},[r,l]),b=a((x)=>{let g=t.insertEntry(x);if(!g){c();return}f(x.path,g)},[t,c,f]),h=a((x,g)=>{p?.(x,g),r((k)=>{let v=Pt(k,x,g);return l(Array.from(v)),v});let m=t.moveEntry(x,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:b,moveRenamed:h}}var Cn=new Set;function Wt({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((x)=>{let g=Ee(x.path,x.name);if(!g)return;p((k)=>{let v=k.scope===t?k.chains:new Map;if(v.get(x.path)?.length===g.length)return k;let E=new Map(v);return E.set(x.path,g),{scope:t,chains:E}});let m=g.slice(0,-1);r((k)=>{if(m.every((D)=>k.has(D)))return k;let v=new Set(k);for(let D of m)v.add(D);return l(Array.from(v)),v})},[t,r,l]),b=a((x)=>{let g=c.scope===t?c.chains.get(x):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let v=new Map(k.chains);return v.delete(x),{scope:t,chains:v}}),r((k)=>{if(!m.some((D)=>k.has(D)))return k;let v=new Set(k);for(let D of m)v.delete(D);return l(Array.from(v)),v})},[t,c,r,l]),h=a((x,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,v=[],D=!1;for(let[E,N]of m){if(N.findIndex((A,H)=>A===x&&H>0&&H<N.length-1)!==-1){D=!0;continue}let T=N.map((A)=>A===x?g:A.startsWith(`${x}/`)?`${g}${A.slice(x.length)}`:A),R=T[T.length-1];if(R!==E||T.some((A,H)=>A!==N[H]))D=!0;k.set(R,T),v.push(...T.slice(0,-1))}if(!D)return;p({scope:t,chains:k}),r((E)=>{if(v.every((M)=>E.has(M)))return E;let N=new Set(E);for(let M of v)N.add(M);return l(Array.from(N)),N})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):Cn,unfold:f,fold:b,rekey:h}}function Ut(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 b=(p.children||[]).map(c).filter((h)=>h!==null);if(f||b.length>0)return{...p,children:f&&b.length===0?p.children:b,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 i(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(b)=>{if(!b.currentTarget.contains(b.relatedTarget))f(!1)},onDragOver:(b)=>{if(!c)return;if(b.preventDefault(),b.dataTransfer)b.dataTransfer.dropEffect="move"},onDrop:(b)=>{if(!c)return;b.preventDefault(),f(!1),r.move(t,l)}}}function oi({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:b}){let[h,x]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[v,D]=n(()=>new Set(g)),{activeRepo:E,setActiveRepo:N}=ar(c),{repos:M,scanning:T,rescan:R}=ir(c,r),{fileMap:A,folderMap:H,refreshGitStatus:W}=Ds(c,E,r),[ee,te]=n(null),oe=o(null);i(()=>{if(!k)return;D((O)=>{let Z=new Set(g);if(O.size===Z.size&&Array.from(Z).every((me)=>O.has(me)))return O;return Z})},[k,g]);let G=Ht({enabled:r,rootPath:c,activeRepo:E,expandedPaths:v,onExpansionPruned:(O)=>{D(O),m(Array.from(O))}});i(()=>{if(!k||!l)return;G.reload()},[f,c,r,E,k,l]);let P=r&&k?IA(G.scope):null,z=we(P);i(()=>{if(z.data)G.adoptRoot(z.data)},[z.data]);let K=(O)=>(W(),G.loadChildren(O)),j=(O,Z)=>{let me=new Set(v);if(Z)me.add(O);else me.delete(O);D(me),m(Array.from(me))},{unfolded:ne,unfold:Q,fold:q,rekey:J}=Wt({scope:G.scope,setExpandedPaths:D,setStoredExpandedPaths:m}),re=G.files,he=it(re,ne),Y=Ut(he.nodes,h),fe=Ke(Y,(O)=>O.forceExpanded!==void 0?O.forceExpanded:v.has(O.path)),ae=jt(fe.map((O)=>O.path)),xe=fe.filter((O)=>ae.selected.has(O.path)).map(({path:O,name:Z,kind:me})=>({path:O,name:Z,kind:me})),L=(O)=>{if(O===E)return;G.reset(),D(new Set),m([]),ae.clear(),N(O)},_=()=>{if(W(),b)b();else G.reload()},{insertCreated:ce,moveRenamed:ye}=_t({listing:G,setExpandedPaths:D,setStoredExpandedPaths:m,reload:_,onMoved:(O,Z)=>J(O,Z)}),be=Eu(),{pushToast:X}=Ve(),B=Gt({rootPath:c,repo:E,onComplete:_,onError:(O)=>X(O,"error")}),ke=Kt({rootPath:c,repo:E,onComplete:_}),ve={path:".",name:".",kind:"folder"},pe=B.clip&&!B.refusalFor(ve)?`Paste ${Ne(B.clip)??"item"}`:null,[V,ge]=n(null),ue=Xt({dragging:V,clipboard:B,target:ve}),Re=Fe({folderPath:".",rootPath:c,repo:E,onCreated:ce,onOpenCreated:(O)=>p?.({...O,root:c,repo:E})}),[je,Vt]=n(!1);i(()=>Vt(!0),[]);let{count:_e,clear:We}=ae;if(i(()=>{if(!l)return;let O=(Z)=>{if(Z.key==="Escape"&&_e>0)We()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[l,_e,We]),!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=G.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Ye,{rootPath:c,activeRepo:E,repos:M,reposScanning:T,onRefreshRepos:R,onSelectRepo:L,searchQuery:h,onSearchChange:x,onRefresh:_,refreshing:qt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(O)=>{O.preventDefault(),te({x:O.clientX,y:O.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:G.isLoading&&Y.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Y.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Y.map((O)=>e(ze,{file:O,rootPath:c,basePath:G.root,repo:E,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:ce,onRenamed:ye,expandedPaths:v,onToggleFolder:j,gitFileMap:A,gitFolderMap:H,clipboard:B,archive:ke,selection:ae,selectionTargets:xe,dragging:V,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!V)return;B.move(V,Z)},onUnfold:Q,onFold:q,foldRoots:he.roots,touch:be},O.path))}),e(Et,{}),je&&e(Tt,{menu:ee,menuRef:oe,pasteLabel:pe,busy:B.busy,create:Re,onAction:(O)=>{if(te(null),O==="new_file")Re.openDialog("file");if(O==="new_folder")Re.openDialog("folder");if(O==="paste")B.paste(ve)}}),je&&e(At,{archive:ke})]})}export{oi as FileExplorer};
1
+ import{d,n,i,o,u,a,Ar,He,de,e,Gn,w,SA,we,Ds,S,ir,or,s,Bn,U,Xe,I,se,ie,Be,Ge,Yi,Xt,Ji,Ur,C,F,y,le,hn,Tu,rt,at,zA,UA,jo,qo,Du,Ve}from"./index-4s8ttfxj.js";import{Cu,ji,Eu,Bu}from"./index-p7btwjvj.js";import{Ss,fr,Iu}from"./index-a733k69t.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"]},Ue=s(Yt);var Bt={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(Bt);var Jt={name:"package-open",size:24,node:[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]},Qe=s(Jt);var Zt={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"}]]},Te=s(Zt);function Ye({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:b,onSearchChange:h,onRefresh:x,refreshing:g}){return e("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-2",children:[e("div",{className:"flex items-center justify-between",children:[e(fr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),e("button",{onClick:x,className:"p-1.5 text-ink/40 hover:text-ink hover:bg-ink/5 rounded transition-colors",title:"Refresh",children:e(C,{size:14,className:g?"animate-spin":""})})]}),e("div",{className:"relative",children:[e(F,{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:b,onChange:(m)=>h(m.currentTarget.value),className:"w-full bg-canvas border border-ink/20 rounded pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:border-ink transition-colors text-ink placeholder-ink/40"})]})]})}function Je({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:b,folderStatus:h}){let x=f?"text-ink font-semibold":b?b.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(I,{size:12,className:"flex-shrink-0 text-ink/40"}):e(se,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(rt,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${x}`,title:p?`${r} — git-ignored`:void 0,children:t}),b&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${b.colorClass}`,title:`Git: ${b.label}`,children:b.charStatus}),h&&e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h.hasDeleted?"bg-error":h.hasModified||h.hasStaged?"bg-info":"bg-success"}`,title:`${h.count} changed file${h.count>1?"s":""}`})]})}var en=28,tn=9,nn=8;function rn(t){let{isFolder:r,hasGitStatus:l,pasteLabel:c,busy:p,chainLabel:f,foldable:b,selectionCount:h,isArchive:x}=t,g=[],m=h>1,k=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${k}`,icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${k}`,icon:e(ie,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${k} to…`,icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${k}`,icon:e(U,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(Yi,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(Xt,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(I,{size:13,className:"text-ink/60"})});if(b)g.push({kind:"item",id:"fold",label:"Fold Folders",icon:e(se,{size:13,className:"text-ink/60"})});g.push({kind:"separator"})}else{if(g.push({kind:"item",id:"view",label:"View",icon:e(Ge,{size:13,className:"text-ink/60"})}),x)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Qe,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(Ji,{size:13,className:"text-warning"}),tone:"font-medium"});g.push({kind:"separator"})}if(g.push({kind:"item",id:"cut",label:"Cut",icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:"Copy",icon:e(ie,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(qe,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(Ss,{size:13,className:"text-ink/60"}),disabled:p});return g.push({kind:"separator"}),g.push({kind:"item",id:"explorer",label:"Go to Explorer",icon:e(Be,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(ie,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(ie,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Bn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ue,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(U,{size:13,className:"text-error"}),tone:"text-error"}),g}function on(t){let r=t.filter((c)=>c.kind==="item").length,l=t.length-r;return r*en+l*tn+nn}function Ze({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:b,busy:h,selectionCount:x,isArchive:g,onAction:m,menuRef:k}){let D=rn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:b,selectionCount:x,isArchive:g}),E=on(D),N=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-E-12)):r;return de(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(T)=>{T.preventDefault(),m("close")},children:e("div",{ref:k,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:M,left:N},onClick:(T)=>T.stopPropagation(),children:D.map((T,R)=>T.kind==="separator"?e("div",{className:"my-1 border-t border-ink/10"},`sep-${R}`):e("button",{type:"button",disabled:T.disabled,onClick:()=>m(T.id),className:`w-full text-left px-3 py-1.5 flex items-center space-x-2 transition-colors ${T.disabled?"opacity-40 cursor-default":"hover:bg-ink/5"} ${T.tone??""}`,children:[T.icon,e("span",{children:T.label})]},T.id))})}),document.body)}function Ce({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:b,onSubmit:h}){let x=r==="folder"?"Folder":"File";return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",x]}),e("div",{className:"flex items-center gap-1 mb-1 text-xs font-mono text-ink/50 min-w-0",children:e("span",{className:"truncate",title:t,children:[t||".","/"]})}),e("input",{autoFocus:!0,type:"text",value:l,onChange:(g)=>f(g.currentTarget.value),placeholder:r==="folder"?"folder name or nested/path":"file name or nested/path","aria-label":`New ${x.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:b,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function et({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:b}){let h=c>1;return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:b,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:b,onCancel:h,onSubmit:x}){return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:x,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["Rename ",t?"Folder":"File"]}),e("input",{autoFocus:!0,type:"text",value:r,onChange:(g)=>b(g.currentTarget.value),"aria-label":`Rename ${t?"folder":"file"} path`,className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none mb-1 ${p?"border-error":"border-ink/20 focus:border-ink"}`}),e("p",{className:"text-[10px] text-ink/40 mb-2",children:["Paths are relative to the tree — ",e("span",{className:"font-mono",children:"lib/deep/name.ts"})," moves it too."]}),c&&e("p",{className:"text-[11px] text-ink/50 mb-2",children:["The row is ",e("span",{className:"font-mono",children:c}),"; this renames"," ",e("span",{className:"font-mono",children:l}),". Use"," ",e("span",{className:"font-mono",children:"Unfold Folders"})," to rename a folder inside the chain."]}),p&&e("p",{className:"text-[11px] text-error mb-2",children:p}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:f,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:f||!r.trim()||r===l,children:f?"Renaming...":"Rename"})]})]})}),document.body)}function nt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Bn,{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(y,{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,b)=>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})]},b))})]}):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(C,{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(Ce,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(et,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(tt,{isFolder:l,renameValue:t.renameValue,originalPath:r.path,displayName:l?c:void 0,error:t.renameError,isLoading:t.busy,onChange:t.setRenameValue,onCancel:t.closeRename,onSubmit:t.submitRename}),t.showHistoryModal&&e(nt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Se(t){let r=t.map(sn);return r.some((l,c)=>l!==t[c])?r:t}function sn(t){if(t.type!=="folder"||!Array.isArray(t.children))return t;let r=Se(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 Ae(t){return t.type==="folder"&&t.name.includes("/")}function Ee(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,b)=>[...p,...l.slice(0,b+1)].join("/"))}function it(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(b)=>b.flatMap((h)=>{if(h.type!=="folder")return[h];let x=Array.isArray(h.children)?p(h.children):h.children,g=x===h.children?h:{...h,children:x},m=r.has(h.path)?Ee(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let k={...g,name:m[m.length-1].split("/").pop()};for(let v=m.length-1;v>0;v-=1){let D=m[v-1];k={name:D.split("/").pop(),path:D,type:"folder",ignored:g.ignored,children:[k]}}return[k]}),f=p(t);return{nodes:c?f:t,roots:l}}function st(t,r){let l=new Set,c=(b)=>{for(let h of b){if(h.type!=="folder")continue;if(l.add(h.path),Array.isArray(h.children))c(h.children)}};c(t);let p=r.split("/").slice(0,-1),f=[];for(let b=0;b<p.length;b+=1){let h=p.slice(0,b+1).join("/");if(l.has(h))f.push(h)}return f}function Fe({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=at(),[b,h]=n(!1),[x,g]=n("file"),[m,k]=n(""),[v,D]=n(null),E=o(null);return i(()=>{if(f.state!=="idle"||!f.data)return;let N=f.data;if(E.current===N)return;if(E.current=N,N.success&&N.path){let M=N.kind==="folder"?"folder":"file";h(!1),k(""),D(null);let T=N.path.split("/").pop()||N.path;if(c({path:N.path,name:T,kind:M}),M==="file")p?.({path:N.path,name:T})}else D(N.error||`Could not create the ${x}`)},[f.state,f.data]),{open:b,kind:x,name:m,setName:k,error:v,busy:f.state!=="idle",openDialog:(N="file")=>{g(N),k(""),D(null),h(!0)},closeDialog:()=>h(!1),submit:(N)=>{N.preventDefault();let M=m.trim();if(!M)return;D(null);let T=new FormData;if(T.append("actionType","create"),T.append("path",t),T.append("name",M),x==="folder")T.append("kind","folder");if(l&&l!==".")T.append("repo",l);if(r)T.append("root",r);f.submit(T,{method:"post",action:"/api/fs/action"})}}}function Ne(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function lt(t,r){return`${t??""}\x00${r}`}function Me(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function ct(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function dt(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=dt(t,r);if(l)return l;if(r===ct(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===ct(c.path)))return"Already in this folder";for(let c of t.entries){let p=dt(c,l);if(p)return p}return null}function ft(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=an(p);if(!f)return null;c.push(f)}if(c.length===0)return null;return{scope:r.scope,entries:c,mode:r.mode}}function an(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 Le=[{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"}],mt=[[".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 $e(t){let r=t.toLowerCase();for(let[l,c]of mt)if(r.endsWith(l))return c;return null}function ht(t){return $e(t)!==null}function ln(t){return Le.find((r)=>r.id===t)}function cn(t){return ln(t)?.extension??"zip"}function gt(t){let r=t.toLowerCase();for(let[l]of mt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function bt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function xt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function vt(t){if(t.length===0)return".";let r=t.map((c)=>bt(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=cn(r);if(t.length===1){let f=t[0],b=gt(f.name),h=b.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?b.slice(0,h):b)||"archive"}.${l}`}let c=vt(t.map((f)=>f.path)),p=xt(c);return`${p==="."||p===""?"archive":p}.${l}`}function yt(t){return vt(t.map((r)=>r.path))}function kt(t){let r=bt(t),l=gt(xt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function Ct(t){return t.toUpperCase()}function Ft({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:b,onFold:h,clipboard:x,isFolder:g,selection:m,selected:k,archive:v}){let D=at(),[E,N]=n(null),M=o(null),[T,R]=n(!1),[A,H]=n(!1),[W,ee]=n(!1),[te,oe]=n(t.path),[G,P]=n(null),{repo:z,rootPath:K}=t,j=Fe({folderPath:t.path,rootPath:K,repo:z,onCreated:(L)=>p?p(L):c(),onOpenCreated:(L)=>l?.({...L,root:K,repo:z||"."})}),ne=o(null);i(()=>{if(D.state!=="idle"||!D.data)return;let L=D.data;if(ne.current===L)return;if(ne.current=L,L.success&&!L.type)if(R(!1),H(!1),P(null),L.previousPath&&L.path&&f)f(L.previousPath,L.path);else c();else if(!L.success&&L.error&&T)P(L.error)},[D.state,D.data]);let Q=(L)=>{if(z&&z!==".")L.append("repo",z);if(K)L.append("root",K);D.submit(L,{method:"post",action:"/api/fs/action"})},q=()=>{l?.({path:t.path,name:t.name,root:K,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},re=k&&m.length>1?m:[J],he=ht(t.name),Y=x.clip&&!x.refusalFor(J)?`Paste ${Ne(x.clip)??"item"}`:null,fe=(L)=>{if(N(null),P(null),L==="view")q();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:K}}));else if(L==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),Q(_)}else if(L==="copy_path")hn(Tu(t.basePath,t.path));else if(L==="copy_relative")hn(t.path);else if(L==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),Q(_)}else if(L==="rename")oe(t.path),R(!0);else if(L==="unfold")b?.();else if(L==="fold")h?.();else if(L==="new_file")j.openDialog("file");else if(L==="new_folder")j.openDialog("folder");else if(L==="delete")H(!0);else if(L==="cut")x.cut(re);else if(L==="copy")x.copy(re);else if(L==="compress")v.openCompress(re);else if(L==="extract")v.openExtract(J);else if(L==="duplicate")x.duplicate(J);else if(L==="paste")x.paste(J)},ae=(L)=>{L.preventDefault(),P(null);let _=new FormData;_.append("actionType","rename"),_.append("path",t.path),_.append("newPath",te),Q(_)},xe=()=>{let L=new FormData;if(L.append("actionType","delete"),re.length>1)L.append("paths",JSON.stringify(re.map((_)=>_.path)));else L.append("path",t.path);Q(L)};return{contextMenu:E,contextMenuRef:M,openContextMenu:(L,_)=>N({x:L,y:_}),closeContextMenu:()=>N(null),showRenameModal:T,showDeleteModal:A,showHistoryModal:W,showCreateModal:j.open,createKind:j.kind,createError:j.error,createName:j.name,setCreateName:j.setName,renameValue:te,setRenameValue:oe,renameError:G,busy:D.state!=="idle"||j.busy||x.busy||v.busy,pasteLabel:Y,selectionCount:re.length,isArchive:he,chainLabel:b!==void 0,foldable:h!==void 0,fetcherState:D.state,fetcherData:D.data,handleAction:fe,submitCreate:j.submit,submitRename:ae,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>R(!1),closeHistory:()=>ee(!1)}}function Nt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:b}){let h=r?.path===t.path,x=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return i(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:x,isDropHovered:g&&x,onDragStart:(v)=>{if(v.dataTransfer?.setData("text/plain",t.path),v.dataTransfer)v.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(v)=>{if(!r)return;if(v.stopPropagation(),m(x),!x)return;if(v.preventDefault(),v.dataTransfer)v.dataTransfer.dropEffect="move";b?.(t)},onDragLeave:()=>m(!1),onDrop:(v)=>{if(!r)return;if(v.stopPropagation(),!x)return;v.preventDefault(),f(t)}}}var dn=450,wt=8,pn=700;function Dt({enabled:t,onLongPress:r}){let l=o(null),c=o(null),p=o(0),f=o(r);f.current=r;let b=a(()=>{if(l.current!==null)clearTimeout(l.current),l.current=null;c.current=null},[]);return i(()=>b,[b]),{onTouchStart:(h)=>{if(!t)return;let x=h.touches[0];if(!x)return;b(),c.current={x:x.clientX,y:x.clientY},l.current=setTimeout(()=>{l.current=null;let g=c.current;if(c.current=null,!g)return;p.current=Date.now(),f.current(g.x,g.y)},dn)},onTouchMove:(h)=>{let x=c.current,g=h.touches[0];if(!x||!g)return;if(Math.abs(g.clientX-x.x)>wt||Math.abs(g.clientY-x.y)>wt)b()},onTouchEnd:b,onTouchCancel:b,consume:()=>{if(p.current===0)return!1;let h=Date.now()-p.current<pn;return p.current=0,h}}}function un(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function ze({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:b,onCreated:h,onRenamed:x,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:v,clipboard:D,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:oe=!1}){let G=t.type==="folder",[P,z]=n(!1),[K,j]=n(!1),[ne,Q]=n(!1),[q,J]=n(!1),re=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Y=!G?k?.get(he)||k?.get(t.path):void 0,fe=Y?Gn(Y.status,Y.staged):null,ae=G?v?.get(he)||v?.get(t.path):null,xe=Boolean(fe),L=t.ignored===!0,_=g?g.has(t.path):P,ce=t.forceExpanded!==void 0?t.forceExpanded:_;i(()=>{J(!0)},[]),i(()=>{if(G&&g)z(g.has(t.path))},[g,t.path,G]),i(()=>{if(G&&ce&&un(t,K,ne)&&p)Q(!0),j(!0),Promise.resolve(p(t.path)).finally(()=>j(!1))},[G,ce,t.children,t.path,p,K,ne]);let ye={path:t.path,name:t.name,kind:G?"folder":"file"},be=N.selected.has(t.path),X=Ft({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:M,selected:be,archive:E,diff:{staged:Y?.staged||(Y?.status?Y.status[0]!==" "&&Y.status[0]!=="?":!1),status:fe?.charStatus},onOpenFile:f,onActionComplete:b,onCreated:h,onRenamed:x,onUnfold:W&&Ae({type:G?"folder":"file",name:t.name})?()=>W(ye):void 0,onFold:ee&&te?.has(t.path)?()=>ee(te.get(t.path)):void 0,clipboard:D,isFolder:G});le(X.contextMenuRef,X.closeContextMenu);let B=Dt({enabled:oe,onLongPress:(V,ge)=>X.openContextMenu(V,ge)}),ke=(V)=>{if(V.stopPropagation(),B.consume())return;let ge=N.gestureOf(V);if(ge!=="plain"){N.applyGesture(ge,t.path);return}if(N.applyGesture("plain",t.path),G){let ue=!ce;if(z(ue),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,ue),!ue)Q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(V)=>{V.preventDefault(),V.stopPropagation(),N.ensureForContext(t.path),X.openContextMenu(V.clientX,V.clientY)},pe=Nt({target:ye,dragging:T,clipboard:D,onDragStart:R,onDragEnd:A,onDropOn:H,onHoverAccept:W});return e("div",{children:[e("div",{className:`flex items-center space-x-1.5 py-1 px-2 cursor-pointer rounded group select-none ${pe.isDragging?"opacity-40":""} ${pe.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":be?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!oe,onClick:ke,onContextMenu:ve,onDragStart:pe.onDragStart,onDragEnd:pe.onDragEnd,onDragOver:pe.onDragOver,onDragLeave:pe.onDragLeave,onDrop:pe.onDrop,onTouchStart:B.onTouchStart,onTouchMove:B.onTouchMove,onTouchEnd:B.onTouchEnd,onTouchCancel:B.onTouchCancel,children:e(Je,{name:t.name,path:t.path,isFolder:G,isOpen:ce,ignored:L,selected:be,gitStatus:fe,folderStatus:ae})}),ce&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!K&&re.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:re.map((V)=>e(ze,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:b,onCreated:h,onRenamed:x,expandedPaths:g,onToggleFolder:m,gitFileMap:k,gitFolderMap:v,clipboard:D,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:oe},V.path))}),q&&X.contextMenu&&e(Ze,{x:X.contextMenu.x,y:X.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:X.pasteLabel,chainLabel:X.chainLabel,foldable:X.foldable,busy:X.busy,selectionCount:X.selectionCount,isArchive:X.isArchive,onAction:X.handleAction}),q&&e(ot,{actions:X,file:t,isFolder:G,chainLabel:Ae({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function Rt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,x=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return de(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:x},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(Yi,{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(Xt,{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(Ss,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function Tt({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(Rt,{x:t.x,y:t.y,menuRef:r,pasteLabel:l,busy:c,onAction:p}),f.open&&e(Ce,{folderPath:".",kind:f.kind,value:f.name,error:f.error,isLoading:f.busy,onChange:f.setName,onCancel:f.closeDialog,onSubmit:f.submit})]})}function St({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:b,onCancel:h,children:x}){return de(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:b,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}),x,l&&e("p",{className:"text-[11px] text-error mb-2",children:l}),e("div",{className:"flex justify-end space-x-2 mt-3",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:c,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:c,children:c?f:p})]})]})}),document.body)}function fn({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:b,onFormatChange:h,onNameChange:x,onDestinationChange:g,onCancel:m,onSubmit:k}){let v=t.slice(0,4).map((E)=>E.name).join(", "),D=t.length>4?` +${t.length-4} more`:"";return e(St,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${v}${D}`,error:f,busy:b,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(E)=>{E.preventDefault(),k()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-format",children:"Format"}),e("select",{id:"archive-format",value:r,onChange:(E)=>h(E.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 text-xs font-mono focus:outline-none focus:border-ink mb-3",children:p.map((E)=>e("option",{value:E.id,disabled:!E.available,children:[E.label,E.available?"":` — ${E.tool} not installed`]},E.id))}),e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"archive-name",children:"Archive name"}),e("input",{id:"archive-name",autoFocus:!0,type:"text",value:l,onChange:(E)=>x(E.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:(E)=>g(E.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 mn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:b,onSubmit:h}){return e(St,{title:`Extract ${t.name}`,subject:`${r} archive · extracts into a folder`,error:c,busy:p,submitLabel:"Extract",busyLabel:"Extracting...",onCancel:b,onSubmit:(x)=>{x.preventDefault(),h()},children:[e("label",{className:"block text-[10px] uppercase tracking-wide text-ink/40 mb-1",htmlFor:"extract-destination",children:"Extract to folder"}),e("input",{id:"extract-destination",autoFocus:!0,type:"text",value:l,onChange:(x)=>f(x.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 At({archive:t}){if(t.compress)return e(fn,{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(mn,{archive:t.extract.archive,kindLabel:Ct($e(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 Et(){let[t,r]=S("files.outlineExpanded",!1),l=Ar(),c=He(UA,zA),{symbols:p,total:f,truncated:b,notice:h}=Bu({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let x=c.preview,g=(m,k)=>{if(!c.path)return;if(x){let v=Du(p,k);if(v)qo({path:c.path,...v});return}jo({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(Ur,{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:b?`${p.length}/${f.toLocaleString()}`:f})]})}),e("div",{className:"section-reveal","data-expanded":t,id:l,inert:!t,children:e("div",{children:e("div",{className:"px-2 pb-2",children:p.length===0?e("div",{className:"px-1 text-[10px] text-ink/40 italic py-1",children:h}):e("div",{className:"max-h-48 overflow-y-auto scrollbar-overlay-container flex flex-col",children:[p.map((m,k)=>e("button",{type:"button",onClick:()=>g(m,k),"aria-label":x?`${ji(m.kind)} ${m.name}`:`${ji(m.kind)} ${m.name}, line ${m.line}`,title:x?`Jump to ${ji(m.kind).toLowerCase()}`:`${ji(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(Cu,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!x&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),b&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Eu(f)})]})})})})]})}function Oe(t,r){return Se(t.map((l)=>gn(l,r)))}function gn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Oe(l,r)}}function bn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function Lt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Mt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Pe(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],b={...r},h=f,x=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),k=h.find((M)=>M.type==="folder"&&M.path===m),v=k?null:h.find((M)=>M.type==="folder"&&M.path.startsWith(`${m}/`)&&(p===M.path||p.startsWith(`${M.path}/`))),D=k??v,E=D?b[D.path]??D.children:null;if(D&&!Array.isArray(E))return{nodes:t,cache:r};if(!D){let M=xn(h,b,m);if(M){h=M;let T=h.find((A)=>A.path===m),R=Array.isArray(T?.children)?[...T.children]:[];b[m]=R,h=R,x=m,g+=1;continue}}let N=Array.isArray(E)?[...E]:[];if(D){b[D.path]=N,h=N,x=D.path,g=D.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),b[m]=N,h=N,x=m,g+=1}if(h.push(l),x!==null)b[x]=Mt(h);return f=Mt(f),{nodes:f,cache:b}}function xn(t,r,l){let c=t.findIndex((x)=>x.type==="folder"&&x.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),b=r[p.path]??p.children;if(Array.isArray(b))r[p.path]=b;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(b)?{children:b}:{}};for(let x=f.length-2;x>=0;x-=1)h={name:f[x],path:`${l}/${f.slice(0,x+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:Lt(l),path:l,type:"folder",ignored:!1,children:[h]},t}function $t(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=bn(l),f=r[p],b=f?.find((m)=>m.path===l);if(f&&b)return{entry:b,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let x=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((k)=>k.path===l)).sort((m,k)=>k.length-m.length)[0];if(!x)return{entry:null,nodes:t,cache:r};let g=r[x];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[x]:g.filter((m)=>m.path!==l)}}}function zt(t,r,l){let c=!1,p=t.map((f)=>{let b=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?zt(f.children,r,l):void 0;if(!b&&h===f.children)return f;c=!0;let x=b?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=b?{...f,path:x,name:Lt(x)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function Ot(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let b=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[b]=b===p?f:zt(f,r,l)}return c}function Pt(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 It(t){if(!w(t))return{status:"missing"};if(typeof t.root!=="string"||t.root==="")return{status:"missing"};return{status:"ok",files:Array.isArray(t.files)?t.files.filter((r)=>w(r)):[],root:t.root}}async function Ie(t){try{return It(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Ht({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[b,h]=n({scope:"",files:[],root:""}),[x,g]=n(!1),m=o({}),k=o([]),v=o(f);v.current=f;let D=o(""),E=o(""),N=o(c);N.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()}`},T=(P,z)=>{D.current=P,E.current=z;let K=Oe(k.current,m.current);return h({scope:P,files:K,root:z}),K},R=async(P)=>{let z=[...N.current];if(z.length===0)return;let K=await Promise.all(z.map(async(q)=>({path:q,read:await Ie(M(q))})));if(v.current!==P)return;let j=[];for(let{path:q,read:J}of K)if(J.status==="ok")m.current[q]=J.files;else if(J.status==="missing")j.push(q);if(j.length===0)return;let ne=new Set(j);for(let q of j)delete m.current[q];let Q=new Set([...N.current].filter((q)=>!ne.has(q)));N.current=Q,p(Q)},A=async()=>{if(!t)return;let P=v.current;g(!0);try{let z=await Ie(M());if(v.current!==P)return;if(z.status!=="ok")return;if(D.current!==P)m.current={};if(k.current=z.files,T(P,z.root),await R(P),v.current!==P)return;T(P,z.root)}finally{if(v.current===P)g(!1)}},H=async(P)=>{let z=v.current,K=await Ie(M(P));if(v.current!==z||K.status!=="ok")return;if(m.current[P]=K.files,D.current===z)T(z,E.current)},W=(P)=>{let z=It(P);if(z.status!=="ok")return;let K=v.current;if(D.current!==K)m.current={};k.current=z.files,T(K,z.root),R(K).then(()=>{if(v.current===K)T(K,z.root)})},ee=()=>{m.current={},k.current=[],D.current="",E.current="",h({scope:"",files:[],root:""})},te=(P)=>{let z=v.current;if(D.current!==z)return null;let K={name:P.path.slice(P.path.lastIndexOf("/")+1),path:P.path,type:P.kind,ignored:!1},j=Pe(k.current,m.current,K);if(j.nodes===k.current)return null;return k.current=j.nodes,m.current=j.cache,T(z,E.current)},oe=(P,z)=>{let K=v.current;if(D.current!==K)return null;let j=$t(k.current,m.current,P);if(!j.entry)return null;m.current=Ot(j.cache,P,z);let ne={...j.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},Q=Pe(j.nodes,m.current,ne);return k.current=Q.nodes,m.current=Q.cache,T(K,E.current)},G=b.scope===f;return{scope:f,files:G?b.files:[],root:G?b.root:"",isLoading:x,reload:A,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:oe,reset:ee}}function Gt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=at(),[f,b]=S("files.clipboard",null),h=ft(f),x=lt(t,r),g=o(!1),m=o(null);i(()=>{if(p.state!=="idle"||!p.data)return;let N=p.data;if(m.current===N)return;m.current=N;let M=g.current;if(g.current=!1,N.success){if(M)b(null);if(N.failures?.length)c(`${N.failures.length} item(s) could not be moved: ${N.failures[0].error}`);l()}else c(N.error||"The transfer did not complete")},[p.state,p.data]);let k=a((N,M)=>{g.current=M;let T=new FormData;for(let[R,A]of Object.entries(N))T.append(R,A);if(r&&r!==".")T.append("repo",r);if(t)T.append("root",t);p.submit(T,{method:"post",action:"/api/fs/action"})},[p,r,t]),v=a((N)=>ut(h,x,Me(N.path,N.kind)),[h,x]),D=a((N,M)=>pt(N,Me(M.path,M.kind)),[]),E=a((N,M,T,R)=>{let A=new FormData;A.append("actionType","paste"),A.append("mode",T),A.append("targetPath",M.path),A.append("targetKind",M.kind);for(let H of N)A.append("sourcePath",H.path);if(r&&r!==".")A.append("repo",r);if(t)A.append("root",t);g.current=R,p.submit(A,{method:"post",action:"/api/fs/action"})},[p,r,t]);return{clip:h,busy:p.state!=="idle",refusalFor:v,moveRefusalFor:D,copy:(N)=>{if(N.length===0)return;b({scope:x,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"copy"})},cut:(N)=>{if(N.length===0)return;b({scope:x,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"cut"})},duplicate:(N)=>{k({actionType:"duplicate",path:N.path},!1)},move:(N,M)=>{let T=D(N,M);if(T){c(T);return}E([N],M,"cut",Boolean(h?.mode==="cut"&&h.entries.some((R)=>R.path===N.path)))},paste:(N)=>{if(!h)return;let M=v(N);if(M){c(M);return}E(h.entries.map(({path:T,name:R,kind:A})=>({path:T,name:R,kind:A})),N,h.mode,h.mode==="cut")}}}var vn=Le.map((t)=>({...t,available:!0,tool:t.id}));function Kt({rootPath:t,repo:r,onComplete:l}){let c=at(),[p,f]=n(vn),[b,h]=n(null),[x,g]=n(null),[m,k]=n(null),v=o(null),D=o(null);i(()=>{let R=!1;return(async()=>{try{let H=await(await fetch("/api/fs/archive")).json();if(!R&&Array.isArray(H.formats)&&H.formats.length>0)f(H.formats)}catch{}})(),()=>{R=!0}},[]),i(()=>{if(c.state!=="idle"||!c.data)return;let R=c.data;if(D.current===R)return;D.current=R;let A=v.current;if(v.current=null,R.success){if(k(null),A==="compress")h(null);if(A==="extract")g(null);l()}else if(A)k(R.error||"The archive request failed")},[c.state,c.data]);let E=a((R)=>{let A=new FormData;for(let[H,W]of Object.entries(R))A.append(H,W);if(r&&r!==".")A.append("repo",r);if(t)A.append("root",t);c.submit(A,{method:"post",action:"/api/fs/action"})},[c,r,t]),N=a((R)=>{if(R.length===0)return;let A=p.find((H)=>H.id==="zip"&&H.available)?.id??p.find((H)=>H.available)?.id??"zip";k(null),g(null),h({entries:R.map(({path:H,name:W,kind:ee})=>({path:H,name:W,kind:ee})),format:A,name:De(R,A),destination:yt(R)})},[p]),M=a((R)=>{k(null),h(null),g({archive:R,destination:kt(R.path)})},[]),T=a((R)=>{h((A)=>{if(!A)return A;let H=De(A.entries,A.format),W=A.name===H?De(A.entries,R):A.name;return{...A,format:R,name:W}})},[]);return{formats:p,compress:b,extract:x,error:m,busy:c.state!=="idle",openCompress:N,openExtract:M,setFormat:T,setName:(R)=>h((A)=>A&&{...A,name:R}),setCompressDestination:(R)=>h((A)=>A&&{...A,destination:R}),setExtractDestination:(R)=>g((A)=>A&&{...A,destination:R}),cancel:()=>{h(null),g(null),k(null)},submitCompress:()=>{let R=b;if(!R)return;v.current="compress",k(null),E({actionType:"compress",format:R.format,name:R.name.trim(),destination:R.destination.trim()||".",paths:JSON.stringify(R.entries.map((A)=>A.path))})},submitExtract:()=>{let R=x;if(!R)return;v.current="extract",k(null),E({actionType:"extract",path:R.archive.path,destination:R.destination.trim()||"."})}}}function yn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function kn(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),b=Math.max(c,p);return t.slice(f,b+1)}function jt(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(kn(t,c,m)));return}if(p(m),g==="toggle"){l((k)=>{let v=new Set(k);if(v.has(m))v.delete(m);else v.add(m);return v});return}l(new Set([m]))},[c,t]),b=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),x=a(yn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:x,applyGesture:f,ensureForContext:b,clear:h}),[r,c,x,f,b,h])}function Ke(t,r,l=0,c=[]){for(let p of t)if(c.push({path:p.path,name:p.name,kind:p.type==="folder"?"folder":"file",depth:l}),p.type==="folder"&&r(p)&&Array.isArray(p.children))Ke(p.children,r,l+1,c);return c}function _t({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((x,g)=>{let m=st(g,x);if(m.length===0)return;r((k)=>{if(m.every((D)=>k.has(D)))return k;let v=new Set(k);for(let D of m)v.add(D);return l(Array.from(v)),v})},[r,l]),b=a((x)=>{let g=t.insertEntry(x);if(!g){c();return}f(x.path,g)},[t,c,f]),h=a((x,g)=>{p?.(x,g),r((k)=>{let v=Pt(k,x,g);return l(Array.from(v)),v});let m=t.moveEntry(x,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:b,moveRenamed:h}}var Cn=new Set;function Wt({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((x)=>{let g=Ee(x.path,x.name);if(!g)return;p((k)=>{let v=k.scope===t?k.chains:new Map;if(v.get(x.path)?.length===g.length)return k;let E=new Map(v);return E.set(x.path,g),{scope:t,chains:E}});let m=g.slice(0,-1);r((k)=>{if(m.every((D)=>k.has(D)))return k;let v=new Set(k);for(let D of m)v.add(D);return l(Array.from(v)),v})},[t,r,l]),b=a((x)=>{let g=c.scope===t?c.chains.get(x):void 0;if(!g)return;let m=g.slice(0,-1);p((k)=>{if(k.scope!==t)return k;let v=new Map(k.chains);return v.delete(x),{scope:t,chains:v}}),r((k)=>{if(!m.some((D)=>k.has(D)))return k;let v=new Set(k);for(let D of m)v.delete(D);return l(Array.from(v)),v})},[t,c,r,l]),h=a((x,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let k=new Map,v=[],D=!1;for(let[E,N]of m){if(N.findIndex((A,H)=>A===x&&H>0&&H<N.length-1)!==-1){D=!0;continue}let T=N.map((A)=>A===x?g:A.startsWith(`${x}/`)?`${g}${A.slice(x.length)}`:A),R=T[T.length-1];if(R!==E||T.some((A,H)=>A!==N[H]))D=!0;k.set(R,T),v.push(...T.slice(0,-1))}if(!D)return;p({scope:t,chains:k}),r((E)=>{if(v.every((M)=>E.has(M)))return E;let N=new Set(E);for(let M of v)N.add(M);return l(Array.from(N)),N})},[t,c,r,l]);return{unfolded:c.scope===t&&c.chains.size>0?new Set(c.chains.keys()):Cn,unfold:f,fold:b,rekey:h}}function Ut(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 b=(p.children||[]).map(c).filter((h)=>h!==null);if(f||b.length>0)return{...p,children:f&&b.length===0?p.children:b,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Vt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return i(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(b)=>{if(!b.currentTarget.contains(b.relatedTarget))f(!1)},onDragOver:(b)=>{if(!c)return;if(b.preventDefault(),b.dataTransfer)b.dataTransfer.dropEffect="move"},onDrop:(b)=>{if(!c)return;b.preventDefault(),f(!1),r.move(t,l)}}}function oi({className:t="",enabled:r=!0,active:l=!0,rootPath:c,onOpenFile:p,refreshKey:f=0,onRefresh:b}){let[h,x]=S("files.searchQuery",""),[g,m,k]=S("files.expandedPaths",[]),[v,D]=n(()=>new Set(g)),{activeRepo:E,setActiveRepo:N}=ir(c),{repos:M,scanning:T,rescan:R}=or(c,r),{fileMap:A,folderMap:H,refreshGitStatus:W}=Ds(c,E,r),[ee,te]=n(null),oe=o(null);i(()=>{if(!k)return;D((O)=>{let Z=new Set(g);if(O.size===Z.size&&Array.from(Z).every((me)=>O.has(me)))return O;return Z})},[k,g]);let G=Ht({enabled:r,rootPath:c,activeRepo:E,expandedPaths:v,onExpansionPruned:(O)=>{D(O),m(Array.from(O))}});i(()=>{if(!k||!l)return;G.reload()},[f,c,r,E,k,l]);let P=r&&k?SA(G.scope):null,z=we(P);i(()=>{if(z.data)G.adoptRoot(z.data)},[z.data]);let K=(O)=>(W(),G.loadChildren(O)),j=(O,Z)=>{let me=new Set(v);if(Z)me.add(O);else me.delete(O);D(me),m(Array.from(me))},{unfolded:ne,unfold:Q,fold:q,rekey:J}=Wt({scope:G.scope,setExpandedPaths:D,setStoredExpandedPaths:m}),re=G.files,he=it(re,ne),Y=Ut(he.nodes,h),fe=Ke(Y,(O)=>O.forceExpanded!==void 0?O.forceExpanded:v.has(O.path)),ae=jt(fe.map((O)=>O.path)),xe=fe.filter((O)=>ae.selected.has(O.path)).map(({path:O,name:Z,kind:me})=>({path:O,name:Z,kind:me})),L=(O)=>{if(O===E)return;G.reset(),D(new Set),m([]),ae.clear(),N(O)},_=()=>{if(W(),b)b();else G.reload()},{insertCreated:ce,moveRenamed:ye}=_t({listing:G,setExpandedPaths:D,setStoredExpandedPaths:m,reload:_,onMoved:(O,Z)=>J(O,Z)}),be=Iu(),{pushToast:X}=Ve(),B=Gt({rootPath:c,repo:E,onComplete:_,onError:(O)=>X(O,"error")}),ke=Kt({rootPath:c,repo:E,onComplete:_}),ve={path:".",name:".",kind:"folder"},pe=B.clip&&!B.refusalFor(ve)?`Paste ${Ne(B.clip)??"item"}`:null,[V,ge]=n(null),ue=Vt({dragging:V,clipboard:B,target:ve}),Re=Fe({folderPath:".",rootPath:c,repo:E,onCreated:ce,onOpenCreated:(O)=>p?.({...O,root:c,repo:E})}),[je,qt]=n(!1);i(()=>qt(!0),[]);let{count:_e,clear:We}=ae;if(i(()=>{if(!l)return;let O=(Z)=>{if(Z.key==="Escape"&&_e>0)We()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[l,_e,We]),!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=G.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Ye,{rootPath:c,activeRepo:E,repos:M,reposScanning:T,onRefreshRepos:R,onSelectRepo:L,searchQuery:h,onSearchChange:x,onRefresh:_,refreshing:Qt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${ue.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(O)=>{O.preventDefault(),te({x:O.clientX,y:O.clientY})},onDragEnter:ue.onDragEnter,onDragLeave:ue.onDragLeave,onDragOver:ue.onDragOver,onDrop:ue.onDrop,children:G.isLoading&&Y.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Y.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Y.map((O)=>e(ze,{file:O,rootPath:c,basePath:G.root,repo:E,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:ce,onRenamed:ye,expandedPaths:v,onToggleFolder:j,gitFileMap:A,gitFolderMap:H,clipboard:B,archive:ke,selection:ae,selectionTargets:xe,dragging:V,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!V)return;B.move(V,Z)},onUnfold:Q,onFold:q,foldRoots:he.roots,touch:be},O.path))}),e(Et,{}),je&&e(Tt,{menu:ee,menuRef:oe,pasteLabel:pe,busy:B.busy,create:Re,onAction:(O)=>{if(te(null),O==="new_file")Re.openDialog("file");if(O==="new_folder")Re.openDialog("folder");if(O==="paste")B.paste(ve)}}),je&&e(At,{archive:ke})]})}export{oi as FileExplorer};