@qitqode/qitqode-android-arm64 0.1.24 → 0.1.26
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/bundle/{chunk-gn9p1d50.js → chunk-01gwb793.js} +1 -1
- package/bundle/{chunk-4kse3awh.js → chunk-0304b7xg.js} +1 -1
- package/bundle/{chunk-k9d927xe.js → chunk-05amr7y9.js} +1 -1
- package/bundle/{chunk-am73j1bt.js → chunk-06x1p3t4.js} +1 -1
- package/bundle/{chunk-9798jffg.js → chunk-07net7s8.js} +1 -1
- package/bundle/chunk-08y06vgt.js +3 -0
- package/bundle/chunk-09ecxdmd.js +2 -0
- package/bundle/{chunk-6mscvf6y.js → chunk-0cehm5fn.js} +1 -1
- package/bundle/chunk-0jaj2g7x.js +2 -0
- package/bundle/{chunk-7gczzccz.js → chunk-0m2tj2h9.js} +1 -1
- package/bundle/{chunk-srf73nm4.js → chunk-0mekr486.js} +1 -1
- package/bundle/{chunk-gen6f3dn.js → chunk-0ndvy0nh.js} +2 -2
- package/bundle/chunk-0nr2925m.js +2 -0
- package/bundle/chunk-0vqrakhw.js +3 -0
- package/bundle/{chunk-vf1r5ckp.js → chunk-0w5npkgr.js} +1 -1
- package/bundle/chunk-0wbq1y92.js +2 -0
- package/bundle/chunk-12pxszgn.js +2 -0
- package/bundle/chunk-1337582e.js +2 -0
- package/bundle/{chunk-hxgb0y1w.js → chunk-14ag9ea0.js} +1 -1
- package/bundle/chunk-182jf8fz.js +2 -0
- package/bundle/chunk-1ht3zcsh.js +2 -0
- package/bundle/{chunk-fhng5her.js → chunk-1n4w8dya.js} +2 -2
- package/bundle/{chunk-g7vkkmsk.js → chunk-1qbm1k9y.js} +3 -3
- package/bundle/{chunk-apq38bt4.js → chunk-1xkwm21b.js} +3 -3
- package/bundle/{chunk-3tkp27x7.js → chunk-1xpx1t40.js} +2 -2
- package/bundle/{chunk-w1atxyz0.js → chunk-1yx4jesj.js} +1 -1
- package/bundle/chunk-25zkavr0.js +2 -0
- package/bundle/{chunk-4k149ews.js → chunk-28vnspd4.js} +1 -1
- package/bundle/chunk-2cm91ktc.js +3 -0
- package/bundle/chunk-2jfd82jk.js +2 -0
- package/bundle/{chunk-ve5gb789.js → chunk-2jn2hd12.js} +2 -2
- package/bundle/chunk-2k7bbzj2.js +2 -0
- package/bundle/{chunk-7yf15a3a.js → chunk-2kdn66xt.js} +1 -1
- package/bundle/{chunk-99n6czag.js → chunk-2q76qax6.js} +2 -2
- package/bundle/{chunk-8pe047p0.js → chunk-2sy1wx99.js} +1 -1
- package/bundle/{chunk-8651hq0k.js → chunk-2yb59jwr.js} +1 -1
- package/bundle/chunk-30081kwd.js +2 -0
- package/bundle/{chunk-g0v9g37f.js → chunk-32zrch7h.js} +1 -1
- package/bundle/{chunk-7y3y3j51.js → chunk-3bb7y9pq.js} +2 -2
- package/bundle/{chunk-jz3aav8a.js → chunk-3kdhvq0p.js} +2 -2
- package/bundle/{chunk-m8djypsy.js → chunk-3rgct4bd.js} +1 -1
- package/bundle/{chunk-frdc3ysq.js → chunk-3s0d17xe.js} +1 -1
- package/bundle/chunk-3vag59se.js +2 -0
- package/bundle/{chunk-j1a64ade.js → chunk-3w64fpwn.js} +2 -2
- package/bundle/chunk-3x5v6sjw.js +2 -0
- package/bundle/{chunk-hqg5qbxk.js → chunk-3zn71txs.js} +1 -1
- package/bundle/{chunk-3vbtra1j.js → chunk-41ftye7w.js} +1 -1
- package/bundle/chunk-43ep9d7a.js +2 -0
- package/bundle/chunk-48j09m6e.js +3 -0
- package/bundle/{chunk-6szvs3k9.js → chunk-4920vf6a.js} +1 -1
- package/bundle/{chunk-wa2ce2sg.js → chunk-49tqzsy0.js} +2 -2
- package/bundle/{chunk-cvchztkc.js → chunk-49ypxzfx.js} +1 -1
- package/bundle/{chunk-6nhje520.js → chunk-4k70wrhf.js} +1 -1
- package/bundle/{chunk-tk3bve0x.js → chunk-4nck07pc.js} +2 -2
- package/bundle/chunk-4qqja22v.js +2 -0
- package/bundle/{chunk-23geekk5.js → chunk-54pk7nna.js} +1 -1
- package/bundle/{chunk-ewyk4py6.js → chunk-56pwz1kk.js} +1 -1
- package/bundle/{chunk-2y8qz8te.js → chunk-56qm8xpt.js} +1 -1
- package/bundle/{chunk-y3n31nnx.js → chunk-58gp7wbg.js} +2 -2
- package/bundle/{chunk-9easaxy7.js → chunk-5dm3p5r6.js} +1 -1
- package/bundle/chunk-5gazgxt5.js +2 -0
- package/bundle/{chunk-0ae5q6ck.js → chunk-5jtd006j.js} +2 -2
- package/bundle/{chunk-t488d66k.js → chunk-5mec6cde.js} +1 -1
- package/bundle/{chunk-gvzfffr4.js → chunk-5yaahmjb.js} +1 -1
- package/bundle/{chunk-jbd9k041.js → chunk-5ymj2q6j.js} +2 -2
- package/bundle/{chunk-ebjhggdw.js → chunk-613kegcn.js} +1 -1
- package/bundle/chunk-63znhwx0.js +2 -0
- package/bundle/{chunk-zavtsfxz.js → chunk-6fpfr8tk.js} +1 -1
- package/bundle/{chunk-0pvbk8ks.js → chunk-6h2faxs9.js} +2 -2
- package/bundle/chunk-6hmyy7n6.js +2 -0
- package/bundle/{chunk-78bajmqm.js → chunk-6nk3wx6f.js} +1 -1
- package/bundle/{chunk-1jsywey3.js → chunk-6nkcfncg.js} +1 -1
- package/bundle/{chunk-ps543k72.js → chunk-6s2f5sv4.js} +1 -1
- package/bundle/{chunk-dcx8hjbs.js → chunk-6vb26adv.js} +1 -1
- package/bundle/{chunk-r48g0kaq.js → chunk-6wdwwpsc.js} +2 -2
- package/bundle/{chunk-8r79zf3y.js → chunk-77e1wh0j.js} +2 -2
- package/bundle/chunk-7dyddrpk.js +2 -0
- package/bundle/{chunk-4d1a547n.js → chunk-7e1aw8rw.js} +1 -1
- package/bundle/{chunk-ac202abt.js → chunk-7ez3ye6e.js} +1 -1
- package/bundle/{chunk-wfnk2vsd.js → chunk-7fmy4cvn.js} +1 -1
- package/bundle/{chunk-82gs5cmn.js → chunk-7n2kpqh5.js} +1 -1
- package/bundle/chunk-7penjsgq.js +2 -0
- package/bundle/chunk-7qxn24qa.js +3 -0
- package/bundle/{chunk-4q9w2yve.js → chunk-7rxsj310.js} +2 -2
- package/bundle/{chunk-dkv2mg97.js → chunk-7ryv0f5h.js} +1 -1
- package/bundle/chunk-7t5gzkj6.js +2 -0
- package/bundle/{chunk-84gnbzky.js → chunk-7tbvr236.js} +1 -1
- package/bundle/{chunk-8cr7ks31.js → chunk-81engf0t.js} +1 -1
- package/bundle/{chunk-cy2586rv.js → chunk-880msfsd.js} +1 -1
- package/bundle/chunk-89vgt8vq.js +2 -0
- package/bundle/{chunk-vftqwdpg.js → chunk-8ahpk8td.js} +1 -1
- package/bundle/{chunk-9f7y0dj0.js → chunk-8bzwgcjb.js} +1 -1
- package/bundle/chunk-8e8n82f9.js +2 -0
- package/bundle/{chunk-xj73j10a.js → chunk-91khd3fq.js} +1 -1
- package/bundle/chunk-97exhw9j.js +2 -0
- package/bundle/chunk-9cvkaht5.js +2 -0
- package/bundle/{chunk-1jh5p5qw.js → chunk-9p83me3p.js} +2 -2
- package/bundle/{chunk-ygj1cy0n.js → chunk-9qtf8khv.js} +1 -1
- package/bundle/{chunk-kaeyhw2n.js → chunk-9wm41z2f.js} +2 -2
- package/bundle/chunk-9zrwbxx0.js +3 -0
- package/bundle/{chunk-q6fbyvpq.js → chunk-admgf65a.js} +1 -1
- package/bundle/{chunk-spm1yy6w.js → chunk-afhg3w2j.js} +1 -1
- package/bundle/chunk-akdvstd9.js +2 -0
- package/bundle/{chunk-w7p2x973.js → chunk-atbm0pnt.js} +2 -2
- package/bundle/chunk-ave2e4sa.js +2 -0
- package/bundle/chunk-axnwehc7.js +2 -0
- package/bundle/{chunk-ns0pswww.js → chunk-b79k456s.js} +1 -1
- package/bundle/chunk-bmzyxspj.js +2 -0
- package/bundle/{chunk-9sy9ws1w.js → chunk-bse8p94q.js} +1 -1
- package/bundle/chunk-bvaqpfv8.js +2 -0
- package/bundle/{chunk-gf4ek7rv.js → chunk-c0k8j498.js} +1 -1
- package/bundle/{chunk-pyq01301.js → chunk-cbmw8fy2.js} +1 -1
- package/bundle/{chunk-cesrhm09.js → chunk-cn10hn58.js} +1 -1
- package/bundle/{chunk-gc9q0x8z.js → chunk-cqhpbfcn.js} +3 -3
- package/bundle/{chunk-jegn6jc3.js → chunk-cr06m77n.js} +2 -2
- package/bundle/{chunk-3wzqs241.js → chunk-crap29f6.js} +1 -1
- package/bundle/chunk-cxb05cdg.js +2 -0
- package/bundle/chunk-cxe92z5c.js +2 -0
- package/bundle/{chunk-b643cra9.js → chunk-cyjzqa5p.js} +195 -195
- package/bundle/{chunk-0w4v0fbs.js → chunk-d2n09yvh.js} +2 -2
- package/bundle/{chunk-fm4xa6yx.js → chunk-d31yrcrn.js} +2 -2
- package/bundle/chunk-d5wp85kw.js +2 -0
- package/bundle/{chunk-6j0365q3.js → chunk-dazye86e.js} +2 -2
- package/bundle/chunk-dm5xnb4t.js +2 -0
- package/bundle/chunk-dpeqsvan.js +2 -0
- package/bundle/chunk-drxtmg5c.js +2 -0
- package/bundle/{chunk-k16hzy2q.js → chunk-dv5zf5gz.js} +1 -1
- package/bundle/{chunk-2qcndbxv.js → chunk-e57d1he9.js} +1 -1
- package/bundle/{chunk-1d64dywx.js → chunk-e58pdw5k.js} +2 -2
- package/bundle/chunk-e9pfdjcy.js +2 -0
- package/bundle/chunk-ejn5hfzd.js +2 -0
- package/bundle/{chunk-hg563h5r.js → chunk-ek1fawsj.js} +2 -2
- package/bundle/{chunk-rvvfs9ps.js → chunk-eq33vmze.js} +1 -1
- package/bundle/{chunk-6sdh1q7g.js → chunk-eqaym8gm.js} +1 -1
- package/bundle/chunk-ernd18jb.js +2 -0
- package/bundle/{chunk-evqxvhdb.js → chunk-ewvgbg68.js} +1 -1
- package/bundle/{chunk-wf09j72q.js → chunk-f3c9667r.js} +2 -2
- package/bundle/{chunk-9nx8hm57.js → chunk-f3rrd2p6.js} +1 -1
- package/bundle/chunk-f416n3mp.js +14 -0
- package/bundle/{chunk-hh3w51wp.js → chunk-f6y7a5w3.js} +2 -2
- package/bundle/{chunk-zeh481tm.js → chunk-fd9zrmhr.js} +2 -2
- package/bundle/chunk-ff9b4cg8.js +2 -0
- package/bundle/{chunk-bas6x25m.js → chunk-fffj9447.js} +2 -2
- package/bundle/{chunk-5y8efy5b.js → chunk-fk3praj7.js} +1 -1
- package/bundle/{chunk-ecwz9nhs.js → chunk-fk8cctjy.js} +2 -2
- package/bundle/{chunk-1y9t7nxn.js → chunk-fkat2pw6.js} +1 -1
- package/bundle/chunk-fpff6a4q.js +2 -0
- package/bundle/chunk-fvy5w4dh.js +7 -0
- package/bundle/{chunk-2gxjjqfx.js → chunk-fx7w497c.js} +1 -1
- package/bundle/{chunk-5rkmhzq0.js → chunk-fxb6vjcb.js} +2 -2
- package/bundle/{chunk-9xvctnjr.js → chunk-g4qwkcdv.js} +1 -1
- package/bundle/{chunk-2eardzxs.js → chunk-g6dgc5af.js} +1 -1
- package/bundle/{chunk-2mmspnr3.js → chunk-g7vahvkz.js} +1 -1
- package/bundle/chunk-g8wvr7a1.js +3 -0
- package/bundle/{chunk-21ejqv4v.js → chunk-gaxbbxk6.js} +1 -1
- package/bundle/chunk-gq361kdt.js +2 -0
- package/bundle/{chunk-n1chdwrs.js → chunk-gxa2r4zc.js} +1 -1
- package/bundle/{chunk-p54bzjtv.js → chunk-h56jxxvj.js} +1 -1
- package/bundle/{chunk-2z6fzwyc.js → chunk-hb4d06q0.js} +2 -2
- package/bundle/chunk-hbagpppv.js +2 -0
- package/bundle/chunk-hf473xav.js +2 -0
- package/bundle/{chunk-gff87y4n.js → chunk-hjratj6g.js} +1 -1
- package/bundle/{chunk-y2jmtfdh.js → chunk-hk8j5ht8.js} +2 -2
- package/bundle/{chunk-jr8qcf99.js → chunk-hkmb3zer.js} +2 -2
- package/bundle/chunk-hr88054m.js +2 -0
- package/bundle/{chunk-ep8zn49w.js → chunk-hybq019j.js} +2 -2
- package/bundle/{chunk-1xyn0sp2.js → chunk-hyckncza.js} +2 -2
- package/bundle/{chunk-wj6aq50n.js → chunk-hz1hd1bd.js} +1 -1
- package/bundle/{chunk-zp2ffbc2.js → chunk-j0ftbmex.js} +2 -2
- package/bundle/chunk-j3czd7v2.js +28 -0
- package/bundle/{chunk-0w0jfzb4.js → chunk-j7zs1yg2.js} +1 -1
- package/bundle/{chunk-xv8gnkh5.js → chunk-j87bvp1b.js} +1 -1
- package/bundle/chunk-j9m2d6t5.js +2 -0
- package/bundle/chunk-jd9edy2s.js +2 -0
- package/bundle/{chunk-4tn69nqs.js → chunk-jdkxeqw5.js} +1 -1
- package/bundle/chunk-jwtdbx31.js +2 -0
- package/bundle/chunk-jzcz92pq.js +8 -0
- package/bundle/{chunk-5h2hcp46.js → chunk-k7h6tfzj.js} +1 -1
- package/bundle/{chunk-dann9gfq.js → chunk-kbg3k1az.js} +1 -1
- package/bundle/{chunk-va4davgy.js → chunk-kbjwdv1x.js} +259 -253
- package/bundle/{chunk-j1veq3zr.js → chunk-kbyk7hyn.js} +2 -2
- package/bundle/{chunk-jr9xnvjq.js → chunk-kfk1zqc1.js} +1 -1
- package/bundle/{chunk-9jf67xb0.js → chunk-kkdgzeva.js} +2 -2
- package/bundle/{chunk-9rqrm9y8.js → chunk-kn318ev4.js} +1 -1
- package/bundle/{chunk-pv8jcpnf.js → chunk-kp84yba1.js} +1 -1
- package/bundle/{chunk-b8ag61vj.js → chunk-kpnfndkg.js} +1 -1
- package/bundle/chunk-krkxrej2.js +2 -0
- package/bundle/{chunk-ms1fd6h4.js → chunk-kvz0vzsn.js} +1 -1
- package/bundle/chunk-m26mcy8p.js +2 -0
- package/bundle/chunk-m62wgqp1.js +2 -0
- package/bundle/chunk-m7txgh5w.js +2 -0
- package/bundle/chunk-m84cn9c6.js +2 -0
- package/bundle/{chunk-kr0fsqas.js → chunk-md7vpe1e.js} +1 -1
- package/bundle/{chunk-yz7rqzby.js → chunk-mg239rc3.js} +3 -3
- package/bundle/chunk-mvc7pvtq.js +2 -0
- package/bundle/{chunk-tsn1jkr7.js → chunk-n07rsssz.js} +1 -1
- package/bundle/{chunk-8717htya.js → chunk-n10atvac.js} +1 -1
- package/bundle/chunk-nfp9xtca.js +3 -0
- package/bundle/{chunk-fdezde1z.js → chunk-ngz5xw45.js} +1 -1
- package/bundle/{chunk-7mhffm9f.js → chunk-njzpswgt.js} +183 -183
- package/bundle/{chunk-najzfhb2.js → chunk-nszqy06d.js} +1 -1
- package/bundle/{chunk-q3x4x2tq.js → chunk-nxjbbq5h.js} +1 -1
- package/bundle/{chunk-jmjg8d8a.js → chunk-p0k4sv89.js} +4 -4
- package/bundle/{chunk-bf146hz2.js → chunk-p31yg62z.js} +2 -2
- package/bundle/chunk-p5t9mq8r.js +2 -0
- package/bundle/chunk-pfbykat1.js +2 -0
- package/bundle/{chunk-bd21p9zz.js → chunk-pfn1db1m.js} +2 -2
- package/bundle/{chunk-1fnmkm0z.js → chunk-pjbbdm96.js} +2 -2
- package/bundle/{chunk-k9g77a02.js → chunk-pnj8s20t.js} +1 -1
- package/bundle/{chunk-a5zjrwqy.js → chunk-ppvmy940.js} +2 -2
- package/bundle/{chunk-r3yqe7x0.js → chunk-ptf09vmp.js} +1 -1
- package/bundle/{chunk-sjrmhd3e.js → chunk-q2exgz82.js} +1 -1
- package/bundle/{chunk-te1zfpzv.js → chunk-qan3kwbv.js} +1 -1
- package/bundle/{chunk-7tgm8wp5.js → chunk-qb5qemtp.js} +1 -1
- package/bundle/chunk-qd0nvn4z.js +2 -0
- package/bundle/chunk-qh99kv2j.js +2 -0
- package/bundle/{chunk-kc3hpmr2.js → chunk-qkwhgfjt.js} +2 -2
- package/bundle/{chunk-5kmfnkzv.js → chunk-qm9ezq93.js} +1 -1
- package/bundle/chunk-qmhcbdkg.js +8 -0
- package/bundle/{chunk-7a6p7dfx.js → chunk-qngs31yf.js} +1 -1
- package/bundle/{chunk-hbnr0j7h.js → chunk-qpv4438m.js} +2 -2
- package/bundle/{chunk-hv4nhx6q.js → chunk-qq71akpw.js} +2 -2
- package/bundle/chunk-qyrafh4m.js +2 -0
- package/bundle/{chunk-17ggas8k.js → chunk-r1yqmd4y.js} +1 -1
- package/bundle/chunk-rc37cw86.js +2 -0
- package/bundle/{chunk-xccs5c50.js → chunk-rf625fxx.js} +1 -1
- package/bundle/chunk-rmpty636.js +2 -0
- package/bundle/{chunk-9pe4agdz.js → chunk-rs0nx844.js} +2 -2
- package/bundle/{chunk-9vcw33dv.js → chunk-rvrjw0fy.js} +1 -1
- package/bundle/{chunk-jpygkh1c.js → chunk-rz54qjew.js} +1 -1
- package/bundle/{chunk-a9y27zd2.js → chunk-rze20q68.js} +1 -1
- package/bundle/{chunk-hg9nk090.js → chunk-s1h0k1yj.js} +1 -1
- package/bundle/{chunk-hh4c02fh.js → chunk-s2za1y84.js} +1 -1
- package/bundle/chunk-s3wjwxme.js +2 -0
- package/bundle/chunk-s4ncnbgd.js +2 -0
- package/bundle/{chunk-p4hpr8d7.js → chunk-s54c8fpf.js} +1 -1
- package/bundle/{chunk-0pbt75ev.js → chunk-s5krbdvd.js} +1 -1
- package/bundle/{chunk-wmw2gne9.js → chunk-s86fj82v.js} +2 -2
- package/bundle/{chunk-qywwj58s.js → chunk-sdsggxm4.js} +2 -2
- package/bundle/{chunk-r7xp0xcn.js → chunk-se195e52.js} +2 -2
- package/bundle/chunk-snz3w30x.js +2 -0
- package/bundle/chunk-srw748gr.js +2 -0
- package/bundle/{chunk-mj24ntn9.js → chunk-st74db4c.js} +1 -1
- package/bundle/{chunk-0rtshz2r.js → chunk-t1vtdgd6.js} +1 -1
- package/bundle/{chunk-6dxaty1v.js → chunk-t6xm49ea.js} +1 -1
- package/bundle/{chunk-f819a7ec.js → chunk-t7tstr83.js} +1 -1
- package/bundle/{chunk-v2kyarwz.js → chunk-tedrfa7d.js} +2 -2
- package/bundle/{chunk-zfnbk5gy.js → chunk-tfggzzqw.js} +1 -1
- package/bundle/chunk-tn167yyz.js +2 -0
- package/bundle/{chunk-d56zc21w.js → chunk-txty44v2.js} +1 -1
- package/bundle/{chunk-b6m4yyww.js → chunk-tyy4gx61.js} +1 -1
- package/bundle/chunk-v1xwe58d.js +2 -0
- package/bundle/{chunk-vvypb02q.js → chunk-vh05n2x3.js} +1 -1
- package/bundle/{chunk-agdfqncf.js → chunk-vpqd0t8a.js} +2 -2
- package/bundle/chunk-vrfegg5f.js +2 -0
- package/bundle/{chunk-tzc4jkzg.js → chunk-vthm5q05.js} +1 -1
- package/bundle/{chunk-6g3m7yxf.js → chunk-vw673y0t.js} +2 -2
- package/bundle/{chunk-3tdqsm5c.js → chunk-vx837ete.js} +1 -1
- package/bundle/{chunk-hjbks7r9.js → chunk-vy9xre57.js} +1 -1
- package/bundle/{chunk-x6z2b63w.js → chunk-vyjsng14.js} +1 -1
- package/bundle/{chunk-ftk58wxe.js → chunk-vztxv9dj.js} +1 -1
- package/bundle/{chunk-1p34bx7c.js → chunk-w01gjnty.js} +2 -2
- package/bundle/chunk-w12tky28.js +2 -0
- package/bundle/{chunk-t6w96xq2.js → chunk-w2gpgapp.js} +1 -1
- package/bundle/{chunk-gn7xgd4c.js → chunk-w3pzv615.js} +1 -1
- package/bundle/chunk-w4hbw37v.js +3 -0
- package/bundle/chunk-w9ct698t.js +2 -0
- package/bundle/{chunk-8ace31r2.js → chunk-wefjbwv6.js} +1 -1
- package/bundle/{chunk-sgtgvzv6.js → chunk-wg42cxrw.js} +1 -1
- package/bundle/{chunk-02txthqv.js → chunk-wg5dv21f.js} +2 -2
- package/bundle/chunk-wms4skr9.js +11 -0
- package/bundle/chunk-wr5hdsst.js +9 -0
- package/bundle/chunk-wxnqgh8t.js +2 -0
- package/bundle/chunk-wzmte7sy.js +3 -0
- package/bundle/chunk-x0h1jdxt.js +2 -0
- package/bundle/{chunk-ha1w0xzh.js → chunk-x36jhtex.js} +1 -1
- package/bundle/{chunk-yzdty5t9.js → chunk-x3931we7.js} +2 -2
- package/bundle/{chunk-v7r9np94.js → chunk-x3z8q0ep.js} +1 -1
- package/bundle/chunk-x6hsmnhz.js +2 -0
- package/bundle/{chunk-fkvccmgk.js → chunk-xak2r993.js} +2 -2
- package/bundle/{chunk-c31k8yh0.js → chunk-xc3fadkh.js} +1 -1
- package/bundle/{chunk-hh9a709t.js → chunk-xcs2jbz9.js} +1 -1
- package/bundle/{chunk-qw2hgs5b.js → chunk-xdv9xt0y.js} +2 -2
- package/bundle/{chunk-dgzyn27r.js → chunk-xdwej3ae.js} +1 -1
- package/bundle/chunk-xg9e0enb.js +2 -0
- package/bundle/{chunk-pfhp78cr.js → chunk-xqxpjbqk.js} +1 -1
- package/bundle/chunk-xtxxb25n.js +2 -0
- package/bundle/{chunk-8h9r6c8g.js → chunk-y2ch07yv.js} +2 -2
- package/bundle/chunk-y3s7sh1e.js +2 -0
- package/bundle/chunk-ydvheqw9.js +2 -0
- package/bundle/{chunk-0z3z0gk1.js → chunk-ygwe0vf1.js} +2 -2
- package/bundle/{chunk-58enbars.js → chunk-ykxde207.js} +2 -2
- package/bundle/{chunk-dkm7x8rj.js → chunk-ynfbz3sz.js} +2 -2
- package/bundle/{chunk-2wp1w8cy.js → chunk-yqtfvgrp.js} +1 -1
- package/bundle/{chunk-edvcz2gd.js → chunk-yt1yk4j1.js} +1 -1
- package/bundle/{chunk-yh174jhg.js → chunk-yvj021eg.js} +2 -2
- package/bundle/chunk-yxnq0d7k.js +2 -0
- package/bundle/{chunk-e346x00p.js → chunk-z2m09m4w.js} +1 -1
- package/bundle/{chunk-f3kjp838.js → chunk-z2q3mg73.js} +2 -2
- package/bundle/chunk-z2raegj9.js +2 -0
- package/bundle/{chunk-y1srca0c.js → chunk-z3hj5bfd.js} +2 -2
- package/bundle/chunk-z3pyhmg6.js +2 -0
- package/bundle/{chunk-3nhqd8wg.js → chunk-z4ae6jmb.js} +3 -3
- package/bundle/{chunk-7dckfame.js → chunk-z559gc3n.js} +1 -1
- package/bundle/chunk-z7pg6sw1.js +2 -0
- package/bundle/chunk-z84376c6.js +2 -0
- package/bundle/{chunk-ktmazmas.js → chunk-ze00x1xb.js} +2 -2
- package/bundle/{chunk-pb7rnkke.js → chunk-zjvzc0my.js} +1 -1
- package/bundle/chunk-zn8th65r.js +2 -0
- package/bundle/{chunk-sswbfqcq.js → chunk-zna6neq5.js} +1 -1
- package/bundle/chunk-ztv1brgn.js +2 -0
- package/bundle/{chunk-s9amvacw.js → chunk-zvsafnkp.js} +2 -2
- package/bundle/chunk-zyxvd9fj.js +2 -0
- package/bundle/index.js +16 -16
- package/bundle/parser.worker.js +2 -2
- package/bundle/worker.js +1 -1
- package/package.json +1 -1
- package/bundle/chunk-0bvde0cx.js +0 -2
- package/bundle/chunk-0kbxnazj.js +0 -2
- package/bundle/chunk-19z5q33z.js +0 -2
- package/bundle/chunk-1a0wnwna.js +0 -2
- package/bundle/chunk-1ddm2wxv.js +0 -2
- package/bundle/chunk-1fk4vsmc.js +0 -2
- package/bundle/chunk-1j2f9nd5.js +0 -2
- package/bundle/chunk-27s736an.js +0 -2
- package/bundle/chunk-2j17xrzj.js +0 -2
- package/bundle/chunk-2zca3nak.js +0 -2
- package/bundle/chunk-2zcvcfq4.js +0 -2
- package/bundle/chunk-38hwkfj5.js +0 -2
- package/bundle/chunk-3afqxvsn.js +0 -2
- package/bundle/chunk-3avc1ppg.js +0 -7
- package/bundle/chunk-3v4vtah1.js +0 -2
- package/bundle/chunk-3ypk0j2f.js +0 -2
- package/bundle/chunk-3z1y040p.js +0 -3
- package/bundle/chunk-4aykrj51.js +0 -9
- package/bundle/chunk-4dtbmqmq.js +0 -2
- package/bundle/chunk-4zjb6rps.js +0 -2
- package/bundle/chunk-5hkcjgwh.js +0 -2
- package/bundle/chunk-5snrz263.js +0 -2
- package/bundle/chunk-653c0mxr.js +0 -11
- package/bundle/chunk-6av7hrrk.js +0 -7
- package/bundle/chunk-6bswn7w5.js +0 -2
- package/bundle/chunk-6epghftw.js +0 -2
- package/bundle/chunk-6jjhxh8p.js +0 -2
- package/bundle/chunk-6ws7xyc5.js +0 -2
- package/bundle/chunk-7g28zhar.js +0 -2
- package/bundle/chunk-7v02b2ms.js +0 -2
- package/bundle/chunk-7vmp2034.js +0 -2
- package/bundle/chunk-7wxrypkr.js +0 -2
- package/bundle/chunk-8kk9gvdy.js +0 -2
- package/bundle/chunk-8ygpp4y3.js +0 -2
- package/bundle/chunk-95q60g1p.js +0 -2
- package/bundle/chunk-9mjbenja.js +0 -2
- package/bundle/chunk-9vn1gy8h.js +0 -2
- package/bundle/chunk-ajp3f08k.js +0 -2
- package/bundle/chunk-aptkpdkc.js +0 -2
- package/bundle/chunk-bky5a42k.js +0 -3
- package/bundle/chunk-bry94ar5.js +0 -2
- package/bundle/chunk-btzyvqkf.js +0 -2
- package/bundle/chunk-c94pjdfh.js +0 -2
- package/bundle/chunk-cct9ds5c.js +0 -2
- package/bundle/chunk-czn535v0.js +0 -2
- package/bundle/chunk-d7wd5hz1.js +0 -2
- package/bundle/chunk-d86cmjrp.js +0 -2
- package/bundle/chunk-dnq65xvn.js +0 -2
- package/bundle/chunk-dpqv8rtn.js +0 -2
- package/bundle/chunk-e9mh7s3z.js +0 -2
- package/bundle/chunk-ek2y5f6g.js +0 -2
- package/bundle/chunk-epdsay73.js +0 -2
- package/bundle/chunk-f89gntcy.js +0 -3
- package/bundle/chunk-ffnsn7tv.js +0 -2
- package/bundle/chunk-fkezc7ew.js +0 -2
- package/bundle/chunk-fsxddgj0.js +0 -2
- package/bundle/chunk-gbcsfg6v.js +0 -2
- package/bundle/chunk-gfmz85hp.js +0 -2
- package/bundle/chunk-gk63k4t6.js +0 -2
- package/bundle/chunk-j0vf8s12.js +0 -2
- package/bundle/chunk-j1bxt69x.js +0 -2
- package/bundle/chunk-jcem8s30.js +0 -2
- package/bundle/chunk-jjwjb9w0.js +0 -3
- package/bundle/chunk-jpham2a3.js +0 -2
- package/bundle/chunk-jzkymnr5.js +0 -2
- package/bundle/chunk-k0qtwnhb.js +0 -2
- package/bundle/chunk-k2rsky7z.js +0 -2
- package/bundle/chunk-kcetcysa.js +0 -2
- package/bundle/chunk-kjfc5v3s.js +0 -2
- package/bundle/chunk-kkvb2c2z.js +0 -8
- package/bundle/chunk-km2ayfyf.js +0 -2
- package/bundle/chunk-knrh89eb.js +0 -2
- package/bundle/chunk-ksqfjawv.js +0 -2
- package/bundle/chunk-mjhb1q0n.js +0 -3
- package/bundle/chunk-mxcger73.js +0 -2
- package/bundle/chunk-nazkrkeb.js +0 -2
- package/bundle/chunk-nk01s49e.js +0 -2
- package/bundle/chunk-ns8b7rx1.js +0 -2
- package/bundle/chunk-ny6vpkx2.js +0 -2
- package/bundle/chunk-q0dd3ak6.js +0 -3
- package/bundle/chunk-q2s057bm.js +0 -2
- package/bundle/chunk-q5cqg2c0.js +0 -28
- package/bundle/chunk-qk2wnp2x.js +0 -2
- package/bundle/chunk-r012q335.js +0 -3
- package/bundle/chunk-rbdjbgkb.js +0 -2
- package/bundle/chunk-rxjprhgh.js +0 -2
- package/bundle/chunk-s3w9bmze.js +0 -2
- package/bundle/chunk-s3zste1a.js +0 -2
- package/bundle/chunk-sbt7qmwm.js +0 -3
- package/bundle/chunk-sf6h44pb.js +0 -2
- package/bundle/chunk-sgvzxs7m.js +0 -2
- package/bundle/chunk-sp9bndyh.js +0 -2
- package/bundle/chunk-vavrczqm.js +0 -3
- package/bundle/chunk-vg4styg5.js +0 -2
- package/bundle/chunk-vh09hhcs.js +0 -2
- package/bundle/chunk-vhktpm0n.js +0 -2
- package/bundle/chunk-vzjcmwry.js +0 -14
- package/bundle/chunk-wtp0yvqw.js +0 -2
- package/bundle/chunk-xmzs7q66.js +0 -2
- package/bundle/chunk-xv80476w.js +0 -2
- package/bundle/chunk-yjvr0et1.js +0 -2
- package/bundle/chunk-zk8n8hnh.js +0 -3
- package/bundle/chunk-zx3kcfkj.js +0 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ag as In,bg as a2,cg as d2,dg as o2,eg as x2,fg as t2,gg as b2,hg as e2,ig as s2,jg as f2,kg as k2,ng as nA}from"./chunk-dazye86e.js";import{og as Er,pg as R2}from"./chunk-3bb7y9pq.js";import{Bg as P2,yg as U2}from"./chunk-wr5hdsst.js";import{Hg as Sc}from"./chunk-nfp9xtca.js";import{Jg as Ey}from"./chunk-ze00x1xb.js";import{Kg as fj}from"./chunk-sdsggxm4.js";import{$g as ai,Lg as Tl,Mg as zl,Ng as ui,Og as _n,Vg as Xr,Wg as hl,Xg as Km,Zg as Hm,_g as xi,ah as im,bh as mm,ch as _r,dh as bc,eh as y2,fh as ql,hh as tc,ih as _l,jh as Ml,kh as yn,lh as Ll,mh as gl,nh as b0,oh as Zm,ph as S2,qh as Dr,rh as jn,sh as Wr,uh as e}from"./chunk-kbjwdv1x.js";import{$j as lr,Aj as J2,Cj as f0,Dj as qn,Ej as K2,Ij as sj,Ik as qr,Jj as tr,Jk as _i,Kj as Zr,Kk as jA,Lj as Q1,Mj as yr,Nj as br,Oj as Si,Pj as pi,Pk as c2,Sj as Ym,Uk as ir,Vk as Cr,Wk as vr,Yk as w1,Zk as j0,_j as A2,ak as er,dl as J,el as mr,xk as Pn,yj as wr,yk as Qr,zj as Y2}from"./chunk-njzpswgt.js";import{gl as ul,ql as uI}from"./chunk-2cm91ktc.js";import{Dl as iA,El as b,Gl as Ci,Il as l0,Ml as Gr,Ol as M,rl as Lr,vl as tj,wl as nr,xl as Xi,yl as Ki}from"./chunk-ygwe0vf1.js";import{_l as yi}from"./chunk-1qbm1k9y.js";import{Fn as c0,cn as Li,en as dj,hn as d,jn as nm,kn as g2,ln as z2,pn as M2,qn as fn}from"./chunk-3rgct4bd.js";import{kp as rm,pp as D2}from"./chunk-qmhcbdkg.js";import{Dp as F}from"./chunk-vx837ete.js";import{Gr as tI,Hr as bI,Ir as Dn}from"./chunk-4nck07pc.js";import{Rr as sI,Sr as fI}from"./chunk-d2n09yvh.js";import{$r as Wn,As as k0,Bs as RI,Cs as eI,Ds as OI,Es as LI,Fs as qI,Gs as q1,Hs as Im,Yr as PI,ls as B0,ms as Pr,ns as CI,os as o0,ps as WI,qs as XI,rs as KI,ss as HI,ts as zr,us as Ql,vs as x0,ws as ZI,xs as VI,ys as YI,zs as JI}from"./chunk-f3c9667r.js";import{Ts as En}from"./chunk-z2q3mg73.js";import{$t as _,Rt as Vi,St as k,Ws as mA,gt as pI}from"./chunk-08y06vgt.js";import{du as m0,ou as kl,pu as yA,tu as Wi}from"./chunk-9p83me3p.js";import{vu as I}from"./chunk-48j09m6e.js";import{Pz as ji,oA as mI,pA as cI}from"./chunk-tedrfa7d.js";import{AD as Zi,AG as vm,AL as El,BC as II,BG as wm,BI as NI,CI as EI,CL as ml,DG as AI,DJ as DI,FF as g1,GL as X1,HG as Ti,HI as QI,HO as UI,II as S0,JF as Y0,KI as d1,LA as Ii,LG as SI,LI as A0,LN as gr,MI as t1,NA as Xl,NG as h0,NI as Al,NN as cl,OA as Fi,OI as Sl,ON as H0,PC as MI,PF as T,PI as b1,PL as Dm,QI as e1,RC as Mi,RG as R0,RI as W1,SA as o1,SI as ec,SN as g,TI as wl,UA as P1,UI as s1,UL as sc,XG as hi,XL as jm,ZC as O1,_C as L1,aD as K0,aH as vI,aL as T0,bL as Nl,cI as Pl,cM as Zn,fL as f1,gD as u1,gM as Cn,iH as Gl,iM as Fr,jB as gi,kC as Dl,mC as x1,nD as $r,nG as J0,nH as $m,nL as rI,oD as V0,oH as wI,pF as Sm,pH as Ul,pL as iI,qD as or,qI as C,qL as nI,rD as Ai,sC as k1,sD as O0,sH as z1,tC as p1,tG as t,uD as Um,uI as $I,uL as W0,vC as Qm,vD as Il,wD as vl,wI as GI,wL as X0,xD as Mr,xI as Ln,yD as Am,yI as Cl,yL as Pm,zD as a1}from"./chunk-ynfbz3sz.js";import{CP as jv,DP as rr,EP as Nr,GP as bi}from"./chunk-s2za1y84.js";var pm=rr((By)=>{Object.defineProperty(By,"__esModule",{value:!0});By.default=aA;var Ty=/[A-Z]/g;function hy(r){return r.toLowerCase()}function aA(r,i){let n=r.replace(Ty,hy),m=i.replace(Ty,hy);return n===m}});var Zc=rr((oy)=>{Object.defineProperty(oy,"__esModule",{value:!0});oy.DnsTxt=void 0;class Hc{constructor(r={}){this.binary=r?r.binary:!1}encode(r={}){return Object.entries(r).map(([i,n])=>{let m=`${i}=${n}`;return Buffer.from(m)})}decode(r){var i={};try{let m=r.toString().split(/=(.+)/),c=m[0],l=m[1];i[c]=l}catch(n){}return i}decodeAll(r){return r.filter((i)=>i.length>1).map((i)=>this.decode(i)).reduce((i,n)=>{var m=i;let[c]=Object.keys(n),[l]=Object.values(n);return m[c]=l,m},{})}}oy.DnsTxt=Hc;oy.default=Hc});var Vc=rr((py)=>{Object.defineProperty(py,"__esModule",{value:!0});py.toType=py.toString=void 0;var ky=(r)=>{return"_"+r},bA=(r)=>{return["name","protocol","subtype"].includes(r)},eA=(r)=>{let i={name:r.name,protocol:r.protocol,subtype:r.subtype};return Object.entries(i).filter(([m,c])=>bA(m)&&c!==void 0).reduce((m,[c,l])=>{switch(typeof l){case"object":l.map((y)=>m.push(ky(y)));break;default:m.push(ky(l));break}return m},[]).join(".")};py.toString=eA;var sA=(r)=>{let i=r.split("."),n;for(let m in i){if(i[m][0]!=="_")continue;i[m]=i[m].slice(1)}if(i.includes("sub"))n=i.shift(),i.shift();return{name:i.shift(),protocol:i.shift()||null,subtype:n}};py.toType=sA});var Jc=rr((ti)=>{var dy=ti&&ti.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ti,"__esModule",{value:!0});ti.Service=void 0;var ay=dy(bi("os")),rS=dy(Zc()),iS=bi("events"),nS=Vc(),um=".local";class Yc extends iS.EventEmitter{constructor(r){super();if(this.probe=!0,this.published=!1,this.activated=!1,this.destroyed=!1,this.txtService=new rS.default,!r.name)throw Error("ServiceConfig requires `name` property to be set");if(!r.type)throw Error("ServiceConfig requires `type` property to be set");if(!r.port)throw Error("ServiceConfig requires `port` property to be set");this.name=r.name.split(".").join("-"),this.protocol=r.protocol||"tcp",this.type=(0,nS.toString)({name:r.type,protocol:this.protocol}),this.port=r.port,this.host=r.host||ay.default.hostname(),this.fqdn=`${this.name}.${this.type}${um}`,this.txt=r.txt,this.subtypes=r.subtypes,this.disableIPv6=!!r.disableIPv6}records(){var r=[this.RecordPTR(this),this.RecordSRV(this),this.RecordTXT(this)];for(let n of this.subtypes||[])r.push(this.RecordSubtypePTR(this,n));let i=Object.values(ay.default.networkInterfaces());for(let n of i){let m=n;for(let c of m){if(c.internal||c.mac==="00:00:00:00:00:00")continue;switch(c.family){case"IPv4":r.push(this.RecordA(this,c.address));break;case"IPv6":if(this.disableIPv6)break;r.push(this.RecordAAAA(this,c.address));break}}}return r}RecordPTR(r){return{name:`${r.type}${um}`,type:"PTR",ttl:28800,data:r.fqdn}}RecordSubtypePTR(r,i){return{name:`_${i}._sub.${r.type}${um}`,type:"PTR",ttl:28800,data:`${r.name}.${r.type}${um}`}}RecordSRV(r){return{name:r.fqdn,type:"SRV",ttl:120,data:{port:r.port,target:r.host}}}RecordTXT(r){return{name:r.fqdn,type:"TXT",ttl:4500,data:this.txtService.encode(r.txt)}}RecordA(r,i){return{name:r.host,type:"A",ttl:120,data:i}}RecordAAAA(r,i){return{name:r.host,type:"AAAA",ttl:120,data:i}}}ti.Service=Yc;ti.default=Yc});var by=rr((ei)=>{var ty=ei&&ei.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ei,"__esModule",{value:!0});ei.Registry=void 0;var mS=ty(pm()),Rc=ty(Jc()),cS=3600000,lS=3,yS=function(){};class Oc{constructor(r){this.services=[],this.server=r}publish(r){function i(c,l,y){if(c.activated)return;if(c.activated=!0,l.services.push(c),!(c instanceof Rc.default))return;if(y===null||y===void 0?void 0:y.probe)l.probe(l.server.mdns,c,(j)=>{if(j){if(c.stop!==void 0)c.stop();console.log(Error("Service name is already in use on the network"));return}l.announce(l.server,c)});else l.announce(l.server,c)}function n(c,l,y){if(!y)y=yS;if(!c.activated)return process.nextTick(y);if(!(c instanceof Rc.default))return process.nextTick(y);l.teardown(l.server,c,y);let j=l.services.indexOf(c);if(j!==-1)l.services.splice(j,1)}let m=new Rc.default(r);return m.start=i.bind(null,m,this),m.stop=n.bind(null,m,this),m.start({probe:r.probe!==!1}),m}unpublishAll(r){this.teardown(this.server,this.services,r),this.services=[]}destroy(){this.services.map((r)=>r.destroyed=!0)}probe(r,i,n){var m=!1,c=0,l;let y=()=>{if(!i.activated||i.destroyed)return;r.query(i.fqdn,"ANY",function(){m=!0,l=setTimeout(++c<3?y:S,250),l.unref()})},j=(v)=>{if(!m)return;if(v.answers.some(A)||v.additionals.some(A))S(!0)},A=(v)=>{return(0,mS.default)(v.name,i.fqdn)},S=(v)=>{r.removeListener("response",j),clearTimeout(l),n(!!v)};r.on("response",j),setTimeout(y,Math.random()*250)}announce(r,i){var n=1000,m=i.records();r.register(m);let c=()=>{if(!i.activated||i.destroyed)return;r.mdns.respond(m,function(){if(!i.published)i.activated=!0,i.published=!0,i.emit("up");if(n=n*lS,n<cS&&!i.destroyed)setTimeout(c,n).unref()})};c()}teardown(r,i,n){if(!Array.isArray(i))i=[i];i=i.filter((c)=>c.activated);var m=i.flatMap(function(c){c.activated=!1;var l=c.records();return l.forEach((y)=>{y.ttl=0}),l});if(m.length===0)return n&&process.nextTick(n);r.unregister(m),r.mdns.respond(m,function(){if(i.forEach(function(c){c.published=!1}),typeof n==="function")n.apply(null,arguments)})}}ei.Registry=Oc;ei.default=Oc});var ey=rr((jS)=>{jS.toString=function(r){switch(r){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+r};jS.toType=function(r){switch(r.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}if(r.toUpperCase().startsWith("UNKNOWN_"))return parseInt(r.slice(8));return 0}});var sy=rr((SS)=>{SS.toString=function(r){switch(r){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+r};SS.toRcode=function(r){switch(r.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var fy=rr(($S)=>{$S.toString=function(r){switch(r){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+r};$S.toOpcode=function(r){switch(r.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var rj=rr((ES)=>{ES.toString=function(r){switch(r){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+r};ES.toClass=function(r){switch(r.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var ij=rr((US)=>{US.toString=function(r){switch(r){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}if(r<0)return null;return`OPTION_${r}`};US.toCode=function(r){if(typeof r==="number")return r;if(!r)return-1;switch(r.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let i=r.match(/_(\d+)$/);if(i)return parseInt(i[1],10);return-1}});var cj=rr((mj,Lc)=>{var nj=function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.decode=w,r.encode=v,r.familyOf=S,r.name=void 0,r.sizeOf=A,r.v6=r.v4=void 0;let i=/^(\d{1,3}\.){3,3}\d{1,3}$/,n=4,m=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,c=16,l={name:"v4",size:n,isFormat:(N)=>i.test(N),encode(N,E,Q){Q=~~Q,E=E||new Uint8Array(Q+n);let W=N.length,Z=0;for(let X=0;X<W;){let K=N.charCodeAt(X++);if(K===46)E[Q++]=Z,Z=0;else Z=Z*10+(K-48)}return E[Q]=Z,E},decode(N,E){return E=~~E,`${N[E++]}.${N[E++]}.${N[E++]}.${N[E]}`}};r.v4=l;let y={name:"v6",size:c,isFormat:(N)=>N.length>0&&m.test(N),encode(N,E,Q){Q=~~Q;let W=Q+c,Z=-1,X=0,K=0,R=!0,q=!1;E=E||new Uint8Array(Q+c);for(let z=0;z<N.length;z++){let L=N.charCodeAt(z);if(L===58){if(R){if(Z!==-1){if(Q<W)E[Q]=0;if(Q<W-1)E[Q+1]=0;Q+=2}else if(Q<W)Z=Q}else{if(q===!0){if(Q<W)E[Q]=K;Q++}else{if(Q<W)E[Q]=X>>8;if(Q<W-1)E[Q+1]=X&255;Q+=2}X=0,K=0}R=!0,q=!1}else if(L===46){if(Q<W)E[Q]=K;Q++,K=0,X=0,R=!1,q=!0}else{if(R=!1,L>=97)L-=87;else if(L>=65)L-=55;else L-=48,K=K*10+L;X=(X<<4)+L}}if(R===!1)if(q===!0){if(Q<W)E[Q]=K;Q++}else{if(Q<W)E[Q]=X>>8;if(Q<W-1)E[Q+1]=X&255;Q+=2}else if(Z===0){if(Q<W)E[Q]=0;if(Q<W-1)E[Q+1]=0;Q+=2}else if(Z!==-1){Q+=2;for(let z=Math.min(Q-1,W-1);z>=Z+2;z--)E[z]=E[z-2];E[Z]=0,E[Z+1]=0,Z=Q}if(Z!==Q&&Z!==-1){if(Q>W-2)Q=W-2;while(W>Z)E[--W]=Q<W&&Q>Z?E[--Q]:0}else while(Q<W)E[Q++]=0;return E},decode(N,E){E=~~E;let Q="";for(let W=0;W<c;W+=2){if(W!==0)Q+=":";Q+=(N[E+W]<<8|N[E+W+1]).toString(16)}return Q.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=y;let j="ip";r.name=j;function A(N){if(l.isFormat(N))return l.size;if(y.isFormat(N))return y.size;throw Error(`Invalid ip address: ${N}`)}function S(N){return A(N)===l.size?1:2}function v(N,E,Q){Q=~~Q;let W=A(N);if(typeof E==="function")E=E(Q+W);if(W===l.size)return l.encode(N,E,Q);return y.encode(N,E,Q)}function w(N,E,Q){if(E=~~E,Q=Q||N.length-E,Q===l.size)return l.decode(N,E,Q);if(Q===y.size)return y.decode(N,E,Q);throw Error(`Invalid buffer size needs to be ${l.size} for v4 or ${y.size} for v6.`)}return"default"in r?r.default:r}({});if(typeof define==="function"&&define.amd)define([],function(){return nj});else if(typeof Lc==="object"&&typeof mj==="object")Lc.exports=nj});var lj=rr((ZS)=>{var Y=bi("buffer").Buffer,Pi=ey(),WS=sy(),XS=fy(),dm=rj(),Fc=ij(),si=cj(),H=ZS.name={};H.encode=function(r,i,n,{mail:m=!1}={}){if(!i)i=Y.alloc(H.encodingLength(r));if(!n)n=0;let c=n,l=r.replace(/^\.|\.$/gm,"");if(l.length){let y=[];if(m){let j="";l.split(".").forEach((A)=>{if(A.endsWith("\\"))j+=(j.length?".":"")+A.slice(0,-1);else if(y.length===0&&j.length)y.push(j+"."+A);else y.push(A)})}else y=l.split(".");for(let j=0;j<y.length;j++){let A=i.write(y[j],n+1);i[n]=A,n+=A+1}}return i[n++]=0,H.encode.bytes=n-c,i};H.encode.bytes=0;H.decode=function(r,i,{mail:n=!1}={}){if(!i)i=0;let m=[],c=i,l=0,y=0,j=!1;while(!0){if(i>=r.length)throw Error("Cannot decode name (buffer overflow)");let A=r[i++];if(y+=j?0:1,A===0)break;else if((A&192)===0){if(i+A>r.length)throw Error("Cannot decode name (buffer overflow)");if(l+=A+1,l>254)throw Error("Cannot decode name (name too long)");let S=r.toString("utf-8",i,i+A);if(n)S=S.replace(/\./g,"\\.");m.push(S),i+=A,y+=j?0:A}else if((A&192)===192){if(i+1>r.length)throw Error("Cannot decode name (buffer overflow)");let S=r.readUInt16BE(i-1)-49152;if(S>=c)throw Error("Cannot decode name (bad pointer)");i=S,c=S,y+=j?0:1,j=!0}else throw Error("Cannot decode name (bad label)")}return H.decode.bytes=y,m.length===0?".":m.join(".")};H.decode.bytes=0;H.encodingLength=function(r){if(r==="."||r==="..")return 1;return Y.byteLength(r.replace(/^\.|\.$/gm,""))+2};var O={};O.encode=function(r,i,n){if(!i)i=Y.alloc(O.encodingLength(r));if(!n)n=0;let m=i.write(r,n+1);return i[n]=m,O.encode.bytes=m+1,i};O.encode.bytes=0;O.decode=function(r,i){if(!i)i=0;let n=r[i],m=r.toString("utf-8",i+1,i+1+n);return O.decode.bytes=n+1,m};O.decode.bytes=0;O.encodingLength=function(r){return Y.byteLength(r)+1};var ar={};ar.encode=function(r,i,n){if(!i)i=ar.encodingLength(r);if(!n)n=0;let m=(r.flags||0)&32767,c=r.type==="response"?32768:0;return i.writeUInt16BE(r.id||0,n),i.writeUInt16BE(m|c,n+2),i.writeUInt16BE(r.questions.length,n+4),i.writeUInt16BE(r.answers.length,n+6),i.writeUInt16BE(r.authorities.length,n+8),i.writeUInt16BE(r.additionals.length,n+10),i};ar.encode.bytes=12;ar.decode=function(r,i){if(!i)i=0;if(r.length<12)throw Error("Header must be 12 bytes");let n=r.readUInt16BE(i+2);return{id:r.readUInt16BE(i),type:n&32768?"response":"query",flags:n&32767,flag_qr:(n>>15&1)===1,opcode:XS.toString(n>>11&15),flag_aa:(n>>10&1)===1,flag_tc:(n>>9&1)===1,flag_rd:(n>>8&1)===1,flag_ra:(n>>7&1)===1,flag_z:(n>>6&1)===1,flag_ad:(n>>5&1)===1,flag_cd:(n>>4&1)===1,rcode:WS.toString(n&15),questions:Array(r.readUInt16BE(i+4)),answers:Array(r.readUInt16BE(i+6)),authorities:Array(r.readUInt16BE(i+8)),additionals:Array(r.readUInt16BE(i+10))}};ar.decode.bytes=12;ar.encodingLength=function(){return 12};var vi=ZS.unknown={};vi.encode=function(r,i,n){if(!i)i=Y.alloc(vi.encodingLength(r));if(!n)n=0;return i.writeUInt16BE(r.length,n),r.copy(i,n+2),vi.encode.bytes=r.length+2,i};vi.encode.bytes=0;vi.decode=function(r,i){if(!i)i=0;let n=r.readUInt16BE(i),m=r.slice(i+2,i+2+n);return vi.decode.bytes=n+2,m};vi.decode.bytes=0;vi.encodingLength=function(r){return r.length+2};var wi=ZS.ns={};wi.encode=function(r,i,n){if(!i)i=Y.alloc(wi.encodingLength(r));if(!n)n=0;return H.encode(r,i,n+2),i.writeUInt16BE(H.encode.bytes,n),wi.encode.bytes=H.encode.bytes+2,i};wi.encode.bytes=0;wi.decode=function(r,i){if(!i)i=0;let n=r.readUInt16BE(i),m=H.decode(r,i+2);return wi.decode.bytes=n+2,m};wi.decode.bytes=0;wi.encodingLength=function(r){return H.encodingLength(r)+2};var $i=ZS.soa={};$i.encode=function(r,i,n){if(!i)i=Y.alloc($i.encodingLength(r));if(!n)n=0;let m=n;return n+=2,H.encode(r.mname,i,n),n+=H.encode.bytes,H.encode(r.rname,i,n,{mail:!0}),n+=H.encode.bytes,i.writeUInt32BE(r.serial||0,n),n+=4,i.writeUInt32BE(r.refresh||0,n),n+=4,i.writeUInt32BE(r.retry||0,n),n+=4,i.writeUInt32BE(r.expire||0,n),n+=4,i.writeUInt32BE(r.minimum||0,n),n+=4,i.writeUInt16BE(n-m-2,m),$i.encode.bytes=n-m,i};$i.encode.bytes=0;$i.decode=function(r,i){if(!i)i=0;let n=i,m={};return i+=2,m.mname=H.decode(r,i),i+=H.decode.bytes,m.rname=H.decode(r,i,{mail:!0}),i+=H.decode.bytes,m.serial=r.readUInt32BE(i),i+=4,m.refresh=r.readUInt32BE(i),i+=4,m.retry=r.readUInt32BE(i),i+=4,m.expire=r.readUInt32BE(i),i+=4,m.minimum=r.readUInt32BE(i),i+=4,$i.decode.bytes=i-n,m};$i.decode.bytes=0;$i.encodingLength=function(r){return 22+H.encodingLength(r.mname)+H.encodingLength(r.rname)};var Gi=ZS.txt={};Gi.encode=function(r,i,n){if(!Array.isArray(r))r=[r];for(let c=0;c<r.length;c++){if(typeof r[c]==="string")r[c]=Y.from(r[c]);if(!Y.isBuffer(r[c]))throw Error("Must be a Buffer")}if(!i)i=Y.alloc(Gi.encodingLength(r));if(!n)n=0;let m=n;return n+=2,r.forEach(function(c){i[n++]=c.length,c.copy(i,n,0,c.length),n+=c.length}),i.writeUInt16BE(n-m-2,m),Gi.encode.bytes=n-m,i};Gi.encode.bytes=0;Gi.decode=function(r,i){if(!i)i=0;let n=i,m=r.readUInt16BE(i);i+=2;let c=[];while(m>0){let l=r[i++];if(--m,m<l)throw Error("Buffer overflow");c.push(r.slice(i,i+l)),i+=l,m-=l}return Gi.decode.bytes=i-n,c};Gi.decode.bytes=0;Gi.encodingLength=function(r){if(!Array.isArray(r))r=[r];let i=2;return r.forEach(function(n){if(typeof n==="string")i+=Y.byteLength(n)+1;else i+=n.length+1}),i};var Ni=ZS.null={};Ni.encode=function(r,i,n){if(!i)i=Y.alloc(Ni.encodingLength(r));if(!n)n=0;if(typeof r==="string")r=Y.from(r);if(!r)r=Y.alloc(0);let m=n;n+=2;let c=r.length;return r.copy(i,n,0,c),n+=c,i.writeUInt16BE(n-m-2,m),Ni.encode.bytes=n-m,i};Ni.encode.bytes=0;Ni.decode=function(r,i){if(!i)i=0;let n=i,m=r.readUInt16BE(i);i+=2;let c=r.slice(i,i+m);return i+=m,Ni.decode.bytes=i-n,c};Ni.decode.bytes=0;Ni.encodingLength=function(r){if(!r)return 2;return(Y.isBuffer(r)?r.length:Y.byteLength(r))+2};var Ei=ZS.hinfo={};Ei.encode=function(r,i,n){if(!i)i=Y.alloc(Ei.encodingLength(r));if(!n)n=0;let m=n;return n+=2,O.encode(r.cpu,i,n),n+=O.encode.bytes,O.encode(r.os,i,n),n+=O.encode.bytes,i.writeUInt16BE(n-m-2,m),Ei.encode.bytes=n-m,i};Ei.encode.bytes=0;Ei.decode=function(r,i){if(!i)i=0;let n=i,m={};return i+=2,m.cpu=O.decode(r,i),i+=O.decode.bytes,m.os=O.decode(r,i),i+=O.decode.bytes,Ei.decode.bytes=i-n,m};Ei.decode.bytes=0;Ei.encodingLength=function(r){return O.encodingLength(r.cpu)+O.encodingLength(r.os)+2};var pr=ZS.ptr={},KS=ZS.cname=pr,HS=ZS.dname=pr;pr.encode=function(r,i,n){if(!i)i=Y.alloc(pr.encodingLength(r));if(!n)n=0;return H.encode(r,i,n+2),i.writeUInt16BE(H.encode.bytes,n),pr.encode.bytes=H.encode.bytes+2,i};pr.encode.bytes=0;pr.decode=function(r,i){if(!i)i=0;let n=H.decode(r,i+2);return pr.decode.bytes=H.decode.bytes+2,n};pr.decode.bytes=0;pr.encodingLength=function(r){return H.encodingLength(r)+2};var Qi=ZS.srv={};Qi.encode=function(r,i,n){if(!i)i=Y.alloc(Qi.encodingLength(r));if(!n)n=0;i.writeUInt16BE(r.priority||0,n+2),i.writeUInt16BE(r.weight||0,n+4),i.writeUInt16BE(r.port||0,n+6),H.encode(r.target,i,n+8);let m=H.encode.bytes+6;return i.writeUInt16BE(m,n),Qi.encode.bytes=m+2,i};Qi.encode.bytes=0;Qi.decode=function(r,i){if(!i)i=0;let n=r.readUInt16BE(i),m={};return m.priority=r.readUInt16BE(i+2),m.weight=r.readUInt16BE(i+4),m.port=r.readUInt16BE(i+6),m.target=H.decode(r,i+8),Qi.decode.bytes=n+2,m};Qi.decode.bytes=0;Qi.encodingLength=function(r){return 8+H.encodingLength(r.target)};var Jr=ZS.caa={};Jr.ISSUER_CRITICAL=128;Jr.encode=function(r,i,n){let m=Jr.encodingLength(r);if(!i)i=Y.alloc(Jr.encodingLength(r));if(!n)n=0;if(r.issuerCritical)r.flags=Jr.ISSUER_CRITICAL;return i.writeUInt16BE(m-2,n),n+=2,i.writeUInt8(r.flags||0,n),n+=1,O.encode(r.tag,i,n),n+=O.encode.bytes,i.write(r.value,n),n+=Y.byteLength(r.value),Jr.encode.bytes=m,i};Jr.encode.bytes=0;Jr.decode=function(r,i){if(!i)i=0;let n=r.readUInt16BE(i);i+=2;let m=i,c={};return c.flags=r.readUInt8(i),i+=1,c.tag=O.decode(r,i),i+=O.decode.bytes,c.value=r.toString("utf-8",i,m+n),c.issuerCritical=!!(c.flags&Jr.ISSUER_CRITICAL),Jr.decode.bytes=n+2,c};Jr.decode.bytes=0;Jr.encodingLength=function(r){return O.encodingLength(r.tag)+O.encodingLength(r.value)+2};var Ri=ZS.mx={};Ri.encode=function(r,i,n){if(!i)i=Y.alloc(Ri.encodingLength(r));if(!n)n=0;let m=n;return n+=2,i.writeUInt16BE(r.preference||0,n),n+=2,H.encode(r.exchange,i,n),n+=H.encode.bytes,i.writeUInt16BE(n-m-2,m),Ri.encode.bytes=n-m,i};Ri.encode.bytes=0;Ri.decode=function(r,i){if(!i)i=0;let n=i,m={};return i+=2,m.preference=r.readUInt16BE(i),i+=2,m.exchange=H.decode(r,i),i+=H.decode.bytes,Ri.decode.bytes=i-n,m};Ri.encodingLength=function(r){return 4+H.encodingLength(r.exchange)};var Di=ZS.a={};Di.encode=function(r,i,n){if(!i)i=Y.alloc(Di.encodingLength(r));if(!n)n=0;return i.writeUInt16BE(4,n),n+=2,si.v4.encode(r,i,n),Di.encode.bytes=6,i};Di.encode.bytes=0;Di.decode=function(r,i){if(!i)i=0;i+=2;let n=si.v4.decode(r,i);return Di.decode.bytes=6,n};Di.decode.bytes=0;Di.encodingLength=function(){return 6};var Ui=ZS.aaaa={};Ui.encode=function(r,i,n){if(!i)i=Y.alloc(Ui.encodingLength(r));if(!n)n=0;return i.writeUInt16BE(16,n),n+=2,si.v6.encode(r,i,n),Ui.encode.bytes=18,i};Ui.encode.bytes=0;Ui.decode=function(r,i){if(!i)i=0;i+=2;let n=si.v6.decode(r,i);return Ui.decode.bytes=18,n};Ui.decode.bytes=0;Ui.encodingLength=function(){return 18};var Kr=ZS.option={};Kr.encode=function(r,i,n){if(!i)i=Y.alloc(Kr.encodingLength(r));if(!n)n=0;let m=n,c=Fc.toCode(r.code);if(i.writeUInt16BE(c,n),n+=2,r.data)i.writeUInt16BE(r.data.length,n),n+=2,r.data.copy(i,n),n+=r.data.length;else switch(c){case 8:let l=r.sourcePrefixLength||0,y=r.family||si.familyOf(r.ip),j=si.encode(r.ip,Y.alloc),A=Math.ceil(l/8);i.writeUInt16BE(A+4,n),n+=2,i.writeUInt16BE(y,n),n+=2,i.writeUInt8(l,n++),i.writeUInt8(r.scopePrefixLength||0,n++),j.copy(i,n,0,A),n+=A;break;case 11:if(r.timeout)i.writeUInt16BE(2,n),n+=2,i.writeUInt16BE(r.timeout,n),n+=2;else i.writeUInt16BE(0,n),n+=2;break;case 12:let S=r.length||0;i.writeUInt16BE(S,n),n+=2,i.fill(0,n,n+S),n+=S;break;case 14:let v=r.tags.length*2;i.writeUInt16BE(v,n),n+=2;for(let w of r.tags)i.writeUInt16BE(w,n),n+=2;break;default:throw Error(`Unknown roption code: ${r.code}`)}return Kr.encode.bytes=n-m,i};Kr.encode.bytes=0;Kr.decode=function(r,i){if(!i)i=0;let n={};n.code=r.readUInt16BE(i),n.type=Fc.toString(n.code),i+=2;let m=r.readUInt16BE(i);switch(i+=2,n.data=r.slice(i,i+m),n.code){case 8:n.family=r.readUInt16BE(i),i+=2,n.sourcePrefixLength=r.readUInt8(i++),n.scopePrefixLength=r.readUInt8(i++);let c=Y.alloc(n.family===1?4:16);r.copy(c,0,i,i+m-4),n.ip=si.decode(c);break;case 11:if(m>0)n.timeout=r.readUInt16BE(i),i+=2;break;case 14:n.tags=[];for(let l=0;l<m;l+=2)n.tags.push(r.readUInt16BE(i)),i+=2}return Kr.decode.bytes=m+4,n};Kr.decode.bytes=0;Kr.encodingLength=function(r){if(r.data)return r.data.length+4;switch(Fc.toCode(r.code)){case 8:let n=r.sourcePrefixLength||0;return Math.ceil(n/8)+8;case 11:return typeof r.timeout==="number"?6:4;case 12:return r.length+4;case 14:return 4+r.tags.length*2}throw Error(`Unknown roption code: ${r.code}`)};var Or=ZS.opt={};Or.encode=function(r,i,n){if(!i)i=Y.alloc(Or.encodingLength(r));if(!n)n=0;let m=n,c=$n(r,Kr);return i.writeUInt16BE(c,n),n=pn(r,Kr,i,n+2),Or.encode.bytes=n-m,i};Or.encode.bytes=0;Or.decode=function(r,i){if(!i)i=0;let n=i,m=[],c=r.readUInt16BE(i);i+=2;let l=0;while(c>0)m[l++]=Kr.decode(r,i),i+=Kr.decode.bytes,c-=Kr.decode.bytes;return Or.decode.bytes=i-n,m};Or.decode.bytes=0;Or.encodingLength=function(r){return 2+$n(r||[],Kr)};var Ur=ZS.dnskey={};Ur.PROTOCOL_DNSSEC=3;Ur.ZONE_KEY=128;Ur.SECURE_ENTRYPOINT=32768;Ur.encode=function(r,i,n){if(!i)i=Y.alloc(Ur.encodingLength(r));if(!n)n=0;let m=n,c=r.key;if(!Y.isBuffer(c))throw Error("Key must be a Buffer");return n+=2,i.writeUInt16BE(r.flags,n),n+=2,i.writeUInt8(Ur.PROTOCOL_DNSSEC,n),n+=1,i.writeUInt8(r.algorithm,n),n+=1,c.copy(i,n,0,c.length),n+=c.length,Ur.encode.bytes=n-m,i.writeUInt16BE(Ur.encode.bytes-2,m),i};Ur.encode.bytes=0;Ur.decode=function(r,i){if(!i)i=0;let n=i;var m={},c=r.readUInt16BE(i);if(i+=2,m.flags=r.readUInt16BE(i),i+=2,r.readUInt8(i)!==Ur.PROTOCOL_DNSSEC)throw Error("Protocol must be 3");return i+=1,m.algorithm=r.readUInt8(i),i+=1,m.key=r.slice(i,n+c+2),i+=m.key.length,Ur.decode.bytes=i-n,m};Ur.decode.bytes=0;Ur.encodingLength=function(r){return 6+Y.byteLength(r.key)};var sr=ZS.rrsig={};sr.encode=function(r,i,n){if(!i)i=Y.alloc(sr.encodingLength(r));if(!n)n=0;let m=n,c=r.signature;if(!Y.isBuffer(c))throw Error("Signature must be a Buffer");return n+=2,i.writeUInt16BE(Pi.toType(r.typeCovered),n),n+=2,i.writeUInt8(r.algorithm,n),n+=1,i.writeUInt8(r.labels,n),n+=1,i.writeUInt32BE(r.originalTTL,n),n+=4,i.writeUInt32BE(r.expiration,n),n+=4,i.writeUInt32BE(r.inception,n),n+=4,i.writeUInt16BE(r.keyTag,n),n+=2,H.encode(r.signersName,i,n),n+=H.encode.bytes,c.copy(i,n,0,c.length),n+=c.length,sr.encode.bytes=n-m,i.writeUInt16BE(sr.encode.bytes-2,m),i};sr.encode.bytes=0;sr.decode=function(r,i){if(!i)i=0;let n=i;var m={},c=r.readUInt16BE(i);return i+=2,m.typeCovered=Pi.toString(r.readUInt16BE(i)),i+=2,m.algorithm=r.readUInt8(i),i+=1,m.labels=r.readUInt8(i),i+=1,m.originalTTL=r.readUInt32BE(i),i+=4,m.expiration=r.readUInt32BE(i),i+=4,m.inception=r.readUInt32BE(i),i+=4,m.keyTag=r.readUInt16BE(i),i+=2,m.signersName=H.decode(r,i),i+=H.decode.bytes,m.signature=r.slice(i,n+c+2),i+=m.signature.length,sr.decode.bytes=i-n,m};sr.decode.bytes=0;sr.encodingLength=function(r){return 20+H.encodingLength(r.signersName)+Y.byteLength(r.signature)};var fr=ZS.rp={};fr.encode=function(r,i,n){if(!i)i=Y.alloc(fr.encodingLength(r));if(!n)n=0;let m=n;return n+=2,H.encode(r.mbox||".",i,n,{mail:!0}),n+=H.encode.bytes,H.encode(r.txt||".",i,n),n+=H.encode.bytes,fr.encode.bytes=n-m,i.writeUInt16BE(fr.encode.bytes-2,m),i};fr.encode.bytes=0;fr.decode=function(r,i){if(!i)i=0;let n=i,m={};return i+=2,m.mbox=H.decode(r,i,{mail:!0})||".",i+=H.decode.bytes,m.txt=H.decode(r,i)||".",i+=H.decode.bytes,fr.decode.bytes=i-n,m};fr.decode.bytes=0;fr.encodingLength=function(r){return 2+H.encodingLength(r.mbox||".")+H.encodingLength(r.txt||".")};var jr={};jr.encode=function(r,i,n){if(!i)i=Y.alloc(jr.encodingLength(r));if(!n)n=0;let m=n;var c=[];for(var l=0;l<r.length;l++){var y=Pi.toType(r[l]);if(c[y>>8]===void 0)c[y>>8]=[];c[y>>8][y>>3&31]|=1<<7-(y&7)}for(l=0;l<c.length;l++)if(c[l]!==void 0){var j=Y.from(c[l]);i.writeUInt8(l,n),n+=1,i.writeUInt8(j.length,n),n+=1,j.copy(i,n),n+=j.length}return jr.encode.bytes=n-m,i};jr.encode.bytes=0;jr.decode=function(r,i,n){if(!i)i=0;let m=i;var c=[];while(i-m<n){var l=r.readUInt8(i);i+=1;var y=r.readUInt8(i);i+=1;for(var j=0;j<y;j++){var A=r.readUInt8(i+j);for(var S=0;S<8;S++)if(A&1<<7-S){var v=Pi.toString(l<<8|j<<3|S);c.push(v)}}i+=y}return jr.decode.bytes=i-m,c};jr.decode.bytes=0;jr.encodingLength=function(r){var i=[];for(var n=0;n<r.length;n++){var m=Pi.toType(r[n]);i[m>>8]=Math.max(i[m>>8]||0,m&255)}var c=0;for(n=0;n<i.length;n++)if(i[n]!==void 0)c+=2+Math.ceil((i[n]+1)/8);return c};var ri=ZS.nsec={};ri.encode=function(r,i,n){if(!i)i=Y.alloc(ri.encodingLength(r));if(!n)n=0;let m=n;return n+=2,H.encode(r.nextDomain,i,n),n+=H.encode.bytes,jr.encode(r.rrtypes,i,n),n+=jr.encode.bytes,ri.encode.bytes=n-m,i.writeUInt16BE(ri.encode.bytes-2,m),i};ri.encode.bytes=0;ri.decode=function(r,i){if(!i)i=0;let n=i;var m={},c=r.readUInt16BE(i);return i+=2,m.nextDomain=H.decode(r,i),i+=H.decode.bytes,m.rrtypes=jr.decode(r,i,c-(i-n)),i+=jr.decode.bytes,ri.decode.bytes=i-n,m};ri.decode.bytes=0;ri.encodingLength=function(r){return 2+H.encodingLength(r.nextDomain)+jr.encodingLength(r.rrtypes)};var ii=ZS.nsec3={};ii.encode=function(r,i,n){if(!i)i=Y.alloc(ii.encodingLength(r));if(!n)n=0;let m=n,c=r.salt;if(!Y.isBuffer(c))throw Error("salt must be a Buffer");let l=r.nextDomain;if(!Y.isBuffer(l))throw Error("nextDomain must be a Buffer");return n+=2,i.writeUInt8(r.algorithm,n),n+=1,i.writeUInt8(r.flags,n),n+=1,i.writeUInt16BE(r.iterations,n),n+=2,i.writeUInt8(c.length,n),n+=1,c.copy(i,n,0,c.length),n+=c.length,i.writeUInt8(l.length,n),n+=1,l.copy(i,n,0,l.length),n+=l.length,jr.encode(r.rrtypes,i,n),n+=jr.encode.bytes,ii.encode.bytes=n-m,i.writeUInt16BE(ii.encode.bytes-2,m),i};ii.encode.bytes=0;ii.decode=function(r,i){if(!i)i=0;let n=i;var m={},c=r.readUInt16BE(i);i+=2,m.algorithm=r.readUInt8(i),i+=1,m.flags=r.readUInt8(i),i+=1,m.iterations=r.readUInt16BE(i),i+=2;let l=r.readUInt8(i);i+=1,m.salt=r.slice(i,i+l),i+=l;let y=r.readUInt8(i);return i+=1,m.nextDomain=r.slice(i,i+y),i+=y,m.rrtypes=jr.decode(r,i,c-(i-n)),i+=jr.decode.bytes,ii.decode.bytes=i-n,m};ii.decode.bytes=0;ii.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+jr.encodingLength(r.rrtypes)};var ni=ZS.ds={};ni.encode=function(r,i,n){if(!i)i=Y.alloc(ni.encodingLength(r));if(!n)n=0;let m=n,c=r.digest;if(!Y.isBuffer(c))throw Error("Digest must be a Buffer");return n+=2,i.writeUInt16BE(r.keyTag,n),n+=2,i.writeUInt8(r.algorithm,n),n+=1,i.writeUInt8(r.digestType,n),n+=1,c.copy(i,n,0,c.length),n+=c.length,ni.encode.bytes=n-m,i.writeUInt16BE(ni.encode.bytes-2,m),i};ni.encode.bytes=0;ni.decode=function(r,i){if(!i)i=0;let n=i;var m={},c=r.readUInt16BE(i);return i+=2,m.keyTag=r.readUInt16BE(i),i+=2,m.algorithm=r.readUInt8(i),i+=1,m.digestType=r.readUInt8(i),i+=1,m.digest=r.slice(i,n+c+2),i+=m.digest.length,ni.decode.bytes=i-n,m};ni.decode.bytes=0;ni.encodingLength=function(r){return 6+Y.byteLength(r.digest)};var Rr=ZS.sshfp={};Rr.getFingerprintLengthForHashType=function(i){switch(i){case 1:return 20;case 2:return 32}};Rr.encode=function(i,n,m){if(!n)n=Y.alloc(Rr.encodingLength(i));if(!m)m=0;let c=m;m+=2,n[m]=i.algorithm,m+=1,n[m]=i.hash,m+=1;let l=Y.from(i.fingerprint.toUpperCase(),"hex");if(l.length!==Rr.getFingerprintLengthForHashType(i.hash))throw Error("Invalid fingerprint length");return l.copy(n,m),m+=l.byteLength,Rr.encode.bytes=m-c,n.writeUInt16BE(Rr.encode.bytes-2,c),n};Rr.encode.bytes=0;Rr.decode=function(i,n){if(!n)n=0;let m=n,c={};n+=2,c.algorithm=i[n],n+=1,c.hash=i[n],n+=1;let l=Rr.getFingerprintLengthForHashType(c.hash);return c.fingerprint=i.slice(n,n+l).toString("hex").toUpperCase(),n+=l,Rr.decode.bytes=n-m,c};Rr.decode.bytes=0;Rr.encodingLength=function(r){return 4+Y.from(r.fingerprint,"hex").byteLength};var mi=ZS.naptr={};mi.encode=function(r,i,n){if(!i)i=Y.alloc(mi.encodingLength(r));if(!n)n=0;let m=n;return n+=2,i.writeUInt16BE(r.order||0,n),n+=2,i.writeUInt16BE(r.preference||0,n),n+=2,O.encode(r.flags,i,n),n+=O.encode.bytes,O.encode(r.services,i,n),n+=O.encode.bytes,O.encode(r.regexp,i,n),n+=O.encode.bytes,H.encode(r.replacement,i,n),n+=H.encode.bytes,mi.encode.bytes=n-m,i.writeUInt16BE(mi.encode.bytes-2,m),i};mi.encode.bytes=0;mi.decode=function(r,i){if(!i)i=0;let n=i,m={};return i+=2,m.order=r.readUInt16BE(i),i+=2,m.preference=r.readUInt16BE(i),i+=2,m.flags=O.decode(r,i),i+=O.decode.bytes,m.services=O.decode(r,i),i+=O.decode.bytes,m.regexp=O.decode(r,i),i+=O.decode.bytes,m.replacement=H.decode(r,i),i+=H.decode.bytes,mi.decode.bytes=i-n,m};mi.decode.bytes=0;mi.encodingLength=function(r){return O.encodingLength(r.flags)+O.encodingLength(r.services)+O.encodingLength(r.regexp)+H.encodingLength(r.replacement)+6};var ci=ZS.tlsa={};ci.encode=function(r,i,n){if(!i)i=Y.alloc(ci.encodingLength(r));if(!n)n=0;let m=n,c=r.certificate;if(!Y.isBuffer(c))throw Error("Certificate must be a Buffer");return n+=2,i.writeUInt8(r.usage,n),n+=1,i.writeUInt8(r.selector,n),n+=1,i.writeUInt8(r.matchingType,n),n+=1,c.copy(i,n,0,c.length),n+=c.length,ci.encode.bytes=n-m,i.writeUInt16BE(ci.encode.bytes-2,m),i};ci.encode.bytes=0;ci.decode=function(r,i){if(!i)i=0;let n=i,m={},c=r.readUInt16BE(i);return i+=2,m.usage=r.readUInt8(i),i+=1,m.selector=r.readUInt8(i),i+=1,m.matchingType=r.readUInt8(i),i+=1,m.certificate=r.slice(i,n+c+2),i+=m.certificate.length,ci.decode.bytes=i-n,m};ci.decode.bytes=0;ci.encodingLength=function(r){return 5+Y.byteLength(r.certificate)};var gc=ZS.record=function(r){switch(r.toUpperCase()){case"A":return Di;case"PTR":return pr;case"CNAME":return KS;case"DNAME":return HS;case"TXT":return Gi;case"NULL":return Ni;case"AAAA":return Ui;case"SRV":return Qi;case"HINFO":return Ei;case"CAA":return Jr;case"NS":return wi;case"SOA":return $i;case"MX":return Ri;case"OPT":return Or;case"DNSKEY":return Ur;case"RRSIG":return sr;case"RP":return fr;case"NSEC":return ri;case"NSEC3":return ii;case"SSHFP":return Rr;case"DS":return ni;case"NAPTR":return mi;case"TLSA":return ci}return vi},Sr=ZS.answer={};Sr.encode=function(r,i,n){if(!i)i=Y.alloc(Sr.encodingLength(r));if(!n)n=0;let m=n;if(H.encode(r.name,i,n),n+=H.encode.bytes,i.writeUInt16BE(Pi.toType(r.type),n),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw Error("OPT name must be root.");i.writeUInt16BE(r.udpPayloadSize||4096,n+2),i.writeUInt8(r.extendedRcode||0,n+4),i.writeUInt8(r.ednsVersion||0,n+5),i.writeUInt16BE(r.flags||0,n+6),n+=8,Or.encode(r.options||[],i,n),n+=Or.encode.bytes}else{let c=dm.toClass(r.class===void 0?"IN":r.class);if(r.flush)c|=32768;i.writeUInt16BE(c,n+2),i.writeUInt32BE(r.ttl||0,n+4),n+=8;let l=gc(r.type);l.encode(r.data,i,n),n+=l.encode.bytes}return Sr.encode.bytes=n-m,i};Sr.encode.bytes=0;Sr.decode=function(r,i){if(!i)i=0;let n={},m=i;if(n.name=H.decode(r,i),i+=H.decode.bytes,n.type=Pi.toString(r.readUInt16BE(i)),n.type==="OPT")n.udpPayloadSize=r.readUInt16BE(i+2),n.extendedRcode=r.readUInt8(i+4),n.ednsVersion=r.readUInt8(i+5),n.flags=r.readUInt16BE(i+6),n.flag_do=(n.flags>>15&1)===1,n.options=Or.decode(r,i+8),i+=8+Or.decode.bytes;else{let c=r.readUInt16BE(i+2);n.ttl=r.readUInt32BE(i+4),n.class=dm.toString(c&-32769),n.flush=!!(c&32768);let l=gc(n.type);n.data=l.decode(r,i+8),i+=8+l.decode.bytes}return Sr.decode.bytes=i-m,n};Sr.decode.bytes=0;Sr.encodingLength=function(r){let i=r.data!==null&&r.data!==void 0?r.data:r.options;return H.encodingLength(r.name)+8+gc(r.type).encodingLength(i)};var ur=ZS.question={};ur.encode=function(r,i,n){if(!i)i=Y.alloc(ur.encodingLength(r));if(!n)n=0;let m=n;return H.encode(r.name,i,n),n+=H.encode.bytes,i.writeUInt16BE(Pi.toType(r.type),n),n+=2,i.writeUInt16BE(dm.toClass(r.class===void 0?"IN":r.class),n),n+=2,ur.encode.bytes=n-m,r};ur.encode.bytes=0;ur.decode=function(r,i){if(!i)i=0;let n=i,m={};if(m.name=H.decode(r,i),i+=H.decode.bytes,m.type=Pi.toString(r.readUInt16BE(i)),i+=2,m.class=dm.toString(r.readUInt16BE(i)),i+=2,!!(m.class&32768))m.class&=-32769;return ur.decode.bytes=i-n,m};ur.decode.bytes=0;ur.encodingLength=function(r){return H.encodingLength(r.name)+4};ZS.AUTHORITATIVE_ANSWER=1024;ZS.TRUNCATED_RESPONSE=512;ZS.RECURSION_DESIRED=256;ZS.RECURSION_AVAILABLE=128;ZS.AUTHENTIC_DATA=32;ZS.CHECKING_DISABLED=16;ZS.DNSSEC_OK=32768;ZS.encode=function(r,i,n){let m=!i;if(m)i=Y.alloc(ZS.encodingLength(r));if(!n)n=0;let c=n;if(!r.questions)r.questions=[];if(!r.answers)r.answers=[];if(!r.authorities)r.authorities=[];if(!r.additionals)r.additionals=[];if(ar.encode(r,i,n),n+=ar.encode.bytes,n=pn(r.questions,ur,i,n),n=pn(r.answers,Sr,i,n),n=pn(r.authorities,Sr,i,n),n=pn(r.additionals,Sr,i,n),ZS.encode.bytes=n-c,m&&ZS.encode.bytes!==i.length)return i.slice(0,ZS.encode.bytes);return i};ZS.encode.bytes=0;ZS.decode=function(r,i){if(!i)i=0;let n=i,m=ar.decode(r,i);return i+=ar.decode.bytes,i=am(m.questions,ur,r,i),i=am(m.answers,Sr,r,i),i=am(m.authorities,Sr,r,i),i=am(m.additionals,Sr,r,i),ZS.decode.bytes=i-n,m};ZS.decode.bytes=0;ZS.encodingLength=function(r){return ar.encodingLength(r)+$n(r.questions||[],ur)+$n(r.answers||[],Sr)+$n(r.authorities||[],Sr)+$n(r.additionals||[],Sr)};ZS.streamEncode=function(r){let i=ZS.encode(r),n=Y.alloc(2);n.writeUInt16BE(i.byteLength);let m=Y.concat([n,i]);return ZS.streamEncode.bytes=m.byteLength,m};ZS.streamEncode.bytes=0;ZS.streamDecode=function(r){let i=r.readUInt16BE(0);if(r.byteLength<i+2)return null;let n=ZS.decode(r.slice(2));return ZS.streamDecode.bytes=ZS.decode.bytes,n};ZS.streamDecode.bytes=0;function $n(r,i){let n=0;for(let m=0;m<r.length;m++)n+=i.encodingLength(r[m]);return n}function pn(r,i,n,m){for(let c=0;c<r.length;c++)i.encode(r[c],n,m),m+=i.encode.bytes;return m}function am(r,i,n,m){for(let c=0;c<r.length;c++)r[c]=i.decode(n,m),m+=i.decode.bytes;return m}});var Ij=rr((eQ,jj)=>{var yj=hS;process.nextTick(TS,42);jj.exports=FS;function FS(r){var i=m;return n;function n(c){i(c||zS)}function m(c){var l=[c];i=y,r(j);function y(A){l.push(A)}function j(A){var S=arguments;i=gS(A)?m:v;while(l.length)v(l.shift());function v(w){yj(MS,w,S)}}}}function gS(r){return Object.prototype.toString.call(r)==="[object Error]"}function zS(){}function MS(r,i){r.apply(null,i)}function TS(r){if(r===42)yj=process.nextTick}function hS(r,i,n){process.nextTick(function(){r(i,n)})}});var vj=rr((sQ,Sj)=>{var zc=lj(),BS=bi("dgram"),oS=Ij(),xS=bi("events"),Tc=bi("os"),Mc=function(){};Sj.exports=function(r){if(!r)r={};var i=new xS.EventEmitter,n=typeof r.port==="number"?r.port:5353,m=r.type||"udp4",c=r.ip||r.host||(m==="udp4"?"224.0.0.251":null),l={address:c,port:n},y={},j=!1,A=null;if(m==="udp6"&&(!c||!r.interface))throw Error("For IPv6 multicast you must specify `ip` and `interface`");var S=r.socket||BS.createSocket({type:m,reuseAddr:r.reuseAddr!==!1,toString:function(){return m}});S.on("error",function(w){if(w.code==="EACCES"||w.code==="EADDRINUSE")i.emit("error",w);else i.emit("warning",w)}),S.on("message",function(w,N){try{w=zc.decode(w)}catch(E){i.emit("warning",E);return}if(i.emit("packet",w,N),w.type==="query")i.emit("query",w,N);if(w.type==="response")i.emit("response",w,N)}),S.on("listening",function(){if(!n)n=l.port=S.address().port;if(r.multicast!==!1)i.update(),A=setInterval(i.update,5000),S.setMulticastTTL(r.ttl||255),S.setMulticastLoopback(r.loopback!==!1)});var v=oS(function(w){if(!n||r.bind===!1)return w(null);S.once("error",w),S.bind(n,r.bind||r.interface,function(){S.removeListener("error",w),w(null)})});return v(function(w){if(w)return i.emit("error",w);i.emit("ready")}),i.send=function(w,N,E){if(typeof N==="function")return i.send(w,null,N);if(!E)E=Mc;if(!N)N=l;else if(!N.host&&!N.address)N.address=l.address;v(Q);function Q(W){if(j)return E();if(W)return E(W);var Z=zc.encode(w);S.send(Z,0,Z.length,N.port,N.address||N.host,E)}},i.response=i.respond=function(w,N,E){if(Array.isArray(w))w={answers:w};w.type="response",w.flags=(w.flags||0)|zc.AUTHORITATIVE_ANSWER,i.send(w,N,E)},i.query=function(w,N,E,Q){if(typeof N==="function")return i.query(w,null,null,N);if(typeof N==="object"&&N&&N.port)return i.query(w,null,N,E);if(typeof E==="function")return i.query(w,N,null,E);if(!Q)Q=Mc;if(typeof w==="string")w=[{name:w,type:N||"ANY"}];if(Array.isArray(w))w={type:"query",questions:w};w.type="query",i.send(w,E,Q)},i.destroy=function(w){if(!w)w=Mc;if(j)return process.nextTick(w);j=!0,clearInterval(A);for(var N in y)try{S.dropMembership(c,N)}catch(E){}y={},S.close(w)},i.update=function(){var w=r.interface?[].concat(r.interface):pS(),N=!1;for(var E=0;E<w.length;E++){var Q=w[E];if(y[Q])continue;try{S.addMembership(c,Q),y[Q]=!0,N=!0}catch(W){i.emit("warning",W)}}if(N){if(S.setMulticastInterface)try{S.setMulticastInterface(r.interface||kS())}catch(W){i.emit("warning",W)}i.emit("networkInterface")}},i};function kS(){var r=Tc.networkInterfaces(),i=Object.keys(r);for(var n=0;n<i.length;n++){var m=r[i[n]];for(var c=0;c<m.length;c++){var l=m[c];if(Aj(l.family)&&!l.internal){if(Tc.platform()==="darwin"&&i[n]==="en0")return l.address;return"0.0.0.0"}}}return"127.0.0.1"}function pS(){var r=Tc.networkInterfaces(),i=Object.keys(r),n=[];for(var m=0;m<i.length;m++){var c=r[i[m]];for(var l=0;l<c.length;l++){var y=c[l];if(Aj(y.family)){n.push(y.address);break}}}return n}function Aj(r){return r===4||r==="IPv4"}});var $j=rr((fQ,wj)=>{wj.exports=function r(i,n){if(i===n)return!0;if(i&&n&&typeof i=="object"&&typeof n=="object"){if(i.constructor!==n.constructor)return!1;var m,c,l;if(Array.isArray(i)){if(m=i.length,m!=n.length)return!1;for(c=m;c--!==0;)if(!r(i[c],n[c]))return!1;return!0}if(i instanceof Map&&n instanceof Map){if(i.size!==n.size)return!1;for(c of i.entries())if(!n.has(c[0]))return!1;for(c of i.entries())if(!r(c[1],n.get(c[0])))return!1;return!0}if(i instanceof Set&&n instanceof Set){if(i.size!==n.size)return!1;for(c of i.entries())if(!n.has(c[0]))return!1;return!0}if(ArrayBuffer.isView(i)&&ArrayBuffer.isView(n)){if(m=i.length,m!=n.length)return!1;for(c=m;c--!==0;)if(i[c]!==n[c])return!1;return!0}if(i.constructor===RegExp)return i.source===n.source&&i.flags===n.flags;if(i.valueOf!==Object.prototype.valueOf)return i.valueOf()===n.valueOf();if(i.toString!==Object.prototype.toString)return i.toString()===n.toString();if(l=Object.keys(i),m=l.length,m!==Object.keys(n).length)return!1;for(c=m;c--!==0;)if(!Object.prototype.hasOwnProperty.call(n,l[c]))return!1;for(c=m;c--!==0;){var y=l[c];if(!r(i[y],n[y]))return!1}return!0}return i!==i&&n!==n}});var Gj=rr((fi)=>{var hc=fi&&fi.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(fi,"__esModule",{value:!0});fi.Server=void 0;var uS=hc(vj()),aS=hc($j()),dS=hc(pm());class Bc{constructor(r,i){this.registry={},this.mdns=(0,uS.default)(r),this.mdns.setMaxListeners(0),this.mdns.on("query",this.respondToQuery.bind(this)),this.errorCallback=i!==null&&i!==void 0?i:function(n){throw n}}register(r){let i=(n)=>{var m=this.registry[n.type];if(!m)m=this.registry[n.type]=[];else if(m.some(this.isDuplicateRecord(n)))return;m.push(n)};if(Array.isArray(r))r.forEach(i);else i(r)}unregister(r){let i=(n)=>{let m=n.type;if(!(m in this.registry))return;this.registry[m]=this.registry[m].filter((c)=>c.name!==n.name)};if(Array.isArray(r))r.forEach(i);else i(r)}respondToQuery(r){let i=this;r.questions.forEach((n)=>{var{type:m,name:c}=n,l=m==="ANY"?Object.keys(i.registry).map(i.recordsFor.bind(i,c)).flat(1):i.recordsFor(c,m);if(l.length===0)return;var y=[];if(m!=="ANY")l.forEach((j)=>{if(j.type!=="PTR")return;y=y.concat(i.recordsFor(j.data,"SRV")).concat(i.recordsFor(j.data,"TXT"))}),y.filter(function(j){return j.type==="SRV"}).map(function(j){return j.data.target}).filter(this.unique()).forEach(function(j){y=y.concat(i.recordsFor(j,"A")).concat(i.recordsFor(j,"AAAA"))});i.mdns.respond({answers:l,additionals:y},(j)=>{if(j)this.errorCallback(j)})})}recordsFor(r,i){if(!(i in this.registry))return[];return this.registry[i].filter((n)=>{var m=~r.indexOf(".")?n.name:n.name.split(".")[0];return(0,dS.default)(m,r)})}isDuplicateRecord(r){return(i)=>{return r.type===i.type&&r.name===i.name&&(0,aS.default)(r.data,i.data)}}unique(){var r=[];return(i)=>{if(~r.indexOf(i))return!1;return r.push(i),!0}}}fi.Server=Bc;fi.default=Bc});var Ej=rr((Nj)=>{Object.defineProperty(Nj,"__esModule",{value:!0});Nj.default=(r,i)=>{if(i===void 0)return!0;let n=r.txt,m=Object.entries(i).map(([c,l])=>{let y=n[c];if(y===void 0)return!1;if(l!=y)return!1;return!0});if(m.length==0)return!0;if(m.includes(!1))return!1;return!0}});var Dj=rr((Qj)=>{Object.defineProperty(Qj,"__esModule",{value:!0});Qj.default=(r)=>Object.keys(r).filter((i)=>!i.includes("binary")).reduce((i,n)=>{return Object.assign(i,{[n]:r[n]})},{})});var Pj=rr((Uj)=>{Object.defineProperty(Uj,"__esModule",{value:!0});Uj.default=eS;function eS(r,i){if(r===void 0||i===void 0)return!1;let n=Object.keys(r),m=Object.keys(i);if(n.length!=m.length)return!1;for(let c of n)if(r[c]!=i[c])return!1;return!0}});var Xj=rr((rn)=>{var an=rn&&rn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(rn,"__esModule",{value:!0});rn.Browser=void 0;var fS=an(Zc()),Oi=an(pm()),rv=bi("events"),oc=Vc(),Cj=an(Ej()),iv=an(Dj()),nv=an(Pj()),Wj=".local",mv="_services._dns-sd._udp"+Wj;class tm extends rv.EventEmitter{constructor(r,i,n){super();if(this.onresponse=void 0,this.serviceMap={},this.wildcard=!1,this._services=[],typeof i==="function")return new tm(r,null,i);if(this.mdns=r,this.txt=new fS.default(i!==null&&i.txt!=null?i.txt:void 0),i===null||i.type===void 0)this.name=mv,this.wildcard=!0;else{if(this.name=(0,oc.toString)({name:i.type,protocol:i.protocol||"tcp"})+Wj,i.name)this.name=i.name+"."+this.name;this.wildcard=!1}if(i!=null&&i.txt!==void 0)this.txtQuery=(0,iv.default)(i.txt);if(n)this.on("up",n);this.start()}start(){if(this.onresponse||this.name===void 0)return;var r=this,i={};if(!this.wildcard)i[this.name]=!0;this.onresponse=(n,m)=>{if(r.wildcard)n.answers.forEach((c)=>{if(c.type!=="PTR"||c.name!==r.name||c.name in i)return;i[c.data]=!0,r.mdns.query(c.data,"PTR")});Object.keys(i).forEach(function(c){r.goodbyes(c,n).forEach(r.removeService.bind(r));var l=r.buildServicesFor(c,n,r.txt,m);if(l.length===0)return;l.forEach((y)=>{if(r.serviceMap[y.fqdn]){r.updateService(y);return}r.addService(y)})})},this.mdns.on("response",this.onresponse),this.update()}stop(){if(!this.onresponse)return;this.mdns.removeListener("response",this.onresponse),this.onresponse=void 0}update(){this.mdns.query(this.name,"PTR")}get services(){return this._services}addService(r){if((0,Cj.default)(r,this.txtQuery)===!1)return;this._services.push(r),this.serviceMap[r.fqdn]=!0,this.emit("up",r)}updateService(r){var i;if((0,nv.default)(r.txt,((i=this._services.find((n)=>(0,Oi.default)(n.fqdn,r.fqdn)))===null||i===void 0?void 0:i.txt)||{}))return;if(!(0,Cj.default)(r,this.txtQuery)){this.removeService(r.fqdn);return}this._services=this._services.map(function(n){if(!(0,Oi.default)(n.fqdn,r.fqdn))return n;return r}),this.emit("txt-update",r)}removeService(r){var i,n;if(this._services.some(function(m,c){if((0,Oi.default)(m.fqdn,r))return i=m,n=c,!0}),!i||n===void 0)return;this._services.splice(n,1),delete this.serviceMap[r],this.emit("down",i)}goodbyes(r,i){return i.answers.concat(i.additionals).filter((n)=>n.type==="PTR"&&n.ttl===0&&(0,Oi.default)(n.name,r)).map((n)=>n.data)}buildServicesFor(r,i,n,m){var c=i.answers.concat(i.additionals).filter((l)=>l.ttl>0);return c.filter((l)=>l.type==="PTR"&&(0,Oi.default)(l.name,r)).map((l)=>{let y={addresses:[],subtypes:[]};if(c.filter((j)=>{return j.type==="PTR"&&(0,Oi.default)(j.data,l.data)&&j.name.includes("._sub")}).forEach((j)=>{let A=(0,oc.toType)(j.name);y.subtypes.push(A.subtype)}),c.filter((j)=>{return(j.type==="SRV"||j.type==="TXT")&&(0,Oi.default)(j.name,l.data)}).forEach((j)=>{if(j.type==="SRV"){var A=j.name.split("."),S=A[0],v=(0,oc.toType)(A.slice(1,-1).join("."));y.name=S,y.fqdn=j.name,y.host=j.data.target,y.referer=m,y.port=j.data.port,y.type=v.name,y.protocol=v.protocol}else if(j.type==="TXT")y.rawTxt=j.data,y.txt=this.txt.decodeAll(j.data)}),!y.name)return;return c.filter((j)=>(j.type==="A"||j.type==="AAAA")&&(0,Oi.default)(j.name,y.host)).forEach((j)=>y.addresses.push(j.data)),y}).filter((l)=>!!l)}}rn.Browser=tm;rn.default=tm});var Kj=rr((dr)=>{var bm=dr&&dr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(dr,"__esModule",{value:!0});dr.Browser=dr.Service=dr.Bonjour=void 0;var cv=bm(by()),lv=bm(Gj()),xc=bm(Xj());dr.Browser=xc.default;var yv=bm(Jc());dr.Service=yv.default;class kc{constructor(r={},i){this.server=new lv.default(r,i),this.registry=new cv.default(this.server)}publish(r){return this.registry.publish(r)}unpublishAll(r){return this.registry.unpublishAll(r)}find(r=null,i){return new xc.default(this.server.mdns,r,i)}findOne(r=null,i=1e4,n){let m=new xc.default(this.server.mdns,r);var c;return m.once("up",(l)=>{if(c!==void 0)clearTimeout(c);if(m.stop(),n)n(l)}),c=setTimeout(()=>{if(m.stop(),n)n(null)},i),m}destroy(r){this.registry.destroy(),this.server.mdns.destroy(r)}}dr.Bonjour=kc;dr.default=kc});var bl={};Nr(bl,{url:()=>AA,openapi:()=>B$,listen:()=>o$,Server:()=>bl,Default:()=>T$});var cc=(r)=>{let i=r.split("/");if(i[0]==="")i.shift();return i},el=(r)=>{let{groups:i,path:n}=SA(r),m=cc(n);return vA(m,i)},SA=(r)=>{let i=[];return r=r.replace(/\{[^}]+\}/g,(n,m)=>{let c=`@${m}`;return i.push([c,n]),c}),{groups:i,path:r}},vA=(r,i)=>{for(let n=i.length-1;n>=0;n--){let[m]=i[n];for(let c=r.length-1;c>=0;c--)if(r[c].includes(m)){r[c]=r[c].replace(m,i[n][1]);break}}return r},Fm={},sl=(r,i)=>{if(r==="*")return"*";let n=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){let m=`${r}#${i}`;if(!Fm[m])if(n[2])Fm[m]=i&&i[0]!==":"&&i[0]!=="*"?[m,n[1],new RegExp(`^${n[2]}(?=/${i})`)]:[r,n[1],new RegExp(`^${n[2]}$`)];else Fm[m]=[r,n[1],!0];return Fm[m]}return null},Sn=(r,i)=>{try{return i(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,(n)=>{try{return i(n)}catch{return n}})}},fl=(r)=>Sn(r,decodeURI),lc=(r)=>{let i=r.url,n=i.indexOf("/",i.indexOf(":")+4),m=n;for(;m<i.length;m++){let c=i.charCodeAt(m);if(c===37){let l=i.indexOf("?",m),y=i.indexOf("#",m),j=l===-1?y===-1?void 0:y:y===-1?l:Math.min(l,y),A=i.slice(n,j);return fl(A.includes("%25")?A.replace(/%25/g,"%2525"):A)}else if(c===63||c===35)break}return i.slice(n,m)};var ry=(r)=>{let i=lc(r);return i.length>1&&i.at(-1)==="/"?i.slice(0,-1):i},Ji=(r,i,...n)=>{if(n.length)i=Ji(i,...n);return`${r?.[0]==="/"?"":"/"}${r}${i==="/"?"":`${r?.at(-1)==="/"?"":"/"}${i?.[0]==="/"?i.slice(1):i}`}`},gm=(r)=>{if(r.charCodeAt(r.length-1)!==63||!r.includes(":"))return null;let i=r.split("/"),n=[],m="";return i.forEach((c)=>{if(c!==""&&!/\:/.test(c))m+="/"+c;else if(/\:/.test(c))if(/\?/.test(c)){if(n.length===0&&m==="")n.push("/");else n.push(m);let l=c.replace("?","");m+="/"+l,n.push(m)}else m+="/"+c}),n.filter((c,l,y)=>y.indexOf(c)===l)},mc=(r)=>{if(!/[%+]/.test(r))return r;if(r.indexOf("+")!==-1)r=r.replace(/\+/g," ");return r.indexOf("%")!==-1?Sn(r,Mn):r},iy=(r,i,n)=>{let m;if(!n&&i&&!/[%+]/.test(i)){let y=r.indexOf("?",8);if(y===-1)return;if(!r.startsWith(i,y+1))y=r.indexOf(`&${i}`,y+1);while(y!==-1){let j=r.charCodeAt(y+i.length+1);if(j===61){let A=y+i.length+2,S=r.indexOf("&",A);return mc(r.slice(A,S===-1?void 0:S))}else if(j==38||isNaN(j))return"";y=r.indexOf(`&${i}`,y+1)}if(m=/[%+]/.test(r),!m)return}let c={};m??=/[%+]/.test(r);let l=r.indexOf("?",8);while(l!==-1){let y=r.indexOf("&",l+1),j=r.indexOf("=",l);if(j>y&&y!==-1)j=-1;let A=r.slice(l+1,j===-1?y===-1?void 0:y:j);if(m)A=mc(A);if(l=y,A==="")continue;let S;if(j===-1)S="";else if(S=r.slice(j+1,y===-1?void 0:y),m)S=mc(S);if(n){if(!(c[A]&&Array.isArray(c[A])))c[A]=[];c[A].push(S)}else c[A]??=S}return i?c[i]:c},ny=iy,my=(r,i)=>{return iy(r,i,!0)},Mn=decodeURIComponent;var wA=/^[\w!#$%&'*.^`|~+-]+$/,$A=/^[ !#-:<-[\]-~]*$/,cy=(r)=>{let i=0,n=r.length;while(i<n){let m=r.charCodeAt(i);if(m!==32&&m!==9)break;i++}while(n>i){let m=r.charCodeAt(n-1);if(m!==32&&m!==9)break;n--}return i===0&&n===r.length?r:r.slice(i,n)},yc=(r,i)=>{if(i&&r.indexOf(i)===-1)return{};let n=r.split(";"),m=Object.create(null);for(let c of n){let l=c.indexOf("=");if(l===-1)continue;let y=cy(c.substring(0,l));if(i&&i!==y||!wA.test(y)||y in m)continue;let j=cy(c.substring(l+1));if(j.startsWith('"')&&j.endsWith('"'))j=j.slice(1,-1);if($A.test(j)){if(m[y]=j.indexOf("%")!==-1?Sn(j,Mn):j,i)break}}return m};var ly=(r,i,n)=>{let m=r.req.raw.headers.get("Cookie");if(typeof i==="string"){if(!m)return;let l=i;if(n==="secure")l="__Secure-"+i;else if(n==="host")l="__Host-"+i;return yc(m,l)[l]}if(!m)return{};return yc(m)};var kr=class extends Error{res;status;constructor(r=500,i){super(i?.message,{cause:i?.cause});this.res=i?.res,this.status=r}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 jc=async(r)=>{return await GA(r,{name:"SHA-256",alias:"sha256"})};var GA=async(r,i)=>{let n;if(ArrayBuffer.isView(r)||r instanceof ArrayBuffer)n=r;else{if(typeof r==="object")r=JSON.stringify(r);n=new TextEncoder().encode(String(r))}if(crypto&&crypto.subtle){let m=await crypto.subtle.digest({name:i.name},n);return Array.prototype.map.call(new Uint8Array(m),(l)=>("00"+l.toString(16)).slice(-2)).join("")}return null};var yy=(r,i)=>{let n=r.length,m=i.length,c=Math.max(n,m),l=n^m;for(let y=0;y<c;y++){let j=y<n?r.charCodeAt(y):0,A=y<m?i.charCodeAt(y):0;l|=j^A}return l===0},jy=async(r,i,n)=>{if(!n)n=jc;let[m,c]=await Promise.all([n(r),n(i)]);if(m==null||c==null||typeof m!=="string"||typeof c!=="string")return!1;let l=yy(m,c),y=yy(r,i);return l&&y},Ic=async(r,i,n)=>{if(typeof r==="string"&&typeof i==="string")return jy(r,i,n);if(!n)n=jc;let[m,c]=await Promise.all([n(r),n(i)]);if(!m||!c||typeof m!=="string"||typeof c!=="string")return!1;return jy(m,c)};var zm=(r,i)=>{return new Response(r,{headers:{"Content-Type":i.replace(/^[^;]+/,(m)=>m.toLowerCase())}}).formData()};var NA=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i,EA=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/i,QA=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i,Ac=(r,i)=>{return async(n,m)=>{let c={},l=n.req.header("Content-Type");switch(r){case"json":if(!l||!NA.test(l))break;try{c=await n.req.json()}catch{throw new kr(400,{message:"Malformed JSON in request body"})}break;case"form":{if(!l||!(EA.test(l)||QA.test(l)))break;let j;if(n.req.bodyCache.formData)j=await n.req.bodyCache.formData;else try{let S=await n.req.arrayBuffer();j=await zm(S,l),n.req.bodyCache.formData=j}catch(S){let v="Malformed FormData request.";throw v+=S instanceof Error?` ${S.message}`:` ${String(S)}`,new kr(400,{message:v})}let A=Object.create(null);j.forEach((S,v)=>{if(v.endsWith("[]"))(A[v]??=[]).push(S);else if(Array.isArray(A[v]))A[v].push(S);else if(Object.hasOwn(A,v))A[v]=[A[v],S];else A[v]=S}),c=A;break}case"query":c=Object.fromEntries(Object.entries(n.req.queries()).map(([j,A])=>{return A.length===1?[j,A[0]]:[j,A]}));break;case"param":c=n.req.param();break;case"header":c=n.req.header();break;case"cookie":c=ly(n);break}let y=await i(c,n);if(y instanceof Response)return y;return n.req.addValidatedData(r,y),await m()}};var Iy={header:["cookie"]};function DA(r,i,n){if(!(n in Iy))return r;let m=Iy[n]||[];if(i==="arktype")return UA(r,m);if(i==="valibot")return PA(r,m);return r}function UA(r,i){return r.map((n)=>{if(n&&typeof n==="object"&&"data"in n&&typeof n.data==="object"&&n.data!==null&&!Array.isArray(n.data)){let m={...n.data};for(let l of i)delete m[l];let c=Object.create(Object.getPrototypeOf(n));return Object.assign(c,n,{data:m}),c}return n})}function PA(r,i){return r.map((n)=>{if(n&&typeof n==="object"&&"path"in n&&Array.isArray(n.path)){for(let m of n.path)if(typeof m==="object"&&"input"in m&&typeof m.input==="object"&&m.input!==null&&!Array.isArray(m.input))for(let c of i)delete m.input[c]}return n})}var Ay=(r,i,n)=>Ac(r,async(m,c)=>{let l=await i["~standard"].validate(m);if(n){let y=await n(l.issues?{data:m,error:l.issues,success:!1,target:r}:{data:m,success:!0,target:r},c);if(y){if(y instanceof Response)return y;if("response"in y)return y.response}}if(l.issues){let y=DA(l.issues,i["~standard"].vendor,r);return c.json({data:m,error:y,success:!1},400)}return l.value});var vc=Symbol("openapi"),WA=["GET","PUT","POST","DELETE","OPTIONS","HEAD","PATCH","TRACE"],XA=(r)=>r.split("/").map((i)=>{let n=i;if(n.startsWith(":")){let m=n.match(/^:([^{?]+)(?:{(.+)})?(\?)?$/);if(m)n=`{${m[1]}}`;else{if(n=n.slice(1,n.length),n.endsWith("?"))n=n.slice(0,-1);n=`{${n}}`}}return n}).join("/"),Sy=(r)=>r.charAt(0).toUpperCase()+r.slice(1),KA=(r)=>{let i=r.method.toLowerCase();if(r.path==="/")return`${i}Index`;for(let n of r.path.split("/"))if(n.charCodeAt(0)===123)i+=`By${Sy(n.slice(1,-1))}`;else i+=Sy(n);return i},HA=(r)=>("$ref"in r)?r.$ref:`${r.in} ${r.name}`;function vy(...r){let i=r.flatMap((n)=>n??[]).reduce((n,m)=>{return n.set(HA(m),m),n},new Map);return Array.from(i.values())}var vn=new Map;function ZA(r){let i=[];for(let[n,m]of vn)if(m&&r.match(n))i.push(m);return i}function VA(){vn.clear()}function wy(r,...i){return i.reduce((n,m)=>{if(!m||!n)return n;for(let[c,l]of Object.entries(m)){if(l==null)continue;if(c in n&&(typeof l==="object"||typeof l==="function"&&c==="operationId"))if(Array.isArray(l)){let y=[...n[c]??[],...l];if(c==="tags")n[c]=Array.from(new Set(y));else if(c==="parameters")n[c]=vy(y);else n[c]=y}else if(typeof l==="function")n[c]=l(r);else if(c==="parameters")n[c]=vy(n[c],l);else n[c]={...n[c],...l};else n[c]=l}return n},{operationId:KA(r)})}function $y({route:r,specs:i,paths:n}){let m=XA(r.path),c=r.method.toLowerCase();if(c==="all"){if(!i)return;if(vn.has(m)){let l=vn.get(m)??{};vn.set(m,wy(r,l,i))}else vn.set(m,i)}else{let l=ZA(m);if(!(m in n))n[m]={};if(n[m])n[m][c]=wy(r,...l,n[m]?.[c],i)}}function YA(r,i){let{exclude:n,excludeStaticFile:m}=i.options,c={},l=Array.isArray(n)?n:[n];for(let[y,j]of Object.entries(r)){if(j==null)continue;if(l.some((v)=>{if(typeof v==="string")return y===v;return v.test(y)}))continue;if(y.includes("*")&&!y.includes("{"))continue;if(m){let v=y.includes("{"),N=(y.split("/").pop()||"").includes(".");if(!v&&N)continue}for(let v of Object.keys(j)){let w=j[v];if(w==null)continue;if(y.includes("{")){w.parameters=w.parameters?[...w.parameters]:[];let N=y.split("/").filter((E)=>E.startsWith("{")&&!w.parameters.find((Q)=>Q.in==="path"&&Q.name===E.slice(1,E.length-1)));for(let E of N){let Q=E.slice(1,E.length-1);if(w.parameters.findIndex((Z)=>{if("$ref"in Z){let X=Z.$ref.split("/").pop();if(X){let K=i.components.parameters?.[X];if(K&&!("$ref"in K))return K.in==="path"&&K.name===Q}return!1}return Z.in==="path"&&Z.name===Q})===-1)w.parameters.push({schema:{type:"string"},in:"path",name:Q,required:!0})}}if(!w.responses)w.responses={200:{}}}c[y]=j}return c}var Gy={documentation:{},excludeStaticFile:!0,exclude:[],excludeMethods:["OPTIONS"],excludeTags:[]};function Qy(r,i){let n;return async(m)=>{if(n)return m.json(n);return n=await wc(r,i,m),m.json(n)}}async function wc(r,i=Gy,n){let m={components:{},options:{...Gy,...i}},c=m.options.documentation??{};VA();let l=await JA(r,m);for(let j in l)for(let A in l[j])if(RA({valueOrFunc:l[j][A]?.hide,method:A,path:j,c:n}))l[j][A]=void 0;let y=$c(c.components,m.components);return{openapi:"3.1.0",...c,tags:c.tags?.filter((j)=>!m.options.excludeTags?.includes(j?.name)),info:{title:"Hono Documentation",description:"Development documentation",version:"0.0.0",...c.info},paths:{...YA(l,m),...c.paths},components:y}}async function JA(r,i){let n={};for(let m of r.routes){let c=m.handler[vc];if(!c){if(i.options.includeEmptyPaths)$y({route:m,paths:n});continue}let l=m.method;if(l!=="ALL"){if(i.options.excludeMethods?.includes(l))continue;if(!WA.includes(l))continue}let y=i.options.defaultOptions?.[l],{schema:j,components:A={}}=await OA(c,y);i.components=$c(i.components,A),$y({route:m,specs:j,paths:n})}return n}function RA(r){let{valueOrFunc:i,c:n,method:m,path:c}=r;if(i!=null){if(typeof i==="boolean")return i;if(typeof i==="function")return i({c:n,method:m,path:c})}return!1}async function OA(r,i){if("spec"in r){let c={},l={...i,...r.spec,responses:{...i?.responses,...r.spec.responses}};if(l.responses)for(let y of Object.keys(l.responses)){let j=l.responses[y];if(!j||!("content"in j))continue;for(let A of Object.keys(j.content??{})){let S=j.content?.[A];if(!S)continue;if(S.schema&&"toOpenAPISchema"in S.schema){let v=await S.schema.toOpenAPISchema();if(S.schema=v.schema,v.components)c=$c(c,v.components)}}}return{schema:l,components:c}}let n=await r.toOpenAPISchema(),m=i??{};if(r.target==="form"||r.target==="json"){let c=r.options?.media??r.target==="json"?"application/json":"multipart/form-data";if(!m.requestBody||!("content"in m.requestBody)||!m.requestBody.content)m.requestBody={content:{[c]:{schema:n.schema}}};else m.requestBody.content[c]={schema:n.schema}}else{let c=[];if("$ref"in n.schema){let y=n.schema.$ref.split("/").pop();if(y&&n.components?.schemas?.[y]){let j=n.components.schemas[y],A=Ny(r.target,j)[0];if(!n.components.parameters)n.components.parameters={};n.components.parameters[y]=A,delete n.components.schemas[y],c.push({$ref:`#/components/parameters/${y}`})}}else c=Ny(r.target,n.schema);m.parameters=c}return{schema:m,components:n.components}}function Ny(r,i){let n=[];for(let[m,c]of Object.entries(i.properties??{})){let l={in:r==="param"?"path":r,name:m,schema:c};if(i.required?.includes(m))l.required=!0;if(l.schema&&"description"in l.schema&&l.schema.description)l.description=l.schema.description,l.schema.description=void 0;n.push(l)}return n}function $c(...r){return r.reduce((i,n,m)=>{if(n==null||m===0)return i;if(i.schemas&&Object.keys(i.schemas).length>0||n.schemas&&Object.keys(n.schemas).length>0)i.schemas={...i.schemas,...n.schemas};if(i.parameters&&Object.keys(i.parameters).length>0||n.parameters&&Object.keys(n.parameters).length>0)i.parameters={...i.parameters,...n.parameters};return i},r[0]??{})}function $(r,i){return{vendor:r["~standard"].vendor,validate:r["~standard"].validate,toJSONSchema:(n)=>Ey(r,{...i,...n}),toOpenAPISchema:(n)=>Sc(r,{...i,...n})}}function D(r,i,n,m){let c=Ay(r,i,n);return Object.assign(c,{[vc]:{target:r,...$(i,m),options:m}})}function G(r){return Object.assign(async(n,m)=>{await m()},{[vc]:{spec:r}})}var Gc=(r,i,n)=>{return(m,c)=>{let l=-1;return y(0);async function y(j){if(j<=l)throw Error("next() called multiple times");l=j;let A,S=!1,v;if(r[j])v=r[j][0][0],m.req.routeIndex=j;else v=j===r.length&&c||void 0;if(v)try{A=await v(m,()=>y(j+1))}catch(w){if(w instanceof Error&&i)m.error=w,A=await i(w,m),S=!0;else throw w}else if(m.finalized===!1&&n)A=await n(m);if(A&&(m.finalized===!1||S))m.res=A;return m}}};var Dy=Symbol();var Nc=(r)=>("headers"in r),Uy=async(r,i=Object.create(null))=>{let{all:n=!1,dot:m=!1}=i,y=(Nc(r)?r.headers:r.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();if(y==="multipart/form-data"||y==="application/x-www-form-urlencoded")return LA(r,{all:n,dot:m});return{}};async function LA(r,i){let n=Nc(r)?r.headers:r.raw.headers,m=await r.arrayBuffer(),c=zm(m,n.get("Content-Type")||"");if(!Nc(r))r.bodyCache.formData=c;let l=await c;if(l)return qA(l,i);return{}}function qA(r,i){let n=Object.create(null);if(r.forEach((m,c)=>{if(!(i.all||c.endsWith("[]")))n[c]=m;else _A(n,c,m)}),i.dot)Object.entries(n).forEach(([m,c])=>{if(m.includes("."))FA(n,m,c),delete n[m]});return n}var _A=(r,i,n)=>{if(r[i]!==void 0)if(Array.isArray(r[i]))r[i].push(n);else r[i]=[r[i],n];else if(!i.endsWith("[]"))r[i]=n;else r[i]=[n]},FA=(r,i,n)=>{if(/(?:^|\.)__proto__\./.test(i))return;let m=r,c=i.split(".");c.forEach((l,y)=>{if(y===c.length-1)m[l]=n;else{if(!m[l]||typeof m[l]!=="object"||Array.isArray(m[l])||m[l]instanceof File)m[l]=Object.create(null);m=m[l]}})};var Py=(r)=>Sn(r,Mn),Cy=class{raw;#r;#i;routeIndex=0;path;bodyCache={};constructor(r,i="/",n=[[]]){this.raw=r,this.path=i,this.#i=n,this.#r={}}param(r){return r?this.#n(r):this.#l()}#n(r){let i=this.#i[0][this.routeIndex][1][r],n=this.#c(i);return n&&/\%/.test(n)?Py(n):n}#l(){let r={},i=Object.keys(this.#i[0][this.routeIndex][1]);for(let n of i){let m=this.#c(this.#i[0][this.routeIndex][1][n]);if(m!==void 0)r[n]=/\%/.test(m)?Py(m):m}return r}#c(r){return this.#i[1]?this.#i[1][r]:r}query(r){return ny(this.url,r)}queries(r){return my(this.url,r)}header(r){if(r)return this.raw.headers.get(r)??void 0;let i={};return this.raw.headers.forEach((n,m)=>{i[m]=n}),i}async parseBody(r){return Uy(this,r)}#m=(r)=>{let{bodyCache:i,raw:n}=this,m=i[r];if(m)return m;let c=Object.keys(i)[0];if(c)return i[c].then((l)=>{if(c==="json")l=JSON.stringify(l);return new Response(l)[r]()});return i[r]=n[r]()};json(){return this.#m("text").then((r)=>JSON.parse(r))}text(){return this.#m("text")}arrayBuffer(){return this.#m("arrayBuffer")}bytes(){return this.#m("arrayBuffer").then((r)=>new Uint8Array(r))}blob(){return this.#m("blob")}formData(){return this.#m("formData")}addValidatedData(r,i){this.#r[r]=i}valid(r){return this.#r[r]}get url(){return this.raw.url}get method(){return this.raw.method}get[Dy](){return this.#i}get matchedRoutes(){return this.#i[0].map(([[,r]])=>r)}get routePath(){return this.#i[0].map(([[,r]])=>r)[this.routeIndex].path}};var Mm={Stringify:1,BeforeStream:2,Stream:3},Wy=(r,i)=>{let n=new String(r);return n.isEscaped=!0,n.callbacks=i,n};var Tn=async(r,i,n,m,c)=>{if(typeof r==="object"&&!(r instanceof String)){if(!(r instanceof Promise))r=r.toString();if(r instanceof Promise)r=await r}let l=r.callbacks;if(!l?.length)return Promise.resolve(r);if(c)c[0]+=r;else c=[r];let y=Promise.all(l.map((j)=>j({phase:i,buffer:c,context:m}))).then((j)=>Promise.all(j.filter(Boolean).map((A)=>Tn(A,i,!1,m,c))).then(()=>c[0]));if(n)return Wy(await y,l);else return y};var Xy="text/plain; charset=UTF-8",Ec=(r,i)=>{return{"Content-Type":r,...i}},hn=(r,i)=>new Response(r,i),Qc=class{#r;#i;env={};#n;finalized=!1;error;#l;#c;#m;#S;#I;#A;#j;#v;#w;constructor(r,i){if(this.#r=r,i)this.#c=i.executionCtx,this.env=i.env,this.#A=i.notFoundHandler,this.#w=i.path,this.#v=i.matchResult}get req(){return this.#i??=new Cy(this.#r,this.#w,this.#v),this.#i}get event(){if(this.#c&&"respondWith"in this.#c)return this.#c;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#c)return this.#c;else throw Error("This context has no ExecutionContext")}get res(){return this.#m||=hn(null,{headers:this.#j??=new Headers})}set res(r){if(this.#m&&r){r=hn(r.body,r);for(let[i,n]of this.#m.headers.entries()){if(i==="content-type")continue;if(i==="set-cookie"){let m=this.#m.headers.getSetCookie();r.headers.delete("set-cookie");for(let c of m)r.headers.append("set-cookie",c)}else r.headers.set(i,n)}}this.#m=r,this.finalized=!0}render=(...r)=>{return this.#I??=(i)=>this.html(i),this.#I(...r)};setLayout=(r)=>this.#S=r;getLayout=()=>this.#S;setRenderer=(r)=>{this.#I=r};header=(r,i,n)=>{if(this.finalized)this.#m=hn(this.#m.body,this.#m);let m=this.#m?this.#m.headers:this.#j??=new Headers;if(i===void 0)m.delete(r);else if(n?.append)m.append(r,i);else m.set(r,i)};status=(r)=>{this.#l=r};set=(r,i)=>{this.#n??=new Map,this.#n.set(r,i)};get=(r)=>{return this.#n?this.#n.get(r):void 0};get var(){if(!this.#n)return{};return Object.fromEntries(this.#n)}#y(r,i,n){let m=this.#m?new Headers(this.#m.headers):this.#j??new Headers;if(typeof i==="object"&&"headers"in i){let l=i.headers instanceof Headers?i.headers:new Headers(i.headers);for(let[y,j]of l)if(y.toLowerCase()==="set-cookie")m.append(y,j);else m.set(y,j)}if(n)for(let[l,y]of Object.entries(n))if(typeof y==="string")m.set(l,y);else{m.delete(l);for(let j of y)m.append(l,j)}let c=typeof i==="number"?i:i?.status??this.#l;return hn(r,{status:c,headers:m})}newResponse=(...r)=>this.#y(...r);body=(r,i,n)=>this.#y(r,i,n);text=(r,i,n)=>{return!this.#j&&!this.#l&&!i&&!n&&!this.finalized?new Response(r):this.#y(r,i,Ec(Xy,n))};json=(r,i,n)=>{return this.#y(JSON.stringify(r),i,Ec("application/json",n))};html=(r,i,n)=>{let m=(c)=>this.#y(c,i,Ec("text/html; charset=UTF-8",n));return typeof r==="object"?Tn(r,Mm.Stringify,!1,{}).then(m):m(r)};redirect=(r,i)=>{let n=String(r);return this.header("Location",!/[^\x00-\xFF]/.test(n)?n:encodeURI(n)),this.newResponse(null,i??302)};notFound=()=>{return this.#A??=()=>hn(),this.#A(this)}};var o="ALL",Ky="all",Hy=["get","post","put","delete","options","patch"],Tm="Can not add a route since the matcher is already built.",hm=class extends Error{};var Dc="__COMPOSED_HANDLER";var gA=(r)=>{return r.text("404 Not Found",404)},Zy=(r,i)=>{if("getResponse"in r){let n=r.getResponse();return i.newResponse(n.body,n)}return console.error(r),i.text("Internal Server Error",500)},Vy=class r{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#r="/";routes=[];constructor(i={}){[...Hy,Ky].forEach((l)=>{this[l]=(y,...j)=>{if(typeof y==="string")this.#r=y;else this.#l(l,this.#r,y);return j.forEach((A)=>{this.#l(l,this.#r,A)}),this}}),this.on=(l,y,...j)=>{for(let A of[y].flat()){this.#r=A;for(let S of[l].flat())j.map((v)=>{this.#l(S.toUpperCase(),this.#r,v)})}return this},this.use=(l,...y)=>{if(typeof l==="string")this.#r=l;else this.#r="*",y.unshift(l);return y.forEach((j)=>{this.#l(o,this.#r,j)}),this};let{strict:m,...c}=i;Object.assign(this,c),this.getPath=m??!0?i.getPath??lc:ry}#i(){let i=new r({router:this.router,getPath:this.getPath});return i.errorHandler=this.errorHandler,i.#n=this.#n,i.routes=this.routes,i}#n=gA;errorHandler=Zy;route(i,n){let m=this.basePath(i);return n.routes.map((c)=>{let l;if(n.errorHandler===Zy)l=c.handler;else l=async(y,j)=>(await Gc([],n.errorHandler)(y,()=>c.handler(y,j))).res,l[Dc]=c.handler;m.#l(c.method,c.path,l,c.basePath)}),this}basePath(i){let n=this.#i();return n._basePath=Ji(this._basePath,i),n}onError=(i)=>{return this.errorHandler=i,this};notFound=(i)=>{return this.#n=i,this};mount(i,n,m){let c,l;if(m)if(typeof m==="function")l=m;else if(l=m.optionHandler,m.replaceRequest===!1)c=(A)=>A;else c=m.replaceRequest;let y=l?(A)=>{let S=l(A);return Array.isArray(S)?S:[S]}:(A)=>{let S=void 0;try{S=A.executionCtx}catch{}return[A.env,S]};c||=(()=>{let A=Ji(this._basePath,i),S=A==="/"?0:A.length;return(v)=>{let w=new URL(v.url);return w.pathname=this.getPath(v).slice(S)||"/",new Request(w,v)}})();let j=async(A,S)=>{let v=await n(c(A.req.raw),...y(A));if(v)return v;await S()};return this.#l(o,Ji(i,"*"),j),this}#l(i,n,m,c){i=i.toUpperCase(),n=Ji(this._basePath,n);let l={basePath:c!==void 0?Ji(this._basePath,c):this._basePath,path:n,method:i,handler:m};this.router.add(i,n,[m,l]),this.routes.push(l)}#c(i,n){if(i instanceof Error)return this.errorHandler(i,n);throw i}#m(i,n,m,c){if(c==="HEAD")return(async()=>new Response(null,await this.#m(i,n,m,"GET")))();let l=this.getPath(i,{env:m}),y=this.router.match(c,l),j=new Qc(i,{path:l,matchResult:y,env:m,executionCtx:n,notFoundHandler:this.#n});if(y[0].length===1){let S;try{S=y[0][0][0][0](j,async()=>{j.res=await this.#n(j)})}catch(v){return this.#c(v,j)}return S instanceof Promise?S.then((v)=>v||(j.finalized?j.res:this.#n(j))).catch((v)=>this.#c(v,j)):S??this.#n(j)}let A=Gc(y[0],this.errorHandler,this.#n);return(async()=>{try{let S=await A(j);if(!S.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return S.res}catch(S){return this.#c(S,j)}})()}fetch=(i,...n)=>{return this.#m(i,n[1],n[0],i.method)};request=(i,n,m,c)=>{if(i instanceof Request)return this.fetch(n?new Request(i,n):i,m,c);return i=i.toString(),this.fetch(new Request(/^https?:\/\//.test(i)?i:`http://localhost${Ji("/",i)}`,n),m,c)};fire=()=>{addEventListener("fetch",(i)=>{i.respondWith(this.#m(i.request,i,void 0,i.request.method))})}};var Bn=[];function Bm(r,i){let n=this.buildAllMatchers(),m=(c,l)=>{let y=n[c]||n[o],j=y[2][l];if(j)return j;let A=l.match(y[0]);if(!A)return[[],Bn];let S=A.indexOf("",1);return[y[1][S],A]};return this.match=m,m(r,i)}var om="[^/]+",on=".*",xn="(?:|/.*)",di=Symbol(),zA=new Set(".\\+*[^]$()");function MA(r,i){if(r.length===1)return i.length===1?r<i?-1:1:-1;if(i.length===1)return 1;if(r===on||r===xn)return 1;else if(i===on||i===xn)return-1;if(r===om)return 1;else if(i===om)return-1;return r.length===i.length?r<i?-1:1:i.length-r.length}var Yy=class r{#r;#i;#n=Object.create(null);insert(i,n,m,c,l){if(i.length===0){if(this.#r!==void 0)throw di;if(l)return;this.#r=n;return}let[y,...j]=i,A=y==="*"?j.length===0?["","",on]:["","",om]:y==="/*"?["","",xn]:y.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),S;if(A){let v=A[1],w=A[2]||om;if(v&&A[2]){if(w===".*")throw di;if(w=w.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(w))throw di}if(S=this.#n[w],!S){if(Object.keys(this.#n).some((N)=>N!==on&&N!==xn))throw di;if(l)return;if(S=this.#n[w]=new r,v!=="")S.#i=c.varIndex++}if(!l&&v!=="")m.push([v,S.#i])}else if(S=this.#n[y],!S){if(Object.keys(this.#n).some((v)=>v.length>1&&v!==on&&v!==xn))throw di;if(l)return;S=this.#n[y]=new r}S.insert(j,n,m,c,l)}buildRegExpStr(){let n=Object.keys(this.#n).sort(MA).map((m)=>{let c=this.#n[m];return(typeof c.#i==="number"?`(${m})@${c.#i}`:zA.has(m)?`\\${m}`:m)+c.buildRegExpStr()});if(typeof this.#r==="number")n.unshift(`#${this.#r}`);if(n.length===0)return"";if(n.length===1)return n[0];return"(?:"+n.join("|")+")"}};var Jy=class{#r={varIndex:0};#i=new Yy;insert(r,i,n){let m=[],c=[];for(let y=0;;){let j=!1;if(r=r.replace(/\{[^}]+\}/g,(A)=>{let S=`@\\${y}`;return c[y]=[S,A],y++,j=!0,S}),!j)break}let l=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let y=c.length-1;y>=0;y--){let[j]=c[y];for(let A=l.length-1;A>=0;A--)if(l[A].indexOf(j)!==-1){l[A]=l[A].replace(j,c[y][1]);break}}return this.#i.insert(l,i,m,this.#r,n),m}buildRegExp(){let r=this.#i.buildRegExpStr();if(r==="")return[/^$/,[],[]];let i=0,n=[],m=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(c,l,y)=>{if(l!==void 0)return n[++i]=Number(l),"$()";if(y!==void 0)return m[Number(y)]=++i,"";return""}),[new RegExp(`^${r}`),n,m]}};var TA=[/^$/,[],Object.create(null)],Ry=Object.create(null);function Oy(r){return Ry[r]??=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(i,n)=>n?`\\${n}`:"(?:|/.*)")}$`)}function hA(){Ry=Object.create(null)}function BA(r){let i=new Jy,n=[];if(r.length===0)return TA;let m=r.map((S)=>[!/\*|\/:/.test(S[0]),...S]).sort(([S,v],[w,N])=>S?1:w?-1:v.length-N.length),c=Object.create(null);for(let S=0,v=-1,w=m.length;S<w;S++){let[N,E,Q]=m[S];if(N)c[E]=[Q.map(([Z])=>[Z,Object.create(null)]),Bn];else v++;let W;try{W=i.insert(E,v,N)}catch(Z){throw Z===di?new hm(E):Z}if(N)continue;n[v]=Q.map(([Z,X])=>{let K=Object.create(null);X-=1;for(;X>=0;X--){let[R,q]=W[X];K[R]=q}return[Z,K]})}let[l,y,j]=i.buildRegExp();for(let S=0,v=n.length;S<v;S++)for(let w=0,N=n[S].length;w<N;w++){let E=n[S][w]?.[1];if(!E)continue;let Q=Object.keys(E);for(let W=0,Z=Q.length;W<Z;W++)E[Q[W]]=j[E[Q[W]]]}let A=[];for(let S in y)A[S]=n[y[S]];return[l,A,c]}function wn(r,i){if(!r)return;for(let n of Object.keys(r).sort((m,c)=>c.length-m.length))if(Oy(n).test(i))return[...r[n]];return}var xm=class{name="RegExpRouter";#r;#i;constructor(){this.#r={[o]:Object.create(null)},this.#i={[o]:Object.create(null)}}add(r,i,n){let m=this.#r,c=this.#i;if(!m||!c)throw Error(Tm);if(!m[r])[m,c].forEach((j)=>{j[r]=Object.create(null),Object.keys(j[o]).forEach((A)=>{j[r][A]=[...j[o][A]]})});if(i==="/*")i="*";let l=(i.match(/\/:/g)||[]).length;if(/\*$/.test(i)){let j=Oy(i);if(r===o)Object.keys(m).forEach((A)=>{m[A][i]||=wn(m[A],i)||wn(m[o],i)||[]});else m[r][i]||=wn(m[r],i)||wn(m[o],i)||[];Object.keys(m).forEach((A)=>{if(r===o||r===A)Object.keys(m[A]).forEach((S)=>{j.test(S)&&m[A][S].push([n,l])})}),Object.keys(c).forEach((A)=>{if(r===o||r===A)Object.keys(c[A]).forEach((S)=>j.test(S)&&c[A][S].push([n,l]))});return}let y=gm(i)||[i];for(let j=0,A=y.length;j<A;j++){let S=y[j];Object.keys(c).forEach((v)=>{if(r===o||r===v)c[v][S]||=[...wn(m[v],S)||wn(m[o],S)||[]],c[v][S].push([n,l-A+j+1])})}}match=Bm;buildAllMatchers(){let r=Object.create(null);return Object.keys(this.#i).concat(Object.keys(this.#r)).forEach((i)=>{r[i]||=this.#n(i)}),this.#r=this.#i=void 0,hA(),r}#n(r){let i=[],n=r===o;if([this.#r,this.#i].forEach((m)=>{let c=m[r]?Object.keys(m[r]).map((l)=>[l,m[r][l]]):[];if(c.length!==0)n||=!0,i.push(...c);else if(r!==o)i.push(...Object.keys(m[o]).map((l)=>[l,m[o][l]]))}),!n)return null;else return BA(i)}};var oA=class{name="PreparedRegExpRouter";#r;#i;constructor(r,i){this.#r=r,this.#i=i}#n(r,i){let n=this.#r[r];n[1].forEach((m)=>m&&m.push(i)),Object.values(n[2]).forEach((m)=>m[0].push(i))}#l(r,i,n,m,c){let l=this.#r[r];if(!c)l[2][i][0].push([n,{}]);else m.forEach((y)=>{if(typeof y==="number")l[1][y].push([n,c]);else l[2][y||i][0].push([n,c])})}add(r,i,n){if(!this.#r[r]){let c=this.#r[o],l={};for(let y in c[2])l[y]=[c[2][y][0].slice(),Bn];this.#r[r]=[c[0],c[1].map((y)=>Array.isArray(y)?y.slice():0),l]}if(i==="/*"||i==="*"){let c=[n,{}];if(r===o)for(let l in this.#r)this.#n(l,c);else this.#n(r,c);return}let m=this.#i[i];if(!m)throw Error(`Path ${i} is not registered`);for(let[c,l]of m)if(r===o)for(let y in this.#r)this.#l(y,i,n,c,l);else this.#l(r,i,n,c,l)}buildAllMatchers(){return this.#r}match=Bm};var Uc=class{name="SmartRouter";#r=[];#i=[];constructor(r){this.#r=r.routers}add(r,i,n){if(!this.#i)throw Error(Tm);this.#i.push([r,i,n])}match(r,i){if(!this.#i)throw Error("Fatal error");let n=this.#r,m=this.#i,c=n.length,l=0,y;for(;l<c;l++){let j=n[l];try{for(let A=0,S=m.length;A<S;A++)j.add(...m[A]);y=j.match(r,i)}catch(A){if(A instanceof hm)continue;throw A}this.match=j.match.bind(j),this.#r=[j],this.#i=void 0;break}if(l===c)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,y}get activeRouter(){if(this.#i||this.#r.length!==1)throw Error("No active router has been determined yet.");return this.#r[0]}};var kn=Object.create(null),xA=(r)=>{for(let i in r)return!0;return!1},Ly=class r{#r;#i;#n;#l=0;#c=kn;constructor(i,n,m){if(this.#i=m||Object.create(null),this.#r=[],i&&n){let c=Object.create(null);c[i]={handler:n,possibleKeys:[],score:0},this.#r=[c]}this.#n=[]}insert(i,n,m){this.#l=++this.#l;let c=this,l=el(n),y=[];for(let j=0,A=l.length;j<A;j++){let S=l[j],v=l[j+1],w=sl(S,v),N=Array.isArray(w)?w[0]:S;if(N in c.#i){if(c=c.#i[N],w)y.push(w[1]);continue}if(c.#i[N]=new r,w)c.#n.push(w),y.push(w[1]);c=c.#i[N]}return c.#r.push({[i]:{handler:m,possibleKeys:y.filter((j,A,S)=>S.indexOf(j)===A),score:this.#l}}),c}#m(i,n,m,c,l){for(let y=0,j=n.#r.length;y<j;y++){let A=n.#r[y],S=A[m]||A[o],v={};if(S!==void 0){if(S.params=Object.create(null),i.push(S),c!==kn||l&&l!==kn)for(let w=0,N=S.possibleKeys.length;w<N;w++){let E=S.possibleKeys[w],Q=v[S.score];S.params[E]=l?.[E]&&!Q?l[E]:c[E]??l?.[E],v[S.score]=!0}}}}search(i,n){let m=[];this.#c=kn;let l=[this],y=cc(n),j=[],A=y.length,S=null;for(let v=0;v<A;v++){let w=y[v],N=v===A-1,E=[];for(let W=0,Z=l.length;W<Z;W++){let X=l[W],K=X.#i[w];if(K)if(K.#c=X.#c,N){if(K.#i["*"])this.#m(m,K.#i["*"],i,X.#c);this.#m(m,K,i,X.#c)}else E.push(K);for(let R=0,q=X.#n.length;R<q;R++){let z=X.#n[R],L=X.#c===kn?{}:{...X.#c};if(z==="*"){let Br=X.#i["*"];if(Br)this.#m(m,Br,i,X.#c),Br.#c=L,E.push(Br);continue}let[f,hr,Yr]=z;if(!w&&!(Yr instanceof RegExp))continue;let x=X.#i[f];if(Yr instanceof RegExp){if(S===null){S=Array(A);let An=n[0]==="/"?1:0;for(let zn=0;zn<A;zn++)S[zn]=An,An+=y[zn].length+1}let Br=n.substring(S[v]),Yi=Yr.exec(Br);if(Yi){if(L[hr]=Yi[0],this.#m(m,x,i,X.#c,L),Yi[0].length===Br.length&&x.#i["*"])this.#m(m,x.#i["*"],i,X.#c,L);if(xA(x.#i)){x.#c=L;let An=Yi[0].match(/\//)?.length??0;(j[An]||=[]).push(x)}continue}}if(Yr===!0||Yr.test(w))if(L[hr]=w,N){if(this.#m(m,x,i,L,X.#c),x.#i["*"])this.#m(m,x.#i["*"],i,L,X.#c)}else x.#c=L,E.push(x)}}let Q=j.shift();l=Q?E.concat(Q):E}if(m.length>1)m.sort((v,w)=>{return v.score-w.score});return[m.map(({handler:v,params:w})=>[v,w])]}};var Pc=class{name="TrieRouter";#r;constructor(){this.#r=new Ly}add(r,i,n){let m=gm(i);if(m){for(let c=0,l=m.length;c<l;c++)this.#r.insert(r,m[c],n);return}this.#r.insert(r,i,n)}match(r,i){return this.#r.search(r,i)}};var V=class extends Vy{constructor(r={}){super(r);this.router=r.router??new Uc({routers:[new xm,new Pc]})}};var Cc=/^\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 kA={br:".br",zstd:".zst",gzip:".gz"},oN=Object.keys(kA);var Wc="x-hono-disable-ssg",jE=(()=>{try{return new Response("SSG is disabled",{status:404,headers:{[Wc]:"true"}})}catch{return null}})();var{write:xE}=Bun;var qy=class{#r;constructor(r){this.#r=r,this.raw=r.raw,this.url=r.url?new URL(r.url):null,this.protocol=r.protocol??null}send(r,i){this.#r.send(r,i??{})}raw;binaryType="arraybuffer";get readyState(){return this.#r.readyState}url;protocol;close(r,i){this.#r.close(r,i)}},_y=(r)=>{return new MessageEvent("message",{data:r})},Fy=(r)=>{return(...i)=>{if(typeof i[0]==="function"){let[n,m]=i;return async function(l,y){let j=await n(l),A=await r(l,j,m);if(A)return A;await y()}}else{let[n,m,c]=i;return(async()=>{let l=await r(n,m,c);if(!l)throw Error("Failed to upgrade WebSocket");return l})()}}};var km=(r)=>("server"in r.env)?r.env.server:r.env;var Xc=(r)=>{return new qy({send:(i,n)=>{r.send(i,n?.compress)},raw:r,readyState:r.readyState,url:r.data.url,protocol:r.data.protocol,close(i,n){r.close(i,n)}})},gy=Fy((r,i)=>{let n=km(r);if(!n)throw TypeError("env has to include the 2nd argument of fetch.");if(n.upgrade(r.req.raw,{data:{events:i,url:new URL(r.req.url),protocol:r.req.header("sec-websocket-protocol")?.split(",")[0]?.trim()??""}}))return new Response(null);return}),zy={open(r){let i=r.data.events;if(i.onOpen)i.onOpen(new Event("open"),Xc(r))},close(r,i,n){let m=r.data.events;if(m.onClose)m.onClose(new CloseEvent("close",{code:i,reason:n}),Xc(r))},message(r,i){let n=r.data.events;if(n.onMessage){let m=typeof i==="string"?i:i.buffer;n.onMessage(_y(m),Xc(r))}}},Kc=()=>({upgradeWebSocket:gy,websocket:zy});var My={create(r){let i=Kc();return{upgradeWebSocket:i.upgradeWebSocket,async listen(n){let m={fetch:r.fetch,hostname:n.hostname,idleTimeout:0,websocket:i.websocket},c=(y)=>{try{return Bun.serve({...m,port:y})}catch{return}},l=n.port===0?c(4096)??c(0):c(n.port);if(!l)throw Error(`Failed to start server on port ${n.port}`);if(!l.port)throw Error(`Failed to resolve server address for port ${n.port}`);return{port:l.port,stop(y){return Promise.resolve(l.stop(y))}}}}}};var Nn={};Nr(Nn,{unpublish:()=>Zj,publish:()=>Iv,MDNS:()=>Nn});var Hj=jv(Kj(),1),dn=_.create({service:"mdns"}),li,em;function Iv(r,i){if(em===r)return;if(li)Zj();try{let n=i??"qitqode.local",m=`qitqode-${r}`;li=new Hj.Bonjour;let c=li.publish({name:m,type:"http",host:n,port:r,txt:{path:"/"}});c.on("up",()=>{dn.info("mDNS service published",{name:m,port:r})}),c.on("error",(l)=>{dn.error("mDNS service error",{error:l})}),em=r}catch(n){if(dn.error("mDNS publish failed",{error:n}),li)try{li.destroy()}catch{}li=void 0,em=void 0}}function Zj(){if(li){try{li.unpublishAll(),li.destroy()}catch(r){dn.error("mDNS unpublish failed",{error:r})}li=void 0,em=void 0,dn.info("mDNS service unpublished")}}var Vj=(r)=>{let i=atob(r),n=new Uint8Array(new ArrayBuffer(i.length)),m=i.length/2;for(let c=0,l=i.length-1;c<=m;c++,l--)n[c]=i.charCodeAt(c),n[l]=i.charCodeAt(l);return n};var Av=/^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/,Sv=/^([^:]*):(.*)$/,vv=new TextDecoder,Yj=(r)=>{let i=Av.exec(r.headers.get("Authorization")||"");if(!i)return;let n=void 0;try{n=Sv.exec(vv.decode(Vj(i[1])))}catch{}if(!n)return;return{username:n[1],password:n[2]}};var Jj=(r,...i)=>{let n="username"in r&&"password"in r,m="verifyUser"in r;if(!(n||m))throw Error('basic auth middleware requires options for "username and password" or "verifyUser"');if(!r.realm)r.realm="Secure Area";if(!r.invalidUserMessage)r.invalidUserMessage="Unauthorized";if(n)i.unshift({username:r.username,password:r.password});return async function(l,y){let j=Yj(l.req.raw);if(j)if(m){if(await r.verifyUser(j.username,j.password,l)){if(r.onAuthSuccess)await r.onAuthSuccess(l,j.username);await y();return}}else for(let N of i){let[E,Q]=await Promise.all([Ic(N.username,j.username,r.hashFunction),Ic(N.password,j.password,r.hashFunction)]);if(E&&Q){if(r.onAuthSuccess)await r.onAuthSuccess(l,j.username);await y();return}}let A=401,S={"WWW-Authenticate":'Basic realm="'+r.realm?.replace(/"/g,"\\\"")+'"'},v=typeof r.invalidUserMessage==="function"?await r.invalidUserMessage(l):r.invalidUserMessage,w=typeof v==="string"?new Response(v,{status:A,headers:S}):new Response(JSON.stringify(v),{status:A,headers:{...S,"content-type":"application/json"}});throw new kr(A,{res:w})}};var Rj=(r)=>{let i={origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[],...r},n=((c)=>{if(typeof c==="string")if(c==="*")return()=>c;else return(l)=>c===l?l:null;else if(typeof c==="function")return c;else return(l)=>c.includes(l)?l:null})(i.origin),m=((c)=>{if(typeof c==="function")return c;else if(Array.isArray(c))return()=>c;else return()=>[]})(i.allowMethods);return async function(l,y){function j(S,v){l.res.headers.set(S,v)}let A=await n(l.req.header("origin")||"",l);if(A)j("Access-Control-Allow-Origin",A);if(i.credentials)j("Access-Control-Allow-Credentials","true");if(i.exposeHeaders?.length)j("Access-Control-Expose-Headers",i.exposeHeaders.join(","));if(l.req.method==="OPTIONS"){if(i.origin!=="*")j("Vary","Origin");if(i.maxAge!=null)j("Access-Control-Max-Age",i.maxAge.toString());let S=await m(l.req.header("origin")||"",l);if(S.length)j("Access-Control-Allow-Methods",S.join(","));let v=i.allowHeaders;if(!v?.length){let w=l.req.header("Access-Control-Request-Headers");if(w)v=w.split(/\s*,\s*/)}if(v?.length)j("Access-Control-Allow-Headers",v.join(",")),l.res.headers.append("Vary","Access-Control-Request-Headers");return l.res.headers.delete("Content-Length"),l.res.headers.delete("Content-Type"),new Response(null,{headers:l.res.headers,status:204,statusText:"No Content"})}if(await y(),i.origin!=="*")l.header("Vary","Origin",{append:!0})}};var Lj=(r)=>r===32||r===9||r===10||r===13,sm=(r,i)=>{while(i<r.length){if(!Lj(r.charCodeAt(i)))break;i++}return i},tn=(r,i)=>{while(i>0){if(!Lj(r.charCodeAt(i-1)))break;i--}return i},Oj=(r,i)=>{while(i<r.length){let n=r.charCodeAt(i);if(n===59)return[i+1,!0];if(n===44)return[i+1,!1];i++}return[i,!1]},wv=(r,i)=>{let n=i,m=!1;while(n<r.length){let c=r.charCodeAt(n);if(m&&c===92)n++;else if(c===34)m=!m;else if(!m&&c===44)return n+1;n++}return n},$v=(r,i)=>{i=sm(r,i);let n=i,m,c,l=!1;while(n<r.length){let A=r.charCodeAt(n);if(A===61){m=r.slice(i,tn(r,n)),n++;break}if(A===59)return[n+1,void 0,void 0,!0];if(A===44)return[n+1,void 0,void 0,!1];n++}if(m===void 0)return[n,void 0,void 0,!1];if(n=sm(r,n),r.charCodeAt(n)===61){let A=Oj(r,n+1);return[A[0],m,void 0,A[1]]}let y=!1,j=n;while(n<r.length){let A=r.charCodeAt(n);if(y&&A===92)n++;else if(A===34){if(y){let S=sm(r,n+1),v=r.charCodeAt(S);if(S<r.length&&!(v===59||v===44)){let w=Oj(r,S);return[w[0],m,void 0,w[1]]}if(c=r.slice(j+1,n),c.includes("\\"))c=c.replace(/\\(.)/g,"$1");if(v===44)return[S+1,m,c,!1];if(v===59)l=!0,S++;n=S;break}y=!0}else if(!y&&(A===59||A===44)){if(c=r.slice(j,tn(r,n)),A===59)l=!0;n++;break}n++}return[n,m,c??r.slice(j,tn(r,n)),l]},Gv=(r,i)=>{let n={type:"",params:{},q:1};i=sm(r,i);let m=i;while(m<r.length){let j=r.charCodeAt(m);if(j===59||j===44){if(n.type=r.slice(i,tn(r,m)),m++,j===44)return[m,n.type?n:void 0];if(!n.type)return[wv(r,m),void 0];break}m++}if(!n.type)return n.type=r.slice(i,tn(r,r.length)),[r.length,n.type?n:void 0];let c,l,y;while(m<r.length){if([m,c,l,y]=$v(r,m),c&&l)n.params[c]=l;if(!y)break}return[m,n]},qj=(r)=>{if(!r)return[];let i=[],n=0,m,c=!1,l;while(n<r.length)if([n,m]=Gv(r,n),m){if(m.q=Nv(m.params.q),i.push(m),l&&l.q<m.q)c=!0;l=m}if(c)i.sort((y,j)=>j.q-y.q);return i},Nv=(r)=>{if(r===void 0)return 1;if(r==="")return 1;if(r==="NaN")return 0;let i=Number(r);if(i===1/0)return 1;if(i===-1/0)return 0;if(Number.isNaN(i))return 1;if(i<0||i>1)return 1;return i};var Ev=["gzip","deflate"],Qv=/(?:^|,)\s*?no-transform\s*?(?:,|$)/i,Dv=(r,i)=>{if(r===void 0)return;let n=qj(r),m=n.find((l)=>l.type==="*")?.q,c;for(let l of i){let y=n.find((A)=>A.type.toLowerCase()===l),j=y?y.q:m??0;if(j===1)return l;else if(j>0&&(!c||j>c.q))c={encoding:l,q:j}}return c?.encoding},_j=(r)=>{let i=r?.threshold??1024,n=r?.encoding?[r.encoding]:Ev,m=r?.contentTypeFilter??Cc,c=typeof m==="function"?(l)=>{let y=l.headers.get("Content-Type");return y&&m(y)}:(l)=>{let y=l.headers.get("Content-Type");return y&&m.test(y)};return async function(y,j){await j();let A=y.res.headers.get("Content-Length");if(y.res.status===206||y.res.headers.has("Content-Encoding")||y.res.headers.has("Transfer-Encoding")||y.req.method==="HEAD"||A&&Number(A)<i||!c(y.res)||!Uv(y.res))return;let S=y.req.header("Accept-Encoding"),v=Dv(S,n);if(!v||!y.res.body)return;let w=new CompressionStream(v);y.res=new Response(y.res.body.pipeThrough(w),y.res),y.res.headers.delete("Content-Length"),y.res.headers.set("Content-Encoding",v);let N=y.res.headers.get("ETag");if(N&&!N.startsWith("W/"))y.res.headers.set("ETag",`W/${N}`)}},Uv=(r)=>{let i=r.headers.get("Cache-Control");return!i||!Qv.test(i)};import{randomUUID as Pv}from"crypto";var fm="ticket",Fj="x-qitqode-ticket",gj="1",Cv=/^\/pty\/[^/]+\/connect$/,Wv=60000,bn=new Map;function Xv(){let r=Date.now();for(let[i,n]of bn)if(n.expiresAt<=r)bn.delete(i)}function zj(r){return Cv.test(r)}function Mj(r,i=Wv){Xv();let n=Pv();return bn.set(n,{ptyID:r,expiresAt:Date.now()+i}),{ticket:n,expires_in:Math.round(i/1000)}}function Tj(r,i){let n=bn.get(r);if(!n)return!1;if(bn.delete(r),n.expiresAt<=Date.now())return!1;return n.ptyID===i}var r0=_.create({service:"server"}),hj=(r,i)=>{let n=crypto.randomUUID();r0.error("failed",{error_id:n,error:r});let m=()=>i.json(new En.Unknown({message:"Internal server error"}).toObject(),{status:500,headers:{"x-qitqode-error-id":n}});if(r instanceof En){let c;if(r instanceof Ci)c=404;else if(r instanceof ir.ModelNotFoundError)c=400;else if(r.name==="ProviderAuthValidationFailed")c=400;else if(r.name.startsWith("Worktree"))c=400;else c=500;if(c===500)return m();return i.json(r.toObject(),{status:c})}if(r instanceof J.BusyError)return i.json(new En.Unknown({message:r.message}).toObject(),{status:409});if(r instanceof kr)return r.getResponse();return m()},Bj=(r,i)=>{if(r.req.method==="OPTIONS")return i();let n=k.QITQODE_SERVER_PASSWORD;if(!n)return i();let m=new URL(r.req.url).pathname;if(zj(m)&&r.req.query(fm))return i();let c=k.QITQODE_SERVER_USERNAME??"qitqode";return Jj({username:c,password:n})(r,i)},oj=async(r,i)=>{let n=r.req.path==="/log";if(!n)r0.info("request",{method:r.req.method,path:r.req.path});let m=r0.time("request",{method:r.req.method,path:r.req.path});if(await i(),!n)m.stop()};function xj(r){return Rj({maxAge:86400,origin(i){if(!i)return;if(r?.cors?.includes(i))return i}})}function Kv(r){return r==="localhost"||r==="::1"||/^127(\.\d{1,3}){3}$/.test(r)||r==="127.0.0.1"}function Hv(r){if(r.startsWith("[")){let i=r.indexOf("]");return i===-1?r:r.slice(1,i)}return r.split(":")[0]}function kj(r){let i=r.hostname===void 0,n=r.hostname==="0.0.0.0"||r.hostname==="::";return(m,c)=>{if(i||n)return c();let l=m.req.header("host");if(!l)return c();let y=Hv(l);if(Kv(y))return c();if(r.hostname&&y===r.hostname)return c();if(r.mdnsDomain&&y===r.mdnsDomain)return c();if(r.allowedHosts?.includes(y))return c();throw r0.warn("rejected request with unexpected Host header",{host:y}),new kr(403,{message:`Forbidden: unexpected Host header "${y}"`})}}var Zv=_j(),pj=(r,i)=>{let n=r.req.path,m=r.req.method;if(n==="/event"||n==="/global/event")return i();if(m==="POST"&&/\/session\/[^/]+\/(message|prompt_async)$/.test(n))return i();return Zv(r,i)};var p={};Nr(p,{waitForSync:()=>Tv,status:()=>zv,startWorkspaceSyncing:()=>uc,sessionRestore:()=>qv,remove:()=>Fv,list:()=>_v,isSyncing:()=>Mv,get:()=>i1,create:()=>Ov,Workspace:()=>p,Info:()=>i0,Event:()=>sn,ConnectionStatus:()=>r1});var uj=["forgewise"];var Vv=new TextEncoder;function Yv(r){return Vv.encode(r).byteLength}function aj(r,i=16384){let n=[...uj.filter((l)=>(l in r)),...Object.keys(r).filter((l)=>!uj.includes(l))],m={},c=0;for(let l of n){let y={...m,[l]:r[l]},j=JSON.stringify(y);if(Yv(j)>i)continue;m[l]=r[l],c+=1}if(c===0)return;return JSON.stringify(m)}var Hr=dj("workspace",{id:Li().$type().primaryKey(),type:Li().notNull(),name:Li().notNull().default(""),branch:Li(),directory:Li(),extra:Li({mode:"json"}),project_id:Li().$type().notNull().references(()=>tj.id,{onDelete:"cascade"})});async function bj(r,i,n){let m=r.getReader(),c=new TextDecoder,l="",y="",j=1000,A=()=>{m.cancel().catch(()=>{return})};if(i.addEventListener("abort",A),i.aborted)A();try{while(!i.aborted){let S=await m.read().catch(()=>({done:!0,value:void 0}));if(S.done)break;l+=c.decode(S.value,{stream:!0}),l=l.replace(/\r\n/g,`
|
|
3
|
+
`).replace(/\r/g,`
|
|
4
|
+
`);let v=l.split(`
|
|
5
|
+
|
|
6
|
+
`);l=v.pop()??"",v.forEach((w)=>{let N=[],E=(W)=>{let Z=W.slice(W.indexOf(":")+1);return Z.startsWith(" ")?Z.slice(1):Z};if(w.split(`
|
|
7
|
+
`).forEach((W)=>{if(W.startsWith("data:")){N.push(E(W));return}if(W.startsWith("id:")){y=E(W);return}if(W.startsWith("retry:")){let Z=Number.parseInt(E(W),10);if(!Number.isNaN(Z))j=Z}}),!N.length)return;let Q=N.join(`
|
|
8
|
+
`);try{n(JSON.parse(Q))}catch{n({type:"sse.message",properties:{data:Q,id:y||void 0,retry:j}})}})}}finally{i.removeEventListener("abort",A),m.releaseLock()}}function pc(r){if(r.signal?.aborted)return Promise.reject(r.signal.reason??Error("Request aborted"));return new Promise((i,n)=>{let m=()=>{l(),n(r.signal?.reason??Error("Request aborted"))},c=(j)=>{try{if(!r.fn(j))return;l(),i()}catch(A){l(),n(A)}},l=()=>{clearTimeout(y),Lr.off("event",c),r.signal?.removeEventListener("abort",m)},y=setTimeout(()=>{l(),n(Error("Timed out waiting for global event"))},r.timeout);if(Lr.on("event",c),r.signal?.addEventListener("abort",m,{once:!0}),r.signal?.aborted)m()})}var i0=fj.meta({ref:"Workspace"}),r1=I.object({workspaceID:qr.zod,status:I.enum(["connected","connecting","disconnected","error"])}),Jv=I.object({workspaceID:qr.zod,sessionID:br.zod,total:I.number().int().min(0),step:I.number().int().min(0)}),sn={Ready:yi.define("workspace.ready",I.object({name:I.string()})),Failed:yi.define("workspace.failed",I.object({message:I.string()})),Restore:yi.define("workspace.restore",Jv),Status:yi.define("workspace.status",r1)};function y0(r){return{id:r.id,type:r.type,branch:r.branch,name:r.name,directory:r.directory,extra:r.extra,projectID:r.project_id}}var Rv=I.object({id:qr.zod.optional(),type:i0.shape.type,branch:i0.shape.branch,projectID:l0.zod,extra:i0.shape.extra}),Ov=im(Rv,async(r)=>{let i=qr.ascending(r.id),n=await _i(r.projectID,r.type),m=await n.configure({...r,id:i,name:sj.create(),directory:null}),c={id:i,type:m.type,branch:m.branch??null,name:m.name??null,directory:m.directory??null,extra:m.extra??null,projectID:r.projectID};b.use((A)=>{A.insert(Hr).values({id:c.id,type:c.type,branch:c.branch,name:c.name,directory:c.directory,extra:c.extra,project_id:c.projectID}).run()});let l=aj(await e.runPromise(rm.Service.use((A)=>A.all()))),y={...l!==void 0?{QITQODE_AUTH_CONTENT:l}:{},QITQODE_WORKSPACE_ID:m.id,QITQODE_EXPERIMENTAL_WORKSPACES:"true",OTEL_EXPORTER_OTLP_HEADERS:process.env.OTEL_EXPORTER_OTLP_HEADERS,OTEL_EXPORTER_OTLP_ENDPOINT:process.env.OTEL_EXPORTER_OTLP_ENDPOINT,OTEL_RESOURCE_ATTRIBUTES:process.env.OTEL_RESOURCE_ATTRIBUTES};await n.create(m,y);let j=pc({timeout:n1,fn(A){if(A.workspace===c.id&&A.payload.type===sn.Status.type){let{status:S}=A.payload.properties;return S==="error"||S==="connected"}return!1}});return await m1(c),await j,c}),Lv=I.object({workspaceID:qr.zod,sessionID:br.zod}),qv=im(Lv,async(r)=>{Ir.info("session restore requested",{workspaceID:r.workspaceID,sessionID:r.sessionID});try{let i=await i1(r.workspaceID);if(!i)throw Error(`Workspace not found: ${r.workspaceID}`);let m=await(await _i(i.projectID,i.type)).target(i);yr.run(J.Event.Updated,{sessionID:r.sessionID,info:{workspaceID:r.workspaceID}});let c=b.use((S)=>S.select({id:Zr.id,aggregateID:Zr.aggregate_id,seq:Zr.seq,type:Zr.type,data:Zr.data}).from(Zr).where(d(Zr.aggregate_id,r.sessionID)).orderBy(c0(Zr.seq)).all());if(c.length===0)throw Error(`No events found for session: ${r.sessionID}`);let l=c,y=100,j=Array.from({length:Math.ceil(l.length/y)},(S,v)=>l.slice(v*y,(v+1)*y)),A=j.length;Ir.info("session restore prepared",{workspaceID:r.workspaceID,sessionID:r.sessionID,workspaceType:i.type,directory:i.directory,target:m.type==="remote"?String(en(m.url,"/sync/replay")):m.directory,events:l.length,batches:A,first:l[0]?.seq,last:l.at(-1)?.seq}),Lr.emit("event",{directory:"global",workspace:r.workspaceID,payload:{type:sn.Restore.type,properties:{workspaceID:r.workspaceID,sessionID:r.sessionID,total:A,step:0}}});for(let[S,v]of j.entries()){if(Ir.info("session restore batch starting",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,events:v.length,first:v[0]?.seq,last:v.at(-1)?.seq,target:m.type==="remote"?String(en(m.url,"/sync/replay")):m.directory}),m.type==="local")yr.replayAll(v),Ir.info("session restore batch replayed locally",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,events:v.length});else{let w=en(m.url,"/sync/replay"),N=new Headers(m.headers);N.set("content-type","application/json");let E=await fetch(w,{method:"POST",headers:N,body:JSON.stringify({directory:i.directory??"",events:v})});if(!E.ok){let Q=await E.text();throw Ir.error("session restore batch failed",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,status:E.status,body:Q}),Error(`Failed to replay session ${r.sessionID} into workspace ${r.workspaceID}: HTTP ${E.status} ${Q}`)}Ir.info("session restore batch posted",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,status:E.status})}Lr.emit("event",{directory:"global",workspace:r.workspaceID,payload:{type:sn.Restore.type,properties:{workspaceID:r.workspaceID,sessionID:r.sessionID,total:A,step:S+1}}})}return Ir.info("session restore complete",{workspaceID:r.workspaceID,sessionID:r.sessionID,batches:A}),{total:A}}catch(i){throw Ir.error("session restore failed",{workspaceID:r.workspaceID,sessionID:r.sessionID,error:m0(i)}),i}});function _v(r){return b.use((m)=>m.select().from(Hr).where(d(Hr.project_id,r.id)).all()).map(y0).sort((m,c)=>m.id.localeCompare(c.id))}var i1=im(qr.zod,async(r)=>{let i=b.use((n)=>n.select().from(Hr).where(d(Hr.id,r)).get());if(!i)return;return y0(i)}),Fv=im(qr.zod,async(r)=>{let i=b.use((m)=>m.select({id:nr.id}).from(nr).where(d(nr.workspace_id,r)).all());for(let m of i)await e.runPromise(J.Service.use((c)=>c.remove(m.id)));let n=b.use((m)=>m.select().from(Hr).where(d(Hr.id,r)).get());if(n){xv(r);let m=y0(n);try{await(await _i(m.projectID,n.type)).remove(m)}catch{Ir.error("adaptor not available when removing workspace",{type:n.type})}return b.use((c)=>c.delete(Hr).where(d(Hr.id,r)).run()),m}}),n0=new Map,Qn=new Map,n1=5000;function gv(r,i){return new Promise((n)=>{if(i.aborted){n();return}let m=()=>{clearTimeout(c),i.removeEventListener("abort",m),n()},c=setTimeout(m,r);if(i.addEventListener("abort",m,{once:!0}),i.aborted)m()})}function qi(r,i){if(n0.get(r)?.status===i)return;let m={workspaceID:r,status:i};n0.set(r,m),Lr.emit("event",{directory:"global",workspace:r,payload:{type:sn.Status.type,properties:m}})}function zv(){return[...n0.values()]}function ej(r){let i=Object.keys(r);if(i.length===0)return!0;let n=Object.fromEntries(b.use((m)=>m.select({id:tr.aggregate_id,seq:tr.seq}).from(tr).where(fn(tr.aggregate_id,i)).all()).map((m)=>[m.id,m.seq]));return i.every((m)=>{return(n[m]??-1)>=r[m]})}async function Mv(r){return Qn.has(r)}async function Tv(r,i,n){if(ej(i))return;try{await pc({timeout:n1,signal:n,fn(m){if(m.workspace!==r||m.payload.type!=="sync")return!1;return ej(i)}})}catch{if(n?.aborted)throw n.reason??Error("Request aborted");throw Error(`Timed out waiting for sync fence: ${JSON.stringify(i)}`)}}var Ir=_.create({service:"workspace-sync"});function en(r,i){let n=new URL(r);return n.pathname=`${n.pathname.replace(/\/$/,"")}${i}`,n.search="",n.hash="",n}async function hv(r,i,n){let m=await fetch(en(r,"/global/event"),{method:"GET",headers:i,signal:n});if(!m.ok)throw Error(`Workspace sync HTTP failure: ${m.status}`);if(!m.body)throw Error("No response body from global sync");return m.body}async function Bv(r,i,n,m){let c=b.use((S)=>S.select({id:nr.id}).from(nr).where(d(nr.workspace_id,r.id)).all().map((v)=>v.id)),l=c.length?Object.fromEntries(b.use((S)=>S.select().from(tr).where(fn(tr.aggregate_id,c)).all()).map((S)=>[S.aggregate_id,S.seq])):{};Ir.info("syncing workspace history",{workspaceID:r.id,sessions:c.length,known:Object.keys(l).length});let y=new Headers(n);y.set("content-type","application/json");let j=await fetch(en(i,"/sync/history"),{method:"POST",headers:y,body:JSON.stringify(l),signal:m});if(!j.ok){let S=await j.text();throw Error(`Workspace history HTTP failure: ${j.status} ${S}`)}let A=await j.json();return Ir.info("workspace history synced",{workspaceID:r.id,events:A.length}),Dn.provide({workspaceID:r.id,fn:()=>{for(let S of A)yr.replay({id:S.id,aggregateID:S.aggregate_id,seq:S.seq,type:S.type,data:S.data},{publish:!0})}})}async function ov(r,i){let m=await(await _i(r.projectID,r.type)).target(r);if(m.type==="local")return null;let c=0;while(!i.aborted){Ir.info("connecting to global sync",{workspace:r.name}),qi(r.id,"connecting");let l;try{l=await hv(m.url,m.headers,i),await Bv(r,m.url,m.headers,i)}catch(y){await l?.cancel().catch(()=>{return}),l=null,qi(r.id,"error"),Ir.info("failed to connect to global sync",{workspace:r.name,err:y})}if(l)c=0,Ir.info("global sync connected",{workspace:r.name}),qi(r.id,"connected"),await bj(l,i,(y)=>{try{if(!("payload"in y))return;if(y.payload.type==="server.heartbeat")return;if(y.payload.type==="sync")yr.replay(y.payload.syncEvent);Lr.emit("event",{directory:y.directory,project:y.project,workspace:r.id,payload:y.payload})}catch(j){Ir.info("failed to replay global event",{workspaceID:r.id,error:j})}}),Ir.info("disconnected from global sync: "+r.id),qi(r.id,"disconnected");await gv(Math.min(120000,1000*2**c),i),c+=1}}async function m1(r){if(!k.QITQODE_EXPERIMENTAL_WORKSPACES)return;let n=await(await _i(r.projectID,r.type)).target(r);if(n.type==="local"){Wi.exists(n.directory).then((c)=>{qi(r.id,c?"connected":"error")});return}if(Qn.has(r.id))return!0;qi(r.id,"disconnected");let m=new AbortController;Qn.set(r.id,m),ov(r,m.signal).catch((c)=>{Qn.delete(r.id),qi(r.id,"error"),Ir.warn("workspace listener failed",{workspaceID:r.id,error:c})})}function xv(r){Qn.get(r)?.abort(),Qn.delete(r),n0.delete(r)}function uc(r){let i=b.use((n)=>n.select({workspace:Hr}).from(Hr).innerJoin(nr,d(nr.workspace_id,Hr.id)).where(d(Hr.project_id,r)).all());for(let n of new Map(i.map((m)=>[m.workspace.id,m.workspace])).values()){let m=y0(n);m1(m).catch((c)=>{qi(m.id,"error"),Ir.warn("failed to start workspace sync",{workspaceID:m.id,error:c})})}}var l1="x-qitqode-sync",ac=_.create({service:"fence"});function c1(r){let i=b.use((n)=>{if(!r?.length)return n.select().from(tr).all();return n.select().from(tr).where(fn(tr.aggregate_id,r)).all()});return Object.fromEntries(i.map((n)=>[n.aggregate_id,n.seq]))}function kv(r,i){let n=new Set([...Object.keys(r),...Object.keys(i)]);return Object.fromEntries([...n].map((m)=>[m,i[m]??-1]).filter(([m,c])=>{return(r[m]??-1)!==c}))}function y1(r){let i=r.get(l1);if(!i)return;let n;try{n=JSON.parse(i)}catch{return}if(!n||typeof n!=="object")return;return Object.fromEntries(Object.entries(n).filter(([m,c])=>{return typeof m==="string"&&Number.isInteger(c)}))}async function j1(r,i,n){ac.info("waiting for state",{workspaceID:r,state:i}),await p.waitForSync(r,i,n),ac.info("state fully synced",{workspaceID:r,state:i})}var I1=async(r,i)=>{if(r.req.method==="GET"||r.req.method==="HEAD"||r.req.method==="OPTIONS")return i();let n=c1();await i();let m=kv(n,c1());if(Object.keys(m).length>0)ac.info("header",{diff:m}),r.res.headers.set(l1,JSON.stringify(m))};var A1=_.create({service:"session.projector"});function S1(r){if(typeof r!=="object"||r===null)return!1;if("code"in r&&r.code==="SQLITE_CONSTRAINT_FOREIGNKEY")return!0;return"message"in r&&typeof r.message==="string"&&r.message.includes("FOREIGN KEY constraint failed")}function B(r,i,n){if(r==null||!(i in r))return;let m=r[i];if(m&&typeof m==="object"&&n)return n(m);if(m===void 0)throw Error("Session update failure: pass `null` to clear a field instead of `undefined`: "+JSON.stringify(r));return m}function uv(r){let i={id:B(r,"id"),project_id:B(r,"projectID"),workspace_id:B(r,"workspaceID"),parent_id:B(r,"parentID"),context_from:B(r,"contextFrom"),context_watermark:B(r,"contextWatermark"),slug:B(r,"slug"),directory:B(r,"directory"),title:B(r,"title"),version:B(r,"version"),share_url:B(r,"share",(n)=>B(n,"url")),summary_additions:B(r,"summary",(n)=>B(n,"additions")),summary_deletions:B(r,"summary",(n)=>B(n,"deletions")),summary_files:B(r,"summary",(n)=>B(n,"files")),summary_diffs:B(r,"summary",(n)=>B(n,"diffs")),revert:B(r,"revert"),permission:B(r,"permission"),time_created:B(r,"time",(n)=>B(n,"created")),time_updated:B(r,"time",(n)=>B(n,"updated")),time_compacting:B(r,"time",(n)=>B(n,"compacting")),time_archived:B(r,"time",(n)=>B(n,"archived"))};return Object.fromEntries(Object.entries(i).filter(([n,m])=>m!==void 0))}var v1=[yr.project(j0.Created,(r,i)=>{r.insert(nr).values(w1(i.info)).run()}),yr.project(j0.Updated,(r,i)=>{let n=i.info;if(!r.update(nr).set(uv(n)).where(d(nr.id,i.sessionID)).returning().get())throw new Ci({message:`Session not found: ${i.sessionID}`})}),yr.project(j0.Deleted,(r,i)=>{r.delete(nr).where(d(nr.id,i.sessionID)).run()}),yr.project(vr.Event.Updated,(r,i)=>{let n=i.info.time.created,{id:m,sessionID:c,agentID:l,...y}=i.info;try{r.insert(Xi).values({id:m,session_id:c,agent_id:l??"main",time_created:n,data:y}).onConflictDoUpdate({target:Xi.id,set:{agent_id:l??"main",data:y}}).run()}catch(j){if(!S1(j))throw j;A1.warn("ignored late message update",{messageID:m,sessionID:c})}}),yr.project(vr.Event.Removed,(r,i)=>{r.delete(Xi).where(nm(d(Xi.id,i.messageID),d(Xi.session_id,i.sessionID))).run()}),yr.project(vr.Event.PartRemoved,(r,i)=>{r.delete(Ki).where(nm(d(Ki.id,i.partID),d(Ki.session_id,i.sessionID))).run()}),yr.project(vr.Event.PartUpdated,(r,i)=>{let{id:n,messageID:m,sessionID:c,...l}=i.part;try{r.insert(Ki).values({id:n,message_id:m,session_id:c,time_created:i.time,data:l}).onConflictDoUpdate({target:Ki.id,set:{data:l}}).run()}catch(y){if(!S1(y))throw y;A1.warn("ignored late part update",{partID:n,messageID:m,sessionID:c})}})];function dc(){yr.init({projectors:v1,convertEvent:(r,i)=>{if(r==="session.updated"){let n=i.sessionID,m=b.use((c)=>c.select().from(nr).where(d(nr.id,n)).get());if(!m)return i;return{sessionID:n,info:J.fromRow(m)}}return i}})}dc();class Un{queue=[];resolvers=[];capacity;maxWeight;itemWeight;totalWeight=0;dropped=0;droppedWeight=0;constructor(r){this.capacity=r?.capacity??1/0,this.maxWeight=r?.maxWeight??1/0,this.itemWeight=r?.weight??(()=>1)}push(r){let i=this.resolvers.shift();if(i)return i(r),!0;let n=this.itemWeight(r);if(!Number.isFinite(n)||n<0)throw Error("Queue item weight must be a finite non-negative number");if(this.capacity<=0)return this.dropped++,this.droppedWeight+=n,!1;if(n>this.maxWeight)return this.dropped++,this.droppedWeight+=n,!1;while(this.queue.length>=this.capacity||this.totalWeight+n>this.maxWeight){let m=this.queue.shift();if(!m)break;this.totalWeight-=m.weight,this.dropped++,this.droppedWeight+=m.weight}return this.queue.push({item:r,weight:n}),this.totalWeight+=n,!0}get size(){return this.queue.length}get bufferedWeight(){return this.totalWeight}async next(){if(this.queue.length>0){let r=this.queue.shift();return this.totalWeight-=r.weight,r.item}return new Promise((r)=>this.resolvers.push(r))}async*[Symbol.asyncIterator](){while(!0)yield await this.next()}}var av={400:{description:"Bad request",content:{"application/json":{schema:$(I.object({data:I.any(),errors:I.array(I.record(I.string(),I.any())),success:I.literal(!1)}).meta({ref:"BadRequestError"}))}}},404:{description:"Not found",content:{"application/json":{schema:$(Ci.Schema)}}},409:{description:"Conflict \u2014 session resource is busy",content:{"application/json":{schema:$(I.object({name:I.literal("UnknownError"),data:I.object({message:I.string()})}).meta({ref:"ConflictError"}))}}}};function P(...r){return Object.fromEntries(r.map((i)=>[i,av[i]]))}function dv(r){let i=r.match(/^(.+)ID$/);if(i)return`${i[1].toLowerCase()}.id`;return`qitqode.${r}`}function tv(r){let i={"http.method":r.req.method,"http.path":new URL(r.req.url).pathname};for(let[n,m]of Object.entries(r.req.param()))i[dv(n)]=m;return i}function u(r,i,n){return e.runPromise(n.pipe(C.withSpan(r,{attributes:tv(i)})))}async function U(r,i,n){return i.json(await u(r,i,C.gen(()=>n(i))))}var bv=I.object({path:I.string(),body:I.any()}),ev=new Un,sv=new Un;var fv=new V().get("/next",G({summary:"Get next TUI request",description:"Retrieve the next TUI (Terminal User Interface) request from the queue for processing.",operationId:"tui.control.next",responses:{200:{description:"Next TUI request",content:{"application/json":{schema:$(bv)}}}}}),async(r)=>{let i=await ev.next();return r.json(i)}).post("/response",G({summary:"Submit TUI response",description:"Submit a response to the TUI request queue to complete a pending request.",operationId:"tui.control.response",responses:{200:{description:"Response submitted successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),D("json",I.any()),async(r)=>{let i=r.req.valid("json");return sv.push(i),r.json(!0)}),$1=F(()=>new V().post("/append-prompt",G({summary:"Append TUI prompt",description:"Append prompt to the TUI",operationId:"tui.appendPrompt",responses:{200:{description:"Prompt processed successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("json",Er.PromptAppend.properties),async(r)=>{return await wr.publish(Er.PromptAppend,r.req.valid("json")),r.json(!0)}).post("/open-help",G({summary:"Open help dialog",description:"Open the help dialog in the TUI to display user assistance information.",operationId:"tui.openHelp",responses:{200:{description:"Help dialog opened successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Er.CommandExecute,{command:"help.show"}),r.json(!0)}).post("/open-sessions",G({summary:"Open sessions dialog",description:"Open the session dialog",operationId:"tui.openSessions",responses:{200:{description:"Session dialog opened successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Er.CommandExecute,{command:"session.list"}),r.json(!0)}).post("/open-themes",G({summary:"Open themes dialog",description:"Open the theme dialog",operationId:"tui.openThemes",responses:{200:{description:"Theme dialog opened successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Er.CommandExecute,{command:"session.list"}),r.json(!0)}).post("/open-models",G({summary:"Open models dialog",description:"Open the model dialog",operationId:"tui.openModels",responses:{200:{description:"Model dialog opened successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Er.CommandExecute,{command:"model.list"}),r.json(!0)}).post("/submit-prompt",G({summary:"Submit TUI prompt",description:"Submit the prompt",operationId:"tui.submitPrompt",responses:{200:{description:"Prompt submitted successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Er.CommandExecute,{command:"prompt.submit"}),r.json(!0)}).post("/clear-prompt",G({summary:"Clear TUI prompt",description:"Clear the prompt",operationId:"tui.clearPrompt",responses:{200:{description:"Prompt cleared successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Er.CommandExecute,{command:"prompt.clear"}),r.json(!0)}).post("/execute-command",G({summary:"Execute TUI command",description:"Execute a TUI command (e.g. agent_cycle)",operationId:"tui.executeCommand",responses:{200:{description:"Command executed successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("json",I.object({command:I.string()})),async(r)=>{let i=r.req.valid("json").command;return await wr.publish(Er.CommandExecute,{command:{session_new:"session.new",session_share:"session.share",session_interrupt:"session.interrupt",session_compact:"session.compact",messages_page_up:"session.page.up",messages_page_down:"session.page.down",messages_line_up:"session.line.up",messages_line_down:"session.line.down",messages_half_page_up:"session.half.page.up",messages_half_page_down:"session.half.page.down",messages_first:"session.first",messages_last:"session.last",agent_cycle:"agent.cycle"}[i]}),r.json(!0)}).post("/show-toast",G({summary:"Show TUI toast",description:"Show a toast notification in the TUI",operationId:"tui.showToast",responses:{200:{description:"Toast notification shown successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),D("json",Er.ToastShow.properties),async(r)=>{return await wr.publish(Er.ToastShow,r.req.valid("json")),r.json(!0)}).post("/publish",G({summary:"Publish TUI event",description:"Publish a TUI event",operationId:"tui.publish",responses:{200:{description:"Event published successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("json",I.union(Object.values(Er).map((r)=>{return I.object({type:I.literal(r.type),properties:r.properties}).meta({ref:`Event.${r.type}`})}))),async(r)=>{let i=r.req.valid("json");return await wr.publish(Object.values(Er).find((n)=>n.type===i.type),i.properties),r.json(!0)}).post("/select-session",G({summary:"Select session",description:"Navigate the TUI to display the specified session.",operationId:"tui.selectSession",responses:{200:{description:"Session selected successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),D("json",Er.SessionSelect.properties),async(r)=>{let{sessionID:i}=r.req.valid("json");return await u("TuiRoutes.sessionSelect",r,J.Service.use((n)=>n.get(i))),await wr.publish(Er.SessionSelect,{sessionID:i}),r.json(!0)}).route("/control",fv));var rw=I.object({answers:_r.Answer.zod.array().describe("User answers in order of questions (each answer is an array of selected labels)")}),G1=()=>D("param",I.object({requestID:mm.zod})),N1=F(()=>new V().get("/",G({summary:"List pending questions",description:"Get all pending question requests across all sessions.",operationId:"question.list",responses:{200:{description:"List of pending questions",content:{"application/json":{schema:$(_r.Request.zod.array())}}}}}),async(r)=>U("QuestionRoutes.list",r,function*(){return yield*(yield*_r.Service).list()})).get("/never-ask",G({summary:"Get never-ask state",description:"Whether the question tool auto-resolves to a [Never-Ask] directive instead of blocking for a user.",operationId:"question.neverAsk",responses:{200:{description:"Current never-ask state",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>U("QuestionRoutes.neverAsk",r,function*(){return yield*(yield*_r.Service).neverAsk()})).post("/never-ask",G({summary:"Set never-ask state",description:"Enable or disable never-ask: the question tool stays visible but returns a [Never-Ask] directive so the model resolves decisions itself.",operationId:"question.setNeverAsk",responses:{200:{description:"Updated never-ask state",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("json",I.object({enabled:I.boolean().describe("Whether never-ask is enabled")})),async(r)=>U("QuestionRoutes.setNeverAsk",r,function*(){let i=yield*_r.Service;return yield*i.setNeverAsk(r.req.valid("json").enabled),yield*i.neverAsk()})).post("/:requestID/reply",G({summary:"Reply to question request",description:"Provide answers to a question request from the AI assistant.",operationId:"question.reply",responses:{200:{description:"Question answered successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),G1(),D("json",rw),async(r)=>U("QuestionRoutes.reply",r,function*(){let i=r.req.valid("param"),n=r.req.valid("json");return yield*(yield*_r.Service).reply({requestID:i.requestID,answers:n.answers}),!0})).post("/:requestID/reject",G({summary:"Reject question request",description:"Reject a question request from the AI assistant.",operationId:"question.reject",responses:{200:{description:"Question rejected successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),G1(),async(r)=>U("QuestionRoutes.reject",r,function*(){let i=r.req.valid("param");return yield*(yield*_r.Service).reject(i.requestID),!0})));function I0(r){return C.gen(function*(){return yield*(yield*Qr.Service).reply(r),!0})}var E1=F(()=>new V().post("/:requestID/reply",G({summary:"Respond to permission request",description:"Approve or deny a permission request from the AI assistant.",operationId:"permission.reply",responses:{200:{description:"Permission processed successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),D("param",I.object({requestID:Pn.zod})),D("json",I.object({reply:Qr.Reply.zod,message:I.string().optional()})),async(r)=>U("PermissionRoutes.reply",r,function*(){let i=r.req.valid("param"),n=r.req.valid("json");return yield*I0({requestID:i.requestID,reply:n.reply,message:n.message})})).get("/",G({summary:"List pending permissions",description:"Get all pending permission requests across all sessions.",operationId:"permission.list",responses:{200:{description:"List of pending permissions",content:{"application/json":{schema:$(Qr.Request.zod.array())}}}}}),async(r)=>U("PermissionRoutes.list",r,function*(){return yield*(yield*Qr.Service).list()})));var D1=F(()=>new V().get("/",G({summary:"List workflow runs",description:"List dynamic-workflow runs for a session. sessionID is REQUIRED \u2014 there is no per-user identity, so the session is the access boundary and an omitted/invalid sessionID is a 400 (never an unfiltered all-session listing). Empty when the workflow runtime is not running.",operationId:"workflow.list",responses:{200:{description:"Workflow runs",content:{"application/json":{schema:$(I.array(I.any()))}}}}}),D("query",I.object({sessionID:Q1.schema("session")})),async(r)=>U("WorkflowRoutes.list",r,function*(){let i=tc.current;if(!i)return[];let n=r.req.valid("query");return yield*i.list({sessionID:n.sessionID})})).post("/:runID/resume",G({summary:"Resume a workflow run",description:"Re-launch a persisted workflow run by id. Returns { runID, resumed }; resumed is false if the run is unknown, still running, or has no persisted script.",operationId:"workflow.resume",responses:{200:{description:"Resume result",content:{"application/json":{schema:$(I.object({runID:I.string(),resumed:I.boolean()}))}}}}}),D("param",I.object({runID:I.string().regex(/^wf_[0-9A-Za-z]{26}$/,"invalid workflow runID")})),async(r)=>U("WorkflowRoutes.resume",r,function*(){let i=tc.current,n=r.req.valid("param");if(!i)return{runID:n.runID,resumed:!1};return yield*i.resume({runID:n.runID})})));var iw=I.object({output:I.string().describe("Captured output from the interactive command"),exitCode:I.number().describe("Exit code of the interactive command")}),U1=F(()=>new V().get("/",G({summary:"List pending interactive bash requests",description:"Get all pending interactive bash requests waiting for user interaction.",operationId:"bash.interactive.list",responses:{200:{description:"List of pending interactive requests",content:{"application/json":{schema:$(I.array(I.object({id:I.string(),command:I.string(),cwd:I.string(),description:I.string()})))}}}}}),async(r)=>U("BashInteractiveRoutes.list",r,function*(){return yield*(yield*bc).list()})).post("/:id/reply",G({summary:"Reply to interactive bash request",description:"Provide the result of an interactive bash command execution.",operationId:"bash.interactive.reply",responses:{200:{description:"Reply accepted",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),D("param",I.object({id:I.string()})),D("json",iw),async(r)=>U("BashInteractiveRoutes.reply",r,function*(){let i=r.req.valid("param"),n=r.req.valid("json");return yield*(yield*bc).reply({id:i.id,output:n.output,exitCode:n.exitCode}),!0})));var Xm={};Nr(Xm,{webHandler:()=>a4,routes:()=>i2,ExperimentalHttpApiServer:()=>Xm});var Tr={};Nr(Tr,{reflect:()=>yl,make:()=>ew,isHttpApi:()=>tw,AdditionalSchemas:()=>Z0});var a={};Nr(a,{put:()=>xw,post:()=>ow,patch:()=>kw,options:()=>aw,make:()=>zi,isHttpApiEndpoint:()=>Fw,head:()=>uw,getSuccessSchemas:()=>nn,getPayloadSchemas:()=>gw,getErrorSchemas:()=>mn,get:()=>Bw,delete:()=>pw});var Vn={};Nr(Vn,{UnauthorizedNoContent:()=>Xw,Unauthorized:()=>v0,ServiceUnavailableNoContent:()=>qw,ServiceUnavailable:()=>C0,RequestTimeoutNoContent:()=>Yw,RequestTimeout:()=>E0,NotImplementedNoContent:()=>Lw,NotImplemented:()=>P0,NotFoundNoContent:()=>Hw,NotFound:()=>$0,NotAcceptableNoContent:()=>Vw,NotAcceptable:()=>N0,MethodNotAllowedNoContent:()=>Zw,MethodNotAllowed:()=>G0,InternalServerErrorNoContent:()=>Ow,InternalServerError:()=>U0,GoneNoContent:()=>Rw,Gone:()=>D0,ForbiddenNoContent:()=>Kw,Forbidden:()=>w0,ConflictNoContent:()=>Jw,Conflict:()=>Q0,BadRequestNoContent:()=>Ww,BadRequestFromSchemaError:()=>rl,BadRequest:()=>Hi});function mw(r){return(i)=>{return i.annotate({httpApiStatus:r})}}var cw=(r)=>sc.pipe(mw(r)),K1=cw(204);function Vr(r){return(i)=>{return sc.pipe(Cn(X1(i),S0({decode:r.decode,encode:P1})))}}function lw(r,i){return r.annotate({"~httpApiEncoding":{_tag:i._tag,contentType:i.contentType??yw(i._tag)}})}function yw(r){switch(r){case"Multipart":return"multipart/form-data";case"Json":return"application/json";case"FormUrlEncoded":return"application/x-www-form-urlencoded";case"Uint8Array":return"application/octet-stream";case"Text":return"text/plain"}}function H1(r){return(i)=>lw(i,{_tag:"FormUrlEncoded",...r})}var cm=(r)=>{if(A0(r))return!0;let i=W1(r);if(A0(i))return!0;let n=r.encoding?.[0].to;if(n===void 0)return!1;return A0(n)},Z1=ec("~httpApiEncoding"),V1=ec("httpApiStatus"),Y1={_tag:"Json",contentType:"application/json"},jw={_tag:"FormUrlEncoded",contentType:"application/x-www-form-urlencoded"};function Iw(r){return Z1(r)??Y1}function fc(r,i){let n=Z1(r);if(n)return n;return Wn(i)?Y1:jw}function Xn(r){let i=Iw(r);if(i._tag==="Multipart")throw Error("Multipart is not supported in response");return i}function Kn(r){return V1(r)??200}function Hn(r){return V1(r)??500}var Sw=Pr({status:400}),vw=Pr({status:401}),ww=Pr({status:403}),$w=Pr({status:404}),Gw=Pr({status:405}),Nw=Pr({status:406}),Ew=Pr({status:408}),Qw=Pr({status:409}),Dw=Pr({status:410}),Uw=Pr({status:500}),Pw=Pr({status:501}),Cw=Pr({status:503});class Hi extends gr("effect/HttpApiError/BadRequest")({_tag:Fr("BadRequest")},{description:"BadRequest",httpApiStatus:400}){[ji]=!0;[zr](){return t(Sw)}static singleton=new Hi}var Ww=Hi.pipe(Vr({decode:()=>new Hi({})})),rl=Hi.pipe(Cn(Zn([W0(X0),Hi]),S0({encode:(r)=>Hi.singleton,decode:Fi})),Vr({decode:()=>new Hi({})})).annotate({httpApiStatus:400,description:"BadRequest"});class v0 extends gr("effect/HttpApiError/Unauthorized")({_tag:Fr("Unauthorized")},{description:"Unauthorized",httpApiStatus:401}){[ji]=!0;[zr](){return t(vw)}}var Xw=v0.pipe(Vr({decode:()=>new v0({})}));class w0 extends gr("effect/HttpApiError/Forbidden")({_tag:Fr("Forbidden")},{description:"Forbidden",httpApiStatus:403}){[ji]=!0;[zr](){return t(ww)}}var Kw=w0.pipe(Vr({decode:()=>new w0({})}));class $0 extends gr("effect/HttpApiError/NotFound")({_tag:Fr("NotFound")},{description:"NotFound",httpApiStatus:404}){[ji]=!0;[zr](){return t($w)}}var Hw=$0.pipe(Vr({decode:()=>new $0({})}));class G0 extends gr("effect/HttpApiError/MethodNotAllowed")({_tag:Fr("MethodNotAllowed")},{description:"MethodNotAllowed",httpApiStatus:405}){[ji]=!0;[zr](){return t(Gw)}}var Zw=G0.pipe(Vr({decode:()=>new G0({})}));class N0 extends gr("effect/HttpApiError/NotAcceptable")({_tag:Fr("NotAcceptable")},{description:"NotAcceptable",httpApiStatus:406}){[ji]=!0;[zr](){return t(Nw)}}var Vw=N0.pipe(Vr({decode:()=>new N0({})}));class E0 extends gr("effect/HttpApiError/RequestTimeout")({_tag:Fr("RequestTimeout")},{description:"RequestTimeout",httpApiStatus:408}){[ji]=!0;[zr](){return t(Ew)}}var Yw=E0.pipe(Vr({decode:()=>new E0({})}));class Q0 extends gr("effect/HttpApiError/Conflict")({_tag:Fr("Conflict")},{description:"Conflict",httpApiStatus:409}){[ji]=!0;[zr](){return t(Qw)}}var Jw=Q0.pipe(Vr({decode:()=>new Q0({})}));class D0 extends gr("effect/HttpApiError/Gone")({_tag:Fr("Gone")},{description:"Gone",httpApiStatus:410}){[ji]=!0;[zr](){return t(Dw)}}var Rw=D0.pipe(Vr({decode:()=>new D0({})}));class U0 extends gr("effect/HttpApiError/InternalServerError")({_tag:Fr("InternalServerError")},{description:"InternalServerError",httpApiStatus:500}){[zr](){return t(Uw)}}var Ow=U0.pipe(Vr({decode:()=>new U0({})}));class P0 extends gr("effect/HttpApiError/NotImplemented")({_tag:Fr("NotImplemented")},{description:"NotImplemented",httpApiStatus:501}){[zr](){return t(Pw)}}var Lw=P0.pipe(Vr({decode:()=>new P0({})}));class C0 extends gr("effect/HttpApiError/ServiceUnavailable")({_tag:Fr("ServiceUnavailable")},{description:"ServiceUnavailable",httpApiStatus:503}){[zr](){return t(Cw)}}var qw=C0.pipe(Vr({decode:()=>new C0({})}));var nl="~effect/httpapi/HttpApiEndpoint",Fw=(r)=>gi(r,nl);function gw(r){let i=[];for(let{schemas:n}of r.payload.values())i.push(...n);return i}function nn(r){let i=Array.from(r.success);return K0(i)?i:[K1]}function mn(r){let i=new Set(r.error);for(let n of r.middlewares){let m=n;for(let c of m.error)i.add(c)}return L1(Array.from(i),rl)}var zw={[nl]:nl,pipe(){return Ii(this,arguments)},prefix(r){return ym({...this,path:q1(this.path,r)})},middleware(r){return ym({...this,middlewares:new Set([...this.middlewares,r])})},annotate(r,i){return ym({...this,annotations:Ai(this.annotations,r,i)})},annotateMerge(r){return ym({...this,annotations:Mr(this.annotations,r)})}};function ym(r){return Object.assign(Object.create(zw),r)}var zi=(r)=>(i,n,m)=>{let c=m?.disableCodecs??!1,l=c?Fi:H0;return ym({name:i,path:n,method:r,params:il(m?.params,l),query:il(m?.query,l),headers:il(m?.headers,l),payload:Mw(m?.payload,r,c),success:J1(m?.success,c),error:J1(m?.error,c),annotations:or(),middlewares:new Set})};function il(r,i){if(r===void 0)return;if(ml(r))return i(r);return i(jm(r))}function Mw(r,i,n){let m=new Map;if(r===void 0)return m;let c=Array.isArray(r)?r:ml(r)?[r]:[jm(r).pipe(H1())],l=n?Fi:hw;for(let y of c){let j=fc(y.ast,i),A=m.get(j.contentType);if(A){if(A.encoding._tag!==j._tag)throw Error(`Multiple payload encodings for content-type: ${j.contentType}`);if(A.encoding._tag==="Multipart")throw Error(`Multiple multipart payloads for content-type: ${j.contentType}`);A.schemas.push(l(y,i))}else m.set(j.contentType,{encoding:j,schemas:[l(y,i)]})}return m}function J1(r,i){if(r===void 0)return new Set;let n=O1(r);return new Set(i?n:n.map(Tw))}function Tw(r){switch(Xn(r.ast)._tag){case"Json":return cl(r);case"FormUrlEncoded":return H0(r);case"Text":case"Uint8Array":return r}}function hw(r,i){switch(fc(r.ast,i)._tag){case"Json":return cl(r);case"FormUrlEncoded":return H0(r);case"Text":case"Uint8Array":case"Multipart":return r}}var Bw=zi("GET"),ow=zi("POST"),xw=zi("PUT"),kw=zi("PATCH"),pw=zi("DELETE");var uw=zi("HEAD"),aw=zi("OPTIONS");var ll="~effect/httpapi/HttpApi",tw=(r)=>gi(r,ll),bw={[ll]:ll,pipe(){return Ii(this,arguments)},add(...r){let i={...this.groups};for(let n of r)i[n.identifier]=n;return cn({identifier:this.identifier,groups:i,annotations:this.annotations})},addHttpApi(r){let i={...this.groups};for(let n in r.groups){let m=r.groups[n];m.annotations=Mr(r.annotations,m.annotations),i[n]=m}return cn({identifier:this.identifier,groups:i,annotations:this.annotations})},prefix(r){return cn({identifier:this.identifier,groups:Mi(this.groups,(i)=>i.prefix(r)),annotations:this.annotations})},middleware(r){return cn({identifier:this.identifier,groups:Mi(this.groups,(i)=>i.middleware(r)),annotations:this.annotations})},annotate(r,i){return cn({identifier:this.identifier,groups:this.groups,annotations:Ai(this.annotations,r,i)})},annotateMerge(r){return cn({identifier:this.identifier,groups:this.groups,annotations:Mr(this.annotations,r)})}},cn=(r)=>{function i(){}return Object.setPrototypeOf(i,bw),i.groups=r.groups,i.annotations=r.annotations,i},ew=(r)=>cn({identifier:r,groups:new Map,annotations:or()}),yl=(r,i)=>{let n=Object.values(r.groups);for(let m of n){let c=Mr(r.annotations,m.annotations);i.onGroup({group:m,mergedAnnotations:c});let l=Object.values(m.endpoints);for(let y of l){if(i.predicate&&!i.predicate({endpoint:y,group:m}))continue;i.onEndpoint({group:m,endpoint:y,middleware:y.middlewares,mergedAnnotations:Mr(c,y.annotations),successes:_1(nn(y),Kn),errors:_1(mn(y),Hn)})}}},_1=(r,i)=>{let n=new Map;return r.forEach(m),n;function m(c){let l=c.ast,y=i(l),j=n.get(y);if(j===void 0)n.set(y,[c]);else j.push(c)}};class Z0 extends $r()("effect/httpapi/HttpApi/AdditionalSchemas"){}var Ar={};Nr(Ar,{securitySetCookie:()=>A4,securityDecode:()=>FI,layer:()=>y4,group:()=>j4,endpoint:()=>I4,HandlersTypeId:()=>_I});var Yn={};Nr(Yn,{layerSchemaErrorTransform:()=>r4,layerClient:()=>i4,isSecurity:()=>Gm,Service:()=>sw});var F1="~effect/httpapi/HttpApiMiddleware",jl="~effect/httpapi/HttpApiMiddleware/Security",Gm=(r)=>gi(r,jl),sw=()=>(r,i)=>{let n=globalThis.Error,m=n.stackTraceLimit;n.stackTraceLimit=2;let c=new n;n.stackTraceLimit=m;class l extends $r()(r){}let y=l;if(Object.defineProperty(l,"stack",{get(){return c.stack}}),y[F1]=F1,y.error=fw(i?.error),y.requiredForClient=i?.requiredForClient??!1,i?.security!==void 0){if(Object.keys(i.security).length===0)throw Error("HttpApiMiddleware.Service: security object must not be empty");y[jl]=jl,y.security=i.security}return y};function fw(r){if(r===void 0)return new Set;return new Set(Array.isArray(r)?r:[r])}var r4=(r,i)=>g1(r,(n,m)=>R0(n,(c)=>X0(c)?i(c,m):wm(c))),i4=(r,i)=>Y0(vm(function*(){let n=(yield*$m()).pipe(Am(Sm)),m=J0(i)?yield*i:i;return V0(new Map([[`${r.key}/Client`,(c)=>z1(m(c),(l)=>Mr(n,l))]]))}));var h={};Nr(h,{fromApi:()=>$l,annotations:()=>c4,Version:()=>_0,Transform:()=>On,Title:()=>Jn,Summary:()=>Em,Servers:()=>g0,Override:()=>Rn,License:()=>F0,Identifier:()=>q0,Format:()=>z0,ExternalDocs:()=>Nm,Exclude:()=>L0,Description:()=>ln,Deprecated:()=>M0});class q0 extends $r()("effect/httpapi/OpenApi/Identifier"){}class Jn extends $r()("effect/httpapi/OpenApi/Title"){}class _0 extends $r()("effect/httpapi/OpenApi/Version"){}class ln extends $r()("effect/httpapi/OpenApi/Description"){}class F0 extends $r()("effect/httpapi/OpenApi/License"){}class Nm extends $r()("effect/httpapi/OpenApi/ExternalDocs"){}class g0 extends $r()("effect/httpapi/OpenApi/Servers"){}class z0 extends $r()("effect/httpapi/OpenApi/Format"){}class Em extends $r()("effect/httpapi/OpenApi/Summary"){}class M0 extends $r()("effect/httpapi/OpenApi/Deprecated"){}class Rn extends $r()("effect/httpapi/OpenApi/Override"){}var L0=a1("effect/httpapi/OpenApi/Exclude",{defaultValue:o1});class On extends $r()("effect/httpapi/OpenApi/Transform"){}var m4=(r)=>{let i=Object.entries(r);return(n)=>{let m=or();for(let[c,l]of i)if(n[c]!==void 0)m=Ai(m,l,n[c]);return m}},c4=m4({identifier:q0,title:Jn,version:_0,description:ln,license:F0,summary:Em,deprecated:M0,externalDocs:Nm,servers:g0,format:z0,override:Rn,exclude:L0,transform:On}),M1=new WeakMap;function cr(r,i,n){let m=vl(r,i);if(x1(m))n(m.value)}function $l(r,i){let n=M1.get(r);if(n!==void 0)return n;let m={openapi:"3.1.0",info:{title:"Api",version:"0.0.1"},paths:{},components:{schemas:{},securitySchemes:{}},security:[],tags:[]},c=[];cr(r.annotations,Jn,(y)=>{m.info.title=y}),cr(r.annotations,_0,(y)=>{m.info.version=y}),cr(r.annotations,ln,(y)=>{m.info.description=y}),cr(r.annotations,F0,(y)=>{m.info.license=y}),cr(r.annotations,Em,(y)=>{m.info.summary=y}),cr(r.annotations,g0,(y)=>{m.servers=[...y]}),yl(r,{onGroup({group:y}){if(Il(y.annotations,L0))return;let j={name:O0(y.annotations,Jn,()=>y.identifier)};cr(y.annotations,ln,(A)=>{j.description=A}),cr(y.annotations,Nm,(A)=>{j.externalDocs=A}),cr(y.annotations,Rn,(A)=>{Object.assign(j,A)}),cr(y.annotations,On,(A)=>{j=A(j)}),m.tags.push(j)},onEndpoint({endpoint:y,group:j,mergedAnnotations:A,middleware:S}){if(Il(A,L0))return;let v={tags:[O0(j.annotations,Jn,()=>j.identifier)],operationId:O0(y.annotations,q0,()=>j.topLevel?y.name:`${j.identifier}.${y.name}`),parameters:[],security:[],responses:{}},w=y.path.replace(/:(\w+)\??/g,"{$1}"),N=y.method.toLowerCase();function E(K){if(K.size>0){let R={},q=!1;if(K.forEach(({encoding:z,schemas:L},f)=>{let hr=L.filter((Br)=>!cm(Br.ast));if(hr.length===0)return;q=!0;let Yr=hr.map(Al),x=Yr.length===1?Yr[0]:new Sl(Yr,"anyOf");c.push({_tag:"schema",ast:B1(x,z._tag),path:["paths",w,N,"requestBody","content",f,"schema"]}),R[f]={schema:{}}}),q)v.requestBody={content:R,required:!0}}}function Q(K,R){for(let[q,{content:z,descriptions:L}]of K){let f=L.size>0?Array.from(L).join(" | "):R();if(v.responses[q]={description:f},z!==void 0)z.forEach((hr,Yr)=>{hr.forEach((x,Br)=>{let Yi=Array.from(x,Al),An=Yi.length===1?Yi[0]:new Sl(Yi,"anyOf");c.push({_tag:"schema",ast:B1(An,Yr),path:["paths",w,N,"responses",String(q),"content",Br,"schema"]}),v.responses[q].content??={},v.responses[q].content[Br]={schema:{}}})})}}function W(K,R){if(K){let q=b1(K.ast);if(t1(q))for(let z of q.propertySignatures)v.parameters.push({name:String(z.name),in:R,schema:{},required:R==="path"||!e1(z.type)}),c.push({_tag:"parameter",ast:z.type,path:["paths",w,N,"parameters",String(v.parameters.length-1),"schema"]})}}cr(y.annotations,ln,(K)=>{v.description=K}),cr(y.annotations,Em,(K)=>{v.summary=K}),cr(y.annotations,M0,(K)=>{v.deprecated=K}),cr(y.annotations,Nm,(K)=>{v.externalDocs=K}),S.forEach((K)=>{if(!Gm(K))return;for(let[R,q]of Object.entries(K.security))Z(R,q),v.security.push({[R]:[]})});function Z(K,R){if(m.components.securitySchemes[K]!==void 0)return;m.components.securitySchemes[K]=l4(R)}let X=Wn(y.method);if(X)E(y.payload);if(W(y.params,"path"),!X&&y.payload.size===1){let K=y.payload.values().next().value;W(K.schemas[0],"query")}if(W(y.headers,"header"),W(y.query,"query"),Q(T1(nn(y),Kn,h1),()=>"Success"),Q(T1(mn(y),Hn,h1),()=>"Error"),!m.paths[w])m.paths[w]={};cr(y.annotations,Rn,(K)=>{Object.assign(v,K)}),cr(y.annotations,On,(K)=>{v=K(v)}),m.paths[w][N]=v}}),cr(r.annotations,Z0,(y)=>{y.forEach((j)=>{let A=wl(j.ast);if(A!==void 0){if(A in m.components.schemas)throw new globalThis.Error(`Duplicate component schema identifier: ${A}`);m.components.schemas[A]={},c.push({_tag:"schema",ast:j.ast,path:["components","schemas",A]})}})});function l(y){return"/"+y.map(f1).join("/")}if(K0(c)){let y=mI(u1(c,(S)=>S.ast)),j=iI(cI(y,{additionalProperties:i?.additionalProperties})),A=c.map((S,v)=>{let w=l(S.path),N=j.schemas[v];return{op:"replace",path:w,value:N}});Object.entries(j.definitions).forEach(([S,v])=>{A.push({op:"add",path:l(["components","schemas",S]),value:v})}),m=rI(A,m)}return Object.keys(m.components.schemas).forEach((y)=>{if(!nI.test(y))throw new globalThis.Error(`Invalid component schema key: ${y}`)}),cr(r.annotations,Rn,(y)=>{Object.assign(m,y)}),cr(r.annotations,On,(y)=>{m=y(m)}),M1.set(r,m),m}function T1(r,i,n){let m=new Map;return r.forEach(c),m;function c(j){let A=j.ast,S=i(A);if(cm(A))l(S,n(j.ast)??"<No Content>");else y(j,S,Xn(A))}function l(j,A){let S=m.get(j);if(S===void 0)m.set(j,{descriptions:new Set([A]),content:void 0});else if(A!==void 0)S.descriptions.add(A)}function y(j,A,S){let v=n(j.ast),w=m.get(A),{_tag:N,contentType:E}=S;if(w===void 0)m.set(A,{descriptions:new Set(v!==void 0?[v]:[]),content:new Map([[N,new Map([[E,new Set([j])]])]])});else if(w.content!==void 0){if(v!==void 0)w.descriptions.add(v);let Q=w.content.get(N);if(Q===void 0)w.content.set(N,new Map([[E,new Set([j])]]));else{let W=Q.get(E);if(W===void 0)Q.set(E,new Set([j]));else W.add(j)}}}}function h1(r){return s1(r)??wl(r)}var lI=Dm.annotate({format:"binary"});function B1(r,i){switch(i){case"Uint8Array":return lI.ast;case"Text":return Dm.ast;case"FormUrlEncoded":case"Json":return r;case"Multipart":return yI(r)}}function yI(r){if(d1(r)&&r.annotations?.typeConstructor?._tag==="effect/http/PersistedFile")return lI.ast;if(typeof r?.recur==="function")return r.recur(yI);return r}var l4=(r)=>{let i={};switch(cr(r.annotations,ln,(n)=>{i.description=n}),r._tag){case"Basic":return{...i,type:"http",scheme:"basic"};case"Bearer":{let n=vl(r.annotations,z0).pipe(p1((m)=>({bearerFormat:m})),k1);return{...i,type:"http",scheme:"bearer",...n}}case"ApiKey":return{...i,type:"apiKey",name:r.key,in:r.in}}};var y4=(r,i)=>LI(Pl(function*(n){let m=yield*$m(),c=[],l=Array.from(m.mapUnsafe.keys()).filter((y)=>y.startsWith("effect/httpapi/HttpApiGroup/"));for(let y of Object.values(r.groups)){let j=m.mapUnsafe.get(y.key);if(j===void 0){let A=l.length===0?"none":l.join(", ");return yield*AI(`HttpApiGroup "${y.identifier}" not found (key: "${y.key}"). Did you forget to provide HttpApiBuilder.group(api, "${y.identifier}", ...)? Available groups: ${A}`)}c.push(...j)}if(yield*n.addAll(c),i?.openapiPath){let y=$l(r);yield*n.add("GET",i.openapiPath,t(WI(y)))}})),j4=(r,i,n)=>Y0(vm(function*(){let m=(yield*$m()).pipe(Am(Sm)),c=r.groups[i],l=n($4(c)),y=J0(l)?yield*l:l,j=[];for(let A of y.handlers)j.push(E4(c,A,m));return V0(new Map([[c.key,j]]))})),_I=Symbol.for("@effect/platform/HttpApiBuilder/Handlers"),I4=(r,i,n,m)=>wI((c)=>{let l=r.groups[i],y=l.endpoints[n];return t(gI(l,y,Am(Sm)(c),m,!1))}),FI=(r)=>{switch(r._tag){case"Bearer":return h0(x0.asEffect(),(i)=>Ln((i.headers.authorization??"").slice(S4)));case"ApiKey":{let i=r.in==="header"?r.key.toLowerCase():r.key,n=jm({[i]:Dm}),m=r.in==="query"?JI(n):r.in==="cookie"?VI(n):YI(n);return Gl(m,{onFailure:()=>Ln(""),onSuccess:(c)=>Ln(c[i])})}case"Basic":{let i={username:"",password:Ln("")};return x0.asEffect().pipe(Ti((n)=>$I((n.headers.authorization??"").slice(v4)).asEffect()),Gl({onFailure:()=>i,onSuccess:(n)=>{let m=n.split(":");if(m.length!==2)return i;return{username:m[0],password:Ln(m[1])}}}))}}},A4=(r,i,n)=>RI((m,c)=>hi(HI(c,r.key,GI(i),{secure:!0,httpOnly:!0,...n}))),S4=7,v4=6,w4={[_I]:{_Endpoints:Fi},pipe(){return Ii(this,arguments)},handle(r,i,n){let m=this.group.endpoints[r];return this.handlers.add({endpoint:m,handler:i,isRaw:!1,uninterruptible:n?.uninterruptible??!1}),this},handleRaw(r,i,n){let m=this.group.endpoints[r];return this.handlers.add({endpoint:m,handler:i,isRaw:!0,uninterruptible:n?.uninterruptible??!1}),this}},$4=(r)=>{let i=Object.create(w4);return i.group=r,i.handlers=new Set,i};function G4(r){let i=new Map;return r.forEach(({encoding:n,schemas:m},c)=>{let l=Pm(Zn(m));if(n._tag==="Multipart")i.set(c,{_tag:"Multipart",mode:n.mode,limits:n.limits,decode:l});else i.set(c,{_tag:n._tag,decode:l})}),i}function N4(r,i,n){let m=Wn(i.method),c=m?D4(i):"application/x-www-form-urlencoded",l=r.get(c);if(!l)return o0(`Unsupported content-type: ${c}`,{status:415});let{_tag:y,decode:j}=l;switch(y){case"Multipart":{if(l.mode==="buffered")return Ti(hi(Nl(l.limits,{onUndefined:()=>i.multipart,onDefined:(A)=>Ul(i.multipart,Ql(A))})),j);return t(Nl(l.limits,{onUndefined:()=>i.multipartStream,onDefined:(A)=>UI(i.multipartStream,Ql(A))}))}case"Json":return Ti(hi(i.json),j);case"Text":return Ti(hi(i.text),j);case"FormUrlEncoded":{let A=m?h0(hi(i.urlParamsBody),PI):t(n);return Ti(A,j)}case"Uint8Array":return Ti(h0(hi(i.arrayBuffer),(A)=>new Uint8Array(A)),j)}}function gI(r,i,n,m,c){let l=El(K4(i)),y=El(H4(i)),j=T0(i.params,Pm),A=T0(i.headers,Pm),S=T0(i.query,Pm),w=i.payload.size>0&&!c?G4(i.payload):void 0;return U4(r,i,n,vm(function*(){let E=DI().context,Q=Um(E,x0),W=Um(E,OI),Z=Um(E,ZI),X={request:Q,endpoint:i,group:r};if(j)X.params=yield*j(W.params);if(A)X.headers=yield*A(Q.headers);if(S)X.query=yield*S(Z);if(w){let R=N4(w,Q,Z);if(B0(R))return R;if(R!==void 0)X.payload=yield*R}let K=yield*m(X);return B0(K)?K:yield*l(K)})).pipe(vI,R0((N)=>hi(y(N))),Ul(n))}function E4(r,i,n){let m=i.endpoint;return qI(m.method,m.path,gI(r,m,n,i.handler,i.isRaw),{uninterruptible:i.uninterruptible})}var Q4=(r)=>r.headers["content-type"]?r.headers["content-type"].toLowerCase().trim():"application/json",D4=(r)=>{let i=Q4(r),n=i.indexOf(";");return n===-1?i:i.slice(0,n).trim()},U4=(r,i,n,m)=>{let c={group:r,endpoint:i};for(let l of i.middlewares){let y=l,j=Um(n,y);m=(Gm(y)?P4(y,j):j)(m,c)}return m},jI=new WeakMap,P4=(r,i)=>{let n=jI.get(i);if(n!==void 0)return n;let m=Object.entries(r.security).map(([l,y])=>({decode:FI(y),middleware:i[l]}));if(m.length===0)return Fi;let c=Pl(function*(l,y){let j;for(let A=0;A<m.length;A++){let{decode:S,middleware:v}=m[A],w=yield*SI(Ti(S,(N)=>v(l,{credential:N,endpoint:y.endpoint,group:y.group})));if(II(w)){j=w;continue}return w.success}return yield*j.asEffect()});return jI.set(i,c),c},C4=W0(B0),W4=zI(Kn),X4=zI(Hn);function K4(r){let i=nn(r).map(W4);return i.length===1?i[0]:Zn(i)}function H4(r){let i=mn(r).map(X4);return i.length===1?i[0]:Zn(i)}function zI(r){let i=new WeakMap;return(n)=>{let m=i.get(n.ast);if(m!==void 0)return m;let c=C4.pipe(Cn(n,Z4(r,n)));return i.set(c.ast,c),c}}function Z4(r,i){let n=i.ast,m=V4(r(n),Xn(n),cm(n));return QI({decode:(c)=>wm(new EI(Dl(c),{message:"Encode only schema"})),encode:m})}function V4(r,i,n){switch(i._tag){case"Json":return(m)=>{if(m===void 0||n)return t(Pr({status:r}));try{let c=JSON.stringify(m);return t(o0(c,{status:r,contentType:i.contentType}))}catch(c){return wm(new NI(Dl(m),{message:globalThis.String(c)}))}};case"Text":return(m)=>t(o0(m,{status:r,contentType:i.contentType}));case"Uint8Array":return(m)=>t(CI(m,{status:r,contentType:i.contentType}));case"FormUrlEncoded":return(m)=>t(XI(m,{status:r}).pipe(KI("content-type",i.contentType)))}}var xr={};Nr(xr,{make:()=>R4,isHttpApiGroup:()=>Y4});var Wl="~effect/httpapi/HttpApiGroup",Y4=(r)=>gi(r,Wl),J4={[Wl]:Wl,add(...r){let i={...this.endpoints};for(let n of r)i[n.name]=n;return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:i,annotations:this.annotations})},prefix(r){return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:Mi(this.endpoints,(i)=>i.prefix(r)),annotations:this.annotations})},middleware(r){return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:Mi(this.endpoints,(i)=>i.middleware(r)),annotations:this.annotations})},annotateMerge(r){return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,annotations:Mr(this.annotations,r)})},annotate(r,i){return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,annotations:Ai(this.annotations,r,i)})},annotateEndpointsMerge(r){return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:Mi(this.endpoints,(i)=>i.annotateMerge(r)),annotations:this.annotations})},annotateEndpoints(r,i){return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:Mi(this.endpoints,(n)=>n.annotate(r,i)),annotations:this.annotations})},pipe(){return Ii(this,arguments)}},Bi=(r)=>{function i(){}return Object.setPrototypeOf(i,J4),i.key=`effect/httpapi/HttpApiGroup/${r.identifier}`,Object.assign(i,r)},R4=(r,i)=>Bi({identifier:r,topLevel:i?.topLevel??!1,endpoints:MI(),annotations:or()});var p0={};Nr(p0,{bearer:()=>O4,basic:()=>q4,apiKey:()=>L4,annotateMerge:()=>_4,annotate:()=>F4});var TI="~effect/httpapi/HttpApiSecurity",Cm={[TI]:TI,pipe(){return Ii(this,arguments)}},O4=Object.assign(Object.create(Cm),{_tag:"Bearer",annotations:or()}),L4=(r)=>Object.assign(Object.create(Cm),{_tag:"ApiKey",key:r.key,in:r.in??"header",annotations:or()}),q4=Object.assign(Object.create(Cm),{_tag:"Basic",annotations:or()}),_4=Xl(2,(r,i)=>Object.assign(Object.create(Cm),{...r,annotations:Mr(r.annotations,i)})),F4=Xl(3,(r,i,n)=>Object.assign(Object.create(Cm),{...r,annotations:Ai(r.annotations,i,n)}));var g4="/config",Kl=Tr.make("config").add(xr.make("config").add(a.get("providers",`${g4}/providers`,{success:ir.ConfigProvidersResult}).annotateMerge(h.annotations({identifier:"config.providers",summary:"List config providers",description:"Get a list of all configured AI providers and their default models."}))).annotateMerge(h.annotations({title:"config",description:"Experimental HttpApi config routes."}))).annotateMerge(h.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),hI=T.unwrap(C.gen(function*(){let r=yield*ir.Service,i=C.fn("ConfigHttpApi.providers")(function*(){let n=yield*r.list();return{providers:Object.values(n),default:ir.defaultModelIDs(n)}});return Ar.group(Kl,"config",(n)=>n.handle("providers",i))})).pipe(T.provide(ir.defaultLayer),T.provide(mr.defaultLayer));var BI="/permission",Hl=Tr.make("permission").add(xr.make("permission").add(a.get("list",BI,{success:g.Array(Qr.Request)}).annotateMerge(h.annotations({identifier:"permission.list",summary:"List pending permissions",description:"Get all pending permission requests across all sessions."})),a.post("reply",`${BI}/:requestID/reply`,{params:{requestID:Pn},payload:Qr.ReplyBody,success:g.Boolean}).annotateMerge(h.annotations({identifier:"permission.reply",summary:"Respond to permission request",description:"Approve or deny a permission request from the AI assistant."}))).annotateMerge(h.annotations({title:"permission",description:"Experimental HttpApi permission routes."}))).annotateMerge(h.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),oI=T.unwrap(C.gen(function*(){let r=yield*Qr.Service,i=C.fn("PermissionHttpApi.list")(function*(){return yield*r.list()}),n=C.fn("PermissionHttpApi.reply")(function*(m){return yield*r.reply({requestID:m.params.requestID,reply:m.payload.reply,message:m.payload.message}),!0});return Ar.group(Hl,"permission",(m)=>m.handle("list",i).handle("reply",n))})).pipe(T.provide(Qr.defaultLayer));var xI="/project",Zl=Tr.make("project").add(xr.make("project").add(a.get("list",xI,{success:g.Array(Gr.Info)}).annotateMerge(h.annotations({identifier:"project.list",summary:"List all projects",description:"Get a list of projects that have been opened with QitQode."})),a.get("current",`${xI}/current`,{success:Gr.Info}).annotateMerge(h.annotations({identifier:"project.current",summary:"Get current project",description:"Retrieve the currently active project that QitQode is working with."}))).annotateMerge(h.annotations({title:"project",description:"Experimental HttpApi project routes."}))).annotateMerge(h.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),kI=T.unwrap(C.gen(function*(){let r=yield*Gr.Service,i=C.fn("ProjectHttpApi.list")(function*(){return yield*r.list()}),n=C.fn("ProjectHttpApi.current")(function*(){return M.project});return Ar.group(Zl,"project",(m)=>m.handle("list",i).handle("current",n))})).pipe(T.provide(Gr.defaultLayer));var u0=C.fnUntraced(function*(r,i){let n=yield*C.promise(()=>uI.get()),m=new Set(r.disabled_providers??[]),c=r.enabled_providers?new Set(r.enabled_providers):void 0,l={};for(let[j,A]of Object.entries(n))if((c?c.has(j):!0)&&!m.has(j))l[j]=A;let y=Object.assign(pI(l,(j)=>ir.fromModelsDevProvider(j)),i);return{all:Object.values(y),default:ir.defaultModelIDs(y),connected:Object.keys(i)}});var a0="/provider",Vl=Tr.make("provider").add(xr.make("provider").add(a.get("list",a0,{success:ir.ListResult}).annotateMerge(h.annotations({identifier:"provider.list",summary:"List providers",description:"Get a list of all available AI providers, including both available and connected ones."})),a.get("auth",`${a0}/auth`,{success:Cr.Methods}).annotateMerge(h.annotations({identifier:"provider.auth",summary:"Get provider auth methods",description:"Retrieve available authentication methods for all AI providers."})),a.post("authorize",`${a0}/:providerID/oauth/authorize`,{params:{providerID:lr},payload:Cr.AuthorizeInput,success:Cr.Authorization}).annotateMerge(h.annotations({identifier:"provider.oauth.authorize",summary:"Start OAuth authorization",description:"Start the OAuth authorization flow for a provider."})),a.post("callback",`${a0}/:providerID/oauth/callback`,{params:{providerID:lr},payload:Cr.CallbackInput,success:g.Boolean}).annotateMerge(h.annotations({identifier:"provider.oauth.callback",summary:"Handle OAuth callback",description:"Handle the OAuth callback from a provider after user authorization."}))).annotateMerge(h.annotations({title:"provider",description:"Experimental HttpApi provider routes."}))).annotateMerge(h.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),aI=T.unwrap(C.gen(function*(){let r=yield*mr.Service,i=yield*ir.Service,n=yield*Cr.Service,m=C.fn("ProviderHttpApi.list")(function*(){let j=yield*r.get(),A=yield*i.list();return yield*u0(j,A)}),c=C.fn("ProviderHttpApi.auth")(function*(){return yield*n.methods()}),l=C.fn("ProviderHttpApi.authorize")(function*(j){let A=yield*n.authorize({providerID:j.params.providerID,method:j.payload.method,inputs:j.payload.inputs}).pipe(C.catch(()=>C.fail(new Vn.BadRequest({}))));if(!A)return yield*new Vn.BadRequest({});return A}),y=C.fn("ProviderHttpApi.callback")(function*(j){return yield*n.callback({providerID:j.params.providerID,method:j.payload.method,code:j.payload.code}).pipe(C.catch(()=>C.fail(new Vn.BadRequest({})))),!0});return Ar.group(Vl,"provider",(j)=>j.handle("list",m).handle("auth",c).handle("authorize",l).handle("callback",y))})).pipe(T.provide(Cr.defaultLayer),T.provide(ir.defaultLayer),T.provide(mr.defaultLayer));var Wm="/question",Yl=Tr.make("question").add(xr.make("question").add(a.get("list",Wm,{success:g.Array(_r.Request)}).annotateMerge(h.annotations({identifier:"question.list",summary:"List pending questions",description:"Get all pending question requests across all sessions."})),a.post("reply",`${Wm}/:requestID/reply`,{params:{requestID:mm},payload:_r.Reply,success:g.Boolean}).annotateMerge(h.annotations({identifier:"question.reply",summary:"Reply to question request",description:"Provide answers to a question request from the AI assistant."})),a.post("reject",`${Wm}/:requestID/reject`,{params:{requestID:mm},success:g.Boolean}).annotateMerge(h.annotations({identifier:"question.reject",summary:"Reject question request",description:"Reject a question request from the AI assistant."})),a.get("neverAsk",`${Wm}/never-ask`,{success:g.Boolean}).annotateMerge(h.annotations({identifier:"question.neverAsk",summary:"Get never-ask state",description:"Whether the question tool auto-resolves to a [Never-Ask] directive instead of blocking for a user."})),a.post("setNeverAsk",`${Wm}/never-ask`,{payload:g.Struct({enabled:g.Boolean}),success:g.Boolean}).annotateMerge(h.annotations({identifier:"question.setNeverAsk",summary:"Set never-ask state",description:"Enable or disable never-ask: the question tool stays visible but returns a [Never-Ask] directive so the model resolves decisions itself."}))).annotateMerge(h.annotations({title:"question",description:"Question routes."}))).annotateMerge(h.annotations({title:"qitqode HttpApi",version:"0.0.1",description:"Effect HttpApi surface for instance routes."})),dI=T.unwrap(C.gen(function*(){let r=yield*_r.Service,i=C.fn("QuestionHttpApi.list")(function*(){return yield*r.list()}),n=C.fn("QuestionHttpApi.reply")(function*(y){return yield*r.reply({requestID:y.params.requestID,answers:y.payload.answers}),!0}),m=C.fn("QuestionHttpApi.reject")(function*(y){return yield*r.reject(y.params.requestID),!0}),c=C.fn("QuestionHttpApi.neverAsk")(function*(){return yield*r.neverAsk()}),l=C.fn("QuestionHttpApi.setNeverAsk")(function*(y){return yield*r.setNeverAsk(y.payload.enabled),yield*r.neverAsk()});return Ar.group(Yl,"question",(y)=>y.handle("list",i).handle("reply",n).handle("reject",m).handle("neverAsk",c).handle("setNeverAsk",l))})).pipe(T.provide(_r.defaultLayer));var z4=g.Struct({directory:g.optional(g.String),workspace:g.optional(g.String)}),M4=g.Struct({authorization:g.optional(g.String),"x-qitqode-directory":g.optional(g.String)});function T4(r){try{return decodeURIComponent(r)}catch{return r}}class d0 extends g.TaggedErrorClass()("Unauthorized",{message:g.String},{httpApiStatus:401}){}class oi extends Yn.Service()("@qitqode/ExperimentalHttpApiAuthorization",{error:d0,security:{basic:p0.basic}}){}var h4=T.succeed(oi,oi.of({basic:(r,{credential:i})=>C.gen(function*(){if(!k.QITQODE_SERVER_PASSWORD)return yield*r;let n=k.QITQODE_SERVER_USERNAME??"qitqode";if(i.username!==n)return yield*new d0({message:"Unauthorized"});if(Cl.value(i.password)!==k.QITQODE_SERVER_PASSWORD)return yield*new d0({message:"Unauthorized"});return yield*r})}));class r2 extends g.TaggedErrorClass()("DirectoryAccessDenied",{message:g.String},{httpApiStatus:403}){}var B4=Im.middleware()(C.gen(function*(){return(r)=>C.gen(function*(){let i=yield*k0.schemaSearchParams(z4),n=yield*k0.schemaHeaders(M4),m=i.directory||n["x-qitqode-directory"]||process.cwd(),c=i.workspace||void 0,l=Wi.resolve(T4(m));if(!k.QITQODE_SERVER_PASSWORD){let A=Wi.resolve(process.cwd());if(!Wi.contains(A,l))return yield*new r2({message:"Access denied: directory must be within the server's working directory"})}let y=yield*C.promise(()=>M.provide({directory:l,init:()=>e.runPromise(xi),fn:()=>M.current}));return yield*(c?r.pipe(C.provideService(bI,c)):r).pipe(C.provideService(tI,y))})})).layer,o4=Yl.middleware(oi),x4=Hl.middleware(oi),k4=Zl.middleware(oi),p4=Vl.middleware(oi),u4=Kl.middleware(oi),i2=T.mergeAll(Ar.layer(u4).pipe(T.provide(hI)),Ar.layer(k4).pipe(T.provide(kI)),Ar.layer(o4).pipe(T.provide(dI)),Ar.layer(x4).pipe(T.provide(oI)),Ar.layer(p4).pipe(T.provide(aI))).pipe(T.provide(h4),T.provide(B4),T.provide(eI.layerServices),T.provideMerge(sI.layer)),a4=F(()=>Im.toWebHandler(i2,{memoMap:fI}));var n2=F(()=>new V().get("/",G({summary:"List all projects",description:"Get a list of projects that have been opened with QitQode.",operationId:"project.list",responses:{200:{description:"List of projects",content:{"application/json":{schema:$(Gr.Info.zod.array())}}}}}),async(r)=>{let i=Gr.list();return r.json(i)}).get("/current",G({summary:"Get current project",description:"Retrieve the currently active project that QitQode is working with.",operationId:"project.current",responses:{200:{description:"Current project information",content:{"application/json":{schema:$(Gr.Info.zod)}}}}}),async(r)=>{return r.json(M.project)}).post("/git/init",G({summary:"Initialize git repository",description:"Create a git repository for the current project and return the refreshed project info.",operationId:"project.initGit",responses:{200:{description:"Project information after git initialization",content:{"application/json":{schema:$(Gr.Info.zod)}}}}}),async(r)=>{let i=M.directory,n=M.project,m=await u("ProjectRoutes.initGit",r,Gr.Service.use((c)=>c.initGit({directory:i,project:n})));if(m.id===n.id&&m.vcs===n.vcs&&m.worktree===n.worktree)return r.json(m);return await M.reload({directory:i,worktree:i,project:m,init:()=>e.runPromise(xi)}),r.json(m)}).patch("/:projectID",G({summary:"Update project",description:"Update project properties such as name, icon, and commands.",operationId:"project.update",responses:{200:{description:"Updated project information",content:{"application/json":{schema:$(Gr.Info.zod)}}},...P(400,404)}}),D("param",I.object({projectID:l0.zod})),D("json",Gr.UpdateInput.omit({projectID:!0})),async(r)=>U("ProjectRoutes.update",r,function*(){let i=r.req.valid("param").projectID,n=r.req.valid("json");return yield*(yield*Gr.Service).update({...n,projectID:i})})));var ki={directory:I.string().optional().meta({description:"Filter sessions by project directory"}),roots:I.coerce.boolean().optional().meta({description:"Only return root sessions (no parentID)"}),start:I.coerce.number().optional().meta({description:"Filter sessions updated on or after this timestamp (milliseconds since epoch)"}),search:I.string().optional().meta({description:"Filter sessions by title (case-insensitive)"}),limit:I.coerce.number().optional().meta({description:"Maximum number of sessions to return"})};var t0=_.create({service:"server"}),s=()=>D("param",I.object({sessionID:br.zod})),Jl=()=>D("param",I.object({sessionID:br.zod,messageID:Si.zod})),Rl=()=>D("param",I.object({sessionID:br.zod,messageID:Si.zod,partID:pi.zod}));function m2(r){let i=r.status==="in_progress"?"in_progress":r.status==="done"?"completed":r.status==="abandoned"?"cancelled":"pending";return{content:r.summary,status:i}}var Ol=(r,i)=>C.gen(function*(){let m=yield*(yield*J.Service).messages({sessionID:r,agentID:"main"});for(let c=m.length-1;c>=0;c--){let l=m[c].info;if(l.role==="user")return l.agent||i}return i});function l2(){return new V().get("/",G({summary:"List sessions",description:"Get a list of all QitQode sessions, sorted by most recently updated.",operationId:"session.list",responses:{200:{description:"List of sessions",content:{"application/json":{schema:$(J.Info.array())}}}}}),D("query",I.object(ki)),async(r)=>{let i=r.req.valid("query"),n=[];for await(let m of J.list({directory:i.directory,roots:i.roots,start:i.start,search:i.search,limit:i.limit}))n.push(m);return r.json(n)}).get("/status",G({summary:"Get session status",description:"Retrieve the current status of all sessions, including active, idle, and completed states.",operationId:"session.status",responses:{200:{description:"Get session status",content:{"application/json":{schema:$(I.record(I.string(),Ll.Info))}}},...P(400)}}),async(r)=>U("SessionRoutes.status",r,function*(){let i=yield*Ll.Service;return Object.fromEntries(yield*i.list())})).get("/:sessionID",G({summary:"Get session",description:"Retrieve detailed information about a specific QitQode session.",tags:["Session"],operationId:"session.get",responses:{200:{description:"Get session",content:{"application/json":{schema:$(J.Info)}}},...P(400,404)}}),D("param",I.object({sessionID:J.GetInput})),async(r)=>{let i=r.req.valid("param").sessionID;return U("SessionRoutes.get",r,function*(){return yield*(yield*J.Service).get(i)})}).get("/:sessionID/children",G({summary:"Get session children",tags:["Session"],description:"Retrieve all child sessions that were forked from the specified parent session.",operationId:"session.children",responses:{200:{description:"List of children",content:{"application/json":{schema:$(J.Info.array())}}},...P(400,404)}}),D("param",I.object({sessionID:J.ChildrenInput})),async(r)=>{let i=r.req.valid("param").sessionID;return U("SessionRoutes.children",r,function*(){return yield*(yield*J.Service).children(i)})}).post("/",G({summary:"Create session",description:"Create a new QitQode session for interacting with AI assistants and managing conversations.",operationId:"session.create",responses:{...P(400),200:{description:"Successfully created session",content:{"application/json":{schema:$(J.Info)}}}}}),D("json",J.CreateInput),async(r)=>U("SessionRoutes.create",r,function*(){let i=r.req.valid("json")??{};return yield*(yield*Hm.Service).create(i)})).delete("/:sessionID",G({summary:"Delete session",description:"Delete a session and permanently remove all associated data, including messages and history.",operationId:"session.delete",responses:{200:{description:"Successfully deleted session",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),D("param",I.object({sessionID:J.RemoveInput})),async(r)=>U("SessionRoutes.delete",r,function*(){let i=r.req.valid("param").sessionID;return yield*(yield*J.Service).remove(i),!0})).patch("/:sessionID",G({summary:"Update session",description:"Update properties of an existing session, such as title or other metadata.",operationId:"session.update",responses:{200:{description:"Successfully updated session",content:{"application/json":{schema:$(J.Info)}}},...P(400,404)}}),s(),D("json",I.object({title:I.string().optional(),permission:Qr.Ruleset.zod.optional(),time:I.object({archived:I.number().optional()}).optional()})),async(r)=>U("SessionRoutes.update",r,function*(){let i=r.req.valid("param").sessionID,n=r.req.valid("json"),m=yield*J.Service,c=yield*m.get(i);if(n.title!==void 0)yield*m.setTitle({sessionID:i,title:n.title});if(n.permission!==void 0)yield*m.setPermission({sessionID:i,permission:Qr.merge(c.permission??[],n.permission)});if(n.time?.archived!==void 0)yield*m.setArchived({sessionID:i,time:n.time.archived});return yield*m.get(i)})).post("/:sessionID/init",G({summary:"Initialize session",description:"Analyze the current application and create an AGENTS.md file with project-specific agent configurations.",operationId:"session.init",responses:{200:{description:"200",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),s(),D("json",I.object({modelID:er.zod,providerID:lr.zod,messageID:Si.zod})),async(r)=>U("SessionRoutes.init",r,function*(){let i=r.req.valid("param").sessionID,n=r.req.valid("json");return yield*(yield*Dr.Service).command({sessionID:i,messageID:n.messageID,model:n.providerID+"/"+n.modelID,command:Km.Default.INIT,arguments:""}),!0})).post("/:sessionID/fork",G({summary:"Fork session",description:"Create a new session by forking an existing session at a specific message point.",operationId:"session.fork",responses:{200:{description:"200",content:{"application/json":{schema:$(J.Info)}}}}}),D("param",I.object({sessionID:J.ForkInput.shape.sessionID})),D("json",J.ForkInput.omit({sessionID:!0})),async(r)=>U("SessionRoutes.fork",r,function*(){let i=r.req.valid("param").sessionID,n=r.req.valid("json");return yield*(yield*J.Service).fork({...n,sessionID:i})})).post("/:sessionID/abort",G({summary:"Abort session",description:"Abort an active session and stop any ongoing AI processing or command execution.",operationId:"session.abort",responses:{200:{description:"Aborted session",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),s(),async(r)=>U("SessionRoutes.abort",r,function*(){return yield*(yield*Dr.Service).cancel(r.req.valid("param").sessionID),!0})).get("/:sessionID/actors",G({summary:"List session actors",description:"List actors registered for a session.",operationId:"session.actors",responses:{200:{description:"Actor list"},...P(400,404)}}),s(),async(r)=>{let i=r.req.valid("param").sessionID,n=await u("SessionRoutes.actors",r,C.gen(function*(){let m=yield*c2.Service;return yield*(yield*J.Service).get(i),yield*m.listBySession(i)}));return r.json(n)})}function j2(){return new V().get("/:sessionID/todo",G({summary:"Get session todos",description:"Retrieve the todo list associated with a specific session, showing tasks and action items.",operationId:"session.todo",responses:{200:{description:"Todo list",content:{"application/json":{schema:$(_l.Info.array())}}},...P(400,404)}}),s(),async(r)=>{let i=r.req.valid("param").sessionID;return U("SessionRoutes.todo",r,function*(){let m=yield*(yield*ql.Service).list({session_id:i,include_terminal:!0});if(m.length>0)return m.map(m2);return yield*(yield*_l.Service).get(i)})}).get("/:sessionID/task",G({summary:"List session tasks",description:"List tasks registered for a session (the work-item registry).",operationId:"session.task",responses:{200:{description:"Task list",content:{"application/json":{schema:$(y2.array())}}},...P(400,404)}}),s(),async(r)=>{let i=r.req.valid("param").sessionID,n=await u("SessionRoutes.task",r,C.gen(function*(){let m=yield*ql.Service;return yield*(yield*J.Service).get(i),yield*m.list({session_id:i,include_terminal:!0})}));return r.json(n)})}function I2(){return new V().post("/:sessionID/share",G({summary:"Share session",description:"Create a shareable link for a session, allowing others to view the conversation.",operationId:"session.share",responses:{200:{description:"Successfully shared session",content:{"application/json":{schema:$(J.Info)}}},...P(400,404)}}),s(),async(r)=>U("SessionRoutes.share",r,function*(){let i=r.req.valid("param").sessionID,n=yield*Hm.Service,m=yield*J.Service;return yield*n.share(i),yield*m.get(i)})).delete("/:sessionID/share",G({summary:"Unshare session",description:"Remove the shareable link for a session, making it private again.",operationId:"session.unshare",responses:{200:{description:"Successfully unshared session",content:{"application/json":{schema:$(J.Info)}}},...P(400,404)}}),s(),async(r)=>U("SessionRoutes.unshare",r,function*(){let i=r.req.valid("param").sessionID,n=yield*Hm.Service,m=yield*J.Service;return yield*n.unshare(i),yield*m.get(i)}))}function v2(){return new V().get("/:sessionID/diff",G({summary:"Get message diff",description:"Get the file changes (diff) that resulted from a specific user message in the session.",operationId:"session.diff",responses:{200:{description:"Successfully retrieved diff",content:{"application/json":{schema:$(A2.FileDiff.array())}}}}}),D("param",I.object({sessionID:b0.DiffInput.shape.sessionID})),D("query",I.object({messageID:b0.DiffInput.shape.messageID})),async(r)=>U("SessionRoutes.diff",r,function*(){let i=r.req.valid("query"),n=r.req.valid("param");return yield*(yield*b0.Service).diff({sessionID:n.sessionID,messageID:i.messageID})})).post("/:sessionID/summarize",G({summary:"Summarize session",description:"Generate a concise summary of the session using AI compaction to preserve key information.",operationId:"session.summarize",responses:{200:{description:"Summarized session",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),s(),D("json",I.object({providerID:lr.zod,modelID:er.zod,auto:I.boolean().optional().default(!1)})),async(r)=>U("SessionRoutes.summarize",r,function*(){let i=r.req.valid("param").sessionID,n=r.req.valid("json"),m=yield*J.Service,c=yield*Zm.Service,l=yield*S2.Service,y=yield*Dr.Service,j=yield*yn.Service;yield*c.cleanup(yield*m.get(i));let A=yield*Ol(i,yield*j.defaultAgent());return yield*l.create({sessionID:i,agent:A,model:{providerID:n.providerID,modelID:n.modelID},auto:n.auto,agentID:"main"}),yield*y.loop({sessionID:i}),!0})).post("/:sessionID/revert",G({summary:"Revert message",description:"Revert a specific message in a session, undoing its effects and restoring the previous state.",operationId:"session.revert",responses:{200:{description:"Updated session",content:{"application/json":{schema:$(J.Info)}}},...P(400,404)}}),s(),D("json",Zm.RevertInput.omit({sessionID:!0})),async(r)=>{let i=r.req.valid("param").sessionID;return t0.info("revert",r.req.valid("json")),U("SessionRoutes.revert",r,function*(){return yield*(yield*Zm.Service).revert({sessionID:i,...r.req.valid("json")})})}).post("/:sessionID/unrevert",G({summary:"Restore reverted messages",description:"Restore all previously reverted messages in a session.",operationId:"session.unrevert",responses:{200:{description:"Updated session",content:{"application/json":{schema:$(J.Info)}}},...P(400,404)}}),s(),async(r)=>U("SessionRoutes.unrevert",r,function*(){let i=r.req.valid("param").sessionID;return yield*(yield*Zm.Service).unrevert({sessionID:i})}))}var e0=class{writer;encoder;writable;abortSubscribers=[];responseReadable;aborted=!1;closed=!1;constructor(r,i){this.writable=r,this.writer=r.getWriter(),this.encoder=new TextEncoder;let n=i.getReader();this.abortSubscribers.push(async()=>{await n.cancel()}),this.responseReadable=new ReadableStream({async pull(m){let{done:c,value:l}=await n.read();c?m.close():m.enqueue(l)},cancel:()=>{if(!this.closed)this.abort()}})}async write(r){try{if(typeof r==="string")r=this.encoder.encode(r);await this.writer.write(r)}catch{}return this}async writeln(r){return await this.write(r+`
|
|
9
|
+
`),this}sleep(r){return new Promise((i)=>setTimeout(i,r))}async close(){this.closed=!0;try{await this.writer.close()}catch{}}async pipe(r){this.writer.releaseLock(),await r.pipeTo(this.writable,{preventClose:!0}),this.writer=this.writable.getWriter()}onAbort(r){this.abortSubscribers.push(r)}abort(){if(!this.aborted)this.aborted=!0,this.abortSubscribers.forEach((r)=>r())}};var Vm=()=>{let r=typeof Bun<"u"?Bun.version:void 0;if(r===void 0)return!1;let i=r.startsWith("1.1")||r.startsWith("1.0")||r.startsWith("0.");return Vm=()=>i,i};var d4=new WeakMap,s0=(r,i,n)=>{let{readable:m,writable:c}=new TransformStream,l=new e0(c,m);if(Vm())r.req.raw.signal.addEventListener("abort",()=>{if(!l.closed)l.abort()});return d4.set(l.responseReadable,r),(async()=>{try{await i(l)}catch(y){if(y===void 0);else if(y instanceof Error&&n)await n(y,l);else console.error(y)}finally{l.close()}})(),r.newResponse(l.responseReadable)};var w2=class extends e0{constructor(r,i){super(r,i)}async writeSSE(r){let n=(await Tn(r.data,Mm.Stringify,!1,{})).split(/\r\n|\r|\n/).map((c)=>{return`data: ${c}`}).join(`
|
|
10
|
+
`);for(let c of["event","id","retry"])if(r[c]&&/[\r\n]/.test(r[c]))throw Error(`${c} must not contain "\\r" or "\\n"`);let m=[r.event&&`event: ${r.event}`,n,r.id&&`id: ${r.id}`,r.retry&&`retry: ${r.retry}`].filter(Boolean).join(`
|
|
11
|
+
`)+`
|
|
12
|
+
|
|
13
|
+
`;await this.write(m)}},t4=async(r,i,n)=>{try{await i(r)}catch(m){if(m instanceof Error&&n)await n(m,r),await r.writeSSE({event:"error",data:m.message});else console.error(m)}finally{r.close()}},b4=new WeakMap,Fl=(r,i,n)=>{let{readable:m,writable:c}=new TransformStream,l=new w2(c,m);if(Vm())r.req.raw.signal.addEventListener("abort",()=>{if(!l.closed)l.abort()});return b4.set(l.responseReadable,r),r.header("Transfer-Encoding","chunked"),r.header("Content-Type","text/event-stream"),r.header("Cache-Control","no-cache"),r.header("Connection","keep-alive"),t4(l,i,n),r.newResponse(l.responseReadable)};var $2=I.object({info:vr.Assistant,parts:vr.Part.array()});function G2(){return new V().get("/:sessionID/message",G({summary:"Get session messages",description:"Retrieve all messages in a session, including user prompts and AI responses.",operationId:"session.messages",responses:{200:{description:"List of messages",content:{"application/json":{schema:$(vr.WithParts.array())}}},...P(400,404)}}),s(),D("query",I.object({limit:I.coerce.number().int().min(0).optional().meta({description:"Maximum number of messages to return"}),before:I.string().optional().meta({description:"Opaque cursor for loading older messages"}).refine((r)=>{if(!r)return!0;try{return vr.cursor.decode(r),!0}catch{return!1}},{message:"Invalid cursor"}),agent_id:I.string().optional().meta({description:"Filter by message slice. Omitted = main-agent slice only (default). Pass a subagent's actor id to fetch its slice. Pass `*` to return every message regardless of slice."})}).refine((r)=>!r.before||r.limit!==void 0,{message:"before requires limit",path:["before"]})),async(r)=>{let i=r.req.valid("query"),n=r.req.valid("param").sessionID,m=i.agent_id??"main";if(i.limit===void 0||i.limit===0){let l=await u("SessionRoutes.messages",r,C.gen(function*(){let y=yield*J.Service;return yield*y.get(n),yield*y.messages({sessionID:n,agentID:m})}));return r.json(l)}let c=await vr.page({sessionID:n,limit:i.limit,before:i.before,agentID:m});if(c.cursor){let l=new URL(r.req.url);l.searchParams.set("limit",i.limit.toString()),l.searchParams.set("before",c.cursor),r.header("Access-Control-Expose-Headers","Link, X-Next-Cursor"),r.header("Link",`<${l.toString()}>; rel="next"`),r.header("X-Next-Cursor",c.cursor)}return r.json(c.items)}).get("/:sessionID/message/:messageID",G({summary:"Get message",description:"Retrieve a specific message from a session by its message ID.",operationId:"session.message",responses:{200:{description:"Message",content:{"application/json":{schema:$(I.object({info:vr.Info,parts:vr.Part.array()}))}}},...P(400,404)}}),Jl(),async(r)=>{let i=r.req.valid("param"),n=await vr.get({sessionID:i.sessionID,messageID:i.messageID});return r.json(n)}).delete("/:sessionID/message/:messageID",G({summary:"Delete message",description:"Permanently delete a specific message (and all of its parts) from a session. This does not revert any file changes that may have been made while processing the message.",operationId:"session.deleteMessage",responses:{200:{description:"Successfully deleted message",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),Jl(),async(r)=>U("SessionRoutes.deleteMessage",r,function*(){let i=r.req.valid("param"),n=yield*gl.Service,m=yield*J.Service;return yield*n.assertNotBusy(i.sessionID),yield*m.removeMessage({sessionID:i.sessionID,messageID:i.messageID}),!0})).delete("/:sessionID/message/:messageID/part/:partID",G({description:"Delete a part from a message",operationId:"part.delete",responses:{200:{description:"Successfully deleted part",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),Rl(),async(r)=>U("SessionRoutes.deletePart",r,function*(){let i=r.req.valid("param");return yield*(yield*J.Service).removePart({sessionID:i.sessionID,messageID:i.messageID,partID:i.partID}),!0})).patch("/:sessionID/message/:messageID/part/:partID",G({description:"Update a part in a message",operationId:"part.update",responses:{200:{description:"Successfully updated part",content:{"application/json":{schema:$(vr.Part)}}},...P(400,404)}}),Rl(),D("json",vr.Part),async(r)=>{let i=r.req.valid("param"),n=r.req.valid("json");if(n.id!==i.partID||n.messageID!==i.messageID||n.sessionID!==i.sessionID)throw Error(`Part mismatch: body.id='${n.id}' vs partID='${i.partID}', body.messageID='${n.messageID}' vs messageID='${i.messageID}', body.sessionID='${n.sessionID}' vs sessionID='${i.sessionID}'`);return U("SessionRoutes.updatePart",r,function*(){return yield*(yield*J.Service).updatePart(n)})}).post("/:sessionID/message",G({summary:"Send message",description:"Create and send a new message to a session, streaming the AI response.",operationId:"session.prompt",responses:{200:{description:"Created message",content:{"application/json":{schema:$($2)}}},...P(400,404,409)}}),s(),D("json",Dr.PromptInput.omit({sessionID:!0})),async(r)=>{let i=r.req.valid("param").sessionID;return await u("SessionRoutes.prompt.assertNotBusy",r,gl.Service.use((n)=>n.assertNotBusy(i))),r.status(200),r.header("Content-Type","application/json"),s0(r,async(n)=>{let m=r.req.valid("json"),c=r.req.raw.signal,l=()=>{u("SessionRoutes.prompt.disconnect",r,Dr.Service.use((y)=>y.cancel(i))).catch(()=>{})};if(c.aborted){l();return}c.addEventListener("abort",l,{once:!0});try{let y=await u("SessionRoutes.prompt",r,Dr.Service.use((j)=>j.prompt({...m,sessionID:i})));n.write(JSON.stringify(y))}finally{c.removeEventListener("abort",l)}})}).post("/:sessionID/prompt_async",G({summary:"Send async message",description:"Create and send a new message to a session asynchronously, starting the session if needed and returning immediately.",operationId:"session.prompt_async",responses:{204:{description:"Prompt accepted"},...P(400,404)}}),s(),D("json",Dr.PromptInput.omit({sessionID:!0})),async(r)=>{let i=r.req.valid("param").sessionID,n=r.req.valid("json");return u("SessionRoutes.prompt_async",r,Dr.Service.use((m)=>m.prompt({...n,sessionID:i}))).catch((m)=>{t0.error("prompt_async failed",{sessionID:i,error:m}),wr.publish(J.Event.Error,{sessionID:i,error:new En.Unknown({message:m instanceof Error?m.message:String(m)}).toObject()})}),r.body(null,204)}).post("/:sessionID/command",G({summary:"Send command",description:"Send a new command to a session for execution by the AI assistant.",operationId:"session.command",responses:{200:{description:"Created message",content:{"application/json":{schema:$($2)}}},...P(400,404)}}),s(),D("json",Dr.CommandInput.omit({sessionID:!0})),async(r)=>U("SessionRoutes.command",r,function*(){let i=r.req.valid("param").sessionID,n=r.req.valid("json");return yield*(yield*Dr.Service).command({...n,sessionID:i})})).post("/:sessionID/predict",G({summary:"Predict next prompt",description:"Predict the user's most likely next prompt based on the latest user message and the assistant's result. Returns an empty string when disabled or unavailable.",operationId:"session.predict",responses:{200:{description:"Predicted next prompt",content:{"application/json":{schema:$(I.object({prediction:I.string()}))}}},...P(400,404)}}),s(),async(r)=>U("SessionRoutes.predict",r,function*(){let i=r.req.valid("param").sessionID;return{prediction:yield*(yield*Dr.Service).predict({sessionID:i})}})).post("/:sessionID/shell",G({summary:"Run shell command",description:"Execute a shell command within the session context and return the AI's response.",operationId:"session.shell",responses:{200:{description:"Created message",content:{"application/json":{schema:$(vr.WithParts)}}},...P(400,404)}}),s(),D("json",Dr.ShellInput.omit({sessionID:!0})),async(r)=>U("SessionRoutes.shell",r,function*(){let i=r.req.valid("param").sessionID,n=r.req.valid("json");return yield*(yield*Dr.Service).shell({...n,sessionID:i})}))}function N2(){return new V().post("/:sessionID/permissions/:permissionID",G({summary:"Respond to permission",deprecated:!0,description:"Approve or deny a permission request from the AI assistant.",operationId:"permission.respond",responses:{200:{description:"Permission processed successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400,404)}}),D("param",I.object({sessionID:br.zod,permissionID:Pn.zod})),D("json",I.object({response:Qr.Reply.zod})),async(r)=>U("SessionRoutes.permissionRespond",r,function*(){let i=r.req.valid("param");return yield*I0({requestID:i.permissionID,reply:r.req.valid("json").response})}))}var E2=F(()=>{let r=new V;return r.route("/",l2()),r.route("/",j2()),r.route("/",I2()),r.route("/",v2()),r.route("/",G2()),r.route("/",N2()),r});var Q2=_.create({service:"server.qredits"}),e4=I.object({balance:I.number().nullable(),status:I.enum(["signed_out","available","unavailable","reauth_required"])}),C2=F(()=>new V().get("/balance",G({summary:"Get Qredits balance",description:"Retrieve the current Qredits balance for the signed-in Forgewise user. The response status distinguishes signed-out users from temporary billing-service outages.",operationId:"qredits.balance",responses:{200:{description:"Qredits balance",content:{"application/json":{schema:$(e4)}}}}}),async(r)=>U("QreditsRoutes.balance",r,function*(){let i=yield*C.promise(()=>D2());if(!i)return{balance:null,status:"signed_out"};let n=yield*P2(i);if(!n.accessToken)return Q2.warn("no relayable Forgewise token; balance needs an account sign-in",{method:i.method}),{balance:null,status:"reauth_required"};let m=yield*C.tryPromise({try:()=>U2(n),catch:(c)=>{return Q2.warn("qredits balance read failed; reporting unavailable",{method:i.method,error:c instanceof Error?c.message:String(c)}),null}}).pipe(C.orElseSucceed(()=>null));if(!m)return{balance:null,status:"unavailable"};return{balance:m.balance,status:"available"}})));function W2(r){return new V().get("/",G({summary:"List PTY sessions",description:"Get a list of all active pseudo-terminal (PTY) sessions managed by QitQode.",operationId:"pty.list",responses:{200:{description:"List of sessions",content:{"application/json":{schema:$(Wr.Info.array())}}}}}),async(i)=>U("PtyRoutes.list",i,function*(){return yield*(yield*Wr.Service).list()})).post("/",G({summary:"Create PTY session",description:"Create a new pseudo-terminal (PTY) session for running shell commands and processes.",operationId:"pty.create",responses:{200:{description:"Created session",content:{"application/json":{schema:$(Wr.Info)}}},...P(400)}}),D("json",Wr.CreateInput),async(i)=>U("PtyRoutes.create",i,function*(){return yield*(yield*Wr.Service).create(i.req.valid("json"))})).get("/:ptyID",G({summary:"Get PTY session",description:"Retrieve detailed information about a specific pseudo-terminal (PTY) session.",operationId:"pty.get",responses:{200:{description:"Session info",content:{"application/json":{schema:$(Wr.Info)}}},...P(404)}}),D("param",I.object({ptyID:jn.zod})),async(i)=>{let n=await u("PtyRoutes.get",i,C.gen(function*(){return yield*(yield*Wr.Service).get(i.req.valid("param").ptyID)}));if(!n)throw new Ci({message:"Session not found"});return i.json(n)}).put("/:ptyID",G({summary:"Update PTY session",description:"Update properties of an existing pseudo-terminal (PTY) session.",operationId:"pty.update",responses:{200:{description:"Updated session",content:{"application/json":{schema:$(Wr.Info)}}},...P(400)}}),D("param",I.object({ptyID:jn.zod})),D("json",Wr.UpdateInput),async(i)=>U("PtyRoutes.update",i,function*(){return yield*(yield*Wr.Service).update(i.req.valid("param").ptyID,i.req.valid("json"))})).delete("/:ptyID",G({summary:"Remove PTY session",description:"Remove and terminate a specific pseudo-terminal (PTY) session.",operationId:"pty.remove",responses:{200:{description:"Session removed",content:{"application/json":{schema:$(I.boolean())}}},...P(404)}}),D("param",I.object({ptyID:jn.zod})),async(i)=>U("PtyRoutes.remove",i,function*(){return yield*(yield*Wr.Service).remove(i.req.valid("param").ptyID),!0})).post("/:ptyID/connect-token",G({summary:"Issue PTY connect ticket",description:"Issue a one-time ticket for authenticating a WebSocket connection to a PTY session. The ticket must be passed as the 'ticket' query parameter on the /connect WebSocket URL.",operationId:"pty.connectToken",responses:{200:{description:"Issued ticket",content:{"application/json":{schema:$(I.object({ticket:I.string(),expires_in:I.number()}))}}},403:{description:"Forbidden \u2014 missing required header or invalid origin"},...P(404)}}),D("param",I.object({ptyID:jn.zod})),async(i)=>{if(i.req.header(Fj)!==gj)return i.json({error:"Forbidden"},403);let n=i.req.valid("param").ptyID;if(!await u("PtyRoutes.connectToken",i,C.gen(function*(){return yield*(yield*Wr.Service).get(n)})))throw new Ci({message:"Session not found"});return i.json(Mj(n))}).get("/:ptyID/connect",G({summary:"Connect to PTY session",description:"Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time.",operationId:"pty.connect",responses:{200:{description:"Connected session",content:{"application/json":{schema:$(I.boolean())}}},...P(404)}}),D("param",I.object({ptyID:jn.zod})),r(async(i)=>{let n=jn.zod.parse(i.req.param("ptyID")),m=i.req.query(fm);if(!m||!Tj(m,n))throw new kr(401,{message:"Invalid or expired ticket"});let c=(()=>{let S=i.req.query("cursor");if(!S)return;let v=Number(S);if(!Number.isSafeInteger(v)||v<-1)return;return v})(),l;if(!await u("PtyRoutes.connect",i,C.gen(function*(){return yield*(yield*Wr.Service).get(n)})))throw Error("Session not found");let y=(S)=>{if(!S||typeof S!=="object")return!1;if(!("readyState"in S))return!1;if(!("send"in S)||typeof S.send!=="function")return!1;if(!("close"in S)||typeof S.close!=="function")return!1;return typeof S.readyState==="number"},j=[],A=!1;return{async onOpen(S,v){let w=v.raw;if(!y(w)){v.close();return}l=await e.runPromise(C.gen(function*(){return yield*(yield*Wr.Service).connect(n,w,c)}).pipe(C.withSpan("PtyRoutes.connect.open"))),A=!0;for(let N of j)l?.onMessage(N);j.length=0},onMessage(S){if(typeof S.data!=="string")return;if(!A){j.push(S.data);return}l?.onMessage(S.data)},onClose(){l?.onClose()},onError(){l?.onClose()}}}))}var X2=(r,i)=>C.gen(function*(){let n=yield*Xr.Service;if(i==="connect")yield*n.connect(r);else yield*n.disconnect(r);return!0}),H2=F(()=>new V().get("/",G({summary:"Get MCP status",description:"Get the status of all Model Context Protocol (MCP) servers.",operationId:"mcp.status",responses:{200:{description:"MCP server status",content:{"application/json":{schema:$(I.record(I.string(),Xr.Status))}}}}}),async(r)=>U("McpRoutes.status",r,function*(){return yield*(yield*Xr.Service).status()})).post("/",G({summary:"Add MCP server",description:"Dynamically add a new Model Context Protocol (MCP) server to the system.",operationId:"mcp.add",responses:{200:{description:"MCP server added successfully",content:{"application/json":{schema:$(I.record(I.string(),Xr.Status))}}},...P(400)}}),D("json",I.object({name:I.string(),config:K2.Info.zod})),async(r)=>{if(!k.QITQODE_SERVER_PASSWORD)return r.json({error:"Forbidden: QITQODE_SERVER_PASSWORD must be set to add MCP servers via API"},403);return U("McpRoutes.add",r,function*(){let{name:i,config:n}=r.req.valid("json");return(yield*(yield*Xr.Service).add(i,n)).status})}).post("/:name/auth",G({summary:"Start MCP OAuth",description:"Start OAuth authentication flow for a Model Context Protocol (MCP) server.",operationId:"mcp.auth.start",responses:{200:{description:"OAuth flow started",content:{"application/json":{schema:$(I.object({authorizationUrl:I.string().describe("URL to open in browser for authorization")}))}}},...P(400,404)}}),async(r)=>{let i=r.req.param("name"),n=await u("McpRoutes.auth.start",r,C.gen(function*(){let m=yield*Xr.Service,c=yield*m.supportsOAuth(i);if(!c)return{supports:c};return{supports:c,auth:yield*m.startAuth(i)}}));if(!n.supports)return r.json({error:`MCP server ${i} does not support OAuth`},400);return r.json(n.auth)}).post("/:name/auth/callback",G({summary:"Complete MCP OAuth",description:"Complete OAuth authentication for a Model Context Protocol (MCP) server using the authorization code.",operationId:"mcp.auth.callback",responses:{200:{description:"OAuth authentication completed",content:{"application/json":{schema:$(Xr.Status)}}},...P(400,404)}}),D("json",I.object({code:I.string().describe("Authorization code from OAuth callback")})),async(r)=>U("McpRoutes.auth.callback",r,function*(){let i=r.req.param("name"),{code:n}=r.req.valid("json");return yield*(yield*Xr.Service).finishAuth(i,n)})).post("/:name/auth/authenticate",G({summary:"Authenticate MCP OAuth",description:"Start OAuth flow and wait for callback (opens browser)",operationId:"mcp.auth.authenticate",responses:{200:{description:"OAuth authentication completed",content:{"application/json":{schema:$(Xr.Status)}}},...P(400,404)}}),async(r)=>{let i=r.req.param("name"),n=await u("McpRoutes.auth.authenticate",r,C.gen(function*(){let m=yield*Xr.Service,c=yield*m.supportsOAuth(i);if(!c)return{supports:c};return{supports:c,status:yield*m.authenticate(i)}}));if(!n.supports)return r.json({error:`MCP server ${i} does not support OAuth`},400);return r.json(n.status)}).delete("/:name/auth",G({summary:"Remove MCP OAuth",description:"Remove OAuth credentials for an MCP server",operationId:"mcp.auth.remove",responses:{200:{description:"OAuth credentials removed",content:{"application/json":{schema:$(I.object({success:I.literal(!0)}))}}},...P(404)}}),async(r)=>U("McpRoutes.auth.remove",r,function*(){let i=r.req.param("name");return yield*(yield*Xr.Service).removeAuth(i),{success:!0}})).post("/:name/connect",G({description:"Connect an MCP server",operationId:"mcp.connect",responses:{200:{description:"MCP server connected successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),D("param",I.object({name:I.string()})),async(r)=>U("McpRoutes.connect",r,function*(){return yield*X2(r.req.valid("param").name,"connect")})).post("/:name/disconnect",G({description:"Disconnect an MCP server",operationId:"mcp.disconnect",responses:{200:{description:"MCP server disconnected successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),D("param",I.object({name:I.string()})),async(r)=>U("McpRoutes.disconnect",r,function*(){return yield*X2(r.req.valid("param").name,"disconnect")})));var Z2=F(()=>new V().get("/find",G({summary:"Find text",description:"Search for text patterns across files in the project using ripgrep.",operationId:"find.text",responses:{200:{description:"Matches",content:{"application/json":{schema:$(zl.Match.shape.data.array())}}}}}),D("query",I.object({pattern:I.string()})),async(r)=>U("FileRoutes.findText",r,function*(){let i=r.req.valid("query").pattern;return(yield*(yield*zl.Service).search({cwd:M.directory,pattern:i,limit:10})).items})).get("/find/file",G({summary:"Find files",description:"Search for files or directories by name or pattern in the project directory.",operationId:"find.files",responses:{200:{description:"File paths",content:{"application/json":{schema:$(I.string().array())}}}}}),D("query",I.object({query:I.string(),dirs:I.enum(["true","false"]).optional(),type:I.enum(["file","directory"]).optional(),limit:I.coerce.number().int().min(1).max(200).optional()})),async(r)=>U("FileRoutes.findFile",r,function*(){let i=r.req.valid("query");return yield*(yield*ui.Service).search({query:i.query,limit:i.limit??10,dirs:i.dirs!=="false",type:i.type})})).get("/find/symbol",G({summary:"Find symbols",description:"Search for workspace symbols like functions, classes, and variables using LSP.",operationId:"find.symbols",responses:{200:{description:"Symbols",content:{"application/json":{schema:$(Ym.Symbol.array())}}}}}),D("query",I.object({query:I.string()})),async(r)=>{return r.json([])}).get("/file",G({summary:"List files",description:"List files and directories in a specified path.",operationId:"file.list",responses:{200:{description:"Files and directories",content:{"application/json":{schema:$(ui.Node.array())}}}}}),D("query",I.object({path:I.string()})),async(r)=>U("FileRoutes.list",r,function*(){return yield*(yield*ui.Service).list(r.req.valid("query").path)})).get("/file/content",G({summary:"Read file",description:"Read the content of a specified file.",operationId:"file.read",responses:{200:{description:"File content",content:{"application/json":{schema:$(ui.Content)}}}}}),D("query",I.object({path:I.string()})),async(r)=>U("FileRoutes.read",r,function*(){return yield*(yield*ui.Service).read(r.req.valid("query").path)})).get("/file/status",G({summary:"Get file status",description:"Get the git status of all files in the project.",operationId:"file.status",responses:{200:{description:"File status",content:{"application/json":{schema:$(ui.Info.array())}}}}}),async(r)=>U("FileRoutes.status",r,function*(){return yield*(yield*ui.Service).status()})));var V2=F(()=>new V().get("/",G({summary:"Get configuration",description:"Retrieve the current QitQode configuration settings and preferences.",operationId:"config.get",responses:{200:{description:"Get config info",content:{"application/json":{schema:$(mr.Info)}}}}}),async(r)=>U("ConfigRoutes.get",r,function*(){return yield*(yield*mr.Service).get()})).patch("/",G({summary:"Update configuration",description:"Update QitQode configuration settings and preferences.",operationId:"config.update",responses:{200:{description:"Successfully updated config",content:{"application/json":{schema:$(mr.Info)}}},...P(400)}}),D("json",mr.Info),async(r)=>U("ConfigRoutes.update",r,function*(){let i=r.req.valid("json");return yield*(yield*mr.Service).update(i),i})).get("/providers",G({summary:"List config providers",description:"Get a list of all configured AI providers and their default models.",operationId:"config.providers",responses:{200:{description:"List of providers",content:{"application/json":{schema:$(ir.ConfigProvidersResult.zod)}}}}}),async(r)=>U("ConfigRoutes.providers",r,function*(){let n=yield*(yield*ir.Service).list();return{providers:Object.values(n),default:ir.defaultModelIDs(n)}})));var s4=I.object({accountID:I.string(),accountEmail:I.string(),accountUrl:I.string(),orgID:I.string(),orgName:I.string(),active:I.boolean()}),f4=I.object({orgs:I.array(s4)}),r$=I.object({accountID:I.string(),orgID:I.string()}),O2=F(()=>new V().get("/console",G({summary:"Get active Console provider metadata",description:"Get the active Console org name and the set of provider IDs managed by that Console org.",operationId:"experimental.console.get",responses:{200:{description:"Active Console provider metadata",content:{"application/json":{schema:$(R2.zod)}}}}}),async(r)=>U("ExperimentalRoutes.console.get",r,function*(){let i=yield*mr.Service,n=yield*f0.Service,[m,c]=yield*C.all([i.getConsoleState(),n.orgsByAccount()],{concurrency:"unbounded"});return{...m,switchableOrgCount:c.reduce((l,y)=>l+y.orgs.length,0)}})).get("/console/orgs",G({summary:"List switchable Console orgs",description:"Get the available Console orgs across logged-in accounts, including the current active org.",operationId:"experimental.console.listOrgs",responses:{200:{description:"Switchable Console orgs",content:{"application/json":{schema:$(f4)}}}}}),async(r)=>U("ExperimentalRoutes.console.listOrgs",r,function*(){let i=yield*f0.Service,[n,m]=yield*C.all([i.orgsByAccount(),i.active()],{concurrency:"unbounded"}),c=Qm.getOrUndefined(m);return{orgs:n.flatMap((y)=>y.orgs.map((j)=>({accountID:y.account.id,accountEmail:y.account.email,accountUrl:y.account.url,orgID:j.id,orgName:j.name,active:!!c&&c.id===y.account.id&&c.active_org_id===j.id})))}})).post("/console/switch",G({summary:"Switch active Console org",description:"Persist a new active Console account/org selection for the current local QitQode state.",operationId:"experimental.console.switchOrg",responses:{200:{description:"Switch success",content:{"application/json":{schema:$(I.boolean())}}}}}),D("json",r$),async(r)=>U("ExperimentalRoutes.console.switchOrg",r,function*(){let i=r.req.valid("json");return yield*(yield*f0.Service).use(Y2.make(i.accountID),Qm.some(J2.make(i.orgID))),!0})).get("/tool/ids",G({summary:"List tool IDs",description:"Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.",operationId:"tool.ids",responses:{200:{description:"Tool IDs",content:{"application/json":{schema:$(I.array(I.string()).meta({ref:"ToolIDs"}))}}},...P(400)}}),async(r)=>U("ExperimentalRoutes.tool.ids",r,function*(){return yield*(yield*Ml.Service).ids()})).get("/tool",G({summary:"List tools",description:"Get a list of available tools with their JSON schema parameters for a specific provider and model combination.",operationId:"tool.list",responses:{200:{description:"Tools",content:{"application/json":{schema:$(I.array(I.object({id:I.string(),description:I.string(),parameters:I.any()}).meta({ref:"ToolListItem"})).meta({ref:"ToolList"}))}}},...P(400)}}),D("query",I.object({provider:I.string(),model:I.string()})),async(r)=>{let{provider:i,model:n}=r.req.valid("query"),m=await u("ExperimentalRoutes.tool.list",r,C.gen(function*(){let c=yield*yn.Service;return yield*(yield*Ml.Service).tools({providerID:lr.make(i),modelID:er.make(n),agent:yield*c.get(yield*c.defaultAgent())})}));return r.json(m.map((c)=>({id:c.id,description:c.description,parameters:I.toJSONSchema(c.parameters)})))}).post("/worktree",G({summary:"Create worktree",description:"Create a new git worktree for the current project and run any configured startup scripts.",operationId:"worktree.create",responses:{200:{description:"Worktree created",content:{"application/json":{schema:$(ai.Info)}}},...P(400)}}),D("json",ai.CreateInput.optional()),async(r)=>U("ExperimentalRoutes.worktree.create",r,function*(){let i=r.req.valid("json"),n=i?{...i,startCommand:k.QITQODE_SERVER_PASSWORD?i.startCommand:void 0}:i;return yield*(yield*ai.Service).create(n)})).get("/worktree",G({summary:"List worktrees",description:"List all sandbox worktrees for the current project.",operationId:"worktree.list",responses:{200:{description:"List of worktree directories",content:{"application/json":{schema:$(I.array(I.string()))}}}}}),async(r)=>U("ExperimentalRoutes.worktree.list",r,function*(){return yield*(yield*Gr.Service).sandboxes(M.project.id)})).delete("/worktree",G({summary:"Remove worktree",description:"Remove a git worktree and delete its branch.",operationId:"worktree.remove",responses:{200:{description:"Worktree removed",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("json",ai.RemoveInput),async(r)=>U("ExperimentalRoutes.worktree.remove",r,function*(){let i=r.req.valid("json"),n=yield*ai.Service,m=yield*Gr.Service;return yield*n.remove(i),yield*m.removeSandbox(M.project.id,i.directory),!0})).post("/worktree/reset",G({summary:"Reset worktree",description:"Reset a worktree branch to the primary default branch.",operationId:"worktree.reset",responses:{200:{description:"Worktree reset",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("json",ai.ResetInput),async(r)=>U("ExperimentalRoutes.worktree.reset",r,function*(){let i=r.req.valid("json");return yield*(yield*ai.Service).reset(i),!0})).get("/session",G({summary:"List sessions",description:"Get a list of all QitQode sessions across projects, sorted by most recently updated. Archived sessions are excluded by default.",operationId:"experimental.session.list",responses:{200:{description:"List of sessions",content:{"application/json":{schema:$(J.GlobalInfo.array())}}}}}),D("query",I.object({directory:ki.directory,roots:ki.roots,start:ki.start,cursor:I.coerce.number().optional().meta({description:"Return sessions updated before this timestamp (milliseconds since epoch)"}),search:ki.search,limit:ki.limit,archived:I.coerce.boolean().optional().meta({description:"Include archived sessions (default false)"})})),async(r)=>{let i=r.req.valid("query"),n=i.limit??100,m=[];for await(let y of J.listGlobal({directory:i.directory,roots:i.roots,start:i.start,cursor:i.cursor,search:i.search,limit:n+1,archived:i.archived}))m.push(y);let c=m.length>n,l=c?m.slice(0,n):m;if(c&&l.length>0)r.header("x-next-cursor",String(l[l.length-1].time.updated));return r.json(l)}).get("/resource",G({summary:"Get MCP resources",description:"Get all available MCP resources from connected servers. Optionally filter by name.",operationId:"experimental.resource.list",responses:{200:{description:"MCP resources",content:{"application/json":{schema:$(I.record(I.string(),Xr.Resource))}}}}}),async(r)=>U("ExperimentalRoutes.resource.list",r,function*(){return yield*(yield*Xr.Service).resources()})));var L2=F(()=>new V().get("/",G({summary:"List providers",description:"Get a list of all available AI providers, including both available and connected ones.",operationId:"provider.list",responses:{200:{description:"List of providers",content:{"application/json":{schema:$(ir.ListResult.zod)}}}}}),async(r)=>U("ProviderRoutes.list",r,function*(){let i=yield*ir.Service,m=yield*(yield*mr.Service).get(),c=yield*i.list();return yield*u0(m,c)})).get("/auth",G({summary:"Get provider auth methods",description:"Retrieve available authentication methods for all AI providers.",operationId:"provider.auth",responses:{200:{description:"Provider auth methods",content:{"application/json":{schema:$(Cr.Methods.zod)}}}}}),async(r)=>U("ProviderRoutes.auth",r,function*(){return yield*(yield*Cr.Service).methods()})).post("/:providerID/oauth/authorize",G({summary:"OAuth authorize",description:"Initiate OAuth authorization for a specific AI provider to get an authorization URL.",operationId:"provider.oauth.authorize",responses:{200:{description:"Authorization URL and method",content:{"application/json":{schema:$(Cr.Authorization.zod.optional())}}},...P(400)}}),D("param",I.object({providerID:lr.zod.meta({description:"Provider ID"})})),D("json",Cr.AuthorizeInput.zod),async(r)=>U("ProviderRoutes.oauth.authorize",r,function*(){let i=r.req.valid("param").providerID,{method:n,inputs:m}=r.req.valid("json");return yield*(yield*Cr.Service).authorize({providerID:i,method:n,inputs:m})})).post("/:providerID/oauth/callback",G({summary:"OAuth callback",description:"Handle the OAuth callback from a provider after user authorization.",operationId:"provider.oauth.callback",responses:{200:{description:"OAuth callback processed successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("param",I.object({providerID:lr.zod.meta({description:"Provider ID"})})),D("json",Cr.CallbackInput.zod),async(r)=>U("ProviderRoutes.oauth.callback",r,function*(){let i=r.req.valid("param").providerID,{method:n,code:m}=r.req.valid("json");return yield*(yield*Cr.Service).callback({providerID:i,method:n,code:m}),!0})));var i$=1e4,n$=1e5,m$=8388608,c$=67108864,l$=2097152,y$=8388608;function j$(r=process.env.QITQODE_EVENT_QUEUE_CAPACITY){let i=Number(r);if(!Number.isSafeInteger(i)||i<1||i>n$)return i$;return i}var I$=j$();function A$(r=process.env.QITQODE_EVENT_QUEUE_BYTES){let i=Number(r);if(!Number.isSafeInteger(i)||i<1||i>c$)return m$;return i}function S$(r=process.env.QITQODE_EVENT_MAX_BYTES){let i=Number(r);if(!Number.isSafeInteger(i)||i<1||i>y$)return l$;return i}var q2=A$(),v$=Math.min(S$(),q2);function w$(r,i=v$){let n=JSON.stringify(r);if(n===void 0||Buffer.byteLength(n)>i)return;return n}function rc(r,i){return Fl(r,async(n)=>{let m=new Un({capacity:I$,maxWeight:q2,weight:(v)=>v===null?0:Buffer.byteLength(v)}),c=!1,l=0,y=()=>{},j=(v)=>{let w=w$(v);if(w===void 0){l++;return}m.push(w)};j(i.connected);let A=setInterval(()=>j(i.heartbeat),1e4),S=()=>{if(c)return;if(c=!0,clearInterval(A),y(),m.push(null),m.dropped+l>0)i.onDrop?.(m.dropped+l);i.onDisconnect?.(m.size,m.bufferedWeight)};try{let v=i.subscribe(j,S);if(c)v();else y=v;n.onAbort(S);for await(let w of m){if(w===null)return;await n.writeSSE({data:w})}}finally{S()}})}class Jm{limit;windowMs;buckets=new Map;pruneKeys=[];pruneIndex=0;sweeping=!1;nextSweepAt=0;constructor(r,i){this.limit=r;this.windowMs=i}check(r,i=Date.now()){if(this.sweeping||this.buckets.size>1024||this.buckets.size>0&&i>=this.nextSweepAt)this.pruneSome(i);let n=i-this.windowMs,m=(this.buckets.get(r)??[]).filter((c)=>c>n);if(m.length>=this.limit){this.buckets.set(r,m);let c=m[0]??i;return{allowed:!1,retryAfterSeconds:Math.max(1,Math.ceil((c+this.windowMs-i)/1000))}}return m.push(i),this.buckets.set(r,m),{allowed:!0}}pruneSome(r,i=64){if(!this.sweeping)this.pruneKeys=[...this.buckets.keys()],this.pruneIndex=0,this.sweeping=!0,this.nextSweepAt=r+this.windowMs;let n=r-this.windowMs,m=Math.min(this.pruneIndex+i,this.pruneKeys.length);for(;this.pruneIndex<m;this.pruneIndex++){let c=this.pruneKeys[this.pruneIndex],l=this.buckets.get(c);if(!l)continue;let y=l.filter((j)=>j>n);if(y.length===0)this.buckets.delete(c);else this.buckets.set(c,y)}if(this.pruneIndex>=this.pruneKeys.length)this.sweeping=!1,this.pruneKeys=[],this.pruneIndex=0}}var ic=_.create({service:"server"}),_2=()=>{let r=Number(process.env.QITQODE_EVENT_CONNECT_LIMIT)||60,i=Number(process.env.QITQODE_EVENT_CONNECT_WINDOW_MS)||60000,n=new Jm(r,i);return new V().get("/event",G({summary:"Subscribe to events",description:"Get events",operationId:"event.subscribe",responses:{200:{description:"Event stream",content:{"text/event-stream":{schema:$(I.union(yi.payloads()).meta({ref:"Event"}))}}}}}),async(m)=>{let c=m.req.header("x-forwarded-for")?.split(",")[0]?.trim()||"local",l=n.check(c);if(!l.allowed)return ic.warn("event connection rate limited",{key:c,retryAfterSeconds:l.retryAfterSeconds}),m.header("Retry-After",String(l.retryAfterSeconds)),m.json({error:"Too many reconnect attempts, slow down"},429);return ic.info("event connected"),m.header("Cache-Control","no-cache, no-transform"),m.header("X-Accel-Buffering","no"),m.header("X-Content-Type-Options","nosniff"),rc(m,{connected:{type:qn.Connected.type,properties:{}},heartbeat:{type:qn.Heartbeat.type,properties:{}},subscribe(y,j){return wr.subscribeAll((A)=>{if(y(A),A.type===wr.InstanceDisposed.type)j()})},onDrop(y){ic.warn("event dropped under backpressure",{dropped:y})},onDisconnect(y,j){ic.info("event disconnected",{buffered:y,bufferedBytes:j})}})})};var $$=I.object({id:I.string(),aggregateID:I.string(),seq:I.number().int().min(0),type:I.string(),data:I.record(I.string(),I.unknown())}),F2=_.create({service:"server.sync"}),T2=F(()=>new V().post("/start",G({summary:"Start workspace sync",description:"Start sync loops for workspaces in the current project that have active sessions.",operationId:"sync.start",responses:{200:{description:"Workspace sync started",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return uc(M.project.id),r.json(!0)}).post("/replay",G({summary:"Replay sync events",description:"Validate and replay a complete sync event history.",operationId:"sync.replay",responses:{200:{description:"Replayed sync events",content:{"application/json":{schema:$(I.object({sessionID:I.string()}))}}},...P(400)}}),D("json",I.object({directory:I.string(),events:I.array($$).min(1)})),async(r)=>{let i=r.req.valid("json"),n=i.events,m=n[0].aggregateID;return F2.info("sync replay requested",{sessionID:m,events:n.length,first:n[0]?.seq,last:n.at(-1)?.seq,directory:i.directory}),yr.replayAll(n),F2.info("sync replay complete",{sessionID:m,events:n.length,first:n[0]?.seq,last:n.at(-1)?.seq}),r.json({sessionID:m})}).post("/history",G({summary:"List sync events",description:"List sync events for all aggregates. Keys are aggregate IDs the client already knows about, values are the last known sequence ID. Events with seq > value are returned for those aggregates. Aggregates not listed in the input get their full history.",operationId:"sync.history.list",responses:{200:{description:"Sync events",content:{"application/json":{schema:$(I.array(I.object({id:I.string(),aggregate_id:I.string(),seq:I.number(),type:I.string(),data:I.record(I.string(),I.unknown())})))}}},...P(400)}}),D("json",I.record(I.string(),I.number().int().min(0))),async(r)=>{let i=r.req.valid("json"),n=Object.entries(i),m=n.length>0?z2(g2(...n.map(([l,y])=>nm(d(Zr.aggregate_id,l),M2(Zr.seq,y))))):void 0,c=b.use((l)=>l.select().from(Zr).where(m).orderBy(c0(Zr.seq)).all());return r.json(c)}));var Bl=(r)=>{let i=new V;if(k.QITQODE_EXPERIMENTAL_HTTPAPI){let n=Xm.webHandler().handler,m=Zi.empty();i.get("/question",(c)=>n(c.req.raw,m)),i.post("/question/:requestID/reply",(c)=>n(c.req.raw,m)),i.post("/question/:requestID/reject",(c)=>n(c.req.raw,m)),i.get("/permission",(c)=>n(c.req.raw,m)),i.post("/permission/:requestID/reply",(c)=>n(c.req.raw,m)),i.get("/config/providers",(c)=>n(c.req.raw,m)),i.get("/provider",(c)=>n(c.req.raw,m)),i.get("/provider/auth",(c)=>n(c.req.raw,m)),i.post("/provider/:providerID/oauth/authorize",(c)=>n(c.req.raw,m)),i.post("/provider/:providerID/oauth/callback",(c)=>n(c.req.raw,m)),i.get("/project",(c)=>n(c.req.raw,m)),i.get("/project/current",(c)=>n(c.req.raw,m))}return i.route("/project",n2()).route("/pty",W2(r)).route("/config",V2()).route("/experimental",O2()).route("/session",E2()).route("/qredits",C2()).route("/permission",E1()).route("/workflows",D1()).route("/question",N1()).route("/bash-interactive",U1()).route("/provider",L2()).route("/sync",T2()).route("/",Z2()).route("/",_2()).route("/mcp",H2()).route("/tui",$1()).post("/instance/dispose",G({summary:"Dispose instance",description:"Clean up and dispose the current QitQode instance, releasing all resources.",operationId:"instance.dispose",responses:{200:{description:"Instance disposed",content:{"application/json":{schema:$(I.boolean())}}}}}),async(n)=>{return await M.dispose(),n.json(!0)}).get("/path",G({summary:"Get paths",description:"Retrieve the current working directory and related path information for the QitQode instance.",operationId:"path.get",responses:{200:{description:"Path",content:{"application/json":{schema:$(I.object({home:I.string(),state:I.string(),config:I.string(),worktree:I.string(),directory:I.string()}).meta({ref:"Path"}))}}}}}),async(n)=>{return n.json({home:Vi.Path.home,state:Vi.Path.state,config:Vi.Path.config,worktree:M.worktree,directory:M.directory})}).get("/vcs",G({summary:"Get VCS info",description:"Retrieve version control system (VCS) information for the current project, such as git branch.",operationId:"vcs.get",responses:{200:{description:"VCS info",content:{"application/json":{schema:$(_n.Info)}}}}}),async(n)=>U("InstanceRoutes.vcs.get",n,function*(){let m=yield*_n.Service,[c,l]=yield*C.all([m.branch(),m.defaultBranch()],{concurrency:2});return{branch:c,default_branch:l}})).get("/vcs/diff",G({summary:"Get VCS diff",description:"Retrieve the current git diff for the working tree or against the default branch.",operationId:"vcs.diff",responses:{200:{description:"VCS diff",content:{"application/json":{schema:$(_n.FileDiff.array())}}}}}),D("query",I.object({mode:_n.Mode})),async(n)=>U("InstanceRoutes.vcs.diff",n,function*(){return yield*(yield*_n.Service).diff(n.req.valid("query").mode)})).get("/command",G({summary:"List commands",description:"Get a list of all available commands in the QitQode system.",operationId:"command.list",responses:{200:{description:"List of commands",content:{"application/json":{schema:$(Km.Info.array())}}}}}),async(n)=>U("InstanceRoutes.command.list",n,function*(){return yield*(yield*Km.Service).list()})).get("/agent",G({summary:"List agents",description:"Get a list of all available AI agents in the QitQode system.",operationId:"app.agents",responses:{200:{description:"List of agents",content:{"application/json":{schema:$(yn.Info.array())}}}}}),async(n)=>U("InstanceRoutes.agent.list",n,function*(){return yield*(yield*yn.Service).list()})).get("/skill",G({summary:"List skills",description:"Get a list of all available skills in the QitQode system.",operationId:"app.skills",responses:{200:{description:"List of skills",content:{"application/json":{schema:$(hl.Info.array())}}}}}),async(n)=>U("InstanceRoutes.skill.list",n,function*(){return yield*(yield*hl.Service).all()})).get("/lsp",G({summary:"Get LSP status",description:"Get LSP server status",operationId:"lsp.status",responses:{200:{description:"LSP server status",content:{"application/json":{schema:$(Ym.Status.array())}}}}}),async(n)=>U("InstanceRoutes.lsp.status",n,function*(){return yield*(yield*Ym.Service).status()})).get("/formatter",G({summary:"Get formatter status",description:"Get formatter status",operationId:"formatter.status",responses:{200:{description:"Formatter status",content:{"application/json":{schema:$(Tl.Status.array())}}}}}),async(n)=>U("InstanceRoutes.formatter.status",n,function*(){return yield*(yield*Tl.Service).status()}))};function h2(){let r=new V,i=(n,m)=>e.runPromise(C.gen(function*(){let c=yield*rm.Service;if(m)yield*c.set(n,m);else yield*c.remove(n)}));return r.put("/auth/:providerID",G({summary:"Set auth credentials",description:"Set authentication credentials",operationId:"auth.set",responses:{200:{description:"Successfully set authentication credentials",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("param",I.object({providerID:lr.zod})),D("json",rm.Info.zod),async(n)=>{let m=n.req.valid("param").providerID,c=n.req.valid("json");return await i(m,c),n.json(!0)}).delete("/auth/:providerID",G({summary:"Remove auth credentials",description:"Remove authentication credentials",operationId:"auth.remove",responses:{200:{description:"Successfully removed authentication credentials",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("param",I.object({providerID:lr.zod})),async(n)=>{let m=n.req.valid("param").providerID;return await i(m),n.json(!0)}).get("/doc",Qy(r,{documentation:{info:{title:"qitqode",version:"0.0.3",description:"qitqode api"},openapi:"3.1.1"}})).use(D("query",I.object({directory:I.string().optional(),workspace:I.string().optional()}))).post("/log",G({summary:"Write log",description:"Write a log entry to the server logs with specified level and metadata.",operationId:"app.log",responses:{200:{description:"Log entry written successfully",content:{"application/json":{schema:$(I.boolean())}}},...P(400)}}),D("json",I.object({service:I.string().meta({description:"Service name for the log entry"}),level:I.enum(["debug","info","error","warn"]).meta({description:"Log level"}),message:I.string().meta({description:"Log message"}),extra:I.record(I.string(),I.any()).optional().meta({description:"Additional metadata for the log entry"})})),async(n)=>{let{service:m,level:c,message:l,extra:y}=n.req.valid("json"),j=_.create({service:m});switch(c){case"debug":j.debug(l,y);break;case"info":j.info(l,y);break;case"error":j.error(l,y);break;case"warn":j.warn(l,y);break}return n.json(!0)})}var Fn={};Nr(Fn,{scan:()=>W$,runAll:()=>X$,ExternalImport:()=>Fn,ALL_SOURCES:()=>pl});import rA from"path";import{access as ol}from"fs/promises";import{Database as G$}from"bun:sqlite";function Rm(r){let i=new G$(r,{readonly:!0});return{all:(n,...m)=>i.query(n).all(...m),get:(n,...m)=>i.query(n).get(...m)??null,close:()=>i.close()}}var Om={};Nr(Om,{run:()=>D$,parse:()=>p2,CodexImport:()=>Om});import N$ from"path";var E$=_.create({service:"codex-import"});function B2(r){if(!r)return Date.now();let i=Date.parse(r);return Number.isNaN(i)?Date.now():i}function Q$(r){if(typeof r==="string")try{return JSON.parse(r)}catch{return{raw:r}}if(r&&typeof r==="object")return r;return{}}function p2(r,i){let n=o2(r);if(n.length===0)return;let m,c,l,y,j=0,A,S=[],v=new Map,w=null,N=null,E=()=>{if(w)S.push(w);w=null},Q=(W)=>{if(!N){let Z=Si.ascending();S.push({info:{id:Z,sessionID:i,role:"user",agent:"main",time:{created:W},model:{providerID:lr.make("openai"),modelID:er.make("unknown")}},parts:[]}),N=Z}if(!w||w.info.role!=="assistant")E(),w={info:{id:Si.ascending(),sessionID:i,role:"assistant",time:{created:W,completed:W},parentID:N,modelID:er.make("unknown"),providerID:lr.make("openai"),mode:"build",agent:"main",path:{cwd:m??"",root:m??""},cost:0,tokens:{input:0,output:0,reasoning:0,cache:{read:0,write:0}}},parts:[]};return w.info.time.completed=W,w};for(let W of n){let{type:Z,payload:X}=W,K=B2(W.timestamp);if(y===void 0)y=K;if(j=Math.max(j,K),Z==="session_meta"&&X){m=X.cwd,c=`codex-${X.cli_version??"unknown"}`,l=X.id;let q=B2(X.timestamp);if(y===void 0||q<y)y=q;continue}if(Z!=="response_item"||!X)continue;let R=X.type;if(R==="message"){let q=X.role,z=X.content??[];if(q==="user"||q==="developer"){let L=z.filter((x)=>(x.type==="input_text"||x.type==="text")&&typeof x.text==="string"&&x.text.trim()).map((x)=>x.text);if(L.length===0)continue;E();let f=Si.ascending(),hr=L.map((x)=>({part:{id:pi.ascending(),sessionID:i,messageID:f,type:"text",text:x},time:K})),Yr={id:f,sessionID:i,role:"user",agent:"main",time:{created:K},model:{providerID:lr.make("openai"),modelID:er.make("unknown")}};if(S.push({info:Yr,parts:hr}),N=f,!A)A=x2(L);continue}if(q==="assistant"){let L=Q(K);for(let f of z)if((f.type==="output_text"||f.type==="text")&&typeof f.text==="string"&&f.text.trim())L.parts.push({part:{id:pi.ascending(),sessionID:i,messageID:L.info.id,type:"text",text:f.text},time:K});continue}continue}if(R==="reasoning"){let q=Q(K),L=X.summary?.map((f)=>f.text??"").join("")??"";if(L.trim())q.parts.push({part:{id:pi.ascending(),sessionID:i,messageID:q.info.id,type:"reasoning",text:L,time:{start:K,end:K}},time:K});continue}if(R==="function_call"||R==="custom_tool_call"){let q=Q(K),z=X.call_id??pi.ascending(),L=X.name??"unknown",f=R==="function_call"?Q$(X.arguments):{raw:X.input??""},hr={id:pi.ascending(),sessionID:i,messageID:q.info.id,type:"tool",callID:z,tool:L,state:{status:"pending",input:f,raw:JSON.stringify(f)}};q.parts.push({part:hr,time:K}),v.set(z,{part:hr,start:K});continue}if(R==="function_call_output"||R==="custom_tool_call_output"){let q=X.call_id,z=q?v.get(q):void 0;if(!z)continue;let L=typeof X.output==="string"?X.output:JSON.stringify(X.output??"");z.part.state={status:"completed",input:z.part.state.input??{},output:L,title:z.part.tool,metadata:{},time:{start:z.start,end:K}};continue}}if(E(),S.length===0)return;return{cwd:m??"",version:c??"codex",sessionUuid:l,title:A??"Codex session",timeCreated:y??Date.now(),timeUpdated:j||y||Date.now(),messages:S}}var D$=k2({source:"codex",root:N$.join(Vi.Path.home,".codex","sessions"),pattern:"**/*.jsonl",log:E$,logMessage:"codex import",parse:p2});var qm={};Nr(qm,{run:()=>C$,OpencodeImport:()=>qm,DEFAULT_DB_PATH:()=>Lm});import{access as U$}from"fs/promises";var P$=_.create({service:"opencode-import"}),Lm=(()=>{return`${process.env.XDG_DATA_HOME||`${process.env.HOME||process.env.USERPROFILE}/.local/share`}/opencode/opencode.db`})(),u2=200;async function C$(r){let i=r?.dbPath??Lm,n=a2();if(!await U$(i).then(()=>!0).catch(()=>!1))return n;let m;try{m=Rm(i)}catch(c){return n.errors.push(`failed to open ${i}: ${c}`),n}try{if(!m.get("SELECT name FROM sqlite_master WHERE type='table' AND name='session'"))return n.errors.push(`${i}: missing 'session' table`),n;let l=m.all("SELECT * FROM session ORDER BY time_created DESC");for(let y of l){n.scanned++;try{let j=y.id,A=t2("opencode",j);if(A&&A.source_mtime===y.time_updated&&!r?.force){n.skipped++;continue}let S=b2("opencode",A);A=S.existing;let v=S.existingUpdated,w=await d2(y.directory),N=Date.now(),E=m.all("SELECT * FROM message WHERE session_id = ? ORDER BY id",y.id);if(E.length===0){n.skipped++;continue}let Q=E.map((Z)=>Z.id),W=[];for(let Z=0;Z<Q.length;Z+=u2){let X=Q.slice(Z,Z+u2),K=X.map(()=>"?").join(","),R=m.all(`SELECT * FROM part WHERE session_id = ? AND message_id IN (${K}) ORDER BY id`,y.id,...X);W.push(...R)}if(b.transaction((Z)=>{if(e2(Z,w,y.time_created,y.time_updated),A)s2(Z,A,y.id),f2(Z,y.id,{projectId:w.id,directory:y.directory,version:y.version,existingUpdated:v,timeUpdated:y.time_updated});else Z.insert(nr).values({id:y.id,project_id:w.id,parent_id:y.parent_id,slug:y.slug,directory:y.directory,title:y.title,version:y.version,time_created:y.time_created,time_updated:y.time_updated}).onConflictDoUpdate({target:nr.id,set:{project_id:w.id,directory:y.directory,time_updated:y.time_updated}}).run();for(let X of E){let K=typeof X.data==="string"?JSON.parse(X.data):X.data;Z.insert(Xi).values({id:X.id,session_id:y.id,agent_id:"main",time_created:X.time_created,data:K}).onConflictDoUpdate({target:Xi.id,set:{data:K,time_created:X.time_created}}).run()}for(let X of W){let K=typeof X.data==="string"?JSON.parse(X.data):X.data;Z.insert(Ki).values({id:X.id,message_id:X.message_id,session_id:y.id,time_created:X.time_created,data:K}).onConflictDoUpdate({target:Ki.id,set:{data:K,time_created:X.time_created}}).run()}Z.insert(In).values({source:"opencode",source_key:j,session_id:y.id,source_path:i,source_mtime:y.time_updated,time_imported:N,message_ids:Q}).onConflictDoUpdate({target:[In.source,In.source_key],set:{source_mtime:y.time_updated,time_imported:N,message_ids:Q}}).run()}),A)n.resynced++;else n.imported++}catch(j){n.errors.push(`session ${y.id}: ${j}`)}}}finally{m.close()}if(n.imported+n.resynced>0||n.errors.length>0)P$.info("opencode import",{...n,errors:n.errors.length});return n}var _m=_.create({service:"external-import"}),pl=["cc","codex","opencode"];async function W$(){let r=(c)=>b.use((l)=>l.select({n:iA()}).from(In).where(d(In.source,c)).get())?.n??0,i={cc:{available:!1,sessions:0,imported:0},codex:{available:!1,sessions:0,imported:0},opencode:{available:!1,sessions:0,imported:0}},n=rA.join(Vi.Path.home,".claude","projects");if(await ol(n).then(()=>!0).catch(()=>!1))try{let c=await kl.scan("*/*.jsonl",{cwd:n,absolute:!1});i.cc={available:!0,sessions:c.length,imported:r("cc")}}catch(c){_m.warn("cc scan failed",{error:String(c)})}let m=rA.join(Vi.Path.home,".codex","sessions");if(await ol(m).then(()=>!0).catch(()=>!1))try{let c=await kl.scan("**/*.jsonl",{cwd:m,absolute:!1});i.codex={available:!0,sessions:c.length,imported:r("codex")}}catch(c){_m.warn("codex scan failed",{error:String(c)})}if(await ol(Lm).then(()=>!0).catch(()=>!1))try{let c=Rm(Lm);try{let l=c.get("SELECT count(*) AS n FROM session");i.opencode={available:!0,sessions:l?.n??0,imported:r("opencode")}}finally{c.close()}}catch(c){_m.warn("opencode scan failed",{error:String(c)})}return i}function xl(){return{scanned:0,imported:0,resynced:0,skipped:0,errors:[]}}async function X$(r){let i=new Set(r?.sources??pl),n={cc:xl(),codex:xl(),opencode:xl()};for(let c of pl){if(!i.has(c))continue;try{if(c==="cc")n.cc=await nA.run({force:r?.force});else if(c==="codex")n.codex=await Om.run({force:r?.force});else n.opencode=await qm.run({force:r?.force})}catch(l){_m.warn(`${c} import failed`,{error:String(l)}),n[c].errors.push(String(l))}}let m={scanned:n.cc.scanned+n.codex.scanned+n.opencode.scanned,imported:n.cc.imported+n.codex.imported+n.opencode.imported,resynced:n.cc.resynced+n.codex.resynced+n.opencode.resynced,errors:n.cc.errors.length+n.codex.errors.length+n.opencode.errors.length};if(m.imported+m.resynced>0||m.errors>0)_m.info("external import",m);return n}var nc=_.create({service:"server"}),K$=yi.define("global.disposed",I.object({})),cA=F(()=>{let r=Number(process.env.QITQODE_GLOBAL_EVENT_CONNECT_LIMIT)||60,i=Number(process.env.QITQODE_GLOBAL_EVENT_CONNECT_WINDOW_MS)||60000,n=new Jm(r,i);return new V().get("/health",G({summary:"Get health",description:"Get health information about the QitQode server.",operationId:"global.health",responses:{200:{description:"Health information",content:{"application/json":{schema:$(I.object({healthy:I.literal(!0),version:I.string()}))}}}}}),async(m)=>{return m.json({healthy:!0,version:mA})}).get("/event",G({summary:"Get global events",description:"Subscribe to global events from the QitQode system using server-sent events.",operationId:"global.event",responses:{200:{description:"Event stream",content:{"text/event-stream":{schema:$(I.object({directory:I.string(),project:I.string().optional(),workspace:I.string().optional(),payload:I.union([...yi.payloads(),...yr.payloads()])}).meta({ref:"GlobalEvent"}))}}}}}),async(m)=>{let c=m.req.header("x-forwarded-for")?.split(",")[0]?.trim()||"local",l=n.check(c);if(!l.allowed)return nc.warn("global event connection rate limited",{key:c,retryAfterSeconds:l.retryAfterSeconds}),m.header("Retry-After",String(l.retryAfterSeconds)),m.json({error:"Too many reconnect attempts, slow down"},429);return nc.info("global event connected"),m.header("Cache-Control","no-cache, no-transform"),m.header("X-Accel-Buffering","no"),m.header("X-Content-Type-Options","nosniff"),rc(m,{connected:{directory:"global",payload:{type:qn.Connected.type,properties:{}}},heartbeat:{directory:"global",payload:{type:qn.Heartbeat.type,properties:{}}},subscribe(y){function j(A){y(A)}return Lr.on("event",j),()=>Lr.off("event",j)},onDrop(y){nc.warn("global event dropped under backpressure",{dropped:y})},onDisconnect(y,j){nc.info("global event disconnected",{buffered:y,bufferedBytes:j})}})}).get("/config",G({summary:"Get global configuration",description:"Retrieve the current global QitQode configuration settings and preferences.",operationId:"global.config.get",responses:{200:{description:"Get global config info",content:{"application/json":{schema:$(mr.Info)}}}}}),async(m)=>{return m.json(await e.runPromise(mr.Service.use((c)=>c.getGlobal())))}).patch("/config",G({summary:"Update global configuration",description:"Update global QitQode configuration settings and preferences.",operationId:"global.config.update",responses:{200:{description:"Successfully updated global config",content:{"application/json":{schema:$(mr.Info)}}},...P(400)}}),D("json",mr.Info),async(m)=>{let c=m.req.valid("json"),l=await e.runPromise(mr.Service.use((y)=>y.updateGlobal(c)));return m.json(l)}).post("/dispose",G({summary:"Dispose instance",description:"Clean up and dispose all QitQode instances, releasing all resources.",operationId:"global.dispose",responses:{200:{description:"Global disposed",content:{"application/json":{schema:$(I.boolean())}}}}}),async(m)=>{return await M.disposeAll(),Lr.emit("event",{directory:"global",payload:{type:K$.type,properties:{}}}),m.json(!0)}).post("/upgrade",G({summary:"Upgrade qitqode",description:"Upgrade qitqode to the specified version or latest if not specified.",operationId:"global.upgrade",responses:{200:{description:"Upgrade result",content:{"application/json":{schema:$(I.union([I.object({success:I.literal(!0),version:I.string()}),I.object({success:I.literal(!1),error:I.string()})]))}}},...P(400)}}),D("json",I.object({target:I.string().optional()})),async(m)=>{let c=await e.runPromise(ul.Service.use((y)=>C.gen(function*(){let j=yield*y.method();if(j==="unknown")return{success:!1,status:400,error:"Unknown installation method"};let A=m.req.valid("json").target||(yield*y.latest(j)),S=yield*C.catch(y.upgrade(j,A).pipe(C.as({success:!0,version:A})),(v)=>C.succeed({success:!1,status:500,error:v instanceof Error?v.message:String(v)}));if(!S.success)return S;return{...S,status:200}})));if(!c.success)return m.json({success:!1,error:c.error},c.status);let l=c.version;return Lr.emit("event",{directory:"global",payload:{type:ul.Event.Updated.type,properties:{version:l}}}),m.json({success:!0,version:l})}).get("/import/scan",G({summary:"Scan external session sources",description:"Detect availability and session counts of external AI tool session stores (Claude Code, Codex, opencode). Read-only.",operationId:"global.import.scan",responses:{200:{description:"Per-source availability and counts",content:{"application/json":{schema:$(I.record(I.enum(["cc","codex","opencode"]),I.object({available:I.boolean(),sessions:I.number(),imported:I.number()})))}}}}}),async(m)=>{return m.json(await Fn.scan())}).post("/import/run",G({summary:"Import external sessions",description:"Import sessions from external AI tools (Claude Code, Codex, opencode) into qitqode. Idempotent; pass force to re-sync. Per-source failures are not thrown as HTTP errors \u2014 they are collected into the corresponding stats.errors[] while other sources continue.",operationId:"global.import.run",responses:{200:{description:"Per-source import stats",content:{"application/json":{schema:$(I.record(I.enum(["cc","codex","opencode"]),I.object({scanned:I.number(),imported:I.number(),resynced:I.number(),skipped:I.number(),errors:I.array(I.string())})))}}},...P(400)}}),D("json",I.object({sources:I.array(I.enum(["cc","codex","opencode"])).optional(),force:I.boolean().optional()})),async(m)=>{let{sources:c,force:l}=m.req.valid("json");return m.json(await Fn.runAll({sources:c,force:l}))})});var gn={};Nr(gn,{websocket:()=>q$,http:()=>L$,ServerProxy:()=>gn});var H$=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","te","trailer","transfer-encoding","upgrade","host","authorization"]);function Z$(r,i){let n=new Headers(r.headers);for(let m of H$)n.delete(m);if(n.delete("accept-encoding"),n.delete("x-qitqode-directory"),n.delete("x-qitqode-workspace"),!i)return n;for(let[m,c]of new Headers(i).entries())n.set(m,c);return n}function V$(r){let i=r.headers.get("sec-websocket-protocol");if(!i)return[];return i.split(",").map((n)=>n.trim()).filter(Boolean)}function Y$(r){let i=new URL(r);if(i.protocol==="http:")i.protocol="ws:";if(i.protocol==="https:")i.protocol="wss:";return i.toString()}function J$(r,i){if(i instanceof Blob)return i.arrayBuffer().then((n)=>r.send(n));return r.send(i)}var R$=(r)=>new V().get("/__workspace_ws",r((i)=>{let n=i.req.header("x-qitqode-proxy-url"),m=[],c;return{onOpen(l,y){if(!n){y.close(1011,"missing proxy target");return}c=new WebSocket(n,V$(i.req.raw)),c.binaryType="arraybuffer",c.onopen=()=>{for(let j of m)c?.send(j);m.length=0},c.onmessage=(j)=>{J$(y,j.data)},c.onerror=()=>{y.close(1011,"proxy error")},c.onclose=(j)=>{y.close(j.code,j.reason)}},onMessage(l){let y=l.data;if(typeof y!=="string"&&!(y instanceof Uint8Array)&&!(y instanceof ArrayBuffer))return;if(c?.readyState===WebSocket.OPEN){c.send(y);return}m.push(y)},onClose(l){c?.close(l.code,l.reason)}}})),O$=_.Default.clone().tag("service","server-proxy");async function L$(r,i,n,m){if(!p.isSyncing(m))return new Response(`broken sync connection for workspace: ${m}`,{status:503,headers:{"content-type":"text/plain; charset=utf-8"}});return fetch(new Request(r,{method:n.method,headers:Z$(n,i),body:n.method==="GET"||n.method==="HEAD"?void 0:n.body,redirect:"manual",signal:n.signal})).then((c)=>{let l=y1(c.headers),y=new Headers(c.headers);return y.delete("content-encoding"),y.delete("content-length"),(l?j1(m,l,n.signal):Promise.resolve()).then(async()=>{return new Response(c.body,{status:c.status,statusText:c.statusText,headers:y})})})}function q$(r,i,n,m,c){let l=new URL(m.url);l.pathname="/__workspace_ws",l.search="";let y=new Headers(m.headers);y.set("x-qitqode-proxy-url",Y$(i));for(let[j,A]of new Headers(n).entries())y.set(j,A);return O$.info("proxy websocket",{request:m.url,target:String(i)}),R$(r).fetch(new Request(l,{method:m.method,headers:y,signal:m.signal}),c)}var _$=[{path:"/session/status",action:"forward"},{method:"GET",path:"/session",action:"local"}];function F$(r,i){for(let n of _$){if(n.method&&n.method!==r)continue;if(n.exact?i===n.path:i===n.path||i.startsWith(n.path+"/"))return n.action==="local"}return!1}function g$(r){if(r.pathname==="/session/status")return null;let i=r.pathname.match(/^\/session\/([^/]+)(?:\/|$)/)?.[1];if(!i)return null;return br.make(i)}async function z$(r){let i=g$(r);if(!i)return null;return(await e.runPromise(J.Service.use((m)=>m.get(i)).pipe(C.withSpan("WorkspaceRouter.lookup"))).catch(()=>{return}))?.workspaceID}function lA(r){let i=_.create({service:"workspace-router"});return async(n,m)=>{let c=new URL(n.req.url),y=await z$(c)||c.searchParams.get("workspace");if(!y||c.pathname.startsWith("/console")||k.QITQODE_WORKSPACE_ID)return m();let j=await p.get(qr.make(y));if(!j)return new Response(`Workspace not found: ${y}`,{status:500,headers:{"content-type":"text/plain; charset=utf-8"}});if(F$(n.req.method,c.pathname))return m();let S=await(await _i(j.projectID,j.type)).target(j);if(S.type==="local")return Dn.provide({workspaceID:qr.make(y),fn:()=>M.provide({directory:S.directory,init:()=>e.runPromise(xi),async fn(){return m()}})});let v=new URL(S.url);if(v.pathname=`${v.pathname.replace(/\/$/,"")}${c.pathname}`,v.search=c.search,v.hash=c.hash,v.searchParams.delete("workspace"),v.searchParams.delete("auth_token"),i.info("workspace proxy forwarding",{workspaceID:y,request:c.toString(),target:String(S.url),proxy:v.toString()}),n.req.header("upgrade")?.toLowerCase()==="websocket")return gn.websocket(r,v,S.headers,n.req.raw,n.env);let w=new Headers(n.req.raw.headers);w.delete("x-qitqode-workspace");let N=new Request(n.req.raw,{headers:w});return gn.http(v,S.headers,N,j.id)}}function al(r){return async(i,n)=>{let m=i.req.query("directory")||i.req.header("x-qitqode-directory")||process.cwd(),c=yA.resolve((()=>{try{return decodeURIComponent(m)}catch{return m}})());if(!k.QITQODE_SERVER_PASSWORD){let l=Wi.resolve(process.cwd());if(!Wi.contains(l,c))return i.json({error:"Access denied: directory must be within the server's working directory"},403)}return Dn.provide({workspaceID:r,async fn(){return M.provide({directory:c,init:()=>e.runPromise(xi),async fn(){return n()}})}})}}var dl=_.create({service:"server.workspace"}),IA=F(()=>new V().get("/adaptor",G({summary:"List workspace adaptors",description:"List all available workspace adaptors for the current project.",operationId:"experimental.workspace.adaptor.list",responses:{200:{description:"Workspace adaptors",content:{"application/json":{schema:$(I.array(I.object({type:I.string(),name:I.string(),description:I.string()})))}}}}}),async(r)=>{return r.json(await jA(M.project.id))}).post("/",G({summary:"Create workspace",description:"Create a workspace for the current project.",operationId:"experimental.workspace.create",responses:{200:{description:"Workspace created",content:{"application/json":{schema:$(p.Info)}}},...P(400)}}),D("json",p.create.schema.omit({projectID:!0})),async(r)=>{let i=r.req.valid("json"),n=await p.create({projectID:M.project.id,...i});return r.json(n)}).get("/",G({summary:"List workspaces",description:"List all workspaces.",operationId:"experimental.workspace.list",responses:{200:{description:"Workspaces",content:{"application/json":{schema:$(I.array(p.Info))}}}}}),async(r)=>{return r.json(p.list(M.project))}).get("/status",G({summary:"Workspace status",description:"Get connection status for workspaces in the current project.",operationId:"experimental.workspace.status",responses:{200:{description:"Workspace status",content:{"application/json":{schema:$(I.array(p.ConnectionStatus))}}}}}),async(r)=>{let i=new Set(p.list(M.project).map((n)=>n.id));return r.json(p.status().filter((n)=>i.has(n.workspaceID)))}).delete("/:id",G({summary:"Remove workspace",description:"Remove an existing workspace.",operationId:"experimental.workspace.remove",responses:{200:{description:"Workspace removed",content:{"application/json":{schema:$(p.Info.optional())}}},...P(400)}}),D("param",I.object({id:p.Info.shape.id})),async(r)=>{let{id:i}=r.req.valid("param");return r.json(await p.remove(i))}).post("/:id/session-restore",G({summary:"Restore session into workspace",description:"Replay a session's sync events into the target workspace in batches.",operationId:"experimental.workspace.sessionRestore",responses:{200:{description:"Session replay started",content:{"application/json":{schema:$(I.object({total:I.number().int().min(0)}))}}},...P(400)}}),D("param",I.object({id:p.Info.shape.id})),D("json",p.sessionRestore.schema.omit({workspaceID:!0})),async(r)=>{let{id:i}=r.req.valid("param"),n=r.req.valid("json");dl.info("session restore route requested",{workspaceID:i,sessionID:n.sessionID,directory:M.directory});try{let m=await p.sessionRestore({workspaceID:i,...n});return dl.info("session restore route complete",{workspaceID:i,sessionID:n.sessionID,total:m.total}),r.json(m)}catch(m){throw dl.error("session restore route failed",{workspaceID:i,sessionID:n.sessionID,error:m0(m)}),m}}));globalThis.AI_SDK_LOG_WARNINGS=!1;dc();var M$=_.create({service:"server"}),T$=F(()=>tl({}));function h$(r){try{return new URL(r).hostname}catch{return}}function tl(r){let i=new V().onError(hj).use(kj({hostname:r.hostname,mdnsDomain:r.mdnsDomain,allowedHosts:r.cors?.map(h$).filter((m)=>!!m)})).use(xj(r)).use(oj).use(Bj).use(pj).route("/global",cA()),n=My.create(i);if(k.QITQODE_WORKSPACE_ID)return{app:i.use(al(k.QITQODE_WORKSPACE_ID?qr.make(k.QITQODE_WORKSPACE_ID):void 0)).use(I1).route("/",Bl(n.upgradeWebSocket)),runtime:n};return{app:i.route("/",h2()).route("/",new V().use(al()).route("/experimental/workspace",IA()).use(lA(n.upgradeWebSocket)).route("/",Bl(n.upgradeWebSocket))),runtime:n}}async function B$(){let{app:r}=tl({});return await wc(r,{documentation:{info:{title:"qitqode",version:"1.0.0",description:"qitqode api"},openapi:"3.1.1"}})}var AA;async function o$(r){let n=await tl(r).runtime.listen(r),m=new URL("http://localhost");m.hostname=r.hostname,m.port=String(n.port),AA=m;let c=r.mdns&&n.port&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost"&&r.hostname!=="::1";if(c)Nn.publish(n.port,r.mdnsDomain);else if(r.mdns)M$.warn("mDNS enabled but hostname is loopback; skipping mDNS publish");let l;return{hostname:r.hostname,port:n.port,url:m,stop(y){return l??=(async()=>{if(c)Nn.unpublish();await n.stop(y)})(),l}}}
|
|
14
|
+
export{T$ as Xf,B$ as Yf,AA as Zf,o$ as _f,bl as $f};
|