@kabmo-labs/kabmo 0.44.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +1 -1
  3. package/dist/client/static/js/{CsvGrid-1t2q46rg.js → CsvGrid-z74weshk.js} +2 -2
  4. package/dist/client/static/js/{DocxView-301hxnwk.js → DocxView-dpe5x9ab.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-47bwea5t.js → DrawioView-ftzwjf8v.js} +2 -2
  6. package/dist/client/static/js/{ImageView-68zdx5ex.js → ImageView-vchn6wyq.js} +1 -1
  7. package/dist/client/static/js/LayoutWrapper-1x0gnppc.js +2 -0
  8. package/dist/client/static/js/{Modal-fb9b4gq6.js → Modal-tteg7vtb.js} +18 -18
  9. package/dist/client/static/js/{PdfView-m64ksepp.js → PdfView-vjec8z3z.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-zyjwhpzm.js → SessionsView-g7z3fxbp.js} +1 -1
  11. package/dist/client/static/js/{SheetView-e88sqprx.js → SheetView-hhtfkdhe.js} +25 -25
  12. package/dist/client/static/js/{SvgPreview-hs9a713t.js → SvgPreview-48n3ex6p.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-fnr5kyqk.js → abnfDiagram-O67JEVCF-bpvzdara.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-bch3nye9.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-7v003363.js → architectureDiagram-NJMV4G6O-xw62cr7j.js} +3 -3
  16. package/dist/client/static/js/{astro-t9vjc0mc.js → astro-56b0as3q.js} +1 -1
  17. package/dist/client/static/js/bash-mevzaywf.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-k4mwbw3d.js → blockDiagram-BEXU5L5S-x3a6cgar.js} +4 -4
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-688zq6f4.js → c4Diagram-YGBWAQC7-katvaxbj.js} +2 -2
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-h0s16pxr.js → classDiagram-v2-NBCMYWYE-bjz4mqqh.js} +3 -3
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-qb2t8qq5.js → cose-bilkent-JH36ORCC-fsn80psf.js} +1 -1
  22. package/dist/client/static/js/cpp-wk9z0c5g.js +1 -0
  23. package/dist/client/static/js/css-3w3p9s67.js +1 -0
  24. package/dist/client/static/js/cynefin-OW5HDTMX-vqy5jtnk.js +1 -0
  25. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-syhtcr7b.js → cynefinDiagram-VND7K2PF-cfhbsnkm.js} +2 -2
  26. package/dist/client/static/js/{dagre-6A5THRUB-7wgbx6cm.js → dagre-6A5THRUB-j2wt7ns6.js} +2 -2
  27. package/dist/client/static/js/{diagram-22UHCM2B-951cmp5h.js → diagram-22UHCM2B-abrdj714.js} +8 -8
  28. package/dist/client/static/js/{diagram-3UASUU5V-mvdbqt7b.js → diagram-3UASUU5V-dbn15bxn.js} +1 -1
  29. package/dist/client/static/js/{diagram-ATOU4E4O-hkvdtgdm.js → diagram-ATOU4E4O-y79pwf7w.js} +3 -3
  30. package/dist/client/static/js/{diagram-CDSNMT55-bkkz35ca.js → diagram-CDSNMT55-f8ryt86n.js} +2 -2
  31. package/dist/client/static/js/{diagram-MLGK6HIB-z6pcrkc3.js → diagram-MLGK6HIB-ws7wn3q9.js} +1 -1
  32. package/dist/client/static/js/{diagram-MPIPVDR6-mkwf8j4m.js → diagram-MPIPVDR6-zmznrg13.js} +2 -2
  33. package/dist/client/static/js/{dockerfile-7gd570bm.js → dockerfile-qgc921kw.js} +1 -1
  34. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-trym26ts.js → ebnfDiagram-ZINNZB2B-y5q7hy1v.js} +1 -1
  35. package/dist/client/static/js/{elixir-z77c7tfn.js → elixir-12pgbgtq.js} +1 -1
  36. package/dist/client/static/js/{elk-276RUBZZ-gkhz67v6.js → elk-276RUBZZ-vddwbn6q.js} +1 -1
  37. package/dist/client/static/js/{erDiagram-OPXOYQCR-gkyr5cqs.js → erDiagram-OPXOYQCR-qdqcx4g4.js} +6 -6
  38. package/dist/client/static/js/{erlang-6vrvh2m6.js → erlang-811btv6p.js} +1 -1
  39. package/dist/client/static/js/eventmodeling-NTZA5JFV-65ph4s3m.js +1 -0
  40. package/dist/client/static/js/flowDiagram-KWPJA3E3-nh2tb65b.js +1 -0
  41. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-1qpme6ks.js → ganttDiagram-FUAMR5RP-763hk9rm.js} +1 -1
  42. package/dist/client/static/js/gitGraph-4MIJSDKK-t45ekjb6.js +1 -0
  43. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-wbg3kqak.js → gitGraphDiagram-X574FWY7-bgx1q5nw.js} +4 -4
  44. package/dist/client/static/js/graphql-027z8sc0.js +1 -0
  45. package/dist/client/static/js/html-fqda6wxx.js +1 -0
  46. package/dist/client/static/js/{index-ks23y2cd.js → index-03j5j1j0.js} +2 -2
  47. package/dist/client/static/js/{index-czedkbmb.js → index-05hx4ftf.js} +2 -2
  48. package/dist/client/static/js/index-0vk6v4y4.js +2 -0
  49. package/dist/client/static/js/{index-83pwa9c0.js → index-1nwwvv29.js} +1 -1
  50. package/dist/client/static/js/{index-31hntzse.js → index-228yzebd.js} +5 -5
  51. package/dist/client/static/js/{index-xf36nmbm.js → index-2b1wnvez.js} +2 -2
  52. package/dist/client/static/js/{index-6t21c6jt.js → index-34ff2vq6.js} +2 -2
  53. package/dist/client/static/js/{index-1923aj4g.js → index-3d21hpk7.js} +2 -2
  54. package/dist/client/static/js/{index-hfsvwfgw.js → index-3h2mr90j.js} +2 -2
  55. package/dist/client/static/js/{index-svmzgtcx.js → index-3sqndc9n.js} +2 -2
  56. package/dist/client/static/js/{index-6gyk52ff.js → index-47wn2gjx.js} +1 -1
  57. package/dist/client/static/js/{index-6ah5sj5y.js → index-4b5b6g0k.js} +1 -1
  58. package/dist/client/static/js/{index-53ysgsd2.js → index-5b2vsbcf.js} +1 -1
  59. package/dist/client/static/js/{index-qm92sf9w.js → index-5mrqfs82.js} +12 -12
  60. package/dist/client/static/js/{index-62ng8tkj.js → index-61j9qkck.js} +3 -3
  61. package/dist/client/static/js/index-6bm4pw90.css +1 -0
  62. package/dist/client/static/js/{index-fj4k07zt.js → index-6sqmhdyv.js} +2 -2
  63. package/dist/client/static/js/{index-gtkhz0hj.js → index-8dtp7mt0.js} +2 -2
  64. package/dist/client/static/js/index-a11ptyzf.js +1 -0
  65. package/dist/client/static/js/{index-nvevymac.js → index-acphtw1r.js} +2 -2
  66. package/dist/client/static/js/{index-pxm44qfd.js → index-cj39b26c.js} +1 -1
  67. package/dist/client/static/js/{index-wytdbvax.js → index-dgjerk4w.js} +3 -3
  68. package/dist/client/static/js/{index-ad4x44d6.js → index-dn6pqym4.js} +6 -6
  69. package/dist/client/static/js/{index-nr8s5xm9.js → index-ehg2ftnp.js} +2 -2
  70. package/dist/client/static/js/{index-jbkkwa2q.js → index-f51jxezc.js} +2 -2
  71. package/dist/client/static/js/index-f7paep2f.js +2 -0
  72. package/dist/client/static/js/{index-qkjx6521.js → index-f98dhbt4.js} +4 -4
  73. package/dist/client/static/js/{index-92n96mgd.js → index-fbct0jcf.js} +2 -2
  74. package/dist/client/static/js/{index-bjqz7swa.js → index-fqatn0vh.js} +1 -1
  75. package/dist/client/static/js/{index-tzdm1y3z.js → index-gcwmpfr4.js} +2 -2
  76. package/dist/client/static/js/{index-v5npdwy2.js → index-gmq5pbcv.js} +51 -51
  77. package/dist/client/static/js/{index-fbpc1wx6.js → index-gzafyqsr.js} +21 -21
  78. package/dist/client/static/js/{index-4y4hshcx.js → index-gzp4j2h5.js} +2 -2
  79. package/dist/client/static/js/{index-nqjd3hh5.js → index-h0rmkz9n.js} +2 -2
  80. package/dist/client/static/js/{index-8trggh1z.js → index-jpp0zm7t.js} +7 -7
  81. package/dist/client/static/js/{index-qf9x7yet.js → index-kg2sk8cf.js} +1 -1
  82. package/dist/client/static/js/{index-rpzxrr2d.js → index-mrw7qweg.js} +1 -1
  83. package/dist/client/static/js/{index-s8bktzpg.js → index-mwm8aptp.js} +1 -1
  84. package/dist/client/static/js/{index-c3v62nvt.js → index-n1ga63de.js} +2 -2
  85. package/dist/client/static/js/{index-22whvfdw.js → index-nzhwd6t3.js} +2 -2
  86. package/dist/client/static/js/{index-tr2pkfs6.js → index-p21mvqc2.js} +2 -2
  87. package/dist/client/static/js/{index-qsw5edtk.js → index-pfj3sd1n.js} +5 -5
  88. package/dist/client/static/js/{index-pysqpc5n.js → index-pxq4v81r.js} +2 -2
  89. package/dist/client/static/js/{index-07yh7qx0.js → index-q76jfb54.js} +1 -1
  90. package/dist/client/static/js/{index-6s4mrdew.js → index-qt9jc4ck.js} +2 -2
  91. package/dist/client/static/js/{index-ehacfgwm.js → index-r6e44vkx.js} +1 -1
  92. package/dist/client/static/js/{index-232nsp2c.js → index-szk3vk8h.js} +1 -1
  93. package/dist/client/static/js/{index-e6rm5xzj.js → index-t0yv1375.js} +1 -1
  94. package/dist/client/static/js/{index-n0matkz9.js → index-vgcm2g0g.js} +2 -2
  95. package/dist/client/static/js/{index-kwpaz891.js → index-vkerrwpa.js} +2 -2
  96. package/dist/client/static/js/{index-v7bcgh77.js → index-w57zbym7.js} +2 -2
  97. package/dist/client/static/js/{index-yfjvx4yf.js → index-wqrdgt1g.js} +2 -2
  98. package/dist/client/static/js/{index-barbpakv.js → index-x2wvq4ae.js} +2 -2
  99. package/dist/client/static/js/{index-3w845q50.js → index-x7rfmwg8.js} +2 -2
  100. package/dist/client/static/js/{index-cq98p2rb.js → index-xkwybnf3.js} +179 -179
  101. package/dist/client/static/js/info-A6RAGUB7-mw29xbwf.js +1 -0
  102. package/dist/client/static/js/{infoDiagram-VRGFBTTK-yebngg8c.js → infoDiagram-VRGFBTTK-e66pw8d9.js} +1 -1
  103. package/dist/client/static/js/ini-3cx6tmv4.js +1 -0
  104. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-kh4nqj6q.js → ishikawaDiagram-OU5B5YK6-ehc0q24d.js} +1 -1
  105. package/dist/client/static/js/java-zs6qh1dm.js +1 -0
  106. package/dist/client/static/js/javascript-b9mkygak.js +1 -0
  107. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-4khnf8x1.js → journeyDiagram-ZHPQQLJL-hye05qtd.js} +2 -2
  108. package/dist/client/static/js/jsx-gahhfczw.js +1 -0
  109. package/dist/client/static/js/{julia-svwxx41e.js → julia-mgsev9df.js} +1 -1
  110. package/dist/client/static/js/{kanban-definition-PNTS6WVX-snmq3wq4.js → kanban-definition-PNTS6WVX-vce614m8.js} +6 -6
  111. package/dist/client/static/js/lua-d8enp14s.js +1 -0
  112. package/dist/client/static/js/markdown-qetaj4vp.js +1 -0
  113. package/dist/client/static/js/{mermaid.core-yctw30sk.js → mermaid.core-gc79re5p.js} +7 -7
  114. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-atfv66wq.js → mindmap-definition-NLK3R4M7-ft1whaf5.js} +3 -3
  115. package/dist/client/static/js/one-dark-pro-rvg5xm1a.js +1 -0
  116. package/dist/client/static/js/one-light-2b5w3ksh.js +1 -0
  117. package/dist/client/static/js/packet-AYTQ26CC-md85wpjq.js +1 -0
  118. package/dist/client/static/js/{pegDiagram-GJSIUBJH-hpbtxjht.js → pegDiagram-GJSIUBJH-2s4ykhaa.js} +1 -1
  119. package/dist/client/static/js/{perl-mr0ds2ex.js → perl-6n93vjsa.js} +1 -1
  120. package/dist/client/static/js/{php-5h3wt6tv.js → php-w23nmbtc.js} +1 -1
  121. package/dist/client/static/js/pie-WAS4IAKB-4grcqnp8.js +1 -0
  122. package/dist/client/static/js/{pieDiagram-5QR66LMP-9zrtkdr2.js → pieDiagram-5QR66LMP-7h8dp0z3.js} +2 -2
  123. package/dist/client/static/js/properties-g6tpq003.js +1 -0
  124. package/dist/client/static/js/python-cy06fzhg.js +1 -0
  125. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-xq970vx1.js → quadrantDiagram-O4NWA36T-pteyxjxr.js} +2 -2
  126. package/dist/client/static/js/r-vw8berfv.js +1 -0
  127. package/dist/client/static/js/radar-RG4KPBEZ-7j9prhg1.js +1 -0
  128. package/dist/client/static/js/railroad-74A4TZTK-g8x2jps1.js +1 -0
  129. package/dist/client/static/js/railroad-abnf-HS5TGJTU-cbg7k68h.js +1 -0
  130. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-xfvjk9f8.js +1 -0
  131. package/dist/client/static/js/railroad-peg-WCYAUIDC-7w97805z.js +1 -0
  132. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-1g9jchbk.js → railroadDiagram-XR7U4H2S-68z9wdt0.js} +1 -1
  133. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-ntt088y4.js → requirementDiagram-PLB6GJNP-c08nmey6.js} +3 -3
  134. package/dist/client/static/js/{ruby-nn836rtq.js → ruby-ag3b3t9t.js} +1 -1
  135. package/dist/client/static/js/{rust-eygk56y5.js → rust-ke5ec0w5.js} +1 -1
  136. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-95k8c5v6.js → sankeyDiagram-IPEJSGJF-2r3kvjs5.js} +3 -3
  137. package/dist/client/static/js/{sass-c2bk03e4.js → sass-x0eez0kp.js} +1 -1
  138. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-qfvxrwfa.js → sequenceDiagram-PO4LG4MO-ctjycd88.js} +6 -6
  139. package/dist/client/static/js/{sizeCapture-INFHLROL-0m7dc5nd.js → sizeCapture-INFHLROL-97ndea95.js} +1 -1
  140. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-femwcn7n.js → stateDiagram-v2-GCMORJYK-aqnmsb96.js} +3 -3
  141. package/dist/client/static/js/{svelte-bfy1rq5g.js → svelte-tg19by0f.js} +1 -1
  142. package/dist/client/static/js/{swimlanes-2SLR337P-5n1qq48r.js → swimlanes-2SLR337P-v50cx1nx.js} +1 -1
  143. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-e227mz39.js +8 -0
  144. package/dist/client/static/js/{timeline-definition-EJHVYXUP-vdsj18be.js → timeline-definition-EJHVYXUP-1ggrtdcj.js} +4 -4
  145. package/dist/client/static/js/treeView-Q6P3EWNA-xhf1r6c3.js +1 -0
  146. package/dist/client/static/js/treemap-WGGIJYW6-4n3j7ekq.js +1 -0
  147. package/dist/client/static/js/tsx-3dzv8h6k.js +1 -0
  148. package/dist/client/static/js/typescript-44vs0wn4.js +1 -0
  149. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-psjbrprk.js → usecaseDiagram-POWQR4AR-ybcwhpzs.js} +19 -19
  150. package/dist/client/static/js/{vennDiagram-UO4OBE2U-4yn9kac9.js → vennDiagram-UO4OBE2U-p9ggrt07.js} +4 -4
  151. package/dist/client/static/js/{vue-0fwtgwj4.js → vue-mhj4sme0.js} +1 -1
  152. package/dist/client/static/js/wardley-WFR3VGLG-fb0py35r.js +1 -0
  153. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-js0tbpca.js → wardleyDiagram-VNRHLVJA-v79nb9kx.js} +2 -2
  154. package/dist/client/static/js/xml-yvv5fn3k.js +1 -0
  155. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-svr38ygh.js → xychartDiagram-PMCCYNJV-43thqscz.js} +2 -2
  156. package/dist/client/static/js/yaml-avewh7n5.js +1 -0
  157. package/marketplace/marketplace.json +7 -0
  158. package/marketplace/plugins/github-actions/README.md +142 -0
  159. package/marketplace/plugins/github-actions/icon.svg +12 -0
  160. package/marketplace/plugins/github-actions/package.json +30 -0
  161. package/marketplace/plugins/github-actions/settings-schema.json +27 -0
  162. package/marketplace/plugins/github-actions/src/app.tsx +32 -0
  163. package/marketplace/plugins/github-actions/src/panel/Actions.tsx +105 -0
  164. package/marketplace/plugins/github-actions/src/panel/LogView.tsx +76 -0
  165. package/marketplace/plugins/github-actions/src/panel/Row.tsx +59 -0
  166. package/marketplace/plugins/github-actions/src/panel/RunView.tsx +197 -0
  167. package/marketplace/plugins/github-actions/src/panel/format.ts +74 -0
  168. package/marketplace/plugins/github-actions/src/panel/index.test.tsx +86 -0
  169. package/marketplace/plugins/github-actions/src/panel/index.tsx +256 -0
  170. package/marketplace/plugins/github-actions/src/panel/picker.test.tsx +68 -0
  171. package/marketplace/plugins/github-actions/src/panel/test-fixtures.ts +98 -0
  172. package/marketplace/plugins/github-actions/src/panel/test-harness.tsx +175 -0
  173. package/marketplace/plugins/github-actions/src/protocol.ts +156 -0
  174. package/marketplace/plugins/github-actions/src/server/github.test.ts +264 -0
  175. package/marketplace/plugins/github-actions/src/server/github.ts +309 -0
  176. package/marketplace/plugins/github-actions/src/server/http.test.ts +150 -0
  177. package/marketplace/plugins/github-actions/src/server/http.ts +202 -0
  178. package/marketplace/plugins/github-actions/src/server/json.ts +44 -0
  179. package/marketplace/plugins/github-actions/src/server/logtext.test.ts +84 -0
  180. package/marketplace/plugins/github-actions/src/server/logtext.ts +59 -0
  181. package/marketplace/plugins/github-actions/src/server/progress.test.ts +96 -0
  182. package/marketplace/plugins/github-actions/src/server/progress.ts +62 -0
  183. package/marketplace/plugins/github-actions/src/server/remote.ts +84 -0
  184. package/marketplace/plugins/github-actions/src/server/scope.ts +51 -0
  185. package/marketplace/plugins/github-actions/src/server/token.ts +84 -0
  186. package/marketplace/plugins/github-actions/src/server.ts +163 -0
  187. package/marketplace/plugins/github-actions/src/state.test.ts +55 -0
  188. package/marketplace/plugins/github-actions/src/state.ts +63 -0
  189. package/marketplace/plugins/github-actions/tsconfig.json +16 -0
  190. package/package.json +1 -1
  191. package/src/client/components/mobile/RightSidebar.tsx +164 -66
  192. package/src/client/components/mobile/header-titlebar.test.tsx +92 -0
  193. package/src/client/components/mobile/mobile-right-sidebar/Chrome.tsx +179 -0
  194. package/src/client/components/mobile/panel-chips.test.tsx +12 -0
  195. package/src/client/components/mobile/panel-chips.tsx +5 -1
  196. package/src/client/components/mobile/right-drawer-nav.test.tsx +258 -0
  197. package/src/client/components/settings/apply-side-effects.ts +6 -0
  198. package/src/client/components/settings/categories/appearance-settings/PanelNavSection.tsx +123 -2
  199. package/src/client/components/workspace/panel-tabs/Home.tsx +14 -2
  200. package/src/client/components/workspace/panel-tabs/TabChip.tsx +173 -0
  201. package/src/client/components/workspace/panel-tabs/TabStrip.test.tsx +118 -0
  202. package/src/client/components/workspace/panel-tabs/TabStrip.tsx +89 -102
  203. package/src/client/components/workspace/panel-tabs/index.tsx +9 -1
  204. package/src/client/hooks/workspace/mobile-right-panel-nav.ts +63 -0
  205. package/src/client/hooks/workspace/panel-nav.test.ts +39 -1
  206. package/src/client/lib/ui/control-plate.ts +33 -0
  207. package/src/server/lib/bundler/titlebar-css.test.ts +5 -3
  208. package/src/shared/lib/settings/defaults.ts +2 -1
  209. package/src/shared/lib/workspace/panel-nav.test.ts +36 -0
  210. package/src/shared/lib/workspace/panel-nav.ts +43 -0
  211. package/src/shared/types/settings/state.ts +9 -1
  212. package/dist/client/static/js/LayoutWrapper-vw54s8ra.js +0 -2
  213. package/dist/client/static/js/architecture-7GRP2DOG-mq93vqx9.js +0 -1
  214. package/dist/client/static/js/bash-fjzhxy10.js +0 -1
  215. package/dist/client/static/js/cpp-9f6zkdd4.js +0 -1
  216. package/dist/client/static/js/css-y4y3qtsb.js +0 -1
  217. package/dist/client/static/js/cynefin-OW5HDTMX-qyg5rjr5.js +0 -1
  218. package/dist/client/static/js/eventmodeling-NTZA5JFV-15yz245z.js +0 -1
  219. package/dist/client/static/js/flowDiagram-KWPJA3E3-n1sapfye.js +0 -1
  220. package/dist/client/static/js/gitGraph-4MIJSDKK-xtjwv160.js +0 -1
  221. package/dist/client/static/js/graphql-amk52c95.js +0 -1
  222. package/dist/client/static/js/html-2y935m7r.js +0 -1
  223. package/dist/client/static/js/index-19ffgf9a.js +0 -2
  224. package/dist/client/static/js/index-204ae4vs.js +0 -2
  225. package/dist/client/static/js/index-n6fbd265.js +0 -1
  226. package/dist/client/static/js/index-sc7r305t.css +0 -1
  227. package/dist/client/static/js/info-A6RAGUB7-e31s2xvj.js +0 -1
  228. package/dist/client/static/js/ini-kemnmt16.js +0 -1
  229. package/dist/client/static/js/java-caqpfm88.js +0 -1
  230. package/dist/client/static/js/javascript-zegm06a1.js +0 -1
  231. package/dist/client/static/js/jsx-bvterpm5.js +0 -1
  232. package/dist/client/static/js/lua-1hcfm8ya.js +0 -1
  233. package/dist/client/static/js/markdown-n6na4ykv.js +0 -1
  234. package/dist/client/static/js/one-dark-pro-c1vnxka7.js +0 -1
  235. package/dist/client/static/js/one-light-mbxx52p5.js +0 -1
  236. package/dist/client/static/js/packet-AYTQ26CC-mtzmsrk4.js +0 -1
  237. package/dist/client/static/js/pie-WAS4IAKB-85nwadmj.js +0 -1
  238. package/dist/client/static/js/properties-nxcks67c.js +0 -1
  239. package/dist/client/static/js/python-58p0gqn0.js +0 -1
  240. package/dist/client/static/js/r-eyn8en0g.js +0 -1
  241. package/dist/client/static/js/radar-RG4KPBEZ-ae3jdajx.js +0 -1
  242. package/dist/client/static/js/railroad-74A4TZTK-3m0s7cse.js +0 -1
  243. package/dist/client/static/js/railroad-abnf-HS5TGJTU-pz22c3eb.js +0 -1
  244. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-cgqgqq15.js +0 -1
  245. package/dist/client/static/js/railroad-peg-WCYAUIDC-ts0nmcxb.js +0 -1
  246. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-n85hawg8.js +0 -8
  247. package/dist/client/static/js/treeView-Q6P3EWNA-fvpt3hm8.js +0 -1
  248. package/dist/client/static/js/treemap-WGGIJYW6-4z9s24je.js +0 -1
  249. package/dist/client/static/js/tsx-fnzxsv25.js +0 -1
  250. package/dist/client/static/js/typescript-0ppbqrb6.js +0 -1
  251. package/dist/client/static/js/wardley-WFR3VGLG-73mrhkmy.js +0 -1
  252. package/dist/client/static/js/xml-v1ytr8qz.js +0 -1
  253. package/dist/client/static/js/yaml-txrqz62t.js +0 -1
@@ -0,0 +1 @@
1
+ import{qn,zo,rf,As,Ai,hl,fd,bl,_g,gd,af,of,sf,lf,Gh,yl,Ad,jh,hd,Nr,qh}from"./index-xkwybnf3.js";export{bl as IndentContext,qh as StreamLanguage,hd as bracketMatching,yl as codeFolding,sf as foldAll,af as foldCode,Ad as foldGutter,Gh as foldKeymap,gd as foldService,Ai as getIndentUnit,fd as getIndentation,jh as highlightingFor,_g as indentOnInput,rf as indentService,hl as indentString,As as indentUnit,zo as language,Nr as matchBrackets,qn as syntaxTree,lf as unfoldAll,of as unfoldCode};
@@ -1,2 +1,2 @@
1
- import{d,n,o,i,a,e,m,F,en,ba,Fe,P,D,$n,b,je,Se,_,RA,Zp,Vu,FA,sc}from"./index-cq98p2rb.js";import{wu}from"./index-6t21c6jt.js";import"./index-ehacfgwm.js";var $e={idle:"Kosong",loading:"Memuat",ready:"Siap"},ee="p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors";function ae({url:t,input:r,loading:s,error:l,canGoBack:c,canGoForward:u,viewportMode:f,zoomLevel:p,onInputChange:g,onSubmit:y,onBack:L,onForward:S,onReload:w,onOpenExternal:B,onIncludeInChat:h,onChangeViewport:z,onZoomIn:E,onZoomOut:R,onResetZoom:x,onSetZoom:T,annotate:I,focusKey:k}){let O=i(void 0),G=i(null),V=i(null);o(()=>{if(O.current===t)return;O.current=t;let v=V.current;if(V.current=null,!t)return;if(v!==null&&v!==r)return;g(t)},[t,r,g]);let N=i(k);o(()=>{if(k===void 0||N.current===k)return;if(N.current=k,t)return;G.current?.focus()},[k,t]);let A=(v)=>{V.current=v,g(v)},M=!t?"idle":s?"loading":"ready",U=M==="ready"?"bg-success animate-pulse":M==="loading"?"bg-ink/40 animate-pulse":"bg-ink/25",Y=e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 flex-shrink-0",children:[e("button",{type:"button",onClick:L,disabled:!c,"aria-label":"Back",title:"Back",className:ee,children:e(en,{size:12})}),e("button",{type:"button",onClick:S,disabled:!u,"aria-label":"Maju",title:"Maju",className:ee,children:e(ba,{size:12})}),e("button",{type:"button",onClick:w,disabled:!t,"aria-label":"Reload",title:"Reload",className:ee,children:e(D,{size:12,className:s?"animate-spin":void 0})})]});return e(wu,{twoRows:!0,url:t,statusDotClass:U,statusLabel:$e[M],viewportMode:f,zoomLevel:p,onChangeViewport:z,onZoomIn:E,onZoomOut:R,onResetZoom:x,onSetZoom:T,annotate:I,onIncludeInChat:h,onOpenExternal:B,openExternalLabel:"Buka di tab baru",openExternalTitle:"Buka di tab baru (untuk situs yang menolak iframe)",children:e("div",{className:"flex items-center flex-1 min-w-0 space-x-1.5",children:[Y,e("form",{className:`flex-1 min-w-0 flex items-center bg-canvas border rounded-md px-2 py-1 space-x-1 focus-within:border-ink/40 ${l?"border-error":"border-ink/15"}`,onSubmit:(v)=>{v.preventDefault(),y(r)},children:[e(Fe,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{ref:G,type:"text",value:r,onChange:(v)=>A(v.currentTarget.value),placeholder:"Type an address (e.g. localhost:5173) and press Enter…","aria-label":"Browser address","aria-invalid":l!==void 0&&l!==null,title:l??void 0,spellcheck:!1,autoComplete:"off",className:`w-full min-w-0 bg-transparent outline-none font-mono text-[11px] placeholder:text-ink/35 ${l?"text-error":"text-ink/90"}`})]})]})})}var ie={"desktop-16-9":"w-full max-w-[1280px] aspect-video max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",laptop:"w-[1024px] max-w-full h-[768px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",tablet:"w-[768px] max-w-full h-[1024px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",mobile:"w-[375px] max-w-full h-[667px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto","mobile-lg":"w-[414px] max-w-full h-[896px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto",responsive:"w-full h-full border-0"};function le(t){let r=t.trim();if(!r)return"";try{let s=new URL(r),l=s.pathname==="/"?"":s.pathname;return`${s.hostname}${l}`.slice(0,64)}catch{return r.slice(0,64)}}var W=12,ce=60,Oe=8192,de=0;function Z(){return de+=1,`tab-${Date.now().toString(36)}-${de}`}function j(t,r=""){return r?{id:t,history:[r],index:0,frameKey:0}:{id:t,history:[],index:-1,frameKey:0}}function K(t){if(!t||t.index<0)return"";return t.history[t.index]??""}function te(t){return Boolean(t)&&t.index>0}function ne(t){return Boolean(t)&&t.index>=0&&t.index<t.history.length-1}function ue(t,r){if(K(t)===r)return re(t);let s=[...t.history.slice(0,t.index+1),r],l=Math.max(0,s.length-ce),c=l>0?s.slice(l):s;return{...t,history:c,index:c.length-1,frameKey:t.frameKey+1}}function oe(t,r){let s=t.index+r;if(s<0||s>=t.history.length)return t;return{...t,index:s}}function re(t){return{...t,frameKey:t.frameKey+1}}function pe(t,r,s){let l=t.findIndex((f)=>f.id===s);if(l===-1)return{tabs:t,activeId:r};let c=t.filter((f)=>f.id!==s);if(r!==s)return{tabs:c,activeId:r};let u=c[Math.min(l,c.length-1)]??null;return{tabs:c,activeId:u?u.id:null}}function me(t,r){return t.find((s)=>s.id===r)??t[t.length-1]??null}function ze(t){if(!Array.isArray(t))return[];let r=[];for(let s of t){if(typeof s!=="string")continue;let l=s.trim();if(!l||l.length>Oe)continue;if(r.push(l),r.length>=ce)break}return r}function se(t){if(!Array.isArray(t))return[];let r=[],s=new Set;for(let l of t){if(typeof l!=="object"||l===null)continue;let c=l,u=typeof c.id==="string"?c.id.trim():"";if(!u||s.has(u))continue;let f=ze(c.history),p=typeof c.index==="number"&&Number.isFinite(c.index)?Math.trunc(c.index):-1,g=f.length===0?-1:Math.min(f.length-1,Math.max(0,p===-1?0:p)),y=typeof c.frameKey==="number"&&Number.isFinite(c.frameKey)?Math.trunc(c.frameKey):0;if(s.add(u),r.push({id:u,history:f,index:g,frameKey:Math.max(0,y)}),r.length>=W)break}return r}function fe(t){return le(K(t))||"Tab baru"}var Ke="clipboard-read; clipboard-write; fullscreen";function he({tabs:t,activeTabId:r,loadingTabId:s,viewportMode:l,zoomLevel:c,onLoad:u,active:f=!0,overlay:p,onFrame:g}){let y=i(new Map),L=t.map((w)=>`${w.id}:${w.frameKey}`).join("|");if(o(()=>{g?.(r?y.current.get(r)??null:null)},[r,g,L]),!f)return null;let S=t.filter((w)=>K(w)!=="");if(S.length===0)return e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none",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(Fe,{size:22})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Browser Anda"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"Type an address above and press Enter. The page loads inside this panel."}),e("p",{className:"text-[11px] text-ink/45 max-w-sm mt-2",children:"Sebagian situs (Google, GitHub) menolak ditampilkan dalam iframe — pakai tombol buka di tab baru."})]});return e("div",{className:"flex-1 min-h-0 relative flex items-center justify-center p-2 overflow-auto bg-canvas/60",children:S.map((w)=>{let B=K(w),h=w.id===r,z=w.id===s;return e("div",{"data-user-browser-tab":w.id,className:h?"relative flex-1 min-h-0 flex items-center justify-center":"hidden",children:[z?e("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:e("div",{className:"flex items-center space-x-2 px-3 py-1.5 rounded-md bg-paper border border-ink/15",children:[e(m,{size:13,className:"animate-spin text-ink/50"}),e("span",{className:"text-[11px] font-mono text-ink/60",children:"Memuat…"})]})}):null,e("div",{className:`relative flex flex-col bg-white ${ie[l]} transition-all duration-200`,style:{zoom:c!==100?`${c}%`:void 0,transformOrigin:"top center"},children:[e("iframe",{ref:(E)=>{if(E)y.current.set(w.id,E);else y.current.delete(w.id)},src:B,title:`Browser pengguna ${w.id}`,onLoad:()=>u(w.id),referrerPolicy:"no-referrer",allow:Ke,className:"w-full h-full bg-white border-0",style:h&&p?{pointerEvents:"none"}:void 0},`${w.id}:${w.frameKey}`),h?p:null]})]},w.id)})})}var be="cursor-pointer transition-colors";function ge({tabs:t,activeTabId:r,canOpenTab:s,onSelect:l,onClose:c,onNewTab:u}){let f=i(null);return o(()=>{f.current?.scrollIntoView({block:"nearest",inline:"nearest"})},[r,t.length]),e("div",{"data-toolbar-band":"strip",className:"h-8 px-1.5 border-b border-ink/10 bg-paper flex items-center gap-1 flex-shrink-0 select-none",children:[e("div",{className:"flex-1 min-w-0 flex items-center gap-1 overflow-x-auto",children:t.map((p)=>{let g=p.id===r,y=fe(p),L=K(p);return e("div",{ref:g?f:void 0,className:`group flex items-center rounded border flex-shrink-0 ${g?"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:()=>l(p.id),"aria-pressed":g,"aria-label":`Tab ${y}`,title:L?`${y}
2
- ${L}`:y,className:`pl-2 pr-1 py-0.5 text-[11px] font-mono max-w-[150px] truncate ${be}`,children:y}),e("button",{type:"button",onClick:()=>c(p.id),"aria-label":`Tutup tab ${y}`,title:`Tutup tab ${y}`,className:`mr-0.5 p-1 rounded hover:bg-error hover:text-paper ${be} ${g?"text-on-ink-muted":"text-ink/40 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,children:e(b,{size:11})})]},p.id)})}),e("button",{type:"button",onClick:u,disabled:!s,"aria-label":"Tab baru",title:s?"Tab baru":`Maksimal ${W} tab`,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink disabled:opacity-30 disabled:hover:bg-transparent disabled:cursor-not-allowed cursor-pointer transition-colors flex-shrink-0",children:e(P,{size:13})})]})}var xe="w-full min-w-0 bg-canvas border border-ink/15 rounded px-2 py-1 text-[11px] font-mono text-ink placeholder:text-ink/35 focus:outline-none focus:border-ink/40";function He(t){if(!t||t.ok)return null;if(t.reason==="cross-origin")return"This page is cross-origin, so its elements cannot be read. Name the part and add a note instead.";if(t.reason==="no-frame")return"The page has not loaded, so its elements cannot be read yet.";return"There is no element at this point (empty space). Name the part instead."}function we({shape:t,index:r,readability:s,onLabel:l,onNote:c}){let u=He(s),f=t.element;return e("div",{className:"flex items-start gap-1.5 min-w-0",children:[e("span",{className:"text-[11px] font-mono text-ink/45 pt-1 flex-shrink-0",children:[Vu[t.tool]," #",r]}),e("div",{className:"flex-1 min-w-0 space-y-1",children:[e("div",{className:"flex items-center gap-1 flex-wrap",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/40",children:"bagian"}),FA.map((p)=>{let g=t.label===p;return e("button",{type:"button",onClick:()=>l(g?"":p),"aria-pressed":g,className:`px-1.5 py-0.5 rounded-full border text-[10px] font-mono transition-colors cursor-pointer ${g?"bg-ink text-canvas border-ink":"bg-canvas text-ink/65 border-ink/15 hover:border-ink/40"}`,children:p},p)}),e("input",{value:t.label,onInput:(p)=>l(p.currentTarget.value),placeholder:"or type your own…","aria-label":"Name of the marked part",spellcheck:!1,className:`${xe} flex-1 min-w-[110px]`})]}),e("textarea",{value:t.note,onInput:(p)=>c(p.currentTarget.value),placeholder:"What is wrong with this part? (e.g. the Pay button looks disabled)",rows:2,"aria-label":"Annotation note",className:`${xe} resize-y`}),f?e("p",{className:"text-[10px] font-mono text-ink/45 truncate",title:f.path,children:["elemen: ",f.path,f.state?` · ${f.state}`:""]}):null,u?e("p",{className:"text-[10px] text-ink/40",children:u}):null]})]})}var De=["box","pin","arrow"],Ge="px-2 py-1 rounded text-[11px] font-mono border transition-colors cursor-pointer",q="flex items-center gap-1 px-2 py-1 rounded text-[11px] border border-ink/15 hover:border-ink/40 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";function ve({tool:t,shapes:r,selectedId:s,readability:l,onTool:c,onLabel:u,onNote:f,onRemove:p,onReset:g,onCancel:y,onSend:L}){let S=r.find((B)=>B.id===s)??null,w=r.length>0;return e("div",{className:"flex-shrink-0 border-b border-ink/10 bg-paper px-2.5 py-1.5 space-y-1.5 select-none",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/50 mr-1",children:"Anotasi"}),De.map((B)=>e("button",{type:"button",onClick:()=>c(B),"aria-pressed":t===B,className:`${Ge} ${t===B?"bg-ink text-canvas border-ink":"bg-canvas text-ink/70 border-ink/15 hover:border-ink/40"}`,children:Vu[B]},B)),e("span",{className:"text-[11px] font-mono text-ink/45 ml-1",children:r.length>0?`${r.length} mark${r.length===1?"":"s"}`:"drag on the page to mark a part"}),e("div",{className:"flex-1"}),e("button",{type:"button",onClick:g,disabled:!w,className:q,title:"Clear all marks",children:[e(F,{size:12})," Bersihkan"]}),e("button",{type:"button",onClick:L,disabled:!w,className:q,title:"Kirim anotasi ke draft chat",children:[e($n,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:y,className:q,title:"Tutup mode anotasi",children:e(b,{size:12})})]}),S?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(we,{shape:S,index:r.indexOf(S)+1,readability:l,onLabel:(B)=>u(S.id,B),onNote:(B)=>f(S.id,B)})}),e("button",{type:"button",onClick:()=>p(S.id),className:q,title:"Remove this mark",children:e(F,{size:12})})]}):e("p",{className:"text-[11px] text-ink/45",children:"This page cannot be screenshotted, so what gets sent is the area, the part name and your note."})]})}var ye=0;function Te(){return ye+=1,`annot-${Date.now().toString(36)}-${ye}`}function ke(t){let[r,s]=n(!1),[l,c]=n("box"),[u,f]=n([]),[p,g]=n(null);o(()=>{f([]),g(null)},[t]);let y=a(()=>{s((E)=>!E),g(null)},[]),L=a(()=>{g(null),s(!1)},[]),S=a((E)=>{f((R)=>[...R,E]),g(E.id)},[]),w=a((E,R)=>{f((x)=>x.map((T)=>T.id===E?{...T,note:R}:T))},[]),B=a((E,R)=>{f((x)=>x.map((T)=>T.id===E?{...T,label:R}:T))},[]),h=a((E)=>{f((R)=>R.filter((x)=>x.id!==E)),g((R)=>R===E?null:R)},[]),z=a(()=>{f([]),g(null)},[]);return{active:r,tool:l,shapes:u,selectedId:p,setTool:c,toggle:y,close:L,add:S,setNote:w,setLabel:B,select:g,remove:h,reset:z}}var Ve=4,X="var(--theme-error)";function Ae({shapes:t,tool:r,selectedId:s,onMeasure:l,onAdd:c,onSelect:u}){let f=i(null),p=i(null),[g,y]=n(null),[L,S]=n({width:0,height:0});o(()=>{let x=f.current;if(!x)return;let T=()=>{let k=x.getBoundingClientRect();if(k.width<=0||k.height<=0)return;S((O)=>O.width===k.width&&O.height===k.height?O:{width:k.width,height:k.height}),l({width:k.width,height:k.height})};if(T(),typeof ResizeObserver!=="function")return;let I=new ResizeObserver(T);return I.observe(x),()=>I.disconnect()},[l]);let w=(x)=>{let T=f.current;if(!T)return null;let I=T.getBoundingClientRect(),k={x:x.clientX-I.left,y:x.clientY-I.top};return{normalized:RA(I,k),px:k.x,py:k.y}},B=(x)=>{if(x.button!==0)return;let T=w(x);if(!T)return;x.preventDefault(),u(null),x.currentTarget.setPointerCapture?.(x.pointerId);let I={id:Te(),tool:r,start:T.normalized,end:T.normalized,label:"",note:""};p.current=I,y(I)},h=(x)=>{let T=p.current;if(!T)return;let I=w(x);if(!I)return;let k={...T,end:I.normalized};p.current=k,y(k)},z=(x)=>{let T=p.current;if(!T)return;let I=w(x),k=I?{...T,end:I.normalized}:T;if(p.current=null,y(null),x.currentTarget.releasePointerCapture?.(x.pointerId),k.tool!=="pin"){let O=f.current?.getBoundingClientRect();if((O?Math.hypot((k.end.x-k.start.x)*O.width,(k.end.y-k.start.y)*O.height):0)<Ve)return}c(k)},E=()=>{p.current=null,y(null)},R=g?[...t,g]:t;return e("div",{ref:f,className:"absolute inset-0 cursor-crosshair touch-none",onPointerDown:B,onPointerMove:h,onPointerUp:z,onPointerCancel:E,children:e("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${Math.max(1,L.width)} ${Math.max(1,L.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:R.map((x,T)=>e(Xe,{shape:x,index:T+1,box:L,selected:x.id===s,onSelect:()=>u(x.id)},x.id))})})}function Xe({shape:t,index:r,box:s,selected:l,onSelect:c}){let u={x:t.start.x*s.width,y:t.start.y*s.height},f={x:t.end.x*s.width,y:t.end.y*s.height},p=Zp(t),g=l?3:2,y=String(r);return e("g",{onPointerDown:(S)=>{S.stopPropagation(),S.preventDefault(),c()},className:"cursor-pointer",children:[t.tool==="box"&&e("rect",{x:p.x*s.width,y:p.y*s.height,width:Math.max(1,p.width*s.width),height:Math.max(1,p.height*s.height),fill:X,fillOpacity:l?0.16:0.1,stroke:X,strokeWidth:g,vectorEffect:"non-scaling-stroke",rx:3}),t.tool==="arrow"&&e(d,{children:[e("line",{x1:u.x,y1:u.y,x2:f.x,y2:f.y,stroke:X,strokeWidth:g,vectorEffect:"non-scaling-stroke"}),e("circle",{cx:f.x,cy:f.y,r:4,fill:X})]}),t.tool==="pin"&&e("circle",{cx:u.x,cy:u.y,r:7,fill:X,fillOpacity:l?0.5:0.3,stroke:X,strokeWidth:g}),e("circle",{cx:u.x,cy:u.y,r:9,fill:X}),e("text",{x:u.x,y:u.y,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:700,fill:"var(--theme-paper)",children:y})]})}function Be(t){let r=t.trim();if(!r)return r;let s=/^[a-z][a-z0-9+.-]*:/i.test(r)?r:`https://${r}`,l=new URL(s);if(l.protocol!=="http:"&&l.protocol!=="https:")throw Error("Only http and https URLs are allowed");return l.toString()}var Ee="userBrowser.tabs",Ne="userBrowser.activeTabId",We="userBrowser.inputUrl",Ze="userBrowser.history",Ye="userBrowser.historyIndex";function Me(){let[t,r]=_(Ee,[]),[s,l]=_(Ne,null),[c,u]=_(We,""),[f,p]=n(null),[g,y]=n(void 0),{sessionId:L,ready:S}=je(),w=i(null),B=(N,A)=>Se(L,N)??A,h=me(t,s),z=K(h);o(()=>{if(!S||w.current===L)return;w.current=L;let N=B(Ee,[]),A=se(N);if(A.length>0){if(JSON.stringify(A)!==JSON.stringify(N))r(A);let Y=B(Ne,null);if(!A.some((v)=>v.id===Y))l(A[A.length-1].id);return}let[M]=se([{id:Z(),history:B(Ze,[]),index:B(Ye,-1),frameKey:0}]),U=M&&M.history.length>0?M:j(Z());r([U]),l(U.id)},[S,L,r,l]);let E=a((N,A)=>{r((M)=>M.map((U)=>U.id===N?A(U):U))},[r]),R=a((N)=>{let A=N.trim();if(!A)return;let M;try{M=Be(A)}catch(U){y(U instanceof Error?U.message:"Alamat tidak valid");return}if(y(void 0),u(M),!h){let U=j(Z(),M);r([U]),l(U.id),p(U.id);return}p(h.id),E(h.id,(U)=>ue(U,M))},[h,l,u,r,E]),x=a(()=>{if(!h||!te(h))return;p(h.id),E(h.id,(N)=>oe(N,-1))},[h,E]),T=a(()=>{if(!h||!ne(h))return;p(h.id),E(h.id,(N)=>oe(N,1))},[h,E]),I=a(()=>{if(!h||!z)return;p(h.id),E(h.id,re)},[h,z,E]),k=a((N)=>{p((A)=>A===N?null:A)},[]),O=a(()=>{if(t.length>=W)return;let N=j(Z());r((A)=>[...A,N]),l(N.id),u(""),y(void 0)},[l,u,r,t.length]),G=a((N)=>{let A=t.find((M)=>M.id===N);if(!A)return;l(N),u(K(A)),y(void 0)},[l,u,t]),V=a((N)=>{let A=pe(t,s,N);if(A.tabs.length===0){let M=j(Z());r([M]),l(M.id),u("");return}if(r(A.tabs),A.activeId!==s){l(A.activeId);let M=A.tabs.find((U)=>U.id===A.activeId);u(K(M)),y(void 0)}},[s,l,u,r,t]);return{tabs:t,activeTab:h,activeTabId:h?.id??null,url:z,input:c,setInput:u,frameKey:h?.frameKey??0,loading:f!==null&&f===h?.id,error:g,canGoBack:te(h),canGoForward:ne(h),canOpenTab:t.length<W,submit:R,goBack:x,goForward:T,reload:I,markLoaded:k,openTab:O,selectTab:G,closeTab:V}}function qe(t){if(!t)return"no-frame";try{return t.contentDocument?"readable":"cross-origin"}catch{return"cross-origin"}}function J(t){let r=t.replace(/\s+/g," ").trim();return r.length>60?`${r.slice(0,59)}…`:r}function Je(t){let r=t.tagName.toLowerCase();if(t.id)return`${r}#${t.id}`;for(let l of["data-testid","data-test","aria-label"]){let c=t.getAttribute(l);if(c)return`${r}[${l}="${J(c)}"]`}let s=t.getAttribute("role");if(s)return`${r}[role="${s}"]`;return r}function Qe(t){let r=[],s=t;while(s&&r.length<4){if(s.tagName.toLowerCase()==="html")break;r.unshift(Je(s)),s=s.parentElement}return r.join(" > ")}function et(t){let r=[];if(t.disabled)r.push("nonaktif");if(t instanceof HTMLSelectElement||t.tagName.toLowerCase()==="select"){let s=t,c=s.selectedOptions?.[0]?.textContent?.trim()||s.value;if(c)r.push(`nilai "${J(c)}"`);let u=s.options?.length??0;if(u>0)r.push(`${u} opsi`)}else if(t.tagName.toLowerCase()==="input"){let s=t;if(s.type)r.push(`tipe ${s.type}`);if(s.type!=="password"&&s.placeholder)r.push(`placeholder "${J(s.placeholder)}"`)}return r.length>0?r.join(", "):void 0}function tt(t){let r={path:Qe(t),tag:t.tagName.toLowerCase()},s=t.getAttribute("role");if(s)r.role=s;let l=J(t.innerText??t.textContent??"");if(l)r.text=l;let c=et(t);if(c)r.state=c;return r}function Le(t,r){let s=qe(t);if(s!=="readable")return{ok:!1,reason:s};let{contentWindow:l,contentDocument:c}=t;if(!l||!c)return{ok:!1,reason:"cross-origin"};try{let u=Math.min(Math.max(r.x,0),1)*l.innerWidth,f=Math.min(Math.max(r.y,0),1)*l.innerHeight,p=c.elementFromPoint(u,f);if(!p||p===c.documentElement||p===c.body)return{ok:!1,reason:"no-element"};return{ok:!0,element:tt(p)}}catch{return{ok:!1,reason:"cross-origin"}}}function rn({className:t="",active:r=!0}){let[s,l]=_("userBrowser.viewportMode","responsive"),[c,u]=_("userBrowser.zoomLevel",100),[f,p]=n(null),[g,y]=n(null),[L,S]=n(null),{tabs:w,activeTabId:B,url:h,input:z,setInput:E,loading:R,error:x,canGoBack:T,canGoForward:I,canOpenTab:k,submit:O,goBack:G,goForward:V,reload:N,markLoaded:A,openTab:M,selectTab:U,closeTab:Y}=Me(),v=ke(`${B??""}:${w.find((C)=>C.id===B)?.frameKey??0}`),Ie=a(()=>{if(!h)return;window.open(h,"_blank","noopener,noreferrer")},[h]),Ue=a(()=>{if(!h)return;sc({url:h})},[h]),Re=a((C)=>{p((H)=>H&&H.width===C.width&&H.height===C.height?H:C)},[]),Pe=a((C)=>{let H=Le(g,C.start);S(H),v.add(H.ok?{...C,element:H.element}:C)},[v,g]),Ce=a(()=>{if(!h||v.shapes.length===0)return;let C=c/100;sc({url:h,annotations:v.shapes,panel:{width:(f?.width??0)/C,height:(f?.height??0)/C,viewportMode:s,zoom:c}}),v.close()},[h,v,f,s,c]),Q=v.active&&Boolean(h),_e=R?B??null:null;return e("div",{"data-user-browser-panel":"",className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,children:[e(ge,{tabs:w,activeTabId:B,canOpenTab:k,onSelect:U,onClose:Y,onNewTab:M}),e(ae,{url:h,input:z,loading:R,error:x,canGoBack:T,canGoForward:I,viewportMode:s,zoomLevel:c,onInputChange:E,onSubmit:O,onBack:G,onForward:V,onReload:N,onOpenExternal:Ie,onIncludeInChat:Ue,onChangeViewport:l,onZoomIn:()=>u((C)=>Math.min(200,C+10)),onZoomOut:()=>u((C)=>Math.max(50,C-10)),onResetZoom:()=>u(100),onSetZoom:u,focusKey:B??void 0,annotate:{active:Q,count:v.shapes.length,onToggle:v.toggle}}),Q&&e(ve,{tool:v.tool,shapes:v.shapes,selectedId:v.selectedId,readability:L,onTool:v.setTool,onLabel:v.setLabel,onNote:v.setNote,onRemove:v.remove,onReset:v.reset,onCancel:v.close,onSend:Ce}),e(he,{tabs:w,activeTabId:B,loadingTabId:_e,viewportMode:s,zoomLevel:c,onLoad:A,onFrame:y,active:r,overlay:Q?e(Ae,{shapes:v.shapes,tool:v.tool,selectedId:v.selectedId,onMeasure:Re,onAdd:Pe,onSelect:v.select}):null})]})}export{rn as UserBrowserPanel};
1
+ import{d,n,o,i,a,e,m,L,tn,ba,Fe,P,D,$n,b,Oe,Ce,_,zA,nm,Xu,UA,uc}from"./index-xkwybnf3.js";import{Iu}from"./index-34ff2vq6.js";import"./index-r6e44vkx.js";var $e={idle:"Kosong",loading:"Memuat",ready:"Siap"},ee="p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors";function ae({url:t,input:r,loading:s,error:l,canGoBack:c,canGoForward:u,viewportMode:f,zoomLevel:p,onInputChange:g,onSubmit:y,onBack:I,onForward:S,onReload:w,onOpenExternal:B,onIncludeInChat:h,onChangeViewport:F,onZoomIn:E,onZoomOut:C,onResetZoom:x,onSetZoom:T,annotate:U,focusKey:k}){let z=i(void 0),G=i(null),V=i(null);o(()=>{if(z.current===t)return;z.current=t;let v=V.current;if(V.current=null,!t)return;if(v!==null&&v!==r)return;g(t)},[t,r,g]);let N=i(k);o(()=>{if(k===void 0||N.current===k)return;if(N.current=k,t)return;G.current?.focus()},[k,t]);let A=(v)=>{V.current=v,g(v)},M=!t?"idle":s?"loading":"ready",R=M==="ready"?"bg-success animate-pulse":M==="loading"?"bg-ink/40 animate-pulse":"bg-ink/25",Y=e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 flex-shrink-0",children:[e("button",{type:"button",onClick:I,disabled:!c,"aria-label":"Back",title:"Back",className:ee,children:e(tn,{size:12})}),e("button",{type:"button",onClick:S,disabled:!u,"aria-label":"Maju",title:"Maju",className:ee,children:e(ba,{size:12})}),e("button",{type:"button",onClick:w,disabled:!t,"aria-label":"Reload",title:"Reload",className:ee,children:e(D,{size:12,className:s?"animate-spin":void 0})})]});return e(Iu,{twoRows:!0,url:t,statusDotClass:R,statusLabel:$e[M],viewportMode:f,zoomLevel:p,onChangeViewport:F,onZoomIn:E,onZoomOut:C,onResetZoom:x,onSetZoom:T,annotate:U,onIncludeInChat:h,onOpenExternal:B,openExternalLabel:"Buka di tab baru",openExternalTitle:"Buka di tab baru (untuk situs yang menolak iframe)",children:e("div",{className:"flex items-center flex-1 min-w-0 space-x-1.5",children:[Y,e("form",{className:`flex-1 min-w-0 flex items-center bg-canvas border rounded-md px-2 py-1 space-x-1 focus-within:border-ink/40 ${l?"border-error":"border-ink/15"}`,onSubmit:(v)=>{v.preventDefault(),y(r)},children:[e(Fe,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{ref:G,type:"text",value:r,onChange:(v)=>A(v.currentTarget.value),placeholder:"Type an address (e.g. localhost:5173) and press Enter…","aria-label":"Browser address","aria-invalid":l!==void 0&&l!==null,title:l??void 0,spellcheck:!1,autoComplete:"off",className:`w-full min-w-0 bg-transparent outline-none font-mono text-[11px] placeholder:text-ink/35 ${l?"text-error":"text-ink/90"}`})]})]})})}var ie={"desktop-16-9":"w-full max-w-[1280px] aspect-video max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",laptop:"w-[1024px] max-w-full h-[768px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",tablet:"w-[768px] max-w-full h-[1024px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",mobile:"w-[375px] max-w-full h-[667px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto","mobile-lg":"w-[414px] max-w-full h-[896px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto",responsive:"w-full h-full border-0"};function le(t){let r=t.trim();if(!r)return"";try{let s=new URL(r),l=s.pathname==="/"?"":s.pathname;return`${s.hostname}${l}`.slice(0,64)}catch{return r.slice(0,64)}}var W=12,ce=60,ze=8192,de=0;function Z(){return de+=1,`tab-${Date.now().toString(36)}-${de}`}function j(t,r=""){return r?{id:t,history:[r],index:0,frameKey:0}:{id:t,history:[],index:-1,frameKey:0}}function K(t){if(!t||t.index<0)return"";return t.history[t.index]??""}function te(t){return Boolean(t)&&t.index>0}function ne(t){return Boolean(t)&&t.index>=0&&t.index<t.history.length-1}function ue(t,r){if(K(t)===r)return re(t);let s=[...t.history.slice(0,t.index+1),r],l=Math.max(0,s.length-ce),c=l>0?s.slice(l):s;return{...t,history:c,index:c.length-1,frameKey:t.frameKey+1}}function oe(t,r){let s=t.index+r;if(s<0||s>=t.history.length)return t;return{...t,index:s}}function re(t){return{...t,frameKey:t.frameKey+1}}function pe(t,r,s){let l=t.findIndex((f)=>f.id===s);if(l===-1)return{tabs:t,activeId:r};let c=t.filter((f)=>f.id!==s);if(r!==s)return{tabs:c,activeId:r};let u=c[Math.min(l,c.length-1)]??null;return{tabs:c,activeId:u?u.id:null}}function me(t,r){return t.find((s)=>s.id===r)??t[t.length-1]??null}function Ke(t){if(!Array.isArray(t))return[];let r=[];for(let s of t){if(typeof s!=="string")continue;let l=s.trim();if(!l||l.length>ze)continue;if(r.push(l),r.length>=ce)break}return r}function se(t){if(!Array.isArray(t))return[];let r=[],s=new Set;for(let l of t){if(typeof l!=="object"||l===null)continue;let c=l,u=typeof c.id==="string"?c.id.trim():"";if(!u||s.has(u))continue;let f=Ke(c.history),p=typeof c.index==="number"&&Number.isFinite(c.index)?Math.trunc(c.index):-1,g=f.length===0?-1:Math.min(f.length-1,Math.max(0,p===-1?0:p)),y=typeof c.frameKey==="number"&&Number.isFinite(c.frameKey)?Math.trunc(c.frameKey):0;if(s.add(u),r.push({id:u,history:f,index:g,frameKey:Math.max(0,y)}),r.length>=W)break}return r}function fe(t){return le(K(t))||"Tab baru"}var He="clipboard-read; clipboard-write; fullscreen";function he({tabs:t,activeTabId:r,loadingTabId:s,viewportMode:l,zoomLevel:c,onLoad:u,active:f=!0,overlay:p,onFrame:g}){let y=i(new Map),I=t.map((w)=>`${w.id}:${w.frameKey}`).join("|");if(o(()=>{g?.(r?y.current.get(r)??null:null)},[r,g,I]),!f)return null;let S=t.filter((w)=>K(w)!=="");if(S.length===0)return e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none",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(Fe,{size:22})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Browser Anda"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"Type an address above and press Enter. The page loads inside this panel."}),e("p",{className:"text-[11px] text-ink/45 max-w-sm mt-2",children:"Sebagian situs (Google, GitHub) menolak ditampilkan dalam iframe — pakai tombol buka di tab baru."})]});return e("div",{className:"flex-1 min-h-0 relative flex items-center justify-center p-2 overflow-auto bg-canvas/60",children:S.map((w)=>{let B=K(w),h=w.id===r,F=w.id===s;return e("div",{"data-user-browser-tab":w.id,className:h?"relative flex-1 min-h-0 flex items-center justify-center":"hidden",children:[F?e("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:e("div",{className:"flex items-center space-x-2 px-3 py-1.5 rounded-md bg-paper border border-ink/15",children:[e(m,{size:13,className:"animate-spin text-ink/50"}),e("span",{className:"text-[11px] font-mono text-ink/60",children:"Memuat…"})]})}):null,e("div",{className:`relative flex flex-col bg-white ${ie[l]} transition-all duration-200`,style:{zoom:c!==100?`${c}%`:void 0,transformOrigin:"top center"},children:[e("iframe",{ref:(E)=>{if(E)y.current.set(w.id,E);else y.current.delete(w.id)},src:B,title:`Browser pengguna ${w.id}`,onLoad:()=>u(w.id),referrerPolicy:"no-referrer",allow:He,className:"w-full h-full bg-white border-0",style:h&&p?{pointerEvents:"none"}:void 0},`${w.id}:${w.frameKey}`),h?p:null]})]},w.id)})})}var be="cursor-pointer transition-colors";function ge({tabs:t,activeTabId:r,canOpenTab:s,onSelect:l,onClose:c,onNewTab:u}){let f=i(null);return o(()=>{f.current?.scrollIntoView({block:"nearest",inline:"nearest"})},[r,t.length]),e("div",{"data-toolbar-band":"strip",className:"h-8 px-1.5 border-b border-ink/10 bg-paper flex items-center gap-1 flex-shrink-0 select-none",children:[e("div",{className:"flex-1 min-w-0 flex items-center gap-1 overflow-x-auto",children:t.map((p)=>{let g=p.id===r,y=fe(p),I=K(p);return e("div",{ref:g?f:void 0,className:`group flex items-center rounded border flex-shrink-0 ${g?"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:()=>l(p.id),"aria-pressed":g,"aria-label":`Tab ${y}`,title:I?`${y}
2
+ ${I}`:y,className:`pl-2 pr-1 py-0.5 text-[11px] font-mono max-w-[150px] truncate ${be}`,children:y}),e("button",{type:"button",onClick:()=>c(p.id),"aria-label":`Tutup tab ${y}`,title:`Tutup tab ${y}`,className:`mr-0.5 p-1 rounded hover:bg-error hover:text-paper ${be} ${g?"text-on-ink-muted":"text-ink/40 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,children:e(b,{size:11})})]},p.id)})}),e("button",{type:"button",onClick:u,disabled:!s,"aria-label":"Tab baru",title:s?"Tab baru":`Maksimal ${W} tab`,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink disabled:opacity-30 disabled:hover:bg-transparent disabled:cursor-not-allowed cursor-pointer transition-colors flex-shrink-0",children:e(P,{size:13})})]})}var xe="w-full min-w-0 bg-canvas border border-ink/15 rounded px-2 py-1 text-[11px] font-mono text-ink placeholder:text-ink/35 focus:outline-none focus:border-ink/40";function De(t){if(!t||t.ok)return null;if(t.reason==="cross-origin")return"This page is cross-origin, so its elements cannot be read. Name the part and add a note instead.";if(t.reason==="no-frame")return"The page has not loaded, so its elements cannot be read yet.";return"There is no element at this point (empty space). Name the part instead."}function we({shape:t,index:r,readability:s,onLabel:l,onNote:c}){let u=De(s),f=t.element;return e("div",{className:"flex items-start gap-1.5 min-w-0",children:[e("span",{className:"text-[11px] font-mono text-ink/45 pt-1 flex-shrink-0",children:[Xu[t.tool]," #",r]}),e("div",{className:"flex-1 min-w-0 space-y-1",children:[e("div",{className:"flex items-center gap-1 flex-wrap",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/40",children:"bagian"}),UA.map((p)=>{let g=t.label===p;return e("button",{type:"button",onClick:()=>l(g?"":p),"aria-pressed":g,className:`px-1.5 py-0.5 rounded-full border text-[10px] font-mono transition-colors cursor-pointer ${g?"bg-ink text-canvas border-ink":"bg-canvas text-ink/65 border-ink/15 hover:border-ink/40"}`,children:p},p)}),e("input",{value:t.label,onInput:(p)=>l(p.currentTarget.value),placeholder:"or type your own…","aria-label":"Name of the marked part",spellcheck:!1,className:`${xe} flex-1 min-w-[110px]`})]}),e("textarea",{value:t.note,onInput:(p)=>c(p.currentTarget.value),placeholder:"What is wrong with this part? (e.g. the Pay button looks disabled)",rows:2,"aria-label":"Annotation note",className:`${xe} resize-y`}),f?e("p",{className:"text-[10px] font-mono text-ink/45 truncate",title:f.path,children:["elemen: ",f.path,f.state?` · ${f.state}`:""]}):null,u?e("p",{className:"text-[10px] text-ink/40",children:u}):null]})]})}var Ge=["box","pin","arrow"],Ve="px-2 py-1 rounded text-[11px] font-mono border transition-colors cursor-pointer",q="flex items-center gap-1 px-2 py-1 rounded text-[11px] border border-ink/15 hover:border-ink/40 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";function ve({tool:t,shapes:r,selectedId:s,readability:l,onTool:c,onLabel:u,onNote:f,onRemove:p,onReset:g,onCancel:y,onSend:I}){let S=r.find((B)=>B.id===s)??null,w=r.length>0;return e("div",{className:"flex-shrink-0 border-b border-ink/10 bg-paper px-2.5 py-1.5 space-y-1.5 select-none",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/50 mr-1",children:"Anotasi"}),Ge.map((B)=>e("button",{type:"button",onClick:()=>c(B),"aria-pressed":t===B,className:`${Ve} ${t===B?"bg-ink text-canvas border-ink":"bg-canvas text-ink/70 border-ink/15 hover:border-ink/40"}`,children:Xu[B]},B)),e("span",{className:"text-[11px] font-mono text-ink/45 ml-1",children:r.length>0?`${r.length} mark${r.length===1?"":"s"}`:"drag on the page to mark a part"}),e("div",{className:"flex-1"}),e("button",{type:"button",onClick:g,disabled:!w,className:q,title:"Clear all marks",children:[e(L,{size:12})," Bersihkan"]}),e("button",{type:"button",onClick:I,disabled:!w,className:q,title:"Kirim anotasi ke draft chat",children:[e($n,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:y,className:q,title:"Tutup mode anotasi",children:e(b,{size:12})})]}),S?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(we,{shape:S,index:r.indexOf(S)+1,readability:l,onLabel:(B)=>u(S.id,B),onNote:(B)=>f(S.id,B)})}),e("button",{type:"button",onClick:()=>p(S.id),className:q,title:"Remove this mark",children:e(L,{size:12})})]}):e("p",{className:"text-[11px] text-ink/45",children:"This page cannot be screenshotted, so what gets sent is the area, the part name and your note."})]})}var ye=0;function Te(){return ye+=1,`annot-${Date.now().toString(36)}-${ye}`}function ke(t){let[r,s]=n(!1),[l,c]=n("box"),[u,f]=n([]),[p,g]=n(null);o(()=>{f([]),g(null)},[t]);let y=a(()=>{s((E)=>!E),g(null)},[]),I=a(()=>{g(null),s(!1)},[]),S=a((E)=>{f((C)=>[...C,E]),g(E.id)},[]),w=a((E,C)=>{f((x)=>x.map((T)=>T.id===E?{...T,note:C}:T))},[]),B=a((E,C)=>{f((x)=>x.map((T)=>T.id===E?{...T,label:C}:T))},[]),h=a((E)=>{f((C)=>C.filter((x)=>x.id!==E)),g((C)=>C===E?null:C)},[]),F=a(()=>{f([]),g(null)},[]);return{active:r,tool:l,shapes:u,selectedId:p,setTool:c,toggle:y,close:I,add:S,setNote:w,setLabel:B,select:g,remove:h,reset:F}}var Xe=4,X="var(--theme-error)";function Ae({shapes:t,tool:r,selectedId:s,onMeasure:l,onAdd:c,onSelect:u}){let f=i(null),p=i(null),[g,y]=n(null),[I,S]=n({width:0,height:0});o(()=>{let x=f.current;if(!x)return;let T=()=>{let k=x.getBoundingClientRect();if(k.width<=0||k.height<=0)return;S((z)=>z.width===k.width&&z.height===k.height?z:{width:k.width,height:k.height}),l({width:k.width,height:k.height})};if(T(),typeof ResizeObserver!=="function")return;let U=new ResizeObserver(T);return U.observe(x),()=>U.disconnect()},[l]);let w=(x)=>{let T=f.current;if(!T)return null;let U=T.getBoundingClientRect(),k={x:x.clientX-U.left,y:x.clientY-U.top};return{normalized:zA(U,k),px:k.x,py:k.y}},B=(x)=>{if(x.button!==0)return;let T=w(x);if(!T)return;x.preventDefault(),u(null),x.currentTarget.setPointerCapture?.(x.pointerId);let U={id:Te(),tool:r,start:T.normalized,end:T.normalized,label:"",note:""};p.current=U,y(U)},h=(x)=>{let T=p.current;if(!T)return;let U=w(x);if(!U)return;let k={...T,end:U.normalized};p.current=k,y(k)},F=(x)=>{let T=p.current;if(!T)return;let U=w(x),k=U?{...T,end:U.normalized}:T;if(p.current=null,y(null),x.currentTarget.releasePointerCapture?.(x.pointerId),k.tool!=="pin"){let z=f.current?.getBoundingClientRect();if((z?Math.hypot((k.end.x-k.start.x)*z.width,(k.end.y-k.start.y)*z.height):0)<Xe)return}c(k)},E=()=>{p.current=null,y(null)},C=g?[...t,g]:t;return e("div",{ref:f,className:"absolute inset-0 cursor-crosshair touch-none",onPointerDown:B,onPointerMove:h,onPointerUp:F,onPointerCancel:E,children:e("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${Math.max(1,I.width)} ${Math.max(1,I.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:C.map((x,T)=>e(We,{shape:x,index:T+1,box:I,selected:x.id===s,onSelect:()=>u(x.id)},x.id))})})}function We({shape:t,index:r,box:s,selected:l,onSelect:c}){let u={x:t.start.x*s.width,y:t.start.y*s.height},f={x:t.end.x*s.width,y:t.end.y*s.height},p=nm(t),g=l?3:2,y=String(r);return e("g",{onPointerDown:(S)=>{S.stopPropagation(),S.preventDefault(),c()},className:"cursor-pointer",children:[t.tool==="box"&&e("rect",{x:p.x*s.width,y:p.y*s.height,width:Math.max(1,p.width*s.width),height:Math.max(1,p.height*s.height),fill:X,fillOpacity:l?0.16:0.1,stroke:X,strokeWidth:g,vectorEffect:"non-scaling-stroke",rx:3}),t.tool==="arrow"&&e(d,{children:[e("line",{x1:u.x,y1:u.y,x2:f.x,y2:f.y,stroke:X,strokeWidth:g,vectorEffect:"non-scaling-stroke"}),e("circle",{cx:f.x,cy:f.y,r:4,fill:X})]}),t.tool==="pin"&&e("circle",{cx:u.x,cy:u.y,r:7,fill:X,fillOpacity:l?0.5:0.3,stroke:X,strokeWidth:g}),e("circle",{cx:u.x,cy:u.y,r:9,fill:X}),e("text",{x:u.x,y:u.y,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:700,fill:"var(--theme-paper)",children:y})]})}function Be(t){let r=t.trim();if(!r)return r;let s=/^[a-z][a-z0-9+.-]*:/i.test(r)?r:`https://${r}`,l=new URL(s);if(l.protocol!=="http:"&&l.protocol!=="https:")throw Error("Only http and https URLs are allowed");return l.toString()}var Ee="userBrowser.tabs",Ne="userBrowser.activeTabId",Ze="userBrowser.inputUrl",Ye="userBrowser.history",je="userBrowser.historyIndex";function Se(){let[t,r]=_(Ee,[]),[s,l]=_(Ne,null),[c,u]=_(Ze,""),[f,p]=n(null),[g,y]=n(void 0),{sessionId:I,ready:S}=Oe(),w=i(null),B=(N,A)=>Ce(I,N)??A,h=me(t,s),F=K(h);o(()=>{if(!S||w.current===I)return;w.current=I;let N=B(Ee,[]),A=se(N);if(A.length>0){if(JSON.stringify(A)!==JSON.stringify(N))r(A);let Y=B(Ne,null);if(!A.some((v)=>v.id===Y))l(A[A.length-1].id);return}let[M]=se([{id:Z(),history:B(Ye,[]),index:B(je,-1),frameKey:0}]),R=M&&M.history.length>0?M:j(Z());r([R]),l(R.id)},[S,I,r,l]);let E=a((N,A)=>{r((M)=>M.map((R)=>R.id===N?A(R):R))},[r]),C=a((N)=>{let A=N.trim();if(!A)return;let M;try{M=Be(A)}catch(R){y(R instanceof Error?R.message:"Alamat tidak valid");return}if(y(void 0),u(M),!h){let R=j(Z(),M);r([R]),l(R.id),p(R.id);return}p(h.id),E(h.id,(R)=>ue(R,M))},[h,l,u,r,E]),x=a(()=>{if(!h||!te(h))return;p(h.id),E(h.id,(N)=>oe(N,-1))},[h,E]),T=a(()=>{if(!h||!ne(h))return;p(h.id),E(h.id,(N)=>oe(N,1))},[h,E]),U=a(()=>{if(!h||!F)return;p(h.id),E(h.id,re)},[h,F,E]),k=a((N)=>{p((A)=>A===N?null:A)},[]),z=a(()=>{if(t.length>=W)return;let N=j(Z());r((A)=>[...A,N]),l(N.id),u(""),y(void 0)},[l,u,r,t.length]),G=a((N)=>{let A=t.find((M)=>M.id===N);if(!A)return;l(N),u(K(A)),y(void 0)},[l,u,t]),V=a((N)=>{let A=pe(t,s,N);if(A.tabs.length===0){let M=j(Z());r([M]),l(M.id),u("");return}if(r(A.tabs),A.activeId!==s){l(A.activeId);let M=A.tabs.find((R)=>R.id===A.activeId);u(K(M)),y(void 0)}},[s,l,u,r,t]);return{tabs:t,activeTab:h,activeTabId:h?.id??null,url:F,input:c,setInput:u,frameKey:h?.frameKey??0,loading:f!==null&&f===h?.id,error:g,canGoBack:te(h),canGoForward:ne(h),canOpenTab:t.length<W,submit:C,goBack:x,goForward:T,reload:U,markLoaded:k,openTab:z,selectTab:G,closeTab:V}}function qe(t){if(!t)return"no-frame";try{return t.contentDocument?"readable":"cross-origin"}catch{return"cross-origin"}}function J(t){let r=t.replace(/\s+/g," ").trim();return r.length>60?`${r.slice(0,59)}…`:r}function Je(t){let r=t.tagName.toLowerCase();if(t.id)return`${r}#${t.id}`;for(let l of["data-testid","data-test","aria-label"]){let c=t.getAttribute(l);if(c)return`${r}[${l}="${J(c)}"]`}let s=t.getAttribute("role");if(s)return`${r}[role="${s}"]`;return r}function Qe(t){let r=[],s=t;while(s&&r.length<4){if(s.tagName.toLowerCase()==="html")break;r.unshift(Je(s)),s=s.parentElement}return r.join(" > ")}function et(t){let r=[];if(t.disabled)r.push("nonaktif");if(t instanceof HTMLSelectElement||t.tagName.toLowerCase()==="select"){let s=t,c=s.selectedOptions?.[0]?.textContent?.trim()||s.value;if(c)r.push(`nilai "${J(c)}"`);let u=s.options?.length??0;if(u>0)r.push(`${u} opsi`)}else if(t.tagName.toLowerCase()==="input"){let s=t;if(s.type)r.push(`tipe ${s.type}`);if(s.type!=="password"&&s.placeholder)r.push(`placeholder "${J(s.placeholder)}"`)}return r.length>0?r.join(", "):void 0}function tt(t){let r={path:Qe(t),tag:t.tagName.toLowerCase()},s=t.getAttribute("role");if(s)r.role=s;let l=J(t.innerText??t.textContent??"");if(l)r.text=l;let c=et(t);if(c)r.state=c;return r}function Me(t,r){let s=qe(t);if(s!=="readable")return{ok:!1,reason:s};let{contentWindow:l,contentDocument:c}=t;if(!l||!c)return{ok:!1,reason:"cross-origin"};try{let u=Math.min(Math.max(r.x,0),1)*l.innerWidth,f=Math.min(Math.max(r.y,0),1)*l.innerHeight,p=c.elementFromPoint(u,f);if(!p||p===c.documentElement||p===c.body)return{ok:!1,reason:"no-element"};return{ok:!0,element:tt(p)}}catch{return{ok:!1,reason:"cross-origin"}}}function rn({className:t="",active:r=!0}){let[s,l]=_("userBrowser.viewportMode","responsive"),[c,u]=_("userBrowser.zoomLevel",100),[f,p]=n(null),[g,y]=n(null),[I,S]=n(null),{tabs:w,activeTabId:B,url:h,input:F,setInput:E,loading:C,error:x,canGoBack:T,canGoForward:U,canOpenTab:k,submit:z,goBack:G,goForward:V,reload:N,markLoaded:A,openTab:M,selectTab:R,closeTab:Y}=Se(),v=ke(`${B??""}:${w.find((O)=>O.id===B)?.frameKey??0}`),Le=a(()=>{if(!h)return;window.open(h,"_blank","noopener,noreferrer")},[h]),Ie=a(()=>{if(!h)return;uc({url:h})},[h]),Ue=a((O)=>{p((H)=>H&&H.width===O.width&&H.height===O.height?H:O)},[]),Re=a((O)=>{let H=Me(g,O.start);S(H),v.add(H.ok?{...O,element:H.element}:O)},[v,g]),Pe=a(()=>{if(!h||v.shapes.length===0)return;let O=c/100;uc({url:h,annotations:v.shapes,panel:{width:(f?.width??0)/O,height:(f?.height??0)/O,viewportMode:s,zoom:c}}),v.close()},[h,v,f,s,c]),Q=v.active&&Boolean(h),_e=C?B??null:null;return e("div",{"data-user-browser-panel":"",className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,children:[e(ge,{tabs:w,activeTabId:B,canOpenTab:k,onSelect:R,onClose:Y,onNewTab:M}),e(ae,{url:h,input:F,loading:C,error:x,canGoBack:T,canGoForward:U,viewportMode:s,zoomLevel:c,onInputChange:E,onSubmit:z,onBack:G,onForward:V,onReload:N,onOpenExternal:Le,onIncludeInChat:Ie,onChangeViewport:l,onZoomIn:()=>u((O)=>Math.min(200,O+10)),onZoomOut:()=>u((O)=>Math.max(50,O-10)),onResetZoom:()=>u(100),onSetZoom:u,focusKey:B??void 0,annotate:{active:Q,count:v.shapes.length,onToggle:v.toggle}}),Q&&e(ve,{tool:v.tool,shapes:v.shapes,selectedId:v.selectedId,readability:I,onTool:v.setTool,onLabel:v.setLabel,onNote:v.setNote,onRemove:v.remove,onReset:v.reset,onCancel:v.close,onSend:Pe}),e(he,{tabs:w,activeTabId:B,loadingTabId:_e,viewportMode:s,zoomLevel:c,onLoad:A,onFrame:y,active:r,overlay:Q?e(Ae,{shapes:v.shapes,tool:v.tool,selectedId:v.selectedId,onMeasure:Ue,onAdd:Re,onSelect:v.select}):null})]})}export{rn as UserBrowserPanel};
@@ -1 +1 @@
1
- import{d,n,o,i,u,a,le,e,s,f,B,se,va,re,ce,b,Qp,Ee,_,At,Ha,ot,me,it,pA,pi}from"./index-cq98p2rb.js";var ae={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},F=s(ae);function O(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function J({used:l,limit:r,percent:c}){let h=l.toLocaleString(),x=r.toLocaleString(),m=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[h," / ",x]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${m}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[m.toFixed(1),"% used"]})]})}function T(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function Z({open:l,onClose:r,breakdown:c,costFormatted:h}){let x=i(null);if(me(x,r),!l)return null;let m=c?[{label:"Total Cost",value:T(c.total),strong:!0},{label:"Input (cache miss)",value:T(c.input)},{label:"Output",value:T(c.output)},{label:"Cache Read (cache hit)",value:T(c.cacheRead)},{label:"Cache Write",value:T(c.cacheWrite)}]:[{label:"Total Cost",value:h??"$0.01",strong:!0}];return e("div",{ref:x,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:m.map((t)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:t.label}),e("span",{className:`${t.strong?"font-semibold text-ink":"text-ink/80"}`,children:t.value})]},t.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:h,cacheHitAverage:x,costBreakdown:m}){let[t,v]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(it,{variant:"compact",label:"Messages",value:l}),e(it,{variant:"compact",label:"User",value:r}),e(it,{variant:"compact",label:"Assistant",value:c}),e(it,{variant:"compact",label:"Cache Hit",value:x!==void 0?`${x.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>v(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(ce,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:h}),e(Z,{open:t,onClose:()=>v(!1),breakdown:m,costFormatted:h})]})]})]})}function z({input:l,output:r,reasoning:c,cacheRead:h,cacheWrite:x,cacheHitPercent:m}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(it,{variant:"compact",label:"In",value:l.toLocaleString()}),e(it,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(it,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(it,{variant:"compact",label:"Cache",value:`${h.toLocaleString()}/${x.toLocaleString()}`}),e(it,{variant:"compact",label:"Hit",value:`${m.toFixed(1)}%`})]})]})}function Q({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:h}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${h}%`},title:`Other: ${h}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",h,"%"]})]})]})]})}function G({data:l}){pi();let[r,c]=n(!1),h=i(null),x=i(null),m=JSON.stringify(l,null,2),t=pA(m),v=a((C)=>{let g=x.current;if(!g)return;g.scrollLeft=C.currentTarget.scrollLeft,g.scrollTop=C.currentTarget.scrollTop},[]),y=a(async(C)=>{C.stopPropagation();try{await navigator.clipboard.writeText(m)}catch{let g=document.createElement("textarea");g.value=m,g.style.position="fixed",g.style.opacity="0",document.body.appendChild(g),g.select(),document.execCommand("copy"),document.body.removeChild(g)}c(!0),setTimeout(()=>c(!1),2000)},[m]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",m.length," chars"]}),e("button",{type:"button",onClick:y,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(re,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:x,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:t}}),e("pre",{ref:h,onScroll:v,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:m})})]})]})}var D=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],L=20;function K(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function q(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,h=r>0?l.slice(r+1):"";return h?`${c} · ${h}`:c}function Y(l,r){if(r<=7)return Array.from({length:r},(t,v)=>v+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((t)=>c.add(t));if(l>=r-2)[r-3,r-2,r-1].forEach((t)=>c.add(t));let h=[...c].filter((t)=>t>=1&&t<=r).sort((t,v)=>t-v),x=[],m=0;for(let t of h){if(t-m>1)x.push("…");x.push(t),m=t}return x}function X({sessionId:l,refreshKey:r=0}){let[c,h]=_("context.rawExpandedIds",{}),[x,m]=_("context.rawFilterRole","all"),[t,v]=n(1),[y,C]=n([]),[g,I]=n(0),[W,S]=n(!1),w=i(0),E=i(!1),j=a((p)=>{if(typeof window>"u")return;let k=++w.current;if(!p?.silent)S(!0);let P=new URLSearchParams({page:String(t),pageSize:String(L),role:x});if(l)P.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${P.toString()}`).then((N)=>N.ok?N.json():null).then((N)=>{if(E.current||k!==w.current)return;C(N&&Array.isArray(N.items)?N.items:[]),I(N&&Number.isFinite(N.filteredTotal)?N.filteredTotal:0)}).catch(()=>{if(E.current||k!==w.current)return;C([]),I(0)}).finally(()=>{if(!p?.silent&&k===w.current)S(!1)})},[l,t,x]);o(()=>(E.current=!1,j(),()=>{E.current=!0}),[j,r]);let R=Math.max(1,Math.ceil(g/L)),M=Math.min(t,R),U=(p)=>v(Math.min(Math.max(1,p),R)),ee=(p)=>{h((k)=>({...k,[p]:!k[p]}))},te=()=>{if(y.every((k)=>c[k.id]))h({});else{let k={};y.forEach((P)=>{k[P.id]=!0}),h(k)}},H=u(()=>{let p=[];for(let k of y){let P=k.info.modelID;if(!P||p.includes(P))continue;p.push(P)}return p},[y]),A=(p)=>p?D[K(p)%D.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[H.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:H.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${A(p)}`}),e("span",{children:q(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:g})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{m("all"),v(1)},className:`px-1.5 py-0.5 rounded ${x==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{m("assistant"),v(1)},className:`px-1.5 py-0.5 rounded ${x==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{m("user"),v(1)},className:`px-1.5 py-0.5 rounded ${x==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:te,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(F,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!W&&y.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):y.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${W?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>ee(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(se,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${A(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(G,{data:p.rawPayload})})]},p.id)})}),R>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(M-1)*L+1,"–",Math.min(M*L,g)," of ",g]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:M<=1,onClick:()=>U(M-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(va,{size:14})}),Y(M,R).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>U(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===M?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:M>=R,onClick:()=>U(M+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(se,{size:14})})]})]})]})}function mt({className:l="",enabled:r=!0,refreshKey:c=0,tabsMode:h=!1}){let[x]=le(),m=x.get("sessionId"),[t,v]=n(()=>O(m||"default","Session not started")),y=i(!1),C=a(()=>{if(typeof window>"u")return;let S=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${S}`).then((w)=>w.ok?w.json():null).then((w)=>{if(!y.current&&w&&w.telemetry)v(w.telemetry)}).catch((w)=>{if(!y.current)console.warn("Failed to fetch context telemetry:",w)})},[m]);o(()=>{if(y.current=!1,!r)return;return C(),()=>{y.current=!0}},[r,c,C]);let g=Ee(m?Qp(m):null,{enabled:r}),[I,W]=n(0);if(o(()=>{if(g.data)v(g.data),W((S)=>S+1)},[g.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e(At,{left:e(d,{children:[e(Ha,{id:"context",tabsMode:h,children:e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle})}),e("span",{className:"text-[11px] text-ink/50 truncate font-mono",children:t.timestamp})]}),right:e(ot,{label:"Refresh context telemetry",onClick:()=>{g.refresh(),C()},busy:g.refreshing,disabled:!r})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(J,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(z,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(Q,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(X,{sessionId:m,refreshKey:c+I})]})]})}export{mt as ContextPanel};
1
+ import{d,n,o,i,u,a,le,e,s,f,B,se,va,re,ce,b,Mp,Be,_,At,Ha,ot,me,it,yA,pi}from"./index-xkwybnf3.js";var ae={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},F=s(ae);function O(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function J({used:l,limit:r,percent:c}){let h=l.toLocaleString(),x=r.toLocaleString(),m=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[h," / ",x]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${m}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[m.toFixed(1),"% used"]})]})}function T(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function Z({open:l,onClose:r,breakdown:c,costFormatted:h}){let x=i(null);if(me(x,r),!l)return null;let m=c?[{label:"Total Cost",value:T(c.total),strong:!0},{label:"Input (cache miss)",value:T(c.input)},{label:"Output",value:T(c.output)},{label:"Cache Read (cache hit)",value:T(c.cacheRead)},{label:"Cache Write",value:T(c.cacheWrite)}]:[{label:"Total Cost",value:h??"$0.01",strong:!0}];return e("div",{ref:x,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:m.map((t)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:t.label}),e("span",{className:`${t.strong?"font-semibold text-ink":"text-ink/80"}`,children:t.value})]},t.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:h,cacheHitAverage:x,costBreakdown:m}){let[t,v]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(it,{variant:"compact",label:"Messages",value:l}),e(it,{variant:"compact",label:"User",value:r}),e(it,{variant:"compact",label:"Assistant",value:c}),e(it,{variant:"compact",label:"Cache Hit",value:x!==void 0?`${x.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>v(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(ce,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:h}),e(Z,{open:t,onClose:()=>v(!1),breakdown:m,costFormatted:h})]})]})]})}function z({input:l,output:r,reasoning:c,cacheRead:h,cacheWrite:x,cacheHitPercent:m}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(it,{variant:"compact",label:"In",value:l.toLocaleString()}),e(it,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(it,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(it,{variant:"compact",label:"Cache",value:`${h.toLocaleString()}/${x.toLocaleString()}`}),e(it,{variant:"compact",label:"Hit",value:`${m.toFixed(1)}%`})]})]})}function Q({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:h}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${h}%`},title:`Other: ${h}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",h,"%"]})]})]})]})}function G({data:l}){pi();let[r,c]=n(!1),h=i(null),x=i(null),m=JSON.stringify(l,null,2),t=yA(m),v=a((C)=>{let g=x.current;if(!g)return;g.scrollLeft=C.currentTarget.scrollLeft,g.scrollTop=C.currentTarget.scrollTop},[]),y=a(async(C)=>{C.stopPropagation();try{await navigator.clipboard.writeText(m)}catch{let g=document.createElement("textarea");g.value=m,g.style.position="fixed",g.style.opacity="0",document.body.appendChild(g),g.select(),document.execCommand("copy"),document.body.removeChild(g)}c(!0),setTimeout(()=>c(!1),2000)},[m]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",m.length," chars"]}),e("button",{type:"button",onClick:y,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(re,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:x,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:t}}),e("pre",{ref:h,onScroll:v,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:m})})]})]})}var D=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],L=20;function K(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function q(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,h=r>0?l.slice(r+1):"";return h?`${c} · ${h}`:c}function Y(l,r){if(r<=7)return Array.from({length:r},(t,v)=>v+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((t)=>c.add(t));if(l>=r-2)[r-3,r-2,r-1].forEach((t)=>c.add(t));let h=[...c].filter((t)=>t>=1&&t<=r).sort((t,v)=>t-v),x=[],m=0;for(let t of h){if(t-m>1)x.push("…");x.push(t),m=t}return x}function X({sessionId:l,refreshKey:r=0}){let[c,h]=_("context.rawExpandedIds",{}),[x,m]=_("context.rawFilterRole","all"),[t,v]=n(1),[y,C]=n([]),[g,I]=n(0),[W,S]=n(!1),w=i(0),E=i(!1),j=a((p)=>{if(typeof window>"u")return;let k=++w.current;if(!p?.silent)S(!0);let P=new URLSearchParams({page:String(t),pageSize:String(L),role:x});if(l)P.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${P.toString()}`).then((N)=>N.ok?N.json():null).then((N)=>{if(E.current||k!==w.current)return;C(N&&Array.isArray(N.items)?N.items:[]),I(N&&Number.isFinite(N.filteredTotal)?N.filteredTotal:0)}).catch(()=>{if(E.current||k!==w.current)return;C([]),I(0)}).finally(()=>{if(!p?.silent&&k===w.current)S(!1)})},[l,t,x]);o(()=>(E.current=!1,j(),()=>{E.current=!0}),[j,r]);let R=Math.max(1,Math.ceil(g/L)),M=Math.min(t,R),U=(p)=>v(Math.min(Math.max(1,p),R)),ee=(p)=>{h((k)=>({...k,[p]:!k[p]}))},te=()=>{if(y.every((k)=>c[k.id]))h({});else{let k={};y.forEach((P)=>{k[P.id]=!0}),h(k)}},H=u(()=>{let p=[];for(let k of y){let P=k.info.modelID;if(!P||p.includes(P))continue;p.push(P)}return p},[y]),A=(p)=>p?D[K(p)%D.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[H.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:H.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${A(p)}`}),e("span",{children:q(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:g})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{m("all"),v(1)},className:`px-1.5 py-0.5 rounded ${x==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{m("assistant"),v(1)},className:`px-1.5 py-0.5 rounded ${x==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{m("user"),v(1)},className:`px-1.5 py-0.5 rounded ${x==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:te,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(F,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!W&&y.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):y.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${W?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>ee(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(se,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${A(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(G,{data:p.rawPayload})})]},p.id)})}),R>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(M-1)*L+1,"–",Math.min(M*L,g)," of ",g]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:M<=1,onClick:()=>U(M-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(va,{size:14})}),Y(M,R).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>U(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===M?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:M>=R,onClick:()=>U(M+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(se,{size:14})})]})]})]})}function mt({className:l="",enabled:r=!0,refreshKey:c=0,tabsMode:h=!1}){let[x]=le(),m=x.get("sessionId"),[t,v]=n(()=>O(m||"default","Session not started")),y=i(!1),C=a(()=>{if(typeof window>"u")return;let S=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${S}`).then((w)=>w.ok?w.json():null).then((w)=>{if(!y.current&&w&&w.telemetry)v(w.telemetry)}).catch((w)=>{if(!y.current)console.warn("Failed to fetch context telemetry:",w)})},[m]);o(()=>{if(y.current=!1,!r)return;return C(),()=>{y.current=!0}},[r,c,C]);let g=Be(m?Mp(m):null,{enabled:r}),[I,W]=n(0);if(o(()=>{if(g.data)v(g.data),W((S)=>S+1)},[g.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e(At,{left:e(d,{children:[e(Ha,{id:"context",tabsMode:h,children:e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle})}),e("span",{className:"text-[11px] text-ink/50 truncate font-mono",children:t.timestamp})]}),right:e(ot,{label:"Refresh context telemetry",onClick:()=>{g.refresh(),C()},busy:g.refreshing,disabled:!r})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(J,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(z,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(Q,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(X,{sessionId:m,refreshKey:c+I})]})]})}export{mt as ContextPanel};
@@ -1,3 +1,3 @@
1
- import{d,n,o,K,i,u,a,Ue,oe,e,s,E,m,Xt,S,f,B,re,gt,ge,_t,He,ii,cn,Yr,D,U,b,Jn,je,Se,_,gr,Ze,me,Ar,Z,st,el,Io,tl,nl,So,lh,kh,Pm,Po,pl,Le,ae,Yt,T,ve,hi,mf,Bg}from"./index-cq98p2rb.js";import{dt,ki,iu,su,cu,ys,xi,Sd}from"./index-204ae4vs.js";import{zc,yd,vd,Dg,Ng,Uc,rr,gs,Gc,jc,qc,Hc,Wc,As,Uo,hs,yi,Vc,vl,kl,Yc,Jc,Zc,Xc,eu,tu,nu,ru,au}from"./index-qm92sf9w.js";import{Qa,Ra,Ho}from"./index-ehacfgwm.js";var gn={name:"git-commit-vertical",size:24,node:[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]},De=s(gn);var vn={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]},we=s(vn);var yn={name:"minimize",size:24,node:[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]},ke=s(yn);var xn={name:"panel-right-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]},Ve=s(xn);var wn={name:"save-all",size:24,node:[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]},Ce=s(wn);var se=new Set,Oe=new Set,We=new Set;function Ke(){We=new Set(se);for(let t of[...Oe])t()}function _e(t){let r=new Set(t);if(r.size===se.size){let l=!0;for(let c of r)if(!se.has(c)){l=!1;break}if(l)return}se.clear();for(let l of r)se.add(l);Ke()}function Ge(t){let r=new Set(t),l=!1;for(let c of[...se])if(!r.has(c))se.delete(c),l=!0;if(l)Ke()}function qe(t){return se.has(t)}function Xe(){return se.size>0}function kn(t){return Oe.add(t),()=>{Oe.delete(t)}}var Sn=kn;function Ye(){return Ue(Sn,()=>We)}function Je({x:t,y:r,rows:l,onAction:c,onClose:p}){let g=i(null),[v,h]=n({left:t,top:r});return K(()=>{let y=g.current;if(!y)return;let{width:w,height:x}=y.getBoundingClientRect();h({left:Math.min(t,Math.max(0,window.innerWidth-w-8)),top:Math.min(r,Math.max(0,window.innerHeight-x-8))})},[t,r,l.length]),oe(e("div",{className:"fixed inset-0 z-[70]",onClick:p,onContextMenu:(y)=>{y.preventDefault(),p()},children:e("div",{ref:g,role:"menu","aria-label":"Tab actions",className:"glass-popover absolute w-52 bg-paper border border-ink/15 rounded-md shadow-xl py-1 text-xs text-ink",style:{left:`${v.left}px`,top:`${v.top}px`},onClick:(y)=>y.stopPropagation(),children:l.map((y)=>e("button",{type:"button",role:"menuitem",onClick:()=>{c(y.action),p()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:y.label},y.action))})}),document.body)}var he={rightFileId:null,fraction:0.5};function Ee(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Qe(t,r){for(let l=r.length-1;l>=0;l-=1){let c=r[l];if(c!==t)return c}return null}function et(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function pe(t){if(!Number.isFinite(t))return he.fraction;return Math.max(0.2,Math.min(0.8,t))}function tt(t,r){if(typeof t!=="object"||t===null)return he;let l=t,c=typeof l.fraction==="number"?pe(l.fraction):he.fraction,p=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(p===null||!r.includes(p))return{rightFileId:null,fraction:c};return{rightFileId:p,fraction:c}}function nt({tab:t,openedFiles:r,dirtyIds:l,reopenable:c,activeFileId:p,splitRightFileId:g}){let v=r.filter((x)=>x.id!==t.id),h=r.filter((x)=>!l.has(x.id)),y=r.map((x)=>x.id);return[{action:"split-right",label:"Split right",enabled:Ee(t.id,p,y)},{action:"unsplit",label:"Unsplit",enabled:g!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:v.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:h.some((x)=>x.id!==t.id)},{action:"copy-path",label:"Copy path",enabled:Boolean(t.path)},{action:"reveal-in-files",label:"Reveal in Files",enabled:Boolean(t.path)&&!t.isDiff},{action:"reopen-closed",label:"Reopen closed tab",enabled:c>0}].filter((x)=>x.enabled)}function fe({onHide:t}){let r=Po("toggleEditorPanel","Hide Editor Panel");return e("button",{type:"button",onClick:t,className:"p-1.5 mx-1 rounded transition-colors cursor-pointer text-ink/60 hover:bg-ink/10 hover:text-ink flex-shrink-0",title:r,"aria-label":r,children:e(Ve,{size:14})})}function rt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,missingIds:p,onCopyPath:g,onRevealInFiles:v,onReopenClosed:h,reopenableCount:y,onSplitTo:w,onUnsplit:x,splitRightFileId:k=null,onHide:O}){let C=Ye(),M=i(null),A=i(null),[F,z]=n(5),[I,W]=n(!1),[R,L]=n(null);me(A,()=>W(!1)),o(()=>{let N=new ResizeObserver((P)=>{for(let H of P){let J=H.contentRect.width,Q=Math.max(1,Math.floor((J-60)/150));z(Q)}});if(M.current)N.observe(M.current);return()=>N.disconnect()},[]);let G=Qe(r,t.map((N)=>N.id)),X=[],Y=[];if(t.length<=F)X=t;else{let N=t.findIndex((H)=>H.id===r),P=new Set;if(N!==-1&&r!==null)P.add(r);for(let H=t.length-1;H>=0;H--){if(P.size>=F)break;P.add(t[H].id)}X=t.filter((H)=>P.has(H.id)),Y=t.filter((H)=>!P.has(H.id))}return e("div",{className:"flex bg-ink/10 w-full relative border-b border-ink/10",ref:M,children:[e("div",{className:"flex overflow-hidden",children:X.map((N)=>{let P=N.id===r,H=Boolean(N.isDiff),J=H?Jn(N.diffStatus||"M",N.diffStaged):null,Q=Boolean(p?.has(N.id));return e("div",{onClick:()=>l(N.id),onContextMenu:(te)=>{te.preventDefault(),L({tab:N,x:te.clientX,y:te.clientY})},className:`flex items-center space-x-1.5 px-3 py-1.5 cursor-pointer border-r border-ink/10 min-w-[120px] max-w-[210px] group ${P?"bg-paper border-t-2 border-t-ink text-ink":"bg-transparent border-t-2 border-t-transparent text-ink/60 hover:bg-paper/50"}`,title:Q?`${N.path} — file no longer exists`:N.path,children:[H?e(ii,{size:14,className:P?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(st,{name:N.name,size:14,className:`flex-shrink-0${P||Q?"":" opacity-60"}${Q?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${Q?" text-error line-through":""}`,children:N.name}),J&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${J.badgeBgClass}`,children:J.charStatus}),e(ot,{dirty:C.has(N.id),active:P,label:`Close ${N.name}`,onClose:()=>c(N.id)})]},N.id)})}),R?e(Je,{x:R.x,y:R.y,rows:nt({tab:R.tab,openedFiles:t,dirtyIds:C,reopenable:y?.()??0,activeFileId:r,splitRightFileId:k}),onAction:(N)=>{let P=R.tab;switch(N){case"close":c(P.id);return;case"close-others":for(let H of[...t].reverse())if(H.id!==P.id)c(H.id);l(P.id);return;case"close-all":for(let H of[...t].reverse())c(H.id);return;case"close-saved":for(let H of[...t].reverse())if(!C.has(H.id))c(H.id);return;case"copy-path":g?.(P);return;case"reveal-in-files":v?.(P);return;case"reopen-closed":h?.();return;case"split-right":w?.(P.id);return;case"unsplit":x?.();return}},onClose:()=>L(null)}):null,e("div",{className:"ml-auto flex items-center",children:[e("button",{type:"button",onClick:()=>k!==null?x?.():w?.(G),disabled:k===null&&G===null,"aria-pressed":k!==null,"aria-label":"Split editor",title:k!==null?"Close the split pane (the tab stays open)":G===null?"Open another file to split the editor":"Split the editor and show the newest other file",className:`p-1.5 mx-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-default ${k!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(Yr,{size:14})}),O&&e(fe,{onHide:O})]}),Y.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:A,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${I?"bg-ink/10 text-ink":""}`,onClick:()=>W(!I),title:"More open files",children:e(B,{size:14})}),I&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-52 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-mono text-ink/40 border-b border-ink/10 mb-1",children:"Older Tabs"}),Y.map((N)=>{let P=Boolean(p?.has(N.id));return e("div",{onClick:()=>{l(N.id),W(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[N.isDiff?e(ii,{size:14,className:"text-info/80"}):e(st,{name:N.name,size:14,className:P?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${P?"text-error line-through":"text-ink/80"}`,children:N.name}),e(ot,{dirty:C.has(N.id),active:!1,label:`Close ${N.name}`,onClose:()=>{if(c(N.id),Y.length===1)W(!1)}})]},N.id)})]})]})]})}function ot({dirty:t,active:r,label:l,onClose:c}){return e("div",{role:"button",tabIndex:-1,"aria-label":l,title:t?`${l} — unsaved changes`:l,className:`p-0.5 rounded hover:bg-ink/10 touch-visible ${r||t?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:(p)=>{p.stopPropagation(),c()},children:t?e("span",{className:"block w-2 h-2 rounded-full bg-current mx-0.5","data-tab-dirty":"","aria-hidden":"true"}):e(b,{size:12})})}function Cn(t){if(t===null)return null;let r=new Date(t);if(Number.isNaN(r.getTime()))return null;return r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Te({diskMtimeMs:t,fileName:r,onReload:l,onKeepMine:c}){let p=Cn(t);return e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-[11px] text-ink flex-shrink-0",role:"alert","data-conflict-strip":"",children:[e(S,{size:13,className:"text-warning flex-shrink-0 mt-0.5"}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"font-medium",children:[e("span",{className:"font-mono",children:r})," changed on disk",p?e("span",{className:"text-ink/60",children:[" at ",p]}):null,"."]}),e("div",{className:"text-ink/60 mt-0.5",children:"Your save was refused so nothing was overwritten."})]}),e("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e("button",{type:"button",onClick:l,className:"px-2 py-1 rounded border border-ink/20 hover:bg-ink/5 transition-colors cursor-pointer",title:"Discard my changes and take the file from disk",children:"Reload"}),e("button",{type:"button",onClick:c,className:"px-2 py-1 rounded border border-warning/50 text-warning hover:bg-warning/10 transition-colors cursor-pointer",title:"Write my buffer over the file on disk",children:"Keep mine"})]})]})}function it(t){if(t.byteViewer)return[];return[{id:"save",pinned:!0,actions:[{label:"Save file",icon:Ce,onSelect:t.onSave,disabled:t.saveDisabled}],children:t.saveButton},{id:"save-as",actions:[{label:"Save as…",icon:Ce,onSelect:t.onSaveAs}],children:e("button",{type:"button",onClick:t.onSaveAs,className:`${rr} hover:bg-ink/5 hover:text-ink`,title:"Save the buffer to a new file","aria-label":"Save as",children:e(Ce,{size:14})})}]}function at(t){if(!t.hasReview)return[];let r=t.isReviewing?"Exit review mode":"Review this document";return[{id:"review",actions:[{label:r,icon:cn,onSelect:t.onToggleReview,active:t.isReviewing}],children:e(gs,{label:r,pressed:t.isReviewing,title:t.isReviewing?"Review mode is on — click a block to judge it":"Review: click blocks to mark them good or needing work",onClick:t.onToggleReview,children:e(cn,{size:14})})}]}function lt(t){if(!t.hasPreview)return[];return[{id:"preview",actions:[{label:t.previewLabel,icon:t.isPreview?_t:He,onSelect:t.onTogglePreview,active:t.isPreview}],children:e(gs,{label:t.previewLabel,pressed:t.isPreview,onClick:t.onTogglePreview,children:t.isPreview?e(_t,{size:14}):e(He,{size:14})})}]}function ct(t){let r=[];if(r.push(...it(t),...at(t),...lt(t)),!t.byteViewer)r.push({id:"find",actions:[{label:t.findLabel,icon:U,onSelect:t.onToggleFind,active:t.findOpen}],children:e(gs,{label:t.findLabel,pressed:t.findOpen,title:`${t.findLabel} (Ctrl+F)`,onClick:t.onToggleFind,children:e(U,{size:14})})}),r.push({id:"wrap",actions:[{label:t.wordWrapLabel,icon:Xt,onSelect:t.onToggleWordWrap,active:t.wordWrap}],children:e(gs,{label:t.wordWrapLabel,pressed:t.wordWrap,onClick:t.onToggleWordWrap,children:e(Xt,{size:14})})}),r.push({id:"blame",actions:[{label:t.blameInline?"Hide line blame":"Show line blame",icon:De,onSelect:t.onToggleBlameInline,active:t.blameInline}],children:e(gs,{label:t.blameInline?"Hide line blame":"Show line blame",pressed:t.blameInline,title:"Who last changed each block, from git (hover a line for the commit)",onClick:t.onToggleBlameInline,children:e(De,{size:14})})}),r.push({id:"zoom",actions:[{label:"Decrease font size",icon:Ra,onSelect:t.onZoomOut},{label:"Increase font size",icon:Qa,onSelect:t.onZoomIn}],children:e(d,{children:[e("button",{type:"button",onClick:t.onZoomOut,className:`${rr} hover:bg-ink/5 hover:text-ink`,title:"Decrease font size","aria-label":"Decrease font size",children:e(Ra,{size:14})}),e("button",{type:"button",onClick:t.onZoomIn,className:`${rr} hover:bg-ink/5 hover:text-ink`,title:"Increase font size","aria-label":"Increase font size",children:e(Qa,{size:14})})]})}),r.push({id:"reload",actions:[{label:"Reload from disk",icon:D,onSelect:t.onReload,disabled:!t.canReload}],children:e("button",{type:"button",onClick:t.onReload,disabled:!t.canReload||t.refreshing,"aria-busy":t.refreshing,className:`${rr} hover:bg-ink/5 hover:text-ink`,title:!t.canReload?"Nothing to reload — this tab has no file on disk":t.reloadDiscardsEdits?"Discard my changes and reload from disk":"Reload from disk","aria-label":"Reload from disk",children:e(D,{size:14,className:t.refreshing?"animate-spin":void 0})})});return r.push({id:"copy",actions:[{label:t.copyLabel,icon:re,onSelect:t.onCopy},{label:"Download file",icon:ge,onSelect:t.onDownload}],children:e(d,{children:[e("button",{type:"button",onClick:t.onCopy,className:`${rr} hover:bg-ink/5 hover:text-ink`,title:t.copyLabel,"aria-label":t.copyLabel,children:t.copied?e(re,{size:14,className:"text-success"}):e(re,{size:14})}),e("button",{type:"button",onClick:t.onDownload,className:`${rr} hover:bg-ink/5 hover:text-ink`,title:"Download file","aria-label":"Download file",children:e(ge,{size:14})})]})}),r.push({id:"view-modes",pinned:!0,actions:t.viewModeActions,children:t.viewModeButtons}),r.push({id:"maximize",pinned:!0,actions:[{label:t.maximizeLabel,icon:t.isMaximized?ke:we,onSelect:t.onToggleMaximize,active:t.isMaximized}],children:t.maximizeButton}),r}function mt({path:t,saveStatus:r,wordWrap:l,hasPreview:c,isPreview:p,hasReview:g,isReviewing:v,copied:h,byteViewer:y=!1,saveDisabled:w=!1,unsupported:x=!1,handleMissing:k=!1,readOnly:O=!1,isMaximized:C=!1,findOpen:M=!1,onToggleFind:A,onSave:F,onTogglePreview:z,onToggleReview:I,onToggleWordWrap:W,onZoomIn:R,onZoomOut:L,onCopy:G,onDownload:X,onReload:Y,canReload:N,refreshing:P=!1,reloadDiscardsEdits:H,onSaveAs:J,onToggleMaximize:Q}){let te=w?O?"Read-only — this file was opened from the phone, not from a workspace":k?"Cannot save — reopen the file from the system to restore write access":x?"Nothing to save — this file cannot be opened as a document":"Nothing to save — this file could not be read":r==="needs-permission"?"Click Save to allow writing this file":r==="saving"?"Saving…":r==="error"?"Save failed — the file on disk was not changed":"Save file (Ctrl+S)",ie=e("button",{type:"button",onClick:F,disabled:w||r==="saving",className:`${rr} hover:bg-ink/5`,title:te,"aria-label":te,children:r==="saving"?e(dt,{size:14,className:"text-warning animate-pulse"}):r==="saved"?e(f,{size:14,className:"text-success"}):r==="error"?e(E,{size:14,className:"text-error"}):r==="needs-permission"?e(dt,{size:14,className:"text-warning"}):e(dt,{size:14,className:"hover:text-ink"})}),le=C?"Exit full screen":"Full screen",ee=e("button",{type:"button",onClick:Q,className:`${rr} hover:bg-ink/5 hover:text-ink ${C?"text-ink":""}`,title:le,"aria-label":le,"aria-pressed":C,children:C?e(ke,{size:14}):e(we,{size:14})}),ne=Sd(),de=yd(),ce=ct({byteViewer:y,hasPreview:c,isPreview:p,wordWrap:l,hasReview:g,isReviewing:v,blameInline:ne.inline,findOpen:M,copied:h,isMaximized:C,saveDisabled:w,canReload:N,refreshing:P,reloadDiscardsEdits:H,saveButton:ie,maximizeButton:ee,viewModeButtons:e(vd,{size:14}),viewModeActions:de,previewLabel:p?"Show source":"Show preview",findLabel:"Find and replace",wordWrapLabel:l?"Word wrap on":"Word wrap off",copyLabel:h?"Copied":y?"Copy image":"Copy content",maximizeLabel:le,onTogglePreview:z,onToggleReview:I,onToggleFind:A,onToggleWordWrap:W,onToggleBlameInline:()=>{let be={...xi(),inline:!ne.inline};gr({editorBlameInline:be.inline}),window.dispatchEvent(new CustomEvent(ys,{detail:be}))},onZoomIn:R,onZoomOut:L,onCopy:G,onDownload:X,onReload:Y,onSaveAs:J,onToggleMaximize:Q,onSave:F});return e("div",{className:"@container flex items-center justify-between gap-2 px-3 py-2 border-b border-ink/10 bg-paper flex-shrink-0",children:[e("div",{className:"hidden @[420px]:flex items-center space-x-2 text-xs font-mono text-ink/40 min-w-0",children:e("span",{className:"truncate max-w-[300px]",title:t,children:t})}),e(Ho,{clusters:ce,className:"text-ink/40 ml-auto"})]})}function ut({content:t,file:r,zoomLevel:l,reviewActive:c,onExitReview:p,scrollRef:g,onScroll:v}){return e("div",{ref:g,onScroll:v,"data-testid":"editor-scroller",className:"flex-1 overflow-auto bg-paper flex",children:e("div",{className:"p-6 max-w-4xl mx-auto font-sans flex-1",style:{fontSize:`${l}px`},children:e(Gc,{content:t,file:r,active:c,onExit:p})})})}function En(t,r){return r?`Spaces: ${t}`:"Tabs"}function pt({caret:t,eol:r,onSetEol:l,indentWidth:c,insertSpaces:p,language:g,byteViewer:v,viewerKind:h,lineCount:y,conflicts:w=0}){return e("footer",{className:"flex bg-canvas border-t border-ink/10 px-3 items-center justify-between text-[10px] text-ink/50 flex-shrink-0 font-mono h-6","data-editor-status-bar":"",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:v?e("span",{className:"uppercase",children:Uo[h]}):e(d,{children:[e("span",{className:"tabular-nums",children:t?`Ln ${t.line}, Col ${t.column}`:"Ln —, Col —"}),e("span",{children:En(c,p)}),e("button",{type:"button",onClick:()=>l(r==="lf"?"crlf":"lf"),className:"uppercase hover:text-ink transition-colors cursor-pointer",title:`Line endings: ${r.toUpperCase()} — click to switch`,"aria-label":`Line endings ${r.toUpperCase()}, switch`,children:r}),e("span",{children:[y," lines"]})]})}),e("div",{className:"flex items-center gap-3 min-w-0",children:[w>0&&e("span",{className:"text-error font-semibold tabular-nums",title:`${w} unresolved conflict${w===1?"":"s"} — markers are highlighted in the file`,children:["⚠ ",w," conflict",w===1?"":"s"]}),e("span",{className:"uppercase text-ink/40",children:g})]})]})}function Tn(t){if(t===0)return 0;return Math.max(-1,Math.min(1,-Math.sign(t)))}function Mn(t,r,l=tl,c=nl){return Math.max(l,Math.min(c,t+r))}function Nn(t,r){let l=t instanceof HTMLElement?t:null;while(l&&l!==r){let c=getComputedStyle(l);if(/(auto|scroll)/.test(c.overflowY)&&l.scrollHeight>l.clientHeight)return!0;l=l.parentElement}return!1}function ft(t,r){o(()=>{if(!t)return;let l=t.closest("[data-code-surface]"),c=l instanceof HTMLElement?l:t,p=(g)=>{if(!g.ctrlKey&&!g.metaKey)return;if(g.preventDefault(),Nn(g.target,c))return;let v=Tn(g.deltaY);if(v===0)return;r((h)=>Mn(h,v))};return t.addEventListener("wheel",p,{passive:!1}),()=>t.removeEventListener("wheel",p)},[t,r])}function bt(t,r){let l=t.trim();if(!/^\d+$/.test(l))return null;let c=Number(l);if(c<1)return null;return Math.min(c,Math.max(r,1))}function ht({lineCount:t,onGo:r,onClose:l}){let[c,p]=n(""),g=i(null);o(()=>{g.current?.focus(),g.current?.select()},[]);let v=()=>{let w=bt(c,t);if(w===null)return;r(w)},h=(w)=>{if(w.key==="Enter"){w.preventDefault(),v();return}if(w.key==="Escape")w.preventDefault(),l()},y=bt(c,t);return e(Z,{onClose:l,maxWidthClass:"max-w-xs",header:e("span",{className:"text-sm font-semibold text-ink",children:"Go to line"}),children:e("div",{className:"px-4 py-3 space-y-2",children:[e("div",{className:"flex items-center gap-2",children:[e("input",{ref:g,value:c,onInput:(w)=>p(w.target.value),onKeyDown:h,inputMode:"numeric",placeholder:"1","aria-label":"Line number",className:"flex-1 bg-paper border border-ink/20 rounded px-2 py-1 text-xs font-mono text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10px] font-mono text-ink/40",children:["/ ",t]}),e("button",{type:"button",onClick:v,disabled:y===null,className:"flex items-center gap-1 px-2 py-1 rounded bg-ink text-paper text-xs disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[e(gt,{size:12}),"Go"]})]}),c&&y!==null&&String(y)!==c.trim()?e("div",{className:"text-[10px] text-ink/50 font-mono",children:["line ",y," (the last line)"]}):null,c&&y===null?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a line number"}):null]})})}var vt={status:"idle",payload:null,message:null};function yt(t){if(!t?.path)return"";return`${t.root??""}\x00${t.repo??""}\x00${t.path}`}function xt(t,r={}){let l=r.enabled!==!1&&Boolean(t?.path)&&t?.deviceFile!==!0,c=r.dirty===!0,p=yt(t),[g,v]=n({key:"",value:vt}),h=i(t);h.current=t;let y=i(p);y.current=p;let w=i(l);w.current=l;let x=i(c);x.current=c;let k=i(g);k.current=g;let O=i(0),C=i(""),M=i(new Map),A=i(new Set),F=a(async()=>{let L=h.current;if(!L?.path)return;let G=yt(L),X=++O.current;C.current=G,v((N)=>({key:G,value:{status:"loading",payload:N.key===G?N.value.payload:null,message:null}}));let Y=new URLSearchParams({blame:"1",file:L.path,repo:L.repo||"."});if(L.root)Y.set("root",L.root);try{let N=await fetch(`/api/fs/git?${Y.toString()}`),P=await N.json().catch(()=>null);if(X!==O.current)return;if(!N.ok||!P){v({key:G,value:{status:"error",payload:null,message:P?.error??`Blame request failed (HTTP ${N.status})`}});return}v({key:G,value:P.available?{status:"ready",payload:P,message:null}:{status:"unavailable",payload:P,message:P.message??null}})}catch(N){if(X!==O.current)return;v({key:G,value:{status:"error",payload:null,message:N instanceof Error?N.message:"Blame failed"}})}finally{if(C.current===G)C.current=""}},[]),z=a(async(L)=>{let G=M.current.get(L);if(G)return G;let X=h.current;if(!X?.path)return{entries:[],truncated:!1};let Y=new URLSearchParams({blameHistory:"1",file:X.path,line:String(L),repo:X.repo||"."});if(X.root)Y.set("root",X.root);try{let P=await(await fetch(`/api/fs/git?${Y.toString()}`)).json().catch(()=>null),H={entries:Array.isArray(P?.entries)?P.entries:[],truncated:P?.truncated===!0};return M.current.set(L,H),H}catch{return{entries:[],truncated:!1}}},[]),I=i(null);if(!I.current)I.current={ensure:()=>{if(!w.current||x.current)return;let L=k.current;if(L.key===y.current&&L.value.status!=="idle")return;if(C.current===y.current)return;F()},reload:()=>{M.current.clear(),F()},history:z,snapshot:()=>{let L=k.current;return L.key===y.current?L.value:vt},stale:()=>x.current,subscribe:(L)=>(A.current.add(L),()=>{A.current.delete(L)})};o(()=>{if(!l||c||!p)return;M.current.clear(),F()},[l,c,p,F]);let W=i(c);return o(()=>{if(W.current===c)return;W.current=c;for(let L of A.current)L()},[c]),o(()=>{for(let L of A.current)L()},[g]),I.current}var Rn="0".repeat(40);function Me(t){return t===Rn}function ye(t,r=Date.now()){let l=Math.max(0,Math.floor(r/1000)-t);if(l<60)return"just now";let c=Math.floor(l/60);if(c<60)return`${c}m ago`;let p=Math.floor(c/60);if(p<24)return`${p}h ago`;let g=Math.floor(p/24);if(g<30)return`${g}d ago`;let v=Math.floor(g/30);if(v<12)return`${v}mo ago`;return`${Math.floor(g/365)}y ago`}function wt(t,r){switch(t){case"not-repo":return"This folder is not a git repository.";case"no-commit":return"This repository has no commits yet.";case"untracked":return"This file has never been committed, so it has no history.";case"too-large":return r??"This file is too large to blame.";case"empty":return"This file is empty.";default:return r??"git could not read this file."}}var Et="fixed z-50 w-[min(340px,92vw)] rounded-xl border border-ink/20 bg-paper p-3 shadow-xl font-sans text-xs text-ink",kt="flex items-baseline justify-between gap-2",St="truncate text-xs font-semibold text-ink",Pn="shrink-0 font-mono text-[10px] text-ink/40",Ln="mt-1 line-clamp-2 text-[11px] leading-snug text-ink/80",Bn="mt-2 border-t border-ink/10 pt-2",Dn="flex items-center gap-2 font-mono text-[10px] text-ink/40",Ct="mt-1 text-[10px] leading-snug text-ink/50",On="mt-2 flex w-full items-center gap-1.5 text-left text-[10px] text-ink/50 hover:text-ink cursor-pointer",An="mt-1.5 space-y-1 border-t border-ink/10 pt-1.5",Ne="flex items-center gap-1.5 font-mono text-[10px]";function q(t,r,l){let c=document.createElement(t);if(c.className=r,l!==void 0)c.textContent=l;return c}function In(t){return new Date(t*1000).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}function Fn(t){let r=t.payload;if(t.status==="error")return{title:"Blame failed",body:t.message??"git could not read this file."};if(t.status==="unavailable")return{title:r?.reason==="untracked"?"Not tracked":"No history",body:wt(r?.reason??"error",t.message??void 0)};if(!r)return null;if(t.stale)return{title:"Not committed yet",body:"This line changed in the editor. Save the file to see its blame."};if(t.line>r.lines)return{title:"Not committed yet",body:`Line ${t.line} is past the end of the file at HEAD (${r.lines} lines).`};let l=r.runs.length>0?Tt(r,t.line):null;if(!l)return{title:"Not committed yet",body:`git has no attribution for line ${t.line}.`};if(Me(l.sha))return{title:"Not committed yet",body:"This line differs from the last commit."};return null}function Tt(t,r){for(let l of t.runs)if(r>=l.from&&r<=l.to)return t.commits[l.sha]??null;return null}function zn(t,r){t.replaceChildren(),t.className=Et;let l=Fn(r);if(l){let w=q("div",kt);if(w.append(q("span",St,l.title)),r.status==="error"&&r.message){let x=q("button","shrink-0 cursor-pointer text-[10px] text-ink/50 hover:text-ink","Try again");x.type="button",x.setAttribute("aria-label","Read the blame again"),w.append(x)}t.append(w,q("p",Ct,l.body));return}let c=r.payload;if(!c){t.append(q("p",Ct,"Reading blame…"));return}let p=Tt(c,r.line),g=q("div",kt);if(g.append(q("span",St,p.author.trim()||"Unknown"),q("span",Pn,ye(p.time))),t.append(g),p.summary)t.append(q("p",Ln,p.summary));let v=q("div",`${Dn} ${Bn}`);if(v.append(q("code","truncate",p.sha.slice(0,7)),q("span","",In(p.time))),p.mail){let w=q("span","truncate",p.mail);w.title=p.mail,v.append(w)}t.append(v);let h=q("button",On);if(h.type="button",h.setAttribute("aria-expanded",r.historyOpen?"true":"false"),h.textContent=`${r.historyOpen?"▾":"▸"} Line history`,t.append(h),!r.historyOpen)return;let y=q("ol",An);if(r.historyLoading)y.append(q("li",`${Ne} text-ink/40`,"Reading history…"));else if(!r.history||r.history.entries.length===0)y.append(q("li",`${Ne} text-ink/40`,"No commits touched this line."));else{let w=r.history.entries;if(w.forEach((x,k)=>{let O=q("li",Ne),C=k===w.length-1?"new":"edit";O.append(q("span","text-ink/40",k===0?"●":"○"),q("code","text-ink/60",x.sha.slice(0,7)),q("span","truncate text-ink/80",x.author.trim()||"Unknown"),q("span","ml-auto shrink-0 text-ink/40",ye(x.time)),q("span","shrink-0 rounded bg-ink/5 px-1 text-[8.5px] uppercase tracking-wider text-ink/45",C)),y.append(O)}),r.history.truncated)y.append(q("li",`${Ne} text-ink/40`,"Older commits are not shown."))}t.append(y)}function Mt(t,r,l){let c=q("div",Et);c.setAttribute("role","dialog"),c.setAttribute("aria-label","Line blame"),c.addEventListener("mousedown",(x)=>x.stopPropagation());let p=null,g=!1,v=!1,h=()=>{let x=r.snapshot();return{line:t,status:x.status,payload:x.payload,message:x.message,stale:r.stale(),history:p,historyOpen:g,historyLoading:v}},y=()=>{zn(c,h());let x=c.querySelector('[aria-label="Read the blame again"]');if(x)x.addEventListener("click",(k)=>{k.stopPropagation(),l()});c.querySelector("button[aria-expanded]")?.addEventListener("click",(k)=>{if(k.stopPropagation(),g=!g,y(),!g||p||v)return;v=!0,y(),r.history(t).then((O)=>{p=O,v=!1,y()})})};y();let w=r.subscribe(y);return{element:c,place(x){let k=c.ownerDocument.defaultView,O=k?.innerWidth??1024,C=k?.innerHeight??768,M=c.offsetWidth||340,A=c.offsetHeight||120,F=8,z=Math.max(8,Math.min(x.left,O-M-8)),I=x.bottom+6,W=x.top-A-6,R=I+A>C-8&&W>8?W:I;c.style.left=`${z}px`,c.style.top=`${Math.max(8,R)}px`},destroy(){w(),c.remove()}}}function Nt(t){return ve.define((r)=>{let l=null,c=0,p,g=()=>{clearTimeout(p),p=void 0,l?.destroy(),l=null,c=0},v=(C,M)=>{let A=C.getBoundingClientRect();if(A.width>0)return{left:A.left,top:A.top,bottom:A.bottom};let F=r.state.doc.line(Math.min(M,r.state.doc.lines)),z=null;try{z=r.coordsAtPos(F.from)}catch{z=null}if(z)return z;let I=r.scrollDOM.getBoundingClientRect();return{left:I.left,top:I.top+24,bottom:I.top+24}},h=(C,M)=>{if(c===C&&l)return;g(),c=C,l=Mt(C,t,()=>{t.reload(),g()}),document.body.append(l.element),l.place(M)},y=(C)=>{let M=C.target,A=M?.closest?.(".cm-blame-label");if(A){let I=Number(A.dataset.blameLine);return Number.isInteger(I)&&I>0?{line:I,anchor:A}:null}let F=M?.closest?.(".cm-lineNumbers .cm-gutterElement");if(!F)return null;let z=Number((F.textContent??"").trim());return Number.isInteger(z)&&z>0?{line:z,anchor:F}:null},w=(C)=>{let M=y(C);if(!M)return;h(M.line,v(M.anchor,M.line))},x=(C)=>{let M=y(C);if(M){C.preventDefault(),h(M.line,v(M.anchor,M.line));return}if(l&&!l.element.contains(C.target))g()},k=(C)=>{if(C.key==="Escape"&&l)g(),C.stopPropagation()},O=(C)=>{if(!l)return;let M=C.relatedTarget;if(M&&(l.element.contains(M)||r.scrollDOM.contains(M)))return;p=setTimeout(g,200)};return r.scrollDOM.addEventListener("mouseover",w),r.scrollDOM.addEventListener("mouseleave",O),r.scrollDOM.addEventListener("mousedown",x),document.addEventListener("mousedown",x),document.addEventListener("keydown",k,!0),{update(C){if(C.docChanged&&l)g()},destroy(){g(),r.scrollDOM.removeEventListener("mouseover",w),r.scrollDOM.removeEventListener("mouseleave",O),r.scrollDOM.removeEventListener("mousedown",x),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",k,!0)}}})}var Rt=40,Lt=ae.define();function Hn(t){return Le.define({create:()=>({payload:t.snapshot().payload,stale:!1}),update(r,l){let c=r;for(let p of l.effects){if(!p.is(Lt))continue;c=p.value.payload!==r.payload?{payload:p.value.payload,stale:!1}:{payload:r.payload,stale:r.stale}}if(l.docChanged&&!c.stale)c={payload:c.payload,stale:!0};return c}})}function $n(t,r,l){let c=t.commits[r];if(!c||Me(r))return null;let p=c.author.trim()||"Unknown";return l?p:`${p} · ${ye(c.time)}`}class Bt extends Yt{constructor(t,r,l){super();this.line=t;this.text=r;this.title=l}eq(t){return t.line===this.line&&t.text===this.text&&t.title===this.title}toDOM(){let t=document.createElement("span");return t.className="cm-blame-label",t.dataset.blameLine=String(this.line),t.title=this.title,t.textContent=this.text,t}}function Pt(t,r,l){let{payload:c,stale:p}=t;if(!c?.available||p)return T.none;let g=Math.min(c.lines,r.state.doc.lines);if(g<1)return T.none;let v=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.from,r.state.doc.length))).number,h=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.to,r.state.doc.length))).number,y=Math.max(1,v-Rt),w=Math.min(g,h+Rt),x=[];for(let k of c.runs){let O=Math.max(k.from,y);if(O>k.to||O>w)continue;let C=$n(c,k.sha,l);if(!C)continue;let M=c.commits[k.sha],A=r.state.doc.line(O);x.push({from:A.to,deco:T.widget({widget:new Bt(A.number,C,M.summary||M.sha),side:1})})}return T.set(x.map((k)=>k.deco.range(k.from)),!0)}function Vn(t,r){return ve.fromClass(class{constructor(l){this.view=l;this.decorations=Pt(l.state.field(t),l,r)}update(l){if(l.startState.field(t)===l.state.field(t)&&!l.docChanged&&!l.viewportChanged)return;this.decorations=Pt(l.state.field(t),l.view,r)}},{decorations:(l)=>l.decorations})}function Wn(t){return ve.define((r)=>{let l=!0,c=()=>{if(!l)return;let g=t.snapshot();r.dispatch({effects:Lt.of({payload:g.payload,stale:!1})})},p=t.subscribe(c);return{destroy(){l=!1,p()}}})}function Dt({controller:t,inline:r=!0,compact:l=!1}){let c=Hn(t);return[c,Wn(t),r?Vn(c,l):[],Nt(t)]}function Ot({activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:p,rootPath:g=null,repoPath:v=null,onRunCommand:h,wordWrap:y,zoomLevel:w,setZoomLevel:x,editorFontFamily:k,editorTheme:O,viewerKind:C,isPreview:M,reviewActive:A,onToggleReview:F,revealActive:z}){let I=C==="markdown",W=su(),R=cu(),L=Sd(),G=xt({name:t.name,path:t.path,root:t.root??g??void 0,repo:t.repo??v??"."},{enabled:L.enabled,dirty:r.isDirty}),X=u(()=>L.enabled?Dt({controller:G,inline:L.inline}):null,[L.enabled,L.inline,G]),[Y,N]=n(null),P=u(()=>jc(r.content),[r.content]),[H,J]=n(!1);o(()=>{if(p>0)J(!0)},[p]);let[Q,te]=n(null),[ie,le]=n(null);ft(Q,x);let ee=pl({tabKey:String(t.id),surface:I&&M?"rendered":"code",ready:r.loaded,element:I&&M?void 0:Q}),ne=a((de)=>{ee.ref(de),le(de)},[ee.ref]);return Wc({path:t.path,scroller:ie,preview:I&&M}),e("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[l.open?e(Hc,{find:l}):null,H?e(ht,{lineCount:r.content?r.content.split(`
2
- `).length:1,onGo:(de)=>{J(!1);let ce=Ar(r.content,de-1);c.current?.select(ce,ce,!0),c.current?.revealOffset(ce)},onClose:()=>J(!1)}):null,I&&M?e(ut,{content:r.content,file:{name:t.name,path:t.path,root:t.root,repo:t.repo},zoomLevel:w,reviewActive:A,onExitReview:F,scrollRef:ne,onScroll:ee.onScroll}):e(qc,{ref:c,value:r.content,onValueChange:r.onChange,language:r.language,wordWrap:y,documentKey:String(t.id),marks:l.open||z?l.matches:void 0,currentMark:l.currentIndex,onCommand:h,onScroller:te,onCaret:N,scrollTestId:"editor-scroller",className:"flex-1 min-h-0 text-ink select-text",blame:X,themeVars:O.vars,themes:O.themes,indentUnitText:iu(W),typing:R,padding:16,placeholder:"This file is empty",style:{fontFamily:k,fontSize:`${w}px`,lineHeight:el}}),!I||!M?e(pt,{caret:Y,eol:r.eol,onSetEol:r.setEol,indentWidth:W.width,insertSpaces:W.insertSpaces,language:r.language,byteViewer:r.isBinaryViewer,viewerKind:C,lineCount:r.content?r.content.split(`
3
- `).length:0,conflicts:P}):null]})}function At({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:g,setWordWrap:v,viewerKind:h,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:O,zoomLevel:C,setZoomLevel:M,goToLineRequest:A,onSaveAs:F,rootPath:z=null,repoPath:I=null,runCommand:W,editorFontFamily:R,editorTheme:L,togglePreview:G,revealActive:X,missing:Y}){let N=h==="image"||h==="pdf"||h==="docx"||h==="spreadsheet",P=As[h]===!0,H=a(async(J)=>{let Q=await Jc(t,J,{interactive:!0,baseMtimeMs:r.baseMtimeMs});if(Q.status==="written")return{ok:!0};if(Q.status==="conflict")return{ok:!1,error:"This file changed on disk since it was opened."};if(Q.status==="needs-permission")return{ok:!1,error:"Click Save again to grant write access."};return{ok:!1,error:Q.error}},[t,r.baseMtimeMs]);return e(d,{children:[e(mt,{path:t.path,saveStatus:r.saveStatus,wordWrap:g,hasPreview:P,isPreview:y,hasReview:h==="markdown"&&y,isReviewing:w,copied:r.copied,byteViewer:N,saveDisabled:Boolean(r.loadError)||r.handleMissing||r.deviceBacked,unsupported:Boolean(r.unsupported),handleMissing:r.handleMissing,readOnly:r.deviceBacked,isMaximized:k,findOpen:l.open,onToggleFind:()=>l.open?l.close():l.openFind(),onSave:r.saveNow,onTogglePreview:G,onToggleReview:x,onToggleWordWrap:()=>v(!g),onZoomIn:()=>M((J)=>Math.min(nl,J+1)),onZoomOut:()=>M((J)=>Math.max(tl,J-1)),onCopy:r.copy,onDownload:r.download,onReload:r.reloadFromDisk,onSaveAs:F,canReload:kl(t)&&!r.loadError&&!r.unsupported,refreshing:r.isReading,reloadDiscardsEdits:r.isDirty,onToggleMaximize:()=>O(!k)}),Y&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-error/30 bg-error/10 text-error",children:[e(S,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was deleted from disk."}),e("div",{className:"text-[11px] font-sans text-error/80",children:"The buffer is still here. Saving recreates the file — autosave is off until then."})]})]}),r.conflict&&e(Te,{diskMtimeMs:r.conflict.diskMtimeMs,fileName:t.name,onReload:r.resolveConflictByReload,onKeepMine:r.resolveConflictByKeepingMine}),r.handleMissing&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-warning",children:[e(S,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was opened by the system, not from a workspace."}),e("div",{className:"text-[11px] font-sans text-warning/80",children:"Its write permission ended with the last page load. Reopen the file from the OS to edit it again."})]})]}),r.deviceBacked&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-ink/20 bg-ink/5 text-ink/70",children:[e(S,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:r.deviceMissing?"The bytes for this file did not survive the reload.":"Opened from this device, so it is read-only here."}),e("div",{className:"text-[11px] font-sans text-ink/50",children:r.deviceMissing?"A phone's file lives only on the phone, so it cannot be re-read. Open it again from the app that shared it.":"The console cannot reach a file on your phone. Copy it into a workspace to edit it."})]})]}),r.isImage&&r.imageUrl?e(yi,{src:r.imageUrl,name:t.name,className:"flex-1 min-h-0"}):r.isImage?e(vl,{kind:"image",path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision}):r.isLoading?e("div",{className:"flex-1 flex items-center justify-center gap-2 text-ink/40 text-xs font-mono",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Loading file content…"})]}):r.unsupported?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(zc,{size:20,className:"text-ink/40"}),e("span",{className:"text-xs text-ink/70 font-sans",children:[t.name," cannot be opened here"]}),e("span",{className:"text-[11px] text-ink/50 font-sans max-w-[42ch]",children:r.unsupported})]}):r.loadError?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(S,{size:20,className:"text-error"}),e("span",{className:"text-xs text-error font-sans",children:["Could not read ",t.name]}),e("span",{className:"text-[11px] text-ink/50 font-mono break-all",children:r.loadError})]}):p&&!r.isImage?e(Ng,{view:p}):Vc(h)&&(N||y)?e(vl,{kind:h,path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision,onContentChange:r.onChange,onSaveBytes:r.deviceBacked?void 0:H,onDirtyChange:r.setBinaryDirty}):e(Ot,{activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:A,rootPath:z,repoPath:I,onRunCommand:W,wordWrap:g,zoomLevel:C,setZoomLevel:M,editorFontFamily:R,editorTheme:L,isPreview:y,reviewActive:w,onToggleReview:x,viewerKind:h,revealActive:X})]})}function It({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:g,setWordWrap:v,viewerKind:h,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:O,zoomLevel:C,setZoomLevel:M,goToLineRequest:A,onSaveAs:F,rootPath:z=null,repoPath:I=null,runCommand:W,editorFontFamily:R,editorTheme:L,togglePreview:G,revealActive:X,missing:Y,onConvertDiffToEditor:N,onFileSaved:P}){if(!t)return e("div",{className:"flex-1 flex items-center justify-center text-ink/40",children:e("p",{className:"font-mono text-sm",children:"Select a tab to view content"})});if(t.isDiff)return e(Uc,{filePath:t.path,status:t.diffStatus||"M",isStaged:Boolean(t.diffStaged),root:t.root,repo:t.repo||".",journalDiff:t.journalDiff,readOnly:t.diffSource==="journal",onOpenInEditor:()=>N(t.id),onFileSaved:P,className:"flex-1",tabKey:String(t.id)});return e(At,{activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:g,setWordWrap:v,viewerKind:h,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:O,zoomLevel:C,setZoomLevel:M,goToLineRequest:A,onSaveAs:F,rootPath:z,repoPath:I,runCommand:W,editorFontFamily:R,editorTheme:L,togglePreview:G,revealActive:X,missing:Y})}function Ft({pluginId:t,Component:r,sessionId:l,className:c="",onHide:p}){return e("div",{className:`flex flex-col h-full bg-canvas ${c}`,children:[p&&e("div",{className:"flex justify-end flex-shrink-0 border-b border-ink/10",children:e(fe,{onHide:p})}),e(Ze,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})]})}function zt({className:t="",onHide:r}){return e("div",{className:`relative flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[r&&e("div",{className:"absolute top-0 right-0 flex items-center",children:e(fe,{onHide:r})}),e(st,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Ht({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let c=i(null);o(()=>{if(!t||c.current===t.request)return;c.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function $t({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:c,setPreviewMode:p,sessionId:g}){o(()=>{let v=new Set(t.filter((h)=>!h.isDiff&&h.content===void 0).map((h)=>h.id));_e([...r].filter((h)=>v.has(h)))},[r,t]),o(()=>{if(!c)return;let v=l?.id;if(!l||v===void 0||v===null)return;if(!As[hs(l.name)])return;let h=Se(g,"editor.previewMode");if(h&&h[v]!==void 0)return;p((y)=>y[v]===void 0?{...y,[v]:!0}:y)},[c,l])}function Vt({activeFile:t,externalChange:r,conflict:l,onReload:c,onKeepMine:p}){if(!t)return null;if(l)return e(Te,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:c,onKeepMine:p});if(r)return e(nu,{fileName:t.name,onReload:c,onKeepMine:p});return null}async function Wt(t){let r=t.name.trim();if(!r)return{status:"failed",reason:"Enter a file name."};let l=new FormData;if(l.append("actionType","saveAs"),l.append("path",t.parent),l.append("name",r),l.append("content",t.content),l.append("eol",t.eol),t.root)l.append("root",t.root);if(t.repo&&t.repo!==".")l.append("repo",t.repo);try{let c=await fetch("/api/fs/action",{method:"POST",body:l}),p=await c.json().catch(()=>null),g=typeof p?.error==="string"?p.error:null;if(c.status===409)return{status:"exists",reason:g??`${r} already exists.`};if(c.ok&&p?.success&&typeof p.path==="string")return{status:"written",path:p.path};return{status:"failed",reason:g??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Kt(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Ut(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function Kn(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function Gt({fileName:t,filePath:r,content:l,eol:c,root:p,repo:g,onSaved:v,onClose:h}){let[y,w]=n(()=>Kn(r)),[x,k]=n(()=>Kt(t)),[O,C]=n(!1),[M,A]=n(null),F=i(null);o(()=>{F.current?.focus(),F.current?.select()},[]);let z=Ut(x),I=async()=>{if(!z||O)return;C(!0),A(null);let R=await Wt({parent:y,name:x,content:l,eol:c,root:p,repo:g});if(C(!1),R.status==="written"){v({path:R.path});return}A(R.reason)},W=(R)=>{if(R.key==="Enter"){R.preventDefault(),I();return}if(R.key==="Escape")R.preventDefault(),h()};return e(Z,{onClose:h,maxWidthClass:"max-w-md",header:e("span",{className:"text-sm font-semibold text-ink",children:"Save as"}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>void I(),disabled:!z||O,className:"flex items-center gap-1.5 px-3 py-1.5 rounded bg-ink text-paper disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[O?e(m,{size:12,className:"animate-spin"}):e(gt,{size:12}),"Save"]})]}),children:e("div",{className:"px-4 py-3 space-y-2 text-xs",children:[e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Folder"}),e("input",{value:y,onInput:(R)=>w(R.target.value),onKeyDown:W,placeholder:"(workspace root)","aria-label":"Destination folder",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"})]}),e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Name"}),e("input",{ref:F,value:x,onInput:(R)=>k(R.target.value),onKeyDown:W,"aria-label":"File name","aria-invalid":!z,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${z?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!z?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,M?e("div",{className:"text-[10px] text-error font-mono",children:M}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function qt(){o(()=>{let t=(r)=>{if(!Xe())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function Zt({fileName:t,onAnswer:r}){return e(Z,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(S,{size:15,className:"text-warning"}),e("span",{className:"text-sm font-semibold text-ink",children:"Unsaved changes"})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:()=>r("cancel"),className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>r("discard"),className:"px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer",children:"Discard"}),e("button",{type:"button",onClick:()=>r("save"),className:"px-3 py-1.5 rounded bg-ink text-paper hover:bg-ink/90 transition-colors cursor-pointer",children:"Save & close"})]}),children:e("div",{className:"px-4 py-3 text-xs text-ink/80",children:[e("span",{className:"font-mono text-ink",children:t})," has changes that are not on disk.",e("div",{className:"mt-1 text-ink/50",children:"Discarding them cannot be undone."})]})})}function jt({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:c,onConfirmSaveMissing:p}){if(t.pending)return e(Zt,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(ru,{fileName:r.name,filePath:r.path,onClose:c,onConfirm:p});return null}function Jt({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:c,asSplitPane:p,tabs:g,activeFile:v,editor:h,externalChange:y,conflict:w,onReload:x,onKeepMine:k,body:O,saveAsOpen:C,onSaveAsClose:M,onSavedAs:A,closeGuard:F}){let z=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:z,onKeyDownCapture:l,onFocusCapture:c,children:[p?null:g,e(Vt,{activeFile:v,externalChange:y,conflict:w,onReload:x,onKeepMine:k}),O,C&&v?e(Gt,{fileName:v.name,filePath:v.path,content:h.content,eol:h.eol,root:v.root,repo:v.repo,onSaved:({path:I})=>A(I),onClose:M}):null,e(jt,{closeGuard:F,activeFile:v,saveMissingConfirm:h.saveMissingConfirm,onCancelSaveMissing:h.cancelSaveMissing,onConfirmSaveMissing:h.confirmSaveMissing})]})}function Qt({fileName:t,onClose:r,children:l}){return e("div",{className:"flex flex-col h-full min-w-0","data-split-pane":"",children:[e("div",{className:"flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:[e("span",{className:"text-[11px] font-mono text-ink/60 truncate",title:t,children:t}),e("button",{type:"button",onClick:r,className:"p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0",title:"Close this pane (the tab stays open)","aria-label":"Close split pane",children:e(b,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function en({fraction:t,onFraction:r,rightPaneName:l,onClosePane:c,rightPane:p,children:g}){let v=i(null),h=i(null),y=Pm(h),w=(x)=>{let k=x.currentTarget,O=v.current;if(!k||!O)return;k.setPointerCapture(x.pointerId);let C=(A)=>{let F=O.getBoundingClientRect();if(F.width===0)return;r(pe((A.clientX-F.left)/F.width))},M=()=>{k.releasePointerCapture(x.pointerId),k.removeEventListener("pointermove",C),k.removeEventListener("pointerup",M)};k.addEventListener("pointermove",C),k.addEventListener("pointerup",M)};return e("div",{ref:v,className:"flex w-full h-full","data-split-column":"",children:[e("div",{className:"flex flex-col min-w-0 h-full",style:{width:`${Math.round(pe(t)*100)}%`},children:g}),e("div",{ref:h,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${y?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:w}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Qt,{fileName:l,onClose:c,children:p})})]})}function tn({openedFiles:t,activeFileId:r,enabled:l}){let[c,p]=_("editor.split",he),g=t.map((k)=>k.id),v=et(tt(c,g),r),h=l&&v.rightFileId!==null?t.find((k)=>k.id===v.rightFileId)??null:null,y=a((k)=>{if(k!==null&&!Ee(k,r,g))return;p({...v,rightFileId:k})},[v,p,r,g]),w=a(()=>p({...v,rightFileId:null}),[v,p]),x=a((k)=>p({...v,fraction:pe(k)}),[v,p]);return{rightFile:h,fraction:v.fraction,splitTo:y,close:w,setFraction:x}}function nn({find:t,runCommand:r,reopenClosed:l}){let c=i(t);c.current=t;let p=i(r);p.current=r;let g=i(l);return g.current=l,{onKeyDownCapture:a((h)=>{let y=c.current;if(h.key==="Escape"){if(!y.open)return;h.preventDefault(),h.stopPropagation(),y.close();return}if((h.metaKey||h.ctrlKey)&&h.shiftKey&&h.code==="KeyT"){if(g.current?.())h.preventDefault(),h.stopPropagation();return}let w=lh(hi,h);if(!w||!mf(w))return;h.preventDefault(),h.stopPropagation(),p.current(w)},[])}}function on(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(p)=>r.current.runCommand(p)};return o(()=>{let p=l.current;if(!p)return;return Bg(p)},[]),{onFocusCapture:a(()=>{if(l.current)Bg(l.current)},[])}}function rn({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,saveNow:p}){let[g,v]=n(null);qt();let h=a((w)=>{let x=t.find((k)=>k.id===w);if(x&&qe(w)){v(x);return}c(w)},[t,c]),y=a((w)=>{let x=g;if(!x)return;if(w==="cancel"){v(null);return}if(w==="save"){if(x.id!==r)l(x.id);p()}v(null),c(x.id)},[g,r,l,p,c]);return{requestClose:h,pending:g,answer:y}}function an(){let[t,r]=n(0),[l,c]=n(!1),p=a(()=>r((g)=>g+1),[]);return{goToLineRequest:t,openGoToLine:p,saveAsOpen:l,setSaveAsOpen:c}}function Un({className:t="",openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:g,refreshKey:v=0,onFileSaved:h,onOpenPath:y,onReopenClosed:w,reopenableCount:x,onCopyPath:k,onRevealInFiles:O,rootPath:C=null,repoPath:M=null,activeEditorPanelKey:A=null,forcedActiveFileId:F=null,asSplitPane:z=!1,onHidePanel:I}){let W=z?F:l,R=r.find((V)=>V.id===W),[L,G,X]=_("editor.previewMode",{}),Y=au(String(W??"")),[N,P]=_("editor.zoomLevel",Io),[H,J]=n(!1),[Q,te]=_("editor.wordWrap",!0),ie=an(),{sessionId:le}=je(),ee=tn({openedFiles:r,activeFileId:W,enabled:!z}),ne=i(null),de=So(),ce=ki(),be=Yc(r,v),Ae=Boolean(R&&be.has(R.id)),j=Zc(R??null,{reportSaveError:!0,onFileSaved:h,missing:Ae}),sn=Dg({path:R?.path??"",content:j.content,language:j.language}),ln=j.diskChange,Ie=rn({openedFiles:r,activeFileId:W,onSelectFile:c,onCloseFile:p,saveNow:j.saveNow}),xe=Xc({text:j.content,documentKey:`${R?.id??""}\x00${j.language}`,readSelection:()=>ne.current?.getSelection()??null,select:(V,ue,Be=!0)=>ne.current?.select(V,ue,Be),reveal:(V)=>ne.current?.revealOffset(V),applyDocument:(V,ue,Be)=>ne.current?.applyDocument(V,ue,Be),toggleWordWrap:()=>te((V)=>!V)}),Fe=eu(R?.path??null,j.content,j.loaded&&!j.loadError);Ht({searchReveal:Fe,revealMatch:xe.revealMatch}),tu({file:R,editor:j,surfaceRef:ne,isPreview:R?L[R.id]===!0:!1,exitPreview:()=>{let V=R?.id;if(V===void 0||V===null)return;G((ue)=>({...ue,[V]:!1}))}}),o(()=>{if(v>0)j.reset()},[v]),o(()=>{j.retain(r.map((V)=>V.id)),Ge(r.map((V)=>V.id))},[r]),$t({openedFiles:r,dirtyKeys:j.dirtyKeys,activeFile:R,previewReady:X,setPreviewMode:G,sessionId:le});let dn=()=>{if(!R)return;G((V)=>({...V,[R.id]:!V[R.id]}))},Re=(V)=>{if(mf(V)){xe.runCommand(V);return}if(V==="toggleWordWrap"){te((ue)=>!ue);return}if(V==="goToLine"){ie.openGoToLine();return}ne.current?.runCommand(V)},mn=nn({find:xe,runCommand:Re,reopenClosed:w}),un=on({saveNow:j.saveNow,runCommand:Re}),Pe=kh(A);if(Pe)return e(Ft,{pluginId:Pe.pluginId,Component:Pe.Component,sessionId:le,className:t,onHide:I});if(r.length===0)return e(zt,{className:t,onHide:I});let pn=j.viewerKind,ze=R?L[R.id]:!1,fn={activeFile:R,editor:j,find:xe,surfaceRef:ne,pluginFileView:sn,wordWrap:Q,setWordWrap:te,viewerKind:pn,isPreview:Boolean(ze),isReviewing:Boolean(ze)&&Y.active,onToggleReview:Y.toggle,isMaximized:H,setIsMaximized:J,zoomLevel:N,setZoomLevel:P,goToLineRequest:ie.goToLineRequest,onSaveAs:()=>ie.setSaveAsOpen(!0),onOpenPath:y,rootPath:C,repoPath:M,runCommand:Re,editorFontFamily:de,editorTheme:ce,togglePreview:dn,revealActive:Boolean(Fe),missing:Ae,onConvertDiffToEditor:g,onFileSaved:h},bn=(V)=>({openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:g,refreshKey:v,onFileSaved:h,onOpenPath:y,rootPath:C,repoPath:M,forcedActiveFileId:V,asSplitPane:!0}),hn=e(rt,{openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:Ie.requestClose,missingIds:be,onCopyPath:k,onRevealInFiles:O,onReopenClosed:w,reopenableCount:x,onSplitTo:ee.splitTo,onUnsplit:ee.close,splitRightFileId:ee.rightFile?.id??null,onHide:I}),$e=e(Jt,{className:t,isMaximized:H,onKeyDownCapture:mn.onKeyDownCapture,onFocusCapture:un.onFocusCapture,asSplitPane:z,tabs:hn,activeFile:R,editor:j,externalChange:ln,conflict:j.conflict,onReload:j.resolveConflictByReload,onKeepMine:j.keepMineAgainstDisk,body:e(It,{...fn}),saveAsOpen:ie.saveAsOpen,onSaveAsClose:()=>ie.setSaveAsOpen(!1),onSavedAs:(V)=>{ie.setSaveAsOpen(!1),y?.(V)},closeGuard:Ie});if(!ee.rightFile)return $e;return e(en,{fraction:ee.fraction,onFraction:ee.setFraction,rightPaneName:ee.rightFile.name,onClosePane:ee.close,rightPane:e(Un,{...bn(ee.rightFile.id)}),children:$e})}export{Un as Editor};
1
+ import{d,n,o,K,i,u,a,Ge,oe,e,s,E,m,en,S,f,B,re,gt,ge,St,He,ii,un,Jn,D,U,b,Xn,Oe,Ce,_,Ar,Ze,me,hr,Z,st,rl,So,al,ol,Do,hh,Th,Um,$o,gl,Le,ae,Jt,T,ve,hi,hf,Dg}from"./index-xkwybnf3.js";import{dt,ki,uu,du,mu,ks,xi,Qd}from"./index-0vk6v4y4.js";import{qc,wd,Cd,Lg,Mg,Hc,ar,hs,Wc,Kc,Vc,Yc,Jc,bs,Uo,ys,yi,Xc,wl,Cl,eu,tu,nu,ru,au,ou,iu,su,lu}from"./index-5mrqfs82.js";import{Qa,Ra,Ho}from"./index-r6e44vkx.js";var gn={name:"git-commit-vertical",size:24,node:[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]},De=s(gn);var vn={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]},we=s(vn);var yn={name:"minimize",size:24,node:[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]},ke=s(yn);var xn={name:"panel-right-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]},We=s(xn);var wn={name:"save-all",size:24,node:[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]},Se=s(wn);var se=new Set,Ae=new Set,Ke=new Set;function Ue(){Ke=new Set(se);for(let t of[...Ae])t()}function _e(t){let r=new Set(t);if(r.size===se.size){let l=!0;for(let c of r)if(!se.has(c)){l=!1;break}if(l)return}se.clear();for(let l of r)se.add(l);Ue()}function qe(t){let r=new Set(t),l=!1;for(let c of[...se])if(!r.has(c))se.delete(c),l=!0;if(l)Ue()}function Xe(t){return se.has(t)}function Ye(){return se.size>0}function kn(t){return Ae.add(t),()=>{Ae.delete(t)}}var Sn=kn;function je(){return Ge(Sn,()=>Ke)}function Je({x:t,y:r,rows:l,onAction:c,onClose:p}){let g=i(null),[v,h]=n({left:t,top:r});return K(()=>{let y=g.current;if(!y)return;let{width:w,height:x}=y.getBoundingClientRect();h({left:Math.min(t,Math.max(0,window.innerWidth-w-8)),top:Math.min(r,Math.max(0,window.innerHeight-x-8))})},[t,r,l.length]),oe(e("div",{className:"fixed inset-0 z-[70]",onClick:p,onContextMenu:(y)=>{y.preventDefault(),p()},children:e("div",{ref:g,role:"menu","aria-label":"Tab actions",className:"glass-popover absolute w-52 bg-paper border border-ink/15 rounded-md shadow-xl py-1 text-xs text-ink",style:{left:`${v.left}px`,top:`${v.top}px`},onClick:(y)=>y.stopPropagation(),children:l.map((y)=>e("button",{type:"button",role:"menuitem",onClick:()=>{c(y.action),p()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:y.label},y.action))})}),document.body)}var he={rightFileId:null,fraction:0.5};function Ee(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Qe(t,r){for(let l=r.length-1;l>=0;l-=1){let c=r[l];if(c!==t)return c}return null}function et(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function pe(t){if(!Number.isFinite(t))return he.fraction;return Math.max(0.2,Math.min(0.8,t))}function tt(t,r){if(typeof t!=="object"||t===null)return he;let l=t,c=typeof l.fraction==="number"?pe(l.fraction):he.fraction,p=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(p===null||!r.includes(p))return{rightFileId:null,fraction:c};return{rightFileId:p,fraction:c}}function nt({tab:t,openedFiles:r,dirtyIds:l,reopenable:c,activeFileId:p,splitRightFileId:g}){let v=r.filter((x)=>x.id!==t.id),h=r.filter((x)=>!l.has(x.id)),y=r.map((x)=>x.id);return[{action:"split-right",label:"Split right",enabled:Ee(t.id,p,y)},{action:"unsplit",label:"Unsplit",enabled:g!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:v.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:h.some((x)=>x.id!==t.id)},{action:"copy-path",label:"Copy path",enabled:Boolean(t.path)},{action:"reveal-in-files",label:"Reveal in Files",enabled:Boolean(t.path)&&!t.isDiff},{action:"reopen-closed",label:"Reopen closed tab",enabled:c>0}].filter((x)=>x.enabled)}function fe({onHide:t}){let r=$o("toggleEditorPanel","Hide Editor Panel");return e("button",{type:"button",onClick:t,className:"p-1.5 mx-1 rounded transition-colors cursor-pointer text-ink/60 hover:bg-ink/10 hover:text-ink flex-shrink-0",title:r,"aria-label":r,children:e(We,{size:14})})}function rt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,missingIds:p,onCopyPath:g,onRevealInFiles:v,onReopenClosed:h,reopenableCount:y,onSplitTo:w,onUnsplit:x,splitRightFileId:k=null,onHide:O}){let C=je(),M=i(null),A=i(null),[F,z]=n(5),[I,W]=n(!1),[R,L]=n(null);me(A,()=>W(!1)),o(()=>{let N=new ResizeObserver((P)=>{for(let H of P){let J=H.contentRect.width,Q=Math.max(1,Math.floor((J-60)/150));z(Q)}});if(M.current)N.observe(M.current);return()=>N.disconnect()},[]);let G=Qe(r,t.map((N)=>N.id)),X=[],Y=[];if(t.length<=F)X=t;else{let N=t.findIndex((H)=>H.id===r),P=new Set;if(N!==-1&&r!==null)P.add(r);for(let H=t.length-1;H>=0;H--){if(P.size>=F)break;P.add(t[H].id)}X=t.filter((H)=>P.has(H.id)),Y=t.filter((H)=>!P.has(H.id))}return e("div",{className:"flex bg-ink/10 w-full relative border-b border-ink/10",ref:M,children:[e("div",{className:"flex overflow-hidden",children:X.map((N)=>{let P=N.id===r,H=Boolean(N.isDiff),J=H?Xn(N.diffStatus||"M",N.diffStaged):null,Q=Boolean(p?.has(N.id));return e("div",{onClick:()=>l(N.id),onContextMenu:(te)=>{te.preventDefault(),L({tab:N,x:te.clientX,y:te.clientY})},className:`flex items-center space-x-1.5 px-3 py-1.5 cursor-pointer border-r border-ink/10 min-w-[120px] max-w-[210px] group ${P?"bg-paper border-t-2 border-t-ink text-ink":"bg-transparent border-t-2 border-t-transparent text-ink/60 hover:bg-paper/50"}`,title:Q?`${N.path} — file no longer exists`:N.path,children:[H?e(ii,{size:14,className:P?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(st,{name:N.name,size:14,className:`flex-shrink-0${P||Q?"":" opacity-60"}${Q?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${Q?" text-error line-through":""}`,children:N.name}),J&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${J.badgeBgClass}`,children:J.charStatus}),e(ot,{dirty:C.has(N.id),active:P,label:`Close ${N.name}`,onClose:()=>c(N.id)})]},N.id)})}),R?e(Je,{x:R.x,y:R.y,rows:nt({tab:R.tab,openedFiles:t,dirtyIds:C,reopenable:y?.()??0,activeFileId:r,splitRightFileId:k}),onAction:(N)=>{let P=R.tab;switch(N){case"close":c(P.id);return;case"close-others":for(let H of[...t].reverse())if(H.id!==P.id)c(H.id);l(P.id);return;case"close-all":for(let H of[...t].reverse())c(H.id);return;case"close-saved":for(let H of[...t].reverse())if(!C.has(H.id))c(H.id);return;case"copy-path":g?.(P);return;case"reveal-in-files":v?.(P);return;case"reopen-closed":h?.();return;case"split-right":w?.(P.id);return;case"unsplit":x?.();return}},onClose:()=>L(null)}):null,e("div",{className:"ml-auto flex items-center",children:[e("button",{type:"button",onClick:()=>k!==null?x?.():w?.(G),disabled:k===null&&G===null,"aria-pressed":k!==null,"aria-label":"Split editor",title:k!==null?"Close the split pane (the tab stays open)":G===null?"Open another file to split the editor":"Split the editor and show the newest other file",className:`p-1.5 mx-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-default ${k!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(Jn,{size:14})}),O&&e(fe,{onHide:O})]}),Y.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:A,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${I?"bg-ink/10 text-ink":""}`,onClick:()=>W(!I),title:"More open files",children:e(B,{size:14})}),I&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-52 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-mono text-ink/40 border-b border-ink/10 mb-1",children:"Older Tabs"}),Y.map((N)=>{let P=Boolean(p?.has(N.id));return e("div",{onClick:()=>{l(N.id),W(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[N.isDiff?e(ii,{size:14,className:"text-info/80"}):e(st,{name:N.name,size:14,className:P?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${P?"text-error line-through":"text-ink/80"}`,children:N.name}),e(ot,{dirty:C.has(N.id),active:!1,label:`Close ${N.name}`,onClose:()=>{if(c(N.id),Y.length===1)W(!1)}})]},N.id)})]})]})]})}function ot({dirty:t,active:r,label:l,onClose:c}){return e("div",{role:"button",tabIndex:-1,"aria-label":l,title:t?`${l} — unsaved changes`:l,className:`p-0.5 rounded hover:bg-ink/10 touch-visible ${r||t?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:(p)=>{p.stopPropagation(),c()},children:t?e("span",{className:"block w-2 h-2 rounded-full bg-current mx-0.5","data-tab-dirty":"","aria-hidden":"true"}):e(b,{size:12})})}function Cn(t){if(t===null)return null;let r=new Date(t);if(Number.isNaN(r.getTime()))return null;return r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Te({diskMtimeMs:t,fileName:r,onReload:l,onKeepMine:c}){let p=Cn(t);return e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-[11px] text-ink flex-shrink-0",role:"alert","data-conflict-strip":"",children:[e(S,{size:13,className:"text-warning flex-shrink-0 mt-0.5"}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"font-medium",children:[e("span",{className:"font-mono",children:r})," changed on disk",p?e("span",{className:"text-ink/60",children:[" at ",p]}):null,"."]}),e("div",{className:"text-ink/60 mt-0.5",children:"Your save was refused so nothing was overwritten."})]}),e("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e("button",{type:"button",onClick:l,className:"px-2 py-1 rounded border border-ink/20 hover:bg-ink/5 transition-colors cursor-pointer",title:"Discard my changes and take the file from disk",children:"Reload"}),e("button",{type:"button",onClick:c,className:"px-2 py-1 rounded border border-warning/50 text-warning hover:bg-warning/10 transition-colors cursor-pointer",title:"Write my buffer over the file on disk",children:"Keep mine"})]})]})}function it(t){if(t.byteViewer)return[];return[{id:"save",pinned:!0,actions:[{label:"Save file",icon:Se,onSelect:t.onSave,disabled:t.saveDisabled}],children:t.saveButton},{id:"save-as",actions:[{label:"Save as…",icon:Se,onSelect:t.onSaveAs}],children:e("button",{type:"button",onClick:t.onSaveAs,className:`${ar} hover:bg-ink/5 hover:text-ink`,title:"Save the buffer to a new file","aria-label":"Save as",children:e(Se,{size:14})})}]}function at(t){if(!t.hasReview)return[];let r=t.isReviewing?"Exit review mode":"Review this document";return[{id:"review",actions:[{label:r,icon:un,onSelect:t.onToggleReview,active:t.isReviewing}],children:e(hs,{label:r,pressed:t.isReviewing,title:t.isReviewing?"Review mode is on — click a block to judge it":"Review: click blocks to mark them good or needing work",onClick:t.onToggleReview,children:e(un,{size:14})})}]}function lt(t){if(!t.hasPreview)return[];return[{id:"preview",actions:[{label:t.previewLabel,icon:t.isPreview?St:He,onSelect:t.onTogglePreview,active:t.isPreview}],children:e(hs,{label:t.previewLabel,pressed:t.isPreview,onClick:t.onTogglePreview,children:t.isPreview?e(St,{size:14}):e(He,{size:14})})}]}function ct(t){let r=[];if(r.push(...it(t),...at(t),...lt(t)),!t.byteViewer)r.push({id:"find",actions:[{label:t.findLabel,icon:U,onSelect:t.onToggleFind,active:t.findOpen}],children:e(hs,{label:t.findLabel,pressed:t.findOpen,title:`${t.findLabel} (Ctrl+F)`,onClick:t.onToggleFind,children:e(U,{size:14})})}),r.push({id:"wrap",actions:[{label:t.wordWrapLabel,icon:en,onSelect:t.onToggleWordWrap,active:t.wordWrap}],children:e(hs,{label:t.wordWrapLabel,pressed:t.wordWrap,onClick:t.onToggleWordWrap,children:e(en,{size:14})})}),r.push({id:"blame",actions:[{label:t.blameInline?"Hide line blame":"Show line blame",icon:De,onSelect:t.onToggleBlameInline,active:t.blameInline}],children:e(hs,{label:t.blameInline?"Hide line blame":"Show line blame",pressed:t.blameInline,title:"Who last changed each block, from git (hover a line for the commit)",onClick:t.onToggleBlameInline,children:e(De,{size:14})})}),r.push({id:"zoom",actions:[{label:"Decrease font size",icon:Ra,onSelect:t.onZoomOut},{label:"Increase font size",icon:Qa,onSelect:t.onZoomIn}],children:e(d,{children:[e("button",{type:"button",onClick:t.onZoomOut,className:`${ar} hover:bg-ink/5 hover:text-ink`,title:"Decrease font size","aria-label":"Decrease font size",children:e(Ra,{size:14})}),e("button",{type:"button",onClick:t.onZoomIn,className:`${ar} hover:bg-ink/5 hover:text-ink`,title:"Increase font size","aria-label":"Increase font size",children:e(Qa,{size:14})})]})}),r.push({id:"reload",actions:[{label:"Reload from disk",icon:D,onSelect:t.onReload,disabled:!t.canReload}],children:e("button",{type:"button",onClick:t.onReload,disabled:!t.canReload||t.refreshing,"aria-busy":t.refreshing,className:`${ar} hover:bg-ink/5 hover:text-ink`,title:!t.canReload?"Nothing to reload — this tab has no file on disk":t.reloadDiscardsEdits?"Discard my changes and reload from disk":"Reload from disk","aria-label":"Reload from disk",children:e(D,{size:14,className:t.refreshing?"animate-spin":void 0})})});return r.push({id:"copy",actions:[{label:t.copyLabel,icon:re,onSelect:t.onCopy},{label:"Download file",icon:ge,onSelect:t.onDownload}],children:e(d,{children:[e("button",{type:"button",onClick:t.onCopy,className:`${ar} hover:bg-ink/5 hover:text-ink`,title:t.copyLabel,"aria-label":t.copyLabel,children:t.copied?e(re,{size:14,className:"text-success"}):e(re,{size:14})}),e("button",{type:"button",onClick:t.onDownload,className:`${ar} hover:bg-ink/5 hover:text-ink`,title:"Download file","aria-label":"Download file",children:e(ge,{size:14})})]})}),r.push({id:"view-modes",pinned:!0,actions:t.viewModeActions,children:t.viewModeButtons}),r.push({id:"maximize",pinned:!0,actions:[{label:t.maximizeLabel,icon:t.isMaximized?ke:we,onSelect:t.onToggleMaximize,active:t.isMaximized}],children:t.maximizeButton}),r}function mt({path:t,saveStatus:r,wordWrap:l,hasPreview:c,isPreview:p,hasReview:g,isReviewing:v,copied:h,byteViewer:y=!1,saveDisabled:w=!1,unsupported:x=!1,handleMissing:k=!1,readOnly:O=!1,isMaximized:C=!1,findOpen:M=!1,onToggleFind:A,onSave:F,onTogglePreview:z,onToggleReview:I,onToggleWordWrap:W,onZoomIn:R,onZoomOut:L,onCopy:G,onDownload:X,onReload:Y,canReload:N,refreshing:P=!1,reloadDiscardsEdits:H,onSaveAs:J,onToggleMaximize:Q}){let te=w?O?"Read-only — this file was opened from the phone, not from a workspace":k?"Cannot save — reopen the file from the system to restore write access":x?"Nothing to save — this file cannot be opened as a document":"Nothing to save — this file could not be read":r==="needs-permission"?"Click Save to allow writing this file":r==="saving"?"Saving…":r==="error"?"Save failed — the file on disk was not changed":"Save file (Ctrl+S)",ie=e("button",{type:"button",onClick:F,disabled:w||r==="saving",className:`${ar} hover:bg-ink/5`,title:te,"aria-label":te,children:r==="saving"?e(dt,{size:14,className:"text-warning animate-pulse"}):r==="saved"?e(f,{size:14,className:"text-success"}):r==="error"?e(E,{size:14,className:"text-error"}):r==="needs-permission"?e(dt,{size:14,className:"text-warning"}):e(dt,{size:14,className:"hover:text-ink"})}),le=C?"Exit full screen":"Full screen",ee=e("button",{type:"button",onClick:Q,className:`${ar} hover:bg-ink/5 hover:text-ink ${C?"text-ink":""}`,title:le,"aria-label":le,"aria-pressed":C,children:C?e(ke,{size:14}):e(we,{size:14})}),ne=Qd(),de=wd(),ce=ct({byteViewer:y,hasPreview:c,isPreview:p,wordWrap:l,hasReview:g,isReviewing:v,blameInline:ne.inline,findOpen:M,copied:h,isMaximized:C,saveDisabled:w,canReload:N,refreshing:P,reloadDiscardsEdits:H,saveButton:ie,maximizeButton:ee,viewModeButtons:e(Cd,{size:14}),viewModeActions:de,previewLabel:p?"Show source":"Show preview",findLabel:"Find and replace",wordWrapLabel:l?"Word wrap on":"Word wrap off",copyLabel:h?"Copied":y?"Copy image":"Copy content",maximizeLabel:le,onTogglePreview:z,onToggleReview:I,onToggleFind:A,onToggleWordWrap:W,onToggleBlameInline:()=>{let be={...xi(),inline:!ne.inline};Ar({editorBlameInline:be.inline}),window.dispatchEvent(new CustomEvent(ks,{detail:be}))},onZoomIn:R,onZoomOut:L,onCopy:G,onDownload:X,onReload:Y,onSaveAs:J,onToggleMaximize:Q,onSave:F});return e("div",{className:"@container flex items-center justify-between gap-2 px-3 py-2 border-b border-ink/10 bg-paper flex-shrink-0",children:[e("div",{className:"hidden @[420px]:flex items-center space-x-2 text-xs font-mono text-ink/40 min-w-0",children:e("span",{className:"truncate max-w-[300px]",title:t,children:t})}),e(Ho,{clusters:ce,className:"text-ink/40 ml-auto"})]})}function ut({content:t,file:r,zoomLevel:l,reviewActive:c,onExitReview:p,scrollRef:g,onScroll:v}){return e("div",{ref:g,onScroll:v,"data-testid":"editor-scroller",className:"flex-1 overflow-auto bg-paper flex",children:e("div",{className:"p-6 max-w-4xl mx-auto font-sans flex-1",style:{fontSize:`${l}px`},children:e(Wc,{content:t,file:r,active:c,onExit:p})})})}function En(t,r){return r?`Spaces: ${t}`:"Tabs"}function pt({caret:t,eol:r,onSetEol:l,indentWidth:c,insertSpaces:p,language:g,byteViewer:v,viewerKind:h,lineCount:y,conflicts:w=0}){return e("footer",{className:"flex bg-canvas border-t border-ink/10 px-3 items-center justify-between text-[10px] text-ink/50 flex-shrink-0 font-mono h-6","data-editor-status-bar":"",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:v?e("span",{className:"uppercase",children:Uo[h]}):e(d,{children:[e("span",{className:"tabular-nums",children:t?`Ln ${t.line}, Col ${t.column}`:"Ln —, Col —"}),e("span",{children:En(c,p)}),e("button",{type:"button",onClick:()=>l(r==="lf"?"crlf":"lf"),className:"uppercase hover:text-ink transition-colors cursor-pointer",title:`Line endings: ${r.toUpperCase()} — click to switch`,"aria-label":`Line endings ${r.toUpperCase()}, switch`,children:r}),e("span",{children:[y," lines"]})]})}),e("div",{className:"flex items-center gap-3 min-w-0",children:[w>0&&e("span",{className:"text-error font-semibold tabular-nums",title:`${w} unresolved conflict${w===1?"":"s"} — markers are highlighted in the file`,children:["⚠ ",w," conflict",w===1?"":"s"]}),e("span",{className:"uppercase text-ink/40",children:g})]})]})}function Tn(t){if(t===0)return 0;return Math.max(-1,Math.min(1,-Math.sign(t)))}function Mn(t,r,l=al,c=ol){return Math.max(l,Math.min(c,t+r))}function Nn(t,r){let l=t instanceof HTMLElement?t:null;while(l&&l!==r){let c=getComputedStyle(l);if(/(auto|scroll)/.test(c.overflowY)&&l.scrollHeight>l.clientHeight)return!0;l=l.parentElement}return!1}function ft(t,r){o(()=>{if(!t)return;let l=t.closest("[data-code-surface]"),c=l instanceof HTMLElement?l:t,p=(g)=>{if(!g.ctrlKey&&!g.metaKey)return;if(g.preventDefault(),Nn(g.target,c))return;let v=Tn(g.deltaY);if(v===0)return;r((h)=>Mn(h,v))};return t.addEventListener("wheel",p,{passive:!1}),()=>t.removeEventListener("wheel",p)},[t,r])}function bt(t,r){let l=t.trim();if(!/^\d+$/.test(l))return null;let c=Number(l);if(c<1)return null;return Math.min(c,Math.max(r,1))}function ht({lineCount:t,onGo:r,onClose:l}){let[c,p]=n(""),g=i(null);o(()=>{g.current?.focus(),g.current?.select()},[]);let v=()=>{let w=bt(c,t);if(w===null)return;r(w)},h=(w)=>{if(w.key==="Enter"){w.preventDefault(),v();return}if(w.key==="Escape")w.preventDefault(),l()},y=bt(c,t);return e(Z,{onClose:l,maxWidthClass:"max-w-xs",header:e("span",{className:"text-sm font-semibold text-ink",children:"Go to line"}),children:e("div",{className:"px-4 py-3 space-y-2",children:[e("div",{className:"flex items-center gap-2",children:[e("input",{ref:g,value:c,onInput:(w)=>p(w.target.value),onKeyDown:h,inputMode:"numeric",placeholder:"1","aria-label":"Line number",className:"flex-1 bg-paper border border-ink/20 rounded px-2 py-1 text-xs font-mono text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10px] font-mono text-ink/40",children:["/ ",t]}),e("button",{type:"button",onClick:v,disabled:y===null,className:"flex items-center gap-1 px-2 py-1 rounded bg-ink text-paper text-xs disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[e(gt,{size:12}),"Go"]})]}),c&&y!==null&&String(y)!==c.trim()?e("div",{className:"text-[10px] text-ink/50 font-mono",children:["line ",y," (the last line)"]}):null,c&&y===null?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a line number"}):null]})})}var vt={status:"idle",payload:null,message:null};function yt(t){if(!t?.path)return"";return`${t.root??""}\x00${t.repo??""}\x00${t.path}`}function xt(t,r={}){let l=r.enabled!==!1&&Boolean(t?.path)&&t?.deviceFile!==!0,c=r.dirty===!0,p=yt(t),[g,v]=n({key:"",value:vt}),h=i(t);h.current=t;let y=i(p);y.current=p;let w=i(l);w.current=l;let x=i(c);x.current=c;let k=i(g);k.current=g;let O=i(0),C=i(""),M=i(new Map),A=i(new Set),F=a(async()=>{let L=h.current;if(!L?.path)return;let G=yt(L),X=++O.current;C.current=G,v((N)=>({key:G,value:{status:"loading",payload:N.key===G?N.value.payload:null,message:null}}));let Y=new URLSearchParams({blame:"1",file:L.path,repo:L.repo||"."});if(L.root)Y.set("root",L.root);try{let N=await fetch(`/api/fs/git?${Y.toString()}`),P=await N.json().catch(()=>null);if(X!==O.current)return;if(!N.ok||!P){v({key:G,value:{status:"error",payload:null,message:P?.error??`Blame request failed (HTTP ${N.status})`}});return}v({key:G,value:P.available?{status:"ready",payload:P,message:null}:{status:"unavailable",payload:P,message:P.message??null}})}catch(N){if(X!==O.current)return;v({key:G,value:{status:"error",payload:null,message:N instanceof Error?N.message:"Blame failed"}})}finally{if(C.current===G)C.current=""}},[]),z=a(async(L)=>{let G=M.current.get(L);if(G)return G;let X=h.current;if(!X?.path)return{entries:[],truncated:!1};let Y=new URLSearchParams({blameHistory:"1",file:X.path,line:String(L),repo:X.repo||"."});if(X.root)Y.set("root",X.root);try{let P=await(await fetch(`/api/fs/git?${Y.toString()}`)).json().catch(()=>null),H={entries:Array.isArray(P?.entries)?P.entries:[],truncated:P?.truncated===!0};return M.current.set(L,H),H}catch{return{entries:[],truncated:!1}}},[]),I=i(null);if(!I.current)I.current={ensure:()=>{if(!w.current||x.current)return;let L=k.current;if(L.key===y.current&&L.value.status!=="idle")return;if(C.current===y.current)return;F()},reload:()=>{M.current.clear(),F()},history:z,snapshot:()=>{let L=k.current;return L.key===y.current?L.value:vt},stale:()=>x.current,subscribe:(L)=>(A.current.add(L),()=>{A.current.delete(L)})};o(()=>{if(!l||c||!p)return;M.current.clear(),F()},[l,c,p,F]);let W=i(c);return o(()=>{if(W.current===c)return;W.current=c;for(let L of A.current)L()},[c]),o(()=>{for(let L of A.current)L()},[g]),I.current}var Rn="0".repeat(40);function Me(t){return t===Rn}function ye(t,r=Date.now()){let l=Math.max(0,Math.floor(r/1000)-t);if(l<60)return"just now";let c=Math.floor(l/60);if(c<60)return`${c}m ago`;let p=Math.floor(c/60);if(p<24)return`${p}h ago`;let g=Math.floor(p/24);if(g<30)return`${g}d ago`;let v=Math.floor(g/30);if(v<12)return`${v}mo ago`;return`${Math.floor(g/365)}y ago`}function wt(t,r){switch(t){case"not-repo":return"This folder is not a git repository.";case"no-commit":return"This repository has no commits yet.";case"untracked":return"This file has never been committed, so it has no history.";case"too-large":return r??"This file is too large to blame.";case"empty":return"This file is empty.";default:return r??"git could not read this file."}}var Tt="fixed z-50 w-[min(340px,92vw)] rounded-xl border border-ink/20 bg-paper p-3 shadow-xl font-sans text-xs text-ink",kt="flex items-baseline justify-between gap-2",Ct="truncate text-xs font-semibold text-ink",Pn="shrink-0 font-mono text-[10px] text-ink/40",Ln="mt-1 line-clamp-2 text-[11px] leading-snug text-ink/80",Bn="mt-2 border-t border-ink/10 pt-2",Dn="flex items-center gap-2 font-mono text-[10px] text-ink/40",Et="mt-1 text-[10px] leading-snug text-ink/50",On="mt-2 flex w-full items-center gap-1.5 text-left text-[10px] text-ink/50 hover:text-ink cursor-pointer",An="mt-1.5 space-y-1 border-t border-ink/10 pt-1.5",Ne="flex items-center gap-1.5 font-mono text-[10px]";function q(t,r,l){let c=document.createElement(t);if(c.className=r,l!==void 0)c.textContent=l;return c}function In(t){return new Date(t*1000).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}function Fn(t){let r=t.payload;if(t.status==="error")return{title:"Blame failed",body:t.message??"git could not read this file."};if(t.status==="unavailable")return{title:r?.reason==="untracked"?"Not tracked":"No history",body:wt(r?.reason??"error",t.message??void 0)};if(!r)return null;if(t.stale)return{title:"Not committed yet",body:"This line changed in the editor. Save the file to see its blame."};if(t.line>r.lines)return{title:"Not committed yet",body:`Line ${t.line} is past the end of the file at HEAD (${r.lines} lines).`};let l=r.runs.length>0?Mt(r,t.line):null;if(!l)return{title:"Not committed yet",body:`git has no attribution for line ${t.line}.`};if(Me(l.sha))return{title:"Not committed yet",body:"This line differs from the last commit."};return null}function Mt(t,r){for(let l of t.runs)if(r>=l.from&&r<=l.to)return t.commits[l.sha]??null;return null}function zn(t,r){t.replaceChildren(),t.className=Tt;let l=Fn(r);if(l){let w=q("div",kt);if(w.append(q("span",Ct,l.title)),r.status==="error"&&r.message){let x=q("button","shrink-0 cursor-pointer text-[10px] text-ink/50 hover:text-ink","Try again");x.type="button",x.setAttribute("aria-label","Read the blame again"),w.append(x)}t.append(w,q("p",Et,l.body));return}let c=r.payload;if(!c){t.append(q("p",Et,"Reading blame…"));return}let p=Mt(c,r.line),g=q("div",kt);if(g.append(q("span",Ct,p.author.trim()||"Unknown"),q("span",Pn,ye(p.time))),t.append(g),p.summary)t.append(q("p",Ln,p.summary));let v=q("div",`${Dn} ${Bn}`);if(v.append(q("code","truncate",p.sha.slice(0,7)),q("span","",In(p.time))),p.mail){let w=q("span","truncate",p.mail);w.title=p.mail,v.append(w)}t.append(v);let h=q("button",On);if(h.type="button",h.setAttribute("aria-expanded",r.historyOpen?"true":"false"),h.textContent=`${r.historyOpen?"▾":"▸"} Line history`,t.append(h),!r.historyOpen)return;let y=q("ol",An);if(r.historyLoading)y.append(q("li",`${Ne} text-ink/40`,"Reading history…"));else if(!r.history||r.history.entries.length===0)y.append(q("li",`${Ne} text-ink/40`,"No commits touched this line."));else{let w=r.history.entries;if(w.forEach((x,k)=>{let O=q("li",Ne),C=k===w.length-1?"new":"edit";O.append(q("span","text-ink/40",k===0?"●":"○"),q("code","text-ink/60",x.sha.slice(0,7)),q("span","truncate text-ink/80",x.author.trim()||"Unknown"),q("span","ml-auto shrink-0 text-ink/40",ye(x.time)),q("span","shrink-0 rounded bg-ink/5 px-1 text-[8.5px] uppercase tracking-wider text-ink/45",C)),y.append(O)}),r.history.truncated)y.append(q("li",`${Ne} text-ink/40`,"Older commits are not shown."))}t.append(y)}function Nt(t,r,l){let c=q("div",Tt);c.setAttribute("role","dialog"),c.setAttribute("aria-label","Line blame"),c.addEventListener("mousedown",(x)=>x.stopPropagation());let p=null,g=!1,v=!1,h=()=>{let x=r.snapshot();return{line:t,status:x.status,payload:x.payload,message:x.message,stale:r.stale(),history:p,historyOpen:g,historyLoading:v}},y=()=>{zn(c,h());let x=c.querySelector('[aria-label="Read the blame again"]');if(x)x.addEventListener("click",(k)=>{k.stopPropagation(),l()});c.querySelector("button[aria-expanded]")?.addEventListener("click",(k)=>{if(k.stopPropagation(),g=!g,y(),!g||p||v)return;v=!0,y(),r.history(t).then((O)=>{p=O,v=!1,y()})})};y();let w=r.subscribe(y);return{element:c,place(x){let k=c.ownerDocument.defaultView,O=k?.innerWidth??1024,C=k?.innerHeight??768,M=c.offsetWidth||340,A=c.offsetHeight||120,F=8,z=Math.max(8,Math.min(x.left,O-M-8)),I=x.bottom+6,W=x.top-A-6,R=I+A>C-8&&W>8?W:I;c.style.left=`${z}px`,c.style.top=`${Math.max(8,R)}px`},destroy(){w(),c.remove()}}}function Rt(t){return ve.define((r)=>{let l=null,c=0,p,g=()=>{clearTimeout(p),p=void 0,l?.destroy(),l=null,c=0},v=(C,M)=>{let A=C.getBoundingClientRect();if(A.width>0)return{left:A.left,top:A.top,bottom:A.bottom};let F=r.state.doc.line(Math.min(M,r.state.doc.lines)),z=null;try{z=r.coordsAtPos(F.from)}catch{z=null}if(z)return z;let I=r.scrollDOM.getBoundingClientRect();return{left:I.left,top:I.top+24,bottom:I.top+24}},h=(C,M)=>{if(c===C&&l)return;g(),c=C,l=Nt(C,t,()=>{t.reload(),g()}),document.body.append(l.element),l.place(M)},y=(C)=>{let M=C.target,A=M?.closest?.(".cm-blame-label");if(A){let I=Number(A.dataset.blameLine);return Number.isInteger(I)&&I>0?{line:I,anchor:A}:null}let F=M?.closest?.(".cm-lineNumbers .cm-gutterElement");if(!F)return null;let z=Number((F.textContent??"").trim());return Number.isInteger(z)&&z>0?{line:z,anchor:F}:null},w=(C)=>{let M=y(C);if(!M)return;h(M.line,v(M.anchor,M.line))},x=(C)=>{let M=y(C);if(M){C.preventDefault(),h(M.line,v(M.anchor,M.line));return}if(l&&!l.element.contains(C.target))g()},k=(C)=>{if(C.key==="Escape"&&l)g(),C.stopPropagation()},O=(C)=>{if(!l)return;let M=C.relatedTarget;if(M&&(l.element.contains(M)||r.scrollDOM.contains(M)))return;p=setTimeout(g,200)};return r.scrollDOM.addEventListener("mouseover",w),r.scrollDOM.addEventListener("mouseleave",O),r.scrollDOM.addEventListener("mousedown",x),document.addEventListener("mousedown",x),document.addEventListener("keydown",k,!0),{update(C){if(C.docChanged&&l)g()},destroy(){g(),r.scrollDOM.removeEventListener("mouseover",w),r.scrollDOM.removeEventListener("mouseleave",O),r.scrollDOM.removeEventListener("mousedown",x),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",k,!0)}}})}var Pt=40,Bt=ae.define();function Hn(t){return Le.define({create:()=>({payload:t.snapshot().payload,stale:!1}),update(r,l){let c=r;for(let p of l.effects){if(!p.is(Bt))continue;c=p.value.payload!==r.payload?{payload:p.value.payload,stale:!1}:{payload:r.payload,stale:r.stale}}if(l.docChanged&&!c.stale)c={payload:c.payload,stale:!0};return c}})}function $n(t,r,l){let c=t.commits[r];if(!c||Me(r))return null;let p=c.author.trim()||"Unknown";return l?p:`${p} · ${ye(c.time)}`}class Dt extends Jt{constructor(t,r,l){super();this.line=t;this.text=r;this.title=l}eq(t){return t.line===this.line&&t.text===this.text&&t.title===this.title}toDOM(){let t=document.createElement("span");return t.className="cm-blame-label",t.dataset.blameLine=String(this.line),t.title=this.title,t.textContent=this.text,t}}function Lt(t,r,l){let{payload:c,stale:p}=t;if(!c?.available||p)return T.none;let g=Math.min(c.lines,r.state.doc.lines);if(g<1)return T.none;let v=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.from,r.state.doc.length))).number,h=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.to,r.state.doc.length))).number,y=Math.max(1,v-Pt),w=Math.min(g,h+Pt),x=[];for(let k of c.runs){let O=Math.max(k.from,y);if(O>k.to||O>w)continue;let C=$n(c,k.sha,l);if(!C)continue;let M=c.commits[k.sha],A=r.state.doc.line(O);x.push({from:A.to,deco:T.widget({widget:new Dt(A.number,C,M.summary||M.sha),side:1})})}return T.set(x.map((k)=>k.deco.range(k.from)),!0)}function Vn(t,r){return ve.fromClass(class{constructor(l){this.view=l;this.decorations=Lt(l.state.field(t),l,r)}update(l){if(l.startState.field(t)===l.state.field(t)&&!l.docChanged&&!l.viewportChanged)return;this.decorations=Lt(l.state.field(t),l.view,r)}},{decorations:(l)=>l.decorations})}function Wn(t){return ve.define((r)=>{let l=!0,c=()=>{if(!l)return;let g=t.snapshot();r.dispatch({effects:Bt.of({payload:g.payload,stale:!1})})},p=t.subscribe(c);return{destroy(){l=!1,p()}}})}function Ot({controller:t,inline:r=!0,compact:l=!1}){let c=Hn(t);return[c,Wn(t),r?Vn(c,l):[],Rt(t)]}function At({activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:p,rootPath:g=null,repoPath:v=null,onRunCommand:h,wordWrap:y,zoomLevel:w,setZoomLevel:x,editorFontFamily:k,editorTheme:O,viewerKind:C,isPreview:M,reviewActive:A,onToggleReview:F,revealActive:z}){let I=C==="markdown",W=du(),R=mu(),L=Qd(),G=xt({name:t.name,path:t.path,root:t.root??g??void 0,repo:t.repo??v??"."},{enabled:L.enabled,dirty:r.isDirty}),X=u(()=>L.enabled?Ot({controller:G,inline:L.inline}):null,[L.enabled,L.inline,G]),[Y,N]=n(null),P=u(()=>Kc(r.content),[r.content]),[H,J]=n(!1);o(()=>{if(p>0)J(!0)},[p]);let[Q,te]=n(null),[ie,le]=n(null);ft(Q,x);let ee=gl({tabKey:String(t.id),surface:I&&M?"rendered":"code",ready:r.loaded,element:I&&M?void 0:Q}),ne=a((de)=>{ee.ref(de),le(de)},[ee.ref]);return Jc({path:t.path,scroller:ie,preview:I&&M}),e("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[l.open?e(Yc,{find:l}):null,H?e(ht,{lineCount:r.content?r.content.split(`
2
+ `).length:1,onGo:(de)=>{J(!1);let ce=hr(r.content,de-1);c.current?.select(ce,ce,!0),c.current?.revealOffset(ce)},onClose:()=>J(!1)}):null,I&&M?e(ut,{content:r.content,file:{name:t.name,path:t.path,root:t.root,repo:t.repo},zoomLevel:w,reviewActive:A,onExitReview:F,scrollRef:ne,onScroll:ee.onScroll}):e(Vc,{ref:c,value:r.content,onValueChange:r.onChange,language:r.language,wordWrap:y,documentKey:String(t.id),marks:l.open||z?l.matches:void 0,currentMark:l.currentIndex,onCommand:h,onScroller:te,onCaret:N,scrollTestId:"editor-scroller",className:"flex-1 min-h-0 text-ink select-text",blame:X,themeVars:O.vars,themes:O.themes,indentUnitText:uu(W),typing:R,padding:16,placeholder:"This file is empty",style:{fontFamily:k,fontSize:`${w}px`,lineHeight:rl}}),!I||!M?e(pt,{caret:Y,eol:r.eol,onSetEol:r.setEol,indentWidth:W.width,insertSpaces:W.insertSpaces,language:r.language,byteViewer:r.isBinaryViewer,viewerKind:C,lineCount:r.content?r.content.split(`
3
+ `).length:0,conflicts:P}):null]})}function It({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:g,setWordWrap:v,viewerKind:h,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:O,zoomLevel:C,setZoomLevel:M,goToLineRequest:A,onSaveAs:F,rootPath:z=null,repoPath:I=null,runCommand:W,editorFontFamily:R,editorTheme:L,togglePreview:G,revealActive:X,missing:Y}){let N=h==="image"||h==="pdf"||h==="docx"||h==="spreadsheet",P=bs[h]===!0,H=a(async(J)=>{let Q=await tu(t,J,{interactive:!0,baseMtimeMs:r.baseMtimeMs});if(Q.status==="written")return{ok:!0};if(Q.status==="conflict")return{ok:!1,error:"This file changed on disk since it was opened."};if(Q.status==="needs-permission")return{ok:!1,error:"Click Save again to grant write access."};return{ok:!1,error:Q.error}},[t,r.baseMtimeMs]);return e(d,{children:[e(mt,{path:t.path,saveStatus:r.saveStatus,wordWrap:g,hasPreview:P,isPreview:y,hasReview:h==="markdown"&&y,isReviewing:w,copied:r.copied,byteViewer:N,saveDisabled:Boolean(r.loadError)||r.handleMissing||r.deviceBacked,unsupported:Boolean(r.unsupported),handleMissing:r.handleMissing,readOnly:r.deviceBacked,isMaximized:k,findOpen:l.open,onToggleFind:()=>l.open?l.close():l.openFind(),onSave:r.saveNow,onTogglePreview:G,onToggleReview:x,onToggleWordWrap:()=>v(!g),onZoomIn:()=>M((J)=>Math.min(ol,J+1)),onZoomOut:()=>M((J)=>Math.max(al,J-1)),onCopy:r.copy,onDownload:r.download,onReload:r.reloadFromDisk,onSaveAs:F,canReload:Cl(t)&&!r.loadError&&!r.unsupported,refreshing:r.isReading,reloadDiscardsEdits:r.isDirty,onToggleMaximize:()=>O(!k)}),Y&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-error/30 bg-error/10 text-error",children:[e(S,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was deleted from disk."}),e("div",{className:"text-[11px] font-sans text-error/80",children:"The buffer is still here. Saving recreates the file — autosave is off until then."})]})]}),r.conflict&&e(Te,{diskMtimeMs:r.conflict.diskMtimeMs,fileName:t.name,onReload:r.resolveConflictByReload,onKeepMine:r.resolveConflictByKeepingMine}),r.handleMissing&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-warning",children:[e(S,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was opened by the system, not from a workspace."}),e("div",{className:"text-[11px] font-sans text-warning/80",children:"Its write permission ended with the last page load. Reopen the file from the OS to edit it again."})]})]}),r.deviceBacked&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-ink/20 bg-ink/5 text-ink/70",children:[e(S,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:r.deviceMissing?"The bytes for this file did not survive the reload.":"Opened from this device, so it is read-only here."}),e("div",{className:"text-[11px] font-sans text-ink/50",children:r.deviceMissing?"A phone's file lives only on the phone, so it cannot be re-read. Open it again from the app that shared it.":"The console cannot reach a file on your phone. Copy it into a workspace to edit it."})]})]}),r.isImage&&r.imageUrl?e(yi,{src:r.imageUrl,name:t.name,className:"flex-1 min-h-0"}):r.isImage?e(wl,{kind:"image",path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision}):r.isLoading?e("div",{className:"flex-1 flex items-center justify-center gap-2 text-ink/40 text-xs font-mono",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Loading file content…"})]}):r.unsupported?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(qc,{size:20,className:"text-ink/40"}),e("span",{className:"text-xs text-ink/70 font-sans",children:[t.name," cannot be opened here"]}),e("span",{className:"text-[11px] text-ink/50 font-sans max-w-[42ch]",children:r.unsupported})]}):r.loadError?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(S,{size:20,className:"text-error"}),e("span",{className:"text-xs text-error font-sans",children:["Could not read ",t.name]}),e("span",{className:"text-[11px] text-ink/50 font-mono break-all",children:r.loadError})]}):p&&!r.isImage?e(Mg,{view:p}):Xc(h)&&(N||y)?e(wl,{kind:h,path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision,onContentChange:r.onChange,onSaveBytes:r.deviceBacked?void 0:H,onDirtyChange:r.setBinaryDirty}):e(At,{activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:A,rootPath:z,repoPath:I,onRunCommand:W,wordWrap:g,zoomLevel:C,setZoomLevel:M,editorFontFamily:R,editorTheme:L,isPreview:y,reviewActive:w,onToggleReview:x,viewerKind:h,revealActive:X})]})}function Ft({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:g,setWordWrap:v,viewerKind:h,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:O,zoomLevel:C,setZoomLevel:M,goToLineRequest:A,onSaveAs:F,rootPath:z=null,repoPath:I=null,runCommand:W,editorFontFamily:R,editorTheme:L,togglePreview:G,revealActive:X,missing:Y,onConvertDiffToEditor:N,onFileSaved:P}){if(!t)return e("div",{className:"flex-1 flex items-center justify-center text-ink/40",children:e("p",{className:"font-mono text-sm",children:"Select a tab to view content"})});if(t.isDiff)return e(Hc,{filePath:t.path,status:t.diffStatus||"M",isStaged:Boolean(t.diffStaged),root:t.root,repo:t.repo||".",journalDiff:t.journalDiff,readOnly:t.diffSource==="journal",onOpenInEditor:()=>N(t.id),onFileSaved:P,className:"flex-1",tabKey:String(t.id)});return e(It,{activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:g,setWordWrap:v,viewerKind:h,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:O,zoomLevel:C,setZoomLevel:M,goToLineRequest:A,onSaveAs:F,rootPath:z,repoPath:I,runCommand:W,editorFontFamily:R,editorTheme:L,togglePreview:G,revealActive:X,missing:Y})}function zt({pluginId:t,Component:r,sessionId:l,className:c="",onHide:p}){return e("div",{className:`flex flex-col h-full bg-canvas ${c}`,children:[p&&e("div",{className:"flex justify-end flex-shrink-0 border-b border-ink/10",children:e(fe,{onHide:p})}),e(Ze,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})]})}function Ht({className:t="",onHide:r}){return e("div",{className:`relative flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[r&&e("div",{className:"absolute top-0 right-0 flex items-center",children:e(fe,{onHide:r})}),e(st,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function $t({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let c=i(null);o(()=>{if(!t||c.current===t.request)return;c.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function Vt({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:c,setPreviewMode:p,sessionId:g}){o(()=>{let v=new Set(t.filter((h)=>!h.isDiff&&h.content===void 0).map((h)=>h.id));_e([...r].filter((h)=>v.has(h)))},[r,t]),o(()=>{if(!c)return;let v=l?.id;if(!l||v===void 0||v===null)return;if(!bs[ys(l.name)])return;let h=Ce(g,"editor.previewMode");if(h&&h[v]!==void 0)return;p((y)=>y[v]===void 0?{...y,[v]:!0}:y)},[c,l])}function Wt({activeFile:t,externalChange:r,conflict:l,onReload:c,onKeepMine:p}){if(!t)return null;if(l)return e(Te,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:c,onKeepMine:p});if(r)return e(iu,{fileName:t.name,onReload:c,onKeepMine:p});return null}async function Kt(t){let r=t.name.trim();if(!r)return{status:"failed",reason:"Enter a file name."};let l=new FormData;if(l.append("actionType","saveAs"),l.append("path",t.parent),l.append("name",r),l.append("content",t.content),l.append("eol",t.eol),t.root)l.append("root",t.root);if(t.repo&&t.repo!==".")l.append("repo",t.repo);try{let c=await fetch("/api/fs/action",{method:"POST",body:l}),p=await c.json().catch(()=>null),g=typeof p?.error==="string"?p.error:null;if(c.status===409)return{status:"exists",reason:g??`${r} already exists.`};if(c.ok&&p?.success&&typeof p.path==="string")return{status:"written",path:p.path};return{status:"failed",reason:g??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Ut(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function _t(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function Kn(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function Gt({fileName:t,filePath:r,content:l,eol:c,root:p,repo:g,onSaved:v,onClose:h}){let[y,w]=n(()=>Kn(r)),[x,k]=n(()=>Ut(t)),[O,C]=n(!1),[M,A]=n(null),F=i(null);o(()=>{F.current?.focus(),F.current?.select()},[]);let z=_t(x),I=async()=>{if(!z||O)return;C(!0),A(null);let R=await Kt({parent:y,name:x,content:l,eol:c,root:p,repo:g});if(C(!1),R.status==="written"){v({path:R.path});return}A(R.reason)},W=(R)=>{if(R.key==="Enter"){R.preventDefault(),I();return}if(R.key==="Escape")R.preventDefault(),h()};return e(Z,{onClose:h,maxWidthClass:"max-w-md",header:e("span",{className:"text-sm font-semibold text-ink",children:"Save as"}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:h,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>void I(),disabled:!z||O,className:"flex items-center gap-1.5 px-3 py-1.5 rounded bg-ink text-paper disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[O?e(m,{size:12,className:"animate-spin"}):e(gt,{size:12}),"Save"]})]}),children:e("div",{className:"px-4 py-3 space-y-2 text-xs",children:[e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Folder"}),e("input",{value:y,onInput:(R)=>w(R.target.value),onKeyDown:W,placeholder:"(workspace root)","aria-label":"Destination folder",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"})]}),e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Name"}),e("input",{ref:F,value:x,onInput:(R)=>k(R.target.value),onKeyDown:W,"aria-label":"File name","aria-invalid":!z,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${z?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!z?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,M?e("div",{className:"text-[10px] text-error font-mono",children:M}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function qt(){o(()=>{let t=(r)=>{if(!Ye())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function Zt({fileName:t,onAnswer:r}){return e(Z,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(S,{size:15,className:"text-warning"}),e("span",{className:"text-sm font-semibold text-ink",children:"Unsaved changes"})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:()=>r("cancel"),className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>r("discard"),className:"px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer",children:"Discard"}),e("button",{type:"button",onClick:()=>r("save"),className:"px-3 py-1.5 rounded bg-ink text-paper hover:bg-ink/90 transition-colors cursor-pointer",children:"Save & close"})]}),children:e("div",{className:"px-4 py-3 text-xs text-ink/80",children:[e("span",{className:"font-mono text-ink",children:t})," has changes that are not on disk.",e("div",{className:"mt-1 text-ink/50",children:"Discarding them cannot be undone."})]})})}function Xt({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:c,onConfirmSaveMissing:p}){if(t.pending)return e(Zt,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(su,{fileName:r.name,filePath:r.path,onClose:c,onConfirm:p});return null}function Yt({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:c,asSplitPane:p,tabs:g,activeFile:v,editor:h,externalChange:y,conflict:w,onReload:x,onKeepMine:k,body:O,saveAsOpen:C,onSaveAsClose:M,onSavedAs:A,closeGuard:F}){let z=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:z,onKeyDownCapture:l,onFocusCapture:c,children:[p?null:g,e(Wt,{activeFile:v,externalChange:y,conflict:w,onReload:x,onKeepMine:k}),O,C&&v?e(Gt,{fileName:v.name,filePath:v.path,content:h.content,eol:h.eol,root:v.root,repo:v.repo,onSaved:({path:I})=>A(I),onClose:M}):null,e(Xt,{closeGuard:F,activeFile:v,saveMissingConfirm:h.saveMissingConfirm,onCancelSaveMissing:h.cancelSaveMissing,onConfirmSaveMissing:h.confirmSaveMissing})]})}function jt({fileName:t,onClose:r,children:l}){return e("div",{className:"flex flex-col h-full min-w-0","data-split-pane":"",children:[e("div",{className:"flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:[e("span",{className:"text-[11px] font-mono text-ink/60 truncate",title:t,children:t}),e("button",{type:"button",onClick:r,className:"p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0",title:"Close this pane (the tab stays open)","aria-label":"Close split pane",children:e(b,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function Qt({fraction:t,onFraction:r,rightPaneName:l,onClosePane:c,rightPane:p,children:g}){let v=i(null),h=i(null),y=Um(h),w=(x)=>{let k=x.currentTarget,O=v.current;if(!k||!O)return;k.setPointerCapture(x.pointerId);let C=(A)=>{let F=O.getBoundingClientRect();if(F.width===0)return;r(pe((A.clientX-F.left)/F.width))},M=()=>{k.releasePointerCapture(x.pointerId),k.removeEventListener("pointermove",C),k.removeEventListener("pointerup",M)};k.addEventListener("pointermove",C),k.addEventListener("pointerup",M)};return e("div",{ref:v,className:"flex w-full h-full","data-split-column":"",children:[e("div",{className:"flex flex-col min-w-0 h-full",style:{width:`${Math.round(pe(t)*100)}%`},children:g}),e("div",{ref:h,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${y?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:w}),e("div",{className:"flex-1 min-w-0 h-full",children:e(jt,{fileName:l,onClose:c,children:p})})]})}function tn({openedFiles:t,activeFileId:r,enabled:l}){let[c,p]=_("editor.split",he),g=t.map((k)=>k.id),v=et(tt(c,g),r),h=l&&v.rightFileId!==null?t.find((k)=>k.id===v.rightFileId)??null:null,y=a((k)=>{if(k!==null&&!Ee(k,r,g))return;p({...v,rightFileId:k})},[v,p,r,g]),w=a(()=>p({...v,rightFileId:null}),[v,p]),x=a((k)=>p({...v,fraction:pe(k)}),[v,p]);return{rightFile:h,fraction:v.fraction,splitTo:y,close:w,setFraction:x}}function nn({find:t,runCommand:r,reopenClosed:l}){let c=i(t);c.current=t;let p=i(r);p.current=r;let g=i(l);return g.current=l,{onKeyDownCapture:a((h)=>{let y=c.current;if(h.key==="Escape"){if(!y.open)return;h.preventDefault(),h.stopPropagation(),y.close();return}if((h.metaKey||h.ctrlKey)&&h.shiftKey&&h.code==="KeyT"){if(g.current?.())h.preventDefault(),h.stopPropagation();return}let w=hh(hi,h);if(!w||!hf(w))return;h.preventDefault(),h.stopPropagation(),p.current(w)},[])}}function on(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(p)=>r.current.runCommand(p)};return o(()=>{let p=l.current;if(!p)return;return Dg(p)},[]),{onFocusCapture:a(()=>{if(l.current)Dg(l.current)},[])}}function rn({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,saveNow:p}){let[g,v]=n(null);qt();let h=a((w)=>{let x=t.find((k)=>k.id===w);if(x&&Xe(w)){v(x);return}c(w)},[t,c]),y=a((w)=>{let x=g;if(!x)return;if(w==="cancel"){v(null);return}if(w==="save"){if(x.id!==r)l(x.id);p()}v(null),c(x.id)},[g,r,l,p,c]);return{requestClose:h,pending:g,answer:y}}function an(){let[t,r]=n(0),[l,c]=n(!1),p=a(()=>r((g)=>g+1),[]);return{goToLineRequest:t,openGoToLine:p,saveAsOpen:l,setSaveAsOpen:c}}function Un({className:t="",openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:g,refreshKey:v=0,onFileSaved:h,onOpenPath:y,onReopenClosed:w,reopenableCount:x,onCopyPath:k,onRevealInFiles:O,rootPath:C=null,repoPath:M=null,activeEditorPanelKey:A=null,forcedActiveFileId:F=null,asSplitPane:z=!1,onHidePanel:I}){let W=z?F:l,R=r.find((V)=>V.id===W),[L,G,X]=_("editor.previewMode",{}),Y=lu(String(W??"")),[N,P]=_("editor.zoomLevel",So),[H,J]=n(!1),[Q,te]=_("editor.wordWrap",!0),ie=an(),{sessionId:le}=Oe(),ee=tn({openedFiles:r,activeFileId:W,enabled:!z}),ne=i(null),de=Do(),ce=ki(),be=eu(r,v),Ie=Boolean(R&&be.has(R.id)),j=nu(R??null,{reportSaveError:!0,onFileSaved:h,missing:Ie}),sn=Lg({path:R?.path??"",content:j.content,language:j.language}),ln=j.diskChange,Fe=rn({openedFiles:r,activeFileId:W,onSelectFile:c,onCloseFile:p,saveNow:j.saveNow}),xe=ru({text:j.content,documentKey:`${R?.id??""}\x00${j.language}`,readSelection:()=>ne.current?.getSelection()??null,select:(V,ue,Be=!0)=>ne.current?.select(V,ue,Be),reveal:(V)=>ne.current?.revealOffset(V),applyDocument:(V,ue,Be)=>ne.current?.applyDocument(V,ue,Be),toggleWordWrap:()=>te((V)=>!V)}),ze=au(R?.path??null,j.content,j.loaded&&!j.loadError);$t({searchReveal:ze,revealMatch:xe.revealMatch}),ou({file:R,editor:j,surfaceRef:ne,isPreview:R?L[R.id]===!0:!1,exitPreview:()=>{let V=R?.id;if(V===void 0||V===null)return;G((ue)=>({...ue,[V]:!1}))}}),o(()=>{if(v>0)j.reset()},[v]),o(()=>{j.retain(r.map((V)=>V.id)),qe(r.map((V)=>V.id))},[r]),Vt({openedFiles:r,dirtyKeys:j.dirtyKeys,activeFile:R,previewReady:X,setPreviewMode:G,sessionId:le});let dn=()=>{if(!R)return;G((V)=>({...V,[R.id]:!V[R.id]}))},Re=(V)=>{if(hf(V)){xe.runCommand(V);return}if(V==="toggleWordWrap"){te((ue)=>!ue);return}if(V==="goToLine"){ie.openGoToLine();return}ne.current?.runCommand(V)},cn=nn({find:xe,runCommand:Re,reopenClosed:w}),mn=on({saveNow:j.saveNow,runCommand:Re}),Pe=Th(A);if(Pe)return e(zt,{pluginId:Pe.pluginId,Component:Pe.Component,sessionId:le,className:t,onHide:I});if(r.length===0)return e(Ht,{className:t,onHide:I});let pn=j.viewerKind,$e=R?L[R.id]:!1,fn={activeFile:R,editor:j,find:xe,surfaceRef:ne,pluginFileView:sn,wordWrap:Q,setWordWrap:te,viewerKind:pn,isPreview:Boolean($e),isReviewing:Boolean($e)&&Y.active,onToggleReview:Y.toggle,isMaximized:H,setIsMaximized:J,zoomLevel:N,setZoomLevel:P,goToLineRequest:ie.goToLineRequest,onSaveAs:()=>ie.setSaveAsOpen(!0),onOpenPath:y,rootPath:C,repoPath:M,runCommand:Re,editorFontFamily:de,editorTheme:ce,togglePreview:dn,revealActive:Boolean(ze),missing:Ie,onConvertDiffToEditor:g,onFileSaved:h},bn=(V)=>({openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:g,refreshKey:v,onFileSaved:h,onOpenPath:y,rootPath:C,repoPath:M,forcedActiveFileId:V,asSplitPane:!0}),hn=e(rt,{openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:Fe.requestClose,missingIds:be,onCopyPath:k,onRevealInFiles:O,onReopenClosed:w,reopenableCount:x,onSplitTo:ee.splitTo,onUnsplit:ee.close,splitRightFileId:ee.rightFile?.id??null,onHide:I}),Ve=e(Yt,{className:t,isMaximized:H,onKeyDownCapture:cn.onKeyDownCapture,onFocusCapture:mn.onFocusCapture,asSplitPane:z,tabs:hn,activeFile:R,editor:j,externalChange:ln,conflict:j.conflict,onReload:j.resolveConflictByReload,onKeepMine:j.keepMineAgainstDisk,body:e(Ft,{...fn}),saveAsOpen:ie.saveAsOpen,onSaveAsClose:()=>ie.setSaveAsOpen(!1),onSavedAs:(V)=>{ie.setSaveAsOpen(!1),y?.(V)},closeGuard:Fe});if(!ee.rightFile)return Ve;return e(Qt,{fraction:ee.fraction,onFraction:ee.setFraction,rightPaneName:ee.rightFile.name,onClosePane:ee.close,rightPane:e(Un,{...bn(ee.rightFile.id)}),children:Ve})}export{Un as Editor};