@kabmo-labs/kabmo 0.43.0 → 0.43.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 (163) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +609 -600
  3. package/dist/client/static/js/{CsvGrid-3fr85032.js → CsvGrid-g67pk2zy.js} +1 -1
  4. package/dist/client/static/js/{DocxView-pqbp2fpd.js → DocxView-pyh6p2kb.js} +1 -1
  5. package/dist/client/static/js/{DrawioView-m0vecq1m.js → DrawioView-g48r6y2m.js} +1 -1
  6. package/dist/client/static/js/{ImageView-rbejbjwg.js → ImageView-rnzf5tve.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-mxfsqh57.js → LayoutWrapper-rekrgth6.js} +1 -1
  8. package/dist/client/static/js/{Modal-vnwg4xn3.js → Modal-edw446r8.js} +1 -1
  9. package/dist/client/static/js/{PdfView-wmg0vk2p.js → PdfView-6z3cgj37.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-90z2t4qe.js → SessionsView-e84tjbcr.js} +1 -1
  11. package/dist/client/static/js/{SheetView-rg5gkcd7.js → SheetView-64076z1j.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-wpb7b0ez.js → SvgPreview-dmpgavgd.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-4pxqt66j.js → abnfDiagram-O67JEVCF-nfz5z1vw.js} +1 -1
  14. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-kwt1va5y.js → architectureDiagram-NJMV4G6O-jra2jyzw.js} +1 -1
  15. package/dist/client/static/js/{blockDiagram-BEXU5L5S-hbj5v7n7.js → blockDiagram-BEXU5L5S-3szktxam.js} +1 -1
  16. package/dist/client/static/js/{c4Diagram-YGBWAQC7-epfzh8dw.js → c4Diagram-YGBWAQC7-xe9vbppt.js} +1 -1
  17. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-kbks4qgz.js → classDiagram-v2-NBCMYWYE-egzhj1xn.js} +1 -1
  18. package/dist/client/static/js/{cose-bilkent-JH36ORCC-dvdmckrf.js → cose-bilkent-JH36ORCC-dfrk1wnr.js} +1 -1
  19. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-r084stj5.js → cynefinDiagram-VND7K2PF-xefpcmpg.js} +1 -1
  20. package/dist/client/static/js/{dagre-6A5THRUB-64qc51n1.js → dagre-6A5THRUB-vtzjnrt9.js} +1 -1
  21. package/dist/client/static/js/{diagram-22UHCM2B-70qtb1rm.js → diagram-22UHCM2B-4vvn790v.js} +1 -1
  22. package/dist/client/static/js/{diagram-3UASUU5V-dgkvnsme.js → diagram-3UASUU5V-tmht3bew.js} +1 -1
  23. package/dist/client/static/js/{diagram-ATOU4E4O-rnpsp26v.js → diagram-ATOU4E4O-p5wa5ztx.js} +1 -1
  24. package/dist/client/static/js/{diagram-CDSNMT55-26hthh60.js → diagram-CDSNMT55-8myesjfc.js} +1 -1
  25. package/dist/client/static/js/{diagram-MLGK6HIB-nc1s85r5.js → diagram-MLGK6HIB-9t3x2d5f.js} +1 -1
  26. package/dist/client/static/js/{diagram-MPIPVDR6-e4dckqhv.js → diagram-MPIPVDR6-8ahgnmhy.js} +1 -1
  27. package/dist/client/static/js/{dockerfile-rxtyyhr1.js → dockerfile-x8aa0543.js} +1 -1
  28. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-3w9h8qk7.js → ebnfDiagram-ZINNZB2B-5semw111.js} +1 -1
  29. package/dist/client/static/js/{elk-276RUBZZ-httpkyb1.js → elk-276RUBZZ-jmhs58ww.js} +1 -1
  30. package/dist/client/static/js/{erDiagram-OPXOYQCR-3qhvf7se.js → erDiagram-OPXOYQCR-31wvbpdr.js} +1 -1
  31. package/dist/client/static/js/flowDiagram-KWPJA3E3-36ygrbvm.js +1 -0
  32. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-t53m50e5.js → ganttDiagram-FUAMR5RP-c2dycjrf.js} +1 -1
  33. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-b5wn9eht.js → gitGraphDiagram-X574FWY7-y4k4pdd8.js} +1 -1
  34. package/dist/client/static/js/{index-kc3c2gzb.js → index-0q2qfcjn.js} +1 -1
  35. package/dist/client/static/js/{index-7zc1z9z9.js → index-2b46dzw8.js} +1 -1
  36. package/dist/client/static/js/{index-dg3b0mfk.js → index-2cbnjc32.js} +1 -1
  37. package/dist/client/static/js/{index-q1gwgmxt.js → index-3588r3wg.js} +1 -1
  38. package/dist/client/static/js/{index-8y51kgan.js → index-48gh56ka.js} +1 -1
  39. package/dist/client/static/js/{index-2q23dwrs.js → index-48pb18zj.js} +1 -1
  40. package/dist/client/static/js/{index-ksph3kpr.js → index-4rv388z7.js} +1 -1
  41. package/dist/client/static/js/{index-qzw4jnnv.js → index-52xmdeh2.js} +1 -1
  42. package/dist/client/static/js/{index-kccp6tgd.js → index-6fpd55cq.js} +1 -1
  43. package/dist/client/static/js/{index-d8r84zjd.js → index-8kqepehd.js} +2 -2
  44. package/dist/client/static/js/{index-fgyenbv8.js → index-aar68x31.js} +1 -1
  45. package/dist/client/static/js/{index-r11bbnek.js → index-cgzw43bc.js} +2 -2
  46. package/dist/client/static/js/{index-g3a9j9hf.js → index-cje5gg45.js} +1 -1
  47. package/dist/client/static/js/{index-rv4qs3wm.js → index-cjhvtzdd.js} +1 -1
  48. package/dist/client/static/js/{index-wmv3crye.js → index-dkwhs38j.js} +1 -1
  49. package/dist/client/static/js/{index-vmgzhp41.js → index-efra065v.js} +1 -1
  50. package/dist/client/static/js/{index-zqthmaxq.js → index-f77c3ag0.js} +147 -146
  51. package/dist/client/static/js/{index-7z9tz4ze.js → index-f7djda1g.js} +1 -1
  52. package/dist/client/static/js/{index-egd0vfey.js → index-fbcg8y95.js} +1 -1
  53. package/dist/client/static/js/{index-1dwdgp27.js → index-g3shdymf.js} +1 -1
  54. package/dist/client/static/js/{index-axszsg7a.js → index-h5n1btqy.js} +1 -1
  55. package/dist/client/static/js/{index-tzbzehqd.js → index-kc5znr75.js} +2 -2
  56. package/dist/client/static/js/{index-tnv3dryk.js → index-m1n4v0z7.js} +1 -1
  57. package/dist/client/static/js/{index-g4rsmakg.js → index-m94f4ngb.js} +1 -1
  58. package/dist/client/static/js/{index-4banz7gr.js → index-nt7nhchn.js} +1 -1
  59. package/dist/client/static/js/{index-f4fqvct6.js → index-pt8440xh.js} +1 -1
  60. package/dist/client/static/js/{index-jvs2fvqz.js → index-rn8w29pv.js} +1 -1
  61. package/dist/client/static/js/{index-kmzd0adv.js → index-s00j9042.js} +1 -1
  62. package/dist/client/static/js/{index-dkqgmacr.js → index-s7rfbydk.js} +1 -1
  63. package/dist/client/static/js/{index-j60gtvw8.js → index-sg6sz3g8.js} +1 -1
  64. package/dist/client/static/js/{index-k9ws464d.js → index-vyw4tbn8.js} +1 -1
  65. package/dist/client/static/js/{index-enb6chty.js → index-w5rw8f7w.js} +1 -1
  66. package/dist/client/static/js/{index-gwqb7m8g.js → index-x6v37h3j.js} +1 -1
  67. package/dist/client/static/js/{infoDiagram-VRGFBTTK-qv7438m3.js → infoDiagram-VRGFBTTK-z3pqx7w8.js} +1 -1
  68. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-p1w6zg5y.js → ishikawaDiagram-OU5B5YK6-f5v6z8yr.js} +1 -1
  69. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-ywk6xqxr.js → journeyDiagram-ZHPQQLJL-js1yxatk.js} +1 -1
  70. package/dist/client/static/js/{kanban-definition-PNTS6WVX-gtrmhggc.js → kanban-definition-PNTS6WVX-m0a6069c.js} +1 -1
  71. package/dist/client/static/js/{mermaid.core-5s24b4hh.js → mermaid.core-6xvbnm63.js} +2 -2
  72. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-3wx7abqn.js → mindmap-definition-NLK3R4M7-a9f9yzc0.js} +1 -1
  73. package/dist/client/static/js/one-dark-pro-hteqzfb0.js +1 -0
  74. package/dist/client/static/js/one-light-dapnh0rs.js +1 -0
  75. package/dist/client/static/js/{pegDiagram-GJSIUBJH-yvyqnjya.js → pegDiagram-GJSIUBJH-4v4pf1h1.js} +1 -1
  76. package/dist/client/static/js/{pieDiagram-5QR66LMP-26x6pj38.js → pieDiagram-5QR66LMP-a54yrmfm.js} +1 -1
  77. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-qhe8h0j9.js → quadrantDiagram-O4NWA36T-1twhvnp2.js} +1 -1
  78. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-dwy3k2jx.js → railroadDiagram-XR7U4H2S-83tqfdcy.js} +1 -1
  79. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-hcmgfesg.js → requirementDiagram-PLB6GJNP-73e3pzw6.js} +1 -1
  80. package/dist/client/static/js/{rust-bmb4ee5w.js → rust-jds4e4r7.js} +1 -1
  81. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-s6d3k4zs.js → sankeyDiagram-IPEJSGJF-1bzwj6sb.js} +1 -1
  82. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-0fcmzgdy.js → sequenceDiagram-PO4LG4MO-yh3h988k.js} +1 -1
  83. package/dist/client/static/js/{sizeCapture-INFHLROL-t8fcm7rq.js → sizeCapture-INFHLROL-1n121yp6.js} +1 -1
  84. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-jr80hfeg.js → stateDiagram-v2-GCMORJYK-0tdrzn06.js} +1 -1
  85. package/dist/client/static/js/{swimlanes-2SLR337P-x1ay6w39.js → swimlanes-2SLR337P-77n1ttdw.js} +1 -1
  86. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-xj123xrp.js → swimlanesDiagram-TC7HE7FX-akjqm31r.js} +1 -1
  87. package/dist/client/static/js/{timeline-definition-EJHVYXUP-qz0g6msb.js → timeline-definition-EJHVYXUP-b6r0k3e8.js} +1 -1
  88. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-sxzrv8ht.js → usecaseDiagram-POWQR4AR-efq58m3m.js} +1 -1
  89. package/dist/client/static/js/{vennDiagram-UO4OBE2U-qsqgnjcv.js → vennDiagram-UO4OBE2U-ad4gvd5r.js} +1 -1
  90. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-rvwxn458.js → wardleyDiagram-VNRHLVJA-v89tys2p.js} +1 -1
  91. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-nb4w7rcg.js → xychartDiagram-PMCCYNJV-xtgzmknw.js} +1 -1
  92. package/package.json +1 -1
  93. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +21 -9
  94. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/TaskResult.tsx +18 -4
  95. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/task-rows.ts +47 -0
  96. package/src/client/hooks/chat/omp/index.ts +2 -6
  97. package/src/server/lib/changes/capture-client-write.server.ts +45 -0
  98. package/src/server/lib/changes/capture.server.ts +20 -5
  99. package/src/server/lib/db/schema.ts +3 -0
  100. package/src/server/lib/harness/acp/auth.test.ts +69 -0
  101. package/src/server/lib/harness/acp/auth.ts +71 -0
  102. package/src/server/lib/harness/acp/background-replay.test.ts +139 -0
  103. package/src/server/lib/harness/acp/background-replay.ts +87 -0
  104. package/src/server/lib/harness/acp/background-work.ts +50 -33
  105. package/src/server/lib/harness/acp/calls.test.ts +68 -0
  106. package/src/server/lib/harness/acp/calls.ts +13 -0
  107. package/src/server/lib/harness/acp/client-capabilities.ts +5 -2
  108. package/src/server/lib/harness/acp/client-fs.test.ts +13 -0
  109. package/src/server/lib/harness/acp/client-fs.ts +16 -2
  110. package/src/server/lib/harness/acp/client.ts +22 -23
  111. package/src/server/lib/harness/acp/commands.test.ts +19 -0
  112. package/src/server/lib/harness/acp/commands.ts +26 -8
  113. package/src/server/lib/harness/acp/frames.ts +16 -1
  114. package/src/server/lib/harness/acp/grants.server.ts +75 -0
  115. package/src/server/lib/harness/acp/grants.test.ts +65 -0
  116. package/src/server/lib/harness/acp/grants.ts +79 -0
  117. package/src/server/lib/harness/acp/permissions.test.ts +9 -0
  118. package/src/server/lib/harness/acp/permissions.ts +56 -36
  119. package/src/server/lib/harness/acp/prompt-files.test.ts +69 -0
  120. package/src/server/lib/harness/acp/prompt-files.ts +58 -0
  121. package/src/server/lib/harness/acp/prompt.ts +50 -11
  122. package/src/server/lib/harness/acp/protocol.ts +20 -1
  123. package/src/server/lib/harness/acp/session-approvals.ts +45 -0
  124. package/src/server/lib/harness/acp/session-config-view.ts +81 -0
  125. package/src/server/lib/harness/acp/session-config.ts +48 -9
  126. package/src/server/lib/harness/acp/session-handshake.test.ts +71 -2
  127. package/src/server/lib/harness/acp/session-handshake.ts +128 -53
  128. package/src/server/lib/harness/acp/session-intake.test.ts +93 -0
  129. package/src/server/lib/harness/acp/session-intake.ts +75 -0
  130. package/src/server/lib/harness/acp/session-lifecycle.ts +50 -0
  131. package/src/server/lib/harness/acp/session-lost.test.ts +44 -0
  132. package/src/server/lib/harness/acp/session-lost.ts +34 -0
  133. package/src/server/lib/harness/acp/session-notify.ts +47 -0
  134. package/src/server/lib/harness/acp/session-observers.test.ts +4 -4
  135. package/src/server/lib/harness/acp/session-permissions.test.ts +64 -0
  136. package/src/server/lib/harness/acp/session-permissions.ts +9 -4
  137. package/src/server/lib/harness/acp/session-requests.ts +6 -0
  138. package/src/server/lib/harness/acp/session-roots.server.ts +47 -0
  139. package/src/server/lib/harness/acp/session-roots.test.ts +31 -0
  140. package/src/server/lib/harness/acp/session-start.ts +7 -0
  141. package/src/server/lib/harness/acp/session-turns.ts +11 -0
  142. package/src/server/lib/harness/acp/session-wiring.ts +100 -0
  143. package/src/server/lib/harness/acp/session.test-util.ts +34 -2
  144. package/src/server/lib/harness/acp/session.test.ts +10 -10
  145. package/src/server/lib/harness/acp/session.ts +146 -144
  146. package/src/server/lib/harness/acp/tool-calls.ts +27 -15
  147. package/src/server/lib/harness/acp/tool-identity.test.ts +136 -0
  148. package/src/server/lib/harness/acp/tool-identity.ts +121 -0
  149. package/src/server/lib/harness/acp/turn-cancel.test.ts +79 -0
  150. package/src/server/lib/harness/acp/turn-cancel.ts +61 -0
  151. package/src/server/lib/harness/acp/turn-dispatch.test.ts +103 -0
  152. package/src/server/lib/harness/acp/turn-dispatch.ts +61 -0
  153. package/src/server/lib/harness/acp/turn-queue.ts +43 -0
  154. package/src/server/lib/harness/acp/turn-verdict.ts +102 -0
  155. package/src/server/lib/harness/acp/turn.ts +86 -88
  156. package/src/server/lib/harness/acp/v2.test.ts +9 -0
  157. package/src/server/lib/harness/acp/v2.ts +13 -0
  158. package/src/server/lib/harness/acp/verbs.ts +35 -4
  159. package/src/server/lib/omp/session/delete.server.ts +3 -0
  160. package/src/shared/types/omp/agent.ts +14 -5
  161. package/dist/client/static/js/flowDiagram-KWPJA3E3-1jat076e.js +0 -1
  162. package/dist/client/static/js/one-dark-pro-3vya9z02.js +0 -1
  163. package/dist/client/static/js/one-light-1yrwn9my.js +0 -1
@@ -1,2 +1,2 @@
1
- import{n,o,i,a,e,tt,S,s,ne,An,m,_,dr,At,Re,Ge,Cr,Pn,Jr,qi,b,oc}from"./index-zqthmaxq.js";import{ku}from"./index-ksph3kpr.js";import"./index-2q23dwrs.js";var te={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]},U=s(te);var re={name:"move-vertical",size:24,node:[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]},D=s(re);var oe={live:"Live","agent-offline":"Agent offline","browser-offline":"Browser offline","no-tab":"Tanpa tab"};function j({url:t,status:r,zoomLevel:d=100,onIncludeInChat:c,onReconnect:l,onOpenExternal:u,onZoomIn:p,onZoomOut:w,onResetZoom:k}){return e(ku,{url:t??"",statusDotClass:r==="live"?"bg-success animate-pulse":"bg-ink/25",statusLabel:oe[r],zoomLevel:d,onZoomIn:p,onZoomOut:w,onResetZoom:k,onIncludeInChat:c,onOpenExternal:u,onReconnect:l,openExternalLabel:"Buka di jendela baru",openExternalTitle:t?"Open in new window":"No URL loaded",children:e("div",{className:"flex-1 min-w-0 flex items-center bg-canvas border border-ink/15 rounded-md px-2 py-0.5",children:[e(Re,{size:12,className:"text-ink/40 mr-1.5 flex-shrink-0"}),e("span",{className:"w-full truncate text-ink/80 font-mono text-[11px]",title:t??"",children:t||"No page open yet"})]})})}var se=[["RAM","~93 MB → ~259 MB untuk satu tab"],["Disk","~346 MB untuk Chrome for Testing bila belum terpasang"],["Idle","Tab Chromium terus melukis; omp membekukannya saat turn selesai"],["Deteksi","Halaman bisa melihat otomasi (navigator.webdriver, CDP)"]];function Z({saving:t,onUseChromium:r}){return e("button",{type:"button",onClick:r,disabled:t,className:"inline-flex items-center gap-1.5 rounded-md border border-ink/15 bg-ink/5 px-2.5 py-1 text-[11px] font-medium text-ink transition-colors hover:bg-ink/10 disabled:cursor-not-allowed disabled:opacity-60",children:[t&&e(m,{size:11,className:"animate-spin"}),t?"Mengaktifkan…":"Pakai Chromium"]})}function z({saving:t,error:r,onUseChromium:d,variant:c}){if(c==="strip")return e("div",{className:"flex items-center justify-between gap-2 border-b border-ink/10 bg-ink/[0.03] px-2.5 py-1.5 flex-shrink-0",children:[e("span",{className:"min-w-0 truncate text-[11px] text-ink/70",children:"Agen memakai WebKit — tab baru tidak akan muncul di panel ini."}),e(Z,{saving:t,onUseChromium:d})]});return e("div",{className:"flex-1 flex flex-col items-center justify-center overflow-y-auto p-6 text-center select-none my-auto",children:[e("div",{className:"w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3",children:e(_,{size:24})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Agen memakai WebKit — panel ini tidak bisa memantulkannya"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"WebKit milik omp tidak punya CDP dan tidak mengekspos aliran frame, jadi tab yang dijalankannya tidak bisa ditampilkan di sini. Panel ini hanya bisa memantulkan Chromium."}),e("div",{className:"mt-4 w-full max-w-sm rounded-lg border border-ink/10 bg-paper text-left",children:[e("div",{className:"border-b border-ink/10 px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/50",children:"Biaya pindah ke Chromium"}),e("dl",{className:"divide-y divide-ink/5",children:se.map(([l,u])=>e("div",{className:"flex gap-2 px-3 py-1.5",children:[e("dt",{className:"w-14 flex-shrink-0 text-[11px] font-medium text-ink/70",children:l}),e("dd",{className:"text-[11px] text-ink/60",children:u})]},l))})]}),e("div",{className:"mt-3 flex flex-col items-center gap-1.5",children:[e(Z,{saving:t,onUseChromium:d}),e("p",{className:"text-[10.5px] text-ink/45 max-w-sm",children:"Berlaku untuk tab yang dibuka berikutnya; sesi tidak perlu di-restart. Tab WebKit yang sudah terbuka tetap tidak terlihat."}),r&&e("p",{role:"alert",className:"text-[11px] text-error max-w-sm",children:r})]})]})}var ae={open:Re,navigate:Re,loaded:ne,click:U,type:Jr,press:At,submit:Pn,wait:Ge,screenshot:dr,scroll:D,upload:qi,close:An,error:An};function F({actions:t}){if(t.length===0)return null;return e("div",{className:"absolute bottom-3 left-3 z-20 flex flex-col gap-1.5 pointer-events-none max-w-[320px]",children:t.map((r)=>{let d=ae[r.kind],c=r.kind==="error";return e("div",{className:`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur-sm ${c?"border-error/30 bg-error/10 text-error":"border-ink/15 bg-paper/95 text-ink"}`,children:[e(d,{size:12,className:`flex-shrink-0 ${c?"text-error":"text-ink/60"}`}),e("span",{className:"truncate",children:r.label})]},r.id)})})}function ie(t){return t.title||t.url||t.targetId}function H({tabs:t,targetId:r,closing:d,onSelectTarget:c,onCloseTarget:l}){let u=i(null);return o(()=>{u.current?.scrollIntoView({block:"nearest",inline:"nearest"})},[r,t.length]),e("div",{className:"px-2 py-1 border-b border-ink/10 bg-paper flex items-center gap-1 overflow-x-auto flex-shrink-0",children:t.map((p)=>{let w=p.targetId===r,k=ie(p);return e("div",{ref:w?u:void 0,className:`group flex items-center rounded border transition-colors flex-shrink-0 ${w?"bg-ink text-canvas border-ink":"bg-paper text-ink/70 border-ink/15 hover:border-ink/35 hover:text-ink"}`,children:[e("button",{type:"button",onClick:()=>c(w?"":p.targetId),className:"pl-2 pr-1 py-0.5 text-[11px] font-mono max-w-[220px] truncate cursor-pointer",title:`${k}
1
+ import{n,o,i,a,e,tt,S,s,ne,An,m,_,dr,At,Re,Ge,Cr,Pn,Jr,qi,b,oc}from"./index-f77c3ag0.js";import{ku}from"./index-4rv388z7.js";import"./index-48pb18zj.js";var te={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]},U=s(te);var re={name:"move-vertical",size:24,node:[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]},D=s(re);var oe={live:"Live","agent-offline":"Agent offline","browser-offline":"Browser offline","no-tab":"Tanpa tab"};function j({url:t,status:r,zoomLevel:d=100,onIncludeInChat:c,onReconnect:l,onOpenExternal:u,onZoomIn:p,onZoomOut:w,onResetZoom:k}){return e(ku,{url:t??"",statusDotClass:r==="live"?"bg-success animate-pulse":"bg-ink/25",statusLabel:oe[r],zoomLevel:d,onZoomIn:p,onZoomOut:w,onResetZoom:k,onIncludeInChat:c,onOpenExternal:u,onReconnect:l,openExternalLabel:"Buka di jendela baru",openExternalTitle:t?"Open in new window":"No URL loaded",children:e("div",{className:"flex-1 min-w-0 flex items-center bg-canvas border border-ink/15 rounded-md px-2 py-0.5",children:[e(Re,{size:12,className:"text-ink/40 mr-1.5 flex-shrink-0"}),e("span",{className:"w-full truncate text-ink/80 font-mono text-[11px]",title:t??"",children:t||"No page open yet"})]})})}var se=[["RAM","~93 MB → ~259 MB untuk satu tab"],["Disk","~346 MB untuk Chrome for Testing bila belum terpasang"],["Idle","Tab Chromium terus melukis; omp membekukannya saat turn selesai"],["Deteksi","Halaman bisa melihat otomasi (navigator.webdriver, CDP)"]];function Z({saving:t,onUseChromium:r}){return e("button",{type:"button",onClick:r,disabled:t,className:"inline-flex items-center gap-1.5 rounded-md border border-ink/15 bg-ink/5 px-2.5 py-1 text-[11px] font-medium text-ink transition-colors hover:bg-ink/10 disabled:cursor-not-allowed disabled:opacity-60",children:[t&&e(m,{size:11,className:"animate-spin"}),t?"Mengaktifkan…":"Pakai Chromium"]})}function z({saving:t,error:r,onUseChromium:d,variant:c}){if(c==="strip")return e("div",{className:"flex items-center justify-between gap-2 border-b border-ink/10 bg-ink/[0.03] px-2.5 py-1.5 flex-shrink-0",children:[e("span",{className:"min-w-0 truncate text-[11px] text-ink/70",children:"Agen memakai WebKit — tab baru tidak akan muncul di panel ini."}),e(Z,{saving:t,onUseChromium:d})]});return e("div",{className:"flex-1 flex flex-col items-center justify-center overflow-y-auto p-6 text-center select-none my-auto",children:[e("div",{className:"w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3",children:e(_,{size:24})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Agen memakai WebKit — panel ini tidak bisa memantulkannya"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"WebKit milik omp tidak punya CDP dan tidak mengekspos aliran frame, jadi tab yang dijalankannya tidak bisa ditampilkan di sini. Panel ini hanya bisa memantulkan Chromium."}),e("div",{className:"mt-4 w-full max-w-sm rounded-lg border border-ink/10 bg-paper text-left",children:[e("div",{className:"border-b border-ink/10 px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/50",children:"Biaya pindah ke Chromium"}),e("dl",{className:"divide-y divide-ink/5",children:se.map(([l,u])=>e("div",{className:"flex gap-2 px-3 py-1.5",children:[e("dt",{className:"w-14 flex-shrink-0 text-[11px] font-medium text-ink/70",children:l}),e("dd",{className:"text-[11px] text-ink/60",children:u})]},l))})]}),e("div",{className:"mt-3 flex flex-col items-center gap-1.5",children:[e(Z,{saving:t,onUseChromium:d}),e("p",{className:"text-[10.5px] text-ink/45 max-w-sm",children:"Berlaku untuk tab yang dibuka berikutnya; sesi tidak perlu di-restart. Tab WebKit yang sudah terbuka tetap tidak terlihat."}),r&&e("p",{role:"alert",className:"text-[11px] text-error max-w-sm",children:r})]})]})}var ae={open:Re,navigate:Re,loaded:ne,click:U,type:Jr,press:At,submit:Pn,wait:Ge,screenshot:dr,scroll:D,upload:qi,close:An,error:An};function F({actions:t}){if(t.length===0)return null;return e("div",{className:"absolute bottom-3 left-3 z-20 flex flex-col gap-1.5 pointer-events-none max-w-[320px]",children:t.map((r)=>{let d=ae[r.kind],c=r.kind==="error";return e("div",{className:`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur-sm ${c?"border-error/30 bg-error/10 text-error":"border-ink/15 bg-paper/95 text-ink"}`,children:[e(d,{size:12,className:`flex-shrink-0 ${c?"text-error":"text-ink/60"}`}),e("span",{className:"truncate",children:r.label})]},r.id)})})}function ie(t){return t.title||t.url||t.targetId}function H({tabs:t,targetId:r,closing:d,onSelectTarget:c,onCloseTarget:l}){let u=i(null);return o(()=>{u.current?.scrollIntoView({block:"nearest",inline:"nearest"})},[r,t.length]),e("div",{className:"px-2 py-1 border-b border-ink/10 bg-paper flex items-center gap-1 overflow-x-auto flex-shrink-0",children:t.map((p)=>{let w=p.targetId===r,k=ie(p);return e("div",{ref:w?u:void 0,className:`group flex items-center rounded border transition-colors flex-shrink-0 ${w?"bg-ink text-canvas border-ink":"bg-paper text-ink/70 border-ink/15 hover:border-ink/35 hover:text-ink"}`,children:[e("button",{type:"button",onClick:()=>c(w?"":p.targetId),className:"pl-2 pr-1 py-0.5 text-[11px] font-mono max-w-[220px] truncate cursor-pointer",title:`${k}
2
2
  ${p.url}`,"aria-pressed":w,children:k}),e("button",{type:"button",onClick:()=>l(p.targetId),disabled:d===p.targetId,className:`mr-0.5 p-1 rounded hover:bg-error hover:text-paper transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed ${w?"text-on-ink-muted":"text-ink/40 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,"aria-label":`Tutup tab ${k}`,title:`Tutup tab ${k}`,children:e(b,{size:11})})]},p.targetId)})})}function le(t){let r=atob(t),d=new Uint8Array(r.length);for(let c=0;c<r.length;c++)d[c]=r.charCodeAt(c);return d}function ce(t,r){return new Blob([le(t)],{type:r})}async function K(t,r,d){let c=t.getContext("2d");if(!c)return!1;if(typeof createImageBitmap!=="function")return!1;let l;try{l=await createImageBitmap(ce(r,d))}catch{return!1}try{if(t.width!==l.width||t.height!==l.height)t.width=l.width,t.height=l.height;return c.drawImage(l,0,0),!0}finally{l.close()}}var ue={"agent-offline":{title:"The agent is not running",body:"Start this session so the agent can drive the browser."},"browser-offline":{title:"No browser is open",body:"Ask the agent to open a page; the live view appears here."},"no-tab":{title:"Browser is open, with no tab yet",body:"This session has not opened a tab in the shared browser."}};function J({status:t,url:r,tabs:d,targetId:c,frame:l,actions:u,onSelectTarget:p,onCloseTarget:w,closingTarget:k,zoomLevel:I}){let B=t==="live",L=B?null:ue[t],g=i(null),[f,x]=n(!1);return o(()=>{let E=g.current;if(!E||!l)return;let y=!1;return K(E,l.data,l.mimeType).then((T)=>{if(T&&!y)x(!0)}),()=>{y=!0}},[l]),o(()=>{if(!B)x(!1)},[B]),e("div",{className:"flex-1 flex flex-col min-h-0 bg-canvas/60 relative overflow-hidden",children:[e(F,{actions:u}),B&&d.length>0&&e(H,{tabs:d,targetId:c,closing:k,onSelectTarget:p,onCloseTarget:w}),e("div",{className:"flex-1 flex items-center justify-center p-2 min-h-0 overflow-auto",children:B?e("div",{className:"relative flex flex-col bg-paper w-full h-full transition-all duration-200",style:{zoom:I!==100?`${I}%`:void 0,transformOrigin:"top center"},children:[e("canvas",{ref:g,"aria-label":r||"Live browser view",className:`w-full h-full object-contain bg-paper ${f?"":"hidden"}`}),!f&&e("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-center p-6 select-none",children:[e(m,{size:20,className:"animate-spin text-ink/40 mb-2"}),e("p",{className:"text-xs text-ink/60",children:"Menunggu frame pertama dari browser…"})]})]}):e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none my-auto",children:[e("div",{className:"w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3",children:t==="agent-offline"?e(Cr,{size:24}):e(Re,{size:24})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:L?.title}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:L?.body})]})})]})}function W(t){if(typeof t!=="object"||t===null||!("error"in t))return null;return typeof t.error==="string"?t.error:null}function X(){let[t,r]=n(null),[d,c]=n(!0),[l,u]=n(!1),[p,w]=n(null),[k,I]=n(0);o(()=>{let g=!1;return c(!0),fetch("/api/browser/engine").then((f)=>f.json()).then((f)=>{if(g)return;let x=W(f);if(x){w(x);return}r(f),w(null)}).catch((f)=>{if(!g)w(f instanceof Error?f.message:String(f))}).finally(()=>{if(!g)c(!1)}),()=>{g=!0}},[k]);let B=a(()=>I((g)=>g+1),[]),L=a(async()=>{u(!0),w(null);try{let g=await fetch("/api/browser/engine",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({webkit:!1})}),f=await g.json().catch(()=>null),x=W(f)??(g.ok?null:`The write answered ${g.status}`);if(x)return w(x),!1;return r(f),!0}catch(g){return w(g instanceof Error?g.message:String(g)),!1}finally{u(!1)}},[]);return{state:t,loading:d,saving:l,error:p,refresh:B,useChromium:L}}var G={status:"agent-offline",tabs:[]},Y=5000,de=4000,me=500,pe=3,q=16;function Q(t=!0){let{sessionId:r,ready:d}=tt(),[c,l]=n(G),[u,p]=n(null),[w,k]=n([]),[I,B]=n(""),[L,g]=n(0),f=i(null),x=i(null),E=i(void 0),y=i(0),T=i([]),M=a((N)=>{B(N.trim())},[]),O=a(()=>{g((N)=>N+1)},[]);return o(()=>{let N=setInterval(()=>{k((P)=>{let R=Date.now(),A=P.filter((h)=>h.expiresAt>R),C=T.current.shift();if(!C)return A.length===P.length?P:A;return[...A.slice(-(pe-1)),{...C,expiresAt:R+de}]})},me);return()=>clearInterval(N)},[]),o(()=>{l(G),p(null),B(""),T.current=[],k([])},[r]),o(()=>{if(!d||!r||!t)return;let N=!1,P=()=>{if(N)return;let A=I?`?target=${encodeURIComponent(I)}`:"",C=new EventSource(`/api/browser/${encodeURIComponent(r)}/stream${A}`);f.current=C,C.addEventListener("open",()=>{y.current=0}),C.addEventListener("state",(h)=>{try{let v=JSON.parse(h.data);if(E.current=v.targetId,l(v),v.status!=="live")p(null)}catch{}}),C.addEventListener("frame",(h)=>{try{let v=JSON.parse(h.data),V=E.current;if(V&&v.targetId&&v.targetId!==V)return;if(!V&&v.targetId)E.current=v.targetId;p({data:v.data,mimeType:v.mimeType})}catch{}}),C.addEventListener("action",(h)=>{try{let v=JSON.parse(h.data);if(typeof v?.label!=="string"||!v.label)return;if(T.current.push(v),T.current.length>q)T.current.splice(0,T.current.length-q)}catch{}}),C.addEventListener("error",()=>{if(C.readyState===EventSource.CLOSED)R()})},R=()=>{if(N||x.current)return;let A=Math.min(y.current+1,Y/1000);y.current=A,x.current=setTimeout(()=>{x.current=null,f.current?.close(),f.current=null,P()},Math.min(A*1000,Y))};return P(),()=>{if(N=!0,x.current)clearTimeout(x.current),x.current=null;f.current?.close(),f.current=null}},[d,r,I,L,t]),{status:c.status,url:c.url,title:c.title,tabs:c.tabs,targetId:c.targetId,frame:u,actions:w,sessionId:r,selectTarget:M,reconnect:O}}function fe(t){return typeof t==="string"&&t?t:null}function ee(t){let[r,d]=n(null);return{closeTab:a(async(l)=>{if(!t||!l)return{ok:!1,next:null,error:"No tab to close"};d(l);try{let u=await fetch(`/api/browser/${encodeURIComponent(t)}/tabs/close`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({targetId:l})}),p=await u.json().catch(()=>({}));if(!u.ok)return{ok:!1,next:null,error:typeof p.error==="string"&&p.error?p.error:`Close failed (${u.status})`};return{ok:!0,next:fe(p.next)}}catch(u){return{ok:!1,next:null,error:u instanceof Error?u.message:String(u)}}finally{d(null)}},[t]),closing:r}}function at({className:t="",active:r=!0}){let[d,c]=S("browser.zoomLevel",100),{status:l,url:u,title:p,tabs:w,targetId:k,frame:I,actions:B,sessionId:L,selectTarget:g,reconnect:f}=Q(r),{closeTab:x,closing:E}=ee(L),y=X(),[T,M]=n(null),O=y.state?.effective==="webkit"&&!y.state.mock,N=O&&(l==="browser-offline"||l==="no-tab"),P=a(()=>{y.useChromium().then((h)=>{if(h)f()})},[y.useChromium,f]),R=()=>{if(!u)return;let h=u.startsWith("/")&&typeof window<"u"?`${window.location.origin}${u}`:u;window.open(h,"_blank","noopener,noreferrer")},A=a(()=>{if(!u)return;oc({url:u,title:p})},[u,p]),C=a((h)=>{if(E===h)return;x(h).then((v)=>{if(!v.ok){M(v.error??"The tab could not be closed");return}M(null),g(v.next??"")})},[x,E,g]);return e("div",{className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden select-none ${t}`,children:[e(j,{url:u,status:l,zoomLevel:d,onIncludeInChat:A,onReconnect:f,onOpenExternal:R,onZoomIn:()=>c((h)=>Math.min(200,h+10)),onZoomOut:()=>c((h)=>Math.max(50,h-10)),onResetZoom:()=>c(100)}),T&&e("div",{role:"alert",className:"px-2.5 py-1 border-b border-error/30 bg-error/5 text-[11px] text-error flex items-center justify-between gap-2 flex-shrink-0",children:[e("span",{className:"truncate",title:T,children:T}),e("button",{type:"button",onClick:()=>M(null),className:"text-[10px] uppercase tracking-wide text-error/80 hover:text-error cursor-pointer flex-shrink-0",children:"Tutup"})]}),O&&l==="live"&&y.state&&e(z,{saving:y.saving,error:y.error,onUseChromium:P,variant:"strip"}),N&&y.state?e(z,{saving:y.saving,error:y.error,onUseChromium:P,variant:"body"}):e(J,{status:l,url:u,tabs:w,targetId:k,frame:I,actions:B,onSelectTarget:g,onCloseTarget:C,closingTarget:E,zoomLevel:d})]})}export{at as BrowserPanel};
@@ -1 +1 @@
1
- import{d,e,Vg,Ce,E,ht,ot}from"./index-zqthmaxq.js";import{oa,bu,Ts,yu,vu}from"./index-wmv3crye.js";function u(t,r){if(!t)return r;if(!r)return t;let n=Date.parse(t.generatedAt),s=Date.parse(r.generatedAt);if(Number.isNaN(n)||Number.isNaN(s))return t;return s>n?r:t}function R({className:t="",active:r=!0}){let{report:n,isLoading:s,error:o,reload:i}=vu(),l=Ce(Vg,{enabled:r}),a=u(l.data,n),p=a?Ts(a):[];if(o&&!a)return e("div",{className:`flex h-full w-full flex-col items-center justify-center gap-2 p-8 text-center text-xs ${t}`,children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-error text-xs",children:o}),e("button",{type:"button",onClick:()=>i(),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Try again"})]});if(!a)return e("div",{className:`flex h-full w-full items-center justify-center text-ink/40 text-xs ${t}`,children:"Loading provider usage..."});return e("div",{className:`flex h-full w-full min-w-0 min-h-0 flex-col overflow-hidden bg-paper text-xs text-ink ${t}`,children:[e(ht,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Usage"}),e("span",{className:"text-[11px] text-ink/50 truncate",children:["Updated ",oa(a.generatedAt)]}),a.isMock&&e("span",{className:"text-[10px] font-mono uppercase tracking-wider bg-ink/5 border border-ink/15 rounded px-1.5 py-0.5 text-ink/60",children:"Mock"})]}),right:e(ot,{label:"Refresh usage",onClick:()=>i({force:!0}),busy:s||l.refreshing,disabled:s})}),e("div",{className:"flex-1 min-w-0 min-h-0 w-full overflow-y-auto scrollbar-overlay-container p-3.5 space-y-4",children:[o&&e("p",{className:"text-error text-xs",children:o}),p.length>0?p.map((m)=>e(bu,{summary:m.summary},m.id)):e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:"No provider credentials detected. Add an API key in Settings → Providers and it will appear here."}),e(yu,{})]})]})}export{R as UsagePanel};
1
+ import{d,e,Vg,Ce,E,ht,ot}from"./index-f77c3ag0.js";import{oa,bu,Ts,yu,vu}from"./index-dkwhs38j.js";function u(t,r){if(!t)return r;if(!r)return t;let n=Date.parse(t.generatedAt),s=Date.parse(r.generatedAt);if(Number.isNaN(n)||Number.isNaN(s))return t;return s>n?r:t}function R({className:t="",active:r=!0}){let{report:n,isLoading:s,error:o,reload:i}=vu(),l=Ce(Vg,{enabled:r}),a=u(l.data,n),p=a?Ts(a):[];if(o&&!a)return e("div",{className:`flex h-full w-full flex-col items-center justify-center gap-2 p-8 text-center text-xs ${t}`,children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-error text-xs",children:o}),e("button",{type:"button",onClick:()=>i(),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Try again"})]});if(!a)return e("div",{className:`flex h-full w-full items-center justify-center text-ink/40 text-xs ${t}`,children:"Loading provider usage..."});return e("div",{className:`flex h-full w-full min-w-0 min-h-0 flex-col overflow-hidden bg-paper text-xs text-ink ${t}`,children:[e(ht,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Usage"}),e("span",{className:"text-[11px] text-ink/50 truncate",children:["Updated ",oa(a.generatedAt)]}),a.isMock&&e("span",{className:"text-[10px] font-mono uppercase tracking-wider bg-ink/5 border border-ink/15 rounded px-1.5 py-0.5 text-ink/60",children:"Mock"})]}),right:e(ot,{label:"Refresh usage",onClick:()=>i({force:!0}),busy:s||l.refreshing,disabled:s})}),e("div",{className:"flex-1 min-w-0 min-h-0 w-full overflow-y-auto scrollbar-overlay-container p-3.5 space-y-4",children:[o&&e("p",{className:"text-error text-xs",children:o}),p.length>0?p.map((m)=>e(bu,{summary:m.summary},m.id)):e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:"No provider credentials detected. Add an API key in Settings → Providers and it will appear here."}),e(yu,{})]})]})}export{R as UsagePanel};
@@ -1 +1 @@
1
- import{d,u,le,e,qg,Ce,E,B,se,xr,qs,ht,ot,Ku,Jp,BA,Zp,Xp}from"./index-zqthmaxq.js";function g({phase:t,index:s,collapsed:a,currentKey:r,onToggle:x}){let m=Zp(t),i=t.tasks.length>0&&m===t.tasks.length;return e("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[e("button",{type:"button",onClick:x,"aria-expanded":!a,className:"flex w-full items-center gap-1.5 border-b border-ink/8 bg-canvas/40 px-2.5 py-1.5 text-left hover:bg-ink/5",children:[a?e(se,{size:12,className:"shrink-0 text-ink/40"}):e(B,{size:12,className:"shrink-0 text-ink/40"}),e("span",{className:`min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wider ${i?"text-ink/35":"text-ink/60"}`,title:t.name,children:[s+1,". ",t.name]}),e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:[m,"/",t.tasks.length]})]}),!a&&e("div",{className:"divide-y divide-ink/[0.05] p-0.5",children:t.tasks.length===0?e("div",{className:"px-2.5 py-1.5 text-[11px] text-ink/40",children:"No tasks in this phase"}):t.tasks.map((l,f)=>e(Xp,{task:l,current:r===`${s}:${f}`},`${f}-${l.content}`))})]})}function I({className:t="",active:s=!0}){let[a]=le(),r=a.get("sessionId"),[x,m]=qs("todo.collapsedPhases",{}),{data:i,isLoading:l,refreshing:f,stale:k,refresh:b}=Ce(r?qg(r):null,{enabled:s}),o=i?.snapshot??null,p=i?.progress??null,v=u(()=>{let n=BA(o?.phases??[]);return n?`${n.phase}:${n.task}`:null},[o]);if(!r)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`flex h-full w-full min-w-0 flex-col overflow-hidden bg-paper text-ink ${t}`,children:[e(ht,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold uppercase tracking-wider text-ink",children:"Todos"}),o&&e("span",{className:"truncate font-mono text-[10.5px] text-ink/50",title:Ku(p),children:Ku(p)}),i?.isMock&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",children:"Mock"})]}),right:e(ot,{label:"Refresh todos",onClick:b,busy:l||f,disabled:l})}),p&&p.total>0&&e("div",{className:"flex-shrink-0 border-b border-ink/10 px-3.5 py-2.5",children:e("div",{className:"h-1.5 overflow-hidden rounded-full bg-ink/8",children:e("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${Jp(p)}%`}})})}),e("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto scrollbar-overlay-container p-3.5",children:[k&&e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/60",children:[e(E,{size:13,className:"mt-[1px] shrink-0"}),e("span",{className:"min-w-0 break-words",children:"Reconnecting: this list may be out of date."})]}),!o?e("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-ink/40",children:[e(xr,{size:20}),e("p",{className:"max-w-[240px] text-[11.5px] leading-relaxed",children:["No todo list in this session. The agent writes one with the ",e("span",{className:"font-mono",children:"todo"})," tool when a task is worth planning."]})]}):e(d,{children:[o.phases.map((n,c)=>e(g,{phase:n,index:c,collapsed:Boolean(x[String(c)]),currentKey:v,onToggle:()=>m((h)=>({...h,[String(c)]:!h[String(c)]}))},`${c}-${n.name}`)),e("p",{className:"pt-1 text-[10.5px] leading-relaxed text-ink/35",children:["Read from this session's transcript",o.updatedAt?` · updated ${N(o.updatedAt)}`:"",o.source==="custom"?" · edited by hand":"","."]})]})]})]})}function N(t){let s=new Date(t);if(Number.isNaN(s.getTime()))return t;return s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}export{I as TodoPanel};
1
+ import{d,u,le,e,qg,Ce,E,B,se,xr,qs,ht,ot,Ku,Jp,BA,Zp,Xp}from"./index-f77c3ag0.js";function g({phase:t,index:s,collapsed:a,currentKey:r,onToggle:x}){let m=Zp(t),i=t.tasks.length>0&&m===t.tasks.length;return e("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[e("button",{type:"button",onClick:x,"aria-expanded":!a,className:"flex w-full items-center gap-1.5 border-b border-ink/8 bg-canvas/40 px-2.5 py-1.5 text-left hover:bg-ink/5",children:[a?e(se,{size:12,className:"shrink-0 text-ink/40"}):e(B,{size:12,className:"shrink-0 text-ink/40"}),e("span",{className:`min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wider ${i?"text-ink/35":"text-ink/60"}`,title:t.name,children:[s+1,". ",t.name]}),e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:[m,"/",t.tasks.length]})]}),!a&&e("div",{className:"divide-y divide-ink/[0.05] p-0.5",children:t.tasks.length===0?e("div",{className:"px-2.5 py-1.5 text-[11px] text-ink/40",children:"No tasks in this phase"}):t.tasks.map((l,f)=>e(Xp,{task:l,current:r===`${s}:${f}`},`${f}-${l.content}`))})]})}function I({className:t="",active:s=!0}){let[a]=le(),r=a.get("sessionId"),[x,m]=qs("todo.collapsedPhases",{}),{data:i,isLoading:l,refreshing:f,stale:k,refresh:b}=Ce(r?qg(r):null,{enabled:s}),o=i?.snapshot??null,p=i?.progress??null,v=u(()=>{let n=BA(o?.phases??[]);return n?`${n.phase}:${n.task}`:null},[o]);if(!r)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`flex h-full w-full min-w-0 flex-col overflow-hidden bg-paper text-ink ${t}`,children:[e(ht,{left:e(d,{children:[e("h2",{className:"text-xs font-semibold uppercase tracking-wider text-ink",children:"Todos"}),o&&e("span",{className:"truncate font-mono text-[10.5px] text-ink/50",title:Ku(p),children:Ku(p)}),i?.isMock&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",children:"Mock"})]}),right:e(ot,{label:"Refresh todos",onClick:b,busy:l||f,disabled:l})}),p&&p.total>0&&e("div",{className:"flex-shrink-0 border-b border-ink/10 px-3.5 py-2.5",children:e("div",{className:"h-1.5 overflow-hidden rounded-full bg-ink/8",children:e("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${Jp(p)}%`}})})}),e("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto scrollbar-overlay-container p-3.5",children:[k&&e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/60",children:[e(E,{size:13,className:"mt-[1px] shrink-0"}),e("span",{className:"min-w-0 break-words",children:"Reconnecting: this list may be out of date."})]}),!o?e("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-ink/40",children:[e(xr,{size:20}),e("p",{className:"max-w-[240px] text-[11.5px] leading-relaxed",children:["No todo list in this session. The agent writes one with the ",e("span",{className:"font-mono",children:"todo"})," tool when a task is worth planning."]})]}):e(d,{children:[o.phases.map((n,c)=>e(g,{phase:n,index:c,collapsed:Boolean(x[String(c)]),currentKey:v,onToggle:()=>m((h)=>({...h,[String(c)]:!h[String(c)]}))},`${c}-${n.name}`)),e("p",{className:"pt-1 text-[10.5px] leading-relaxed text-ink/35",children:["Read from this session's transcript",o.updatedAt?` · updated ${N(o.updatedAt)}`:"",o.source==="custom"?" · edited by hand":"","."]})]})]})]})}function N(t){let s=new Date(t);if(Number.isNaN(s.getTime()))return t;return s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}export{I as TodoPanel};
@@ -1 +1 @@
1
- import{d,n,o,i,u,a,br,Ue,oe,e,Kn,x,Wg,Ce,$s,S,cr,ur,s,Rn,F,nt,B,se,bo,re,Ee,qe,ni,ln,ri,Kr,D,O,b,ht,ot,me,wt,ju,st,lt,aA,oA,Yi,Ji,qu,je,Xi}from"./index-zqthmaxq.js";import{Mu,Pu,Yo,Ou,$u}from"./index-g4rsmakg.js";import{hr}from"./index-q1gwgmxt.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"]},Ve=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"}]]},Xe=s(Yt);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"}]]},Be=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 Qe({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:v,onSearchChange:h,onRefresh:y,refreshing:g}){return e("div",{className:"border-b border-ink/10",children:[e(ht,{className:"border-b-0",left:e(hr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(ot,{label:"Refresh",onClick:y,busy:g})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(O,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:v,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 Ye({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:v,folderStatus:h}){let y=f?"text-ink font-semibold":v?v.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(B,{size:12,className:"flex-shrink-0 text-ink/40"}):e(se,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(st,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${y}`,title:p?`${r} — git-ignored`:void 0,children:t}),v&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${v.colorClass}`,title:`Git: ${v.label}`,children:v.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:v,selectionCount:h,isArchive:y}=t,g=[],m=h>1,C=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${C}`,icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${C}`,icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${C} to…`,icon:e(nt,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${C}`,icon:e(F,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(ni,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(ln,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(B,{size:13,className:"text-ink/60"})});if(v)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(qe,{size:13,className:"text-ink/60"})}),y)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(ri,{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(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(nt,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(bo,{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(Ee,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Rn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ve,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(F,{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 Je({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:v,busy:h,selectionCount:y,isArchive:g,onAction:m,menuRef:C}){let w=rn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:v,selectionCount:y,isArchive:g}),E=on(w),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 oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(T)=>{T.preventDefault(),m("close")},children:e("div",{ref:C,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:M,left:N},onClick:(T)=>T.stopPropagation(),children:w.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 Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:v,onSubmit:h}){let y=r==="folder"?"Folder":"File";return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",y]}),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 ${y.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:v,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function Ze({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:v}){let h=c>1;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:v,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 et({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:v,onCancel:h,onSubmit:y}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:y,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)=>v(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 tt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Rn,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,v)=>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})]},v))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(D,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function rt({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(Ze,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(et,{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(tt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(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=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Se(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,v)=>[...p,...l.slice(0,v+1)].join("/"))}function it(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(v)=>v.flatMap((h)=>{if(h.type!=="folder")return[h];let y=Array.isArray(h.children)?p(h.children):h.children,g=y===h.children?h:{...h,children:y},m=r.has(h.path)?Me(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let C={...g,name:m[m.length-1].split("/").pop()};for(let k=m.length-1;k>0;k-=1){let w=m[k-1];C={name:w.split("/").pop(),path:w,type:"folder",ignored:g.ignored,children:[C]}}return[C]}),f=p(t);return{nodes:c?f:t,roots:l}}function at(t,r){let l=new Set,c=(v)=>{for(let h of v){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 v=0;v<p.length;v+=1){let h=p.slice(0,v+1).join("/");if(l.has(h))f.push(h)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=lt(),[v,h]=n(!1),[y,g]=n("file"),[m,C]=n(""),[k,w]=n(null),E=i(null);return o(()=>{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),C(""),w(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 w(N.error||`Could not create the ${y}`)},[f.state,f.data]),{open:v,kind:y,name:m,setName:C,error:k,busy:f.state!=="idle",openDialog:(N="file")=>{g(N),C(""),w(null),h(!0)},closeDialog:()=>h(!1),submit:(N)=>{N.preventDefault();let M=m.trim();if(!M)return;w(null);let T=new FormData;if(T.append("actionType","create"),T.append("path",t),T.append("name",M),y==="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 we(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function ct(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function dt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function pt(t,r){if(t.path===""||t.path===".")return"The workspace root cannot be moved or copied";if(t.kind==="folder"&&(r===t.path||r.startsWith(`${t.path}/`)))return"Cannot paste a folder into itself";return null}function ut(t,r){let l=pt(t,r);if(l)return l;if(r===dt(t.path))return"Already in this folder";return null}function ft(t,r,l){if(!t||t.entries.length===0)return"Nothing to paste";if(t.scope!==r)return"The clipboard holds an entry from another workspace";if(t.mode==="cut"&&t.entries.some((c)=>l===dt(c.path)))return"Already in this folder";for(let c of t.entries){let p=pt(c,l);if(p)return p}return null}function mt(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 $e=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],gt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function ze(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return ze(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function xt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function vt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function yt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function kt(t){if(t.length===0)return".";let r=t.map((c)=>vt(c).split("/").filter((p)=>p!==".")),l=r[0]??[];for(let c of r.slice(1)){let p=0;while(p<l.length&&p<c.length&&l[p]===c[p])p+=1;l=l.slice(0,p)}return l.length===0?".":l.join("/")}function De(t,r){let l=dn(r);if(t.length===1){let f=t[0],v=xt(f.name),h=v.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?v.slice(0,h):v)||"archive"}.${l}`}let c=kt(t.map((f)=>f.path)),p=yt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ct(t){return kt(t.map((r)=>r.path))}function Ft(t){let r=vt(t),l=xt(yt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function Nt(t){return t.toUpperCase()}function Dt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:v,onFold:h,clipboard:y,isFolder:g,selection:m,selected:C,archive:k}){let w=lt(),[E,N]=n(null),M=i(null),[T,R]=n(!1),[A,H]=n(!1),[W,ee]=n(!1),[te,ae]=n(t.path),[G,I]=n(null),{repo:z,rootPath:K}=t,j=Ne({folderPath:t.path,rootPath:K,repo:z,onCreated:(L)=>p?p(L):c(),onOpenCreated:(L)=>l?.({...L,root:K,repo:z||"."})}),ne=i(null);o(()=>{if(w.state!=="idle"||!w.data)return;let L=w.data;if(ne.current===L)return;if(ne.current=L,L.success&&!L.type)if(R(!1),H(!1),I(null),L.previousPath&&L.path&&f)f(L.previousPath,L.path);else c();else if(!L.success&&L.error&&T)I(L.error)},[w.state,w.data]);let q=(L)=>{if(z&&z!==".")L.append("repo",z);if(K)L.append("root",K);w.submit(L,{method:"post",action:"/api/fs/action"})},X=()=>{l?.({path:t.path,name:t.name,root:K,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},ie=C&&m.length>1?m:[J],he=bt(t.name),Q=y.clip&&!y.refusalFor(J)?`Paste ${we(y.clip)??"item"}`:null,ue=(L)=>{if(N(null),I(null),L==="view")X();else if(L==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:K}}));else if(L==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),q(_)}else if(L==="copy_path")wt(ju(t.basePath,t.path));else if(L==="copy_relative")wt(t.path);else if(L==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),q(_)}else if(L==="rename")ae(t.path),R(!0);else if(L==="unfold")v?.();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")y.cut(ie);else if(L==="copy")y.copy(ie);else if(L==="compress")k.openCompress(ie);else if(L==="extract")k.openExtract(J);else if(L==="duplicate")y.duplicate(J);else if(L==="paste")y.paste(J)},le=(L)=>{L.preventDefault(),I(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"),ie.length>1)L.append("paths",JSON.stringify(ie.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:ae,renameError:G,busy:w.state!=="idle"||j.busy||y.busy||k.busy,pasteLabel:Q,selectionCount:ie.length,isArchive:he,chainLabel:v!==void 0,foldable:h!==void 0,fetcherState:w.state,fetcherData:w.data,handleAction:ue,submitCreate:j.submit,submitRename:le,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>R(!1),closeHistory:()=>ee(!1)}}function Rt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:v}){let h=r?.path===t.path,y=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:y,isDropHovered:g&&y,onDragStart:(k)=>{if(k.dataTransfer?.setData("text/plain",t.path),k.dataTransfer)k.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(k)=>{if(!r)return;if(k.stopPropagation(),m(y),!y)return;if(k.preventDefault(),k.dataTransfer)k.dataTransfer.dropEffect="move";v?.(t)},onDragLeave:()=>m(!1),onDrop:(k)=>{if(!r)return;if(k.stopPropagation(),!y)return;k.preventDefault(),f(t)}}}function pn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Oe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:v,onCreated:h,onRenamed:y,expandedPaths:g,onToggleFolder:m,gitFileMap:C,gitFolderMap:k,clipboard:w,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae=!1}){let G=t.type==="folder",[I,z]=n(!1),[K,j]=n(!1),[ne,q]=n(!1),[X,J]=n(!1),ie=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!G?C?.get(he)||C?.get(t.path):void 0,ue=Q?Kn(Q.status,Q.staged):null,le=G?k?.get(he)||k?.get(t.path):null,xe=Boolean(ue),L=t.ignored===!0,_=g?g.has(t.path):I,ce=t.forceExpanded!==void 0?t.forceExpanded:_;o(()=>{J(!0)},[]),o(()=>{if(G&&g)z(g.has(t.path))},[g,t.path,G]),o(()=>{if(G&&ce&&pn(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),U=Dt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:M,selected:be,archive:E,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:ue?.charStatus},onOpenFile:f,onActionComplete:v,onCreated:h,onRenamed:y,onUnfold:W&&Se({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:w,isFolder:G});me(U.contextMenuRef,U.closeContextMenu);let Y=Mu({enabled:ae,onLongPress:(V,ge)=>U.openContextMenu(V,ge)}),ke=(V)=>{if(V.stopPropagation(),Y.consume())return;let ge=N.gestureOf(V);if(ge!=="plain"){N.applyGesture(ge,t.path);return}if(N.applyGesture("plain",t.path),G){let pe=!ce;if(z(pe),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,pe),!pe)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(V)=>{V.preventDefault(),V.stopPropagation(),N.ensureForContext(t.path),U.openContextMenu(V.clientX,V.clientY)},de=Rt({target:ye,dragging:T,clipboard:w,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 ${de.isDragging?"opacity-40":""} ${de.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":be?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!ae,onClick:ke,onContextMenu:ve,onDragStart:de.onDragStart,onDragEnd:de.onDragEnd,onDragOver:de.onDragOver,onDragLeave:de.onDragLeave,onDrop:de.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Ye,{name:t.name,path:t.path,isFolder:G,isOpen:ce,ignored:L,selected:be,gitStatus:ue,folderStatus:le})}),ce&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!K&&ie.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:ie.map((V)=>e(Oe,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:v,onCreated:h,onRenamed:y,expandedPaths:g,onToggleFolder:m,gitFileMap:C,gitFolderMap:k,clipboard:w,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae},V.path))}),X&&U.contextMenu&&e(Je,{x:U.contextMenu.x,y:U.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:U.pasteLabel,chainLabel:U.chainLabel,foldable:U.foldable,busy:U.busy,selectionCount:U.selectionCount,isArchive:U.isArchive,onAction:U.handleAction}),X&&e(rt,{actions:U,file:t,isFolder:G,chainLabel:Se({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function Tt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,y=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:y},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(ni,{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(ln,{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(bo,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function At({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(Tt,{x:t.x,y:t.y,menuRef:r,pasteLabel:l,busy:c,onAction:p}),f.open&&e(Fe,{folderPath:".",kind:f.kind,value:f.name,error:f.error,isLoading:f.busy,onChange:f.setName,onCancel:f.closeDialog,onSubmit:f.submit})]})}function St({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:v,onCancel:h,children:y}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),y,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 un({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:v,onFormatChange:h,onNameChange:y,onDestinationChange:g,onCancel:m,onSubmit:C}){let k=t.slice(0,4).map((E)=>E.name).join(", "),w=t.length>4?` +${t.length-4} more`:"";return e(St,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${k}${w}`,error:f,busy:v,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(E)=>{E.preventDefault(),C()},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)=>y(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 fn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:v,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:v,onSubmit:(y)=>{y.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:(y)=>f(y.currentTarget.value),"aria-label":"Extract destination",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none ${c?"border-error":"border-ink/20 focus:border-ink"}`})]})}function Et({archive:t}){if(t.compress)return e(un,{entries:t.compress.entries,format:t.compress.format,name:t.compress.name,destination:t.compress.destination,formats:t.formats,error:t.error,busy:t.busy,onFormatChange:t.setFormat,onNameChange:t.setName,onDestinationChange:t.setCompressDestination,onCancel:t.cancel,onSubmit:t.submitCompress});if(t.extract)return e(fn,{archive:t.extract.archive,kindLabel:Nt(ze(t.extract.archive.name)??"zip"),destination:t.extract.destination,error:t.error,busy:t.busy,onDestinationChange:t.setExtractDestination,onCancel:t.cancel,onSubmit:t.submitExtract});return null}function Mt(){let[t,r]=S("files.outlineExpanded",!1),l=br(),c=Ue(oA,aA),{symbols:p,total:f,truncated:v,notice:h}=$u({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let y=c.preview,g=(m,C)=>{if(!c.path)return;if(y){let k=qu(p,C);if(k)Ji({path:c.path,...k});return}Yi({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(Kr,{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:v?`${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,C)=>e("button",{type:"button",onClick:()=>g(m,C),"aria-label":y?`${Yo(m.kind)} ${m.name}`:`${Yo(m.kind)} ${m.name}, line ${m.line}`,title:y?`Jump to ${Yo(m.kind).toLowerCase()}`:`${Yo(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(Pu,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!y&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),v&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Ou(f)})]})})})})]})}function Pe(t,r){return Ae(t.map((l)=>mn(l,r)))}function mn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Pe(l,r)}}function hn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function $t(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Lt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ie(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],v={...r},h=f,y=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),C=h.find((M)=>M.type==="folder"&&M.path===m),k=C?null:h.find((M)=>M.type==="folder"&&M.path.startsWith(`${m}/`)&&(p===M.path||p.startsWith(`${M.path}/`))),w=C??k,E=w?v[w.path]??w.children:null;if(w&&!Array.isArray(E))return{nodes:t,cache:r};if(!w){let M=gn(h,v,m);if(M){h=M;let T=h.find((A)=>A.path===m),R=Array.isArray(T?.children)?[...T.children]:[];v[m]=R,h=R,y=m,g+=1;continue}}let N=Array.isArray(E)?[...E]:[];if(w){v[w.path]=N,h=N,y=w.path,g=w.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),v[m]=N,h=N,y=m,g+=1}if(h.push(l),y!==null)v[y]=Lt(h);return f=Lt(f),{nodes:f,cache:v}}function gn(t,r,l){let c=t.findIndex((y)=>y.type==="folder"&&y.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),v=r[p.path]??p.children;if(Array.isArray(v))r[p.path]=v;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(v)?{children:v}:{}};for(let y=f.length-2;y>=0;y-=1)h={name:f[y],path:`${l}/${f.slice(0,y+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:$t(l),path:l,type:"folder",ignored:!1,children:[h]},t}function zt(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=hn(l),f=r[p],v=f?.find((m)=>m.path===l);if(f&&v)return{entry:v,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let y=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((C)=>C.path===l)).sort((m,C)=>C.length-m.length)[0];if(!y)return{entry:null,nodes:t,cache:r};let g=r[y];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[y]:g.filter((m)=>m.path!==l)}}}function Ot(t,r,l){let c=!1,p=t.map((f)=>{let v=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?Ot(f.children,r,l):void 0;if(!v&&h===f.children)return f;c=!0;let y=v?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=v?{...f,path:y,name:$t(y)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function Pt(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let v=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[v]=v===p?f:Ot(f,r,l)}return c}function It(t,r,l){let c=new Set;for(let p of t)if(p===r)c.add(l);else if(p.startsWith(`${r}/`))c.add(`${l}${p.slice(r.length)}`);else c.add(p);return c}function Ht(t){if(!x(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)=>x(r)):[],root:t.root}}async function He(t){try{return Ht(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Gt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[v,h]=n({scope:"",files:[],root:""}),[y,g]=n(!1),m=i({}),C=i([]),k=i(f);k.current=f;let w=i(""),E=i(""),N=i(c);N.current=c;let M=(I)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(I)z.set("path",I);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},T=(I,z)=>{w.current=I,E.current=z;let K=Pe(C.current,m.current);return h({scope:I,files:K,root:z}),K},R=async(I)=>{let z=[...N.current];if(z.length===0)return;let K=await Promise.all(z.map(async(X)=>({path:X,read:await He(M(X))})));if(k.current!==I)return;let j=[];for(let{path:X,read:J}of K)if(J.status==="ok")m.current[X]=J.files;else if(J.status==="missing")j.push(X);if(j.length===0)return;let ne=new Set(j);for(let X of j)delete m.current[X];let q=new Set([...N.current].filter((X)=>!ne.has(X)));N.current=q,p(q)},A=async()=>{if(!t)return;let I=k.current;g(!0);try{let z=await He(M());if(k.current!==I)return;if(z.status!=="ok")return;if(w.current!==I)m.current={};if(C.current=z.files,T(I,z.root),await R(I),k.current!==I)return;T(I,z.root)}finally{if(k.current===I)g(!1)}},H=async(I)=>{let z=k.current,K=await He(M(I));if(k.current!==z||K.status!=="ok")return;if(m.current[I]=K.files,w.current===z)T(z,E.current)},W=(I)=>{let z=Ht(I);if(z.status!=="ok")return;let K=k.current;if(w.current!==K)m.current={};C.current=z.files,T(K,z.root),R(K).then(()=>{if(k.current===K)T(K,z.root)})},ee=()=>{m.current={},C.current=[],w.current="",E.current="",h({scope:"",files:[],root:""})},te=(I)=>{let z=k.current;if(w.current!==z)return null;let K={name:I.path.slice(I.path.lastIndexOf("/")+1),path:I.path,type:I.kind,ignored:!1},j=Ie(C.current,m.current,K);if(j.nodes===C.current)return null;return C.current=j.nodes,m.current=j.cache,T(z,E.current)},ae=(I,z)=>{let K=k.current;if(w.current!==K)return null;let j=zt(C.current,m.current,I);if(!j.entry)return null;m.current=Pt(j.cache,I,z);let ne={...j.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Ie(j.nodes,m.current,ne);return C.current=q.nodes,m.current=q.cache,T(K,E.current)},G=v.scope===f;return{scope:f,files:G?v.files:[],root:G?v.root:"",isLoading:y,reload:A,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:ae,reset:ee}}function Kt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=lt(),[f,v]=S("files.clipboard",null),h=mt(f),y=ct(t,r),g=i(!1),m=i(null);o(()=>{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)v(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 C=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]),k=a((N)=>ft(h,y,Le(N.path,N.kind)),[h,y]),w=a((N,M)=>ut(N,Le(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:k,moveRefusalFor:w,copy:(N)=>{if(N.length===0)return;v({scope:y,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"copy"})},cut:(N)=>{if(N.length===0)return;v({scope:y,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"cut"})},duplicate:(N)=>{C({actionType:"duplicate",path:N.path},!1)},move:(N,M)=>{let T=w(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=k(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 bn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=lt(),[p,f]=n(bn),[v,h]=n(null),[y,g]=n(null),[m,C]=n(null),k=i(null),w=i(null);o(()=>{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}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let R=c.data;if(w.current===R)return;w.current=R;let A=k.current;if(k.current=null,R.success){if(C(null),A==="compress")h(null);if(A==="extract")g(null);l()}else if(A)C(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";C(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:Ct(R)})},[p]),M=a((R)=>{C(null),h(null),g({archive:R,destination:Ft(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:v,extract:y,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),C(null)},submitCompress:()=>{let R=v;if(!R)return;k.current="compress",C(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=y;if(!R)return;k.current="extract",C(null),E({actionType:"extract",path:R.archive.path,destination:R.destination.trim()||"."})}}}function xn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function vn(t,r,l){if(!r)return[l];let c=t.indexOf(r),p=t.indexOf(l);if(c===-1||p===-1)return[l];let f=Math.min(c,p),v=Math.max(c,p);return t.slice(f,v+1)}function _t(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(vn(t,c,m)));return}if(p(m),g==="toggle"){l((C)=>{let k=new Set(C);if(k.has(m))k.delete(m);else k.add(m);return k});return}l(new Set([m]))},[c,t]),v=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),y=a(xn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:y,applyGesture:f,ensureForContext:v,clear:h}),[r,c,y,f,v,h])}function Ge(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))Ge(p.children,r,l+1,c);return c}function Wt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((y,g)=>{let m=at(g,y);if(m.length===0)return;r((C)=>{if(m.every((w)=>C.has(w)))return C;let k=new Set(C);for(let w of m)k.add(w);return l(Array.from(k)),k})},[r,l]),v=a((y)=>{let g=t.insertEntry(y);if(!g){c();return}f(y.path,g)},[t,c,f]),h=a((y,g)=>{p?.(y,g),r((C)=>{let k=It(C,y,g);return l(Array.from(k)),k});let m=t.moveEntry(y,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:v,moveRenamed:h}}var yn=new Set;function Ut({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((y)=>{let g=Me(y.path,y.name);if(!g)return;p((C)=>{let k=C.scope===t?C.chains:new Map;if(k.get(y.path)?.length===g.length)return C;let E=new Map(k);return E.set(y.path,g),{scope:t,chains:E}});let m=g.slice(0,-1);r((C)=>{if(m.every((w)=>C.has(w)))return C;let k=new Set(C);for(let w of m)k.add(w);return l(Array.from(k)),k})},[t,r,l]),v=a((y)=>{let g=c.scope===t?c.chains.get(y):void 0;if(!g)return;let m=g.slice(0,-1);p((C)=>{if(C.scope!==t)return C;let k=new Map(C.chains);return k.delete(y),{scope:t,chains:k}}),r((C)=>{if(!m.some((w)=>C.has(w)))return C;let k=new Set(C);for(let w of m)k.delete(w);return l(Array.from(k)),k})},[t,c,r,l]),h=a((y,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let C=new Map,k=[],w=!1;for(let[E,N]of m){if(N.findIndex((A,H)=>A===y&&H>0&&H<N.length-1)!==-1){w=!0;continue}let T=N.map((A)=>A===y?g:A.startsWith(`${y}/`)?`${g}${A.slice(y.length)}`:A),R=T[T.length-1];if(R!==E||T.some((A,H)=>A!==N[H]))w=!0;C.set(R,T),k.push(...T.slice(0,-1))}if(!w)return;p({scope:t,chains:C}),r((E)=>{if(k.every((M)=>E.has(M)))return E;let N=new Set(E);for(let M of k)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()):yn,unfold:f,fold:v,rekey:h}}function Vt(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let v=(p.children||[]).map(c).filter((h)=>h!==null);if(f||v.length>0)return{...p,children:f&&v.length===0?p.children:v,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Xt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return o(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(v)=>{if(!v.currentTarget.contains(v.relatedTarget))f(!1)},onDragOver:(v)=>{if(!c)return;if(v.preventDefault(),v.dataTransfer)v.dataTransfer.dropEffect="move"},onDrop:(v)=>{if(!c)return;v.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:v}){let[h,y]=S("files.searchQuery",""),[g,m,C]=S("files.expandedPaths",[]),[k,w]=n(()=>new Set(g)),{activeRepo:E,setActiveRepo:N}=cr(c),{repos:M,scanning:T,rescan:R}=ur(c,r),{fileMap:A,folderMap:H,refreshGitStatus:W}=$s(c,E,r),[ee,te]=n(null),ae=i(null);o(()=>{if(!C)return;w((P)=>{let Z=new Set(g);if(P.size===Z.size&&Array.from(Z).every((fe)=>P.has(fe)))return P;return Z})},[C,g]);let G=Gt({enabled:r,rootPath:c,activeRepo:E,expandedPaths:k,onExpansionPruned:(P)=>{w(P),m(Array.from(P))}});o(()=>{if(!C||!l)return;G.reload()},[f,c,r,E,C,l]);let I=r&&C?Wg(G.scope):null,z=Ce(I);o(()=>{if(z.data)G.adoptRoot(z.data)},[z.data]);let K=(P)=>(W(),G.loadChildren(P)),j=(P,Z)=>{let fe=new Set(k);if(Z)fe.add(P);else fe.delete(P);w(fe),m(Array.from(fe))},{unfolded:ne,unfold:q,fold:X,rekey:J}=Ut({scope:G.scope,setExpandedPaths:w,setStoredExpandedPaths:m}),ie=G.files,he=it(ie,ne),Q=Vt(he.nodes,h),ue=Ge(Q,(P)=>P.forceExpanded!==void 0?P.forceExpanded:k.has(P.path)),le=_t(ue.map((P)=>P.path)),xe=ue.filter((P)=>le.selected.has(P.path)).map(({path:P,name:Z,kind:fe})=>({path:P,name:Z,kind:fe})),L=(P)=>{if(P===E)return;G.reset(),w(new Set),m([]),le.clear(),N(P)},_=()=>{if(W(),v)v();else G.reload()},{insertCreated:ce,moveRenamed:ye}=Wt({listing:G,setExpandedPaths:w,setStoredExpandedPaths:m,reload:_,onMoved:(P,Z)=>J(P,Z)}),be=Xi(),{pushToast:U}=je(),Y=Kt({rootPath:c,repo:E,onComplete:_,onError:(P)=>U(P,"error")}),ke=jt({rootPath:c,repo:E,onComplete:_}),ve={path:".",name:".",kind:"folder"},de=Y.clip&&!Y.refusalFor(ve)?`Paste ${we(Y.clip)??"item"}`:null,[V,ge]=n(null),pe=Xt({dragging:V,clipboard:Y,target:ve}),Re=Ne({folderPath:".",rootPath:c,repo:E,onCreated:ce,onOpenCreated:(P)=>p?.({...P,root:c,repo:E})}),[Ke,qt]=n(!1);o(()=>qt(!0),[]);let{count:_e,clear:We}=le;if(o(()=>{if(!l)return;let P=(Z)=>{if(Z.key==="Escape"&&_e>0)We()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[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 Bt=G.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Qe,{rootPath:c,activeRepo:E,repos:M,reposScanning:T,onRefreshRepos:R,onSelectRepo:L,searchQuery:h,onSearchChange:y,onRefresh:_,refreshing:Bt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${pe.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(P)=>{P.preventDefault(),te({x:P.clientX,y:P.clientY})},onDragEnter:pe.onDragEnter,onDragLeave:pe.onDragLeave,onDragOver:pe.onDragOver,onDrop:pe.onDrop,children:G.isLoading&&Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Q.map((P)=>e(Oe,{file:P,rootPath:c,basePath:G.root,repo:E,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:ce,onRenamed:ye,expandedPaths:k,onToggleFolder:j,gitFileMap:A,gitFolderMap:H,clipboard:Y,archive:ke,selection:le,selectionTargets:xe,dragging:V,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!V)return;Y.move(V,Z)},onUnfold:q,onFold:X,foldRoots:he.roots,touch:be},P.path))}),e(Mt,{}),Ke&&e(At,{menu:ee,menuRef:ae,pasteLabel:de,busy:Y.busy,create:Re,onAction:(P)=>{if(te(null),P==="new_file")Re.openDialog("file");if(P==="new_folder")Re.openDialog("folder");if(P==="paste")Y.paste(ve)}}),Ke&&e(Et,{archive:ke})]})}export{oi as FileExplorer};
1
+ import{d,n,o,i,u,a,br,Ue,oe,e,Kn,x,Wg,Ce,$s,S,cr,ur,s,Rn,F,nt,B,se,bo,re,Ee,qe,ni,ln,ri,Kr,D,O,b,ht,ot,me,wt,ju,st,lt,aA,oA,Yi,Ji,qu,je,Xi}from"./index-f77c3ag0.js";import{Mu,Pu,Yo,Ou,$u}from"./index-m94f4ngb.js";import{hr}from"./index-3588r3wg.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"]},Ve=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"}]]},Xe=s(Yt);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"}]]},Be=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 Qe({rootPath:t,activeRepo:r,repos:l,reposScanning:c,onRefreshRepos:p,onSelectRepo:f,searchQuery:v,onSearchChange:h,onRefresh:y,refreshing:g}){return e("div",{className:"border-b border-ink/10",children:[e(ht,{className:"border-b-0",left:e(hr,{rootPath:t,activeRepo:r,onSelectRepo:f,repos:l,scanning:c,onRefreshRepos:p}),right:e(ot,{label:"Refresh",onClick:y,busy:g})}),e("div",{className:"px-3 pb-3",children:e("div",{className:"relative",children:[e(O,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",placeholder:"Search files...",value:v,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 Ye({name:t,path:r,isFolder:l,isOpen:c,ignored:p,selected:f,gitStatus:v,folderStatus:h}){let y=f?"text-ink font-semibold":v?v.colorClass:h?h.colorClass:p?"text-ink/40":"";return e(d,{children:[l?c?e(B,{size:12,className:"flex-shrink-0 text-ink/40"}):e(se,{size:12,className:"flex-shrink-0 text-ink/40"}):e("span",{className:"w-3 flex-shrink-0"}),e(st,{name:t,isFolder:l,isOpen:c,size:12,className:`flex-shrink-0${p?" opacity-40":""}`}),e("span",{className:`truncate min-w-0 flex-1 ${y}`,title:p?`${r} — git-ignored`:void 0,children:t}),v&&e("span",{className:`font-mono text-[10px] font-bold px-1 rounded flex-shrink-0 ${v.colorClass}`,title:`Git: ${v.label}`,children:v.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:v,selectionCount:h,isArchive:y}=t,g=[],m=h>1,C=h===1?"":` ${h} items`;if(m)return g.push({kind:"item",id:"cut",label:`Cut${C}`,icon:e(Te,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"copy",label:`Copy${C}`,icon:e(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"compress",label:`Compress${C} to…`,icon:e(nt,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"separator"}),g.push({kind:"item",id:"delete",label:`Delete${C}`,icon:e(F,{size:13,className:"text-error"}),tone:"text-error"}),g;if(r){if(g.push({kind:"item",id:"new_file",label:"New File",icon:e(ni,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"new_folder",label:"New Folder",icon:e(ln,{size:13,className:"text-ink/60"})}),f)g.push({kind:"item",id:"unfold",label:"Unfold Folders",icon:e(B,{size:13,className:"text-ink/60"})});if(v)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(qe,{size:13,className:"text-ink/60"})}),y)g.push({kind:"item",id:"extract",label:"Extract…",icon:e(Be,{size:13,className:"text-ink/60"}),disabled:p});if(l)g.push({kind:"item",id:"diff",label:"Open in Diff Panel",icon:e(ri,{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(re,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"compress",label:"Compress to…",icon:e(nt,{size:13,className:"text-ink/60"}),disabled:p}),g.push({kind:"item",id:"duplicate",label:"Duplicate",icon:e(Xe,{size:13,className:"text-ink/60"}),disabled:p}),c)g.push({kind:"item",id:"paste",label:c,icon:e(bo,{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(Ee,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_path",label:"Copy Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"copy_relative",label:"Copy Relative Path",icon:e(re,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"history",label:"Show Git History",icon:e(Rn,{size:13,className:"text-ink/60"})}),g.push({kind:"separator"}),g.push({kind:"item",id:"rename",label:"Rename",icon:e(Ve,{size:13,className:"text-ink/60"})}),g.push({kind:"item",id:"delete",label:"Delete",icon:e(F,{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 Je({x:t,y:r,isFolder:l,hasGitStatus:c,pasteLabel:p,chainLabel:f,foldable:v,busy:h,selectionCount:y,isArchive:g,onAction:m,menuRef:C}){let w=rn({isFolder:l,hasGitStatus:c,pasteLabel:p,busy:h,chainLabel:f,foldable:v,selectionCount:y,isArchive:g}),E=on(w),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 oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>m("close"),onContextMenu:(T)=>{T.preventDefault(),m("close")},children:e("div",{ref:C,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:M,left:N},onClick:(T)=>T.stopPropagation(),children:w.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 Fe({folderPath:t,kind:r,value:l,error:c,isLoading:p,onChange:f,onCancel:v,onSubmit:h}){let y=r==="folder"?"Folder":"File";return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:h,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-3 text-sm",children:["New ",y]}),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 ${y.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:v,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{type:"submit",className:"px-3 py-1.5 text-xs bg-ink text-canvas rounded hover:bg-ink/90 transition-colors flex items-center",disabled:p||!l.trim(),children:p?"Creating...":"Create"})]})]})}),document.body)}function Ze({fileName:t,displayName:r,isFolder:l,count:c=1,isLoading:p,onCancel:f,onConfirm:v}){let h=c>1;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-2 text-sm",children:["Delete ",h?`${c} Items`:l?"Folder":"File"]}),e("p",{className:"text-xs text-ink/70 mb-4",children:["Are you sure you want to delete ",h?e(d,{children:["the ",c," selected entries"]}):e("span",{className:"font-mono bg-canvas px-1 rounded",children:t}),"? This action cannot be undone."]}),r&&r!==t&&e("p",{className:"text-[11px] text-ink/50 mb-4",children:["The row is ",e("span",{className:"font-mono",children:r}),"; this deletes"," ",e("span",{className:"font-mono",children:t})," only."]}),e("div",{className:"flex justify-end space-x-2",children:[e("button",{onClick:f,className:"px-3 py-1.5 text-xs text-ink hover:bg-ink/5 rounded transition-colors",disabled:p,children:"Cancel"}),e("button",{onClick:v,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 et({isFolder:t,renameValue:r,originalPath:l,displayName:c,error:p,isLoading:f,onChange:v,onCancel:h,onSubmit:y}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:y,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)=>v(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 tt({filePath:t,fetcherState:r,fetcherData:l,onClose:c}){let p=l?.type==="history"?l.data:void 0;return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("div",{className:"glass-overlay bg-paper rounded-lg shadow-xl w-full max-w-4xl border border-ink/10 flex flex-col max-h-[85vh]",children:[e("div",{className:"flex items-center justify-between p-4 border-b border-ink/10",children:[e("h3",{className:"text-sm font-semibold text-ink flex items-center space-x-2",children:[e(Rn,{size:16,className:"text-ink/60"}),e("span",{children:["Git History: ",e("span",{className:"font-mono font-normal opacity-80",children:t})]})]}),e("button",{onClick:c,className:"p-1 hover:bg-ink/5 rounded text-ink/60 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-2",children:r==="idle"?p?p.length>0?e("table",{className:"w-full text-left border-collapse text-[11px]",children:[e("thead",{className:"bg-canvas sticky top-0 z-10 border-b border-ink/10",children:e("tr",{children:[e("th",{className:"px-3 py-2 font-semibold text-ink/70 rounded-tl",children:"Description"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Date"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-32",children:"Author"}),e("th",{className:"px-3 py-2 font-semibold text-ink/70 w-24 text-right rounded-tr",children:"Commit"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:p.map((f,v)=>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})]},v))})]}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"No commit history found for this file."}):l?.error?e("div",{className:"p-8 text-center text-error font-mono text-xs",children:l.error}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs",children:"Loading history..."}):e("div",{className:"p-8 text-center text-ink/40 font-mono text-xs flex items-center justify-center space-x-2",children:[e(D,{size:14,className:"animate-spin"}),e("span",{children:"Loading history..."})]})})]})}),document.body)}function rt({actions:t,file:r,isFolder:l,chainLabel:c}){let p=t.selectionCount;return e(d,{children:[t.showCreateModal&&e(Fe,{folderPath:r.path,kind:t.createKind,value:t.createName,error:t.createError,isLoading:t.busy,onChange:t.setCreateName,onCancel:t.closeCreate,onSubmit:t.submitCreate}),t.showDeleteModal&&e(Ze,{fileName:r.path,displayName:p>1?void 0:c,isFolder:l,count:p,isLoading:t.busy,onCancel:t.closeDelete,onConfirm:t.submitDelete}),t.showRenameModal&&e(et,{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(tt,{filePath:r.path,fetcherState:t.fetcherState,fetcherData:t.fetcherData,onClose:t.closeHistory})]})}function Ae(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=Ae(t.children),l=r===t.children?t:{...t,children:r};while(Array.isArray(l.children)&&l.children.length===1){let c=l.children[0];if(c.type!=="folder")break;l={...l,name:`${l.name}/${c.name}`,path:c.path,children:c.children,ignored:c.ignored??l.ignored}}return l}function Se(t){return t.type==="folder"&&t.name.includes("/")}function Me(t,r){let l=r.split("/"),c=t.split("/");if(l.length<2||l.length>c.length||l.some((f)=>!f))return null;let p=c.slice(0,c.length-l.length);return l.map((f,v)=>[...p,...l.slice(0,v+1)].join("/"))}function it(t,r){let l=new Map;if(r.size===0)return{nodes:t,roots:l};let c=!1,p=(v)=>v.flatMap((h)=>{if(h.type!=="folder")return[h];let y=Array.isArray(h.children)?p(h.children):h.children,g=y===h.children?h:{...h,children:y},m=r.has(h.path)?Me(h.path,h.name):null;if(!m)return[g];c=!0,l.set(m[0],h.path);let C={...g,name:m[m.length-1].split("/").pop()};for(let k=m.length-1;k>0;k-=1){let w=m[k-1];C={name:w.split("/").pop(),path:w,type:"folder",ignored:g.ignored,children:[C]}}return[C]}),f=p(t);return{nodes:c?f:t,roots:l}}function at(t,r){let l=new Set,c=(v)=>{for(let h of v){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 v=0;v<p.length;v+=1){let h=p.slice(0,v+1).join("/");if(l.has(h))f.push(h)}return f}function Ne({folderPath:t,rootPath:r,repo:l,onCreated:c,onOpenCreated:p}){let f=lt(),[v,h]=n(!1),[y,g]=n("file"),[m,C]=n(""),[k,w]=n(null),E=i(null);return o(()=>{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),C(""),w(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 w(N.error||`Could not create the ${y}`)},[f.state,f.data]),{open:v,kind:y,name:m,setName:C,error:k,busy:f.state!=="idle",openDialog:(N="file")=>{g(N),C(""),w(null),h(!0)},closeDialog:()=>h(!1),submit:(N)=>{N.preventDefault();let M=m.trim();if(!M)return;w(null);let T=new FormData;if(T.append("actionType","create"),T.append("path",t),T.append("name",M),y==="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 we(t){if(!t)return null;if(t.entries.length===1)return t.entries[0].name;return`${t.entries.length} items`}function ct(t,r){return`${t??""}\x00${r}`}function Le(t,r){if(r==="folder")return t;let l=t.lastIndexOf("/");return l===-1?".":t.slice(0,l)}function dt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function pt(t,r){if(t.path===""||t.path===".")return"The workspace root cannot be moved or copied";if(t.kind==="folder"&&(r===t.path||r.startsWith(`${t.path}/`)))return"Cannot paste a folder into itself";return null}function ut(t,r){let l=pt(t,r);if(l)return l;if(r===dt(t.path))return"Already in this folder";return null}function ft(t,r,l){if(!t||t.entries.length===0)return"Nothing to paste";if(t.scope!==r)return"The clipboard holds an entry from another workspace";if(t.mode==="cut"&&t.entries.some((c)=>l===dt(c.path)))return"Already in this folder";for(let c of t.entries){let p=pt(c,l);if(p)return p}return null}function mt(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 $e=[{id:"zip",label:"ZIP",extension:"zip"},{id:"7z",label:"7Z",extension:"7z"},{id:"rar",label:"RAR",extension:"rar"},{id:"tar",label:"TAR",extension:"tar"},{id:"tar.gz",label:"TAR.GZ",extension:"tar.gz"}],gt=[[".tar.gz","tar.gz"],[".tar.bz2","tar.bz2"],[".tar.xz","tar.xz"],[".tgz","tar.gz"],[".tbz2","tar.bz2"],[".txz","tar.xz"],[".tar","tar"],[".zip","zip"],[".7z","7z"],[".rar","rar"],[".gz","gz"],[".bz2","bz2"],[".xz","xz"]];function ze(t){let r=t.toLowerCase();for(let[l,c]of gt)if(r.endsWith(l))return c;return null}function bt(t){return ze(t)!==null}function cn(t){return $e.find((r)=>r.id===t)}function dn(t){return cn(t)?.extension??"zip"}function xt(t){let r=t.toLowerCase();for(let[l]of gt)if(r.endsWith(l))return t.slice(0,-l.length);return t}function vt(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)||"."}function yt(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function kt(t){if(t.length===0)return".";let r=t.map((c)=>vt(c).split("/").filter((p)=>p!==".")),l=r[0]??[];for(let c of r.slice(1)){let p=0;while(p<l.length&&p<c.length&&l[p]===c[p])p+=1;l=l.slice(0,p)}return l.length===0?".":l.join("/")}function De(t,r){let l=dn(r);if(t.length===1){let f=t[0],v=xt(f.name),h=v.lastIndexOf(".");return`${(f.kind==="folder"?f.name:h>0?v.slice(0,h):v)||"archive"}.${l}`}let c=kt(t.map((f)=>f.path)),p=yt(c);return`${p==="."||p===""?"archive":p}.${l}`}function Ct(t){return kt(t.map((r)=>r.path))}function Ft(t){let r=vt(t),l=xt(yt(t));if(!l)return r;return r==="."?l:`${r}/${l}`}function Nt(t){return t.toUpperCase()}function Dt({file:t,diff:r,onOpenFile:l,onActionComplete:c,onCreated:p,onRenamed:f,onUnfold:v,onFold:h,clipboard:y,isFolder:g,selection:m,selected:C,archive:k}){let w=lt(),[E,N]=n(null),M=i(null),[T,R]=n(!1),[A,H]=n(!1),[W,ee]=n(!1),[te,ae]=n(t.path),[G,I]=n(null),{repo:z,rootPath:K}=t,j=Ne({folderPath:t.path,rootPath:K,repo:z,onCreated:(L)=>p?p(L):c(),onOpenCreated:(L)=>l?.({...L,root:K,repo:z||"."})}),ne=i(null);o(()=>{if(w.state!=="idle"||!w.data)return;let L=w.data;if(ne.current===L)return;if(ne.current=L,L.success&&!L.type)if(R(!1),H(!1),I(null),L.previousPath&&L.path&&f)f(L.previousPath,L.path);else c();else if(!L.success&&L.error&&T)I(L.error)},[w.state,w.data]);let q=(L)=>{if(z&&z!==".")L.append("repo",z);if(K)L.append("root",K);w.submit(L,{method:"post",action:"/api/fs/action"})},X=()=>{l?.({path:t.path,name:t.name,root:K,repo:z||"."})},J={path:t.path,name:t.name,kind:g?"folder":"file"},ie=C&&m.length>1?m:[J],he=bt(t.name),Q=y.clip&&!y.refusalFor(J)?`Paste ${we(y.clip)??"item"}`:null,ue=(L)=>{if(N(null),I(null),L==="view")X();else if(L==="diff")window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.path,staged:r?.staged,status:r?.status||"M",repo:z||".",root:K}}));else if(L==="explorer"){let _=new FormData;_.append("actionType","open_explorer"),_.append("path",t.path),q(_)}else if(L==="copy_path")wt(ju(t.basePath,t.path));else if(L==="copy_relative")wt(t.path);else if(L==="history"){ee(!0);let _=new FormData;_.append("actionType","git_history"),_.append("path",t.path),q(_)}else if(L==="rename")ae(t.path),R(!0);else if(L==="unfold")v?.();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")y.cut(ie);else if(L==="copy")y.copy(ie);else if(L==="compress")k.openCompress(ie);else if(L==="extract")k.openExtract(J);else if(L==="duplicate")y.duplicate(J);else if(L==="paste")y.paste(J)},le=(L)=>{L.preventDefault(),I(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"),ie.length>1)L.append("paths",JSON.stringify(ie.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:ae,renameError:G,busy:w.state!=="idle"||j.busy||y.busy||k.busy,pasteLabel:Q,selectionCount:ie.length,isArchive:he,chainLabel:v!==void 0,foldable:h!==void 0,fetcherState:w.state,fetcherData:w.data,handleAction:ue,submitCreate:j.submit,submitRename:le,submitDelete:xe,closeCreate:j.closeDialog,closeDelete:()=>H(!1),closeRename:()=>R(!1),closeHistory:()=>ee(!1)}}function Rt({target:t,dragging:r,clipboard:l,onDragStart:c,onDragEnd:p,onDropOn:f,onHoverAccept:v}){let h=r?.path===t.path,y=Boolean(r)&&!h&&l.moveRefusalFor(r,t)===null,[g,m]=n(!1);return o(()=>{if(!r)m(!1)},[r]),{isDragging:h,acceptsDrop:y,isDropHovered:g&&y,onDragStart:(k)=>{if(k.dataTransfer?.setData("text/plain",t.path),k.dataTransfer)k.dataTransfer.effectAllowed="move";c(t)},onDragEnd:p,onDragOver:(k)=>{if(!r)return;if(k.stopPropagation(),m(y),!y)return;if(k.preventDefault(),k.dataTransfer)k.dataTransfer.dropEffect="move";v?.(t)},onDragLeave:()=>m(!1),onDrop:(k)=>{if(!r)return;if(k.stopPropagation(),!y)return;k.preventDefault(),f(t)}}}function pn(t,r,l){if(r||l)return!1;return!Array.isArray(t.children)}function Oe({file:t,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:v,onCreated:h,onRenamed:y,expandedPaths:g,onToggleFolder:m,gitFileMap:C,gitFolderMap:k,clipboard:w,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae=!1}){let G=t.type==="folder",[I,z]=n(!1),[K,j]=n(!1),[ne,q]=n(!1),[X,J]=n(!1),ie=Array.isArray(t.children)?t.children:[],he=(t.path||"").replace(/^\/+/,""),Q=!G?C?.get(he)||C?.get(t.path):void 0,ue=Q?Kn(Q.status,Q.staged):null,le=G?k?.get(he)||k?.get(t.path):null,xe=Boolean(ue),L=t.ignored===!0,_=g?g.has(t.path):I,ce=t.forceExpanded!==void 0?t.forceExpanded:_;o(()=>{J(!0)},[]),o(()=>{if(G&&g)z(g.has(t.path))},[g,t.path,G]),o(()=>{if(G&&ce&&pn(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),U=Dt({file:{path:t.path,name:t.name,basePath:l,rootPath:r,repo:c},selection:M,selected:be,archive:E,diff:{staged:Q?.staged||(Q?.status?Q.status[0]!==" "&&Q.status[0]!=="?":!1),status:ue?.charStatus},onOpenFile:f,onActionComplete:v,onCreated:h,onRenamed:y,onUnfold:W&&Se({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:w,isFolder:G});me(U.contextMenuRef,U.closeContextMenu);let Y=Mu({enabled:ae,onLongPress:(V,ge)=>U.openContextMenu(V,ge)}),ke=(V)=>{if(V.stopPropagation(),Y.consume())return;let ge=N.gestureOf(V);if(ge!=="plain"){N.applyGesture(ge,t.path);return}if(N.applyGesture("plain",t.path),G){let pe=!ce;if(z(pe),t.forceExpanded!==void 0)t.forceExpanded=void 0;if(m?.(t.path,pe),!pe)q(!1)}else if(f)f({...t,root:r,repo:c||"."})},ve=(V)=>{V.preventDefault(),V.stopPropagation(),N.ensureForContext(t.path),U.openContextMenu(V.clientX,V.clientY)},de=Rt({target:ye,dragging:T,clipboard:w,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 ${de.isDragging?"opacity-40":""} ${de.isDropHovered?"bg-info/10 ring-1 ring-info/40 ring-inset":be?"bg-ink/[0.08] ring-1 ring-ink/20 ring-inset":"hover:bg-ink/5"}`,draggable:!ae,onClick:ke,onContextMenu:ve,onDragStart:de.onDragStart,onDragEnd:de.onDragEnd,onDragOver:de.onDragOver,onDragLeave:de.onDragLeave,onDrop:de.onDrop,onTouchStart:Y.onTouchStart,onTouchMove:Y.onTouchMove,onTouchEnd:Y.onTouchEnd,onTouchCancel:Y.onTouchCancel,children:e(Ye,{name:t.name,path:t.path,isFolder:G,isOpen:ce,ignored:L,selected:be,gitStatus:ue,folderStatus:le})}),ce&&K&&e("div",{className:"ml-3 border-l border-ink/10 pl-3 py-0.5 text-[10px] text-ink/30",children:"Loading…"}),ce&&!K&&ie.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:ie.map((V)=>e(Oe,{file:V,rootPath:r,basePath:l,repo:c,onLoadChildren:p,onOpenFile:f,onActionComplete:v,onCreated:h,onRenamed:y,expandedPaths:g,onToggleFolder:m,gitFileMap:C,gitFolderMap:k,clipboard:w,archive:E,selection:N,selectionTargets:M,dragging:T,onDragStart:R,onDragEnd:A,onDropOn:H,onUnfold:W,onFold:ee,foldRoots:te,touch:ae},V.path))}),X&&U.contextMenu&&e(Je,{x:U.contextMenu.x,y:U.contextMenu.y,isFolder:G,hasGitStatus:xe,pasteLabel:U.pasteLabel,chainLabel:U.chainLabel,foldable:U.foldable,busy:U.busy,selectionCount:U.selectionCount,isArchive:U.isArchive,onAction:U.handleAction}),X&&e(rt,{actions:U,file:t,isFolder:G,chainLabel:Se({type:G?"folder":"file",name:t.name})?t.name:void 0})]})}function Tt({x:t,y:r,pasteLabel:l,busy:c,onAction:p,menuRef:f}){let h=l?104:76,y=typeof window<"u"?Math.max(10,Math.min(t,window.innerWidth-190-12)):t,g=typeof window<"u"?Math.max(10,Math.min(r,window.innerHeight-h-12)):r;return oe(e("div",{className:"fixed inset-0 z-50 bg-ink/20",onClick:()=>p("close"),onContextMenu:(m)=>{m.preventDefault(),p("close")},children:e("div",{ref:f,className:"glass-popover fixed z-50 bg-paper border border-ink/15 shadow-2xl rounded-lg py-1 min-w-[185px] text-xs text-ink font-sans",style:{top:g,left:y},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(ni,{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(ln,{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(bo,{size:13,className:"text-ink/60"}),e("span",{children:l})]})]})}),document.body)}function At({menu:t,menuRef:r,pasteLabel:l,busy:c,onAction:p,create:f}){return e(d,{children:[t&&e(Tt,{x:t.x,y:t.y,menuRef:r,pasteLabel:l,busy:c,onAction:p}),f.open&&e(Fe,{folderPath:".",kind:f.kind,value:f.name,error:f.error,isLoading:f.busy,onChange:f.setName,onCancel:f.closeDialog,onSubmit:f.submit})]})}function St({title:t,subject:r,error:l,busy:c,submitLabel:p,busyLabel:f,onSubmit:v,onCancel:h,children:y}){return oe(e("div",{className:"fixed inset-0 modal-scrim z-[100] flex items-center justify-center p-4 backdrop-blur-sm",children:e("form",{onSubmit:v,className:"glass-overlay bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans",children:[e("h3",{className:"font-semibold text-ink mb-1 text-sm",children:t}),e("p",{className:"text-[11px] text-ink/50 mb-3 break-words",children:r}),y,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 un({entries:t,format:r,name:l,destination:c,formats:p,error:f,busy:v,onFormatChange:h,onNameChange:y,onDestinationChange:g,onCancel:m,onSubmit:C}){let k=t.slice(0,4).map((E)=>E.name).join(", "),w=t.length>4?` +${t.length-4} more`:"";return e(St,{title:`Compress ${t.length===1?t[0].name:`${t.length} items`}`,subject:`${k}${w}`,error:f,busy:v,submitLabel:"Compress",busyLabel:"Compressing...",onCancel:m,onSubmit:(E)=>{E.preventDefault(),C()},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)=>y(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 fn({archive:t,kindLabel:r,destination:l,error:c,busy:p,onDestinationChange:f,onCancel:v,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:v,onSubmit:(y)=>{y.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:(y)=>f(y.currentTarget.value),"aria-label":"Extract destination",className:`w-full bg-paper border rounded px-2 py-1.5 text-xs font-mono focus:outline-none ${c?"border-error":"border-ink/20 focus:border-ink"}`})]})}function Et({archive:t}){if(t.compress)return e(un,{entries:t.compress.entries,format:t.compress.format,name:t.compress.name,destination:t.compress.destination,formats:t.formats,error:t.error,busy:t.busy,onFormatChange:t.setFormat,onNameChange:t.setName,onDestinationChange:t.setCompressDestination,onCancel:t.cancel,onSubmit:t.submitCompress});if(t.extract)return e(fn,{archive:t.extract.archive,kindLabel:Nt(ze(t.extract.archive.name)??"zip"),destination:t.extract.destination,error:t.error,busy:t.busy,onDestinationChange:t.setExtractDestination,onCancel:t.cancel,onSubmit:t.submitExtract});return null}function Mt(){let[t,r]=S("files.outlineExpanded",!1),l=br(),c=Ue(oA,aA),{symbols:p,total:f,truncated:v,notice:h}=$u({content:c.content,language:c.language,state:c.state,note:c.note,path:c.path});if(c.state==="diff")return null;let y=c.preview,g=(m,C)=>{if(!c.path)return;if(y){let k=qu(p,C);if(k)Ji({path:c.path,...k});return}Yi({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(Kr,{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:v?`${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,C)=>e("button",{type:"button",onClick:()=>g(m,C),"aria-label":y?`${Yo(m.kind)} ${m.name}`:`${Yo(m.kind)} ${m.name}, line ${m.line}`,title:y?`Jump to ${Yo(m.kind).toLowerCase()}`:`${Yo(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(Pu,{kind:m.kind}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] font-mono text-ink/80",children:m.name}),!y&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/35",children:m.line})]},`${m.line}:${m.kind}:${m.name}`)),v&&e("div",{className:"px-1 py-1 text-[10px] italic text-ink/40",children:Ou(f)})]})})})})]})}function Pe(t,r){return Ae(t.map((l)=>mn(l,r)))}function mn(t,r){if(t.type!=="folder")return t;let l=r[t.path];if(!l)return t;return{...t,children:Pe(l,r)}}function hn(t){let r=t.lastIndexOf("/");return r===-1?".":t.slice(0,r)}function $t(t){let r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}function Lt(t){return[...t].sort((r,l)=>{if(r.type!==l.type)return r.type==="folder"?-1:1;return r.name.localeCompare(l.name)})}function Ie(t,r,l){let c=l.path.split("/"),p=c.slice(0,-1).join("/"),f=[...t],v={...r},h=f,y=null;for(let g=0;g<c.length-1;){let m=c.slice(0,g+1).join("/"),C=h.find((M)=>M.type==="folder"&&M.path===m),k=C?null:h.find((M)=>M.type==="folder"&&M.path.startsWith(`${m}/`)&&(p===M.path||p.startsWith(`${M.path}/`))),w=C??k,E=w?v[w.path]??w.children:null;if(w&&!Array.isArray(E))return{nodes:t,cache:r};if(!w){let M=gn(h,v,m);if(M){h=M;let T=h.find((A)=>A.path===m),R=Array.isArray(T?.children)?[...T.children]:[];v[m]=R,h=R,y=m,g+=1;continue}}let N=Array.isArray(E)?[...E]:[];if(w){v[w.path]=N,h=N,y=w.path,g=w.path.split("/").length;continue}h.push({name:c[g],path:m,type:"folder",ignored:!1}),v[m]=N,h=N,y=m,g+=1}if(h.push(l),y!==null)v[y]=Lt(h);return f=Lt(f),{nodes:f,cache:v}}function gn(t,r,l){let c=t.findIndex((y)=>y.type==="folder"&&y.path.startsWith(`${l}/`));if(c===-1)return null;let p=t[c],f=p.path.slice(l.length+1).split("/"),v=r[p.path]??p.children;if(Array.isArray(v))r[p.path]=v;let h={name:f[f.length-1],path:p.path,type:"folder",ignored:p.ignored,...Array.isArray(v)?{children:v}:{}};for(let y=f.length-2;y>=0;y-=1)h={name:f[y],path:`${l}/${f.slice(0,y+1).join("/")}`,type:"folder",ignored:!1,children:[h]};return t[c]={name:$t(l),path:l,type:"folder",ignored:!1,children:[h]},t}function zt(t,r,l){let c=t.find((m)=>m.path===l);if(c)return{entry:c,nodes:t.filter((m)=>m.path!==l),cache:r};let p=hn(l),f=r[p],v=f?.find((m)=>m.path===l);if(f&&v)return{entry:v,nodes:t,cache:{...r,[p]:f.filter((m)=>m.path!==l)}};let y=Object.keys(r).filter((m)=>l.startsWith(`${m}/`)&&r[m].some((C)=>C.path===l)).sort((m,C)=>C.length-m.length)[0];if(!y)return{entry:null,nodes:t,cache:r};let g=r[y];return{entry:g.find((m)=>m.path===l),nodes:t,cache:{...r,[y]:g.filter((m)=>m.path!==l)}}}function Ot(t,r,l){let c=!1,p=t.map((f)=>{let v=f.path===r||f.path.startsWith(`${r}/`),h=Array.isArray(f.children)?Ot(f.children,r,l):void 0;if(!v&&h===f.children)return f;c=!0;let y=v?f.path===r?l:`${l}${f.path.slice(r.length)}`:f.path,g=v?{...f,path:y,name:$t(y)}:{...f};if(h!==void 0)g.children=h;return g});return c?p:t}function Pt(t,r,l){let c={};for(let[p,f]of Object.entries(t)){let v=p===r?l:p.startsWith(`${r}/`)?`${l}${p.slice(r.length)}`:p;c[v]=v===p?f:Ot(f,r,l)}return c}function It(t,r,l){let c=new Set;for(let p of t)if(p===r)c.add(l);else if(p.startsWith(`${r}/`))c.add(`${l}${p.slice(r.length)}`);else c.add(p);return c}function Ht(t){if(!x(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)=>x(r)):[],root:t.root}}async function He(t){try{return Ht(await(await fetch(t)).json())}catch{return{status:"failed"}}}function Gt({enabled:t,rootPath:r,activeRepo:l,expandedPaths:c,onExpansionPruned:p}){let f=`${r??""}\x00${l}`,[v,h]=n({scope:"",files:[],root:""}),[y,g]=n(!1),m=i({}),C=i([]),k=i(f);k.current=f;let w=i(""),E=i(""),N=i(c);N.current=c;let M=(I)=>{let z=new URLSearchParams;if(r)z.set("root",r);if(l&&l!==".")z.set("repo",l);if(I)z.set("path",I);return z.set("t",String(Date.now())),`/api/fs/dir?${z.toString()}`},T=(I,z)=>{w.current=I,E.current=z;let K=Pe(C.current,m.current);return h({scope:I,files:K,root:z}),K},R=async(I)=>{let z=[...N.current];if(z.length===0)return;let K=await Promise.all(z.map(async(X)=>({path:X,read:await He(M(X))})));if(k.current!==I)return;let j=[];for(let{path:X,read:J}of K)if(J.status==="ok")m.current[X]=J.files;else if(J.status==="missing")j.push(X);if(j.length===0)return;let ne=new Set(j);for(let X of j)delete m.current[X];let q=new Set([...N.current].filter((X)=>!ne.has(X)));N.current=q,p(q)},A=async()=>{if(!t)return;let I=k.current;g(!0);try{let z=await He(M());if(k.current!==I)return;if(z.status!=="ok")return;if(w.current!==I)m.current={};if(C.current=z.files,T(I,z.root),await R(I),k.current!==I)return;T(I,z.root)}finally{if(k.current===I)g(!1)}},H=async(I)=>{let z=k.current,K=await He(M(I));if(k.current!==z||K.status!=="ok")return;if(m.current[I]=K.files,w.current===z)T(z,E.current)},W=(I)=>{let z=Ht(I);if(z.status!=="ok")return;let K=k.current;if(w.current!==K)m.current={};C.current=z.files,T(K,z.root),R(K).then(()=>{if(k.current===K)T(K,z.root)})},ee=()=>{m.current={},C.current=[],w.current="",E.current="",h({scope:"",files:[],root:""})},te=(I)=>{let z=k.current;if(w.current!==z)return null;let K={name:I.path.slice(I.path.lastIndexOf("/")+1),path:I.path,type:I.kind,ignored:!1},j=Ie(C.current,m.current,K);if(j.nodes===C.current)return null;return C.current=j.nodes,m.current=j.cache,T(z,E.current)},ae=(I,z)=>{let K=k.current;if(w.current!==K)return null;let j=zt(C.current,m.current,I);if(!j.entry)return null;m.current=Pt(j.cache,I,z);let ne={...j.entry,path:z,name:z.slice(z.lastIndexOf("/")+1)},q=Ie(j.nodes,m.current,ne);return C.current=q.nodes,m.current=q.cache,T(K,E.current)},G=v.scope===f;return{scope:f,files:G?v.files:[],root:G?v.root:"",isLoading:y,reload:A,loadChildren:H,adoptRoot:W,insertEntry:te,moveEntry:ae,reset:ee}}function Kt({rootPath:t,repo:r,onComplete:l,onError:c}){let p=lt(),[f,v]=S("files.clipboard",null),h=mt(f),y=ct(t,r),g=i(!1),m=i(null);o(()=>{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)v(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 C=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]),k=a((N)=>ft(h,y,Le(N.path,N.kind)),[h,y]),w=a((N,M)=>ut(N,Le(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:k,moveRefusalFor:w,copy:(N)=>{if(N.length===0)return;v({scope:y,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"copy"})},cut:(N)=>{if(N.length===0)return;v({scope:y,entries:N.map(({path:M,name:T,kind:R})=>({path:M,name:T,kind:R})),mode:"cut"})},duplicate:(N)=>{C({actionType:"duplicate",path:N.path},!1)},move:(N,M)=>{let T=w(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=k(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 bn=$e.map((t)=>({...t,available:!0,tool:t.id}));function jt({rootPath:t,repo:r,onComplete:l}){let c=lt(),[p,f]=n(bn),[v,h]=n(null),[y,g]=n(null),[m,C]=n(null),k=i(null),w=i(null);o(()=>{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}},[]),o(()=>{if(c.state!=="idle"||!c.data)return;let R=c.data;if(w.current===R)return;w.current=R;let A=k.current;if(k.current=null,R.success){if(C(null),A==="compress")h(null);if(A==="extract")g(null);l()}else if(A)C(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";C(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:Ct(R)})},[p]),M=a((R)=>{C(null),h(null),g({archive:R,destination:Ft(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:v,extract:y,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),C(null)},submitCompress:()=>{let R=v;if(!R)return;k.current="compress",C(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=y;if(!R)return;k.current="extract",C(null),E({actionType:"extract",path:R.archive.path,destination:R.destination.trim()||"."})}}}function xn(t){if(t.shiftKey)return"range";if(t.metaKey||t.ctrlKey)return"toggle";return"plain"}function vn(t,r,l){if(!r)return[l];let c=t.indexOf(r),p=t.indexOf(l);if(c===-1||p===-1)return[l];let f=Math.min(c,p),v=Math.max(c,p);return t.slice(f,v+1)}function _t(t){let[r,l]=n(()=>new Set),[c,p]=n(null),f=a((g,m)=>{if(g==="range"){l(new Set(vn(t,c,m)));return}if(p(m),g==="toggle"){l((C)=>{let k=new Set(C);if(k.has(m))k.delete(m);else k.add(m);return k});return}l(new Set([m]))},[c,t]),v=a((g)=>{l((m)=>{if(m.has(g))return m;return new Set([g])}),p(g)},[]),h=a(()=>{l(new Set),p(null)},[]),y=a(xn,[]);return u(()=>({selected:r,count:r.size,anchor:c,gestureOf:y,applyGesture:f,ensureForContext:v,clear:h}),[r,c,y,f,v,h])}function Ge(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))Ge(p.children,r,l+1,c);return c}function Wt({listing:t,setExpandedPaths:r,setStoredExpandedPaths:l,reload:c,onMoved:p}){let f=a((y,g)=>{let m=at(g,y);if(m.length===0)return;r((C)=>{if(m.every((w)=>C.has(w)))return C;let k=new Set(C);for(let w of m)k.add(w);return l(Array.from(k)),k})},[r,l]),v=a((y)=>{let g=t.insertEntry(y);if(!g){c();return}f(y.path,g)},[t,c,f]),h=a((y,g)=>{p?.(y,g),r((C)=>{let k=It(C,y,g);return l(Array.from(k)),k});let m=t.moveEntry(y,g);if(!m){c();return}f(g,m)},[t,c,f,r,l,p]);return{insertCreated:v,moveRenamed:h}}var yn=new Set;function Ut({scope:t,setExpandedPaths:r,setStoredExpandedPaths:l}){let[c,p]=n({scope:t,chains:new Map}),f=a((y)=>{let g=Me(y.path,y.name);if(!g)return;p((C)=>{let k=C.scope===t?C.chains:new Map;if(k.get(y.path)?.length===g.length)return C;let E=new Map(k);return E.set(y.path,g),{scope:t,chains:E}});let m=g.slice(0,-1);r((C)=>{if(m.every((w)=>C.has(w)))return C;let k=new Set(C);for(let w of m)k.add(w);return l(Array.from(k)),k})},[t,r,l]),v=a((y)=>{let g=c.scope===t?c.chains.get(y):void 0;if(!g)return;let m=g.slice(0,-1);p((C)=>{if(C.scope!==t)return C;let k=new Map(C.chains);return k.delete(y),{scope:t,chains:k}}),r((C)=>{if(!m.some((w)=>C.has(w)))return C;let k=new Set(C);for(let w of m)k.delete(w);return l(Array.from(k)),k})},[t,c,r,l]),h=a((y,g)=>{let m=c.scope===t?c.chains:null;if(!m)return;let C=new Map,k=[],w=!1;for(let[E,N]of m){if(N.findIndex((A,H)=>A===y&&H>0&&H<N.length-1)!==-1){w=!0;continue}let T=N.map((A)=>A===y?g:A.startsWith(`${y}/`)?`${g}${A.slice(y.length)}`:A),R=T[T.length-1];if(R!==E||T.some((A,H)=>A!==N[H]))w=!0;C.set(R,T),k.push(...T.slice(0,-1))}if(!w)return;p({scope:t,chains:C}),r((E)=>{if(k.every((M)=>E.has(M)))return E;let N=new Set(E);for(let M of k)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()):yn,unfold:f,fold:v,rekey:h}}function Vt(t,r){let l=r.trim().toLowerCase();if(!l)return t;let c=(p)=>{let f=p.name.toLowerCase().includes(l);if(p.type==="folder"){let v=(p.children||[]).map(c).filter((h)=>h!==null);if(f||v.length>0)return{...p,children:f&&v.length===0?p.children:v,forceExpanded:!0};return null}return f?p:null};return t.map(c).filter((p)=>p!==null)}function Xt({dragging:t,clipboard:r,target:l}){let c=Boolean(t)&&r.moveRefusalFor(t,l)===null,[p,f]=n(!1);return o(()=>{if(!t)f(!1)},[t]),{accepts:c,highlighted:p&&c,onDragEnter:()=>{if(t)f(!0)},onDragLeave:(v)=>{if(!v.currentTarget.contains(v.relatedTarget))f(!1)},onDragOver:(v)=>{if(!c)return;if(v.preventDefault(),v.dataTransfer)v.dataTransfer.dropEffect="move"},onDrop:(v)=>{if(!c)return;v.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:v}){let[h,y]=S("files.searchQuery",""),[g,m,C]=S("files.expandedPaths",[]),[k,w]=n(()=>new Set(g)),{activeRepo:E,setActiveRepo:N}=cr(c),{repos:M,scanning:T,rescan:R}=ur(c,r),{fileMap:A,folderMap:H,refreshGitStatus:W}=$s(c,E,r),[ee,te]=n(null),ae=i(null);o(()=>{if(!C)return;w((P)=>{let Z=new Set(g);if(P.size===Z.size&&Array.from(Z).every((fe)=>P.has(fe)))return P;return Z})},[C,g]);let G=Gt({enabled:r,rootPath:c,activeRepo:E,expandedPaths:k,onExpansionPruned:(P)=>{w(P),m(Array.from(P))}});o(()=>{if(!C||!l)return;G.reload()},[f,c,r,E,C,l]);let I=r&&C?Wg(G.scope):null,z=Ce(I);o(()=>{if(z.data)G.adoptRoot(z.data)},[z.data]);let K=(P)=>(W(),G.loadChildren(P)),j=(P,Z)=>{let fe=new Set(k);if(Z)fe.add(P);else fe.delete(P);w(fe),m(Array.from(fe))},{unfolded:ne,unfold:q,fold:X,rekey:J}=Ut({scope:G.scope,setExpandedPaths:w,setStoredExpandedPaths:m}),ie=G.files,he=it(ie,ne),Q=Vt(he.nodes,h),ue=Ge(Q,(P)=>P.forceExpanded!==void 0?P.forceExpanded:k.has(P.path)),le=_t(ue.map((P)=>P.path)),xe=ue.filter((P)=>le.selected.has(P.path)).map(({path:P,name:Z,kind:fe})=>({path:P,name:Z,kind:fe})),L=(P)=>{if(P===E)return;G.reset(),w(new Set),m([]),le.clear(),N(P)},_=()=>{if(W(),v)v();else G.reload()},{insertCreated:ce,moveRenamed:ye}=Wt({listing:G,setExpandedPaths:w,setStoredExpandedPaths:m,reload:_,onMoved:(P,Z)=>J(P,Z)}),be=Xi(),{pushToast:U}=je(),Y=Kt({rootPath:c,repo:E,onComplete:_,onError:(P)=>U(P,"error")}),ke=jt({rootPath:c,repo:E,onComplete:_}),ve={path:".",name:".",kind:"folder"},de=Y.clip&&!Y.refusalFor(ve)?`Paste ${we(Y.clip)??"item"}`:null,[V,ge]=n(null),pe=Xt({dragging:V,clipboard:Y,target:ve}),Re=Ne({folderPath:".",rootPath:c,repo:E,onCreated:ce,onOpenCreated:(P)=>p?.({...P,root:c,repo:E})}),[Ke,qt]=n(!1);o(()=>qt(!0),[]);let{count:_e,clear:We}=le;if(o(()=>{if(!l)return;let P=(Z)=>{if(Z.key==="Escape"&&_e>0)We()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[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 Bt=G.isLoading||z.refreshing;return e("div",{className:`flex flex-col h-full bg-paper ${t}`,children:[e(Qe,{rootPath:c,activeRepo:E,repos:M,reposScanning:T,onRefreshRepos:R,onSelectRepo:L,searchQuery:h,onSearchChange:y,onRefresh:_,refreshing:Bt}),e("div",{className:`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${be?"file-tree-touch":""} ${pe.highlighted?"bg-info/[0.06]":""}`,onContextMenu:(P)=>{P.preventDefault(),te({x:P.clientX,y:P.clientY})},onDragEnter:pe.onDragEnter,onDragLeave:pe.onDragLeave,onDragOver:pe.onDragOver,onDrop:pe.onDrop,children:G.isLoading&&Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"Loading files..."}):Q.length===0?e("div",{className:"p-4 text-center text-ink/40",children:"No files found"}):Q.map((P)=>e(Oe,{file:P,rootPath:c,basePath:G.root,repo:E,onLoadChildren:K,onOpenFile:p,onActionComplete:_,onCreated:ce,onRenamed:ye,expandedPaths:k,onToggleFolder:j,gitFileMap:A,gitFolderMap:H,clipboard:Y,archive:ke,selection:le,selectionTargets:xe,dragging:V,onDragStart:ge,onDragEnd:()=>ge(null),onDropOn:(Z)=>{if(!V)return;Y.move(V,Z)},onUnfold:q,onFold:X,foldRoots:he.roots,touch:be},P.path))}),e(Mt,{}),Ke&&e(At,{menu:ee,menuRef:ae,pasteLabel:de,busy:Y.busy,create:Re,onAction:(P)=>{if(te(null),P==="new_file")Re.openDialog("file");if(P==="new_folder")Re.openDialog("folder");if(P==="paste")Y.paste(ve)}}),Ke&&e(Et,{archive:ke})]})}export{oi as FileExplorer};
@@ -1,2 +1,2 @@
1
- import{d,n,o,i,a,e,s,E,ne,Qe,_e,_,ei,At,De,Se,b,J,ui,qm}from"./index-zqthmaxq.js";var B={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(B);function I({title:t,options:r,methodLabel:p,badge:m,icon:x,onCancel:g}){let f=ui({title:t,options:r})?qm(t):null,h=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:h}),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(_e,{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(b,{size:14})})]})}function T({options:t,optionDetails:r,selectedOption:p,customValue:m,onCustomChange:x,customInputRef:g,onSelect:f,onConfirmOption:h,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,y)=>{let u=p===k,v=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>h(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),v&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:v})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(ei,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:g,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())h(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(b,{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(At,{size:12,className:"opacity-70"})]})]})]})}function P({title:t,options:r}){let p=ui({title:t,options:r})?qm(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(_,{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}){o(()=>{let h=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u<r.length-1?u+1:0;m(r[v]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===p),v=u>0?u-1:r.length-1;m(r[v]);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",h),()=>window.removeEventListener("keydown",h)},[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(E,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Se,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(De,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Qe,{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,h]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),v=t.options??[],N=t.optionDetails??[],C=ui(t);o(()=>{let c=t.options??[];m(t.method==="editor"?t.prefill??"":""),g(c.length>0?c[0]:null),h("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((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()&&!C)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:p})},[r,t,x,p,f,C]),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:v,selectedOption:x,onSelectOption:g,customInputRef:u,onSubmit:A,onCancel:w});let D=L(t.method,v.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||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(I,{title:t.title,options:v,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(P,{title:t.title,options:v}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(J,{content:t.message})}),t.method==="select"&&e(T,{options:v,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:h,customInputRef:u,onSelect:z,onConfirmOption:O,hideCustomAnswer:C}),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:k,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
- `).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:y,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:v.length,selectedOption:x,hasCustomAnswer:f.trim().length>0,onCancel:w,onSubmit:A})]})})}export{ke as ExtensionDialog};
1
+ import{d,n,o,i,a,e,s,E,ne,Qe,_e,_,ei,At,De,Se,b,J,ui,qm}from"./index-f77c3ag0.js";var B={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},I=s(B);function T({title:t,options:r,methodLabel:c,badge:m,icon:x,onCancel:k}){let f=ui({title:t,options:r})?qm(t):null,h=f?`Allow ${f.tool}`:t||c;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:h}),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(_e,{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:k,"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(b,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:c,customValue:m,onCustomChange:x,customInputRef:k,onSelect:f,onConfirmOption:h,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((v,y)=>{let u=c===v,g=r[y]?.description;return e("button",{type:"button",onClick:()=>f(v),onDblClick:()=>h(v),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:v})}),g&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:g})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(ei,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},v)})}),!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:k,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(v)=>x(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter"){if(v.preventDefault(),v.stopPropagation(),m.trim())h(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function P({method:t,optionsLength:r,selectedOption:c,hasCustomAnswer:m=!1,onCancel:x,onSubmit:k}){let f=t==="select"&&!c&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(b,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:k,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(At,{size:12,className:"opacity-70"})]})]})]})}function R({title:t,options:r}){let c=ui({title:t,options:r})?qm(t):null;if(!c)return null;return e("div",{className:"space-y-2",children:[c.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:c.reason})]}),c.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:c.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function L({method:t,options:r,selectedOption:c,onSelectOption:m,customInputRef:x,onSubmit:k,onCancel:f}){o(()=>{let h=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u<r.length-1?u+1:0;m(r[g]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u>0?u-1:r.length-1;m(r[g]);return}if(l.key==="Enter"&&c){l.preventDefault(),k();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),k();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),k();return}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,k,t,r,c,m,x])}function z(t,r){switch(t){case"select":return{icon:e(I,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(E,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Se,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(De,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Qe,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[c,m]=n(t.method==="editor"?t.prefill??"":""),[x,k]=n(null),[f,h]=n(""),l=i(null),v=i(null),y=i(null),u=i(null),g=t.options??[],N=t.optionDetails??[],A=ui(t);o(()=>{let p=t.options??[];m(t.method==="editor"?t.prefill??"":""),k(p.length>0?p[0]:null),h("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")v.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((C)=>/^other\b/i.test(C.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),M=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!A)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:c})},[r,t,x,c,f,A]),O=a((p)=>{if(/^other\b/i.test(p.trim())){k(p),u.current?.focus();return}r(t,{value:p})},[r,t]),H=a((p)=>{if(k(p),/^other\b/i.test(p.trim()))u.current?.focus()},[]);L({method:t.method,options:g,selectedOption:x,onSelectOption:k,customInputRef:u,onSubmit:M,onCancel:w});let D=z(t.method,g.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 backdrop-blur-[8px]",onMouseDown:(p)=>{if(p.target===p.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(T,{title:t.title,options:g,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(R,{title:t.title,options:g}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(J,{content:t.message})}),t.method==="select"&&e(S,{options:g,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:h,customInputRef:u,onSelect:H,onConfirmOption:O,hideCustomAnswer:A}),t.method==="confirm"&&g.length>0&&e("div",{className:"space-y-2",children:g.map((p,C)=>e("button",{type:"button",onClick:()=>r(t,{optionId:t.optionIds?.[C]??p}),className:"flex w-full cursor-pointer items-center justify-between rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 text-left text-[13px] font-medium text-ink transition-colors hover:border-ink/30 hover:bg-canvas/50",children:e("span",{className:"min-w-0 break-words",children:p})},t.optionIds?.[C]??p))}),t.method==="confirm"&&g.length===0&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(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:v,type:t.secret===!0?"password":"text",value:c,placeholder:t.placeholder||"Type your response...",onChange:(p)=>m(p.currentTarget.value),onKeyDown:(p)=>{if(p.key==="Enter")p.preventDefault(),M()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[c.split(`
2
+ `).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:y,value:c,onChange:(p)=>m(p.currentTarget.value),rows:8,placeholder:t.placeholder||"Enter content...",className:"w-full rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 font-mono text-[12px] leading-relaxed text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:bg-paper focus:ring-2 focus:ring-ink/15"})]})]}),e(P,{method:t.method,optionsLength:g.length,selectedOption:x,hasCustomAnswer:f.trim().length>0,onCancel:w,onSubmit:M})]})})}export{ke as ExtensionDialog};