@bkm016/basalt 0.1.35 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/chunk-082x3g29.js +3 -0
- package/chunk-0aaf270z.js +3 -0
- package/chunk-0dqv9x0y.js +51 -0
- package/chunk-0ns02fzq.js +2 -0
- package/chunk-0y13kfpt.js +5 -0
- package/chunk-1753m6xk.js +4179 -0
- package/chunk-24ae99b6.js +5 -0
- package/chunk-2cp8why4.js +2 -0
- package/chunk-3bdzn4h2.js +2 -0
- package/chunk-48m0w8xg.js +2 -0
- package/chunk-4pr7ykh0.js +2 -0
- package/chunk-4qtw5cga.js +12 -0
- package/chunk-4yqge35f.js +3 -0
- package/chunk-65rd9zn4.js +3 -0
- package/chunk-67ehvv4n.js +44 -0
- package/chunk-6wm62kte.js +18 -0
- package/chunk-6zkggkdm.js +13 -0
- package/chunk-78ferdza.js +3 -0
- package/chunk-794r8w6m.js +2 -0
- package/chunk-7azn0brs.js +7 -0
- package/chunk-7wh4n0yg.js +2 -0
- package/chunk-7z0wh161.js +25 -0
- package/chunk-95aqrqnh.js +2 -0
- package/chunk-a0zcps2d.js +2 -0
- package/chunk-a23pv6tv.js +3 -0
- package/chunk-adb2nbxk.js +2 -0
- package/chunk-as2ty5w5.js +3 -0
- package/chunk-b84y794v.js +3 -0
- package/chunk-bh80e336.js +3 -0
- package/chunk-c6azecvs.js +3 -0
- package/chunk-cc8h8mz9.js +2 -0
- package/chunk-cdb6caq7.js +3 -0
- package/chunk-cjdbsa9s.js +3 -0
- package/chunk-cnqgtmwm.js +10 -0
- package/chunk-cwn9vs1a.js +3 -0
- package/chunk-cxybp3fn.js +8 -0
- package/chunk-dea2htm4.js +2 -0
- package/chunk-e01wravf.js +12 -0
- package/chunk-f0pz8pvb.js +5 -0
- package/chunk-fvmrsrmq.js +3 -0
- package/chunk-fwdhn0gw.js +7 -0
- package/chunk-h7x8g57v.js +9 -0
- package/chunk-h8qhy3px.js +39 -0
- package/chunk-hsvchrh3.js +7 -0
- package/chunk-j1peg724.js +504 -0
- package/chunk-j2cse817.js +63 -0
- package/chunk-j3jzgw98.js +31 -0
- package/chunk-jmzdtefg.js +2 -0
- package/chunk-k0e6n6yy.js +3 -0
- package/chunk-mb2jqd5z.js +3 -0
- package/chunk-nbgtqpay.js +3 -0
- package/chunk-prfczhpq.js +10 -0
- package/chunk-pv25a7sw.js +2 -0
- package/chunk-q8m2x20d.js +286 -0
- package/chunk-qnkxeh37.js +3 -0
- package/chunk-qvfrv3rb.js +59 -0
- package/chunk-r14x07ez.js +2 -0
- package/chunk-r1kah65k.js +2 -0
- package/chunk-r6pt44wk.js +60 -0
- package/chunk-rhkw8ygf.js +3 -0
- package/chunk-rvqeb7gr.js +3 -0
- package/chunk-rwa7mfwa.js +2 -0
- package/chunk-sj46f002.js +2 -0
- package/chunk-sp89jja7.js +3 -0
- package/chunk-sss5x2ak.js +2 -0
- package/chunk-szn4y5mx.js +25 -0
- package/chunk-t05q9ksf.js +2 -0
- package/chunk-tb66q678.js +11 -0
- package/chunk-tej75y8n.js +2 -0
- package/chunk-tmfr2ym8.js +4 -0
- package/chunk-txwheg1n.js +2 -0
- package/chunk-ve6n38r4.js +16 -0
- package/chunk-vfa49qcy.js +3 -0
- package/chunk-wcy1r6vv.js +2 -0
- package/chunk-wj6am3ag.js +3 -0
- package/chunk-x0afp8wt.js +3 -0
- package/chunk-xe627eyp.js +20 -0
- package/chunk-y18ey7s9.js +8 -0
- package/chunk-y9r7tt53.js +3 -0
- package/chunk-yq20v3va.js +3 -0
- package/chunk-yyg4ygv7.js +2 -0
- package/chunk-z2zhr4e5.js +3 -0
- package/chunk-zdtg52xn.js +2 -0
- package/chunk-zrhdrkdb.js +5 -0
- package/compiled.js +9 -9
- package/package.json +1 -1
- package/ui-test-worker.js +33 -33
- package/web/chunk-0d0fwb7b.js +2 -0
- package/web/chunk-0d0fwb7b.js.br +0 -0
- package/web/chunk-0d0fwb7b.js.gz +0 -0
- package/web/chunk-0jm4zyrt.js +1 -0
- package/web/chunk-0jm4zyrt.js.br +0 -0
- package/web/chunk-0jm4zyrt.js.gz +0 -0
- package/web/chunk-0pp7dzx1.js +1 -0
- package/web/chunk-0pp7dzx1.js.br +0 -0
- package/web/chunk-0pp7dzx1.js.gz +0 -0
- package/web/chunk-0w73jp4n.js +1 -0
- package/web/chunk-0w73jp4n.js.br +0 -0
- package/web/chunk-0w73jp4n.js.gz +0 -0
- package/web/chunk-1416f30c.js +2 -0
- package/web/chunk-1416f30c.js.br +0 -0
- package/web/chunk-1416f30c.js.gz +0 -0
- package/web/chunk-18wyawez.js +30 -0
- package/web/chunk-18wyawez.js.br +0 -0
- package/web/chunk-18wyawez.js.gz +0 -0
- package/web/chunk-19ew9re5.js +1 -0
- package/web/chunk-19ew9re5.js.br +0 -0
- package/web/chunk-19ew9re5.js.gz +0 -0
- package/web/chunk-1mdtr9wk.js +8 -0
- package/web/chunk-1mdtr9wk.js.br +1 -0
- package/web/chunk-1mdtr9wk.js.gz +0 -0
- package/web/chunk-1p4egv85.js +1 -0
- package/web/chunk-1p4egv85.js.br +0 -0
- package/web/chunk-1p4egv85.js.gz +0 -0
- package/web/chunk-1x61dvvr.js +2 -0
- package/web/chunk-1x61dvvr.js.br +0 -0
- package/web/chunk-1x61dvvr.js.gz +0 -0
- package/web/chunk-241n0y1h.js +1 -0
- package/web/chunk-241n0y1h.js.br +0 -0
- package/web/chunk-241n0y1h.js.gz +0 -0
- package/web/chunk-26sgnzb2.js +1 -0
- package/web/chunk-26sgnzb2.js.br +0 -0
- package/web/chunk-26sgnzb2.js.gz +0 -0
- package/web/chunk-2p77pefd.js +1 -0
- package/web/chunk-2p77pefd.js.br +0 -0
- package/web/chunk-2p77pefd.js.gz +0 -0
- package/web/chunk-2ppe5znq.js +1 -0
- package/web/chunk-2ppe5znq.js.br +0 -0
- package/web/chunk-2ppe5znq.js.gz +0 -0
- package/web/chunk-2qzr943m.js +2 -0
- package/web/chunk-2qzr943m.js.br +0 -0
- package/web/chunk-2qzr943m.js.gz +0 -0
- package/web/chunk-32k44660.js +214 -0
- package/web/chunk-32k44660.js.br +0 -0
- package/web/chunk-32k44660.js.gz +0 -0
- package/web/chunk-33zb5a76.js +2 -0
- package/web/chunk-33zb5a76.js.br +0 -0
- package/web/chunk-33zb5a76.js.gz +0 -0
- package/web/chunk-38bzkv9k.js +7 -0
- package/web/chunk-38bzkv9k.js.br +0 -0
- package/web/chunk-38bzkv9k.js.gz +0 -0
- package/web/chunk-42ytz496.js +1 -0
- package/web/chunk-42ytz496.js.br +0 -0
- package/web/chunk-42ytz496.js.gz +0 -0
- package/web/chunk-4749rrqv.js +55 -0
- package/web/chunk-4749rrqv.js.br +0 -0
- package/web/chunk-4749rrqv.js.gz +0 -0
- package/web/chunk-4d57cnh5.js +40 -0
- package/web/chunk-4d57cnh5.js.br +0 -0
- package/web/chunk-4d57cnh5.js.gz +0 -0
- package/web/chunk-4gh3hcrc.js +1 -0
- package/web/chunk-4gh3hcrc.js.br +0 -0
- package/web/chunk-4gh3hcrc.js.gz +0 -0
- package/web/chunk-4hg08mj3.js +1 -0
- package/web/chunk-4hg08mj3.js.br +0 -0
- package/web/chunk-4hg08mj3.js.gz +0 -0
- package/web/chunk-4rra9tt7.js +78 -0
- package/web/chunk-4rra9tt7.js.br +0 -0
- package/web/chunk-4rra9tt7.js.gz +0 -0
- package/web/chunk-572kjbne.js +89 -0
- package/web/chunk-572kjbne.js.br +0 -0
- package/web/chunk-572kjbne.js.gz +0 -0
- package/web/chunk-5hqe3cct.js +98 -0
- package/web/chunk-5hqe3cct.js.br +0 -0
- package/web/chunk-5hqe3cct.js.gz +0 -0
- package/web/chunk-5k4vdcwk.js +24 -0
- package/web/chunk-5k4vdcwk.js.br +0 -0
- package/web/chunk-5k4vdcwk.js.gz +0 -0
- package/web/chunk-5z44jbdc.js +1 -0
- package/web/chunk-5z44jbdc.js.br +0 -0
- package/web/chunk-5z44jbdc.js.gz +0 -0
- package/web/chunk-600x58nm.js +1143 -0
- package/web/chunk-600x58nm.js.br +0 -0
- package/web/chunk-600x58nm.js.gz +0 -0
- package/web/chunk-61djfs0t.js +140 -0
- package/web/chunk-61djfs0t.js.br +0 -0
- package/web/chunk-61djfs0t.js.gz +0 -0
- package/web/chunk-6j4jdvtd.js +1 -0
- package/web/chunk-6j4jdvtd.js.br +0 -0
- package/web/chunk-6j4jdvtd.js.gz +0 -0
- package/web/chunk-74ymgabb.js +2 -0
- package/web/chunk-74ymgabb.js.br +0 -0
- package/web/chunk-74ymgabb.js.gz +0 -0
- package/web/chunk-768vchz5.js +169 -0
- package/web/chunk-768vchz5.js.br +0 -0
- package/web/chunk-768vchz5.js.gz +0 -0
- package/web/chunk-7f87paxe.js +36 -0
- package/web/chunk-7f87paxe.js.br +0 -0
- package/web/chunk-7f87paxe.js.gz +0 -0
- package/web/chunk-7ns0kj87.js +2 -0
- package/web/chunk-7ns0kj87.js.br +0 -0
- package/web/chunk-7ns0kj87.js.gz +0 -0
- package/web/chunk-7vpk9y00.js +1 -0
- package/web/chunk-7vpk9y00.js.br +0 -0
- package/web/chunk-7vpk9y00.js.gz +0 -0
- package/web/chunk-89mc1vj3.js +1 -0
- package/web/chunk-89mc1vj3.js.br +0 -0
- package/web/chunk-89mc1vj3.js.gz +0 -0
- package/web/chunk-8wgpesrk.js +139 -0
- package/web/chunk-8wgpesrk.js.br +0 -0
- package/web/chunk-8wgpesrk.js.gz +0 -0
- package/web/chunk-9nh1aeqs.js +303 -0
- package/web/chunk-9nh1aeqs.js.br +0 -0
- package/web/chunk-9nh1aeqs.js.gz +0 -0
- package/web/chunk-9pgq2ax4.js +1 -0
- package/web/chunk-9pgq2ax4.js.br +0 -0
- package/web/chunk-9pgq2ax4.js.gz +0 -0
- package/web/chunk-9tfs2dg1.js +1 -0
- package/web/chunk-9tfs2dg1.js.br +0 -0
- package/web/chunk-9tfs2dg1.js.gz +0 -0
- package/web/chunk-9wemd2wn.js +41 -0
- package/web/chunk-9wemd2wn.js.br +0 -0
- package/web/chunk-9wemd2wn.js.gz +0 -0
- package/web/chunk-9wsz2j8n.js +1 -0
- package/web/chunk-9wsz2j8n.js.br +0 -0
- package/web/chunk-9wsz2j8n.js.gz +0 -0
- package/web/chunk-9wzvqpre.js +2 -0
- package/web/chunk-9wzvqpre.js.br +0 -0
- package/web/chunk-9wzvqpre.js.gz +0 -0
- package/web/chunk-a48wgrb1.js +1 -0
- package/web/chunk-a48wgrb1.js.br +2 -0
- package/web/chunk-a48wgrb1.js.gz +0 -0
- package/web/chunk-a67d8w1k.js +14 -0
- package/web/chunk-a67d8w1k.js.br +0 -0
- package/web/chunk-a67d8w1k.js.gz +0 -0
- package/web/chunk-ah8e1y9j.js +4 -0
- package/web/chunk-ah8e1y9j.js.br +0 -0
- package/web/chunk-ah8e1y9j.js.gz +0 -0
- package/web/chunk-amsr9cg2.js +1 -0
- package/web/chunk-amsr9cg2.js.br +0 -0
- package/web/chunk-amsr9cg2.js.gz +0 -0
- package/web/chunk-aps2c5t2.js +16 -0
- package/web/chunk-aps2c5t2.js.br +0 -0
- package/web/chunk-aps2c5t2.js.gz +0 -0
- package/web/chunk-avfynf6y.js +1 -0
- package/web/chunk-avfynf6y.js.br +0 -0
- package/web/chunk-avfynf6y.js.gz +0 -0
- package/web/chunk-b5zrttcx.js +2 -0
- package/web/chunk-b5zrttcx.js.br +0 -0
- package/web/chunk-b5zrttcx.js.gz +0 -0
- package/web/chunk-bvvf024a.js +24 -0
- package/web/chunk-bvvf024a.js.br +0 -0
- package/web/chunk-bvvf024a.js.gz +0 -0
- package/web/chunk-by2dphx7.js +200 -0
- package/web/chunk-by2dphx7.js.br +0 -0
- package/web/chunk-by2dphx7.js.gz +0 -0
- package/web/chunk-c0sc2yy1.js +1 -0
- package/web/chunk-c0sc2yy1.js.br +0 -0
- package/web/chunk-c0sc2yy1.js.gz +0 -0
- package/web/chunk-c612n2pw.js +2 -0
- package/web/chunk-c612n2pw.js.br +0 -0
- package/web/chunk-c612n2pw.js.gz +0 -0
- package/web/chunk-c91rk85x.js +2 -0
- package/web/chunk-c91rk85x.js.br +0 -0
- package/web/chunk-c91rk85x.js.gz +0 -0
- package/web/chunk-catm30vp.js +2 -0
- package/web/chunk-catm30vp.js.br +0 -0
- package/web/chunk-catm30vp.js.gz +0 -0
- package/web/chunk-cbdxzddd.js +142 -0
- package/web/chunk-cbdxzddd.js.br +0 -0
- package/web/chunk-cbdxzddd.js.gz +0 -0
- package/web/chunk-cng693ts.js +2 -0
- package/web/chunk-cng693ts.js.br +0 -0
- package/web/chunk-cng693ts.js.gz +0 -0
- package/web/chunk-d5vcma5a.js +89 -0
- package/web/chunk-d5vcma5a.js.br +0 -0
- package/web/chunk-d5vcma5a.js.gz +0 -0
- package/web/chunk-d6d9cp71.js +1 -0
- package/web/chunk-d6d9cp71.js.br +2 -0
- package/web/chunk-d6d9cp71.js.gz +0 -0
- package/web/chunk-dsghhcew.js +1 -0
- package/web/chunk-dsghhcew.js.br +0 -0
- package/web/chunk-dsghhcew.js.gz +0 -0
- package/web/chunk-dt2e6evf.js +1 -0
- package/web/chunk-dt2e6evf.js.br +0 -0
- package/web/chunk-dt2e6evf.js.gz +0 -0
- package/web/chunk-dxrsmcah.js +1 -0
- package/web/chunk-dxrsmcah.js.br +0 -0
- package/web/chunk-dxrsmcah.js.gz +0 -0
- package/web/chunk-ent5zx24.js +1 -0
- package/web/chunk-ent5zx24.js.br +2 -0
- package/web/chunk-ent5zx24.js.gz +0 -0
- package/web/chunk-f4n1q3mf.js +1 -0
- package/web/chunk-f4n1q3mf.js.br +0 -0
- package/web/chunk-f4n1q3mf.js.gz +0 -0
- package/web/chunk-fdfrv6bc.js +1 -0
- package/web/chunk-fdfrv6bc.js.br +2 -0
- package/web/chunk-fdfrv6bc.js.gz +0 -0
- package/web/chunk-fh44xz70.js +1 -0
- package/web/chunk-fh44xz70.js.br +0 -0
- package/web/chunk-fh44xz70.js.gz +0 -0
- package/web/chunk-fkbp72gk.js +1 -0
- package/web/chunk-fkbp72gk.js.br +0 -0
- package/web/chunk-fkbp72gk.js.gz +0 -0
- package/web/chunk-fzkjgwzq.js +4 -0
- package/web/chunk-fzkjgwzq.js.br +0 -0
- package/web/chunk-fzkjgwzq.js.gz +0 -0
- package/web/chunk-gf2gznsb.js +38 -0
- package/web/chunk-gf2gznsb.js.br +0 -0
- package/web/chunk-gf2gznsb.js.gz +0 -0
- package/web/chunk-gne1ybac.js +2 -0
- package/web/chunk-gne1ybac.js.br +0 -0
- package/web/chunk-gne1ybac.js.gz +0 -0
- package/web/chunk-gws1fj71.js +106 -0
- package/web/chunk-gws1fj71.js.br +0 -0
- package/web/chunk-gws1fj71.js.gz +0 -0
- package/web/chunk-h4m88fg8.js +2 -0
- package/web/chunk-h4m88fg8.js.br +0 -0
- package/web/chunk-h4m88fg8.js.gz +0 -0
- package/web/chunk-h4vk09kd.js +2 -0
- package/web/chunk-h4vk09kd.js.br +0 -0
- package/web/chunk-h4vk09kd.js.gz +0 -0
- package/web/chunk-h6wzjfj2.js +34 -0
- package/web/chunk-h6wzjfj2.js.br +0 -0
- package/web/chunk-h6wzjfj2.js.gz +0 -0
- package/web/chunk-hajg1p0h.js +7 -0
- package/web/chunk-hajg1p0h.js.br +0 -0
- package/web/chunk-hajg1p0h.js.gz +0 -0
- package/web/chunk-hhmd6qrc.js +2 -0
- package/web/chunk-hhmd6qrc.js.br +0 -0
- package/web/chunk-hhmd6qrc.js.gz +0 -0
- package/web/chunk-hya0fh1r.js +1 -0
- package/web/chunk-hya0fh1r.js.br +0 -0
- package/web/chunk-hya0fh1r.js.gz +0 -0
- package/web/chunk-j469ky77.js +1 -0
- package/web/chunk-j469ky77.js.br +0 -0
- package/web/chunk-j469ky77.js.gz +0 -0
- package/web/chunk-j6ymcm3h.js +2 -0
- package/web/chunk-j6ymcm3h.js.br +0 -0
- package/web/chunk-j6ymcm3h.js.gz +0 -0
- package/web/chunk-j79z6bta.js +21 -0
- package/web/chunk-j79z6bta.js.br +0 -0
- package/web/chunk-j79z6bta.js.gz +0 -0
- package/web/chunk-jbxc5y3z.js +12 -0
- package/web/chunk-jbxc5y3z.js.br +0 -0
- package/web/chunk-jbxc5y3z.js.gz +0 -0
- package/web/chunk-jcc187d7.js +1 -0
- package/web/chunk-jcc187d7.js.br +0 -0
- package/web/chunk-jcc187d7.js.gz +0 -0
- package/web/chunk-jjvpdxhd.js +2 -0
- package/web/chunk-jjvpdxhd.js.br +0 -0
- package/web/chunk-jjvpdxhd.js.gz +0 -0
- package/web/chunk-jrh3mwmy.js +2 -0
- package/web/chunk-jrh3mwmy.js.br +0 -0
- package/web/chunk-jrh3mwmy.js.gz +0 -0
- package/web/chunk-jv3pgdp0.js +1 -0
- package/web/chunk-jv3pgdp0.js.br +2 -0
- package/web/chunk-jv3pgdp0.js.gz +0 -0
- package/web/chunk-ksxjhezb.js +1 -0
- package/web/chunk-ksxjhezb.js.br +0 -0
- package/web/chunk-ksxjhezb.js.gz +0 -0
- package/web/chunk-ktnd8t40.js +2 -0
- package/web/chunk-ktnd8t40.js.br +0 -0
- package/web/chunk-ktnd8t40.js.gz +0 -0
- package/web/chunk-mgwv3dp0.js +1 -0
- package/web/chunk-mgwv3dp0.js.br +0 -0
- package/web/chunk-mgwv3dp0.js.gz +0 -0
- package/web/chunk-mtjdfgjj.js +2 -0
- package/web/chunk-mtjdfgjj.js.br +0 -0
- package/web/chunk-mtjdfgjj.js.gz +0 -0
- package/web/chunk-mzkaanwd.js +2 -0
- package/web/chunk-mzkaanwd.js.br +0 -0
- package/web/chunk-mzkaanwd.js.gz +0 -0
- package/web/chunk-n22pg5xy.js +1 -0
- package/web/chunk-n22pg5xy.js.br +0 -0
- package/web/chunk-n22pg5xy.js.gz +0 -0
- package/web/chunk-n58ezsfb.js +2 -0
- package/web/chunk-n58ezsfb.js.br +0 -0
- package/web/chunk-n58ezsfb.js.gz +0 -0
- package/web/chunk-nhx74teq.js +3 -0
- package/web/chunk-nhx74teq.js.br +0 -0
- package/web/chunk-nhx74teq.js.gz +0 -0
- package/web/chunk-njjsgwfw.js +2 -0
- package/web/chunk-njjsgwfw.js.br +0 -0
- package/web/chunk-njjsgwfw.js.gz +0 -0
- package/web/chunk-nwhqcbnr.js +1 -0
- package/web/chunk-nwhqcbnr.js.br +0 -0
- package/web/chunk-nwhqcbnr.js.gz +0 -0
- package/web/chunk-pnghaajd.js +70 -0
- package/web/chunk-pnghaajd.js.br +0 -0
- package/web/chunk-pnghaajd.js.gz +0 -0
- package/web/chunk-pqfn8x7v.js +1 -0
- package/web/chunk-pqfn8x7v.js.br +0 -0
- package/web/chunk-pqfn8x7v.js.gz +0 -0
- package/web/chunk-ptk0jnyx.js +1 -0
- package/web/chunk-ptk0jnyx.js.br +0 -0
- package/web/chunk-ptk0jnyx.js.gz +0 -0
- package/web/chunk-pv7e5g4k.js +370 -0
- package/web/chunk-pv7e5g4k.js.br +0 -0
- package/web/chunk-pv7e5g4k.js.gz +0 -0
- package/web/chunk-pxnh5qgn.js +2 -0
- package/web/chunk-pxnh5qgn.js.br +0 -0
- package/web/chunk-pxnh5qgn.js.gz +0 -0
- package/web/chunk-q6eq5y2t.js +1 -0
- package/web/chunk-q6eq5y2t.js.br +2 -0
- package/web/chunk-q6eq5y2t.js.gz +0 -0
- package/web/chunk-qdwg9n1d.js +1 -0
- package/web/chunk-qdwg9n1d.js.br +0 -0
- package/web/chunk-qdwg9n1d.js.gz +0 -0
- package/web/chunk-qp42gtvd.js +1 -0
- package/web/chunk-qp42gtvd.js.br +0 -0
- package/web/chunk-qp42gtvd.js.gz +0 -0
- package/web/chunk-qzdw8vdp.js +1 -0
- package/web/chunk-qzdw8vdp.js.br +0 -0
- package/web/chunk-qzdw8vdp.js.gz +0 -0
- package/web/chunk-r571ywxq.js +1 -0
- package/web/chunk-r571ywxq.js.br +0 -0
- package/web/chunk-r571ywxq.js.gz +0 -0
- package/web/chunk-r9fx4cjw.js +1 -0
- package/web/chunk-r9fx4cjw.js.br +0 -0
- package/web/chunk-r9fx4cjw.js.gz +0 -0
- package/web/chunk-rhvq3c1c.js +1 -0
- package/web/chunk-rhvq3c1c.js.br +0 -0
- package/web/chunk-rhvq3c1c.js.gz +0 -0
- package/web/chunk-rjay9w1t.js +1 -0
- package/web/chunk-rjay9w1t.js.br +0 -0
- package/web/chunk-rjay9w1t.js.gz +0 -0
- package/web/chunk-rpvdnc3p.js +1 -0
- package/web/chunk-rpvdnc3p.js.br +0 -0
- package/web/chunk-rpvdnc3p.js.gz +0 -0
- package/web/chunk-rrfr4wyt.js +62 -0
- package/web/chunk-rrfr4wyt.js.br +0 -0
- package/web/chunk-rrfr4wyt.js.gz +0 -0
- package/web/chunk-rvngywg9.js +2 -0
- package/web/chunk-rvngywg9.js.br +0 -0
- package/web/chunk-rvngywg9.js.gz +0 -0
- package/web/chunk-rw7d025r.js +84 -0
- package/web/chunk-rw7d025r.js.br +0 -0
- package/web/chunk-rw7d025r.js.gz +0 -0
- package/web/chunk-s1g8acth.js +324 -0
- package/web/chunk-s1g8acth.js.br +0 -0
- package/web/chunk-s1g8acth.js.gz +0 -0
- package/web/chunk-s8572njv.js +2 -0
- package/web/chunk-s8572njv.js.br +1 -0
- package/web/chunk-s8572njv.js.gz +0 -0
- package/web/chunk-sb57e1m9.css +1 -0
- package/web/chunk-sb57e1m9.css.br +0 -0
- package/web/chunk-sb57e1m9.css.gz +0 -0
- package/web/chunk-sn3h5adt.js +2 -0
- package/web/chunk-sn3h5adt.js.br +0 -0
- package/web/chunk-sn3h5adt.js.gz +0 -0
- package/web/chunk-tb2v18q8.js +2 -0
- package/web/chunk-tb2v18q8.js.br +0 -0
- package/web/chunk-tb2v18q8.js.gz +0 -0
- package/web/chunk-tetbyky0.js +39 -0
- package/web/chunk-tetbyky0.js.br +0 -0
- package/web/chunk-tetbyky0.js.gz +0 -0
- package/web/chunk-tqvctvsv.js +1 -0
- package/web/chunk-tqvctvsv.js.br +0 -0
- package/web/chunk-tqvctvsv.js.gz +0 -0
- package/web/chunk-v9mj2pxz.js +1 -0
- package/web/chunk-v9mj2pxz.js.br +0 -0
- package/web/chunk-v9mj2pxz.js.gz +0 -0
- package/web/chunk-vkhah4nd.js +2 -0
- package/web/chunk-vkhah4nd.js.br +0 -0
- package/web/chunk-vkhah4nd.js.gz +0 -0
- package/web/chunk-vpnh7wmw.js +1 -0
- package/web/chunk-vpnh7wmw.js.br +0 -0
- package/web/chunk-vpnh7wmw.js.gz +0 -0
- package/web/chunk-w1qe2x5p.js +217 -0
- package/web/chunk-w1qe2x5p.js.br +0 -0
- package/web/chunk-w1qe2x5p.js.gz +0 -0
- package/web/chunk-werh47fw.js +99 -0
- package/web/chunk-werh47fw.js.br +0 -0
- package/web/chunk-werh47fw.js.gz +0 -0
- package/web/chunk-wfmf0dc8.js +1 -0
- package/web/chunk-wfmf0dc8.js.br +0 -0
- package/web/chunk-wfmf0dc8.js.gz +0 -0
- package/web/chunk-wna4vqp6.js +1 -0
- package/web/chunk-wna4vqp6.js.br +0 -0
- package/web/chunk-wna4vqp6.js.gz +0 -0
- package/web/chunk-wwhq09nf.js +1 -0
- package/web/chunk-wwhq09nf.js.br +0 -0
- package/web/chunk-wwhq09nf.js.gz +0 -0
- package/web/chunk-x6va53y6.js +291 -0
- package/web/chunk-x6va53y6.js.br +0 -0
- package/web/chunk-x6va53y6.js.gz +0 -0
- package/web/chunk-xefyzr9s.js +120 -0
- package/web/chunk-xefyzr9s.js.br +0 -0
- package/web/chunk-xefyzr9s.js.gz +0 -0
- package/web/chunk-xj1w9054.js +2 -0
- package/web/chunk-xj1w9054.js.br +0 -0
- package/web/chunk-xj1w9054.js.gz +0 -0
- package/web/chunk-xtb3xhxk.js +2 -0
- package/web/chunk-xtb3xhxk.js.br +2 -0
- package/web/chunk-xtb3xhxk.js.gz +0 -0
- package/web/chunk-y1eeptks.js +2 -0
- package/web/chunk-y1eeptks.js.br +0 -0
- package/web/chunk-y1eeptks.js.gz +0 -0
- package/web/chunk-y7z6zmvp.js +292 -0
- package/web/chunk-y7z6zmvp.js.br +0 -0
- package/web/chunk-y7z6zmvp.js.gz +0 -0
- package/web/chunk-yj8tkncg.js +7 -0
- package/web/chunk-yj8tkncg.js.br +0 -0
- package/web/chunk-yj8tkncg.js.gz +0 -0
- package/web/chunk-z0m2d74w.js +1 -0
- package/web/chunk-z0m2d74w.js.br +0 -0
- package/web/chunk-z0m2d74w.js.gz +0 -0
- package/web/chunk-z30kqv40.js +1 -0
- package/web/chunk-z30kqv40.js.br +0 -0
- package/web/chunk-z30kqv40.js.gz +0 -0
- package/web/chunk-z3a96d42.js +332 -0
- package/web/chunk-z3a96d42.js.br +0 -0
- package/web/chunk-z3a96d42.js.gz +0 -0
- package/web/index.html +1 -1
- package/web/index.html.br +0 -0
- package/web/index.html.gz +0 -0
- package/worker.js +1 -1
- package/chunk-10y5hvt2.js +0 -2
- package/chunk-22k2be3e.js +0 -13
- package/chunk-28hye007.js +0 -2
- package/chunk-2fmsw1c6.js +0 -5
- package/chunk-2h2mvrw2.js +0 -3
- package/chunk-2xj51v3m.js +0 -3
- package/chunk-3x0wm92n.js +0 -3
- package/chunk-4fgsqb1e.js +0 -2
- package/chunk-519eek65.js +0 -39
- package/chunk-5qa4dean.js +0 -2
- package/chunk-5x256mz8.js +0 -2
- package/chunk-6n01sefp.js +0 -8
- package/chunk-74xtmwpw.js +0 -2
- package/chunk-7mafj833.js +0 -3
- package/chunk-7v1sqn9k.js +0 -59
- package/chunk-8my52htr.js +0 -3
- package/chunk-8vh98e46.js +0 -2
- package/chunk-92mpgche.js +0 -2
- package/chunk-9vacevyf.js +0 -3
- package/chunk-9y44m27k.js +0 -5
- package/chunk-a5wv2shs.js +0 -3
- package/chunk-a78qhb4t.js +0 -5
- package/chunk-axsxx67j.js +0 -3
- package/chunk-b49fzzzn.js +0 -2
- package/chunk-bc8awbnt.js +0 -2
- package/chunk-crxs0n0r.js +0 -3
- package/chunk-csed8fsv.js +0 -3
- package/chunk-cspx3bz9.js +0 -2
- package/chunk-ctdtmwmd.js +0 -63
- package/chunk-d3xsmwbh.js +0 -25
- package/chunk-dvwgpsfz.js +0 -3
- package/chunk-dzd8k6bw.js +0 -3
- package/chunk-e2xqa46t.js +0 -2
- package/chunk-e41mpwx9.js +0 -9
- package/chunk-e5ccfgsk.js +0 -3
- package/chunk-e67wqhzh.js +0 -12
- package/chunk-emeb13nd.js +0 -25
- package/chunk-ers9s2c4.js +0 -31
- package/chunk-ezq0fnz6.js +0 -3
- package/chunk-ezqvx0hm.js +0 -2
- package/chunk-f10ca9ma.js +0 -12
- package/chunk-f72jhcp8.js +0 -2
- package/chunk-fjv41a8r.js +0 -4155
- package/chunk-gj0dhgbg.js +0 -3
- package/chunk-h0ggc6pv.js +0 -60
- package/chunk-hrt42rkh.js +0 -4
- package/chunk-j7m36g5w.js +0 -3
- package/chunk-jhn30hjp.js +0 -2
- package/chunk-ka41gq1g.js +0 -16
- package/chunk-kcp9byws.js +0 -2
- package/chunk-me72k64f.js +0 -7
- package/chunk-n4jemqf1.js +0 -2
- package/chunk-ndt4jvh1.js +0 -3
- package/chunk-pyxn4wqj.js +0 -3
- package/chunk-rajb3566.js +0 -2
- package/chunk-rbq2gsar.js +0 -3
- package/chunk-rd98e7kg.js +0 -10
- package/chunk-rm5dbbsg.js +0 -3
- package/chunk-rztw3tgx.js +0 -3
- package/chunk-s4mn41eh.js +0 -8
- package/chunk-s9p624fq.js +0 -44
- package/chunk-sawrte7v.js +0 -3
- package/chunk-sd8d792h.js +0 -51
- package/chunk-sgvmxx0d.js +0 -2
- package/chunk-sqbnt2t1.js +0 -3
- package/chunk-t2bvj735.js +0 -2
- package/chunk-t8tkamx6.js +0 -2
- package/chunk-tbehe5ky.js +0 -18
- package/chunk-tsha69rv.js +0 -7
- package/chunk-twqwer9t.js +0 -5
- package/chunk-vr2rtqeh.js +0 -2
- package/chunk-vr6eej6b.js +0 -3
- package/chunk-w41gswj8.js +0 -3
- package/chunk-x7tras0x.js +0 -498
- package/chunk-xakmebnm.js +0 -10
- package/chunk-xj453mny.js +0 -286
- package/chunk-xmrw19xj.js +0 -2
- package/chunk-xpj8fcjp.js +0 -20
- package/chunk-y218jsvc.js +0 -3
- package/chunk-y33fkh8m.js +0 -2
- package/chunk-z3h9ydyr.js +0 -11
- package/chunk-zc51vfhr.js +0 -2
- package/chunk-zm88mnds.js +0 -7
- package/chunk-zz9rj82y.js +0 -3
- package/web/chunk-0b5vh2pt.js +0 -2
- package/web/chunk-0b5vh2pt.js.br +0 -0
- package/web/chunk-0b5vh2pt.js.gz +0 -0
- package/web/chunk-0hkdqhkv.js +0 -1
- package/web/chunk-0hkdqhkv.js.br +0 -0
- package/web/chunk-0hkdqhkv.js.gz +0 -0
- package/web/chunk-0v7wrb32.js +0 -2
- package/web/chunk-0v7wrb32.js.br +0 -0
- package/web/chunk-0v7wrb32.js.gz +0 -0
- package/web/chunk-0x2fgw1m.js +0 -1
- package/web/chunk-0x2fgw1m.js.br +0 -0
- package/web/chunk-0x2fgw1m.js.gz +0 -0
- package/web/chunk-0xctxqvv.js +0 -2
- package/web/chunk-0xctxqvv.js.br +0 -0
- package/web/chunk-0xctxqvv.js.gz +0 -0
- package/web/chunk-0y9tf0rt.js +0 -89
- package/web/chunk-0y9tf0rt.js.br +0 -0
- package/web/chunk-0y9tf0rt.js.gz +0 -0
- package/web/chunk-0yrp0f6x.js +0 -1
- package/web/chunk-0yrp0f6x.js.br +0 -0
- package/web/chunk-0yrp0f6x.js.gz +0 -0
- package/web/chunk-10jk2pn9.js +0 -1
- package/web/chunk-10jk2pn9.js.br +0 -0
- package/web/chunk-10jk2pn9.js.gz +0 -0
- package/web/chunk-15ka35m9.js +0 -2
- package/web/chunk-15ka35m9.js.br +0 -0
- package/web/chunk-15ka35m9.js.gz +0 -0
- package/web/chunk-1700cges.js +0 -1
- package/web/chunk-1700cges.js.br +0 -0
- package/web/chunk-1700cges.js.gz +0 -0
- package/web/chunk-1apw6pnk.css +0 -1
- package/web/chunk-1apw6pnk.css.br +0 -0
- package/web/chunk-1apw6pnk.css.gz +0 -0
- package/web/chunk-1b005nqw.js +0 -139
- package/web/chunk-1b005nqw.js.br +0 -0
- package/web/chunk-1b005nqw.js.gz +0 -0
- package/web/chunk-1c9khgyt.js +0 -1
- package/web/chunk-1c9khgyt.js.br +0 -2
- package/web/chunk-1c9khgyt.js.gz +0 -0
- package/web/chunk-1pr20x9x.js +0 -1
- package/web/chunk-1pr20x9x.js.br +0 -0
- package/web/chunk-1pr20x9x.js.gz +0 -0
- package/web/chunk-1sjgdggk.js +0 -7
- package/web/chunk-1sjgdggk.js.br +0 -0
- package/web/chunk-1sjgdggk.js.gz +0 -0
- package/web/chunk-1tt5ympp.js +0 -1
- package/web/chunk-1tt5ympp.js.br +0 -0
- package/web/chunk-1tt5ympp.js.gz +0 -0
- package/web/chunk-29fpfs5q.js +0 -1142
- package/web/chunk-29fpfs5q.js.br +0 -0
- package/web/chunk-29fpfs5q.js.gz +0 -0
- package/web/chunk-2gr7vwnp.js +0 -24
- package/web/chunk-2gr7vwnp.js.br +0 -0
- package/web/chunk-2gr7vwnp.js.gz +0 -0
- package/web/chunk-2p84jch3.js +0 -1
- package/web/chunk-2p84jch3.js.br +0 -0
- package/web/chunk-2p84jch3.js.gz +0 -0
- package/web/chunk-2qs283mh.js +0 -2
- package/web/chunk-2qs283mh.js.br +0 -0
- package/web/chunk-2qs283mh.js.gz +0 -0
- package/web/chunk-3gf2d852.js +0 -1
- package/web/chunk-3gf2d852.js.br +0 -0
- package/web/chunk-3gf2d852.js.gz +0 -0
- package/web/chunk-3hswqkb0.js +0 -1
- package/web/chunk-3hswqkb0.js.br +0 -0
- package/web/chunk-3hswqkb0.js.gz +0 -0
- package/web/chunk-46yjp1x4.js +0 -2
- package/web/chunk-46yjp1x4.js.br +0 -0
- package/web/chunk-46yjp1x4.js.gz +0 -0
- package/web/chunk-4ezd1rkc.js +0 -84
- package/web/chunk-4ezd1rkc.js.br +0 -0
- package/web/chunk-4ezd1rkc.js.gz +0 -0
- package/web/chunk-4v9ar0sf.js +0 -142
- package/web/chunk-4v9ar0sf.js.br +0 -0
- package/web/chunk-4v9ar0sf.js.gz +0 -0
- package/web/chunk-51z88j1t.js +0 -21
- package/web/chunk-51z88j1t.js.br +0 -0
- package/web/chunk-51z88j1t.js.gz +0 -0
- package/web/chunk-5f5zcfga.js +0 -1
- package/web/chunk-5f5zcfga.js.br +0 -2
- package/web/chunk-5f5zcfga.js.gz +0 -0
- package/web/chunk-5n61r0rr.js +0 -36
- package/web/chunk-5n61r0rr.js.br +0 -0
- package/web/chunk-5n61r0rr.js.gz +0 -0
- package/web/chunk-5vcdeenv.js +0 -2
- package/web/chunk-5vcdeenv.js.br +0 -0
- package/web/chunk-5vcdeenv.js.gz +0 -0
- package/web/chunk-5y7ks8c3.js +0 -30
- package/web/chunk-5y7ks8c3.js.br +0 -0
- package/web/chunk-5y7ks8c3.js.gz +0 -0
- package/web/chunk-60v8qwec.js +0 -2
- package/web/chunk-60v8qwec.js.br +0 -0
- package/web/chunk-60v8qwec.js.gz +0 -0
- package/web/chunk-61m5t9wg.js +0 -200
- package/web/chunk-61m5t9wg.js.br +0 -0
- package/web/chunk-61m5t9wg.js.gz +0 -0
- package/web/chunk-669n37qf.js +0 -70
- package/web/chunk-669n37qf.js.br +0 -0
- package/web/chunk-669n37qf.js.gz +0 -0
- package/web/chunk-6kf1xwz9.js +0 -2
- package/web/chunk-6kf1xwz9.js.br +0 -0
- package/web/chunk-6kf1xwz9.js.gz +0 -0
- package/web/chunk-6rw72jmj.js +0 -2
- package/web/chunk-6rw72jmj.js.br +0 -0
- package/web/chunk-6rw72jmj.js.gz +0 -0
- package/web/chunk-6wyxxd9h.js +0 -2
- package/web/chunk-6wyxxd9h.js.br +0 -0
- package/web/chunk-6wyxxd9h.js.gz +0 -0
- package/web/chunk-77vj65dc.js +0 -1
- package/web/chunk-77vj65dc.js.br +0 -0
- package/web/chunk-77vj65dc.js.gz +0 -0
- package/web/chunk-8ktz0w1x.js +0 -120
- package/web/chunk-8ktz0w1x.js.br +0 -0
- package/web/chunk-8ktz0w1x.js.gz +0 -0
- package/web/chunk-8rcfpj02.js +0 -2
- package/web/chunk-8rcfpj02.js.br +0 -0
- package/web/chunk-8rcfpj02.js.gz +0 -0
- package/web/chunk-8x4s1c9g.js +0 -1
- package/web/chunk-8x4s1c9g.js.br +0 -2
- package/web/chunk-8x4s1c9g.js.gz +0 -0
- package/web/chunk-8zf4cywy.js +0 -1
- package/web/chunk-8zf4cywy.js.br +0 -0
- package/web/chunk-8zf4cywy.js.gz +0 -0
- package/web/chunk-a18y5dmf.js +0 -2
- package/web/chunk-a18y5dmf.js.br +0 -0
- package/web/chunk-a18y5dmf.js.gz +0 -0
- package/web/chunk-a36sfjyk.js +0 -1
- package/web/chunk-a36sfjyk.js.br +0 -0
- package/web/chunk-a36sfjyk.js.gz +0 -0
- package/web/chunk-aahzqxq7.js +0 -34
- package/web/chunk-aahzqxq7.js.br +0 -0
- package/web/chunk-aahzqxq7.js.gz +0 -0
- package/web/chunk-b2gtwatf.js +0 -370
- package/web/chunk-b2gtwatf.js.br +0 -0
- package/web/chunk-b2gtwatf.js.gz +0 -0
- package/web/chunk-bdp4y1zg.js +0 -1
- package/web/chunk-bdp4y1zg.js.br +0 -0
- package/web/chunk-bdp4y1zg.js.gz +0 -0
- package/web/chunk-be67vfx1.js +0 -1
- package/web/chunk-be67vfx1.js.br +0 -0
- package/web/chunk-be67vfx1.js.gz +0 -0
- package/web/chunk-bt6r78y9.js +0 -106
- package/web/chunk-bt6r78y9.js.br +0 -0
- package/web/chunk-bt6r78y9.js.gz +0 -0
- package/web/chunk-bvyjy17t.js +0 -14
- package/web/chunk-bvyjy17t.js.br +0 -0
- package/web/chunk-bvyjy17t.js.gz +0 -0
- package/web/chunk-c97th1x0.js +0 -1
- package/web/chunk-c97th1x0.js.br +0 -0
- package/web/chunk-c97th1x0.js.gz +0 -0
- package/web/chunk-cfkp7taw.js +0 -1
- package/web/chunk-cfkp7taw.js.br +0 -0
- package/web/chunk-cfkp7taw.js.gz +0 -0
- package/web/chunk-cvf9k1fy.js +0 -140
- package/web/chunk-cvf9k1fy.js.br +0 -0
- package/web/chunk-cvf9k1fy.js.gz +0 -0
- package/web/chunk-d33n9fsr.js +0 -1
- package/web/chunk-d33n9fsr.js.br +0 -1
- package/web/chunk-d33n9fsr.js.gz +0 -0
- package/web/chunk-e667nxc9.js +0 -1
- package/web/chunk-e667nxc9.js.br +0 -0
- package/web/chunk-e667nxc9.js.gz +0 -0
- package/web/chunk-eejjsqm1.js +0 -303
- package/web/chunk-eejjsqm1.js.br +0 -0
- package/web/chunk-eejjsqm1.js.gz +0 -0
- package/web/chunk-eg3qjy7a.js +0 -2
- package/web/chunk-eg3qjy7a.js.br +0 -0
- package/web/chunk-eg3qjy7a.js.gz +0 -0
- package/web/chunk-embvjvdj.js +0 -12
- package/web/chunk-embvjvdj.js.br +0 -0
- package/web/chunk-embvjvdj.js.gz +0 -0
- package/web/chunk-etjfr79m.js +0 -2
- package/web/chunk-etjfr79m.js.br +0 -0
- package/web/chunk-etjfr79m.js.gz +0 -0
- package/web/chunk-ez36gbz3.js +0 -7
- package/web/chunk-ez36gbz3.js.br +0 -0
- package/web/chunk-ez36gbz3.js.gz +0 -0
- package/web/chunk-f0vcm8mk.js +0 -214
- package/web/chunk-f0vcm8mk.js.br +0 -0
- package/web/chunk-f0vcm8mk.js.gz +0 -0
- package/web/chunk-f3t3ey83.js +0 -1
- package/web/chunk-f3t3ey83.js.br +0 -0
- package/web/chunk-f3t3ey83.js.gz +0 -0
- package/web/chunk-f84sngcq.js +0 -2
- package/web/chunk-f84sngcq.js.br +0 -0
- package/web/chunk-f84sngcq.js.gz +0 -0
- package/web/chunk-f97hz4v5.js +0 -99
- package/web/chunk-f97hz4v5.js.br +0 -0
- package/web/chunk-f97hz4v5.js.gz +0 -0
- package/web/chunk-fnkp6s0g.js +0 -1
- package/web/chunk-fnkp6s0g.js.br +0 -0
- package/web/chunk-fnkp6s0g.js.gz +0 -0
- package/web/chunk-fpdyzyn8.js +0 -16
- package/web/chunk-fpdyzyn8.js.br +0 -0
- package/web/chunk-fpdyzyn8.js.gz +0 -0
- package/web/chunk-g43z223a.js +0 -2
- package/web/chunk-g43z223a.js.br +0 -0
- package/web/chunk-g43z223a.js.gz +0 -0
- package/web/chunk-gcm82aj8.js +0 -1
- package/web/chunk-gcm82aj8.js.br +0 -0
- package/web/chunk-gcm82aj8.js.gz +0 -0
- package/web/chunk-gffb3p4z.js +0 -2
- package/web/chunk-gffb3p4z.js.br +0 -0
- package/web/chunk-gffb3p4z.js.gz +0 -0
- package/web/chunk-gnzg3krt.js +0 -1
- package/web/chunk-gnzg3krt.js.br +0 -0
- package/web/chunk-gnzg3krt.js.gz +0 -0
- package/web/chunk-grqtpfdp.js +0 -2
- package/web/chunk-grqtpfdp.js.br +0 -0
- package/web/chunk-grqtpfdp.js.gz +0 -0
- package/web/chunk-gsm8spf8.js +0 -1
- package/web/chunk-gsm8spf8.js.br +0 -0
- package/web/chunk-gsm8spf8.js.gz +0 -0
- package/web/chunk-h6ygrnd0.js +0 -38
- package/web/chunk-h6ygrnd0.js.br +0 -0
- package/web/chunk-h6ygrnd0.js.gz +0 -0
- package/web/chunk-h8n9w5th.js +0 -169
- package/web/chunk-h8n9w5th.js.br +0 -0
- package/web/chunk-h8n9w5th.js.gz +0 -0
- package/web/chunk-hmdvm5pp.js +0 -2
- package/web/chunk-hmdvm5pp.js.br +0 -0
- package/web/chunk-hmdvm5pp.js.gz +0 -0
- package/web/chunk-hrntwvx8.js +0 -1
- package/web/chunk-hrntwvx8.js.br +0 -0
- package/web/chunk-hrntwvx8.js.gz +0 -0
- package/web/chunk-hrys15jh.js +0 -324
- package/web/chunk-hrys15jh.js.br +0 -0
- package/web/chunk-hrys15jh.js.gz +0 -0
- package/web/chunk-j0ng7zdq.js +0 -41
- package/web/chunk-j0ng7zdq.js.br +0 -0
- package/web/chunk-j0ng7zdq.js.gz +0 -0
- package/web/chunk-j2t5ycte.js +0 -78
- package/web/chunk-j2t5ycte.js.br +0 -0
- package/web/chunk-j2t5ycte.js.gz +0 -0
- package/web/chunk-jkjd1y3p.js +0 -3
- package/web/chunk-jkjd1y3p.js.br +0 -0
- package/web/chunk-jkjd1y3p.js.gz +0 -0
- package/web/chunk-jweahmyy.js +0 -1
- package/web/chunk-jweahmyy.js.br +0 -0
- package/web/chunk-jweahmyy.js.gz +0 -0
- package/web/chunk-k56v8k7n.js +0 -4
- package/web/chunk-k56v8k7n.js.br +0 -0
- package/web/chunk-k56v8k7n.js.gz +0 -0
- package/web/chunk-k59sk88z.js +0 -7
- package/web/chunk-k59sk88z.js.br +0 -0
- package/web/chunk-k59sk88z.js.gz +0 -0
- package/web/chunk-k75a0fpt.js +0 -62
- package/web/chunk-k75a0fpt.js.br +0 -0
- package/web/chunk-k75a0fpt.js.gz +0 -0
- package/web/chunk-kfx9q7xv.js +0 -2
- package/web/chunk-kfx9q7xv.js.br +0 -0
- package/web/chunk-kfx9q7xv.js.gz +0 -0
- package/web/chunk-ksp1gg3v.js +0 -1
- package/web/chunk-ksp1gg3v.js.br +0 -0
- package/web/chunk-ksp1gg3v.js.gz +0 -0
- package/web/chunk-kxxp1mn4.js +0 -2
- package/web/chunk-kxxp1mn4.js.br +0 -0
- package/web/chunk-kxxp1mn4.js.gz +0 -0
- package/web/chunk-mapbxzsz.js +0 -1
- package/web/chunk-mapbxzsz.js.br +0 -0
- package/web/chunk-mapbxzsz.js.gz +0 -0
- package/web/chunk-msw43fnq.js +0 -2
- package/web/chunk-msw43fnq.js.br +0 -0
- package/web/chunk-msw43fnq.js.gz +0 -0
- package/web/chunk-mzzjg4sn.js +0 -2
- package/web/chunk-mzzjg4sn.js.br +0 -0
- package/web/chunk-mzzjg4sn.js.gz +0 -0
- package/web/chunk-n1bmcj13.js +0 -2
- package/web/chunk-n1bmcj13.js.br +0 -0
- package/web/chunk-n1bmcj13.js.gz +0 -0
- package/web/chunk-n5y4ar3e.js +0 -1
- package/web/chunk-n5y4ar3e.js.br +0 -0
- package/web/chunk-n5y4ar3e.js.gz +0 -0
- package/web/chunk-n9vszqw9.js +0 -1
- package/web/chunk-n9vszqw9.js.br +0 -0
- package/web/chunk-n9vszqw9.js.gz +0 -0
- package/web/chunk-nzzcmxq8.js +0 -1
- package/web/chunk-nzzcmxq8.js.br +0 -0
- package/web/chunk-nzzcmxq8.js.gz +0 -0
- package/web/chunk-p25eppk1.js +0 -1
- package/web/chunk-p25eppk1.js.br +0 -0
- package/web/chunk-p25eppk1.js.gz +0 -0
- package/web/chunk-p9352vpw.js +0 -1
- package/web/chunk-p9352vpw.js.br +0 -0
- package/web/chunk-p9352vpw.js.gz +0 -0
- package/web/chunk-pdvm4n6f.js +0 -1
- package/web/chunk-pdvm4n6f.js.br +0 -2
- package/web/chunk-pdvm4n6f.js.gz +0 -0
- package/web/chunk-pjm2t9da.js +0 -1
- package/web/chunk-pjm2t9da.js.br +0 -0
- package/web/chunk-pjm2t9da.js.gz +0 -0
- package/web/chunk-pka3qm06.js +0 -98
- package/web/chunk-pka3qm06.js.br +0 -0
- package/web/chunk-pka3qm06.js.gz +0 -0
- package/web/chunk-pkbcbta6.js +0 -1
- package/web/chunk-pkbcbta6.js.br +0 -0
- package/web/chunk-pkbcbta6.js.gz +0 -0
- package/web/chunk-pq4vn3zh.js +0 -1
- package/web/chunk-pq4vn3zh.js.br +0 -0
- package/web/chunk-pq4vn3zh.js.gz +0 -0
- package/web/chunk-prk9ks5j.js +0 -1
- package/web/chunk-prk9ks5j.js.br +0 -0
- package/web/chunk-prk9ks5j.js.gz +0 -0
- package/web/chunk-px68tdjm.js +0 -1
- package/web/chunk-px68tdjm.js.br +0 -2
- package/web/chunk-px68tdjm.js.gz +0 -0
- package/web/chunk-px8k5edz.js +0 -24
- package/web/chunk-px8k5edz.js.br +0 -0
- package/web/chunk-px8k5edz.js.gz +0 -0
- package/web/chunk-pz4g2bem.js +0 -292
- package/web/chunk-pz4g2bem.js.br +0 -0
- package/web/chunk-pz4g2bem.js.gz +0 -0
- package/web/chunk-q0gx75nf.js +0 -55
- package/web/chunk-q0gx75nf.js.br +0 -0
- package/web/chunk-q0gx75nf.js.gz +0 -0
- package/web/chunk-q9rpxfmm.js +0 -1
- package/web/chunk-q9rpxfmm.js.br +0 -0
- package/web/chunk-q9rpxfmm.js.gz +0 -0
- package/web/chunk-qpfhs1x0.js +0 -1
- package/web/chunk-qpfhs1x0.js.br +0 -0
- package/web/chunk-qpfhs1x0.js.gz +0 -0
- package/web/chunk-qredmg6m.js +0 -1
- package/web/chunk-qredmg6m.js.br +0 -0
- package/web/chunk-qredmg6m.js.gz +0 -0
- package/web/chunk-qtc9ar2m.js +0 -2
- package/web/chunk-qtc9ar2m.js.br +0 -0
- package/web/chunk-qtc9ar2m.js.gz +0 -0
- package/web/chunk-r5dsw56r.js +0 -1
- package/web/chunk-r5dsw56r.js.br +0 -0
- package/web/chunk-r5dsw56r.js.gz +0 -0
- package/web/chunk-rkaps675.js +0 -1
- package/web/chunk-rkaps675.js.br +0 -0
- package/web/chunk-rkaps675.js.gz +0 -0
- package/web/chunk-rp87pgcp.js +0 -40
- package/web/chunk-rp87pgcp.js.br +0 -0
- package/web/chunk-rp87pgcp.js.gz +0 -0
- package/web/chunk-rs1mtd35.js +0 -2
- package/web/chunk-rs1mtd35.js.br +0 -0
- package/web/chunk-rs1mtd35.js.gz +0 -0
- package/web/chunk-s31n33g5.js +0 -2
- package/web/chunk-s31n33g5.js.br +0 -0
- package/web/chunk-s31n33g5.js.gz +0 -0
- package/web/chunk-sbcyvn42.js +0 -1
- package/web/chunk-sbcyvn42.js.br +0 -0
- package/web/chunk-sbcyvn42.js.gz +0 -0
- package/web/chunk-sew9vfwy.js +0 -1
- package/web/chunk-sew9vfwy.js.br +0 -0
- package/web/chunk-sew9vfwy.js.gz +0 -0
- package/web/chunk-sgaw26nc.js +0 -2
- package/web/chunk-sgaw26nc.js.br +0 -0
- package/web/chunk-sgaw26nc.js.gz +0 -0
- package/web/chunk-t2ak4a9d.js +0 -1
- package/web/chunk-t2ak4a9d.js.br +0 -0
- package/web/chunk-t2ak4a9d.js.gz +0 -0
- package/web/chunk-ta0e3dk6.js +0 -2
- package/web/chunk-ta0e3dk6.js.br +0 -0
- package/web/chunk-ta0e3dk6.js.gz +0 -0
- package/web/chunk-tqax5mb6.js +0 -217
- package/web/chunk-tqax5mb6.js.br +0 -0
- package/web/chunk-tqax5mb6.js.gz +0 -0
- package/web/chunk-v1wxeq38.js +0 -2
- package/web/chunk-v1wxeq38.js.br +0 -0
- package/web/chunk-v1wxeq38.js.gz +0 -0
- package/web/chunk-v3kwg4zn.js +0 -2
- package/web/chunk-v3kwg4zn.js.br +0 -0
- package/web/chunk-v3kwg4zn.js.gz +0 -0
- package/web/chunk-vcpvhkxh.js +0 -39
- package/web/chunk-vcpvhkxh.js.br +0 -0
- package/web/chunk-vcpvhkxh.js.gz +0 -0
- package/web/chunk-vg9qv3aa.js +0 -1
- package/web/chunk-vg9qv3aa.js.br +0 -0
- package/web/chunk-vg9qv3aa.js.gz +0 -0
- package/web/chunk-vwxnt3nh.js +0 -1
- package/web/chunk-vwxnt3nh.js.br +0 -0
- package/web/chunk-vwxnt3nh.js.gz +0 -0
- package/web/chunk-w1xjqhwy.js +0 -1
- package/web/chunk-w1xjqhwy.js.br +0 -2
- package/web/chunk-w1xjqhwy.js.gz +0 -0
- package/web/chunk-w3nfxvzd.js +0 -1
- package/web/chunk-w3nfxvzd.js.br +0 -0
- package/web/chunk-w3nfxvzd.js.gz +0 -0
- package/web/chunk-w7h3x3ys.js +0 -1
- package/web/chunk-w7h3x3ys.js.br +0 -0
- package/web/chunk-w7h3x3ys.js.gz +0 -0
- package/web/chunk-wb0yn3r4.js +0 -8
- package/web/chunk-wb0yn3r4.js.br +0 -0
- package/web/chunk-wb0yn3r4.js.gz +0 -0
- package/web/chunk-wff6hqjf.js +0 -1
- package/web/chunk-wff6hqjf.js.br +0 -0
- package/web/chunk-wff6hqjf.js.gz +0 -0
- package/web/chunk-whj4e4sb.js +0 -89
- package/web/chunk-whj4e4sb.js.br +0 -0
- package/web/chunk-whj4e4sb.js.gz +0 -0
- package/web/chunk-wn3kdpj0.js +0 -1
- package/web/chunk-wn3kdpj0.js.br +0 -0
- package/web/chunk-wn3kdpj0.js.gz +0 -0
- package/web/chunk-wzq3qxpb.js +0 -1
- package/web/chunk-wzq3qxpb.js.br +0 -0
- package/web/chunk-wzq3qxpb.js.gz +0 -0
- package/web/chunk-x2tezwv1.js +0 -4
- package/web/chunk-x2tezwv1.js.br +0 -0
- package/web/chunk-x2tezwv1.js.gz +0 -0
- package/web/chunk-xmajh4qe.js +0 -2
- package/web/chunk-xmajh4qe.js.br +0 -0
- package/web/chunk-xmajh4qe.js.gz +0 -0
- package/web/chunk-xz7py7yx.js +0 -1
- package/web/chunk-xz7py7yx.js.br +0 -0
- package/web/chunk-xz7py7yx.js.gz +0 -0
- package/web/chunk-y4af9gsm.js +0 -291
- package/web/chunk-y4af9gsm.js.br +0 -0
- package/web/chunk-y4af9gsm.js.gz +0 -0
- package/web/chunk-y512gr5a.js +0 -332
- package/web/chunk-y512gr5a.js.br +0 -0
- package/web/chunk-y512gr5a.js.gz +0 -0
- package/web/chunk-ywg44m2b.js +0 -2
- package/web/chunk-ywg44m2b.js.br +0 -0
- package/web/chunk-ywg44m2b.js.gz +0 -0
- package/web/chunk-zhzp4fm1.js +0 -2
- package/web/chunk-zhzp4fm1.js.br +0 -0
- package/web/chunk-zhzp4fm1.js.gz +0 -0
package/chunk-ctdtmwmd.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{de,t,d,Ht,un,so,pn,Ts,ao,Na,Ua,Fa,Mr,Rs,za,Is,Ai}from"./chunk-s9p624fq.js";import{tn,vr,Jn,ut,Pt,nt,w,ye,Er,an,Pr,wt,ne}from"./chunk-x7tras0x.js";import{zr,as}from"./chunk-d3xsmwbh.js";import{Ee,Do}from"./chunk-8my52htr.js";import{f,g,y,ba}from"./chunk-3x0wm92n.js";import{ae,Ye,m}from"./chunk-e67wqhzh.js";var He=new TextEncoder,Be=new TextDecoder,me=new TextDecoder("utf-8",{fatal:!0});function xr(...e){let r=e.reduce((i,{length:s})=>i+s,0),n=new Uint8Array(r),o=0;for(let i of e)n.set(i,o),o+=i.length;return n}var Io=/[^\x00-\x7f]/;function fe(e){if(typeof e=="string"&&e.length>=128){if(Io.test(e))throw TypeError("non-ASCII string encountered in encode()");return He.encode(e)}let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o>127)throw TypeError("non-ASCII string encountered in encode()");r[n]=o}return r}function Rr(e,r=!1){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e,{alphabet:r?"base64url":"base64"});if(r){if(e.includes("+")||e.includes("/"))throw TypeError("Invalid base64url");e=e.replace(/-/g,"+").replace(/_/g,"/")}let n=atob(e),o=new Uint8Array(n.length);for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);return o}class B extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,r){super(e,r),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class ie extends B{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,r,n="unspecified",o="unspecified"){super(e,{cause:{claim:n,reason:o,payload:r}}),this.claim=n,this.reason=o,this.payload=r}}class ze extends B{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,r,n="unspecified",o="unspecified"){super(e,{cause:{claim:n,reason:o,payload:r}}),this.claim=n,this.reason=o,this.payload=r}}class ft extends B{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class te extends B{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class H extends B{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class z extends B{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class Te extends B{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class ke extends B{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",r){super(e,r)}}class gt extends B{[Symbol.asyncIterator]=async function*(){};static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",r){super(e,r)}}class yt extends B{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",r){super(e,r)}}class Je extends B{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",r){super(e,r)}}var qo="The input to be decoded is not correctly encoded.";function le(e){try{return Rr(typeof e=="string"?e:Be.decode(e),!0)}catch(r){throw TypeError(qo,{cause:r})}}function V(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let r=Object.getPrototypeOf(e);return r===null||Object.getPrototypeOf(r)===null}function Ke(e){return V(e)&&Array.isArray(e.keys)&&Array.from(e.keys).every(V)}function Ar(...e){let r=new Set;for(let n of e)if(n)for(let o of Object.keys(n)){if(r.has(o))return!1;r.add(o)}return!0}function bt(e,r,n){try{return le(e)}catch(o){throw new n(`Failed to base64url decode the ${r}`,{cause:o})}}function Tr(e,r,n){try{return fe(e)}catch(o){throw new n(`The ${r} is not a valid base64url string`,{cause:o})}}function kr(e,r,n){let o;try{o=JSON.parse(me.decode(le(e)))}catch(i){throw new r(n,{cause:i})}if(!V(o))throw new r(n);return o}var _r={__proto__:null,b64:!0};function Cr(e,r){if(r!==void 0&&(!Array.isArray(r)||r.some((n)=>typeof n!="string")))throw TypeError(`"${e}" option must be an array of strings`);return r===void 0?void 0:new Set(r)}function Ir(e,r,n,o,i){if(i.crit!==void 0&&o?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!o||o.crit===void 0)return[];if(!Array.isArray(o.crit)||o.crit.length===0||o.crit.some((a)=>typeof a!="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let s=n===void 0?r:{__proto__:null,...n,...r};for(let a of o.crit){if(!(a in s))throw new te(`Extension Header Parameter "${a}" is not recognized`);if(!Object.hasOwn(i,a)||i[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(s[a]&&(!Object.hasOwn(o,a)||o[a]===void 0))throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return o.crit}function Lr(e,r){if(r.includes("b64")){let n=e.b64;if(typeof n!="boolean")throw new H('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return n}return!0}var Wo=(e)=>e[Symbol.toStringTag],No=(e,r,n)=>{let{alg:o}=e;if(r.use!==void 0){let i=n==="sign"||n==="verify"?"sig":"enc";if(r.use!==i)throw TypeError(`Invalid key for this operation, its "use" must be "${i}" when present`)}if(r.alg!==void 0&&r.alg!==o)throw TypeError(`Invalid key for this operation, its "alg" must be "${o}" when present`);if(Array.isArray(r.key_ops)){let i=n==="encrypt"||n==="decrypt"?e.ops?.[n==="encrypt"?0:1]:n;if(i&&!r.key_ops.includes(i))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${i}" when present`)}};async function Dr(e,r,n){let{alg:o,secret:i}=e,s=n==="decrypt"||n==="sign";if(i&&r instanceof Uint8Array)return r;let a,c;if(V(r)){if(a=Jo(r),typeof a.kty!="string")throw qr(o,r,i);if(!(i?a.kty==="oct"&&typeof a.k=="string":a.kty!=="oct"&&(s?a.kty==="AKP"&&typeof a.priv=="string"||typeof a.d=="string":a.d===void 0&&a.priv===void 0)))throw TypeError(i?'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present':`JSON Web Key for this operation must be a ${s?"private":"public"} JWK`);if(No(e,a,n),a.kty==="oct")return le(a.k);if(!Object.isFrozen(r)){let{key_ops:p}=r;Array.isArray(p)&&Object.freeze(p),Object.freeze(r)}}else{if(!$o(r))throw qr(o,r,i);let p=i?"secret":s?"private":"public";if(r.type!==p&&(i||["secret","public","private"].includes(r.type)))throw TypeError(`${Wo(r)} instances must be of type "${p}" for the ${o} algorithm`);if(Or(r))return r;if(c=r,c.type==="secret")return c.export()}vt||=new WeakMap;let u=r,l=vt.get(u);if(l?.[o])return l[o];if(l||vt.set(u,l={}),c&&typeof c.toCryptoKey=="function"){let p=c.type==="public",v=Uo[c.asymmetricKeyDetails?.namedCurve],h=e.resolve?.({crv:v,asymmetricKeyType:c.asymmetricKeyType})??e.subtle;return l[o]=c.toCryptoKey(h,p,e.usages[p?0:1])}return a??=c.export({format:"jwk"}),a.alg=o,l[o]=await xt(e,a)}var vt,Uo={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"};var Or=(e)=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},jo=(e)=>e?.[Symbol.toStringTag]==="KeyObject",$o=(e)=>Or(e)||jo(e);function Ho(e,r,...n){if(n.length>2){let o=n.pop();e+=`one of type ${n.join(", ")}, or ${o}.`}else n.length===2?e+=`one of type ${n[0]} or ${n[1]}.`:e+=`of type ${n[0]}.`;return r==null?e+=` Received ${r}`:typeof r=="function"&&r.name?e+=` Received function ${r.name}`:typeof r=="object"&&r!=null&&r.constructor?.name&&(e+=` Received an instance of ${r.constructor.name}`),e}function qr(e,r,n){let o=["CryptoKey","KeyObject","JSON Web Key"];return n&&o.push("Uint8Array"),TypeError(Ho(`Key for the ${e} algorithm must be `,r,...o))}var Ge=(e,r="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${r} must be ${e}`);function Bo(e,r){if(r&&!e.usages.includes(r))throw TypeError(`CryptoKey does not support this operation, its usages must include ${r}.`)}function Wr(e,r){let{modulusLength:n}=r.algorithm;if(typeof n!="number"||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}function zo(e,r,n){let o=e.algorithm;if(o.name!==r.name)throw Ge(r.name);if(r.hash&&o.hash?.name!==r.hash)throw Ge(r.hash,"algorithm.hash");if(r.namedCurve&&o.namedCurve!==r.namedCurve)throw Ge(r.namedCurve,"algorithm.namedCurve");if(r.length!==void 0&&o.length!==r.length)throw Ge(r.length,"algorithm.length");Bo(e,n)}function St(e){return{__proto__:null,...e}}function Jo(e){let r=St(e);if(r.ext!==void 0&&typeof r.ext!="boolean")throw TypeError('"ext" (Extractable) Parameter must be a boolean');if(r.key_ops!==void 0){let n=r.key_ops,o=Array.isArray(n)?[...n]:void 0;if(!o||o.some((i)=>typeof i!="string")||new Set(o).size!==o.length)throw TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');r.key_ops=o}return r}async function xt(e,r,n){if(!e.kty.includes(r.kty))throw new te('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');let o=e.resolve?.({kty:r.kty,crv:r.crv})??e.subtle,i=!!(r.d||r.priv),s={...r,ext:n??r.ext};return s.kty!=="AKP"&&delete s.alg,delete s.use,crypto.subtle.importKey("jwk",s,o,s.ext??!i,r.key_ops??e.usages[i?1:0])}async function Nr(e,r,n,o=!1){return e instanceof Uint8Array&&(e=await crypto.subtle.importKey("raw",e,r,o,[n])),zo(e,r,n),e}function Ur(e){let r={__proto__:null};for(let n in e)r[n]={...e[n],alg:n};return r}var Pe=[["verify"],["sign"]];function Rt(e){let r={name:"HMAC",hash:`SHA-${e}`};return{kty:["oct"],secret:!0,subtle:r,signing:r,usages:Pe}}function ge(e,r){let n={name:r?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:`SHA-${e}`};return{kty:["RSA"],subtle:n,signing:r?{...n,saltLength:r}:n,usages:Pe,minRsaBits:2048}}function At(e,r){return{kty:["EC"],crv:e,subtle:{name:"ECDSA",namedCurve:e},signing:{name:"ECDSA",hash:`SHA-${r}`},usages:Pe}}function jr(){let e={name:"Ed25519"};return{kty:["OKP"],crv:"Ed25519",subtle:e,signing:e,usages:Pe}}function Tt(e){let r={name:`ML-DSA-${e}`};return{kty:["AKP"],subtle:r,signing:r,usages:Pe}}var kt=Ur({HS256:Rt(256),HS384:Rt(384),HS512:Rt(512),RS256:ge(256),RS384:ge(384),RS512:ge(512),PS256:ge(256,32),PS384:ge(384,48),PS512:ge(512,64),ES256:At("P-256",256),ES384:At("P-384",384),ES512:At("P-521",512),EdDSA:jr(),Ed25519:jr(),"ML-DSA-44":Tt(44),"ML-DSA-65":Tt(65),"ML-DSA-87":Tt(87)});function $r(e){let r=typeof e=="string"?kt[e]:void 0;if(!r)throw new te(`alg ${e} is not supported either by JOSE or your javascript runtime`);return r}function Hr(e){return[e&&Cr("algorithms",e.algorithms),e?.crit]}function Ko(e){return e===void 0?{}:kr(e,H,"JWS Protected Header is invalid")}function Go(e){try{return fe(e)}catch(r){throw new H("JWS Compact Serialization payload must use only ASCII characters",{cause:r})}}async function Fo(e,r,n,o,i){let{protected:s,header:a,payload:c}=e,u=i??Ko(s);if(!Ar(u,a))throw new H("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let l={...u,...a},p=Lr(u,Ir(H,_r,r[1],u,l)),{alg:v}=l;if(typeof v!="string"||!v)throw new H('JWS "alg" (Algorithm) Header Parameter missing or invalid');if(r[0]&&!r[0].has(v))throw new ft('"alg" (Algorithm) Header Parameter value not allowed');if(p){if(typeof c!="string")throw new H("JWS Payload must be a string")}else if(typeof c!="string"&&!(c instanceof Uint8Array))throw new H("JWS Payload must be a string or an Uint8Array instance");let h=p||typeof c!="string"?c:o(c),b=!1;typeof n=="function"&&(n=await n(u,e),b=!0);let T=$r(v),_=xr(s!==void 0?fe(s):new Uint8Array,fe("."),typeof h=="string"?r[2]??=Tr(h,"payload",H):h),k=bt(e.signature,"signature",H),q=await Dr(T,n,"verify"),I=await Nr(q,T.subtle,"verify");T.minRsaBits&&Wr(T.alg,I);let N=!1;try{N=await crypto.subtle.verify(T.signing,I,k,_)}catch(J){throw new Je(void 0,{cause:J})}if(!N)throw new Je;let U={payload:typeof h=="string"?bt(h,"payload",H):h};return s!==void 0&&(U.protectedHeader=u),a!==void 0&&(U.unprotectedHeader=a),b?[{...U,key:q},p]:[U,p]}async function Br(e,r,n){if(e instanceof Uint8Array&&(e=Be.decode(e)),typeof e!="string")throw new H("Compact JWS must be a string or Uint8Array");let{0:o,1:i,2:s,length:a}=e.split(".");if(a!==3)throw new H("Invalid Compact JWS");return Fo({payload:i,protected:o,signature:s},r,n,Go)}var Vo=(e)=>Math.floor(e.getTime()/1000),Qo={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},Xo=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,we="check_failed";function Et(){throw TypeError("Invalid time period format")}function Jr(e){typeof e!="string"&&Et();let r=Xo.exec(e);(!r||r[4]&&r[1])&&Et();let n=parseFloat(r[2]),o=Math.round(n*Qo[r[3][0].toLowerCase()]);return Number.isFinite(o)||Et(),r[1]==="-"||r[4]==="ago"?-o:o}function _t(e,r){if(!Number.isFinite(r))throw TypeError(`Invalid ${e} input`);return r}var Kr=(e)=>{let r=e.toLowerCase();return e.includes("/")?r:`application/${r}`},Yo=(e,r)=>typeof e=="string"?r.includes(e):Array.isArray(e)?r.some((n)=>e.includes(n)):!1;function Ct(e,r,n=!1){let o=e[r];if(!(o===void 0&&!n)){if(typeof o!="number")throw new ie(`"${r}" claim must be a number`,e,r,"invalid");return o}}function Mt(e,r){throw new ie(`unexpected "${r}" claim value`,e,r,we)}function Gr(e,r,n={}){let o;try{o=JSON.parse(me.decode(r))}catch(I){throw new z("JWT Claims Set must be a top-level JSON object",{cause:I})}if(!V(o))throw new z("JWT Claims Set must be a top-level JSON object");let{typ:i}=n;if(i!==void 0&&(typeof e.typ!="string"||Kr(e.typ)!==Kr(i)))throw new ie('unexpected "typ" JWT header value',o,"typ",we);let{requiredClaims:s=[],issuer:a,subject:c,audience:u,maxTokenAge:l}=n,p=[...s];l!==void 0&&p.push("iat"),u!==void 0&&p.push("aud"),c!==void 0&&p.push("sub"),a!==void 0&&p.push("iss");for(let I of new Set(p.reverse()))if(!Object.hasOwn(o,I))throw new ie(`missing required "${I}" claim`,o,I,"missing");a!==void 0&&!(Array.isArray(a)?a:[a]).includes(o.iss)&&Mt(o,"iss"),c!==void 0&&o.sub!==c&&Mt(o,"sub"),u!==void 0&&!Yo(o.aud,typeof u=="string"?[u]:u)&&Mt(o,"aud");let{clockTolerance:v}=n,h=0;if(typeof v=="string")h=Jr(v);else if(v!==void 0){if(typeof v!="number")throw TypeError("Invalid clockTolerance option type");h=v}_t("clockTolerance option",h);let{currentDate:b}=n,T=_t("currentDate option",Vo(b===void 0?new Date:b)),_=Ct(o,"iat",l!==void 0),k=Ct(o,"nbf");if(k!==void 0&&k>T+h)throw new ie('"nbf" claim timestamp check failed',o,"nbf",we);let q=Ct(o,"exp");if(q!==void 0&&q<=T-h)throw new ze('"exp" claim timestamp check failed',o,"exp",we);if(l!==void 0){let I=T-_,N=_t("maxTokenAge option",typeof l=="number"?l:Jr(l));if(I-h>N)throw new ze('"iat" claim timestamp check failed (too far in the past)',o,"iat",we);if(I<-h)throw new ie('"iat" claim timestamp check failed (it should be in the past)',o,"iat",we)}return o}async function It(e,r,n){let[o,i]=await Br(e,Hr(n),r);if(!i)throw new z("JWTs MUST NOT use unencoded payload");let s=Gr(o.protectedHeader,o.payload,n);return{...o,payload:s}}function Zo(e,r,n,o){let{kty:i,key_ops:s,ext:a,kid:c,alg:u,use:l,crv:p}=e;return(a===void 0||typeof a=="boolean")&&(s===void 0||Array.isArray(s)&&s.every((v,h)=>typeof v=="string"&&s.indexOf(v)===h)&&s.includes("verify"))&&r.kty.includes(i)&&(o===void 0||typeof o=="string"&&o===c)&&(u===void 0?i!=="AKP":n===u)&&(l===void 0||l==="sig")&&(!r.crv||p===r.crv)}async function Fr(e,r,n){let o=e.get(r)||e.set(r,{}).get(r),{alg:i}=n;if(o[i]===void 0){let s=xt(n,r,!0).then((a)=>{if(a.type!=="public")throw new Te("JSON Web Key Set members must be public keys");return o[i]=a,a}).catch((a)=>{throw o[i]===s&&delete o[i],a});o[i]=s}return o[i]}function Lt(e){let r;try{r=structuredClone(e)}catch(i){throw new Te("JSON Web Key Set malformed",{cause:i})}if(!Ke(r))throw new Te("JSON Web Key Set malformed");let n=r.keys.map((i)=>{let s=St(i);return Array.isArray(s.key_ops)&&(s.key_ops=[...s.key_ops]),s}),o=new WeakMap;return Object.defineProperty(async(i,s)=>{let{alg:a,kid:c}={...i,...s?.header},u=typeof a=="string"?kt[a]:void 0;if(!u||u.secret)throw new te('Unsupported "alg" value for a JSON Web Key Set');let l=r.keys.filter((h,b)=>Zo(n[b],u,a,c)),{0:p,length:v}=l;if(!v)throw new ke;if(v!==1){let h=new gt;throw h[Symbol.asyncIterator]=async function*(){for(let b of l)try{yield await Fr(o,b,u)}catch{}},h}return Fr(o,p,u)},"jwks",{value:()=>structuredClone(r)})}function ei(){return typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel"}var qt;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(qt="jose/v6.2.13");var Qr=Symbol();async function ti(e,r,n,o=fetch){let i=await o(e,{method:"GET",signal:n,redirect:"manual",headers:r}).catch((s)=>{throw s.name==="TimeoutError"?new yt(void 0,{cause:s}):s});if(i.status!==200)throw new B("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch(s){throw new B("Failed to parse the JSON Web Key Set HTTP response as JSON",{cause:s})}}var Xr=Symbol();function _e(e,r){return Number.isFinite(e)&&Date.now()<e+r}function Vr(e,r,n){if(Number.isNaN(e))throw TypeError(`"${n}" option must not be NaN`);return typeof e=="number"?e:r}function Dt(e,r){if(!(e instanceof URL))throw TypeError("url must be an instance of URL");let n=new URL(e.href).href,o=r??{},i=o.timeoutDuration;if(typeof i=="number"&&(!Number.isInteger(i)||i<0))throw TypeError('"timeoutDuration" option must be a non-negative integer');let s=typeof i=="number"?i:5000,a=Vr(o.cooldownDuration,30000,"cooldownDuration"),c=Vr(o.cacheMaxAge,600000,"cacheMaxAge"),u=new Headers(o.headers);qt&&!u.has("User-Agent")&&u.set("User-Agent",qt),u.has("accept")||u.set("accept","application/json, application/jwk-set+json");let l=o[Qr],p=o[Xr],v,h,b=0,T=0,_;if(p&&typeof p=="object"){let{uat:q,jwks:I}=p;_e(q,c)&&Ke(I)&&(v=q,_=Lt(I))}let k=async()=>{if(h&&ei()&&(h=void 0),!h){let q=++b,I=h=ti(n,u,AbortSignal.timeout(s),l).then((N)=>{let U=Lt(N);if(q<=T)return;_=U;let J=Date.now();p&&(p.uat=J,p.jwks=N),v=J,T=q}).finally(()=>{h===I&&(h=void 0)})}await h};return Object.defineProperties(async(q,I)=>{(!_||!_e(v,c))&&await k();try{return await _(q,I)}catch(N){if(N instanceof ke&&!_e(v,a))return await k(),_(q,I);throw N}},{coolingDown:{get:()=>_e(v,a),enumerable:!0},fresh:{get:()=>_e(v,c),enumerable:!0},reload:{value:k,enumerable:!0},reloading:{get:()=>!!h,enumerable:!0},jwks:{value:()=>_?.jwks(),enumerable:!0}})}function Ot(e){if(typeof e!="string")throw new z("JWTs must use Compact JWS serialization, JWT must be a string");let{1:r,length:n}=e.split(".");if(n===5)throw new z("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new z("Invalid JWT");if(!r)throw new z("JWTs must contain a payload");let o;try{o=le(r)}catch(s){throw new z("Failed to base64url decode the payload",{cause:s})}let i;try{i=JSON.parse(me.decode(o))}catch(s){throw new z("Failed to parse the decoded payload as JSON",{cause:s})}if(!V(i))throw new z("Invalid JWT Claims Set");return i}var ri=["cf-connecting-ip","cf-ray","x-forwarded-for","x-forwarded-host","forwarded","x-real-ip"],ni="cf-access-jwt-assertion",oi=/^https:\/\/([a-z0-9-]+(?:\.fed)?\.cloudflareaccess\.com)\//i;function Ce(e){return e?oi.exec(e)?.[1]?.toLowerCase():void 0}function ii(e){return ri.some((r)=>e.headers.has(r))}async function Wt(e,r={}){let n=r.fetch??globalThis.fetch;try{let o=await n(`https://${e}/`,{redirect:"manual",signal:AbortSignal.timeout(1e4)});await o.body?.cancel();let i=Ce(o.headers.get("location"));if(!i&&o.status>=400&&r.reportFailure)throw Error(`\u516C\u5171\u5730\u5740\u8FD4\u56DE HTTP ${o.status}`);return i}catch(o){if(r.reportFailure)throw o;return}}function Nt(e,r={}){let n=`https://${e.teamDomain}`,o=Dt(r.jwksURL??new URL(`${n}/cdn-cgi/access/certs`));return{async denies(i){if(!ii(i))return!1;let s=i.headers.get(ni);if(!s)return!0;try{return await It(s,o,{issuer:n,audience:e.audience,algorithms:["RS256"],requiredClaims:["exp"]}),!1}catch{return!0}}}}import{timingSafeEqual as si}from"crypto";import{chmodSync as ai,existsSync as Yr,readFileSync as ci,writeFileSync as ui}from"fs";import{join as li}from"path";var di=600000,pi=2592000000,hi=5,mi=50,Zr=1024,fi=3600000,Ut="23456789ABCDEFGHJKMNPQRSTUVWXYZ";class Fe{dataDir;now;devices;revocations=new Set;code="";expires=0;failures=new Map;codeFailures=0;lastSavedAt=0;constructor(e,r=Date.now){this.dataDir=e;this.now=r;let n=this.path,o=Yr(n)?JSON.parse(ci(n,"utf8")):[],i=this.now(),s=Array.isArray(o)?o.map((a)=>wi(a,i)).filter((a)=>a!==void 0):[];this.devices=yi(s);while(this.tokenCount()>Zr)this.evictLeastRecentlyUsed();if(Yr(n))this.save();this.lastSavedAt=this.now(),this.rotate()}get path(){return li(this.dataDir,"devices.json")}pairingCode(){if(this.now()>=this.expires)this.rotate();return this.code}pairingExpires(){return this.expires}renewPairingCode(){return this.rotate(),this.code}pair(e,r,n="unknown"){if(this.now()>=this.expires)this.rotate();let o=this.failures.get(n);if(o&&o.blockedUntil>this.now())return;if(o)this.failures.delete(n);if(gi(e)!==this.code){let i=(o?.count??0)+1;if(this.failures.set(n,{count:i,blockedUntil:i>=hi?this.expires:0}),this.codeFailures++,this.codeFailures>=mi)this.rotate();return}return this.rotate(),this.failures.delete(n),this.issue(r)}issue(e){let r=this.now();this.pruneExpired(r);let n=new Set;while(this.tokenCount()>=Zr){let u=this.evictLeastRecentlyUsed();if(!u)break;n.add(u)}let o=Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("base64url"),i={hash:en(o),created:r,lastSeen:r,expires:r+pi},s=e.slice(0,100)||"device",a={id:crypto.randomUUID(),name:s,created:r,lastSeen:r,expires:i.expires,tokens:[i]};this.devices.push(a);let c=a.id;this.save();for(let u of n)for(let l of this.revocations)l(u);return{deviceID:c,token:o}}verify(e){if(!e)return;let r=this.now(),n=Buffer.from(en(e),"hex");for(let o of this.devices){let i=o.tokens.findIndex((a)=>{if(a.expires<=r)return!1;let c=Buffer.from(a.hash,"hex");return c.length===n.length&&si(c,n)}),s=o.tokens[i];if(!s)continue;if(s.lastSeen=r,o.lastSeen=r,i>0)o.tokens.splice(i,1),o.tokens.unshift(s);if(r-this.lastSavedAt>=fi)this.save();return{id:o.id,name:o.name,created:o.created,lastSeen:o.lastSeen,expires:o.expires,token:s}}return}list(){return this.devices.filter((e)=>e.expires>this.now()).map((e)=>({id:e.id,name:e.name,created:e.created,lastSeen:e.lastSeen,expires:e.expires}))}onRevoke(e){return this.revocations.add(e),()=>{this.revocations.delete(e)}}revoke(e){let r=this.devices.length;if(this.devices=this.devices.filter((n)=>n.id!==e),this.devices.length===r)return!1;this.save();for(let n of this.revocations)n(e);return!0}pruneExpired(e){for(let r of this.devices)if(r.tokens=r.tokens.filter((n)=>n.expires>e),r.tokens.length>0)r.expires=Math.max(...r.tokens.map((n)=>n.expires));this.devices=this.devices.filter((r)=>r.tokens.length>0)}tokenCount(){return this.devices.reduce((e,r)=>e+r.tokens.length,0)}evictLeastRecentlyUsed(){let e,r;for(let o of this.devices)for(let i of o.tokens){let s=r&&(i.lastSeen<r.lastSeen||i.lastSeen===r.lastSeen&&i.created<=r.created);if(!r||s)e=o,r=i}if(!e||!r)return;let n=e.id;if(e.tokens=e.tokens.filter((o)=>o!==r),e.tokens.length===0)this.devices=this.devices.filter((o)=>o!==e);else e.expires=Math.max(...e.tokens.map((o)=>o.expires));return n}rotate(){let e=256-256%Ut.length,r="";while(r.length<8)for(let n of crypto.getRandomValues(new Uint8Array(16))){if(n>=e||r.length>=8)continue;r+=Ut[n%Ut.length]}this.code=r,this.expires=this.now()+di,this.failures.clear(),this.codeFailures=0}save(){ui(this.path,JSON.stringify(this.devices,null,2),{mode:384}),ai(this.path,384),this.lastSavedAt=this.now()}}function gi(e){return e.toUpperCase().replace(/[^0-9A-Z]/g,"")}function en(e){return new Bun.CryptoHasher("sha256").update(e).digest("hex")}function yi(e){let r=[...e].sort((o,i)=>i.lastSeen-o.lastSeen||i.created-o.created),n=new Map;for(let o of r){let i=n.get(o.id);if(!i){n.set(o.id,{...o,tokens:o.tokens.map((s)=>({...s}))});continue}for(let s of o.tokens){let a=i.tokens.find((c)=>c.hash===s.hash);if(!a)i.tokens.push({...s});else a.created=Math.min(a.created,s.created),a.lastSeen=Math.max(a.lastSeen,s.lastSeen),a.expires=Math.max(a.expires,s.expires)}i.created=Math.min(i.created,o.created),i.lastSeen=Math.max(i.lastSeen,o.lastSeen),i.expires=Math.max(i.expires,o.expires)}for(let o of n.values())o.tokens.sort((i,s)=>s.lastSeen-i.lastSeen||s.created-i.created);return Array.from(n.values())}function wi(e,r){if(typeof e!=="object"||e===null)return;let n=e;if(typeof n.id!=="string"||typeof n.name!=="string"||typeof n.created!=="number"||!Number.isFinite(n.created)||typeof n.lastSeen!=="number"||!Number.isFinite(n.lastSeen)||typeof n.expires!=="number"||!Number.isFinite(n.expires))return;let o=[];if(Array.isArray(n.tokens))for(let i of n.tokens){let s=bi(i,r);if(s&&!o.some((a)=>a.hash===s.hash))o.push(s)}if(typeof n.tokenHash==="string"&&n.expires>r){let i=[n.tokenHash];if(Array.isArray(n.tokenHashes)){for(let s of n.tokenHashes)if(typeof s==="string"&&s.length>0&&!i.includes(s))i.push(s)}for(let s of i){if(s.length===0||o.some((a)=>a.hash===s))continue;o.push({hash:s,created:n.created,lastSeen:n.lastSeen,expires:n.expires})}}if(o.length===0)return;return{id:n.id,name:n.name,created:n.created,lastSeen:Math.max(n.lastSeen,...o.map((i)=>i.lastSeen)),expires:Math.max(...o.map((i)=>i.expires)),tokens:o}}function bi(e,r){if(typeof e!=="object"||e===null)return;let n=e;if(typeof n.hash!=="string"||n.hash.length===0||typeof n.created!=="number"||!Number.isFinite(n.created)||typeof n.lastSeen!=="number"||!Number.isFinite(n.lastSeen)||typeof n.expires!=="number"||!Number.isFinite(n.expires)||n.expires<=r)return;return{hash:n.hash,created:n.created,lastSeen:n.lastSeen,expires:n.expires}}import{chmodSync as rn,existsSync as vi,mkdirSync as Si,readFileSync as xi,renameSync as Ri,writeFileSync as Ti}from"fs";import{join as ki}from"path";var P=()=>ae(()=>import("./chunk-zm88mnds.js"));var Le=()=>ae(()=>import("./chunk-dzd8k6bw.js"));var sn=300000,cn=64000;class Yt{dataDir;models;proxy;path;builtin=new Map;config={providers:[]};constructor(e,r,n){this.dataDir=e;this.models=r;this.proxy=n;this.path=ki(e,"models.json");for(let o of r.getProviders())this.builtin.set(o.id,o)}async load(){if(!vi(this.path))return;let e=JSON.parse(xi(this.path,"utf8")),r=Array.isArray(e.providers)?e.providers:[];this.config={providers:[]};for(let n of r){if(!Mi(n))continue;try{nn(n.id,n),this.config.providers.push(n),this.models.setProvider(this.createProvider(n))}catch{}}}isUntrusted(e){return this.config.providers.some((r)=>r.id===e&&r.untrusted===!0)}list(){return this.config.providers.map(jt)}async save(e,r){nn(e,r);let n=this.config.providers.find((c)=>c.id===e),o=r.apiKey?.trim()||n?.apiKey,s=pn(r.models).length?r.models:Ts(await on(r.protocol,$t(r.baseUrl),o,this.proxy?.createFetch(Pr(e)))),a={id:e,name:r.name.trim(),protocol:r.protocol,baseUrl:$t(r.baseUrl),apiKey:o,untrusted:r.untrusted===!0,models:s,defaultContextWindow:r.defaultContextWindow,defaultMaxTokens:r.defaultMaxTokens};return this.models.setProvider(this.createProvider(a)),this.config.providers=[...this.config.providers.filter((c)=>c.id!==e),a],await this.persist(),jt(a)}async discover(e){let r=this.config.providers.find((a)=>a.id===e);if(!r)throw new t("no such model provider");let n=pn(r.models),o=new Set(n.map((a)=>a.id)),s=(await on(r.protocol,r.baseUrl,r.apiKey,this.proxy?.createFetch(Pr(e)))).filter((a)=>!o.has(a.id));return r.models=Ts([...n,...s]),this.models.setProvider(this.createProvider(r)),await this.persist(),jt(r)}async remove(e){if(!this.config.providers.some((o)=>o.id===e))return!1;let n=this.builtin.get(e);if(n)this.models.setProvider(n);else this.models.deleteProvider(e);return this.config.providers=this.config.providers.filter((o)=>o.id!==e),await this.persist(),!0}createProvider(e){let r=Ei(e.protocol),n=e.defaultContextWindow??sn,o=e.defaultMaxTokens??cn,i=pn(e.models).map((s)=>({id:s.id,name:s.name,api:e.protocol,provider:e.id,baseUrl:e.baseUrl,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},reasoning:Boolean(s.reasoning),contextWindow:s.contextWindow??n,maxTokens:s.maxTokens??o,...e.protocol==="openai-completions"||e.protocol==="openai-responses"?{compat:{supportsDeveloperRole:!1}}:{}}));return m({id:e.id,name:e.name,baseUrl:e.baseUrl,auth:{apiKey:{name:`${e.name} API key`,resolve:async()=>({auth:{apiKey:e.apiKey,baseUrl:e.baseUrl},source:e.apiKey?"Basalt settings":"configured endpoint"})}},models:i,api:r})}async persist(){Si(this.dataDir,{recursive:!0});let e=`${this.path}.tmp-${process.pid}`;Ti(e,`${JSON.stringify(this.config,null,2)}
|
|
3
|
-
`,{mode:384}),rn(e,384),Ri(e,this.path),rn(this.path,384)}}function Ei(e){if(e==="openai-completions")return P();if(e==="openai-responses")return Le();return{stream:zr,streamSimple:as}}function nn(e,r){if(!/^[a-z0-9][a-z0-9._-]{0,63}$/i.test(e))throw new t("provider id must be 1-64 letters, numbers, ., _, or -");if(typeof r.name!=="string"||!r.name.trim())throw new t("provider name is required");if(!ln(r.protocol))throw new t("unsupported model protocol");if(r.apiKey!==void 0&&typeof r.apiKey!=="string")throw new t("api key must be a string");if(r.untrusted!==void 0&&typeof r.untrusted!=="boolean")throw new t("untrusted must be a boolean");if(typeof r.models!=="string")throw new t("models must be a string");if(r.defaultContextWindow!==void 0&&(typeof r.defaultContextWindow!=="number"||!Number.isFinite(r.defaultContextWindow)||r.defaultContextWindow<=0))throw new t("default context window must be a positive number");if(r.defaultMaxTokens!==void 0&&(typeof r.defaultMaxTokens!=="number"||!Number.isFinite(r.defaultMaxTokens)||r.defaultMaxTokens<=0))throw new t("default max tokens must be a positive number");$t(r.baseUrl);let n=pn(r.models);if(n.length===0)return;let o=new Set;for(let i of n){if(!/^\S+$/.test(i.id)||o.has(i.id))throw new t("invalid model list");o.add(i.id)}}function jt(e){let{defaultContextWindow:r,defaultMaxTokens:n}=e;return{id:e.id,name:e.name,protocol:e.protocol,baseUrl:e.baseUrl,apiKeyConfigured:Boolean(e.apiKey?.trim()),untrusted:e.untrusted===!0,models:pn(e.models).map((o)=>({...o,contextWindow:o.contextWindow??r??sn,maxTokens:o.maxTokens??n??cn})),defaultContextWindow:r,defaultMaxTokens:n}}async function on(e,r,n,o=fetch){let i=new Headers({accept:"application/json"});if(n)if(e==="anthropic-messages")i.set("x-api-key",n),i.set("anthropic-version","2023-06-01");else i.set("authorization",`Bearer ${n}`);let s;try{s=await o(Pi(r),{headers:i,signal:AbortSignal.timeout(1e4)})}catch{throw new t("\u81EA\u52A8\u83B7\u53D6\u6A21\u578B\u5931\u8D25\uFF1A\u65E0\u6CD5\u8FDE\u63A5\u6A21\u578B\u670D\u52A1")}if(!s.ok)throw new t(`\u81EA\u52A8\u83B7\u53D6\u6A21\u578B\u5931\u8D25\uFF1A\u670D\u52A1\u8FD4\u56DE HTTP ${s.status}`);let a;try{a=await s.json()}catch{throw new t("\u81EA\u52A8\u83B7\u53D6\u6A21\u578B\u5931\u8D25\uFF1A\u670D\u52A1\u8FD4\u56DE\u7684\u4E0D\u662F JSON")}let c=_i(a);if(c.length===0)throw new t("\u81EA\u52A8\u83B7\u53D6\u6A21\u578B\u5931\u8D25\uFF1A\u670D\u52A1\u6CA1\u6709\u8FD4\u56DE\u6A21\u578B");return c}function Pi(e){let r=e.replace(/\/$/,"");return r.endsWith("/v1")?`${r}/models`:`${r}/v1/models`}function _i(e){if(!e||typeof e!=="object")return[];let r=e,n=Array.isArray(r.data)?r.data:Array.isArray(r.models)?r.models:[],o=new Set,i=[];for(let s of n){let a=typeof s==="string"?{id:s.trim(),name:s.trim()}:Ci(s);if(!a||!/^\S+$/.test(a.id)||o.has(a.id))continue;o.add(a.id),i.push(a)}return i}function re(e){if(typeof e==="number"&&Number.isFinite(e)&&e>0)return Math.round(e);if(typeof e==="string"&&e.trim())return so(e);return}function Ci(e){if(!e||typeof e!=="object")return;let r=e;if(typeof r.id!=="string"||!r.id.trim())return;let n=typeof r.display_name==="string"?r.display_name:typeof r.name==="string"?r.name:r.id,o=re(r.context_window)??re(r.context_length)??re(r.max_context_length)??re(r.context_window_tokens)??re(r.top_provider?.context_length),i=re(r.max_tokens)??re(r.max_output_tokens)??re(r.max_completion_tokens)??re(r.top_provider?.max_completion_tokens),s={id:r.id.trim(),name:n.trim()||r.id.trim()};if(o!==void 0)s.contextWindow=o;if(i!==void 0)s.maxTokens=i;return s}function $t(e){if(typeof e!=="string")throw new t("base URL is required");let r;try{r=new URL(e.trim())}catch{throw new t("base URL must be a valid http or https URL")}if(r.protocol!=="http:"&&r.protocol!=="https:")throw new t("base URL must use http or https");if(r.username||r.password||r.hash)throw new t("base URL cannot contain credentials or a fragment");return r.toString().replace(/\/$/,"")}function ln(e){return typeof e==="string"&&un.includes(e)}function Mi(e){if(!e||typeof e!=="object")return!1;let r=e;return typeof r.id==="string"&&typeof r.name==="string"&&ln(r.protocol)&&typeof r.baseUrl==="string"&&typeof r.models==="string"&&(r.apiKey===void 0||typeof r.apiKey==="string")&&(r.defaultContextWindow===void 0||typeof r.defaultContextWindow==="number")&&(r.defaultMaxTokens===void 0||typeof r.defaultMaxTokens==="number")}import{closeSync as Ii,existsSync as Li,fsyncSync as qi,mkdirSync as Di,openSync as Oi,readFileSync as Wi,renameSync as Ni,unlinkSync as Ui,writeFileSync as ji}from"fs";import{networkInterfaces as $i}from"os";import{join as Hi}from"path";function Xa(e,r){if(r.host!==void 0){if(!Ee(r.host)&&!r.insecureHttp)throw Error("\u975E\u672C\u673A\u76D1\u542C\u5FC5\u987B\u663E\u5F0F\u4F20\u5165 --insecure-http\u3002");if(!Ee(r.host)&&!r.auth&&!r.allowRemoteNoAuth)throw Error("\u975E\u672C\u673A\u76D1\u542C\u4E0D\u80FD\u5173\u95ED\u8BA4\u8BC1\uFF0C\u9664\u975E\u663E\u5F0F\u4F20\u5165 --allow-remote-no-auth\u3002");return r.host}if(e.lanEnabled&&!r.auth)throw Error("\u5DF2\u5F00\u542F\u5C40\u57DF\u7F51\u8BBF\u95EE\uFF0C\u4E0D\u80FD\u4F7F\u7528 --no-auth\uFF1B\u8BF7\u542F\u7528\u8BA4\u8BC1\u6216\u7528 --host 127.0.0.1 \u4EC5\u76D1\u542C\u672C\u673A\u3002");return"127.0.0.1"}function dn(e){if(!e||typeof e!=="object"||Array.isArray(e)||!("lanEnabled"in e)||typeof e.lanEnabled!=="boolean"||Object.keys(e).some((r)=>r!=="lanEnabled"))throw new t("\u7F51\u7EDC\u8BBE\u7F6E\u5FC5\u987B\u53EA\u5305\u542B\u5E03\u5C14\u503C lanEnabled");return{lanEnabled:e.lanEnabled}}function Bi(e){let r=e.split(".").map(Number);if(r.length!==4||r.some((n)=>!Number.isInteger(n)||n<0||n>255))return!1;return r[0]===10||r[0]===172&&(r[1]??0)>=16&&(r[1]??0)<=31||r[0]===192&&r[1]===168}function Me(e,r,n=$i()){let o=[],i=new Set;for(let[s,a]of Object.entries(n))for(let c of a??[]){if(c.internal||c.family!=="IPv4"||!Bi(c.address)||i.has(c.address))continue;if(e!=="0.0.0.0"&&e!==c.address)continue;i.add(c.address),o.push({interface:s,address:c.address,url:`http://${c.address}:${r}`})}return o}class oa{dataDir;current={lanEnabled:!1};path;constructor(e){this.dataDir=e;this.path=Hi(e,"network.json")}load(){if(!Li(this.path))return;try{this.current=dn(JSON.parse(Wi(this.path,"utf8")))}catch(e){throw Error("\u8BFB\u53D6\u7F51\u7EDC\u914D\u7F6E\u5931\u8D25\uFF0C\u8BF7\u4FEE\u590D\u6570\u636E\u76EE\u5F55\u4E2D\u7684 network.json \u540E\u91CD\u8BD5",{cause:e})}}settings(){return{...this.current}}save(e,r){let n=dn(e);r(n);let o=`${this.path}.tmp-${crypto.randomUUID()}`,i=!1;try{try{Di(this.dataDir,{recursive:!0});let s=Oi(o,"wx",384);i=!0;try{ji(s,`${JSON.stringify(n,null,2)}
|
|
4
|
-
`),qi(s)}finally{Ii(s)}Ni(o,this.path),i=!1}finally{if(i)Ui(o)}}catch(s){try{r(this.current)}catch(a){throw Error("\u4FDD\u5B58\u7F51\u7EDC\u914D\u7F6E\u5931\u8D25\uFF0C\u4E14\u76D1\u542C\u72B6\u6001\u56DE\u6EDA\u5931\u8D25\uFF1B\u8BF7\u68C0\u67E5\u6570\u636E\u76EE\u5F55\u540E\u91CD\u542F\u670D\u52A1\u4EE5\u6062\u590D\u4E00\u81F4\u72B6\u6001",{cause:AggregateError([s,a])})}throw Error("\u4FDD\u5B58\u7F51\u7EDC\u914D\u7F6E\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u6570\u636E\u76EE\u5F55\u7684\u53EF\u7528\u7A7A\u95F4\u548C\u5199\u5165\u6743\u9650\u540E\u91CD\u8BD5",{cause:s})}this.current=n}configuration(e){let r;if(!e.auth)r="\u670D\u52A1\u5668\u4EE5 --no-auth \u542F\u52A8\uFF0C\u8BF7\u542F\u7528\u8BBE\u5907\u8BA4\u8BC1\u540E\u518D\u914D\u7F6E\u5C40\u57DF\u7F51\u8BBF\u95EE\u3002";else if(e.hostOverride!==void 0)r="\u76D1\u542C\u5730\u5740\u7531\u663E\u5F0F --host \u53C2\u6570\u7BA1\u7406\uFF1B\u79FB\u9664\u8BE5\u53C2\u6570\u540E\u53EF\u5728\u8FD9\u91CC\u914D\u7F6E\u3002";let n=e.hostOverride!==void 0;return{settings:this.settings(),current:{port:e.port,remote:n?!Ee(e.host):e.lanActive},editable:r===void 0,disabledReason:r,addresses:n?Me(e.host,e.port):e.addresses}}}var hn=()=>({classify:async(e,r,n)=>(await import("./chunk-a78qhb4t.js")).classify(e,r,n)});var Ve={"openai-decisions":{"classifier:gpt-6-luna":{type:"classifier",id:"gpt-6-luna",name:"GPT-6 Luna",api:"openai-decisions",provider:"openai",baseUrl:"https://api.openai.com/v1",input:["text","image"],cost:{input:0.1,output:0,cacheRead:0,cacheWrite:0,tiers:[{inputTokensAbove:272000,input:0.2,output:0,cacheRead:0,cacheWrite:0}]},contextWindow:922000}},"openai-responses":{"chat:gpt-4":{id:"gpt-4",name:"GPT-4",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192,compat:{supportsStrictMode:!0},type:"chat"},"chat:gpt-4-turbo":{id:"gpt-4-turbo",name:"GPT-4 Turbo",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128000,maxTokens:4096,compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768,compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-4.1-mini":{id:"gpt-4.1-mini",name:"GPT-4.1 mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:0.4,output:1.6,cacheRead:0.1,cacheWrite:0},contextWindow:1047576,maxTokens:32768,compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-4.1-nano":{id:"gpt-4.1-nano",name:"GPT-4.1 nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0},contextWindow:1047576,maxTokens:32768,compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128000,maxTokens:16384,compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-4o-2024-05-13":{id:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128000,maxTokens:4096,compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-4o-2024-08-06":{id:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128000,maxTokens:16384,compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-4o-2024-11-20":{id:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128000,maxTokens:16384,compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-4o-mini":{id:"gpt-4o-mini",name:"GPT-4o mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0},contextWindow:128000,maxTokens:16384,compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5":{id:"gpt-5",name:"GPT-5",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5-chat-latest":{id:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",api:"openai-responses",baseUrl:"https://api.openai.com/v1",provider:"openai",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0},contextWindow:128000,maxTokens:16384,thinkingLevelMap:{off:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5 Mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:0.05,output:0.4,cacheRead:0.005,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5-pro":{id:"gpt-5-pro",name:"GPT-5 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.2-chat-latest":{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0},contextWindow:128000,maxTokens:16384,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:null,xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.2-pro":{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.3-chat-latest":{id:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0},contextWindow:128000,maxTokens:16384,thinkingLevelMap:{off:null,xhigh:"xhigh"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0},contextWindow:128000,maxTokens:32000,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0,tiers:[{inputTokensAbove:272000,input:5,output:22.5,cacheRead:0.5,cacheWrite:0}]},contextWindow:272000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.4-mini":{id:"gpt-5.4-mini",name:"GPT-5.4 mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.4-nano":{id:"gpt-5.4-nano",name:"GPT-5.4 nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0,tiers:[{inputTokensAbove:272000,input:60,output:270,cacheRead:0,cacheWrite:0}]},contextWindow:1050000,maxTokens:128000,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.5":{id:"gpt-5.5",name:"GPT-5.5",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0,tiers:[{inputTokensAbove:272000,input:10,output:45,cacheRead:1,cacheWrite:0}]},contextWindow:272000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.5-pro":{id:"gpt-5.5-pro",name:"GPT-5.5 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0,tiers:[{inputTokensAbove:272000,input:60,output:270,cacheRead:0,cacheWrite:0}]},contextWindow:1050000,maxTokens:128000,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:0.2,output:1.2,cacheRead:0.02,cacheWrite:0.25,tiers:[{inputTokensAbove:272000,input:0.4,output:1.8,cacheRead:0.04,cacheWrite:0.5}]},contextWindow:272000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0,supportsExplicitPromptCacheMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:4,output:20,cacheRead:0.4,cacheWrite:5,tiers:[{inputTokensAbove:272000,input:8,output:30,cacheRead:0.8,cacheWrite:10}]},contextWindow:272000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0,supportsExplicitPromptCacheMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:0.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272000,input:4,output:18,cacheRead:0.4,cacheWrite:5}]},contextWindow:272000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0,supportsExplicitPromptCacheMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-astra":{id:"gpt-6-astra",name:"GPT-6 Astra",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5,tiers:[{inputTokensAbove:272000,input:20,output:75,cacheRead:2,cacheWrite:25}]},contextWindow:272000,maxTokens:128000,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0,supportsExplicitPromptCacheMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-luna":{id:"gpt-6-luna",name:"GPT-6 Luna",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:0.1,output:0.5,cacheRead:0.01,cacheWrite:0.125,tiers:[{inputTokensAbove:272000,input:0.2,output:0.75,cacheRead:0.02,cacheWrite:0.25}]},contextWindow:272000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0,supportsExplicitPromptCacheMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-sol":{id:"gpt-6-sol",name:"GPT-6 Sol",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:0.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272000,input:4,output:15,cacheRead:0.4,cacheWrite:5}]},contextWindow:272000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0,supportsExplicitPromptCacheMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6.1-sol":{id:"gpt-6.1-sol",name:"GPT-6.1 Sol",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:0.1,cacheWrite:2.5,tiers:[{inputTokensAbove:272000,input:4,output:15,cacheRead:0.2,cacheWrite:5}]},contextWindow:272000,maxTokens:128000,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0,supportsAdditionalTools:!0,supportsToolSearch:!0,supportsMidConvoSystemMessages:!0,supportsExplicitPromptCacheMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-daybreak-blue-latest":{id:"gpt-daybreak-blue-latest",name:"Daybreak Blue",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:4,output:20,cacheRead:0.4,cacheWrite:5,tiers:[{inputTokensAbove:272000,input:8,output:30,cacheRead:0.8,cacheWrite:10}]},contextWindow:1050000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictMode:!0,supportsExplicitPromptCacheMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-daybreak-red-latest":{id:"gpt-daybreak-red-latest",name:"Daybreak Red",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:12.5,output:75,cacheRead:1.25,cacheWrite:15.625},contextWindow:400000,maxTokens:128000,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictMode:!0,supportsExplicitPromptCacheMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-realtime-2.1":{id:"gpt-realtime-2.1",name:"GPT-Realtime-2.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:4,output:24,cacheRead:0.4,cacheWrite:0},contextWindow:128000,maxTokens:32000,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:o1":{id:"o1",name:"o1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:200000,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:o1-pro":{id:"o1-pro",name:"o1-pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:150,output:600,cacheRead:0,cacheWrite:0},contextWindow:200000,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:o3":{id:"o3",name:"o3",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0},contextWindow:200000,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:o3-mini":{id:"o3-mini",name:"o3-mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0},contextWindow:200000,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0},type:"chat"},"chat:o3-pro":{id:"o3-pro",name:"o3-pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:200000,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:o4-mini":{id:"o4-mini",name:"o4-mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0},contextWindow:200000,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},compat:{supportsStrictMode:!0},inputLimits:{maxRequestBytes:536870912,images:{maxPerRequest:1500,resize:{maxWidth:2000,maxHeight:2000,maxBytes:4718592,jpegQuality:80}}},type:"chat"}}};var mn=f("openai",Ve),xu=g("openai",Ve),fn=y("openai",Ve);function Mo(){return m({id:"openai",name:"OpenAI",baseUrl:"https://api.openai.com/v1",auth:{apiKey:w("OpenAI API key",["OPENAI_API_KEY"]),oauth:ye({name:"OpenAI (ChatGPT subscription)",isSubscription:!0,loginLabel:"Sign in with ChatGPT",load:ba})},models:[...Object.values(mn),...Object.values(fn)],filterAllModels:(e,r)=>r?.type==="oauth"?e.filter((n)=>!Ye(n,"classifier")):e,api:Le(),classifiers:{"openai-decisions":hn()}})}var Ji=2000,Ki=1e4,gn="openai";function Oo(){let e=Mo(),r=e.auth.oauth;if(!r)throw Error("OpenAI SDK \u672A\u63D0\u4F9B ChatGPT \u8BA2\u9605\u767B\u5F55\uFF0C\u8BF7\u68C0\u67E5\u4F9D\u8D56\u5B89\u88C5");return m({id:Ht,name:"ChatGPT \u8BA2\u9605",baseUrl:e.baseUrl,auth:{oauth:r},models:e.getModels().filter((n)=>n.api==="openai-responses").map((n)=>({...n,provider:Ht})),api:e})}function Gi(e){if(typeof e!=="string")return;try{let r=Ot(e);for(let n of[r.name,r.preferred_username,r.email])if(typeof n==="string"&&n.trim())return n.trim()}catch{return}return}class Fn{models;store;providerID;pending;transitions=Promise.resolve();closed=!1;lastError;constructor(e,r,n=Ht){this.models=e;this.store=r;this.providerID=n}async status(){let e=this.pending,r=e?{providerID:gn,connected:!1,pending:!0,authorizeURL:e.state.authorizeURL,instructions:e.state.instructions,awaitingInput:e.state.awaitingInput,error:e.state.error}:{providerID:gn,connected:!1,pending:!1,error:this.lastError};try{let n=await this.store.read(this.providerID),o=n?.type==="oauth",i=o?Gi(n.idToken):void 0;return{...r,connected:o,...i?{displayName:i}:{}}}catch(n){throw Error("\u8BFB\u53D6\u767B\u5F55\u51ED\u636E\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u6570\u636E\u76EE\u5F55\u7684\u53EF\u7528\u7A7A\u95F4\u4E0E\u5199\u5165\u6743\u9650\u540E\u91CD\u8BD5",{cause:n})}}async start(e){let r=await this.transition(async()=>{if(this.closed)throw new t("\u767B\u5F55\u670D\u52A1\u6B63\u5728\u5173\u95ED");let o=this.models.getProvider(this.providerID);if(!o)throw new t("OpenAI provider is unavailable");let i=o.auth.oauth;if(!i)throw new t(`${o.name} does not support oauth login`);let s=this.pending;if(s)s.state.controller.abort(),await yn(s.done);let a=new AbortController,c=Promise.withResolvers(),u=Promise.withResolvers(),l={controller:a,signal:a.signal,awaitingInput:!1,closed:!1,authorizeReady:c.resolve},p={state:l,done:u.promise,ready:c.promise};this.pending=p,this.lastError=void 0;let v={signal:l.signal,prompt:(b)=>this.handlePrompt(l,b),notify:(b)=>this.handleEvent(l,b)};return(async()=>{let b=await i.login(v,{getDeviceId:()=>this.store.deviceId(),agentName:e});l.signal.throwIfAborted();try{await this.store.modify(this.providerID,async()=>b,{signal:l.signal})}catch(T){if(l.signal.aborted)throw T;throw Error("\u4FDD\u5B58\u767B\u5F55\u51ED\u636E\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u6570\u636E\u76EE\u5F55\u7684\u53EF\u7528\u7A7A\u95F4\u4E0E\u5199\u5165\u6743\u9650\u540E\u91CD\u8BD5",{cause:T})}})().catch((b)=>{if(!l.signal.aborted)l.error=b instanceof Error?b.message:String(b)}).finally(()=>{if(l.closed=!0,l.cancelPrompt?.(new DOMException("\u767B\u5F55\u6D41\u7A0B\u5DF2\u7ED3\u675F","AbortError")),l.authorizeURL=void 0,l.instructions=void 0,this.pending===p)this.lastError=l.error,this.pending=void 0;u.resolve()}),p});await Fi(r);let n=await this.status();if(!n.pending&&n.error)throw new t(n.error);return n}transition(e){let r=this.transitions.then(e);return this.transitions=r.then(()=>{return},()=>{return}),r}async manualInput(e){let r=this.pending;if(!r)throw new t("\u6CA1\u6709\u8FDB\u884C\u4E2D\u7684\u767B\u5F55\u6D41\u7A0B");if(!r.state.awaitingInput||!r.state.resolvePrompt)throw new t("\u5F53\u524D\u767B\u5F55\u6D41\u7A0B\u4E0D\u63A5\u53D7\u624B\u52A8\u8F93\u5165");r.state.resolvePrompt(e)}abort(){let e=this.pending;if(!e)return;e.state.controller.abort()}logout(){return this.transition(async()=>{let e=this.pending;if(e)e.state.controller.abort(),await yn(e.done);await this.models.logout(this.providerID)})}async close(){this.closed=!0,await this.transitions;let e=this.pending;if(!e)return;e.state.controller.abort(),await e.done}handlePrompt(e,r){if(e.signal.aborted||e.closed)return Promise.reject(e.signal.reason??new DOMException("\u767B\u5F55\u6D41\u7A0B\u5DF2\u7ED3\u675F","AbortError"));if(r.signal?.aborted)return Promise.reject(r.signal.reason);if(r.type!=="manual_code"){let n=`\u767B\u5F55\u6D41\u7A0B\u8BF7\u6C42\u4E86\u4E0D\u652F\u6301\u7684\u4EA4\u4E92\u7C7B\u578B\uFF1A${r.type}`;return e.error=n,e.controller.abort(),Promise.reject(Error(n))}return e.awaitingInput=!0,e.instructions=r.message,new Promise((n,o)=>{let i=()=>{if(e.signal.removeEventListener("abort",a),r.signal?.removeEventListener("abort",c),e.resolvePrompt=void 0,e.cancelPrompt=void 0,e.awaitingInput=!1,e.instructions===r.message)e.instructions=void 0},s=(u)=>{i(),o(u)},a=()=>s(e.signal.reason),c=()=>s(r.signal?.reason);if(e.resolvePrompt=(u)=>{i(),n(u)},e.cancelPrompt=s,e.signal.addEventListener("abort",a,{once:!0}),r.signal?.addEventListener("abort",c,{once:!0}),e.signal.aborted)a();else if(r.signal?.aborted)c()})}handleEvent(e,r){if(e.signal.aborted||e.closed)return;if(r.type==="auth_url"){e.authorizeURL=r.url,e.instructions=r.instructions??e.instructions,e.authorizeReady();return}if(r.type==="progress"){e.instructions=r.message;return}if(r.type==="info")e.instructions=r.message}}async function yn(e){let r;try{await Promise.race([e,new Promise((n,o)=>{r=setTimeout(()=>o(new t("\u4E0A\u6B21\u767B\u5F55\u5C1A\u672A\u9000\u51FA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")),Ji)})])}finally{clearTimeout(r)}}async function Fi(e){let r;try{await Promise.race([e.done,e.ready,new Promise((n)=>{r=setTimeout(n,Ki)})])}finally{clearTimeout(r)}}import{chmodSync as cs,existsSync as us,mkdirSync as ls,readFileSync as ds,writeFileSync as ps}from"fs";import{isIP as hs}from"net";import{join as Vt}from"path";import{chmodSync as Vi,existsSync as Ie,mkdirSync as Qi,readFileSync as Gt,rmSync as Xi,writeFileSync as bn}from"fs";import{join as Q}from"path";var Bt=/^[a-f0-9]{32}$/;class zt extends nt{async list(e,r=this.credentials?.token){let n=[];for(let o=1;o<=100;o++){let i=await this.request(`${e}${e.includes("?")?"&":"?"}per_page=100&page=${o}`,"GET",void 0,r);if(!Array.isArray(i))throw new t("Cloudflare \u5217\u8868\u54CD\u5E94\u65E0\u6548");if(n.push(...i),i.length<100)return n}throw new t("Cloudflare \u8D44\u6E90\u8FC7\u591A\uFF0C\u8BF7\u7F29\u5C0F\u4EE4\u724C\u7684\u8D26\u53F7\u548C\u57DF\u540D\u8303\u56F4")}async connect(e){if(typeof e!=="string"||!/^[A-Za-z0-9_-]{20,256}$/.test(e))throw new t("\u8BF7\u5B8C\u6574\u7C98\u8D34 Cloudflare API Token\uFF0C\u4E0D\u662F\u96A7\u9053\u4EE4\u724C\u6216 Global API Key");let r=await this.list("/zones",e);if(!r.length)throw new t("\u4EE4\u724C\u65E0\u6CD5\u8BBF\u95EE\u4EFB\u4F55\u57DF\u540D\uFF0C\u8BF7\u6388\u4E88\u6240\u9009\u57DF\u540D\u7684 Zone Read \u548C DNS Edit \u6743\u9650");let n=new Set(r.map((o)=>o.account.id));for(let o of n){if(!Bt.test(o))throw new t("Cloudflare \u8FD4\u56DE\u4E86\u65E0\u6548\u7684\u8D26\u53F7");await this.request(`/accounts/${o}/cfd_tunnel?per_page=1`,"GET",void 0,e),await this.request(`/accounts/${o}/access/apps?per_page=1`,"GET",void 0,e)}this.saveToken(e)}async zone(e){let n=(await this.list("/zones")).filter((o)=>e===o.name||e.endsWith(`.${o.name}`)).sort((o,i)=>i.name.length-o.name.length)[0];if(!n||!Bt.test(n.id)||!Bt.test(n.account.id))throw new t("\u8BE5\u57DF\u540D\u4E0D\u5728\u6388\u6743\u8303\u56F4\u5185\uFF0C\u8BF7\u68C0\u67E5\u57DF\u540D\u6216\u91CD\u65B0\u8FDE\u63A5 Cloudflare");return n}async application(e,r){let o=(await this.list(`/accounts/${e}/access/apps`)).filter((a)=>[a.domain,...(a.destinations??[]).map((u)=>u.uri)].filter((u)=>!!u).some((u)=>{let l=u.split("/")[0]??"";return l===r||l.startsWith("*.")&&r.endsWith(l.slice(1))}));if(o.length>1)throw new t("\u8BE5\u5730\u5740\u88AB\u591A\u4E2A Access \u5E94\u7528\u8986\u76D6\uFF0C\u65E0\u6CD5\u5B89\u5168\u5730\u7528\u5355\u4E2A\u5F00\u5173\u4FEE\u6539");let i=o[0];if(!i)return;let s=new Set([i.domain,...(i.destinations??[]).map((a)=>a.uri)].filter(Boolean));if(i.type!=="self_hosted"||s.size!==1||!s.has(r))throw new t("\u73B0\u6709 Access \u5E94\u7528\u5305\u542B\u5176\u4ED6\u57DF\u540D\u3001\u8DEF\u5F84\u6216\u901A\u914D\u89C4\u5219\uFF0C\u4E0D\u80FD\u5728\u6B64\u4FEE\u6539\u4EE5\u514D\u5F71\u54CD\u5176\u4ED6\u670D\u52A1");return i}async accessState(e){let r=await this.zone(e),n=await this.application(r.account.id,e);if(!n)return!1;return!(await this.list(`/accounts/${r.account.id}/access/apps/${n.id}/policies`)).some((i)=>i.decision==="bypass"&&!i.require?.length&&!i.exclude?.length&&Array.isArray(i.include)&&i.include.some((s)=>!!s&&typeof s==="object"&&("everyone"in s)))}async provision(e,r){let n=await this.zone(e);if((await this.list(`/zones/${n.id}/dns_records?name=${encodeURIComponent(e)}`)).length)throw new t("\u8BE5\u57DF\u540D\u5DF2\u6709 DNS \u8BB0\u5F55\uFF0C\u8BF7\u4F7F\u7528\u5C1A\u672A\u5360\u7528\u7684\u5B50\u57DF\u540D\uFF1B\u73B0\u6709 Basalt \u96A7\u9053\u53EF\u76F4\u63A5\u5F00\u5173");let i=n.account.id,s=await this.request(`/accounts/${i}/cfd_tunnel`,"POST",{name:`basalt-${crypto.randomUUID()}`,config_src:"cloudflare"});if(!s.id||!s.token)throw new t("Cloudflare \u672A\u8FD4\u56DE\u96A7\u9053\u51ED\u636E");try{await this.request(`/accounts/${i}/cfd_tunnel/${s.id}/configurations`,"PUT",{config:{ingress:[{hostname:e,service:`http://127.0.0.1:${r}`},{service:"http_status:404"}]}}),await this.request(`/zones/${n.id}/dns_records`,"POST",{type:"CNAME",proxied:!0,name:e,content:`${s.id}.cfargotunnel.com`})}catch(a){try{await this.request(`/accounts/${i}/cfd_tunnel/${s.id}`,"DELETE")}catch{throw new t("\u914D\u7F6E\u96A7\u9053\u5931\u8D25\uFF0C\u4E14\u65B0\u5EFA\u7A7A\u96A7\u9053\u6E05\u7406\u5931\u8D25\uFF1B\u8BF7\u91CD\u8BD5\u8FDE\u63A5\u6216\u68C0\u67E5 Cloudflare \u6388\u6743")}throw a}return{token:s.token,tunnelId:s.id}}async setAccess(e,r,n){let o=await this.zone(e),i=`/accounts/${o.account.id}/access`,s=await this.application(o.account.id,e);if(!r&&!s)return;if(r&&(!n||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)||n.length>254))throw new t("\u8BF7\u586B\u5199\u5141\u8BB8\u767B\u5F55\u7684\u90AE\u7BB1");if(!r&&s){let b=await this.list(`${i}/apps/${s.id}/policies`),T=b.find((_)=>_.name==="Basalt public access");await this.request(`${i}/apps/${s.id}/policies${T?`/${T.id}`:""}`,T?"PUT":"POST",{name:"Basalt public access",decision:"bypass",include:[{everyone:{}}],precedence:T?.precedence??Math.max(0,...b.map((_)=>_.precedence??0))+1});return}if(!r)return;let c=(await this.list(`${i}/identity_providers`)).find((b)=>b.type==="github");if(!c)throw new t("\u8D26\u53F7\u5C1A\u672A\u914D\u7F6E GitHub \u8EAB\u4EFD\u6E90\uFF0C\u9700\u8981\u5148\u63D0\u4F9B GitHub OAuth \u5E94\u7528\u6388\u6743\uFF1B\u4E0D\u4F1A\u4F7F\u7528\u90AE\u7BB1\u9A8C\u8BC1\u7801\u66FF\u4EE3");let u=s?await this.list(`${i}/apps/${s.id}/policies`):[];if(!(!s||s.name===`Basalt ${e}`))throw new t("\u6B64\u5E94\u7528\u7531\u5916\u90E8\u7BA1\u7406\uFF0C\u65E0\u6CD5\u4FDD\u8BC1 GitHub \u4E0E\u90AE\u7BB1\u53CC\u91CD\u9650\u5236\uFF0C\u5DF2\u4FDD\u7559\u539F\u914D\u7F6E\uFF1B\u8BF7\u4F7F\u7528\u65B0\u7684\u5B50\u57DF\u540D");if(u.some((b)=>b.decision==="bypass"&&b.name!=="Basalt public access"))throw new t("\u73B0\u6709\u5E94\u7528\u5305\u542B\u5916\u90E8\u7ED5\u8FC7\u7B56\u7565\uFF0C\u5DF2\u505C\u6B62\u5F00\u542F\uFF0C\u907F\u514D\u663E\u793A\u5F00\u542F\u5374\u4ECD\u516C\u5F00\u8BBF\u95EE");let p;try{p=await this.request(`${i}/organizations`)}catch(b){if(!(b instanceof Error)||!("upstreamStatus"in b)||b.upstreamStatus!==404)throw b;p=await this.request(`${i}/organizations`,"POST",{name:"Basalt"})}if(!s)s=await this.request(`${i}/apps`,"POST",{name:`Basalt ${e}`,domain:e,type:"self_hosted",session_duration:"24h",allowed_idps:[c.id],auto_redirect_to_identity:!0});await this.request(`${i}/apps/${s.id}`,"PUT",{name:s.name,domain:e,type:"self_hosted",session_duration:"24h",allowed_idps:[c.id],auto_redirect_to_identity:!0});let v=await this.list(`${i}/apps/${s.id}/policies`);if(v.some((b)=>!["Basalt public access","Basalt email access"].includes(b.name)))throw new t("\u5E94\u7528\u4E2D\u5B58\u5728\u5176\u4ED6\u7B56\u7565\uFF0C\u5DF2\u505C\u6B62\u4FEE\u6539\u4EE5\u4FDD\u7559\u539F\u6709\u8BBF\u95EE\u89C4\u5219");let h=v.find((b)=>b.name==="Basalt email access");await this.request(`${i}/apps/${s.id}/policies${h?`/${h.id}`:""}`,h?"PUT":"POST",{name:"Basalt email access",decision:"allow",include:[{email:{email:n}}],require:[{login_method:{id:c.id}}],precedence:h?.precedence??Math.max(0,...v.map((b)=>b.precedence??0))+1});for(let b of v.filter((T)=>T.name==="Basalt public access"))await this.request(`${i}/apps/${s.id}/policies/${b.id}`,"DELETE");if(!s.aud||!/^[a-z0-9-]+\.cloudflareaccess\.com$/.test(p.auth_domain))throw new t("\u4E91\u7AEF\u4FDD\u62A4\u5DF2\u914D\u7F6E\uFF0C\u4F46\u6821\u9A8C\u53C2\u6570\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u91CD\u8BD5\uFF1B\u5F53\u524D\u4FDD\u62A4\u4E0D\u4F1A\u81EA\u52A8\u653E\u5BBD");return{teamDomain:p.auth_domain,audience:s.aud}}}var Yi=/https:\/\/dash\.cloudflare\.com\/argotunnel\S+/,Zi=/Created tunnel \S+ with id ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/,Jt=/^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/,es=/^[a-z0-9-]+\.cloudflareaccess\.com$/,ts=/^[A-Za-z0-9]{16,128}$/,rs=/^[A-Za-z0-9+/=_-]{20,4096}$/;class Xt{options;cloudflare;managementError;managedAccess;path;home;loginChild;loginState={state:"idle"};stored;process;accessAppsURLCache;state="off";error;connections=new Set;tail=[];startedAt=0;lastError;restartTimer;backoff;stopping=!1;metricsTimer;metricsAnswered=!1;accessInspection;constructor(e,r){this.options=r;this.cloudflare=new zt(e),this.path=Q(e,"tunnel.json"),this.home=Q(e,"cloudflared"),this.backoff=r.backoffMs?.min??2000,this.stored=ns(this.path)}access(){return this.stored?.access}publicURL(){return this.stored?`https://${this.stored.hostname}`:void 0}running(){return this.process!==void 0}status(){let e=this.accessAppsURL();return{configured:this.stored!==void 0,cloudflareConnected:this.cloudflare.credentials!==void 0,enabled:this.stored!==void 0&&this.stored.enabled!==!1,...this.managedAccess===void 0?{}:{managedAccess:this.managedAccess},...this.managementError?{managementError:this.managementError}:{},...this.stored?.accessEmail?{accessEmail:this.stored.accessEmail}:{},...this.stored?{hostname:this.stored.hostname,access:this.stored.access}:{},...e?{accessAppsURL:e}:{},hasToken:this.stored?.token!==void 0,...this.stored?{mode:this.stored.token===void 0?"local":"token"}:{},login:this.hasCert()?{state:"done"}:this.loginState,binary:this.binary()!==void 0,install:vn(),state:this.stored?this.state:"off",...this.visibleError()?{error:this.visibleError()}:{},localPort:this.options.localPort(),...this.stored?{publicURL:this.publicURL()}:{}}}inspectStatus(){let e=this.status(),r=e.hostname;if(!r)return e;let n=this.accessInspection;if(!n||n.hostname!==r)n={hostname:r,checkedAt:0,pending:!1,state:"checking"},this.accessInspection=n;if(!n.pending&&Date.now()-n.checkedAt>=30000){n.pending=!0;let o=n;Wt(r,{reportFailure:!0}).then((i)=>{o.team=i,o.state=i?"login":"no-login",o.checkedAt=Date.now(),o.pending=!1},()=>{o.team=void 0,o.state="error",o.checkedAt=Date.now(),o.pending=!1})}return{...e,cloudAccessState:n.state,...n.team?{cloudAccessTeam:n.team}:{}}}binary(){return Ft(this.options.binary)}async save(e,r={}){let n=e.hostname?.trim().toLowerCase();if(!n||!Jt.test(n))throw new t("\u4E3B\u673A\u540D\u683C\u5F0F\u4E0D\u5BF9\uFF0C\u5E94\u5F62\u5982 basalt.example.com");let o=e.token?.trim(),i=o?za(o):this.stored?.token;if(o&&!i)throw new t("\u6CA1\u627E\u5230\u96A7\u9053\u4EE4\u724C\uFF08\u4EE5 eyJ \u5F00\u5934\uFF09\uFF0C\u8BF7\u4ECE Cloudflare \u9875\u9762\u5B8C\u6574\u590D\u5236");if(!i)throw new t("\u9700\u8981\u586B\u5199\u96A7\u9053\u4EE4\u724C");if(!rs.test(i))throw new t("\u96A7\u9053\u4EE4\u724C\u683C\u5F0F\u4E0D\u5BF9\uFF0C\u8BF7\u5B8C\u6574\u590D\u5236 Cloudflare \u91CC\u7684\u4EE4\u724C");let s=e.access===void 0?this.stored?.access:await this.resolveAccess(e.access??void 0,n);if(await this.stop(),this.stored={hostname:n,token:i,...s?{access:s}:{}},pe(this.path,this.stored),r.start??!0)this.start();return this.status()}async connectCloudflare(e){return await this.cloudflare.connect(e),this.refreshManagement()}async refreshManagement(){if(this.managedAccess=void 0,this.managementError=void 0,this.cloudflare.credentials&&this.stored)try{this.managedAccess=await this.cloudflare.accessState(this.stored.hostname)}catch(e){this.managementError=e instanceof Error?e.message:"\u65E0\u6CD5\u8BFB\u53D6\u4E91\u7AEF\u914D\u7F6E"}return this.inspectStatus()}async configureManaged(e){if(typeof e.enabled!=="boolean")throw new t("\u96A7\u9053\u5F00\u5173\u5FC5\u987B\u4E3A\u5E03\u5C14\u503C");if(!e.enabled){if(this.stored)this.stored.enabled=!1,pe(this.path,this.stored);return await this.stop(),this.state="off",this.status()}let r=e.hostname?.trim().toLowerCase()??this.stored?.hostname;if(!r||!Jt.test(r))throw new t("\u8BF7\u586B\u5199\u6709\u6548\u7684\u57DF\u540D\uFF0C\u5982 basalt.example.com");if(this.stored?.hostname===r)return this.stored.enabled=!0,pe(this.path,this.stored),this.start(),this.refreshManagement();if(this.stored&&(this.stored.access||await this.cloudflare.accessState(this.stored.hostname)))throw new t("\u8BF7\u5148\u5173\u95ED\u5F53\u524D\u57DF\u540D\u7684 Access \u4FDD\u62A4\uFF0C\u518D\u4FEE\u6539\u57DF\u540D");let n=await this.cloudflare.provision(r,this.options.localPort());return await this.stop(),this.stored={hostname:r,token:n.token,enabled:!0},pe(this.path,this.stored),this.start(),this.refreshManagement()}async configureManagedAccess(e){if(typeof e.enabled!=="boolean")throw new t("Access \u5F00\u5173\u5FC5\u987B\u4E3A\u5E03\u5C14\u503C");if(!this.stored)throw new t("\u8BF7\u5148\u914D\u7F6E\u96A7\u9053\u57DF\u540D");let r=e.email?.trim()||this.stored.accessEmail,n=await this.cloudflare.setAccess(this.stored.hostname,e.enabled,r);if(n)this.stored.access=n;else delete this.stored.access;if(r)this.stored.accessEmail=r;return pe(this.path,this.stored),this.accessInspection=void 0,this.refreshManagement()}async remove(){return this.cancelLogin(),await this.stop(),Xi(this.path,{force:!0}),this.stored=void 0,this.state="off",this.error=void 0,this.status()}hasCert(){return Ie(Q(this.home,".cloudflared","cert.pem"))}accessAppsURL(){if(this.accessAppsURLCache)return this.accessAppsURLCache;try{let e=Gt(Q(this.home,".cloudflared","cert.pem"),"utf8"),r=JSON.parse(Buffer.from(e.replace(/-----[A-Z ]+-----/g,"").replace(/\s+/g,""),"base64").toString("utf8"));if(r&&typeof r==="object"&&"accountID"in r&&typeof r.accountID==="string")this.accessAppsURLCache=`https://dash.cloudflare.com/${r.accountID}/one/access-controls/apps`}catch{}return this.accessAppsURLCache}localEnv(){return Qe(this.home)}writeConfig(e,r){let n=Q(this.home,"config.yml");return bn(n,[`tunnel: ${e}`,`credentials-file: ${Q(this.home,".cloudflared",`${e}.json`)}`,"ingress:",` - hostname: ${r}`,` service: http://127.0.0.1:${this.options.localPort()}`," - service: http_status:404",""].join(`
|
|
5
|
-
`),{mode:384}),n}startLogin(){if(this.hasCert()||this.loginChild)return this.status();let e=this.binary();if(!e)throw new t(be());Qi(Q(this.home,".cloudflared"),{recursive:!0,mode:448});let r=Bun.spawn([e,"tunnel","login"],{env:this.localEnv(),stdin:"ignore",stdout:"pipe",stderr:"pipe",windowsHide:!0});this.loginChild=r,this.loginState={state:"waiting"};let n=[],o=async(i)=>{let s=new TextDecoder;try{for await(let a of i){let c=s.decode(a,{stream:!0});for(let l of c.split(`
|
|
6
|
-
`))if(l.trim())n.push(l.trim());let u=Yi.exec(c)?.[0];if(u&&this.loginChild===r)this.loginState={state:"waiting",url:u}}}catch{}};return o(r.stdout),o(r.stderr),r.exited.then((i)=>{if(this.loginChild!==r)return;this.loginChild=void 0,this.loginState=i===0&&this.hasCert()?{state:"done"}:{state:"error",error:`\u6388\u6743\u6CA1\u6709\u5B8C\u6210\uFF1A${n.at(-1)??`cloudflared \u5DF2\u9000\u51FA\uFF08${i}\uFF09`}`}}),this.status()}cancelLogin(){let e=this.loginChild;return this.loginChild=void 0,this.loginState={state:"idle"},e?.kill(),this.status()}async provision(e){let r=e.hostname?.trim().toLowerCase();if(!r||!Jt.test(r))throw new t("\u4E3B\u673A\u540D\u683C\u5F0F\u4E0D\u5BF9\uFF0C\u5E94\u5F62\u5982 basalt.example.com");if(!this.hasCert())throw new t("\u8FD8\u6CA1\u6709\u8FDE\u63A5 Cloudflare\uFF0C\u8BF7\u5148\u5B8C\u6210\u6388\u6743");let n=await this.resolveAccess(e.access??void 0,r);await this.stop();let o=this.stored?.token===void 0&&this.stored?.hostname===r?this.stored.tunnelId:void 0;if(!o){let a=Q(this.home,"config.yml");if(Ie(a)){let c=Gt(a,"utf8"),u=/^ {2}- hostname: (\S+)$/m.exec(c)?.[1],l=/^tunnel: ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/m.exec(c)?.[1];if(u===r&&l&&Ie(Q(this.home,".cloudflared",`${l}.json`)))o=l}}let i=o!==void 0;if(!o){let a=await this.run(["tunnel","create",`basalt-${crypto.randomUUID().slice(0,8)}`]);if(o=Zi.exec(a.text)?.[1],a.code!==0||!o)throw new t(`\u521B\u5EFA\u96A7\u9053\u5931\u8D25\uFF1A${wn(a.text)}`)}let s=await this.run(["tunnel","route","dns",o,r]);if(s.code!==0){if(!i)await this.run(["tunnel","delete","-f",o]);throw new t(`\u7ED9 ${r} \u6DFB\u52A0\u57DF\u540D\u89E3\u6790\u5931\u8D25\uFF1A${wn(s.text)}\uFF08\u8BF7\u786E\u8BA4\u5B83\u5C5E\u4E8E\u4F60\u521A\u624D\u6388\u6743\u7684\u57DF\u540D\uFF0C\u4E14\u8FD8\u6CA1\u6709\u540C\u540D\u7684 DNS \u8BB0\u5F55\uFF09`)}return this.stored={hostname:r,tunnelId:o,...n?{access:n}:{}},pe(this.path,this.stored),this.start(),this.status()}async setAccess(e){if(!this.stored)throw new t("\u8FD8\u6CA1\u6709\u914D\u7F6E\u8FDC\u7A0B\u8BBF\u95EE");let r=await this.resolveAccess(e??void 0,this.stored.hostname);if(this.stored={...this.stored,access:r},!r)delete this.stored.access;return pe(this.path,this.stored),this.status()}async resolveAccess(e,r){if(!e)return;let n=e.teamDomain?.trim().toLowerCase(),o=e.audience?.trim();if(!ts.test(o??""))throw new t("Audience \u6807\u7B7E\u683C\u5F0F\u4E0D\u5BF9\uFF0C\u8BF7\u5B8C\u6574\u590D\u5236");if(!n){let i=await Wt(r);if(!i)throw new t(`\u6CA1\u68C0\u6D4B\u5230 ${r} \u4E0A\u7684 Access \u5E94\u7528\uFF0C\u8BF7\u5148\u5728 Cloudflare \u7ED9\u8BE5\u57DF\u540D\u5EFA\u597D\u5E94\u7528\uFF08\u6216\u624B\u52A8\u586B\u5199\u56E2\u961F\u57DF\u540D\uFF09`);return{teamDomain:i,audience:o}}if(!es.test(n))throw new t("\u56E2\u961F\u57DF\u540D\u5E94\u5F62\u5982 myteam.cloudflareaccess.com");return{teamDomain:n,audience:o}}async run(e){let r=this.binary();if(!r)throw new t(be());let n=Bun.spawn([r,...e],{env:this.localEnv(),stdin:"ignore",stdout:"pipe",stderr:"pipe",windowsHide:!0}),o=setTimeout(()=>n.kill(),60000);try{let[i,s,a]=await Promise.all([new Response(n.stdout).text(),new Response(n.stderr).text(),n.exited]);return{code:a,text:`${i}
|
|
7
|
-
${s}`}}finally{clearTimeout(o)}}visibleError(){if(this.error)return this.error;if(this.state!=="starting"||!this.lastError)return;return Date.now()-this.startedAt>=(this.options.errorAfterMs??8000)?this.lastError:void 0}start(){if(!this.stored||this.stored.enabled===!1||this.process)return;this.stopping=!1,clearTimeout(this.restartTimer);let e=this.binary();if(!e){this.state="missing-binary",this.error=be();return}this.state="starting",this.error=void 0,this.connections.clear(),this.tail=[],this.startedAt=Date.now(),this.lastError=void 0;let{token:r,tunnelId:n,hostname:o}=this.stored,i=ss();this.metricsAnswered=!1;let s=["tunnel","--no-autoupdate","--metrics",`127.0.0.1:${i}`],a=r===void 0?this.localEnv():{...process.env,TUNNEL_TOKEN:r};if(r===void 0&&n)s.push("--config",this.writeConfig(n,o)),s.push("run",n);else s.push("run");let c;try{c=Bun.spawn([e,...s],{env:a,stdin:"ignore",stdout:"pipe",stderr:"pipe",windowsHide:!0})}catch(u){let l=u instanceof Error&&"code"in u&&u.code==="ENOENT";this.state=l?"missing-binary":"error",this.error=l?be():`\u65E0\u6CD5\u542F\u52A8 cloudflared\uFF1A${u instanceof Error?u.message:u}`;return}this.process=c,this.metricsTimer=setInterval(()=>void this.pollReady(i,c),this.options.readyPollMs??1000),this.pump(c.stdout,r),this.pump(c.stderr,r),c.exited.then((u)=>this.exited(c,u))}async stop(){this.stopping=!0,clearTimeout(this.restartTimer),clearInterval(this.metricsTimer);let e=this.process;if(!e)return;if(e.kill(),await Promise.race([e.exited,Bun.sleep(5000)]),this.process===e)e.kill("SIGKILL"),this.process=void 0;this.state="off",this.connections.clear()}exited(e,r){if(this.process!==e)return;if(clearInterval(this.metricsTimer),this.process=void 0,this.connections.clear(),this.stopping)return;this.state="error",this.error=os(this.tail,r),this.restartTimer=setTimeout(()=>this.start(),this.backoff),this.backoff=Math.min(this.backoff*2,this.options.backoffMs?.max??30000)}async pollReady(e,r){try{let o=await(await fetch(`http://127.0.0.1:${e}/ready`,{signal:AbortSignal.timeout(800)})).json();if(this.process!==r||!o||typeof o!=="object"||!("readyConnections"in o))return;if(typeof o.readyConnections!=="number")return;if(this.metricsAnswered=!0,o.readyConnections>0)this.state="connected",this.error=void 0,this.lastError=void 0,this.backoff=this.options.backoffMs?.min??2000;else if(this.state==="connected")this.state="starting"}catch{}}async pump(e,r){let n=new TextDecoder,o="";try{for await(let i of e){o+=n.decode(i,{stream:!0});let s=o.split(`
|
|
8
|
-
`);o=s.pop()??"";for(let a of s)this.line(r?a.replaceAll(r,"***"):a)}}catch{}}line(e){let r=e.trim();if(!r)return;this.tail=[...this.tail,r].slice(-20);let n=is(r);if(n)this.lastError=n;let o=/connIndex=(\d+)/.exec(r)?.[1];if(this.metricsAnswered)return;if(o!==void 0&&r.includes("Registered tunnel connection"))this.connections.add(o),this.state="connected",this.error=void 0,this.lastError=void 0,this.backoff=this.options.backoffMs?.min??2000;else if(o!==void 0&&/Unregistered tunnel connection|Connection terminated/.test(r)){if(this.connections.delete(o),this.connections.size===0&&this.state==="connected")this.state="starting"}}}function ns(e){if(!Ie(e))return;try{let r=JSON.parse(Gt(e,"utf8"));if(!r||typeof r!=="object")return;let{hostname:n,token:o,tunnelId:i,access:s,enabled:a,accessEmail:c}=r;if(typeof n!=="string")return;let u={...s?.teamDomain&&s.audience?{access:s}:{},...typeof a==="boolean"?{enabled:a}:{},...typeof c==="string"?{accessEmail:c}:{}};if(typeof o==="string")return{hostname:n,token:o,...u};if(typeof i==="string")return{hostname:n,tunnelId:i,...u};return}catch{return}}function pe(e,r){bn(e,JSON.stringify(r),{mode:384}),Vi(e,384)}function os(e,r){let n=e.join(`
|
|
9
|
-
`);if(/Unauthorized|token is not valid/i.test(n))return"\u4EE4\u724C\u65E0\u6548\u6216\u5DF2\u88AB\u64A4\u9500\uFF0C\u8BF7\u5230 Cloudflare \u91CD\u65B0\u590D\u5236";let o=e.at(-1);return o?`cloudflared \u5DF2\u9000\u51FA\uFF08${r}\uFF09\uFF1A${o}`:`cloudflared \u5DF2\u9000\u51FA\uFF08${r}\uFF09`}var Kt="https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/";function Ft(e){if(e)return Ie(e)?e:void 0;let r=Bun.which("cloudflared");if(r)return r;if(process.platform!=="win32")return;let n=[process.env["ProgramFiles(x86)"],process.env.ProgramFiles].filter((o)=>o!==void 0).map((o)=>Q(o,"cloudflared"));return Bun.which("cloudflared",{PATH:n.join(";")})??void 0}function Qe(e){return{...process.env,HOME:e,USERPROFILE:e}}function vn(){if(process.platform==="darwin")return{command:"brew install cloudflared",url:Kt};if(process.platform==="win32")return{command:"winget install --id Cloudflare.cloudflared",url:Kt};return{url:Kt}}function be(){let{command:e,url:r}=vn();return e?`\u6CA1\u627E\u5230 cloudflared\uFF0C\u8BF7\u5148\u5B89\u88C5\uFF1A${e}`:`\u6CA1\u627E\u5230 cloudflared\uFF0C\u8BF7\u6309\u5B98\u65B9\u6587\u6863\u5B89\u88C5\uFF1A${r}`}function is(e){let n=/\bERR\b\s+(.*)$/.exec(e)?.[1]?.replace(/\s+event=\d+$/,"").trim();if(!n)return;if(/^(Please try|\d\.\s|Run your|See GitHub|For example|https?:)/.test(n))return;return n.length>200?`${n.slice(0,200)}\u2026`:n}function ss(){let e=Bun.serve({port:0,hostname:"127.0.0.1",fetch:()=>new Response}),r=e.port;if(e.stop(!0),r===void 0)throw Error("no free port");return r}function wn(e){return e.split(`
|
|
10
|
-
`).map((n)=>n.replace(/^\d{4}-\d\d-\d\dT\S+\s+(ERR|INF|WRN)\s+/,"").trim()).filter(Boolean).at(-1)??"\u6CA1\u6709\u8F93\u51FA"}var xn=/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/,ms=/https:\/\/[^\s"'<>]+/,fs=30000,gs=300000,ys=5000,ws=new Set(["authorization",Is,"cookie","host","origin","referer","connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade"]),bs=new Set(["set-cookie","connection","keep-alive","transfer-encoding"]);function se(e){if(!e)return!1;let r=e.trim();if(!xn.test(r))return!1;let n=r.split(".")[1];if(!n)return!1;try{let o=Buffer.from(n,"base64url").toString("utf8"),i=JSON.parse(o);if(!i||typeof i!=="object"||!("exp"in i)||typeof i.exp!=="number")return!1;return i.exp*1000>Date.now()+fs}catch{return!1}}function Qt(e,r=!1){let n;try{n=new URL(e.trim())}catch{throw new t("\u8FDC\u7A0B\u670D\u52A1\u5668\u5730\u5740\u683C\u5F0F\u65E0\u6548")}if(n.username||n.password)throw new t("\u8FDC\u7A0B\u670D\u52A1\u5668\u5730\u5740\u4E0D\u5141\u8BB8\u5305\u542B\u7528\u6237\u540D\u6216\u5BC6\u7801");if(n.protocol!=="https:"&&!(r&&n.protocol==="http:"))throw new t("\u8FDC\u7A0B Access \u4EE3\u7406\u4EC5\u652F\u6301 HTTPS \u670D\u52A1\u5668\u5730\u5740");if(!r&&_s(n.hostname))throw new t("\u4E0D\u5141\u8BB8\u4EE3\u7406\u672C\u673A\u56DE\u73AF\u6216\u79C1\u6709\u5185\u7F51\u5730\u5740");return n.origin}function vs(e,r=!1){let n;try{n=Buffer.from(e,"base64url").toString("utf8")}catch{throw new t("\u8FDC\u7A0B\u76EE\u6807\u7F16\u7801\u65E0\u6548")}return Qt(n,r)}class Xe{options;storePath;home;tokens=new Map;loginTasks=new Map;loginResults=new Map;lastCliLookup=new Map;constructor(e,r={}){this.options=r;this.storePath=Vt(e,"remote-access.json"),this.home=Vt(e,"cloudflared");for(let[n,o]of Object.entries(Es(this.storePath)))if(se(o))this.tokens.set(n,o)}async status(e){let r=Qt(e,this.options.allowInsecureTarget),n=this.options.fetch??globalThis.fetch,o,i=!1;try{let a=await n(`${r}/api/info`,{redirect:"manual",signal:AbortSignal.timeout(8000)});await a.body?.cancel(),o=Ce(a.headers.get("location")),i=o!==void 0}catch{}let s=await this.resolveToken(r);if(s&&i)try{let a=await n(`${r}/api/info`,{headers:{[Ai]:s},redirect:"manual",signal:AbortSignal.timeout(8000)});if(await a.body?.cancel(),Ce(a.headers.get("location")))this.deleteToken(r),s=void 0}catch{}return this.buildStatus(r,i,o,s!==void 0)}async startLogin(e){let r=Qt(e,this.options.allowInsecureTarget);if(await this.resolveToken(r))return this.loginResults.set(r,{state:"done"}),this.status(r);if(this.loginTasks.get(r))return this.buildStatus(r,!0,void 0,!1);let i=this.resolveCommand();if(!i)throw new t(be());ls(Vt(this.home,".cloudflared"),{recursive:!0,mode:448});let s=Bun.spawn([...i,"access","login","--no-verbose","--auto-close",r],{env:Qe(this.home),stdin:"ignore",stdout:"pipe",stderr:"pipe",windowsHide:!0}),a={child:s,state:{state:"waiting"}};this.loginTasks.set(r,a),this.loginResults.delete(r);let c,u=new Promise((b)=>{c=b}),l=setTimeout(()=>s.kill(),gs);l.unref?.();let p=(async()=>{let b=new TextDecoder,T="";try{for await(let _ of s.stderr)if(T+=b.decode(_,{stream:!0}),!a.state.url){let k=ms.exec(T);if(k?.[0])a.state={state:"waiting",url:k[0]},c?.()}}catch{}return T})(),v=new Response(s.stdout).text().catch(()=>"");Promise.all([v,p,s.exited]).then(([b,T,_])=>{if(clearTimeout(l),this.loginTasks.get(r)===a)this.loginTasks.delete(r);let k=Sn(b);if(_===0&&se(k)){this.saveToken(r,k),this.lastCliLookup.delete(r),this.loginResults.set(r,{state:"done"});return}let q=ks(T)??`\u6388\u6743\u8FDB\u7A0B\u5DF2\u9000\u51FA\uFF08${_}\uFF09`;this.loginResults.set(r,{state:"error",error:q})}),await Promise.race([u,s.exited,Bun.sleep(1500)]);let h=this.tokens.get(r);return this.buildStatus(r,!0,void 0,se(h))}async forward(e,r,n){let o=vs(e,this.options.allowInsecureTarget),i=Ss(o,r),s=n.method.toUpperCase(),a=xs(n.headers);if(!a.has(Ai)){let k=await this.resolveToken(o);if(k)a.set(Ai,k)}let c;if(s!=="GET"&&s!=="HEAD"){let k=await n.arrayBuffer();if(k.byteLength>0)c=k}let u=new AbortController,l=()=>u.abort();if(n.signal.aborted)u.abort();else n.signal.addEventListener("abort",l,{once:!0});let p=this.options.fetch??globalThis.fetch,v={method:s,headers:a,body:c,redirect:"manual",decompress:!1,signal:u.signal},h;try{h=await p(i.toString(),v)}catch(k){throw n.signal.removeEventListener("abort",l),k}if(h.status>=300&&h.status<400){n.signal.removeEventListener("abort",l),await h.body?.cancel();let k=Ce(h.headers.get("location"));if(k)return this.deleteToken(o),{kind:"access_required",teamDomain:k};throw new t(`\u8FDC\u7A0B\u670D\u52A1\u5668\u8FD4\u56DE\u4E86\u9884\u671F\u5916\u7684\u91CD\u5B9A\u5411\uFF08HTTP ${h.status}\uFF09`)}let b=As(h.headers);if(!h.body)return n.signal.removeEventListener("abort",l),{kind:"response",response:new Response(null,{status:h.status,statusText:h.statusText,headers:b})};let T=h.body.getReader(),_=new ReadableStream({async pull(k){try{let{done:q,value:I}=await T.read();if(q){n.signal.removeEventListener("abort",l),k.close();return}k.enqueue(I)}catch(q){throw n.signal.removeEventListener("abort",l),q}},cancel(k){return n.signal.removeEventListener("abort",l),u.abort(),T.cancel(k)}});return{kind:"response",response:new Response(_,{status:h.status,statusText:h.statusText,headers:b})}}async stop(){let e=[...this.loginTasks.values()];this.loginTasks.clear();for(let r of e)r.child.kill();await Promise.all(e.map((r)=>Promise.race([r.child.exited,Bun.sleep(1000)])))}buildStatus(e,r,n,o){let i=this.loginTasks.get(e),s=i?i.state:o?{state:"done"}:this.loginResults.get(e)??{state:"idle"};return{target:e,protected:r,...n?{teamDomain:n}:{},authenticated:o,binary:this.resolveCommand()!==void 0,login:s}}resolveCommand(){if(this.options.command&&this.options.command.length>0)return this.options.command;let e=Ft(this.options.binary);return e?[e]:void 0}async resolveToken(e){let r=this.tokens.get(e);if(se(r))return r;if(r)this.deleteToken(e);let n=this.resolveCommand();if(!n)return;let o=Date.now(),i=this.lastCliLookup.get(e)??0;if(o-i<ys)return;this.lastCliLookup.set(e,o);try{let s=Bun.spawn([...n,"access","token",`--app=${e}`],{env:Qe(this.home),stdin:"ignore",stdout:"pipe",stderr:"ignore",windowsHide:!0}),a=setTimeout(()=>s.kill(),5000);a.unref?.();try{let[c,u]=await Promise.all([new Response(s.stdout).text(),s.exited]),l=Sn(c);if(u===0&&se(l))return this.saveToken(e,l),l}finally{clearTimeout(a)}}catch{}return}saveToken(e,r){this.tokens.set(e,r),this.persist()}deleteToken(e){if(!this.tokens.delete(e))return;this.persist()}persist(){let e={};for(let[r,n]of this.tokens)if(se(n))e[r]=n;Ps(this.storePath,{tokens:e})}}function Ss(e,r){if(!r.startsWith("/api/")&&r!=="/api"&&!r.startsWith("/api?"))throw new t("\u8FDC\u7A0B\u4EE3\u7406\u4EC5\u5141\u8BB8\u8BBF\u95EE /api/* \u8DEF\u5F84");let n=new URL(r,e);if(n.origin!==e||n.pathname!=="/api"&&!n.pathname.startsWith("/api/"))throw new t("\u8FDC\u7A0B\u4EE3\u7406\u8DEF\u5F84\u8D8A\u754C");return n}function xs(e){let r=new Headers;e.forEach((o,i)=>{if(ws.has(i.toLowerCase()))return;r.set(i,o)});let n=e.get(Is);if(n)r.set("authorization",n);return r}function As(e){let r=new Headers;return e.forEach((n,o)=>{let i=o.toLowerCase();if(bs.has(i)||i.startsWith("access-control-"))return;r.set(o,n)}),r}function Sn(e){for(let r of e.split(/\r?\n/)){let n=r.trim();if(xn.test(n))return n}return}function ks(e){return e.split(/\r?\n/).map((n)=>n.trim()).filter((n)=>n.length>0&&!n.startsWith("https://")).at(-1)}function Es(e){if(!us(e))return{};try{let r=JSON.parse(ds(e,"utf8"));if(!r||typeof r!=="object"||!("tokens"in r))return{};let n=r.tokens;if(!n||typeof n!=="object")return{};let o={};for(let[i,s]of Object.entries(n))if(typeof s==="string")o[i]=s;return o}catch{return{}}}function Ps(e,r){ps(e,JSON.stringify(r),{mode:384}),cs(e,384)}function _s(e){let r=e.toLowerCase().replace(/^\[|\]$/g,"");if(Ee(e)||r==="0.0.0.0"||r.endsWith(".localhost")||r.endsWith(".local"))return!0;let o=(r.startsWith("::ffff:")?r.slice(7):void 0)??r,i=hs(o);if(i===4){let s=o.split(".").map((u)=>Number(u)),a=s[0]??0,c=s[1]??0;return a===0||a===10||a===127||a===100&&c>=64&&c<=127||a===169&&c===254||a===172&&c>=16&&c<=31||a===192&&c===168}if(i===6)return o==="::"||o==="::1"||/^f[cd][0-9a-f]{0,2}:/i.test(o)||/^fe[89ab][0-9a-f]:/i.test(o);return!1}var Cs=500;function qe(e,r,n,o,i){let s=!0,a=new Map,c,u={id:crypto.randomUUID(),...r,sessions:n,subscriptions:n,send(l){if(!s)return;if(u.expires!==void 0&&Date.now()>=u.expires){u.close(4401,"authentication expired");return}o(l)},close(l,p){s=!1,e.connections.delete(u.id),i(l,p)},enqueue(l,p="connection"){let v=(a.get(p)??Promise.resolve()).then(async()=>{if(!s)throw new d("connection closed");await l()}),h=v.catch(()=>{});return a.set(p,h),h.then(()=>{if(a.get(p)===h)a.delete(p)}),v},dispose(){if(c)return c;s=!1,e.connections.delete(u.id);let l=[];for(let p of n){let v=e.get(p);if(v)l.push(e.plugins.notify("session.close",v,u))}return n.clear(),c=Promise.all(l).then(()=>{}),c}};return e.connections.set(u.id,u),u}async function ve(e,r,n){if(!e.connections.has(r.id))throw new d("connection closed");if(typeof n.sessionID!=="string"||!n.sessionID)throw new t("sessionID is required");if(n.type==="subscribe"){let o=e.get(n.sessionID);if(!o)throw new d("no such session");let i=e.store.truncationEpoch(o.id),s=n.after??0;if(!Number.isSafeInteger(s)||s<0||n.truncationEpoch!==void 0&&(!Number.isSafeInteger(n.truncationEpoch)||n.truncationEpoch<0))throw new t("invalid subscription cursor");let a=!r.subscriptions.has(o.id);if(r.subscriptions.add(o.id),a)await e.plugins.notify("session.open",o,r);let c=n.tail&&Number.isSafeInteger(n.tail)&&n.tail>0?n.tail:0,l=c>0&&s>0&&e.store.lastSeq(o.id)-s>Cs||(n.truncationEpoch??0)!==i;if(l)r.send({type:"truncated",sessionID:o.id,after:0,truncationEpoch:i});let p=l?0:s,v=p===0&&c>0?o.replayEntries(Math.min(c,2000),!r.refImages):o.entries(p,void 0,!r.refImages),h=0,b=0;if(r.refImages)r.send({type:"replay_progress",sessionID:o.id,received:0,total:v.length});for(let[T,_]of v.entries()){if(!e.connections.has(r.id))return;if(e.store.truncationEpoch(o.id)!==i){r.close();return}if(r.send({type:"entry",sessionID:o.id,entry:_}),h+=Buffer.byteLength(JSON.stringify(_)),b++,T===0||h>=32768||b>=20||T===v.length-1){if(r.refImages)r.send({type:"replay_progress",sessionID:o.id,received:T+1,total:v.length});h=0,b=0,await new Promise((k)=>setImmediate(k)),await r.drained?.()}}if(r.send({type:"session",session:o.info(),truncationEpoch:i}),o.draft)r.send({type:"draft",sessionID:o.id,parts:o.draft});return}if(n.type==="unsubscribe"&&r.subscriptions.delete(n.sessionID)){let o=e.get(n.sessionID);if(o)await e.plugins.notify("session.close",o,r)}}import{constants as Ms,createGzip as Ls}from"zlib";var qs=32,Zt=2097152,Ds=262144,Os=20;class Ze{streams=new Map;async open(e){let r=e.runtime;if(e.index)await r.initialize();let n=Ws(e.subscribe),o=this.streams,i,s,a;return new ReadableStream({start(c){let u=Ns(c,e.gzip,()=>i.close(1013,"client is too slow")),l=!1;a=(h=!1)=>{if(!l)l=!0,clearInterval(s),e.signal.removeEventListener("abort",v),o.delete(i.id),u.close(h);return i.dispose()};let p=(h)=>a(h).catch((b)=>console.error("SSE cleanup failed",b)),v=()=>p(!0);i=qe(r,e.identity,new Set,(h)=>{let b=e.refImages&&h.type==="entry"?{...h,entry:r.store.refImages(h.entry)}:h;u.write(`data: ${JSON.stringify(b)}
|
|
11
|
-
|
|
12
|
-
`)},()=>p(!1)),i.refImages=e.refImages,i.drained=u.drained,o.set(i.id,i),s=setInterval(()=>u.write(`: ping
|
|
13
|
-
|
|
14
|
-
`),e.heartbeatMs??15000),e.signal.addEventListener("abort",v,{once:!0}),i.send({type:"welcome",server:e.server,connectionID:i.id,subscribed:n.map((h)=>h.sessionID),...e.index&&{index:{sessions:r.list(!0,{archive:"all"}),projects:r.projects(),plugins:r.plugins.list()}}});for(let h of n)i.enqueue(()=>ve(r,i,{...h,type:"subscribe"}),h.sessionID).catch((b)=>{if(b instanceof d&&r.get(h.sessionID)===void 0)i.send({type:"removed",kind:"session",id:h.sessionID});else i.send({type:"error",code:"bad_request",message:b instanceof Error?b.message:String(b)})});if(e.signal.aborted)v()},cancel(){return a(!0)}},{highWaterMark:Zt,size:(c)=>c?.byteLength??0})}async control(e,r,n,o){let i=this.streams.get(r);if(!i)return"not_found";if(i.deviceID!==n)return"forbidden";await i.enqueue(()=>ve(e,i,o),o.sessionID);return}}function Ws(e){if(!e)return[];let r;try{r=JSON.parse(e)}catch{return[]}if(!Array.isArray(r))return[];return r.filter((n)=>typeof n?.sessionID==="string"&&n.sessionID!=="").slice(0,qs)}function Ns(e,r,n){let o=new TextEncoder,i=!1,s=0,a=()=>(i=!0,queueMicrotask(n),!1),c=(b)=>!i&&((e.desiredSize??0)+s>=b||a()),u=r?Ls():void 0,l=!0,p=()=>Zt-(e.desiredSize??0)+(u?.writableLength??0),v=async()=>{while(!i&&l&&p()>Ds)await Bun.sleep(Os)};if(!u)return{drained:v,write:(b)=>{let T=o.encode(b);if(s=Math.max(s,T.byteLength),c(T.byteLength))e.enqueue(T)},close:(b)=>{if(l=!1,!b)e.close()}};let h=!1;return u.on("data",(b)=>{if(!l||!c(b.byteLength))return;try{e.enqueue(new Uint8Array(b))}catch{l=!1,u.destroy()}}),{drained:v,write(b){if(!l||u.writableEnded)return;if(s=Math.max(s,Buffer.byteLength(b)),!c(0))return;if(u.writableLength>Zt+s){a();return}if(u.write(b),h)return;h=!0,setImmediate(()=>{if(h=!1,l&&!u.writableEnded)u.flush(Ms.Z_SYNC_FLUSH)})},close(b){if(b){l=!1,u.destroy();return}u.once("end",()=>{l=!1,e.close()}),u.end()}}}var Us=["connection","upgrade","sec-websocket-key","sec-websocket-version","sec-websocket-extensions"];function Rn(e,r){let n=new URL(e),o=Number(n.port)+1e4,i=(c,u)=>{let l=new Headers(c.headers);if(u.startsWith("/api/"))return l;let p=l.get("host");if(p)l.set("x-forwarded-host",p);if(l.set("host",n.host),l.has("origin"))l.set("origin",n.origin);return l},s={hostname:"127.0.0.1",idleTimeout:0,async fetch(c,u){if(await r?.(c))return new Response(null,{status:403});let l=new URL(c.url),p;try{p=new URL(decodeURIComponent(l.pathname),n.origin).pathname}catch{return new Response("invalid path",{status:400})}let v=c.headers.get("upgrade")?.toLowerCase()==="websocket";if(p==="/_bun"||p.startsWith("/_bun/")||v&&!p.startsWith("/api/"))return new Response("not found",{status:404});let h=i(c,l.pathname),b=`${n.origin}${l.pathname}${l.search}`;if(c.headers.get("upgrade")?.toLowerCase()==="websocket"){for(let _ of Us)h.delete(_);let T={url:b.replace(/^http/,"ws"),headers:h,pending:[]};if(u.upgrade(c,{data:T}))return;return new Response("expected websocket",{status:400})}return fetch(b,{method:c.method,headers:h,body:c.body,redirect:"manual",decompress:!1})},websocket:{open(c){let u=new WebSocket(c.data.url,{headers:Object.fromEntries(c.data.headers)});u.binaryType="arraybuffer",c.data.upstream=u,u.onopen=()=>{for(let l of c.data.pending.splice(0))u.send(l)},u.onmessage=(l)=>{c.send(l.data)},u.onclose=(l)=>{c.close(l.code===1005||l.code===1006?1011:l.code,l.reason)}},message(c,u){let l=c.data.upstream;if(l?.readyState===WebSocket.OPEN)l.send(u);else c.data.pending.push(u)},close(c,u,l){if(u===1000||u>=3000&&u<=4999)c.data.upstream?.close(u,l);else c.data.upstream?.close()}}},a;try{a=Bun.serve({...s,port:o<=65535?o:0})}catch{a=Bun.serve({...s,port:0})}return{port:a.port,stop(){a.stop(!0)}}}var js=["x-forwarded-for","x-forwarded-host","forwarded","cf-connecting-ip","x-real-ip"];function er(e){let r=e.headers.get("host");if(!r)return!1;try{return Ee(new URL(`http://${r}`).hostname)}catch{return!1}}function K(e,r){return tr(e.requestIP(r))&&er(r)&&!js.some((n)=>r.headers.has(n))}function tr(e){if(!e)return!1;return e==="127.0.0.1"||e==="::1"||e==="::ffff:127.0.0.1"}function x(e,r,n={}){return async(o)=>{let i=o.req.raw;if(await e.accessDenied?.(i))return new Response(null,{status:403});if(!e.allowed(i.headers.get("origin"),i))return A(o,"unauthorized","origin not allowed",403);if(!n.public&&e.authEnabled&&!e.internalRequest?.(i)&&!e.auth.verify(j(i)))return A(o,"unauthorized","missing or invalid token",401);if(n.localOnly&&!K(e,i))return A(o,"unauthorized","\u4EC5\u5141\u8BB8\u672C\u673A\u76F4\u8FDE\u7BA1\u7406",403);try{return await r(o)}catch(s){if(s instanceof wt)return A(o,"archived",s.message,409);if(s instanceof ne)return A(o,"busy",s.message,409);if(s instanceof t)return A(o,"bad_request",s.message,400);if(s instanceof d)return A(o,"not_found",s.message,404);if(s instanceof SyntaxError)return A(o,"bad_request","invalid JSON",400);if(console.error(s),n.public)return A(o,"internal","internal server error",500);return A(o,"internal",s instanceof Error?s.message:String(s),500)}}}async function C(e){let r=await e.req.json();if(!r||typeof r!=="object"||Array.isArray(r))throw new t("expected a JSON object");return r}function L(e,r){let n=e.req.param(r);if(!n)throw new t(`${r} is required`);return n}function R(e,r,n=200){return Response.json(r,{status:n,headers:F(e)})}function A(e,r,n,o){return R(e,{error:{code:r,message:n}},o)}function et(e,r){let n=e.req.raw;if(!r.allowed(n.headers.get("origin"),n))return new Response(null,{status:403});let o=F(e);if(o.set("access-control-allow-methods","GET, POST, PUT, PATCH, DELETE, OPTIONS"),o.set("access-control-allow-headers",n.headers.get("access-control-request-headers")?.trim()||"authorization, content-type"),o.append("vary","access-control-request-headers"),o.set("access-control-max-age","600"),n.headers.get("access-control-request-private-network")==="true")o.set("access-control-allow-private-network","true");return new Response(null,{status:204,headers:o})}function j(e){return e.headers.get("authorization")?.replace(/^Bearer\s+/i,"")}function F(e){let r=new Headers,n=e.req.raw.headers.get("origin");if(n)r.set("access-control-allow-origin",n),r.set("vary","origin");return r}var $s=2147483647;function tt(e,r,n){let o=n.body;if(!o)return n;let i=o.getReader(),s=!1,a,c=()=>{},u=()=>{s=!0,clearTimeout(a),c()},l=new ReadableStream({start(p){let v=()=>{if(s)return;u(),p.close(),i.cancel("authentication ended").catch((b)=>console.error("\u5173\u95ED\u54CD\u5E94\u6D41\u5931\u8D25",b))},h=()=>{let b=r.token.expires-Date.now();if(b<=0){v();return}a=setTimeout(h,Math.min(b,$s))};c=e.onRevoke((b)=>{if(b===r.id)v()}),h()},async pull(p){try{let{done:v,value:h}=await i.read();if(s)return;if(v){u(),p.close();return}p.enqueue(h)}catch(v){throw u(),v}},cancel(p){return u(),i.cancel(p)}});return new Response(l,{status:n.status,statusText:n.statusText,headers:n.headers})}var De=class extends Error{res;status;constructor(e=500,r){super(r?.message,{cause:r?.cause});this.res=r?.res,this.status=e}getResponse(){if(this.res)return new Response(this.res.body,{status:this.status,headers:this.res.headers});return new Response(this.message,{status:this.status})}};var Se=Symbol();var An=(e,r)=>new Response(e,{headers:{"Content-Type":r.replace(/^[^;]+/,(n)=>n.toLowerCase())}}).formData();var Hs=1e4,rt=(e)=>("headers"in e),En=async(e,r=Object.create(null))=>{let{all:n=!1,dot:o=!1}=r,i=(rt(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();if(i==="multipart/form-data"||i==="application/x-www-form-urlencoded")return Bs(e,{all:n,dot:o});return{}};async function Bs(e,r){if(!rt(e)&&e.bodyCache.formData)return Tn(await e.bodyCache.formData,r);let n=rt(e)?e.headers:e.raw.headers,o=await e.arrayBuffer(),i=An(o,n.get("Content-Type")||"");if(!rt(e))e.bodyCache.formData=i;let s=await i;if(s)return Tn(s,r);return{}}function Tn(e,r){let n=Object.create(null),o={count:0};if(e.forEach((i,s)=>{if(!(r.all||s.endsWith("[]")))n[s]=i;else zs(n,s,i)}),r.dot)Object.entries(n).forEach(([i,s])=>{if(i.includes("."))Js(n,i,s,o),delete n[i]});return n}var zs=(e,r,n)=>{if(e[r]!==void 0)if(Array.isArray(e[r]))e[r].push(n);else e[r]=[e[r],n];else if(!r.endsWith("[]"))e[r]=n;else e[r]=[n]},Js=(e,r,n,o)=>{if(/(?:^|\.)__proto__\./.test(r))return;let i=e,s=r.split(".",34);if(s.length>33)kn();s.forEach((a,c)=>{if(c===s.length-1)i[a]=n;else{if(!i[a]||typeof i[a]!=="object"||Array.isArray(i[a])||i[a]instanceof File){if(o.count++>=Hs)kn();i[a]=Object.create(null)}i=i[a]}})},kn=()=>{throw Error("Nesting limit exceeded")};var or=(e)=>{let r=e.split("/");if(r[0]==="")r.shift();return r},Oe=(e)=>{let{groups:r,path:n}=Ks(e),o=or(n);return Gs(o,r)},Ks=(e)=>{let r=[];return e=e.replace(/\{[^}]+\}/g,(n,o)=>{let i=`@${o}`;return r.push([i,n]),i}),{groups:r,path:e}},Gs=(e,r)=>{for(let n=r.length-1;n>=0;n--){let[o]=r[n];for(let i=e.length-1;i>=0;i--)if(e[i].includes(o)){e[i]=e[i].replace(o,r[n][1]);break}}return e},ot={},We=(e,r)=>{if(e==="*")return"*";let n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){let o=`${e}#${r}`;if(!ot[o])if(n[2])ot[o]=r&&r[0]!==":"&&r[0]!=="*"?[o,n[1],new RegExp(`^${n[2]}(?=/${r})`)]:[e,n[1],new RegExp(`^${n[2]}$`)];else ot[o]=[e,n[1],!0];return ot[o]}return null},it=(e,r)=>{try{return r(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,(n)=>{try{return r(n)}catch{return n}})}};var rr=(e)=>decodeURI(e.includes("%25")?e.replace(/%25/g,"%2525"):e),ir=(e)=>{let r=e.url,n=r.indexOf("/",r.indexOf(":")+4),o=n;for(;o<r.length;o++){let i=r.charCodeAt(o);if(i===37){let s=r.indexOf("?",o),a=r.indexOf("#",o),c=s===-1?a===-1?void 0:a:a===-1?s:Math.min(s,a),u=r.slice(n,c),l=it(u,rr);if(/%(?![0-9A-Fa-f]{2})/.test(u)){let p=new URL("http://localhost");if(p.pathname=l.replace(/[\\\t\n\r]/g,encodeURIComponent),it(p.pathname,rr)!==l)return it(u.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"),rr)}return l}else if(i===63||i===35)break}return r.slice(n,o)};var Pn=(e)=>{let r=ir(e);return r.length>1&&r.at(-1)==="/"?r.slice(0,-1):r},he=(e,r,...n)=>{if(n.length)r=he(r,...n);return`${e?.[0]==="/"?"":"/"}${e}${r==="/"?"":`${e?.at(-1)==="/"?"":"/"}${r?.[0]==="/"?r.slice(1):r}`}`},st=(e)=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;let r=e.split("/"),n=[],o="";return r.forEach((i)=>{if(i!==""&&!/\:/.test(i))o+="/"+i;else if(/\:/.test(i))if(i.charCodeAt(i.length-1)===63){if(n.length===0&&o==="")n.push("/");else n.push(o);let s=i.slice(0,-1);o+="/"+s,n.push(o)}else o+="/"+i}),n.filter((i,s,a)=>a.indexOf(i)===s)},at=(e)=>e.indexOf("%")!==-1?it(e,Fs):e,nr=(e)=>{if(e.indexOf("+")!==-1)e=e.replace(/\+/g," ");return at(e)},_n=(e,r,n)=>{let o=e.indexOf("#",8);if(o!==-1)e=e.slice(0,o);let i;if(!n&&r&&!/[%+&=]/.test(r)){let c=e.indexOf("?",8),u=c;if(u===-1)return;if(!e.startsWith(r,u+1))u=e.indexOf(`&${r}`,u+1);while(u!==-1){let l=e.charCodeAt(u+r.length+1);if(l===61||l===38||isNaN(l)){if(u>c&&/(?:^|&)[^=&]*[%+]/.test(e.slice(c+1,u)))break;if(l===61){let p=u+r.length+2,v=e.indexOf("&",p);return nr(e.slice(p,v===-1?void 0:v))}return""}u=e.indexOf(`&${r}`,u+1)}if(i=/[%+]/.test(e),!i)return}let s=Object.create(null);i??=/[%+]/.test(e);let a=e.indexOf("?",8);while(a!==-1){let c=e.indexOf("&",a+1),u=e.indexOf("=",a);if(u>c&&c!==-1)u=-1;let l=e.slice(a+1,u===-1?c===-1?void 0:c:u);if(i)l=nr(l);if(a=c,l==="")continue;let p;if(u===-1)p="";else if(p=e.slice(u+1,c===-1?void 0:c),i)p=nr(p);if(n){if(!(s[l]&&Array.isArray(s[l])))s[l]=[];s[l].push(p)}else s[l]??=p}return r?s[r]:s},Cn=_n,Mn=(e,r)=>_n(e,r,!0),Fs=decodeURIComponent;var In=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(e,r="/",n=[[]]){this.raw=e,this.path=r,this.#e=n}param(e){return e?this.#r(e):this.#i()}#r(e){let r=this.#e[0][this.routeIndex]?.[1][e],n=this.#o(r);return n&&at(n)}#i(){let e={},r=Object.keys(this.#e[0][this.routeIndex]?.[1]??{});for(let n of r){let o=this.#o(this.#e[0][this.routeIndex][1][n]);if(o!==void 0)e[n]=at(o)}return e}#o(e){return this.#e[1]?this.#e[1][e]:e}query(e){return Cn(this.url,e)}queries(e){return Mn(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let r=Object.create(null);return this.raw.headers.forEach((n,o)=>{r[o]=n}),r}async parseBody(e){return En(this,e)}#n=(e)=>{let{bodyCache:r,raw:n}=this,o=r[e];if(o)return o;for(let i in r)return r[i].then((s)=>{if(i==="json")s=JSON.stringify(s);let a=i==="formData"?void 0:n.headers.get("content-type");return new Response(s,{headers:a?{"Content-Type":a}:void 0})[e]()});return r[e]=n[e]()};json(){return this.#n("text").then((e)=>JSON.parse(e))}text(){return this.#n("text")}arrayBuffer(){return this.#n("arrayBuffer")}bytes(){return this.#n("arrayBuffer").then((e)=>new Uint8Array(e))}blob(){return this.#n("blob")}formData(){return this.#n("formData")}addValidatedData(e,r){(this.#t??={})[e]=r}valid(e){return this.#t?.[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[Se](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,e]])=>e)}get routePath(){return this.#e[0].map(([[,e]])=>e)[this.routeIndex].path}};var Ln={Stringify:1,BeforeStream:2,Stream:3},Vs=(e,r)=>{let n=new String(e);return n.isEscaped=!0,n.callbacks=r,n};var sr=async(e,r,n,o,i)=>{if(typeof e==="object"&&!(e instanceof String)){if(!(e instanceof Promise))e=e.toString();if(e instanceof Promise)e=await e}let s=e.callbacks;if(!s?.length)return Promise.resolve(e);if(i)i[0]+=e;else i=[e];let a=Promise.all(s.map((c)=>c({phase:r,buffer:i,context:o}))).then((c)=>Promise.all(c.filter(Boolean).map((u)=>sr(u,r,!1,o,i))).then(()=>i[0]));if(n)return Vs(await a,s);else return a};var Qs="text/plain; charset=UTF-8",ar=(e,r)=>({"Content-Type":e,...r}),Ne=(e,r)=>new Response(e,r),cr=class{#t;#e;env={};#r;finalized=!1;error;#i;#o;#n;#l;#c;#u;#a;#d;#p;constructor(e,r){if(this.#t=e,r)this.#o=r.executionCtx,this.env=r.env,this.#u=r.notFoundHandler,this.#p=r.path,this.#d=r.matchResult}get req(){return this.#e??=new In(this.#t,this.#p,this.#d),this.#e}get event(){if(this.#o&&"respondWith"in this.#o)return this.#o;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#o)return this.#o;else throw Error("This context has no ExecutionContext")}get res(){return this.#n||=Ne(null,{headers:this.#a??=new Headers})}set res(e){if(this.#n&&e){e=Ne(e.body,e);for(let[r,n]of this.#n.headers.entries()){if(r==="content-type")continue;if(r==="set-cookie"){let o=this.#n.headers.getSetCookie();e.headers.delete("set-cookie");for(let i of o)e.headers.append("set-cookie",i)}else e.headers.set(r,n)}}this.#n=e,this.finalized=!0}render=(...e)=>(this.#c??=(r)=>this.html(r),this.#c(...e));setLayout=(e)=>this.#l=e;getLayout=()=>this.#l;setRenderer=(e)=>{this.#c=e};header=(e,r,n)=>{if(this.finalized&&!this.#n.bodyUsed)this.#n=Ne(this.#n.body,this.#n);let o=this.#n?this.#n.headers:this.#a??=new Headers;if(r===void 0)o.delete(e);else if(n?.append)o.append(e,r);else o.set(e,r)};status=(e)=>{this.#i=e};set=(e,r)=>{this.#r??=new Map,this.#r.set(e,r)};get=(e)=>this.#r?this.#r.get(e):void 0;get var(){if(!this.#r)return{};return Object.fromEntries(this.#r)}#s(e,r,n){let o=this.#n?new Headers(this.#n.headers):this.#a;if(typeof r==="object"&&r.headers){o??=new Headers;for(let[s,a]of new Headers(r.headers))if(s==="set-cookie")o.append(s,a);else o.set(s,a)}if(n){if(!o){let s=0;for(let a in n)if(++s>1||typeof n[a]!=="string"){o=new Headers;break}}if(o)for(let s in n){let a=n[s];if(typeof a==="string")o.set(s,a);else{o.delete(s);for(let c of a)o.append(s,c)}}}let i=typeof r==="number"?r:r?.status??this.#i;return Ne(e,{status:i,headers:o??n})}newResponse=(...e)=>this.#s(...e);body=(e,r,n)=>this.#s(e,r,n);text=(e,r,n)=>!this.#a&&!this.#i&&!r&&!n&&!this.finalized?new Response(e):this.#s(e,r,ar(Qs,n));json=(e,r,n)=>this.#s(JSON.stringify(e),r,ar("application/json",n));html=(e,r,n)=>{let o=(i)=>this.#s(i,r,ar("text/html; charset=UTF-8",n));return typeof e==="object"?sr(e,Ln.Stringify,!1,{}).then(o):o(e)};redirect=(e,r)=>{let n=String(e);return this.header("Location",!/[^\x00-\xFF]/.test(n)?n:encodeURI(n)),this.newResponse(null,r??302)};notFound=()=>(this.#u??=()=>Ne(),this.#u(this))};var ur=(e,r,n)=>(o,i)=>{let s=-1;return a(0);async function a(c){if(c<=s)throw Error("next() called multiple times");s=c;let u,l=!1,p;if(e[c])p=e[c][0][0],o.req.routeIndex=c;else p=c===e.length&&i||void 0;if(p)try{u=await p(o,()=>a(c+1))}catch(v){if(v instanceof Error&&r)o.error=v,u=await r(v,o),l=!0;else throw v}else if(o.finalized===!1&&n)u=await n(o);if(u&&(o.finalized===!1||l))o.res=u;return o}};var Xs=(e)=>e.req[Se][0].map(([[,r]])=>r),qn=(e,r)=>Xs(e).at(r??e.req.routeIndex)?.path??"";var Dn=["get","post","put","delete","options","patch","query"],ct="Can not add a route since the matcher is already built.",lt=class extends Error{};var On="__COMPOSED_HANDLER";var Wn=(e)=>{let r=e.length;while(r>0&&e.charCodeAt(r-1)===47)r--;return e.length-r},Ys=(e,r,n)=>{if(!/[:*]/.test(r))return r.length;let o=e.req.path,i=e.req[Se],s=new Set,a=0;for(let c of Oe(r)){if(c[0]===":"&&c.endsWith("}?"))throw Error(`mount(): Optional regular expression parameters are not supported in "${n}".`);let u=We(c);if(u&&u!=="*"){let l=u[1];if(s.has(l))throw Error(`mount(): Duplicate path parameter "${l}" in "${n}".`);s.add(l)}if(u&&u!=="*"&&u[2]!==!0){let l=i.length===2?i[1][i[0][e.req.routeIndex][1][u[1]]]:i[0][e.req.routeIndex][1][u[1]];a+=l.length+1}else if(u||c.endsWith("*")){let l=o.indexOf("/",a+1);a=l===-1?o.length:l}else a+=c.length+1}return a},Nn=(e,r,n)=>{if(/[^/]\*$/.test(n))throw Error(`mount(): Wildcard must follow "/" in "${n}".`);let o=Ys(e,r,n),i=e.req.path.slice(o)||"/";if(o>e.req.path.length||i[0]!=="/"||/\/(?:\.|%2e){1,2}(?:\/|$)/i.test(i))throw new De(400,{message:"Invalid mounted path"});let s=e.req.raw.url;if(/^[^/?#]*\/\/[^/?#\\]*[?#\\]/.test(s))throw new De(400,{message:"Invalid mounted path"});let a=s.search(/[?#]/),c=Wn(a===-1?s:s.slice(0,a));if(c>1&&Wn(e.req.path)===c-1)throw new De(400,{message:"Invalid mounted path"});let u=new URL(s);if(u.pathname=i.replace(/[\\\t\n\r]/g,encodeURIComponent),i.includes("%"));return new Request(u,e.req.raw)};var Zs=(e)=>e.text("404 Not Found",404),Un=(e,r)=>{if("getResponse"in e){let n=e.getResponse();return r.newResponse(n.body,n)}return console.error(e),r.text("Internal Server Error",500)},jn=class e{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(r={}){[...Dn,"all"].forEach((i)=>{this[i]=(s,...a)=>{let c=i.toUpperCase();if(typeof s==="string")this.#t=s;else this.#i(c,this.#t,s);return a.forEach((u)=>{this.#i(c,this.#t,u)}),this}}),this.on=(i,s,...a)=>{for(let c of[s].flat()){this.#t=c;for(let u of[i].flat()){let l=u.toUpperCase();for(let p of a)this.#i(l,this.#t,p)}}return this},this.use=(i,...s)=>{if(typeof i==="string")this.#t=i;else this.#t="*",s.unshift(i);return s.forEach((a)=>{this.#i("ALL",this.#t,a)}),this};let{strict:n,...o}=r;Object.assign(this,o),this.getPath=n??!0?r.getPath??ir:Pn}#e(){let r=new e({router:this.router,getPath:this.getPath});return r.errorHandler=this.errorHandler,r.#r=this.#r,r.routes=this.routes,r}#r=Zs;errorHandler=Un;route(r,n){let o=this.basePath(r);return n.routes.map((i)=>{let s;if(n.errorHandler===Un)s=i.handler;else s=async(a,c)=>(await ur([],n.errorHandler)(a,()=>i.handler(a,c))).res,s[On]=i.handler;o.#i(i.method,i.path,s,i.basePath)}),this}basePath(r){let n=this.#e();return n._basePath=he(this._basePath,r),n}onError=(r)=>(this.errorHandler=r,this);notFound=(r)=>(this.#r=r,this);mount(r,n,o){let i,s;if(o)if(typeof o==="function")s=o;else if(s=o.optionHandler,o.replaceRequest===!1)i=(l)=>l;else i=o.replaceRequest;let a=s?(l)=>{let p=s(l);return Array.isArray(p)?p:[p]}:(l)=>{let p=void 0;try{p=l.executionCtx}catch{}return[l.env,p]},c=(l)=>{let p=qn(l);return Nn(l,p.replace(/\/?\*$/,""),p)},u=async(l,p)=>{let v=await n(i?i(l.req.raw):c(l),...a(l));if(v)return v;await p()};return this.#i("ALL",he(r,"*"),u),this}#i(r,n,o,i){n=he(this._basePath,n);let s={basePath:i!==void 0?he(this._basePath,i):this._basePath,path:n,method:r,handler:o};this.router.add(r,n,[o,s]),this.routes.push(s)}#o(r,n){if(r instanceof Error)return this.errorHandler(r,n);throw r}#n(r,n,o,i){if(i==="HEAD")return(async()=>new Response(null,await this.#n(r,n,o,"GET")))();let s=this.getPath(r,{env:o}),a=this.router.match(i,s),c=new cr(r,{path:s,matchResult:a,env:o,executionCtx:n,notFoundHandler:this.#r});if(a[0].length===1){let l;try{l=a[0][0][0][0](c,async()=>{c.res=await this.#r(c)})}catch(p){return this.#o(p,c)}return l instanceof Promise?l.then((p)=>p||(c.finalized?c.res:this.#r(c))).catch((p)=>this.#o(p,c)):l??this.#r(c)}let u=ur(a[0],this.errorHandler,this.#r);return(async()=>{try{let l=await u(c);if(!l.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#o(l,c)}})()}fetch=(r,...n)=>this.#n(r,n[1],n[0],r.method);request=(r,n,o,i)=>{if(r instanceof Request)return this.fetch(n?new Request(r,n):r,o,i);return r=r.toString(),this.fetch(new Request(/^https?:\/\//.test(r)?r:`http://localhost${he("/",r)}`,n),o,i)};fire=()=>{addEventListener("fetch",(r)=>{r.respondWith(this.#n(r.request,r,void 0,r.request.method))})}};var G=()=>Object.create(null);var lr=[];function $n(e,r){let n=this.buildAllMatchers(),o=(i,s)=>{let a=n[i]||n.ALL,c=a[2][s];if(c)return c;let u=s.match(a[0]);if(!u)return[[],lr];let l=u.indexOf("",1);return[a[1][l],u]};return this.match=o,o(e,r)}var ea="[^/]+",ta="[^]*",ra="(?:|/[^]*)",ce=Symbol(),Hn=new Set(".\\+*[^]$()");function na(e,r){if(e.length===1)return r.length===1?e<r?-1:1:-1;if(r.length===1)return 1;if(e==="[^]*"||e==="(?:|/[^]*)")return r==="[^]*"?-1:1;else if(r==="[^]*"||r==="(?:|/[^]*)")return-1;if(e==="[^/]+")return 1;else if(r==="[^/]+")return-1;return e.length===r.length?e<r?-1:1:r.length-e.length}var Bn=class e{#t;#e;#r=G();insert(r,n,o,i,s){let a=this;for(let c=0,u=r.length;c<u;c++){let l=r[c],p=l.length===1?l==="*"?c===u-1?["","",ta]:["","",ea]:null:l==="/*"?["","",ra]:l.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),v;if(p){let h=p[1],b=p[2]||"[^/]+";if(h&&p[2]){if(new RegExp(b).test(""))throw ce;if(b=b.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(b))throw ce;if(b.length===1&&Hn.has(b))throw ce}if(s.push(b),v=a.#r[b],!v){if(b!=="[^]*"&&b!=="(?:|/[^]*)"){for(let T in a.#r)if((b.length>1||T.length>1)&&T!=="[^]*"&&T!=="(?:|/[^]*)")throw ce}v=a.#r[b]=new e}if(h!=="")v.#e??=i.varIndex++,o.push([h,v.#e])}else if(s.push(l),v=a.#r[l],!v){for(let h in a.#r)if(h.length>1&&h!=="[^]*"&&h!=="(?:|/[^]*)")throw ce;v=a.#r[l]=new e}a=v}if(a.#t!==void 0)throw ce;a.#t=n}buildRegExpStr(){let r=Object.keys(this.#r).sort(na).map((n)=>{let o=this.#r[n],i=o.buildRegExpStr();return i===""?"":(typeof o.#e==="number"?`(${n})@${o.#e}`:Hn.has(n)?`\\${n}`:n)+i}).filter(Boolean);if(typeof this.#t==="number"&&this.#t!==-1)r.unshift(`#${this.#t}`);if(r.length===0)return"";if(r.length===1)return r[0];return"(?:"+r.join("|")+")"}};var dr=class{#t={varIndex:0};#e=new Bn;#r=0;paths=G();insert(e,r){let n=[];if(r){this.#e.insert(e.split(""),-1,[],this.#t,n),this.paths[e]=[-1,[],n];return}let o=[],i=[],s=e;for(let c=0;;){let u=!1;if(s=s.replace(/\{(?:\{[\d,]+\}|[^}])+\}/g,(l)=>{let p=`@\\${c}`;return i[c]=[p,l],c++,u=!0,p}),!u)break}let a=s.match(/(?::[^\/]+)|(?:\/\*$)|./gs)||[];for(let c=i.length-1;c>=0;c--){let[u]=i[c];for(let l=a.length-1;l>=0;l--)if(a[l].indexOf(u)!==-1){a[l]=a[l].replace(u,i[c][1]);break}}this.#e.insert(a,this.#r,o,this.#t,n),this.paths[e]=[this.#r++,o,n]}buildRegExp(){let e=this.#e.buildRegExpStr();if(e==="")return[/^$/,[],[]];let r=0,n=[],o=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,s,a)=>{if(s!==void 0)return n[++r]=Number(s),"$()";if(a!==void 0)return o[Number(a)]=++r,"";return""}),[new RegExp(`^${e}`),n,o]}};function ia(e){let r=e[e.length-1];return r==="[^]*"||r==="(?:|/[^]*)"}function sa(e,r){let n=e.length-1;for(let o=0;o<n;o++)if(e[o]!==r[o])return!1;return e[n]==="[^]*"||r.length===n||r[n]==="/"}var zn=class{name="RegExpRouter";#t;#e;constructor(){this.#t={["ALL"]:[]},this.#e={["ALL"]:new dr}}#r(e,r){try{this.#e[e].insert(r,!/\*|\/:/.test(r))}catch(n){throw n===ce?new lt(r):n}}add(e,r,n){let o=this.#t;if(!o)throw Error(ct);let i=this.#e;if(!o[e]){i[e]=new dr,o[e]=[...o.ALL];for(let c in i.ALL.paths)this.#r(e,c)}if(r==="/*")r="*";let s=e==="ALL"?Object.keys(o):[e],a=st(r)||[r];for(let c of a)for(let u of s){if(!i[u].paths[c])this.#r(u,c);o[u].push([n,c])}}match=$n;buildAllMatchers(){let e=G();for(let r of Object.keys(this.#t))e[r]=this.#i(r);return this.#t=this.#e=void 0,e}#i(e){let r=this.#t[e],n=this.#e[e],o=G(),i=[],[s,a,c]=n.buildRegExp(),u=G(),l=r.map(([v,h],b)=>((u[h]??=[]).push(b),[v,n.paths[h][1].reduceRight((T,[_,k])=>(T[_]=c[k],T),G())])),p=Object.keys(u).filter((v)=>ia(n.paths[v][2]));for(let v in n.paths){let[h,,b]=n.paths[v],T=[...u[v]];for(let k of p)if(k!==v&&sa(n.paths[k][2],b))T.push(...u[k]);let _=T.sort((k,q)=>k-q).map((k)=>l[k]);if(h===-1){let k=Math.max(-1,..._.flatMap(([,q])=>Object.values(q)));o[v]=[_,k===-1?lr:v.match(s).slice(0,k+1)]}else i[h]=_}return[s,a.map((v)=>i[v]),o]}};var Kn=class{name="SmartRouter";#t=[];#e=[];constructor(e){this.#t=e.routers}add(e,r,n){if(!this.#e)throw Error(ct);this.#e.push([e,r,n])}match(e,r){if(!this.#e)throw Error("Fatal error");let n=this.#t,o=this.#e,i=n.length,s=0,a;for(;s<i;s++){let c=n[s];try{for(let u=0,l=o.length;u<l;u++)c.add(...o[u]);a=c.match(e,r)}catch(u){if(u instanceof lt)continue;throw u}this.match=c.match.bind(c),this.#t=[c],this.#e=void 0;break}if(s===i)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(this.#e||this.#t.length!==1)throw Error("No active router has been determined yet.");return this.#t[0]}};var pr=G(),aa=0,Gn=class e{#t=[];#e=G();#r=[];#i;#o=pr;insert(r,n,o){let i=this,s=Oe(n),a=new Set,c=0;for(let u of s){let l=s[++c],p=We(u,l)||(l===void 0&&u&&u.indexOf("*")===u.length-1?u:null),v=Array.isArray(p),h=v?p[0]:p||u,b=i.#e[h]||=new e;if(p&&!b.#i)b.#i=p,i.#r.push(b);if(i=b,v)a.add(p[1])}i.#t.push({[r]:{handler:o,possibleKeys:[...a],score:++aa}})}#n(r,n,o,i,s){for(let a=0,c=n.#t.length;a<c;a++){let u=n.#t[a],l=u[o]||u.ALL;if(l){l.params=G(),r.push(l);for(let p=0,v=l.possibleKeys.length;p<v;p++){let h=l.possibleKeys[p];l.params[h]=s?.[h]&&!p?s[h]:i[h]??s?.[h]}}}}search(r,n){let o=[];this.#o=pr;let i=[this],s=or(n),a=[],c=s.length,u=null;for(let l=0;l<c;l++){let p=s[l],v=l===c-1,h=[];for(let T=0,_=i.length;T<_;T++){let k=i[T],q=k.#e[p];if(q)if(q.#o=k.#o,v){if(q.#e["*"])this.#n(o,q.#e["*"],r,k.#o);this.#n(o,q,r,k.#o)}else h.push(q);for(let I of k.#r){let N=I.#i,U=k.#o===pr?{}:{...k.#o};if(typeof N==="string"){if(N==="*"||p.startsWith(N.slice(0,-1))){if(this.#n(o,I,r,k.#o),N==="*")I.#o=U,h.push(I)}continue}let[,J,oe]=N;if(!p&&oe===!0)continue;if(oe!==!0){if(!u){u=[];let Re=n[0]==="/"?1:0;for(let X=0;X<c;X++)u[X]=Re,Re+=s[X].length+1}let xe=n.slice(u[l]),ue=oe.exec(xe);if(ue){if(!Object.hasOwn(U,J))U[J]=ue[0];if(this.#n(o,I,r,k.#o,U),ue[0].length===xe.length&&I.#e["*"])this.#n(o,I.#e["*"],r,k.#o,U);for(let Re in I.#e){I.#o=U;let X=ue[0].match(/\//g)?.length??0;(a[X]||=[]).push(I);break}continue}}if(oe===!0||oe.test(p)){if(!Object.hasOwn(U,J))U[J]=p;if(v){if(this.#n(o,I,r,U,k.#o),I.#e["*"])this.#n(o,I.#e["*"],r,U,k.#o)}else I.#o=U,h.push(I)}}}let b=a.shift();i=b?h.concat(b):h}if(o[1])o.sort((l,p)=>l.score-p.score);return[o.map(({handler:l,params:p})=>[l,p])]}};var hr=class{name="TrieRouter";#t=new Gn;add(e,r,n){for(let o of st(r)||[r])this.#t.insert(e,o,n)}match(e,r){return this.#t.search(e,r)}};var D=class extends jn{constructor(e={}){super(e);this.router=e.router??new Kn({routers:[new zn,new hr]})}};var Qn=(e)=>e===32||e===9||e===10||e===13,dt=(e,r)=>{while(r<e.length){if(!Qn(e.charCodeAt(r)))break;r++}return r},Ue=(e,r)=>{while(r>0){if(!Qn(e.charCodeAt(r-1)))break;r--}return r},Vn=(e,r)=>{while(r<e.length){let n=e.charCodeAt(r);if(n===59)return[r+1,!0];if(n===44)return[r+1,!1];r++}return[r,!1]},ca=(e,r)=>{let n=r,o=!1;while(n<e.length){let i=e.charCodeAt(n);if(o&&i===92)n++;else if(i===34)o=!o;else if(!o&&i===44)return n+1;n++}return n},ua=(e,r)=>{r=dt(e,r);let n=r,o,i,s=!1;while(n<e.length){let u=e.charCodeAt(n);if(u===61){o=e.slice(r,Ue(e,n)),n++;break}if(u===59)return[n+1,void 0,void 0,!0];if(u===44)return[n+1,void 0,void 0,!1];n++}if(o===void 0)return[n,void 0,void 0,!1];if(n=dt(e,n),e.charCodeAt(n)===61){let u=Vn(e,n+1);return[u[0],o,void 0,u[1]]}let a=!1,c=n;while(n<e.length){let u=e.charCodeAt(n);if(a&&u===92)n++;else if(u===34){if(a){let l=dt(e,n+1),p=e.charCodeAt(l);if(l<e.length&&!(p===59||p===44)){let v=Vn(e,l);return[v[0],o,void 0,v[1]]}if(i=e.slice(c+1,n),i.includes("\\"))i=i.replace(/\\(.)/g,"$1");if(p===44)return[l+1,o,i,!1];if(p===59)s=!0,l++;n=l;break}a=!0}else if(!a&&(u===59||u===44)){if(i=e.slice(c,Ue(e,n)),u===59)s=!0;n++;break}n++}return[n,o,i??e.slice(c,Ue(e,n)),s]},la=(e,r)=>{let n={type:"",params:Object.create(null),q:1};r=dt(e,r);let o=r;while(o<e.length){let c=e.charCodeAt(o);if(c===59||c===44){if(n.type=e.slice(r,Ue(e,o)),o++,c===44)return[o,n.type?n:void 0];if(!n.type)return[ca(e,o),void 0];break}o++}if(!n.type)return n.type=e.slice(r,Ue(e,e.length)),[e.length,n.type?n:void 0];let i,s,a;while(o<e.length){if([o,i,s,a]=ua(e,o),i&&s)n.params[i]=s;if(!a)break}return[o,n]},Xn=(e)=>{if(!e)return[];let r=[],n=0,o,i=!1,s;while(n<e.length)if([n,o]=la(e,n),o){if(o.q=da(o.params.q??o.params.Q),r.push(o),s&&s.q<o.q)i=!0;s=o}if(i)r.sort((a,c)=>c.q-a.q);return r},da=(e)=>{if(e===void 0)return 1;if(e==="")return 1;if(e==="NaN")return 0;let r=Number(e);if(Number.isNaN(r))return 1;if(r<0)return 0;if(r>1)return 1;return r};var Yn=/^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|msgpack|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|vnd\.msgpack|wasm|x-httpd-php|x-javascript|x-msgpack|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml|msgpack))(?:[;\s]|$)/i;var pa=["gzip","deflate"],ha=/(?:^|,)\s*?no-transform\s*?(?:,|$)/i,ma=(e,r)=>{if(e===void 0)return;let n=Xn(e),o=n.find((s)=>s.type==="*")?.q,i;for(let s of r){let a=n.find((u)=>u.type.toLowerCase()===s),c=a?a.q:o??0;if(c===1)return s;else if(c>0&&(!i||c>i.q))i={encoding:s,q:c}}return i?.encoding},fa=/(?:^|,)\s*accept-encoding\s*(?:,|$)/i,Zn=(e)=>{let r=e?.threshold??1024,n=e?.encoding?[e.encoding]:pa,o=e?.contentTypeFilter??Yn,i=typeof o==="function"?(s)=>{let a=s.headers.get("Content-Type");return a&&o(a)}:(s)=>{let a=s.headers.get("Content-Type");return a&&o.test(a)};return async function(a,c){await c();let u=a.res.headers.get("Content-Length");if(a.res.status===206||a.res.headers.has("Content-Encoding")||a.res.headers.has("Transfer-Encoding")||a.req.method==="HEAD"||u&&Number(u)<r||!i(a.res)||!ga(a.res))return;let l=a.res.headers.get("Vary");if(l!=="*"&&!(l&&fa.test(l)))a.header("Vary",l?`${l}, Accept-Encoding`:"Accept-Encoding");let p=a.req.header("Accept-Encoding"),v=ma(p,n);if(!v||!a.res.body)return;let h=new CompressionStream(v);a.res=new Response(a.res.body.pipeThrough(h),a.res),a.res.headers.delete("Content-Length"),a.res.headers.set("Content-Encoding",v);let b=a.res.headers.get("ETag");if(b&&!b.startsWith("W/"))a.res.headers.set("ETag",`W/${b}`)}},ga=(e)=>{let r=e.headers.get("Cache-Control");return!r||!ha.test(r)};import{timingSafeEqual as eo}from"crypto";function to(e){let r=new D,n=!1;return r.post("/pair",x(e,async(o)=>{let i=await C(o),s=o.req.raw,a=e.requestIP(s),c=tr(a)&&e.tunnel?.running()?s.headers.get("cf-connecting-ip"):null,u=c?`tunnel:${c}`:a??"unknown",l=e.auth.pair(String(i.code??""),String(i.device??""),u);if(!l)return A(o,"unauthorized","invalid or expired pairing code",401);return R(o,l)},{public:!0})),r.post("/pair/approve",x(e,async(o)=>{let i=o.req.raw.headers.get("origin")??void 0;if(!i||!e.approveLocalPairing||!K(e,o.req.raw)||!e.allowed(i,o.req.raw,{wildcard:!1}))return A(o,"unauthorized","local approval not available",403);if(n)throw new ne("local approval already in progress");let s=await C(o),a=String(s.device??"").trim()||"Browser";n=!0,e.disableTimeout?.(o.req.raw);try{if(!await e.approveLocalPairing({device:a,origin:i}))return A(o,"unauthorized","local approval rejected",403);if(o.req.raw.signal.aborted)return A(o,"unauthorized","local approval request was closed",403);return R(o,e.auth.issue(a))}finally{n=!1}},{public:!0})),r.post("/pair/code",x(e,(o)=>{let i=o.req.raw,s=e.cliSecret?Buffer.from(e.cliSecret):void 0,a=Buffer.from(j(i)??"");if(!s||i.headers.has("origin")||!K(e,i)||s.length!==a.length||!eo(s,a))return A(o,"unauthorized","pairing code is only available to the local CLI",403);if(!e.authEnabled)return A(o,"bad_request","authentication is disabled, no pairing needed",400);let c=e.auth.renewPairingCode();return R(o,{code:c,expires:e.auth.pairingExpires()})},{public:!0})),r.post("/server/shutdown",x(e,(o)=>{let i=o.req.raw,s=e.cliSecret?Buffer.from(e.cliSecret):void 0,a=Buffer.from(j(i)??"");if(!s||i.headers.has("origin")||!K(e,i)||s.length!==a.length||!eo(s,a))return A(o,"unauthorized","shutdown is only available to the local CLI",403);if(!e.shutdown)return A(o,"not_found","shutdown is unavailable",404);return e.shutdown(),R(o,{ok:!0})},{public:!0})),r.get("/pair/current",x(e,(o)=>{if(!e.authEnabled)return A(o,"bad_request","authentication is disabled, no pairing needed",400);let i=e.auth.pairingCode();return R(o,{code:i,expires:e.auth.pairingExpires()})},{localOnly:!0})),r.post("/pair/current",x(e,(o)=>{if(!e.authEnabled)return A(o,"bad_request","authentication is disabled, no pairing needed",400);let i=e.auth.renewPairingCode();return R(o,{code:i,expires:e.auth.pairingExpires()})},{localOnly:!0})),r.get("/devices",x(e,(o)=>{let i=e.auth.verify(j(o.req.raw))?.id;return R(o,e.auth.list().map((s)=>s.id===i?{...s,current:!0}:s))},{localOnly:!0})),r.delete("/devices/:id",x(e,(o)=>e.auth.revoke(L(o,"id"))?R(o,{ok:!0}):A(o,"not_found","no such device",404),{localOnly:!0})),r}function ro(e){let r=new D,n=new Ze,o=(i)=>e.authEnabled?e.auth.verify(j(i)):void 0;r.get("/events",x(e,async(i)=>{if(i.req.query("protocol")!==String(Mr))return A(i,"protocol_mismatch",`server speaks protocol ${Mr}`,400);let s=i.req.raw,a=o(s),c=/\bgzip\b/i.test(s.headers.get("accept-encoding")??""),u=await n.open({runtime:e.runtime,identity:{deviceID:a?.id,expires:a?.token.expires},server:{...e.info,localManagement:K(e,s)},index:i.req.query("index")==="1",subscribe:i.req.query("subscribe"),refImages:i.req.query("images")==="ref",gzip:c,heartbeatMs:e.heartbeatMs,signal:s.signal});e.disableTimeout?.(s);let l=F(i);if(l.set("content-type","text/event-stream"),l.set("cache-control","no-cache, no-transform"),l.set("x-accel-buffering","no"),c)l.set("content-encoding","gzip"),l.set("vary","accept-encoding");return new Response(u,{headers:l})}));for(let i of["subscribe","unsubscribe"])r.post(`/events/:connectionID/${i}`,x(e,async(s)=>{let a=await C(s),c=await n.control(e.runtime,L(s,"connectionID"),o(s.req.raw)?.id,{...a,type:i});if(c==="not_found")return A(s,"not_found","no such connection",404);if(c==="forbidden")return A(s,"unauthorized","connection belongs to another device",403);return new Response(null,{status:204,headers:F(s)})}));return r}function no(e){let r=new D;return r.get("/folding/settings",x(e,(n)=>R(n,{digestModel:e.runtime.digestModel()}))),r.put("/folding/settings",x(e,async(n)=>{let o=await n.req.json();if(!o||typeof o!=="object"||!("digestModel"in o)||o.digestModel!==null&&typeof o.digestModel!=="string")return A(n,"bad_request","digestModel must be a model id or null",400);return R(n,{digestModel:e.runtime.setDigestModel(o.digestModel)})})),r}import{homedir as ya}from"os";import{resolve as mr}from"path";async function io(e,r,n){if(!n){let o=mr(process.cwd());return oo(e.host(),mr(r?.trim()||o),"on the server",[{name:"\u5DE5\u4F5C\u533A",path:o},{name:"\u7528\u6237\u76EE\u5F55",path:mr(ya())}])}try{return await e.withSshHost(n,async(o)=>{let i=o.info.home,s=r?.trim()||"~",a=s==="~"||s.startsWith("~/")?i+s.slice(1):s,c=de(o).resolve(i,a);return await oo(o,c,`on ${n}`,[{name:"\u7528\u6237\u76EE\u5F55",path:i},{name:"\u6839\u76EE\u5F55",path:de(o).parse(i).root}])})}catch(o){throw new t(`cannot browse ${n}: ${o instanceof Error?o.message:o}`)}}async function oo(e,r,n,o){let i=await e.readdir(r).catch(()=>{throw new t(`${r} is not a readable directory ${n}`)}),s=de(e).dirname(r);return{path:r,parent:s===r?null:s,entries:i.filter((a)=>a.directory).map((a)=>({name:a.name,path:de(e).join(r,a.name)})).sort((a,c)=>a.name.localeCompare(c.name,void 0,{numeric:!0,sensitivity:"base"})),shortcuts:o.filter((a,c)=>o.findIndex((u)=>u.path===a.path)===c)}}import{globSync as wa,readFileSync as va}from"fs";import{homedir as Sa}from"os";import{isAbsolute as xa,join as fr}from"path";function co(e=Sa()){let r=new Map;for(let n of uo(fr(e,".ssh","config"),e,new Set))r.set(n.name,n);for(let n of Ra(fr(e,".ssh","known_hosts")))if(!r.has(n))r.set(n,{name:n,source:"known_hosts"});return[...r.values()]}function uo(e,r,n){if(n.has(e))return[];n.add(e);let o=[],i=[];for(let s of lo(e).split(`
|
|
15
|
-
`)){let a=/^\s*(\w+)\s*(?:=\s*|\s+)(.+?)\s*$/.exec(s);if(!a?.[1]||!a[2]||s.trimStart().startsWith("#"))continue;let c=a[1].toLowerCase(),u=a[2].split(/\s+/).map((l)=>l.replace(/^"|"$/g,""));if(c==="host")i=u.filter((l)=>!/[*?!]/.test(l)).map((l)=>({name:l,source:"config"})),o.push(...i);if(c==="match")i=[];if(c==="hostname")for(let l of i)l.hostname=u[0];if(c==="user")for(let l of i)l.user=u[0];if(c==="include")for(let l of u){let p=l.replace(/^~(?=\/|$)/,r),v=xa(p)?p:fr(r,".ssh",p);for(let h of wa(v).sort())o.push(...uo(h,r,n))}}return o}function Ra(e){return lo(e).split(`
|
|
16
|
-
`).flatMap((r)=>r.startsWith("#")||r.startsWith("@")?[]:r.split(/\s/)[0]?.split(",")??[]).filter((r)=>r&&!r.startsWith("|")).map((r)=>r.replace(/^\[(.+)\]:\d+$/,"$1"))}function lo(e){try{return va(e,"utf8")}catch{return""}}function po(e){let r=new D;return r.get("/info",x(e,(n)=>{e.info.shell=e.runtime.serverShell();let o=e.authEnabled&&e.approveLocalPairing!==void 0&&K(e,n.req.raw);return R(n,{...!e.authEnabled||e.auth.verify(j(n.req.raw))?e.info:{name:e.info.name,auth:e.info.auth},localManagement:K(e,n.req.raw),...o?{localApproval:!0}:{}})},{public:!0})),r.get("/health",x(e,async(n)=>{if(!K(e,n.req.raw))return A(n,"unauthorized","loopback only",403);let{models:o}=await e.runtime.models(),i=o.filter((u)=>u.available===!0).length,s=e.runtime.list(!0),a=s.filter((u)=>u.status==="busy").length,c=0;for(let u of s)c+=e.runtime.get(u.id)?.runningTools??0;if(i===0)return R(n,{ready:!1,availableModels:i,busySessions:a,runningTools:c},503);return R(n,{ready:!0,availableModels:i,busySessions:a,runningTools:c})},{public:!0})),r.get("/server/autostart",x(e,(n)=>{if(!e.autostart)return A(n,"not_found","\u5F53\u524D\u670D\u52A1\u5165\u53E3\u4E0D\u652F\u6301\u767B\u5F55\u81EA\u542F",404);return R(n,e.autostart.status())})),r.put("/server/autostart",x(e,async(n)=>{if(!e.autostart)return A(n,"not_found","\u5F53\u524D\u670D\u52A1\u5165\u53E3\u4E0D\u652F\u6301\u767B\u5F55\u81EA\u542F",404);let o=await C(n);if(typeof o.enabled!=="boolean")return A(n,"bad_request","enabled \u5FC5\u987B\u662F\u5E03\u5C14\u503C",400);return R(n,e.autostart.set(o.enabled))})),r.post("/server/restart",x(e,(n)=>{if(!e.restart)return A(n,"not_found","\u5F53\u524D\u670D\u52A1\u5165\u53E3\u4E0D\u652F\u6301\u91CD\u542F",404);return e.restart(),R(n,{restarting:!0},202)})),r.patch("/server/shell",x(e,async(n)=>{let o=await C(n),i=e.runtime.setServerShell(o.shell);return e.info.shell=i,R(n,{shell:i})})),r.get("/models",x(e,async(n)=>R(n,await e.runtime.models()))),r.get("/directories",x(e,async(n)=>R(n,await io(e.runtime,n.req.query("path"),n.req.query("remote"))),{public:!1})),r.get("/ssh/hosts",x(e,(n)=>R(n,co()),{public:!1})),r.get("/storage",x(e,(n)=>R(n,e.runtime.storage(n.req.query("detailed")==="true")))),r.post("/storage/compact",x(e,async(n)=>{let o=await C(n);return R(n,await e.runtime.compactStorage({checkpoint:o.checkpoint===!0,vacuum:o.vacuum===!0,images:o.images===!0}))})),r}function ho(e){let r=new D,n=e.modelProviders;if(!n)return r;return r.get("/model-providers",x(e,(o)=>R(o,n.list()))),r.put("/model-providers/:id",x(e,async(o)=>{let i=await n.save(L(o,"id"),await C(o));return R(o,i)})),r.post("/model-providers/:id/discover",x(e,async(o)=>R(o,await n.discover(L(o,"id"))))),r.delete("/model-providers/:id",x(e,async(o)=>await n.remove(L(o,"id"))?R(o,{ok:!0}):A(o,"not_found","no such model provider",404))),r}function mo(e){let r=new D;return r.get("/server/network",x(e,(n)=>{if(!e.network)return A(n,"not_found","network settings unavailable",404);return R(n,e.network.manager.configuration(e.network.runtime()))},{localOnly:!0})),r.put("/server/network",x(e,async(n)=>{if(!e.network)return A(n,"not_found","network settings unavailable",404);let o=e.network.manager.configuration(e.network.runtime());if(!o.editable)return A(n,"unauthorized",o.disabledReason??"network settings are read-only",403);let i=await C(n),s=n.req.raw;if(!e.internalRequest?.(s)&&!e.auth.verify(j(s)))return A(n,"unauthorized","authentication expired or revoked",403);return e.network.save(i),R(n,e.network.manager.configuration(e.network.runtime()))},{localOnly:!0})),r}function fo(e){let r=new D;return r.get("/plugins",x(e,async(n)=>(await e.runtime.initialize(),R(n,e.runtime.plugins.list())))),r.post("/plugins/load",x(e,async(n)=>{let o=await C(n);if(typeof o.path!=="string"||!o.path||o.path.length>4096)throw new t("path must be a non-empty plugin file path");return await e.runtime.initialize(),await e.runtime.plugins.load(o.path),R(n,e.runtime.plugins.list())})),r.post("/plugins/:id/reload",x(e,async(n)=>(await e.runtime.initialize(),await e.runtime.plugins.reload(L(n,"id")),R(n,e.runtime.plugins.list())))),r.patch("/plugins/:id",x(e,async(n)=>{let o=await C(n);if(typeof o.enabled!=="boolean")throw new t("enabled must be a boolean");return await e.runtime.initialize(),await e.runtime.plugins.setEnabled(L(n,"id"),o.enabled),R(n,e.runtime.plugins.list())})),r.post("/plugins/:id/commands/:command",x(e,async(n)=>{await e.runtime.initialize();let o=await C(n);if(!Array.isArray(o.args)||o.args.length>100||o.args.some((i)=>typeof i!=="string"||i.length>1e5))throw new t("args must be an array of strings");return R(n,await e.runtime.plugins.command(L(n,"id"),L(n,"command"),o.args))})),r.get("/plugins/:id/web.js",x(e,async(n)=>{await e.runtime.initialize();let o=await e.runtime.plugins.webBundle(L(n,"id"));if(!o)return R(n,{error:"Plugin web bundle not found"},404);return new Response(o,{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-cache"}})})),r.get("/plugins/:id/web.css",x(e,async(n)=>{await e.runtime.initialize();let o=await e.runtime.plugins.webCSS(L(n,"id"));if(o===void 0)return new Response(null,{status:204});return new Response(o,{headers:{"Content-Type":"text/css; charset=utf-8","Cache-Control":"no-cache"}})})),r}function go(e){let r=new D;return r.get("/projects",x(e,(n)=>R(n,e.runtime.projects()))),r.post("/projects",x(e,async(n)=>R(n,await e.runtime.createProject(await C(n))))),r.put("/projects/order",x(e,async(n)=>(e.runtime.reorderProjects((await C(n)).ids),R(n,{ok:!0})))),r.get("/projects/:id",x(e,(n)=>{let o=e.runtime.project(L(n,"id"));return o?R(n,o):A(n,"not_found","no such project",404)})),r.patch("/projects/:id",x(e,async(n)=>R(n,e.runtime.updateProject(L(n,"id"),await C(n))))),r.delete("/projects/:id",x(e,async(n)=>(await e.runtime.deleteProject(L(n,"id")),R(n,{ok:!0})))),r}function yo(e){let r=new D,n=e.providerAuth;if(!n)return r;return r.get("/provider-auth/openai",x(e,async(o)=>R(o,await n.status()))),r.post("/provider-auth/openai/login",x(e,async(o)=>{let i=await n.start("Basalt");return R(o,i)})),r.post("/provider-auth/openai/manual",x(e,async(o)=>{let i=await C(o);if(typeof i.url!=="string"||!i.url.trim())return A(o,"bad_request","url is required",400);return await n.manualInput(i.url),R(o,await n.status())})),r.post("/provider-auth/openai/logout",x(e,async(o)=>(await n.logout(),R(o,{ok:!0})))),r}function wo(e){let r=new D,n=e.proxy;if(!n)return r;let o=(i)=>{let s=e.proxyTargets?.()??[],a=new Set(s.map((c)=>c.id));for(let c of Object.keys(i.routes))if(!a.has(c))s.push({id:c,name:`\u672A\u542F\u7528\u7684\u7528\u9014\uFF1A${c}`});return{...i,targets:s}};return r.get("/proxy",x(e,(i)=>R(i,o(n.settings())))),r.put("/proxy",x(e,async(i)=>{let s=await C(i),a=i.req.raw;if(e.authEnabled&&!e.internalRequest?.(a)&&!e.auth.verify(j(a)))return A(i,"unauthorized","authentication expired or revoked",403);let c=n.save(s);return R(i,o(c))})),r}import{randomBytes as Aa}from"crypto";var Ta=/^[A-Za-z0-9_-]{8,128}$/,ka="/api/remote-access/proxy/";function bo(e){let r=new D;if(r.get("/access/handoff",x(e,(o)=>{let i=o.req.raw,s=Pa(o.req.query("origin"));if(!s)throw new t("\u7F3A\u5C11\u5408\u6CD5\u7684\u5DE5\u4F5C\u53F0 origin \u53C2\u6570");let a=o.req.query("state")?.trim()??"";if(!Ta.test(a))throw new t("\u7F3A\u5C11\u5408\u6CD5\u7684 state \u53C2\u6570");let c=o.req.query("return_to"),u=c?_a(c,s):void 0;if(c&&!u)throw new t("return_to \u5FC5\u987B\u4E0E\u5DE5\u4F5C\u53F0 origin \u540C\u6E90");let l=e.allowed(s,i,{wildcard:!1}),p=e.authEnabled&&Do(s);if(!l&&!p)return A(o,"unauthorized","origin not allowed",403);let v=i.headers.get("cf-access-jwt-assertion")?.trim()??Ca(i.headers.get("cookie"),"CF_Authorization");if(!se(v))return A(o,"bad_request","\u672A\u68C0\u6D4B\u5230\u6709\u6548\u7684 Cloudflare Access \u767B\u5F55\u51ED\u636E",400);let h={server:Ma(i,e),state:a,token:v};return Ia(h,s,u,l)},{public:!0})),!e.remoteAccess)return r;let n=e.remoteAccess;return r.post("/remote-access/status",x(e,async(o)=>{let i=await C(o);if(typeof i.url!=="string"||!i.url.trim())throw new t("\u9700\u8981\u63D0\u4F9B\u8FDC\u7A0B\u670D\u52A1\u5668\u5730\u5740");return R(o,await n.status(i.url))},{localOnly:!0})),r.post("/remote-access/login",x(e,async(o)=>{let i=await C(o);if(typeof i.url!=="string"||!i.url.trim())throw new t("\u9700\u8981\u63D0\u4F9B\u8FDC\u7A0B\u670D\u52A1\u5668\u5730\u5740");return R(o,await n.startLogin(i.url))},{localOnly:!0})),r.all("/remote-access/proxy/:target/*",(o)=>{if(o.req.method==="OPTIONS")return et(o,e);return x(e,async(i)=>{let s=i.req.raw,a=L(i,"target"),c=Ea(s.url,a);e.disableTimeout?.(s);let u=await n.forward(a,c,s);if(u.kind==="access_required")return Response.json({error:{code:"access_required",message:"\u9700\u8981\u901A\u8FC7 Cloudflare Access \u767B\u5F55\u8BA4\u8BC1",...u.teamDomain?{details:{teamDomain:u.teamDomain}}:{}}},{status:403,headers:F(i)});let l=new Headers(u.response.headers);F(i).forEach((h,b)=>{l.set(b,h)});let p=new Response(u.response.body,{status:u.response.status,statusText:u.response.statusText,headers:l}),v=e.authEnabled?e.auth.verify(j(s)):void 0;return v?tt(e.auth,v,p):p},{localOnly:!0})(o)}),r}function Ea(e,r){let n=new URL(e),o=`${ka}${r}`;if(!n.pathname.startsWith(o))throw new t("\u65E0\u6548\u7684\u8FDC\u7A0B\u4EE3\u7406\u8BF7\u6C42\u8DEF\u5F84");return`${n.pathname.slice(o.length)}${n.search}`}function Pa(e){if(!e)return;try{let r=new URL(e);if(r.protocol!=="http:"&&r.protocol!=="https:")return;return r.origin}catch{return}}function _a(e,r){try{let n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:"||n.origin!==r)return;return n.hash="",n.toString()}catch{return}}function Ca(e,r){if(!e)return;for(let n of e.split(";")){let o=n.indexOf("=");if(o<=0)continue;if(n.slice(0,o).trim()!==r)continue;return n.slice(o+1).trim()}return}function Ma(e,r){let n=r.tunnel?.publicURL();if(n)return n;let o=new URL(e.url),i=e.headers.get("x-forwarded-proto")?.split(",")[0]?.trim().toLowerCase();return`${i==="https"||i==="http"?`${i}:`:e.headers.has("cf-connecting-ip")?"https:":o.protocol}//${o.host}`}function Ia(e,r,n,o){let i=Aa(16).toString("base64"),s=Buffer.from(JSON.stringify(e),"utf8").toString("base64url"),a=n?`${n}#access=${s}`:void 0,c=gr({type:"basalt:access-handoff",...e}),u=gr(r),l=gr(a??null),p=o?"true":"false",v=`<!doctype html>
|
|
17
|
-
<html lang="zh-CN">
|
|
18
|
-
<head>
|
|
19
|
-
<meta charset="utf-8">
|
|
20
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
21
|
-
<title>Basalt Access \u8BA4\u8BC1</title>
|
|
22
|
-
<style>
|
|
23
|
-
body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:#111110;color:#e7e5e4;font-family:system-ui,-apple-system,sans-serif;padding:24px;box-sizing:border-box}
|
|
24
|
-
.card{max-width:380px;width:100%;border:1px solid #292524;border-radius:16px;background:#191817;padding:24px;text-align:center}
|
|
25
|
-
h1{font-size:16px;margin:0 0 8px;font-weight:600}
|
|
26
|
-
p{font-size:13px;line-height:1.6;color:#a8a29e;margin:0 0 18px;word-break:break-all}
|
|
27
|
-
button{appearance:none;border:0;border-radius:10px;background:#e7e5e4;color:#111110;font-size:13px;font-weight:600;padding:10px 18px;cursor:pointer;width:100%}
|
|
28
|
-
</style>
|
|
29
|
-
</head>
|
|
30
|
-
<body>
|
|
31
|
-
<div class="card">
|
|
32
|
-
<h1 id="title">${o?"\u8BA4\u8BC1\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u8FD4\u56DE\u5DE5\u4F5C\u53F0\u2026":"\u786E\u8BA4\u8FD4\u56DE\u5DE5\u4F5C\u53F0"}</h1>
|
|
33
|
-
<p id="desc">\u76EE\u6807\u5DE5\u4F5C\u53F0\uFF1A${La(r)}</p>
|
|
34
|
-
<button id="continue" type="button"${o?' style="display:none"':""}>\u7EE7\u7EED\u8FDE\u63A5</button>
|
|
35
|
-
</div>
|
|
36
|
-
<script nonce="${i}">
|
|
37
|
-
(function(){
|
|
38
|
-
var msg=${c};
|
|
39
|
-
var origin=${u};
|
|
40
|
-
var redirect=${l};
|
|
41
|
-
var btn=document.getElementById("continue");
|
|
42
|
-
function finish(){
|
|
43
|
-
if(window.opener&&!window.opener.closed){
|
|
44
|
-
window.opener.postMessage(msg,origin);
|
|
45
|
-
window.close();
|
|
46
|
-
document.getElementById("title").textContent="\u8BA4\u8BC1\u5DF2\u540C\u6B65\uFF0C\u53EF\u5173\u95ED\u6B64\u7A97\u53E3";
|
|
47
|
-
if(btn)btn.style.display="none";
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if(redirect){
|
|
51
|
-
window.location.replace(redirect);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
document.getElementById("title").textContent="\u5DF2\u5B8C\u6210 Cloudflare Access \u8BA4\u8BC1";
|
|
55
|
-
document.getElementById("desc").textContent="\u8BF7\u8FD4\u56DE\u539F\u5DE5\u4F5C\u53F0\u7A97\u53E3\u7EE7\u7EED\u8FDE\u63A5\u3002";
|
|
56
|
-
}
|
|
57
|
-
if(btn)btn.addEventListener("click",finish);
|
|
58
|
-
if(${p})finish();
|
|
59
|
-
})();
|
|
60
|
-
</script>
|
|
61
|
-
</body>
|
|
62
|
-
</html>`;return new Response(v,{status:200,headers:{"content-type":"text/html; charset=utf-8","cache-control":"no-store","referrer-policy":"no-referrer","x-frame-options":"DENY","content-security-policy":`default-src 'none'; style-src 'unsafe-inline'; script-src 'nonce-${i}'; frame-ancestors 'none'`}})}function gr(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function La(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var qa=new Set(ao);function Da(e){if(!e||typeof e!=="object"||Array.isArray(e))return!1;let r=e;if(typeof r.q!=="string"||r.q.length>4096)return!1;for(let n of["caseSensitive","wholeWord","deep"])if(r[n]!==void 0&&typeof r[n]!=="boolean")return!1;for(let[n,o]of[["mode",Na],["sort",Ua],["group",Fa]])if(r[n]!==void 0&&!o.some((i)=>i===r[n]))return!1;if(r.limit!==void 0&&(typeof r.limit!=="number"||!Number.isInteger(r.limit)||r.limit<1||r.limit>200))return!1;if(r.cursor!==void 0&&(typeof r.cursor!=="string"||r.cursor.length>262144))return!1;if(r.filters!==void 0){if(!r.filters||typeof r.filters!=="object"||Array.isArray(r.filters))return!1;let n=r.filters;for(let o of["projectID","sessionID","fields","tools","model"]){let i=n[o];if(i!==void 0&&(!Array.isArray(i)||i.length>100||!i.every((s)=>typeof s==="string"&&s.length<=1024&&(o!=="fields"||qa.has(s)))))return!1}for(let o of["isError","archived","compacted"])if(n[o]!==void 0&&typeof n[o]!=="boolean")return!1;for(let o of["after","before"])if(n[o]!==void 0&&(typeof n[o]!=="number"||!Number.isFinite(n[o])))return!1}return!0}function vo(e){let r=new D,n=new Map,o=(i)=>{let s=Date.now(),a=e.requestConnection?.(i)??e.requestIP(i)??"local";for(let[u,l]of n)if(s-l.start>=1000)n.delete(u);let c=n.get(a)??{start:s,count:0};return c.count++,n.set(a,c),c.count>20};return r.get("/search/settings",x(e,(i)=>{let s=e.runtime.searchStatus();return R(i,{enabled:s.state!=="disabled",status:s})})),r.put("/search/settings",x(e,async(i)=>{let s=await i.req.json();if(!s||typeof s!=="object"||!("enabled"in s)||typeof s.enabled!=="boolean")return A(i,"bad_request","enabled must be a boolean",400);let a=await e.runtime.setSearchEnabled(s.enabled);return R(i,{enabled:a.state!=="disabled",status:a})})),r.post("/search/rebuild",x(e,async(i)=>{if(e.runtime.searchStatus().state==="disabled")return A(i,"bad_request","\u5386\u53F2\u641C\u7D22\u672A\u542F\u7528",409);return await e.runtime.search.rebuild(),R(i,e.runtime.searchStatus())})),r.get("/search/status",x(e,(i)=>R(i,e.runtime.searchStatus()))),r.get("/search/suggest",x(e,(i)=>{if(o(i.req.raw))return R(i,{error:{code:"rate_limited",message:"too many searches"}},429);let s=i.req.query("q");if(s===void 0||s.length>4096)return A(i,"bad_request","q is required (maximum 4096 characters)",400);return R(i,{terms:Jn(e.runtime.search,s)})})),r.post("/search",x(e,async(i)=>{if(o(i.req.raw))return R(i,{error:{code:"rate_limited",message:"too many searches"}},429);let s=await i.req.json();if(!Da(s))return A(i,"bad_request","invalid search request",400);if(s.cursor)try{tn(s,s.filters?.sessionID?.length===1?s.filters.sessionID[0]:void 0)}catch{return A(i,"bad_request","invalid search cursor",400)}let a=new AbortController,c=()=>a.abort(),u=i.req.raw.signal;if(u.addEventListener("abort",c,{once:!0}),u.aborted)a.abort();let l=new TextEncoder,p=!1,v=new ReadableStream({async start(b){if(a.signal.aborted){b.close(),u.removeEventListener("abort",c);return}let T=()=>{if(!p)b.close()};a.signal.addEventListener("abort",T,{once:!0});try{if(await vr(e.runtime,s,{signal:a.signal,sessionID:s.filters?.sessionID?.length===1?s.filters.sessionID[0]:void 0,onEvent(_){b.enqueue(l.encode(`${JSON.stringify(_)}
|
|
63
|
-
`))}}),!a.signal.aborted)b.close()}catch(_){if(!a.signal.aborted)b.error(_)}finally{a.signal.removeEventListener("abort",T),u.removeEventListener("abort",c)}},cancel(){p=!0,a.abort(),u.removeEventListener("abort",c)}}),h=new Headers(R(i,null).headers);return h.set("content-type","application/x-ndjson; charset=utf-8"),h.set("cache-control","no-store"),new Response(v,{headers:h})})),r}import{open as Wa,realpath as So}from"fs/promises";import{isAbsolute as ja,relative as $a,resolve as Ha}from"path";import Oa from"sharp";class yr{cached=new Map;pending=new Map;bytes=0;tail=Promise.resolve();get(e,r){let n=this.cached.get(e);if(n)return Promise.resolve(n);let o=this.pending.get(e);if(o)return o;if(this.pending.size>=16)return Promise.reject(Error("thumbnail queue full"));let i=this.tail.then(async()=>{let s=await Oa(r(),{limitInputPixels:40000000,pages:1}).autoOrient().resize({width:640,height:640,fit:"inside",withoutEnlargement:!0}).webp({quality:72,effort:2}).timeout({seconds:10}).toBuffer();while(this.bytes+s.byteLength>33554432){let a=this.cached.entries().next().value;if(!a)break;this.cached.delete(a[0]),this.bytes-=a[1].byteLength}return this.cached.set(e,s),this.bytes+=s.byteLength,s});return this.pending.set(e,i),this.tail=i.catch(()=>{return}),i.finally(()=>this.pending.delete(e)).catch(()=>{return}),i}}var Ba=150,Ja=(e)=>Rs.includes(e);function Ao(e){let r=new D,n=new yr;return r.get("/sessions",x(e,(o)=>{let i=o.req.query("archive")??"active";if(!Ja(i))return A(o,"bad_request",`archive must be ${Rs.join(", ")}`,400);return R(o,e.runtime.list(o.req.query("includeChildren")==="true",{archive:i}))})),r.post("/sessions",x(e,async(o)=>{let i=await C(o),s=e.runtime.create({projectID:i.projectID,title:i.title,model:i.model,thinking:i.thinking});return await e.runtime.plugins.idle(),R(o,s.info())})),r.get("/sessions/:id",x(e,(o)=>{let i=e.runtime.get(L(o,"id"));return i?R(o,i.info()):A(o,"not_found","no such session",404)})),r.get("/sessions/:id/image",x(e,async(o)=>{let i=e.runtime.get(L(o,"id"));if(!i)return A(o,"not_found","no such session",404);let s=i.projectID?e.runtime.project(i.projectID):void 0;if(!s||s.remote)return A(o,"bad_request","\u56FE\u7247\u9700\u8981\u672C\u673A\u9879\u76EE\u4E0A\u4E0B\u6587",400);let a=o.req.query("path");if(!a||a.includes("\x00"))return A(o,"bad_request","\u56FE\u7247\u8DEF\u5F84\u65E0\u6548",400);let c=await So(s.directory),u=Ha(c,a),l=(p)=>{let v=$a(c,p);return v!==".."&&!v.startsWith("../")&&!v.startsWith("..\\")&&!ja(v)};if(!l(u))return A(o,"bad_request","\u56FE\u7247\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u9879\u76EE\u5185",400);try{let p=await So(u);if(!l(p))return A(o,"bad_request","\u56FE\u7247\u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u9879\u76EE\u5185",400);let v=await Wa(p,"r");try{let h=await v.stat();if(!h.isFile()||h.size>10485760)return A(o,"bad_request","\u53EA\u652F\u6301\u4E0D\u8D85\u8FC7 10 MB \u7684\u4F4D\u56FE\u6587\u4EF6",400);let b=await v.readFile(),T=an(b);if(!T)return A(o,"bad_request","\u4E0D\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F",400);let _=F(o);return _.set("content-type",T),_.set("cache-control","no-store"),_.set("x-content-type-options","nosniff"),new Response(b,{headers:_})}finally{await v.close()}}catch(p){if(p&&typeof p==="object"&&"code"in p&&["ENOENT","ENOTDIR","EACCES"].includes(String(p.code)))return A(o,"not_found","\u9879\u76EE\u56FE\u7247\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8BFB",404);throw p}})),r.post("/sessions/:id/shell-approvals/:aid",x(e,async(o)=>{let i=e.runtime.get(L(o,"id"));if(!i)return A(o,"not_found","no such session",404);let s=await C(o);if(typeof s.approved!=="boolean")throw new t("approved must be a boolean");i.assertWritable();let a=Er(i,L(o,"aid"),s.approved);if(a==="unknown")return A(o,"not_found","\u6388\u6743\u8BF7\u6C42\u4E0D\u5B58\u5728\u6216\u5DF2\u5931\u6548",404);return R(o,{ok:!0,expired:a==="expired"})})),r.patch("/sessions/:id",x(e,async(o)=>{let i=e.runtime.get(L(o,"id"));if(!i)return A(o,"not_found","no such session",404);let s=await C(o);if("archived"in s){if(typeof s.archived!=="boolean"||Object.keys(s).length!==1)return A(o,"bad_request","archived must be a boolean and cannot be mixed with other fields",400);return R(o,e.runtime.setArchived(i.id,s.archived))}if(i.assertWritable(),s.title!==void 0&&typeof s.title!=="string")return A(o,"bad_request","title must be a string",400);if(s.model!==void 0)e.runtime.checkModel(s.model);if(s.thinking!==void 0&&s.thinking!==null&&typeof s.thinking!=="string")return A(o,"bad_request","thinking must be a string or null",400);if(s.title!==void 0)i.rename(s.title);if(s.model!==void 0)i.setModel(s.model);if(s.thinking!==void 0)i.setThinking(s.thinking);return R(o,i.info())})),r.delete("/sessions/:id",x(e,async(o)=>(await e.runtime.deleteSession(L(o,"id")),await e.runtime.plugins.idle(),R(o,{ok:!0})))),r.get("/sessions/:id/export",x(e,(o)=>{let i=L(o,"id"),s=e.runtime.exportSession(i),a=R(o,s);return a.headers.set("content-disposition",`attachment; filename="basalt-${i}.json"`),a})),r.post("/sessions/import",x(e,async(o)=>{let i=e.runtime.parseImport(await C(o)),s=e.runtime.importSession(i,{projectID:o.req.query("projectID")||void 0,model:o.req.query("model")||void 0});return await e.runtime.plugins.idle(),R(o,s.info())})),r.get("/sessions/:id/last-model-request",x(e,(o)=>{let i=e.runtime.get(L(o,"id"));if(!i)return A(o,"not_found","no such session",404);let s=i.lastModelRequest();return s?R(o,s):A(o,"not_found","\u8BE5\u4F1A\u8BDD\u5728\u672C\u8FDB\u7A0B\u5185\u8FD8\u6CA1\u6709\u53D1\u51FA\u8FC7\u6A21\u578B\u8BF7\u6C42\uFF08\u5FEB\u7167\u9A7B\u7559\u5185\u5B58\uFF0C\u91CD\u542F\u5373\u6E05\u7A7A\uFF09",404)})),r.get("/sessions/:id/last-model-response",x(e,(o)=>{let i=e.runtime.get(L(o,"id"));if(!i)return A(o,"not_found","no such session",404);let s=i.lastModelResponse();return s?R(o,s):A(o,"not_found","\u8BE5\u4F1A\u8BDD\u5728\u672C\u8FDB\u7A0B\u5185\u8FD8\u6CA1\u6709\u6536\u5230\u8FC7\u6A21\u578B\u54CD\u5E94\uFF08\u5FEB\u7167\u9A7B\u7559\u5185\u5B58\uFF0C\u91CD\u542F\u5373\u6E05\u7A7A\uFF09",404)})),r.get("/blobs/:hash",x(e,async(o)=>{let i=L(o,"hash"),s=/^[0-9a-f]{64}$/.test(i)?e.runtime.store.blob(i):void 0;if(!s)return A(o,"not_found","no such blob",404);let a=/^image\/(png|jpeg|gif|webp|avif|bmp)$/.test(s.mime),c=F(o),u=s.data,l=a?s.mime:"application/octet-stream";if(o.req.query("variant")==="thumbnail"){if(!a)return A(o,"bad_request","unsupported thumbnail format",400);try{u=new Uint8Array(await n.get(i,()=>s.data)),l="image/webp"}catch{return A(o,"bad_request","thumbnail unavailable; retry or open the original image",422)}}return c.set("content-type",l),c.set("cache-control","private, max-age=31536000, immutable"),c.set("x-content-type-options","nosniff"),c.set("content-security-policy","default-src 'none'; sandbox"),new Response(u,{headers:c})})),r.get("/sessions/:id/entries",x(e,(o)=>{let i=e.runtime.get(L(o,"id"));if(!i)return A(o,"not_found","no such session",404);let s=(h)=>Number(o.req.query(h)??Ba),a=o.req.query("images")!=="ref",c=o.req.query("around");if(c!==void 0){let h=Number(c),b=s("before"),T=s("after");if(![h,b,T].every(Number.isSafeInteger)||h<1||b<0||T<0)return A(o,"bad_request","invalid around/before/after",400);return R(o,i.entriesAround(h,Math.min(b,2000),Math.min(T,2000),a))}let u=o.req.query("from");if(u!==void 0){let h=Number(u),b=Number(o.req.query("limit")??300);if(!Number.isSafeInteger(h)||h<1||!Number.isSafeInteger(b)||b<1)return A(o,"bad_request","invalid from/limit",400);return R(o,i.entriesFrom(h,Math.min(b,2000),a))}let l=o.req.query("tail");if(l!==void 0){let h=Number(l);if(!Number.isSafeInteger(h)||h<1)return A(o,"bad_request","invalid tail",400);let b=e.runtime.store.truncationEpoch(i.id),T={entries:i.replayEntries(Math.min(h,2000),a),truncationEpoch:b};return R(o,T)}let p=o.req.query("before");if(p!==void 0){let h=Number(p),b=Number(o.req.query("limit")??300);if(!Number.isSafeInteger(h)||h<1||!Number.isSafeInteger(b)||b<1)return A(o,"bad_request","invalid before/limit",400);return R(o,i.entriesBefore(h,Math.min(b,2000),a))}let v=Number(o.req.query("after")??0);return R(o,i.entries(v,void 0,a))})),r.post("/sessions/:id/prompt",Ro(e,!1)),r.post("/sessions/:id/steer",Ro(e,!0)),r.post("/sessions/:id/unsteer",x(e,async(o)=>{let i=e.runtime.get(L(o,"id"));if(!i)return A(o,"not_found","no such session",404);let s=await C(o);if(!Number.isSafeInteger(s.seq)||s.seq<1)return A(o,"bad_request","invalid seq",400);if(!i.unsteer(s.seq))return A(o,"bad_request","\u5F15\u5BFC\u6D88\u606F\u5DF2\u9001\u8FBE\u6A21\u578B\u6216\u4E0D\u53EF\u64A4\u56DE",409);return R(o,{ok:!0})})),r.post("/sessions/:id/abort",x(e,(o)=>{let i=e.runtime.get(L(o,"id"));if(!i)return A(o,"not_found","no such session",404);return i.abort(),R(o,{ok:!0})})),r}var Ka=1000,xo=new WeakMap;function Ro(e,r){return x(e,async(n)=>{let o=e.runtime.get(L(n,"id"));if(!o)return A(n,"not_found","no such session",404);o.assertWritable();let i=e.runtime.plugins.pin();try{let u=await i.invoke("session.input",{error:o.info().parentID?"Direct input to a managed session is unavailable":void 0},o);if(u.error)return A(n,"bad_request",u.error,400)}finally{await i.release()}let s=await C(n),a=typeof s.text==="string"?s.text:"";if(s.attachments!==void 0){if(!Array.isArray(s.attachments)||s.attachments.length>ut||!s.attachments.every(Pt))return A(n,"bad_request","invalid attachments",400)}let c=s.attachments?.length?s.attachments:void 0;if(!a.trim()&&!c)return A(n,"bad_request","text is required",400);if(typeof s.id==="string"&&s.id){let u=xo.get(e.runtime)??new Set;xo.set(e.runtime,u);let l=`${o.id}:${s.id}`;if(u.has(l))return R(n,o.info());if(u.add(l),u.size>Ka)u.delete(u.values().next().value??l)}if(r||s.steer)o.steer(a,c);else o.prompt(a,c);return R(n,o.info())})}function To(e){let r=new D;return r.get("/tool-loading",x(e,async(n)=>{await e.runtime.initialize();let o=n.req.query("sessionID"),i=o?e.runtime.get(o):void 0;if(o&&!i)throw new d("no such session");let s=i?await i.toolLoadingInfo():e.runtime.toolLoading.partition(e.runtime.tools.list());return R(n,{settings:e.runtime.toolLoading.settings(),tools:s})})),r.patch("/tool-loading",x(e,async(n)=>{let o=await C(n);try{return R(n,e.runtime.toolLoading.update(o))}catch(i){throw new t(i instanceof Error?i.message:"Invalid tool loading settings")}})),r}function ko(e){let r=new D,n=e.tunnel,o=new nt(e.runtime.options.dataDir);if(r.get("/cloudflare",x(e,(i)=>R(i,{connected:!!o.credentials}),{localOnly:!0})),r.put("/cloudflare",x(e,async(i)=>{if(!e.authEnabled)throw new t("\u5173\u95ED\u8BA4\u8BC1\u65F6\u4E0D\u80FD\u8FDE\u63A5 Cloudflare");let s=await C(i);return await o.connect(s.token,s.account),R(i,{connected:!0})},{localOnly:!0})),!n)return r;return r.get("/tunnel",x(e,(i)=>R(i,n.inspectStatus()),{localOnly:!0})),r.put("/tunnel",x(e,async(i)=>{if(!e.authEnabled)throw new t("\u5DF2\u7528 --no-auth \u5173\u95ED\u8BA4\u8BC1\uFF0C\u4E0D\u80FD\u5F00\u542F\u8FDC\u7A0B\u8BBF\u95EE");return R(i,await n.save(await C(i)))},{localOnly:!0})),r.put("/tunnel/cloudflare",x(e,async(i)=>{if(!e.authEnabled)throw new t("\u5173\u95ED\u8BA4\u8BC1\u65F6\u4E0D\u80FD\u8FDE\u63A5 Cloudflare");let s=await C(i);return R(i,await n.connectCloudflare(s.token))},{localOnly:!0})),r.post("/tunnel/refresh",x(e,async(i)=>R(i,await n.refreshManagement()),{localOnly:!0})),r.put("/tunnel/managed",x(e,async(i)=>{if(!e.authEnabled)throw new t("\u5173\u95ED\u8BA4\u8BC1\u65F6\u4E0D\u80FD\u4FEE\u6539\u8FDC\u7A0B\u8BBF\u95EE");return R(i,await n.configureManaged(await C(i)))},{localOnly:!0})),r.put("/tunnel/managed-access",x(e,async(i)=>{if(!e.authEnabled)throw new t("\u5173\u95ED\u8BA4\u8BC1\u65F6\u4E0D\u80FD\u4FEE\u6539\u8FDC\u7A0B\u8BBF\u95EE");return R(i,await n.configureManagedAccess(await C(i)))},{localOnly:!0})),r.post("/tunnel/login",x(e,(i)=>{if(!e.authEnabled)throw new t("\u5DF2\u7528 --no-auth \u5173\u95ED\u8BA4\u8BC1\uFF0C\u4E0D\u80FD\u5F00\u542F\u8FDC\u7A0B\u8BBF\u95EE");return R(i,n.startLogin())},{localOnly:!0})),r.delete("/tunnel/login",x(e,(i)=>R(i,n.cancelLogin()),{localOnly:!0})),r.post("/tunnel/provision",x(e,async(i)=>{if(!e.authEnabled)throw new t("\u5DF2\u7528 --no-auth \u5173\u95ED\u8BA4\u8BC1\uFF0C\u4E0D\u80FD\u5F00\u542F\u8FDC\u7A0B\u8BBF\u95EE");return R(i,await n.provision(await C(i)))},{localOnly:!0})),r.put("/tunnel/access",x(e,async(i)=>{let s=await C(i);return R(i,await n.setAccess(s.access??null))},{localOnly:!0})),r.delete("/tunnel",x(e,async(i)=>R(i,await n.remove()),{localOnly:!0})),r}function Eo(e){let r=new D,n=e.updates;if(!n)return r;return r.get("/update",x(e,(o)=>R(o,n.status()))),r.post("/update/check",x(e,async(o)=>R(o,await n.check()))),r.post("/update/apply",x(e,async(o)=>{if(!n.status().canApply)return A(o,"bad_request","this installation cannot update itself",400);return R(o,await n.apply())})),r.post("/update/pull",x(e,async(o)=>{if(!n.status().source)return A(o,"bad_request","this installation cannot pull source",400);return R(o,await n.pull())})),r}function Po(e){let r=new WeakSet;e={...e,internalRequest:(i)=>r.has(i)};let n=new D;e.runtime.http={baseUrl:null,auth:e.authEnabled?"token":"none",async request(i){r.add(i);try{return await n.fetch(i)}finally{r.delete(i)}}};let o=Zn({contentTypeFilter:/^application\/json/});return n.use("/api/*",(i,s)=>r.has(i.req.raw)||i.req.path.startsWith("/api/remote-access/proxy/")?s():o(i,s)),n.route("/api",po(e)),n.route("/api",ro(e)),n.route("/api",To(e)),n.route("/api",ho(e)),n.route("/api",mo(e)),n.route("/api",yo(e)),n.route("/api",wo(e)),n.route("/api",Eo(e)),n.route("/api",ko(e)),n.route("/api",bo(e)),n.route("/api",to(e)),n.route("/api",go(e)),n.route("/api",Ao(e)),n.route("/api",fo(e)),n.route("/api",vo(e)),n.route("/api",no(e)),n.all("/api/*",async(i)=>{if(i.req.method==="OPTIONS")return et(i,e);if(!e.runtime.plugins.hasRoute(i.req.raw)){if(await e.runtime.initialize(),!e.runtime.plugins.hasRoute(i.req.raw))return A(i,"not_found","not found",404)}let s=e.runtime.plugins.isPublicRoute(i.req.raw);return x(e,async(a)=>{await e.runtime.initialize();let c=await e.runtime.plugins.route(a.req.raw);if(!c)return A(a,"not_found","not found",404);let u=a.req.header("origin");if(u)c.headers.set("access-control-allow-origin",u),c.headers.set("vary","origin");let l=e.authEnabled&&!s?e.auth.verify(j(a.req.raw)):void 0;if(!l)return c;return tt(e.auth,l,c)},{public:s})(i)}),n}var Ga=1e4,Va=5000;function Lo(e){let{runtime:r}=e,n=new Fe(e.dataDir),o=e.remoteAccess??new Xe(e.dataDir),i=e.network,s=new Set,a={name:"basalt",version:e.version,protocol:Mr,auth:e.auth,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,shell:r.serverShell()},c=!e.auth&&Ee(e.host),u=(S,E,M={})=>{if(c&&!er(E))return!1;let O=new URL(E.url).hostname.toLowerCase(),W=e.tunnel?.publicURL(),Z=W?new URL(W).hostname.toLowerCase():void 0,ee=Me("0.0.0.0",e.port).map((mt)=>mt.address);if(!Ee(O)&&O!==e.host.toLowerCase()&&O!==Z&&!ee.includes(O)&&!e.allowedHosts?.some((mt)=>mt.toLowerCase()===O))return!1;if(!S)return!0;let $e=new URL(E.url);if(S===$e.origin||Qa(S,$e))return!0;if(e.tunnel?.publicURL()===S)return!0;if(e.auth&&M.wildcard!==!1&&Do(S))return!0;return M.wildcard!==!1&&e.origins.includes("*")||e.origins.includes(S)},l,p=async(S)=>{let E=e.tunnel?.access();if(!E)return!1;let M=`${E.teamDomain}/${E.audience}`;if(l?.key!==M)l={key:M,value:Nt(E)};return l.value.denies(S)},v,h=!1,b=new Map,T=new WeakMap,_=Po({runtime:r,auth:n,authEnabled:e.auth,info:a,allowed:u,requestIP:(S)=>(T.get(S)??v)?.requestIP(S)?.address,requestConnection:(S)=>{let E=(T.get(S)??v)?.requestIP(S);return E?`${E.address}:${E.port}`:void 0},modelProviders:e.modelProviders,network:i?{manager:i,runtime:()=>({host:e.host,port:v?.port??e.port,auth:e.auth,lanActive:h,addresses:Me("0.0.0.0",v?.port??e.port).filter((S)=>b.has(S.address)),hostOverride:e.networkHostOverride}),save:(S)=>i.save(S,ue)}:void 0,providerAuth:e.providerAuth,proxy:e.proxy,proxyTargets:e.proxyTargets,updates:e.updates,restart:e.restart,shutdown:e.shutdown,autostart:e.autostart,tunnel:e.tunnel,remoteAccess:o,accessDenied:p,approveLocalPairing:e.approveLocalPairing,cliSecret:e.cliSecret,disableTimeout:(S)=>(T.get(S)??v)?.timeout(S,0),heartbeatMs:e.heartbeatMs}),k=(S,E)=>{S.send(JSON.stringify(E))},q=r.subscribe((S)=>{if(S.type==="aborted")return;let E=S,M=S.type==="entry"||S.type==="draft"||S.type==="truncated"||S.type==="entry_removed"?S.sessionID:void 0,O=S.type==="entry"&&S.entry.type==="run"&&S.entry.state==="end"?{type:"run_end",sessionID:S.sessionID,entry:S.entry}:void 0;for(let W of r.connections.values()){if(!M||W.sessions.has(M))W.send(E);if(O)W.send(O)}}),I=async(S,E)=>{if(T.set(S,E),await p(S))return new Response(null,{status:403});if(!u(S.headers.get("origin"),S))return new Response("origin not allowed",{status:403});let M=new URL(S.url).pathname,O=M==="/api/ws"?void 0:r.plugins.websocket(M);if(M!=="/api/ws"&&!O)return new Response("not found",{status:404});let W=K({requestIP:(Z)=>E.requestIP(Z)?.address},S);if(E.upgrade(S,{data:{authed:!1,localManagement:W,subscriptions:new Set,pluginRoute:O}}))return;return new Response("expected websocket",{status:400})},N=e.web&&!e.development?Bun.serve({hostname:"127.0.0.1",port:0,development:!1,routes:{"/*":e.web},fetch:()=>new Response("not found",{status:404})}):void 0,U=Object.fromEntries(Object.entries(e.webStatic??{}).map(([S,E])=>[S,async(M)=>{if(await p(M))return new Response(null,{status:403});return E(M)}])),J={};if(N)J["/*"]=async(S)=>{if(await p(S))return new Response(null,{status:403});let E=new URL(S.url),M=new URL(N.url);return M.pathname=E.pathname,M.search=E.search,fetch(M,{method:S.method,headers:S.headers,redirect:"manual",decompress:!1})};else if(e.web)J["/*"]=e.web;let oe={hostname:e.host,...i&&e.networkHostOverride===void 0?{reusePort:!0}:{},idleTimeout:e.idleTimeout??120,development:e.development?{hmr:!0,console:!1}:!1,routes:{"/api/ws":I,"/api/*":(S,E)=>(T.set(S,E),S.headers.get("upgrade")?.toLowerCase()==="websocket"?I(S,E):_.fetch(S)),...U,...J},fetch(S,E){if(S.url.includes("/api/"))return T.set(S,E),_.fetch(S);return new Response("not found",{status:404})},websocket:{open(S){s.add(S),S.data.helloTimer=setTimeout(()=>{if(!S.data.authed)S.close(4401,"hello timeout")},Ga)},async close(S){clearTimeout(S.data.helloTimer),s.delete(S);try{await S.data.connection?.dispose()}finally{await S.data.pluginConnection?.close()}},async message(S,E){if(S.data.authed&&S.data.pluginConnection){if(S.data.expires!==void 0&&Date.now()>=S.data.expires){S.close(4401,"authentication expired");return}await S.data.pluginConnection.message(String(E));return}let M;try{if(M=JSON.parse(String(E)),!M||typeof M!=="object"||typeof M.type!=="string")throw Error("Invalid client message")}catch{if(k(S,{type:"error",code:"bad_request",message:"invalid JSON"}),!S.data.authed)S.close(4400,"invalid hello");return}if(M.type==="hello"){if(M.protocol!==Mr){k(S,{type:"error",code:"protocol_mismatch",message:`server speaks protocol ${Mr}, client ${M.protocol}`}),S.close(4400,"protocol mismatch");return}let W=e.auth?n.verify(M.token):void 0;if(e.auth&&!W){k(S,{type:"error",code:"unauthorized",message:"missing or invalid token"}),S.close(4401,"unauthorized");return}if(S.data.authed){S.close(4400,"already authenticated");return}if(clearTimeout(S.data.helloTimer),S.data.authed=!0,S.data.deviceID=W?.id,S.data.expires=W?.token.expires,S.data.connection=qe(r,{deviceID:W?.id,expires:W?.token.expires},S.data.subscriptions,(Z)=>k(S,Z),(Z,ee)=>{S.data.authed=!1,S.close(Z,ee)}),k(S,{type:"welcome",server:{...a,localManagement:S.data.localManagement}}),S.data.pluginRoute){let Z={send(ee){if(S.data.expires!==void 0&&Date.now()>=S.data.expires){S.close(4401,"authentication expired");return}if(S.data.authed&&s.has(S))S.send(ee)},close(ee,$e){S.close(ee,$e)}};S.data.pluginConnection=S.data.pluginRoute.connect(Z);try{await S.data.pluginConnection.open()}catch(ee){console.error("\u63D2\u4EF6 WebSocket \u8FDE\u63A5\u521D\u59CB\u5316\u5931\u8D25\uFF1A",ee),S.close(1011,"plugin connection failed")}}return}if(!S.data.authed){S.close(4401,"hello first");return}if(S.data.expires!==void 0&&Date.now()>=S.data.expires){S.close(4401,"authentication expired");return}let O=S.data.connection;if(O&&(M.type==="subscribe"||M.type==="unsubscribe"))try{await O.enqueue(()=>ve(r,O,M),M.sessionID)}catch(W){if(!(W instanceof t)&&!(W instanceof d))throw W;O.send({type:"error",code:W instanceof d?"not_found":"bad_request",message:W.message})}}}};function xe(){if(!h||!v)return;let S=v.port??e.port,E=Me("0.0.0.0",S),M=new Set(E.map((O)=>O.address));for(let[O,W]of b){if(M.has(O))continue;b.delete(O),je(W,!0)}for(let{address:O}of E){if(b.has(O))continue;let W=Bun.serve({...oe,hostname:O,port:S});b.set(O,W)}}function ue(S){if(!S.lanEnabled){let M=[...b.values()];if(h=!1,b.clear(),M.length===0)return;for(let W of M)je(W,!1);setTimeout(()=>{for(let W of M)je(W,!0)},300).unref?.();return}if(!v)throw Error("\u672C\u673A\u670D\u52A1\u5C1A\u672A\u542F\u52A8\uFF0C\u65E0\u6CD5\u5F00\u542F\u5C40\u57DF\u7F51\u8BBF\u95EE\u3002");let E=!h;h=!0;try{xe()}catch(M){if(E){h=!1;for(let O of b.values())je(O,!0);b.clear()}throw Error("\u5F00\u542F\u5C40\u57DF\u7F51\u76D1\u542C\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7AEF\u53E3\u5360\u7528\u548C\u7CFB\u7EDF\u7F51\u7EDC\u6743\u9650\u540E\u91CD\u8BD5\u3002",{cause:M})}}let Re=e.fallbackPort?100:1,X=e.port,wr;for(let S=0;S<Re;S++)try{v=Bun.serve({...oe,port:X});break}catch(E){wr=E;let M=E instanceof Error&&"code"in E&&E.code==="EADDRINUSE"||E instanceof Error&&E.message.includes("EADDRINUSE");if(e.fallbackPort&&M){X++;continue}throw N?.stop(!0),q(),E}if(!v)throw N?.stop(!0),q(),wr??Error(`Could not bind to any port starting from ${e.port}`);if(i?.settings().lanEnabled&&e.networkHostOverride===void 0)ue(i.settings());let _o=n.onRevoke((S)=>{for(let E of r.connections.values())if(E.deviceID===S)E.close(4401,"authentication revoked")}),Co=setInterval(()=>{for(let S of r.connections.values())if("expires"in S&&typeof S.expires==="number"&&Date.now()>=S.expires)S.close(4401,"authentication expired")},1000),br=setInterval(()=>{try{xe()}catch(S){console.error("\u5237\u65B0\u5C40\u57DF\u7F51\u76D1\u542C\u5931\u8D25\uFF0C\u5C06\u5728\u4E0B\u4E00\u6B21\u5DE1\u68C0\u65F6\u91CD\u8BD5\uFF1A",S)}},Va);br.unref?.();let Y=e.host;if(Y==="0.0.0.0")Y="127.0.0.1";if(Y==="::")Y="::1";if(Y.includes(":")&&!Y.startsWith("["))Y=`[${Y}]`;let Sr=`http://${Y}:${v.port}`,pt=r.http;if(pt)pt.baseUrl=Sr;let ht=e.development&&e.tunnel?Rn(Sr,p):void 0,Ae=new URL(v.url);if(Ae.hostname==="0.0.0.0")Ae.hostname="127.0.0.1";if(Ae.hostname==="[::]")Ae.hostname="[::1]";return{server:v,auth:n,url:Ae.toString().replace(/\/$/,""),tunnelPort:ht?ht.port:v.port,async stop(){for(let S of b.values())je(S,!0);if(b.clear(),clearInterval(br),await o.stop(),ht?.stop(),N?.stop(!0),r.http===pt)r.http=void 0;q(),_o(),clearInterval(Co);for(let S of s)clearTimeout(S.data.helloTimer);for(let S of r.connections.values())S.close(1001,"server stopping");v.stop(!0),await r.plugins.idle()}}}function je(e,r){e.stop(r).catch((n)=>console.error("\u505C\u6B62\u5C40\u57DF\u7F51\u76D1\u542C\u5931\u8D25\uFF1A",n))}function Qa(e,r){try{let n=new URL(e);return n.protocol===r.protocol&&n.port===r.port&&Ee(n.hostname)&&Ee(r.hostname)}catch{return!1}}export{P,Le,Yt,Xa,oa,Mo,Oo,Fn,Xt,Lo};
|