@kabmo-labs/kabmo 0.61.0 → 0.62.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/README.md +53 -49
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +1157 -825
- package/dist/client/static/js/{Body-ab8wswhm.js → Body-z6kstvk6.js} +3 -3
- package/dist/client/static/js/{CsvGrid-czssywvz.js → CsvGrid-f73c0s4e.js} +2 -2
- package/dist/client/static/js/{DocxView-ke0dwdmt.js → DocxView-a1pb7nsb.js} +3 -3
- package/dist/client/static/js/{DrawioView-a1whhy84.js → DrawioView-r61gcg24.js} +2 -2
- package/dist/client/static/js/{HtmlPreview-dr32dwjy.js → HtmlPreview-vt7j0b05.js} +1 -1
- package/dist/client/static/js/ImageView-4nhr5dtm.js +1 -0
- package/dist/client/static/js/LayoutWrapper-vwhy0vhj.js +2 -0
- package/dist/client/static/js/MergeDiffView-f4h9ss71.js +1 -0
- package/dist/client/static/js/Modal-cadmjkak.js +60 -0
- package/dist/client/static/js/{PdfView-2kdn91f9.js → PdfView-mppt2gkd.js} +1 -1
- package/dist/client/static/js/SessionsView-vvsaw9f0.js +1 -0
- package/dist/client/static/js/{SheetView-ettr9pdw.js → SheetView-5s9zfx9g.js} +9 -9
- package/dist/client/static/js/{SvgPreview-hzcejjry.js → SvgPreview-ff78xn3e.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-kdmv4y72.js → abnfDiagram-O67JEVCF-p29sh3w2.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-83w3kytq.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-qyrwaq0x.js → architectureDiagram-NJMV4G6O-nbpdyea3.js} +3 -3
- package/dist/client/static/js/{astro-yphdvdty.js → astro-qtfmc8x7.js} +1 -1
- package/dist/client/static/js/bash-wcy12qjx.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-tszxy2g7.js → blockDiagram-BEXU5L5S-t8xbexa6.js} +6 -6
- package/dist/client/static/js/c-vvantfth.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-0ye36hhv.js → c4Diagram-YGBWAQC7-9fwf2zxk.js} +3 -3
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-szgk1shv.js → classDiagram-v2-NBCMYWYE-nbapgqbs.js} +4 -4
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-0s9s4mmv.js → cose-bilkent-JH36ORCC-k54mmydp.js} +1 -1
- package/dist/client/static/js/cpp-5x63r6g0.js +1 -0
- package/dist/client/static/js/css-j2j6f03w.js +1 -0
- package/dist/client/static/js/css-qk59j6rj.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-80z02zrj.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-664g28ze.js → cynefinDiagram-VND7K2PF-qdg32wah.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-ga4rp1jx.js → dagre-6A5THRUB-qzshg1vs.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-aagj46ty.js → diagram-22UHCM2B-197hemfa.js} +11 -11
- package/dist/client/static/js/{diagram-3UASUU5V-20qk6whk.js → diagram-3UASUU5V-236gnjr6.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-1vg1tfca.js → diagram-ATOU4E4O-vjgpyaaq.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-90d6jrqs.js → diagram-CDSNMT55-ywvzcx7z.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-8je4z8m1.js → diagram-MLGK6HIB-9ey7ev7j.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-0kzpexsj.js → diagram-MPIPVDR6-vrqbb6r7.js} +2 -2
- package/dist/client/static/js/{dockerfile-5nrbr0ef.js → dockerfile-4nked309.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-47yg36zx.js → ebnfDiagram-ZINNZB2B-hvnkevqy.js} +1 -1
- package/dist/client/static/js/{elixir-3nwnd9yw.js → elixir-3jvh6v4k.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-5hqp6r2d.js → elk-276RUBZZ-nej6yy1c.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-bt9te7r0.js → erDiagram-OPXOYQCR-ww453xcy.js} +5 -5
- package/dist/client/static/js/{erlang-p5c4n3t0.js → erlang-4fz73a1q.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-y9pq2709.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-e6v7513q.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-kzc13swm.js → ganttDiagram-FUAMR5RP-abc5wy70.js} +3 -3
- package/dist/client/static/js/gitGraph-4MIJSDKK-fzaf9azs.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-bjf8aa3j.js → gitGraphDiagram-X574FWY7-4acqzj2h.js} +7 -7
- package/dist/client/static/js/graphql-hpkvdvk7.js +1 -0
- package/dist/client/static/js/html-x12gb1wk.js +1 -0
- package/dist/client/static/js/{index-v88m5sva.js → index-0g82ph6h.js} +2 -2
- package/dist/client/static/js/{index-1fmjhm2d.js → index-0w1jzang.js} +5 -5
- package/dist/client/static/js/{index-kj70d2q9.js → index-1svt0cdw.js} +2 -2
- package/dist/client/static/js/{index-m24sebb0.js → index-1tb4py5v.js} +2 -2
- package/dist/client/static/js/index-2gt9krtj.js +4 -0
- package/dist/client/static/js/index-2x9m7s1a.js +1 -0
- package/dist/client/static/js/index-3fvqmz3m.js +4 -0
- package/dist/client/static/js/{index-k9yf2txw.js → index-42wvbkm5.js} +2 -2
- package/dist/client/static/js/index-477vtt51.js +2 -0
- package/dist/client/static/js/{index-ca6tmamh.js → index-4px56qaz.js} +2 -2
- package/dist/client/static/js/{index-excgtjhx.js → index-5anvw7xg.js} +36 -36
- package/dist/client/static/js/index-5nb9k2ph.js +1 -0
- package/dist/client/static/js/{index-97sw4d9n.js → index-615je3km.js} +2 -2
- package/dist/client/static/js/{index-jz4012t5.js → index-66qxrh5n.js} +1 -1
- package/dist/client/static/js/{index-a145x0w2.js → index-7kct1sz1.js} +2 -2
- package/dist/client/static/js/{index-hwv7bfxc.js → index-8e0d8y30.js} +2 -2
- package/dist/client/static/js/{index-s4j2ghmx.js → index-90bq56xw.js} +2 -2
- package/dist/client/static/js/{index-wsy6y5em.js → index-b1gzh60t.js} +11 -11
- package/dist/client/static/js/{index-10vzyga1.js → index-bypkmjrz.js} +2 -2
- package/dist/client/static/js/{index-n8r7r86r.js → index-c1vd63yd.js} +2 -2
- package/dist/client/static/js/index-c9f0hejv.js +3 -0
- package/dist/client/static/js/{index-2dmew334.js → index-cgqj15g0.js} +2 -2
- package/dist/client/static/js/{index-mtav0rpf.js → index-cts5re1t.js} +2 -2
- package/dist/client/static/js/index-dxc14kmm.js +1 -0
- package/dist/client/static/js/{index-krdz5vby.js → index-dxyjxhm1.js} +2 -2
- package/dist/client/static/js/{index-zr3965k9.js → index-edpyqz9f.js} +1 -1
- package/dist/client/static/js/{index-h7agc069.js → index-eesepb70.js} +2 -2
- package/dist/client/static/js/{index-r38e0rya.js → index-evh437bz.js} +2 -2
- package/dist/client/static/js/index-ey6v4t5b.js +1 -0
- package/dist/client/static/js/{index-025s3fp8.js → index-fsd7n336.js} +2 -2
- package/dist/client/static/js/{index-yfcy4cf6.js → index-h7a7fqag.js} +2 -2
- package/dist/client/static/js/{index-11qn05g9.js → index-hffgwnvz.js} +2 -2
- package/dist/client/static/js/index-j734ev6q.js +482 -0
- package/dist/client/static/js/{index-9g2nzgpx.js → index-jcbp1d9d.js} +6 -6
- package/dist/client/static/js/index-jg5h18sm.js +2 -0
- package/dist/client/static/js/{index-bq9f0mxp.js → index-jtdve6xw.js} +7 -7
- package/dist/client/static/js/{index-kyr612aa.js → index-k0bqrb1y.js} +1 -1
- package/dist/client/static/js/{index-bdtftrym.js → index-kegevd10.js} +2 -2
- package/dist/client/static/js/{index-fr6wsqk8.js → index-kqcfxkch.js} +2 -2
- package/dist/client/static/js/{index-sr14vwn5.js → index-kv1xnem9.js} +2 -2
- package/dist/client/static/js/{index-xy0m8te9.js → index-m54ctmxr.js} +1 -1
- package/dist/client/static/js/index-mgzbypt5.js +314 -0
- package/dist/client/static/js/{index-85jfn1fz.js → index-mh52531j.js} +2 -2
- package/dist/client/static/js/{index-776n5n29.js → index-mhz5ywa4.js} +5 -5
- package/dist/client/static/js/{index-3j2he86h.js → index-nnwdbg3t.js} +2 -2
- package/dist/client/static/js/{index-3x7cbxwq.js → index-nxd6z7f9.js} +2 -2
- package/dist/client/static/js/{index-dabnbvbc.js → index-pjrbt77c.js} +2 -2
- package/dist/client/static/js/index-r7h4pm42.js +2 -0
- package/dist/client/static/js/index-ratrdgc9.js +2 -0
- package/dist/client/static/js/{index-475dc6h9.js → index-rhmvh9w5.js} +2 -2
- package/dist/client/static/js/{index-twwsn91p.js → index-sqzjwy9h.js} +2 -2
- package/dist/client/static/js/{index-z5s9tmj8.js → index-tckzkw0f.js} +2 -2
- package/dist/client/static/js/index-tza9h3q6.css +1 -0
- package/dist/client/static/js/{index-qccydkze.js → index-vhjfr093.js} +2 -2
- package/dist/client/static/js/{index-653x8zdq.js → index-w0j96eyy.js} +8 -8
- package/dist/client/static/js/{index-24a40rw8.js → index-ws04kxy9.js} +1 -1
- package/dist/client/static/js/{index-a3bpmw2r.js → index-x1yqmzpr.js} +2 -2
- package/dist/client/static/js/{index-fb2fjndj.js → index-x2f7wykb.js} +6 -6
- package/dist/client/static/js/index-y8405hdg.js +10 -0
- package/dist/client/static/js/{index-sx83ans2.js → index-yxk7dgnb.js} +2 -2
- package/dist/client/static/js/{index-bkn6jtn1.js → index-zavecxak.js} +2 -2
- package/dist/client/static/js/{index-vn59zz0k.js → index-zg7q3kcb.js} +2 -2
- package/dist/client/static/js/{index-enm77k5z.js → index-zhn9vv3z.js} +2 -2
- package/dist/client/static/js/{index-vgcw01yk.js → index-zy963qbh.js} +1 -1
- package/dist/client/static/js/info-A6RAGUB7-t7pbg7rt.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-jy5zvvj8.js → infoDiagram-VRGFBTTK-9pe7w3r5.js} +2 -2
- package/dist/client/static/js/ini-522adp5a.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-pfky1nnf.js → ishikawaDiagram-OU5B5YK6-38arfrx5.js} +2 -2
- package/dist/client/static/js/java-z0rgs7v6.js +1 -0
- package/dist/client/static/js/javascript-fv87f565.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-mvaf7rfh.js → journeyDiagram-ZHPQQLJL-kcwzjgtz.js} +4 -4
- package/dist/client/static/js/json-1czq1ped.js +1 -0
- package/dist/client/static/js/jsx-1fch2jyr.js +1 -0
- package/dist/client/static/js/{julia-rpd1y9vh.js → julia-pzzxbptm.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-hw2xwe6e.js → kanban-definition-PNTS6WVX-nmegwy9w.js} +15 -15
- package/dist/client/static/js/lua-nn8bpjev.js +1 -0
- package/dist/client/static/js/markdown-38tqrgkn.js +1 -0
- package/dist/client/static/js/{mermaid.core-hsw87hmq.js → mermaid.core-3aae27b9.js} +7 -7
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-wfe4d846.js → mindmap-definition-NLK3R4M7-zsaq4e65.js} +12 -12
- package/dist/client/static/js/one-dark-pro-trnff03z.js +1 -0
- package/dist/client/static/js/one-light-ck31ptqs.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-rwac7scq.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-cvnmxgst.js → pegDiagram-GJSIUBJH-2b6whj1p.js} +1 -1
- package/dist/client/static/js/{perl-kmtz9dnv.js → perl-zdkbbjd2.js} +1 -1
- package/dist/client/static/js/{php-bttrsbxy.js → php-ktaxff6g.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-gjz20apz.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-0n3gz7sv.js → pieDiagram-5QR66LMP-y09ar7vz.js} +3 -3
- package/dist/client/static/js/properties-kncqeqhn.js +1 -0
- package/dist/client/static/js/python-gx8ggmyh.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-9qqh6xvv.js → quadrantDiagram-O4NWA36T-mapfzs06.js} +3 -3
- package/dist/client/static/js/r-x8rftkm3.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-akwdknab.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-m5v4rfhx.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-k2gmqcjb.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-1zdsfjf4.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-e98evqb6.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-5f3x3762.js → railroadDiagram-XR7U4H2S-70qy7qdh.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-a68bv6kh.js → requirementDiagram-PLB6GJNP-2vb2gp3e.js} +3 -3
- package/dist/client/static/js/{ruby-dve3y59w.js → ruby-ytqv3pqz.js} +1 -1
- package/dist/client/static/js/{rust-qjhdt4b0.js → rust-6sddyxnt.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-ry7xcphh.js → sankeyDiagram-IPEJSGJF-9jd8ebrn.js} +3 -3
- package/dist/client/static/js/{sass-emxqt5p2.js → sass-dvbra5b6.js} +1 -1
- package/dist/client/static/js/{scss-4j4t3r6y.js → scss-sy7w8916.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-mekzzhet.js → sequenceDiagram-PO4LG4MO-w7z84f80.js} +7 -7
- package/dist/client/static/js/{sizeCapture-INFHLROL-pvc16ame.js → sizeCapture-INFHLROL-q8w7ehgx.js} +1 -1
- package/dist/client/static/js/sql-99y0qnag.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-3ytxby83.js → stateDiagram-v2-GCMORJYK-4978hapr.js} +3 -3
- package/dist/client/static/js/{svelte-dbsx1ehx.js → svelte-xvs3fkza.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-c2zfp416.js → swimlanes-2SLR337P-eshg5fjy.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-914e28hd.js +8 -0
- package/dist/client/static/js/timeline-definition-EJHVYXUP-5h5q357k.js +120 -0
- package/dist/client/static/js/treeView-Q6P3EWNA-fkm3a7gx.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-hm4ktxjf.js +1 -0
- package/dist/client/static/js/tsx-phngprp0.js +1 -0
- package/dist/client/static/js/typescript-m62a7zr2.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-sz6b7bnv.js → usecaseDiagram-POWQR4AR-4j69y3zx.js} +20 -20
- package/dist/client/static/js/vennDiagram-UO4OBE2U-pa9p5jpw.js +34 -0
- package/dist/client/static/js/{vue-hyr58df9.js → vue-p4g4avm3.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-3y2rvdmy.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-xvtyvde9.js → wardleyDiagram-VNRHLVJA-hjddd656.js} +3 -3
- package/dist/client/static/js/xml-59n0cjn6.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-jcs20s84.js → xychartDiagram-PMCCYNJV-8ng5m849.js} +4 -4
- package/dist/client/static/js/yaml-9fw908s4.js +1 -0
- package/dist/client/tailwindcss-oxide.linux-x64-gnu-c0fa36dv.node +0 -0
- package/dist/client/tailwindcss-oxide.linux-x64-musl-kr04sh0e.node +0 -0
- package/marketplace/plugins/command-runner/package.json +2 -2
- package/marketplace/plugins/command-runner/src/app.tsx +2 -5
- package/marketplace/plugins/command-runner/src/panel/CustomForm.tsx +35 -52
- package/marketplace/plugins/command-runner/src/panel/Groups.tsx +6 -5
- package/marketplace/plugins/command-runner/src/panel/Header.tsx +18 -54
- package/marketplace/plugins/command-runner/src/panel/Output.tsx +3 -7
- package/marketplace/plugins/command-runner/src/panel/Row.tsx +19 -38
- package/marketplace/plugins/command-runner/src/panel/index.tsx +1 -4
- package/marketplace/plugins/git-forge/package.json +2 -2
- package/marketplace/plugins/git-forge/src/app.tsx +2 -0
- package/marketplace/plugins/git-forge/src/panel/Credential.tsx +8 -15
- package/marketplace/plugins/git-forge/src/panel/Header.tsx +35 -66
- package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +7 -13
- package/marketplace/plugins/git-forge/src/panel/List.tsx +28 -56
- package/marketplace/plugins/git-forge/src/panel/Row.tsx +7 -9
- package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +21 -31
- package/marketplace/plugins/git-forge/src/panel/Write.tsx +26 -40
- package/marketplace/plugins/git-forge/src/panel/index.tsx +0 -1
- package/marketplace/plugins/github-actions/package.json +2 -2
- package/marketplace/plugins/github-actions/src/app.tsx +2 -0
- package/marketplace/plugins/github-actions/src/panel/Actions.tsx +9 -17
- package/marketplace/plugins/github-actions/src/panel/LogView.tsx +4 -13
- package/marketplace/plugins/github-actions/src/panel/Row.tsx +4 -5
- package/marketplace/plugins/github-actions/src/panel/RunView.tsx +8 -15
- package/marketplace/plugins/github-actions/src/panel/index.test.tsx +3 -2
- package/marketplace/plugins/github-actions/src/panel/index.tsx +31 -37
- package/marketplace/plugins/kanban/package.json +2 -2
- package/marketplace/plugins/kanban/src/app.tsx +2 -0
- package/marketplace/plugins/kanban/src/panel/CardSheet.tsx +88 -98
- package/marketplace/plugins/kanban/src/panel/CardTile.tsx +6 -10
- package/marketplace/plugins/kanban/src/panel/StageColumn.tsx +22 -18
- package/marketplace/plugins/kanban/src/panel/StageSheet.tsx +59 -70
- package/marketplace/plugins/kanban/src/panel/index.tsx +37 -52
- package/marketplace/plugins/kanban/src/panel/use-board.ts +2 -0
- package/marketplace/plugins/session-info/package.json +2 -2
- package/marketplace/plugins/session-info/src/app.tsx +6 -3
- package/marketplace/plugins/stats/package.json +2 -2
- package/marketplace/plugins/stats/src/KillConfirm.test.tsx +6 -4
- package/marketplace/plugins/stats/src/KillConfirm.tsx +26 -76
- package/marketplace/plugins/stats/src/ProcessTable.tsx +8 -6
- package/marketplace/plugins/stats/src/RefreshButton.tsx +7 -5
- package/marketplace/plugins/stats/src/app.tsx +11 -9
- package/package.json +10 -10
- package/src/cli/lib/commands/plugin.js +8 -5
- package/src/client/bootstrap.d.ts +5 -0
- package/src/client/chat-title-overlay.test.ts +53 -0
- package/src/client/components/auth/login-screen/index.tsx +31 -3
- package/src/client/components/common/SignOutButton.tsx +4 -5
- package/src/client/components/common/account-badge/index.tsx +31 -0
- package/src/client/components/common/footer-version/index.tsx +40 -0
- package/src/client/components/common/fullscreen-viewer/fullscreen-viewer.test.tsx +24 -0
- package/src/client/components/common/fullscreen-viewer/index.tsx +22 -31
- package/src/client/components/common/header-controls/MoreMenu.tsx +5 -56
- package/src/client/components/common/header-controls/index.test.tsx +2 -6
- package/src/client/components/common/header-controls/index.tsx +9 -25
- package/src/client/components/common/header-controls/phone-row.test.tsx +3 -16
- package/src/client/components/common/shell-update-button/index.tsx +2 -2
- package/src/client/components/common/zoom-pan-stage/index.tsx +54 -50
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +4 -5
- package/src/client/components/layout/desktop-layout/index.tsx +2 -4
- package/src/client/components/layout/left-bar/index.tsx +25 -3
- package/src/client/components/layout/rail-toggle.test.tsx +112 -0
- package/src/client/components/layout/session-sidebar/CategoryHeader.accent.test.tsx +81 -0
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +11 -3
- package/src/client/components/layout/session-sidebar/Footer.test.tsx +36 -0
- package/src/client/components/layout/session-sidebar/Footer.tsx +42 -61
- package/src/client/components/layout/session-sidebar/FooterHost.tsx +5 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +30 -10
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +4 -0
- package/src/client/components/layout/session-sidebar/modern/index.tsx +8 -1
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +25 -4
- package/src/client/components/layout/session-title-bar/index.tsx +13 -5
- package/src/client/components/layout/top-bars.test.tsx +4 -2
- package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
- package/src/client/components/mobile/RightSidebar.tsx +12 -3
- package/src/client/components/mobile/SessionSidebar.tsx +6 -2
- package/src/client/components/mobile/drawer-layout.test.tsx +7 -3
- package/src/client/components/mobile/drawer-strip.tsx +9 -2
- package/src/client/components/mobile/mobile-main-view/Header.test.tsx +29 -9
- package/src/client/components/mobile/mobile-main-view/Header.tsx +43 -12
- package/src/client/components/mobile/mobile-right-sidebar/Chrome.tsx +12 -1
- package/src/client/components/mobile/mobile-right-sidebar/FullDiff.tsx +9 -2
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +1 -0
- package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +9 -1
- package/src/client/components/mobile/mobile-right-sidebar/StatusBar.tsx +4 -2
- package/src/client/components/mobile/mobile-session-sidebar/Body.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Footer.tsx +48 -46
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +18 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.test.tsx +4 -0
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +4 -6
- package/src/client/components/mobile/right-drawer-nav.test.tsx +53 -1
- package/src/client/components/settings/Band.tsx +5 -2
- package/src/client/components/settings/Modal.tsx +8 -5
- package/src/client/components/settings/Sidebar.tsx +5 -3
- package/src/client/components/settings/apply-side-effects.ts +5 -0
- package/src/client/components/settings/categories/AccountSettings.tsx +266 -0
- package/src/client/components/settings/categories/ProjectSettings.tsx +2 -0
- package/src/client/components/settings/categories/account-settings/Dialogs.tsx +223 -0
- package/src/client/components/settings/categories/appearance-settings/BorderStyleSection.test.tsx +3 -4
- package/src/client/components/settings/categories/appearance-settings/ChromeStyleSection.tsx +66 -39
- package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +7 -4
- package/src/client/components/settings/categories/project-settings/DetailsForm.tsx +14 -1
- package/src/client/components/settings/categories/project-settings/ProjectSharing.tsx +130 -0
- package/src/client/components/settings/categories/project-settings/SidebarList.tsx +5 -0
- package/src/client/components/settings/category-content.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooterSheet.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/SessionSkeleton.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +9 -2
- package/src/client/components/workspace/chat-timeline/chat-input/expansion.test.ts +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/expansion.ts +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/narrow.test.tsx +34 -0
- package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +9 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +4 -1
- package/src/client/components/workspace/editor/Tab.tsx +19 -26
- package/src/client/components/workspace/editor/Tabs.test.ts +13 -7
- package/src/client/components/workspace/git-panel/commit-modal/Header.tsx +1 -0
- package/src/client/components/workspace/git-panel/commit-modal/floating.test.ts +46 -0
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -0
- package/src/client/components/workspace/model-dropdown/Fullscreen.tsx +4 -5
- package/src/client/components/workspace/panel-tabs/TabChip.tsx +40 -39
- package/src/client/components/workspace/panel-tabs/TabStrip.connected.test.tsx +76 -58
- package/src/client/components/workspace/panel-tabs/TabStrip.test.tsx +9 -9
- package/src/client/components/workspace/panel-tabs/TabStrip.tsx +14 -1
- package/src/client/components/workspace/panel-tabs/index.tsx +1 -1
- package/src/client/components/workspace/plugin-panel/catalog.tsx +22 -5
- package/src/client/components/workspace/plugin-panel/chrome.test.tsx +89 -0
- package/src/client/components/workspace/plugin-panel/chrome.tsx +62 -0
- package/src/client/data/settings/omp-schema.json +40 -4
- package/src/client/floating-phone.test.ts +189 -0
- package/src/client/floating.css +205 -2
- package/src/client/floating.test.ts +43 -0
- package/src/client/glass.css +47 -0
- package/src/client/hooks/chat/omp/index.ts +6 -5
- package/src/client/hooks/chat/omp/prompt-send.test.ts +18 -0
- package/src/client/hooks/chat/omp/prompt-send.ts +26 -8
- package/src/client/hooks/chat/omp/session-list.tsx +20 -8
- package/src/client/hooks/chat/timeline/deferred-model.ts +13 -5
- package/src/client/hooks/chat/timeline/index.ts +2 -0
- package/src/client/hooks/chat/timeline/send-props.ts +14 -0
- package/src/client/hooks/chat/timeline/send-steer.test.ts +11 -2
- package/src/client/hooks/chat/timeline/send-switch.test.ts +92 -0
- package/src/client/hooks/chat/timeline/send.test-util.ts +37 -7
- package/src/client/hooks/chat/timeline/send.test.ts +11 -2
- package/src/client/hooks/chat/timeline/send.ts +62 -42
- package/src/client/hooks/editor/image-generation.ts +24 -0
- package/src/client/hooks/editor/resolve-viewer.test.ts +26 -20
- package/src/client/hooks/editor/resolve-viewer.ts +14 -5
- package/src/client/hooks/editor/use-file-editor.test.ts +34 -0
- package/src/client/hooks/editor/use-file-editor.ts +6 -2
- package/src/client/hooks/settings/accounts.ts +162 -0
- package/src/client/hooks/ui/auth.ts +58 -3
- package/src/client/hooks/ui/border-style.test.ts +5 -4
- package/src/client/hooks/ui/border-style.ts +3 -2
- package/src/client/hooks/ui/mobile-chrome-style.ts +68 -0
- package/src/client/hooks/ui/navbar-controls.test.ts +1 -2
- package/src/client/hooks/ui/navbar-controls.ts +0 -3
- package/src/client/hooks/ui/zoom-gesture.ts +104 -0
- package/src/client/lib/desktop/titlebar.test.ts +21 -0
- package/src/client/lib/desktop/titlebar.ts +34 -0
- package/src/client/lib/plugins/bootstrap.test.ts +20 -0
- package/src/client/lib/plugins/bootstrap.tsx +10 -15
- package/src/client/lib/plugins/kit-components.test.tsx +119 -0
- package/src/client/lib/plugins/kit-components.tsx +79 -0
- package/src/client/lib/plugins/kit.ts +8 -0
- package/src/client/lib/plugins/slots.test.ts +34 -0
- package/src/client/lib/plugins/slots.ts +31 -4
- package/src/client/lib/plugins/stylesheets.ts +10 -11
- package/src/client/lib/ui/pinch.test.ts +74 -0
- package/src/client/lib/ui/pinch.ts +104 -0
- package/src/client/lib/ui/safe-area.test.ts +25 -0
- package/src/client/lib/ui/safe-area.ts +23 -0
- package/src/client/main.tsx +8 -1
- package/src/client/tailwind.css +54 -1
- package/src/server/index.ts +2 -0
- package/src/server/lib/assets/shell-attributes.server.ts +12 -4
- package/src/server/lib/assets/shell-attributes.test.ts +19 -18
- package/src/server/lib/auth/client-address.test.ts +2 -2
- package/src/server/lib/auth/guard.test.ts +2 -2
- package/src/server/lib/auth/guard.ts +81 -97
- package/src/server/lib/auth/handover-guard.test.ts +1 -1
- package/src/server/lib/auth/rate-limit.test.ts +2 -2
- package/src/server/lib/auth/token.test.ts +1 -1
- package/src/server/lib/auth/workspace-gate.server.ts +34 -0
- package/src/server/lib/bundler/css.test.ts +16 -0
- package/src/server/lib/connect/devices.server.test.ts +12 -0
- package/src/server/lib/connect/devices.server.ts +63 -19
- package/src/server/lib/connect/pairing.server.ts +5 -3
- package/src/server/lib/connect/status.server.ts +2 -2
- package/src/server/lib/db/schema.test.ts +3 -3
- package/src/server/lib/db/schema.ts +6 -0
- package/src/server/lib/harness/update-spawn.server.test.ts +97 -0
- package/src/server/lib/harness/update-spawn.server.ts +10 -0
- package/src/server/lib/models/provider-icon-override.server.test.ts +140 -0
- package/src/server/lib/models/provider-icon-override.server.ts +197 -0
- package/src/server/lib/models/provider-icon-store.server.ts +8 -0
- package/src/server/lib/models/provider-icon.server.ts +31 -6
- package/src/server/lib/omp/session/artifacts.server.test.ts +11 -7
- package/src/server/lib/omp/session/artifacts.server.ts +21 -17
- package/src/server/lib/panels/build.server.ts +19 -2
- package/src/server/lib/panels/css.server.test.ts +141 -0
- package/src/server/lib/panels/css.server.ts +255 -0
- package/src/server/lib/panels/plugin-ui-contract.test.ts +64 -0
- package/src/server/lib/panels/registry-stylesheet.server.test.ts +69 -0
- package/src/server/lib/panels/scan.server.ts +13 -7
- package/src/server/lib/panels/source-warnings.server.test.ts +65 -0
- package/src/server/lib/panels/source-warnings.server.ts +71 -0
- package/src/server/lib/realtime/topics/catalog.server.ts +3 -0
- package/src/server/lib/realtime/topics.server.ts +14 -0
- package/src/server/lib/sessions/last-opened-client.server.ts +1 -1
- package/src/server/lib/workspace/access.server.ts +108 -0
- package/src/server/lib/workspace/project-patch.server.ts +4 -2
- package/src/server/lib/workspace/register-folder.server.ts +19 -5
- package/src/server/lib/workspace/session-access.server.ts +55 -0
- package/src/server/lib/workspace/tenancy-schema.server.ts +40 -0
- package/src/server/plugins/ssr.ts +19 -3
- package/src/server/routes/accounts/index.ts +8 -0
- package/src/server/routes/accounts/management.test.ts +174 -0
- package/src/server/routes/accounts/management.ts +166 -0
- package/src/server/routes/auth/login.ts +22 -8
- package/src/server/routes/auth/logout.ts +1 -1
- package/src/server/routes/auth/password.ts +40 -33
- package/src/server/routes/auth/revoke.test.ts +1 -1
- package/src/server/routes/auth/revoke.ts +26 -8
- package/src/server/routes/auth/routes.test.ts +3 -3
- package/src/server/routes/auth/state.ts +14 -7
- package/src/server/routes/connect/devices.ts +7 -4
- package/src/server/routes/connect/pair.ts +4 -3
- package/src/server/routes/connect/status.ts +4 -2
- package/src/server/routes/connect/tunnels.ts +2 -1
- package/src/server/routes/folders/batch-delete.ts +12 -0
- package/src/server/routes/folders/clone.ts +7 -2
- package/src/server/routes/folders/create.ts +3 -1
- package/src/server/routes/folders/folder.ts +44 -4
- package/src/server/routes/folders/index.ts +3 -0
- package/src/server/routes/folders/shares.ts +62 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/panels/build.ts +1 -1
- package/src/server/routes/panels/css.test.ts +22 -0
- package/src/server/routes/panels/css.ts +5 -7
- package/src/server/routes/realtime/ws.ts +16 -1
- package/src/server/routes/sessions/list.ts +3 -2
- package/src/server/routes/settings/projects.ts +46 -7
- package/src/server/routes/settings/provider-icon.ts +18 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +2 -2
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +6 -3
- package/src/shared/lib/icons/tint-hues.generated.ts +38 -37
- package/src/shared/lib/omp/config/schema-releases-19-4.test.ts +27 -1
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +1 -1
- package/src/shared/lib/realtime/protocol.ts +16 -0
- package/src/shared/lib/settings/defaults.ts +2 -1
- package/src/shared/lib/settings/sections.ts +1 -1
- package/src/shared/lib/theme/border-style.test.ts +11 -9
- package/src/shared/lib/theme/border-style.ts +7 -7
- package/src/shared/lib/theme/chrome-style.test.ts +15 -0
- package/src/shared/lib/theme/chrome-style.ts +16 -1
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/settings/state.ts +6 -5
- package/src/test-support/file-editor.test-util.ts +25 -6
- package/tsconfig.json +21 -0
- package/dist/client/static/js/ImageView-zf4kh5wp.js +0 -1
- package/dist/client/static/js/LayoutWrapper-dncbzcea.js +0 -2
- package/dist/client/static/js/MergeDiffView-btdx9yb9.js +0 -1
- package/dist/client/static/js/Modal-5cxfw2rv.js +0 -60
- package/dist/client/static/js/SessionsView-vbn0nvx4.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-sxrkxwbq.js +0 -1
- package/dist/client/static/js/bash-bcbct9gc.js +0 -1
- package/dist/client/static/js/c-fn9jz26e.js +0 -1
- package/dist/client/static/js/cpp-a1q64mke.js +0 -1
- package/dist/client/static/js/css-b92azee8.js +0 -1
- package/dist/client/static/js/css-sn00sq6v.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-g1xwa8b9.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-05p61bka.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-500fcx2a.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-z1yehwys.js +0 -1
- package/dist/client/static/js/graphql-8d8bn59j.js +0 -1
- package/dist/client/static/js/html-6hdrwtz2.js +0 -1
- package/dist/client/static/js/index-0kcnghxn.js +0 -4
- package/dist/client/static/js/index-2zhmmtye.js +0 -2
- package/dist/client/static/js/index-4vtc4xct.js +0 -481
- package/dist/client/static/js/index-5srvxsht.js +0 -2
- package/dist/client/static/js/index-6c1s0v4b.js +0 -1
- package/dist/client/static/js/index-cvm2ha01.js +0 -1
- package/dist/client/static/js/index-d11mbz2q.js +0 -4
- package/dist/client/static/js/index-fen0x3qh.js +0 -1
- package/dist/client/static/js/index-gwgh27h3.js +0 -314
- package/dist/client/static/js/index-hxy1sadd.js +0 -2
- package/dist/client/static/js/index-pg87cgpy.js +0 -2
- package/dist/client/static/js/index-q1a40v20.js +0 -3
- package/dist/client/static/js/index-qmvstmvh.js +0 -1
- package/dist/client/static/js/index-t6nqy2n5.css +0 -1
- package/dist/client/static/js/index-wf5j0009.js +0 -10
- package/dist/client/static/js/index-y6zbkh4p.js +0 -2
- package/dist/client/static/js/info-A6RAGUB7-dqyaxjc1.js +0 -1
- package/dist/client/static/js/ini-g6a5xsaw.js +0 -1
- package/dist/client/static/js/java-n596am4c.js +0 -1
- package/dist/client/static/js/javascript-zc1qnyyp.js +0 -1
- package/dist/client/static/js/json-7k70qbkj.js +0 -1
- package/dist/client/static/js/jsx-sndenqrc.js +0 -1
- package/dist/client/static/js/lua-djd3g9q5.js +0 -1
- package/dist/client/static/js/markdown-r2tpvxpn.js +0 -1
- package/dist/client/static/js/one-dark-pro-ckq5capv.js +0 -1
- package/dist/client/static/js/one-light-a908z398.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-7jxzax4z.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-wc9wxr7f.js +0 -1
- package/dist/client/static/js/properties-brn72zdk.js +0 -1
- package/dist/client/static/js/python-g9mghwgm.js +0 -1
- package/dist/client/static/js/r-e247x4mw.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-kwj5padj.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-h8sdx3w5.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-2wmwx246.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-h4cdgw3y.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-q7m0tfd0.js +0 -1
- package/dist/client/static/js/sql-0kar81jy.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-9gm67sq4.js +0 -8
- package/dist/client/static/js/timeline-definition-EJHVYXUP-xtvv4za2.js +0 -120
- package/dist/client/static/js/treeView-Q6P3EWNA-yv9640h3.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-7kpzjg21.js +0 -1
- package/dist/client/static/js/tsx-gjxfjnbk.js +0 -1
- package/dist/client/static/js/typescript-bm89v3gk.js +0 -1
- package/dist/client/static/js/vennDiagram-UO4OBE2U-56q0qs51.js +0 -34
- package/dist/client/static/js/wardley-WFR3VGLG-mggay64p.js +0 -1
- package/dist/client/static/js/xml-b7824nx0.js +0 -1
- package/dist/client/static/js/yaml-kqqktdv1.js +0 -1
- package/src/server/lib/auth/client-address.ts +0 -89
- package/src/server/lib/auth/config.ts +0 -133
- package/src/server/lib/auth/rate-limit.ts +0 -146
- package/src/server/lib/auth/token.ts +0 -220
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d,n,o,O,i,u,a,dn,e,S,kr,wr,Ie,ys,f,ks,ws,Cs,G,Bs,A,It,yo,ze,Oi,Fl,dt,yt,vt,Kd,Hc}from"./index-j734ev6q.js";import{Fr}from"./index-kv1xnem9.js";var fe=2000,z=new Map;function me(s){if(s.length===0)return"";let r="";for(let t of s)r+=`${t.start}-${t.end},`;return r}function ee(s,r,t){let c=Oi(r),h=`${r}\x00${me(t)}\x00${s}`;if(c){let x=z.get(h);if(x!==void 0)return z.delete(h),z.set(h,x),x}let l=Fl(s,r,{marks:t});if(!c)return l;if(z.set(h,l),z.size>fe){let x=z.keys().next();if(!x.done)z.delete(x.value)}return l}function te(s,r,t){let c=[],h=0;for(let l of r){if(l.start<h||l.end<=l.start||l.end>s.length)continue;if(l.start>h)c.push({text:s.slice(h,l.start),kind:"plain"});if(c.push({text:s.slice(l.start,l.end),kind:"removed"}),t)c.push({text:t,kind:"inserted"});h=l.end}if(h<s.length)c.push({text:s.slice(h),kind:"plain"});return c}function ge({file:s,result:r,replacement:t,showReplacePreview:c,onOpen:h}){let l=r.ranges??[],x=c&&t.length>0;return e("button",{type:"button",onClick:()=>h(r),className:"flex w-full items-start gap-2 rounded px-1 py-0.5 text-left hover:bg-ink/5 cursor-pointer",title:`Open ${s}:${r.line}`,children:[e("span",{className:"w-6 flex-shrink-0 text-right font-mono text-ink/40",children:r.line}),x?e("span",{className:"min-w-0 truncate font-mono text-ink",children:te(r.content,l,t).map((k,g)=>k.kind==="plain"?e("span",{children:k.text},g):k.kind==="removed"?e("del",{className:"search-replace-old",children:k.text},g):e("ins",{className:"search-replace-new",children:k.text},g))}):e("span",{className:"min-w-0 truncate font-mono text-ink",dangerouslySetInnerHTML:{__html:ee(r.content,vt(s),l)}})]})}var re=dn(ge);var Z={header:4,hit:4,group:16},ne={headerBox:16,hitBox:20},se=5000;function oe(s){let r=[],t=null;for(let c of s){if(!t||t.file!==c.file)t={file:c.file,results:[]},r.push(t);t.results.push(c)}return r}function ie(s){let r=[];for(let t of s){r.push({kind:"group",file:t.file,count:t.results.length});for(let c=0;c<t.results.length;c++)r.push({kind:"hit",file:t.file,result:t.results[c],last:c===t.results.length-1})}return r}function be(s,r){if(s.kind==="group")return r.headerBox+Z.header;return r.hitBox+(s.last?Z.group:Z.hit)}function ae(s,r){let t=Array(s.length),c=Array(s.length),h=0;for(let l=0;l<s.length;l++){let x=be(s[l],r);t[l]=h,c[l]=x,h+=x}return{offsets:t,heights:c,total:h}}function le(s,r,t,c,h=240){if(s.length===0)return{start:0,end:0};let l=Math.max(0,t),x=l-h,k=l+c+h,g=0,b=s.length-1;while(g<b){let m=g+b>>1;if(s[m]+r[m]>x)b=m;else g=m+1}let C=g;g=C,b=s.length;while(g<b){let m=g+b>>1;if(s[m]>=k)b=m;else g=m+1}return{start:C,end:g}}var xe=8,Se=8;function ce({groups:s,replacement:r,showReplacePreview:t,onOpen:c,onReplaceFile:h,replaceBusy:l}){let x=i(null),k=i(null),g=u(()=>ie(s),[s]),[b,C]=n(ne),m=u(()=>ae(g,b),[g,b]),[T,y]=n(()=>({start:0,end:Math.min(g.length,60)})),L=a((p)=>{x.current=p},[]),v=a(()=>{let p=x.current;if(!p)return;let w=le(m.offsets,m.heights,p.scrollTop,p.clientHeight);y((M)=>M.start===w.start&&M.end===w.end?M:w)},[m]),R=a(()=>{v()},[v]);O(()=>{let p=k.current;if(!p)return;let w=p.querySelector("[data-search-header] > div")?.offsetHeight??0,M=p.querySelector("[data-search-hit] > button")?.offsetHeight??0;if(w>0&&w!==b.headerBox)C((N)=>({...N,headerBox:w}));if(M>0&&M!==b.hitBox)C((N)=>({...N,hitBox:M}))},[T,b,g]),O(()=>{v()},[v]),O(()=>{let p=x.current;if(!p||typeof ResizeObserver>"u")return;let w=new ResizeObserver(()=>v());return w.observe(p),()=>w.disconnect()},[v]);let P=g.length===0?0:Math.min(T.start,g.length-1),F=Math.min(T.end,g.length),H=g.slice(P,F),D=F<g.length?m.total-m.offsets[F]:0;return e("div",{ref:L,onScroll:R,className:"flex-1 scrollbar-overlay-container px-3 text-xs",style:{overflowAnchor:"none"},children:[e("div",{style:{height:xe+(m.offsets[P]??0)},"aria-hidden":"true"}),e("div",{ref:k,children:H.map((p,w)=>{let M=P+w,N=m.heights[M];if(p.kind==="group")return e("div",{"data-search-header":"",style:{height:N},children:e("div",{className:"font-semibold text-ink/80 flex items-center justify-between group",children:[e("div",{className:"flex items-center min-w-0",children:[e(dt,{name:p.file,size:12,className:"mr-1.5 flex-shrink-0"}),e("span",{className:"truncate",children:p.file}),e("span",{className:"ml-2 bg-ink/10 text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",children:p.count})]}),e("button",{onClick:()=>h(p.file),disabled:l,className:"touch-visible opacity-0 group-hover:opacity-100 p-1 text-ink/40 hover:text-ink rounded hover:bg-ink/5 disabled:opacity-50 flex-shrink-0",title:"Replace in this file",children:e(Cs,{size:12})})]})},`group:${p.file}`);return e("div",{"data-search-hit":"",style:{height:N},children:e(re,{file:p.file,result:p.result,replacement:r,showReplacePreview:t,onOpen:c})},`hit:${p.file}:${p.result.line}:${M}`)})}),e("div",{style:{height:Se+D},"aria-hidden":"true"})]})}function ue({className:s,query:r,setQuery:t,replaceQuery:c,setReplaceQuery:h,matchCase:l,setMatchCase:x,wholeWord:k,setWholeWord:g,useRegex:b,setUseRegex:C,includeFiles:m,setIncludeFiles:T,showIncludeField:y,setShowIncludeField:L,showMenu:v,setShowMenu:R,menuRef:P,rootPath:F,activeRepo:H,setActiveRepo:D,repos:p,reposScanning:w,rescanRepos:M,results:N,isSearching:q,truncated:J,error:E,onOpenFile:B,handleReplace:U,replaceBusy:Q,tabsMode:Y=!1}){let X=u(()=>oe(N),[N]),W=i(null),K=i(null),_=a(()=>{t(""),W.current?.focus()},[t]),j=a(()=>{h(""),K.current?.focus()},[h]),V=u(()=>({matchCase:l,wholeWord:k,isRegex:b,inSelection:!1}),[l,k,b]),he=a((I)=>{Kd({path:I.file,line:Number(I.line),query:r,options:V}),B?.({path:I.file,name:I.file.split("/").pop()||I.file,root:F,repo:H})},[r,V,F,H,B]),de=a((I)=>U(I),[U]);return e("div",{className:`flex flex-col h-full bg-paper ${s}`,children:[e(It,{left:e(d,{children:[e(yo,{id:"search",tabsMode:Y,children:e("h2",{className:"text-xs font-semibold text-ink uppercase tracking-wider",children:"Search"})}),e(Fr,{rootPath:F,activeRepo:H,onSelectRepo:D,repos:p,scanning:w,onRefreshRepos:M})]}),right:e("div",{className:"relative",ref:P,children:[e("button",{onClick:()=>R(!v),className:`p-1 rounded hover:bg-ink/5 transition-colors ${v||y?"text-ink":"text-ink/40"}`,title:"Search Options",children:e(Ie,{size:14})}),v&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-48 bg-paper border border-ink/10 rounded shadow-lg z-10 py-1",children:e("button",{onClick:()=>{if(L(!y),y)T("");R(!1)},className:"w-full px-3 py-1.5 text-left text-xs text-ink hover:bg-ink/5 flex items-center justify-between",children:[e("span",{children:"Files to include"}),y&&e(f,{size:12,className:"text-ink/60"})]})})]})}),e("div",{className:"p-3 flex flex-col gap-2.5 border-b border-ink/10",children:[e("div",{className:"relative",children:e("div",{className:"flex items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e(G,{size:14,className:"ml-2 text-ink/40 flex-shrink-0"}),e("input",{ref:W,type:"text",placeholder:"Search",value:r,onChange:(I)=>t(I.currentTarget.value),className:"w-full bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35 min-w-0"}),r&&e("button",{type:"button",onClick:_,title:"Clear search","aria-label":"Clear search",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(A,{size:12})}),e("div",{className:"flex items-center space-x-0.5 pr-1 text-ink/40 flex-shrink-0",children:[e("button",{onClick:()=>x(!l),className:`p-1 rounded hover:text-ink ${l?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Case",children:e(ys,{size:14})}),e("button",{onClick:()=>g(!k),className:`p-1 rounded hover:text-ink ${k?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Match Whole Word",children:e(Bs,{size:14})}),e("button",{onClick:()=>C(!b),className:`p-1 rounded hover:text-ink ${b?"bg-ink/10 text-ink":"hover:bg-ink/5"}`,title:"Use Regular Expression",children:e(ks,{size:14})})]})]})}),e("div",{className:"relative flex items-center space-x-1",children:[e("div",{className:"flex flex-1 min-w-0 items-center border border-ink/20 rounded bg-paper focus-within:border-ink/40 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[e("input",{ref:K,type:"text",placeholder:"Replace",value:c,onChange:(I)=>h(I.currentTarget.value),className:"flex-1 min-w-0 bg-transparent border-none text-xs px-2 py-1.5 focus:outline-none text-ink placeholder-ink/35"}),c&&e("button",{type:"button",onClick:j,title:"Clear replace","aria-label":"Clear replace",className:"p-1 mr-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(A,{size:12})})]}),e("button",{onClick:()=>U(),disabled:N.length===0||Q,className:"p-1.5 rounded border border-ink/20 text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-50 disabled:cursor-not-allowed bg-paper",title:"Replace All",children:e(ws,{size:14})})]}),y&&e("div",{className:"relative",children:e("input",{type:"text",value:m,onChange:(I)=>T(I.currentTarget.value),placeholder:"Files to include (e.g. *.js, src/*)",className:"w-full bg-paper border border-ink/20 rounded text-xs px-2 py-1.5 focus:outline-none focus:border-ink/40 focus:ring-1 focus:ring-ink/10 transition-all text-ink placeholder-ink/40"})})]}),E&&N.length===0?e("div",{className:"flex-1 px-3 py-3",role:"alert",children:e("div",{className:"rounded border border-error/30 bg-error/5 px-2.5 py-2",children:[e("div",{className:"text-[11px] font-semibold text-error-text",children:"Search failed"}),e("div",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-[10.5px] text-ink/70",children:E}),b&&e("div",{className:"mt-1 text-[10.5px] text-ink/50",children:["Regex is on — escape metacharacters such as ",e("code",{className:"font-mono",children:"( ) [ ] * ? +"})," or turn it off to search literally."]})]})}):q&&N.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4 text-[11px]",children:"Searching..."}):r.trim().length<=2?e("div",{className:"flex-1 text-ink/40 italic text-center py-4 text-[11px]",children:"Type at least 3 characters to search."}):N.length===0?e("div",{className:"flex-1 text-ink/40 italic text-center py-4 text-[11px]",children:"No results found."}):e(d,{children:[E&&e("div",{className:"px-3 pt-2 text-[10.5px] text-error-text",role:"alert",children:["Search failed: ",e("span",{className:"font-mono",children:E})]}),q&&e("div",{className:"px-3 pt-2 text-ink/40 italic",children:"Searching…"}),J&&e("div",{className:"px-3 pt-2 text-ink/50 italic",children:["Showing the first ",se," matches — refine the query to see the rest."]}),e(ce,{groups:X,replacement:c,showReplacePreview:c.length>0,onOpen:he,onReplaceFile:de,replaceBusy:Q})]})]})}function pe(s){let[r,t]=n({scope:s,results:[],truncated:!1,error:null}),[c,h]=n(!1),l=i(null),x=i(!0),k=i(s);k.current=s,o(()=>(x.current=!0,()=>{x.current=!1,l.current?.abort(),l.current=null}),[]);let g=a(async(b)=>{l.current?.abort();let C=new AbortController;l.current=C;let m=k.current;t({scope:m,results:[],truncated:!1,error:null}),h(!0);try{let T=await fetch("/api/fs/search",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams(b),signal:C.signal});await Hc(T,(y,L)=>{if(k.current!==m)return;if(y==="done"){let v=!1;try{v=JSON.parse(L)?.truncated===!0}catch{}t((R)=>R.scope===m?{...R,truncated:v}:R);return}if(y==="error"){let v="Search failed";try{v=JSON.parse(L)?.error||v}catch{}t((R)=>R.scope===m?{...R,error:v}:R);return}if(y!=="matches")return;try{let v=JSON.parse(L);if(Array.isArray(v))t((R)=>R.scope===m?{...R,results:[...R.results,...v]}:R)}catch{}},C.signal)}catch{}finally{if(x.current&&l.current===C)l.current=null,h(!1)}},[]);return{results:r.scope===s?r.results:[],isSearching:c&&r.scope===s,truncated:r.scope===s&&r.truncated,error:r.scope===s?r.error:null,start:g}}function it({className:s="",enabled:r=!0,rootPath:t,onOpenFile:c,tabsMode:h=!1}){let[l,x]=S("search.query",""),[k,g]=S("search.replaceQuery",""),[b,C]=S("search.matchCase",!1),[m,T]=S("search.wholeWord",!1),[y,L]=S("search.useRegex",!1),[v,R]=S("search.includeFiles",""),[P,F]=n(!1),[H,D]=S("search.showIncludeField",!1),{activeRepo:p,setActiveRepo:w}=kr(t),{repos:M,scanning:N,rescan:q}=wr(t,r),J=i(null),E=yt(),{results:B,isSearching:U,truncated:Q,error:Y,start:X}=pe(`${t??""}\x00${p}`);ze(J,()=>F(!1));let W=a(()=>{if(!r)return;if(l.trim().length>2)return X({q:l,matchCase:String(b),wholeWord:String(m),useRegex:String(y),includeFiles:H?v:"",...t?{root:t}:{},...p!=="."?{repo:p}:{}})},[r,l,b,m,y,H,v,t,p,X]);o(()=>{let _=setTimeout(()=>{W()},300);return()=>clearTimeout(_)},[W]);let K=a((_)=>{if(!l)return;let j=_?[_]:Array.from(new Set(B.map((V)=>V.file)));if(j.length===0)return;E.submit({q:l,replaceWith:k,matchCase:String(b),wholeWord:String(m),useRegex:String(y),files:JSON.stringify(j),...t?{root:t}:{},...p!=="."?{repo:p}:{}},{method:"POST",action:"/api/fs/replace"})},[l,k,b,m,y,B,t,p,E]);if(o(()=>{if(E.state==="idle"&&E.data?.success)W()},[E.state,E.data,W]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${s}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e(ue,{className:s,tabsMode:h,query:l,setQuery:x,replaceQuery:k,setReplaceQuery:g,matchCase:b,setMatchCase:C,wholeWord:m,setWholeWord:T,useRegex:y,setUseRegex:L,includeFiles:v,setIncludeFiles:R,showIncludeField:H,setShowIncludeField:D,showMenu:P,setShowMenu:F,menuRef:J,rootPath:t,activeRepo:p,setActiveRepo:w,repos:M,reposScanning:N,rescanRepos:q,results:B,isSearching:U,truncated:Q,error:Y,onOpenFile:c,handleReplace:K,replaceBusy:E.state!=="idle"})}export{it as SearchPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,o,a,e,s,B,D,Qe,vt}from"./index-4vtc4xct.js";var V={name:"ticket",size:24,node:[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]},U=s(V);function S({providerName:t,providerSlug:r,iconUrl:i,credentialSources:l,error:p,note:c,children:m}){return e("section",{className:"bg-paper border border-ink/15 rounded-lg shadow-xs",children:[e("header",{className:"flex items-center justify-between gap-2 px-3.5 py-2.5 border-b border-ink/10",children:[e("span",{className:"flex min-w-0 items-center gap-2",children:[r&&e(vt,{provider:{slug:r,name:t,...i?{iconUrl:i}:{}},size:20}),e("span",{className:"truncate text-xs font-semibold text-ink",children:t})]}),e("span",{className:"text-[10px] font-mono uppercase tracking-wider text-ink/50 truncate",title:`Credentials from ${l.join(", ")}`,children:l.join(" · ")})]}),e("div",{className:"p-3.5 space-y-4",children:[p&&e("p",{className:"flex items-start gap-2 text-error-text text-xs leading-relaxed",children:[e(B,{size:14,className:"shrink-0 mt-0.5"}),e("span",{className:"break-words",children:p})]}),m,c&&e("p",{className:"text-[10px] text-ink/50 leading-relaxed border-t border-ink/10 pt-2.5",children:c})]})]})}var J=new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR",maximumFractionDigits:0}),X=new Intl.NumberFormat("id-ID"),P=new Intl.NumberFormat("id-ID",{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}),Y=new Intl.DateTimeFormat("id-ID",{dateStyle:"medium",timeStyle:"short"}),Z=new Intl.DateTimeFormat("id-ID",{dateStyle:"medium"});function x(t){return J.format(t)}function b(t){return X.format(t)}function va(t){let r=new Date(t);if(Number.isNaN(r.getTime()))return t;return Y.format(r)}function C(t){let r=new Date(t);if(Number.isNaN(r.getTime()))return t;return Z.format(r)}function T(t,r){if(r<=0)return 0;return Math.min(100,Math.max(0,t/r*100))}function A(t,r){if(r<=0)return"0%";return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t/r*100)}%`}function v(t){if(!Number.isFinite(t))return"0";let r=Math.abs(t);if(r>=1e9)return`${P.format(t/1e9)}B`;if(r>=1e6)return`${P.format(t/1e6)}M`;if(r>=1000)return`${P.format(t/1000)}K`;return b(t)}function w(t){let r=Number(t);if(t.trim()===""||!Number.isFinite(r))return t;return b(r)}var ee=new Intl.NumberFormat("id-ID",{minimumFractionDigits:2,maximumFractionDigits:2});function F(t){if(!Number.isFinite(t))return"$0,00";return`$${ee.format(t)}`}function h(t,r){if(!Number.isFinite(t))return"—";let i=r.trim().toUpperCase();if(i==="IDR")return x(t);if(i==="USD")return F(t);if(!i)return"—";try{return new Intl.NumberFormat("id-ID",{style:"currency",currency:i}).format(t)}catch{return`${b(t)} ${i}`}}function y(t,r){if(!Number.isFinite(t))return"—";switch(r){case"percent":return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t)}%`;case"usd":return F(t);case"idr":return x(t);case"tokens":case"bytes":return v(t);default:return b(t)}}function L(t){if(!Number.isFinite(t))return"0%";return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t*100)}%`}function te({window:t}){let r=t.usedRp+t.remainingRp,i=T(t.usedRp,r);return e("div",{className:"bg-paper border border-ink/15 rounded-lg p-3 shadow-xs space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-[11px] font-semibold text-ink",children:t.label}),e("span",{className:"text-[10px] text-ink/50",children:["Resets ",va(t.resetsAt)]})]}),e("div",{className:"h-1.5 w-full bg-ink/10 rounded-full overflow-hidden",children:e("div",{className:"h-full bg-ink/80 rounded-full",style:{width:`${i}%`}})}),e("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-0.5 text-[10px] text-ink/60",children:[e("span",{children:["Used ",e("span",{className:"font-semibold text-ink",children:x(t.usedRp)})," ·"," ",A(t.usedRp,r)]}),e("span",{children:["Remaining ",e("span",{className:"font-semibold text-ink",children:x(t.remainingRp)})]})]})]})}function ne({coupon:t}){return e("div",{className:"bg-ink/5 border border-ink/10 rounded-lg p-3 shadow-xs",children:[e("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e(U,{size:12,className:"text-ink/60"}),e("span",{className:"text-[11px] font-semibold text-ink",children:["Active coupon · ",t.name]})]}),e("div",{className:"text-[10px] text-ink/60 space-y-0.5",children:[e("div",{children:["Remaining"," ",e("span",{className:"font-semibold text-ink",children:t.remainingRp===null?"Unlimited":x(t.remainingRp)})," ","· Used ",e("span",{className:"font-semibold text-ink",children:x(t.usedRp)})]}),e("div",{children:["Expires ",va(t.expiresAt)]}),t.scopeModels.length>0&&e("div",{children:["Models: ",t.scopeModels.join(", ")]})]})]})}function I({quota:t}){if(!t)return e("p",{className:"text-[11px] text-ink/50",children:"Quota data is not available for this account."});return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:"Quota windows"}),t.planName&&e("span",{className:"text-[10px] text-ink/60",children:["Plan ",e("span",{className:"font-semibold text-ink",children:t.planName})]})]}),t.windows.length===0?e("p",{className:"text-[11px] text-ink/50",children:"No quota windows reported."}):e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2.5",children:t.windows.map((r)=>e(te,{window:r},r.key))}),t.coupon&&e(ne,{coupon:t.coupon})]})}function E({usage:t}){if(!t)return e("p",{className:"text-[11px] text-ink/50",children:"The 30-day usage report is not available."});let r=t.rows.reduce((l,p)=>l+p.inputTokens,0),i=t.rows.reduce((l,p)=>l+p.outputTokens,0);return e("div",{className:"space-y-2",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:"30-day usage by model"}),e("div",{className:"overflow-x-auto border border-ink/15 rounded-lg shadow-xs",children:e("table",{className:"w-full text-[11px]",children:[e("thead",{className:"bg-ink/5 text-ink/60",children:e("tr",{children:[e("th",{className:"text-left font-semibold px-3 py-2 whitespace-nowrap",children:"Model"}),e("th",{className:"text-right font-semibold px-3 py-2 whitespace-nowrap",children:"Requests"}),e("th",{className:"text-right font-semibold px-3 py-2 whitespace-nowrap",children:"Input tokens"}),e("th",{className:"text-right font-semibold px-3 py-2 whitespace-nowrap",children:"Output tokens"}),e("th",{className:"text-right font-semibold px-3 py-2 whitespace-nowrap",children:"Cost"})]})}),e("tbody",{className:"divide-y divide-ink/10",children:t.rows.length===0?e("tr",{children:e("td",{colSpan:5,className:"px-3 py-3 text-center text-ink/50",children:"No usage recorded in the last 30 days."})}):t.rows.map((l)=>e("tr",{children:[e("td",{className:"px-3 py-1.5 font-mono text-ink whitespace-nowrap",children:l.model}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:b(l.requests)}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:v(l.inputTokens)}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:v(l.outputTokens)}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:x(l.costRp)})]},l.model))}),e("tfoot",{className:"bg-ink/5 border-t border-ink/15 font-semibold text-ink",children:e("tr",{children:[e("td",{className:"px-3 py-2",children:"Total"}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:b(t.totalRequests)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:v(r)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:v(i)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:x(t.totalCostRp)})]})})]})})]})}function M({report:t}){let{balance:r,usage:i,quota:l}=t;if(!r&&!i&&!l)return e("p",{className:"text-[11px] text-ink/50",children:"No kenari data was returned for this account."});let p=r?r.amountRp!==null?x(r.amountRp):r.raw:"–",c=r?r.amountRp!==null?r.raw:"Amount could not be parsed":"Balance unavailable",m=i?i.rows.reduce((f,u)=>f+u.inputTokens+u.outputTokens,0):0;return e(d,{children:[e("div",{className:"@container",children:e("div",{className:"grid grid-cols-3 @[540px]:grid-cols-5 gap-2.5 items-stretch",children:[e(Qe,{value:p,label:"Wallet balance",hint:c}),e(Qe,{value:l?.planName??"–",label:"Active plan",hint:l?"kenari quota plan":"Quota unavailable"}),e(Qe,{value:i?b(i.totalRequests):"–",label:"Requests (30 days)",hint:i?"Across all models":"Usage report unavailable"}),e(Qe,{value:i?x(i.totalCostRp):"–",label:"Cost (30 days)",hint:i?"Billed in Rupiah":"Usage report unavailable"}),e(Qe,{value:i?v(m):"–",label:"Tokens processed (30 days)",hint:i?"Input + output":"Usage report unavailable",tone:"muted",className:"col-span-2 @[540px]:col-span-1"})]})}),e(I,{quota:l}),e(E,{usage:i})]})}function K({report:t}){let r=t.balance;if(!r)return e("p",{className:"text-[11px] text-ink/50",children:"DeepSeek balance data is not available."});return e(d,{children:[e("div",{className:"@container",children:e("div",{className:"grid grid-cols-3 @[540px]:grid-cols-5 gap-2.5 items-stretch",children:[e(Qe,{value:r.isAvailable?"Available":"Unavailable",label:"Prepaid balance",hint:r.isAvailable?"Account can spend":"Top up required",tone:r.isAvailable?"default":"muted"}),e(Qe,{value:b(r.entries.length),label:"Currency buckets",hint:r.entries.length>0?"From the balance endpoint":"No entries returned",tone:"muted"})]})}),r.entries.length===0?e("p",{className:"text-[11px] text-ink/50",children:"The balance endpoint returned no currency entries."}):e("div",{className:"grid grid-cols-1 gap-2.5",children:r.entries.map((i)=>e("div",{className:"bg-paper border border-ink/15 rounded-lg p-3 shadow-xs",children:[e("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e("span",{className:"text-[11px] font-semibold text-ink",children:i.currency}),e("span",{className:"text-[10px] font-mono uppercase tracking-wider text-ink/40",children:"Balance"})]}),e("dl",{className:"grid grid-cols-3 gap-2 text-[10px]",children:[e("div",{children:[e("dt",{className:"text-ink/50",children:"Total"}),e("dd",{className:"font-semibold text-ink tabular-nums break-words",children:w(i.totalBalance)})]}),e("div",{children:[e("dt",{className:"text-ink/50",children:"Granted"}),e("dd",{className:"font-semibold text-ink tabular-nums break-words",children:w(i.grantedBalance)})]}),e("div",{children:[e("dt",{className:"text-ink/50",children:"Topped up"}),e("dd",{className:"font-semibold text-ink tabular-nums break-words",children:w(i.toppedUpBalance)})]})]})]},i.currency))})]})}function _({label:t,percent:r,spent:i,enabled:l=!0,children:p}){let c=l&&r!==null?Math.min(100,Math.max(0,r)):0,m=!l?"Off":i?"Spent":r!==null?`${r}% used`:"Not reported";return e("div",{className:"space-y-1.5",children:[e("div",{className:"flex items-baseline justify-between gap-2",children:[e("span",{className:"text-[11px] font-semibold text-ink",children:t}),e("span",{className:`text-[10px] ${i?"text-error-text":"text-ink/60"}`,children:m})]}),e("div",{className:"h-1.5 w-full bg-ink/10 rounded-full overflow-hidden",...l?{role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,...r!==null?{"aria-valuenow":c}:{}}:{},children:e("div",{className:`h-full rounded-full ${i?"bg-error/70":l?"bg-ink/80":"bg-ink/20"}`,style:{width:`${c}%`}})}),p]})}function H({report:t}){let r=t.allowance;if(!r)return e("p",{className:"text-[11px] text-ink/60",children:"Token Harbor returned no allowance for this key. Refresh to try again."});let{onPlan:i,activated:l,resetAt:p}=r,c=(m)=>m===null?"n/a":y(m,"percent");return e(d,{children:[e("div",{className:"@container",children:e("div",{className:"grid grid-cols-2 @[540px]:grid-cols-4 gap-2.5 items-stretch",children:[e(Qe,{value:r.planName??"No Pass",label:"Plan",hint:i?"Pass allowance applies":"Covered models bill your wallet"}),e(Qe,{value:i?c(r.planUsedPct):"n/a",label:"Pass week used",hint:i?r.planExhausted?"Spent for this window":"Of this 7-day window":"No Pass to draw on",tone:i?"default":"muted"}),e(Qe,{value:c(r.usedPct),label:"Free week used",hint:r.modelsEnabled?"Of this 7-day window":"Free models are off",tone:"muted"}),e(Qe,{value:l&&p?C(p):"Not started",label:"Resets",hint:l?"Pass and free share one window":"The window begins with your first request",tone:"muted"})]})}),e("div",{className:"space-y-3",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-muted",children:"Allowance"}),i?e(_,{label:r.planName??"Pass allowance",percent:r.planUsedPct,spent:r.planExhausted,children:r.planExhausted&&e("p",{className:"text-[10px] text-ink/70 leading-relaxed",children:"Covered calls resume when the window resets. Until then they run only if Keep working after my Pass allowance runs out is on in Dashboard, Billing, which bills your wallet at the Pass discount."})}):e("p",{className:"text-[10px] text-ink/70 leading-relaxed",children:"This account holds no Pass, so there is no Pass allowance to draw. Covered models bill your wallet."}),e(_,{label:"Free allowance",percent:r.usedPct,spent:r.exhausted,enabled:r.modelsEnabled,children:r.modelsEnabled?r.freeModels.length>0&&e("p",{className:"text-[10px] text-ink/60 leading-relaxed break-words",children:["Free models now: ",r.freeModels.join(", ")]}):e("p",{className:"text-[10px] text-ink/70 leading-relaxed",children:"Free models are switched off for this account, so calls to them are refused whatever the percentage says. Turn them back on in the Token Harbor dashboard, under Data and privacy."})}),!l&&e("p",{className:"text-[10px] text-ink/60 leading-relaxed",children:"The 7-day window starts with this account's first request. Both allowances reset together."})]})]})}function W({report:t}){let r=t.balance;if(!r)return e("p",{className:"text-[11px] text-ink/60",children:"TokenPortal returned no balance for this key. Refresh to try again."});let i=r.limit!==null&&r.limitRemaining!==null?Math.max(0,r.limit-r.limitRemaining):null,l=r.limit!==null&&i!==null&&r.limit>0?Math.min(100,i/r.limit*100):null;return e(d,{children:[e("div",{className:"@container",children:e("div",{className:"grid grid-cols-2 @[540px]:grid-cols-4 gap-2.5 items-stretch",children:[e(Qe,{value:h(r.balance,r.currency),label:"Credit balance",hint:r.label?`Key ${r.label}`:`Left on this key, in ${r.currency}`}),e(Qe,{value:r.limit===null?"No cap":h(r.limit,r.currency),label:"Key limit",hint:r.limit===null?"Spending is not capped on this key":i!==null?`${h(i,r.currency)} spent`:"Cap set by the operator",tone:r.limit===null?"muted":"default"}),e(Qe,{value:r.sessionBudget===null?"Not set":h(r.sessionBudget,r.currency),label:"Session budget",hint:r.sessionBudget===null?"No per-session cap":"Applies to one gateway session",tone:"muted"}),e(Qe,{value:r.isFreeTier?"Free":"Paid",label:"Tier",hint:r.isFreeTier?"Free-tier limits apply":"No free-tier limit on this key",tone:"muted"})]})}),l!==null&&i!==null&&e("div",{className:"space-y-1.5",children:[e("div",{className:"flex items-baseline justify-between gap-2",children:[e("span",{className:"text-[11px] font-semibold text-ink",children:"Key limit used"}),e("span",{className:"text-[10px] text-ink/60",children:[h(i,r.currency)," of ",h(r.limit??0,r.currency)]})]}),e("div",{className:"h-1.5 w-full bg-ink/10 rounded-full overflow-hidden",role:"progressbar","aria-label":"Key limit used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(l),children:e("div",{className:`h-full rounded-full ${r.limitRemaining!==null&&r.limitRemaining<=0?"bg-error/70":"bg-ink/80"}`,style:{width:`${l}%`}})}),r.limitRemaining!==null&&e("p",{className:"text-[10px] text-ink/50",children:[h(r.limitRemaining,r.currency)," left under the cap"]})]}),e("p",{className:"text-[10px] text-ink/50 leading-relaxed",children:["Balance and caps come from TokenPortal’s ",e("span",{className:"font-mono",children:"/v1/key"})," endpoint in"," ",r.currency,"; top-ups and transaction history live in its console."]})]})}function q(t){return t.trim().toLowerCase().replace(/[-_\s]/g,"").includes("antigravity")}var ae="anthropic:extra",O="Quota windows";function R(t,r,i,l){let p=t.find((c)=>c.id===r);if(p){p.limits.push(l);return}t.push({id:r,title:i,limits:[l]})}function re(t){let r=(t.split(":")[1]??"").toLowerCase();if(r==="google")return{id:"google",title:"Google"};if(r==="anthropic"||r==="openai")return{id:"third-party",title:"Claude & GPT (shared)"};if(r==="default"||r==="")return{id:"default",title:"Usage"};return{id:r,title:r}}function se(t){let r=[];for(let i of t)if(i.id===ae)R(r,"balance","Balance",i);else R(r,"windows",O,i);return r}function ie(t){let r=[];for(let i of t){let l=re(i.id);if(l.id==="third-party"){if(r.find((c)=>c.id==="third-party")?.limits.some((c)=>oe(c,i)))continue}R(r,l.id,l.title,i)}return r}function oe(t,r){return t.unit===r.unit&&t.label===r.label&&t.usedFraction===r.usedFraction&&t.remaining===r.remaining&&t.resetsAt===r.resetsAt}function Q(t,r){if(r.length===0)return[];let i=t.trim().toLowerCase();if(i==="anthropic")return se(r);if(q(i))return ie(r);return[{id:"all",title:O,limits:[...r]}]}function le({limit:t}){let r=Math.min(100,Math.max(0,(t.usedFraction??0)*100)),i=t.modelId??t.accountId,l=t.used!==void 0?y(t.used,t.unit):void 0,p=t.limit!==void 0?y(t.limit,t.unit):void 0,c=t.remaining!==void 0?y(t.remaining,t.unit):void 0;return e("div",{className:"bg-paper border border-ink/15 rounded-lg p-3 shadow-xs space-y-2",children:[e("div",{className:"flex items-start justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-[11px] font-semibold text-ink truncate",children:[t.label,t.windowLabel&&e("span",{className:"ml-1.5 rounded border border-ink/15 px-1 py-px font-mono text-[9px] font-normal text-ink/50",children:t.windowLabel})]}),i&&e("div",{className:"text-[10px] text-ink/50 truncate",children:i})]}),e("span",{className:"text-[10px] text-ink/50 flex-shrink-0 whitespace-nowrap",children:t.resetsAt!==void 0?`Resets ${va(new Date(t.resetsAt).toISOString())}`:""})]}),e("div",{className:"h-1.5 w-full bg-ink/10 rounded-full overflow-hidden",children:e("div",{className:`h-full rounded-full ${t.status==="exhausted"?"bg-error/70":"bg-ink/80"}`,style:{width:`${r}%`}})}),e("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-0.5 text-[10px] text-ink/60",children:[e("span",{children:["Used"," ",e("span",{className:"font-semibold text-ink",children:t.unit==="percent"||!l?L(t.usedFraction??0):l}),t.unit!=="percent"&&l&&p?` of ${p}`:""]}),e("span",{className:"flex items-center gap-2",children:[t.status!=="ok"&&t.status!=="unknown"&&e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70",children:t.status}),c&&e("span",{children:["Remaining ",e("span",{className:"font-semibold text-ink",children:c})]})]})]}),t.notes&&t.notes.length>0&&e("ul",{className:"text-[10px] text-ink/50 leading-relaxed space-y-0.5",children:t.notes.map((m)=>e("li",{children:m},m))})]})}function j({providerId:t,limits:r,tracked:i,unavailable:l,emptyReason:p,notes:c}){let m=Q(t,r);return e("div",{className:"space-y-2",children:[c&&c.length>0&&e("ul",{className:"text-[10px] text-ink/50 leading-relaxed space-y-0.5",children:c.map((f)=>e("li",{children:f},f))}),m.length===0?e(d,{children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:"Quota windows"}),e("p",{className:"text-[11px] text-ink/50",children:p??(!i?"No quota source for this provider: omp ships no usage adapter for it and it exposes no balance endpoint Kabmo knows.":l?"omp tracks this provider but its usage endpoint returned no data — an invalid or expired credential, an unreachable endpoint, or a plan without quota windows.":"No quota windows were reported for this provider.")})]}):m.map((f)=>e("div",{className:"@container space-y-2",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:f.title}),e("div",{className:"grid grid-cols-1 @[520px]:grid-cols-2 gap-2.5",children:f.limits.map((u)=>e(le,{limit:u},u.id))})]},f.id))]})}var de="DeepSeek exposes no usage or quota API — only the prepaid balance (and the web console at platform.deepseek.com) is available.",pe="Token Harbor reports percentages, never a dollar remainder. Request history and per-request cost are on its usage dashboard.",ce="omp tracks Command Code, but its usage read needs an API key created in Studio — the signed-in OAuth credential cannot read its billing endpoint. Add an API key in Settings → Providers to see the 5-hour, weekly and credit windows.";function ud({summary:t}){let r=Boolean(t.kenari||t.deepseek||t.tokenHarbor||t.tokenPortal),i=t.tokenHarbor?pe:t.deepseek?de:void 0;return e(S,{providerName:t.name,providerSlug:t.id,iconUrl:t.iconUrl,credentialSources:t.credentialSources,error:t.error,note:i,children:[t.kenari&&e(M,{report:t.kenari}),t.deepseek&&e(K,{report:t.deepseek}),t.tokenHarbor&&e(H,{report:t.tokenHarbor}),t.tokenPortal&&e(W,{report:t.tokenPortal}),!r&&(t.limits.length>0||!t.error)&&e(j,{providerId:t.id,limits:t.limits,tracked:t.tracked,unavailable:t.limitsUnavailable,...t.id==="commandcode"&&t.limitsUnavailable?{emptyReason:ce}:{},notes:t.notes})]})}function me(t){let r=t.filter((p)=>p.usedFraction!==void 0);if(r.length===0){let p=t.find((c)=>(c.unit==="usd"||c.unit==="idr")&&c.remaining!==void 0);if(p)return`${h(p.remaining??0,p.unit==="idr"?"IDR":"USD")} left`;return t[0]?.label}let i=r.reduce((p,c)=>(c.usedFraction??0)>(p.usedFraction??0)?c:p),l=Math.round((i.usedFraction??0)*100);return i.windowLabel?`${l}% · ${i.windowLabel}`:`${l}% used`}function bh(t){if(t.error)return!0;if(t.limits.length>0)return!0;return Boolean(t.kenari?.balance||t.kenari?.usage||t.kenari?.quota||t.deepseek?.balance||t.tokenHarbor?.allowance||t.tokenPortal?.balance)}function ll(t){return t.providers.map((r)=>({id:r.id,name:r.name,...r.iconUrl?{iconUrl:r.iconUrl}:{},error:r.error,hint:ue(r),limits:r.limits,tracked:r.tracked,limitsUnavailable:r.limitsUnavailable,summary:r}))}function ue(t){let r=t.kenari?.quota?.planName;if(r)return r;let i=t.tokenPortal?.balance;if(i)return h(i.balance,i.currency);let l=t.deepseek?.balance?.entries[0];if(l)return`${l.currency} ${w(l.totalBalance)}`;let p=t.tokenHarbor?.allowance;if(p){if(!p.activated)return`${p.planName??"Free"} · not started`;if(p.onPlan)return`${p.planName??"Pass"} · ${p.planUsedPct??0}% · 7d`;return`${p.usedPct??0}% free · 7d`}if(t.id==="commandcode"&&t.limitsUnavailable)return"API key needed";return me(t.limits)??"No quota reported"}function yh(t){return t.error?"Error":"Connected"}function G(){let[t,r]=n([]),[i,l]=n(null),[p,c]=n(!0),m=a(()=>{c(!0),fetch("/api/settings/usage/reset").then((u)=>u.json()).then((u)=>{r(Array.isArray(u.accounts)?u.accounts:[]),l(typeof u.error==="string"?u.error:null)}).catch((u)=>{r([]),l(u instanceof Error?u.message:"Failed to load saved resets")}).finally(()=>c(!1))},[]);o(()=>{m()},[m]);let f=a(async(u)=>{try{let N=await(await fetch("/api/settings/usage/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:u})})).json();if(N.ok)m();return{ok:Boolean(N.ok),message:N.message||"No result reported."}}catch(g){return{ok:!1,message:g instanceof Error?g.message:"Failed to spend the saved reset"}}},[m]);return{accounts:t,error:i,isLoading:p,reload:m,spend:f}}function fe({account:t,onSpend:r,spending:i}){let l=`${t.provider}/${t.credentialId}`,p=t.email??t.accountId??t.credentialId,c=t.orgName??t.orgId,m=t.availableCount??t.credits.length,f=t.redeemableCount??0,u=t.error??t.unavailableReason;return e("div",{className:"bg-paper border border-ink/15 rounded-lg p-3 shadow-xs space-y-2",children:[e("div",{className:"flex items-start justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-[11px] font-semibold text-ink truncate",children:[p,c?e("span",{className:"text-ink/50 font-normal",children:[" · ",c]}):null]}),e("div",{className:"text-[10px] text-ink/50 font-mono truncate",children:l})]}),e("span",{className:"text-[10px] text-ink/60 flex-shrink-0 whitespace-nowrap",children:f>0?`${f} of ${m} usable`:`${m} saved`})]}),t.soonestExpiry!==void 0&&e("div",{className:"text-[10px] text-ink/60",children:["Soonest expires ",va(new Date(t.soonestExpiry).toISOString())]}),t.credits.length>0&&e("div",{className:"space-y-1",children:t.credits.map((g)=>e("div",{className:"flex items-center justify-between gap-2 text-[10px] text-ink/70",children:[e("span",{className:"truncate",children:g.title??g.program??g.id}),e("span",{className:"flex items-center gap-1.5 flex-shrink-0",children:[g.clears&&g.clears.length>0&&e("span",{className:"font-mono text-ink/50",children:g.clears.join(", ")}),g.usable===!1&&e("span",{className:"font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/60",children:"blocked"})]})]},g.id))}),u&&e("div",{className:"text-[10px] text-ink/60 leading-snug",children:u}),e("button",{type:"button",onClick:()=>r(l),disabled:i||f===0,title:f===0?u??"Nothing to spend on this account right now.":`Spend a saved reset on ${l}`,className:"w-full rounded-md border border-ink/15 px-2 py-1 text-[11px] font-medium text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:i?"Spending…":"Spend saved reset"})]})}function dd(){let{accounts:t,error:r,isLoading:i,reload:l,spend:p}=G(),[c,m]=n(null),[f,u]=n(null),g=(k)=>{m(k),u(null),p(k).then((z)=>{u(z),m(null)})},N=!i&&!r&&t.length===0;return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-[11px] font-semibold text-ink",children:"Saved rate-limit resets"}),e("div",{className:"text-[10px] text-ink/50 leading-snug",children:"Provider-issued resets for Codex and Claude accounts. Spending one clears the window it covers."})]}),e("button",{type:"button",onClick:l,disabled:i,title:"Re-read saved resets",className:"p-1.5 bg-paper border border-ink/15 rounded-md hover:bg-ink/5 text-ink/80 transition-colors disabled:opacity-50 flex-shrink-0",children:e(D,{size:12,className:i?"animate-spin text-ink":""})})]}),r&&e("div",{className:"flex items-start gap-1.5 text-[10px] text-error-text leading-snug",children:[e(B,{size:12,className:"flex-shrink-0 mt-px"}),e("span",{children:r})]}),t.map((k)=>e(fe,{account:k,onSpend:g,spending:c===`${k.provider}/${k.credentialId}`},`${k.provider}/${k.credentialId}`)),N&&e("p",{className:"text-[10px] text-ink/50 leading-snug",children:"No saved resets on any account."}),f&&e("div",{className:`text-[10px] leading-snug ${f.ok?"text-ink/70":"text-error-text"}`,children:f.message})]})}function pd(){let[t,r]=n(null),[i,l]=n(!0),[p,c]=n(null),m=a(async(f)=>{if(!f?.silent)l(!0);c(null);try{let u=f?.force?"/api/settings/usage?refresh=1":"/api/settings/usage",g=await fetch(u);if(!g.ok)throw Error(`Usage request failed (${g.status})`);let N=await g.json();r(N)}catch(u){c(u instanceof Error?u.message:"Failed to load provider usage")}finally{if(!f?.silent)l(!1)}},[]);return o(()=>{m()},[m]),{report:t,isLoading:i,error:p,reload:m}}
|
|
2
|
-
export{
|
|
1
|
+
import{d,n,o,a,e,s,B,D,Qe,xt}from"./index-j734ev6q.js";var V={name:"ticket",size:24,node:[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]},U=s(V);function S({providerName:t,providerSlug:r,iconUrl:i,credentialSources:l,error:p,note:c,children:m}){return e("section",{className:"bg-paper border border-ink/15 rounded-lg shadow-xs",children:[e("header",{className:"flex items-center justify-between gap-2 px-3.5 py-2.5 border-b border-ink/10",children:[e("span",{className:"flex min-w-0 items-center gap-2",children:[r&&e(xt,{provider:{slug:r,name:t,...i?{iconUrl:i}:{}},size:20}),e("span",{className:"truncate text-xs font-semibold text-ink",children:t})]}),e("span",{className:"text-[10px] font-mono uppercase tracking-wider text-ink/50 truncate",title:`Credentials from ${l.join(", ")}`,children:l.join(" · ")})]}),e("div",{className:"p-3.5 space-y-4",children:[p&&e("p",{className:"flex items-start gap-2 text-error-text text-xs leading-relaxed",children:[e(B,{size:14,className:"shrink-0 mt-0.5"}),e("span",{className:"break-words",children:p})]}),m,c&&e("p",{className:"text-[10px] text-ink/50 leading-relaxed border-t border-ink/10 pt-2.5",children:c})]})]})}var J=new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR",maximumFractionDigits:0}),X=new Intl.NumberFormat("id-ID"),P=new Intl.NumberFormat("id-ID",{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}),Y=new Intl.DateTimeFormat("id-ID",{dateStyle:"medium",timeStyle:"short"}),Z=new Intl.DateTimeFormat("id-ID",{dateStyle:"medium"});function x(t){return J.format(t)}function b(t){return X.format(t)}function Ca(t){let r=new Date(t);if(Number.isNaN(r.getTime()))return t;return Y.format(r)}function C(t){let r=new Date(t);if(Number.isNaN(r.getTime()))return t;return Z.format(r)}function T(t,r){if(r<=0)return 0;return Math.min(100,Math.max(0,t/r*100))}function A(t,r){if(r<=0)return"0%";return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t/r*100)}%`}function v(t){if(!Number.isFinite(t))return"0";let r=Math.abs(t);if(r>=1e9)return`${P.format(t/1e9)}B`;if(r>=1e6)return`${P.format(t/1e6)}M`;if(r>=1000)return`${P.format(t/1000)}K`;return b(t)}function w(t){let r=Number(t);if(t.trim()===""||!Number.isFinite(r))return t;return b(r)}var ee=new Intl.NumberFormat("id-ID",{minimumFractionDigits:2,maximumFractionDigits:2});function F(t){if(!Number.isFinite(t))return"$0,00";return`$${ee.format(t)}`}function h(t,r){if(!Number.isFinite(t))return"—";let i=r.trim().toUpperCase();if(i==="IDR")return x(t);if(i==="USD")return F(t);if(!i)return"—";try{return new Intl.NumberFormat("id-ID",{style:"currency",currency:i}).format(t)}catch{return`${b(t)} ${i}`}}function y(t,r){if(!Number.isFinite(t))return"—";switch(r){case"percent":return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t)}%`;case"usd":return F(t);case"idr":return x(t);case"tokens":case"bytes":return v(t);default:return b(t)}}function L(t){if(!Number.isFinite(t))return"0%";return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t*100)}%`}function te({window:t}){let r=t.usedRp+t.remainingRp,i=T(t.usedRp,r);return e("div",{className:"bg-paper border border-ink/15 rounded-lg p-3 shadow-xs space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-[11px] font-semibold text-ink",children:t.label}),e("span",{className:"text-[10px] text-ink/50",children:["Resets ",Ca(t.resetsAt)]})]}),e("div",{className:"h-1.5 w-full bg-ink/10 rounded-full overflow-hidden",children:e("div",{className:"h-full bg-ink/80 rounded-full",style:{width:`${i}%`}})}),e("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-0.5 text-[10px] text-ink/60",children:[e("span",{children:["Used ",e("span",{className:"font-semibold text-ink",children:x(t.usedRp)})," ·"," ",A(t.usedRp,r)]}),e("span",{children:["Remaining ",e("span",{className:"font-semibold text-ink",children:x(t.remainingRp)})]})]})]})}function ne({coupon:t}){return e("div",{className:"bg-ink/5 border border-ink/10 rounded-lg p-3 shadow-xs",children:[e("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e(U,{size:12,className:"text-ink/60"}),e("span",{className:"text-[11px] font-semibold text-ink",children:["Active coupon · ",t.name]})]}),e("div",{className:"text-[10px] text-ink/60 space-y-0.5",children:[e("div",{children:["Remaining"," ",e("span",{className:"font-semibold text-ink",children:t.remainingRp===null?"Unlimited":x(t.remainingRp)})," ","· Used ",e("span",{className:"font-semibold text-ink",children:x(t.usedRp)})]}),e("div",{children:["Expires ",Ca(t.expiresAt)]}),t.scopeModels.length>0&&e("div",{children:["Models: ",t.scopeModels.join(", ")]})]})]})}function I({quota:t}){if(!t)return e("p",{className:"text-[11px] text-ink/50",children:"Quota data is not available for this account."});return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:"Quota windows"}),t.planName&&e("span",{className:"text-[10px] text-ink/60",children:["Plan ",e("span",{className:"font-semibold text-ink",children:t.planName})]})]}),t.windows.length===0?e("p",{className:"text-[11px] text-ink/50",children:"No quota windows reported."}):e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2.5",children:t.windows.map((r)=>e(te,{window:r},r.key))}),t.coupon&&e(ne,{coupon:t.coupon})]})}function E({usage:t}){if(!t)return e("p",{className:"text-[11px] text-ink/50",children:"The 30-day usage report is not available."});let r=t.rows.reduce((l,p)=>l+p.inputTokens,0),i=t.rows.reduce((l,p)=>l+p.outputTokens,0);return e("div",{className:"space-y-2",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:"30-day usage by model"}),e("div",{className:"overflow-x-auto border border-ink/15 rounded-lg shadow-xs",children:e("table",{className:"w-full text-[11px]",children:[e("thead",{className:"bg-ink/5 text-ink/60",children:e("tr",{children:[e("th",{className:"text-left font-semibold px-3 py-2 whitespace-nowrap",children:"Model"}),e("th",{className:"text-right font-semibold px-3 py-2 whitespace-nowrap",children:"Requests"}),e("th",{className:"text-right font-semibold px-3 py-2 whitespace-nowrap",children:"Input tokens"}),e("th",{className:"text-right font-semibold px-3 py-2 whitespace-nowrap",children:"Output tokens"}),e("th",{className:"text-right font-semibold px-3 py-2 whitespace-nowrap",children:"Cost"})]})}),e("tbody",{className:"divide-y divide-ink/10",children:t.rows.length===0?e("tr",{children:e("td",{colSpan:5,className:"px-3 py-3 text-center text-ink/50",children:"No usage recorded in the last 30 days."})}):t.rows.map((l)=>e("tr",{children:[e("td",{className:"px-3 py-1.5 font-mono text-ink whitespace-nowrap",children:l.model}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:b(l.requests)}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:v(l.inputTokens)}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:v(l.outputTokens)}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:x(l.costRp)})]},l.model))}),e("tfoot",{className:"bg-ink/5 border-t border-ink/15 font-semibold text-ink",children:e("tr",{children:[e("td",{className:"px-3 py-2",children:"Total"}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:b(t.totalRequests)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:v(r)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:v(i)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:x(t.totalCostRp)})]})})]})})]})}function M({report:t}){let{balance:r,usage:i,quota:l}=t;if(!r&&!i&&!l)return e("p",{className:"text-[11px] text-ink/50",children:"No kenari data was returned for this account."});let p=r?r.amountRp!==null?x(r.amountRp):r.raw:"–",c=r?r.amountRp!==null?r.raw:"Amount could not be parsed":"Balance unavailable",m=i?i.rows.reduce((f,u)=>f+u.inputTokens+u.outputTokens,0):0;return e(d,{children:[e("div",{className:"@container",children:e("div",{className:"grid grid-cols-3 @[540px]:grid-cols-5 gap-2.5 items-stretch",children:[e(Qe,{value:p,label:"Wallet balance",hint:c}),e(Qe,{value:l?.planName??"–",label:"Active plan",hint:l?"kenari quota plan":"Quota unavailable"}),e(Qe,{value:i?b(i.totalRequests):"–",label:"Requests (30 days)",hint:i?"Across all models":"Usage report unavailable"}),e(Qe,{value:i?x(i.totalCostRp):"–",label:"Cost (30 days)",hint:i?"Billed in Rupiah":"Usage report unavailable"}),e(Qe,{value:i?v(m):"–",label:"Tokens processed (30 days)",hint:i?"Input + output":"Usage report unavailable",tone:"muted",className:"col-span-2 @[540px]:col-span-1"})]})}),e(I,{quota:l}),e(E,{usage:i})]})}function K({report:t}){let r=t.balance;if(!r)return e("p",{className:"text-[11px] text-ink/50",children:"DeepSeek balance data is not available."});return e(d,{children:[e("div",{className:"@container",children:e("div",{className:"grid grid-cols-3 @[540px]:grid-cols-5 gap-2.5 items-stretch",children:[e(Qe,{value:r.isAvailable?"Available":"Unavailable",label:"Prepaid balance",hint:r.isAvailable?"Account can spend":"Top up required",tone:r.isAvailable?"default":"muted"}),e(Qe,{value:b(r.entries.length),label:"Currency buckets",hint:r.entries.length>0?"From the balance endpoint":"No entries returned",tone:"muted"})]})}),r.entries.length===0?e("p",{className:"text-[11px] text-ink/50",children:"The balance endpoint returned no currency entries."}):e("div",{className:"grid grid-cols-1 gap-2.5",children:r.entries.map((i)=>e("div",{className:"bg-paper border border-ink/15 rounded-lg p-3 shadow-xs",children:[e("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e("span",{className:"text-[11px] font-semibold text-ink",children:i.currency}),e("span",{className:"text-[10px] font-mono uppercase tracking-wider text-ink/40",children:"Balance"})]}),e("dl",{className:"grid grid-cols-3 gap-2 text-[10px]",children:[e("div",{children:[e("dt",{className:"text-ink/50",children:"Total"}),e("dd",{className:"font-semibold text-ink tabular-nums break-words",children:w(i.totalBalance)})]}),e("div",{children:[e("dt",{className:"text-ink/50",children:"Granted"}),e("dd",{className:"font-semibold text-ink tabular-nums break-words",children:w(i.grantedBalance)})]}),e("div",{children:[e("dt",{className:"text-ink/50",children:"Topped up"}),e("dd",{className:"font-semibold text-ink tabular-nums break-words",children:w(i.toppedUpBalance)})]})]})]},i.currency))})]})}function _({label:t,percent:r,spent:i,enabled:l=!0,children:p}){let c=l&&r!==null?Math.min(100,Math.max(0,r)):0,m=!l?"Off":i?"Spent":r!==null?`${r}% used`:"Not reported";return e("div",{className:"space-y-1.5",children:[e("div",{className:"flex items-baseline justify-between gap-2",children:[e("span",{className:"text-[11px] font-semibold text-ink",children:t}),e("span",{className:`text-[10px] ${i?"text-error-text":"text-ink/60"}`,children:m})]}),e("div",{className:"h-1.5 w-full bg-ink/10 rounded-full overflow-hidden",...l?{role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,...r!==null?{"aria-valuenow":c}:{}}:{},children:e("div",{className:`h-full rounded-full ${i?"bg-error/70":l?"bg-ink/80":"bg-ink/20"}`,style:{width:`${c}%`}})}),p]})}function H({report:t}){let r=t.allowance;if(!r)return e("p",{className:"text-[11px] text-ink/60",children:"Token Harbor returned no allowance for this key. Refresh to try again."});let{onPlan:i,activated:l,resetAt:p}=r,c=(m)=>m===null?"n/a":y(m,"percent");return e(d,{children:[e("div",{className:"@container",children:e("div",{className:"grid grid-cols-2 @[540px]:grid-cols-4 gap-2.5 items-stretch",children:[e(Qe,{value:r.planName??"No Pass",label:"Plan",hint:i?"Pass allowance applies":"Covered models bill your wallet"}),e(Qe,{value:i?c(r.planUsedPct):"n/a",label:"Pass week used",hint:i?r.planExhausted?"Spent for this window":"Of this 7-day window":"No Pass to draw on",tone:i?"default":"muted"}),e(Qe,{value:c(r.usedPct),label:"Free week used",hint:r.modelsEnabled?"Of this 7-day window":"Free models are off",tone:"muted"}),e(Qe,{value:l&&p?C(p):"Not started",label:"Resets",hint:l?"Pass and free share one window":"The window begins with your first request",tone:"muted"})]})}),e("div",{className:"space-y-3",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-muted",children:"Allowance"}),i?e(_,{label:r.planName??"Pass allowance",percent:r.planUsedPct,spent:r.planExhausted,children:r.planExhausted&&e("p",{className:"text-[10px] text-ink/70 leading-relaxed",children:"Covered calls resume when the window resets. Until then they run only if Keep working after my Pass allowance runs out is on in Dashboard, Billing, which bills your wallet at the Pass discount."})}):e("p",{className:"text-[10px] text-ink/70 leading-relaxed",children:"This account holds no Pass, so there is no Pass allowance to draw. Covered models bill your wallet."}),e(_,{label:"Free allowance",percent:r.usedPct,spent:r.exhausted,enabled:r.modelsEnabled,children:r.modelsEnabled?r.freeModels.length>0&&e("p",{className:"text-[10px] text-ink/60 leading-relaxed break-words",children:["Free models now: ",r.freeModels.join(", ")]}):e("p",{className:"text-[10px] text-ink/70 leading-relaxed",children:"Free models are switched off for this account, so calls to them are refused whatever the percentage says. Turn them back on in the Token Harbor dashboard, under Data and privacy."})}),!l&&e("p",{className:"text-[10px] text-ink/60 leading-relaxed",children:"The 7-day window starts with this account's first request. Both allowances reset together."})]})]})}function W({report:t}){let r=t.balance;if(!r)return e("p",{className:"text-[11px] text-ink/60",children:"TokenPortal returned no balance for this key. Refresh to try again."});let i=r.limit!==null&&r.limitRemaining!==null?Math.max(0,r.limit-r.limitRemaining):null,l=r.limit!==null&&i!==null&&r.limit>0?Math.min(100,i/r.limit*100):null;return e(d,{children:[e("div",{className:"@container",children:e("div",{className:"grid grid-cols-2 @[540px]:grid-cols-4 gap-2.5 items-stretch",children:[e(Qe,{value:h(r.balance,r.currency),label:"Credit balance",hint:r.label?`Key ${r.label}`:`Left on this key, in ${r.currency}`}),e(Qe,{value:r.limit===null?"No cap":h(r.limit,r.currency),label:"Key limit",hint:r.limit===null?"Spending is not capped on this key":i!==null?`${h(i,r.currency)} spent`:"Cap set by the operator",tone:r.limit===null?"muted":"default"}),e(Qe,{value:r.sessionBudget===null?"Not set":h(r.sessionBudget,r.currency),label:"Session budget",hint:r.sessionBudget===null?"No per-session cap":"Applies to one gateway session",tone:"muted"}),e(Qe,{value:r.isFreeTier?"Free":"Paid",label:"Tier",hint:r.isFreeTier?"Free-tier limits apply":"No free-tier limit on this key",tone:"muted"})]})}),l!==null&&i!==null&&e("div",{className:"space-y-1.5",children:[e("div",{className:"flex items-baseline justify-between gap-2",children:[e("span",{className:"text-[11px] font-semibold text-ink",children:"Key limit used"}),e("span",{className:"text-[10px] text-ink/60",children:[h(i,r.currency)," of ",h(r.limit??0,r.currency)]})]}),e("div",{className:"h-1.5 w-full bg-ink/10 rounded-full overflow-hidden",role:"progressbar","aria-label":"Key limit used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(l),children:e("div",{className:`h-full rounded-full ${r.limitRemaining!==null&&r.limitRemaining<=0?"bg-error/70":"bg-ink/80"}`,style:{width:`${l}%`}})}),r.limitRemaining!==null&&e("p",{className:"text-[10px] text-ink/50",children:[h(r.limitRemaining,r.currency)," left under the cap"]})]}),e("p",{className:"text-[10px] text-ink/50 leading-relaxed",children:["Balance and caps come from TokenPortal’s ",e("span",{className:"font-mono",children:"/v1/key"})," endpoint in"," ",r.currency,"; top-ups and transaction history live in its console."]})]})}function q(t){return t.trim().toLowerCase().replace(/[-_\s]/g,"").includes("antigravity")}var ae="anthropic:extra",O="Quota windows";function R(t,r,i,l){let p=t.find((c)=>c.id===r);if(p){p.limits.push(l);return}t.push({id:r,title:i,limits:[l]})}function re(t){let r=(t.split(":")[1]??"").toLowerCase();if(r==="google")return{id:"google",title:"Google"};if(r==="anthropic"||r==="openai")return{id:"third-party",title:"Claude & GPT (shared)"};if(r==="default"||r==="")return{id:"default",title:"Usage"};return{id:r,title:r}}function se(t){let r=[];for(let i of t)if(i.id===ae)R(r,"balance","Balance",i);else R(r,"windows",O,i);return r}function ie(t){let r=[];for(let i of t){let l=re(i.id);if(l.id==="third-party"){if(r.find((c)=>c.id==="third-party")?.limits.some((c)=>oe(c,i)))continue}R(r,l.id,l.title,i)}return r}function oe(t,r){return t.unit===r.unit&&t.label===r.label&&t.usedFraction===r.usedFraction&&t.remaining===r.remaining&&t.resetsAt===r.resetsAt}function Q(t,r){if(r.length===0)return[];let i=t.trim().toLowerCase();if(i==="anthropic")return se(r);if(q(i))return ie(r);return[{id:"all",title:O,limits:[...r]}]}function le({limit:t}){let r=Math.min(100,Math.max(0,(t.usedFraction??0)*100)),i=t.modelId??t.accountId,l=t.used!==void 0?y(t.used,t.unit):void 0,p=t.limit!==void 0?y(t.limit,t.unit):void 0,c=t.remaining!==void 0?y(t.remaining,t.unit):void 0;return e("div",{className:"bg-paper border border-ink/15 rounded-lg p-3 shadow-xs space-y-2",children:[e("div",{className:"flex items-start justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-[11px] font-semibold text-ink truncate",children:[t.label,t.windowLabel&&e("span",{className:"ml-1.5 rounded border border-ink/15 px-1 py-px font-mono text-[9px] font-normal text-ink/50",children:t.windowLabel})]}),i&&e("div",{className:"text-[10px] text-ink/50 truncate",children:i})]}),e("span",{className:"text-[10px] text-ink/50 flex-shrink-0 whitespace-nowrap",children:t.resetsAt!==void 0?`Resets ${Ca(new Date(t.resetsAt).toISOString())}`:""})]}),e("div",{className:"h-1.5 w-full bg-ink/10 rounded-full overflow-hidden",children:e("div",{className:`h-full rounded-full ${t.status==="exhausted"?"bg-error/70":"bg-ink/80"}`,style:{width:`${r}%`}})}),e("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-0.5 text-[10px] text-ink/60",children:[e("span",{children:["Used"," ",e("span",{className:"font-semibold text-ink",children:t.unit==="percent"||!l?L(t.usedFraction??0):l}),t.unit!=="percent"&&l&&p?` of ${p}`:""]}),e("span",{className:"flex items-center gap-2",children:[t.status!=="ok"&&t.status!=="unknown"&&e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70",children:t.status}),c&&e("span",{children:["Remaining ",e("span",{className:"font-semibold text-ink",children:c})]})]})]}),t.notes&&t.notes.length>0&&e("ul",{className:"text-[10px] text-ink/50 leading-relaxed space-y-0.5",children:t.notes.map((m)=>e("li",{children:m},m))})]})}function j({providerId:t,limits:r,tracked:i,unavailable:l,emptyReason:p,notes:c}){let m=Q(t,r);return e("div",{className:"space-y-2",children:[c&&c.length>0&&e("ul",{className:"text-[10px] text-ink/50 leading-relaxed space-y-0.5",children:c.map((f)=>e("li",{children:f},f))}),m.length===0?e(d,{children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:"Quota windows"}),e("p",{className:"text-[11px] text-ink/50",children:p??(!i?"No quota source for this provider: omp ships no usage adapter for it and it exposes no balance endpoint Kabmo knows.":l?"omp tracks this provider but its usage endpoint returned no data — an invalid or expired credential, an unreachable endpoint, or a plan without quota windows.":"No quota windows were reported for this provider.")})]}):m.map((f)=>e("div",{className:"@container space-y-2",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:f.title}),e("div",{className:"grid grid-cols-1 @[520px]:grid-cols-2 gap-2.5",children:f.limits.map((u)=>e(le,{limit:u},u.id))})]},f.id))]})}var de="DeepSeek exposes no usage or quota API — only the prepaid balance (and the web console at platform.deepseek.com) is available.",pe="Token Harbor reports percentages, never a dollar remainder. Request history and per-request cost are on its usage dashboard.",ce="omp tracks Command Code, but its usage read needs an API key created in Studio — the signed-in OAuth credential cannot read its billing endpoint. Add an API key in Settings → Providers to see the 5-hour, weekly and credit windows.";function yd({summary:t}){let r=Boolean(t.kenari||t.deepseek||t.tokenHarbor||t.tokenPortal),i=t.tokenHarbor?pe:t.deepseek?de:void 0;return e(S,{providerName:t.name,providerSlug:t.id,iconUrl:t.iconUrl,credentialSources:t.credentialSources,error:t.error,note:i,children:[t.kenari&&e(M,{report:t.kenari}),t.deepseek&&e(K,{report:t.deepseek}),t.tokenHarbor&&e(H,{report:t.tokenHarbor}),t.tokenPortal&&e(W,{report:t.tokenPortal}),!r&&(t.limits.length>0||!t.error)&&e(j,{providerId:t.id,limits:t.limits,tracked:t.tracked,unavailable:t.limitsUnavailable,...t.id==="commandcode"&&t.limitsUnavailable?{emptyReason:ce}:{},notes:t.notes})]})}function me(t){let r=t.filter((p)=>p.usedFraction!==void 0);if(r.length===0){let p=t.find((c)=>(c.unit==="usd"||c.unit==="idr")&&c.remaining!==void 0);if(p)return`${h(p.remaining??0,p.unit==="idr"?"IDR":"USD")} left`;return t[0]?.label}let i=r.reduce((p,c)=>(c.usedFraction??0)>(p.usedFraction??0)?c:p),l=Math.round((i.usedFraction??0)*100);return i.windowLabel?`${l}% · ${i.windowLabel}`:`${l}% used`}function Dh(t){if(t.error)return!0;if(t.limits.length>0)return!0;return Boolean(t.kenari?.balance||t.kenari?.usage||t.kenari?.quota||t.deepseek?.balance||t.tokenHarbor?.allowance||t.tokenPortal?.balance)}function yl(t){return t.providers.map((r)=>({id:r.id,name:r.name,...r.iconUrl?{iconUrl:r.iconUrl}:{},error:r.error,hint:ue(r),limits:r.limits,tracked:r.tracked,limitsUnavailable:r.limitsUnavailable,summary:r}))}function ue(t){let r=t.kenari?.quota?.planName;if(r)return r;let i=t.tokenPortal?.balance;if(i)return h(i.balance,i.currency);let l=t.deepseek?.balance?.entries[0];if(l)return`${l.currency} ${w(l.totalBalance)}`;let p=t.tokenHarbor?.allowance;if(p){if(!p.activated)return`${p.planName??"Free"} · not started`;if(p.onPlan)return`${p.planName??"Pass"} · ${p.planUsedPct??0}% · 7d`;return`${p.usedPct??0}% free · 7d`}if(t.id==="commandcode"&&t.limitsUnavailable)return"API key needed";return me(t.limits)??"No quota reported"}function Nh(t){return t.error?"Error":"Connected"}function G(){let[t,r]=n([]),[i,l]=n(null),[p,c]=n(!0),m=a(()=>{c(!0),fetch("/api/settings/usage/reset").then((u)=>u.json()).then((u)=>{r(Array.isArray(u.accounts)?u.accounts:[]),l(typeof u.error==="string"?u.error:null)}).catch((u)=>{r([]),l(u instanceof Error?u.message:"Failed to load saved resets")}).finally(()=>c(!1))},[]);o(()=>{m()},[m]);let f=a(async(u)=>{try{let N=await(await fetch("/api/settings/usage/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:u})})).json();if(N.ok)m();return{ok:Boolean(N.ok),message:N.message||"No result reported."}}catch(g){return{ok:!1,message:g instanceof Error?g.message:"Failed to spend the saved reset"}}},[m]);return{accounts:t,error:i,isLoading:p,reload:m,spend:f}}function fe({account:t,onSpend:r,spending:i}){let l=`${t.provider}/${t.credentialId}`,p=t.email??t.accountId??t.credentialId,c=t.orgName??t.orgId,m=t.availableCount??t.credits.length,f=t.redeemableCount??0,u=t.error??t.unavailableReason;return e("div",{className:"bg-paper border border-ink/15 rounded-lg p-3 shadow-xs space-y-2",children:[e("div",{className:"flex items-start justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-[11px] font-semibold text-ink truncate",children:[p,c?e("span",{className:"text-ink/50 font-normal",children:[" · ",c]}):null]}),e("div",{className:"text-[10px] text-ink/50 font-mono truncate",children:l})]}),e("span",{className:"text-[10px] text-ink/60 flex-shrink-0 whitespace-nowrap",children:f>0?`${f} of ${m} usable`:`${m} saved`})]}),t.soonestExpiry!==void 0&&e("div",{className:"text-[10px] text-ink/60",children:["Soonest expires ",Ca(new Date(t.soonestExpiry).toISOString())]}),t.credits.length>0&&e("div",{className:"space-y-1",children:t.credits.map((g)=>e("div",{className:"flex items-center justify-between gap-2 text-[10px] text-ink/70",children:[e("span",{className:"truncate",children:g.title??g.program??g.id}),e("span",{className:"flex items-center gap-1.5 flex-shrink-0",children:[g.clears&&g.clears.length>0&&e("span",{className:"font-mono text-ink/50",children:g.clears.join(", ")}),g.usable===!1&&e("span",{className:"font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/60",children:"blocked"})]})]},g.id))}),u&&e("div",{className:"text-[10px] text-ink/60 leading-snug",children:u}),e("button",{type:"button",onClick:()=>r(l),disabled:i||f===0,title:f===0?u??"Nothing to spend on this account right now.":`Spend a saved reset on ${l}`,className:"w-full rounded-md border border-ink/15 px-2 py-1 text-[11px] font-medium text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:i?"Spending…":"Spend saved reset"})]})}function vd(){let{accounts:t,error:r,isLoading:i,reload:l,spend:p}=G(),[c,m]=n(null),[f,u]=n(null),g=(k)=>{m(k),u(null),p(k).then((z)=>{u(z),m(null)})},N=!i&&!r&&t.length===0;return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-[11px] font-semibold text-ink",children:"Saved rate-limit resets"}),e("div",{className:"text-[10px] text-ink/50 leading-snug",children:"Provider-issued resets for Codex and Claude accounts. Spending one clears the window it covers."})]}),e("button",{type:"button",onClick:l,disabled:i,title:"Re-read saved resets",className:"p-1.5 bg-paper border border-ink/15 rounded-md hover:bg-ink/5 text-ink/80 transition-colors disabled:opacity-50 flex-shrink-0",children:e(D,{size:12,className:i?"animate-spin text-ink":""})})]}),r&&e("div",{className:"flex items-start gap-1.5 text-[10px] text-error-text leading-snug",children:[e(B,{size:12,className:"flex-shrink-0 mt-px"}),e("span",{children:r})]}),t.map((k)=>e(fe,{account:k,onSpend:g,spending:c===`${k.provider}/${k.credentialId}`},`${k.provider}/${k.credentialId}`)),N&&e("p",{className:"text-[10px] text-ink/50 leading-snug",children:"No saved resets on any account."}),f&&e("div",{className:`text-[10px] leading-snug ${f.ok?"text-ink/70":"text-error-text"}`,children:f.message})]})}function xd(){let[t,r]=n(null),[i,l]=n(!0),[p,c]=n(null),m=a(async(f)=>{if(!f?.silent)l(!0);c(null);try{let u=f?.force?"/api/settings/usage?refresh=1":"/api/settings/usage",g=await fetch(u);if(!g.ok)throw Error(`Usage request failed (${g.status})`);let N=await g.json();r(N)}catch(u){c(u instanceof Error?u.message:"Failed to load provider usage")}finally{if(!f?.silent)l(!1)}},[]);return o(()=>{m()},[m]),{report:t,isLoading:i,error:p,reload:m}}
|
|
2
|
+
export{Ca,yd,Dh,yl,Nh,vd,xd};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,n,o,i,Oo,a,vl,e,k,us,Uo,Pe,me,S,vr,kr,s,p,ua,f,Oa,Le,Bt,Mc,Tt,Jm,Vt,Br,pf,zc,Uc}from"./index-4vtc4xct.js";import{yl,Rr}from"./index-sr14vwn5.js";function oe(){if(typeof crypto<"u"&&typeof crypto.randomUUID==="function")return crypto.randomUUID();return`t-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function ie(t){return JSON.stringify(t)}function pe(t){let r=st(t);if(!k(r))return null;if(r.t==="ready"){if(typeof r.id!=="string"||typeof r.cwd!=="string")return null;let l=typeof r.replayBytes==="number"?r.replayBytes:0;return{...r,t:"ready",replayBytes:l}}if(r.t==="exit")return{t:"exit",exitCode:typeof r.exitCode==="number"?r.exitCode:null,signal:typeof r.signal==="string"?r.signal:null};if(r.t==="error"&&typeof r.message==="string")return{t:"error",code:at(r.code),message:r.message};return null}function fe(t){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/terminal/${encodeURIComponent(t)}/ws`}function at(t){return t==="capacity"||t==="cwd"||t==="shell"||t==="spawn"?t:"unknown"}function st(t){try{return JSON.parse(t)}catch{return null}}function be(t){if(t.buffer instanceof ArrayBuffer)return t;return new Uint8Array(t)}var lt=500,ct=8000,ut=4;function he(t,r){let l=null,c=null,u=0,b=!1,m=!1,h=!1,w=null,R=[],M=0,E=null,O=()=>{let y=new WebSocket(fe(t));y.binaryType="arraybuffer",l=y,y.onopen=()=>{if(m)return;if(u=0,b=!0,r.onConnectionChange(!0),w)y.send(ie(w))},y.onmessage=(x)=>{if(m)return;if(x.data instanceof ArrayBuffer){v(new Uint8Array(x.data));return}if(typeof x.data!=="string")return;let D=pe(x.data);if(D)A(D)},y.onclose=()=>{if(l=null,m)return;if(r.onConnectionChange(!1),h=!1,R=[],M=0,E=null,!b)return;if(u+=1,u>ut)return;let x=Math.min(lt*2**(u-1),ct);c=setTimeout(()=>{if(c=null,!m)O()},x)},y.onerror=()=>{}},A=(y)=>{if(y.t==="ready"){if(h=!0,E=y,M=y.replayBytes,R=[],r.onReady(y),M===0)P();return}if(y.t==="exit"){r.onExit(y.exitCode,y.signal);return}r.onError(y.code,y.message)},v=(y)=>{if(M<=0){r.onOutput(y);return}if(R.push(y),M-=y.length,M>0)return;P()},P=()=>{let y=E,x=R;if(E=null,R=[],M=0,!y)return;r.onReplay(x.length===1?x[0]:mt(x),y)};O();let F=(y)=>{let x=l;if(!x||x.readyState!==WebSocket.OPEN)return;x.send(ie(y))};return{attach(y,x,D,L,T){if(h)return;let g={t:"attach",cols:y,rows:x};if(D)g.root=D;if(L)g.repo=L;if(T)g.theme=T;w=g,F(g)},resize(y,x){F({t:"resize",cols:y,rows:x})},input(y){let x=l;if(!x||x.readyState!==WebSocket.OPEN)return;x.send(be(y))},close(){F({t:"close"})},release(){if(m=!0,c!==null)clearTimeout(c),c=null;let y=l;if(l=null,!y)return;y.onopen=null,y.onmessage=null,y.onclose=null,y.onerror=null,y.close()}}}function mt(t){let r=0;for(let u of t)r+=u.length;let l=new Uint8Array(r),c=0;for(let u of t)l.set(u,c),c+=u.length;return l}function ye(t){return{connect:t.visible||t.opened,persist:t.ready&&t.visible&&!t.opened}}function ge(t={}){let{sessionId:r,ready:l}=Pe(),[c,u]=S("terminal.id",""),[b,m]=S("terminal.opened",!1),h=ye({visible:t.visible===!0,ready:l,opened:b}),[w,R]=n("connecting"),[M,E]=n(""),[O,A]=n(null),[v,P]=n(null),[F,y]=n(0),x=i(null),D=i(null),L=i(t.onOutput);L.current=t.onOutput;let T=i(t.onReplay);T.current=t.onReplay;let g=i(t.onRestart);g.current=t.onRestart;let I=i(t.root);I.current=t.root;let B=i(t.repo);B.current=t.repo;let X=i(t.theme);X.current=t.theme;let G=i(u);G.current=u;let H=i(null);o(()=>{if(!h.persist)return;m(!0)},[h.persist]),o(()=>{if(!h.connect||!l)return;if(me(r,"terminal.id"))return;G.current(oe())},[h.connect,l,r]),o(()=>{if(!h.connect||!l||!c)return;R("connecting"),P(null),A(null);let N=he(c,{onReady(U){R("running"),E(U.shell),A(null)},onReplay(U,W){T.current?.(U,W)},onOutput(U){L.current?.(U)},onExit(U){R("exited"),A(U)},onError(U,W){R("error"),P(`${U}: ${W}`)},onConnectionChange(U){if(!U)R("connecting")}});x.current=N;let K=D.current;if(K)N.attach(K.cols,K.rows,I.current,B.current,X.current);return()=>{N.release(),x.current=null}},[h.connect,l,c,F]);let Y=a(()=>{x.current?.close(),g.current?.(),G.current(oe())},[]);o(()=>{if(!l)return;let N=t.root;if(!N)return;let K=`${N}\x00${t.repo??"."}`;if(H.current===null){H.current=K;return}if(H.current===K)return;H.current=K,Y()},[l,t.root,t.repo,Y]);let q=a((N,K)=>{D.current={cols:N,rows:K},x.current?.attach(N,K,I.current,B.current,X.current)},[]),J=a((N,K)=>{D.current={cols:N,rows:K},x.current?.resize(N,K)},[]),j=a((N)=>{x.current?.input(N)},[]),ne=a(()=>{y((N)=>N+1)},[]);return{status:w,shell:M,exitCode:O,error:v,attach:q,resize:J,input:j,restart:Y,reattach:ne}}var dt={name:"clipboard-copy",size:24,node:[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]},Te=s(dt);var pt={name:"zap",size:24,node:[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]},xe=s(pt);var ft={connecting:"CONNECTING",running:"LIVE",exited:"EXITED",error:"ERROR"},bt={connecting:"bg-warning/10 text-warning-text border-warning/20",running:"bg-success/10 text-success-text border-success/20",exited:"bg-ink/5 text-ink/60 border-ink/15",error:"bg-error/10 text-error-text border-error/20"};function we({status:t,exitCode:r,rootPath:l,activeRepo:c,onSelectRepo:u,repos:b,reposScanning:m,onRefreshRepos:h,shell:w,onRestart:R,tabsMode:M=!1}){let E=w?w.split("/").pop():"";return e(Bt,{left:e(d,{children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Le,{size:14,className:"text-ink/80 flex-shrink-0"}),M?null:e("span",{className:"text-xs font-semibold tracking-wider text-ink uppercase",children:"Terminal"})]}),e("span",{className:`inline-flex items-center space-x-1 px-1.5 py-0.5 rounded text-[10px] font-mono border ${bt[t]}`,title:t==="exited"&&r!==null?`Shell exited with code ${r}`:void 0,children:[t==="connecting"&&e(p,{size:10,className:"animate-spin"}),e("span",{children:t==="exited"&&r!==null?`EXIT ${r}`:ft[t]})]}),e(Rr,{rootPath:l,activeRepo:c,onSelectRepo:u,repos:b,scanning:m,onRefreshRepos:h}),e(Mc,{label:"Kill this shell and start a new one",onClick:R,children:e(Oa,{size:14})})]}),right:E?e("span",{className:"hidden sm:block text-[10px] font-mono text-ink/40 flex-shrink-0",children:E}):void 0})}var ht=[{label:"bun build",cmd:"bun run build"},{label:"bun test",cmd:"bun test"},{label:"git status",cmd:"git status -s"},{label:"git diff",cmd:"git diff"},{label:"ls -la",cmd:"ls -la"},{label:"pwd",cmd:"pwd"},{label:"bun -v",cmd:"bun --version"}];function ve({onSelectCommand:t,disabled:r}){return e("div",{className:"flex flex-wrap items-center gap-1.5 px-3 py-1.5 bg-paper border-b border-ink/10 flex-shrink-0",children:[e("div",{className:"flex items-center space-x-1 text-[10px] font-mono text-ink/50 uppercase tracking-wider flex-shrink-0 select-none",children:[e(xe,{size:11,className:"text-warning-text"}),e("span",{children:"Quick:"})]}),ht.map((l)=>e("button",{type:"button",disabled:r,onClick:()=>t(l.cmd),className:"px-2 py-0.5 rounded text-[10px] font-mono bg-canvas hover:bg-ink/5 active:bg-ink/10 text-ink/80 hover:text-ink border border-ink/15 transition-all whitespace-nowrap disabled:opacity-40 cursor-pointer shadow-2xs",children:l.label},l.cmd))]})}var V=Object.freeze({ctrl:!1,alt:!1}),ae=[{id:"escape",label:"Esc",name:"Escape",sequence:"\x1B"},{id:"tab",label:"Tab",name:"Tab",sequence:"\t"},{id:"interrupt",label:"^C",name:"Ctrl+C — interrupt",sequence:"\x03"},{id:"left",label:"←",name:"Left arrow",csi:{prefix:"1",final:"D",application:"OD"}},{id:"up",label:"↑",name:"Up arrow",csi:{prefix:"1",final:"A",application:"OA"}},{id:"down",label:"↓",name:"Down arrow",csi:{prefix:"1",final:"B",application:"OB"}},{id:"right",label:"→",name:"Right arrow",csi:{prefix:"1",final:"C",application:"OC"}},{id:"home",label:"Home",name:"Home",csi:{prefix:"1",final:"H",application:"OH",terminfo:"\x1BOH"}},{id:"end",label:"End",name:"End",csi:{prefix:"1",final:"F",application:"OF",terminfo:"\x1BOF"}},{id:"pageUp",label:"PgUp",name:"Page up",csi:{prefix:"5",final:"~"}},{id:"pageDown",label:"PgDn",name:"Page down",csi:{prefix:"6",final:"~"}},{id:"delete",label:"Del",name:"Delete",csi:{prefix:"3",final:"~"}},{id:"shiftTab",label:"⇧Tab",name:"Shift+Tab",sequence:"\x1B[Z"},{id:"eof",label:"^D",name:"Ctrl+D — end of input",sequence:"\x04"},{id:"clear",label:"^L",name:"Ctrl+L — clear screen",sequence:"\f"}],se=[{id:"pipe",label:"|",name:"Pipe",sequence:"|"},{id:"tilde",label:"~",name:"Tilde",sequence:"~"},{id:"dollar",label:"$",name:"Dollar",sequence:"$"},{id:"asterisk",label:"*",name:"Asterisk",sequence:"*"},{id:"question",label:"?",name:"Question mark",sequence:"?"},{id:"underscore",label:"_",name:"Underscore",sequence:"_"},{id:"backslash",label:"\\",name:"Backslash",sequence:"\\"},{id:"slash",label:"/",name:"Slash",sequence:"/"},{id:"minus",label:"-",name:"Minus",sequence:"-"},{id:"equals",label:"=",name:"Equals",sequence:"="},{id:"plus",label:"+",name:"Plus",sequence:"+"},{id:"ampersand",label:"&",name:"Ampersand",sequence:"&"},{id:"semicolon",label:";",name:"Semicolon",sequence:";"},{id:"colon",label:":",name:"Colon",sequence:":"},{id:"comma",label:",",name:"Comma",sequence:","},{id:"dot",label:".",name:"Period",sequence:"."},{id:"at",label:"@",name:"At sign",sequence:"@"},{id:"percent",label:"%",name:"Percent",sequence:"%"},{id:"caret",label:"^",name:"Caret",sequence:"^"},{id:"hash",label:"#",name:"Hash",sequence:"#"},{id:"bang",label:"!",name:"Exclamation mark",sequence:"!"},{id:"parenOpen",label:"(",name:"Open parenthesis",sequence:"("},{id:"parenClose",label:")",name:"Close parenthesis",sequence:")"},{id:"bracketOpen",label:"[",name:"Open bracket",sequence:"["},{id:"bracketClose",label:"]",name:"Close bracket",sequence:"]"},{id:"braceOpen",label:"{",name:"Open brace",sequence:"{"},{id:"braceClose",label:"}",name:"Close brace",sequence:"}"},{id:"lessThan",label:"<",name:"Less than",sequence:"<"},{id:"greaterThan",label:">",name:"Greater than",sequence:">"},{id:"quote",label:"'",name:"Single quote",sequence:"'"},{id:"doubleQuote",label:'"',name:"Double quote",sequence:'"'},{id:"backtick",label:"`",name:"Backtick",sequence:"`"}],Se={};for(let t of[...ae,...se])Se[t.id]=t;function Ce(t,r={}){let l=Se[t];if(!l)return"";let c=r.modifiers??V;if(l.csi)return yt(l.csi,c,r.applicationCursorKeys??!1);let u=l.sequence??"";return c.alt?`\x1B${u}`:u}function yt(t,r,l){let c=gt(r);if(c!==null)return`\x1B[${t.prefix};${c}${t.final}`;if(t.terminfo)return t.terminfo;if(l&&t.application)return`\x1B${t.application}`;return`\x1B[${t.prefix==="1"?"":t.prefix}${t.final}`}function gt(t){let r=(t.alt?2:0)|(t.ctrl?4:0);return r===0?null:r+1}function Re(t,r){if(t.length!==1)return t;let l=t;if(r.ctrl)l=wt(l)??l;if(r.alt)l=`\x1B${l}`;return l}var xt={"@":"\x00"," ":"\x00","":"\b","[":"\x1B","\\":"\x1C","]":"\x1D","^":"\x1E",_:"\x1F","?":""};function wt(t){if(t.length!==1)return null;let r=t.charCodeAt(0);if(r>=97&&r<=122)return String.fromCharCode(r-96);if(r>=65&&r<=90)return String.fromCharCode(r-64);return xt[t]??null}var vt=[{modifier:"ctrl",label:"Ctrl",name:"Ctrl — applies to the next key"},{modifier:"alt",label:"Alt",name:"Alt / meta — applies to the next key"}],Q="flex items-center justify-center h-8 min-w-8 px-1.5 rounded border font-mono transition-colors cursor-pointer select-none disabled:opacity-40 disabled:cursor-default text-[11px] @[420px]:h-9 @[420px]:min-w-10 @[420px]:text-xs",Z="bg-canvas text-ink/80 border-ink/15 hover:text-ink hover:bg-ink/5 active:bg-ink/10",ke="bg-ink text-canvas border-ink";function Ee({modifiers:t,onToggleModifier:r,onKey:l,onCopy:c,onPaste:u,disabled:b}){let[m,h]=n(!1),[w,R]=n(null),M=t.ctrl||t.alt,E=(v)=>{R(v),setTimeout(()=>R((P)=>P===v?null:P),1500)},O=async()=>{E(await c()?"copied":"empty")},A=async()=>{if(!await u())E("pasteFailed")};return e("div",{className:"@container flex flex-col gap-1 px-2 py-1.5 border-t border-ink/10 bg-paper flex-shrink-0",onPointerDown:(v)=>v.preventDefault(),children:[e("div",{className:"flex flex-wrap items-center gap-1",children:[vt.map(({modifier:v,label:P,name:F})=>e("button",{type:"button",onClick:()=>r(v),"aria-pressed":t[v],title:F,"aria-label":F,className:`${Q} ${t[v]?ke:Z}`,children:P},v)),M&&e("span",{className:"text-[10px] font-mono text-ink/50 px-0.5 whitespace-nowrap","aria-hidden":!0,children:"next"}),e("span",{className:"w-px h-5 bg-ink/15 flex-shrink-0","aria-hidden":!0}),e("button",{type:"button",onClick:O,disabled:b,title:w==="empty"?"Nothing selected":"Copy selection","aria-label":"Copy selection",className:`${Q} ${w==="empty"?"bg-warning/10 text-warning-text border-warning/30":Z}`,children:[w==="copied"?e(f,{size:13}):e(Te,{size:13}),e("span",{className:"pl-1",children:"Copy"})]}),e("button",{type:"button",onClick:A,disabled:b,title:w==="pasteFailed"?"Clipboard unavailable":"Paste into the shell","aria-label":"Paste into the shell",className:`${Q} ${w==="pasteFailed"?"bg-error/10 text-error-text border-error/30":Z}`,children:[e(yl,{size:13}),e("span",{className:"pl-1",children:"Paste"})]}),e("button",{type:"button",onClick:()=>h((v)=>!v),"aria-pressed":m,title:m?"Show control keys":"Show symbols","aria-label":m?"Show control keys":"Show symbols",className:`${Q} ml-auto ${m?ke:Z}`,children:m?"ABC":"123"})]}),e("div",{className:"flex flex-wrap items-center gap-1",children:(m?se:ae).map((v)=>e("button",{type:"button",disabled:b,onClick:()=>l(v.id),title:v.name,"aria-label":v.name,className:`${Q} ${Z}`,children:v.label},v.id))})]})}function Me(t){if(!t.startsWith("\x1B[M")||t.length<6)return{text:t};let r=new Uint8Array(t.length);for(let l=0;l<t.length;l+=1)r[l]=t.charCodeAt(l)&255;return{bytes:r}}function Ae(t){let r=Vt(t),{canvas:l,ink:c,paper:u}=r,b=(h)=>Br(h,c,0.2),m=(h)=>Br(l,c,h);return{background:"transparent",foreground:c,cursor:r.meta,cursorAccent:u,selectionBackground:m(0.28),selectionForeground:c,black:m(0.2),red:r.error,green:r.success,yellow:r.warning,blue:r.info,magenta:r.meta,cyan:Br(r.info,r.success,0.5),white:m(0.75),brightBlack:m(0.5),brightRed:b(r.error),brightGreen:b(r.success),brightYellow:b(r.warning),brightBlue:b(r.info),brightMagenta:b(r.meta),brightCyan:b(Br(r.info,r.success,0.5)),brightWhite:m(0.92)}}var ee="Fira Code",St="'FiraCode Nerd Font Mono', 'FiraCode Nerd Font', 'JetBrainsMono Nerd Font', 'JetBrainsMono NF', 'JetBrains Mono Nerd Font', 'Hack Nerd Font', 'MesloLGS NF', 'MesloLGM Nerd Font', 'CaskaydiaCove Nerd Font', 'SauceCodePro Nerd Font', 'Symbols Nerd Font Mono', 'Symbols Nerd Font', 'PowerlineSymbols'",Fe="Kabmo Nerd Symbols",Ie=[ee,Fe],te=`'${ee}', ${St}, '${Fe}', Menlo, Monaco, 'Courier New', monospace`,z=12,Ct=16,Rt=1e4;function kt(t,r){return Math.max(1,t)*Math.max(1,r)*Ct}var Ne=kt(Rt,100);var Et=2000;async function Oe(){if(typeof document>"u"||!document.fonts?.load)return;let t=Promise.withResolvers(),r=setTimeout(t.resolve,Et);try{await Promise.race([document.fonts.load(`${z}px "${ee}"`).then(()=>{return},()=>{return}),t.promise])}finally{clearTimeout(r)}}function De(t){if(typeof document>"u"||!document.fonts)return()=>{};let r=new Set(Ie),l=(c)=>{if([...c.fontfaces].some((b)=>r.has(b.family.replace(/['"]/g,"").trim())))t()};return document.fonts.addEventListener("loadingdone",l),()=>document.fonts.removeEventListener("loadingdone",l)}var _e=2.5,Mt=1;function At(t,r){let l=t*0.8,c=t*0.2,u=Math.ceil(t*0.6),b=l,m=c,h=typeof document>"u"?null:document.createElement("canvas").getContext("2d");if(h){h.font=`${t}px ${r}`,u=Math.ceil(h.measureText("M").width)||u;let w=h.measureText("Mg");b=w.actualBoundingBoxAscent||l,m=w.actualBoundingBoxDescent||c}return{width:u,height:Math.ceil(b+m+_e+Mt),baseline:Math.round(b+_e)}}function Be(t){let r=t.renderer;if(!r)return;r.measureFont=()=>At(t.options.fontSize??z,t.options.fontFamily??te),r.remeasureFont()}function Ke(t){let r=t.renderer;if(!r||!t.wasmTerm)return;r.setFontSize(t.options.fontSize??z),r.resize(t.cols,t.rows),r.render(t.wasmTerm,!0,t.viewportY,t)}function Ft(t){let{cols:r,rows:l,attached:c,committed:u}=t;if(r<10||l<5)return{kind:"ignore"};if(!c)return{kind:"attach",cols:r,rows:l};if(r===u.cols&&l===u.rows)return{kind:"ignore"};return{kind:"change",cols:r,rows:l}}function Ue(t){let r={cols:0,rows:0},l=!1,c,u=()=>{if(!t.fit())return;let b=t.current();if(!b)return;let m=Ft({cols:b.cols,rows:b.rows,attached:l,committed:r});if(m.kind==="ignore")return;if(r={cols:m.cols,rows:m.rows},m.kind==="attach"){l=!0,t.onReady(m.cols,m.rows);return}t.onGridChange(m.cols,m.rows)};return{schedule(){clearTimeout(c),c=setTimeout(u,120)},restate(){r={cols:0,rows:0}},isAttached:()=>l,dispose(){clearTimeout(c),c=void 0}}}function qe(t,r){if(r.type!=="keydown"||!r.shiftKey)return!1;if(r.key==="PageUp")return t.scrollPages(-1),!0;if(r.key==="PageDown")return t.scrollPages(1),!0;if(r.key==="Home")return t.scrollToTop(),!0;if(r.key==="End")return t.scrollToBottom(),!0;if(r.key==="ArrowUp")return t.scrollLines(-1),!0;if(r.key==="ArrowDown")return t.scrollLines(1),!0;return!1}function He(t,r){let l=0,c=(b)=>{if(b.touches.length===1)l=b.touches[0].clientY},u=(b)=>{if(b.touches.length!==1)return;let m=l-b.touches[0].clientY;if(Math.abs(m)<16)return;r()?.scrollLines(Math.trunc(m/16)),l=b.touches[0].clientY};return t.addEventListener("touchstart",c,{passive:!0}),t.addEventListener("touchmove",u,{passive:!0}),()=>{t.removeEventListener("touchstart",c),t.removeEventListener("touchmove",u)}}function Lt(t){if(t.viewportY<=0&&!t.hasSelection&&!t.pointerHeld)return null;return t.scrollback-t.viewportY}function It(t){let r=t.scrollback-t.top;return r>0?r:null}function $e(t){let r={pointerHeld:!1},l=()=>{r.pointerHeld=!0},c=()=>{r.pointerHeld=!1};return t.addEventListener("pointerdown",l,!0),globalThis.addEventListener("pointerup",c),globalThis.addEventListener("pointercancel",c),{get pointerHeld(){return r.pointerHeld},stop(){t.removeEventListener("pointerdown",l,!0),globalThis.removeEventListener("pointerup",c),globalThis.removeEventListener("pointercancel",c)}}}function Ge(t,r,l){let c=Lt({scrollback:t.getScrollbackLength(),viewportY:t.getViewportY(),hasSelection:t.hasSelection(),pointerHeld:r.pointerHeld});if(l(),c===null)return;let u=It({scrollback:t.getScrollbackLength(),top:c});if(u===null)return;let b=u-t.getViewportY();if(b===0)return;try{t.scrollLines(-b)}catch{}}function Ye(t,r){let l=(c)=>{let u=r();if(!u)return;if(c.preventDefault(),c.clipboardData)c.clipboardData.setData("text/plain",u);else Tt(u)};return t.addEventListener("copy",l),()=>t.removeEventListener("copy",l)}function ze(t,r){let l=(c)=>{if(!c.ctrlKey||!c.shiftKey||c.altKey)return;if(c.code==="KeyC"){let u=r.getSelection();if(!u)return;c.preventDefault(),c.stopImmediatePropagation(),Tt(u);return}if(c.code==="KeyV")c.preventDefault(),c.stopImmediatePropagation(),Jm().then((u)=>{if(u)r.paste(u)})};return t.addEventListener("keydown",l,!0),()=>t.removeEventListener("keydown",l,!0)}function Xe(t){if(us()&&t.textarea)t.textarea.focus();else t.focus()}function We(t){if(us())t.textarea?.focus()}function Ve(t,r){let l=(c)=>{if(c.target!==t||!us())return;r.textarea?.focus()};return t.addEventListener("focusin",l),()=>t.removeEventListener("focusin",l)}function Nt(t,r,l){if(!l.width||!l.height)return null;return{cols:Math.max(2,Math.floor(t/l.width)),rows:Math.max(1,Math.floor(r/l.height))}}function Qe(t,r){let l=t;l.proposeDimensions=()=>{let c=r.element,u=r.renderer?.getMetrics();if(!c||!u)return;let b=getComputedStyle(c),m=(parseFloat(b.paddingLeft)||0)+(parseFloat(b.paddingRight)||0),h=(parseFloat(b.paddingTop)||0)+(parseFloat(b.paddingBottom)||0);return Nt(c.clientWidth-m,c.clientHeight-h,u)??void 0}}function le(t,r,l,c,u){let b=new t.Terminal({cursorBlink:!0,cursorStyle:"block",fontSize:z,fontFamily:te,theme:Ae(c),scrollback:Ne,smoothScrollDuration:0,ghostty:r});if(b.open(l),Be(b),b.clear(),l.clientWidth>0)We(b);let m=new t.FitAddon;b.loadAddon(m),Qe(m,b);let h={term:b,fitAddon:m,disposables:[]};return u(h),h}function ce(t){if(!t)return;for(let r of t.disposables)try{r.dispose()}catch{}try{t.fitAddon.dispose()}catch{}try{t.term.dispose()}catch{}}async function Ze(t,r,l,c){let u=await import("./ghostty-web-22pdvhta.js"),[b]=await Promise.all([u.Ghostty.load(),Oe()]);if(c())return null;let m=r,h=null,w=!1,R,M=null,E=!1,O=(T)=>{let{term:g}=T;g.attachCustomKeyEventHandler((I)=>qe(g,I)),T.disposables.push({dispose:Ye(t,()=>g.getSelection())},{dispose:ze(t,{getSelection:()=>g.getSelection(),paste:(I)=>g.paste(I)})},{dispose:Ve(t,g)},g.onScroll((I)=>l.onScrolledUpChange(I>0)),g.onData((I)=>{let B=Me(I);if(B.bytes)l.onBinaryInput(B.bytes);else l.onInput(B.text)}),g.onResize(()=>{if(w)return;F.schedule()}))},A=()=>{if(E)return!1;if(t.clientWidth<=0||t.clientHeight<=0)return!1;let T=h?.term.renderer?.getMetrics();if(!T?.width||!T.height)return!1;try{return h?.fitAddon.fit(),!0}catch{return!1}},v=()=>{if(E)return;w=!1,A(),F.restate(),F.schedule()},P=(T,g,I)=>{let B=h?.term;if(!B)return;if(w=!0,B.cols!==g||B.rows!==I)B.resize(g,I);if(T.length===0){requestAnimationFrame(v);return}B.write(T,v)},F=Ue({current:()=>h?.term,fit:A,onReady:l.onReady,onGridChange:l.onGridChange}),y=$e(t);h=le(u,b,t,m,O),A(),F.schedule();let x=new ResizeObserver(()=>{clearTimeout(R),R=setTimeout(()=>{A(),F.schedule()},35)});x.observe(t);let D=De(()=>{let T=h?.term;if(!T)return;Ke(T),A(),F.schedule()}),L=He(t,()=>h?.term??null);return M=requestAnimationFrame(()=>{A(),F.schedule()}),{write(T){let g=h?.term;if(!g)return;Ge(g,y,()=>g.write(T))},writeReplay:P,reset(){let T=h?.term;if(!T)return;T.reset(),T.clear(),A()},focus(){let T=h?.term;if(T)Xe(T)},applicationCursorKeys(){return h?.term.wasmTerm?.getMode(1,!1)??!1},getSelection(){return h?.term.getSelection()??""},paste(T){h?.term.paste(T)},scrollToBottom(){h?.term.scrollToBottom()},setTheme(T){if(E||T===m)return;m=T,ce(h),h=le(u,b,t,T,O),A()},dispose(){if(E=!0,M!==null)cancelAnimationFrame(M);clearTimeout(R),F.dispose(),D(),L(),y.stop(),x.disconnect(),ce(h),h=null}}}function Je(){let t=null,r=!1;return{request(){if(t)t();else r=!0},attach(l){if(t=l,!r)return;r=!1,l()},detach(){t=null,r=!1}}}var ue=vl(({onInput:t,onBinaryInput:r,onGridChange:l,onReady:c,onReattach:u},b)=>{let{theme:m}=pf(),h=i(null),w=i(null),[R,M]=n(!1),E=i(null);if(!E.current)E.current=Je();let O=E.current,A=i(t);A.current=t;let v=i(r);v.current=r;let P=i(l);P.current=l;let F=i(c);F.current=c;let y=i(u);y.current=u;let x=i(m);x.current=m,o(()=>{let L=w.current;if(!L)return;L.setTheme(m),y.current?.()},[m]),Oo(b,()=>({write(L){w.current?.write(L)},writeReplay(L,T,g){w.current?.writeReplay(L,T,g)},reset(){w.current?.reset()},focus(){O.request()},applicationCursorKeys(){return w.current?.applicationCursorKeys()??!1},getSelection(){return w.current?.getSelection()??""},paste(L){w.current?.paste(L)}}),[]);let D=a(()=>{w.current?.scrollToBottom(),M(!1)},[]);return o(()=>{let L=h.current;if(!L)return;let T=!1;return Ze(L,x.current,{onInput:(g)=>A.current(g),onBinaryInput:(g)=>v.current(g),onGridChange:(g,I)=>P.current(g,I),onReady:(g,I)=>F.current(g,I),onScrolledUpChange:M},()=>T).then((g)=>{if(!g)return;if(T){g.dispose();return}w.current=g,L.querySelector("textarea")?.setAttribute("data-terminal-input",""),O.attach(()=>w.current?.focus())}),()=>{T=!0,O.detach(),w.current?.dispose(),w.current=null}},[]),e("div",{className:"relative flex-1 w-full h-full overflow-hidden p-2",children:[e("div",{ref:h,"data-terminal-root":"",className:"kabmo-terminal w-full h-full cursor-text",style:{height:"100%",width:"100%"}}),R&&e("button",{type:"button",onClick:D,className:"absolute bottom-3 right-4 z-20 flex items-center space-x-1.5 px-2.5 py-1 bg-paper hover:bg-canvas text-ink border border-ink/20 rounded-full shadow-lg text-[11px] font-mono transition-all presence-enter cursor-pointer",title:"Scroll to latest output (Shift+End)",children:[e(ua,{size:12,className:"text-warning-text"}),e("span",{children:"Latest"})]})]})});ue.displayName="RealtimeTerminalView";var de=new TextEncoder;function pr({className:t="",enabled:r=!0,rootPath:l,showHeader:c=!0,active:u=!0,tabsMode:b=!1}){let m=i(null),{isDark:h}=pf(),w=Uo(),R=i(null),M=zc(R),[E,O]=n(V),{activeRepo:A,setActiveRepo:v}=vr(l),{repos:P,scanning:F,rescan:y}=kr(l,r),x=i(null),D=i(E);D.current=E;let L=a((C)=>{m.current?.write(C)},[]);o(()=>{if(!u||!r){Uc();return}m.current?.focus()},[u,r]);let T=a((C,_)=>{m.current?.writeReplay(C,_.replayCols,_.replayRows)},[]),g=a(()=>{m.current?.reset()},[]),{status:I,shell:B,exitCode:X,error:G,attach:H,resize:Y,input:q,restart:J,reattach:j}=ge({visible:u&&r,root:r?l:void 0,repo:A,theme:h?"dark":"light",onOutput:L,onReplay:T,onRestart:g}),ne=a((C,_)=>{x.current={cols:C,rows:_},H(C,_)},[H]),N=a((C,_)=>{let re=x.current;if(x.current={cols:C,rows:_},!re)return;Y(C,_)},[Y]),K=a((C)=>{let _=D.current,re=_.ctrl||_.alt,it=Re(C,_);if(re&&C.length===1)O(V);q(de.encode(it))},[q]),U=a((C)=>{O((_)=>({..._,[C]:!_[C]})),m.current?.focus()},[]),W=a((C)=>{let _=Ce(C,{applicationCursorKeys:m.current?.applicationCursorKeys()??!1,modifiers:D.current});if(!_)return;q(de.encode(_)),O(V),m.current?.focus()},[q]),je=a(async()=>{let C=m.current?.getSelection()??"";if(!C)return!1;return Tt(C)},[]),et=a(async()=>{let C=await Jm();if(C===null||C.length===0)return!1;return m.current?.paste(C),m.current?.focus(),!0},[]),tt=a((C)=>{q(C)},[q]),nt=a((C)=>{q(de.encode(`${C}\r`)),m.current?.focus()},[q]),rt=a(()=>{J()},[J]),ot=a(()=>{j()},[j]);if(!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{ref:R,className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,"aria-hidden":!u,style:M>0?{paddingBottom:M}:void 0,children:[c&&e(we,{status:I,exitCode:X,rootPath:l,activeRepo:A,onSelectRepo:v,repos:P,reposScanning:F,onRefreshRepos:y,shell:B,onRestart:rt,tabsMode:b}),e(ve,{onSelectCommand:nt,disabled:I!=="running"}),G&&e("div",{className:"px-3 py-1.5 border-b border-error/20 bg-error/5 text-[11px] font-mono text-error-text flex-shrink-0",children:G}),e("div",{className:"flex-1 w-full min-h-0 bg-canvas overflow-hidden",children:e(ue,{ref:m,onInput:K,onBinaryInput:tt,onReady:ne,onGridChange:N,onReattach:ot})}),w&&e(Ee,{modifiers:E,onToggleModifier:U,onKey:W,onCopy:je,onPaste:et,disabled:I!=="running"})]})}export{pr as TerminalPanel};
|
|
1
|
+
import{d,n,o,i,zo,a,Uo,e,x,hs,jo,Oe,me,S,kr,wr,s,p,pa,f,Ga,Fe,Kt,_r,It,Uc,Nt,of,bf,Wc,Kc}from"./index-j734ev6q.js";import{_l,Fr}from"./index-kv1xnem9.js";function oe(){if(typeof crypto<"u"&&typeof crypto.randomUUID==="function")return crypto.randomUUID();return`t-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function ie(t){return JSON.stringify(t)}function pe(t){let r=st(t);if(!x(r))return null;if(r.t==="ready"){if(typeof r.id!=="string"||typeof r.cwd!=="string")return null;let l=typeof r.replayBytes==="number"?r.replayBytes:0;return{...r,t:"ready",replayBytes:l}}if(r.t==="exit")return{t:"exit",exitCode:typeof r.exitCode==="number"?r.exitCode:null,signal:typeof r.signal==="string"?r.signal:null};if(r.t==="error"&&typeof r.message==="string")return{t:"error",code:at(r.code),message:r.message};return null}function fe(t){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/terminal/${encodeURIComponent(t)}/ws`}function at(t){return t==="capacity"||t==="cwd"||t==="shell"||t==="spawn"?t:"unknown"}function st(t){try{return JSON.parse(t)}catch{return null}}function be(t){if(t.buffer instanceof ArrayBuffer)return t;return new Uint8Array(t)}var lt=500,ct=8000,ut=4;function he(t,r){let l=null,c=null,u=0,b=!1,m=!1,h=!1,v=null,k=[],M=0,E=null,O=()=>{let y=new WebSocket(fe(t));y.binaryType="arraybuffer",l=y,y.onopen=()=>{if(m)return;if(u=0,b=!0,r.onConnectionChange(!0),v)y.send(ie(v))},y.onmessage=(w)=>{if(m)return;if(w.data instanceof ArrayBuffer){C(new Uint8Array(w.data));return}if(typeof w.data!=="string")return;let D=pe(w.data);if(D)A(D)},y.onclose=()=>{if(l=null,m)return;if(r.onConnectionChange(!1),h=!1,k=[],M=0,E=null,!b)return;if(u+=1,u>ut)return;let w=Math.min(lt*2**(u-1),ct);c=setTimeout(()=>{if(c=null,!m)O()},w)},y.onerror=()=>{}},A=(y)=>{if(y.t==="ready"){if(h=!0,E=y,M=y.replayBytes,k=[],r.onReady(y),M===0)P();return}if(y.t==="exit"){r.onExit(y.exitCode,y.signal);return}r.onError(y.code,y.message)},C=(y)=>{if(M<=0){r.onOutput(y);return}if(k.push(y),M-=y.length,M>0)return;P()},P=()=>{let y=E,w=k;if(E=null,k=[],M=0,!y)return;r.onReplay(w.length===1?w[0]:mt(w),y)};O();let F=(y)=>{let w=l;if(!w||w.readyState!==WebSocket.OPEN)return;w.send(ie(y))};return{attach(y,w,D,L,T){if(h)return;let g={t:"attach",cols:y,rows:w};if(D)g.root=D;if(L)g.repo=L;if(T)g.theme=T;v=g,F(g)},resize(y,w){F({t:"resize",cols:y,rows:w})},input(y){let w=l;if(!w||w.readyState!==WebSocket.OPEN)return;w.send(be(y))},close(){F({t:"close"})},release(){if(m=!0,c!==null)clearTimeout(c),c=null;let y=l;if(l=null,!y)return;y.onopen=null,y.onmessage=null,y.onclose=null,y.onerror=null,y.close()}}}function mt(t){let r=0;for(let u of t)r+=u.length;let l=new Uint8Array(r),c=0;for(let u of t)l.set(u,c),c+=u.length;return l}function ye(t){return{connect:t.visible||t.opened,persist:t.ready&&t.visible&&!t.opened}}function ge(t={}){let{sessionId:r,ready:l}=Oe(),[c,u]=S("terminal.id",""),[b,m]=S("terminal.opened",!1),h=ye({visible:t.visible===!0,ready:l,opened:b}),[v,k]=n("connecting"),[M,E]=n(""),[O,A]=n(null),[C,P]=n(null),[F,y]=n(0),w=i(null),D=i(null),L=i(t.onOutput);L.current=t.onOutput;let T=i(t.onReplay);T.current=t.onReplay;let g=i(t.onRestart);g.current=t.onRestart;let I=i(t.root);I.current=t.root;let B=i(t.repo);B.current=t.repo;let X=i(t.theme);X.current=t.theme;let G=i(u);G.current=u;let H=i(null);o(()=>{if(!h.persist)return;m(!0)},[h.persist]),o(()=>{if(!h.connect||!l)return;if(me(r,"terminal.id"))return;G.current(oe())},[h.connect,l,r]),o(()=>{if(!h.connect||!l||!c)return;k("connecting"),P(null),A(null);let N=he(c,{onReady(U){k("running"),E(U.shell),A(null)},onReplay(U,W){T.current?.(U,W)},onOutput(U){L.current?.(U)},onExit(U){k("exited"),A(U)},onError(U,W){k("error"),P(`${U}: ${W}`)},onConnectionChange(U){if(!U)k("connecting")}});w.current=N;let K=D.current;if(K)N.attach(K.cols,K.rows,I.current,B.current,X.current);return()=>{N.release(),w.current=null}},[h.connect,l,c,F]);let Y=a(()=>{w.current?.close(),g.current?.(),G.current(oe())},[]);o(()=>{if(!l)return;let N=t.root;if(!N)return;let K=`${N}\x00${t.repo??"."}`;if(H.current===null){H.current=K;return}if(H.current===K)return;H.current=K,Y()},[l,t.root,t.repo,Y]);let q=a((N,K)=>{D.current={cols:N,rows:K},w.current?.attach(N,K,I.current,B.current,X.current)},[]),J=a((N,K)=>{D.current={cols:N,rows:K},w.current?.resize(N,K)},[]),j=a((N)=>{w.current?.input(N)},[]),ne=a(()=>{y((N)=>N+1)},[]);return{status:v,shell:M,exitCode:O,error:C,attach:q,resize:J,input:j,restart:Y,reattach:ne}}var dt={name:"clipboard-copy",size:24,node:[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]},Te=s(dt);var pt={name:"zap",size:24,node:[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]},xe=s(pt);var ft={connecting:"CONNECTING",running:"LIVE",exited:"EXITED",error:"ERROR"},bt={connecting:"bg-warning/10 text-warning-text border-warning/20",running:"bg-success/10 text-success-text border-success/20",exited:"bg-ink/5 text-ink/60 border-ink/15",error:"bg-error/10 text-error-text border-error/20"};function we({status:t,exitCode:r,rootPath:l,activeRepo:c,onSelectRepo:u,repos:b,reposScanning:m,onRefreshRepos:h,shell:v,onRestart:k,tabsMode:M=!1}){let E=v?v.split("/").pop():"";return e(It,{left:e(d,{children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Fe,{size:14,className:"text-ink/80 flex-shrink-0"}),M?null:e("span",{className:"text-xs font-semibold tracking-wider text-ink uppercase",children:"Terminal"})]}),e("span",{className:`inline-flex items-center space-x-1 px-1.5 py-0.5 rounded text-[10px] font-mono border ${bt[t]}`,title:t==="exited"&&r!==null?`Shell exited with code ${r}`:void 0,children:[t==="connecting"&&e(p,{size:10,className:"animate-spin"}),e("span",{children:t==="exited"&&r!==null?`EXIT ${r}`:ft[t]})]}),e(Fr,{rootPath:l,activeRepo:c,onSelectRepo:u,repos:b,scanning:m,onRefreshRepos:h}),e(Uc,{label:"Kill this shell and start a new one",onClick:k,children:e(Ga,{size:14})})]}),right:E?e("span",{className:"hidden sm:block text-[10px] font-mono text-ink/40 flex-shrink-0",children:E}):void 0})}var ht=[{label:"bun build",cmd:"bun run build"},{label:"bun test",cmd:"bun test"},{label:"git status",cmd:"git status -s"},{label:"git diff",cmd:"git diff"},{label:"ls -la",cmd:"ls -la"},{label:"pwd",cmd:"pwd"},{label:"bun -v",cmd:"bun --version"}];function ve({onSelectCommand:t,disabled:r}){return e("div",{className:"flex flex-wrap items-center gap-1.5 px-3 py-1.5 bg-paper border-b border-ink/10 flex-shrink-0",children:[e("div",{className:"flex items-center space-x-1 text-[10px] font-mono text-ink/50 uppercase tracking-wider flex-shrink-0 select-none",children:[e(xe,{size:11,className:"text-warning-text"}),e("span",{children:"Quick:"})]}),ht.map((l)=>e("button",{type:"button",disabled:r,onClick:()=>t(l.cmd),className:"px-2 py-0.5 rounded text-[10px] font-mono bg-canvas hover:bg-ink/5 active:bg-ink/10 text-ink/80 hover:text-ink border border-ink/15 transition-all whitespace-nowrap disabled:opacity-40 cursor-pointer shadow-2xs",children:l.label},l.cmd))]})}var V=Object.freeze({ctrl:!1,alt:!1}),ae=[{id:"escape",label:"Esc",name:"Escape",sequence:"\x1B"},{id:"tab",label:"Tab",name:"Tab",sequence:"\t"},{id:"interrupt",label:"^C",name:"Ctrl+C — interrupt",sequence:"\x03"},{id:"left",label:"←",name:"Left arrow",csi:{prefix:"1",final:"D",application:"OD"}},{id:"up",label:"↑",name:"Up arrow",csi:{prefix:"1",final:"A",application:"OA"}},{id:"down",label:"↓",name:"Down arrow",csi:{prefix:"1",final:"B",application:"OB"}},{id:"right",label:"→",name:"Right arrow",csi:{prefix:"1",final:"C",application:"OC"}},{id:"home",label:"Home",name:"Home",csi:{prefix:"1",final:"H",application:"OH",terminfo:"\x1BOH"}},{id:"end",label:"End",name:"End",csi:{prefix:"1",final:"F",application:"OF",terminfo:"\x1BOF"}},{id:"pageUp",label:"PgUp",name:"Page up",csi:{prefix:"5",final:"~"}},{id:"pageDown",label:"PgDn",name:"Page down",csi:{prefix:"6",final:"~"}},{id:"delete",label:"Del",name:"Delete",csi:{prefix:"3",final:"~"}},{id:"shiftTab",label:"⇧Tab",name:"Shift+Tab",sequence:"\x1B[Z"},{id:"eof",label:"^D",name:"Ctrl+D — end of input",sequence:"\x04"},{id:"clear",label:"^L",name:"Ctrl+L — clear screen",sequence:"\f"}],se=[{id:"pipe",label:"|",name:"Pipe",sequence:"|"},{id:"tilde",label:"~",name:"Tilde",sequence:"~"},{id:"dollar",label:"$",name:"Dollar",sequence:"$"},{id:"asterisk",label:"*",name:"Asterisk",sequence:"*"},{id:"question",label:"?",name:"Question mark",sequence:"?"},{id:"underscore",label:"_",name:"Underscore",sequence:"_"},{id:"backslash",label:"\\",name:"Backslash",sequence:"\\"},{id:"slash",label:"/",name:"Slash",sequence:"/"},{id:"minus",label:"-",name:"Minus",sequence:"-"},{id:"equals",label:"=",name:"Equals",sequence:"="},{id:"plus",label:"+",name:"Plus",sequence:"+"},{id:"ampersand",label:"&",name:"Ampersand",sequence:"&"},{id:"semicolon",label:";",name:"Semicolon",sequence:";"},{id:"colon",label:":",name:"Colon",sequence:":"},{id:"comma",label:",",name:"Comma",sequence:","},{id:"dot",label:".",name:"Period",sequence:"."},{id:"at",label:"@",name:"At sign",sequence:"@"},{id:"percent",label:"%",name:"Percent",sequence:"%"},{id:"caret",label:"^",name:"Caret",sequence:"^"},{id:"hash",label:"#",name:"Hash",sequence:"#"},{id:"bang",label:"!",name:"Exclamation mark",sequence:"!"},{id:"parenOpen",label:"(",name:"Open parenthesis",sequence:"("},{id:"parenClose",label:")",name:"Close parenthesis",sequence:")"},{id:"bracketOpen",label:"[",name:"Open bracket",sequence:"["},{id:"bracketClose",label:"]",name:"Close bracket",sequence:"]"},{id:"braceOpen",label:"{",name:"Open brace",sequence:"{"},{id:"braceClose",label:"}",name:"Close brace",sequence:"}"},{id:"lessThan",label:"<",name:"Less than",sequence:"<"},{id:"greaterThan",label:">",name:"Greater than",sequence:">"},{id:"quote",label:"'",name:"Single quote",sequence:"'"},{id:"doubleQuote",label:'"',name:"Double quote",sequence:'"'},{id:"backtick",label:"`",name:"Backtick",sequence:"`"}],Se={};for(let t of[...ae,...se])Se[t.id]=t;function Ce(t,r={}){let l=Se[t];if(!l)return"";let c=r.modifiers??V;if(l.csi)return yt(l.csi,c,r.applicationCursorKeys??!1);let u=l.sequence??"";return c.alt?`\x1B${u}`:u}function yt(t,r,l){let c=gt(r);if(c!==null)return`\x1B[${t.prefix};${c}${t.final}`;if(t.terminfo)return t.terminfo;if(l&&t.application)return`\x1B${t.application}`;return`\x1B[${t.prefix==="1"?"":t.prefix}${t.final}`}function gt(t){let r=(t.alt?2:0)|(t.ctrl?4:0);return r===0?null:r+1}function Re(t,r){if(t.length!==1)return t;let l=t;if(r.ctrl)l=xt(l)??l;if(r.alt)l=`\x1B${l}`;return l}var Tt={"@":"\x00"," ":"\x00","":"\b","[":"\x1B","\\":"\x1C","]":"\x1D","^":"\x1E",_:"\x1F","?":""};function xt(t){if(t.length!==1)return null;let r=t.charCodeAt(0);if(r>=97&&r<=122)return String.fromCharCode(r-96);if(r>=65&&r<=90)return String.fromCharCode(r-64);return Tt[t]??null}var wt=[{modifier:"ctrl",label:"Ctrl",name:"Ctrl — applies to the next key"},{modifier:"alt",label:"Alt",name:"Alt / meta — applies to the next key"}],Q="flex items-center justify-center h-8 min-w-8 px-1.5 rounded border font-mono transition-colors cursor-pointer select-none disabled:opacity-40 disabled:cursor-default text-[11px] @[420px]:h-9 @[420px]:min-w-10 @[420px]:text-xs",Z="bg-canvas text-ink/80 border-ink/15 hover:text-ink hover:bg-ink/5 active:bg-ink/10",ke="bg-ink text-canvas border-ink";function Ee({modifiers:t,onToggleModifier:r,onKey:l,onCopy:c,onPaste:u,disabled:b}){let[m,h]=n(!1),[v,k]=n(null),M=t.ctrl||t.alt,E=(C)=>{k(C),setTimeout(()=>k((P)=>P===C?null:P),1500)},O=async()=>{E(await c()?"copied":"empty")},A=async()=>{if(!await u())E("pasteFailed")};return e("div",{className:"@container flex flex-col gap-1 px-2 py-1.5 border-t border-ink/10 bg-paper flex-shrink-0",onPointerDown:(C)=>C.preventDefault(),children:[e("div",{className:"flex flex-wrap items-center gap-1",children:[wt.map(({modifier:C,label:P,name:F})=>e("button",{type:"button",onClick:()=>r(C),"aria-pressed":t[C],title:F,"aria-label":F,className:`${Q} ${t[C]?ke:Z}`,children:P},C)),M&&e("span",{className:"text-[10px] font-mono text-ink/50 px-0.5 whitespace-nowrap","aria-hidden":!0,children:"next"}),e("span",{className:"w-px h-5 bg-ink/15 flex-shrink-0","aria-hidden":!0}),e("button",{type:"button",onClick:O,disabled:b,title:v==="empty"?"Nothing selected":"Copy selection","aria-label":"Copy selection",className:`${Q} ${v==="empty"?"bg-warning/10 text-warning-text border-warning/30":Z}`,children:[v==="copied"?e(f,{size:13}):e(Te,{size:13}),e("span",{className:"pl-1",children:"Copy"})]}),e("button",{type:"button",onClick:A,disabled:b,title:v==="pasteFailed"?"Clipboard unavailable":"Paste into the shell","aria-label":"Paste into the shell",className:`${Q} ${v==="pasteFailed"?"bg-error/10 text-error-text border-error/30":Z}`,children:[e(_l,{size:13}),e("span",{className:"pl-1",children:"Paste"})]}),e("button",{type:"button",onClick:()=>h((C)=>!C),"aria-pressed":m,title:m?"Show control keys":"Show symbols","aria-label":m?"Show control keys":"Show symbols",className:`${Q} ml-auto ${m?ke:Z}`,children:m?"ABC":"123"})]}),e("div",{className:"flex flex-wrap items-center gap-1",children:(m?se:ae).map((C)=>e("button",{type:"button",disabled:b,onClick:()=>l(C.id),title:C.name,"aria-label":C.name,className:`${Q} ${Z}`,children:C.label},C.id))})]})}function Me(t){if(!t.startsWith("\x1B[M")||t.length<6)return{text:t};let r=new Uint8Array(t.length);for(let l=0;l<t.length;l+=1)r[l]=t.charCodeAt(l)&255;return{bytes:r}}function Ae(t){let r=Kt(t),{canvas:l,ink:c,paper:u}=r,b=(h)=>_r(h,c,0.2),m=(h)=>_r(l,c,h);return{background:"transparent",foreground:c,cursor:r.meta,cursorAccent:u,selectionBackground:m(0.28),selectionForeground:c,black:m(0.2),red:r.error,green:r.success,yellow:r.warning,blue:r.info,magenta:r.meta,cyan:_r(r.info,r.success,0.5),white:m(0.75),brightBlack:m(0.5),brightRed:b(r.error),brightGreen:b(r.success),brightYellow:b(r.warning),brightBlue:b(r.info),brightMagenta:b(r.meta),brightCyan:b(_r(r.info,r.success,0.5)),brightWhite:m(0.92)}}var ee="Fira Code",vt="'FiraCode Nerd Font Mono', 'FiraCode Nerd Font', 'JetBrainsMono Nerd Font', 'JetBrainsMono NF', 'JetBrains Mono Nerd Font', 'Hack Nerd Font', 'MesloLGS NF', 'MesloLGM Nerd Font', 'CaskaydiaCove Nerd Font', 'SauceCodePro Nerd Font', 'Symbols Nerd Font Mono', 'Symbols Nerd Font', 'PowerlineSymbols'",Le="Kabmo Nerd Symbols",Ie=[ee,Le],te=`'${ee}', ${vt}, '${Le}', Menlo, Monaco, 'Courier New', monospace`,z=12,St=16,Ct=1e4;function Rt(t,r){return Math.max(1,t)*Math.max(1,r)*St}var Ne=Rt(Ct,100);var kt=2000;async function Pe(){if(typeof document>"u"||!document.fonts?.load)return;let t=Promise.withResolvers(),r=setTimeout(t.resolve,kt);try{await Promise.race([document.fonts.load(`${z}px "${ee}"`).then(()=>{return},()=>{return}),t.promise])}finally{clearTimeout(r)}}function De(t){if(typeof document>"u"||!document.fonts)return()=>{};let r=new Set(Ie),l=(c)=>{if([...c.fontfaces].some((b)=>r.has(b.family.replace(/['"]/g,"").trim())))t()};return document.fonts.addEventListener("loadingdone",l),()=>document.fonts.removeEventListener("loadingdone",l)}var _e=2.5,Et=1;function Mt(t,r){let l=t*0.8,c=t*0.2,u=Math.ceil(t*0.6),b=l,m=c,h=typeof document>"u"?null:document.createElement("canvas").getContext("2d");if(h){h.font=`${t}px ${r}`,u=Math.ceil(h.measureText("M").width)||u;let v=h.measureText("Mg");b=v.actualBoundingBoxAscent||l,m=v.actualBoundingBoxDescent||c}return{width:u,height:Math.ceil(b+m+_e+Et),baseline:Math.round(b+_e)}}function Be(t){let r=t.renderer;if(!r)return;r.measureFont=()=>Mt(t.options.fontSize??z,t.options.fontFamily??te),r.remeasureFont()}function Ke(t){let r=t.renderer;if(!r||!t.wasmTerm)return;r.setFontSize(t.options.fontSize??z),r.resize(t.cols,t.rows),r.render(t.wasmTerm,!0,t.viewportY,t)}function At(t){let{cols:r,rows:l,attached:c,committed:u}=t;if(r<10||l<5)return{kind:"ignore"};if(!c)return{kind:"attach",cols:r,rows:l};if(r===u.cols&&l===u.rows)return{kind:"ignore"};return{kind:"change",cols:r,rows:l}}function Ue(t){let r={cols:0,rows:0},l=!1,c,u=()=>{if(!t.fit())return;let b=t.current();if(!b)return;let m=At({cols:b.cols,rows:b.rows,attached:l,committed:r});if(m.kind==="ignore")return;if(r={cols:m.cols,rows:m.rows},m.kind==="attach"){l=!0,t.onReady(m.cols,m.rows);return}t.onGridChange(m.cols,m.rows)};return{schedule(){clearTimeout(c),c=setTimeout(u,120)},restate(){r={cols:0,rows:0}},isAttached:()=>l,dispose(){clearTimeout(c),c=void 0}}}function qe(t,r){if(r.type!=="keydown"||!r.shiftKey)return!1;if(r.key==="PageUp")return t.scrollPages(-1),!0;if(r.key==="PageDown")return t.scrollPages(1),!0;if(r.key==="Home")return t.scrollToTop(),!0;if(r.key==="End")return t.scrollToBottom(),!0;if(r.key==="ArrowUp")return t.scrollLines(-1),!0;if(r.key==="ArrowDown")return t.scrollLines(1),!0;return!1}function He(t,r){let l=0,c=(b)=>{if(b.touches.length===1)l=b.touches[0].clientY},u=(b)=>{if(b.touches.length!==1)return;let m=l-b.touches[0].clientY;if(Math.abs(m)<16)return;r()?.scrollLines(Math.trunc(m/16)),l=b.touches[0].clientY};return t.addEventListener("touchstart",c,{passive:!0}),t.addEventListener("touchmove",u,{passive:!0}),()=>{t.removeEventListener("touchstart",c),t.removeEventListener("touchmove",u)}}function Ft(t){if(t.viewportY<=0&&!t.hasSelection&&!t.pointerHeld)return null;return t.scrollback-t.viewportY}function Lt(t){let r=t.scrollback-t.top;return r>0?r:null}function $e(t){let r={pointerHeld:!1},l=()=>{r.pointerHeld=!0},c=()=>{r.pointerHeld=!1};return t.addEventListener("pointerdown",l,!0),globalThis.addEventListener("pointerup",c),globalThis.addEventListener("pointercancel",c),{get pointerHeld(){return r.pointerHeld},stop(){t.removeEventListener("pointerdown",l,!0),globalThis.removeEventListener("pointerup",c),globalThis.removeEventListener("pointercancel",c)}}}function Ge(t,r,l){let c=Ft({scrollback:t.getScrollbackLength(),viewportY:t.getViewportY(),hasSelection:t.hasSelection(),pointerHeld:r.pointerHeld});if(l(),c===null)return;let u=Lt({scrollback:t.getScrollbackLength(),top:c});if(u===null)return;let b=u-t.getViewportY();if(b===0)return;try{t.scrollLines(-b)}catch{}}function Ye(t,r){let l=(c)=>{let u=r();if(!u)return;if(c.preventDefault(),c.clipboardData)c.clipboardData.setData("text/plain",u);else Nt(u)};return t.addEventListener("copy",l),()=>t.removeEventListener("copy",l)}function ze(t,r){let l=(c)=>{if(!c.ctrlKey||!c.shiftKey||c.altKey)return;if(c.code==="KeyC"){let u=r.getSelection();if(!u)return;c.preventDefault(),c.stopImmediatePropagation(),Nt(u);return}if(c.code==="KeyV")c.preventDefault(),c.stopImmediatePropagation(),of().then((u)=>{if(u)r.paste(u)})};return t.addEventListener("keydown",l,!0),()=>t.removeEventListener("keydown",l,!0)}function Xe(t){if(hs()&&t.textarea)t.textarea.focus();else t.focus()}function We(t){if(hs())t.textarea?.focus()}function Ve(t,r){let l=(c)=>{if(c.target!==t||!hs())return;r.textarea?.focus()};return t.addEventListener("focusin",l),()=>t.removeEventListener("focusin",l)}function _t(t,r,l){if(!l.width||!l.height)return null;return{cols:Math.max(2,Math.floor(t/l.width)),rows:Math.max(1,Math.floor(r/l.height))}}function Qe(t,r){let l=t;l.proposeDimensions=()=>{let c=r.element,u=r.renderer?.getMetrics();if(!c||!u)return;let b=getComputedStyle(c),m=(parseFloat(b.paddingLeft)||0)+(parseFloat(b.paddingRight)||0),h=(parseFloat(b.paddingTop)||0)+(parseFloat(b.paddingBottom)||0);return _t(c.clientWidth-m,c.clientHeight-h,u)??void 0}}function le(t,r,l,c,u){let b=new t.Terminal({cursorBlink:!0,cursorStyle:"block",fontSize:z,fontFamily:te,theme:Ae(c),scrollback:Ne,smoothScrollDuration:0,ghostty:r});if(b.open(l),Be(b),b.clear(),l.clientWidth>0)We(b);let m=new t.FitAddon;b.loadAddon(m),Qe(m,b);let h={term:b,fitAddon:m,disposables:[]};return u(h),h}function ce(t){if(!t)return;for(let r of t.disposables)try{r.dispose()}catch{}try{t.fitAddon.dispose()}catch{}try{t.term.dispose()}catch{}}async function Ze(t,r,l,c){let u=await import("./ghostty-web-22pdvhta.js"),[b]=await Promise.all([u.Ghostty.load(),Pe()]);if(c())return null;let m=r,h=null,v=!1,k,M=null,E=!1,O=(T)=>{let{term:g}=T;g.attachCustomKeyEventHandler((I)=>qe(g,I)),T.disposables.push({dispose:Ye(t,()=>g.getSelection())},{dispose:ze(t,{getSelection:()=>g.getSelection(),paste:(I)=>g.paste(I)})},{dispose:Ve(t,g)},g.onScroll((I)=>l.onScrolledUpChange(I>0)),g.onData((I)=>{let B=Me(I);if(B.bytes)l.onBinaryInput(B.bytes);else l.onInput(B.text)}),g.onResize(()=>{if(v)return;F.schedule()}))},A=()=>{if(E)return!1;if(t.clientWidth<=0||t.clientHeight<=0)return!1;let T=h?.term.renderer?.getMetrics();if(!T?.width||!T.height)return!1;try{return h?.fitAddon.fit(),!0}catch{return!1}},C=()=>{if(E)return;v=!1,A(),F.restate(),F.schedule()},P=(T,g,I)=>{let B=h?.term;if(!B)return;if(v=!0,B.cols!==g||B.rows!==I)B.resize(g,I);if(T.length===0){requestAnimationFrame(C);return}B.write(T,C)},F=Ue({current:()=>h?.term,fit:A,onReady:l.onReady,onGridChange:l.onGridChange}),y=$e(t);h=le(u,b,t,m,O),A(),F.schedule();let w=new ResizeObserver(()=>{clearTimeout(k),k=setTimeout(()=>{A(),F.schedule()},35)});w.observe(t);let D=De(()=>{let T=h?.term;if(!T)return;Ke(T),A(),F.schedule()}),L=He(t,()=>h?.term??null);return M=requestAnimationFrame(()=>{A(),F.schedule()}),{write(T){let g=h?.term;if(!g)return;Ge(g,y,()=>g.write(T))},writeReplay:P,reset(){let T=h?.term;if(!T)return;T.reset(),T.clear(),A()},focus(){let T=h?.term;if(T)Xe(T)},applicationCursorKeys(){return h?.term.wasmTerm?.getMode(1,!1)??!1},getSelection(){return h?.term.getSelection()??""},paste(T){h?.term.paste(T)},scrollToBottom(){h?.term.scrollToBottom()},setTheme(T){if(E||T===m)return;m=T,ce(h),h=le(u,b,t,T,O),A()},dispose(){if(E=!0,M!==null)cancelAnimationFrame(M);clearTimeout(k),F.dispose(),D(),L(),y.stop(),w.disconnect(),ce(h),h=null}}}function Je(){let t=null,r=!1;return{request(){if(t)t();else r=!0},attach(l){if(t=l,!r)return;r=!1,l()},detach(){t=null,r=!1}}}var ue=Uo(({onInput:t,onBinaryInput:r,onGridChange:l,onReady:c,onReattach:u},b)=>{let{theme:m}=bf(),h=i(null),v=i(null),[k,M]=n(!1),E=i(null);if(!E.current)E.current=Je();let O=E.current,A=i(t);A.current=t;let C=i(r);C.current=r;let P=i(l);P.current=l;let F=i(c);F.current=c;let y=i(u);y.current=u;let w=i(m);w.current=m,o(()=>{let L=v.current;if(!L)return;L.setTheme(m),y.current?.()},[m]),zo(b,()=>({write(L){v.current?.write(L)},writeReplay(L,T,g){v.current?.writeReplay(L,T,g)},reset(){v.current?.reset()},focus(){O.request()},applicationCursorKeys(){return v.current?.applicationCursorKeys()??!1},getSelection(){return v.current?.getSelection()??""},paste(L){v.current?.paste(L)}}),[]);let D=a(()=>{v.current?.scrollToBottom(),M(!1)},[]);return o(()=>{let L=h.current;if(!L)return;let T=!1;return Ze(L,w.current,{onInput:(g)=>A.current(g),onBinaryInput:(g)=>C.current(g),onGridChange:(g,I)=>P.current(g,I),onReady:(g,I)=>F.current(g,I),onScrolledUpChange:M},()=>T).then((g)=>{if(!g)return;if(T){g.dispose();return}v.current=g,L.querySelector("textarea")?.setAttribute("data-terminal-input",""),O.attach(()=>v.current?.focus())}),()=>{T=!0,O.detach(),v.current?.dispose(),v.current=null}},[]),e("div",{className:"relative flex-1 w-full h-full overflow-hidden p-2",children:[e("div",{ref:h,"data-terminal-root":"",className:"kabmo-terminal w-full h-full cursor-text",style:{height:"100%",width:"100%"}}),k&&e("button",{type:"button",onClick:D,className:"absolute bottom-3 right-4 z-20 flex items-center space-x-1.5 px-2.5 py-1 bg-paper hover:bg-canvas text-ink border border-ink/20 rounded-full shadow-lg text-[11px] font-mono transition-all presence-enter cursor-pointer",title:"Scroll to latest output (Shift+End)",children:[e(pa,{size:12,className:"text-warning-text"}),e("span",{children:"Latest"})]})]})});ue.displayName="RealtimeTerminalView";var de=new TextEncoder;function pr({className:t="",enabled:r=!0,rootPath:l,showHeader:c=!0,active:u=!0,tabsMode:b=!1}){let m=i(null),{isDark:h}=bf(),v=jo(),k=i(null),M=Wc(k),[E,O]=n(V),{activeRepo:A,setActiveRepo:C}=kr(l),{repos:P,scanning:F,rescan:y}=wr(l,r),w=i(null),D=i(E);D.current=E;let L=a((R)=>{m.current?.write(R)},[]);o(()=>{if(!u||!r){Kc();return}m.current?.focus()},[u,r]);let T=a((R,_)=>{m.current?.writeReplay(R,_.replayCols,_.replayRows)},[]),g=a(()=>{m.current?.reset()},[]),{status:I,shell:B,exitCode:X,error:G,attach:H,resize:Y,input:q,restart:J,reattach:j}=ge({visible:u&&r,root:r?l:void 0,repo:A,theme:h?"dark":"light",onOutput:L,onReplay:T,onRestart:g}),ne=a((R,_)=>{w.current={cols:R,rows:_},H(R,_)},[H]),N=a((R,_)=>{let re=w.current;if(w.current={cols:R,rows:_},!re)return;Y(R,_)},[Y]),K=a((R)=>{let _=D.current,re=_.ctrl||_.alt,it=Re(R,_);if(re&&R.length===1)O(V);q(de.encode(it))},[q]),U=a((R)=>{O((_)=>({..._,[R]:!_[R]})),m.current?.focus()},[]),W=a((R)=>{let _=Ce(R,{applicationCursorKeys:m.current?.applicationCursorKeys()??!1,modifiers:D.current});if(!_)return;q(de.encode(_)),O(V),m.current?.focus()},[q]),je=a(async()=>{let R=m.current?.getSelection()??"";if(!R)return!1;return Nt(R)},[]),et=a(async()=>{let R=await of();if(R===null||R.length===0)return!1;return m.current?.paste(R),m.current?.focus(),!0},[]),tt=a((R)=>{q(R)},[q]),nt=a((R)=>{q(de.encode(`${R}\r`)),m.current?.focus()},[q]),rt=a(()=>{J()},[J]),ot=a(()=>{j()},[j]);if(!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{ref:k,className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,"aria-hidden":!u,style:M>0?{paddingBottom:M}:void 0,children:[c&&e(we,{status:I,exitCode:X,rootPath:l,activeRepo:A,onSelectRepo:C,repos:P,reposScanning:F,onRefreshRepos:y,shell:B,onRestart:rt,tabsMode:b}),e(ve,{onSelectCommand:nt,disabled:I!=="running"}),G&&e("div",{className:"px-3 py-1.5 border-b border-error/20 bg-error/5 text-[11px] font-mono text-error-text flex-shrink-0",children:G}),e("div",{className:"flex-1 w-full min-h-0 bg-canvas overflow-hidden",children:e(ue,{ref:m,onInput:K,onBinaryInput:tt,onReady:ne,onGridChange:N,onReattach:ot})}),v&&e(Ee,{modifiers:E,onToggleModifier:U,onKey:W,onCopy:je,onPaste:et,disabled:I!=="running"})]})}export{pr as TerminalPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t,
|
|
2
|
-
export{
|
|
1
|
+
import{t,rn}from"./index-mgzbypt5.js";var N=5,R=0.00001,X=2,Y=0.6,w=0.000001;function P(n){let o=[];for(let r=0;r<n.length-1;r++)o.push({a:n[r],b:n[r+1]});return o}t(P,"buildSegmentList");function T(n,o,r,a){let c=o.x-n.x,s=o.y-n.y,u=a.x-r.x,f=a.y-r.y,d=c*f-s*u;if(d===0)return null;let e=r.x-n.x,i=r.y-n.y,h=(e*f-i*u)/d,p=(e*s-i*c)/d;if(h<=w||h>=1-w||p<=w||p>=1-w)return null;return{point:{x:n.x+h*c,y:n.y+h*s},tA:h,tB:p}}t(T,"segmentIntersection");function v(n){return Math.abs(n.b.x-n.a.x)>=Math.abs(n.b.y-n.a.y)}t(v,"isHorizontalSeg");function B(n,o,r){if(n.curve!=="rounded")return!1;let a=n.points,c=a[o],s=a[o+1];if(!c||!s)return!1;let u=Math.hypot(s.x-c.x,s.y-c.y),f=r*u,d=o>0?L(a[o-1],c,s,N):null;if(d&&f<d.cutLen)return!0;let e=o+2<a.length?L(c,s,a[o+2],N):null;return e!==null&&u-f<e.cutLen}t(B,"crossingSitsInRoundedCorner");function C(n){let o=[];for(let r=0;r<n.length;r++){let a=n[r],c=P(a.points);for(let s=r+1;s<n.length;s++){let u=n[s],f=P(u.points);for(let[d,e]of c.entries())for(let[i,h]of f.entries()){let p=T(e.a,e.b,h.a,h.b);if(!p)continue;if(B(a,d,p.tA)||B(u,i,p.tB))continue;let g=v(e),S=v(h);if(g!==S?g:!1)o.push({jumpEdgeId:a.id,otherEdgeId:u.id,segIndex:d,t:p.tA,point:p.point});else o.push({jumpEdgeId:u.id,otherEdgeId:a.id,segIndex:i,t:p.tB,point:p.point})}}}return o}t(C,"findEdgeIntersections");function M(n){let o=Math.round(n*1000)/1000;return Number.isInteger(o)?`${o}`:`${o}`}t(M,"fmt");function A(n){return`${M(n.x)},${M(n.y)}`}t(A,"pointToString");function D(n){let o=n.b.x-n.a.x,r=n.b.y-n.a.y;if(Math.abs(o)>=Math.abs(r))return o>=0?1:0;return r>=0?1:0}t(D,"getArcSweepFlag");function _(n,o){if(n.length<2)return n.map((s)=>({...s}));let r=n.map((s)=>({...s})),a=o.arrowTypeStart&&rn[o.arrowTypeStart];if(a){let s=n[0],u=n[1],f=Math.atan2(u.y-s.y,u.x-s.x);r[0].x=s.x+a*Math.cos(f),r[0].y=s.y+a*Math.sin(f)}let c=o.arrowTypeEnd&&rn[o.arrowTypeEnd];if(c){let s=n.length,u=n[s-2],f=n[s-1],d=Math.atan2(f.y-u.y,f.x-u.x);r[s-1].x=f.x-c*Math.cos(d),r[s-1].y=f.y-c*Math.sin(d)}return r}t(_,"applyMarkerOffsets");function k(n,o,r,a,c){let s=n.point.x,u=n.point.y,f={x:s-o*n.r,y:u-r*n.r},d={x:s+o*n.r,y:u+r*n.r},e=[`L${A(f)}`];if(c==="arc")e.push(`A${M(n.r)},${M(n.r)} 0 0 ${a} ${A(d)}`);else e.push(`M${A(d)}`);return e}t(k,"emitJump");function L(n,o,r,a){let c=o.x-n.x,s=o.y-n.y,u=r.x-o.x,f=r.y-o.y,d=Math.hypot(c,s),e=Math.hypot(u,f);if(d<R||e<R)return null;let i=c/d,h=s/d,p=u/e,g=f/e,S=i*p+h*g,b=Math.max(-1,Math.min(1,S)),x=Math.acos(b);if(x<R||Math.abs(Math.PI-x)<R)return null;let y=Math.min(a/Math.sin(x/2),d/2,e/2);return{startX:o.x-i*y,startY:o.y-h*y,endX:o.x+p*y,endY:o.y+g*y,ctrlX:o.x,ctrlY:o.y,cutLen:y}}t(L,"computeRoundedCorner");function H(n,o,r){let a=n.points;if(a.length<2)return"";let c=_(a,n),s=n.curve==="rounded",u=P(c),f=new Map;for(let e of o){let i=u[e.segIndex];if(!i)continue;let h=Math.hypot(i.b.x-i.a.x,i.b.y-i.a.y),p=f.get(e.segIndex)??[];p.push({t:e.t,point:e.point,d:e.t*h,r:r.jumpRadius}),f.set(e.segIndex,p)}let d=[`M${A(c[0])}`];for(let e=0;e<u.length;e++){let i=u[e],h=Math.hypot(i.b.x-i.a.x,i.b.y-i.a.y),p=h===0?0:(i.b.x-i.a.x)/h,g=h===0?0:(i.b.y-i.a.y)/h,S=D(i),b=0;if(s&&e>0){let l=L(c[e-1],c[e],c[e+1]??c[e],N);if(l)b=l.cutLen}let x=h,y=null;if(s&&e<u.length-1){if(y=L(c[e],c[e+1],c[e+2]??c[e+1],N),y)x=h-y.cutLen}let I=r.jumpRadius*Y,m=[...f.get(e)??[]].sort((l,E)=>l.t-E.t).filter((l)=>{let E=Math.min(l.d-b,x-l.d)-X;return l.r=Math.min(l.r,E),l.r>=I});for(let l=0;l<m.length-1;l++){let E=m[l+1].d-m[l].d;if(m[l].r+m[l+1].r>E){let O=E/2;m[l].r=Math.min(m[l].r,O),m[l+1].r=Math.min(m[l+1].r,O)}}for(let l of m){if(l.r<I)continue;d.push(...k(l,p,g,S,r.jumpStyle))}if(s&&y)d.push(`L${M(y.startX)},${M(y.startY)}`),d.push(`Q${M(y.ctrlX)},${M(y.ctrlY)} ${M(y.endX)},${M(y.endY)}`);else d.push(`L${A(i.b)}`)}return d.join(" ")}t(H,"rewriteEdgePath");function J(n){return/^[\d\s+,.LMelm-]*$/.test(n)}t(J,"isStraightPath");function U(n){if(!n)return!0;return n==="linear"||n==="rounded"||n==="step"||n==="stepBefore"||n==="stepAfter"}t(U,"curveSupportsLineHops");function j(n){if(!n)return null;try{let o=typeof atob==="function"?atob(n):Buffer.from(n,"base64").toString(),r=JSON.parse(o);if(!Array.isArray(r))return null;let a=[];for(let c of r)if(c&&typeof c.x==="number"&&typeof c.y==="number")a.push({x:c.x,y:c.y});return a.length>=2?a:null}catch{return null}}t(j,"decodeDataPoints");function fc(n,o,r){if(!r.enabled)return;let a=n.node();if(!a)return;let c=new Map;for(let e of o)c.set(e.id,e);let s=new Map;for(let e of a.querySelectorAll("path[data-id]")){let i=e.getAttribute("data-id");if(i!==null&&!s.has(i))s.set(i,e)}let u=[];for(let e of o){let i=s.get(e.id);if(!i)continue;let p=j(i.getAttribute("data-points"))??e.points;u.push({...e,points:p})}let f=C(u);if(f.length===0)return;let d=new Map;for(let e of f){let i=d.get(e.jumpEdgeId)??[];i.push(e),d.set(e.jumpEdgeId,i)}for(let e of u){let i=d.get(e.id);if(!i||i.length===0)continue;let p=c.get(e.id)?.curve;if(p!==void 0&&!U(p))continue;let g=s.get(e.id);if(!g)continue;if(p===void 0){let m=g.getAttribute("d")??"";if(!J(m))continue}let S=g.getAttribute("style")??"",b=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(S),x=b?Number.parseFloat(b[1]):null,y=b?Number.parseFloat(b[2]):null,I=H(e,i,r);if(g.setAttribute("d",I),x!==null&&y!==null&&typeof g.getTotalLength==="function"){let m=g.getTotalLength(),l=Math.max(0,m-x-y),E=`0 ${x} ${l} ${y}`,O=S.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${E};`).replace(/;\s*;+/g,";");g.setAttribute("style",O)}}}t(fc,"applyLineJumpsToSvg");
|
|
2
|
+
export{fc};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,o,i,a,e,s,B,ae,Re,Ne,E,Bi,rt,Oe,Le,h,J,Pi,bg}from"./index-4vtc4xct.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},I=s(F);function T({title:t,options:r,methodLabel:c,badge:m,icon:x,onCancel:b}){let f=Pi({title:t,options:r})?bg(t):null,v=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:v}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Ne,{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:b,"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(h,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:c,customValue:m,onCustomChange:x,customInputRef:b,onSelect:f,onConfirmOption:v,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,y)=>{let u=c===k,g=r[y]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>v(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:y+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),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(ae,{size:16,className:"text-ink"}):e(Bi,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:b,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())v(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function P({method:t,optionsLength:r,selectedOption:c,hasCustomAnswer:m=!1,onCancel:x,onSubmit:b}){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(h,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:b,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(rt,{size:12,className:"opacity-70"})]})]})]})}function R({title:t,options:r}){let c=Pi({title:t,options:r})?bg(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(E,{size:13,className:"mt-0.5 shrink-0 text-warning-text"}),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:b,onCancel:f}){o(()=>{let v=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let 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(),b();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),b();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),b();return}}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f,b,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(B,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Le,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e(Oe,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Re,{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,b]=n(null),[f,v]=n(""),l=i(null),k=i(null),y=i(null),u=i(null),g=t.options??[],N=t.optionDetails??[],A=Pi(t);o(()=>{let p=t.options??[];m(t.method==="editor"?t.prefill??"":""),b(p.length>0?p[0]:null),v("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")y.current?.focus();else if(t.method==="select"){if((t.options??[]).some((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())){b(p),u.current?.focus();return}r(t,{value:p})},[r,t]),H=a((p)=>{if(b(p),/^other\b/i.test(p.trim()))u.current?.focus()},[]);L({method:t.method,options:g,selectedOption:x,onSelectOption:b,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:v,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(ae,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:k,type:t.secret===!0?"password":"text",value:c,placeholder:t.placeholder||"Type your response...",onChange:(p)=>m(p.currentTarget.value),onKeyDown:(p)=>{if(p.key==="Enter")p.preventDefault(),M()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[c.split(`
|
|
2
|
-
`).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:
|
|
1
|
+
import{d,n,o,i,a,e,s,B,oe,Re,Ne,E,Ni,ot,$e,Fe,A,X,ji,Tg}from"./index-j734ev6q.js";var F={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]},I=s(F);function T({title:t,options:r,methodLabel:c,badge:m,icon:x,onCancel:b}){let f=ji({title:t,options:r})?Tg(t):null,v=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:v}),e("span",{className:"flex items-center gap-1 rounded-full border border-ink/10 bg-paper px-2 py-0.5 font-mono text-[10px] font-medium tracking-wider text-ink/60 uppercase",children:[e(Ne,{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:b,"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(A,{size:14})})]})}function S({options:t,optionDetails:r,selectedOption:c,customValue:m,onCustomChange:x,customInputRef:b,onSelect:f,onConfirmOption:v,hideCustomAnswer:l=!1}){return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Available Options"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:["Press [1-",Math.min(9,t.length),"] to choose"]})]}),e("div",{className:"grid gap-2",role:"radiogroup",children:t.map((k,h)=>{let u=c===k,g=r[h]?.description;return e("button",{type:"button",onClick:()=>f(k),onDblClick:()=>v(k),"aria-checked":u,role:"radio",className:`group flex w-full cursor-pointer items-start gap-3 rounded-xl border p-3.5 text-left transition-all ${u?"border-ink bg-paper shadow-sm ring-1 ring-ink/10":"border-ink/10 bg-canvas/30 hover:border-ink/25 hover:bg-paper"}`,children:[e("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md font-mono text-[11px] font-semibold transition-colors ${u?"bg-ink text-paper":"border border-ink/15 bg-paper text-ink/60 group-hover:border-ink/30 group-hover:text-ink"}`,children:h+1}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2",children:e("span",{className:`text-[13px] font-medium leading-snug ${u?"text-ink font-semibold":"text-ink/85"}`,children:k})}),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(oe,{size:16,className:"text-ink"}):e(Ni,{size:16,className:"text-ink/20 group-hover:text-ink/40"})})]},k)})}),!l&&e("div",{className:"space-y-1.5 pt-1",children:[e("div",{className:"text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:"Other: type your own answer"}),e("input",{ref:b,type:"text",value:m,placeholder:"Type a custom answer and press Enter...",onChange:(k)=>x(k.currentTarget.value),onKeyDown:(k)=>{if(k.key==="Enter"){if(k.preventDefault(),k.stopPropagation(),m.trim())v(m.trim())}},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]})]})}function P({method:t,optionsLength:r,selectedOption:c,hasCustomAnswer:m=!1,onCancel:x,onSubmit:b}){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(A,{size:12,className:"opacity-60"}),e("span",{children:"Cancel"})]}),e("button",{type:"button",onClick:b,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(ot,{size:12,className:"opacity-70"})]})]})]})}function R({title:t,options:r}){let c=ji({title:t,options:r})?Tg(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(E,{size:13,className:"mt-0.5 shrink-0 text-warning-text"}),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:b,onCancel:f}){o(()=>{let v=(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),f();return}if(t==="select"&&r.length>0){if(l.target instanceof HTMLInputElement&&l.target===x.current)return;let h=parseInt(l.key,10);if(!isNaN(h)&&h>=1&&h<=r.length){l.preventDefault(),m(r[h-1]);return}if(l.key==="ArrowDown"){l.preventDefault();let u=r.findIndex((y)=>y===c),g=u<r.length-1?u+1:0;m(r[g]);return}if(l.key==="ArrowUp"){l.preventDefault();let u=r.findIndex((y)=>y===c),g=u>0?u-1:r.length-1;m(r[g]);return}if(l.key==="Enter"&&c){l.preventDefault(),b();return}}if(t==="confirm"){if(l.key==="Enter"){l.preventDefault(),b();return}}if(t==="editor"){if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),b();return}}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f,b,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(B,{size:16,className:"text-ink"}),label:"Confirmation Required",badge:"Confirm Action"};case"input":return{icon:e(Fe,{size:16,className:"text-ink"}),label:"Prompt Input",badge:"Text Input"};case"editor":return{icon:e($e,{size:16,className:"text-ink"}),label:"Buffer Editor",badge:"Multiline Buffer"};default:return{icon:e(Re,{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,b]=n(null),[f,v]=n(""),l=i(null),k=i(null),h=i(null),u=i(null),g=t.options??[],y=t.optionDetails??[],C=ji(t);o(()=>{let p=t.options??[];m(t.method==="editor"?t.prefill??"":""),b(p.length>0?p[0]:null),v("")},[t]),o(()=>{if(l.current?.focus(),t.method==="input")k.current?.focus();else if(t.method==="editor")h.current?.focus();else if(t.method==="select"){if((t.options??[]).some((D)=>/^other\b/i.test(D.trim())))u.current?.focus()}},[t]);let N=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()&&!C)r(t,{value:f.trim()});else if(x)r(t,{value:x})}else r(t,{value:c})},[r,t,x,c,f,C]),O=a((p)=>{if(/^other\b/i.test(p.trim())){b(p),u.current?.focus();return}r(t,{value:p})},[r,t]),H=a((p)=>{if(b(p),/^other\b/i.test(p.trim()))u.current?.focus()},[]);L({method:t.method,options:g,selectedOption:x,onSelectOption:b,customInputRef:u,onSubmit:M,onCancel:N});let w=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)N()},children:e("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":t.title||w.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:w.label,badge:w.badge,icon:w.icon,onCancel:N}),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(X,{content:t.message})}),t.method==="select"&&e(S,{options:g,optionDetails:y,selectedOption:x,customValue:f,onCustomChange:v,customInputRef:u,onSelect:H,onConfirmOption:O,hideCustomAnswer:C}),t.method==="confirm"&&g.length>0&&e("div",{className:"space-y-2",children:g.map((p,D)=>e("button",{type:"button",onClick:()=>r(t,{optionId:t.optionIds?.[D]??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?.[D]??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(oe,{size:18})}),e("div",{className:"text-[12.5px] leading-relaxed text-ink/75",children:["Confirming will allow the autonomous agent to proceed with this operation. Press ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Enter"})," to confirm or ",e("kbd",{className:"rounded border border-ink/20 bg-paper px-1 py-0.2 font-mono text-[10.5px]",children:"Esc"})," to abort."]})]}),t.method==="input"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Your Response"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:"Press [Enter] to submit"})]}),e("input",{ref:k,type:t.secret===!0?"password":"text",value:c,placeholder:t.placeholder||"Type your response...",onChange:(p)=>m(p.currentTarget.value),onKeyDown:(p)=>{if(p.key==="Enter")p.preventDefault(),M()},className:"w-full rounded-xl border border-ink/15 bg-paper px-4 py-3 text-[13.5px] text-ink placeholder:text-ink/35 outline-none transition-all focus:border-ink focus:ring-2 focus:ring-ink/15"})]}),t.method==="editor"&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between text-[11px] font-medium tracking-wider text-ink/50 uppercase",children:[e("span",{children:"Buffer Content"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:[c.split(`
|
|
2
|
+
`).length," lines · ⌘↵ to save"]})]}),e("textarea",{ref:h,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:N,onSubmit:M})]})})}export{ke as ExtensionDialog};
|