@kabmo-labs/kabmo 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/static/js/{CsvGrid-vze4m5ag.js → CsvGrid-0amzgtd7.js} +2 -2
- package/dist/client/static/js/{DocxView-jbf21gmh.js → DocxView-bxjhzxe9.js} +3 -3
- package/dist/client/static/js/{DrawioView-b52qybx5.js → DrawioView-7s1yqsf4.js} +2 -2
- package/dist/client/static/js/{ImageView-mdgzj8px.js → ImageView-ycfbn66h.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-3c49dvtt.js → LayoutWrapper-tw1q1x0g.js} +2 -2
- package/dist/client/static/js/{Modal-sqp864vd.js → Modal-wqjactyd.js} +16 -16
- package/dist/client/static/js/{PdfView-g06rxqb1.js → PdfView-x6dmtwvr.js} +1 -1
- package/dist/client/static/js/{SessionsView-521adxyr.js → SessionsView-t85wq0me.js} +1 -1
- package/dist/client/static/js/{SheetView-h8xmsz7q.js → SheetView-n52nvz8s.js} +13 -13
- package/dist/client/static/js/{SvgPreview-1j4jvcvz.js → SvgPreview-59z7syme.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-pasxh4b6.js → abnfDiagram-O67JEVCF-91gnt049.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-bajpnvy7.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-ms14g0bm.js → architectureDiagram-NJMV4G6O-5b9qtff2.js} +3 -3
- package/dist/client/static/js/{astro-80bs6hvg.js → astro-31cbyw7b.js} +1 -1
- package/dist/client/static/js/bash-0h36tk0k.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-ycn78fcq.js → blockDiagram-BEXU5L5S-6f23fjkn.js} +3 -3
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-vn2gpjfm.js → c4Diagram-YGBWAQC7-76t6d3am.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fyrm1pr5.js → classDiagram-v2-NBCMYWYE-f9tb19xm.js} +3 -3
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-ea5nwvgq.js → cose-bilkent-JH36ORCC-t6nwrbwj.js} +1 -1
- package/dist/client/static/js/cpp-4wp9sy20.js +1 -0
- package/dist/client/static/js/css-c9nsbkh6.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-8q9e90m8.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-j6bsjpre.js → cynefinDiagram-VND7K2PF-69gc244j.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-4smdkwv8.js → dagre-6A5THRUB-54bry3ey.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-9sm4kqwc.js → diagram-22UHCM2B-gfkebye6.js} +5 -5
- package/dist/client/static/js/{diagram-3UASUU5V-2h3qxaed.js → diagram-3UASUU5V-a1mr319f.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-1981bc94.js → diagram-ATOU4E4O-tkyk0qbe.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-3vgsxavc.js → diagram-CDSNMT55-np0hc9m2.js} +2 -2
- package/dist/client/static/js/{diagram-MLGK6HIB-c9gf2r3f.js → diagram-MLGK6HIB-nh06fshp.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-gjqeq92d.js → diagram-MPIPVDR6-27q2veks.js} +1 -1
- package/dist/client/static/js/{dockerfile-8v935dkn.js → dockerfile-4rtt6c0f.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4vbsgh99.js → ebnfDiagram-ZINNZB2B-x9p9jqe8.js} +1 -1
- package/dist/client/static/js/{elixir-vcbg60wv.js → elixir-rpa1g4gy.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-nca3t891.js → elk-276RUBZZ-fw7waks3.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-5kfkev03.js → erDiagram-OPXOYQCR-fdfgzr5d.js} +5 -5
- package/dist/client/static/js/{erlang-qt876zrq.js → erlang-trjm07as.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-kn4hsm3p.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ah8cvps1.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-mxc73wmq.js → ganttDiagram-FUAMR5RP-2avbqgdr.js} +2 -2
- package/dist/client/static/js/gitGraph-4MIJSDKK-hvavh16n.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-7en3ag0e.js → gitGraphDiagram-X574FWY7-9jmc0a3g.js} +2 -2
- package/dist/client/static/js/graphql-hbkmxsty.js +1 -0
- package/dist/client/static/js/html-pv88ny12.js +1 -0
- package/dist/client/static/js/{index-4g46wbdw.js → index-0v34a7wf.js} +1 -1
- package/dist/client/static/js/{index-vtbbfwx0.js → index-1wjp16f0.js} +2 -2
- package/dist/client/static/js/{index-7a64yjrm.js → index-2v1nmxwr.js} +5 -5
- package/dist/client/static/js/{index-rs80cwsv.js → index-3ecsp1rx.js} +3 -3
- package/dist/client/static/js/{index-1y9r4frb.js → index-43qpbxjv.js} +2 -2
- package/dist/client/static/js/{index-ag2rmtas.js → index-4vybd9e7.js} +1 -1
- package/dist/client/static/js/{index-ahv9y42z.js → index-6f6cmcbq.js} +2 -2
- package/dist/client/static/js/{index-vy6termr.js → index-7ct7qrsp.js} +2 -2
- package/dist/client/static/js/{index-fvmfge3p.js → index-7q02xnvq.js} +1 -1
- package/dist/client/static/js/{index-rytaa8ca.js → index-7smwzkvq.js} +2 -2
- package/dist/client/static/js/{index-nccwxv0s.js → index-8f9x7ev8.js} +1 -1
- package/dist/client/static/js/{index-7y6rpsrp.js → index-8mwragbj.js} +2 -2
- package/dist/client/static/js/{index-52rqxgya.js → index-8x9ecxb0.js} +1 -1
- package/dist/client/static/js/{index-ptcrwswj.js → index-9ketbkh6.js} +1 -1
- package/dist/client/static/js/{index-s7gkkkyz.js → index-a293pdg7.js} +2 -2
- package/dist/client/static/js/{index-vhqe0y82.js → index-a628fg4m.js} +2 -2
- package/dist/client/static/js/{index-c3ek61zv.js → index-a8ffattk.js} +2 -2
- package/dist/client/static/js/{index-a0fmsv1d.js → index-b8s3xraa.js} +6 -6
- package/dist/client/static/js/index-btr2w8cq.js +12 -0
- package/dist/client/static/js/index-dfzrpy54.js +2 -0
- package/dist/client/static/js/{index-g2dyfze9.js → index-ee2p07eg.js} +1 -1
- package/dist/client/static/js/{index-ybm2x4vh.js → index-ek2e773p.js} +1 -1
- package/dist/client/static/js/{index-4qwzxj81.js → index-fvc0x6nx.js} +3 -3
- package/dist/client/static/js/{index-3zc1b0dv.js → index-jc1yagmk.js} +2 -2
- package/dist/client/static/js/{index-p0nz38bm.js → index-jmxqefe3.js} +1 -1
- package/dist/client/static/js/{index-1ksg88qf.js → index-k7q01ye4.js} +2 -2
- package/dist/client/static/js/{index-r014brzs.js → index-kdkfyrja.js} +2 -2
- package/dist/client/static/js/{index-0vm41je9.js → index-mc4nefs7.js} +1 -1
- package/dist/client/static/js/{index-j51d5a5m.js → index-nb8tp4mj.js} +30 -30
- package/dist/client/static/js/{index-cgzrpvzj.js → index-ncrenheb.js} +172 -172
- package/dist/client/static/js/{index-f7jhhqtk.js → index-p16scjt7.js} +2 -2
- package/dist/client/static/js/{index-pm6xxwz1.js → index-pc6eg8h2.js} +2 -2
- package/dist/client/static/js/{index-zvfvqvn9.js → index-pnt0vc59.js} +2 -2
- package/dist/client/static/js/{index-jsyekbx9.js → index-py2k8std.js} +2 -2
- package/dist/client/static/js/{index-dbe6afkf.js → index-pzbssnsc.js} +2 -2
- package/dist/client/static/js/{index-qckv9nte.js → index-qqz6bcdd.js} +2 -2
- package/dist/client/static/js/{index-xx6mqpxm.js → index-rbgemjsp.js} +3 -3
- package/dist/client/static/js/{index-rzxcj7cg.js → index-rkn0bxxt.js} +1 -1
- package/dist/client/static/js/{index-76zb4m0n.js → index-rv89xpaf.js} +2 -2
- package/dist/client/static/js/index-sbd5e816.js +1 -0
- package/dist/client/static/js/{index-1b0t1428.js → index-sdby39w4.js} +3 -3
- package/dist/client/static/js/{index-ev3yt353.js → index-t6c0pd43.js} +2 -2
- package/dist/client/static/js/{index-km2zb6wk.js → index-tp7yb3bv.js} +2 -2
- package/dist/client/static/js/{index-fta1y9pc.js → index-vnw3hbeg.js} +27 -27
- package/dist/client/static/js/{index-354mqqra.js → index-vq6wts05.js} +2 -2
- package/dist/client/static/js/{index-ptcwae2n.js → index-w5373tg1.js} +2 -2
- package/dist/client/static/js/{index-cd65zqba.js → index-w7tpgt46.js} +1 -1
- package/dist/client/static/js/{index-b29afsjh.js → index-whbtxmwh.js} +2 -2
- package/dist/client/static/js/{index-2svnq5gg.js → index-xs1m0bpt.js} +1 -1
- package/dist/client/static/js/{index-eyfcm0cy.js → index-xxtsm2rb.js} +2 -2
- package/dist/client/static/js/{index-hf52f59k.js → index-y3ms153k.js} +2 -2
- package/dist/client/static/js/{index-sd66wv26.js → index-yq39qbs1.js} +2 -2
- package/dist/client/static/js/{index-j0r5hj0j.js → index-zh2jj56s.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-fmjz8qwg.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-sef80132.js → infoDiagram-VRGFBTTK-g2dky5xg.js} +1 -1
- package/dist/client/static/js/ini-72yrpvd4.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-yhvepp1q.js → ishikawaDiagram-OU5B5YK6-exrcjwp1.js} +2 -2
- package/dist/client/static/js/java-ab5tb2ra.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-5w77y95w.js → journeyDiagram-ZHPQQLJL-pn752qa5.js} +3 -3
- package/dist/client/static/js/jsx-25zj9j3k.js +1 -0
- package/dist/client/static/js/{julia-d4j6wgvf.js → julia-evn99h2m.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-02znqtna.js → kanban-definition-PNTS6WVX-v8nvr373.js} +2 -2
- package/dist/client/static/js/lua-j5w0c9wm.js +1 -0
- package/dist/client/static/js/markdown-j6hn4377.js +1 -0
- package/dist/client/static/js/{mermaid.core-a6e6vck4.js → mermaid.core-egzv89zv.js} +6 -6
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-y4n74q9x.js → mindmap-definition-NLK3R4M7-t9njmv2w.js} +2 -2
- package/dist/client/static/js/one-dark-pro-bm3r4js7.js +1 -0
- package/dist/client/static/js/one-light-e07dt7sy.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-cwr6n1cm.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-pr7ehgzb.js → pegDiagram-GJSIUBJH-zhycy2b7.js} +1 -1
- package/dist/client/static/js/{perl-srptw5vm.js → perl-506fy8m8.js} +1 -1
- package/dist/client/static/js/{php-n89g3fk7.js → php-axtsvxck.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-h1ebfzgt.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-39wpsk08.js → pieDiagram-5QR66LMP-sgctvma2.js} +2 -2
- package/dist/client/static/js/properties-q8njes42.js +1 -0
- package/dist/client/static/js/python-vqxc7181.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-esm913km.js → quadrantDiagram-O4NWA36T-kzzhdcph.js} +1 -1
- package/dist/client/static/js/r-0k5eej8m.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-k7p1m364.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-d08dw3t0.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-txnjycgk.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-p0r3cv6w.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-sryk900a.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-wy2mgya6.js → railroadDiagram-XR7U4H2S-nzjffwxm.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-6z9xdgbq.js → requirementDiagram-PLB6GJNP-tz4xxn4d.js} +1 -1
- package/dist/client/static/js/{ruby-r81ytgcm.js → ruby-qp7zfk2m.js} +1 -1
- package/dist/client/static/js/{rust-frn3szvc.js → rust-fz913fvw.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-rtmxk3ys.js → sankeyDiagram-IPEJSGJF-2wcb0xr6.js} +2 -2
- package/dist/client/static/js/{sass-9bxped7y.js → sass-gnk9vsyp.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-awzcrafg.js → sequenceDiagram-PO4LG4MO-vqgebfns.js} +5 -5
- package/dist/client/static/js/{sizeCapture-INFHLROL-03gy196j.js → sizeCapture-INFHLROL-xc314tes.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-an8v3q5n.js → stateDiagram-v2-GCMORJYK-8bd9b1h8.js} +2 -2
- package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-brpgzrtv.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-n9yb4wcs.js → swimlanes-2SLR337P-t6hbdzcw.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-c1czc7kv.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-jceb575g.js → timeline-definition-EJHVYXUP-2txxasx5.js} +2 -2
- package/dist/client/static/js/treeView-Q6P3EWNA-77kj68p1.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-rw94xc82.js +1 -0
- package/dist/client/static/js/tsx-yd5wt250.js +1 -0
- package/dist/client/static/js/typescript-v7z7crfe.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-888h3100.js → usecaseDiagram-POWQR4AR-3x353hn4.js} +5 -5
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-wbfz0rzv.js → vennDiagram-UO4OBE2U-cerpss8e.js} +1 -1
- package/dist/client/static/js/{vue-c0rtg1wf.js → vue-apnkw9qy.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-18xe4fhz.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-rn8c5qf9.js → wardleyDiagram-VNRHLVJA-cx6jfsbf.js} +1 -1
- package/dist/client/static/js/xml-94fhzrfs.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-8sn1apt6.js → xychartDiagram-PMCCYNJV-tgn23xj1.js} +2 -2
- package/dist/client/static/js/yaml-s8af9rnw.js +1 -0
- package/package.json +1 -1
- package/src/client/components/settings/categories/connect-settings/PairDialog.test.tsx +159 -0
- package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +36 -7
- package/src/client/components/settings/categories/connect-settings/QrCode.tsx +2 -19
- package/src/client/components/settings/categories/connect-settings/qr-image.ts +76 -0
- package/src/client/components/workspace/git-panel/init-state.test.ts +5 -0
- package/src/client/hooks/chat/composer/speech-to-text.ts +24 -17
- package/src/client/hooks/editor/file-actions.ts +3 -11
- package/src/client/hooks/editor/font.test.ts +2 -1
- package/src/client/hooks/editor/use-file-transfer.ts +2 -1
- package/src/client/lib/browser/download.ts +22 -0
- package/src/shared/lib/dictation/capture-failure.test.ts +46 -0
- package/src/shared/lib/dictation/capture-failure.ts +36 -0
- package/dist/client/static/js/architecture-7GRP2DOG-fc9kmq1w.js +0 -1
- package/dist/client/static/js/bash-b3rwyg5p.js +0 -1
- package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
- package/dist/client/static/js/css-6vj0d308.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-a4t8992q.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-18bdrkv5.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-fg0yqx0h.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-8fa6y40p.js +0 -1
- package/dist/client/static/js/graphql-n43pd5fs.js +0 -1
- package/dist/client/static/js/html-dbrwss36.js +0 -1
- package/dist/client/static/js/index-231241f4.js +0 -12
- package/dist/client/static/js/index-6sf2vsp2.js +0 -1
- package/dist/client/static/js/index-h5bn97p6.js +0 -2
- package/dist/client/static/js/info-A6RAGUB7-3hk844f7.js +0 -1
- package/dist/client/static/js/ini-j5dyq6gm.js +0 -1
- package/dist/client/static/js/java-g4dgwbfd.js +0 -1
- package/dist/client/static/js/jsx-7t5ecz9s.js +0 -1
- package/dist/client/static/js/lua-1g6w30de.js +0 -1
- package/dist/client/static/js/markdown-afx21x8c.js +0 -1
- package/dist/client/static/js/one-dark-pro-vwhfpzr8.js +0 -1
- package/dist/client/static/js/one-light-y5t9x6zh.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-4nj2yy10.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-k7rde3f9.js +0 -1
- package/dist/client/static/js/properties-thd83wey.js +0 -1
- package/dist/client/static/js/python-264ns4xw.js +0 -1
- package/dist/client/static/js/r-qw82kkv9.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-513dpw4f.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-9bqnst9c.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-7367d5bv.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-b806b1mj.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-5a67rwf8.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-nx5nfnf0.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-kcy40evb.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-fsrvqxf4.js +0 -1
- package/dist/client/static/js/tsx-nm94hed6.js +0 -1
- package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-36dmxww4.js +0 -1
- package/dist/client/static/js/xml-dz51p1m3.js +0 -1
- package/dist/client/static/js/yaml-2cfkd30t.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Mn,Ni,Qm,ts,so,Zs,Hu,Xs,Vf,Wu,Nm,Rm,Fm,Lm,Zg,el,Ku,Xg,Vu,Br,eh}from"./index-ncrenheb.js";export{Xs as IndentContext,eh as StreamLanguage,Vu as bracketMatching,el as codeFolding,Fm as foldAll,Nm as foldCode,Ku as foldGutter,Zg as foldKeymap,Wu as foldService,so as getIndentUnit,Hu as getIndentation,Xg as highlightingFor,Vf as indentOnInput,Qm as indentService,Zs as indentString,ts as indentUnit,Ni as language,Br as matchBrackets,Mn as syntaxTree,Lm as unfoldAll,Rm as unfoldCode};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{d,n,i,V,o,u,a,Ar,e,gr,li,Gn,gp,we,S,bp,Ff,ir,or,s,Ma,Be,Pa,m,En,M,D,Xe,f,B,ie,et,ae,he,fe,_n,Jt,Sn,Y,C,ct,va,F,fi,tn,b,ce,Tu,no,J,rt,at,dt,Ve,ge}from"./index-cgzrpvzj.js";import{pp,fr}from"./index-f7jhhqtk.js";var Tt={name:"folder-tree",size:24,node:[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]},_e=s(Tt);var At={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]},je=s(At);function Ue({message:t,hasStagedChanges:c,isBusy:l=!1,amend:r=!1,seeded:p=!1,onToggleAmend:h,onChangeMessage:g,onCommit:v}){let y=t.trim().length>0&&!l&&(r||c),L=r?"Rewrite the previous commit with this message":c?"Commit staged changes":"Stage changes first";return e("div",{className:"border-t border-ink/10 bg-canvas/50 p-3 flex flex-col gap-2",children:[e("textarea",{value:t,onChange:(N)=>g(N.currentTarget.value),onKeyDown:(N)=>{if(N.key==="Enter"&&(N.metaKey||N.ctrlKey)&&y)N.preventDefault(),v()},placeholder:r?"New message for the previous commit (⌘/Ctrl+Enter to commit)":"Commit message (⌘/Ctrl+Enter to commit)",rows:5,className:"w-full resize-y min-h-[100px] max-h-[200px] bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),e("div",{className:"flex items-center gap-2",children:[e("label",{className:"flex items-center gap-1.5 text-[11px] text-ink/70 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:r,onChange:(N)=>h?.(N.currentTarget.checked),className:`${ge} accent-ink cursor-pointer`}),"Amend"]}),r&&p&&e("span",{className:"text-[10px] text-ink/40",title:"The previous commit's message, loaded as an editable starting point",children:"previous message loaded"}),e("button",{type:"button",onClick:v,disabled:!y,title:L,className:"ml-auto flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(f,{size:12}),r?"Amend commit":"Commit"]})]})]})}function We({operation:t,conflicts:c,isBusy:l,onAbort:r,onContinue:p}){let h=li[t],g=c.length,v=g===0,y=t!=="stash-pop";return e("div",{className:"border-t border-warning/30 bg-warning/5 p-3 flex flex-col gap-2",children:[e("div",{className:"flex items-center gap-2 text-xs text-ink",children:[e(D,{size:13,className:"text-warning flex-shrink-0"}),e("span",{className:"font-medium",children:[h.charAt(0).toUpperCase()+h.slice(1)," in progress"]}),e("span",{className:`font-mono tabular-nums text-[10px] ${v?"text-success":"text-warning"}`,children:v?"all conflicts resolved":`${g} conflict${g===1?"":"s"} left`})]}),!v&&e("div",{className:"max-h-20 overflow-y-auto scrollbar-overlay-container font-mono text-[10px] text-warning/90 space-y-0.5",children:c.map((L)=>e("div",{className:"truncate",title:L,children:L},L))}),e("div",{className:"flex items-stretch gap-2",children:[e("button",{type:"button",onClick:r,disabled:l,title:`Abort the ${h} and restore the previous state`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(tn,{size:12}),"Abort ",h]}),y&&e("button",{type:"button",onClick:p,disabled:l||!v,title:v?`Conclude the ${h}`:`Resolve all ${g} conflict(s) first`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-transparent bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(_n,{size:12}),"Continue ",h]})]})]})}function qe({branchRef:t,showBranchMenu:c,setShowBranchMenu:l,branch:r,branches:p,remoteBranches:h,onCheckout:g,onMerge:v,onOpenBranchPrompt:y,onManageBranches:L,optionsRef:N,showOptions:G,setShowOptions:R,onHistory:P,onGraph:T,viewMode:k,setViewMode:x,isBusy:w=!1,syncCount:E={ahead:0,behind:0},syncing:z=!1,onSync:I,onFetch:A,detached:H=!1}){return e("div",{className:"p-3 border-b border-ink/10 bg-canvas/50 flex items-center justify-between",children:[e("div",{className:"relative",ref:t,children:[e("button",{onClick:()=>l(!c),className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 -ml-2 rounded transition-colors text-[11px] text-ink/80 font-medium",title:H?`Detached HEAD at ${r}`:`On branch ${r}`,children:[e(fe,{size:12,className:H?"text-warning":"text-ink/60"}),e("span",{className:`truncate max-w-[140px] ${H?"font-mono text-warning":""}`,children:r}),e(B,{size:12,className:"text-ink/40"})]}),c&&e("div",{className:"glass-popover absolute top-full left-0 mt-1 w-56 bg-paper border border-ink/20 rounded-md shadow-lg z-50 flex flex-col overflow-hidden text-xs",children:e("div",{className:"max-h-48 scrollbar-overlay-container py-1",children:[p.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Local"}),p.map((O)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(O),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:O}),r===O&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==O&&e("button",{type:"button",onClick:()=>{v(O),l(!1)},title:`Merge ${O} into ${r}`,"aria-label":`Merge ${O} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(_n,{size:12})})]},O))]}),h.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Remote"}),h.map((O)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(O),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:O}),r===O&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==O&&e("button",{type:"button",onClick:()=>{v(O),l(!1)},title:`Merge ${O} into ${r}`,"aria-label":`Merge ${O} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(_n,{size:12})})]},O))]}),e("div",{className:"w-full h-px bg-ink/10 my-1"}),e("button",{onClick:()=>{y(),l(!1)},className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80 italic",children:[e(Y,{size:12}),e("span",{children:"Create new branch..."})]}),e("button",{onClick:L,className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80",children:[e(fi,{size:12}),e("span",{children:"Manage branches..."})]})]})})]}),e("div",{className:"flex items-center space-x-2 text-ink/40 relative",ref:N,children:[e("button",{type:"button",onClick:A,disabled:w,title:"Fetch from all remotes and prune deleted branches","aria-label":"Fetch",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e(Ma,{size:13})}),e("button",{type:"button",onClick:I,disabled:w,title:z?"Syncing with upstream…":E.ahead>0&&E.behind>0?`Pull ${E.behind} then push ${E.ahead} commit(s)`:E.ahead>0?`Push ${E.ahead} commit(s)`:E.behind>0?`Pull ${E.behind} commit(s)`:"Up to date — sync anyway","aria-label":"Sync with upstream","aria-busy":z,className:`flex items-center gap-1 p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:cursor-not-allowed ${z?"":"disabled:opacity-40"}`,children:[e(C,{size:13,className:z?"animate-spin":"","aria-hidden":"true"}),e("span",{className:"font-mono tabular-nums text-[10px]",children:["↑",E.ahead," ↓",E.behind]})]}),e("button",{type:"button",onClick:P,title:"Commit History","aria-label":"Commit History",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(En,{size:13})}),e("button",{type:"button",onClick:T,title:"Git Graph","aria-label":"Git Graph",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(_n,{size:13})}),e("button",{type:"button",onClick:()=>R(!G),title:"View Options","aria-label":"View Options","aria-expanded":G,className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Be,{size:13})}),G&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-36 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 font-mono text-xs",children:[e("button",{type:"button",onClick:()=>{x("flat"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(je,{size:12,className:"text-ink/60"}),e("span",{children:"View as List"})]}),k==="flat"&&e(f,{size:12,className:"text-ink"})]}),e("button",{type:"button",onClick:()=>{x("tree"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(_e,{size:12,className:"text-ink/60"}),e("span",{children:"View as Tree"})]}),k==="tree"&&e(f,{size:12,className:"text-ink"})]})]})]})]})}function Ke({activeRepo:t,repos:c,isRefreshing:l,rootPath:r,reposScanning:p,onSelectRepo:h,onRefresh:g,onRefreshRepos:v}){return e("div",{className:"p-3 border-b border-ink/10 flex items-center justify-between",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e(pp,{size:12,className:"text-ink/50 flex-shrink-0","aria-hidden":!0}),e(fr,{rootPath:r,activeRepo:t,onSelectRepo:h,repos:c,scanning:p,onRefreshRepos:v})]}),e("div",{className:"flex space-x-2 text-ink/40",children:e("button",{type:"button",onClick:g,title:"Refresh","aria-label":"Refresh",className:"hover:text-ink cursor-pointer inline-flex",children:e(ct,{size:14,className:l?"animate-spin":""})})})]})}function Te({change:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let h=Gn(t.status,c),{charStatus:g,colorClass:v}=h,y=t.file.split("/"),L=y.pop()||t.file,N=y.length>0?y.join("/"):"";return e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-ink/5 cursor-pointer group text-[11px] transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:c,status:g,repo:l||".",root:r}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e("span",{className:`font-bold font-mono text-[10px] w-3 flex-shrink-0 text-center ${v}`,title:`Status: ${h.label}`,children:g}),e(rt,{name:L,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${v}`,title:t.file,children:L}),N&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:N})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:[!c&&e(d,{children:[e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),p("revert",t.file)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:11})}),e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),p("stage",t.file)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}),c&&e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),p("unstage",t.file)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})]})})]})}function Ye({change:t,repo:c,rootPath:l,onResolve:r}){let[p,h]=n(!1),[g,v]=n(null),y=t.file.split("/"),L=y.pop()||t.file,N=y.length>0?y.join("/"):"",G=()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:!1,status:t.status,repo:c,root:l}}))},R=async()=>{let k=!p;if(h(k),k&&g===null){let x=new URLSearchParams({conflictMarkers:"1",file:t.file,repo:c||"."});if(l)x.set("root",l);try{let E=await(await fetch(`/api/fs/git?${x.toString()}`)).json();v(E.markers??{})}catch{v({})}}},P=g?.ours||"ours",T=g?.theirs||"theirs";return e("div",{className:"border-b border-warning/20 last:border-b-0",children:[e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-warning/5 cursor-pointer group text-[11px] transition-colors",onClick:G,children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e(Pa,{size:11,className:"text-warning flex-shrink-0"}),e(rt,{name:L,size:12,className:"flex-shrink-0"}),e("span",{className:"truncate text-warning",title:t.file,children:L}),N&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:N}),gr(t.status)&&e("span",{className:"text-[10px] text-warning/70 font-mono flex-shrink-0",children:t.status})]}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),R()},title:p?"Hide resolve actions":"Show resolve actions","aria-label":p?"Hide resolve actions":"Show resolve actions","aria-expanded":p,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors flex-shrink-0",children:p?e(et,{size:11}):e(B,{size:11})})]}),p&&e("div",{className:"px-3 pb-2 pt-0.5 flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>r(t.file,"ours"),title:`Take ${P} — \`git checkout --ours\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",P]}),e("button",{type:"button",onClick:()=>r(t.file,"theirs"),title:`Take ${T} — \`git checkout --theirs\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",T]}),e("button",{type:"button",onClick:()=>r(t.file,""),title:"Mark resolved: the file was edited by hand, this stages it",className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer flex items-center gap-1",children:[e(f,{size:10}),"mark resolved"]})]})]})}function Bt(t){let c={id:"",name:"",path:"",type:"folder",children:[],changeCount:0};for(let r of t){let p=r.file.replace(/^[./]+/,""),h=p.endsWith("/"),g=p.replace(/\/$/,"").split("/").filter(Boolean),v=c,y="";for(let L=0;L<g.length;L++){let N=g[L];y=y?`${y}/${N}`:N;let G=L===g.length-1;if(G&&!h)v.children.push({id:y,name:N,path:y,type:"file",change:r,children:[],changeCount:1});else{let P=v.children.find((T)=>T.type==="folder"&&T.name===N);if(!P)P={id:y,name:N,path:y,type:"folder",children:[],changeCount:0,change:G&&h?r:void 0},v.children.push(P);v=P}}}function l(r){if(r.type==="file")return 1;let p=r.change?1:0;for(let h of r.children)p+=l(h);return r.changeCount=p,r.children.sort((h,g)=>{if(h.type==="folder"&&g.type==="file")return-1;if(h.type==="file"&&g.type==="folder")return 1;return h.name.localeCompare(g.name)}),p}return l(c),c.children}function Ze(t){let{sessionId:c,ready:l,read:r}=bp(),p=u(()=>Bt(t),[t]),h=u(()=>{let R=new Set;function P(T){for(let k of T)if(k.type==="folder"){if(R.add(k.id),k.children&&k.children.length>0)P(k.children)}}return P(p),R},[p]),[g,v]=S("git.expandedFolders",[]),y=u(()=>new Set(g),[g]),L=o(null);i(()=>{if(!l||L.current===c)return;if(h.size===0)return;if(L.current=c,r("git.expandedFolders",[]).length>0)return;v(Array.from(h))},[l,c,h,r,v]);let N=a((R)=>{v((P)=>{let T=new Set(P);if(T.has(R))T.delete(R);else T.add(R);return Array.from(T)})},[v]),G=a((R)=>y.has(R),[y]);return{tree:p,expandedFolders:y,toggleFolder:N,isFolderOpen:G,expandAll:()=>v(Array.from(h)),collapseAll:()=>v([])}}function Ae({node:t,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g}){let v=t.type==="folder",y=v?l(t.id):!1;if(v)return e("div",{className:"select-none",children:[e("div",{className:"flex items-center justify-between px-2 py-1 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>r(t.id),children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center text-ink/40 flex-shrink-0",children:y?e(B,{size:12}):e(ie,{size:12})}),e(rt,{name:t.name,isFolder:!0,isOpen:y,size:13,className:"flex-shrink-0"}),e("span",{className:"font-medium text-ink truncate",children:t.name}),e("span",{className:"text-[10px] text-ink/40 font-normal px-1 py-0.2 bg-ink/5 rounded-full ml-1",children:t.changeCount})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",t.path)},title:`Discard changes in ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",t.path)},title:`Stage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",t.path)},title:`Unstage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})})})]}),y&&t.children&&t.children.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:t.children.map((k)=>e(Ae,{node:k,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g},k.id))})]});let L=t.change,N=Gn(L?.status||"M",c),{charStatus:G,colorClass:R}=N,P=L?L.file:t.path;return e("div",{className:"flex items-center justify-between px-2 py-0.5 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:P,staged:c,status:G,repo:h||".",root:g}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center flex-shrink-0",children:e("span",{className:`font-bold font-mono text-[10px] ${R}`,title:`Status: ${N.label}`,children:G})}),e(rt,{name:t.name,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${R}`,title:P,children:t.name})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",P)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",P)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",P)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})})})]})}function Fe({changes:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let{tree:h,isFolderOpen:g,toggleFolder:v}=Ze(t);if(h.length===0)return null;return e("div",{className:"py-0.5",children:h.map((y)=>e(Ae,{node:y,isStaged:c,isFolderOpen:g,toggleFolder:v,onAction:p,repo:l,rootPath:r},y.id))})}function Qe({changes:t,isLoading:c,viewMode:l,repo:r,rootPath:p,onAction:h,onResolve:g}){let[v,y]=S("git.stagedExpanded",!0),[L,N]=S("git.unstagedExpanded",!0),[G,R]=S("git.conflictsExpanded",!0),P=t.filter((x)=>gr(x.status)),T=t.filter((x)=>{if(gr(x.status))return!1;let w=x.status;return w&&w[0]!==" "&&w[0]!=="?"}),k=t.filter((x)=>{if(gr(x.status))return!1;let w=x.status;return w&&w[1]!==" "&&w[1]!=="?"||w==="??"});if(c&&t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"Loading..."})});if(t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"No changes found."})});return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"py-1",children:[P.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-warning/5 cursor-pointer transition-colors",onClick:()=>R(!G),children:e("div",{className:"flex items-center space-x-1 font-semibold text-warning text-xs",children:[e("span",{className:"w-3 text-center",children:G?"▾":"▸"}),e("span",{children:"Conflicts"}),e("span",{className:"text-warning/70 font-normal ml-1 border border-warning/30 rounded-full px-1.5 text-[10px] bg-paper",children:P.length})]})}),G&&P.map((x)=>e(Ye,{change:x,repo:r,rootPath:p,onResolve:g??(()=>{})},`conflict-${x.file}`))]}),T.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>y(!v),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:v?"▾":"▸"}),e("span",{children:"Staged Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:T.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("unstage_all")},title:"Unstage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:12})})})]}),v&&(l==="tree"?e(Fe,{changes:T,isStaged:!0,repo:r,rootPath:p,onAction:h}):T.map((x)=>e(Te,{change:x,isStaged:!0,repo:r,rootPath:p,onAction:h},x.file+"staged")))]}),k.length>0&&e("div",{children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>N(!L),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:L?"▾":"▸"}),e("span",{children:"Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:k.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:[e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("revert_all")},title:"Discard All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:12})}),e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("stage_all")},title:"Stage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:12})})]})]}),L&&(l==="tree"?e(Fe,{changes:k,isStaged:!1,repo:r,rootPath:p,onAction:h}):k.map((x)=>e(Te,{change:x,isStaged:!1,repo:r,rootPath:p,onAction:h},x.file+"unstaged")))]})]})})}function Je({matches:t,loaded:c,total:l,hasMore:r,isFiltering:p}){if(p)return`${t} of ${c} loaded`;if(typeof l==="number"&&l>0)return r||c<l?`${c} of ${l}`:`${l} commits`;return r?`${c}+ commits`:`${c} commits`}function tt({isGraphMode:t,onToggleMode:c,searchQuery:l,onSearchChange:r,onRefresh:p,onClose:h,isRefreshing:g,totalCommits:v,loadedCount:y,totalCount:L,hasMore:N}){let G=Je({matches:v,loaded:y,total:L,hasMore:N,isFiltering:l.trim().length>0});return e("div",{className:`flex flex-col gap-2 px-3 lg:px-5 py-3 border-b border-ink/10 bg-paper select-none
|
|
2
|
-
pl-[max(0.75rem,env(safe-area-inset-left,0px))] pr-[max(0.75rem,env(safe-area-inset-right,0px))]`,children:[e("div",{className:"flex items-center justify-between gap-2 lg:gap-4",children:[e("div",{className:"flex flex-col min-w-0",children:[e("div",{className:"flex items-center gap-2.5 min-w-0",children:[e("h2",{className:"text-base font-semibold text-ink tracking-tight",children:t?"Graph":"History"}),e("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-ink/5 text-ink/50 border border-ink/10 whitespace-nowrap",children:G})]}),e("p",{className:"text-xs text-ink/50 mt-0.5 hidden lg:block",children:"Browse recent commits and inspect changed files."})]}),e("div",{className:"flex items-center gap-1.5 lg:gap-2 flex-shrink-0",children:[e("div",{className:"flex items-center bg-ink/5 p-0.5 rounded-lg border border-ink/10 text-xs",children:[e("button",{type:"button",onClick:()=>c(!1),title:"History view",className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md font-medium transition-colors cursor-pointer ${!t?"bg-paper text-ink shadow-xs":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:[e(
|
|
1
|
+
import{d,n,i,V,o,u,a,Ar,e,gr,li,Gn,hp,we,S,yp,Mf,ir,or,s,Ma,Be,Pa,m,Bn,M,D,Xe,f,B,ie,et,ae,he,fe,Sn,Jt,Tn,Y,C,ct,va,F,fi,tn,b,ce,Du,no,J,rt,at,dt,Ve,ge}from"./index-ncrenheb.js";import{mp,fr}from"./index-p16scjt7.js";var Tt={name:"folder-tree",size:24,node:[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]},_e=s(Tt);var At={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]},je=s(At);function Ue({message:t,hasStagedChanges:c,isBusy:l=!1,amend:r=!1,seeded:p=!1,onToggleAmend:h,onChangeMessage:g,onCommit:v}){let y=t.trim().length>0&&!l&&(r||c),L=r?"Rewrite the previous commit with this message":c?"Commit staged changes":"Stage changes first";return e("div",{className:"border-t border-ink/10 bg-canvas/50 p-3 flex flex-col gap-2",children:[e("textarea",{value:t,onChange:(N)=>g(N.currentTarget.value),onKeyDown:(N)=>{if(N.key==="Enter"&&(N.metaKey||N.ctrlKey)&&y)N.preventDefault(),v()},placeholder:r?"New message for the previous commit (⌘/Ctrl+Enter to commit)":"Commit message (⌘/Ctrl+Enter to commit)",rows:5,className:"w-full resize-y min-h-[100px] max-h-[200px] bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),e("div",{className:"flex items-center gap-2",children:[e("label",{className:"flex items-center gap-1.5 text-[11px] text-ink/70 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:r,onChange:(N)=>h?.(N.currentTarget.checked),className:`${ge} accent-ink cursor-pointer`}),"Amend"]}),r&&p&&e("span",{className:"text-[10px] text-ink/40",title:"The previous commit's message, loaded as an editable starting point",children:"previous message loaded"}),e("button",{type:"button",onClick:v,disabled:!y,title:L,className:"ml-auto flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(f,{size:12}),r?"Amend commit":"Commit"]})]})]})}function We({operation:t,conflicts:c,isBusy:l,onAbort:r,onContinue:p}){let h=li[t],g=c.length,v=g===0,y=t!=="stash-pop";return e("div",{className:"border-t border-warning/30 bg-warning/5 p-3 flex flex-col gap-2",children:[e("div",{className:"flex items-center gap-2 text-xs text-ink",children:[e(D,{size:13,className:"text-warning flex-shrink-0"}),e("span",{className:"font-medium",children:[h.charAt(0).toUpperCase()+h.slice(1)," in progress"]}),e("span",{className:`font-mono tabular-nums text-[10px] ${v?"text-success":"text-warning"}`,children:v?"all conflicts resolved":`${g} conflict${g===1?"":"s"} left`})]}),!v&&e("div",{className:"max-h-20 overflow-y-auto scrollbar-overlay-container font-mono text-[10px] text-warning/90 space-y-0.5",children:c.map((L)=>e("div",{className:"truncate",title:L,children:L},L))}),e("div",{className:"flex items-stretch gap-2",children:[e("button",{type:"button",onClick:r,disabled:l,title:`Abort the ${h} and restore the previous state`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(tn,{size:12}),"Abort ",h]}),y&&e("button",{type:"button",onClick:p,disabled:l||!v,title:v?`Conclude the ${h}`:`Resolve all ${g} conflict(s) first`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-transparent bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Sn,{size:12}),"Continue ",h]})]})]})}function qe({branchRef:t,showBranchMenu:c,setShowBranchMenu:l,branch:r,branches:p,remoteBranches:h,onCheckout:g,onMerge:v,onOpenBranchPrompt:y,onManageBranches:L,optionsRef:N,showOptions:G,setShowOptions:R,onHistory:P,onGraph:T,viewMode:k,setViewMode:x,isBusy:w=!1,syncCount:E={ahead:0,behind:0},syncing:z=!1,onSync:I,onFetch:A,detached:H=!1}){return e("div",{className:"p-3 border-b border-ink/10 bg-canvas/50 flex items-center justify-between",children:[e("div",{className:"relative",ref:t,children:[e("button",{onClick:()=>l(!c),className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 -ml-2 rounded transition-colors text-[11px] text-ink/80 font-medium",title:H?`Detached HEAD at ${r}`:`On branch ${r}`,children:[e(fe,{size:12,className:H?"text-warning":"text-ink/60"}),e("span",{className:`truncate max-w-[140px] ${H?"font-mono text-warning":""}`,children:r}),e(B,{size:12,className:"text-ink/40"})]}),c&&e("div",{className:"glass-popover absolute top-full left-0 mt-1 w-56 bg-paper border border-ink/20 rounded-md shadow-lg z-50 flex flex-col overflow-hidden text-xs",children:e("div",{className:"max-h-48 scrollbar-overlay-container py-1",children:[p.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Local"}),p.map((O)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(O),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:O}),r===O&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==O&&e("button",{type:"button",onClick:()=>{v(O),l(!1)},title:`Merge ${O} into ${r}`,"aria-label":`Merge ${O} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Sn,{size:12})})]},O))]}),h.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Remote"}),h.map((O)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(O),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:O}),r===O&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==O&&e("button",{type:"button",onClick:()=>{v(O),l(!1)},title:`Merge ${O} into ${r}`,"aria-label":`Merge ${O} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Sn,{size:12})})]},O))]}),e("div",{className:"w-full h-px bg-ink/10 my-1"}),e("button",{onClick:()=>{y(),l(!1)},className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80 italic",children:[e(Y,{size:12}),e("span",{children:"Create new branch..."})]}),e("button",{onClick:L,className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80",children:[e(fi,{size:12}),e("span",{children:"Manage branches..."})]})]})})]}),e("div",{className:"flex items-center space-x-2 text-ink/40 relative",ref:N,children:[e("button",{type:"button",onClick:A,disabled:w,title:"Fetch from all remotes and prune deleted branches","aria-label":"Fetch",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e(Ma,{size:13})}),e("button",{type:"button",onClick:I,disabled:w,title:z?"Syncing with upstream…":E.ahead>0&&E.behind>0?`Pull ${E.behind} then push ${E.ahead} commit(s)`:E.ahead>0?`Push ${E.ahead} commit(s)`:E.behind>0?`Pull ${E.behind} commit(s)`:"Up to date — sync anyway","aria-label":"Sync with upstream","aria-busy":z,className:`flex items-center gap-1 p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:cursor-not-allowed ${z?"":"disabled:opacity-40"}`,children:[e(C,{size:13,className:z?"animate-spin":"","aria-hidden":"true"}),e("span",{className:"font-mono tabular-nums text-[10px]",children:["↑",E.ahead," ↓",E.behind]})]}),e("button",{type:"button",onClick:P,title:"Commit History","aria-label":"Commit History",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Bn,{size:13})}),e("button",{type:"button",onClick:T,title:"Git Graph","aria-label":"Git Graph",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Sn,{size:13})}),e("button",{type:"button",onClick:()=>R(!G),title:"View Options","aria-label":"View Options","aria-expanded":G,className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Be,{size:13})}),G&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-36 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 font-mono text-xs",children:[e("button",{type:"button",onClick:()=>{x("flat"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(je,{size:12,className:"text-ink/60"}),e("span",{children:"View as List"})]}),k==="flat"&&e(f,{size:12,className:"text-ink"})]}),e("button",{type:"button",onClick:()=>{x("tree"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(_e,{size:12,className:"text-ink/60"}),e("span",{children:"View as Tree"})]}),k==="tree"&&e(f,{size:12,className:"text-ink"})]})]})]})]})}function Ke({activeRepo:t,repos:c,isRefreshing:l,rootPath:r,reposScanning:p,onSelectRepo:h,onRefresh:g,onRefreshRepos:v}){return e("div",{className:"p-3 border-b border-ink/10 flex items-center justify-between",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e(mp,{size:12,className:"text-ink/50 flex-shrink-0","aria-hidden":!0}),e(fr,{rootPath:r,activeRepo:t,onSelectRepo:h,repos:c,scanning:p,onRefreshRepos:v})]}),e("div",{className:"flex space-x-2 text-ink/40",children:e("button",{type:"button",onClick:g,title:"Refresh","aria-label":"Refresh",className:"hover:text-ink cursor-pointer inline-flex",children:e(ct,{size:14,className:l?"animate-spin":""})})})]})}function Te({change:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let h=Gn(t.status,c),{charStatus:g,colorClass:v}=h,y=t.file.split("/"),L=y.pop()||t.file,N=y.length>0?y.join("/"):"";return e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-ink/5 cursor-pointer group text-[11px] transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:c,status:g,repo:l||".",root:r}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e("span",{className:`font-bold font-mono text-[10px] w-3 flex-shrink-0 text-center ${v}`,title:`Status: ${h.label}`,children:g}),e(rt,{name:L,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${v}`,title:t.file,children:L}),N&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:N})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:[!c&&e(d,{children:[e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),p("revert",t.file)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:11})}),e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),p("stage",t.file)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}),c&&e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),p("unstage",t.file)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})]})})]})}function Ye({change:t,repo:c,rootPath:l,onResolve:r}){let[p,h]=n(!1),[g,v]=n(null),y=t.file.split("/"),L=y.pop()||t.file,N=y.length>0?y.join("/"):"",G=()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:!1,status:t.status,repo:c,root:l}}))},R=async()=>{let k=!p;if(h(k),k&&g===null){let x=new URLSearchParams({conflictMarkers:"1",file:t.file,repo:c||"."});if(l)x.set("root",l);try{let E=await(await fetch(`/api/fs/git?${x.toString()}`)).json();v(E.markers??{})}catch{v({})}}},P=g?.ours||"ours",T=g?.theirs||"theirs";return e("div",{className:"border-b border-warning/20 last:border-b-0",children:[e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-warning/5 cursor-pointer group text-[11px] transition-colors",onClick:G,children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e(Pa,{size:11,className:"text-warning flex-shrink-0"}),e(rt,{name:L,size:12,className:"flex-shrink-0"}),e("span",{className:"truncate text-warning",title:t.file,children:L}),N&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:N}),gr(t.status)&&e("span",{className:"text-[10px] text-warning/70 font-mono flex-shrink-0",children:t.status})]}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),R()},title:p?"Hide resolve actions":"Show resolve actions","aria-label":p?"Hide resolve actions":"Show resolve actions","aria-expanded":p,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors flex-shrink-0",children:p?e(et,{size:11}):e(B,{size:11})})]}),p&&e("div",{className:"px-3 pb-2 pt-0.5 flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>r(t.file,"ours"),title:`Take ${P} — \`git checkout --ours\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",P]}),e("button",{type:"button",onClick:()=>r(t.file,"theirs"),title:`Take ${T} — \`git checkout --theirs\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",T]}),e("button",{type:"button",onClick:()=>r(t.file,""),title:"Mark resolved: the file was edited by hand, this stages it",className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer flex items-center gap-1",children:[e(f,{size:10}),"mark resolved"]})]})]})}function Bt(t){let c={id:"",name:"",path:"",type:"folder",children:[],changeCount:0};for(let r of t){let p=r.file.replace(/^[./]+/,""),h=p.endsWith("/"),g=p.replace(/\/$/,"").split("/").filter(Boolean),v=c,y="";for(let L=0;L<g.length;L++){let N=g[L];y=y?`${y}/${N}`:N;let G=L===g.length-1;if(G&&!h)v.children.push({id:y,name:N,path:y,type:"file",change:r,children:[],changeCount:1});else{let P=v.children.find((T)=>T.type==="folder"&&T.name===N);if(!P)P={id:y,name:N,path:y,type:"folder",children:[],changeCount:0,change:G&&h?r:void 0},v.children.push(P);v=P}}}function l(r){if(r.type==="file")return 1;let p=r.change?1:0;for(let h of r.children)p+=l(h);return r.changeCount=p,r.children.sort((h,g)=>{if(h.type==="folder"&&g.type==="file")return-1;if(h.type==="file"&&g.type==="folder")return 1;return h.name.localeCompare(g.name)}),p}return l(c),c.children}function Ze(t){let{sessionId:c,ready:l,read:r}=yp(),p=u(()=>Bt(t),[t]),h=u(()=>{let R=new Set;function P(T){for(let k of T)if(k.type==="folder"){if(R.add(k.id),k.children&&k.children.length>0)P(k.children)}}return P(p),R},[p]),[g,v]=S("git.expandedFolders",[]),y=u(()=>new Set(g),[g]),L=o(null);i(()=>{if(!l||L.current===c)return;if(h.size===0)return;if(L.current=c,r("git.expandedFolders",[]).length>0)return;v(Array.from(h))},[l,c,h,r,v]);let N=a((R)=>{v((P)=>{let T=new Set(P);if(T.has(R))T.delete(R);else T.add(R);return Array.from(T)})},[v]),G=a((R)=>y.has(R),[y]);return{tree:p,expandedFolders:y,toggleFolder:N,isFolderOpen:G,expandAll:()=>v(Array.from(h)),collapseAll:()=>v([])}}function Ae({node:t,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g}){let v=t.type==="folder",y=v?l(t.id):!1;if(v)return e("div",{className:"select-none",children:[e("div",{className:"flex items-center justify-between px-2 py-1 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>r(t.id),children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center text-ink/40 flex-shrink-0",children:y?e(B,{size:12}):e(ie,{size:12})}),e(rt,{name:t.name,isFolder:!0,isOpen:y,size:13,className:"flex-shrink-0"}),e("span",{className:"font-medium text-ink truncate",children:t.name}),e("span",{className:"text-[10px] text-ink/40 font-normal px-1 py-0.2 bg-ink/5 rounded-full ml-1",children:t.changeCount})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",t.path)},title:`Discard changes in ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",t.path)},title:`Stage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",t.path)},title:`Unstage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})})})]}),y&&t.children&&t.children.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:t.children.map((k)=>e(Ae,{node:k,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g},k.id))})]});let L=t.change,N=Gn(L?.status||"M",c),{charStatus:G,colorClass:R}=N,P=L?L.file:t.path;return e("div",{className:"flex items-center justify-between px-2 py-0.5 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:P,staged:c,status:G,repo:h||".",root:g}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center flex-shrink-0",children:e("span",{className:`font-bold font-mono text-[10px] ${R}`,title:`Status: ${N.label}`,children:G})}),e(rt,{name:t.name,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${R}`,title:P,children:t.name})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",P)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",P)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",P)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})})})]})}function Fe({changes:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let{tree:h,isFolderOpen:g,toggleFolder:v}=Ze(t);if(h.length===0)return null;return e("div",{className:"py-0.5",children:h.map((y)=>e(Ae,{node:y,isStaged:c,isFolderOpen:g,toggleFolder:v,onAction:p,repo:l,rootPath:r},y.id))})}function Qe({changes:t,isLoading:c,viewMode:l,repo:r,rootPath:p,onAction:h,onResolve:g}){let[v,y]=S("git.stagedExpanded",!0),[L,N]=S("git.unstagedExpanded",!0),[G,R]=S("git.conflictsExpanded",!0),P=t.filter((x)=>gr(x.status)),T=t.filter((x)=>{if(gr(x.status))return!1;let w=x.status;return w&&w[0]!==" "&&w[0]!=="?"}),k=t.filter((x)=>{if(gr(x.status))return!1;let w=x.status;return w&&w[1]!==" "&&w[1]!=="?"||w==="??"});if(c&&t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"Loading..."})});if(t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"No changes found."})});return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"py-1",children:[P.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-warning/5 cursor-pointer transition-colors",onClick:()=>R(!G),children:e("div",{className:"flex items-center space-x-1 font-semibold text-warning text-xs",children:[e("span",{className:"w-3 text-center",children:G?"▾":"▸"}),e("span",{children:"Conflicts"}),e("span",{className:"text-warning/70 font-normal ml-1 border border-warning/30 rounded-full px-1.5 text-[10px] bg-paper",children:P.length})]})}),G&&P.map((x)=>e(Ye,{change:x,repo:r,rootPath:p,onResolve:g??(()=>{})},`conflict-${x.file}`))]}),T.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>y(!v),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:v?"▾":"▸"}),e("span",{children:"Staged Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:T.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("unstage_all")},title:"Unstage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:12})})})]}),v&&(l==="tree"?e(Fe,{changes:T,isStaged:!0,repo:r,rootPath:p,onAction:h}):T.map((x)=>e(Te,{change:x,isStaged:!0,repo:r,rootPath:p,onAction:h},x.file+"staged")))]}),k.length>0&&e("div",{children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>N(!L),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:L?"▾":"▸"}),e("span",{children:"Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:k.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:[e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("revert_all")},title:"Discard All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:12})}),e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("stage_all")},title:"Stage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:12})})]})]}),L&&(l==="tree"?e(Fe,{changes:k,isStaged:!1,repo:r,rootPath:p,onAction:h}):k.map((x)=>e(Te,{change:x,isStaged:!1,repo:r,rootPath:p,onAction:h},x.file+"unstaged")))]})]})})}function Je({matches:t,loaded:c,total:l,hasMore:r,isFiltering:p}){if(p)return`${t} of ${c} loaded`;if(typeof l==="number"&&l>0)return r||c<l?`${c} of ${l}`:`${l} commits`;return r?`${c}+ commits`:`${c} commits`}function tt({isGraphMode:t,onToggleMode:c,searchQuery:l,onSearchChange:r,onRefresh:p,onClose:h,isRefreshing:g,totalCommits:v,loadedCount:y,totalCount:L,hasMore:N}){let G=Je({matches:v,loaded:y,total:L,hasMore:N,isFiltering:l.trim().length>0});return e("div",{className:`flex flex-col gap-2 px-3 lg:px-5 py-3 border-b border-ink/10 bg-paper select-none
|
|
2
|
+
pl-[max(0.75rem,env(safe-area-inset-left,0px))] pr-[max(0.75rem,env(safe-area-inset-right,0px))]`,children:[e("div",{className:"flex items-center justify-between gap-2 lg:gap-4",children:[e("div",{className:"flex flex-col min-w-0",children:[e("div",{className:"flex items-center gap-2.5 min-w-0",children:[e("h2",{className:"text-base font-semibold text-ink tracking-tight",children:t?"Graph":"History"}),e("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-ink/5 text-ink/50 border border-ink/10 whitespace-nowrap",children:G})]}),e("p",{className:"text-xs text-ink/50 mt-0.5 hidden lg:block",children:"Browse recent commits and inspect changed files."})]}),e("div",{className:"flex items-center gap-1.5 lg:gap-2 flex-shrink-0",children:[e("div",{className:"flex items-center bg-ink/5 p-0.5 rounded-lg border border-ink/10 text-xs",children:[e("button",{type:"button",onClick:()=>c(!1),title:"History view",className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md font-medium transition-colors cursor-pointer ${!t?"bg-paper text-ink shadow-xs":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:[e(Bn,{size:13}),e("span",{className:"hidden lg:inline",children:"History"})]}),e("button",{type:"button",onClick:()=>c(!0),title:"Graph view",className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md font-medium transition-colors cursor-pointer ${t?"bg-paper text-ink shadow-xs":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:[e(Sn,{size:13}),e("span",{className:"hidden lg:inline",children:"Graph"})]})]}),e("button",{type:"button",onClick:p,disabled:g,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border border-ink/15 hover:bg-ink/5 text-ink/70 hover:text-ink transition-colors cursor-pointer text-xs disabled:opacity-40",title:"Refresh commit history",children:[e(va,{size:13,className:g?"animate-spin text-ink":""}),e("span",{className:"hidden lg:inline",children:"refresh"})]}),e("button",{type:"button",onClick:h,className:"p-2 -mr-1 rounded-md hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors cursor-pointer",title:"Close modal",children:e(b,{size:16})})]})]}),e("div",{className:"relative mt-1",children:[e(F,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",value:l,onChange:(R)=>r(R.currentTarget.value),placeholder:"Filter commits by message, author, or hash...",className:"w-full bg-ink/[0.03] border border-ink/15 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),l&&e("button",{type:"button",onClick:()=>r(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-ink/40 hover:text-ink cursor-pointer",children:e(b,{size:12})})]})]})}var le=["#38bdf8","#f97316","#a855f7","#10b981","#ec4899","#eab308","#06b6d4","#6366f1"];function Ee(t,c){if(!t||!c)return!1;if(t===c)return!0;let l=Math.min(t.length,c.length);if(l>=4)return t.substring(0,l)===c.substring(0,l);return!1}function Re(t){let c=new Map,l=[];for(let r of t){if(typeof r.lane==="number"){c.set(r.hash,r.lane);continue}let p=l.findIndex((g)=>Ee(g,r.hash)||Ee(g,r.shortHash));if(p===-1)if(p=l.indexOf(null),p===-1)p=l.length,l.push(r.hash);else l[p]=r.hash;c.set(r.hash,p);let h=r.parents&&r.parents[0];if(h)l[p]=h;else l[p]=null;if(r.parents&&r.parents.length>1)for(let g=1;g<r.parents.length;g++){let v=r.parents[g];if(!l.some((L)=>Ee(L,v))){let L=l.indexOf(null);if(L===-1)l.push(v);else l[L]=v}}}return c}function nt(t,c,l,r){let p=[],h=new Map;t.forEach((g,v)=>{if(h.set(g.hash,v),g.shortHash)h.set(g.shortHash,v);if(g.hash.length>=7)h.set(g.hash.substring(0,7),v)});for(let g of t){let v=c.get(g.hash)??0,y=l[g.hash]??0,L=le[v%le.length];if(!g.parents||g.parents.length===0)continue;for(let N of g.parents){let G=h.get(N);if(typeof G!=="number"&&N.length>=7)G=h.get(N.substring(0,7));if(typeof G==="number"){let R=t[G],P=c.get(R.hash)??v,T=l[R.hash]??y+60;p.push({fromHash:g.hash,toHash:R.hash,fromLane:v,toLane:P,fromY:y,toY:T,color:le[v%le.length]})}else p.push({fromHash:g.hash,toHash:"tail-"+g.hash,fromLane:v,toLane:v,fromY:y,toY:Math.max(y+80,r),color:L})}}return p}function ot(t,c,l,r){if(Math.abs(t-l)<1)return`M ${t} ${c} L ${l} ${r}`;let p=r-c,h=c+p*0.45,g=r-p*0.45;return`M ${t} ${c} C ${t} ${h}, ${l} ${g}, ${l} ${r}`}function st({commits:t,nodePositions:c,selectedHash:l,hoveredHash:r,isGraphMode:p,laneWidth:h=18,paddingLeft:g=16,totalHeight:v}){let y=u(()=>{if(!p){let R=new Map;return t.forEach((P)=>R.set(P.hash,0)),R}return Re(t)},[t,p]),L=u(()=>{let R=0;return y.forEach((P)=>{if(P>R)R=P}),R},[y]),N=p?(L+1)*h+g*2:36,G=u(()=>{if(!p){let R=[];for(let P=0;P<t.length-1;P++){let T=c[t[P].hash]??P*60+20,k=c[t[P+1].hash]??(P+1)*60+20;R.push({fromHash:t[P].hash,toHash:t[P+1].hash,fromLane:0,toLane:0,fromY:T,toY:k,color:"var(--theme-ink)"})}return R}return nt(t,y,c,v)},[t,y,c,v,p]);return e("div",{className:"absolute top-0 left-0 pointer-events-none z-10",style:{width:N,height:v},children:e("svg",{className:"w-full h-full overflow-visible",style:{width:N,height:v},children:[e("defs",{children:e("filter",{id:"node-glow",x:"-20%",y:"-20%",width:"140%",height:"140%",children:e("feDropShadow",{dx:"0",dy:"0",stdDeviation:"2",floodOpacity:"0.35"})})}),G.map((R)=>{let P=p?g+R.fromLane*h:16,T=p?g+R.toLane*h:16,k=p?R.color:"currentColor",x=p?0.95:0.25,w=ot(P,R.fromY,T,R.toY);return e("path",{d:w,fill:"none",stroke:k,strokeWidth:p?2.25:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:x},`${R.fromHash}->${R.toHash}`)}),t.map((R)=>{let P=y.get(R.hash)??0,T=p?g+P*h:16,k=c[R.hash]??20,x=l===R.hash||l===R.shortHash,w=r===R.hash||r===R.shortHash,E=p?le[P%le.length]:"var(--theme-success)";return e("g",{"data-commit-node":R.hash,children:[(x||w)&&e("circle",{cx:T,cy:k,r:8,fill:E,fillOpacity:x?0.35:0.2,stroke:E,strokeWidth:1}),e("circle",{"data-commit-dot":"",cx:T,cy:k,r:p?4:4.5,fill:p?"var(--theme-paper)":E,stroke:E,strokeWidth:p?2.5:1.5,filter:"url(#node-glow)"}),p&&e("circle",{cx:T,cy:k,r:1.8,fill:E})]},`node-${R.hash}`)})]})})}function it({commit:t,onAction:c}){return e("div",{className:"flex flex-wrap items-center gap-1.5 pt-1.5 pb-2",children:[e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("checkout",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"checkout"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("create_branch_here",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"create branch here"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("cherry_pick",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"cherry-pick"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("revert",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"revert"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("reset",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"reset..."}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("merge",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"merge into current"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("rebase",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"rebase onto this"})]})}var Ge=3;function Ft(t){let c=[];for(let l=0;l<t.length;l+=1){if(t[l].type!=="context"){c.push({row:t[l],index:l});continue}let r=l;while(r<t.length&&t[r].type==="context")r+=1;let p=r-l;if(p>Ge*2+1){for(let h=l;h<l+Ge;h+=1)c.push({row:t[h],index:h});c.push({row:{type:"elided",count:p-Ge*2},index:-1});for(let h=r-Ge;h<r;h+=1)c.push({row:t[h],index:h})}else for(let h=l;h<r;h+=1)c.push({row:t[h],index:h});l=r-1}return c}function lt({diffText:t,isLoading:c,filePath:l,fullContext:r=!1,onToggleContext:p}){let h=no(),g=u(()=>{if(!t)return[];let N=[],G=1,R=1,P=t.split(/\r?\n/),k=P.some((x)=>x.startsWith("@@"))?P:[`@@ -0,0 +1,${P.length} @@`,...P.map((x)=>x.startsWith("+")||x.startsWith("-")?x:`+${x}`)];for(let x of k){if(x.startsWith("diff --git")||x.startsWith("index ")||x.startsWith("---")||x.startsWith("+++")||x.startsWith("new file mode")||x.startsWith("deleted file mode")||x.startsWith("similarity index")||x.startsWith("old mode")||x.startsWith("new mode")||x.startsWith("\\ No newline"))continue;if(x.startsWith("@@")){let w=x.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(w)G=parseInt(w[1],10),R=parseInt(w[2],10);N.push({type:"meta",text:x})}else if(x.startsWith("+"))N.push({type:"add",text:x.slice(1),newNum:R++});else if(x.startsWith("-"))N.push({type:"del",text:x.slice(1),oldNum:G++});else{let w=x.startsWith(" ")?x.slice(1):x;N.push({type:"context",text:w,oldNum:G++,newNum:R++})}}return N},[t]),v=dt(l),y=u(()=>{let N=Array(g.length).fill(""),G=-1,R=(P)=>{if(G<0)return;let T=Du(g.slice(G,P).map((k)=>k.text).join(`
|
|
3
3
|
`),v);for(let k=G;k<P;k++)N[k]=T[k-G]??"";G=-1};return g.forEach((P,T)=>{if(P.type==="meta")R(T);else if(G<0)G=T}),R(g.length),N},[g,v,h]),L=u(()=>r?g.map((N,G)=>({row:N,index:G})):Ft(g),[g,r]);if(c)return e("div",{className:"my-2 p-4 rounded bg-canvas border border-ink/10 text-ink/40 font-mono text-xs flex items-center justify-center",children:"Loading commit diff..."});if(!t||g.length===0)return e("div",{className:"my-2 p-3 rounded bg-canvas border border-ink/10 text-ink/40 font-mono text-xs text-center",children:"No diff content available for this file."});return e("div",{className:"my-2 rounded border border-ink/15 bg-paper overflow-hidden text-[11px] font-mono leading-relaxed shadow-xs text-ink",children:[e("div",{className:"flex items-center justify-between px-3 py-1.5 bg-canvas border-b border-ink/10 text-ink/70 text-[10.5px]",children:[e("span",{className:"font-semibold text-meta",children:"Diff preview"}),e("button",{type:"button",onClick:p,disabled:!p,className:"hover:text-ink flex items-center gap-1 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-default",title:r?"Show only the changed hunks":"Read the whole file around the change","aria-pressed":r,children:r?e(d,{children:[e(et,{size:12})," Collapse context"]}):e(d,{children:[e(B,{size:12})," Expand all context"]})})]}),e("div",{className:"overflow-x-auto max-h-72 select-text",children:e("div",{className:"w-max min-w-full divide-y divide-ink/[0.04]",children:L.map(({row:N,index:G},R)=>{if(N.type==="elided")return e("div",{className:"px-3 py-1 bg-canvas text-ink/40 text-[10px] text-center select-none",title:`${N.count} unchanged line(s) hidden`,children:["⋯ ",N.count," unchanged line",N.count===1?"":"s"," hidden ⋯"]},`elided-${R}`);let P=N,T=G;if(P.type==="meta")return e("div",{className:"flex items-center gap-2 px-3 py-1 bg-canvas border-y border-ink/10 text-meta text-[10px] font-semibold",children:[e("span",{children:"↕"}),e("span",{children:P.text})]},T);let k=P.type==="add",x=P.type==="del";return e("div",{className:`flex items-start font-mono ${k?"bg-success/10 hover:bg-success/15":x?"bg-error/10 hover:bg-error/15":"text-ink hover:bg-ink/[0.02]"}`,children:[e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${x?"bg-error/15 text-error font-semibold":k?"bg-success/15 text-success/70":"bg-canvas/50 text-ink/40"}`,children:P.oldNum??(k?"+":"")}),e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${k?"bg-success/15 text-success font-semibold":x?"bg-error/15 text-error/70":"bg-canvas/50 text-ink/40"}`,children:P.newNum??(x?"-":"")}),e("div",{className:`w-4 flex-shrink-0 text-center py-0.5 select-none font-bold ${k?"text-success":x?"text-error":"opacity-0"}`,children:k?"+":x?"-":" "}),e("div",{className:"flex-1 py-0.5 pr-3 whitespace-pre text-ink",children:P.text?e("span",{className:"shiki",dangerouslySetInnerHTML:{__html:y[T]}}):" "})]},T)})})})]})}function pt({commit:t,isSelected:c,isGraphMode:l,onSelect:r,onAction:p,onToggleFile:h,isExpandedFile:g,isLoadingFile:v,isFullContextFile:y,onToggleContext:L,fileDiffs:N,headerRef:G}){let[R,P]=n(!1),[T,k]=n(!1),x=t.body?.trim()??"",w=x.length>0,E=(A)=>{A.stopPropagation(),navigator.clipboard.writeText(t.hash),P(!0),setTimeout(()=>P(!1),2000)},z=(A,H)=>{A.stopPropagation(),h(t.hash,H)};return e("div",{onClick:()=>{if(r(t),!w)return;let A=globalThis.getSelection?.();if(A&&!A.isCollapsed)return;k((H)=>!H)},"data-testid":"commit-row","data-commit-hash":t.hash,className:`border-b border-ink/5 transition-colors cursor-pointer ${c?"bg-ink/[0.03]":"hover:bg-ink/[0.015]"}`,children:e("div",{className:"py-2.5 pr-4 pl-1 flex flex-col",children:[e("div",{className:"flex flex-col gap-1",children:[t.refs&&t.refs.length>0&&e("div",{className:"flex flex-wrap items-center gap-1.5 pb-0.5",children:t.refs.map((A,H)=>{let O=A.includes("stash"),X=A.includes("HEAD")||A.includes("main")||A.includes("master");return e("span",{className:`px-2 py-0.5 rounded text-[10px] font-mono border ${O?"bg-warning/10 text-warning border-warning/25 font-semibold":X?"bg-ink/10 text-ink font-semibold border-ink/20":"bg-canvas text-meta border-ink/10 font-medium"}`,children:A},H)})}),e("div",{ref:G,className:"flex items-start gap-1.5",children:[e("span",{"data-commit-title":"",className:"text-[13px] font-semibold text-ink leading-snug break-words flex-1 min-w-0",children:t.message}),w&&e("span",{className:"text-ink/40 flex-shrink-0 mt-0.5","aria-hidden":"true",children:T?e(B,{size:13}):e(ie,{size:13})})]}),w&&T&&e("div",{className:"text-[12px] text-ink/70 leading-relaxed whitespace-pre-wrap break-words border-l-2 border-ink/15 pl-2.5 py-0.5 font-mono",children:x}),e("div",{className:"flex items-center gap-2 text-[11px] text-ink/50 font-mono flex-wrap",children:[e("span",{children:t.author}),e("span",{children:"•"}),e("span",{children:t.date}),e("span",{children:"•"}),e("button",{type:"button",onClick:E,title:"Copy commit hash",className:"inline-flex items-center gap-1 hover:text-ink transition-colors cursor-pointer text-ink/70",children:[e("span",{children:t.shortHash}),R?e(f,{size:11,className:"text-success"}):e(ae,{size:11})]})]})]}),(c||l)&&e("div",{className:"mt-2",children:e(it,{commit:t,onAction:p})}),t.files&&t.files.length>0&&e("div",{className:"mt-2 flex flex-col gap-1",children:t.files.map((A,H)=>{let O=g(t.hash,A.file),X=`${t.hash}:${A.file}`,te=N[X]!==void 0?N[X]:A.diff,j=v(t.hash,A.file),K=A.status==="A"?"text-success font-bold":A.status==="D"?"text-error font-bold":A.status==="R"?"text-meta font-bold":"text-info font-bold";return e("div",{className:"flex flex-col",children:[e("div",{onClick:(W)=>z(W,A),className:"flex items-center gap-2 py-1 px-2 rounded hover:bg-ink/5 text-[11.5px] font-mono text-ink/80 transition-colors group cursor-pointer border border-transparent hover:border-ink/10",children:[e("span",{className:`w-3.5 text-center flex-shrink-0 text-[11px] ${K}`,children:A.status||"M"}),e("span",{className:"truncate flex-1 min-w-0 text-ink/90 group-hover:text-ink font-medium",children:A.file}),e("span",{className:"flex items-center gap-1 text-[10.5px] tabular-nums flex-shrink-0 font-medium",children:[e("span",{className:"text-success",children:["+",A.additions]}),e("span",{className:"text-ink/30",children:"/"}),e("span",{className:"text-error",children:["-",A.deletions]})]}),e("span",{className:"text-ink/40 group-hover:text-ink flex-shrink-0",children:O?e(B,{size:13}):e(ie,{size:13})})]}),O&&e("div",{className:"pl-4 pr-1",children:e(lt,{diffText:te,isLoading:j,filePath:A.file,fullContext:y(t.hash,A.file),onToggleContext:()=>L(t.hash,A)})})]},H)})})]})})}var xe=50;function Et(t){if(!Array.isArray(t))return[];let c=[];for(let l of t){if(!l||typeof l!=="object")continue;let r=l;if(typeof r.file!=="string"||!r.file)continue;c.push({file:r.file,status:typeof r.status==="string"?r.status:"M",additions:typeof r.additions==="number"&&Number.isFinite(r.additions)?r.additions:0,deletions:typeof r.deletions==="number"&&Number.isFinite(r.deletions)?r.deletions:0,diff:typeof r.diff==="string"?r.diff:void 0})}return c}function ze(t){if(!Array.isArray(t))return[];let c=[];for(let l of t){if(!l||typeof l!=="object")continue;let r=l,p=typeof r.hash==="string"&&r.hash?r.hash:"";if(!p)continue;c.push({hash:p,shortHash:typeof r.shortHash==="string"&&r.shortHash?r.shortHash:p.slice(0,8),author:typeof r.author==="string"?r.author:"Unknown",date:typeof r.date==="string"?r.date:typeof r.time==="string"?r.time:"",message:typeof r.message==="string"?r.message:"",body:typeof r.body==="string"?r.body:void 0,parents:Array.isArray(r.parents)?r.parents.filter((h)=>typeof h==="string"):[],refs:Array.isArray(r.refs)?r.refs.filter((h)=>typeof h==="string"):[],files:Et(r.files),lane:typeof r.lane==="number"?r.lane:void 0})}return c}function mt({output:t,isGraphMode:c,rootPath:l,activeRepo:r}){let[p,h]=n(!1),[g,v]=n(t?.hasMore??t?.data?.length===xe),[y,L]=n(t?.total),N=u(()=>ze(t?.data),[t?.data]),G=Array.isArray(t?.data)?t.data.length:0,[R,P]=n(N),[T,k]=n(G);i(()=>{if(P(N),k(G),v(t?.hasMore??G===xe),typeof t?.total==="number")L(t.total)},[N,G,t?.hasMore,t?.total]);let x=a(async()=>{if(p||!g)return;h(!0);try{let w=new FormData;if(w.set("actionType",c?"graph":"history"),w.set("limit",String(xe)),w.set("skip",String(T)),l)w.set("root",l);if(r)w.set("repo",r);let z=await(await fetch("/api/fs/git",{method:"POST",body:w})).json();if(z.success&&Array.isArray(z.data)){let I=ze(z.data),A=z.data.length;if(P((H)=>{let O=new Set(H.map((te)=>te.hash)),X=I.filter((te)=>!O.has(te.hash));return[...H,...X]}),k((H)=>H+A),v(Boolean(z.hasMore??A===xe)),typeof z.total==="number")L(z.total)}else v(!1)}catch(w){console.error("Failed to load more commits:",w)}finally{h(!1)}},[p,g,c,T,l,r]);return{commits:R,hasMore:g,totalCount:y,isLoadingMore:p,handleLoadMore:x}}function ut({onExecuteAction:t,rootPath:c,activeRepo:l}){let[r,p]=n({}),[h,g]=n(new Set),[v,y]=n(new Set),[L,N]=n(new Set),G=a(async(k,x,w)=>{let E=`${k}:${x.file}`;y((z)=>new Set(z).add(E));try{let z=new FormData;if(z.set("actionType","commit_diff"),z.set("hash",k),z.set("file",x.file),w)z.set("full","1");if(c)z.set("root",c);if(l&&l!==".")z.set("repo",l);let A=await(await fetch("/api/fs/git",{method:"POST",body:z})).json();if(A&&typeof A.diff==="string")p((H)=>({...H,[E]:A.diff}));else if(A&&A.error)p((H)=>({...H,[E]:`// Error: ${A.error}`}))}catch(z){console.error("Failed to load file diff:",z);let I=z instanceof Error?z.message:"Network error";p((A)=>({...A,[E]:`// Error loading diff: ${I}`}))}finally{y((z)=>{let I=new Set(z);return I.delete(E),I})}},[c,l]),R=a(async(k,x)=>{let w=`${k}:${x.file}`,E=!h.has(w);if(g((z)=>{let I=new Set(z);if(I.has(w))I.delete(w);else I.add(w);return I}),E&&r[w]===void 0&&!x.diff)await G(k,x,!1)},[h,r,G]),P=a(async(k,x)=>{let w=`${k}:${x.file}`,E=!L.has(w);N((z)=>{let I=new Set(z);if(I.has(w))I.delete(w);else I.add(w);return I}),await G(k,x,E)},[L,G]),T=a((k,x)=>{if(!t)return;if(k==="checkout")t("checkout",void 0,{branch:x.hash});else if(k==="create_branch_here"){let w=window.prompt(`Create new branch at commit ${x.shortHash}:`,`branch-${x.shortHash}`);if(w?.trim())t("create_branch_at",void 0,{branch:w.trim(),hash:x.hash})}else if(k==="cherry_pick"){if(window.confirm(`Cherry-pick commit ${x.shortHash} onto current branch?`))t("cherry_pick",void 0,{hash:x.hash})}else if(k==="revert"){if(window.confirm(`Revert commit ${x.shortHash}?`))t("revert_commit",void 0,{hash:x.hash})}else if(k==="reset"){let w=window.prompt(`Reset current branch to ${x.shortHash} (soft, mixed, hard):`,"soft");if(w&&["soft","mixed","hard"].includes(w.toLowerCase()))t("reset_commit",void 0,{hash:x.hash,mode:w.toLowerCase()})}else if(k==="merge"){if(window.confirm(`Merge commit ${x.shortHash} into current branch?`))t("merge_commit",void 0,{hash:x.hash})}else if(k==="rebase"){if(window.confirm(`Rebase current branch onto commit ${x.shortHash}?`))t("rebase_commit",void 0,{hash:x.hash})}},[t]);return{fileDiffs:r,expandedFiles:h,loadingFiles:v,fullContextFiles:L,handleToggleFile:R,handleToggleContext:P,handleCommitAction:T}}function He({output:t,onClose:c,onRefresh:l,onExecuteAction:r,rootPath:p,activeRepo:h}){if(!t)return null;let[g,v]=n(()=>({title:t.title,graph:t.title.toLowerCase().includes("graph")}));if(g.title!==t.title)v({title:t.title,graph:t.title.toLowerCase().includes("graph")});let y=g.graph,L=(U)=>v((_)=>({..._,graph:U})),[N,G]=n(""),[R,P]=n(""),[T,k]=n(!1),{commits:x,hasMore:w,totalCount:E,isLoadingMore:z,handleLoadMore:I}=mt({output:t,isGraphMode:y,rootPath:p,activeRepo:h}),{fileDiffs:A,expandedFiles:H,loadingFiles:O,fullContextFiles:X,handleToggleFile:te,handleToggleContext:j,handleCommitAction:K}=ut({onExecuteAction:r,rootPath:p,activeRepo:h});i(()=>{if(x.length>0&&!R)P(x[0].hash)},[x,R]);let W=u(()=>{if(!N.trim())return x;let U=N.toLowerCase().trim();return x.filter((_)=>_.message.toLowerCase().includes(U)||_.author.toLowerCase().includes(U)||_.shortHash.toLowerCase().includes(U)||_.hash.toLowerCase().includes(U)||_.refs?.some((ee)=>ee.toLowerCase().includes(U)))},[x,N]),ne=o(null),se=o(null),be=o(null),de=o({}),[pe,ve]=n({}),[Se,Pe]=n(800);i(()=>{let U=be.current;if(!U||!w||z||N.trim())return;let _=new IntersectionObserver((ee)=>{if(ee[0].isIntersecting)I()},{root:ne.current,threshold:0.1});return _.observe(U),()=>_.disconnect()},[w,z,N,I]);let re=a(()=>{if(!ne.current||!se.current)return;let U=ne.current.getBoundingClientRect(),_=ne.current.scrollTop,ee={};W.forEach((me,Le)=>{let ue=de.current[me.hash];if(ue){let oe=ue.getBoundingClientRect();ee[me.hash]=oe.top+oe.height/2-U.top+_}else ee[me.hash]=Le*60+20}),ve(ee);let Ce=se.current.offsetHeight;Pe(Math.max(Ce,ne.current.clientHeight,600))},[W]);V(()=>{re();let U=requestAnimationFrame(()=>{re()});return()=>cancelAnimationFrame(U)},[re,W,A,H,y,R]),i(()=>{let U=se.current;if(!U)return;let _=new ResizeObserver(()=>{re()});_.observe(U);for(let ee of Array.from(U.children))_.observe(ee);return()=>_.disconnect()},[re,W]);let Z=u(()=>Re(W),[W]),$e=u(()=>{let U=0;return Z.forEach((_)=>{if(_>U)U=_}),U},[Z]),ye=18,ke=16,Me=y?($e+1)*ye+ke*2:36;return e("div",{className:"fixed inset-0 z-50 modal-scrim backdrop-blur-xs flex items-center justify-center p-0 lg:p-5",onClick:c,role:"dialog","aria-modal":"true",children:e("div",{className:`glass-overlay bg-paper border-ink/20 shadow-2xl flex flex-col overflow-hidden
|
|
4
4
|
w-full h-full rounded-none border-0
|
|
5
5
|
lg:w-[min(94vw,1200px)] lg:h-[88vh] lg:rounded-xl lg:border
|
|
6
|
-
pt-[env(safe-area-inset-top,0px)] lg:pt-0`,onClick:(U)=>U.stopPropagation(),children:[e(tt,{isGraphMode:y,onToggleMode:L,searchQuery:N,onSearchChange:G,onRefresh:()=>{k(!0),l?.(),setTimeout(()=>k(!1),600)},onClose:c,isRefreshing:T,totalCommits:W.length,loadedCount:x.length,totalCount:E,hasMore:w}),e("div",{ref:ne,className:"flex-1 overflow-y-auto scrollbar-overlay-container relative select-text",children:W.length===0?e("div",{className:"flex flex-col items-center justify-center py-20 text-ink/40 font-mono text-xs",children:N.trim()?"No matching commits found.":"No commits in this branch."}):e("div",{className:"relative min-h-full pb-8",children:[e(st,{commits:W,nodePositions:pe,selectedHash:R,isGraphMode:y,laneWidth:ye,paddingLeft:ke,totalHeight:Se}),e("div",{ref:se,className:"flex flex-col relative z-20",style:{paddingLeft:`${Me}px`},children:[W.map((U)=>e(pt,{commit:U,isSelected:R===U.hash,isGraphMode:y,onSelect:(_)=>P(_.hash),onAction:K,onToggleFile:te,isExpandedFile:(_,ee)=>H.has(`${_}:${ee}`),isLoadingFile:(_,ee)=>O.has(`${_}:${ee}`),isFullContextFile:(_,ee)=>X.has(`${_}:${ee}`),onToggleContext:j,fileDiffs:A,headerRef:(_)=>{de.current[U.hash]=_}},U.hash)),e("div",{ref:be,className:"pt-3 pb-4 px-4 flex items-center justify-center",children:z?e("div",{className:"flex items-center gap-2 text-xs text-ink/60 font-mono py-2",children:[e(m,{size:14,className:"animate-spin text-info"}),e("span",{children:"Loading more commits..."})]}):w&&!N.trim()?e("button",{type:"button",onClick:I,className:"px-3 py-1.5 text-xs font-mono text-ink/70 hover:text-ink bg-ink/5 hover:bg-ink/10 rounded-md border border-ink/10 transition-colors cursor-pointer",children:"Load more commits..."}):W.length>10?e("div",{className:"text-[11px] font-mono text-ink/40 py-2",children:["End of commit history (",typeof E==="number"&&E>0?E:x.length," commits)"]}):null})]})]})})]})})}function ft({children:t,onClose:c}){return e("div",{className:"fixed inset-0 z-50 modal-scrim flex items-center justify-center p-4",onClick:c,role:"dialog","aria-modal":"true",children:e("div",{className:"glass-overlay bg-paper border border-ink/20 rounded-lg shadow-xl flex flex-col overflow-hidden w-[min(94vw,420px)] max-h-[80vh]",onClick:(l)=>l.stopPropagation(),children:t})})}function ht({modal:t,onClose:c,onConfirm:l}){if(!t)return null;return e(ft,{onClose:c,children:[e("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[e(D,{size:16,className:"text-error flex-shrink-0"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Confirm Action"})]}),e("div",{className:"px-4 py-4 text-xs text-ink/80 leading-relaxed",children:t.message}),e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:l,className:"px-3 py-1.5 rounded bg-error text-canvas hover:bg-error/90 transition-colors cursor-pointer text-xs font-medium",children:"Confirm"})]})]})}function gt({isOpen:t,branchName:c,inputRef:l,onChange:r,onClose:p,onCreate:h}){if(!t)return null;let g=a(()=>{if(c.trim())h()},[c,h]);return e(ft,{onClose:p,children:[e("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[e(_n,{size:16,className:"text-ink/60 flex-shrink-0"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Create New Branch"})]}),e("div",{className:"px-4 py-4",children:e("input",{ref:l,type:"text",value:c,onChange:(v)=>r(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter")g();if(v.key==="Escape")p()},placeholder:"branch-name",className:"w-full bg-canvas border border-ink/20 rounded px-3 py-2 text-xs focus:outline-none focus:border-ink/40 text-ink placeholder-ink/40 transition-colors"})}),e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:p,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:g,disabled:!c.trim(),className:"px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:"Create"})]})]})}function xt({branch:t,detached:c,onCheckout:l,onMerge:r,onRename:p,onDelete:h}){let g=t.current&&!c;return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_minmax(0,9.5rem)_4.25rem_4rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:g&&e(f,{size:12,className:"text-ink","aria-label":"Current branch"})}),e("button",{type:"button",onClick:l,disabled:g,title:g?"Already on this branch":`Check out ${t.name}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:[e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(fe,{size:11,className:g?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${g?"font-semibold text-ink":"text-ink/90"}`,children:t.name})]}),t.subject&&e("div",{className:"h-4 flex items-center pl-[18px] min-w-0",children:e("span",{className:"truncate text-[10px] text-ink/40",title:t.subject,children:t.subject})})]}),e("div",{className:"h-5 flex items-center justify-end min-w-0",children:e(zt,{branch:t})}),e("div",{className:"h-5 flex items-center justify-end",children:t.date&&e("span",{className:"text-[10px] text-ink/40 truncate",children:t.date})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[!g&&e("button",{type:"button",onClick:r,title:`Merge ${t.name} into the current branch`,"aria-label":`Merge ${t.name} into the current branch`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(_n,{size:11})}),e("button",{type:"button",onClick:p,title:`Rename ${t.name}`,"aria-label":`Rename ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Sn,{size:11})}),!g&&e("button",{type:"button",onClick:h,title:`Delete ${t.name}`,"aria-label":`Delete ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(M,{size:11})})]})]})}function zt({branch:t}){if(t.gone)return e("span",{className:"text-[10px] font-mono text-warning border border-warning/30 rounded px-1 truncate",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"});if(!t.upstream)return e("span",{className:"text-[10px] font-mono text-ink/40 truncate",title:"No upstream: this branch has never been published",children:"unpublished"});return e("span",{className:"flex items-center gap-1 text-[10px] font-mono text-ink/50 min-w-0",children:[e("span",{className:"truncate",title:t.upstream,children:t.upstream}),(t.ahead>0||t.behind>0)&&e("span",{className:"tabular-nums text-ink/70 flex-shrink-0",children:[t.ahead>0&&`↑${t.ahead}`,t.behind>0&&`↓${t.behind}`]})]})}function bt({branch:t,onClose:c,onSubmit:l}){if(!t)return null;return e(Ht,{branch:t,onClose:c,onSubmit:l})}function Ht({branch:t,onClose:c,onSubmit:l}){let[r,p]=n(t.name),[h,g]=n(!1),v=r.trim(),y=v===t.name,L=v.length>0&&!y,N=()=>{if(L)l(t.name,v,h)};return e(J,{onClose:c,maxWidthClass:"max-w-[min(94vw,460px)]",header:e("div",{className:"flex items-center gap-2",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Rename branch"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:t.name})]}),children:[e("div",{className:"px-5 py-4 flex flex-col gap-3",children:[e("div",{children:[e("label",{className:"text-[10px] uppercase tracking-wider text-ink/50 font-semibold",htmlFor:"branch-rename-input",children:"New name"}),e("input",{id:"branch-rename-input",type:"text",value:r,autoFocus:!0,onChange:(G)=>p(G.currentTarget.value),onKeyDown:(G)=>{if(G.key==="Enter")N();if(G.key==="Escape")c()},className:"mt-1 w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs font-mono text-ink focus:outline-none focus:border-ink/40 transition-colors"}),y&&v.length>0&&e("p",{className:"mt-1 text-[10px] text-ink/50",children:"The name is unchanged."})]}),e("div",{className:"text-[10px] font-mono text-ink/60 flex flex-col gap-0.5 border border-ink/10 rounded p-2 bg-canvas/40",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"upstream"}),e("span",{className:"truncate",children:t.upstream||"none (unpublished)"})]}),e("p",{className:"text-ink/40 leading-relaxed mt-0.5",children:"A local rename keeps this upstream unchanged — a plain push afterwards will refuse until the upstream matches the new name, which is what the remote option below does."})]}),e("label",{className:"flex items-start gap-2 text-[11px] text-ink/80 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:h,onChange:(G)=>g(G.currentTarget.checked),className:`${ge} accent-ink cursor-pointer mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{children:"Also rename it on the remote"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:["git push -u ",t.upstream?t.upstream.split("/")[0]:"origin"," ",v||"<new>",e("br",{}),"git push ",t.upstream?t.upstream.split("/")[0]:"origin"," --delete ",t.name,e("br",{}),"git fetch --prune"]})]})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:N,disabled:!L,className:"px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:"Rename"})]})]})}function vt({branch:t,force:c,onForceChange:l,onClose:r,onConfirm:p}){if(!t)return null;return e(J,{onClose:r,maxWidthClass:"max-w-[min(94vw,440px)]",header:e("div",{className:"flex items-center gap-2",children:[e(D,{size:15,className:"text-error flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Delete branch"})]}),children:[e("div",{className:"px-5 py-4 flex flex-col gap-3 text-xs text-ink/80 leading-relaxed",children:[e("p",{children:["Delete ",e("span",{className:"font-mono font-semibold text-ink",children:t.name}),t.upstream&&e(d,{children:[" ","(tracks ",e("span",{className:"font-mono",children:t.upstream}),")"]}),"?"]}),e("div",{className:"text-[10px] font-mono text-ink/60 border border-ink/10 rounded p-2 bg-canvas/40 flex flex-col gap-0.5",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"last commit"}),e("span",{className:"truncate",children:t.subject||"–"})]}),e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"when"}),e("span",{children:t.date||"–"})]})]}),e("label",{className:"flex items-start gap-2 cursor-pointer select-none text-[11px]",children:[e("input",{type:"checkbox",checked:c,onChange:(h)=>l(h.currentTarget.checked),className:`${ge} accent-error cursor-pointer mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-error font-medium",children:"Delete even if its commits are not merged"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:["git branch ",c?"-D":"-d"," ",t.name]}),e("span",{className:"text-ink/50",children:"Without this, git refuses when the branch holds commits no other branch has. Leaving it off is the safe default."})]})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:()=>p(t.name),className:"px-3 py-1.5 rounded bg-error text-canvas hover:bg-error/90 transition-colors cursor-pointer text-xs font-medium",children:["Delete ",c?"(force)":""]})]})]})}function yt({isOpen:t,rootPath:c,repo:l,currentBranch:r,detached:p,isBusy:h,onClose:g,onAction:v,onConfirmDelete:y}){let[L,N]=n([]),[G,R]=n(!1),[P,T]=n(null),[k,x]=n(""),[w,E]=n(null),[z,I]=n(null),[A,H]=n(!1),O=a(async()=>{R(!0),T(null);let j=new URLSearchParams({branches:"1",repo:l||"."});if(c)j.set("root",c);try{let K=await fetch(`/api/fs/git?${j.toString()}`),W=await K.json();if(W.success&&Array.isArray(W.branches))N(W.branches);else T(W.error||`Failed to read branches (HTTP ${K.status})`)}catch(K){T(K instanceof Error?K.message:"Failed to read branches")}finally{R(!1)}},[c,l]);i(()=>{if(t)O()},[t,O]);let X=o(!1);i(()=>{if(!t){X.current=!1;return}if(X.current&&!h)O();X.current=h},[t,h,O]),i(()=>{if(!t)E(null),I(null),H(!1),x("")},[t]);let te=u(()=>{let j=k.trim().toLowerCase();if(!j)return L;return L.filter((K)=>K.name.toLowerCase().includes(j)||K.upstream.toLowerCase().includes(j))},[L,k]);if(!t)return null;return e(d,{children:[e(J,{onClose:g,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Branches"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:p?`detached at ${r}`:`on ${r}`})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(F,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:k,onChange:(j)=>x(j.currentTarget.value),placeholder:"Filter branches…","aria-label":"Filter branches",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:()=>void O(),disabled:G,title:"Refresh","aria-label":"Refresh branches",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(C,{size:12,className:G?"animate-spin":""})})]}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:G&&L.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(m,{size:14,className:"animate-spin text-info"}),"Loading branches…"]}):P?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:P}):te.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:k.trim()?"No matching branches.":"No branches."}):te.map((j)=>e(xt,{branch:j,detached:p,onCheckout:()=>{v("checkout",{branch:j.name}),g()},onMerge:()=>{v("merge_branch",{branch:j.name}),g()},onRename:()=>E(j),onDelete:()=>{I(j),H(!1)}},j.name))})]}),e(bt,{branch:w,onClose:()=>E(null),onSubmit:(j,K,W)=>{v("rename_branch",{branch:j,newName:K,...W?{remote:"1"}:{}}),E(null)}},w?.name??"none"),e(vt,{branch:z,force:A,onForceChange:H,onClose:()=>{I(null),H(!1)},onConfirm:(j)=>{y(j,A),I(null),H(!1)}})]})}function kt({mounted:t,confirmModal:c,onCloseConfirm:l,onConfirm:r,branchPrompt:p,newBranchName:h,newBranchInputRef:g,onNewBranchNameChange:v,onCloseBranchPrompt:y,onCreateBranch:L,viewingOutput:N,onCloseOutput:G,onRefreshOutput:R,onExecuteAction:P,branchModalOpen:T,onCloseBranchModal:k,rootPath:x,activeRepo:w,currentBranch:E,detached:z,isBusy:I,onBranchAction:A,onConfirmDeleteBranch:H}){if(!t)return null;return e(d,{children:[e(ht,{modal:c,onClose:l,onConfirm:r}),e(gt,{isOpen:p,branchName:h,inputRef:g,onChange:v,onClose:y,onCreate:L}),e(He,{output:N,onClose:G,onRefresh:R,onExecuteAction:P,rootPath:x,activeRepo:w}),e(yt,{isOpen:T,rootPath:x,repo:w,currentBranch:E,detached:z,isBusy:I,onClose:k,onAction:A,onConfirmDelete:H})]})}function Ct({rootPath:t,repo:c,isBusy:l,onAction:r}){let[p,h]=S("git.stashExpanded",!1),[g,v]=n([]),[y,L]=n(!1),[N,G]=n(""),[R,P]=n(!1),T=Ar(),k=a(async()=>{L(!0);let w=new URLSearchParams({stashes:"1",repo:c||"."});if(t)w.set("root",t);try{let z=await(await fetch(`/api/fs/git?${w.toString()}`)).json();v(z.stashes??[])}catch{v([])}finally{L(!1)}},[t,c]);i(()=>{if(p)k()},[p,k,l]);let x=(w,E)=>{if(r(w,E),w==="stash_push")G(""),P(!1)};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:[e("button",{type:"button",onClick:()=>h(!p),"aria-expanded":p,"aria-controls":T,title:p?"Hide stashes":"Show stashes",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:p?"▾":"▸"}),e(Xe,{size:12}),e("span",{children:"Stash"}),g.length>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:g.length})]}),e("button",{type:"button",onClick:()=>x("stash_push",{...N.trim()?{message:N.trim()}:{},...R?{untracked:"1"}:{}}),disabled:l,title:"Stash the working tree",className:"mr-3 flex flex-shrink-0 items-center gap-1 px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Y,{size:10}),"Save"]})]}),e("div",{className:"section-reveal","data-expanded":p,id:T,inert:!p,children:e("div",{children:e("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:[e("div",{className:"flex items-center gap-1.5",children:[e("input",{type:"text",value:N,onChange:(w)=>G(w.currentTarget.value),placeholder:"Stash message (optional)","aria-label":"Stash message",className:"flex-1 min-w-0 bg-paper border border-ink/20 rounded px-2 py-1 text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),e("label",{className:"flex items-center gap-1 text-[10px] text-ink/60 cursor-pointer select-none flex-shrink-0",title:"Also stash untracked files (-u)",children:[e("input",{type:"checkbox",checked:R,onChange:(w)=>P(w.currentTarget.checked),className:`${ge} accent-ink cursor-pointer`}),"-u"]})]}),y&&g.length===0?e("div",{className:"text-[10px] text-ink/40 italic py-1",children:"Loading…"}):g.length===0?e("div",{className:"text-[10px] text-ink/40 italic py-1",children:"No stash entries."}):e("div",{className:"max-h-40 overflow-y-auto scrollbar-overlay-container flex flex-col",children:g.map((w)=>e("div",{className:"grid grid-cols-[4rem_minmax(0,1fr)_3.5rem_4.5rem] items-center gap-x-1 group/stash py-0.5",children:[e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:w.ref}),e("span",{className:"min-w-0 truncate text-[10px] text-ink/80",title:w.subject,children:w.subject}),e("span",{className:"text-[10px] text-ink/40 text-right truncate",children:w.date}),e("div",{className:"flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/stash:opacity-100",children:[e("button",{type:"button",onClick:()=>x("stash_apply",{ref:w.ref,pop:"1"}),disabled:l,title:"Pop: apply and remove the entry","aria-label":"Pop stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-40",children:e(he,{size:10})}),e("button",{type:"button",onClick:()=>x("stash_apply",{ref:w.ref}),disabled:l,title:"Apply: keep the entry","aria-label":"Apply stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-40",children:e(Xe,{size:10})}),e("button",{type:"button",onClick:()=>x("stash_drop",{ref:w.ref}),disabled:l,title:"Drop: discard the entry (the stash is not recoverable from the panel)","aria-label":"Drop stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors disabled:opacity-40",children:e(M,{size:10})})]})]},w.ref))})]})})})]})}function Nt({repo:t,isBusy:c,onInit:l}){let r=t==="."?"this folder":t;return e("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 text-center",children:[e(fe,{size:26,className:"text-ink/25","aria-hidden":!0}),e("div",{className:"font-mono space-y-1",children:[e("p",{className:"text-xs text-ink/70",children:"Not a Git repository"}),e("p",{className:"text-[11px] leading-4 text-ink/40",children:["Initialize one in ",r," to track changes, commit and manage branches."]})]}),e("button",{type:"button",onClick:l,disabled:c,"aria-label":"Initialize Git repository",title:`git init in ${r}`,className:"flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(fe,{size:12,"aria-hidden":!0}),"Initialize repository"]})]})}function wt(t,c,l){let r=at(),{activeRepo:p,setActiveRepo:h,ready:g}=ir(t),{repos:v,scanning:y,rescan:L}=or(t,c),N=Ff(p,v),G=o(N);G.current=N;let R=o("");R.current=`${t??""}\x00${N}`;let P=o(""),T=o(""),k=o(void 0);if(r.data!==k.current)k.current=r.data,T.current=P.current;let x=c&&g?gp(`${t??""}\x00${N}`):null,w=we(x),E=o(w.refresh);E.current=w.refresh;let z=T.current===R.current?r.data:void 0,I=w.data??z,A=I?.syncCount??z?.syncCount,H=a((te)=>{if(!c)return;let j=te??G.current,K=new URLSearchParams;if(t)K.set("root",t);if(j&&j!==".")K.set("repo",j);K.set("sync","1"),K.set("t",String(Date.now())),P.current=R.current;let W=E.current;r.load(`/api/fs/git?${K.toString()}`).then(()=>W())},[c,t,r.load]);i(()=>{if(!g)return;H()},[l,t,c,g,N,H]);let O=r.state==="loading",X=O||w.refreshing;return{activeRepo:N,setActiveRepo:h,repos:v,reposScanning:y,refreshRepos:L,isReading:O,isRefreshing:X,data:I,syncCount:A,loadRepo:H,refreshTopic:w.refresh}}function Rt(t,c){let l=at(),r=o(null),p=a((h,g,v)=>{r.current={actionType:h,extra:v};let y=new FormData;if(y.append("actionType",h),y.append("repo",c),t)y.append("root",t);if(g)y.append("file",g);if(v)Object.entries(v).forEach(([L,N])=>y.append(L,N));l.submit(y,{method:"POST",action:"/api/fs/git"})},[c,t,l]);return{state:l.state,execute:p,data:l.data,lastAction:r.current}}function Gt({rootPath:t,repo:c,execute:l}){let{sessionId:r}=bp(),[p,h]=S("git.commitDraft",""),[g,v]=S("git.amend",!1),y=o(null),L=o(p);L.current=p;let N=o(g);N.current=g;let G=o(h);G.current=h,i(()=>{if(!g)return;if(L.current.trim().length>0)return;let T=new URLSearchParams({headMessage:"1"});if(t)T.set("root",t);if(c&&c!==".")T.set("repo",c);let k=!1;return fetch(`/api/fs/git?${T.toString()}`).then((x)=>x.json()).then((x)=>{if(k)return;if(!N.current||L.current.trim().length>0)return;let w=typeof x?.message==="string"?x.message:"";if(w.length===0)return;y.current=w,G.current(w)}).catch(()=>{}),()=>{k=!0}},[g,r,t,c]);let R=a((T)=>{if(T){v(!0);return}if(y.current!==null&&L.current===y.current)h("");y.current=null,v(!1)},[v,h]),P=a(()=>{l("commit",void 0,{message:L.current,...N.current?{amend:"1"}:{}}),h(""),v(!1),y.current=null},[l,v,h]);return{message:p,setMessage:h,amend:g,seeded:y.current!==null&&p===y.current,toggleAmend:R,commit:P}}var St=48;function Ot(t,c){let l=c?.branch?.trim()??"",r=(c?.hash??"").slice(0,7),p=c?.ref?.trim()||"stash@{0}";switch(t){case"init":return{done:"Initialized the repository"};case"fetch":return{done:"Fetched every remote"};case"push":return{done:"Pushed to upstream"};case"pull":return{done:"Pulled from upstream",stopped:"Pulled"};case"sync":return{done:"Synced with upstream",stopped:"Pulled, but nothing was pushed"};case"abort_operation":return{done:"Aborted the operation in progress"};case"continue_operation":return{done:"Concluded the operation"};case"commit":{if(c?.amend==="1")return{done:"Amended the last commit"};let h=(c?.message??"").split(`
|
|
6
|
+
pt-[env(safe-area-inset-top,0px)] lg:pt-0`,onClick:(U)=>U.stopPropagation(),children:[e(tt,{isGraphMode:y,onToggleMode:L,searchQuery:N,onSearchChange:G,onRefresh:()=>{k(!0),l?.(),setTimeout(()=>k(!1),600)},onClose:c,isRefreshing:T,totalCommits:W.length,loadedCount:x.length,totalCount:E,hasMore:w}),e("div",{ref:ne,className:"flex-1 overflow-y-auto scrollbar-overlay-container relative select-text",children:W.length===0?e("div",{className:"flex flex-col items-center justify-center py-20 text-ink/40 font-mono text-xs",children:N.trim()?"No matching commits found.":"No commits in this branch."}):e("div",{className:"relative min-h-full pb-8",children:[e(st,{commits:W,nodePositions:pe,selectedHash:R,isGraphMode:y,laneWidth:ye,paddingLeft:ke,totalHeight:Se}),e("div",{ref:se,className:"flex flex-col relative z-20",style:{paddingLeft:`${Me}px`},children:[W.map((U)=>e(pt,{commit:U,isSelected:R===U.hash,isGraphMode:y,onSelect:(_)=>P(_.hash),onAction:K,onToggleFile:te,isExpandedFile:(_,ee)=>H.has(`${_}:${ee}`),isLoadingFile:(_,ee)=>O.has(`${_}:${ee}`),isFullContextFile:(_,ee)=>X.has(`${_}:${ee}`),onToggleContext:j,fileDiffs:A,headerRef:(_)=>{de.current[U.hash]=_}},U.hash)),e("div",{ref:be,className:"pt-3 pb-4 px-4 flex items-center justify-center",children:z?e("div",{className:"flex items-center gap-2 text-xs text-ink/60 font-mono py-2",children:[e(m,{size:14,className:"animate-spin text-info"}),e("span",{children:"Loading more commits..."})]}):w&&!N.trim()?e("button",{type:"button",onClick:I,className:"px-3 py-1.5 text-xs font-mono text-ink/70 hover:text-ink bg-ink/5 hover:bg-ink/10 rounded-md border border-ink/10 transition-colors cursor-pointer",children:"Load more commits..."}):W.length>10?e("div",{className:"text-[11px] font-mono text-ink/40 py-2",children:["End of commit history (",typeof E==="number"&&E>0?E:x.length," commits)"]}):null})]})]})})]})})}function ft({children:t,onClose:c}){return e("div",{className:"fixed inset-0 z-50 modal-scrim flex items-center justify-center p-4",onClick:c,role:"dialog","aria-modal":"true",children:e("div",{className:"glass-overlay bg-paper border border-ink/20 rounded-lg shadow-xl flex flex-col overflow-hidden w-[min(94vw,420px)] max-h-[80vh]",onClick:(l)=>l.stopPropagation(),children:t})})}function ht({modal:t,onClose:c,onConfirm:l}){if(!t)return null;return e(ft,{onClose:c,children:[e("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[e(D,{size:16,className:"text-error flex-shrink-0"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Confirm Action"})]}),e("div",{className:"px-4 py-4 text-xs text-ink/80 leading-relaxed",children:t.message}),e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:l,className:"px-3 py-1.5 rounded bg-error text-canvas hover:bg-error/90 transition-colors cursor-pointer text-xs font-medium",children:"Confirm"})]})]})}function gt({isOpen:t,branchName:c,inputRef:l,onChange:r,onClose:p,onCreate:h}){if(!t)return null;let g=a(()=>{if(c.trim())h()},[c,h]);return e(ft,{onClose:p,children:[e("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[e(Sn,{size:16,className:"text-ink/60 flex-shrink-0"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Create New Branch"})]}),e("div",{className:"px-4 py-4",children:e("input",{ref:l,type:"text",value:c,onChange:(v)=>r(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter")g();if(v.key==="Escape")p()},placeholder:"branch-name",className:"w-full bg-canvas border border-ink/20 rounded px-3 py-2 text-xs focus:outline-none focus:border-ink/40 text-ink placeholder-ink/40 transition-colors"})}),e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:p,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:g,disabled:!c.trim(),className:"px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:"Create"})]})]})}function xt({branch:t,detached:c,onCheckout:l,onMerge:r,onRename:p,onDelete:h}){let g=t.current&&!c;return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_minmax(0,9.5rem)_4.25rem_4rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:g&&e(f,{size:12,className:"text-ink","aria-label":"Current branch"})}),e("button",{type:"button",onClick:l,disabled:g,title:g?"Already on this branch":`Check out ${t.name}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:[e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(fe,{size:11,className:g?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${g?"font-semibold text-ink":"text-ink/90"}`,children:t.name})]}),t.subject&&e("div",{className:"h-4 flex items-center pl-[18px] min-w-0",children:e("span",{className:"truncate text-[10px] text-ink/40",title:t.subject,children:t.subject})})]}),e("div",{className:"h-5 flex items-center justify-end min-w-0",children:e(zt,{branch:t})}),e("div",{className:"h-5 flex items-center justify-end",children:t.date&&e("span",{className:"text-[10px] text-ink/40 truncate",children:t.date})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[!g&&e("button",{type:"button",onClick:r,title:`Merge ${t.name} into the current branch`,"aria-label":`Merge ${t.name} into the current branch`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Sn,{size:11})}),e("button",{type:"button",onClick:p,title:`Rename ${t.name}`,"aria-label":`Rename ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Tn,{size:11})}),!g&&e("button",{type:"button",onClick:h,title:`Delete ${t.name}`,"aria-label":`Delete ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(M,{size:11})})]})]})}function zt({branch:t}){if(t.gone)return e("span",{className:"text-[10px] font-mono text-warning border border-warning/30 rounded px-1 truncate",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"});if(!t.upstream)return e("span",{className:"text-[10px] font-mono text-ink/40 truncate",title:"No upstream: this branch has never been published",children:"unpublished"});return e("span",{className:"flex items-center gap-1 text-[10px] font-mono text-ink/50 min-w-0",children:[e("span",{className:"truncate",title:t.upstream,children:t.upstream}),(t.ahead>0||t.behind>0)&&e("span",{className:"tabular-nums text-ink/70 flex-shrink-0",children:[t.ahead>0&&`↑${t.ahead}`,t.behind>0&&`↓${t.behind}`]})]})}function bt({branch:t,onClose:c,onSubmit:l}){if(!t)return null;return e(Ht,{branch:t,onClose:c,onSubmit:l})}function Ht({branch:t,onClose:c,onSubmit:l}){let[r,p]=n(t.name),[h,g]=n(!1),v=r.trim(),y=v===t.name,L=v.length>0&&!y,N=()=>{if(L)l(t.name,v,h)};return e(J,{onClose:c,maxWidthClass:"max-w-[min(94vw,460px)]",header:e("div",{className:"flex items-center gap-2",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Rename branch"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:t.name})]}),children:[e("div",{className:"px-5 py-4 flex flex-col gap-3",children:[e("div",{children:[e("label",{className:"text-[10px] uppercase tracking-wider text-ink/50 font-semibold",htmlFor:"branch-rename-input",children:"New name"}),e("input",{id:"branch-rename-input",type:"text",value:r,autoFocus:!0,onChange:(G)=>p(G.currentTarget.value),onKeyDown:(G)=>{if(G.key==="Enter")N();if(G.key==="Escape")c()},className:"mt-1 w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs font-mono text-ink focus:outline-none focus:border-ink/40 transition-colors"}),y&&v.length>0&&e("p",{className:"mt-1 text-[10px] text-ink/50",children:"The name is unchanged."})]}),e("div",{className:"text-[10px] font-mono text-ink/60 flex flex-col gap-0.5 border border-ink/10 rounded p-2 bg-canvas/40",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"upstream"}),e("span",{className:"truncate",children:t.upstream||"none (unpublished)"})]}),e("p",{className:"text-ink/40 leading-relaxed mt-0.5",children:"A local rename keeps this upstream unchanged — a plain push afterwards will refuse until the upstream matches the new name, which is what the remote option below does."})]}),e("label",{className:"flex items-start gap-2 text-[11px] text-ink/80 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:h,onChange:(G)=>g(G.currentTarget.checked),className:`${ge} accent-ink cursor-pointer mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{children:"Also rename it on the remote"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:["git push -u ",t.upstream?t.upstream.split("/")[0]:"origin"," ",v||"<new>",e("br",{}),"git push ",t.upstream?t.upstream.split("/")[0]:"origin"," --delete ",t.name,e("br",{}),"git fetch --prune"]})]})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:N,disabled:!L,className:"px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:"Rename"})]})]})}function vt({branch:t,force:c,onForceChange:l,onClose:r,onConfirm:p}){if(!t)return null;return e(J,{onClose:r,maxWidthClass:"max-w-[min(94vw,440px)]",header:e("div",{className:"flex items-center gap-2",children:[e(D,{size:15,className:"text-error flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Delete branch"})]}),children:[e("div",{className:"px-5 py-4 flex flex-col gap-3 text-xs text-ink/80 leading-relaxed",children:[e("p",{children:["Delete ",e("span",{className:"font-mono font-semibold text-ink",children:t.name}),t.upstream&&e(d,{children:[" ","(tracks ",e("span",{className:"font-mono",children:t.upstream}),")"]}),"?"]}),e("div",{className:"text-[10px] font-mono text-ink/60 border border-ink/10 rounded p-2 bg-canvas/40 flex flex-col gap-0.5",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"last commit"}),e("span",{className:"truncate",children:t.subject||"–"})]}),e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"when"}),e("span",{children:t.date||"–"})]})]}),e("label",{className:"flex items-start gap-2 cursor-pointer select-none text-[11px]",children:[e("input",{type:"checkbox",checked:c,onChange:(h)=>l(h.currentTarget.checked),className:`${ge} accent-error cursor-pointer mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-error font-medium",children:"Delete even if its commits are not merged"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:["git branch ",c?"-D":"-d"," ",t.name]}),e("span",{className:"text-ink/50",children:"Without this, git refuses when the branch holds commits no other branch has. Leaving it off is the safe default."})]})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:()=>p(t.name),className:"px-3 py-1.5 rounded bg-error text-canvas hover:bg-error/90 transition-colors cursor-pointer text-xs font-medium",children:["Delete ",c?"(force)":""]})]})]})}function yt({isOpen:t,rootPath:c,repo:l,currentBranch:r,detached:p,isBusy:h,onClose:g,onAction:v,onConfirmDelete:y}){let[L,N]=n([]),[G,R]=n(!1),[P,T]=n(null),[k,x]=n(""),[w,E]=n(null),[z,I]=n(null),[A,H]=n(!1),O=a(async()=>{R(!0),T(null);let j=new URLSearchParams({branches:"1",repo:l||"."});if(c)j.set("root",c);try{let K=await fetch(`/api/fs/git?${j.toString()}`),W=await K.json();if(W.success&&Array.isArray(W.branches))N(W.branches);else T(W.error||`Failed to read branches (HTTP ${K.status})`)}catch(K){T(K instanceof Error?K.message:"Failed to read branches")}finally{R(!1)}},[c,l]);i(()=>{if(t)O()},[t,O]);let X=o(!1);i(()=>{if(!t){X.current=!1;return}if(X.current&&!h)O();X.current=h},[t,h,O]),i(()=>{if(!t)E(null),I(null),H(!1),x("")},[t]);let te=u(()=>{let j=k.trim().toLowerCase();if(!j)return L;return L.filter((K)=>K.name.toLowerCase().includes(j)||K.upstream.toLowerCase().includes(j))},[L,k]);if(!t)return null;return e(d,{children:[e(J,{onClose:g,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Branches"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:p?`detached at ${r}`:`on ${r}`})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(F,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:k,onChange:(j)=>x(j.currentTarget.value),placeholder:"Filter branches…","aria-label":"Filter branches",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:()=>void O(),disabled:G,title:"Refresh","aria-label":"Refresh branches",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(C,{size:12,className:G?"animate-spin":""})})]}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:G&&L.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(m,{size:14,className:"animate-spin text-info"}),"Loading branches…"]}):P?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:P}):te.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:k.trim()?"No matching branches.":"No branches."}):te.map((j)=>e(xt,{branch:j,detached:p,onCheckout:()=>{v("checkout",{branch:j.name}),g()},onMerge:()=>{v("merge_branch",{branch:j.name}),g()},onRename:()=>E(j),onDelete:()=>{I(j),H(!1)}},j.name))})]}),e(bt,{branch:w,onClose:()=>E(null),onSubmit:(j,K,W)=>{v("rename_branch",{branch:j,newName:K,...W?{remote:"1"}:{}}),E(null)}},w?.name??"none"),e(vt,{branch:z,force:A,onForceChange:H,onClose:()=>{I(null),H(!1)},onConfirm:(j)=>{y(j,A),I(null),H(!1)}})]})}function kt({mounted:t,confirmModal:c,onCloseConfirm:l,onConfirm:r,branchPrompt:p,newBranchName:h,newBranchInputRef:g,onNewBranchNameChange:v,onCloseBranchPrompt:y,onCreateBranch:L,viewingOutput:N,onCloseOutput:G,onRefreshOutput:R,onExecuteAction:P,branchModalOpen:T,onCloseBranchModal:k,rootPath:x,activeRepo:w,currentBranch:E,detached:z,isBusy:I,onBranchAction:A,onConfirmDeleteBranch:H}){if(!t)return null;return e(d,{children:[e(ht,{modal:c,onClose:l,onConfirm:r}),e(gt,{isOpen:p,branchName:h,inputRef:g,onChange:v,onClose:y,onCreate:L}),e(He,{output:N,onClose:G,onRefresh:R,onExecuteAction:P,rootPath:x,activeRepo:w}),e(yt,{isOpen:T,rootPath:x,repo:w,currentBranch:E,detached:z,isBusy:I,onClose:k,onAction:A,onConfirmDelete:H})]})}function Ct({rootPath:t,repo:c,isBusy:l,onAction:r}){let[p,h]=S("git.stashExpanded",!1),[g,v]=n([]),[y,L]=n(!1),[N,G]=n(""),[R,P]=n(!1),T=Ar(),k=a(async()=>{L(!0);let w=new URLSearchParams({stashes:"1",repo:c||"."});if(t)w.set("root",t);try{let z=await(await fetch(`/api/fs/git?${w.toString()}`)).json();v(z.stashes??[])}catch{v([])}finally{L(!1)}},[t,c]);i(()=>{if(p)k()},[p,k,l]);let x=(w,E)=>{if(r(w,E),w==="stash_push")G(""),P(!1)};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:[e("button",{type:"button",onClick:()=>h(!p),"aria-expanded":p,"aria-controls":T,title:p?"Hide stashes":"Show stashes",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:p?"▾":"▸"}),e(Xe,{size:12}),e("span",{children:"Stash"}),g.length>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:g.length})]}),e("button",{type:"button",onClick:()=>x("stash_push",{...N.trim()?{message:N.trim()}:{},...R?{untracked:"1"}:{}}),disabled:l,title:"Stash the working tree",className:"mr-3 flex flex-shrink-0 items-center gap-1 px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Y,{size:10}),"Save"]})]}),e("div",{className:"section-reveal","data-expanded":p,id:T,inert:!p,children:e("div",{children:e("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:[e("div",{className:"flex items-center gap-1.5",children:[e("input",{type:"text",value:N,onChange:(w)=>G(w.currentTarget.value),placeholder:"Stash message (optional)","aria-label":"Stash message",className:"flex-1 min-w-0 bg-paper border border-ink/20 rounded px-2 py-1 text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),e("label",{className:"flex items-center gap-1 text-[10px] text-ink/60 cursor-pointer select-none flex-shrink-0",title:"Also stash untracked files (-u)",children:[e("input",{type:"checkbox",checked:R,onChange:(w)=>P(w.currentTarget.checked),className:`${ge} accent-ink cursor-pointer`}),"-u"]})]}),y&&g.length===0?e("div",{className:"text-[10px] text-ink/40 italic py-1",children:"Loading…"}):g.length===0?e("div",{className:"text-[10px] text-ink/40 italic py-1",children:"No stash entries."}):e("div",{className:"max-h-40 overflow-y-auto scrollbar-overlay-container flex flex-col",children:g.map((w)=>e("div",{className:"grid grid-cols-[4rem_minmax(0,1fr)_3.5rem_4.5rem] items-center gap-x-1 group/stash py-0.5",children:[e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:w.ref}),e("span",{className:"min-w-0 truncate text-[10px] text-ink/80",title:w.subject,children:w.subject}),e("span",{className:"text-[10px] text-ink/40 text-right truncate",children:w.date}),e("div",{className:"flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/stash:opacity-100",children:[e("button",{type:"button",onClick:()=>x("stash_apply",{ref:w.ref,pop:"1"}),disabled:l,title:"Pop: apply and remove the entry","aria-label":"Pop stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-40",children:e(he,{size:10})}),e("button",{type:"button",onClick:()=>x("stash_apply",{ref:w.ref}),disabled:l,title:"Apply: keep the entry","aria-label":"Apply stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-40",children:e(Xe,{size:10})}),e("button",{type:"button",onClick:()=>x("stash_drop",{ref:w.ref}),disabled:l,title:"Drop: discard the entry (the stash is not recoverable from the panel)","aria-label":"Drop stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors disabled:opacity-40",children:e(M,{size:10})})]})]},w.ref))})]})})})]})}function Nt({repo:t,isBusy:c,onInit:l}){let r=t==="."?"this folder":t;return e("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 text-center",children:[e(fe,{size:26,className:"text-ink/25","aria-hidden":!0}),e("div",{className:"font-mono space-y-1",children:[e("p",{className:"text-xs text-ink/70",children:"Not a Git repository"}),e("p",{className:"text-[11px] leading-4 text-ink/40",children:["Initialize one in ",r," to track changes, commit and manage branches."]})]}),e("button",{type:"button",onClick:l,disabled:c,"aria-label":"Initialize Git repository",title:`git init in ${r}`,className:"flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(fe,{size:12,"aria-hidden":!0}),"Initialize repository"]})]})}function wt(t,c,l){let r=at(),{activeRepo:p,setActiveRepo:h,ready:g}=ir(t),{repos:v,scanning:y,rescan:L}=or(t,c),N=Mf(p,v),G=o(N);G.current=N;let R=o("");R.current=`${t??""}\x00${N}`;let P=o(""),T=o(""),k=o(void 0);if(r.data!==k.current)k.current=r.data,T.current=P.current;let x=c&&g?hp(`${t??""}\x00${N}`):null,w=we(x),E=o(w.refresh);E.current=w.refresh;let z=T.current===R.current?r.data:void 0,I=w.data??z,A=I?.syncCount??z?.syncCount,H=a((te)=>{if(!c)return;let j=te??G.current,K=new URLSearchParams;if(t)K.set("root",t);if(j&&j!==".")K.set("repo",j);K.set("sync","1"),K.set("t",String(Date.now())),P.current=R.current;let W=E.current;r.load(`/api/fs/git?${K.toString()}`).then(()=>W())},[c,t,r.load]);i(()=>{if(!g)return;H()},[l,t,c,g,N,H]);let O=r.state==="loading",X=O||w.refreshing;return{activeRepo:N,setActiveRepo:h,repos:v,reposScanning:y,refreshRepos:L,isReading:O,isRefreshing:X,data:I,syncCount:A,loadRepo:H,refreshTopic:w.refresh}}function Rt(t,c){let l=at(),r=o(null),p=a((h,g,v)=>{r.current={actionType:h,extra:v};let y=new FormData;if(y.append("actionType",h),y.append("repo",c),t)y.append("root",t);if(g)y.append("file",g);if(v)Object.entries(v).forEach(([L,N])=>y.append(L,N));l.submit(y,{method:"POST",action:"/api/fs/git"})},[c,t,l]);return{state:l.state,execute:p,data:l.data,lastAction:r.current}}function Gt({rootPath:t,repo:c,execute:l}){let{sessionId:r}=yp(),[p,h]=S("git.commitDraft",""),[g,v]=S("git.amend",!1),y=o(null),L=o(p);L.current=p;let N=o(g);N.current=g;let G=o(h);G.current=h,i(()=>{if(!g)return;if(L.current.trim().length>0)return;let T=new URLSearchParams({headMessage:"1"});if(t)T.set("root",t);if(c&&c!==".")T.set("repo",c);let k=!1;return fetch(`/api/fs/git?${T.toString()}`).then((x)=>x.json()).then((x)=>{if(k)return;if(!N.current||L.current.trim().length>0)return;let w=typeof x?.message==="string"?x.message:"";if(w.length===0)return;y.current=w,G.current(w)}).catch(()=>{}),()=>{k=!0}},[g,r,t,c]);let R=a((T)=>{if(T){v(!0);return}if(y.current!==null&&L.current===y.current)h("");y.current=null,v(!1)},[v,h]),P=a(()=>{l("commit",void 0,{message:L.current,...N.current?{amend:"1"}:{}}),h(""),v(!1),y.current=null},[l,v,h]);return{message:p,setMessage:h,amend:g,seeded:y.current!==null&&p===y.current,toggleAmend:R,commit:P}}var St=48;function Ot(t,c){let l=c?.branch?.trim()??"",r=(c?.hash??"").slice(0,7),p=c?.ref?.trim()||"stash@{0}";switch(t){case"init":return{done:"Initialized the repository"};case"fetch":return{done:"Fetched every remote"};case"push":return{done:"Pushed to upstream"};case"pull":return{done:"Pulled from upstream",stopped:"Pulled"};case"sync":return{done:"Synced with upstream",stopped:"Pulled, but nothing was pushed"};case"abort_operation":return{done:"Aborted the operation in progress"};case"continue_operation":return{done:"Concluded the operation"};case"commit":{if(c?.amend==="1")return{done:"Amended the last commit"};let h=(c?.message??"").split(`
|
|
7
7
|
`)[0].trim();if(!h)return{done:"Commit created"};return{done:`Committed “${h.length>St?`${h.slice(0,St-1)}…`:h}”`}}case"checkout":return{done:l?`Switched to ${l}`:"Switched branch"};case"create_branch":case"create_branch_at":return{done:l?`Created branch ${l}`:"Created branch"};case"rename_branch":{let h=c?.newName?.trim()??"";return{done:l&&h?`Renamed ${l} to ${h}`:"Renamed branch"}}case"delete_branch":return{done:l?`Deleted branch ${l}`:"Deleted branch"};case"merge_branch":return{done:l?`Merged ${l}`:"Merged branch",stopped:l?`Merging ${l}`:"Merging the branch"};case"merge_commit":return{done:r?`Merged commit ${r}`:"Merged commit",stopped:r?`Merging ${r}`:"Merging the commit"};case"cherry_pick":return{done:r?`Cherry-picked ${r}`:"Cherry-picked commit",stopped:r?`Cherry-picking ${r}`:"Cherry-picking the commit"};case"revert_commit":return{done:r?`Reverted commit ${r}`:"Reverted commit",stopped:r?`Reverting ${r}`:"Reverting the commit"};case"rebase_commit":return{done:r?`Rebased onto ${r}`:"Rebased",stopped:r?`Rebasing onto ${r}`:"Rebasing"};case"reset_commit":{let h=c?.mode??"mixed";return{done:r?`Reset to ${r} (${h})`:`Reset (${h})`}}case"stash_push":return{done:"Stashed your changes"};case"stash_apply":return{done:c?.pop==="1"?`Popped ${p}`:`Applied ${p}`,stopped:c?.pop==="1"?`Popping ${p}`:`Applying ${p}`};case"stash_drop":return{done:`Dropped ${p}`};default:return null}}function Pt({actionType:t,extra:c,stopped:l}){let r=Ot(t,c);if(!l)return r?.done??null;let p=li[l]??l,h=r?.stopped??r?.done??"",g=t==="sync"?"resolve it above, then Sync again":"resolve it above";return h?`${h} — the ${p} stopped on a conflict; ${g}`:`The ${p} stopped on a conflict; ${g}`}function $t(t){let{fetcher:c,onPage:l,onReload:r,onSuccess:p,onError:h}=t,g=o(null),v=o({onPage:l,onReload:r,onSuccess:p,onError:h});v.current={onPage:l,onReload:r,onSuccess:p,onError:h},i(()=>{if(c.state!=="idle"||!c.data)return;let y=c.data;if(y===g.current)return;g.current=y;let L=v.current;if(y.type==="history"||y.type==="graph"){L.onPage({title:y.type==="graph"?"Git Graph":"Commit History",data:y.data||[],hasMore:y.hasMore,total:y.total});return}if(!y.success){L.onError(y.error||"Git operation failed");return}L.onReload();let N=c.lastAction,G=N?Pt({...N,stopped:y.stopped}):null;if(G)L.onSuccess(G,y.stopped?"warning":"success")},[c.state,c.data,c.lastAction])}function Mt(t,c,l,r){if(t==="revert")return{type:t,file:c,message:`Are you sure you want to discard changes in ${c}?`};if(t==="revert_all")return{type:t,message:"Are you sure you want to discard ALL unstaged changes? This cannot be undone."};if(t==="abort_operation"){let p=r?li[r]:"operation";return{type:t,message:`Abort the ${p}? Everything resolved so far is discarded and the working tree returns to its pre-${p} state.`}}if(t==="delete_branch"){let p=l?.branch??"",h=l?.force==="1";return{type:t,extra:{branch:p,...h?{force:"1"}:{}},message:h?`Delete branch ${p} even though its commits are not merged? This cannot be undone from the panel.`:`Delete branch ${p}?`}}if(t==="stash_drop"){let p=l?.ref||"the top entry";return{type:t,extra:{ref:l?.ref??""},message:`Drop ${p}? The stash entry is removed — this cannot be undone from the panel.`}}return null}function sr({className:t="",enabled:c=!0,rootPath:l,refreshKey:r=0}){let{activeRepo:p,setActiveRepo:h,repos:g,reposScanning:v,refreshRepos:y,isReading:L,isRefreshing:N,data:G,syncCount:R,loadRepo:P,refreshTopic:T}=wt(l,c,r),k=Rt(l,p),[x,w]=S("git.viewMode","flat"),[E,z]=n(!1),I=o(null),[A,H]=n(!1),O=o(null),[X,te]=n(null),[j,K]=n(!1),[W,ne]=n(""),se=o(null),[be,de]=n(!1),[pe,ve]=n(null),[Se,Pe]=n(!1),{pushToast:re}=Ve();i(()=>{Pe(!0)},[]),i(()=>{if(j&&se.current)se.current.focus()},[j]),$t({fetcher:k,onPage:ve,onReload:P,onSuccess:(q,Q)=>re(q,Q),onError:(q)=>re(q,"error")}),ce(I,()=>z(!1)),ce(O,()=>H(!1));let Z=k.execute,{message:$e,setMessage:ye,amend:ke,seeded:Me,toggleAmend:Oe,commit:U}=Gt({rootPath:l,repo:p,execute:Z}),_=(q,Q,Ne)=>{let Ie=Mt(q,Q,Ne,G?.state?.operation??null);if(Ie){te(Ie);return}Z(q,Q,Ne)},ee=(q,Q)=>{Z("resolve_conflict",q,Q?{side:Q}:void 0)},Ce=G?.branch||"main",me=G?.branches||["main"],Le=G?.remoteBranches||[],ue=G?.changes||[],oe=L||k.state!=="idle",De=k.state==="idle"?null:k.lastAction?.actionType??null,Lt=De==="sync"||De==="push"||De==="pull",Dt=ue.filter((q)=>{if(gr(q.status))return!1;let Q=q.status;return Q&&Q[0]!==" "&&Q[0]!=="?"});if(!c)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",{className:`flex flex-col h-full bg-paper relative ${t}`,children:[e(kt,{mounted:Se,confirmModal:X,onCloseConfirm:()=>te(null),onConfirm:()=>{if(X)Z(X.type,X.file,X.extra),te(null)},branchPrompt:j,newBranchName:W,newBranchInputRef:se,onNewBranchNameChange:ne,onCloseBranchPrompt:()=>{K(!1),ne("")},onCreateBranch:()=>{if(W.trim())Z("create_branch",void 0,{branch:W.trim()}),K(!1),ne("")},viewingOutput:pe,onCloseOutput:()=>ve(null),onRefreshOutput:()=>{if(pe)Z(pe.title.toLowerCase().includes("graph")?"graph":"history")},onExecuteAction:(q,Q,Ne)=>Z(q,Q,Ne),branchModalOpen:be,onCloseBranchModal:()=>de(!1),rootPath:l,activeRepo:p,currentBranch:Ce,detached:G?.state?.detached??!1,isBusy:oe,onBranchAction:(q,Q)=>Z(q,void 0,Q),onConfirmDeleteBranch:(q,Q)=>{Z("delete_branch",void 0,{branch:q,...Q?{force:"1"}:{}})}}),e(Ke,{activeRepo:p,repos:g,isRefreshing:N,rootPath:l,reposScanning:v,onSelectRepo:(q)=>{if(q!==p)h(q)},onRefresh:()=>{T(),P()},onRefreshRepos:y}),G?.isRepo===!1?e(Nt,{repo:p,isBusy:oe,onInit:()=>Z("init")}):e(d,{children:[e(qe,{branchRef:O,showBranchMenu:A,setShowBranchMenu:H,branch:Ce,branches:me,remoteBranches:Le,onCheckout:(q)=>Z("checkout",void 0,{branch:q}),onMerge:(q)=>Z("merge_branch",void 0,{branch:q}),onOpenBranchPrompt:()=>K(!0),onManageBranches:()=>{de(!0),H(!1)},optionsRef:I,showOptions:E,setShowOptions:z,onHistory:()=>Z("history"),onGraph:()=>Z("graph"),viewMode:x,setViewMode:w,isBusy:oe,syncCount:R,syncing:Lt,onSync:()=>Z("sync"),onFetch:()=>Z("fetch"),detached:G?.state?.detached??!1}),G?.state?.operation?e(We,{operation:G.state.operation,conflicts:G.state.conflicts,isBusy:oe,onAbort:()=>_("abort_operation"),onContinue:()=>Z("continue_operation")}):e(Ue,{message:$e,hasStagedChanges:Dt.length>0,isBusy:oe,amend:ke,seeded:Me,onToggleAmend:Oe,onChangeMessage:ye,onCommit:U}),e(Qe,{changes:ue,isLoading:oe,viewMode:x,repo:p,rootPath:l,onAction:_,onResolve:ee}),e(Ct,{rootPath:l,repo:p,isBusy:oe,onAction:(q,Q)=>_(q,void 0,Q)})]})]})}export{sr as GitPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,i,a,e,s,I,C,nt,Le}from"./index-cgzrpvzj.js";var q={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"}]]},S=s(q);function P({providerName:t,providerSlug:r,iconUrl:o,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(Le,{provider:{slug:r,name:t,...o?{iconUrl:o}:{}},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-xs leading-relaxed",children:[e(I,{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 B=new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR",maximumFractionDigits:0}),j=new Intl.NumberFormat("id-ID"),y=new Intl.NumberFormat("id-ID",{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}),G=new Intl.DateTimeFormat("id-ID",{dateStyle:"medium",timeStyle:"short"});function x(t){return B.format(t)}function b(t){return j.format(t)}function ea(t){let r=new Date(t);if(Number.isNaN(r.getTime()))return t;return G.format(r)}function L(t,r){if(r<=0)return 0;return Math.min(100,Math.max(0,t/r*100))}function T(t,r){if(r<=0)return"0%";return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t/r*100)}%`}function k(t){if(!Number.isFinite(t))return"0";let r=Math.abs(t);if(r>=1e9)return`${y.format(t/1e9)}B`;if(r>=1e6)return`${y.format(t/1e6)}M`;if(r>=1000)return`${y.format(t/1000)}K`;return b(t)}function N(t){let r=Number(t);if(t.trim()===""||!Number.isFinite(r))return t;return b(r)}var O=new Intl.NumberFormat("id-ID",{minimumFractionDigits:2,maximumFractionDigits:2});function U(t){if(!Number.isFinite(t))return"$0,00";return`$${O.format(t)}`}function w(t,r){if(!Number.isFinite(t))return"—";switch(r){case"percent":return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t)}%`;case"usd":return U(t);case"tokens":case"bytes":return k(t);default:return b(t)}}function D(t){if(!Number.isFinite(t))return"0%";return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t*100)}%`}function z({window:t}){let r=t.usedRp+t.remainingRp,o=L(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 ",ea(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:`${o}%`}})}),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)})," ·"," ",T(t.usedRp,r)]}),e("span",{children:["Remaining ",e("span",{className:"font-semibold text-ink",children:x(t.remainingRp)})]})]})]})}function H({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(S,{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 ",ea(t.expiresAt)]}),t.scopeModels.length>0&&e("div",{children:["Models: ",t.scopeModels.join(", ")]})]})]})}function A({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(z,{window:r},r.key))}),t.coupon&&e(H,{coupon:t.coupon})]})}function F({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),o=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:k(l.inputTokens)}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:k(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:k(r)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:k(o)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:x(t.totalCostRp)})]})})]})})]})}function E({report:t}){let{balance:r,usage:o,quota:l}=t;if(!r&&!o&&!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=o?o.rows.reduce((g,u)=>g+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(nt,{value:p,label:"Wallet balance",hint:c}),e(nt,{value:l?.planName??"–",label:"Active plan",hint:l?"kenari quota plan":"Quota unavailable"}),e(nt,{value:o?b(o.totalRequests):"–",label:"Requests (30 days)",hint:o?"Across all models":"Usage report unavailable"}),e(nt,{value:o?x(o.totalCostRp):"–",label:"Cost (30 days)",hint:o?"Billed in Rupiah":"Usage report unavailable"}),e(nt,{value:o?k(m):"–",label:"Tokens processed (30 days)",hint:o?"Input + output":"Usage report unavailable",tone:"muted",className:"col-span-2 @[540px]:col-span-1"})]})}),e(A,{quota:l}),e(F,{usage:o})]})}function W({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(nt,{value:r.isAvailable?"Available":"Unavailable",label:"Prepaid balance",hint:r.isAvailable?"Account can spend":"Top up required",tone:r.isAvailable?"default":"muted"}),e(nt,{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((o)=>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:o.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:N(o.totalBalance)})]}),e("div",{children:[e("dt",{className:"text-ink/50",children:"Granted"}),e("dd",{className:"font-semibold text-ink tabular-nums break-words",children:N(o.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:N(o.toppedUpBalance)})]})]})]},o.currency))})]})}function R(t,r,o,l){let p=t.find((c)=>c.id===r);if(p){p.limits.push(l);return}t.push({id:r,title:o,limits:[l]})}function V(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 X(t){let r=[];for(let o of t)if(o.id==="anthropic:extra")R(r,"balance","Balance",o);else R(r,"windows","Quota windows",o);return r}function J(t){let r=[];for(let o of t){let l=V(o.id);if(l.id==="third-party"){if(r.find((c)=>c.id==="third-party")?.limits.some((c)=>Z(c,o)))continue}R(r,l.id,l.title,o)}return r}function Z(t,r){return t.unit===r.unit&&t.label===r.label&&t.usedFraction===r.usedFraction&&t.remaining===r.remaining&&t.resetsAt===r.resetsAt}function _(t,r){if(r.length===0)return[];let o=t.trim().toLowerCase();if(o==="anthropic")return X(r);if(o==="google-antigravity")return J(r);return[{id:"all",title:"Quota windows",limits:[...r]}]}function Y({limit:t}){let r=Math.min(100,Math.max(0,(t.usedFraction??0)*100)),o=t.modelId??t.accountId,l=t.used!==void 0?w(t.used,t.unit):void 0,p=t.limit!==void 0?w(t.limit,t.unit):void 0,c=t.remaining!==void 0?w(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})]}),o&&e("div",{className:"text-[10px] text-ink/50 truncate",children:o})]}),e("span",{className:"text-[10px] text-ink/50 flex-shrink-0 whitespace-nowrap",children:t.resetsAt!==void 0?`Resets ${ea(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?D(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 Q({providerId:t,limits:r,tracked:o,unavailable:l,notes:p}){let c=_(t,r);return e("div",{className:"space-y-2",children:[p&&p.length>0&&e("ul",{className:"text-[10px] text-ink/50 leading-relaxed space-y-0.5",children:p.map((m)=>e("li",{children:m},m))}),c.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:!o?"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."})]}):c.map((m)=>e("div",{className:"@container space-y-2",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:m.title}),e("div",{className:"grid grid-cols-1 @[520px]:grid-cols-2 gap-2.5",children:m.limits.map((g)=>e(Y,{limit:g},g.id))})]},m.id))]})}var ee="DeepSeek exposes no usage or quota API — only the prepaid balance (and the web console at platform.deepseek.com) is available.";function ou({summary:t}){let r=Boolean(t.kenari||t.deepseek);return e(P,{providerName:t.name,providerSlug:t.id,iconUrl:t.iconUrl,credentialSources:t.credentialSources,error:t.error,note:t.deepseek?ee:void 0,children:[t.kenari&&e(E,{report:t.kenari}),t.deepseek&&e(W,{report:t.deepseek}),!r&&(t.limits.length>0||!t.error)&&e(Q,{providerId:t.id,limits:t.limits,tracked:t.tracked,unavailable:t.limitsUnavailable,notes:t.notes})]})}function te(t){let r=t.filter((p)=>p.usedFraction!==void 0);if(r.length===0){let p=t.find((c)=>c.unit==="usd"&&c.remaining!==void 0);if(p)return`${U(p.remaining??0)} left`;return t[0]?.label}let o=r.reduce((p,c)=>(c.usedFraction??0)>(p.usedFraction??0)?c:p),l=Math.round((o.usedFraction??0)*100);return o.windowLabel?`${l}% · ${o.windowLabel}`:`${l}% used`}function ys(t){return t.providers.map((r)=>({id:r.id,name:r.name,...r.iconUrl?{iconUrl:r.iconUrl}:{},error:r.error,hint:ne(r),limits:r.limits,tracked:r.tracked,limitsUnavailable:r.limitsUnavailable,summary:r}))}function ne(t){let r=t.kenari?.quota?.planName;if(r)return r;let o=t.deepseek?.balance?.entries[0];if(o)return`${o.currency} ${N(o.totalBalance)}`;return te(t.limits)??"No quota reported"}function vs(t){return t.error?"Error":"Connected"}function K(){let[t,r]=n([]),[o,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))},[]);i(()=>{m()},[m]);let g=a(async(u)=>{try{let h=await(await fetch("/api/settings/usage/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:u})})).json();if(h.ok)m();return{ok:Boolean(h.ok),message:h.message||"No result reported."}}catch(f){return{ok:!1,message:f instanceof Error?f.message:"Failed to spend the saved reset"}}},[m]);return{accounts:t,error:o,isLoading:p,reload:m,spend:g}}function ae({account:t,onSpend:r,spending:o}){let l=`${t.provider}/${t.credentialId}`,p=t.email??t.accountId??t.credentialId,c=t.orgName??t.orgId,m=t.availableCount??t.credits.length,g=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:g>0?`${g} of ${m} usable`:`${m} saved`})]}),t.soonestExpiry!==void 0&&e("div",{className:"text-[10px] text-ink/60",children:["Soonest expires ",ea(new Date(t.soonestExpiry).toISOString())]}),t.credits.length>0&&e("div",{className:"space-y-1",children:t.credits.map((f)=>e("div",{className:"flex items-center justify-between gap-2 text-[10px] text-ink/70",children:[e("span",{className:"truncate",children:f.title??f.program??f.id}),e("span",{className:"flex items-center gap-1.5 flex-shrink-0",children:[f.clears&&f.clears.length>0&&e("span",{className:"font-mono text-ink/50",children:f.clears.join(", ")}),f.usable===!1&&e("span",{className:"font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/60",children:"blocked"})]})]},f.id))}),u&&e("div",{className:"text-[10px] text-ink/60 leading-snug",children:u}),e("button",{type:"button",onClick:()=>r(l),disabled:o||g===0,title:g===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:o?"Spending…":"Spend saved reset"})]})}function su(){let{accounts:t,error:r,isLoading:o,reload:l,spend:p}=K(),[c,m]=n(null),[g,u]=n(null),f=(v)=>{m(v),u(null),p(v).then((M)=>{u(M),m(null)})},h=!o&&!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:o,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(C,{size:12,className:o?"animate-spin text-ink":""})})]}),r&&e("div",{className:"flex items-start gap-1.5 text-[10px] text-error leading-snug",children:[e(I,{size:12,className:"flex-shrink-0 mt-px"}),e("span",{children:r})]}),t.map((v)=>e(ae,{account:v,onSpend:f,spending:c===`${v.provider}/${v.credentialId}`},`${v.provider}/${v.credentialId}`)),h&&e("p",{className:"text-[10px] text-ink/50 leading-snug",children:"No saved resets on any account."}),g&&e("div",{className:`text-[10px] leading-snug ${g.ok?"text-ink/70":"text-error"}`,children:g.message})]})}function lu(){let[t,r]=n(null),[o,l]=n(!0),[p,c]=n(null),m=a(async(g)=>{if(!g?.silent)l(!0);c(null);try{let u=g?.force?"/api/settings/usage?refresh=1":"/api/settings/usage",f=await fetch(u);if(!f.ok)throw Error(`Usage request failed (${f.status})`);let h=await f.json();r(h)}catch(u){c(u instanceof Error?u.message:"Failed to load provider usage")}finally{if(!g?.silent)l(!1)}},[]);return i(()=>{m()},[m]),{report:t,isLoading:o,error:p,reload:m}}
|
|
2
|
-
export{ea,
|
|
1
|
+
import{d,n,i,a,e,s,I,C,nt,Le}from"./index-ncrenheb.js";var q={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"}]]},S=s(q);function P({providerName:t,providerSlug:r,iconUrl:o,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(Le,{provider:{slug:r,name:t,...o?{iconUrl:o}:{}},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-xs leading-relaxed",children:[e(I,{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 B=new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR",maximumFractionDigits:0}),j=new Intl.NumberFormat("id-ID"),y=new Intl.NumberFormat("id-ID",{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}),G=new Intl.DateTimeFormat("id-ID",{dateStyle:"medium",timeStyle:"short"});function x(t){return B.format(t)}function b(t){return j.format(t)}function ea(t){let r=new Date(t);if(Number.isNaN(r.getTime()))return t;return G.format(r)}function L(t,r){if(r<=0)return 0;return Math.min(100,Math.max(0,t/r*100))}function T(t,r){if(r<=0)return"0%";return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t/r*100)}%`}function k(t){if(!Number.isFinite(t))return"0";let r=Math.abs(t);if(r>=1e9)return`${y.format(t/1e9)}B`;if(r>=1e6)return`${y.format(t/1e6)}M`;if(r>=1000)return`${y.format(t/1000)}K`;return b(t)}function N(t){let r=Number(t);if(t.trim()===""||!Number.isFinite(r))return t;return b(r)}var O=new Intl.NumberFormat("id-ID",{minimumFractionDigits:2,maximumFractionDigits:2});function U(t){if(!Number.isFinite(t))return"$0,00";return`$${O.format(t)}`}function w(t,r){if(!Number.isFinite(t))return"—";switch(r){case"percent":return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t)}%`;case"usd":return U(t);case"tokens":case"bytes":return k(t);default:return b(t)}}function D(t){if(!Number.isFinite(t))return"0%";return`${new Intl.NumberFormat("id-ID",{maximumFractionDigits:1}).format(t*100)}%`}function z({window:t}){let r=t.usedRp+t.remainingRp,o=L(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 ",ea(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:`${o}%`}})}),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)})," ·"," ",T(t.usedRp,r)]}),e("span",{children:["Remaining ",e("span",{className:"font-semibold text-ink",children:x(t.remainingRp)})]})]})]})}function H({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(S,{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 ",ea(t.expiresAt)]}),t.scopeModels.length>0&&e("div",{children:["Models: ",t.scopeModels.join(", ")]})]})]})}function A({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(z,{window:r},r.key))}),t.coupon&&e(H,{coupon:t.coupon})]})}function F({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),o=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:k(l.inputTokens)}),e("td",{className:"px-3 py-1.5 text-right tabular-nums text-ink/80",children:k(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:k(r)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:k(o)}),e("td",{className:"px-3 py-2 text-right tabular-nums",children:x(t.totalCostRp)})]})})]})})]})}function E({report:t}){let{balance:r,usage:o,quota:l}=t;if(!r&&!o&&!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=o?o.rows.reduce((g,u)=>g+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(nt,{value:p,label:"Wallet balance",hint:c}),e(nt,{value:l?.planName??"–",label:"Active plan",hint:l?"kenari quota plan":"Quota unavailable"}),e(nt,{value:o?b(o.totalRequests):"–",label:"Requests (30 days)",hint:o?"Across all models":"Usage report unavailable"}),e(nt,{value:o?x(o.totalCostRp):"–",label:"Cost (30 days)",hint:o?"Billed in Rupiah":"Usage report unavailable"}),e(nt,{value:o?k(m):"–",label:"Tokens processed (30 days)",hint:o?"Input + output":"Usage report unavailable",tone:"muted",className:"col-span-2 @[540px]:col-span-1"})]})}),e(A,{quota:l}),e(F,{usage:o})]})}function W({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(nt,{value:r.isAvailable?"Available":"Unavailable",label:"Prepaid balance",hint:r.isAvailable?"Account can spend":"Top up required",tone:r.isAvailable?"default":"muted"}),e(nt,{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((o)=>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:o.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:N(o.totalBalance)})]}),e("div",{children:[e("dt",{className:"text-ink/50",children:"Granted"}),e("dd",{className:"font-semibold text-ink tabular-nums break-words",children:N(o.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:N(o.toppedUpBalance)})]})]})]},o.currency))})]})}function R(t,r,o,l){let p=t.find((c)=>c.id===r);if(p){p.limits.push(l);return}t.push({id:r,title:o,limits:[l]})}function V(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 X(t){let r=[];for(let o of t)if(o.id==="anthropic:extra")R(r,"balance","Balance",o);else R(r,"windows","Quota windows",o);return r}function J(t){let r=[];for(let o of t){let l=V(o.id);if(l.id==="third-party"){if(r.find((c)=>c.id==="third-party")?.limits.some((c)=>Z(c,o)))continue}R(r,l.id,l.title,o)}return r}function Z(t,r){return t.unit===r.unit&&t.label===r.label&&t.usedFraction===r.usedFraction&&t.remaining===r.remaining&&t.resetsAt===r.resetsAt}function _(t,r){if(r.length===0)return[];let o=t.trim().toLowerCase();if(o==="anthropic")return X(r);if(o==="google-antigravity")return J(r);return[{id:"all",title:"Quota windows",limits:[...r]}]}function Y({limit:t}){let r=Math.min(100,Math.max(0,(t.usedFraction??0)*100)),o=t.modelId??t.accountId,l=t.used!==void 0?w(t.used,t.unit):void 0,p=t.limit!==void 0?w(t.limit,t.unit):void 0,c=t.remaining!==void 0?w(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})]}),o&&e("div",{className:"text-[10px] text-ink/50 truncate",children:o})]}),e("span",{className:"text-[10px] text-ink/50 flex-shrink-0 whitespace-nowrap",children:t.resetsAt!==void 0?`Resets ${ea(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?D(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 Q({providerId:t,limits:r,tracked:o,unavailable:l,notes:p}){let c=_(t,r);return e("div",{className:"space-y-2",children:[p&&p.length>0&&e("ul",{className:"text-[10px] text-ink/50 leading-relaxed space-y-0.5",children:p.map((m)=>e("li",{children:m},m))}),c.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:!o?"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."})]}):c.map((m)=>e("div",{className:"@container space-y-2",children:[e("h4",{className:"text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40",children:m.title}),e("div",{className:"grid grid-cols-1 @[520px]:grid-cols-2 gap-2.5",children:m.limits.map((g)=>e(Y,{limit:g},g.id))})]},m.id))]})}var ee="DeepSeek exposes no usage or quota API — only the prepaid balance (and the web console at platform.deepseek.com) is available.";function su({summary:t}){let r=Boolean(t.kenari||t.deepseek);return e(P,{providerName:t.name,providerSlug:t.id,iconUrl:t.iconUrl,credentialSources:t.credentialSources,error:t.error,note:t.deepseek?ee:void 0,children:[t.kenari&&e(E,{report:t.kenari}),t.deepseek&&e(W,{report:t.deepseek}),!r&&(t.limits.length>0||!t.error)&&e(Q,{providerId:t.id,limits:t.limits,tracked:t.tracked,unavailable:t.limitsUnavailable,notes:t.notes})]})}function te(t){let r=t.filter((p)=>p.usedFraction!==void 0);if(r.length===0){let p=t.find((c)=>c.unit==="usd"&&c.remaining!==void 0);if(p)return`${U(p.remaining??0)} left`;return t[0]?.label}let o=r.reduce((p,c)=>(c.usedFraction??0)>(p.usedFraction??0)?c:p),l=Math.round((o.usedFraction??0)*100);return o.windowLabel?`${l}% · ${o.windowLabel}`:`${l}% used`}function vs(t){return t.providers.map((r)=>({id:r.id,name:r.name,...r.iconUrl?{iconUrl:r.iconUrl}:{},error:r.error,hint:ne(r),limits:r.limits,tracked:r.tracked,limitsUnavailable:r.limitsUnavailable,summary:r}))}function ne(t){let r=t.kenari?.quota?.planName;if(r)return r;let o=t.deepseek?.balance?.entries[0];if(o)return`${o.currency} ${N(o.totalBalance)}`;return te(t.limits)??"No quota reported"}function ks(t){return t.error?"Error":"Connected"}function K(){let[t,r]=n([]),[o,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))},[]);i(()=>{m()},[m]);let g=a(async(u)=>{try{let h=await(await fetch("/api/settings/usage/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:u})})).json();if(h.ok)m();return{ok:Boolean(h.ok),message:h.message||"No result reported."}}catch(f){return{ok:!1,message:f instanceof Error?f.message:"Failed to spend the saved reset"}}},[m]);return{accounts:t,error:o,isLoading:p,reload:m,spend:g}}function ae({account:t,onSpend:r,spending:o}){let l=`${t.provider}/${t.credentialId}`,p=t.email??t.accountId??t.credentialId,c=t.orgName??t.orgId,m=t.availableCount??t.credits.length,g=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:g>0?`${g} of ${m} usable`:`${m} saved`})]}),t.soonestExpiry!==void 0&&e("div",{className:"text-[10px] text-ink/60",children:["Soonest expires ",ea(new Date(t.soonestExpiry).toISOString())]}),t.credits.length>0&&e("div",{className:"space-y-1",children:t.credits.map((f)=>e("div",{className:"flex items-center justify-between gap-2 text-[10px] text-ink/70",children:[e("span",{className:"truncate",children:f.title??f.program??f.id}),e("span",{className:"flex items-center gap-1.5 flex-shrink-0",children:[f.clears&&f.clears.length>0&&e("span",{className:"font-mono text-ink/50",children:f.clears.join(", ")}),f.usable===!1&&e("span",{className:"font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/60",children:"blocked"})]})]},f.id))}),u&&e("div",{className:"text-[10px] text-ink/60 leading-snug",children:u}),e("button",{type:"button",onClick:()=>r(l),disabled:o||g===0,title:g===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:o?"Spending…":"Spend saved reset"})]})}function lu(){let{accounts:t,error:r,isLoading:o,reload:l,spend:p}=K(),[c,m]=n(null),[g,u]=n(null),f=(v)=>{m(v),u(null),p(v).then((M)=>{u(M),m(null)})},h=!o&&!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:o,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(C,{size:12,className:o?"animate-spin text-ink":""})})]}),r&&e("div",{className:"flex items-start gap-1.5 text-[10px] text-error leading-snug",children:[e(I,{size:12,className:"flex-shrink-0 mt-px"}),e("span",{children:r})]}),t.map((v)=>e(ae,{account:v,onSpend:f,spending:c===`${v.provider}/${v.credentialId}`},`${v.provider}/${v.credentialId}`)),h&&e("p",{className:"text-[10px] text-ink/50 leading-snug",children:"No saved resets on any account."}),g&&e("div",{className:`text-[10px] leading-snug ${g.ok?"text-ink/70":"text-error"}`,children:g.message})]})}function cu(){let[t,r]=n(null),[o,l]=n(!0),[p,c]=n(null),m=a(async(g)=>{if(!g?.silent)l(!0);c(null);try{let u=g?.force?"/api/settings/usage?refresh=1":"/api/settings/usage",f=await fetch(u);if(!f.ok)throw Error(`Usage request failed (${f.status})`);let h=await f.json();r(h)}catch(u){c(u instanceof Error?u.message:"Failed to load provider usage")}finally{if(!g?.silent)l(!1)}},[]);return i(()=>{m()},[m]),{report:t,isLoading:o,error:p,reload:m}}
|
|
2
|
+
export{ea,su,vs,ks,lu,cu};
|