@kabmo-labs/kabmo 0.46.1 → 0.48.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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +506 -502
- package/dist/client/static/js/Body-3tspyjtk.js +3 -0
- package/dist/client/static/js/{CsvGrid-qdkmv8bj.js → CsvGrid-3pwsfmxp.js} +2 -2
- package/dist/client/static/js/{DocxView-k84ns803.js → DocxView-xcg9jktb.js} +3 -3
- package/dist/client/static/js/{DrawioView-r1n717f7.js → DrawioView-2q19tgkx.js} +2 -2
- package/dist/client/static/js/HtmlPreview-92cadvbr.js +1 -0
- package/dist/client/static/js/ImageView-pr4h38hb.js +1 -0
- package/dist/client/static/js/LayoutWrapper-n4tzhjes.js +2 -0
- package/dist/client/static/js/MergeDiffView-0t15nh9f.js +1 -0
- package/dist/client/static/js/{Modal-xe6h99jn.js → Modal-77hgx4dw.js} +20 -20
- package/dist/client/static/js/{PdfView-ffg4mccg.js → PdfView-gzxhvxe8.js} +1 -1
- package/dist/client/static/js/{SessionsView-cdcbsee9.js → SessionsView-2tdqrvk0.js} +1 -1
- package/dist/client/static/js/{SheetView-89sscpz6.js → SheetView-w5w2m2de.js} +22 -22
- package/dist/client/static/js/{SvgPreview-68c0ccbv.js → SvgPreview-mtk6de6h.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-h3a5s259.js → abnfDiagram-O67JEVCF-tha4j2fn.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-zs15nydj.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-983p0jgn.js → architectureDiagram-NJMV4G6O-heep78p6.js} +6 -6
- package/dist/client/static/js/{astro-hyj5wege.js → astro-r4dp34pw.js} +1 -1
- package/dist/client/static/js/bash-8d3wrx5c.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-16pse5mh.js → blockDiagram-BEXU5L5S-6mzgfqh8.js} +5 -5
- package/dist/client/static/js/c-rn3z0csz.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-mvnb00zt.js → c4Diagram-YGBWAQC7-sfkcw7g9.js} +4 -4
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-kmpd91xb.js → classDiagram-v2-NBCMYWYE-v530ny5e.js} +6 -6
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-3ek5r5se.js → cose-bilkent-JH36ORCC-ybv1ttbx.js} +1 -1
- package/dist/client/static/js/cpp-99ws9nak.js +1 -0
- package/dist/client/static/js/css-narcr42w.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-p3y1b4ap.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-jkbh84zn.js → cynefinDiagram-VND7K2PF-k8f3z0mm.js} +2 -2
- package/dist/client/static/js/{dagre-6A5THRUB-4fdc0sgn.js → dagre-6A5THRUB-gk0gp124.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-hbk61nq9.js → diagram-22UHCM2B-2zh2957c.js} +15 -15
- package/dist/client/static/js/{diagram-3UASUU5V-hfpbr9qh.js → diagram-3UASUU5V-bzstt5e2.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-fn0nt71a.js → diagram-ATOU4E4O-16adx4g0.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-ssswxjeb.js → diagram-CDSNMT55-1ja98ens.js} +5 -5
- package/dist/client/static/js/{diagram-MLGK6HIB-whnzxv6f.js → diagram-MLGK6HIB-f9nnyjbq.js} +2 -2
- package/dist/client/static/js/{diagram-MPIPVDR6-hk1chzxk.js → diagram-MPIPVDR6-3qgadfjz.js} +2 -2
- package/dist/client/static/js/{dockerfile-zmsj8r4g.js → dockerfile-04tc68pq.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-q1vkg5mr.js → ebnfDiagram-ZINNZB2B-022cz603.js} +1 -1
- package/dist/client/static/js/{elixir-80wq7gak.js → elixir-61gbjv6c.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-kt98vg8j.js → elk-276RUBZZ-2anf1c36.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-ey3avsn9.js → erDiagram-OPXOYQCR-ndd27fz1.js} +7 -7
- package/dist/client/static/js/{erlang-814e8qy5.js → erlang-bh5cbm8m.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-sx2cwkz3.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-dsc17mty.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-a9k1at43.js → ganttDiagram-FUAMR5RP-9gm6hkgn.js} +4 -4
- package/dist/client/static/js/gitGraph-4MIJSDKK-yqhbscsd.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-gnekjfym.js → gitGraphDiagram-X574FWY7-78bxa67c.js} +8 -8
- package/dist/client/static/js/graphql-tr0jcndy.js +1 -0
- package/dist/client/static/js/html-n8fdvrdk.js +1 -0
- package/dist/client/static/js/index-0e51wknc.js +10 -0
- package/dist/client/static/js/{index-z25ss7xj.js → index-13g17wa3.js} +1 -1
- package/dist/client/static/js/index-1hb8fvw9.js +1 -0
- package/dist/client/static/js/{index-1c2jvnyh.js → index-2bsnywea.js} +2 -2
- package/dist/client/static/js/{index-g7s0wsag.js → index-2n1fgpjv.js} +2 -2
- package/dist/client/static/js/{index-3x7h2eqj.js → index-30a8py59.js} +2 -2
- package/dist/client/static/js/{index-qf3y3ahx.js → index-34aq5bz5.js} +2 -2
- package/dist/client/static/js/index-3en15m75.js +2 -0
- package/dist/client/static/js/{index-nw5mvcaj.js → index-417fbrqk.js} +2 -2
- package/dist/client/static/js/{index-z4530r3c.js → index-45p59fxq.js} +2 -2
- package/dist/client/static/js/index-4n7t26ap.js +2 -0
- package/dist/client/static/js/{index-kty4ncsr.js → index-55pqvh82.js} +2 -2
- package/dist/client/static/js/index-5mpv57fn.js +12 -0
- package/dist/client/static/js/{index-x9r7zfp4.js → index-7pz6n3pg.js} +2 -2
- package/dist/client/static/js/{index-1ax52p0q.js → index-7whstwc7.js} +2 -2
- package/dist/client/static/js/index-869vdnz8.js +2 -0
- package/dist/client/static/js/{index-fzngzhww.js → index-8tvrzce0.js} +2 -2
- package/dist/client/static/js/index-9a78xmkk.js +462 -0
- package/dist/client/static/js/{index-33qxg79j.js → index-a58rkn3f.js} +5 -5
- package/dist/client/static/js/{index-60v30k5h.js → index-aa3hmn6j.js} +64 -64
- package/dist/client/static/js/{index-wrcdc9vz.js → index-aabp7nt6.js} +1 -1
- package/dist/client/static/js/{index-64sqfr4a.js → index-abrrqhne.js} +2 -2
- package/dist/client/static/js/{index-9vv7wr1n.js → index-ac2q5903.js} +2 -2
- package/dist/client/static/js/index-axtm1aq8.js +2 -0
- package/dist/client/static/js/index-b2cs4c51.js +4 -0
- package/dist/client/static/js/{index-8g7q8mz4.js → index-c250nzm1.js} +3 -3
- package/dist/client/static/js/{index-abs635a1.js → index-dxnkwf39.js} +48 -48
- package/dist/client/static/js/{index-kbhrvep8.js → index-e6ny4gd9.js} +6 -6
- package/dist/client/static/js/index-ebf50mrs.js +9 -0
- package/dist/client/static/js/{index-trvqvb1v.js → index-ep6bqcmg.js} +2 -2
- package/dist/client/static/js/{index-qfxn7yh5.js → index-fb2s080r.js} +2 -2
- package/dist/client/static/js/index-fryp0kgf.js +2 -0
- package/dist/client/static/js/{index-2ks0m8ss.js → index-g3rg6vsd.js} +2 -2
- package/dist/client/static/js/{index-sa1675y0.js → index-g8rpydkr.js} +2 -2
- package/dist/client/static/js/{index-bsr7wmj2.js → index-gkmn4y1v.js} +1 -1
- package/dist/client/static/js/{index-xq5f3nxa.js → index-gpmcth0x.js} +2 -2
- package/dist/client/static/js/{index-e9cxje00.js → index-hcmhdpp4.js} +10 -10
- package/dist/client/static/js/{index-kb14dhrx.js → index-he4k2j91.js} +2 -2
- package/dist/client/static/js/{index-wbws16ag.js → index-hq28918s.js} +2 -2
- package/dist/client/static/js/{index-84fyq5a6.js → index-hwzxdwwg.js} +1 -1
- package/dist/client/static/js/{index-2a6qp9y6.js → index-jnkc9p53.js} +1 -1
- package/dist/client/static/js/{index-pavvxrsz.js → index-k39be93q.js} +1 -1
- package/dist/client/static/js/{index-c9e417cs.js → index-kaxvwh07.js} +2 -2
- package/dist/client/static/js/{index-ykm7a3cp.js → index-kjr68pcj.js} +2 -2
- package/dist/client/static/js/{index-b5dfvget.js → index-m0fatq7c.js} +4 -4
- package/dist/client/static/js/{index-atq9q1s7.js → index-m39gbcxn.js} +1 -1
- package/dist/client/static/js/{index-hnb66d3s.js → index-mqzgf7rw.js} +2 -2
- package/dist/client/static/js/{index-5wz0y88c.js → index-pzsp1src.js} +2 -2
- package/dist/client/static/js/{index-yf93db65.js → index-qe0vfv6s.js} +1 -1
- package/dist/client/static/js/{index-q9ytjey8.js → index-qek9mt5w.js} +1 -1
- package/dist/client/static/js/{index-d23eacf2.js → index-qxzj780x.js} +2 -2
- package/dist/client/static/js/index-rgxg0azs.css +1 -0
- package/dist/client/static/js/{index-m4k054wz.js → index-rq4dk4tp.js} +4 -4
- package/dist/client/static/js/{index-fj5rsp5v.js → index-seekt5k3.js} +2 -2
- package/dist/client/static/js/{index-561gkvve.js → index-sng4prpr.js} +2 -2
- package/dist/client/static/js/{index-vjmg7kn5.js → index-t4s10406.js} +2 -2
- package/dist/client/static/js/{index-b2e5pwx7.js → index-tzz5gp8a.js} +5 -5
- package/dist/client/static/js/index-vnv9z0a1.js +1 -0
- package/dist/client/static/js/{index-19x11s5w.js → index-x7rajphe.js} +2 -2
- package/dist/client/static/js/{index-dxvtjn6a.js → index-xny7vsfz.js} +2 -2
- package/dist/client/static/js/index-xr4hjv01.js +2 -0
- package/dist/client/static/js/{index-65afr75v.js → index-ya9yqj5w.js} +2 -2
- package/dist/client/static/js/{index-z0fkfphe.js → index-zcgqacvx.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-0sd3zzgg.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-r1p25738.js → infoDiagram-VRGFBTTK-bxk0g0pe.js} +2 -2
- package/dist/client/static/js/ini-tnaw7zjy.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-afgrqdrt.js → ishikawaDiagram-OU5B5YK6-d1kdkhth.js} +3 -3
- package/dist/client/static/js/java-m4dpc2vw.js +1 -0
- package/dist/client/static/js/javascript-8y26t991.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-hepa4wk7.js → journeyDiagram-ZHPQQLJL-cahg3zjq.js} +4 -4
- package/dist/client/static/js/json-azm7bdqd.js +1 -0
- package/dist/client/static/js/jsx-p9j1k773.js +1 -0
- package/dist/client/static/js/{julia-yv2j8qd0.js → julia-2n5k898q.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-jysft8ya.js → kanban-definition-PNTS6WVX-nq7t83en.js} +6 -6
- package/dist/client/static/js/lua-hbm9rhz9.js +1 -0
- package/dist/client/static/js/markdown-tk3cd3vs.js +1 -0
- package/dist/client/static/js/{mermaid.core-0m90b0s8.js → mermaid.core-6nw0853j.js} +8 -8
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-x2rrzpvr.js → mindmap-definition-NLK3R4M7-cm7ykxf2.js} +3 -3
- package/dist/client/static/js/one-dark-pro-2cdc2nk7.js +1 -0
- package/dist/client/static/js/one-light-bt6z4jf0.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-13w2v5bb.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-z7vb7f1z.js → pegDiagram-GJSIUBJH-xwxz8nsq.js} +1 -1
- package/dist/client/static/js/{perl-917pjq5a.js → perl-66vb5pz7.js} +1 -1
- package/dist/client/static/js/{php-hwz75qzt.js → php-4e9we8am.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-swtnysgn.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-jqv6v4e6.js → pieDiagram-5QR66LMP-n910k9th.js} +3 -3
- package/dist/client/static/js/properties-6911ckw7.js +1 -0
- package/dist/client/static/js/python-44cvj250.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-w2h8yxrv.js → quadrantDiagram-O4NWA36T-dxkwxbqb.js} +6 -6
- package/dist/client/static/js/r-t3sepzm4.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-vtvxkx55.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-5sp2d63r.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-kg706fan.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-4ra1gzx5.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-hms3zpjm.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-nd09yac3.js → railroadDiagram-XR7U4H2S-xb1smt7r.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-t61zxh5v.js → requirementDiagram-PLB6GJNP-6kb21b9f.js} +6 -6
- package/dist/client/static/js/{ruby-er7ayhte.js → ruby-v7nmcvyr.js} +1 -1
- package/dist/client/static/js/{rust-avnkhh0p.js → rust-5ersd7be.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-2f7h2cmw.js → sankeyDiagram-IPEJSGJF-74z0fskw.js} +4 -4
- package/dist/client/static/js/{sass-n47tt136.js → sass-h3nvy4c8.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-kfb5d7zd.js → sequenceDiagram-PO4LG4MO-apn6kezn.js} +17 -17
- package/dist/client/static/js/{sizeCapture-INFHLROL-amfg19se.js → sizeCapture-INFHLROL-2drzcjb8.js} +1 -1
- package/dist/client/static/js/sql-zdkawqx3.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-k5hx7btx.js → stateDiagram-v2-GCMORJYK-ma09vhby.js} +3 -3
- package/dist/client/static/js/{svelte-2pmz35vx.js → svelte-dhspkgss.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-wv3rp8kk.js → swimlanes-2SLR337P-f6y9xqnx.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-3dwas56m.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-0re95wtn.js → timeline-definition-EJHVYXUP-zmcmvq00.js} +5 -5
- package/dist/client/static/js/treeView-Q6P3EWNA-7t5k6rs2.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-w56ry3bg.js +1 -0
- package/dist/client/static/js/tsx-b7eabr17.js +1 -0
- package/dist/client/static/js/typescript-nnkvhwfy.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-yrje14qp.js → usecaseDiagram-POWQR4AR-wfaa019a.js} +24 -24
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-jxkmrfy5.js → vennDiagram-UO4OBE2U-46wf2pgd.js} +8 -8
- package/dist/client/static/js/{vue-d5gpjfgn.js → vue-ffngx2b3.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-rtjb9kgv.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-d3v2m9b1.js → wardleyDiagram-VNRHLVJA-10ph3bzq.js} +4 -4
- package/dist/client/static/js/xml-xy1tw6b2.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-9a1s1rjt.js → xychartDiagram-PMCCYNJV-2ba825z9.js} +5 -5
- package/dist/client/static/js/yaml-0fexqg2d.js +1 -0
- package/marketplace/marketplace.json +34 -7
- package/marketplace/plugins/kanban/README.md +143 -0
- package/marketplace/plugins/kanban/icon.svg +5 -0
- package/marketplace/plugins/kanban/package.json +30 -0
- package/marketplace/plugins/kanban/src/app.tsx +34 -0
- package/marketplace/plugins/kanban/src/mcp-tools.ts +296 -0
- package/marketplace/plugins/kanban/src/mcp.test.ts +199 -0
- package/marketplace/plugins/kanban/src/mcp.ts +148 -0
- package/marketplace/plugins/kanban/src/panel/CardSheet.tsx +319 -0
- package/marketplace/plugins/kanban/src/panel/CardTile.tsx +97 -0
- package/marketplace/plugins/kanban/src/panel/StageColumn.tsx +116 -0
- package/marketplace/plugins/kanban/src/panel/StageSheet.tsx +249 -0
- package/marketplace/plugins/kanban/src/panel/catalogs.ts +114 -0
- package/marketplace/plugins/kanban/src/panel/index.tsx +327 -0
- package/marketplace/plugins/kanban/src/panel/panel.test.ts +219 -0
- package/marketplace/plugins/kanban/src/panel/start-work.ts +132 -0
- package/marketplace/plugins/kanban/src/panel/use-board.ts +148 -0
- package/marketplace/plugins/kanban/src/panel/use-card-detail.ts +70 -0
- package/marketplace/plugins/kanban/src/panel/use-writes.ts +123 -0
- package/marketplace/plugins/kanban/src/protocol.ts +180 -0
- package/marketplace/plugins/kanban/src/server.test.ts +113 -0
- package/marketplace/plugins/kanban/src/server.ts +227 -0
- package/marketplace/plugins/kanban/src/store/board.test.ts +311 -0
- package/marketplace/plugins/kanban/src/store/board.ts +147 -0
- package/marketplace/plugins/kanban/src/store/cards.ts +228 -0
- package/marketplace/plugins/kanban/src/store/fs.ts +159 -0
- package/marketplace/plugins/kanban/src/store/ops.ts +245 -0
- package/marketplace/plugins/kanban/src/store/resolve.test.ts +82 -0
- package/marketplace/plugins/kanban/src/store/resolve.ts +135 -0
- package/marketplace/plugins/kanban/tsconfig.json +26 -0
- package/package.json +2 -2
- package/src/client/components/common/file-icon/index.tsx +1 -1
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +12 -3
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +34 -7
- package/src/client/components/layout/desktop-layout/index.tsx +17 -22
- package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +2 -0
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +11 -3
- package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.test.tsx +21 -0
- package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +8 -4
- package/src/client/components/settings/categories/appearance-settings/ThemeCard.tsx +8 -2
- package/src/client/components/settings/categories/appearance-settings/ThemeGrid.tsx +15 -4
- package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +10 -3
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +27 -4
- package/src/client/components/settings/categories/usage-settings/TokenHarborCard.tsx +160 -0
- package/src/client/components/settings/categories/usage-settings/TokenPortalCard.tsx +104 -0
- package/src/client/components/settings/categories/usage-settings/format.ts +35 -0
- package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +16 -0
- package/src/client/components/settings/categories/usage-settings/providers.ts +26 -4
- package/src/client/components/settings/categories/usage-settings/token-harbor-card.test.tsx +114 -0
- package/src/client/components/settings/categories/usage-settings/token-harbor-hint.test.ts +68 -0
- package/src/client/components/settings/categories/usage-settings/token-portal-card.test.tsx +81 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +66 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.test.ts +21 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +7 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.test.ts +13 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.tsx +41 -18
- package/src/client/components/workspace/editor/BodyLazy.tsx +40 -0
- package/src/client/components/workspace/editor/FilePane.tsx +4 -2
- package/src/client/components/workspace/editor/Tabs.tsx +7 -1
- package/src/client/components/workspace/editor/Toolbar.tsx +7 -1
- package/src/client/components/workspace/editor/chrome-rows.test.tsx +126 -0
- package/src/client/components/workspace/editor/index.tsx +2 -2
- package/src/client/components/workspace/editor/viewers/HtmlPreview.test.tsx +94 -0
- package/src/client/components/workspace/editor/viewers/HtmlPreview.tsx +71 -0
- package/src/client/components/workspace/editor/viewers/bytes.ts +1 -1
- package/src/client/components/workspace/editor/viewers/dispatch.tsx +18 -2
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +14 -1
- package/src/client/components/workspace/panel-header/index.test.tsx +2 -1
- package/src/client/components/workspace/panel-header/index.tsx +6 -4
- package/src/client/data/settings/omp-schema.json +33 -10
- package/src/client/hooks/editor/resolve-viewer.ts +1 -1
- package/src/client/hooks/editor/use-editor-drop.ts +14 -0
- package/src/client/hooks/editor/use-editor-tab-state.ts +5 -4
- package/src/client/hooks/ui/media-query.ts +27 -0
- package/src/client/hooks/workspace/file-tabs.ts +10 -0
- package/src/client/hooks/workspace/right-panel-presence.test.ts +152 -0
- package/src/client/hooks/workspace/right-panel-presence.ts +119 -0
- package/src/client/lib/router/search-params.test.ts +83 -0
- package/src/client/lib/router/search-params.ts +14 -3
- package/src/server/lib/mcp/session-mcp.test.ts +64 -1
- package/src/server/lib/mcp/session-overlay.server.ts +7 -4
- package/src/server/lib/omp/rpc/constants.test.ts +31 -0
- package/src/server/lib/omp/rpc/constants.ts +19 -0
- package/src/server/lib/omp/rpc/session-new.ts +78 -0
- package/src/server/lib/omp/rpc/session-registry.ts +22 -49
- package/src/server/lib/omp/rpc/spawn-mcp.ts +8 -1
- package/src/server/lib/omp/session/blobs.server.ts +2 -1
- package/src/server/lib/plugins/e2e.test.ts +71 -2
- package/src/server/lib/plugins/loader.server.ts +20 -1
- package/src/server/lib/plugins/module-import.server.ts +45 -0
- package/src/server/lib/usage/provider-key.ts +18 -0
- package/src/server/lib/usage/providers.server.ts +27 -3
- package/src/server/lib/usage/report.server.ts +24 -0
- package/src/server/lib/usage/token-harbor.test.ts +191 -0
- package/src/server/lib/usage/token-harbor.ts +207 -0
- package/src/server/lib/usage/token-portal.test.ts +140 -0
- package/src/server/lib/usage/token-portal.ts +179 -0
- package/src/server/lib/usage/vendor-http.test.ts +52 -0
- package/src/server/lib/usage/vendor-http.ts +9 -2
- package/src/server/routes/agent/new-prompt.test.ts +81 -0
- package/src/server/routes/agent/new.ts +78 -4
- package/src/server/routes/fs/raw.test.ts +12 -0
- package/src/server/routes/fs/raw.ts +2 -6
- package/src/server/routes/wiki/asset.ts +1 -1
- package/src/shared/lib/fs/document-kind.test.ts +39 -2
- package/src/shared/lib/fs/document-kind.ts +49 -1
- package/src/shared/lib/fs/file-kind.test.ts +30 -3
- package/src/shared/lib/fs/file-kind.ts +7 -104
- package/src/shared/lib/fs/mime.ts +159 -0
- package/src/shared/lib/omp/config/schema-releases.test.ts +22 -0
- package/src/shared/lib/workspace/sidebar-width.test.ts +34 -0
- package/src/shared/lib/workspace/sidebar-width.ts +33 -0
- package/src/shared/lib/workspace/workspace-panel-widths.test.ts +124 -0
- package/src/shared/lib/workspace/workspace-panel-widths.ts +115 -18
- package/src/shared/types/settings/usage.ts +89 -2
- package/dist/client/static/js/ImageView-jkrdrq8v.js +0 -1
- package/dist/client/static/js/LayoutWrapper-sh634350.js +0 -2
- package/dist/client/static/js/architecture-7GRP2DOG-pvb4d65d.js +0 -1
- package/dist/client/static/js/bash-8d8z8zrg.js +0 -1
- package/dist/client/static/js/c-acmn1zc9.js +0 -1
- package/dist/client/static/js/cpp-620mvjkk.js +0 -1
- package/dist/client/static/js/css-bt76kxbq.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-gmx4vean.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-vrnheyh7.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-7gvtpn3d.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-n6wnc8st.js +0 -1
- package/dist/client/static/js/graphql-j1a6zp7m.js +0 -1
- package/dist/client/static/js/html-m0megrvb.js +0 -1
- package/dist/client/static/js/index-4cag7w6k.js +0 -479
- package/dist/client/static/js/index-5ka2tyf9.js +0 -3
- package/dist/client/static/js/index-83rkg916.js +0 -2
- package/dist/client/static/js/index-amsa0tfs.js +0 -2
- package/dist/client/static/js/index-dn7hg4em.js +0 -2
- package/dist/client/static/js/index-dpy3ewrn.css +0 -1
- package/dist/client/static/js/index-dt6q3rws.js +0 -12
- package/dist/client/static/js/index-hgzntg2j.js +0 -2
- package/dist/client/static/js/index-vkqb4dnt.js +0 -1
- package/dist/client/static/js/index-xwjbq003.js +0 -2
- package/dist/client/static/js/info-A6RAGUB7-1xtdxjz2.js +0 -1
- package/dist/client/static/js/ini-5f4zqtqr.js +0 -1
- package/dist/client/static/js/java-jj41mty3.js +0 -1
- package/dist/client/static/js/javascript-n9w9p97f.js +0 -1
- package/dist/client/static/js/json-rnh2h17x.js +0 -1
- package/dist/client/static/js/jsx-4gecrt29.js +0 -1
- package/dist/client/static/js/lua-zszaw2f7.js +0 -1
- package/dist/client/static/js/markdown-nm6gw4v4.js +0 -1
- package/dist/client/static/js/one-dark-pro-09d8p5vy.js +0 -1
- package/dist/client/static/js/one-light-g3ednt6p.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-zm1r82x5.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-sqa7321j.js +0 -1
- package/dist/client/static/js/properties-rkptax7r.js +0 -1
- package/dist/client/static/js/python-qf1se1mj.js +0 -1
- package/dist/client/static/js/r-ms0cygq2.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-z3z82syp.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-z6swcqq2.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-33km6py4.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-1zbf1xmq.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-wte1xzzy.js +0 -1
- package/dist/client/static/js/sql-hd42h8wx.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-6y8zdbm4.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-pvgx6n22.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-3n9zm628.js +0 -1
- package/dist/client/static/js/tsx-gx7td06z.js +0 -1
- package/dist/client/static/js/typescript-1a808spn.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-7m07ewc4.js +0 -1
- package/dist/client/static/js/xml-3117mxd9.js +0 -1
- package/dist/client/static/js/yaml-dmvh8vyt.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,n,o,i,u,a,le,e,s,f,B,se,vo,re,ce,b,Gp,Ie,S,bt,Wa,st,ue,lt,IA,mi}from"./index-4cag7w6k.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 L(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(ue(x,r),!l)return null;let m=c?[{label:"Total Cost",value:L(c.total),strong:!0},{label:"Input (cache miss)",value:L(c.input)},{label:"Output",value:L(c.output)},{label:"Cache Read (cache hit)",value:L(c.cacheRead)},{label:"Cache Write",value:L(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(lt,{variant:"compact",label:"Messages",value:l}),e(lt,{variant:"compact",label:"User",value:r}),e(lt,{variant:"compact",label:"Assistant",value:c}),e(lt,{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(lt,{variant:"compact",label:"In",value:l.toLocaleString()}),e(lt,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(lt,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(lt,{variant:"compact",label:"Cache",value:`${h.toLocaleString()}/${x.toLocaleString()}`}),e(lt,{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}){mi();let[r,c]=n(!1),h=i(null),x=i(null),m=JSON.stringify(l,null,2),t=IA(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"],_=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]=S("context.rawExpandedIds",{}),[x,m]=S("context.rawFilterRole","all"),[t,v]=n(1),[y,C]=n([]),[g,I]=n(0),[W,R]=n(!1),w=i(0),E=i(!1),j=a((p)=>{if(typeof window>"u")return;let k=++w.current;if(!p?.silent)R(!0);let P=new URLSearchParams({page:String(t),pageSize:String(_),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)R(!1)})},[l,t,x]);o(()=>(E.current=!1,j(),()=>{E.current=!0}),[j,r]);let T=Math.max(1,Math.ceil(g/_)),M=Math.min(t,T),U=(p)=>v(Math.min(Math.max(1,p),T)),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)})}),T>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)*_+1,"–",Math.min(M*_,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(vo,{size:14})}),Y(M,T).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>=T,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 R=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${R}`).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=Ie(m?Gp(m):null,{enabled:r}),[I,W]=n(0);if(o(()=>{if(g.data)v(g.data),W((R)=>R+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(bt,{left:e(d,{children:[e(Wa,{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(st,{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,Co,re,ce,b,um,_e,S,yt,Ja,ut,de,Ne,rh,hi}from"./index-9a78xmkk.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 L(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(de(x,r),!l)return null;let m=c?[{label:"Total Cost",value:L(c.total),strong:!0},{label:"Input (cache miss)",value:L(c.input)},{label:"Output",value:L(c.output)},{label:"Cache Read (cache hit)",value:L(c.cacheRead)},{label:"Cache Write",value:L(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(Ne,{variant:"compact",label:"Messages",value:l}),e(Ne,{variant:"compact",label:"User",value:r}),e(Ne,{variant:"compact",label:"Assistant",value:c}),e(Ne,{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(Ne,{variant:"compact",label:"In",value:l.toLocaleString()}),e(Ne,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(Ne,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(Ne,{variant:"compact",label:"Cache",value:`${h.toLocaleString()}/${x.toLocaleString()}`}),e(Ne,{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}){hi();let[r,c]=n(!1),h=i(null),x=i(null),m=JSON.stringify(l,null,2),t=rh(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"],_=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]=S("context.rawExpandedIds",{}),[x,m]=S("context.rawFilterRole","all"),[t,v]=n(1),[y,C]=n([]),[g,I]=n(0),[W,R]=n(!1),w=i(0),E=i(!1),j=a((p)=>{if(typeof window>"u")return;let k=++w.current;if(!p?.silent)R(!0);let P=new URLSearchParams({page:String(t),pageSize:String(_),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)R(!1)})},[l,t,x]);o(()=>(E.current=!1,j(),()=>{E.current=!0}),[j,r]);let T=Math.max(1,Math.ceil(g/_)),M=Math.min(t,T),U=(p)=>v(Math.min(Math.max(1,p),T)),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)})}),T>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)*_+1,"–",Math.min(M*_,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(Co,{size:14})}),Y(M,T).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>=T,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 pt({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 R=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${R}`).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=_e(m?um(m):null,{enabled:r}),[I,W]=n(0);if(o(()=>{if(g.data)v(g.data),W((R)=>R+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(yt,{left:e(d,{children:[e(Ja,{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(ut,{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{pt as ContextPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,o,i,a,e,s,E,ne,De,Se,_,ai,Xe,Qe,Ne,b,J,hi,cf}from"./index-4cag7w6k.js";var B={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},I=s(B);function T({title:t,options:r,methodLabel:c,badge:m,icon:x,onCancel:k}){let f=hi({title:t,options:r})?cf(t):null,h=f?`Allow ${f.tool}`:t||c;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:h}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Se,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:k,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(b,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:c,customValue:m,onCustomChange:x,customInputRef:k,onSelect:f,onConfirmOption:h,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((v,y)=>{let u=c===v,g=r[y]?.description;return e("button",{type:"button",onClick:()=>f(v),onDblClick:()=>h(v),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:v})}),g&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:g})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(ai,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},v)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:k,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(v)=>x(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter"){if(v.preventDefault(),v.stopPropagation(),m.trim())h(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function P({method:t,optionsLength:r,selectedOption:c,hasCustomAnswer:m=!1,onCancel:x,onSubmit:k}){let f=t==="select"&&!c&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(b,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:k,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(Xe,{size:12,className:"opacity-70"})]})]})]})}function R({title:t,options:r}){let c=hi({title:t,options:r})?cf(t):null;if(!c)return null;return e("div",{className:"space-y-2",children:[c.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:c.reason})]}),c.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:c.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function L({method:t,options:r,selectedOption:c,onSelectOption:m,customInputRef:x,onSubmit:k,onCancel:f}){o(()=>{let h=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u<r.length-1?u+1:0;m(r[g]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u>0?u-1:r.length-1;m(r[g]);return}if(l.key==="Enter"&&c){l.preventDefault(),k();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),k();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),k();return}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,k,t,r,c,m,x])}function z(t,r){switch(t){case"select":return{icon:e(I,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(E,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Ne,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Qe,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(De,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[c,m]=n(t.method==="editor"?t.prefill??"":""),[x,k]=n(null),[f,h]=n(""),l=i(null),v=i(null),y=i(null),u=i(null),g=t.options??[],N=t.optionDetails??[],A=hi(t);o(()=>{let p=t.options??[];m(t.method==="editor"?t.prefill??"":""),k(p.length>0?p[0]:null),h("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")v.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((C)=>/^other\b/i.test(C.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),M=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!A)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:c})},[r,t,x,c,f,A]),O=a((p)=>{if(/^other\b/i.test(p.trim())){k(p),u.current?.focus();return}r(t,{value:p})},[r,t]),H=a((p)=>{if(k(p),/^other\b/i.test(p.trim()))u.current?.focus()},[]);L({method:t.method,options:g,selectedOption:x,onSelectOption:k,customInputRef:u,onSubmit:M,onCancel:w});let D=z(t.method,g.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center modal-safe sm:p-6 backdrop-blur-[8px]",onMouseDown:(p)=>{if(p.target===p.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(T,{title:t.title,options:g,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(R,{title:t.title,options:g}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(J,{content:t.message})}),t.method==="select"&&e(S,{options:g,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:h,customInputRef:u,onSelect:H,onConfirmOption:O,hideCustomAnswer:A}),t.method==="confirm"&&g.length>0&&e("div",{className:"space-y-2",children:g.map((p,C)=>e("button",{type:"button",onClick:()=>r(t,{optionId:t.optionIds?.[C]??p}),className:"flex w-full cursor-pointer items-center justify-between rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 text-left text-[13px] font-medium text-ink transition-colors hover:border-ink/30 hover:bg-canvas/50",children:e("span",{className:"min-w-0 break-words",children:p})},t.optionIds?.[C]??p))}),t.method==="confirm"&&g.length===0&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:v,type:t.secret===!0?"password":"text",value:c,placeholder:t.placeholder||"Type your response...",onChange:(p)=>m(p.currentTarget.value),onKeyDown:(p)=>{if(p.key==="Enter")p.preventDefault(),M()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[c.split(`
|
|
1
|
+
import{d,n,o,i,a,e,s,E,ne,Qe,Te,_,li,Ve,Le,Re,b,J,Ci,Nf}from"./index-9a78xmkk.js";var B={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},I=s(B);function T({title:t,options:r,methodLabel:c,badge:m,icon:x,onCancel:k}){let f=Ci({title:t,options:r})?Nf(t):null,h=f?`Allow ${f.tool}`:t||c;return e("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:[e("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-ink/12 bg-paper text-ink shadow-xs",children:x}),e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2",children:[e("h3",{className:"truncate text-[14px] font-semibold tracking-tight text-ink",children:h}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Te,{size:9,className:"text-ink/40"}),m]})]}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:f?"The agent wants to run this. Review it before you allow.":"Autonomous agent inquiry requiring user confirmation"})]})]}),e("button",{type:"button",onClick:k,"aria-label":"Close dialog (Esc)",title:"Cancel (Esc)",className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-ink/10 text-ink/45 transition-colors hover:border-ink/25 hover:bg-ink/5 hover:text-ink",children:e(b,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:c,customValue:m,onCustomChange:x,customInputRef:k,onSelect:f,onConfirmOption:h,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((v,y)=>{let u=c===v,g=r[y]?.description;return e("button",{type:"button",onClick:()=>f(v),onDblClick:()=>h(v),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:v})}),g&&e("div",{className:"mt-1 text-[11.5px] leading-relaxed text-ink/55",children:g})]}),e("span",{className:"mt-0.5 shrink-0",children:u?e(ne,{size:16,className:"text-ink"}):e(li,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},v)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:k,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(v)=>x(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter"){if(v.preventDefault(),v.stopPropagation(),m.trim())h(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function P({method:t,optionsLength:r,selectedOption:c,hasCustomAnswer:m=!1,onCancel:x,onSubmit:k}){let f=t==="select"&&!c&&!m;return e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/8 bg-canvas/40 px-5 py-3.5",children:[e("div",{className:"flex items-center gap-2 font-mono text-[11px] text-ink/50",children:[t==="select"&&e(d,{children:[e("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:["1-",Math.min(9,r)]}),e("span",{className:"text-ink/40",children:"choose"})]}),e("span",{className:"hidden text-ink/30 sm:inline",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"select"})]})]}),t==="confirm"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"↵"}),e("span",{className:"text-ink/40",children:"confirm"})]}),t==="editor"&&e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"⌘↵"}),e("span",{className:"text-ink/40",children:"save buffer"})]}),e("span",{className:"text-ink/30",children:"•"}),e("span",{className:"inline-flex items-center gap-1",children:[e("kbd",{className:"rounded border border-ink/15 bg-paper px-1.5 py-0.5 text-[10px] text-ink shadow-xs",children:"Esc"}),e("span",{className:"text-ink/40",children:"cancel"})]})]}),e("div",{className:"flex items-center gap-2.5 ml-auto",children:[e("button",{type:"button",onClick:x,className:"flex cursor-pointer items-center gap-1 rounded-lg border border-ink/15 bg-paper px-3.5 py-1.5 text-[12px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:bg-canvas/50 hover:text-ink",children:[e(b,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:k,disabled:f,className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-ink px-4 py-1.5 text-[12px] font-semibold text-paper shadow-xs transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-35",children:[e("span",{children:t==="confirm"?"Confirm":t==="select"?"Select Option":"Submit Response"}),e(Ve,{size:12,className:"opacity-70"})]})]})]})}function R({title:t,options:r}){let c=Ci({title:t,options:r})?Nf(t):null;if(!c)return null;return e("div",{className:"space-y-2",children:[c.reason&&e("div",{className:"flex items-start gap-2 rounded-xl border border-warning/25 bg-warning/8 px-3.5 py-2.5 text-[12px] leading-relaxed text-ink/80",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-warning"}),e("span",{className:"min-w-0 break-words",children:c.reason})]}),c.details.length>0&&e("div",{className:"rounded-xl border border-ink/10 bg-canvas/40 px-3.5 py-2.5",children:c.details.map((m,x)=>e("div",{className:"font-mono text-[11.5px] leading-relaxed text-ink/75 break-all",children:m},`${x}-${m}`))})]})}function L({method:t,options:r,selectedOption:c,onSelectOption:m,customInputRef:x,onSubmit:k,onCancel:f}){o(()=>{let h=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let y=parseInt(l.key,10);if(!isNaN(y)&&y>=1&&y<=r.length){l.preventDefault(),m(r[y-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u<r.length-1?u+1:0;m(r[g]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((N)=>N===c),g=u>0?u-1:r.length-1;m(r[g]);return}if(l.key==="Enter"&&c){l.preventDefault(),k();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),k();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),k();return}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,k,t,r,c,m,x])}function z(t,r){switch(t){case"select":return{icon:e(I,{size:16,className:"text-ink"}),label:"Decision Required",badge:`${r} Choices`};case"confirm":return{icon:e(E,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Re,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Le,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Qe,{size:16,className:"text-ink"}),label:"Agent Request",badge:"Input"}}}function ke({request:t,onRespond:r}){let[c,m]=n(t.method==="editor"?t.prefill??"":""),[x,k]=n(null),[f,h]=n(""),l=i(null),v=i(null),y=i(null),u=i(null),g=t.options??[],N=t.optionDetails??[],A=Ci(t);o(()=>{let p=t.options??[];m(t.method==="editor"?t.prefill??"":""),k(p.length>0?p[0]:null),h("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")v.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((C)=>/^other\b/i.test(C.trim())))u.current?.focus()}},[t]);let w=a(()=>{r(t,{cancelled:!0})},[r,t]),M=a(()=>{if(t.method==="confirm")r(t,{confirmed:!0});else if(t.method==="select"){if(f.trim()&&!A)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:c})},[r,t,x,c,f,A]),O=a((p)=>{if(/^other\b/i.test(p.trim())){k(p),u.current?.focus();return}r(t,{value:p})},[r,t]),H=a((p)=>{if(k(p),/^other\b/i.test(p.trim()))u.current?.focus()},[]);L({method:t.method,options:g,selectedOption:x,onSelectOption:k,customInputRef:u,onSubmit:M,onCancel:w});let D=z(t.method,g.length);return e("div",{className:"extension-dialog-backdrop modal-scrim fixed inset-0 z-50 flex items-center justify-center modal-safe sm:p-6 backdrop-blur-[8px]",onMouseDown:(p)=>{if(p.target===p.currentTarget)w()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||D.label,tabIndex:-1,className:"glass-overlay extension-dialog-panel w-full max-w-[560px] overflow-hidden rounded-2xl border border-ink/15 bg-paper shadow-2xl outline-none",style:{boxShadow:"0 24px 64px -8px color-mix(in srgb, var(--theme-ink) 28%, transparent)"},children:[e(T,{title:t.title,options:g,methodLabel:D.label,badge:D.badge,icon:D.icon,onCancel:w}),e("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5 space-y-4",children:[e(R,{title:t.title,options:g}),t.message&&e("div",{className:"rounded-xl border border-ink/8 bg-canvas/40 p-4 text-[13px] leading-relaxed text-ink/85 select-text",children:e(J,{content:t.message})}),t.method==="select"&&e(S,{options:g,optionDetails:N,selectedOption:x,customValue:f,onCustomChange:h,customInputRef:u,onSelect:H,onConfirmOption:O,hideCustomAnswer:A}),t.method==="confirm"&&g.length>0&&e("div",{className:"space-y-2",children:g.map((p,C)=>e("button",{type:"button",onClick:()=>r(t,{optionId:t.optionIds?.[C]??p}),className:"flex w-full cursor-pointer items-center justify-between rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 text-left text-[13px] font-medium text-ink transition-colors hover:border-ink/30 hover:bg-canvas/50",children:e("span",{className:"min-w-0 break-words",children:p})},t.optionIds?.[C]??p))}),t.method==="confirm"&&g.length===0&&e("div",{className:"flex items-center gap-3 rounded-xl border border-ink/10 bg-canvas/30 p-4",children:[e("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink",children:e(ne,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:v,type:t.secret===!0?"password":"text",value:c,placeholder:t.placeholder||"Type your response...",onChange:(p)=>m(p.currentTarget.value),onKeyDown:(p)=>{if(p.key==="Enter")p.preventDefault(),M()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[c.split(`
|
|
2
2
|
`).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:y,value:c,onChange:(p)=>m(p.currentTarget.value),rows:8,placeholder:t.placeholder||"Enter content...",className:"w-full rounded-xl border border-ink/15 bg-canvas/30 px-4 py-3 font-mono text-[12px] leading-relaxed text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:bg-paper focus:ring-2 focus:ring-ink/15"})]})]}),e(P,{method:t.method,optionsLength:g.length,selectedOption:x,hasCustomAnswer:f.trim().length>0,onCancel:w,onSubmit:M})]})})}export{ke as ExtensionDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,n,o,i,u,a,e,E,m,an,on,Be,Yr,U,bA,Ie,S,gr,Ar,bt,st,Z,J}from"./index-4cag7w6k.js";import{kr}from"./index-c9e417cs.js";function B({sections:c,selected:t,onSelect:l}){let[r,f]=n(""),x=u(()=>{let p=r.trim().toLowerCase();if(!p)return c;return c.map((h)=>({...h,links:h.links.filter((s)=>s.label.toLowerCase().includes(p)||(s.path??s.target).toLowerCase().includes(p))})).filter((h)=>h.links.length>0)},[c,r]),k=c.some((p)=>p.links.length>0);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-canvas/40",children:[e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5 flex-shrink-0",children:[e(U,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{type:"text",value:r,onChange:(p)=>f(p.currentTarget.value),placeholder:"Filter pages…",title:"Filter wiki pages",className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder-ink/40"}),r&&e("button",{type:"button",onClick:()=>f(""),title:"Clear filter",className:"flex-shrink-0 text-ink/40 hover:text-ink",children:"×"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:x.length===0?e("p",{className:"px-3 py-2 text-[11px] italic text-ink/40",children:k?"No page matches the filter":"This wiki has no pages"}):x.map((p,h)=>e("div",{className:"py-0.5",children:[p.title&&e("div",{className:"px-2.5 py-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:p.title}),p.links.map((s,g)=>{let b=s.path!==null&&s.path===t,w=`${s.path??s.target}-${g}`;if(s.path)return e("button",{type:"button",onClick:()=>l(s.path),title:s.path,"aria-current":b?"page":void 0,className:`flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs transition-colors ${b?"bg-ink/8 font-medium text-ink":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,children:e("span",{className:"truncate",children:s.label})},w);if(s.url)return e("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",title:s.url,className:"flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs text-ink/70 hover:bg-ink/5 hover:text-ink",children:[e("span",{className:"truncate",children:s.label}),e(Be,{size:10,className:"flex-shrink-0 text-ink/30"})]},w);return e("div",{title:`Not in this wiki: ${s.target}`,className:"flex w-full items-center px-2.5 py-1 text-left text-xs text-ink/35 line-through decoration-ink/20",children:e("span",{className:"truncate",children:s.label})},w)}),p.notes.map((s,g)=>e("p",{className:"px-2.5 py-0.5 text-[10px] leading-snug text-ink/50",children:s},`note-${g}`))]},`${p.title??"links"}-${h}`))})]})}function j({open:c,onClick:t}){return e("button",{type:"button",onClick:t,title:"Browse wiki pages","aria-label":"Browse wiki pages","aria-expanded":c,className:"absolute bottom-3 right-3 z-20 flex h-9 w-9 items-center justify-center rounded-full border border-ink/20 bg-paper text-ink/60 shadow-sm transition-all hover:bg-ink/5 hover:text-ink",children:e(Yr,{size:16})})}function V({open:c,sections:t,selected:l,onSelect:r,onClose:f}){if(o(()=>{if(!c)return;let x=(k)=>{if(k.key==="Escape")f()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[c,f]),!c)return null;return e(Z,{onClose:f,maxWidthClass:"max-w-sm",zClass:"z-[70]",ariaLabel:"Wiki pages",header:e("div",{className:"flex min-w-0 items-center gap-2",children:[e(Yr,{size:15,className:"flex-shrink-0 text-ink/50"}),e("span",{className:"text-sm font-medium",children:"Wiki pages"})]}),children:e("div",{className:"flex h-[60vh] min-h-0 flex-col",children:e(B,{sections:t,selected:l,onSelect:(x)=>{r(x),f()}})})})}function re(c,t){if(!c.webUrl)return null;let r=(t.split("/").pop()??t).replace(/\.(md|markdown)$/i,"");return c.provider==="gitlab"?`${c.webUrl.replace(/\/home$/,"")}/${encodeURIComponent(t.replace(/\.(md|markdown)$/i,""))}`:`${c.webUrl}/${encodeURIComponent(r)}`}function G({repo:c,entries:t,path:l,page:r,isLoading:f,error:x,rootPath:k,repoScope:p,onNavigate:h,onBack:s}){let g=re(c,l),b=u(()=>({path:l,entries:t,root:k,repo:p}),[l,t,k,p]);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-paper",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2.5 py-1.5",children:[s&&e("button",{type:"button",onClick:s,title:"Back to the page list","aria-label":"Back to the page list",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink @[520px]:hidden",children:e(an,{size:13})}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] text-ink/50",title:l,children:l}),f&&e(m,{size:12,className:"flex-shrink-0 animate-spin text-ink/40"}),g&&e("a",{href:g,target:"_blank",rel:"noopener noreferrer",title:"Open this page on the wiki host","aria-label":"Open this page on the wiki host",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Be,{size:13})})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:x?e("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-xs text-error",children:x})]}):!r?e("div",{className:"px-6 py-8 text-center text-xs text-ink/40",children:f?"Loading page…":"No page selected"}):e("article",{className:"mx-auto max-w-4xl px-5 py-4",children:[e(J,{content:r.content,className:"max-w-none",wikiScope:b,onWikiNavigate:h}),r.truncated&&e("p",{className:"mt-4 border-t border-ink/10 pt-2 text-[11px] text-ink/50",children:"This page is longer than the reader's budget and was cut off."})]})})]})}function O(c,t){return`${c??""}\x00${t}`}function H(c,t){let l=new URLSearchParams;if(c)l.set("root",c);if(t&&t!==".")l.set("repo",t);return l}function X(c){let{rootPath:t,repo:l,enabled:r,active:f,revisionKey:x=0}=c,k=O(t,l),[p,h]=n(null),s=i(k);s.current=k;let g=Ie(bA(k),{enabled:r&&f}),{refresh:b}=g;o(()=>{h(null)},[k]);let w=a((R)=>{if(!r)return;if(!R?.force){b();return}let W=s.current,L=H(t,l);L.set("refresh","1"),fetch(`/api/wiki?${L.toString()}`).then(async(N)=>{let y=await N.json();if(!N.ok)throw Error(y?.error||`Wiki request failed (${N.status})`)}).then(()=>{if(s.current!==W)return;h(null),b()}).catch((N)=>{if(s.current!==W)return;h(N instanceof Error?N.message:"Failed to load the wiki")})},[r,t,l,b]);return o(()=>{if(x>0)b()},[x]),{data:g.data,isLoading:g.isLoading,refreshing:g.refreshing,error:p,reload:w}}function Q(c){let{rootPath:t,repo:l,path:r,enabled:f,active:x,revisionKey:k=0}=c,p=`${O(t,l)}\x00${r??""}`,[h,s]=n({scope:p,data:null}),[g,b]=n(!1),[w,R]=n(null),W=i(0);return o(()=>{if(!f||!x||!r){s({scope:p,data:null}),R(null);return}let L=++W.current;b(!0);let N=H(t,l);N.set("path",r),fetch(`/api/wiki/page?${N.toString()}`).then(async(y)=>{let _=await y.json();if(!y.ok)throw Error(_?.error||`Page request failed (${y.status})`);return _}).then((y)=>{if(W.current!==L)return;s({scope:p,data:y}),R(null)}).catch((y)=>{if(W.current!==L)return;R(y instanceof Error?y.message:"Failed to load the page")}).finally(()=>{if(W.current===L)b(!1)})},[p,t,l,r,f,x,k]),{data:h.scope===p?h.data:null,isLoading:g,error:w}}function Y(c){let t=[];for(let l of c){if(!l.isMarkdown)continue;let r=t[t.length-1],f={label:l.title,target:l.path,path:l.path,url:null};if(r&&r.title===(l.folder||"Pages")){r.links.push(f);continue}t.push({title:l.folder||"Pages",links:[f],notes:[]})}return t}var oe={"no-remote":"This repository has no origin remote, so there is no wiki to find.","unsupported-remote":"The origin remote is not a URL a wiki can be derived from.","no-wiki":"This project has no wiki (or Kabmo cannot read it).",unreachable:"The wiki could not be reached."};function qe({className:c="",enabled:t=!0,active:l=!0,rootPath:r,refreshKey:f=0,layout:x="desktop"}){let k=x==="phone",{activeRepo:p,setActiveRepo:h}=gr(r),{repos:s,scanning:g,rescan:b}=Ar(r,t),w=O(r,p),[R,W]=S("wiki.selectedPage",null),[L,N]=n(!1),[y,_]=n(!1),[ee,te]=n(0),v=X({rootPath:r,repo:p,enabled:t,active:l,revisionKey:f}),M=v.data?.entries??[],z=u(()=>M.filter((C)=>C.isMarkdown),[M]),I=u(()=>v.data?.sidebar??Y(M),[v.data?.sidebar,M]),ie=u(()=>I.some((C)=>C.links.length>0),[I]),A=R&&R.scope===w?R.path:null,T=u(()=>{if(A&&z.some((F)=>F.path===A))return A;return(z.find((F)=>F.title.toLowerCase()==="home")??z[0])?.path??null},[A,z]),D=Q({rootPath:r,repo:p,path:T,enabled:t,active:l,revisionKey:ee});o(()=>{if(!T||T===A)return;W({scope:w,path:T})},[T,A,w,W]),o(()=>{N(!1),_(!1)},[w]);let q=(C)=>{if(W({scope:w,path:C}),!k)_(!0)},ne=()=>{v.reload({force:!0}),te((C)=>C+1)},P=v.data?.repo??null,K=v.data&&!P?v.data:null;if(!t)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${c}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`@container flex h-full min-h-0 w-full flex-col bg-paper text-xs text-ink ${c}`,children:[e(bt,{left:e(d,{children:[e(kr,{rootPath:r,activeRepo:p,onSelectRepo:h,repos:s,scanning:g,onRefreshRepos:b}),P&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",title:`${P.host}/${P.slug} · ${P.revision.slice(0,8)}`,children:P.provider})]}),right:e(d,{children:[P?.webUrl&&e("a",{href:P.webUrl,target:"_blank",rel:"noopener noreferrer",title:"Open the wiki on its host","aria-label":"Open the wiki on its host",className:"rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Be,{size:13})}),e(st,{label:"Re-fetch the wiki",onClick:ne,busy:v.isLoading||v.refreshing,disabled:v.isLoading})]})}),v.error&&!v.data?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-error",children:v.error}),e("button",{type:"button",onClick:()=>v.reload(),className:"text-[11px] font-semibold text-ink/70 underline underline-offset-2 hover:text-ink",children:"Try again"})]}):!v.data?e("div",{className:"flex flex-1 items-center justify-center gap-2 text-ink/40",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Reading the wiki…"})]}):K?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(on,{size:18,className:"text-ink/30"}),e("p",{className:"max-w-sm text-[11px] leading-relaxed text-ink/60",children:oe[K.reason??"no-wiki"]}),K.detail&&e("p",{className:"max-w-sm break-words font-mono text-[10px] text-ink/40",children:K.detail})]}):e("div",{className:"flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse",children:[e("div",{className:`${k?"hidden":y?"hidden @[520px]:flex":"flex"} min-h-0 w-full flex-col @[520px]:w-52 @[520px]:flex-shrink-0 @[520px]:border-l @[520px]:border-ink/10`,children:e(B,{sections:I,selected:T,onSelect:q})}),e("div",{className:`relative min-w-0 min-h-0 flex-1 ${k?"flex":y?"flex":"hidden @[520px]:flex"} flex-col`,children:[P&&T?e(G,{repo:P,entries:M,path:T,page:D.data,isLoading:D.isLoading,error:D.error,rootPath:r,repoScope:p,onNavigate:q,onBack:k?void 0:()=>_(!1)}):e("div",{className:"flex h-full items-center justify-center px-6 text-center text-[11px] text-ink/40",children:"This wiki has no markdown pages."}),k&&ie&&e(j,{open:L,onClick:()=>N(!0)}),e(V,{open:L,sections:I,selected:T,onSelect:q,onClose:()=>N(!1)})]})]})]})}export{qe as WikiPanel};
|
|
1
|
+
import{d,n,o,i,u,a,e,E,m,sn,ln,Ie,ea,U,KA,_e,S,Ar,hr,yt,ut,Z,J}from"./index-9a78xmkk.js";import{Cr}from"./index-kaxvwh07.js";function B({sections:c,selected:t,onSelect:l}){let[r,f]=n(""),x=u(()=>{let p=r.trim().toLowerCase();if(!p)return c;return c.map((h)=>({...h,links:h.links.filter((s)=>s.label.toLowerCase().includes(p)||(s.path??s.target).toLowerCase().includes(p))})).filter((h)=>h.links.length>0)},[c,r]),k=c.some((p)=>p.links.length>0);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-canvas/40",children:[e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5 flex-shrink-0",children:[e(U,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{type:"text",value:r,onChange:(p)=>f(p.currentTarget.value),placeholder:"Filter pages…",title:"Filter wiki pages",className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder-ink/40"}),r&&e("button",{type:"button",onClick:()=>f(""),title:"Clear filter",className:"flex-shrink-0 text-ink/40 hover:text-ink",children:"×"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:x.length===0?e("p",{className:"px-3 py-2 text-[11px] italic text-ink/40",children:k?"No page matches the filter":"This wiki has no pages"}):x.map((p,h)=>e("div",{className:"py-0.5",children:[p.title&&e("div",{className:"px-2.5 py-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:p.title}),p.links.map((s,g)=>{let b=s.path!==null&&s.path===t,w=`${s.path??s.target}-${g}`;if(s.path)return e("button",{type:"button",onClick:()=>l(s.path),title:s.path,"aria-current":b?"page":void 0,className:`flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs transition-colors ${b?"bg-ink/8 font-medium text-ink":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,children:e("span",{className:"truncate",children:s.label})},w);if(s.url)return e("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",title:s.url,className:"flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs text-ink/70 hover:bg-ink/5 hover:text-ink",children:[e("span",{className:"truncate",children:s.label}),e(Ie,{size:10,className:"flex-shrink-0 text-ink/30"})]},w);return e("div",{title:`Not in this wiki: ${s.target}`,className:"flex w-full items-center px-2.5 py-1 text-left text-xs text-ink/35 line-through decoration-ink/20",children:e("span",{className:"truncate",children:s.label})},w)}),p.notes.map((s,g)=>e("p",{className:"px-2.5 py-0.5 text-[10px] leading-snug text-ink/50",children:s},`note-${g}`))]},`${p.title??"links"}-${h}`))})]})}function j({open:c,onClick:t}){return e("button",{type:"button",onClick:t,title:"Browse wiki pages","aria-label":"Browse wiki pages","aria-expanded":c,className:"absolute bottom-3 right-3 z-20 flex h-9 w-9 items-center justify-center rounded-full border border-ink/20 bg-paper text-ink/60 shadow-sm transition-all hover:bg-ink/5 hover:text-ink",children:e(ea,{size:16})})}function V({open:c,sections:t,selected:l,onSelect:r,onClose:f}){if(o(()=>{if(!c)return;let x=(k)=>{if(k.key==="Escape")f()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[c,f]),!c)return null;return e(Z,{onClose:f,maxWidthClass:"max-w-sm",zClass:"z-[70]",ariaLabel:"Wiki pages",header:e("div",{className:"flex min-w-0 items-center gap-2",children:[e(ea,{size:15,className:"flex-shrink-0 text-ink/50"}),e("span",{className:"text-sm font-medium",children:"Wiki pages"})]}),children:e("div",{className:"flex h-[60vh] min-h-0 flex-col",children:e(B,{sections:t,selected:l,onSelect:(x)=>{r(x),f()}})})})}function re(c,t){if(!c.webUrl)return null;let r=(t.split("/").pop()??t).replace(/\.(md|markdown)$/i,"");return c.provider==="gitlab"?`${c.webUrl.replace(/\/home$/,"")}/${encodeURIComponent(t.replace(/\.(md|markdown)$/i,""))}`:`${c.webUrl}/${encodeURIComponent(r)}`}function G({repo:c,entries:t,path:l,page:r,isLoading:f,error:x,rootPath:k,repoScope:p,onNavigate:h,onBack:s}){let g=re(c,l),b=u(()=>({path:l,entries:t,root:k,repo:p}),[l,t,k,p]);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-paper",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2.5 py-1.5",children:[s&&e("button",{type:"button",onClick:s,title:"Back to the page list","aria-label":"Back to the page list",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink @[520px]:hidden",children:e(sn,{size:13})}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] text-ink/50",title:l,children:l}),f&&e(m,{size:12,className:"flex-shrink-0 animate-spin text-ink/40"}),g&&e("a",{href:g,target:"_blank",rel:"noopener noreferrer",title:"Open this page on the wiki host","aria-label":"Open this page on the wiki host",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Ie,{size:13})})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:x?e("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-xs text-error",children:x})]}):!r?e("div",{className:"px-6 py-8 text-center text-xs text-ink/40",children:f?"Loading page…":"No page selected"}):e("article",{className:"mx-auto max-w-4xl px-5 py-4",children:[e(J,{content:r.content,className:"max-w-none",wikiScope:b,onWikiNavigate:h}),r.truncated&&e("p",{className:"mt-4 border-t border-ink/10 pt-2 text-[11px] text-ink/50",children:"This page is longer than the reader's budget and was cut off."})]})})]})}function O(c,t){return`${c??""}\x00${t}`}function H(c,t){let l=new URLSearchParams;if(c)l.set("root",c);if(t&&t!==".")l.set("repo",t);return l}function X(c){let{rootPath:t,repo:l,enabled:r,active:f,revisionKey:x=0}=c,k=O(t,l),[p,h]=n(null),s=i(k);s.current=k;let g=_e(KA(k),{enabled:r&&f}),{refresh:b}=g;o(()=>{h(null)},[k]);let w=a((R)=>{if(!r)return;if(!R?.force){b();return}let W=s.current,L=H(t,l);L.set("refresh","1"),fetch(`/api/wiki?${L.toString()}`).then(async(N)=>{let y=await N.json();if(!N.ok)throw Error(y?.error||`Wiki request failed (${N.status})`)}).then(()=>{if(s.current!==W)return;h(null),b()}).catch((N)=>{if(s.current!==W)return;h(N instanceof Error?N.message:"Failed to load the wiki")})},[r,t,l,b]);return o(()=>{if(x>0)b()},[x]),{data:g.data,isLoading:g.isLoading,refreshing:g.refreshing,error:p,reload:w}}function Q(c){let{rootPath:t,repo:l,path:r,enabled:f,active:x,revisionKey:k=0}=c,p=`${O(t,l)}\x00${r??""}`,[h,s]=n({scope:p,data:null}),[g,b]=n(!1),[w,R]=n(null),W=i(0);return o(()=>{if(!f||!x||!r){s({scope:p,data:null}),R(null);return}let L=++W.current;b(!0);let N=H(t,l);N.set("path",r),fetch(`/api/wiki/page?${N.toString()}`).then(async(y)=>{let _=await y.json();if(!y.ok)throw Error(_?.error||`Page request failed (${y.status})`);return _}).then((y)=>{if(W.current!==L)return;s({scope:p,data:y}),R(null)}).catch((y)=>{if(W.current!==L)return;R(y instanceof Error?y.message:"Failed to load the page")}).finally(()=>{if(W.current===L)b(!1)})},[p,t,l,r,f,x,k]),{data:h.scope===p?h.data:null,isLoading:g,error:w}}function Y(c){let t=[];for(let l of c){if(!l.isMarkdown)continue;let r=t[t.length-1],f={label:l.title,target:l.path,path:l.path,url:null};if(r&&r.title===(l.folder||"Pages")){r.links.push(f);continue}t.push({title:l.folder||"Pages",links:[f],notes:[]})}return t}var oe={"no-remote":"This repository has no origin remote, so there is no wiki to find.","unsupported-remote":"The origin remote is not a URL a wiki can be derived from.","no-wiki":"This project has no wiki (or Kabmo cannot read it).",unreachable:"The wiki could not be reached."};function qe({className:c="",enabled:t=!0,active:l=!0,rootPath:r,refreshKey:f=0,layout:x="desktop"}){let k=x==="phone",{activeRepo:p,setActiveRepo:h}=Ar(r),{repos:s,scanning:g,rescan:b}=hr(r,t),w=O(r,p),[R,W]=S("wiki.selectedPage",null),[L,N]=n(!1),[y,_]=n(!1),[ee,te]=n(0),v=X({rootPath:r,repo:p,enabled:t,active:l,revisionKey:f}),M=v.data?.entries??[],z=u(()=>M.filter((C)=>C.isMarkdown),[M]),I=u(()=>v.data?.sidebar??Y(M),[v.data?.sidebar,M]),ie=u(()=>I.some((C)=>C.links.length>0),[I]),A=R&&R.scope===w?R.path:null,T=u(()=>{if(A&&z.some((F)=>F.path===A))return A;return(z.find((F)=>F.title.toLowerCase()==="home")??z[0])?.path??null},[A,z]),D=Q({rootPath:r,repo:p,path:T,enabled:t,active:l,revisionKey:ee});o(()=>{if(!T||T===A)return;W({scope:w,path:T})},[T,A,w,W]),o(()=>{N(!1),_(!1)},[w]);let q=(C)=>{if(W({scope:w,path:C}),!k)_(!0)},ne=()=>{v.reload({force:!0}),te((C)=>C+1)},P=v.data?.repo??null,K=v.data&&!P?v.data:null;if(!t)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${c}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`@container flex h-full min-h-0 w-full flex-col bg-paper text-xs text-ink ${c}`,children:[e(yt,{left:e(d,{children:[e(Cr,{rootPath:r,activeRepo:p,onSelectRepo:h,repos:s,scanning:g,onRefreshRepos:b}),P&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",title:`${P.host}/${P.slug} · ${P.revision.slice(0,8)}`,children:P.provider})]}),right:e(d,{children:[P?.webUrl&&e("a",{href:P.webUrl,target:"_blank",rel:"noopener noreferrer",title:"Open the wiki on its host","aria-label":"Open the wiki on its host",className:"rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Ie,{size:13})}),e(ut,{label:"Re-fetch the wiki",onClick:ne,busy:v.isLoading||v.refreshing,disabled:v.isLoading})]})}),v.error&&!v.data?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-error",children:v.error}),e("button",{type:"button",onClick:()=>v.reload(),className:"text-[11px] font-semibold text-ink/70 underline underline-offset-2 hover:text-ink",children:"Try again"})]}):!v.data?e("div",{className:"flex flex-1 items-center justify-center gap-2 text-ink/40",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Reading the wiki…"})]}):K?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(ln,{size:18,className:"text-ink/30"}),e("p",{className:"max-w-sm text-[11px] leading-relaxed text-ink/60",children:oe[K.reason??"no-wiki"]}),K.detail&&e("p",{className:"max-w-sm break-words font-mono text-[10px] text-ink/40",children:K.detail})]}):e("div",{className:"flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse",children:[e("div",{className:`${k?"hidden":y?"hidden @[520px]:flex":"flex"} min-h-0 w-full flex-col @[520px]:w-52 @[520px]:flex-shrink-0 @[520px]:border-l @[520px]:border-ink/10`,children:e(B,{sections:I,selected:T,onSelect:q})}),e("div",{className:`relative min-w-0 min-h-0 flex-1 ${k?"flex":y?"flex":"hidden @[520px]:flex"} flex-col`,children:[P&&T?e(G,{repo:P,entries:M,path:T,page:D.data,isLoading:D.isLoading,error:D.error,rootPath:r,repoScope:p,onNavigate:q,onBack:k?void 0:()=>_(!1)}):e("div",{className:"flex h-full items-center justify-center px-6 text-center text-[11px] text-ink/40",children:"This wiki has no markdown pages."}),k&&ie&&e(j,{open:L,onClick:()=>N(!0)}),e(V,{open:L,sections:I,selected:T,onSelect:q,onClose:()=>N(!1)})]})]})]})}export{qe as WikiPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,o,i,u,a,e,s,m,_,Hr,ji,f,re,Vt,me,D,U,Bo,Yp,Z,Ct,kg,Zp,td}from"./index-4cag7w6k.js";var I={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},zp=s(I);function O({row:t,active:r,name:l,loading:h,onSelect:p,onCopyPath:g,onReveal:N}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:p,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(me,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:l})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:g,disabled:h,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-default",children:e(re,{size:11})}),e("button",{type:"button",onClick:N,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Vt,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(Q,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function Q({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${Bo[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(_,{size:9}),Bo[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.conflicts} conflicted path(s)`,children:[e(_,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(ji,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(Hr,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function H(t){let{open:r,rootPath:l,scanning:h}=t,[p,g]=n([]),[N,k]=n(!1),[C,P]=n(!1),[M,y]=n(null),[G,E]=n(0),j=t.repos.join("\x00"),A=i(!0),b=i(null);o(()=>(A.current=!0,()=>{A.current=!1,b.current?.abort(),b.current=null}),[]);let S=a(async()=>{b.current?.abort();let v=new AbortController;b.current=v,P(!0),k(!0);try{let R=new URLSearchParams({repoDetails:"1"});if(l)R.set("root",l);let w=await fetch(`/api/fs/git?${R.toString()}`,{signal:v.signal}),F=await w.json();if(!A.current||b.current!==v)return;if(!w.ok||!Array.isArray(F.details)){y(F.error||`Failed to read repositories (HTTP ${w.status})`);return}g(F.details),y(null)}catch(R){if(!A.current||b.current!==v)return;if(R instanceof Error&&R.name==="AbortError")return;y(R instanceof Error?R.message:"Failed to read repositories")}finally{if(A.current&&b.current===v)b.current=null,P(!1),k(!1)}},[l]);o(()=>{if(!r){g([]),y(null),k(!1);return}S()},[r,S,j,h,G]);let L=a(()=>E((v)=>v+1),[]);return{details:p,loading:N,reading:C,error:M,refresh:L}}function B(t){let r=new Map;for(let l of t){if(!l||l==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let h=l.indexOf("/"),p=h===-1?"":l.slice(0,h),g=r.get(p);if(!g)g={key:p,label:p===""?null:p,paths:[]},r.set(p,g);g.paths.push(l)}for(let l of r.values())l.paths.sort((h,p)=>h==="."?-1:p==="."?1:h.localeCompare(p));return[...r.values()].sort((l,h)=>{if(l.key==="")return-1;if(h.key==="")return 1;return l.key.localeCompare(h.key)})}function W(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function q({isOpen:t,rootPath:r,activeRepo:l,repos:h,scanning:p,onSelectRepo:g,onRefreshRepos:N,onClose:k}){let[C,P]=n(""),[M,y]=n(null),{details:G,loading:E,reading:j,error:A,refresh:b}=H({open:t,rootPath:r,repos:h,scanning:p});o(()=>{if(!t)P(""),y(null)},[t]);let S=u(()=>{let x=C.trim().toLowerCase();if(!x)return G;return G.filter((c)=>c.path.toLowerCase().includes(x))},[G,C]),L=u(()=>B(S.map((x)=>x.path)),[S]),v=u(()=>{let x=new Map;for(let c of G)x.set(c.path,c);return x},[G]),R=a(()=>{N(),b()},[N,b]),w=a(async(x)=>{let c=r?td(r,x==="."?"":x):x,z=await Ct(c);y(z?{text:`Copied ${c}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),F=a(async(x)=>{let c=new FormData;if(c.append("actionType","open_explorer"),c.append("path","."),c.append("repo",x),r)c.append("root",r);try{let z=await fetch("/api/fs/action",{method:"POST",body:c}),T=await z.json();if(!z.ok||T.error)y({text:T.error||"Could not open the file manager",kind:"error"})}catch{y({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(Z,{onClose:k,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(zp,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[h.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(U,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:C,onChange:(x)=>P(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:R,disabled:j||p,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(D,{size:12,className:j||p?"animate-spin":""})})]}),p&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(m,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),M&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${M.kind==="error"?"text-error":"text-ink/60"}`,title:M.text,role:"status",children:M.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:E&&G.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(m,{size:14,className:"animate-spin text-info"}),"Reading repositories…"]}):A?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:A}):S.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:C.trim()?"No matching repositories.":"No repositories in this workspace."}):L.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??kg(".",r)}),x.paths.map((c)=>{let z=v.get(c);if(!z)return null;return e(O,{row:z,active:c===l,name:W(c,x.key),loading:j,onSelect:()=>{g(c),k()},onCopyPath:()=>void w(c),onReveal:()=>void F(c)},c)})]},x.key))})]})}function kr({rootPath:t,activeRepo:r,onSelectRepo:l,repos:h,scanning:p,onRefreshRepos:g}){let[N,k]=n(!1),C=u(()=>({root:t??null,repo:r,rows:Zp(t,h),scanning:p,ready:!0,setRepo:l,refresh:g}),[t,r,h,p,l,g]),P=a(()=>k(!0),[]);return e("div",{className:"relative min-w-0",children:[e(Yp,{scope:C,onManage:P}),e(q,{isOpen:N,rootPath:t,activeRepo:r,repos:h,scanning:p,onSelectRepo:l,onRefreshRepos:g,onClose:()=>k(!1)})]})}
|
|
2
|
-
export{
|
|
1
|
+
import{d,n,o,i,u,a,e,s,m,_,Yr,Yi,f,re,Jt,fe,D,U,To,hm,Z,Et,Lg,xm,gd}from"./index-9a78xmkk.js";var I={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},lm=s(I);function O({row:t,active:r,name:l,loading:h,onSelect:p,onCopyPath:g,onReveal:N}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:p,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(fe,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:l})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:g,disabled:h,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-default",children:e(re,{size:11})}),e("button",{type:"button",onClick:N,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(Q,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function Q({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${To[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(_,{size:9}),To[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.conflicts} conflicted path(s)`,children:[e(_,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(Yi,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(Yr,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function H(t){let{open:r,rootPath:l,scanning:h}=t,[p,g]=n([]),[N,k]=n(!1),[C,P]=n(!1),[M,y]=n(null),[G,E]=n(0),j=t.repos.join("\x00"),A=i(!0),b=i(null);o(()=>(A.current=!0,()=>{A.current=!1,b.current?.abort(),b.current=null}),[]);let S=a(async()=>{b.current?.abort();let v=new AbortController;b.current=v,P(!0),k(!0);try{let R=new URLSearchParams({repoDetails:"1"});if(l)R.set("root",l);let w=await fetch(`/api/fs/git?${R.toString()}`,{signal:v.signal}),F=await w.json();if(!A.current||b.current!==v)return;if(!w.ok||!Array.isArray(F.details)){y(F.error||`Failed to read repositories (HTTP ${w.status})`);return}g(F.details),y(null)}catch(R){if(!A.current||b.current!==v)return;if(R instanceof Error&&R.name==="AbortError")return;y(R instanceof Error?R.message:"Failed to read repositories")}finally{if(A.current&&b.current===v)b.current=null,P(!1),k(!1)}},[l]);o(()=>{if(!r){g([]),y(null),k(!1);return}S()},[r,S,j,h,G]);let L=a(()=>E((v)=>v+1),[]);return{details:p,loading:N,reading:C,error:M,refresh:L}}function B(t){let r=new Map;for(let l of t){if(!l||l==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let h=l.indexOf("/"),p=h===-1?"":l.slice(0,h),g=r.get(p);if(!g)g={key:p,label:p===""?null:p,paths:[]},r.set(p,g);g.paths.push(l)}for(let l of r.values())l.paths.sort((h,p)=>h==="."?-1:p==="."?1:h.localeCompare(p));return[...r.values()].sort((l,h)=>{if(l.key==="")return-1;if(h.key==="")return 1;return l.key.localeCompare(h.key)})}function W(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function q({isOpen:t,rootPath:r,activeRepo:l,repos:h,scanning:p,onSelectRepo:g,onRefreshRepos:N,onClose:k}){let[C,P]=n(""),[M,y]=n(null),{details:G,loading:E,reading:j,error:A,refresh:b}=H({open:t,rootPath:r,repos:h,scanning:p});o(()=>{if(!t)P(""),y(null)},[t]);let S=u(()=>{let x=C.trim().toLowerCase();if(!x)return G;return G.filter((c)=>c.path.toLowerCase().includes(x))},[G,C]),L=u(()=>B(S.map((x)=>x.path)),[S]),v=u(()=>{let x=new Map;for(let c of G)x.set(c.path,c);return x},[G]),R=a(()=>{N(),b()},[N,b]),w=a(async(x)=>{let c=r?gd(r,x==="."?"":x):x,z=await Et(c);y(z?{text:`Copied ${c}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),F=a(async(x)=>{let c=new FormData;if(c.append("actionType","open_explorer"),c.append("path","."),c.append("repo",x),r)c.append("root",r);try{let z=await fetch("/api/fs/action",{method:"POST",body:c}),T=await z.json();if(!z.ok||T.error)y({text:T.error||"Could not open the file manager",kind:"error"})}catch{y({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(Z,{onClose:k,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(lm,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[h.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(U,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:C,onChange:(x)=>P(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:R,disabled:j||p,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(D,{size:12,className:j||p?"animate-spin":""})})]}),p&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(m,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),M&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${M.kind==="error"?"text-error":"text-ink/60"}`,title:M.text,role:"status",children:M.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:E&&G.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(m,{size:14,className:"animate-spin text-info"}),"Reading repositories…"]}):A?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:A}):S.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:C.trim()?"No matching repositories.":"No repositories in this workspace."}):L.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??Lg(".",r)}),x.paths.map((c)=>{let z=v.get(c);if(!z)return null;return e(O,{row:z,active:c===l,name:W(c,x.key),loading:j,onSelect:()=>{g(c),k()},onCopyPath:()=>void w(c),onReveal:()=>void F(c)},c)})]},x.key))})]})}function Cr({rootPath:t,activeRepo:r,onSelectRepo:l,repos:h,scanning:p,onRefreshRepos:g}){let[N,k]=n(!1),C=u(()=>({root:t??null,repo:r,rows:xm(t,h),scanning:p,ready:!0,setRepo:l,refresh:g}),[t,r,h,p,l,g]),P=a(()=>k(!0),[]);return e("div",{className:"relative min-w-0",children:[e(hm,{scope:C,onManage:P}),e(q,{isOpen:N,rootPath:t,activeRepo:r,repos:h,scanning:p,onSelectRepo:l,onRefreshRepos:g,onClose:()=>k(!1)})]})}
|
|
2
|
+
export{lm,Cr};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,o,i,a,e,m,
|
|
2
|
-
${U}`: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 we="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 ve({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:[ad[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"}),YA.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:`${we} 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:`${we} 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 ye({tool:t,shapes:r,selectedId:s,readability:l,onTool:c,onLabel:u,onNote:f,onRemove:p,onReset:g,onCancel:y,onSend:U}){let M=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:ad[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:U,disabled:!w,className:q,title:"Kirim anotasi ke draft chat",children:[e(Un,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:y,className:q,title:"Tutup mode anotasi",children:e(b,{size:12})})]}),M?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(ve,{shape:M,index:r.indexOf(M)+1,readability:l,onLabel:(B)=>u(M.id,B),onNote:(B)=>f(M.id,B)})}),e("button",{type:"button",onClick:()=>p(M.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 Te=0;function ke(){return Te+=1,`annot-${Date.now().toString(36)}-${Te}`}function Ae(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)},[]),U=a(()=>{g(null),s(!1)},[]),M=a((E)=>{f((_)=>[..._,E]),g(E.id)},[]),w=a((E,_)=>{f((x)=>x.map((T)=>T.id===E?{...T,note:_}:T))},[]),B=a((E,_)=>{f((x)=>x.map((T)=>T.id===E?{...T,label:_}:T))},[]),h=a((E)=>{f((_)=>_.filter((x)=>x.id!==E)),g((_)=>_===E?null:_)},[]),F=a(()=>{f([]),g(null)},[]);return{active:r,tool:l,shapes:u,selectedId:p,setTool:c,toggle:y,close:U,add:M,setNote:w,setLabel:B,select:g,remove:h,reset:F}}var Xe=4,X="var(--theme-error)";function Be({shapes:t,tool:r,selectedId:s,onMeasure:l,onAdd:c,onSelect:u}){let f=i(null),p=i(null),[g,y]=n(null),[U,M]=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;M((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 R=new ResizeObserver(T);return R.observe(x),()=>R.disconnect()},[l]);let w=(x)=>{let T=f.current;if(!T)return null;let R=T.getBoundingClientRect(),k={x:x.clientX-R.left,y:x.clientY-R.top};return{normalized:VA(R,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 R={id:ke(),tool:r,start:T.normalized,end:T.normalized,label:"",note:""};p.current=R,y(R)},h=(x)=>{let T=p.current;if(!T)return;let R=w(x);if(!R)return;let k={...T,end:R.normalized};p.current=k,y(k)},F=(x)=>{let T=p.current;if(!T)return;let R=w(x),k=R?{...T,end:R.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)},_=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,U.width)} ${Math.max(1,U.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:_.map((x,T)=>e(We,{shape:x,index:T+1,box:U,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=lm(t),g=l?3:2,y=String(r);return e("g",{onPointerDown:(M)=>{M.stopPropagation(),M.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 Ee(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 Ne="userBrowser.tabs",Se="userBrowser.activeTabId",Ze="userBrowser.inputUrl",Ye="userBrowser.history",je="userBrowser.historyIndex";function Me(){let[t,r]=S(Ne,[]),[s,l]=S(Se,null),[c,u]=S(Ze,""),[f,p]=n(null),[g,y]=n(void 0),{sessionId:U,ready:M}=Oe(),w=i(null),B=(N,A)=>xe(U,N)??A,h=me(t,s),F=K(h);o(()=>{if(!M||w.current===U)return;w.current=U;let N=B(Ne,[]),A=se(N);if(A.length>0){if(JSON.stringify(A)!==JSON.stringify(N))r(A);let Y=B(Se,null);if(!A.some((v)=>v.id===Y))l(A[A.length-1].id);return}let[I]=se([{id:Z(),history:B(Ye,[]),index:B(je,-1),frameKey:0}]),C=I&&I.history.length>0?I:j(Z());r([C]),l(C.id)},[M,U,r,l]);let E=a((N,A)=>{r((I)=>I.map((C)=>C.id===N?A(C):C))},[r]),_=a((N)=>{let A=N.trim();if(!A)return;let I;try{I=Ee(A)}catch(C){y(C instanceof Error?C.message:"Alamat tidak valid");return}if(y(void 0),u(I),!h){let C=j(Z(),I);r([C]),l(C.id),p(C.id);return}p(h.id),E(h.id,(C)=>ue(C,I))},[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]),R=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((I)=>I.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 I=j(Z());r([I]),l(I.id),u("");return}if(r(A.tabs),A.activeId!==s){l(A.activeId);let I=A.tabs.find((C)=>C.id===A.activeId);u(K(I)),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:_,goBack:x,goForward:T,reload:R,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 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 on({className:t="",active:r=!0}){let[s,l]=S("userBrowser.viewportMode","responsive"),[c,u]=S("userBrowser.zoomLevel",100),[f,p]=n(null),[g,y]=n(null),[U,M]=n(null),{tabs:w,activeTabId:B,url:h,input:F,setInput:E,loading:_,error:x,canGoBack:T,canGoForward:R,canOpenTab:k,submit:z,goBack:G,goForward:V,reload:N,markLoaded:A,openTab:I,selectTab:C,closeTab:Y}=Me(),v=Ae(`${B??""}:${w.find((O)=>O.id===B)?.frameKey??0}`),Ie=a(()=>{if(!h)return;window.open(h,"_blank","noopener,noreferrer")},[h]),Ue=a(()=>{if(!h)return;Ac({url:h})},[h]),Re=a((O)=>{p((H)=>H&&H.width===O.width&&H.height===O.height?H:O)},[]),Pe=a((O)=>{let H=Le(g,O.start);M(H),v.add(H.ok?{...O,element:H.element}:O)},[v,g]),Ce=a(()=>{if(!h||v.shapes.length===0)return;let O=c/100;Ac({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=_?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:C,onClose:Y,onNewTab:I}),e(ae,{url:h,input:F,loading:_,error:x,canGoBack:T,canGoForward:R,viewportMode:s,zoomLevel:c,onInputChange:E,onSubmit:z,onBack:G,onForward:V,onReload:N,onOpenExternal:Ie,onIncludeInChat:Ue,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(ye,{tool:v.tool,shapes:v.shapes,selectedId:v.selectedId,readability:U,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(Be,{shapes:v.shapes,tool:v.tool,selectedId:v.selectedId,onMeasure:Re,onAdd:Pe,onSelect:v.select}):null})]})}export{on as UserBrowserPanel};
|
|
1
|
+
import{d,n,o,i,a,e,m,M,sn,ka,Oe,O,D,Wn,b,Ue,xe,S,Eh,Qm,bd,Bh,wc}from"./index-9a78xmkk.js";import{Hu}from"./index-ac2q5903.js";import"./index-8tvrzce0.js";var ze={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:U,onForward:L,onReload:w,onOpenExternal:B,onIncludeInChat:h,onChangeViewport:F,onZoomIn:E,onZoomOut:C,onResetZoom:x,onSetZoom:T,annotate:R,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)},I=!t?"idle":s?"loading":"ready",P=I==="ready"?"bg-success animate-pulse":I==="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:U,disabled:!c,"aria-label":"Back",title:"Back",className:ee,children:e(sn,{size:12})}),e("button",{type:"button",onClick:L,disabled:!u,"aria-label":"Maju",title:"Maju",className:ee,children:e(ka,{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(Hu,{twoRows:!0,url:t,statusDotClass:P,statusLabel:ze[I],viewportMode:f,zoomLevel:p,onChangeViewport:F,onZoomIn:E,onZoomOut:C,onResetZoom:x,onSetZoom:T,annotate:R,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(Oe,{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,Fe=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>Fe)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),U=t.map((w)=>`${w.id}:${w.frameKey}`).join("|");if(o(()=>{g?.(r?y.current.get(r)??null:null)},[r,g,U]),!f)return null;let L=t.filter((w)=>K(w)!=="");if(L.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(Oe,{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:L.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),U=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:U?`${y}
|
|
2
|
+
${U}`: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(O,{size:13})})]})}var we="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 ve({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:[bd[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"}),Bh.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:`${we} 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:`${we} 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 ye({tool:t,shapes:r,selectedId:s,readability:l,onTool:c,onLabel:u,onNote:f,onRemove:p,onReset:g,onCancel:y,onSend:U}){let L=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:bd[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(M,{size:12})," Bersihkan"]}),e("button",{type:"button",onClick:U,disabled:!w,className:q,title:"Kirim anotasi ke draft chat",children:[e(Wn,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:y,className:q,title:"Tutup mode anotasi",children:e(b,{size:12})})]}),L?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(ve,{shape:L,index:r.indexOf(L)+1,readability:l,onLabel:(B)=>u(L.id,B),onNote:(B)=>f(L.id,B)})}),e("button",{type:"button",onClick:()=>p(L.id),className:q,title:"Remove this mark",children:e(M,{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 Te=0;function ke(){return Te+=1,`annot-${Date.now().toString(36)}-${Te}`}function Ae(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)},[]),U=a(()=>{g(null),s(!1)},[]),L=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:U,add:L,setNote:w,setLabel:B,select:g,remove:h,reset:F}}var Xe=4,X="var(--theme-error)";function Be({shapes:t,tool:r,selectedId:s,onMeasure:l,onAdd:c,onSelect:u}){let f=i(null),p=i(null),[g,y]=n(null),[U,L]=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;L((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 R=new ResizeObserver(T);return R.observe(x),()=>R.disconnect()},[l]);let w=(x)=>{let T=f.current;if(!T)return null;let R=T.getBoundingClientRect(),k={x:x.clientX-R.left,y:x.clientY-R.top};return{normalized:Eh(R,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 R={id:ke(),tool:r,start:T.normalized,end:T.normalized,label:"",note:""};p.current=R,y(R)},h=(x)=>{let T=p.current;if(!T)return;let R=w(x);if(!R)return;let k={...T,end:R.normalized};p.current=k,y(k)},F=(x)=>{let T=p.current;if(!T)return;let R=w(x),k=R?{...T,end:R.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,U.width)} ${Math.max(1,U.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:C.map((x,T)=>e(We,{shape:x,index:T+1,box:U,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=Qm(t),g=l?3:2,y=String(r);return e("g",{onPointerDown:(L)=>{L.stopPropagation(),L.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 Ee(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 Ne="userBrowser.tabs",Se="userBrowser.activeTabId",Ze="userBrowser.inputUrl",Ye="userBrowser.history",je="userBrowser.historyIndex";function Me(){let[t,r]=S(Ne,[]),[s,l]=S(Se,null),[c,u]=S(Ze,""),[f,p]=n(null),[g,y]=n(void 0),{sessionId:U,ready:L}=Ue(),w=i(null),B=(N,A)=>xe(U,N)??A,h=me(t,s),F=K(h);o(()=>{if(!L||w.current===U)return;w.current=U;let N=B(Ne,[]),A=se(N);if(A.length>0){if(JSON.stringify(A)!==JSON.stringify(N))r(A);let Y=B(Se,null);if(!A.some((v)=>v.id===Y))l(A[A.length-1].id);return}let[I]=se([{id:Z(),history:B(Ye,[]),index:B(je,-1),frameKey:0}]),P=I&&I.history.length>0?I:j(Z());r([P]),l(P.id)},[L,U,r,l]);let E=a((N,A)=>{r((I)=>I.map((P)=>P.id===N?A(P):P))},[r]),C=a((N)=>{let A=N.trim();if(!A)return;let I;try{I=Ee(A)}catch(P){y(P instanceof Error?P.message:"Alamat tidak valid");return}if(y(void 0),u(I),!h){let P=j(Z(),I);r([P]),l(P.id),p(P.id);return}p(h.id),E(h.id,(P)=>ue(P,I))},[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]),R=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((I)=>I.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 I=j(Z());r([I]),l(I.id),u("");return}if(r(A.tabs),A.activeId!==s){l(A.activeId);let I=A.tabs.find((P)=>P.id===A.activeId);u(K(I)),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:R,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 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 on({className:t="",active:r=!0}){let[s,l]=S("userBrowser.viewportMode","responsive"),[c,u]=S("userBrowser.zoomLevel",100),[f,p]=n(null),[g,y]=n(null),[U,L]=n(null),{tabs:w,activeTabId:B,url:h,input:F,setInput:E,loading:C,error:x,canGoBack:T,canGoForward:R,canOpenTab:k,submit:z,goBack:G,goForward:V,reload:N,markLoaded:A,openTab:I,selectTab:P,closeTab:Y}=Me(),v=Ae(`${B??""}:${w.find((_)=>_.id===B)?.frameKey??0}`),Ie=a(()=>{if(!h)return;window.open(h,"_blank","noopener,noreferrer")},[h]),Re=a(()=>{if(!h)return;wc({url:h})},[h]),Pe=a((_)=>{p((H)=>H&&H.width===_.width&&H.height===_.height?H:_)},[]),Ce=a((_)=>{let H=Le(g,_.start);L(H),v.add(H.ok?{..._,element:H.element}:_)},[v,g]),_e=a(()=>{if(!h||v.shapes.length===0)return;let _=c/100;wc({url:h,annotations:v.shapes,panel:{width:(f?.width??0)/_,height:(f?.height??0)/_,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:P,onClose:Y,onNewTab:I}),e(ae,{url:h,input:F,loading:C,error:x,canGoBack:T,canGoForward:R,viewportMode:s,zoomLevel:c,onInputChange:E,onSubmit:z,onBack:G,onForward:V,onReload:N,onOpenExternal:Ie,onIncludeInChat:Re,onChangeViewport:l,onZoomIn:()=>u((_)=>Math.min(200,_+10)),onZoomOut:()=>u((_)=>Math.max(50,_-10)),onResetZoom:()=>u(100),onSetZoom:u,focusKey:B??void 0,annotate:{active:Q,count:v.shapes.length,onToggle:v.toggle}}),Q&&e(ye,{tool:v.tool,shapes:v.shapes,selectedId:v.selectedId,readability:U,onTool:v.setTool,onLabel:v.setLabel,onNote:v.setNote,onRemove:v.remove,onReset:v.reset,onCancel:v.close,onSend:_e}),e(he,{tabs:w,activeTabId:B,loadingTabId:$e,viewportMode:s,zoomLevel:c,onLoad:A,onFrame:y,active:r,overlay:Q?e(Be,{shapes:v.shapes,tool:v.tool,selectedId:v.selectedId,onMeasure:Pe,onAdd:Ce,onSelect:v.select}):null})]})}export{on as UserBrowserPanel};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{t,l,
|
|
2
|
-
`),l.debug("[Railroad] Accessibility description set:",e)},"setAccDescription"),Q=t(()=>D,"getAccDescription"),Z=Y,V=P,
|
|
1
|
+
import{t,l,Wt,C,ee,te,F,p,me}from"./index-aa3hmn6j.js";var M="",O="",D="",E=[],N=new Map,S=t((e)=>ee(e,p()),"sanitizeText"),z=t((e)=>{switch(e.type){case"terminal":return{...e,value:S(e.value)};case"nonterminal":return{...e,name:S(e.name)};case"sequence":return{...e,elements:e.elements.map(z)};case"choice":return{...e,alternatives:e.alternatives.map(z)};case"optional":return{...e,element:z(e.element)};case"repetition":return{...e,element:z(e.element),separator:e.separator?z(e.separator):void 0};case"special":return{...e,text:S(e.text)}}},"sanitizeAstNode"),H=t(()=>{M="",O="",D="",E.length=0,N.clear(),F(),l.debug("[Railroad] Database cleared")},"clear"),Y=t((e)=>{M=S(e),l.debug("[Railroad] Title set:",e)},"setTitle"),P=t(()=>M,"getTitle"),q=t((e)=>{let n={...e,name:S(e.name),definition:z(e.definition),comment:e.comment?S(e.comment):void 0};if(l.debug("[Railroad] Adding rule:",n.name),N.has(n.name))l.warn(`[Railroad] Rule '${n.name}' is already defined. Overwriting.`);E.push(n),N.set(n.name,n)},"addRule"),G=t(()=>E,"getRules"),U=t((e)=>N.get(e),"getRule"),j=t((e)=>{O=S(e).replace(/^\s+/g,""),l.debug("[Railroad] Accessibility title set:",e)},"setAccTitle"),K=t(()=>O,"getAccTitle"),J=t((e)=>{D=S(e).replace(/\n\s+/g,`
|
|
2
|
+
`),l.debug("[Railroad] Accessibility description set:",e)},"setAccDescription"),Q=t(()=>D,"getAccDescription"),Z=Y,V=P,ze={clear:H,setTitle:Y,getTitle:P,addRule:q,getRules:G,getRule:U,setAccTitle:j,getAccTitle:K,setAccDescription:J,getAccDescription:Q,setDiagramTitle:Z,getDiagramTitle:V},T={compactMode:!1,padding:10,verticalSeparation:8,horizontalSeparation:10,arcRadius:10,fontSize:14,fontFamily:"monospace",terminalFill:"#FFFFC0",terminalStroke:"#000000",terminalTextColor:"#000000",nonTerminalFill:"#FFFFFF",nonTerminalStroke:"#000000",nonTerminalTextColor:"#000000",lineColor:"#000000",strokeWidth:2,markerFill:"#000000",commentFill:"#E8E8E8",commentStroke:"#888888",commentTextColor:"#666666",specialFill:"#F0E0FF",specialStroke:"#8800CC",ruleNameColor:"#000066",showMarkers:!0,markerRadius:5},re=/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$|^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch)\([\d\s%+,./-]+\)$|^[a-z]+$/i,ie=/^[\w "',.-]+$/,ne=new Set(["compactMode","padding","verticalSeparation","horizontalSeparation","arcRadius","fontSize","fontFamily","terminalFill","terminalStroke","terminalTextColor","nonTerminalFill","nonTerminalStroke","nonTerminalTextColor","lineColor","strokeWidth","markerFill","commentFill","commentStroke","commentTextColor","specialFill","specialStroke","ruleNameColor","showMarkers","markerRadius"]),L=t((e)=>{if(!e)return!1;return Object.keys(e).every((n)=>n==="railroad"||ne.has(n))},"isRailroadStyleOptions"),ae=t((e)=>{if(!e)return{};if("railroad"in e&&e.railroad)return e.railroad;return L(e)?e:{}},"extractRailroadOverrides"),oe=t((e)=>{if(!e||L(e))return{};let{railroad:n,svgId:o,theme:i,look:r,...a}=e;return a},"extractThemeOverrides"),u=t((e,n)=>{if(typeof e!=="string")return n;let o=e.trim();return re.test(o)?o:n},"sanitizeColorValue"),I=t((e,n)=>{if(typeof e!=="string")return n;let o=e.trim();return ie.test(o)?o:n},"sanitizeFontFamilyValue"),R=t((e,n)=>{let o=typeof e==="number"?e:typeof e==="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(o)&&o>=0?o:n},"sanitizeNumberValue"),le=t((e)=>{let n=typeof e==="number"?e:typeof e==="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)&&n>0?n:void 0},"parseThemeFontSize"),se=t((e)=>{let n=I(e.fontFamily,T.fontFamily),o=le(e.fontSize)??T.fontSize;return{...T,fontFamily:n,fontSize:o,terminalFill:u(e.secondBkg??e.secondaryColor,T.terminalFill),terminalStroke:u(e.secondaryBorderColor??e.lineColor,T.terminalStroke),terminalTextColor:u(e.secondaryTextColor??e.textColor,T.terminalTextColor),nonTerminalFill:u(e.mainBkg??e.background,T.nonTerminalFill),nonTerminalStroke:u(e.primaryBorderColor??e.lineColor,T.nonTerminalStroke),nonTerminalTextColor:u(e.primaryTextColor??e.textColor,T.nonTerminalTextColor),lineColor:u(e.lineColor,T.lineColor),markerFill:u(e.lineColor,T.markerFill),commentFill:u(e.labelBackground??e.tertiaryColor,T.commentFill),commentStroke:u(e.tertiaryBorderColor??e.lineColor,T.commentStroke),commentTextColor:u(e.tertiaryTextColor??e.textColor,T.commentTextColor),specialFill:u(e.tertiaryColor??e.secondaryColor,T.specialFill),specialStroke:u(e.tertiaryBorderColor??e.secondaryBorderColor,T.specialStroke),ruleNameColor:u(e.titleColor??e.textColor,T.ruleNameColor)}},"buildThemeDefaults"),W=t((e)=>{let n=C(),o={...Wt(),...n.themeVariables??{},...oe(e)},i=se(o),r={...n.railroad??{},...ae(e)};return{compactMode:r.compactMode??i.compactMode,padding:R(r.padding,i.padding),verticalSeparation:R(r.verticalSeparation,i.verticalSeparation),horizontalSeparation:R(r.horizontalSeparation,i.horizontalSeparation),arcRadius:R(r.arcRadius,i.arcRadius),fontSize:R(r.fontSize,i.fontSize),fontFamily:I(r.fontFamily,i.fontFamily),terminalFill:u(r.terminalFill,i.terminalFill),terminalStroke:u(r.terminalStroke,i.terminalStroke),terminalTextColor:u(r.terminalTextColor,i.terminalTextColor),nonTerminalFill:u(r.nonTerminalFill,i.nonTerminalFill),nonTerminalStroke:u(r.nonTerminalStroke,i.nonTerminalStroke),nonTerminalTextColor:u(r.nonTerminalTextColor,i.nonTerminalTextColor),lineColor:u(r.lineColor,i.lineColor),strokeWidth:R(r.strokeWidth,i.strokeWidth),markerFill:u(r.markerFill,i.markerFill),commentFill:u(r.commentFill,i.commentFill),commentStroke:u(r.commentStroke,i.commentStroke),commentTextColor:u(r.commentTextColor,i.commentTextColor),specialFill:u(r.specialFill,i.specialFill),specialStroke:u(r.specialStroke,i.specialStroke),ruleNameColor:u(r.ruleNameColor,i.ruleNameColor),showMarkers:r.showMarkers??i.showMarkers,markerRadius:R(r.markerRadius,i.markerRadius)}},"buildRailroadStyleOptions"),$a=t((e)=>{let{fontFamily:n,fontSize:o,terminalFill:i,terminalStroke:r,terminalTextColor:a,nonTerminalFill:g,nonTerminalStroke:c,nonTerminalTextColor:s,lineColor:f,strokeWidth:h,markerFill:m,commentFill:k,commentStroke:d,commentTextColor:x,specialFill:b,specialStroke:y,ruleNameColor:v}=W(e);return`
|
|
3
3
|
.railroad-diagram {
|
|
4
4
|
font-family: ${n};
|
|
5
5
|
font-size: ${o}px;
|
|
@@ -85,5 +85,5 @@ import{t,l,qt,C,ee,te,F,p,pe}from"./index-60v30k5h.js";var M="",O="",D="",E=[],N
|
|
|
85
85
|
/* Grouping container, no specific styles */
|
|
86
86
|
}
|
|
87
87
|
`},"getStyles"),w=class{constructor(){this.d=""}static{t(this,"PathBuilder")}moveTo(e,n){return this.d+=`M ${e} ${n} `,this}lineTo(e,n){return this.d+=`L ${e} ${n} `,this}horizontalTo(e){return this.d+=`H ${e} `,this}verticalTo(e){return this.d+=`V ${e} `,this}arcTo(e,n,o,i,r,a,g){return this.d+=`A ${e} ${n} ${o} ${i?1:0} ${r?1:0} ${a} ${g} `,this}build(){return this.d.trim()}},de=class{constructor(e,n=W()){this.textCache=new Map,this.svg=e,this.config=n}static{t(this,"RailroadRenderer")}measureText(e){if(this.textCache.has(e))return this.textCache.get(e);let n=this.svg.append("text").attr("font-family",this.config.fontFamily).attr("font-size",this.config.fontSize).text(e),o=n.node().getBBox(),i={width:o.width,height:o.height};return n.remove(),this.textCache.set(e,i),i}renderTerminal(e,n){let o=this.measureText(n),i=o.width+this.config.padding*2,r=o.height+this.config.padding*2,a=e.append("g").attr("class","railroad-terminal");return a.append("rect").attr("x",0).attr("y",0).attr("width",i).attr("height",r).attr("rx",10).attr("ry",10),a.append("text").attr("x",i/2).attr("y",r/2).text(n),{element:a.node(),dimensions:{width:i,height:r,up:r/2,down:r/2}}}renderNonTerminal(e,n){let o=this.measureText(n),i=o.width+this.config.padding*2,r=o.height+this.config.padding*2,a=e.append("g").attr("class","railroad-nonterminal");return a.append("rect").attr("x",0).attr("y",0).attr("width",i).attr("height",r),a.append("text").attr("x",i/2).attr("y",r/2).text(n),{element:a.node(),dimensions:{width:i,height:r,up:r/2,down:r/2}}}renderSequence(e,n){let o=n.map((s)=>this.renderExpression(e,s)),i=0,r=0,a=0;for(let s of o)i+=s.dimensions.width,r=Math.max(r,s.dimensions.up),a=Math.max(a,s.dimensions.down);i+=(o.length-1)*this.config.horizontalSeparation;let g=e.append("g").attr("class","railroad-sequence"),c=0;for(let s=0;s<o.length;s++){let f=o[s],h=r-f.dimensions.up;if(g.node().appendChild(f.element).setAttribute("transform",`translate(${c}, ${h})`),s<o.length-1){let k=c+f.dimensions.width,d=k+this.config.horizontalSeparation,x=r;g.append("path").attr("class","railroad-line").attr("d",new w().moveTo(k,x).lineTo(d,x).build())}c+=f.dimensions.width+this.config.horizontalSeparation}return{element:g.node(),dimensions:{width:i,height:r+a,up:r,down:a}}}renderChoice(e,n){let o=n.map((m)=>this.renderExpression(e,m)),i=0,r=0;for(let m of o)i=Math.max(i,m.dimensions.width),r+=m.dimensions.height;r+=(o.length-1)*this.config.verticalSeparation;let a=this.config.arcRadius,g=a*4,c=i+g,s=e.append("g").attr("class","railroad-choice"),f=0,h=r/2;for(let m of o){let k=f,d=k+m.dimensions.up,x=a*2+(i-m.dimensions.width)/2;s.node().appendChild(m.element).setAttribute("transform",`translate(${x}, ${k})`);let y=new w,v=d>h;if(d===h)y.moveTo(0,h).lineTo(x,d);else y.moveTo(0,h).arcTo(a,a,0,!1,v,a,h+(v?a:-a)).lineTo(a,d-(v?a:-a)).arcTo(a,a,0,!1,!v,a*2,d).lineTo(x,d);s.append("path").attr("class","railroad-line").attr("d",y.build());let A=new w,_=x+m.dimensions.width,X=c-a*2;if(d===h)A.moveTo(_,d).lineTo(c,h);else A.moveTo(_,d).lineTo(X,d).arcTo(a,a,0,!1,!v,c-a,d+(v?-a:a)).lineTo(c-a,h+(v?a:-a)).arcTo(a,a,0,!1,v,c,h);s.append("path").attr("class","railroad-line").attr("d",A.build()),f+=m.dimensions.height+this.config.verticalSeparation}return{element:s.node(),dimensions:{width:c,height:r,up:h,down:r-h}}}renderOptional(e,n){let o=this.renderExpression(e,n),i=this.config.arcRadius,r=i*2,a=o.dimensions.width+i*4,g=o.dimensions.height+r,c=e.append("g").attr("class","railroad-optional"),s=i*2,f=r;c.node().appendChild(o.element).setAttribute("transform",`translate(${s}, ${f})`);let m=f+o.dimensions.up,k=new w().moveTo(0,m).lineTo(i*2,m);c.append("path").attr("class","railroad-line").attr("d",k.build());let d=new w().moveTo(s+o.dimensions.width,m).lineTo(a,m);c.append("path").attr("class","railroad-line").attr("d",d.build());let x=new w().moveTo(0,m).arcTo(i,i,0,!1,!1,i,m-i).lineTo(i,i).arcTo(i,i,0,!1,!0,i*2,0).lineTo(a-i*2,0).arcTo(i,i,0,!1,!0,a-i,i).lineTo(a-i,m-i).arcTo(i,i,0,!1,!1,a,m);return c.append("path").attr("class","railroad-line").attr("d",x.build()),{element:c.node(),dimensions:{width:a,height:g,up:m,down:g-m}}}renderRepetition(e,n,o){let i=this.renderExpression(e,n),r=this.config.arcRadius,a=r*2,g=i.dimensions.width+r*4,c=o===0,s=i.dimensions.height+a+(c?a:0),f=e.append("g").attr("class","railroad-repetition"),h=r*2,m=c?a:0;f.node().appendChild(i.element).setAttribute("transform",`translate(${h}, ${m})`);let d=m+i.dimensions.up;f.append("path").attr("class","railroad-line").attr("d",new w().moveTo(0,d).lineTo(r*2,d).build()),f.append("path").attr("class","railroad-line").attr("d",new w().moveTo(h+i.dimensions.width,d).lineTo(g,d).build());let x=m+i.dimensions.height+r,b=new w().moveTo(h+i.dimensions.width,d).arcTo(r,r,0,!1,!0,h+i.dimensions.width+r,d+r).lineTo(h+i.dimensions.width+r,x).arcTo(r,r,0,!1,!0,h+i.dimensions.width,x+r).lineTo(r*2,x+r).arcTo(r,r,0,!1,!0,r,x).lineTo(r,d+r).arcTo(r,r,0,!1,!0,r*2,d);if(f.append("path").attr("class","railroad-line").attr("d",b.build()),c){let y=new w().moveTo(0,d).arcTo(r,r,0,!1,!1,r,d-r).lineTo(r,r).arcTo(r,r,0,!1,!0,r*2,0).lineTo(g-r*2,0).arcTo(r,r,0,!1,!0,g-r,r).lineTo(g-r,d-r).arcTo(r,r,0,!1,!1,g,d);f.append("path").attr("class","railroad-line").attr("d",y.build())}return{element:f.node(),dimensions:{width:g,height:s,up:d,down:s-d}}}renderSpecial(e,n){let o=this.measureText("? "+n+" ?"),i=o.width+this.config.padding*2,r=o.height+this.config.padding*2,a=e.append("g").attr("class","railroad-special");return a.append("rect").attr("x",0).attr("y",0).attr("width",i).attr("height",r),a.append("text").attr("x",i/2).attr("y",r/2).text("? "+n+" ?"),{element:a.node(),dimensions:{width:i,height:r,up:r/2,down:r/2}}}renderExpression(e,n){switch(n.type){case"terminal":return this.renderTerminal(e,n.value);case"nonterminal":return this.renderNonTerminal(e,n.name);case"sequence":return this.renderSequence(e,n.elements);case"choice":return this.renderChoice(e,n.alternatives);case"optional":return this.renderOptional(e,n.element);case"repetition":return this.renderRepetition(e,n.element,n.min);case"special":return this.renderSpecial(e,n.text);default:throw Error(`Unknown node type: ${n.type}`)}}renderRule(e,n){let o=this.svg.append("g").attr("class","railroad-rule").attr("transform",`translate(0, ${n})`),i=e.name+" =",r=this.measureText(i).width+20,a=r+20,g=o.append("g"),c=this.renderExpression(g,e.definition),s=Math.max(20,c.dimensions.up),f=s-c.dimensions.up;return g.attr("transform",`translate(${a}, ${f})`),o.append("g").attr("class","railroad-rule-name-group").append("text").attr("class","railroad-rule-name").attr("x",0).attr("y",s).text(i),o.append("g").attr("class","railroad-start").append("circle").attr("cx",r).attr("cy",s).attr("r",this.config.markerRadius),o.append("g").attr("class","railroad-end").append("circle").attr("cx",a+c.dimensions.width+10).attr("cy",s).attr("r",this.config.markerRadius),o.append("path").attr("class","railroad-line").attr("d",new w().moveTo(r+this.config.markerRadius,s).lineTo(a,s).build()),o.append("path").attr("class","railroad-line").attr("d",new w().moveTo(a+c.dimensions.width,s).lineTo(a+c.dimensions.width+10-this.config.markerRadius,s).build()),{height:Math.max(40,f+c.dimensions.height+this.config.padding*2),width:a+c.dimensions.width+10+this.config.markerRadius}}renderDiagram(e){let n=this.config.padding,o=0;for(let i of e){let r=this.renderRule(i,n);n+=r.height+this.config.verticalSeparation,o=Math.max(o,r.width)}return{width:o+this.config.padding*2,height:n+this.config.padding}}},B=t((e,n,o)=>{te(e,n.height,n.width,o),e.attr("viewBox",`0 0 ${n.width} ${n.height}`)},"configureRailroadSvgSize"),ce=t((e,n,o)=>{l.debug(`[Railroad] Rendering diagram
|
|
88
|
-
`+e);try{let i=
|
|
89
|
-
export{
|
|
88
|
+
`+e);try{let i=me(n);i.attr("class","railroad-diagram");let a=C().railroad?.useMaxWidth??!0,g=ze.getRules();if(l.debug(`[Railroad] Rendering ${g.length} rules`),g.length===0){l.warn("[Railroad] No rules to render"),B(i,{height:100,width:200},a);return}let s=new de(i,W()).renderDiagram(g);B(i,s,a),l.debug("[Railroad] Render complete")}catch(i){throw l.error("[Railroad] Render error:",i),i}},"draw"),za={draw:ce};
|
|
89
|
+
export{ze,$a,za};
|