@qitqode/qitqode-android-arm64 0.2.9 → 0.2.10
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-062chtrq.js +2 -0
- package/bundle/chunk-062vs7bp.js +2 -0
- package/bundle/chunk-08g14hmz.js +2 -0
- package/bundle/{chunk-wgkcyqn1.js → chunk-0bhzhh7s.js} +2 -2
- package/bundle/{chunk-cfwz1hgr.js → chunk-0mwzxqt5.js} +3 -3
- package/bundle/{chunk-mr17tppa.js → chunk-0sfc21qe.js} +2 -2
- package/bundle/{chunk-7adsab4h.js → chunk-0tkznq75.js} +1 -1
- package/bundle/chunk-0w2v8dfy.js +2 -0
- package/bundle/chunk-10fr7a2y.js +2 -0
- package/bundle/chunk-141p12c4.js +4 -0
- package/bundle/chunk-15bjhfav.js +3 -0
- package/bundle/{chunk-92r1gw2j.js → chunk-1h96bk6p.js} +2 -2
- package/bundle/chunk-1hv61m11.js +2 -0
- package/bundle/{chunk-0z1keh2w.js → chunk-1m78yy4k.js} +1 -1
- package/bundle/chunk-1q10jyka.js +29 -0
- package/bundle/{chunk-g4tyaj0m.js → chunk-1r81q7m3.js} +1 -1
- package/bundle/{chunk-29q89bge.js → chunk-2cvwrabw.js} +2 -2
- package/bundle/{chunk-8p0t8qah.js → chunk-2dmcpqak.js} +1 -1
- package/bundle/{chunk-35fj1sfm.js → chunk-2fbkw84y.js} +2 -2
- package/bundle/chunk-2mkvx8b2.js +2 -0
- package/bundle/chunk-2rykfc3a.js +2 -0
- package/bundle/chunk-2w5hx4fs.js +2 -0
- package/bundle/{chunk-t3w43rft.js → chunk-2y5bthrp.js} +1 -1
- package/bundle/chunk-2yy63sxz.js +2 -0
- package/bundle/chunk-2z3fe4qw.js +2 -0
- package/bundle/{chunk-g7v6sp3c.js → chunk-2zjet9tx.js} +2 -2
- package/bundle/{chunk-qgkb6n8k.js → chunk-32xd626h.js} +2 -2
- package/bundle/chunk-361cmmrp.js +2 -0
- package/bundle/{chunk-eg1m81ax.js → chunk-3mtjxmw1.js} +1 -1
- package/bundle/chunk-3r6dq1h3.js +2 -0
- package/bundle/{chunk-wtt5wms9.js → chunk-3sj0jv91.js} +1 -1
- package/bundle/{chunk-hz02vrqs.js → chunk-3vae1s42.js} +1 -1
- package/bundle/{chunk-t18ka1e7.js → chunk-3yfjgks3.js} +1 -1
- package/bundle/{chunk-phf37x1c.js → chunk-3zzrdpsx.js} +1 -1
- package/bundle/chunk-4a12wv2m.js +2 -0
- package/bundle/{chunk-1rgt2vmt.js → chunk-4a9jqe5s.js} +1 -1
- package/bundle/{chunk-wqk1v8t0.js → chunk-4sa9t0vx.js} +2 -2
- package/bundle/{chunk-qbnt4ynd.js → chunk-532fnfmw.js} +2 -2
- package/bundle/chunk-547a55ba.js +2 -0
- package/bundle/{chunk-vr8nwzp0.js → chunk-56yp5v0w.js} +1 -1
- package/bundle/{chunk-ag8wxwwz.js → chunk-5fcyb122.js} +1 -1
- package/bundle/{chunk-4pmvxnkj.js → chunk-5nm5egq0.js} +2 -2
- package/bundle/{chunk-1v0khv7p.js → chunk-5p2r8bxx.js} +1 -1
- package/bundle/{chunk-5bv63rqj.js → chunk-5rqjze1g.js} +1 -1
- package/bundle/{chunk-sy9w1t2y.js → chunk-5w7ebtcd.js} +1 -1
- package/bundle/chunk-5ztmc770.js +2 -0
- package/bundle/{chunk-a1z8rnq7.js → chunk-61t4g8bh.js} +4 -4
- package/bundle/chunk-62x3r2q8.js +2 -0
- package/bundle/chunk-62y6zk9x.js +2 -0
- package/bundle/{chunk-c76cjhn0.js → chunk-6axm2qtj.js} +1 -1
- package/bundle/{chunk-zfrftgcy.js → chunk-6gbdvz6p.js} +1 -1
- package/bundle/{chunk-fa8pwdwv.js → chunk-6mnk5sg3.js} +1 -1
- package/bundle/chunk-6th7vpwm.js +2 -0
- package/bundle/{chunk-8yzghzjq.js → chunk-6wjdhvdf.js} +1 -1
- package/bundle/{chunk-a8bjcvda.js → chunk-6y58jzak.js} +1 -1
- package/bundle/chunk-6ybh5smv.js +2 -0
- package/bundle/chunk-73kprndw.js +2 -0
- package/bundle/chunk-79fr19xf.js +2 -0
- package/bundle/{chunk-3va85mbe.js → chunk-7a3txs9f.js} +2 -2
- package/bundle/chunk-7ezr478e.js +2 -0
- package/bundle/chunk-7gj1vqyj.js +2 -0
- package/bundle/{chunk-eacpc64g.js → chunk-7hdb1fhq.js} +2 -2
- package/bundle/{chunk-t8fjgkp8.js → chunk-7rbg6mg9.js} +2 -2
- package/bundle/{chunk-59csnjc3.js → chunk-7s0nq2aa.js} +2 -2
- package/bundle/chunk-7ywfkwb4.js +2 -0
- package/bundle/chunk-819qr675.js +2 -0
- package/bundle/{chunk-g6y2c5az.js → chunk-81dvy370.js} +1 -1
- package/bundle/chunk-85fnnwm2.js +2 -0
- package/bundle/chunk-89fwh84w.js +2 -0
- package/bundle/chunk-8e724g3k.js +2 -0
- package/bundle/{chunk-k6981ysw.js → chunk-8gpjmj42.js} +3 -3
- package/bundle/{chunk-wtxh5m6j.js → chunk-8nnajdwf.js} +3 -3
- package/bundle/chunk-8peby2d1.js +2 -0
- package/bundle/{chunk-702bt91p.js → chunk-8rkszwxq.js} +6 -6
- package/bundle/{chunk-w0nc0gcx.js → chunk-8v60bqm0.js} +1 -1
- package/bundle/chunk-9894a2yn.js +2 -0
- package/bundle/chunk-98ye2nwt.js +2 -0
- package/bundle/{chunk-48gap82w.js → chunk-9bbwxp5d.js} +1 -1
- package/bundle/{chunk-z0kbyr00.js → chunk-9d0exvey.js} +2 -2
- package/bundle/{chunk-8ysp6vf8.js → chunk-9fjcgdea.js} +1 -1
- package/bundle/{chunk-jpn9zfj5.js → chunk-9nf5650d.js} +1 -1
- package/bundle/{chunk-n6tqtk6h.js → chunk-9pj10pgd.js} +2 -2
- package/bundle/chunk-9s4excg8.js +2 -0
- package/bundle/{chunk-t6zz47zk.js → chunk-9s5h0f1y.js} +2 -2
- package/bundle/{chunk-p8ak162p.js → chunk-9tz18e54.js} +1 -1
- package/bundle/{chunk-fs1vb39f.js → chunk-9zy5tsry.js} +3 -3
- package/bundle/{chunk-bc2krtaf.js → chunk-a70m6kyn.js} +1 -1
- package/bundle/{chunk-cr5tknvb.js → chunk-acsqvgdw.js} +1 -1
- package/bundle/chunk-aetgcegz.js +2 -0
- package/bundle/chunk-agas0nay.js +2 -0
- package/bundle/{chunk-vs3s49jw.js → chunk-ajnzv5jt.js} +2 -2
- package/bundle/{chunk-9cf2ktyh.js → chunk-asxmkyz2.js} +1 -1
- package/bundle/{chunk-0ffmwhw7.js → chunk-at4dge22.js} +1 -1
- package/bundle/{chunk-sa0rrreh.js → chunk-atacnspd.js} +2 -2
- package/bundle/chunk-ayknzc4m.js +2 -0
- package/bundle/chunk-azss4acq.js +3 -0
- package/bundle/chunk-b2ybst88.js +2 -0
- package/bundle/{chunk-cghz0855.js → chunk-b8rzn48q.js} +1 -1
- package/bundle/{chunk-dhvx9p54.js → chunk-b9f78x5g.js} +1 -1
- package/bundle/chunk-bd5vtjd7.js +2 -0
- package/bundle/chunk-bjqqk6jt.js +2 -0
- package/bundle/{chunk-mv7q6ach.js → chunk-brk1jca3.js} +1 -1
- package/bundle/{chunk-5r7c6vvx.js → chunk-by1kwg4r.js} +2 -2
- package/bundle/{chunk-1acn5me8.js → chunk-c1c8ch3g.js} +327 -313
- package/bundle/{chunk-2nheahmq.js → chunk-c2ns2csn.js} +1 -1
- package/bundle/{chunk-qk5vy2pr.js → chunk-c3ey896z.js} +1 -1
- package/bundle/{chunk-b7sr9rn3.js → chunk-c8080519.js} +1 -1
- package/bundle/{chunk-vd8cmdpv.js → chunk-c8yc8qcd.js} +1 -1
- package/bundle/{chunk-nas631g2.js → chunk-c9cngded.js} +1 -1
- package/bundle/{chunk-ejhhrece.js → chunk-ccdjzn2m.js} +3 -3
- package/bundle/{chunk-rk0fnvp5.js → chunk-cdenq7jb.js} +1 -1
- package/bundle/chunk-cpkcdykz.js +2 -0
- package/bundle/{chunk-56wq8cqj.js → chunk-cs825mxr.js} +1 -1
- package/bundle/{chunk-1bxfzd6r.js → chunk-cxtwavyf.js} +4 -4
- package/bundle/chunk-cyafm8d6.js +2 -0
- package/bundle/{chunk-eewe7tx1.js → chunk-d0dsgxk4.js} +2 -2
- package/bundle/{chunk-g3n465ee.js → chunk-d1fv2c7s.js} +2 -2
- package/bundle/{chunk-1p9s5jj1.js → chunk-d1xfv4d3.js} +1 -1
- package/bundle/chunk-d4316r53.js +2 -0
- package/bundle/chunk-d8ym7mcg.js +2 -0
- package/bundle/{chunk-53jstmdp.js → chunk-d9w2bn2e.js} +1 -1
- package/bundle/{chunk-g26redah.js → chunk-dd461rg3.js} +1 -1
- package/bundle/{chunk-e0vrxetq.js → chunk-djfrkbd5.js} +1 -1
- package/bundle/{chunk-mrq35ftw.js → chunk-dm447tgc.js} +2 -2
- package/bundle/{chunk-7pckez5z.js → chunk-dnjyepb2.js} +2 -2
- package/bundle/chunk-dnpjxjkp.js +2 -0
- package/bundle/{chunk-0a4pmkc9.js → chunk-dp6ms01y.js} +2 -2
- package/bundle/{chunk-rdreeyv0.js → chunk-dx7rexx3.js} +3 -3
- package/bundle/{chunk-kre93a89.js → chunk-dz3kcsb6.js} +2 -2
- package/bundle/{chunk-dcv6wj9x.js → chunk-dzma8zvf.js} +2 -2
- package/bundle/{chunk-e2wfj86b.js → chunk-e10c0crf.js} +1 -1
- package/bundle/{chunk-wn63q3xp.js → chunk-e1x1mp9m.js} +1 -1
- package/bundle/{chunk-tk4z6r09.js → chunk-e3mrw0k7.js} +1 -1
- package/bundle/chunk-e5gjqtby.js +2 -0
- package/bundle/{chunk-3z2zn8rj.js → chunk-e72jwbfc.js} +1 -1
- package/bundle/{chunk-85wh85pk.js → chunk-eabbrt1p.js} +1 -1
- package/bundle/{chunk-jr80q31w.js → chunk-ecz4h0a2.js} +1 -1
- package/bundle/chunk-ee3mqzms.js +2 -0
- package/bundle/chunk-eme9xmh3.js +2 -0
- package/bundle/{chunk-cf9m9m9q.js → chunk-eqpep2m2.js} +1 -1
- package/bundle/chunk-er5f61s5.js +2 -0
- package/bundle/chunk-er716522.js +2 -0
- package/bundle/{chunk-qgek59e6.js → chunk-ev6jwt7q.js} +1 -1
- package/bundle/chunk-ez3gacqe.js +2 -0
- package/bundle/{chunk-ax64ngf2.js → chunk-f0ab2f28.js} +1 -1
- package/bundle/{chunk-ggncq8w8.js → chunk-f17se3hh.js} +1 -1
- package/bundle/chunk-f3y5kr76.js +14 -0
- package/bundle/{chunk-vsqvnxbz.js → chunk-f6btedtt.js} +1 -1
- package/bundle/{chunk-nsp1za8t.js → chunk-f6vy70p6.js} +2 -2
- package/bundle/{chunk-0s4cp6q2.js → chunk-ff8q10gk.js} +2 -2
- package/bundle/chunk-fkc7wf1p.js +2 -0
- package/bundle/chunk-fm6z8nqb.js +2 -0
- package/bundle/{chunk-fw1f47de.js → chunk-fsndgr9a.js} +1 -1
- package/bundle/{chunk-pqg1wjb5.js → chunk-fvv1cret.js} +1 -1
- package/bundle/{chunk-j10a984e.js → chunk-g08qj9z3.js} +2 -2
- package/bundle/chunk-g0qwm23d.js +2 -0
- package/bundle/chunk-g4yn8cj8.js +2 -0
- package/bundle/{chunk-rwwvy89t.js → chunk-g52wmt1v.js} +1 -1
- package/bundle/{chunk-trstb8ee.js → chunk-gb51fn3r.js} +1 -1
- package/bundle/{chunk-kgv68cpb.js → chunk-gbnf7zf9.js} +1 -1
- package/bundle/{chunk-0w19vmd7.js → chunk-ge7csm6m.js} +2 -2
- package/bundle/{chunk-bkfafcbw.js → chunk-gksbv613.js} +2 -2
- package/bundle/{chunk-afr8m0q1.js → chunk-gmq1kwn0.js} +1 -1
- package/bundle/{chunk-b5ym419d.js → chunk-gq3zb4wv.js} +2 -2
- package/bundle/{chunk-tbx741en.js → chunk-gqgjybjc.js} +1 -1
- package/bundle/{chunk-bhg69t69.js → chunk-gx4v8z64.js} +2 -2
- package/bundle/{chunk-sm1g81cv.js → chunk-h0pvxre5.js} +1 -1
- package/bundle/chunk-h1spsy3y.js +2 -0
- package/bundle/{chunk-sbjymf20.js → chunk-h2p984qb.js} +2 -2
- package/bundle/{chunk-gznt3dv8.js → chunk-h6z86aay.js} +1 -1
- package/bundle/chunk-h8gkv40j.js +2 -0
- package/bundle/{chunk-zsg29gba.js → chunk-h91zmzs5.js} +1 -1
- package/bundle/{chunk-zrhw1szj.js → chunk-hgm8yfcb.js} +1 -1
- package/bundle/chunk-j59kmb49.js +2 -0
- package/bundle/chunk-j5z95b6f.js +3 -0
- package/bundle/{chunk-52xvhxek.js → chunk-j7637cwg.js} +2 -2
- package/bundle/{chunk-rwnwjm82.js → chunk-jbcqhw3x.js} +2 -2
- package/bundle/{chunk-maa21rh9.js → chunk-je8fcsa9.js} +1 -1
- package/bundle/{chunk-y0h3jfkj.js → chunk-jt6bvxtr.js} +1 -1
- package/bundle/chunk-jv37ghev.js +2 -0
- package/bundle/chunk-k10rtgsk.js +5 -0
- package/bundle/chunk-k3hcb6qf.js +2 -0
- package/bundle/chunk-k5d822n2.js +3 -0
- package/bundle/{chunk-2vaphpz0.js → chunk-kc8n5cgb.js} +1 -1
- package/bundle/chunk-kcqeh1e5.js +2 -0
- package/bundle/{chunk-5xkp27b1.js → chunk-kds2g7r2.js} +1 -1
- package/bundle/{chunk-scnbt714.js → chunk-kec1xw1n.js} +1 -1
- package/bundle/{chunk-13jq2ygc.js → chunk-kk850sdw.js} +2 -2
- package/bundle/{chunk-3bb4aqh9.js → chunk-m01h6kk1.js} +1 -1
- package/bundle/{chunk-e0hha3be.js → chunk-m4j6t713.js} +1 -1
- package/bundle/chunk-m8ytbq04.js +2 -0
- package/bundle/chunk-mf9nc4xz.js +2 -0
- package/bundle/{chunk-7thhd7ds.js → chunk-mmqyter3.js} +1 -1
- package/bundle/{chunk-y31f8k5f.js → chunk-mn0pshpv.js} +1 -1
- package/bundle/{chunk-s2tc3qs0.js → chunk-mn5cacf6.js} +2 -2
- package/bundle/{chunk-0egrckx0.js → chunk-mp1x10t5.js} +2 -2
- package/bundle/chunk-mxby91bj.js +2 -0
- package/bundle/chunk-mzv1gh6f.js +2 -0
- package/bundle/chunk-n0hsvvw8.js +2 -0
- package/bundle/{chunk-az3nss5m.js → chunk-ngyv4fhn.js} +2 -2
- package/bundle/{chunk-g9nwqwqp.js → chunk-nh4zk07t.js} +1 -1
- package/bundle/{chunk-8jmb5bd4.js → chunk-nk5vrenn.js} +2 -2
- package/bundle/chunk-nm1v9z14.js +2 -0
- package/bundle/chunk-nnkfdhh9.js +2 -0
- package/bundle/{chunk-jqj1ay7x.js → chunk-npdgfqaw.js} +1 -1
- package/bundle/{chunk-p2fte9vz.js → chunk-nq4x6792.js} +2 -2
- package/bundle/{chunk-wr6rnxr5.js → chunk-nqk8d62j.js} +1 -1
- package/bundle/{chunk-7jy53zqy.js → chunk-p506eydh.js} +1 -1
- package/bundle/{chunk-phpxxd48.js → chunk-p6jf1fyt.js} +1 -1
- package/bundle/chunk-p7nstcxa.js +2 -0
- package/bundle/{chunk-6ps30qax.js → chunk-pbanj1gk.js} +2 -2
- package/bundle/{chunk-vph4w4yy.js → chunk-pchv413c.js} +2 -2
- package/bundle/{chunk-qsme16gk.js → chunk-pf2vq6t1.js} +2 -2
- package/bundle/chunk-pfwkvv7g.js +2 -0
- package/bundle/{chunk-ntr0ezf2.js → chunk-pky8h8rh.js} +1 -1
- package/bundle/chunk-pn1jz8qj.js +2 -0
- package/bundle/chunk-pqvmtfk7.js +2 -0
- package/bundle/chunk-prgw26g3.js +2 -0
- package/bundle/{chunk-kckr30tf.js → chunk-psqtptrs.js} +1 -1
- package/bundle/chunk-pv9ty6v7.js +2 -0
- package/bundle/{chunk-060wbpz4.js → chunk-pwsajn96.js} +1 -1
- package/bundle/{chunk-vgt3artc.js → chunk-pxm0x3e0.js} +1 -1
- package/bundle/chunk-pyf649pz.js +2 -0
- package/bundle/{chunk-wd8f9r4k.js → chunk-q0xgxygw.js} +1 -1
- package/bundle/{chunk-rye1yjnr.js → chunk-q26s0wb5.js} +1 -1
- package/bundle/{chunk-a48mx917.js → chunk-q4mtwv1w.js} +2 -2
- package/bundle/chunk-q4rstre7.js +2 -0
- package/bundle/chunk-q6jk2v6g.js +2 -0
- package/bundle/{chunk-5wx962mw.js → chunk-q7s6z0nz.js} +1 -1
- package/bundle/{chunk-jmmtcr2r.js → chunk-q8fjktv4.js} +1 -1
- package/bundle/{chunk-m7tmgvh6.js → chunk-qbewhcsz.js} +1 -1
- package/bundle/chunk-qd43npx3.js +2 -0
- package/bundle/{chunk-ydgst3h8.js → chunk-qdafm7qg.js} +2 -2
- package/bundle/chunk-qdb21y83.js +2 -0
- package/bundle/{chunk-72crs18f.js → chunk-qdbx1qkr.js} +1 -1
- package/bundle/{chunk-6vnqbejg.js → chunk-qdh2dm62.js} +1 -1
- package/bundle/chunk-qeksaefy.js +2 -0
- package/bundle/{chunk-qk1jkc0n.js → chunk-qjw2zcq5.js} +1 -1
- package/bundle/{chunk-dt3bsmfe.js → chunk-qm9fm5ja.js} +2 -2
- package/bundle/{chunk-h8mfbbjh.js → chunk-qq9yc2tp.js} +2 -2
- package/bundle/{chunk-0tcggtwv.js → chunk-qtyapmy7.js} +1 -1
- package/bundle/{chunk-c987bemn.js → chunk-qyan69nb.js} +1 -1
- package/bundle/chunk-r7t9yb9d.js +2 -0
- package/bundle/{chunk-6tqbnxar.js → chunk-r81w6skn.js} +1 -1
- package/bundle/{chunk-f4mnp6xd.js → chunk-rk21wv4k.js} +1 -1
- package/bundle/{chunk-ccf4pgkr.js → chunk-rpdgn9z3.js} +2 -2
- package/bundle/chunk-rxnd79h7.js +7 -0
- package/bundle/chunk-s05hqtx1.js +3 -0
- package/bundle/chunk-s27cz24e.js +808 -0
- package/bundle/chunk-sdv3a4w3.js +2 -0
- package/bundle/{chunk-zwhmg9dj.js → chunk-se8d5xg9.js} +1 -1
- package/bundle/chunk-sk89becn.js +2 -0
- package/bundle/{chunk-sz0favtz.js → chunk-snf6ahg7.js} +1 -1
- package/bundle/{chunk-dgcannw0.js → chunk-t2r51r6v.js} +1 -1
- package/bundle/{chunk-rva2ekrt.js → chunk-t5wdstzv.js} +1 -1
- package/bundle/{chunk-vkkz40je.js → chunk-t9pq363q.js} +2 -2
- package/bundle/chunk-tc0996xz.js +2 -0
- package/bundle/chunk-td9hm9be.js +2 -0
- package/bundle/{chunk-xy8arehp.js → chunk-tdevq564.js} +1 -1
- package/bundle/chunk-te91d271.js +2 -0
- package/bundle/chunk-tfs50mgj.js +2 -0
- package/bundle/{chunk-5cw8235e.js → chunk-tg1f56s3.js} +1 -1
- package/bundle/chunk-thecq33z.js +3 -0
- package/bundle/{chunk-f2v4g7t1.js → chunk-tjfer79w.js} +1 -1
- package/bundle/chunk-tjvtp9d9.js +2 -0
- package/bundle/chunk-tkm9m3n0.js +2 -0
- package/bundle/{chunk-ynf17943.js → chunk-tm79yrf3.js} +2 -2
- package/bundle/{chunk-fv5mrdyc.js → chunk-v03xq38e.js} +2 -2
- package/bundle/chunk-v0hnn7nb.js +2 -0
- package/bundle/{chunk-ftvvm4r5.js → chunk-v16n1fep.js} +2 -2
- package/bundle/chunk-v1s1rcqx.js +2 -0
- package/bundle/chunk-v4dt4062.js +2 -0
- package/bundle/{chunk-makegrxs.js → chunk-v8bxj01h.js} +1 -1
- package/bundle/{chunk-ryrxgn6d.js → chunk-v8rqgt7h.js} +1 -1
- package/bundle/{chunk-m4r8sepw.js → chunk-vbb1jg02.js} +1 -1
- package/bundle/{chunk-2kh0tg92.js → chunk-vbfc0wgv.js} +2 -2
- package/bundle/{chunk-d839fr0w.js → chunk-vjt6mh10.js} +2 -2
- package/bundle/{chunk-gsg6zn7e.js → chunk-vk35g121.js} +2 -2
- package/bundle/{chunk-dwkrqtbc.js → chunk-vsfj16v9.js} +2 -2
- package/bundle/{chunk-zqdjk4rf.js → chunk-vy93mn7d.js} +2 -2
- package/bundle/{chunk-1har4t9a.js → chunk-waa781eh.js} +1 -1
- package/bundle/{chunk-wb47k8ah.js → chunk-wbt31xap.js} +2 -2
- package/bundle/{chunk-0tm6589k.js → chunk-wd2xmkdp.js} +2 -2
- package/bundle/{chunk-fej5x648.js → chunk-wecs14rz.js} +1 -1
- package/bundle/chunk-wgrq86kd.js +2 -0
- package/bundle/{chunk-4y9wbfd2.js → chunk-wh2qqhep.js} +2 -2
- package/bundle/{chunk-g878zd6e.js → chunk-x0hhw46n.js} +1 -1
- package/bundle/{chunk-w7a33cwa.js → chunk-x308f9j4.js} +2 -2
- package/bundle/{chunk-y3gy62q5.js → chunk-x50adh71.js} +1 -1
- package/bundle/chunk-x8ks2bn7.js +2 -0
- package/bundle/{chunk-s5aefff0.js → chunk-xcmbxny8.js} +1 -1
- package/bundle/{chunk-rmsqb6r4.js → chunk-xgf4k9q7.js} +1 -1
- package/bundle/{chunk-2caaqmec.js → chunk-xj0zc9za.js} +1 -1
- package/bundle/{chunk-27saej0r.js → chunk-xnxw5zz9.js} +2 -2
- package/bundle/{chunk-fjftb2sz.js → chunk-xqwk2zsx.js} +2 -2
- package/bundle/{chunk-d30k7dpf.js → chunk-xstxdw7v.js} +1 -1
- package/bundle/{chunk-dwqvcdmf.js → chunk-xv03hbgj.js} +1 -1
- package/bundle/{chunk-bwadggys.js → chunk-xvvt886p.js} +2 -2
- package/bundle/{chunk-bnw744ej.js → chunk-xy2ty5h5.js} +2 -2
- package/bundle/{chunk-wm9nh9nb.js → chunk-yce8ph5b.js} +2 -2
- package/bundle/{chunk-fh3d0wce.js → chunk-yexzxx6f.js} +1 -1
- package/bundle/{chunk-eyr5ymt8.js → chunk-yh1t6jrj.js} +1 -1
- package/bundle/chunk-yspstxkq.js +2 -0
- package/bundle/{chunk-ykpj10nz.js → chunk-yydqavgh.js} +2 -2
- package/bundle/{chunk-k3m7jfdh.js → chunk-yzd6cyep.js} +1 -1
- package/bundle/chunk-z023h7t8.js +2 -0
- package/bundle/chunk-z0383stv.js +2 -0
- package/bundle/{chunk-vbfej8ds.js → chunk-z0m1qm7j.js} +2 -2
- package/bundle/{chunk-bpfq8fz4.js → chunk-z69tt390.js} +1 -1
- package/bundle/chunk-zewrmk8x.js +2 -0
- package/bundle/{chunk-29gwtcey.js → chunk-zfqgh9h7.js} +1 -1
- package/bundle/{chunk-h1bvqstw.js → chunk-zskdxbbh.js} +1 -1
- package/bundle/{chunk-kveztc6k.js → chunk-ztvkzex1.js} +1 -1
- package/bundle/index.js +3 -3
- package/bundle/parser.worker.js +2 -2
- package/bundle/worker.js +1 -1
- package/package.json +1 -1
- package/bundle/chunk-03zpnwk2.js +0 -2
- package/bundle/chunk-0aqdzyar.js +0 -2
- package/bundle/chunk-0eh3yc6e.js +0 -2
- package/bundle/chunk-0mh600tv.js +0 -2
- package/bundle/chunk-1a6q1f5n.js +0 -7
- package/bundle/chunk-2a5gjgvp.js +0 -2
- package/bundle/chunk-2phyc1c0.js +0 -2
- package/bundle/chunk-2pkfphgb.js +0 -2
- package/bundle/chunk-30wp95w1.js +0 -2
- package/bundle/chunk-32fpqd0n.js +0 -2
- package/bundle/chunk-3f2cjzb4.js +0 -2
- package/bundle/chunk-3qvap1kv.js +0 -2
- package/bundle/chunk-42hvspe7.js +0 -2
- package/bundle/chunk-452tk6v3.js +0 -2
- package/bundle/chunk-4gqb1hps.js +0 -2
- package/bundle/chunk-50qgz5ka.js +0 -2
- package/bundle/chunk-539cw9r0.js +0 -2
- package/bundle/chunk-5b0xyq5z.js +0 -2
- package/bundle/chunk-5j4nxpdy.js +0 -2
- package/bundle/chunk-5nxgk6hw.js +0 -2
- package/bundle/chunk-5qkvhr6y.js +0 -2
- package/bundle/chunk-6dpdkzrk.js +0 -2
- package/bundle/chunk-6p6m5956.js +0 -3
- package/bundle/chunk-705qkpra.js +0 -28
- package/bundle/chunk-76c400ze.js +0 -2
- package/bundle/chunk-7bxxc4a3.js +0 -2
- package/bundle/chunk-7g59hc61.js +0 -2
- package/bundle/chunk-7p88j56s.js +0 -2
- package/bundle/chunk-7r92d7v9.js +0 -14
- package/bundle/chunk-7trngc9g.js +0 -2
- package/bundle/chunk-8cebbmtf.js +0 -2
- package/bundle/chunk-8j1xcdmd.js +0 -2
- package/bundle/chunk-90r2z49k.js +0 -2
- package/bundle/chunk-94mjwy22.js +0 -2
- package/bundle/chunk-9bw6bx5c.js +0 -2
- package/bundle/chunk-aenrd7dk.js +0 -2
- package/bundle/chunk-ahmy80vb.js +0 -2
- package/bundle/chunk-avn12jkt.js +0 -2
- package/bundle/chunk-brk6bge4.js +0 -3
- package/bundle/chunk-ce5e7j62.js +0 -2
- package/bundle/chunk-cw1gwjx9.js +0 -2
- package/bundle/chunk-czw30fjs.js +0 -2
- package/bundle/chunk-dtcvqrmn.js +0 -2
- package/bundle/chunk-dwhsvpag.js +0 -2
- package/bundle/chunk-e0hfpdje.js +0 -2
- package/bundle/chunk-e5jk67xh.js +0 -2
- package/bundle/chunk-eg4pq4hv.js +0 -2
- package/bundle/chunk-ew3yz97p.js +0 -2
- package/bundle/chunk-f2yfyhh8.js +0 -2
- package/bundle/chunk-fd8x2nb4.js +0 -2
- package/bundle/chunk-fveaq0pb.js +0 -2
- package/bundle/chunk-gbvm6dpv.js +0 -2
- package/bundle/chunk-gkbx6edf.js +0 -2
- package/bundle/chunk-gq9hb2e8.js +0 -2
- package/bundle/chunk-gswhjd1h.js +0 -3
- package/bundle/chunk-h5w91zr4.js +0 -2
- package/bundle/chunk-hmpb3c21.js +0 -2
- package/bundle/chunk-hq7s4f75.js +0 -2
- package/bundle/chunk-j1h64m65.js +0 -2
- package/bundle/chunk-j32rr7rt.js +0 -2
- package/bundle/chunk-j871xzr7.js +0 -2
- package/bundle/chunk-k1qd8ecm.js +0 -808
- package/bundle/chunk-kx88qekb.js +0 -2
- package/bundle/chunk-m4g4djss.js +0 -2
- package/bundle/chunk-mt2by7rx.js +0 -3
- package/bundle/chunk-mwkms65j.js +0 -3
- package/bundle/chunk-n61e0znt.js +0 -2
- package/bundle/chunk-ndd4cn3z.js +0 -2
- package/bundle/chunk-nr2j8ytn.js +0 -3
- package/bundle/chunk-nsw5x43k.js +0 -2
- package/bundle/chunk-p5b5ekhh.js +0 -2
- package/bundle/chunk-pf23nw4z.js +0 -2
- package/bundle/chunk-pw3cv89g.js +0 -2
- package/bundle/chunk-qwmae3vk.js +0 -5
- package/bundle/chunk-rdk62809.js +0 -2
- package/bundle/chunk-rew6r516.js +0 -2
- package/bundle/chunk-rjcz4kbm.js +0 -2
- package/bundle/chunk-skgr9ypq.js +0 -2
- package/bundle/chunk-sv40pwe2.js +0 -2
- package/bundle/chunk-tax3ecy5.js +0 -2
- package/bundle/chunk-tfhpjmny.js +0 -2
- package/bundle/chunk-tnete6ye.js +0 -2
- package/bundle/chunk-tpyq7ycb.js +0 -2
- package/bundle/chunk-tr0rm1ka.js +0 -2
- package/bundle/chunk-ty14zznd.js +0 -2
- package/bundle/chunk-v5h5wxw5.js +0 -2
- package/bundle/chunk-v6141yq1.js +0 -2
- package/bundle/chunk-vjs69r6x.js +0 -2
- package/bundle/chunk-vmhar83s.js +0 -2
- package/bundle/chunk-vpjyk76v.js +0 -2
- package/bundle/chunk-vqvnw12p.js +0 -2
- package/bundle/chunk-w0sztk4y.js +0 -2
- package/bundle/chunk-w6bb320d.js +0 -2
- package/bundle/chunk-wqw6yjrg.js +0 -2
- package/bundle/chunk-ws08rxge.js +0 -2
- package/bundle/chunk-wwvek9zf.js +0 -3
- package/bundle/chunk-wz3dvc3g.js +0 -2
- package/bundle/chunk-x2pmqvdc.js +0 -2
- package/bundle/chunk-x4wfq39v.js +0 -2
- package/bundle/chunk-x7a3kqe5.js +0 -2
- package/bundle/chunk-xb22grz6.js +0 -2
- package/bundle/chunk-y3eeva80.js +0 -2
- package/bundle/chunk-yb6m08zj.js +0 -2
- package/bundle/chunk-ybcqkgs7.js +0 -2
- package/bundle/chunk-zj1jc1xt.js +0 -2
- package/bundle/chunk-zm0m0504.js +0 -2
- package/bundle/chunk-zq32jhj1.js +0 -2
- package/bundle/chunk-zxwjxszn.js +0 -2
package/bundle/chunk-7r92d7v9.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{mg as In,ng as d2,og as t2,pg as x2,qg as k2,rg as b2,sg as e2,tg as s2,ug as f2,vg as rA,wg as p2,zg as mA}from"./chunk-0s4cp6q2.js";import{Ag as Er,Bg as O2}from"./chunk-mrq35ftw.js";import{Fg as C2}from"./chunk-nsp1za8t.js";import{Kg as Sc}from"./chunk-brk6bge4.js";import{Mg as Ey}from"./chunk-qgkb6n8k.js";import{Ng as r1}from"./chunk-dcv6wj9x.js";import{Ah as Wr,Ch as e,Og as Ml,Pg as gl,Qg as ui,Rg as qn,Yg as Xr,Zg as hl,_g as Xm,ah as Km,bh as xi,ch as ai,dh as rm,fh as nm,hh as _r,ih as bc,lh as j2,mh as ql,oh as tc,ph as _l,qh as Tl,rh as yn,sh as Ll,th as zl,uh as b0,vh as Hm,xh as v2,yh as Dr,zh as jn}from"./chunk-1acn5me8.js";import{$j as s,Aj as V2,Cj as f0,Dj as Ln,Ej as H2,Ij as fj,Ik as qr,Jj as tr,Jk as _i,Kj as Zr,Kk as IA,Lj as D1,Mj as yr,Nj as br,Oj as Si,Pj as pi,Pk as l2,Sj as Ym,Uk as nr,Vk as Cr,Wk as Ar,Yk as $1,Zk as j0,_j as S2,ak as er,dl as R,el as cr,xj as wr,xk as Un,yj as fn,yk as Qr,zj as R2}from"./chunk-k1qd8ecm.js";import{gl as ul,ql as aI}from"./chunk-bhg69t69.js";import{Dl as nA,El as b,Gl as Ci,Il as l0,Ml as Gr,Ol as T,rl as Lr,vl as bj,wl as mr,xl as Xi,yl as Ki}from"./chunk-fv5mrdyc.js";import{_l as yi}from"./chunk-rdreeyv0.js";import{Bm as d,Dm as im,Em as g2,Fm as T2,Jm as M2,Km as sn,Zm as c0,wm as Li,ym as tj}from"./chunk-rmsqb6r4.js";import{Qn as F}from"./chunk-6tqbnxar.js";import{Co as P2,ho as U2}from"./chunk-4y9wbfd2.js";import{wq as bI,xq as eI,yq as Qn}from"./chunk-b5ym419d.js";import{Hq as fI,Iq as r2}from"./chunk-29q89bge.js";import{Oq as CI,Rq as Cn,br as B0,cr as Pr,dr as WI,er as o0,fr as XI,gr as KI,hr as HI,ir as ZI,jr as gr,kr as Ql,lr as x0,mr as YI,nr as JI,or as RI,pr as VI,qr as k0,rr as OI,sr as sI,tr as LI,ur as qI,vr as _I,wr as _1,xr as jm}from"./chunk-wqk1v8t0.js";import{bs as fm}from"./chunk-0tm6589k.js";import{es as cA,qs as uI}from"./chunk-gswhjd1h.js";import{Hs as hj,Js as m0}from"./chunk-wgkcyqn1.js";import{Os as k,Xs as _}from"./chunk-59csnjc3.js";import{bt as kl,ct as jA,gt as Wi,lt as Yi}from"./chunk-1bxfzd6r.js";import{mt as I}from"./chunk-6p6m5956.js";import{Gy as ji,fz as cI,gz as lI}from"./chunk-w7a33cwa.js";import{AB as Zi,AF as vI,AH as t1,AL as Um,BH as A0,CF as h0,CH as b1,CL as El,Cz as Ii,DH as Al,EE as M,EH as Sl,EL as ml,Ez as Xl,FH as e1,Fz as Fi,GB as AI,GF as V0,GH as s1,HH as X1,IH as ec,IL as K1,JH as wl,Jz as x1,KH as f1,Lz as C1,MF as hi,NN as zr,OJ as PI,PN as cl,QN as H0,RF as wI,RL as Qm,TG as Pl,UB as MI,UN as z,WB as Ti,WL as sc,ZF as Gl,ZL as ym,aA as zi,bB as Dl,cC as L1,cF as R0,cG as wm,cL as M0,dB as k1,dC as q1,dG as $I,dL as Nl,eE as Am,eG as Ul,eM as Hn,fC as K0,fH as C,hG as T1,hL as rI,iF as t,iM as Pn,jB as p1,jH as GI,kB as u1,kM as Fr,lC as d1,lH as NI,lI as UI,mB as Em,mH as On,nB as $r,nH as Cl,oB as Y0,pF as Sm,pL as iI,qB as or,qF as vm,qH as EI,rB as Ai,rH as QI,rL as nI,sB as O0,sF as SI,sL as mI,uB as Dm,uE as g1,vB as Il,wB as vl,wF as Mi,wL as W0,xB as Tr,xH as DI,yB as Im,yE as J0,yH as S0,yL as X0,zB as a1}from"./chunk-g7v6sp3c.js";import{tO as Iv,uO as ir,vO as Nr,xO as bi}from"./chunk-e0vrxetq.js";var km=ir((By)=>{Object.defineProperty(By,"__esModule",{value:!0});By.default=dA;var My=/[A-Z]/g;function hy(r){return r.toLowerCase()}function dA(r,i){let n=r.replace(My,hy),m=i.replace(My,hy);return n===m}});var Zc=ir((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 Yc=ir((py)=>{Object.defineProperty(py,"__esModule",{value:!0});py.toType=py.toString=void 0;var ky=(r)=>{return"_"+r},eA=(r)=>{return["name","protocol","subtype"].includes(r)},sA=(r)=>{let i={name:r.name,protocol:r.protocol,subtype:r.subtype};return Object.entries(i).filter(([m,c])=>eA(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=sA;var fA=(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=fA});var Rc=ir((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")),iS=dy(Zc()),nS=bi("events"),mS=Yc(),pm=".local";class Jc extends nS.EventEmitter{constructor(r){super();if(this.probe=!0,this.published=!1,this.activated=!1,this.destroyed=!1,this.txtService=new iS.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,mS.toString)({name:r.type,protocol:this.protocol}),this.port=r.port,this.host=r.host||ay.default.hostname(),this.fqdn=`${this.name}.${this.type}${pm}`,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}${pm}`,type:"PTR",ttl:28800,data:r.fqdn}}RecordSubtypePTR(r,i){return{name:`_${i}._sub.${r.type}${pm}`,type:"PTR",ttl:28800,data:`${r.name}.${r.type}${pm}`}}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=Jc;ti.default=Jc});var by=ir((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 cS=ty(km()),Vc=ty(Rc()),lS=3600000,yS=3,jS=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 Vc.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=jS;if(!c.activated)return process.nextTick(y);if(!(c instanceof Vc.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 Vc.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,cS.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*yS,n<lS&&!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=ir((IS)=>{IS.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};IS.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=ir((vS)=>{vS.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};vS.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=ir((GS)=>{GS.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};GS.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=ir((QS)=>{QS.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};QS.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=ir((PS)=>{PS.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}`};PS.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=ir((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,V=!0,q=!1;E=E||new Uint8Array(Q+c);for(let g=0;g<N.length;g++){let L=N.charCodeAt(g);if(L===58){if(V){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}V=!0,q=!1}else if(L===46){if(Q<W)E[Q]=K;Q++,K=0,X=0,V=!1,q=!0}else{if(V=!1,L>=97)L-=87;else if(L>=65)L-=55;else L-=48,K=K*10+L;X=(X<<4)+L}}if(V===!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 g=Math.min(Q-1,W-1);g>=Z+2;g--)E[g]=E[g-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=ir((YS)=>{var J=bi("buffer").Buffer,Pi=ey(),XS=sy(),KS=fy(),am=rj(),Fc=ij(),si=cj(),H=YS.name={};H.encode=function(r,i,n,{mail:m=!1}={}){if(!i)i=J.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 J.byteLength(r.replace(/^\.|\.$/gm,""))+2};var O={};O.encode=function(r,i,n){if(!i)i=J.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 J.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:KS.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:XS.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=YS.unknown={};vi.encode=function(r,i,n){if(!i)i=J.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=YS.ns={};wi.encode=function(r,i,n){if(!i)i=J.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=YS.soa={};$i.encode=function(r,i,n){if(!i)i=J.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=YS.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]=J.from(r[c]);if(!J.isBuffer(r[c]))throw Error("Must be a Buffer")}if(!i)i=J.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+=J.byteLength(n)+1;else i+=n.length+1}),i};var Ni=YS.null={};Ni.encode=function(r,i,n){if(!i)i=J.alloc(Ni.encodingLength(r));if(!n)n=0;if(typeof r==="string")r=J.from(r);if(!r)r=J.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(J.isBuffer(r)?r.length:J.byteLength(r))+2};var Ei=YS.hinfo={};Ei.encode=function(r,i,n){if(!i)i=J.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=YS.ptr={},HS=YS.cname=pr,ZS=YS.dname=pr;pr.encode=function(r,i,n){if(!i)i=J.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=YS.srv={};Qi.encode=function(r,i,n){if(!i)i=J.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 Rr=YS.caa={};Rr.ISSUER_CRITICAL=128;Rr.encode=function(r,i,n){let m=Rr.encodingLength(r);if(!i)i=J.alloc(Rr.encodingLength(r));if(!n)n=0;if(r.issuerCritical)r.flags=Rr.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+=J.byteLength(r.value),Rr.encode.bytes=m,i};Rr.encode.bytes=0;Rr.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&Rr.ISSUER_CRITICAL),Rr.decode.bytes=n+2,c};Rr.decode.bytes=0;Rr.encodingLength=function(r){return O.encodingLength(r.tag)+O.encodingLength(r.value)+2};var Vi=YS.mx={};Vi.encode=function(r,i,n){if(!i)i=J.alloc(Vi.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),Vi.encode.bytes=n-m,i};Vi.encode.bytes=0;Vi.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,Vi.decode.bytes=i-n,m};Vi.encodingLength=function(r){return 4+H.encodingLength(r.exchange)};var Di=YS.a={};Di.encode=function(r,i,n){if(!i)i=J.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=YS.aaaa={};Ui.encode=function(r,i,n){if(!i)i=J.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=YS.option={};Kr.encode=function(r,i,n){if(!i)i=J.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,J.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=J.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=YS.opt={};Or.encode=function(r,i,n){if(!i)i=J.alloc(Or.encodingLength(r));if(!n)n=0;let m=n,c=$n(r,Kr);return i.writeUInt16BE(c,n),n=kn(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=YS.dnskey={};Ur.PROTOCOL_DNSSEC=3;Ur.ZONE_KEY=128;Ur.SECURE_ENTRYPOINT=32768;Ur.encode=function(r,i,n){if(!i)i=J.alloc(Ur.encodingLength(r));if(!n)n=0;let m=n,c=r.key;if(!J.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+J.byteLength(r.key)};var sr=YS.rrsig={};sr.encode=function(r,i,n){if(!i)i=J.alloc(sr.encodingLength(r));if(!n)n=0;let m=n,c=r.signature;if(!J.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)+J.byteLength(r.signature)};var fr=YS.rp={};fr.encode=function(r,i,n){if(!i)i=J.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=J.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=J.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=YS.nsec={};ri.encode=function(r,i,n){if(!i)i=J.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=YS.nsec3={};ii.encode=function(r,i,n){if(!i)i=J.alloc(ii.encodingLength(r));if(!n)n=0;let m=n,c=r.salt;if(!J.isBuffer(c))throw Error("salt must be a Buffer");let l=r.nextDomain;if(!J.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=YS.ds={};ni.encode=function(r,i,n){if(!i)i=J.alloc(ni.encodingLength(r));if(!n)n=0;let m=n,c=r.digest;if(!J.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+J.byteLength(r.digest)};var Vr=YS.sshfp={};Vr.getFingerprintLengthForHashType=function(i){switch(i){case 1:return 20;case 2:return 32}};Vr.encode=function(i,n,m){if(!n)n=J.alloc(Vr.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=J.from(i.fingerprint.toUpperCase(),"hex");if(l.length!==Vr.getFingerprintLengthForHashType(i.hash))throw Error("Invalid fingerprint length");return l.copy(n,m),m+=l.byteLength,Vr.encode.bytes=m-c,n.writeUInt16BE(Vr.encode.bytes-2,c),n};Vr.encode.bytes=0;Vr.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=Vr.getFingerprintLengthForHashType(c.hash);return c.fingerprint=i.slice(n,n+l).toString("hex").toUpperCase(),n+=l,Vr.decode.bytes=n-m,c};Vr.decode.bytes=0;Vr.encodingLength=function(r){return 4+J.from(r.fingerprint,"hex").byteLength};var mi=YS.naptr={};mi.encode=function(r,i,n){if(!i)i=J.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=YS.tlsa={};ci.encode=function(r,i,n){if(!i)i=J.alloc(ci.encodingLength(r));if(!n)n=0;let m=n,c=r.certificate;if(!J.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+J.byteLength(r.certificate)};var zc=YS.record=function(r){switch(r.toUpperCase()){case"A":return Di;case"PTR":return pr;case"CNAME":return HS;case"DNAME":return ZS;case"TXT":return Gi;case"NULL":return Ni;case"AAAA":return Ui;case"SRV":return Qi;case"HINFO":return Ei;case"CAA":return Rr;case"NS":return wi;case"SOA":return $i;case"MX":return Vi;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 Vr;case"DS":return ni;case"NAPTR":return mi;case"TLSA":return ci}return vi},vr=YS.answer={};vr.encode=function(r,i,n){if(!i)i=J.alloc(vr.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=am.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=zc(r.type);l.encode(r.data,i,n),n+=l.encode.bytes}return vr.encode.bytes=n-m,i};vr.encode.bytes=0;vr.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=am.toString(c&-32769),n.flush=!!(c&32768);let l=zc(n.type);n.data=l.decode(r,i+8),i+=8+l.decode.bytes}return vr.decode.bytes=i-m,n};vr.decode.bytes=0;vr.encodingLength=function(r){let i=r.data!==null&&r.data!==void 0?r.data:r.options;return H.encodingLength(r.name)+8+zc(r.type).encodingLength(i)};var ur=YS.question={};ur.encode=function(r,i,n){if(!i)i=J.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(am.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=am.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};YS.AUTHORITATIVE_ANSWER=1024;YS.TRUNCATED_RESPONSE=512;YS.RECURSION_DESIRED=256;YS.RECURSION_AVAILABLE=128;YS.AUTHENTIC_DATA=32;YS.CHECKING_DISABLED=16;YS.DNSSEC_OK=32768;YS.encode=function(r,i,n){let m=!i;if(m)i=J.alloc(YS.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=kn(r.questions,ur,i,n),n=kn(r.answers,vr,i,n),n=kn(r.authorities,vr,i,n),n=kn(r.additionals,vr,i,n),YS.encode.bytes=n-c,m&&YS.encode.bytes!==i.length)return i.slice(0,YS.encode.bytes);return i};YS.encode.bytes=0;YS.decode=function(r,i){if(!i)i=0;let n=i,m=ar.decode(r,i);return i+=ar.decode.bytes,i=um(m.questions,ur,r,i),i=um(m.answers,vr,r,i),i=um(m.authorities,vr,r,i),i=um(m.additionals,vr,r,i),YS.decode.bytes=i-n,m};YS.decode.bytes=0;YS.encodingLength=function(r){return ar.encodingLength(r)+$n(r.questions||[],ur)+$n(r.answers||[],vr)+$n(r.authorities||[],vr)+$n(r.additionals||[],vr)};YS.streamEncode=function(r){let i=YS.encode(r),n=J.alloc(2);n.writeUInt16BE(i.byteLength);let m=J.concat([n,i]);return YS.streamEncode.bytes=m.byteLength,m};YS.streamEncode.bytes=0;YS.streamDecode=function(r){let i=r.readUInt16BE(0);if(r.byteLength<i+2)return null;let n=YS.decode(r.slice(2));return YS.streamDecode.bytes=YS.decode.bytes,n};YS.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 kn(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 um(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=ir((sQ,jj)=>{var yj=BS;process.nextTick(hS,42);jj.exports=zS;function zS(r){var i=m;return n;function n(c){i(c||TS)}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 TS(){}function MS(r,i){r.apply(null,i)}function hS(r){if(r===42)yj=process.nextTick}function BS(r,i,n){process.nextTick(function(){r(i,n)})}});var vj=ir((fQ,Sj)=>{var gc=lj(),oS=bi("dgram"),xS=Ij(),kS=bi("events"),Mc=bi("os"),Tc=function(){};Sj.exports=function(r){if(!r)r={};var i=new kS.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||oS.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=gc.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=xS(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=Tc;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=gc.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)|gc.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=Tc;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=Tc;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):uS(),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||pS())}catch(W){i.emit("warning",W)}i.emit("networkInterface")}},i};function pS(){var r=Mc.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(Mc.platform()==="darwin"&&i[n]==="en0")return l.address;return"0.0.0.0"}}}return"127.0.0.1"}function uS(){var r=Mc.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=ir((rD,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=ir((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 aS=hc(vj()),dS=hc($j()),tS=hc(km());class Bc{constructor(r,i){this.registry={},this.mdns=(0,aS.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,tS.default)(m,r)})}isDuplicateRecord(r){return(i)=>{return r.type===i.type&&r.name===i.name&&(0,dS.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=ir((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=ir((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=ir((Uj)=>{Object.defineProperty(Uj,"__esModule",{value:!0});Uj.default=sS;function sS(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=ir((rn)=>{var un=rn&&rn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(rn,"__esModule",{value:!0});rn.Browser=void 0;var rv=un(Zc()),Oi=un(km()),iv=bi("events"),oc=Yc(),Cj=un(Ej()),nv=un(Dj()),mv=un(Pj()),Wj=".local",cv="_services._dns-sd._udp"+Wj;class dm extends iv.EventEmitter{constructor(r,i,n){super();if(this.onresponse=void 0,this.serviceMap={},this.wildcard=!1,this._services=[],typeof i==="function")return new dm(r,null,i);if(this.mdns=r,this.txt=new rv.default(i!==null&&i.txt!=null?i.txt:void 0),i===null||i.type===void 0)this.name=cv,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,nv.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,mv.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=dm;rn.default=dm});var Kj=ir((dr)=>{var tm=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 lv=tm(by()),yv=tm(Gj()),xc=tm(Xj());dr.Browser=xc.default;var jv=tm(Rc());dr.Service=jv.default;class kc{constructor(r={},i){this.server=new yv.default(r,i),this.registry=new lv.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:()=>SA,openapi:()=>o$,listen:()=>x$,Server:()=>bl,Default:()=>h$});var cc=(r)=>{let i=r.split("/");if(i[0]==="")i.shift();return i},el=(r)=>{let{groups:i,path:n}=vA(r),m=cc(n);return wA(m,i)},vA=(r)=>{let i=[];return r=r.replace(/\{[^}]+\}/g,(n,m)=>{let c=`@${m}`;return i.push([c,n]),c}),{groups:i,path:r}},wA=(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},_m={},sl=(r,i)=>{if(r==="*")return"*";let n=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){let m=`${r}#${i}`;if(!_m[m])if(n[2])_m[m]=i&&i[0]!==":"&&i[0]!=="*"?[m,n[1],new RegExp(`^${n[2]}(?=/${i})`)]:[r,n[1],new RegExp(`^${n[2]}$`)];else _m[m]=[r,n[1],!0];return _m[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},Ri=(r,i,...n)=>{if(n.length)i=Ri(i,...n);return`${r?.[0]==="/"?"":"/"}${r}${i==="/"?"":`${r?.at(-1)==="/"?"":"/"}${i?.[0]==="/"?i.slice(1):i}`}`},Fm=(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,gn):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)},gn=decodeURIComponent;var $A=/^[\w!#$%&'*.^`|~+-]+$/,GA=/^[ !#-:<-[\]-~]*$/,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||!$A.test(y)||y in m)continue;let j=cy(c.substring(l+1));if(j.startsWith('"')&&j.endsWith('"'))j=j.slice(1,-1);if(GA.test(j)){if(m[y]=j.indexOf("%")!==-1?Sn(j,gn):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 NA(r,{name:"SHA-256",alias:"sha256"})};var NA=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 EA=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i,QA=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/i,DA=/^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||!EA.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||!(QA.test(l)||DA.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 UA(r,i,n){if(!(n in Iy))return r;let m=Iy[n]||[];if(i==="arktype")return PA(r,m);if(i==="valibot")return CA(r,m);return r}function PA(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 CA(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=UA(l.issues,i["~standard"].vendor,r);return c.json({data:m,error:y,success:!1},400)}return l.value});var vc=Symbol("openapi"),XA=["GET","PUT","POST","DELETE","OPTIONS","HEAD","PATCH","TRACE"],KA=(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),HA=(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},ZA=(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(ZA(m),m),n},new Map);return Array.from(i.values())}var vn=new Map;function YA(r){let i=[];for(let[n,m]of vn)if(m&&r.match(n))i.push(m);return i}function JA(){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:HA(r)})}function $y({route:r,specs:i,paths:n}){let m=KA(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=YA(m);if(!(m in n))n[m]={};if(n[m])n[m][c]=wy(r,...l,n[m]?.[c],i)}}function RA(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??{};JA();let l=await VA(r,m);for(let j in l)for(let A in l[j])if(OA({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:{...RA(l,m),...c.paths},components:y}}async function VA(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(!XA.includes(l))continue}let y=i.options.defaultOptions?.[l],{schema:j,components:A={}}=await LA(c,y);i.components=$c(i.components,A),$y({route:m,specs:j,paths:n})}return n}function OA(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 LA(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 qA(r,{all:n,dot:m});return{}};async function qA(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 _A(l,i);return{}}function _A(r,i){let n=Object.create(null);if(r.forEach((m,c)=>{if(!(i.all||c.endsWith("[]")))n[c]=m;else FA(n,c,m)}),i.dot)Object.entries(n).forEach(([m,c])=>{if(m.includes("."))zA(n,m,c),delete n[m]});return n}var FA=(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]},zA=(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,gn),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 gm={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}},Mn=(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||=Mn(null,{headers:this.#j??=new Headers})}set res(r){if(this.#m&&r){r=Mn(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=Mn(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 Mn(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,gm.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??=()=>Mn(),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.",Mm=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)},Yy=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=Ri(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=Ri(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,Ri(i,"*"),j),this}#l(i,n,m,c){i=i.toUpperCase(),n=Ri(this._basePath,n);let l={basePath:c!==void 0?Ri(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${Ri("/",i)}`,n),m,c)};fire=()=>{addEventListener("fetch",(i)=>{i.respondWith(this.#m(i.request,i,void 0,i.request.method))})}};var hn=[];function hm(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[[],hn];let S=A.indexOf("",1);return[y[1][S],A]};return this.match=m,m(r,i)}var Bm="[^/]+",Bn=".*",on="(?:|/.*)",di=Symbol(),TA=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===Bn||r===on)return 1;else if(i===Bn||i===on)return-1;if(r===Bm)return 1;else if(i===Bm)return-1;return r.length===i.length?r<i?-1:1:i.length-r.length}var Jy=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?["","",Bn]:["","",Bm]:y==="/*"?["","",on]:y.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),S;if(A){let v=A[1],w=A[2]||Bm;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!==Bn&&N!==on))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!==Bn&&v!==on))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}`:TA.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 Ry=class{#r={varIndex:0};#i=new Jy;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 hA=[/^$/,[],Object.create(null)],Vy=Object.create(null);function Oy(r){return Vy[r]??=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(i,n)=>n?`\\${n}`:"(?:|/.*)")}$`)}function BA(){Vy=Object.create(null)}function oA(r){let i=new Ry,n=[];if(r.length===0)return hA;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)]),hn];else v++;let W;try{W=i.insert(E,v,N)}catch(Z){throw Z===di?new Mm(E):Z}if(N)continue;n[v]=Q.map(([Z,X])=>{let K=Object.create(null);X-=1;for(;X>=0;X--){let[V,q]=W[X];K[V]=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 om=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=Fm(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=hm;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,BA(),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 oA(i)}};var xA=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(),hn];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=hm};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 Mm)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 xn=Object.create(null),kA=(r)=>{for(let i in r)return!0;return!1},Ly=class r{#r;#i;#n;#l=0;#c=xn;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!==xn||l&&l!==xn)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=xn;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 V=0,q=X.#n.length;V<q;V++){let g=X.#n[V],L=X.#c===xn?{}:{...X.#c};if(g==="*"){let Br=X.#i["*"];if(Br)this.#m(m,Br,i,X.#c),Br.#c=L,E.push(Br);continue}let[rr,hr,Jr]=g;if(!w&&!(Jr instanceof RegExp))continue;let x=X.#i[rr];if(Jr 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]),Ji=Jr.exec(Br);if(Ji){if(L[hr]=Ji[0],this.#m(m,x,i,X.#c,L),Ji[0].length===Br.length&&x.#i["*"])this.#m(m,x.#i["*"],i,X.#c,L);if(kA(x.#i)){x.#c=L;let An=Ji[0].match(/\//)?.length??0;(j[An]||=[]).push(x)}continue}}if(Jr===!0||Jr.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=Fm(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 Y=class extends Yy{constructor(r={}){super(r);this.router=r.router??new Uc({routers:[new om,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 pA={br:".br",zstd:".zst",gzip:".gz"},xN=Object.keys(pA);var Wc="x-hono-disable-ssg",IE=(()=>{try{return new Response("SSG is disabled",{status:404,headers:{[Wc]:"true"}})}catch{return null}})();var{write:kE}=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 xm=(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)}})},zy=Fy((r,i)=>{let n=xm(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}),gy={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:zy,websocket:gy});var Ty={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:()=>Av,MDNS:()=>Nn});var Hj=Iv(Kj(),1),an=_.create({service:"mdns"}),li,bm;function Av(r,i){if(bm===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",()=>{an.info("mDNS service published",{name:m,port:r})}),c.on("error",(l)=>{an.error("mDNS service error",{error:l})}),bm=r}catch(n){if(an.error("mDNS publish failed",{error:n}),li)try{li.destroy()}catch{}li=void 0,bm=void 0}}function Zj(){if(li){try{li.unpublishAll(),li.destroy()}catch(r){an.error("mDNS unpublish failed",{error:r})}li=void 0,bm=void 0,an.info("mDNS service unpublished")}}var Yj=(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 Sv=/^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/,vv=/^([^:]*):(.*)$/,wv=new TextDecoder,Jj=(r)=>{let i=Sv.exec(r.headers.get("Authorization")||"");if(!i)return;let n=void 0;try{n=vv.exec(wv.decode(Yj(i[1])))}catch{}if(!n)return;return{username:n[1],password:n[2]}};var Rj=(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=Jj(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 Vj=(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,em=(r,i)=>{while(i<r.length){if(!Lj(r.charCodeAt(i)))break;i++}return i},dn=(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]},$v=(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},Gv=(r,i)=>{i=em(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,dn(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=em(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=em(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,dn(r,n)),A===59)l=!0;n++;break}n++}return[n,m,c??r.slice(j,dn(r,n)),l]},Nv=(r,i)=>{let n={type:"",params:{},q:1};i=em(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,dn(r,m)),m++,j===44)return[m,n.type?n:void 0];if(!n.type)return[$v(r,m),void 0];break}m++}if(!n.type)return n.type=r.slice(i,dn(r,r.length)),[r.length,n.type?n:void 0];let c,l,y;while(m<r.length){if([m,c,l,y]=Gv(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]=Nv(r,n),m){if(m.q=Ev(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},Ev=(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 Qv=["gzip","deflate"],Dv=/(?:^|,)\s*?no-transform\s*?(?:,|$)/i,Uv=(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]:Qv,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)||!Pv(y.res))return;let S=y.req.header("Accept-Encoding"),v=Uv(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}`)}},Pv=(r)=>{let i=r.headers.get("Cache-Control");return!i||!Dv.test(i)};import{randomUUID as Cv}from"crypto";var sm="ticket",Fj="x-qitqode-ticket",zj="1",Wv=/^\/pty\/[^/]+\/connect$/,Xv=60000,tn=new Map;function Kv(){let r=Date.now();for(let[i,n]of tn)if(n.expiresAt<=r)tn.delete(i)}function gj(r){return Wv.test(r)}function Tj(r,i=Xv){Kv();let n=Cv();return tn.set(n,{ptyID:r,expiresAt:Date.now()+i}),{ticket:n,expires_in:Math.round(i/1000)}}function Mj(r,i){let n=tn.get(r);if(!n)return!1;if(tn.delete(r),n.expiresAt<=Date.now())return!1;return n.ptyID===i}var r0=_.create({service:"server"}),Bj=(r,i)=>{let n=hj(r),m=n.errorID;r0.error("failed",{error_id:m,error:r});let c=()=>i.json(new fm.Unknown({message:"Internal server error",diagnostic:n}).toObject(),{status:500,headers:{"x-qitqode-error-id":m}});if(r instanceof fm){let l;if(r instanceof Ci)l=404;else if(r instanceof nr.ModelNotFoundError)l=400;else if(r.name==="ProviderAuthValidationFailed")l=400;else if(r.name.startsWith("Worktree"))l=400;else l=500;if(l===500)return c();return i.json(r.toObject(),{status:l,headers:{"x-qitqode-error-id":m}})}if(r instanceof R.BusyError)return i.json(new fm.Unknown({message:r.message,diagnostic:n}).toObject(),{status:409,headers:{"x-qitqode-error-id":m}});if(r instanceof kr)return r.getResponse();return c()},oj=(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(gj(m)&&r.req.query(sm))return i();let c=k.QITQODE_SERVER_USERNAME??"qitqode";return Rj({username:c,password:n})(r,i)},xj=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 kj(r){return Vj({maxAge:86400,origin(i){if(!i)return;if(r?.cors?.includes(i))return i}})}function Hv(r){return r==="localhost"||r==="::1"||/^127(\.\d{1,3}){3}$/.test(r)||r==="127.0.0.1"}function Zv(r){if(r.startsWith("[")){let i=r.indexOf("]");return i===-1?r:r.slice(1,i)}return r.split(":")[0]}function pj(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=Zv(l);if(Hv(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 Yv=_j(),uj=(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 Yv(r,i)};var p={};Nr(p,{waitForSync:()=>hv,status:()=>Tv,startWorkspaceSyncing:()=>uc,sessionRestore:()=>_v,remove:()=>zv,list:()=>Fv,isSyncing:()=>Mv,get:()=>n1,create:()=>Lv,Workspace:()=>p,Info:()=>i0,Event:()=>en,ConnectionStatus:()=>i1});var aj=["forgewise"];var Jv=new TextEncoder;function Rv(r){return Jv.encode(r).byteLength}function dj(r,i=16384){let n=[...aj.filter((l)=>(l in r)),...Object.keys(r).filter((l)=>!aj.includes(l))],m={},c=0;for(let l of n){let y={...m,[l]:r[l]},j=JSON.stringify(y);if(Rv(j)>i)continue;m[l]=r[l],c+=1}if(c===0)return;return JSON.stringify(m)}var Hr=tj("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(()=>bj.id,{onDelete:"cascade"})});async function ej(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=r1.meta({ref:"Workspace"}),i1=I.object({workspaceID:qr.zod,status:I.enum(["connected","connecting","disconnected","error"])}),Vv=I.object({workspaceID:qr.zod,sessionID:br.zod,total:I.number().int().min(0),step:I.number().int().min(0)}),en={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",Vv),Status:yi.define("workspace.status",i1)};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 Ov=I.object({id:qr.zod.optional(),type:i0.shape.type,branch:i0.shape.branch,projectID:l0.zod,extra:i0.shape.extra}),Lv=rm(Ov,async(r)=>{let i=qr.ascending(r.id),n=await _i(r.projectID,r.type),m=await n.configure({...r,id:i,name:fj.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=dj(await e.runPromise(fn.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:m1,fn(A){if(A.workspace===c.id&&A.payload.type===en.Status.type){let{status:S}=A.payload.properties;return S==="error"||S==="connected"}return!1}});return await c1(c),await j,c}),qv=I.object({workspaceID:qr.zod,sessionID:br.zod}),_v=rm(qv,async(r)=>{Ir.info("session restore requested",{workspaceID:r.workspaceID,sessionID:r.sessionID});try{let i=await n1(r.workspaceID);if(!i)throw Error(`Workspace not found: ${r.workspaceID}`);let m=await(await _i(i.projectID,i.type)).target(i);yr.run(R.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(bn(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:en.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(bn(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=bn(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:en.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 Fv(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 n1=rm(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)}),zv=rm(qr.zod,async(r)=>{let i=b.use((m)=>m.select({id:mr.id}).from(mr).where(d(mr.workspace_id,r)).all());for(let m of i)await e.runPromise(R.Service.use((c)=>c.remove(m.id)));let n=b.use((m)=>m.select().from(Hr).where(d(Hr.id,r)).get());if(n){kv(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,En=new Map,m1=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:en.Status.type,properties:m}})}function Tv(){return[...n0.values()]}function sj(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(sn(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 En.has(r)}async function hv(r,i,n){if(sj(i))return;try{await pc({timeout:m1,signal:n,fn(m){if(m.workspace!==r||m.payload.type!=="sync")return!1;return sj(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 bn(r,i){let n=new URL(r);return n.pathname=`${n.pathname.replace(/\/$/,"")}${i}`,n.search="",n.hash="",n}async function Bv(r,i,n){let m=await fetch(bn(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 ov(r,i,n,m){let c=b.use((S)=>S.select({id:mr.id}).from(mr).where(d(mr.workspace_id,r.id)).all().map((v)=>v.id)),l=c.length?Object.fromEntries(b.use((S)=>S.select().from(tr).where(sn(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(bn(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}),Qn.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 xv(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 Bv(m.url,m.headers,i),await ov(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 ej(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 c1(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(En.has(r.id))return!0;qi(r.id,"disconnected");let m=new AbortController;En.set(r.id,m),xv(r,m.signal).catch((c)=>{En.delete(r.id),qi(r.id,"error"),Ir.warn("workspace listener failed",{workspaceID:r.id,error:c})})}function kv(r){En.get(r)?.abort(),En.delete(r),n0.delete(r)}function uc(r){let i=b.use((n)=>n.select({workspace:Hr}).from(Hr).innerJoin(mr,d(mr.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);c1(m).catch((c)=>{qi(m.id,"error"),Ir.warn("failed to start workspace sync",{workspaceID:m.id,error:c})})}}var y1="x-qitqode-sync",ac=_.create({service:"fence"});function l1(r){let i=b.use((n)=>{if(!r?.length)return n.select().from(tr).all();return n.select().from(tr).where(sn(tr.aggregate_id,r)).all()});return Object.fromEntries(i.map((n)=>[n.aggregate_id,n.seq]))}function pv(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 j1(r){let i=r.get(y1);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 I1(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 A1=async(r,i)=>{if(r.req.method==="GET"||r.req.method==="HEAD"||r.req.method==="OPTIONS")return i();let n=l1();await i();let m=pv(n,l1());if(Object.keys(m).length>0)ac.info("header",{diff:m}),r.res.headers.set(y1,JSON.stringify(m))};var S1=_.create({service:"session.projector"});function v1(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 av(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 w1=[yr.project(j0.Created,(r,i)=>{r.insert(mr).values($1(i.info)).run()}),yr.project(j0.Updated,(r,i)=>{let n=i.info;if(!r.update(mr).set(av(n)).where(d(mr.id,i.sessionID)).returning().get())throw new Ci({message:`Session not found: ${i.sessionID}`})}),yr.project(j0.Deleted,(r,i)=>{r.delete(mr).where(d(mr.id,i.sessionID)).run()}),yr.project(Ar.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(!v1(j))throw j;S1.warn("ignored late message update",{messageID:m,sessionID:c})}}),yr.project(Ar.Event.Removed,(r,i)=>{r.delete(Xi).where(im(d(Xi.id,i.messageID),d(Xi.session_id,i.sessionID))).run()}),yr.project(Ar.Event.PartRemoved,(r,i)=>{r.delete(Ki).where(im(d(Ki.id,i.partID),d(Ki.session_id,i.sessionID))).run()}),yr.project(Ar.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(!v1(y))throw y;S1.warn("ignored late part update",{partID:n,messageID:m,sessionID:c})}})];function dc(){yr.init({projectors:w1,convertEvent:(r,i)=>{if(r==="session.updated"){let n=i.sessionID,m=b.use((c)=>c.select().from(mr).where(d(mr.id,n)).get());if(!m)return i;return{sessionID:n,info:R.fromRow(m)}}return i}})}dc();class Dn{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 dv={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,dv[i]]))}function tv(r){let i=r.match(/^(.+)ID$/);if(i)return`${i[1].toLowerCase()}.id`;return`qitqode.${r}`}function bv(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[tv(n)]=m;return i}function u(r,i,n){return e.runPromise(n.pipe(C.withSpan(r,{attributes:bv(i)})))}async function U(r,i,n){return i.json(await u(r,i,C.gen(()=>n(i))))}var ev=I.object({path:I.string(),body:I.any()}),sv=new Dn,fv=new Dn;var rw=new Y().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:$(ev)}}}}}),async(r)=>{let i=await sv.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 fv.push(i),r.json(!0)}),G1=F(()=>new Y().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,R.Service.use((n)=>n.get(i))),await wr.publish(Er.SessionSelect,{sessionID:i}),r.json(!0)}).route("/control",rw));var iw=I.object({answers:_r.Answer.zod.array().describe("User answers in order of questions (each answer is an array of selected labels)")}),N1=()=>D("param",I.object({requestID:nm.zod})),E1=F(()=>new Y().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)}}),N1(),D("json",iw),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)}}),N1(),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 Q1=F(()=>new Y().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:Un.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 U1=F(()=>new Y().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:D1.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 nw=I.object({output:I.string().describe("Captured output from the interactive command"),exitCode:I.number().describe("Exit code of the interactive command")}),P1=F(()=>new Y().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",nw),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 Wm={};Nr(Wm,{webHandler:()=>d4,routes:()=>n2,ExperimentalHttpApiServer:()=>Wm});var Mr={};Nr(Mr,{reflect:()=>yl,make:()=>sw,isHttpApi:()=>bw,AdditionalSchemas:()=>Z0});var a={};Nr(a,{put:()=>kw,post:()=>xw,patch:()=>pw,options:()=>dw,make:()=>gi,isHttpApiEndpoint:()=>zw,head:()=>aw,getSuccessSchemas:()=>nn,getPayloadSchemas:()=>gw,getErrorSchemas:()=>mn,get:()=>ow,delete:()=>uw});var Zn={};Nr(Zn,{UnauthorizedNoContent:()=>Kw,Unauthorized:()=>v0,ServiceUnavailableNoContent:()=>_w,ServiceUnavailable:()=>C0,RequestTimeoutNoContent:()=>Rw,RequestTimeout:()=>E0,NotImplementedNoContent:()=>qw,NotImplemented:()=>P0,NotFoundNoContent:()=>Zw,NotFound:()=>$0,NotAcceptableNoContent:()=>Jw,NotAcceptable:()=>N0,MethodNotAllowedNoContent:()=>Yw,MethodNotAllowed:()=>G0,InternalServerErrorNoContent:()=>Lw,InternalServerError:()=>U0,GoneNoContent:()=>Ow,Gone:()=>D0,ForbiddenNoContent:()=>Hw,Forbidden:()=>w0,ConflictNoContent:()=>Vw,Conflict:()=>Q0,BadRequestNoContent:()=>Xw,BadRequestFromSchemaError:()=>rl,BadRequest:()=>Hi});function cw(r){return(i)=>{return i.annotate({httpApiStatus:r})}}var lw=(r)=>sc.pipe(cw(r)),H1=lw(204);function Yr(r){return(i)=>{return sc.pipe(Pn(K1(i),S0({decode:r.decode,encode:C1})))}}function yw(r,i){return r.annotate({"~httpApiEncoding":{_tag:i._tag,contentType:i.contentType??jw(i._tag)}})}function jw(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 Z1(r){return(i)=>yw(i,{_tag:"FormUrlEncoded",...r})}var mm=(r)=>{if(A0(r))return!0;let i=X1(r);if(A0(i))return!0;let n=r.encoding?.[0].to;if(n===void 0)return!1;return A0(n)},Y1=ec("~httpApiEncoding"),J1=ec("httpApiStatus"),R1={_tag:"Json",contentType:"application/json"},Iw={_tag:"FormUrlEncoded",contentType:"application/x-www-form-urlencoded"};function Aw(r){return Y1(r)??R1}function fc(r,i){let n=Y1(r);if(n)return n;return Cn(i)?R1:Iw}function Wn(r){let i=Aw(r);if(i._tag==="Multipart")throw Error("Multipart is not supported in response");return i}function Xn(r){return J1(r)??200}function Kn(r){return J1(r)??500}var vw=Pr({status:400}),ww=Pr({status:401}),$w=Pr({status:403}),Gw=Pr({status:404}),Nw=Pr({status:405}),Ew=Pr({status:406}),Qw=Pr({status:408}),Dw=Pr({status:409}),Uw=Pr({status:410}),Pw=Pr({status:500}),Cw=Pr({status:501}),Ww=Pr({status:503});class Hi extends zr("effect/HttpApiError/BadRequest")({_tag:Fr("BadRequest")},{description:"BadRequest",httpApiStatus:400}){[ji]=!0;[gr](){return t(vw)}static singleton=new Hi}var Xw=Hi.pipe(Yr({decode:()=>new Hi({})})),rl=Hi.pipe(Pn(Hn([W0(X0),Hi]),S0({encode:(r)=>Hi.singleton,decode:Fi})),Yr({decode:()=>new Hi({})})).annotate({httpApiStatus:400,description:"BadRequest"});class v0 extends zr("effect/HttpApiError/Unauthorized")({_tag:Fr("Unauthorized")},{description:"Unauthorized",httpApiStatus:401}){[ji]=!0;[gr](){return t(ww)}}var Kw=v0.pipe(Yr({decode:()=>new v0({})}));class w0 extends zr("effect/HttpApiError/Forbidden")({_tag:Fr("Forbidden")},{description:"Forbidden",httpApiStatus:403}){[ji]=!0;[gr](){return t($w)}}var Hw=w0.pipe(Yr({decode:()=>new w0({})}));class $0 extends zr("effect/HttpApiError/NotFound")({_tag:Fr("NotFound")},{description:"NotFound",httpApiStatus:404}){[ji]=!0;[gr](){return t(Gw)}}var Zw=$0.pipe(Yr({decode:()=>new $0({})}));class G0 extends zr("effect/HttpApiError/MethodNotAllowed")({_tag:Fr("MethodNotAllowed")},{description:"MethodNotAllowed",httpApiStatus:405}){[ji]=!0;[gr](){return t(Nw)}}var Yw=G0.pipe(Yr({decode:()=>new G0({})}));class N0 extends zr("effect/HttpApiError/NotAcceptable")({_tag:Fr("NotAcceptable")},{description:"NotAcceptable",httpApiStatus:406}){[ji]=!0;[gr](){return t(Ew)}}var Jw=N0.pipe(Yr({decode:()=>new N0({})}));class E0 extends zr("effect/HttpApiError/RequestTimeout")({_tag:Fr("RequestTimeout")},{description:"RequestTimeout",httpApiStatus:408}){[ji]=!0;[gr](){return t(Qw)}}var Rw=E0.pipe(Yr({decode:()=>new E0({})}));class Q0 extends zr("effect/HttpApiError/Conflict")({_tag:Fr("Conflict")},{description:"Conflict",httpApiStatus:409}){[ji]=!0;[gr](){return t(Dw)}}var Vw=Q0.pipe(Yr({decode:()=>new Q0({})}));class D0 extends zr("effect/HttpApiError/Gone")({_tag:Fr("Gone")},{description:"Gone",httpApiStatus:410}){[ji]=!0;[gr](){return t(Uw)}}var Ow=D0.pipe(Yr({decode:()=>new D0({})}));class U0 extends zr("effect/HttpApiError/InternalServerError")({_tag:Fr("InternalServerError")},{description:"InternalServerError",httpApiStatus:500}){[gr](){return t(Pw)}}var Lw=U0.pipe(Yr({decode:()=>new U0({})}));class P0 extends zr("effect/HttpApiError/NotImplemented")({_tag:Fr("NotImplemented")},{description:"NotImplemented",httpApiStatus:501}){[gr](){return t(Cw)}}var qw=P0.pipe(Yr({decode:()=>new P0({})}));class C0 extends zr("effect/HttpApiError/ServiceUnavailable")({_tag:Fr("ServiceUnavailable")},{description:"ServiceUnavailable",httpApiStatus:503}){[gr](){return t(Ww)}}var _w=C0.pipe(Yr({decode:()=>new C0({})}));var nl="~effect/httpapi/HttpApiEndpoint",zw=(r)=>zi(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:[H1]}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 q1(Array.from(i),rl)}var Tw={[nl]:nl,pipe(){return Ii(this,arguments)},prefix(r){return lm({...this,path:_1(this.path,r)})},middleware(r){return lm({...this,middlewares:new Set([...this.middlewares,r])})},annotate(r,i){return lm({...this,annotations:Ai(this.annotations,r,i)})},annotateMerge(r){return lm({...this,annotations:Tr(this.annotations,r)})}};function lm(r){return Object.assign(Object.create(Tw),r)}var gi=(r)=>(i,n,m)=>{let c=m?.disableCodecs??!1,l=c?Fi:H0;return lm({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:V1(m?.success,c),error:V1(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(ym(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]:[ym(r).pipe(Z1())],l=n?Fi:Bw;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 V1(r,i){if(r===void 0)return new Set;let n=L1(r);return new Set(i?n:n.map(hw))}function hw(r){switch(Wn(r.ast)._tag){case"Json":return cl(r);case"FormUrlEncoded":return H0(r);case"Text":case"Uint8Array":return r}}function Bw(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 ow=gi("GET"),xw=gi("POST"),kw=gi("PUT"),pw=gi("PATCH"),uw=gi("DELETE");var aw=gi("HEAD"),dw=gi("OPTIONS");var ll="~effect/httpapi/HttpApi",bw=(r)=>zi(r,ll),ew={[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=Tr(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:Ti(this.groups,(i)=>i.prefix(r)),annotations:this.annotations})},middleware(r){return cn({identifier:this.identifier,groups:Ti(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:Tr(this.annotations,r)})}},cn=(r)=>{function i(){}return Object.setPrototypeOf(i,ew),i.groups=r.groups,i.annotations=r.annotations,i},sw=(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=Tr(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:Tr(c,y.annotations),successes:F1(nn(y),Xn),errors:F1(mn(y),Kn)})}}},F1=(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 Sr={};Nr(Sr,{securitySetCookie:()=>S4,securityDecode:()=>zI,layer:()=>j4,group:()=>I4,endpoint:()=>A4,HandlersTypeId:()=>FI});var Yn={};Nr(Yn,{layerSchemaErrorTransform:()=>i4,layerClient:()=>n4,isSecurity:()=>$m,Service:()=>fw});var z1="~effect/httpapi/HttpApiMiddleware",jl="~effect/httpapi/HttpApiMiddleware/Security",$m=(r)=>zi(r,jl),fw=()=>(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[z1]=z1,y.error=r4(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 r4(r){if(r===void 0)return new Set;return new Set(Array.isArray(r)?r:[r])}var i4=(r,i)=>g1(r,(n,m)=>V0(n,(c)=>X0(c)?i(c,m):vm(c))),n4=(r,i)=>J0(Sm(function*(){let n=(yield*wm()).pipe(Im(Am)),m=R0(i)?yield*i:i;return Y0(new Map([[`${r.key}/Client`,(c)=>T1(m(c),(l)=>Tr(n,l))]]))}));var h={};Nr(h,{fromApi:()=>$l,annotations:()=>l4,Version:()=>_0,Transform:()=>Vn,Title:()=>Jn,Summary:()=>Nm,Servers:()=>z0,Override:()=>Rn,License:()=>F0,Identifier:()=>q0,Format:()=>g0,ExternalDocs:()=>Gm,Exclude:()=>L0,Description:()=>ln,Deprecated:()=>T0});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 Gm extends $r()("effect/httpapi/OpenApi/ExternalDocs"){}class z0 extends $r()("effect/httpapi/OpenApi/Servers"){}class g0 extends $r()("effect/httpapi/OpenApi/Format"){}class Nm extends $r()("effect/httpapi/OpenApi/Summary"){}class T0 extends $r()("effect/httpapi/OpenApi/Deprecated"){}class Rn extends $r()("effect/httpapi/OpenApi/Override"){}var L0=a1("effect/httpapi/OpenApi/Exclude",{defaultValue:x1});class Vn extends $r()("effect/httpapi/OpenApi/Transform"){}var c4=(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}},l4=c4({identifier:q0,title:Jn,version:_0,description:ln,license:F0,summary:Nm,deprecated:T0,externalDocs:Gm,servers:z0,format:g0,override:Rn,exclude:L0,transform:Vn}),M1=new WeakMap;function lr(r,i,n){let m=vl(r,i);if(k1(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=[];lr(r.annotations,Jn,(y)=>{m.info.title=y}),lr(r.annotations,_0,(y)=>{m.info.version=y}),lr(r.annotations,ln,(y)=>{m.info.description=y}),lr(r.annotations,F0,(y)=>{m.info.license=y}),lr(r.annotations,Nm,(y)=>{m.info.summary=y}),lr(r.annotations,z0,(y)=>{m.servers=[...y]}),yl(r,{onGroup({group:y}){if(Il(y.annotations,L0))return;let j={name:O0(y.annotations,Jn,()=>y.identifier)};lr(y.annotations,ln,(A)=>{j.description=A}),lr(y.annotations,Gm,(A)=>{j.externalDocs=A}),lr(y.annotations,Rn,(A)=>{Object.assign(j,A)}),lr(y.annotations,Vn,(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 V={},q=!1;if(K.forEach(({encoding:g,schemas:L},rr)=>{let hr=L.filter((Br)=>!mm(Br.ast));if(hr.length===0)return;q=!0;let Jr=hr.map(Al),x=Jr.length===1?Jr[0]:new Sl(Jr,"anyOf");c.push({_tag:"schema",ast:o1(x,g._tag),path:["paths",w,N,"requestBody","content",rr,"schema"]}),V[rr]={schema:{}}}),q)v.requestBody={content:V,required:!0}}}function Q(K,V){for(let[q,{content:g,descriptions:L}]of K){let rr=L.size>0?Array.from(L).join(" | "):V();if(v.responses[q]={description:rr},g!==void 0)g.forEach((hr,Jr)=>{hr.forEach((x,Br)=>{let Ji=Array.from(x,Al),An=Ji.length===1?Ji[0]:new Sl(Ji,"anyOf");c.push({_tag:"schema",ast:o1(An,Jr),path:["paths",w,N,"responses",String(q),"content",Br,"schema"]}),v.responses[q].content??={},v.responses[q].content[Br]={schema:{}}})})}}function W(K,V){if(K){let q=e1(K.ast);if(b1(q))for(let g of q.propertySignatures)v.parameters.push({name:String(g.name),in:V,schema:{},required:V==="path"||!s1(g.type)}),c.push({_tag:"parameter",ast:g.type,path:["paths",w,N,"parameters",String(v.parameters.length-1),"schema"]})}}lr(y.annotations,ln,(K)=>{v.description=K}),lr(y.annotations,Nm,(K)=>{v.summary=K}),lr(y.annotations,T0,(K)=>{v.deprecated=K}),lr(y.annotations,Gm,(K)=>{v.externalDocs=K}),S.forEach((K)=>{if(!$m(K))return;for(let[V,q]of Object.entries(K.security))Z(V,q),v.security.push({[V]:[]})});function Z(K,V){if(m.components.securitySchemes[K]!==void 0)return;m.components.securitySchemes[K]=y4(V)}let X=Cn(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(h1(nn(y),Xn,B1),()=>"Success"),Q(h1(mn(y),Kn,B1),()=>"Error"),!m.paths[w])m.paths[w]={};lr(y.annotations,Rn,(K)=>{Object.assign(v,K)}),lr(y.annotations,Vn,(K)=>{v=K(v)}),m.paths[w][N]=v}}),lr(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(rI).join("/")}if(K0(c)){let y=cI(d1(c,(S)=>S.ast)),j=nI(lI(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=iI(A,m)}return Object.keys(m.components.schemas).forEach((y)=>{if(!mI.test(y))throw new globalThis.Error(`Invalid component schema key: ${y}`)}),lr(r.annotations,Rn,(y)=>{Object.assign(m,y)}),lr(r.annotations,Vn,(y)=>{m=y(m)}),M1.set(r,m),m}function h1(r,i,n){let m=new Map;return r.forEach(c),m;function c(j){let A=j.ast,S=i(A);if(mm(A))l(S,n(j.ast)??"<No Content>");else y(j,S,Wn(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 B1(r){return f1(r)??wl(r)}var yI=Qm.annotate({format:"binary"});function o1(r,i){switch(i){case"Uint8Array":return yI.ast;case"Text":return Qm.ast;case"FormUrlEncoded":case"Json":return r;case"Multipart":return jI(r)}}function jI(r){if(t1(r)&&r.annotations?.typeConstructor?._tag==="effect/http/PersistedFile")return yI.ast;if(typeof r?.recur==="function")return r.recur(jI);return r}var y4=(r)=>{let i={};switch(lr(r.annotations,ln,(n)=>{i.description=n}),r._tag){case"Basic":return{...i,type:"http",scheme:"basic"};case"Bearer":{let n=vl(r.annotations,g0).pipe(u1((m)=>({bearerFormat:m})),p1);return{...i,type:"http",scheme:"bearer",...n}}case"ApiKey":return{...i,type:"apiKey",name:r.key,in:r.in}}};var j4=(r,i)=>qI(Pl(function*(n){let m=yield*wm(),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*SI(`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(XI(y)))}})),I4=(r,i,n)=>J0(Sm(function*(){let m=(yield*wm()).pipe(Im(Am)),c=r.groups[i],l=n(G4(c)),y=R0(l)?yield*l:l,j=[];for(let A of y.handlers)j.push(Q4(c,A,m));return Y0(new Map([[c.key,j]]))})),FI=Symbol.for("@effect/platform/HttpApiBuilder/Handlers"),A4=(r,i,n,m)=>$I((c)=>{let l=r.groups[i],y=l.endpoints[n];return t(gI(l,y,Im(Am)(c),m,!1))}),zI=(r)=>{switch(r._tag){case"Bearer":return h0(x0.asEffect(),(i)=>On((i.headers.authorization??"").slice(v4)));case"ApiKey":{let i=r.in==="header"?r.key.toLowerCase():r.key,n=ym({[i]:Qm}),m=r.in==="query"?VI(n):r.in==="cookie"?JI(n):RI(n);return Gl(m,{onFailure:()=>On(""),onSuccess:(c)=>On(c[i])})}case"Basic":{let i={username:"",password:On("")};return x0.asEffect().pipe(Mi((n)=>GI((n.headers.authorization??"").slice(w4)).asEffect()),Gl({onFailure:()=>i,onSuccess:(n)=>{let m=n.split(":");if(m.length!==2)return i;return{username:m[0],password:On(m[1])}}}))}}},S4=(r,i,n)=>OI((m,c)=>hi(ZI(c,r.key,NI(i),{secure:!0,httpOnly:!0,...n}))),v4=7,w4=6,$4={[FI]:{_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}},G4=(r)=>{let i=Object.create($4);return i.group=r,i.handlers=new Set,i};function N4(r){let i=new Map;return r.forEach(({encoding:n,schemas:m},c)=>{let l=Um(Hn(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 E4(r,i,n){let m=Cn(i.method),c=m?U4(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 Mi(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)=>PI(i.multipartStream,Ql(A))}))}case"Json":return Mi(hi(i.json),j);case"Text":return Mi(hi(i.text),j);case"FormUrlEncoded":{let A=m?h0(hi(i.urlParamsBody),CI):t(n);return Mi(A,j)}case"Uint8Array":return Mi(h0(hi(i.arrayBuffer),(A)=>new Uint8Array(A)),j)}}function gI(r,i,n,m,c){let l=El(H4(i)),y=El(Z4(i)),j=M0(i.params,Um),A=M0(i.headers,Um),S=M0(i.query,Um),w=i.payload.size>0&&!c?N4(i.payload):void 0;return P4(r,i,n,Sm(function*(){let E=UI().context,Q=Dm(E,x0),W=Dm(E,LI),Z=Dm(E,YI),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 V=E4(w,Q,Z);if(B0(V))return V;if(V!==void 0)X.payload=yield*V}let K=yield*m(X);return B0(K)?K:yield*l(K)})).pipe(wI,V0((N)=>hi(y(N))),Ul(n))}function Q4(r,i,n){let m=i.endpoint;return _I(m.method,m.path,gI(r,m,n,i.handler,i.isRaw),{uninterruptible:i.uninterruptible})}var D4=(r)=>r.headers["content-type"]?r.headers["content-type"].toLowerCase().trim():"application/json",U4=(r)=>{let i=D4(r),n=i.indexOf(";");return n===-1?i:i.slice(0,n).trim()},P4=(r,i,n,m)=>{let c={group:r,endpoint:i};for(let l of i.middlewares){let y=l,j=Dm(n,y);m=($m(y)?C4(y,j):j)(m,c)}return m},II=new WeakMap,C4=(r,i)=>{let n=II.get(i);if(n!==void 0)return n;let m=Object.entries(r.security).map(([l,y])=>({decode:zI(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*vI(Mi(S,(N)=>v(l,{credential:N,endpoint:y.endpoint,group:y.group})));if(AI(w)){j=w;continue}return w.success}return yield*j.asEffect()});return II.set(i,c),c},W4=W0(B0),X4=TI(Xn),K4=TI(Kn);function H4(r){let i=nn(r).map(X4);return i.length===1?i[0]:Hn(i)}function Z4(r){let i=mn(r).map(K4);return i.length===1?i[0]:Hn(i)}function TI(r){let i=new WeakMap;return(n)=>{let m=i.get(n.ast);if(m!==void 0)return m;let c=W4.pipe(Pn(n,Y4(r,n)));return i.set(c.ast,c),c}}function Y4(r,i){let n=i.ast,m=J4(r(n),Wn(n),mm(n));return DI({decode:(c)=>vm(new QI(Dl(c),{message:"Encode only schema"})),encode:m})}function J4(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 vm(new EI(Dl(m),{message:globalThis.String(c)}))}};case"Text":return(m)=>t(o0(m,{status:r,contentType:i.contentType}));case"Uint8Array":return(m)=>t(WI(m,{status:r,contentType:i.contentType}));case"FormUrlEncoded":return(m)=>t(KI(m,{status:r}).pipe(HI("content-type",i.contentType)))}}var xr={};Nr(xr,{make:()=>O4,isHttpApiGroup:()=>R4});var Wl="~effect/httpapi/HttpApiGroup",R4=(r)=>zi(r,Wl),V4={[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:Ti(this.endpoints,(i)=>i.prefix(r)),annotations:this.annotations})},middleware(r){return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:Ti(this.endpoints,(i)=>i.middleware(r)),annotations:this.annotations})},annotateMerge(r){return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,annotations:Tr(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:Ti(this.endpoints,(i)=>i.annotateMerge(r)),annotations:this.annotations})},annotateEndpoints(r,i){return Bi({identifier:this.identifier,topLevel:this.topLevel,endpoints:Ti(this.endpoints,(n)=>n.annotate(r,i)),annotations:this.annotations})},pipe(){return Ii(this,arguments)}},Bi=(r)=>{function i(){}return Object.setPrototypeOf(i,V4),i.key=`effect/httpapi/HttpApiGroup/${r.identifier}`,Object.assign(i,r)},O4=(r,i)=>Bi({identifier:r,topLevel:i?.topLevel??!1,endpoints:MI(),annotations:or()});var p0={};Nr(p0,{bearer:()=>L4,basic:()=>_4,apiKey:()=>q4,annotateMerge:()=>F4,annotate:()=>z4});var hI="~effect/httpapi/HttpApiSecurity",Pm={[hI]:hI,pipe(){return Ii(this,arguments)}},L4=Object.assign(Object.create(Pm),{_tag:"Bearer",annotations:or()}),q4=(r)=>Object.assign(Object.create(Pm),{_tag:"ApiKey",key:r.key,in:r.in??"header",annotations:or()}),_4=Object.assign(Object.create(Pm),{_tag:"Basic",annotations:or()}),F4=Xl(2,(r,i)=>Object.assign(Object.create(Pm),{...r,annotations:Tr(r.annotations,i)})),z4=Xl(3,(r,i,n)=>Object.assign(Object.create(Pm),{...r,annotations:Ai(r.annotations,i,n)}));var g4="/config",Kl=Mr.make("config").add(xr.make("config").add(a.get("providers",`${g4}/providers`,{success:nr.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."})),BI=M.unwrap(C.gen(function*(){let r=yield*nr.Service,i=C.fn("ConfigHttpApi.providers")(function*(){let n=yield*r.list();return{providers:Object.values(n),default:nr.defaultModelIDs(n)}});return Sr.group(Kl,"config",(n)=>n.handle("providers",i))})).pipe(M.provide(nr.defaultLayer),M.provide(cr.defaultLayer));var oI="/permission",Hl=Mr.make("permission").add(xr.make("permission").add(a.get("list",oI,{success:z.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",`${oI}/:requestID/reply`,{params:{requestID:Un},payload:Qr.ReplyBody,success:z.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."})),xI=M.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 Sr.group(Hl,"permission",(m)=>m.handle("list",i).handle("reply",n))})).pipe(M.provide(Qr.defaultLayer));var kI="/project",Zl=Mr.make("project").add(xr.make("project").add(a.get("list",kI,{success:z.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",`${kI}/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."})),pI=M.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 T.project});return Sr.group(Zl,"project",(m)=>m.handle("list",i).handle("current",n))})).pipe(M.provide(Gr.defaultLayer));var u0=C.fnUntraced(function*(r,i){let n=yield*C.promise(()=>aI.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(uI(l,(j)=>nr.fromModelsDevProvider(j)),i);return{all:Object.values(y),default:nr.defaultModelIDs(y),connected:Object.keys(i)}});var a0="/provider",Yl=Mr.make("provider").add(xr.make("provider").add(a.get("list",a0,{success:nr.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:s},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:s},payload:Cr.CallbackInput,success:z.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."})),dI=M.unwrap(C.gen(function*(){let r=yield*cr.Service,i=yield*nr.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 Zn.BadRequest({}))));if(!A)return yield*new Zn.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 Zn.BadRequest({})))),!0});return Sr.group(Yl,"provider",(j)=>j.handle("list",m).handle("auth",c).handle("authorize",l).handle("callback",y))})).pipe(M.provide(Cr.defaultLayer),M.provide(nr.defaultLayer),M.provide(cr.defaultLayer));var Cm="/question",Jl=Mr.make("question").add(xr.make("question").add(a.get("list",Cm,{success:z.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",`${Cm}/:requestID/reply`,{params:{requestID:nm},payload:_r.Reply,success:z.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",`${Cm}/:requestID/reject`,{params:{requestID:nm},success:z.Boolean}).annotateMerge(h.annotations({identifier:"question.reject",summary:"Reject question request",description:"Reject a question request from the AI assistant."})),a.get("neverAsk",`${Cm}/never-ask`,{success:z.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",`${Cm}/never-ask`,{payload:z.Struct({enabled:z.Boolean}),success:z.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."})),tI=M.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 Sr.group(Jl,"question",(y)=>y.handle("list",i).handle("reply",n).handle("reject",m).handle("neverAsk",c).handle("setNeverAsk",l))})).pipe(M.provide(_r.defaultLayer));var T4=z.Struct({directory:z.optional(z.String),workspace:z.optional(z.String)}),M4=z.Struct({authorization:z.optional(z.String),"x-qitqode-directory":z.optional(z.String)});function h4(r){try{return decodeURIComponent(r)}catch{return r}}class d0 extends z.TaggedErrorClass()("Unauthorized",{message:z.String},{httpApiStatus:401}){}class oi extends Yn.Service()("@qitqode/ExperimentalHttpApiAuthorization",{error:d0,security:{basic:p0.basic}}){}var B4=M.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 i2 extends z.TaggedErrorClass()("DirectoryAccessDenied",{message:z.String},{httpApiStatus:403}){}var o4=jm.middleware()(C.gen(function*(){return(r)=>C.gen(function*(){let i=yield*k0.schemaSearchParams(T4),n=yield*k0.schemaHeaders(M4),m=i.directory||n["x-qitqode-directory"]||process.cwd(),c=i.workspace||void 0,l=Wi.resolve(h4(m));if(!k.QITQODE_SERVER_PASSWORD){let A=Wi.resolve(process.cwd());if(!Wi.contains(A,l))return yield*new i2({message:"Access denied: directory must be within the server's working directory"})}let y=yield*C.promise(()=>T.provide({directory:l,init:()=>e.runPromise(xi),fn:()=>T.current}));return yield*(c?r.pipe(C.provideService(eI,c)):r).pipe(C.provideService(bI,y))})})).layer,x4=Jl.middleware(oi),k4=Hl.middleware(oi),p4=Zl.middleware(oi),u4=Yl.middleware(oi),a4=Kl.middleware(oi),n2=M.mergeAll(Sr.layer(a4).pipe(M.provide(BI)),Sr.layer(p4).pipe(M.provide(pI)),Sr.layer(x4).pipe(M.provide(tI)),Sr.layer(k4).pipe(M.provide(xI)),Sr.layer(u4).pipe(M.provide(dI))).pipe(M.provide(B4),M.provide(o4),M.provide(sI.layerServices),M.provideMerge(fI.layer)),d4=F(()=>jm.toWebHandler(n2,{memoMap:r2}));var m2=F(()=>new Y().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(T.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=T.directory,n=T.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 T.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"}),f=()=>D("param",I.object({sessionID:br.zod})),Rl=()=>D("param",I.object({sessionID:br.zod,messageID:Si.zod})),Vl=()=>D("param",I.object({sessionID:br.zod,messageID:Si.zod,partID:pi.zod}));function c2(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*R.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 y2(){return new Y().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:$(R.Info.array())}}}}}),D("query",I.object(ki)),async(r)=>{let i=r.req.valid("query"),n=[];for await(let m of R.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:$(R.Info)}}},...P(400,404)}}),D("param",I.object({sessionID:R.GetInput})),async(r)=>{let i=r.req.valid("param").sessionID;return U("SessionRoutes.get",r,function*(){return yield*(yield*R.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:$(R.Info.array())}}},...P(400,404)}}),D("param",I.object({sessionID:R.ChildrenInput})),async(r)=>{let i=r.req.valid("param").sessionID;return U("SessionRoutes.children",r,function*(){return yield*(yield*R.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:$(R.Info)}}}}}),D("json",R.CreateInput),async(r)=>U("SessionRoutes.create",r,function*(){let i=r.req.valid("json")??{};return yield*(yield*Km.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:R.RemoveInput})),async(r)=>U("SessionRoutes.delete",r,function*(){let i=r.req.valid("param").sessionID;return yield*(yield*R.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:$(R.Info)}}},...P(400,404)}}),f(),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*R.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)}}),f(),D("json",I.object({modelID:er.zod,providerID:s.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:Xm.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:$(R.Info)}}}}}),D("param",I.object({sessionID:R.ForkInput.shape.sessionID})),D("json",R.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*R.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)}}),f(),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)}}),f(),async(r)=>{let i=r.req.valid("param").sessionID,n=await u("SessionRoutes.actors",r,C.gen(function*(){let m=yield*l2.Service;return yield*(yield*R.Service).get(i),yield*m.listBySession(i)}));return r.json(n)})}function I2(){return new Y().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)}}),f(),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(c2);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:$(j2.array())}}},...P(400,404)}}),f(),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*R.Service).get(i),yield*m.list({session_id:i,include_terminal:!0})}));return r.json(n)})}function A2(){return new Y().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:$(R.Info)}}},...P(400,404)}}),f(),async(r)=>U("SessionRoutes.share",r,function*(){let i=r.req.valid("param").sessionID,n=yield*Km.Service,m=yield*R.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:$(R.Info)}}},...P(400,404)}}),f(),async(r)=>U("SessionRoutes.unshare",r,function*(){let i=r.req.valid("param").sessionID,n=yield*Km.Service,m=yield*R.Service;return yield*n.unshare(i),yield*m.get(i)}))}function w2(){return new Y().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:$(S2.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)}}),f(),D("json",I.object({providerID:s.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*R.Service,c=yield*Hm.Service,l=yield*v2.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:$(R.Info)}}},...P(400,404)}}),f(),D("json",Hm.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*Hm.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:$(R.Info)}}},...P(400,404)}}),f(),async(r)=>U("SessionRoutes.unrevert",r,function*(){let i=r.req.valid("param").sessionID;return yield*(yield*Hm.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 Zm=()=>{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 Zm=()=>i,i};var t4=new WeakMap,s0=(r,i,n)=>{let{readable:m,writable:c}=new TransformStream,l=new e0(c,m);if(Zm())r.req.raw.signal.addEventListener("abort",()=>{if(!l.closed)l.abort()});return t4.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 $2=class extends e0{constructor(r,i){super(r,i)}async writeSSE(r){let n=(await Tn(r.data,gm.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)}},b4=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()}},e4=new WeakMap,Fl=(r,i,n)=>{let{readable:m,writable:c}=new TransformStream,l=new $2(c,m);if(Zm())r.req.raw.signal.addEventListener("abort",()=>{if(!l.closed)l.abort()});return e4.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"),b4(l,i,n),r.newResponse(l.responseReadable)};var G2=I.object({info:Ar.Assistant,parts:Ar.Part.array()});function N2(){return new Y().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:$(Ar.WithParts.array())}}},...P(400,404)}}),f(),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 Ar.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*R.Service;return yield*y.get(n),yield*y.messages({sessionID:n,agentID:m})}));return r.json(l)}let c=await Ar.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:Ar.Info,parts:Ar.Part.array()}))}}},...P(400,404)}}),Rl(),async(r)=>{let i=r.req.valid("param"),n=await Ar.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)}}),Rl(),async(r)=>U("SessionRoutes.deleteMessage",r,function*(){let i=r.req.valid("param"),n=yield*zl.Service,m=yield*R.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)}}),Vl(),async(r)=>U("SessionRoutes.deletePart",r,function*(){let i=r.req.valid("param");return yield*(yield*R.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:$(Ar.Part)}}},...P(400,404)}}),Vl(),D("json",Ar.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*R.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:$(G2)}}},...P(400,404,409)}}),f(),D("json",Dr.PromptInput.omit({sessionID:!0})),async(r)=>{let i=r.req.valid("param").sessionID;return await u("SessionRoutes.prompt.assertNotBusy",r,zl.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)}}),f(),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(R.Event.Error,{sessionID:i,error:Ar.fromError(m,{providerID:s.make(n.model?.providerID??"qlex")})})}),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:$(G2)}}},...P(400,404)}}),f(),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)}}),f(),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:$(Ar.WithParts)}}},...P(400,404)}}),f(),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 E2(){return new Y().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:Un.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 Q2=F(()=>{let r=new Y;return r.route("/",y2()),r.route("/",I2()),r.route("/",A2()),r.route("/",w2()),r.route("/",N2()),r.route("/",E2()),r});var D2=_.create({service:"server.qredits"}),s4=I.object({balance:I.number().nullable(),status:I.enum(["signed_out","available","unavailable","not_linked"])}),W2=F(()=>new Y().get("/balance",G({summary:"Get Qredits balance",description:"Retrieve the current Qredits balance for the account behind the active credential. The response status distinguishes signed-out users, credentials with no linked account, and temporary billing-service outages.",operationId:"qredits.balance",responses:{200:{description:"Qredits balance",content:{"application/json":{schema:$(s4)}}}}}),async(r)=>U("QreditsRoutes.balance",r,function*(){let i=yield*C.promise(()=>U2());if(!i)return{balance:null,status:"signed_out"};let n=yield*C.tryPromise({try:()=>C2(i),catch:(m)=>m}).pipe(C.map((m)=>m?{kind:"ok",balance:m.balance}:{kind:"failed"}),C.catch((m)=>C.sync(()=>{if(m instanceof P2)return D2.warn("credential has no linked account; no wallet to read",{method:i.method}),{kind:"not_linked"};return D2.warn("qredits balance read failed; reporting unavailable",{method:i.method,error:m instanceof Error?m.message:String(m)}),{kind:"failed"}})));if(n.kind==="not_linked")return{balance:null,status:"not_linked"};if(n.kind==="failed")return{balance:null,status:"unavailable"};return{balance:n.balance,status:"available"}})));function X2(r){return new Y().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)!==zj)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(Tj(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(sm);if(!m||!Mj(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 K2=(r,i)=>C.gen(function*(){let n=yield*Xr.Service;if(i==="connect")yield*n.connect(r);else yield*n.disconnect(r);return!0}),Z2=F(()=>new Y().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:H2.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*K2(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*K2(r.req.valid("param").name,"disconnect")})));var Y2=F(()=>new Y().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:$(gl.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*gl.Service).search({cwd:T.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 J2=F(()=>new Y().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:$(cr.Info)}}}}}),async(r)=>U("ConfigRoutes.get",r,function*(){return yield*(yield*cr.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:$(cr.Info)}}},...P(400)}}),D("json",cr.Info),async(r)=>U("ConfigRoutes.update",r,function*(){let i=r.req.valid("json");return yield*(yield*cr.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:$(nr.ConfigProvidersResult.zod)}}}}}),async(r)=>U("ConfigRoutes.providers",r,function*(){let n=yield*(yield*nr.Service).list();return{providers:Object.values(n),default:nr.defaultModelIDs(n)}})));var f4=I.object({accountID:I.string(),accountEmail:I.string(),accountUrl:I.string(),orgID:I.string(),orgName:I.string(),active:I.boolean()}),r$=I.object({orgs:I.array(f4)}),i$=I.object({accountID:I.string(),orgID:I.string()}),L2=F(()=>new Y().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:$(O2.zod)}}}}}),async(r)=>U("ExperimentalRoutes.console.get",r,function*(){let i=yield*cr.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:$(r$)}}}}}),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=Em.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",i$),async(r)=>U("ExperimentalRoutes.console.switchOrg",r,function*(){let i=r.req.valid("json");return yield*(yield*f0.Service).use(R2.make(i.accountID),Em.some(V2.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*Tl.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*Tl.Service).tools({providerID:s.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(T.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(T.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:$(R.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 R.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 q2=F(()=>new Y().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:$(nr.ListResult.zod)}}}}}),async(r)=>U("ProviderRoutes.list",r,function*(){let i=yield*nr.Service,m=yield*(yield*cr.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:s.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:s.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 n$=1e4,m$=1e5,c$=8388608,l$=67108864,y$=2097152,j$=8388608;function I$(r=process.env.QITQODE_EVENT_QUEUE_CAPACITY){let i=Number(r);if(!Number.isSafeInteger(i)||i<1||i>m$)return n$;return i}var A$=I$();function S$(r=process.env.QITQODE_EVENT_QUEUE_BYTES){let i=Number(r);if(!Number.isSafeInteger(i)||i<1||i>l$)return c$;return i}function v$(r=process.env.QITQODE_EVENT_MAX_BYTES){let i=Number(r);if(!Number.isSafeInteger(i)||i<1||i>j$)return y$;return i}var _2=S$(),w$=Math.min(v$(),_2);function $$(r,i=w$){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 Dn({capacity:A$,maxWeight:_2,weight:(v)=>v===null?0:Buffer.byteLength(v)}),c=!1,l=0,y=()=>{},j=(v)=>{let 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"}),F2=()=>{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 Y().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:Ln.Connected.type,properties:{}},heartbeat:{type:Ln.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 G$=I.object({id:I.string(),aggregateID:I.string(),seq:I.number().int().min(0),type:I.string(),data:I.record(I.string(),I.unknown())}),z2=_.create({service:"server.sync"}),h2=F(()=>new Y().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(T.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(G$).min(1)})),async(r)=>{let i=r.req.valid("json"),n=i.events,m=n[0].aggregateID;return z2.info("sync replay requested",{sessionID:m,events:n.length,first:n[0]?.seq,last:n.at(-1)?.seq,directory:i.directory}),yr.replayAll(n),z2.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?T2(g2(...n.map(([l,y])=>im(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 Y;if(k.QITQODE_EXPERIMENTAL_HTTPAPI){let n=Wm.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",m2()).route("/pty",X2(r)).route("/config",J2()).route("/experimental",L2()).route("/session",Q2()).route("/qredits",W2()).route("/permission",Q1()).route("/workflows",U1()).route("/question",E1()).route("/bash-interactive",P1()).route("/provider",q2()).route("/sync",h2()).route("/",Y2()).route("/",F2()).route("/mcp",Z2()).route("/tui",G1()).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 T.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:Yi.Path.home,state:Yi.Path.state,config:Yi.Path.config,worktree:T.worktree,directory:T.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:$(qn.Info)}}}}}),async(n)=>U("InstanceRoutes.vcs.get",n,function*(){let m=yield*qn.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:$(qn.FileDiff.array())}}}}}),D("query",I.object({mode:qn.Mode})),async(n)=>U("InstanceRoutes.vcs.diff",n,function*(){return yield*(yield*qn.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:$(Xm.Info.array())}}}}}),async(n)=>U("InstanceRoutes.command.list",n,function*(){return yield*(yield*Xm.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:$(Ml.Status.array())}}}}}),async(n)=>U("InstanceRoutes.formatter.status",n,function*(){return yield*(yield*Ml.Service).status()}))};function B2(){let r=new Y,i=(n,m)=>e.runPromise(C.gen(function*(){let c=yield*fn.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:s.zod})),D("json",fn.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:s.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 _n={};Nr(_n,{scan:()=>X$,runAll:()=>K$,ExternalImport:()=>_n,ALL_SOURCES:()=>pl});import iA from"path";import{access as ol}from"fs/promises";import{Database as N$}from"bun:sqlite";function Rm(r){let i=new N$(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 Vm={};Nr(Vm,{run:()=>U$,parse:()=>u2,CodexImport:()=>Vm});import E$ from"path";var Q$=_.create({service:"codex-import"});function o2(r){if(!r)return Date.now();let i=Date.parse(r);return Number.isNaN(i)?Date.now():i}function D$(r){if(typeof r==="string")try{return JSON.parse(r)}catch{return{raw:r}}if(r&&typeof r==="object")return r;return{}}function u2(r,i){let n=x2(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:s.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:s.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=o2(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=o2(X.timestamp);if(y===void 0||q<y)y=q;continue}if(Z!=="response_item"||!X)continue;let V=X.type;if(V==="message"){let q=X.role,g=X.content??[];if(q==="user"||q==="developer"){let L=g.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 rr=Si.ascending(),hr=L.map((x)=>({part:{id:pi.ascending(),sessionID:i,messageID:rr,type:"text",text:x},time:K})),Jr={id:rr,sessionID:i,role:"user",agent:"main",time:{created:K},model:{providerID:s.make("openai"),modelID:er.make("unknown")}};if(S.push({info:Jr,parts:hr}),N=rr,!A)A=k2(L);continue}if(q==="assistant"){let L=Q(K);for(let rr of g)if((rr.type==="output_text"||rr.type==="text")&&typeof rr.text==="string"&&rr.text.trim())L.parts.push({part:{id:pi.ascending(),sessionID:i,messageID:L.info.id,type:"text",text:rr.text},time:K});continue}continue}if(V==="reasoning"){let q=Q(K),L=X.summary?.map((rr)=>rr.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(V==="function_call"||V==="custom_tool_call"){let q=Q(K),g=X.call_id??pi.ascending(),L=X.name??"unknown",rr=V==="function_call"?D$(X.arguments):{raw:X.input??""},hr={id:pi.ascending(),sessionID:i,messageID:q.info.id,type:"tool",callID:g,tool:L,state:{status:"pending",input:rr,raw:JSON.stringify(rr)}};q.parts.push({part:hr,time:K}),v.set(g,{part:hr,start:K});continue}if(V==="function_call_output"||V==="custom_tool_call_output"){let q=X.call_id,g=q?v.get(q):void 0;if(!g)continue;let L=typeof X.output==="string"?X.output:JSON.stringify(X.output??"");g.part.state={status:"completed",input:g.part.state.input??{},output:L,title:g.part.tool,metadata:{},time:{start:g.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 U$=p2({source:"codex",root:E$.join(Yi.Path.home,".codex","sessions"),pattern:"**/*.jsonl",log:Q$,logMessage:"codex import",parse:u2});var Lm={};Nr(Lm,{run:()=>W$,OpencodeImport:()=>Lm,DEFAULT_DB_PATH:()=>Om});import{access as P$}from"fs/promises";var C$=_.create({service:"opencode-import"}),Om=(()=>{return`${process.env.XDG_DATA_HOME||`${process.env.HOME||process.env.USERPROFILE}/.local/share`}/opencode/opencode.db`})(),a2=200;async function W$(r){let i=r?.dbPath??Om,n=d2();if(!await P$(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=b2("opencode",j);if(A&&A.source_mtime===y.time_updated&&!r?.force){n.skipped++;continue}let S=e2("opencode",A);A=S.existing;let v=S.existingUpdated,w=await t2(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+=a2){let X=Q.slice(Z,Z+a2),K=X.map(()=>"?").join(","),V=m.all(`SELECT * FROM part WHERE session_id = ? AND message_id IN (${K}) ORDER BY id`,y.id,...X);W.push(...V)}if(b.transaction((Z)=>{if(s2(Z,w,y.time_created,y.time_updated),A)f2(Z,A,y.id),rA(Z,y.id,{projectId:w.id,directory:y.directory,version:y.version,existingUpdated:v,timeUpdated:y.time_updated});else Z.insert(mr).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:mr.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)C$.info("opencode import",{...n,errors:n.errors.length});return n}var qm=_.create({service:"external-import"}),pl=["cc","codex","opencode"];async function X$(){let r=(c)=>b.use((l)=>l.select({n:nA()}).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=iA.join(Yi.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){qm.warn("cc scan failed",{error:String(c)})}let m=iA.join(Yi.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){qm.warn("codex scan failed",{error:String(c)})}if(await ol(Om).then(()=>!0).catch(()=>!1))try{let c=Rm(Om);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){qm.warn("opencode scan failed",{error:String(c)})}return i}function xl(){return{scanned:0,imported:0,resynced:0,skipped:0,errors:[]}}async function K$(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 mA.run({force:r?.force});else if(c==="codex")n.codex=await Vm.run({force:r?.force});else n.opencode=await Lm.run({force:r?.force})}catch(l){qm.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)qm.info("external import",m);return n}var nc=_.create({service:"server"}),H$=yi.define("global.disposed",I.object({})),lA=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 Y().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:cA})}).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:Ln.Connected.type,properties:{}}},heartbeat:{directory:"global",payload:{type:Ln.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:$(cr.Info)}}}}}),async(m)=>{return m.json(await e.runPromise(cr.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:$(cr.Info)}}},...P(400)}}),D("json",cr.Info),async(m)=>{let c=m.req.valid("json"),l=await e.runPromise(cr.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 T.disposeAll(),Lr.emit("event",{directory:"global",payload:{type:H$.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 _n.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 _n.runAll({sources:c,force:l}))})});var Fn={};Nr(Fn,{websocket:()=>_$,http:()=>q$,ServerProxy:()=>Fn});var Z$=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","te","trailer","transfer-encoding","upgrade","host","authorization"]);function Y$(r,i){let n=new Headers(r.headers);for(let m of Z$)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 J$(r){let i=r.headers.get("sec-websocket-protocol");if(!i)return[];return i.split(",").map((n)=>n.trim()).filter(Boolean)}function R$(r){let i=new URL(r);if(i.protocol==="http:")i.protocol="ws:";if(i.protocol==="https:")i.protocol="wss:";return i.toString()}function V$(r,i){if(i instanceof Blob)return i.arrayBuffer().then((n)=>r.send(n));return r.send(i)}var O$=(r)=>new Y().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,J$(i.req.raw)),c.binaryType="arraybuffer",c.onopen=()=>{for(let j of m)c?.send(j);m.length=0},c.onmessage=(j)=>{V$(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)}}})),L$=_.Default.clone().tag("service","server-proxy");async function q$(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:Y$(n,i),body:n.method==="GET"||n.method==="HEAD"?void 0:n.body,redirect:"manual",signal:n.signal})).then((c)=>{let l=j1(c.headers),y=new Headers(c.headers);return y.delete("content-encoding"),y.delete("content-length"),(l?I1(m,l,n.signal):Promise.resolve()).then(async()=>{return new Response(c.body,{status:c.status,statusText:c.statusText,headers:y})})})}function _$(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",R$(i));for(let[j,A]of new Headers(n).entries())y.set(j,A);return L$.info("proxy websocket",{request:m.url,target:String(i)}),O$(r).fetch(new Request(l,{method:m.method,headers:y,signal:m.signal}),c)}var F$=[{path:"/session/status",action:"forward"},{method:"GET",path:"/session",action:"local"}];function z$(r,i){for(let n of F$){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 T$(r){let i=g$(r);if(!i)return null;return(await e.runPromise(R.Service.use((m)=>m.get(i)).pipe(C.withSpan("WorkspaceRouter.lookup"))).catch(()=>{return}))?.workspaceID}function yA(r){let i=_.create({service:"workspace-router"});return async(n,m)=>{let c=new URL(n.req.url),y=await T$(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(z$(n.req.method,c.pathname))return m();let S=await(await _i(j.projectID,j.type)).target(j);if(S.type==="local")return Qn.provide({workspaceID:qr.make(y),fn:()=>T.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 Fn.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 Fn.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=jA.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 Qn.provide({workspaceID:r,async fn(){return T.provide({directory:c,init:()=>e.runPromise(xi),async fn(){return n()}})}})}}var dl=_.create({service:"server.workspace"}),AA=F(()=>new Y().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 IA(T.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:T.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(T.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(T.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:T.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"}),h$=F(()=>tl({}));function B$(r){try{return new URL(r).hostname}catch{return}}function tl(r){let i=new Y().onError(Bj).use(pj({hostname:r.hostname,mdnsDomain:r.mdnsDomain,allowedHosts:r.cors?.map(B$).filter((m)=>!!m)})).use(kj(r)).use(xj).use(oj).use(uj).route("/global",lA()),n=Ty.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(A1).route("/",Bl(n.upgradeWebSocket)),runtime:n};return{app:i.route("/",B2()).route("/",new Y().use(al()).route("/experimental/workspace",AA()).use(yA(n.upgradeWebSocket)).route("/",Bl(n.upgradeWebSocket))),runtime:n}}async function o$(){let{app:r}=tl({});return await wc(r,{documentation:{info:{title:"qitqode",version:"1.0.0",description:"qitqode api"},openapi:"3.1.1"}})}var SA;async function x$(r){let n=await tl(r).runtime.listen(r),m=new URL("http://localhost");m.hostname=r.hostname,m.port=String(n.port),SA=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{h$ as hg,o$ as ig,SA as jg,x$ as kg,bl as lg};
|