@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
|
@@ -0,0 +1,808 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{al as Vq,hl as El}from"./chunk-gx4v8z64.js";import{Bl as KX,Cl as tA,Dl as $Q,Jl as S8,Kl as B0,Ml as T7,ml as L7,ol as d$,pl as xY,ql as AY,rl as I1,sl as L$,tl as C8,vl as MA,zl as W1}from"./chunk-v03xq38e.js";import{Pl as xU,Ql as hU,Rl as uw,Tl as mw,Vl as T1}from"./chunk-dx7rexx3.js";import{Cm as sA,Dm as WX,Em as Wd,Fm as k5,Hm as iK,Nm as rA,Vm as o6,jm as Gd,qm as N8,rm as L1,sm as KQ,tm as g6,um as kQ,wm as m0,ym as j$,zm as LL}from"./chunk-xgf4k9q7.js";import{an as r8,bn as $U,cn as s8,dn as Vw}from"./chunk-dnjyepb2.js";import{En as JX,en as Dw,hn as Oq,in as jq,kn as tD,mn as j6,nn as Mm,on as bm,pn as Dm,sn as wm,tn as Lm,vn as Tm,xn as IA,yn as _m,zn as Sm}from"./chunk-8gpjmj42.js";import{Gn as g0,Hn as Ym,In as A$,Jn as eD,Kn as w0}from"./chunk-qdafm7qg.js";import{Ln as Rm}from"./chunk-r81w6skn.js";import{Mn as d0}from"./chunk-ge7csm6m.js";import{On as cL,Vn as iL}from"./chunk-d0dsgxk4.js";import{Yn as xA,Zn as tl,jo as el,mo as $d}from"./chunk-1q10jyka.js";import{$o as Nl,So as k7,To as m2,Yo as SA,_o as jl,up as yl,vp as xl}from"./chunk-wh2qqhep.js";import{Fq as pL,Hp as hL,Ip as G8,Kp as FJ,Lp as HX,Pp as z4,Qp as gL,Rp as uL,Sp as aU,Up as a6,Wp as AX,Xp as q4,Yp as mL,_p as OX,aq as lL,bq as dL,gq as M4,iq as v8,jq as jX,kq as A4,lq as y8,nq as W8,xq as QH}from"./chunk-yce8ph5b.js";import{Gq as c0,Hq as FX,Jq as r6,Lq as xZ,Nq as JH,Oq as YH,Qq as XH,Sq as I8,Tq as g5,Uq as rU,Vq as UX}from"./chunk-kec1xw1n.js";import{cr as lu}from"./chunk-nq4x6792.js";import{fr as BA,gr as Su}from"./chunk-2y5bthrp.js";import{tr as Kw,vr as OO,zr as UO}from"./chunk-gq3zb4wv.js";import{Br as W2}from"./chunk-2cvwrabw.js";import{Kr as Wq,Rr as U$,Sr as PZ,Yr as hQ,Zr as Kq}from"./chunk-4sa9t0vx.js";import{Gs as jA,vs as D8}from"./chunk-g52wmt1v.js";import{Hs as n8,Ls as f1}from"./chunk-9d0exvey.js";import{Ms as z00}from"./chunk-h2p984qb.js";import{Ts as V30}from"./chunk-qm9fm5ja.js";import{_s as N1}from"./chunk-wd2xmkdp.js";import{at as h1}from"./chunk-8peby2d1.js";import{bt as b$,ft as wq,gt as ym,jt as Wl,kt as bK,lt as q1,mt as _K,nt as v6,wt as e9}from"./chunk-azss4acq.js";import{Ct as Y8,Et as UY,Ft as V6}from"./chunk-0bhzhh7s.js";import{Lt as S0,Ut as _0}from"./chunk-7s0nq2aa.js";import{$t as w$,_t as $4,du as s0,eu as V4,fu as mV,iu as A0}from"./chunk-cxtwavyf.js";import{ju as P}from"./chunk-15bjhfav.js";import{Hu as D}from"./chunk-q4mtwv1w.js";import{zz as oV}from"./chunk-x308f9j4.js";import{BF as R0,GJ as gw,HC as v7,IF as n7,JE as hw,QE as BQ,RO as O,VK as I$,WF as W4,XE as f6,YC as y7,cI as T,jC as O1,kJ as Mw,lF as PY,mD as ml,sI as nV,tJ as h6,xC as S1,yD as J8}from"./chunk-2zjet9tx.js";import{pP as xL}from"./chunk-9pj10pgd.js";import{qP as m6,rP as S,sP as F1,uP as J0,vP as IK,wP as EK}from"./chunk-djfrkbd5.js";var R7=S((DO)=>{Object.defineProperty(DO,"__esModule",{value:!0});DO.stringArray=DO.array=DO.func=DO.error=DO.number=DO.string=DO.boolean=void 0;function Yp($){return $===!0||$===!1}DO.boolean=Yp;function qO($){return typeof $==="string"||$ instanceof String}DO.string=qO;function Xp($){return typeof $==="number"||$ instanceof Number}DO.number=Xp;function Qp($){return $ instanceof Error}DO.error=Qp;function Gp($){return typeof $==="function"}DO.func=Gp;function MO($){return Array.isArray($)}DO.array=MO;function Wp($){return MO($)&&$.every((Z)=>qO(Z))}DO.stringArray=Wp});var HV=S((iO)=>{Object.defineProperty(iO,"__esModule",{value:!0});iO.Message=iO.NotificationType9=iO.NotificationType8=iO.NotificationType7=iO.NotificationType6=iO.NotificationType5=iO.NotificationType4=iO.NotificationType3=iO.NotificationType2=iO.NotificationType1=iO.NotificationType0=iO.NotificationType=iO.RequestType9=iO.RequestType8=iO.RequestType7=iO.RequestType6=iO.RequestType5=iO.RequestType4=iO.RequestType3=iO.RequestType2=iO.RequestType1=iO.RequestType=iO.RequestType0=iO.AbstractMessageSignature=iO.ParameterStructures=iO.ResponseError=iO.ErrorCodes=void 0;var F5=R7(),VV;(function($){$.ParseError=-32700,$.InvalidRequest=-32600,$.MethodNotFound=-32601,$.InvalidParams=-32602,$.InternalError=-32603,$.jsonrpcReservedErrorRangeStart=-32099,$.serverErrorStart=-32099,$.MessageWriteError=-32099,$.MessageReadError=-32098,$.PendingResponseRejected=-32097,$.ConnectionInactive=-32096,$.ServerNotInitialized=-32002,$.UnknownErrorCode=-32001,$.jsonrpcReservedErrorRangeEnd=-32000,$.serverErrorEnd=-32000})(VV||(iO.ErrorCodes=VV={}));class UV extends Error{constructor($,Z,J){super(Z);this.code=F5.number($)?$:VV.UnknownErrorCode,this.data=J,Object.setPrototypeOf(this,UV.prototype)}toJson(){let $={code:this.code,message:this.message};if(this.data!==void 0)$.data=this.data;return $}}iO.ResponseError=UV;class g${constructor($){this.kind=$}static is($){return $===g$.auto||$===g$.byName||$===g$.byPosition}toString(){return this.kind}}iO.ParameterStructures=g$;g$.auto=new g$("auto");g$.byPosition=new g$("byPosition");g$.byName=new g$("byName");class s1{constructor($,Z){this.method=$,this.numberOfParams=Z}get parameterStructures(){return g$.auto}}iO.AbstractMessageSignature=s1;class TO extends s1{constructor($){super($,0)}}iO.RequestType0=TO;class RO extends s1{constructor($,Z=g$.auto){super($,1);this._parameterStructures=Z}get parameterStructures(){return this._parameterStructures}}iO.RequestType=RO;class PO extends s1{constructor($,Z=g$.auto){super($,1);this._parameterStructures=Z}get parameterStructures(){return this._parameterStructures}}iO.RequestType1=PO;class CO extends s1{constructor($){super($,2)}}iO.RequestType2=CO;class IO extends s1{constructor($){super($,3)}}iO.RequestType3=IO;class EO extends s1{constructor($){super($,4)}}iO.RequestType4=EO;class bO extends s1{constructor($){super($,5)}}iO.RequestType5=bO;class _O extends s1{constructor($){super($,6)}}iO.RequestType6=_O;class SO extends s1{constructor($){super($,7)}}iO.RequestType7=SO;class fO extends s1{constructor($){super($,8)}}iO.RequestType8=fO;class kO extends s1{constructor($){super($,9)}}iO.RequestType9=kO;class vO extends s1{constructor($,Z=g$.auto){super($,1);this._parameterStructures=Z}get parameterStructures(){return this._parameterStructures}}iO.NotificationType=vO;class yO extends s1{constructor($){super($,0)}}iO.NotificationType0=yO;class xO extends s1{constructor($,Z=g$.auto){super($,1);this._parameterStructures=Z}get parameterStructures(){return this._parameterStructures}}iO.NotificationType1=xO;class hO extends s1{constructor($){super($,2)}}iO.NotificationType2=hO;class gO extends s1{constructor($){super($,3)}}iO.NotificationType3=gO;class uO extends s1{constructor($){super($,4)}}iO.NotificationType4=uO;class mO extends s1{constructor($){super($,5)}}iO.NotificationType5=mO;class lO extends s1{constructor($){super($,6)}}iO.NotificationType6=lO;class dO extends s1{constructor($){super($,7)}}iO.NotificationType7=dO;class pO extends s1{constructor($){super($,8)}}iO.NotificationType8=pO;class cO extends s1{constructor($){super($,9)}}iO.NotificationType9=cO;var LO;(function($){function Z(X){let Q=X;return Q&&F5.string(Q.method)&&(F5.string(Q.id)||F5.number(Q.id))}$.isRequest=Z;function J(X){let Q=X;return Q&&F5.string(Q.method)&&X.id===void 0}$.isNotification=J;function Y(X){let Q=X;return Q&&(Q.result!==void 0||!!Q.error)&&(F5.string(Q.id)||F5.number(Q.id)||Q.id===null)}$.isResponse=Y})(LO||(iO.Message=LO={}))});var zV=S((rO)=>{var oO;Object.defineProperty(rO,"__esModule",{value:!0});rO.LRUCache=rO.LinkedMap=rO.Touch=void 0;var u$;(function($){$.None=0,$.First=1,$.AsOld=$.First,$.Last=2,$.AsNew=$.Last})(u$||(rO.Touch=u$={}));class BV{constructor(){this[oO]="LinkedMap",this._map=new Map,this._head=void 0,this._tail=void 0,this._size=0,this._state=0}clear(){this._map.clear(),this._head=void 0,this._tail=void 0,this._size=0,this._state++}isEmpty(){return!this._head&&!this._tail}get size(){return this._size}get first(){return this._head?.value}get last(){return this._tail?.value}has($){return this._map.has($)}get($,Z=u$.None){let J=this._map.get($);if(!J)return;if(Z!==u$.None)this.touch(J,Z);return J.value}set($,Z,J=u$.None){let Y=this._map.get($);if(Y){if(Y.value=Z,J!==u$.None)this.touch(Y,J)}else{switch(Y={key:$,value:Z,next:void 0,previous:void 0},J){case u$.None:this.addItemLast(Y);break;case u$.First:this.addItemFirst(Y);break;case u$.Last:this.addItemLast(Y);break;default:this.addItemLast(Y);break}this._map.set($,Y),this._size++}return this}delete($){return!!this.remove($)}remove($){let Z=this._map.get($);if(!Z)return;return this._map.delete($),this.removeItem(Z),this._size--,Z.value}shift(){if(!this._head&&!this._tail)return;if(!this._head||!this._tail)throw Error("Invalid list");let $=this._head;return this._map.delete($.key),this.removeItem($),this._size--,$.value}forEach($,Z){let J=this._state,Y=this._head;while(Y){if(Z)$.bind(Z)(Y.value,Y.key,this);else $(Y.value,Y.key,this);if(this._state!==J)throw Error("LinkedMap got modified during iteration.");Y=Y.next}}keys(){let $=this._state,Z=this._head,J={[Symbol.iterator]:()=>{return J},next:()=>{if(this._state!==$)throw Error("LinkedMap got modified during iteration.");if(Z){let Y={value:Z.key,done:!1};return Z=Z.next,Y}else return{value:void 0,done:!0}}};return J}values(){let $=this._state,Z=this._head,J={[Symbol.iterator]:()=>{return J},next:()=>{if(this._state!==$)throw Error("LinkedMap got modified during iteration.");if(Z){let Y={value:Z.value,done:!1};return Z=Z.next,Y}else return{value:void 0,done:!0}}};return J}entries(){let $=this._state,Z=this._head,J={[Symbol.iterator]:()=>{return J},next:()=>{if(this._state!==$)throw Error("LinkedMap got modified during iteration.");if(Z){let Y={value:[Z.key,Z.value],done:!1};return Z=Z.next,Y}else return{value:void 0,done:!0}}};return J}[(oO=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}trimOld($){if($>=this.size)return;if($===0){this.clear();return}let Z=this._head,J=this.size;while(Z&&J>$)this._map.delete(Z.key),Z=Z.next,J--;if(this._head=Z,this._size=J,Z)Z.previous=void 0;this._state++}addItemFirst($){if(!this._head&&!this._tail)this._tail=$;else if(!this._head)throw Error("Invalid list");else $.next=this._head,this._head.previous=$;this._head=$,this._state++}addItemLast($){if(!this._head&&!this._tail)this._head=$;else if(!this._tail)throw Error("Invalid list");else $.previous=this._tail,this._tail.next=$;this._tail=$,this._state++}removeItem($){if($===this._head&&$===this._tail)this._head=void 0,this._tail=void 0;else if($===this._head){if(!$.next)throw Error("Invalid list");$.next.previous=void 0,this._head=$.next}else if($===this._tail){if(!$.previous)throw Error("Invalid list");$.previous.next=void 0,this._tail=$.previous}else{let{next:Z,previous:J}=$;if(!Z||!J)throw Error("Invalid list");Z.previous=J,J.next=Z}$.next=void 0,$.previous=void 0,this._state++}touch($,Z){if(!this._head||!this._tail)throw Error("Invalid list");if(Z!==u$.First&&Z!==u$.Last)return;if(Z===u$.First){if($===this._head)return;let{next:J,previous:Y}=$;if($===this._tail)Y.next=void 0,this._tail=Y;else J.previous=Y,Y.next=J;$.previous=void 0,$.next=this._head,this._head.previous=$,this._head=$,this._state++}else if(Z===u$.Last){if($===this._tail)return;let{next:J,previous:Y}=$;if($===this._head)J.previous=void 0,this._head=J;else J.previous=Y,Y.next=J;$.next=void 0,$.previous=this._tail,this._tail.next=$,this._tail=$,this._state++}}toJSON(){let $=[];return this.forEach((Z,J)=>{$.push([J,Z])}),$}fromJSON($){this.clear();for(let[Z,J]of $)this.set(Z,J)}}rO.LinkedMap=BV;class sO extends BV{constructor($,Z=1){super();this._limit=$,this._ratio=Math.min(Math.max(0,Z),1)}get limit(){return this._limit}set limit($){this._limit=$,this.checkTrim()}get ratio(){return this._ratio}set ratio($){this._ratio=Math.min(Math.max(0,$),1),this.checkTrim()}get($,Z=u$.AsNew){return super.get($,Z)}peek($){return super.get($,u$.None)}set($,Z){return super.set($,Z,u$.Last),this.checkTrim(),this}checkTrim(){if(this.size>this._limit)this.trimOld(Math.round(this._limit*this._ratio))}}rO.LRUCache=sO});var Zj=S((eO)=>{Object.defineProperty(eO,"__esModule",{value:!0});eO.Disposable=void 0;var tO;(function($){function Z(J){return{dispose:J}}$.create=Z})(tO||(eO.Disposable=tO={}))});var DZ=S((Jj)=>{Object.defineProperty(Jj,"__esModule",{value:!0});var FV;function AV(){if(FV===void 0)throw Error("No runtime abstraction layer installed");return FV}(function($){function Z(J){if(J===void 0)throw Error("No runtime abstraction layer provided");FV=J}$.install=Z})(AV||(AV={}));Jj.default=AV});var P7=S((Qj)=>{Object.defineProperty(Qj,"__esModule",{value:!0});Qj.Emitter=Qj.Event=void 0;var dp=DZ(),Yj;(function($){let Z={dispose(){}};$.None=function(){return Z}})(Yj||(Qj.Event=Yj={}));class Xj{add($,Z=null,J){if(!this._callbacks)this._callbacks=[],this._contexts=[];if(this._callbacks.push($),this._contexts.push(Z),Array.isArray(J))J.push({dispose:()=>this.remove($,Z)})}remove($,Z=null){if(!this._callbacks)return;let J=!1;for(let Y=0,X=this._callbacks.length;Y<X;Y++)if(this._callbacks[Y]===$)if(this._contexts[Y]===Z){this._callbacks.splice(Y,1),this._contexts.splice(Y,1);return}else J=!0;if(J)throw Error("When adding a listener with a context, you should remove it with the same context")}invoke(...$){if(!this._callbacks)return[];let Z=[],J=this._callbacks.slice(0),Y=this._contexts.slice(0);for(let X=0,Q=J.length;X<Q;X++)try{Z.push(J[X].apply(Y[X],$))}catch(G){(0,dp.default)().console.error(G)}return Z}isEmpty(){return!this._callbacks||this._callbacks.length===0}dispose(){this._callbacks=void 0,this._contexts=void 0}}class jQ{constructor($){this._options=$}get event(){if(!this._event)this._event=($,Z,J)=>{if(!this._callbacks)this._callbacks=new Xj;if(this._options&&this._options.onFirstListenerAdd&&this._callbacks.isEmpty())this._options.onFirstListenerAdd(this);this._callbacks.add($,Z);let Y={dispose:()=>{if(!this._callbacks)return;if(this._callbacks.remove($,Z),Y.dispose=jQ._noop,this._options&&this._options.onLastListenerRemove&&this._callbacks.isEmpty())this._options.onLastListenerRemove(this)}};if(Array.isArray(J))J.push(Y);return Y};return this._event}fire($){if(this._callbacks)this._callbacks.invoke.call(this._callbacks,$)}dispose(){if(this._callbacks)this._callbacks.dispose(),this._callbacks=void 0}}Qj.Emitter=jQ;jQ._noop=function(){}});var qQ=S((Kj)=>{Object.defineProperty(Kj,"__esModule",{value:!0});Kj.CancellationTokenSource=Kj.CancellationToken=void 0;var cp=DZ(),ip=R7(),OV=P7(),NQ;(function($){$.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:OV.Event.None}),$.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:OV.Event.None});function Z(J){let Y=J;return Y&&(Y===$.None||Y===$.Cancelled||ip.boolean(Y.isCancellationRequested)&&!!Y.onCancellationRequested)}$.is=Z})(NQ||(Kj.CancellationToken=NQ={}));var np=Object.freeze(function($,Z){let J=(0,cp.default)().timer.setTimeout($.bind(Z),0);return{dispose(){J.dispose()}}});class jV{constructor(){this._isCancelled=!1}cancel(){if(!this._isCancelled){if(this._isCancelled=!0,this._emitter)this._emitter.fire(void 0),this.dispose()}}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){if(this._isCancelled)return np;if(!this._emitter)this._emitter=new OV.Emitter;return this._emitter.event}dispose(){if(this._emitter)this._emitter.dispose(),this._emitter=void 0}}class Wj{get token(){if(!this._token)this._token=new jV;return this._token}cancel(){if(!this._token)this._token=NQ.Cancelled;else this._token.cancel()}dispose(){if(!this._token)this._token=NQ.None;else if(this._token instanceof jV)this._token.dispose()}}Kj.CancellationTokenSource=Wj});var Oj=S((Fj)=>{Object.defineProperty(Fj,"__esModule",{value:!0});Fj.SharedArrayReceiverStrategy=Fj.SharedArraySenderStrategy=void 0;var sp=qQ(),bY;(function($){$.Continue=0,$.Cancelled=1})(bY||(bY={}));class Uj{constructor(){this.buffers=new Map}enableCancellation($){if($.id===null)return;let Z=new SharedArrayBuffer(4),J=new Int32Array(Z,0,1);J[0]=bY.Continue,this.buffers.set($.id,Z),$.$cancellationData=Z}async sendCancellation($,Z){let J=this.buffers.get(Z);if(J===void 0)return;let Y=new Int32Array(J,0,1);Atomics.store(Y,0,bY.Cancelled)}cleanup($){this.buffers.delete($)}dispose(){this.buffers.clear()}}Fj.SharedArraySenderStrategy=Uj;class Hj{constructor($){this.data=new Int32Array($,0,1)}get isCancellationRequested(){return Atomics.load(this.data,0)===bY.Cancelled}get onCancellationRequested(){throw Error("Cancellation over SharedArrayBuffer doesn't support cancellation events")}}class Bj{constructor($){this.token=new Hj($)}cancel(){}dispose(){}}class zj{constructor(){this.kind="request"}createCancellationTokenSource($){let Z=$.$cancellationData;if(Z===void 0)return new sp.CancellationTokenSource;return new Bj(Z)}}Fj.SharedArrayReceiverStrategy=zj});var NV=S((Nj)=>{Object.defineProperty(Nj,"__esModule",{value:!0});Nj.Semaphore=void 0;var ap=DZ();class jj{constructor($=1){if($<=0)throw Error("Capacity must be greater than 0");this._capacity=$,this._active=0,this._waiting=[]}lock($){return new Promise((Z,J)=>{this._waiting.push({thunk:$,resolve:Z,reject:J}),this.runNext()})}get active(){return this._active}runNext(){if(this._waiting.length===0||this._active===this._capacity)return;(0,ap.default)().timer.setImmediate(()=>this.doRunNext())}doRunNext(){if(this._waiting.length===0||this._active===this._capacity)return;let $=this._waiting.shift();if(this._active++,this._active>this._capacity)throw Error("To many thunks active");try{let Z=$.thunk();if(Z instanceof Promise)Z.then((J)=>{this._active--,$.resolve(J),this.runNext()},(J)=>{this._active--,$.reject(J),this.runNext()});else this._active--,$.resolve(Z),this.runNext()}catch(Z){this._active--,$.reject(Z),this.runNext()}}}Nj.Semaphore=jj});var Tj=S((wj)=>{Object.defineProperty(wj,"__esModule",{value:!0});wj.ReadableStreamMessageReader=wj.AbstractMessageReader=wj.MessageReader=void 0;var MV=DZ(),C7=R7(),qV=P7(),tp=NV(),Mj;(function($){function Z(J){let Y=J;return Y&&C7.func(Y.listen)&&C7.func(Y.dispose)&&C7.func(Y.onError)&&C7.func(Y.onClose)&&C7.func(Y.onPartialMessage)}$.is=Z})(Mj||(wj.MessageReader=Mj={}));class wV{constructor(){this.errorEmitter=new qV.Emitter,this.closeEmitter=new qV.Emitter,this.partialMessageEmitter=new qV.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError($){this.errorEmitter.fire(this.asError($))}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}get onPartialMessage(){return this.partialMessageEmitter.event}firePartialMessage($){this.partialMessageEmitter.fire($)}asError($){if($ instanceof Error)return $;else return Error(`Reader received error. Reason: ${C7.string($.message)?$.message:"unknown"}`)}}wj.AbstractMessageReader=wV;var DV;(function($){function Z(J){let Y,X,Q,G=new Map,W,K=new Map;if(J===void 0||typeof J==="string")Y=J??"utf-8";else{if(Y=J.charset??"utf-8",J.contentDecoder!==void 0)Q=J.contentDecoder,G.set(Q.name,Q);if(J.contentDecoders!==void 0)for(let V of J.contentDecoders)G.set(V.name,V);if(J.contentTypeDecoder!==void 0)W=J.contentTypeDecoder,K.set(W.name,W);if(J.contentTypeDecoders!==void 0)for(let V of J.contentTypeDecoders)K.set(V.name,V)}if(W===void 0)W=(0,MV.default)().applicationJson.decoder,K.set(W.name,W);return{charset:Y,contentDecoder:Q,contentDecoders:G,contentTypeDecoder:W,contentTypeDecoders:K}}$.fromOptions=Z})(DV||(DV={}));class Dj extends wV{constructor($,Z){super();this.readable=$,this.options=DV.fromOptions(Z),this.buffer=(0,MV.default)().messageBuffer.create(this.options.charset),this._partialMessageTimeout=1e4,this.nextMessageLength=-1,this.messageToken=0,this.readSemaphore=new tp.Semaphore(1)}set partialMessageTimeout($){this._partialMessageTimeout=$}get partialMessageTimeout(){return this._partialMessageTimeout}listen($){this.nextMessageLength=-1,this.messageToken=0,this.partialMessageTimer=void 0,this.callback=$;let Z=this.readable.onData((J)=>{this.onData(J)});return this.readable.onError((J)=>this.fireError(J)),this.readable.onClose(()=>this.fireClose()),Z}onData($){try{this.buffer.append($);while(!0){if(this.nextMessageLength===-1){let J=this.buffer.tryReadHeaders(!0);if(!J)return;let Y=J.get("content-length");if(!Y){this.fireError(Error(`Header must provide a Content-Length property.
|
|
3
|
+
${JSON.stringify(Object.fromEntries(J))}`));return}let X=parseInt(Y);if(isNaN(X)){this.fireError(Error(`Content-Length value must be a number. Got ${Y}`));return}this.nextMessageLength=X}let Z=this.buffer.tryReadBody(this.nextMessageLength);if(Z===void 0){this.setPartialMessageTimer();return}this.clearPartialMessageTimer(),this.nextMessageLength=-1,this.readSemaphore.lock(async()=>{let J=this.options.contentDecoder!==void 0?await this.options.contentDecoder.decode(Z):Z,Y=await this.options.contentTypeDecoder.decode(J,this.options);this.callback(Y)}).catch((J)=>{this.fireError(J)})}}catch(Z){this.fireError(Z)}}clearPartialMessageTimer(){if(this.partialMessageTimer)this.partialMessageTimer.dispose(),this.partialMessageTimer=void 0}setPartialMessageTimer(){if(this.clearPartialMessageTimer(),this._partialMessageTimeout<=0)return;this.partialMessageTimer=(0,MV.default)().timer.setTimeout(($,Z)=>{if(this.partialMessageTimer=void 0,$===this.messageToken)this.firePartialMessage({messageToken:$,waitingTime:Z}),this.setPartialMessageTimer()},this._partialMessageTimeout,this.messageToken,this._partialMessageTimeout)}}wj.ReadableStreamMessageReader=Dj});var Sj=S((bj)=>{Object.defineProperty(bj,"__esModule",{value:!0});bj.WriteableStreamMessageWriter=bj.AbstractMessageWriter=bj.MessageWriter=void 0;var Rj=DZ(),_Y=R7(),Zc=NV(),Pj=P7(),Jc="Content-Length: ",Cj=`\r
|
|
4
|
+
`,Ij;(function($){function Z(J){let Y=J;return Y&&_Y.func(Y.dispose)&&_Y.func(Y.onClose)&&_Y.func(Y.onError)&&_Y.func(Y.write)}$.is=Z})(Ij||(bj.MessageWriter=Ij={}));class TV{constructor(){this.errorEmitter=new Pj.Emitter,this.closeEmitter=new Pj.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError($,Z,J){this.errorEmitter.fire([this.asError($),Z,J])}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}asError($){if($ instanceof Error)return $;else return Error(`Writer received error. Reason: ${_Y.string($.message)?$.message:"unknown"}`)}}bj.AbstractMessageWriter=TV;var LV;(function($){function Z(J){if(J===void 0||typeof J==="string")return{charset:J??"utf-8",contentTypeEncoder:(0,Rj.default)().applicationJson.encoder};else return{charset:J.charset??"utf-8",contentEncoder:J.contentEncoder,contentTypeEncoder:J.contentTypeEncoder??(0,Rj.default)().applicationJson.encoder}}$.fromOptions=Z})(LV||(LV={}));class Ej extends TV{constructor($,Z){super();this.writable=$,this.options=LV.fromOptions(Z),this.errorCount=0,this.writeSemaphore=new Zc.Semaphore(1),this.writable.onError((J)=>this.fireError(J)),this.writable.onClose(()=>this.fireClose())}async write($){return this.writeSemaphore.lock(async()=>{return this.options.contentTypeEncoder.encode($,this.options).then((J)=>{if(this.options.contentEncoder!==void 0)return this.options.contentEncoder.encode(J);else return J}).then((J)=>{let Y=[];return Y.push(Jc,J.byteLength.toString(),Cj),Y.push(Cj),this.doWrite($,Y,J)},(J)=>{throw this.fireError(J),J})})}async doWrite($,Z,J){try{return await this.writable.write(Z.join(""),"ascii"),this.writable.write(J)}catch(Y){return this.handleError(Y,$),Promise.reject(Y)}}handleError($,Z){this.errorCount++,this.fireError($,Z,this.errorCount)}end(){this.writable.end()}}bj.WriteableStreamMessageWriter=Ej});var yj=S((kj)=>{Object.defineProperty(kj,"__esModule",{value:!0});kj.AbstractMessageBuffer=void 0;var Qc=13,Gc=10,Wc=`\r
|
|
5
|
+
`;class fj{constructor($="utf-8"){this._encoding=$,this._chunks=[],this._totalLength=0}get encoding(){return this._encoding}append($){let Z=typeof $==="string"?this.fromString($,this._encoding):$;this._chunks.push(Z),this._totalLength+=Z.byteLength}tryReadHeaders($=!1){if(this._chunks.length===0)return;let Z=0,J=0,Y=0,X=0;$:while(J<this._chunks.length){let K=this._chunks[J];Y=0;Z:while(Y<K.length){switch(K[Y]){case Qc:switch(Z){case 0:Z=1;break;case 2:Z=3;break;default:Z=0}break;case Gc:switch(Z){case 1:Z=2;break;case 3:Z=4,Y++;break $;default:Z=0}break;default:Z=0}Y++}X+=K.byteLength,J++}if(Z!==4)return;let Q=this._read(X+Y),G=new Map,W=this.toString(Q,"ascii").split(Wc);if(W.length<2)return G;for(let K=0;K<W.length-2;K++){let V=W[K],U=V.indexOf(":");if(U===-1)throw Error(`Message header must separate key and value using ':'
|
|
6
|
+
${V}`);let H=V.substr(0,U),B=V.substr(U+1).trim();G.set($?H.toLowerCase():H,B)}return G}tryReadBody($){if(this._totalLength<$)return;return this._read($)}get numberOfBytes(){return this._totalLength}_read($){if($===0)return this.emptyBuffer();if($>this._totalLength)throw Error("Cannot read so many bytes!");if(this._chunks[0].byteLength===$){let X=this._chunks[0];return this._chunks.shift(),this._totalLength-=$,this.asNative(X)}if(this._chunks[0].byteLength>$){let X=this._chunks[0],Q=this.asNative(X,$);return this._chunks[0]=X.slice($),this._totalLength-=$,Q}let Z=this.allocNative($),J=0,Y=0;while($>0){let X=this._chunks[Y];if(X.byteLength>$){let Q=X.slice(0,$);Z.set(Q,J),J+=$,this._chunks[Y]=X.slice($),this._totalLength-=$,$-=$}else Z.set(X,J),J+=X.byteLength,this._chunks.shift(),this._totalLength-=X.byteLength,$-=X.byteLength}return Z}}kj.AbstractMessageBuffer=fj});var nj=S((lj)=>{Object.defineProperty(lj,"__esModule",{value:!0});lj.createMessageConnection=lj.ConnectionOptions=lj.MessageStrategy=lj.CancellationStrategy=lj.CancellationSenderStrategy=lj.CancellationReceiverStrategy=lj.RequestCancellationReceiverStrategy=lj.IdCancellationReceiverStrategy=lj.ConnectionStrategy=lj.ConnectionError=lj.ConnectionErrors=lj.LogTraceNotification=lj.SetTraceNotification=lj.TraceFormat=lj.TraceValues=lj.Trace=lj.NullLogger=lj.ProgressType=lj.ProgressToken=void 0;var xj=DZ(),$$=R7(),l0=HV(),hj=zV(),SY=P7(),RV=qQ(),vY;(function($){$.type=new l0.NotificationType("$/cancelRequest")})(vY||(vY={}));var PV;(function($){function Z(J){return typeof J==="string"||typeof J==="number"}$.is=Z})(PV||(lj.ProgressToken=PV={}));var fY;(function($){$.type=new l0.NotificationType("$/progress")})(fY||(fY={}));class mj{constructor(){}}lj.ProgressType=mj;var CV;(function($){function Z(J){return $$.func(J)}$.is=Z})(CV||(CV={}));lj.NullLogger=Object.freeze({error:()=>{},warn:()=>{},info:()=>{},log:()=>{}});var R1;(function($){$[$.Off=0]="Off",$[$.Messages=1]="Messages",$[$.Compact=2]="Compact",$[$.Verbose=3]="Verbose"})(R1||(lj.Trace=R1={}));var gj;(function($){$.Off="off",$.Messages="messages",$.Compact="compact",$.Verbose="verbose"})(gj||(lj.TraceValues=gj={}));(function($){function Z(Y){if(!$$.string(Y))return $.Off;switch(Y=Y.toLowerCase(),Y){case"off":return $.Off;case"messages":return $.Messages;case"compact":return $.Compact;case"verbose":return $.Verbose;default:return $.Off}}$.fromString=Z;function J(Y){switch(Y){case $.Off:return"off";case $.Messages:return"messages";case $.Compact:return"compact";case $.Verbose:return"verbose";default:return"off"}}$.toString=J})(R1||(lj.Trace=R1={}));var q8;(function($){$.Text="text",$.JSON="json"})(q8||(lj.TraceFormat=q8={}));(function($){function Z(J){if(!$$.string(J))return $.Text;if(J=J.toLowerCase(),J==="json")return $.JSON;else return $.Text}$.fromString=Z})(q8||(lj.TraceFormat=q8={}));var IV;(function($){$.type=new l0.NotificationType("$/setTrace")})(IV||(lj.SetTraceNotification=IV={}));var MQ;(function($){$.type=new l0.NotificationType("$/logTrace")})(MQ||(lj.LogTraceNotification=MQ={}));var kY;(function($){$[$.Closed=1]="Closed",$[$.Disposed=2]="Disposed",$[$.AlreadyListening=3]="AlreadyListening"})(kY||(lj.ConnectionErrors=kY={}));class I7 extends Error{constructor($,Z){super(Z);this.code=$,Object.setPrototypeOf(this,I7.prototype)}}lj.ConnectionError=I7;var EV;(function($){function Z(J){let Y=J;return Y&&$$.func(Y.cancelUndispatched)}$.is=Z})(EV||(lj.ConnectionStrategy=EV={}));var DQ;(function($){function Z(J){let Y=J;return Y&&(Y.kind===void 0||Y.kind==="id")&&$$.func(Y.createCancellationTokenSource)&&(Y.dispose===void 0||$$.func(Y.dispose))}$.is=Z})(DQ||(lj.IdCancellationReceiverStrategy=DQ={}));var bV;(function($){function Z(J){let Y=J;return Y&&Y.kind==="request"&&$$.func(Y.createCancellationTokenSource)&&(Y.dispose===void 0||$$.func(Y.dispose))}$.is=Z})(bV||(lj.RequestCancellationReceiverStrategy=bV={}));var wQ;(function($){$.Message=Object.freeze({createCancellationTokenSource(J){return new RV.CancellationTokenSource}});function Z(J){return DQ.is(J)||bV.is(J)}$.is=Z})(wQ||(lj.CancellationReceiverStrategy=wQ={}));var LQ;(function($){$.Message=Object.freeze({sendCancellation(J,Y){return J.sendNotification(vY.type,{id:Y})},cleanup(J){}});function Z(J){let Y=J;return Y&&$$.func(Y.sendCancellation)&&$$.func(Y.cleanup)}$.is=Z})(LQ||(lj.CancellationSenderStrategy=LQ={}));var TQ;(function($){$.Message=Object.freeze({receiver:wQ.Message,sender:LQ.Message});function Z(J){let Y=J;return Y&&wQ.is(Y.receiver)&&LQ.is(Y.sender)}$.is=Z})(TQ||(lj.CancellationStrategy=TQ={}));var RQ;(function($){function Z(J){let Y=J;return Y&&$$.func(Y.handleMessage)}$.is=Z})(RQ||(lj.MessageStrategy=RQ={}));var uj;(function($){function Z(J){let Y=J;return Y&&(TQ.is(Y.cancellationStrategy)||EV.is(Y.connectionStrategy)||RQ.is(Y.messageStrategy))}$.is=Z})(uj||(lj.ConnectionOptions=uj={}));var i8;(function($){$[$.New=1]="New",$[$.Listening=2]="Listening",$[$.Closed=3]="Closed",$[$.Disposed=4]="Disposed"})(i8||(i8={}));function Kc($,Z,J,Y){let X=J!==void 0?J:lj.NullLogger,Q=0,G=0,W=0,K="2.0",V=void 0,U=new Map,H=void 0,B=new Map,z=new Map,F,A=new hj.LinkedMap,N=new Map,q=new Set,w=new Map,j=R1.Off,M=q8.Text,I,R=i8.New,L=new SY.Emitter,C=new SY.Emitter,_=new SY.Emitter,E=new SY.Emitter,f=new SY.Emitter,b=Y&&Y.cancellationStrategy?Y.cancellationStrategy:TQ.Message;function k(v){if(v===null)throw Error("Can't send requests with id null since the response can't be correlated.");return"req-"+v.toString()}function u(v){if(v===null)return"res-unknown-"+(++W).toString();else return"res-"+v.toString()}function x(){return"not-"+(++G).toString()}function g(v,i){if(l0.Message.isRequest(i))v.set(k(i.id),i);else if(l0.Message.isResponse(i))v.set(u(i.id),i);else v.set(x(),i)}function c(v){return}function e(){return R===i8.Listening}function G0(){return R===i8.Closed}function Q0(){return R===i8.Disposed}function z0(){if(R===i8.New||R===i8.Listening)R=i8.Closed,C.fire(void 0)}function u0(v){L.fire([v,void 0,void 0])}function m(v){L.fire(v)}$.onClose(z0),$.onError(u0),Z.onClose(z0),Z.onError(m);function l(){if(F||A.size===0)return;F=(0,xj.default)().timer.setImmediate(()=>{F=void 0,h()})}function t(v){if(l0.Message.isRequest(v))p(v);else if(l0.Message.isNotification(v))a(v);else if(l0.Message.isResponse(v))d(v);else s(v)}function h(){if(A.size===0)return;let v=A.shift();try{let i=Y?.messageStrategy;if(RQ.is(i))i.handleMessage(v,t);else t(v)}finally{l()}}let y=(v)=>{try{if(l0.Message.isNotification(v)&&v.method===vY.type.method){let i=v.params.id,n=k(i),Z0=A.get(n);if(l0.Message.isRequest(Z0)){let M0=Y?.connectionStrategy,D1=M0&&M0.cancelUndispatched?M0.cancelUndispatched(Z0,c):c(Z0);if(D1&&(D1.error!==void 0||D1.result!==void 0)){A.delete(n),w.delete(i),D1.id=Z0.id,p0(D1,v.method,Date.now()),Z.write(D1).catch(()=>X.error("Sending response for canceled message failed."));return}}let b0=w.get(i);if(b0!==void 0){b0.cancel(),F0(v);return}else q.add(i)}g(A,v)}finally{l()}};function p(v){if(Q0())return;function i($0,v0,V0){let $1={jsonrpc:K,id:v.id};if($0 instanceof l0.ResponseError)$1.error=$0.toJson();else $1.result=$0===void 0?null:$0;p0($1,v0,V0),Z.write($1).catch(()=>X.error("Sending response failed."))}function n($0,v0,V0){let $1={jsonrpc:K,id:v.id,error:$0.toJson()};p0($1,v0,V0),Z.write($1).catch(()=>X.error("Sending response failed."))}function Z0($0,v0,V0){if($0===void 0)$0=null;let $1={jsonrpc:K,id:v.id,result:$0};p0($1,v0,V0),Z.write($1).catch(()=>X.error("Sending response failed."))}r(v);let b0=U.get(v.method),M0,D1;if(b0)M0=b0.type,D1=b0.handler;let h0=Date.now();if(D1||V){let $0=v.id??String(Date.now()),v0=DQ.is(b.receiver)?b.receiver.createCancellationTokenSource($0):b.receiver.createCancellationTokenSource(v);if(v.id!==null&&q.has(v.id))v0.cancel();if(v.id!==null)w.set($0,v0);try{let V0;if(D1)if(v.params===void 0){if(M0!==void 0&&M0.numberOfParams!==0){n(new l0.ResponseError(l0.ErrorCodes.InvalidParams,`Request ${v.method} defines ${M0.numberOfParams} params but received none.`),v.method,h0);return}V0=D1(v0.token)}else if(Array.isArray(v.params)){if(M0!==void 0&&M0.parameterStructures===l0.ParameterStructures.byName){n(new l0.ResponseError(l0.ErrorCodes.InvalidParams,`Request ${v.method} defines parameters by name but received parameters by position`),v.method,h0);return}V0=D1(...v.params,v0.token)}else{if(M0!==void 0&&M0.parameterStructures===l0.ParameterStructures.byPosition){n(new l0.ResponseError(l0.ErrorCodes.InvalidParams,`Request ${v.method} defines parameters by position but received parameters by name`),v.method,h0);return}V0=D1(v.params,v0.token)}else if(V)V0=V(v.method,v.params,v0.token);let $1=V0;if(!V0)w.delete($0),Z0(V0,v.method,h0);else if($1.then)$1.then((D0)=>{w.delete($0),i(D0,v.method,h0)},(D0)=>{if(w.delete($0),D0 instanceof l0.ResponseError)n(D0,v.method,h0);else if(D0&&$$.string(D0.message))n(new l0.ResponseError(l0.ErrorCodes.InternalError,`Request ${v.method} failed with message: ${D0.message}`),v.method,h0);else n(new l0.ResponseError(l0.ErrorCodes.InternalError,`Request ${v.method} failed unexpectedly without providing any details.`),v.method,h0)});else w.delete($0),i(V0,v.method,h0)}catch(V0){if(w.delete($0),V0 instanceof l0.ResponseError)i(V0,v.method,h0);else if(V0&&$$.string(V0.message))n(new l0.ResponseError(l0.ErrorCodes.InternalError,`Request ${v.method} failed with message: ${V0.message}`),v.method,h0);else n(new l0.ResponseError(l0.ErrorCodes.InternalError,`Request ${v.method} failed unexpectedly without providing any details.`),v.method,h0)}}else n(new l0.ResponseError(l0.ErrorCodes.MethodNotFound,`Unhandled method ${v.method}`),v.method,h0)}function d(v){if(Q0())return;if(v.id===null)if(v.error)X.error(`Received response message without id: Error is:
|
|
7
|
+
${JSON.stringify(v.error,void 0,4)}`);else X.error("Received response message without id. No further error information provided.");else{let i=v.id,n=N.get(i);if(W0(v,n),n!==void 0){N.delete(i);try{if(v.error){let Z0=v.error;n.reject(new l0.ResponseError(Z0.code,Z0.message,Z0.data))}else if(v.result!==void 0)n.resolve(v.result);else throw Error("Should never happen.")}catch(Z0){if(Z0.message)X.error(`Response handler '${n.method}' failed with message: ${Z0.message}`);else X.error(`Response handler '${n.method}' failed unexpectedly.`)}}}}function a(v){if(Q0())return;let i=void 0,n;if(v.method===vY.type.method){let Z0=v.params.id;q.delete(Z0),F0(v);return}else{let Z0=B.get(v.method);if(Z0)n=Z0.handler,i=Z0.type}if(n||H)try{if(F0(v),n)if(v.params===void 0){if(i!==void 0){if(i.numberOfParams!==0&&i.parameterStructures!==l0.ParameterStructures.byName)X.error(`Notification ${v.method} defines ${i.numberOfParams} params but received none.`)}n()}else if(Array.isArray(v.params)){let Z0=v.params;if(v.method===fY.type.method&&Z0.length===2&&PV.is(Z0[0]))n({token:Z0[0],value:Z0[1]});else{if(i!==void 0){if(i.parameterStructures===l0.ParameterStructures.byName)X.error(`Notification ${v.method} defines parameters by name but received parameters by position`);if(i.numberOfParams!==v.params.length)X.error(`Notification ${v.method} defines ${i.numberOfParams} params but received ${Z0.length} arguments`)}n(...Z0)}}else{if(i!==void 0&&i.parameterStructures===l0.ParameterStructures.byPosition)X.error(`Notification ${v.method} defines parameters by position but received parameters by name`);n(v.params)}else if(H)H(v.method,v.params)}catch(Z0){if(Z0.message)X.error(`Notification handler '${v.method}' failed with message: ${Z0.message}`);else X.error(`Notification handler '${v.method}' failed unexpectedly.`)}else _.fire(v)}function s(v){if(!v){X.error("Received empty message.");return}X.error(`Received message which is neither a response nor a notification message:
|
|
8
|
+
${JSON.stringify(v,null,4)}`);let i=v;if($$.string(i.id)||$$.number(i.id)){let n=i.id,Z0=N.get(n);if(Z0)Z0.reject(Error("The received response has neither a result nor an error property."))}}function H0(v){if(v===void 0||v===null)return;switch(j){case R1.Verbose:return JSON.stringify(v,null,4);case R1.Compact:return JSON.stringify(v);default:return}}function O0(v){if(j===R1.Off||!I)return;if(M===q8.Text){let i=void 0;if((j===R1.Verbose||j===R1.Compact)&&v.params)i=`Params: ${H0(v.params)}
|
|
9
|
+
|
|
10
|
+
`;I.log(`Sending request '${v.method} - (${v.id})'.`,i)}else j0("send-request",v)}function C0(v){if(j===R1.Off||!I)return;if(M===q8.Text){let i=void 0;if(j===R1.Verbose||j===R1.Compact)if(v.params)i=`Params: ${H0(v.params)}
|
|
11
|
+
|
|
12
|
+
`;else i=`No parameters provided.
|
|
13
|
+
|
|
14
|
+
`;I.log(`Sending notification '${v.method}'.`,i)}else j0("send-notification",v)}function p0(v,i,n){if(j===R1.Off||!I)return;if(M===q8.Text){let Z0=void 0;if(j===R1.Verbose||j===R1.Compact){if(v.error&&v.error.data)Z0=`Error data: ${H0(v.error.data)}
|
|
15
|
+
|
|
16
|
+
`;else if(v.result)Z0=`Result: ${H0(v.result)}
|
|
17
|
+
|
|
18
|
+
`;else if(v.error===void 0)Z0=`No result returned.
|
|
19
|
+
|
|
20
|
+
`}I.log(`Sending response '${i} - (${v.id})'. Processing request took ${Date.now()-n}ms`,Z0)}else j0("send-response",v)}function r(v){if(j===R1.Off||!I)return;if(M===q8.Text){let i=void 0;if((j===R1.Verbose||j===R1.Compact)&&v.params)i=`Params: ${H0(v.params)}
|
|
21
|
+
|
|
22
|
+
`;I.log(`Received request '${v.method} - (${v.id})'.`,i)}else j0("receive-request",v)}function F0(v){if(j===R1.Off||!I||v.method===MQ.type.method)return;if(M===q8.Text){let i=void 0;if(j===R1.Verbose||j===R1.Compact)if(v.params)i=`Params: ${H0(v.params)}
|
|
23
|
+
|
|
24
|
+
`;else i=`No parameters provided.
|
|
25
|
+
|
|
26
|
+
`;I.log(`Received notification '${v.method}'.`,i)}else j0("receive-notification",v)}function W0(v,i){if(j===R1.Off||!I)return;if(M===q8.Text){let n=void 0;if(j===R1.Verbose||j===R1.Compact){if(v.error&&v.error.data)n=`Error data: ${H0(v.error.data)}
|
|
27
|
+
|
|
28
|
+
`;else if(v.result)n=`Result: ${H0(v.result)}
|
|
29
|
+
|
|
30
|
+
`;else if(v.error===void 0)n=`No result returned.
|
|
31
|
+
|
|
32
|
+
`}if(i){let Z0=v.error?` Request failed: ${v.error.message} (${v.error.code}).`:"";I.log(`Received response '${i.method} - (${v.id})' in ${Date.now()-i.timerStart}ms.${Z0}`,n)}else I.log(`Received response ${v.id} without active response promise.`,n)}else j0("receive-response",v)}function j0(v,i){if(!I||j===R1.Off)return;let n={isLSPMessage:!0,type:v,message:i,timestamp:Date.now()};I.log(n)}function X1(){if(G0())throw new I7(kY.Closed,"Connection is closed.");if(Q0())throw new I7(kY.Disposed,"Connection is disposed.")}function E0(){if(e())throw new I7(kY.AlreadyListening,"Connection is already listening")}function G1(){if(!e())throw Error("Call listen() first.")}function T0(v){if(v===void 0)return null;else return v}function w1(v){if(v===null)return;else return v}function o0(v){return v!==void 0&&v!==null&&!Array.isArray(v)&&typeof v==="object"}function z1(v,i){switch(v){case l0.ParameterStructures.auto:if(o0(i))return w1(i);else return[T0(i)];case l0.ParameterStructures.byName:if(!o0(i))throw Error("Received parameters by name but param is not an object literal.");return w1(i);case l0.ParameterStructures.byPosition:return[T0(i)];default:throw Error(`Unknown parameter structure ${v.toString()}`)}}function t0(v,i){let n,Z0=v.numberOfParams;switch(Z0){case 0:n=void 0;break;case 1:n=z1(v.parameterStructures,i[0]);break;default:n=[];for(let b0=0;b0<i.length&&b0<Z0;b0++)n.push(T0(i[b0]));if(i.length<Z0)for(let b0=i.length;b0<Z0;b0++)n.push(null);break}return n}let U1={sendNotification:(v,...i)=>{X1();let n,Z0;if($$.string(v)){n=v;let M0=i[0],D1=0,h0=l0.ParameterStructures.auto;if(l0.ParameterStructures.is(M0))D1=1,h0=M0;let $0=i.length,v0=$0-D1;switch(v0){case 0:Z0=void 0;break;case 1:Z0=z1(h0,i[D1]);break;default:if(h0===l0.ParameterStructures.byName)throw Error(`Received ${v0} parameters for 'by Name' notification parameter structure.`);Z0=i.slice(D1,$0).map((V0)=>T0(V0));break}}else{let M0=i;n=v.method,Z0=t0(v,M0)}let b0={jsonrpc:K,method:n,params:Z0};return C0(b0),Z.write(b0).catch((M0)=>{throw X.error("Sending notification failed."),M0})},onNotification:(v,i)=>{X1();let n;if($$.func(v))H=v;else if(i)if($$.string(v))n=v,B.set(v,{type:void 0,handler:i});else n=v.method,B.set(v.method,{type:v,handler:i});return{dispose:()=>{if(n!==void 0)B.delete(n);else H=void 0}}},onProgress:(v,i,n)=>{if(z.has(i))throw Error(`Progress handler for token ${i} already registered`);return z.set(i,n),{dispose:()=>{z.delete(i)}}},sendProgress:(v,i,n)=>{return U1.sendNotification(fY.type,{token:i,value:n})},onUnhandledProgress:E.event,sendRequest:(v,...i)=>{X1(),G1();let n,Z0,b0=void 0;if($$.string(v)){n=v;let $0=i[0],v0=i[i.length-1],V0=0,$1=l0.ParameterStructures.auto;if(l0.ParameterStructures.is($0))V0=1,$1=$0;let D0=i.length;if(RV.CancellationToken.is(v0))D0=D0-1,b0=v0;let H1=D0-V0;switch(H1){case 0:Z0=void 0;break;case 1:Z0=z1($1,i[V0]);break;default:if($1===l0.ParameterStructures.byName)throw Error(`Received ${H1} parameters for 'by Name' request parameter structure.`);Z0=i.slice(V0,D0).map((C1)=>T0(C1));break}}else{let $0=i;n=v.method,Z0=t0(v,$0);let v0=v.numberOfParams;b0=RV.CancellationToken.is($0[v0])?$0[v0]:void 0}let M0=Q++,D1;if(b0)D1=b0.onCancellationRequested(()=>{let $0=b.sender.sendCancellation(U1,M0);if($0===void 0)return X.log(`Received no promise from cancellation strategy when cancelling id ${M0}`),Promise.resolve();else return $0.catch(()=>{X.log(`Sending cancellation messages for id ${M0} failed`)})});let h0={jsonrpc:K,id:M0,method:n,params:Z0};if(O0(h0),typeof b.sender.enableCancellation==="function")b.sender.enableCancellation(h0);return new Promise(async($0,v0)=>{let V0=(H1)=>{$0(H1),b.sender.cleanup(M0),D1?.dispose()},$1=(H1)=>{v0(H1),b.sender.cleanup(M0),D1?.dispose()},D0={method:n,timerStart:Date.now(),resolve:V0,reject:$1};try{N.set(M0,D0),await Z.write(h0)}catch(H1){throw N.delete(M0),D0.reject(new l0.ResponseError(l0.ErrorCodes.MessageWriteError,H1.message?H1.message:"Unknown reason")),X.error("Sending request failed."),H1}})},onRequest:(v,i)=>{X1();let n=null;if(CV.is(v))n=void 0,V=v;else if($$.string(v)){if(n=null,i!==void 0)n=v,U.set(v,{handler:i,type:void 0})}else if(i!==void 0)n=v.method,U.set(v.method,{type:v,handler:i});return{dispose:()=>{if(n===null)return;if(n!==void 0)U.delete(n);else V=void 0}}},hasPendingResponse:()=>{return N.size>0},trace:async(v,i,n)=>{let Z0=!1,b0=q8.Text;if(n!==void 0)if($$.boolean(n))Z0=n;else Z0=n.sendNotification||!1,b0=n.traceFormat||q8.Text;if(j=v,M=b0,j===R1.Off)I=void 0;else I=i;if(Z0&&!G0()&&!Q0())await U1.sendNotification(IV.type,{value:R1.toString(v)})},onError:L.event,onClose:C.event,onUnhandledNotification:_.event,onDispose:f.event,end:()=>{Z.end()},dispose:()=>{if(Q0())return;R=i8.Disposed,f.fire(void 0);let v=new l0.ResponseError(l0.ErrorCodes.PendingResponseRejected,"Pending response rejected since connection got disposed");for(let i of N.values())i.reject(v);if(N=new Map,w=new Map,q=new Set,A=new hj.LinkedMap,$$.func(Z.dispose))Z.dispose();if($$.func($.dispose))$.dispose()},listen:()=>{X1(),E0(),R=i8.Listening,$.listen(y)},inspect:()=>{(0,xj.default)().console.log("inspect")}};return U1.onNotification(MQ.type,(v)=>{if(j===R1.Off||!I)return;let i=j===R1.Verbose||j===R1.Compact;I.log(v.message,i?v.verbose:void 0)}),U1.onNotification(fY.type,(v)=>{let i=z.get(v.token);if(i)i(v.value);else E.fire(v)}),U1}lj.createMessageConnection=Kc});var PQ=S((N0)=>{Object.defineProperty(N0,"__esModule",{value:!0});N0.ProgressType=N0.ProgressToken=N0.createMessageConnection=N0.NullLogger=N0.ConnectionOptions=N0.ConnectionStrategy=N0.AbstractMessageBuffer=N0.WriteableStreamMessageWriter=N0.AbstractMessageWriter=N0.MessageWriter=N0.ReadableStreamMessageReader=N0.AbstractMessageReader=N0.MessageReader=N0.SharedArrayReceiverStrategy=N0.SharedArraySenderStrategy=N0.CancellationToken=N0.CancellationTokenSource=N0.Emitter=N0.Event=N0.Disposable=N0.LRUCache=N0.Touch=N0.LinkedMap=N0.ParameterStructures=N0.NotificationType9=N0.NotificationType8=N0.NotificationType7=N0.NotificationType6=N0.NotificationType5=N0.NotificationType4=N0.NotificationType3=N0.NotificationType2=N0.NotificationType1=N0.NotificationType0=N0.NotificationType=N0.ErrorCodes=N0.ResponseError=N0.RequestType9=N0.RequestType8=N0.RequestType7=N0.RequestType6=N0.RequestType5=N0.RequestType4=N0.RequestType3=N0.RequestType2=N0.RequestType1=N0.RequestType0=N0.RequestType=N0.Message=N0.RAL=void 0;N0.MessageStrategy=N0.CancellationStrategy=N0.CancellationSenderStrategy=N0.CancellationReceiverStrategy=N0.ConnectionError=N0.ConnectionErrors=N0.LogTraceNotification=N0.SetTraceNotification=N0.TraceFormat=N0.TraceValues=N0.Trace=void 0;var u1=HV();Object.defineProperty(N0,"Message",{enumerable:!0,get:function(){return u1.Message}});Object.defineProperty(N0,"RequestType",{enumerable:!0,get:function(){return u1.RequestType}});Object.defineProperty(N0,"RequestType0",{enumerable:!0,get:function(){return u1.RequestType0}});Object.defineProperty(N0,"RequestType1",{enumerable:!0,get:function(){return u1.RequestType1}});Object.defineProperty(N0,"RequestType2",{enumerable:!0,get:function(){return u1.RequestType2}});Object.defineProperty(N0,"RequestType3",{enumerable:!0,get:function(){return u1.RequestType3}});Object.defineProperty(N0,"RequestType4",{enumerable:!0,get:function(){return u1.RequestType4}});Object.defineProperty(N0,"RequestType5",{enumerable:!0,get:function(){return u1.RequestType5}});Object.defineProperty(N0,"RequestType6",{enumerable:!0,get:function(){return u1.RequestType6}});Object.defineProperty(N0,"RequestType7",{enumerable:!0,get:function(){return u1.RequestType7}});Object.defineProperty(N0,"RequestType8",{enumerable:!0,get:function(){return u1.RequestType8}});Object.defineProperty(N0,"RequestType9",{enumerable:!0,get:function(){return u1.RequestType9}});Object.defineProperty(N0,"ResponseError",{enumerable:!0,get:function(){return u1.ResponseError}});Object.defineProperty(N0,"ErrorCodes",{enumerable:!0,get:function(){return u1.ErrorCodes}});Object.defineProperty(N0,"NotificationType",{enumerable:!0,get:function(){return u1.NotificationType}});Object.defineProperty(N0,"NotificationType0",{enumerable:!0,get:function(){return u1.NotificationType0}});Object.defineProperty(N0,"NotificationType1",{enumerable:!0,get:function(){return u1.NotificationType1}});Object.defineProperty(N0,"NotificationType2",{enumerable:!0,get:function(){return u1.NotificationType2}});Object.defineProperty(N0,"NotificationType3",{enumerable:!0,get:function(){return u1.NotificationType3}});Object.defineProperty(N0,"NotificationType4",{enumerable:!0,get:function(){return u1.NotificationType4}});Object.defineProperty(N0,"NotificationType5",{enumerable:!0,get:function(){return u1.NotificationType5}});Object.defineProperty(N0,"NotificationType6",{enumerable:!0,get:function(){return u1.NotificationType6}});Object.defineProperty(N0,"NotificationType7",{enumerable:!0,get:function(){return u1.NotificationType7}});Object.defineProperty(N0,"NotificationType8",{enumerable:!0,get:function(){return u1.NotificationType8}});Object.defineProperty(N0,"NotificationType9",{enumerable:!0,get:function(){return u1.NotificationType9}});Object.defineProperty(N0,"ParameterStructures",{enumerable:!0,get:function(){return u1.ParameterStructures}});var _V=zV();Object.defineProperty(N0,"LinkedMap",{enumerable:!0,get:function(){return _V.LinkedMap}});Object.defineProperty(N0,"LRUCache",{enumerable:!0,get:function(){return _V.LRUCache}});Object.defineProperty(N0,"Touch",{enumerable:!0,get:function(){return _V.Touch}});var Tc=Zj();Object.defineProperty(N0,"Disposable",{enumerable:!0,get:function(){return Tc.Disposable}});var oj=P7();Object.defineProperty(N0,"Event",{enumerable:!0,get:function(){return oj.Event}});Object.defineProperty(N0,"Emitter",{enumerable:!0,get:function(){return oj.Emitter}});var sj=qQ();Object.defineProperty(N0,"CancellationTokenSource",{enumerable:!0,get:function(){return sj.CancellationTokenSource}});Object.defineProperty(N0,"CancellationToken",{enumerable:!0,get:function(){return sj.CancellationToken}});var rj=Oj();Object.defineProperty(N0,"SharedArraySenderStrategy",{enumerable:!0,get:function(){return rj.SharedArraySenderStrategy}});Object.defineProperty(N0,"SharedArrayReceiverStrategy",{enumerable:!0,get:function(){return rj.SharedArrayReceiverStrategy}});var SV=Tj();Object.defineProperty(N0,"MessageReader",{enumerable:!0,get:function(){return SV.MessageReader}});Object.defineProperty(N0,"AbstractMessageReader",{enumerable:!0,get:function(){return SV.AbstractMessageReader}});Object.defineProperty(N0,"ReadableStreamMessageReader",{enumerable:!0,get:function(){return SV.ReadableStreamMessageReader}});var fV=Sj();Object.defineProperty(N0,"MessageWriter",{enumerable:!0,get:function(){return fV.MessageWriter}});Object.defineProperty(N0,"AbstractMessageWriter",{enumerable:!0,get:function(){return fV.AbstractMessageWriter}});Object.defineProperty(N0,"WriteableStreamMessageWriter",{enumerable:!0,get:function(){return fV.WriteableStreamMessageWriter}});var Rc=yj();Object.defineProperty(N0,"AbstractMessageBuffer",{enumerable:!0,get:function(){return Rc.AbstractMessageBuffer}});var E$=nj();Object.defineProperty(N0,"ConnectionStrategy",{enumerable:!0,get:function(){return E$.ConnectionStrategy}});Object.defineProperty(N0,"ConnectionOptions",{enumerable:!0,get:function(){return E$.ConnectionOptions}});Object.defineProperty(N0,"NullLogger",{enumerable:!0,get:function(){return E$.NullLogger}});Object.defineProperty(N0,"createMessageConnection",{enumerable:!0,get:function(){return E$.createMessageConnection}});Object.defineProperty(N0,"ProgressToken",{enumerable:!0,get:function(){return E$.ProgressToken}});Object.defineProperty(N0,"ProgressType",{enumerable:!0,get:function(){return E$.ProgressType}});Object.defineProperty(N0,"Trace",{enumerable:!0,get:function(){return E$.Trace}});Object.defineProperty(N0,"TraceValues",{enumerable:!0,get:function(){return E$.TraceValues}});Object.defineProperty(N0,"TraceFormat",{enumerable:!0,get:function(){return E$.TraceFormat}});Object.defineProperty(N0,"SetTraceNotification",{enumerable:!0,get:function(){return E$.SetTraceNotification}});Object.defineProperty(N0,"LogTraceNotification",{enumerable:!0,get:function(){return E$.LogTraceNotification}});Object.defineProperty(N0,"ConnectionErrors",{enumerable:!0,get:function(){return E$.ConnectionErrors}});Object.defineProperty(N0,"ConnectionError",{enumerable:!0,get:function(){return E$.ConnectionError}});Object.defineProperty(N0,"CancellationReceiverStrategy",{enumerable:!0,get:function(){return E$.CancellationReceiverStrategy}});Object.defineProperty(N0,"CancellationSenderStrategy",{enumerable:!0,get:function(){return E$.CancellationSenderStrategy}});Object.defineProperty(N0,"CancellationStrategy",{enumerable:!0,get:function(){return E$.CancellationStrategy}});Object.defineProperty(N0,"MessageStrategy",{enumerable:!0,get:function(){return E$.MessageStrategy}});var Pc=DZ();N0.RAL=Pc.default});var JN=S((ZN)=>{Object.defineProperty(ZN,"__esModule",{value:!0});var aj=J0("util"),u6=PQ();class CQ extends u6.AbstractMessageBuffer{constructor($="utf-8"){super($)}emptyBuffer(){return CQ.emptyBuffer}fromString($,Z){return Buffer.from($,Z)}toString($,Z){if($ instanceof Buffer)return $.toString(Z);else return new aj.TextDecoder(Z).decode($)}asNative($,Z){if(Z===void 0)return $ instanceof Buffer?$:Buffer.from($);else return $ instanceof Buffer?$.slice(0,Z):Buffer.from($,0,Z)}allocNative($){return Buffer.allocUnsafe($)}}CQ.emptyBuffer=Buffer.allocUnsafe(0);class tj{constructor($){this.stream=$}onClose($){return this.stream.on("close",$),u6.Disposable.create(()=>this.stream.off("close",$))}onError($){return this.stream.on("error",$),u6.Disposable.create(()=>this.stream.off("error",$))}onEnd($){return this.stream.on("end",$),u6.Disposable.create(()=>this.stream.off("end",$))}onData($){return this.stream.on("data",$),u6.Disposable.create(()=>this.stream.off("data",$))}}class ej{constructor($){this.stream=$}onClose($){return this.stream.on("close",$),u6.Disposable.create(()=>this.stream.off("close",$))}onError($){return this.stream.on("error",$),u6.Disposable.create(()=>this.stream.off("error",$))}onEnd($){return this.stream.on("end",$),u6.Disposable.create(()=>this.stream.off("end",$))}write($,Z){return new Promise((J,Y)=>{let X=(Q)=>{if(Q===void 0||Q===null)J();else Y(Q)};if(typeof $==="string")this.stream.write($,Z,X);else this.stream.write($,X)})}end(){this.stream.end()}}var $N=Object.freeze({messageBuffer:Object.freeze({create:($)=>new CQ($)}),applicationJson:Object.freeze({encoder:Object.freeze({name:"application/json",encode:($,Z)=>{try{return Promise.resolve(Buffer.from(JSON.stringify($,void 0,0),Z.charset))}catch(J){return Promise.reject(J)}}}),decoder:Object.freeze({name:"application/json",decode:($,Z)=>{try{if($ instanceof Buffer)return Promise.resolve(JSON.parse($.toString(Z.charset)));else return Promise.resolve(JSON.parse(new aj.TextDecoder(Z.charset).decode($)))}catch(J){return Promise.reject(J)}}})}),stream:Object.freeze({asReadableStream:($)=>new tj($),asWritableStream:($)=>new ej($)}),console,timer:Object.freeze({setTimeout($,Z,...J){let Y=setTimeout($,Z,...J);return{dispose:()=>clearTimeout(Y)}},setImmediate($,...Z){let J=setImmediate($,...Z);return{dispose:()=>clearImmediate(J)}},setInterval($,Z,...J){let Y=setInterval($,Z,...J);return{dispose:()=>clearInterval(Y)}}})});function kV(){return $N}(function($){function Z(){u6.RAL.install($N)}$.install=Z})(kV||(kV={}));ZN.default=kV});var VN=S((A1)=>{var _c=A1&&A1.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;var X=Object.getOwnPropertyDescriptor(Z,J);if(!X||("get"in X?!Z.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return Z[J]}};Object.defineProperty($,Y,X)}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),Sc=A1&&A1.__exportStar||function($,Z){for(var J in $)if(J!=="default"&&!Object.prototype.hasOwnProperty.call(Z,J))_c(Z,$,J)};Object.defineProperty(A1,"__esModule",{value:!0});A1.createMessageConnection=A1.createServerSocketTransport=A1.createClientSocketTransport=A1.createServerPipeTransport=A1.createClientPipeTransport=A1.generateRandomPipeName=A1.StreamMessageWriter=A1.StreamMessageReader=A1.SocketMessageWriter=A1.SocketMessageReader=A1.PortMessageWriter=A1.PortMessageReader=A1.IPCMessageWriter=A1.IPCMessageReader=void 0;var E7=JN();E7.default.install();var YN=J0("path"),fc=J0("os"),kc=J0("crypto"),IQ=J0("net"),M8=PQ();Sc(PQ(),A1);class QN extends M8.AbstractMessageReader{constructor($){super();this.process=$;let Z=this.process;Z.on("error",(J)=>this.fireError(J)),Z.on("close",()=>this.fireClose())}listen($){return this.process.on("message",$),M8.Disposable.create(()=>this.process.off("message",$))}}A1.IPCMessageReader=QN;class GN extends M8.AbstractMessageWriter{constructor($){super();this.process=$,this.errorCount=0;let Z=this.process;Z.on("error",(J)=>this.fireError(J)),Z.on("close",()=>this.fireClose)}write($){try{if(typeof this.process.send==="function")this.process.send($,void 0,void 0,(Z)=>{if(Z)this.errorCount++,this.handleError(Z,$);else this.errorCount=0});return Promise.resolve()}catch(Z){return this.handleError(Z,$),Promise.reject(Z)}}handleError($,Z){this.errorCount++,this.fireError($,Z,this.errorCount)}end(){}}A1.IPCMessageWriter=GN;class WN extends M8.AbstractMessageReader{constructor($){super();this.onData=new M8.Emitter,$.on("close",()=>this.fireClose),$.on("error",(Z)=>this.fireError(Z)),$.on("message",(Z)=>{this.onData.fire(Z)})}listen($){return this.onData.event($)}}A1.PortMessageReader=WN;class KN extends M8.AbstractMessageWriter{constructor($){super();this.port=$,this.errorCount=0,$.on("close",()=>this.fireClose()),$.on("error",(Z)=>this.fireError(Z))}write($){try{return this.port.postMessage($),Promise.resolve()}catch(Z){return this.handleError(Z,$),Promise.reject(Z)}}handleError($,Z){this.errorCount++,this.fireError($,Z,this.errorCount)}end(){}}A1.PortMessageWriter=KN;class b7 extends M8.ReadableStreamMessageReader{constructor($,Z="utf-8"){super((0,E7.default)().stream.asReadableStream($),Z)}}A1.SocketMessageReader=b7;class _7 extends M8.WriteableStreamMessageWriter{constructor($,Z){super((0,E7.default)().stream.asWritableStream($),Z);this.socket=$}dispose(){super.dispose(),this.socket.destroy()}}A1.SocketMessageWriter=_7;class vV extends M8.ReadableStreamMessageReader{constructor($,Z){super((0,E7.default)().stream.asReadableStream($),Z)}}A1.StreamMessageReader=vV;class yV extends M8.WriteableStreamMessageWriter{constructor($,Z){super((0,E7.default)().stream.asWritableStream($),Z)}}A1.StreamMessageWriter=yV;var XN=process.env.XDG_RUNTIME_DIR,vc=new Map([["linux",107],["darwin",103]]);function yc(){let $=(0,kc.randomBytes)(21).toString("hex");if(process.platform==="win32")return`\\\\.\\pipe\\vscode-jsonrpc-${$}-sock`;let Z;if(XN)Z=YN.join(XN,`vscode-ipc-${$}.sock`);else Z=YN.join(fc.tmpdir(),`vscode-${$}.sock`);let J=vc.get(process.platform);if(J!==void 0&&Z.length>J)(0,E7.default)().console.warn(`WARNING: IPC handle "${Z}" is longer than ${J} characters.`);return Z}A1.generateRandomPipeName=yc;function xc($,Z="utf-8"){let J,Y=new Promise((X,Q)=>{J=X});return new Promise((X,Q)=>{let G=(0,IQ.createServer)((W)=>{G.close(),J([new b7(W,Z),new _7(W,Z)])});G.on("error",Q),G.listen($,()=>{G.removeListener("error",Q),X({onConnected:()=>{return Y}})})})}A1.createClientPipeTransport=xc;function hc($,Z="utf-8"){let J=(0,IQ.createConnection)($);return[new b7(J,Z),new _7(J,Z)]}A1.createServerPipeTransport=hc;function gc($,Z="utf-8"){let J,Y=new Promise((X,Q)=>{J=X});return new Promise((X,Q)=>{let G=(0,IQ.createServer)((W)=>{G.close(),J([new b7(W,Z),new _7(W,Z)])});G.on("error",Q),G.listen($,"127.0.0.1",()=>{G.removeListener("error",Q),X({onConnected:()=>{return Y}})})})}A1.createClientSocketTransport=gc;function uc($,Z="utf-8"){let J=(0,IQ.createConnection)($,"127.0.0.1");return[new b7(J,Z),new _7(J,Z)]}A1.createServerSocketTransport=uc;function mc($){let Z=$;return Z.read!==void 0&&Z.addListener!==void 0}function lc($){let Z=$;return Z.write!==void 0&&Z.addListener!==void 0}function dc($,Z,J,Y){if(!J)J=M8.NullLogger;let X=mc($)?new vV($):$,Q=lc(Z)?new yV(Z):Z;if(M8.ConnectionStrategy.is(Y))Y={connectionStrategy:Y};return(0,M8.createMessageConnection)(X,Q,J,Y)}A1.createMessageConnection=dc});var cY=S((r20,Sq)=>{var Di=Object.prototype.toString;Sq.exports=function(Z){if(Z===void 0)return"undefined";if(Z===null)return"null";var J=typeof Z;if(J==="boolean")return"boolean";if(J==="string")return"string";if(J==="number")return"number";if(J==="symbol")return"symbol";if(J==="function")return Pi(Z)?"generatorfunction":"function";if(wi(Z))return"array";if(Ei(Z))return"buffer";if(Ii(Z))return"arguments";if(Ti(Z))return"date";if(Li(Z))return"error";if(Ri(Z))return"regexp";switch(_q(Z)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(Ci(Z))return"generator";switch(J=Di.call(Z),J){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return J.slice(8,-1).toLowerCase().replace(/\s/g,"")};function _q($){return typeof $.constructor==="function"?$.constructor.name:null}function wi($){if(Array.isArray)return Array.isArray($);return $ instanceof Array}function Li($){return $ instanceof Error||typeof $.message==="string"&&$.constructor&&typeof $.constructor.stackTraceLimit==="number"}function Ti($){if($ instanceof Date)return!0;return typeof $.toDateString==="function"&&typeof $.getDate==="function"&&typeof $.setDate==="function"}function Ri($){if($ instanceof RegExp)return!0;return typeof $.flags==="string"&&typeof $.ignoreCase==="boolean"&&typeof $.multiline==="boolean"&&typeof $.global==="boolean"}function Pi($,Z){return _q($)==="GeneratorFunction"}function Ci($){return typeof $.throw==="function"&&typeof $.return==="function"&&typeof $.next==="function"}function Ii($){try{if(typeof $.length==="number"&&typeof $.callee==="function")return!0}catch(Z){if(Z.message.indexOf("callee")!==-1)return!0}return!1}function Ei($){if($.constructor&&typeof $.constructor.isBuffer==="function")return $.constructor.isBuffer($);return!1}});var kq=S((a20,fq)=>{/*!
|
|
33
|
+
* is-extendable <https://github.com/jonschlinkert/is-extendable>
|
|
34
|
+
*
|
|
35
|
+
* Copyright (c) 2015, Jon Schlinkert.
|
|
36
|
+
* Licensed under the MIT License.
|
|
37
|
+
*/fq.exports=function(Z){return typeof Z<"u"&&Z!==null&&(typeof Z==="object"||typeof Z==="function")}});var xq=S((t20,yq)=>{var vq=kq();yq.exports=function(Z){if(!vq(Z))Z={};var J=arguments.length;for(var Y=1;Y<J;Y++){var X=arguments[Y];if(vq(X))bi(Z,X)}return Z};function bi($,Z){for(var J in Z)if(_i(Z,J))$[J]=Z[J]}function _i($,Z){return Object.prototype.hasOwnProperty.call($,Z)}});var uq=S((e20,gq)=>{var Si=cY(),fi=xq();gq.exports=function($,Z){if(typeof Z==="function")Z={parse:Z};var J=vi($),Y={section_delimiter:"---",parse:xi},X=fi({},Y,Z),Q=X.section_delimiter,G=J.content.split(/\r?\n/),W=null,K=hq(),V=[],U=[];function H(q){J.content=q,W=[],V=[]}function B(q){if(U.length)K.key=yi(U[0],Q),K.content=q,X.parse(K,W),W.push(K),K=hq(),V=[],U=[]}for(var z=0;z<G.length;z++){var F=G[z],A=U.length,N=F.trim();if(ki(N,Q)){if(N.length===3&&z!==0){if(A===0||A===2){V.push(F);continue}U.push(N),K.data=V.join(`
|
|
38
|
+
`),V=[];continue}if(W===null)H(V.join(`
|
|
39
|
+
`));if(A===2)B(V.join(`
|
|
40
|
+
`));U.push(N);continue}V.push(F)}if(W===null)H(V.join(`
|
|
41
|
+
`));else B(V.join(`
|
|
42
|
+
`));return J.sections=W,J};function ki($,Z){if($.slice(0,Z.length)!==Z)return!1;if($.charAt(Z.length+1)===Z.slice(-1))return!1;return!0}function vi($){if(Si($)!=="object")$={content:$};if(typeof $.content!=="string"&&!hi($.content))throw TypeError("expected a buffer or string");return $.content=$.content.toString(),$.sections=[],$}function yi($,Z){return $?$.slice(Z.length).trim():""}function hq(){return{key:"",data:"",content:""}}function xi($){return $}function hi($){if($&&$.constructor&&typeof $.constructor.isBuffer==="function")return $.constructor.isBuffer($);return!1}});var D5=S((pi,M5)=>{function mq($){return typeof $>"u"||$===null}function gi($){return typeof $==="object"&&$!==null}function ui($){if(Array.isArray($))return $;else if(mq($))return[];return[$]}function mi($,Z){var J,Y,X,Q;if(Z){Q=Object.keys(Z);for(J=0,Y=Q.length;J<Y;J+=1)X=Q[J],$[X]=Z[X]}return $}function li($,Z){var J="",Y;for(Y=0;Y<Z;Y+=1)J+=$;return J}function di($){return $===0&&Number.NEGATIVE_INFINITY===1/$}pi.isNothing=mq;pi.isObject=gi;pi.toArray=ui;pi.repeat=li;pi.isNegativeZero=di;pi.extend=mi});var r7=S(($R0,lq)=>{function iY($,Z){if(Error.call(this),this.name="YAMLException",this.reason=$,this.mark=Z,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else this.stack=Error().stack||""}iY.prototype=Object.create(Error.prototype);iY.prototype.constructor=iY;iY.prototype.toString=function(Z){var J=this.name+": ";if(J+=this.reason||"(unknown reason)",!Z&&this.mark)J+=" "+this.mark.toString();return J};lq.exports=iY});var cq=S((ZR0,pq)=>{var dq=D5();function WU($,Z,J,Y,X){this.name=$,this.buffer=Z,this.position=J,this.line=Y,this.column=X}WU.prototype.getSnippet=function(Z,J){var Y,X,Q,G,W;if(!this.buffer)return null;Z=Z||4,J=J||75,Y="",X=this.position;while(X>0&&`\x00\r
|
|
43
|
+
\x85\u2028\u2029`.indexOf(this.buffer.charAt(X-1))===-1)if(X-=1,this.position-X>J/2-1){Y=" ... ",X+=5;break}Q="",G=this.position;while(G<this.buffer.length&&`\x00\r
|
|
44
|
+
\x85\u2028\u2029`.indexOf(this.buffer.charAt(G))===-1)if(G+=1,G-this.position>J/2-1){Q=" ... ",G-=5;break}return W=this.buffer.slice(X,G),dq.repeat(" ",Z)+Y+W+Q+`
|
|
45
|
+
`+dq.repeat(" ",Z+this.position-X+Y.length)+"^"};WU.prototype.toString=function(Z){var J,Y="";if(this.name)Y+='in "'+this.name+'" ';if(Y+="at line "+(this.line+1)+", column "+(this.column+1),!Z){if(J=this.getSnippet(),J)Y+=`:
|
|
46
|
+
`+J}return Y};pq.exports=WU});var O$=S((JR0,nq)=>{var iq=r7(),ai=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],ti=["scalar","sequence","mapping"];function ei($){var Z={};if($!==null)Object.keys($).forEach(function(J){$[J].forEach(function(Y){Z[String(Y)]=J})});return Z}function $n($,Z){if(Z=Z||{},Object.keys(Z).forEach(function(J){if(ai.indexOf(J)===-1)throw new iq('Unknown option "'+J+'" is met in definition of "'+$+'" YAML type.')}),this.tag=$,this.kind=Z.kind||null,this.resolve=Z.resolve||function(){return!0},this.construct=Z.construct||function(J){return J},this.instanceOf=Z.instanceOf||null,this.predicate=Z.predicate||null,this.represent=Z.represent||null,this.defaultStyle=Z.defaultStyle||null,this.styleAliases=ei(Z.styleAliases||null),ti.indexOf(this.kind)===-1)throw new iq('Unknown kind "'+this.kind+'" is specified for "'+$+'" YAML type.')}nq.exports=$n});var w5=S((YR0,sq)=>{var oq=D5(),lQ=r7(),Zn=O$();function KU($,Z,J){var Y=[];return $.include.forEach(function(X){J=KU(X,Z,J)}),$[Z].forEach(function(X){J.forEach(function(Q,G){if(Q.tag===X.tag&&Q.kind===X.kind)Y.push(G)}),J.push(X)}),J.filter(function(X,Q){return Y.indexOf(Q)===-1})}function Jn(){var $={scalar:{},sequence:{},mapping:{},fallback:{}},Z,J;function Y(X){$[X.kind][X.tag]=$.fallback[X.tag]=X}for(Z=0,J=arguments.length;Z<J;Z+=1)arguments[Z].forEach(Y);return $}function a7($){this.include=$.include||[],this.implicit=$.implicit||[],this.explicit=$.explicit||[],this.implicit.forEach(function(Z){if(Z.loadKind&&Z.loadKind!=="scalar")throw new lQ("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=KU(this,"implicit",[]),this.compiledExplicit=KU(this,"explicit",[]),this.compiledTypeMap=Jn(this.compiledImplicit,this.compiledExplicit)}a7.DEFAULT=null;a7.create=function(){var Z,J;switch(arguments.length){case 1:Z=a7.DEFAULT,J=arguments[0];break;case 2:Z=arguments[0],J=arguments[1];break;default:throw new lQ("Wrong number of arguments for Schema.create function")}if(Z=oq.toArray(Z),J=oq.toArray(J),!Z.every(function(Y){return Y instanceof a7}))throw new lQ("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!J.every(function(Y){return Y instanceof Zn}))throw new lQ("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new a7({include:Z,explicit:J})};sq.exports=a7});var aq=S((XR0,rq)=>{var Yn=O$();rq.exports=new Yn("tag:yaml.org,2002:str",{kind:"scalar",construct:function($){return $!==null?$:""}})});var eq=S((QR0,tq)=>{var Xn=O$();tq.exports=new Xn("tag:yaml.org,2002:seq",{kind:"sequence",construct:function($){return $!==null?$:[]}})});var ZM=S((GR0,$M)=>{var Qn=O$();$M.exports=new Qn("tag:yaml.org,2002:map",{kind:"mapping",construct:function($){return $!==null?$:{}}})});var dQ=S((WR0,JM)=>{var Gn=w5();JM.exports=new Gn({explicit:[aq(),eq(),ZM()]})});var XM=S((KR0,YM)=>{var Wn=O$();function Kn($){if($===null)return!0;var Z=$.length;return Z===1&&$==="~"||Z===4&&($==="null"||$==="Null"||$==="NULL")}function Vn(){return null}function Un($){return $===null}YM.exports=new Wn("tag:yaml.org,2002:null",{kind:"scalar",resolve:Kn,construct:Vn,predicate:Un,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var GM=S((VR0,QM)=>{var Hn=O$();function Bn($){if($===null)return!1;var Z=$.length;return Z===4&&($==="true"||$==="True"||$==="TRUE")||Z===5&&($==="false"||$==="False"||$==="FALSE")}function zn($){return $==="true"||$==="True"||$==="TRUE"}function Fn($){return Object.prototype.toString.call($)==="[object Boolean]"}QM.exports=new Hn("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Bn,construct:zn,predicate:Fn,represent:{lowercase:function($){return $?"true":"false"},uppercase:function($){return $?"TRUE":"FALSE"},camelcase:function($){return $?"True":"False"}},defaultStyle:"lowercase"})});var KM=S((UR0,WM)=>{var An=D5(),On=O$();function jn($){return 48<=$&&$<=57||65<=$&&$<=70||97<=$&&$<=102}function Nn($){return 48<=$&&$<=55}function qn($){return 48<=$&&$<=57}function Mn($){if($===null)return!1;var Z=$.length,J=0,Y=!1,X;if(!Z)return!1;if(X=$[J],X==="-"||X==="+")X=$[++J];if(X==="0"){if(J+1===Z)return!0;if(X=$[++J],X==="b"){J++;for(;J<Z;J++){if(X=$[J],X==="_")continue;if(X!=="0"&&X!=="1")return!1;Y=!0}return Y&&X!=="_"}if(X==="x"){J++;for(;J<Z;J++){if(X=$[J],X==="_")continue;if(!jn($.charCodeAt(J)))return!1;Y=!0}return Y&&X!=="_"}for(;J<Z;J++){if(X=$[J],X==="_")continue;if(!Nn($.charCodeAt(J)))return!1;Y=!0}return Y&&X!=="_"}if(X==="_")return!1;for(;J<Z;J++){if(X=$[J],X==="_")continue;if(X===":")break;if(!qn($.charCodeAt(J)))return!1;Y=!0}if(!Y||X==="_")return!1;if(X!==":")return!0;return/^(:[0-5]?[0-9])+$/.test($.slice(J))}function Dn($){var Z=$,J=1,Y,X,Q=[];if(Z.indexOf("_")!==-1)Z=Z.replace(/_/g,"");if(Y=Z[0],Y==="-"||Y==="+"){if(Y==="-")J=-1;Z=Z.slice(1),Y=Z[0]}if(Z==="0")return 0;if(Y==="0"){if(Z[1]==="b")return J*parseInt(Z.slice(2),2);if(Z[1]==="x")return J*parseInt(Z,16);return J*parseInt(Z,8)}if(Z.indexOf(":")!==-1)return Z.split(":").forEach(function(G){Q.unshift(parseInt(G,10))}),Z=0,X=1,Q.forEach(function(G){Z+=G*X,X*=60}),J*Z;return J*parseInt(Z,10)}function wn($){return Object.prototype.toString.call($)==="[object Number]"&&($%1===0&&!An.isNegativeZero($))}WM.exports=new On("tag:yaml.org,2002:int",{kind:"scalar",resolve:Mn,construct:Dn,predicate:wn,represent:{binary:function($){return $>=0?"0b"+$.toString(2):"-0b"+$.toString(2).slice(1)},octal:function($){return $>=0?"0"+$.toString(8):"-0"+$.toString(8).slice(1)},decimal:function($){return $.toString(10)},hexadecimal:function($){return $>=0?"0x"+$.toString(16).toUpperCase():"-0x"+$.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var HM=S((HR0,UM)=>{var VM=D5(),Ln=O$(),Tn=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Rn($){if($===null)return!1;if(!Tn.test($)||$[$.length-1]==="_")return!1;return!0}function Pn($){var Z,J,Y,X;if(Z=$.replace(/_/g,"").toLowerCase(),J=Z[0]==="-"?-1:1,X=[],"+-".indexOf(Z[0])>=0)Z=Z.slice(1);if(Z===".inf")return J===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;else if(Z===".nan")return NaN;else if(Z.indexOf(":")>=0)return Z.split(":").forEach(function(Q){X.unshift(parseFloat(Q,10))}),Z=0,Y=1,X.forEach(function(Q){Z+=Q*Y,Y*=60}),J*Z;return J*parseFloat(Z,10)}var Cn=/^[-+]?[0-9]+e/;function In($,Z){var J;if(isNaN($))switch(Z){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===$)switch(Z){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===$)switch(Z){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(VM.isNegativeZero($))return"-0.0";return J=$.toString(10),Cn.test(J)?J.replace("e",".e"):J}function En($){return Object.prototype.toString.call($)==="[object Number]"&&($%1!==0||VM.isNegativeZero($))}UM.exports=new Ln("tag:yaml.org,2002:float",{kind:"scalar",resolve:Rn,construct:Pn,predicate:En,represent:In,defaultStyle:"lowercase"})});var VU=S((BR0,BM)=>{var bn=w5();BM.exports=new bn({include:[dQ()],implicit:[XM(),GM(),KM(),HM()]})});var UU=S((zR0,zM)=>{var _n=w5();zM.exports=new _n({include:[VU()]})});var jM=S((FR0,OM)=>{var Sn=O$(),FM=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),AM=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function fn($){if($===null)return!1;if(FM.exec($)!==null)return!0;if(AM.exec($)!==null)return!0;return!1}function kn($){var Z,J,Y,X,Q,G,W,K=0,V=null,U,H,B;if(Z=FM.exec($),Z===null)Z=AM.exec($);if(Z===null)throw Error("Date resolve error");if(J=+Z[1],Y=+Z[2]-1,X=+Z[3],!Z[4])return new Date(Date.UTC(J,Y,X));if(Q=+Z[4],G=+Z[5],W=+Z[6],Z[7]){K=Z[7].slice(0,3);while(K.length<3)K+="0";K=+K}if(Z[9]){if(U=+Z[10],H=+(Z[11]||0),V=(U*60+H)*60000,Z[9]==="-")V=-V}if(B=new Date(Date.UTC(J,Y,X,Q,G,W,K)),V)B.setTime(B.getTime()-V);return B}function vn($){return $.toISOString()}OM.exports=new Sn("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:fn,construct:kn,instanceOf:Date,represent:vn})});var qM=S((AR0,NM)=>{var yn=O$();function xn($){return $==="<<"||$===null}NM.exports=new yn("tag:yaml.org,2002:merge",{kind:"scalar",resolve:xn})});var DM=S((OR0,MM)=>{var L5;try{HU=J0,L5=HU("buffer").Buffer}catch($){}var HU,hn=O$(),BU=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
47
|
+
\r`;function gn($){if($===null)return!1;var Z,J,Y=0,X=$.length,Q=BU;for(J=0;J<X;J++){if(Z=Q.indexOf($.charAt(J)),Z>64)continue;if(Z<0)return!1;Y+=6}return Y%8===0}function un($){var Z,J,Y=$.replace(/[\r\n=]/g,""),X=Y.length,Q=BU,G=0,W=[];for(Z=0;Z<X;Z++){if(Z%4===0&&Z)W.push(G>>16&255),W.push(G>>8&255),W.push(G&255);G=G<<6|Q.indexOf(Y.charAt(Z))}if(J=X%4*6,J===0)W.push(G>>16&255),W.push(G>>8&255),W.push(G&255);else if(J===18)W.push(G>>10&255),W.push(G>>2&255);else if(J===12)W.push(G>>4&255);if(L5)return L5.from?L5.from(W):new L5(W);return W}function mn($){var Z="",J=0,Y,X,Q=$.length,G=BU;for(Y=0;Y<Q;Y++){if(Y%3===0&&Y)Z+=G[J>>18&63],Z+=G[J>>12&63],Z+=G[J>>6&63],Z+=G[J&63];J=(J<<8)+$[Y]}if(X=Q%3,X===0)Z+=G[J>>18&63],Z+=G[J>>12&63],Z+=G[J>>6&63],Z+=G[J&63];else if(X===2)Z+=G[J>>10&63],Z+=G[J>>4&63],Z+=G[J<<2&63],Z+=G[64];else if(X===1)Z+=G[J>>2&63],Z+=G[J<<4&63],Z+=G[64],Z+=G[64];return Z}function ln($){return L5&&L5.isBuffer($)}MM.exports=new hn("tag:yaml.org,2002:binary",{kind:"scalar",resolve:gn,construct:un,predicate:ln,represent:mn})});var LM=S((NR0,wM)=>{var dn=O$(),pn=Object.prototype.hasOwnProperty,cn=Object.prototype.toString;function nn($){if($===null)return!0;var Z=[],J,Y,X,Q,G,W=$;for(J=0,Y=W.length;J<Y;J+=1){if(X=W[J],G=!1,cn.call(X)!=="[object Object]")return!1;for(Q in X)if(pn.call(X,Q))if(!G)G=!0;else return!1;if(!G)return!1;if(Z.indexOf(Q)===-1)Z.push(Q);else return!1}return!0}function on($){return $!==null?$:[]}wM.exports=new dn("tag:yaml.org,2002:omap",{kind:"sequence",resolve:nn,construct:on})});var RM=S((qR0,TM)=>{var sn=O$(),rn=Object.prototype.toString;function an($){if($===null)return!0;var Z,J,Y,X,Q,G=$;Q=Array(G.length);for(Z=0,J=G.length;Z<J;Z+=1){if(Y=G[Z],rn.call(Y)!=="[object Object]")return!1;if(X=Object.keys(Y),X.length!==1)return!1;Q[Z]=[X[0],Y[X[0]]]}return!0}function tn($){if($===null)return[];var Z,J,Y,X,Q,G=$;Q=Array(G.length);for(Z=0,J=G.length;Z<J;Z+=1)Y=G[Z],X=Object.keys(Y),Q[Z]=[X[0],Y[X[0]]];return Q}TM.exports=new sn("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:an,construct:tn})});var CM=S((MR0,PM)=>{var en=O$(),$o=Object.prototype.hasOwnProperty;function Zo($){if($===null)return!0;var Z,J=$;for(Z in J)if($o.call(J,Z)){if(J[Z]!==null)return!1}return!0}function Jo($){return $!==null?$:{}}PM.exports=new en("tag:yaml.org,2002:set",{kind:"mapping",resolve:Zo,construct:Jo})});var t7=S((DR0,IM)=>{var Yo=w5();IM.exports=new Yo({include:[UU()],implicit:[jM(),qM()],explicit:[DM(),LM(),RM(),CM()]})});var bM=S((wR0,EM)=>{var Xo=O$();function Qo(){return!0}function Go(){return}function Wo(){return""}function Ko($){return typeof $>"u"}EM.exports=new Xo("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:Qo,construct:Go,predicate:Ko,represent:Wo})});var SM=S((LR0,_M)=>{var Vo=O$();function Uo($){if($===null)return!1;if($.length===0)return!1;var Z=$,J=/\/([gim]*)$/.exec($),Y="";if(Z[0]==="/"){if(J)Y=J[1];if(Y.length>3)return!1;if(Z[Z.length-Y.length-1]!=="/")return!1}return!0}function Ho($){var Z=$,J=/\/([gim]*)$/.exec($),Y="";if(Z[0]==="/"){if(J)Y=J[1];Z=Z.slice(1,Z.length-Y.length-1)}return new RegExp(Z,Y)}function Bo($){var Z="/"+$.source+"/";if($.global)Z+="g";if($.multiline)Z+="m";if($.ignoreCase)Z+="i";return Z}function zo($){return Object.prototype.toString.call($)==="[object RegExp]"}_M.exports=new Vo("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:Uo,construct:Ho,predicate:zo,represent:Bo})});var kM=S((TR0,fM)=>{var pQ;try{zU=J0,pQ=zU("esprima")}catch($){if(typeof window<"u")pQ=window.esprima}var zU,Fo=O$();function Ao($){if($===null)return!1;try{var Z="("+$+")",J=pQ.parse(Z,{range:!0});if(J.type!=="Program"||J.body.length!==1||J.body[0].type!=="ExpressionStatement"||J.body[0].expression.type!=="ArrowFunctionExpression"&&J.body[0].expression.type!=="FunctionExpression")return!1;return!0}catch(Y){return!1}}function Oo($){var Z="("+$+")",J=pQ.parse(Z,{range:!0}),Y=[],X;if(J.type!=="Program"||J.body.length!==1||J.body[0].type!=="ExpressionStatement"||J.body[0].expression.type!=="ArrowFunctionExpression"&&J.body[0].expression.type!=="FunctionExpression")throw Error("Failed to resolve function");if(J.body[0].expression.params.forEach(function(Q){Y.push(Q.name)}),X=J.body[0].expression.body.range,J.body[0].expression.body.type==="BlockStatement")return Function(Y,Z.slice(X[0]+1,X[1]-1));return Function(Y,"return "+Z.slice(X[0],X[1]))}function jo($){return $.toString()}function No($){return Object.prototype.toString.call($)==="[object Function]"}fM.exports=new Fo("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:Ao,construct:Oo,predicate:No,represent:jo})});var nY=S((PR0,yM)=>{var vM=w5();yM.exports=vM.DEFAULT=new vM({include:[t7()],explicit:[bM(),SM(),kM()]})});var JD=S((lo,oY)=>{var d6=D5(),dM=r7(),qo=cq(),pM=t7(),Mo=nY(),bZ=Object.prototype.hasOwnProperty,cQ=1,cM=2,iM=3,iQ=4,FU=1,Do=2,xM=3,wo=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Lo=/[\x85\u2028\u2029]/,To=/[,\[\]\{\}]/,nM=/^(?:!|!!|![a-z\-]+!)$/i,oM=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function hM($){return Object.prototype.toString.call($)}function w6($){return $===10||$===13}function T5($){return $===9||$===32}function X8($){return $===9||$===32||$===10||$===13}function e7($){return $===44||$===91||$===93||$===123||$===125}function Ro($){var Z;if(48<=$&&$<=57)return $-48;if(Z=$|32,97<=Z&&Z<=102)return Z-97+10;return-1}function Po($){if($===120)return 2;if($===117)return 4;if($===85)return 8;return 0}function Co($){if(48<=$&&$<=57)return $-48;return-1}function gM($){return $===48?"\x00":$===97?"\x07":$===98?"\b":$===116?"\t":$===9?"\t":$===110?`
|
|
48
|
+
`:$===118?"\v":$===102?"\f":$===114?"\r":$===101?"\x1B":$===32?" ":$===34?'"':$===47?"/":$===92?"\\":$===78?"\x85":$===95?"\xA0":$===76?"\u2028":$===80?"\u2029":""}function Io($){if($<=65535)return String.fromCharCode($);return String.fromCharCode(($-65536>>10)+55296,($-65536&1023)+56320)}function sM($,Z,J){if(Z==="__proto__")Object.defineProperty($,Z,{configurable:!0,enumerable:!0,writable:!0,value:J});else $[Z]=J}var rM=Array(256),aM=Array(256);for(IZ=0;IZ<256;IZ++)rM[IZ]=gM(IZ)?1:0,aM[IZ]=gM(IZ);var IZ;function Eo($,Z){this.input=$,this.filename=Z.filename||null,this.schema=Z.schema||Mo,this.onWarning=Z.onWarning||null,this.legacy=Z.legacy||!1,this.json=Z.json||!1,this.listener=Z.listener||null,this.maxTotalMergeKeys=typeof Z.maxTotalMergeKeys==="number"?Z.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=$.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.totalMergeKeys=0,this.documents=[]}function tM($,Z){return new dM(Z,new qo($.filename,$.input,$.position,$.line,$.position-$.lineStart))}function f0($,Z){throw tM($,Z)}function nQ($,Z){if($.onWarning)$.onWarning.call(null,tM($,Z))}var uM={YAML:function(Z,J,Y){var X,Q,G;if(Z.version!==null)f0(Z,"duplication of %YAML directive");if(Y.length!==1)f0(Z,"YAML directive accepts exactly one argument");if(X=/^([0-9]+)\.([0-9]+)$/.exec(Y[0]),X===null)f0(Z,"ill-formed argument of the YAML directive");if(Q=parseInt(X[1],10),G=parseInt(X[2],10),Q!==1)f0(Z,"unacceptable YAML version of the document");if(Z.version=Y[0],Z.checkLineBreaks=G<2,G!==1&&G!==2)nQ(Z,"unsupported YAML version of the document")},TAG:function(Z,J,Y){var X,Q;if(Y.length!==2)f0(Z,"TAG directive accepts exactly two arguments");if(X=Y[0],Q=Y[1],!nM.test(X))f0(Z,"ill-formed tag handle (first argument) of the TAG directive");if(bZ.call(Z.tagMap,X))f0(Z,'there is a previously declared suffix for "'+X+'" tag handle');if(!oM.test(Q))f0(Z,"ill-formed tag prefix (second argument) of the TAG directive");Z.tagMap[X]=Q}};function EZ($,Z,J,Y){var X,Q,G,W;if(Z<J){if(W=$.input.slice(Z,J),Y){for(X=0,Q=W.length;X<Q;X+=1)if(G=W.charCodeAt(X),!(G===9||32<=G&&G<=1114111))f0($,"expected valid JSON character")}else if(wo.test(W))f0($,"the stream contains non-printable characters");$.result+=W}}function mM($,Z,J,Y){var X,Q,G,W;if(!d6.isObject(J))f0($,"cannot merge mappings; the provided source object is unacceptable");X=Object.keys(J);for(G=0,W=X.length;G<W;G+=1){if(Q=X[G],$.maxTotalMergeKeys!==-1&&++$.totalMergeKeys>$.maxTotalMergeKeys)f0($,"merge keys exceeded maxTotalMergeKeys ("+$.maxTotalMergeKeys+")");if(!bZ.call(Z,Q))sM(Z,Q,J[Q]),Y[Q]=!0}}function $J($,Z,J,Y,X,Q,G,W){var K,V;if(Array.isArray(X)){X=Array.prototype.slice.call(X);for(K=0,V=X.length;K<V;K+=1){if(Array.isArray(X[K]))f0($,"nested arrays are not supported inside keys");if(typeof X==="object"&&hM(X[K])==="[object Object]")X[K]="[object Object]"}}if(typeof X==="object"&&hM(X)==="[object Object]")X="[object Object]";if(X=String(X),Z===null)Z={};if(Y==="tag:yaml.org,2002:merge")if(Array.isArray(Q))for(K=0,V=Q.length;K<V;K+=1)mM($,Z,Q[K],J);else mM($,Z,Q,J);else{if(!$.json&&!bZ.call(J,X)&&bZ.call(Z,X))$.line=G||$.line,$.position=W||$.position,f0($,"duplicated mapping key");sM(Z,X,Q),delete J[X]}return Z}function AU($){var Z=$.input.charCodeAt($.position);if(Z===10)$.position++;else if(Z===13){if($.position++,$.input.charCodeAt($.position)===10)$.position++}else f0($,"a line break is expected");$.line+=1,$.lineStart=$.position}function H$($,Z,J){var Y=0,X=$.input.charCodeAt($.position);while(X!==0){while(T5(X))X=$.input.charCodeAt(++$.position);if(Z&&X===35)do X=$.input.charCodeAt(++$.position);while(X!==10&&X!==13&&X!==0);if(w6(X)){AU($),X=$.input.charCodeAt($.position),Y++,$.lineIndent=0;while(X===32)$.lineIndent++,X=$.input.charCodeAt(++$.position)}else break}if(J!==-1&&Y!==0&&$.lineIndent<J)nQ($,"deficient indentation");return Y}function oQ($){var Z=$.position,J;if(J=$.input.charCodeAt(Z),(J===45||J===46)&&J===$.input.charCodeAt(Z+1)&&J===$.input.charCodeAt(Z+2)){if(Z+=3,J=$.input.charCodeAt(Z),J===0||X8(J))return!0}return!1}function OU($,Z){if(Z===1)$.result+=" ";else if(Z>1)$.result+=d6.repeat(`
|
|
49
|
+
`,Z-1)}function bo($,Z,J){var Y,X,Q,G,W,K,V,U,H=$.kind,B=$.result,z;if(z=$.input.charCodeAt($.position),X8(z)||e7(z)||z===35||z===38||z===42||z===33||z===124||z===62||z===39||z===34||z===37||z===64||z===96)return!1;if(z===63||z===45){if(X=$.input.charCodeAt($.position+1),X8(X)||J&&e7(X))return!1}$.kind="scalar",$.result="",Q=G=$.position,W=!1;while(z!==0){if(z===58){if(X=$.input.charCodeAt($.position+1),X8(X)||J&&e7(X))break}else if(z===35){if(Y=$.input.charCodeAt($.position-1),X8(Y))break}else if($.position===$.lineStart&&oQ($)||J&&e7(z))break;else if(w6(z))if(K=$.line,V=$.lineStart,U=$.lineIndent,H$($,!1,-1),$.lineIndent>=Z){W=!0,z=$.input.charCodeAt($.position);continue}else{$.position=G,$.line=K,$.lineStart=V,$.lineIndent=U;break}if(W)EZ($,Q,G,!1),OU($,$.line-K),Q=G=$.position,W=!1;if(!T5(z))G=$.position+1;z=$.input.charCodeAt(++$.position)}if(EZ($,Q,G,!1),$.result)return!0;return $.kind=H,$.result=B,!1}function _o($,Z){var J,Y,X;if(J=$.input.charCodeAt($.position),J!==39)return!1;$.kind="scalar",$.result="",$.position++,Y=X=$.position;while((J=$.input.charCodeAt($.position))!==0)if(J===39)if(EZ($,Y,$.position,!0),J=$.input.charCodeAt(++$.position),J===39)Y=$.position,$.position++,X=$.position;else return!0;else if(w6(J))EZ($,Y,X,!0),OU($,H$($,!1,Z)),Y=X=$.position;else if($.position===$.lineStart&&oQ($))f0($,"unexpected end of the document within a single quoted scalar");else $.position++,X=$.position;f0($,"unexpected end of the stream within a single quoted scalar")}function So($,Z){var J,Y,X,Q,G,W;if(W=$.input.charCodeAt($.position),W!==34)return!1;$.kind="scalar",$.result="",$.position++,J=Y=$.position;while((W=$.input.charCodeAt($.position))!==0)if(W===34)return EZ($,J,$.position,!0),$.position++,!0;else if(W===92){if(EZ($,J,$.position,!0),W=$.input.charCodeAt(++$.position),w6(W))H$($,!1,Z);else if(W<256&&rM[W])$.result+=aM[W],$.position++;else if((G=Po(W))>0){X=G,Q=0;for(;X>0;X--)if(W=$.input.charCodeAt(++$.position),(G=Ro(W))>=0)Q=(Q<<4)+G;else f0($,"expected hexadecimal character");$.result+=Io(Q),$.position++}else f0($,"unknown escape sequence");J=Y=$.position}else if(w6(W))EZ($,J,Y,!0),OU($,H$($,!1,Z)),J=Y=$.position;else if($.position===$.lineStart&&oQ($))f0($,"unexpected end of the document within a double quoted scalar");else $.position++,Y=$.position;f0($,"unexpected end of the stream within a double quoted scalar")}function fo($,Z){var J=!0,Y,X=$.tag,Q,G=$.anchor,W,K,V,U,H,B={},z,F,A,N;if(N=$.input.charCodeAt($.position),N===91)K=93,H=!1,Q=[];else if(N===123)K=125,H=!0,Q={};else return!1;if($.anchor!==null)$.anchorMap[$.anchor]=Q;N=$.input.charCodeAt(++$.position);while(N!==0){if(H$($,!0,Z),N=$.input.charCodeAt($.position),N===K)return $.position++,$.tag=X,$.anchor=G,$.kind=H?"mapping":"sequence",$.result=Q,!0;else if(!J)f0($,"missed comma between flow collection entries");if(F=z=A=null,V=U=!1,N===63){if(W=$.input.charCodeAt($.position+1),X8(W))V=U=!0,$.position++,H$($,!0,Z)}if(Y=$.line,ZJ($,Z,cQ,!1,!0),F=$.tag,z=$.result,H$($,!0,Z),N=$.input.charCodeAt($.position),(U||$.line===Y)&&N===58)V=!0,N=$.input.charCodeAt(++$.position),H$($,!0,Z),ZJ($,Z,cQ,!1,!0),A=$.result;if(H)$J($,Q,B,F,z,A);else if(V)Q.push($J($,null,B,F,z,A));else Q.push(z);if(H$($,!0,Z),N=$.input.charCodeAt($.position),N===44)J=!0,N=$.input.charCodeAt(++$.position);else J=!1}f0($,"unexpected end of the stream within a flow collection")}function ko($,Z){var J,Y,X=FU,Q=!1,G=!1,W=Z,K=0,V=!1,U,H;if(H=$.input.charCodeAt($.position),H===124)Y=!1;else if(H===62)Y=!0;else return!1;$.kind="scalar",$.result="";while(H!==0)if(H=$.input.charCodeAt(++$.position),H===43||H===45)if(FU===X)X=H===43?xM:Do;else f0($,"repeat of a chomping mode identifier");else if((U=Co(H))>=0)if(U===0)f0($,"bad explicit indentation width of a block scalar; it cannot be less than one");else if(!G)W=Z+U-1,G=!0;else f0($,"repeat of an indentation width identifier");else break;if(T5(H)){do H=$.input.charCodeAt(++$.position);while(T5(H));if(H===35)do H=$.input.charCodeAt(++$.position);while(!w6(H)&&H!==0)}while(H!==0){AU($),$.lineIndent=0,H=$.input.charCodeAt($.position);while((!G||$.lineIndent<W)&&H===32)$.lineIndent++,H=$.input.charCodeAt(++$.position);if(!G&&$.lineIndent>W)W=$.lineIndent;if(w6(H)){K++;continue}if($.lineIndent<W){if(X===xM)$.result+=d6.repeat(`
|
|
50
|
+
`,Q?1+K:K);else if(X===FU){if(Q)$.result+=`
|
|
51
|
+
`}break}if(Y)if(T5(H))V=!0,$.result+=d6.repeat(`
|
|
52
|
+
`,Q?1+K:K);else if(V)V=!1,$.result+=d6.repeat(`
|
|
53
|
+
`,K+1);else if(K===0){if(Q)$.result+=" "}else $.result+=d6.repeat(`
|
|
54
|
+
`,K);else $.result+=d6.repeat(`
|
|
55
|
+
`,Q?1+K:K);Q=!0,G=!0,K=0,J=$.position;while(!w6(H)&&H!==0)H=$.input.charCodeAt(++$.position);EZ($,J,$.position,!1)}return!0}function lM($,Z){var J,Y=$.tag,X=$.anchor,Q=[],G,W=!1,K;if($.anchor!==null)$.anchorMap[$.anchor]=Q;K=$.input.charCodeAt($.position);while(K!==0){if(K!==45)break;if(G=$.input.charCodeAt($.position+1),!X8(G))break;if(W=!0,$.position++,H$($,!0,-1)){if($.lineIndent<=Z){Q.push(null),K=$.input.charCodeAt($.position);continue}}if(J=$.line,ZJ($,Z,iM,!1,!0),Q.push($.result),H$($,!0,-1),K=$.input.charCodeAt($.position),($.line===J||$.lineIndent>Z)&&K!==0)f0($,"bad indentation of a sequence entry");else if($.lineIndent<Z)break}if(W)return $.tag=Y,$.anchor=X,$.kind="sequence",$.result=Q,!0;return!1}function vo($,Z,J){var Y,X,Q,G,W=$.tag,K=$.anchor,V={},U={},H=null,B=null,z=null,F=!1,A=!1,N;if($.anchor!==null)$.anchorMap[$.anchor]=V;N=$.input.charCodeAt($.position);while(N!==0){if(Y=$.input.charCodeAt($.position+1),Q=$.line,G=$.position,(N===63||N===58)&&X8(Y)){if(N===63){if(F)$J($,V,U,H,B,null),H=B=z=null;A=!0,F=!0,X=!0}else if(F)F=!1,X=!0;else f0($,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");$.position+=1,N=Y}else if(ZJ($,J,cM,!1,!0))if($.line===Q){N=$.input.charCodeAt($.position);while(T5(N))N=$.input.charCodeAt(++$.position);if(N===58){if(N=$.input.charCodeAt(++$.position),!X8(N))f0($,"a whitespace character is expected after the key-value separator within a block mapping");if(F)$J($,V,U,H,B,null),H=B=z=null;A=!0,F=!1,X=!1,H=$.tag,B=$.result}else if(A)f0($,"can not read an implicit mapping pair; a colon is missed");else return $.tag=W,$.anchor=K,!0}else if(A)f0($,"can not read a block mapping entry; a multiline key may not be an implicit key");else return $.tag=W,$.anchor=K,!0;else break;if($.line===Q||$.lineIndent>Z){if(ZJ($,Z,iQ,!0,X))if(F)B=$.result;else z=$.result;if(!F)$J($,V,U,H,B,z,Q,G),H=B=z=null;H$($,!0,-1),N=$.input.charCodeAt($.position)}if($.lineIndent>Z&&N!==0)f0($,"bad indentation of a mapping entry");else if($.lineIndent<Z)break}if(F)$J($,V,U,H,B,null);if(A)$.tag=W,$.anchor=K,$.kind="mapping",$.result=V;return A}function yo($){var Z,J=!1,Y=!1,X,Q,G;if(G=$.input.charCodeAt($.position),G!==33)return!1;if($.tag!==null)f0($,"duplication of a tag property");if(G=$.input.charCodeAt(++$.position),G===60)J=!0,G=$.input.charCodeAt(++$.position);else if(G===33)Y=!0,X="!!",G=$.input.charCodeAt(++$.position);else X="!";if(Z=$.position,J){do G=$.input.charCodeAt(++$.position);while(G!==0&&G!==62);if($.position<$.length)Q=$.input.slice(Z,$.position),G=$.input.charCodeAt(++$.position);else f0($,"unexpected end of the stream within a verbatim tag")}else{while(G!==0&&!X8(G)){if(G===33)if(!Y){if(X=$.input.slice(Z-1,$.position+1),!nM.test(X))f0($,"named tag handle cannot contain such characters");Y=!0,Z=$.position+1}else f0($,"tag suffix cannot contain exclamation marks");G=$.input.charCodeAt(++$.position)}if(Q=$.input.slice(Z,$.position),To.test(Q))f0($,"tag suffix cannot contain flow indicator characters")}if(Q&&!oM.test(Q))f0($,"tag name cannot contain such characters: "+Q);if(J)$.tag=Q;else if(bZ.call($.tagMap,X))$.tag=$.tagMap[X]+Q;else if(X==="!")$.tag="!"+Q;else if(X==="!!")$.tag="tag:yaml.org,2002:"+Q;else f0($,'undeclared tag handle "'+X+'"');return!0}function xo($){var Z,J;if(J=$.input.charCodeAt($.position),J!==38)return!1;if($.anchor!==null)f0($,"duplication of an anchor property");J=$.input.charCodeAt(++$.position),Z=$.position;while(J!==0&&!X8(J)&&!e7(J))J=$.input.charCodeAt(++$.position);if($.position===Z)f0($,"name of an anchor node must contain at least one character");return $.anchor=$.input.slice(Z,$.position),!0}function ho($){var Z,J,Y;if(Y=$.input.charCodeAt($.position),Y!==42)return!1;Y=$.input.charCodeAt(++$.position),Z=$.position;while(Y!==0&&!X8(Y)&&!e7(Y))Y=$.input.charCodeAt(++$.position);if($.position===Z)f0($,"name of an alias node must contain at least one character");if(J=$.input.slice(Z,$.position),!bZ.call($.anchorMap,J))f0($,'unidentified alias "'+J+'"');return $.result=$.anchorMap[J],H$($,!0,-1),!0}function ZJ($,Z,J,Y,X){var Q,G,W,K=1,V=!1,U=!1,H,B,z,F,A;if($.listener!==null)$.listener("open",$);if($.tag=null,$.anchor=null,$.kind=null,$.result=null,Q=G=W=iQ===J||iM===J,Y){if(H$($,!0,-1)){if(V=!0,$.lineIndent>Z)K=1;else if($.lineIndent===Z)K=0;else if($.lineIndent<Z)K=-1}}if(K===1)while(yo($)||xo($))if(H$($,!0,-1)){if(V=!0,W=Q,$.lineIndent>Z)K=1;else if($.lineIndent===Z)K=0;else if($.lineIndent<Z)K=-1}else W=!1;if(W)W=V||X;if(K===1||iQ===J){if(cQ===J||cM===J)F=Z;else F=Z+1;if(A=$.position-$.lineStart,K===1)if(W&&(lM($,A)||vo($,A,F))||fo($,F))U=!0;else{if(G&&ko($,F)||_o($,F)||So($,F))U=!0;else if(ho($)){if(U=!0,$.tag!==null||$.anchor!==null)f0($,"alias node should not have any properties")}else if(bo($,F,cQ===J)){if(U=!0,$.tag===null)$.tag="?"}if($.anchor!==null)$.anchorMap[$.anchor]=$.result}else if(K===0)U=W&&lM($,A)}if($.tag!==null&&$.tag!=="!")if($.tag==="?"){if($.result!==null&&$.kind!=="scalar")f0($,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+$.kind+'"');for(H=0,B=$.implicitTypes.length;H<B;H+=1)if(z=$.implicitTypes[H],z.resolve($.result)){if($.result=z.construct($.result),$.tag=z.tag,$.anchor!==null)$.anchorMap[$.anchor]=$.result;break}}else if(bZ.call($.typeMap[$.kind||"fallback"],$.tag)){if(z=$.typeMap[$.kind||"fallback"][$.tag],$.result!==null&&z.kind!==$.kind)f0($,"unacceptable node kind for !<"+$.tag+'> tag; it should be "'+z.kind+'", not "'+$.kind+'"');if(!z.resolve($.result))f0($,"cannot resolve a node with !<"+$.tag+"> explicit tag");else if($.result=z.construct($.result),$.anchor!==null)$.anchorMap[$.anchor]=$.result}else f0($,"unknown tag !<"+$.tag+">");if($.listener!==null)$.listener("close",$);return $.tag!==null||$.anchor!==null||U}function go($){var Z=$.position,J,Y,X,Q=!1,G;$.version=null,$.checkLineBreaks=$.legacy,$.tagMap={},$.anchorMap={};while((G=$.input.charCodeAt($.position))!==0){if(H$($,!0,-1),G=$.input.charCodeAt($.position),$.lineIndent>0||G!==37)break;Q=!0,G=$.input.charCodeAt(++$.position),J=$.position;while(G!==0&&!X8(G))G=$.input.charCodeAt(++$.position);if(Y=$.input.slice(J,$.position),X=[],Y.length<1)f0($,"directive name must not be less than one character in length");while(G!==0){while(T5(G))G=$.input.charCodeAt(++$.position);if(G===35){do G=$.input.charCodeAt(++$.position);while(G!==0&&!w6(G));break}if(w6(G))break;J=$.position;while(G!==0&&!X8(G))G=$.input.charCodeAt(++$.position);X.push($.input.slice(J,$.position))}if(G!==0)AU($);if(bZ.call(uM,Y))uM[Y]($,Y,X);else nQ($,'unknown document directive "'+Y+'"')}if(H$($,!0,-1),$.lineIndent===0&&$.input.charCodeAt($.position)===45&&$.input.charCodeAt($.position+1)===45&&$.input.charCodeAt($.position+2)===45)$.position+=3,H$($,!0,-1);else if(Q)f0($,"directives end mark is expected");if(ZJ($,$.lineIndent-1,iQ,!1,!0),H$($,!0,-1),$.checkLineBreaks&&Lo.test($.input.slice(Z,$.position)))nQ($,"non-ASCII line breaks are interpreted as content");if($.documents.push($.result),$.position===$.lineStart&&oQ($)){if($.input.charCodeAt($.position)===46)$.position+=3,H$($,!0,-1);return}if($.position<$.length-1)f0($,"end of the stream or a document separator is expected");else return}function eM($,Z){if($=String($),Z=Z||{},$.length!==0){if($.charCodeAt($.length-1)!==10&&$.charCodeAt($.length-1)!==13)$+=`
|
|
56
|
+
`;if($.charCodeAt(0)===65279)$=$.slice(1)}var J=new Eo($,Z),Y=$.indexOf("\x00");if(Y!==-1)J.position=Y,f0(J,"null byte is not allowed in input");J.input+="\x00";while(J.input.charCodeAt(J.position)===32)J.lineIndent+=1,J.position+=1;while(J.position<J.length-1)go(J);return J.documents}function $D($,Z,J){if(Z!==null&&typeof Z==="object"&&typeof J>"u")J=Z,Z=null;var Y=eM($,J);if(typeof Z!=="function")return Y;for(var X=0,Q=Y.length;X<Q;X+=1)Z(Y[X])}function ZD($,Z){var J=eM($,Z);if(J.length===0)return;else if(J.length===1)return J[0];throw new dM("expected a single document in the stream, but found more")}function uo($,Z,J){if(typeof Z==="object"&&Z!==null&&typeof J>"u")J=Z,Z=null;return $D($,Z,d6.extend({schema:pM},J))}function mo($,Z){return ZD($,d6.extend({schema:pM},Z))}lo.loadAll=$D;lo.load=ZD;lo.safeLoadAll=uo;lo.safeLoad=mo});var RD=S((Is,MU)=>{var rY=D5(),aY=r7(),oo=nY(),so=t7(),UD=Object.prototype.toString,HD=Object.prototype.hasOwnProperty,ro=9,sY=10,ao=13,to=32,eo=33,$s=34,BD=35,Zs=37,Js=38,Ys=39,Xs=42,zD=44,Qs=45,FD=58,Gs=61,Ws=62,Ks=63,Vs=64,AD=91,OD=93,Us=96,jD=123,Hs=124,ND=125,m$={};m$[0]="\\0";m$[7]="\\a";m$[8]="\\b";m$[9]="\\t";m$[10]="\\n";m$[11]="\\v";m$[12]="\\f";m$[13]="\\r";m$[27]="\\e";m$[34]="\\\"";m$[92]="\\\\";m$[133]="\\N";m$[160]="\\_";m$[8232]="\\L";m$[8233]="\\P";var Bs=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function zs($,Z){var J,Y,X,Q,G,W,K;if(Z===null)return{};J={},Y=Object.keys(Z);for(X=0,Q=Y.length;X<Q;X+=1){if(G=Y[X],W=String(Z[G]),G.slice(0,2)==="!!")G="tag:yaml.org,2002:"+G.slice(2);if(K=$.compiledTypeMap.fallback[G],K&&HD.call(K.styleAliases,W))W=K.styleAliases[W];J[G]=W}return J}function YD($){var Z,J,Y;if(Z=$.toString(16).toUpperCase(),$<=255)J="x",Y=2;else if($<=65535)J="u",Y=4;else if($<=4294967295)J="U",Y=8;else throw new aY("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+J+rY.repeat("0",Y-Z.length)+Z}function Fs($){this.schema=$.schema||oo,this.indent=Math.max(1,$.indent||2),this.noArrayIndent=$.noArrayIndent||!1,this.skipInvalid=$.skipInvalid||!1,this.flowLevel=rY.isNothing($.flowLevel)?-1:$.flowLevel,this.styleMap=zs(this.schema,$.styles||null),this.sortKeys=$.sortKeys||!1,this.lineWidth=$.lineWidth||80,this.noRefs=$.noRefs||!1,this.noCompatMode=$.noCompatMode||!1,this.condenseFlow=$.condenseFlow||!1,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function XD($,Z){var J=rY.repeat(" ",Z),Y=0,X=-1,Q="",G,W=$.length;while(Y<W){if(X=$.indexOf(`
|
|
57
|
+
`,Y),X===-1)G=$.slice(Y),Y=W;else G=$.slice(Y,X+1),Y=X+1;if(G.length&&G!==`
|
|
58
|
+
`)Q+=J;Q+=G}return Q}function jU($,Z){return`
|
|
59
|
+
`+rY.repeat(" ",$.indent*Z)}function As($,Z){var J,Y,X;for(J=0,Y=$.implicitTypes.length;J<Y;J+=1)if(X=$.implicitTypes[J],X.resolve(Z))return!0;return!1}function qU($){return $===to||$===ro}function JJ($){return 32<=$&&$<=126||161<=$&&$<=55295&&$!==8232&&$!==8233||57344<=$&&$<=65533&&$!==65279||65536<=$&&$<=1114111}function Os($){return JJ($)&&!qU($)&&$!==65279&&$!==ao&&$!==sY}function QD($,Z){return JJ($)&&$!==65279&&$!==zD&&$!==AD&&$!==OD&&$!==jD&&$!==ND&&$!==FD&&($!==BD||Z&&Os(Z))}function js($){return JJ($)&&$!==65279&&!qU($)&&$!==Qs&&$!==Ks&&$!==FD&&$!==zD&&$!==AD&&$!==OD&&$!==jD&&$!==ND&&$!==BD&&$!==Js&&$!==Xs&&$!==eo&&$!==Hs&&$!==Gs&&$!==Ws&&$!==Ys&&$!==$s&&$!==Zs&&$!==Vs&&$!==Us}function qD($){var Z=/^\n* /;return Z.test($)}var MD=1,DD=2,wD=3,LD=4,sQ=5;function Ns($,Z,J,Y,X){var Q,G,W,K=!1,V=!1,U=Y!==-1,H=-1,B=js($.charCodeAt(0))&&!qU($.charCodeAt($.length-1));if(Z)for(Q=0;Q<$.length;Q++){if(G=$.charCodeAt(Q),!JJ(G))return sQ;W=Q>0?$.charCodeAt(Q-1):null,B=B&&QD(G,W)}else{for(Q=0;Q<$.length;Q++){if(G=$.charCodeAt(Q),G===sY){if(K=!0,U)V=V||Q-H-1>Y&&$[H+1]!==" ",H=Q}else if(!JJ(G))return sQ;W=Q>0?$.charCodeAt(Q-1):null,B=B&&QD(G,W)}V=V||U&&(Q-H-1>Y&&$[H+1]!==" ")}if(!K&&!V)return B&&!X($)?MD:DD;if(J>9&&qD($))return sQ;return V?LD:wD}function qs($,Z,J,Y){$.dump=function(){if(Z.length===0)return"''";if(!$.noCompatMode&&Bs.indexOf(Z)!==-1)return"'"+Z+"'";var X=$.indent*Math.max(1,J),Q=$.lineWidth===-1?-1:Math.max(Math.min($.lineWidth,40),$.lineWidth-X),G=Y||$.flowLevel>-1&&J>=$.flowLevel;function W(K){return As($,K)}switch(Ns(Z,G,$.indent,Q,W)){case MD:return Z;case DD:return"'"+Z.replace(/'/g,"''")+"'";case wD:return"|"+GD(Z,$.indent)+WD(XD(Z,X));case LD:return">"+GD(Z,$.indent)+WD(XD(Ms(Z,Q),X));case sQ:return'"'+Ds(Z,Q)+'"';default:throw new aY("impossible error: invalid scalar style")}}()}function GD($,Z){var J=qD($)?String(Z):"",Y=$[$.length-1]===`
|
|
60
|
+
`,X=Y&&($[$.length-2]===`
|
|
61
|
+
`||$===`
|
|
62
|
+
`),Q=X?"+":Y?"":"-";return J+Q+`
|
|
63
|
+
`}function WD($){return $[$.length-1]===`
|
|
64
|
+
`?$.slice(0,-1):$}function Ms($,Z){var J=/(\n+)([^\n]*)/g,Y=function(){var V=$.indexOf(`
|
|
65
|
+
`);return V=V!==-1?V:$.length,J.lastIndex=V,KD($.slice(0,V),Z)}(),X=$[0]===`
|
|
66
|
+
`||$[0]===" ",Q,G;while(G=J.exec($)){var W=G[1],K=G[2];Q=K[0]===" ",Y+=W+(!X&&!Q&&K!==""?`
|
|
67
|
+
`:"")+KD(K,Z),X=Q}return Y}function KD($,Z){if($===""||$[0]===" ")return $;var J=/ [^ ]/g,Y,X=0,Q,G=0,W=0,K="";while(Y=J.exec($)){if(W=Y.index,W-X>Z)Q=G>X?G:W,K+=`
|
|
68
|
+
`+$.slice(X,Q),X=Q+1;G=W}if(K+=`
|
|
69
|
+
`,$.length-X>Z&&G>X)K+=$.slice(X,G)+`
|
|
70
|
+
`+$.slice(G+1);else K+=$.slice(X);return K.slice(1)}function Ds($){var Z="",J,Y,X;for(var Q=0;Q<$.length;Q++){if(J=$.charCodeAt(Q),J>=55296&&J<=56319){if(Y=$.charCodeAt(Q+1),Y>=56320&&Y<=57343){Z+=YD((J-55296)*1024+Y-56320+65536),Q++;continue}}X=m$[J],Z+=!X&&JJ(J)?$[Q]:X||YD(J)}return Z}function ws($,Z,J){var Y="",X=$.tag,Q,G;for(Q=0,G=J.length;Q<G;Q+=1)if(R5($,Z,J[Q],!1,!1)){if(Q!==0)Y+=","+(!$.condenseFlow?" ":"");Y+=$.dump}$.tag=X,$.dump="["+Y+"]"}function Ls($,Z,J,Y){var X="",Q=$.tag,G,W;for(G=0,W=J.length;G<W;G+=1)if(R5($,Z+1,J[G],!0,!0)){if(!Y||G!==0)X+=jU($,Z);if($.dump&&sY===$.dump.charCodeAt(0))X+="-";else X+="- ";X+=$.dump}$.tag=Q,$.dump=X||"[]"}function Ts($,Z,J){var Y="",X=$.tag,Q=Object.keys(J),G,W,K,V,U;for(G=0,W=Q.length;G<W;G+=1){if(U="",G!==0)U+=", ";if($.condenseFlow)U+='"';if(K=Q[G],V=J[K],!R5($,Z,K,!1,!1))continue;if($.dump.length>1024)U+="? ";if(U+=$.dump+($.condenseFlow?'"':"")+":"+($.condenseFlow?"":" "),!R5($,Z,V,!1,!1))continue;U+=$.dump,Y+=U}$.tag=X,$.dump="{"+Y+"}"}function Rs($,Z,J,Y){var X="",Q=$.tag,G=Object.keys(J),W,K,V,U,H,B;if($.sortKeys===!0)G.sort();else if(typeof $.sortKeys==="function")G.sort($.sortKeys);else if($.sortKeys)throw new aY("sortKeys must be a boolean or a function");for(W=0,K=G.length;W<K;W+=1){if(B="",!Y||W!==0)B+=jU($,Z);if(V=G[W],U=J[V],!R5($,Z+1,V,!0,!0,!0))continue;if(H=$.tag!==null&&$.tag!=="?"||$.dump&&$.dump.length>1024,H)if($.dump&&sY===$.dump.charCodeAt(0))B+="?";else B+="? ";if(B+=$.dump,H)B+=jU($,Z);if(!R5($,Z+1,U,!0,H))continue;if($.dump&&sY===$.dump.charCodeAt(0))B+=":";else B+=": ";B+=$.dump,X+=B}$.tag=Q,$.dump=X||"{}"}function VD($,Z,J){var Y,X,Q,G,W,K;X=J?$.explicitTypes:$.implicitTypes;for(Q=0,G=X.length;Q<G;Q+=1)if(W=X[Q],(W.instanceOf||W.predicate)&&(!W.instanceOf||typeof Z==="object"&&Z instanceof W.instanceOf)&&(!W.predicate||W.predicate(Z))){if($.tag=J?W.tag:"?",W.represent){if(K=$.styleMap[W.tag]||W.defaultStyle,UD.call(W.represent)==="[object Function]")Y=W.represent(Z,K);else if(HD.call(W.represent,K))Y=W.represent[K](Z,K);else throw new aY("!<"+W.tag+'> tag resolver accepts not "'+K+'" style');$.dump=Y}return!0}return!1}function R5($,Z,J,Y,X,Q){if($.tag=null,$.dump=J,!VD($,J,!1))VD($,J,!0);var G=UD.call($.dump);if(Y)Y=$.flowLevel<0||$.flowLevel>Z;var W=G==="[object Object]"||G==="[object Array]",K,V;if(W)K=$.duplicates.indexOf(J),V=K!==-1;if($.tag!==null&&$.tag!=="?"||V||$.indent!==2&&Z>0)X=!1;if(V&&$.usedDuplicates[K])$.dump="*ref_"+K;else{if(W&&V&&!$.usedDuplicates[K])$.usedDuplicates[K]=!0;if(G==="[object Object]"){if(Y&&Object.keys($.dump).length!==0){if(Rs($,Z,$.dump,X),V)$.dump="&ref_"+K+$.dump}else if(Ts($,Z,$.dump),V)$.dump="&ref_"+K+" "+$.dump}else if(G==="[object Array]"){var U=$.noArrayIndent&&Z>0?Z-1:Z;if(Y&&$.dump.length!==0){if(Ls($,U,$.dump,X),V)$.dump="&ref_"+K+$.dump}else if(ws($,U,$.dump),V)$.dump="&ref_"+K+" "+$.dump}else if(G==="[object String]"){if($.tag!=="?")qs($,$.dump,Z,Q)}else{if($.skipInvalid)return!1;throw new aY("unacceptable kind of an object to dump "+G)}if($.tag!==null&&$.tag!=="?")$.dump="!<"+$.tag+"> "+$.dump}return!0}function Ps($,Z){var J=[],Y=[],X,Q;NU($,J,Y);for(X=0,Q=Y.length;X<Q;X+=1)Z.duplicates.push(J[Y[X]]);Z.usedDuplicates=Array(Q)}function NU($,Z,J){var Y,X,Q;if($!==null&&typeof $==="object")if(X=Z.indexOf($),X!==-1){if(J.indexOf(X)===-1)J.push(X)}else if(Z.push($),Array.isArray($))for(X=0,Q=$.length;X<Q;X+=1)NU($[X],Z,J);else{Y=Object.keys($);for(X=0,Q=Y.length;X<Q;X+=1)NU($[Y[X]],Z,J)}}function TD($,Z){Z=Z||{};var J=new Fs(Z);if(!J.noRefs)Ps($,J);if(R5(J,0,$,!0,!0))return J.dump+`
|
|
71
|
+
`;return""}function Cs($,Z){return TD($,rY.extend({schema:so},Z))}Is.dump=TD;Is.safeDump=Cs});var CD=S((_s,Y$)=>{var rQ=JD(),PD=RD();function aQ($){return function(){throw Error("Function "+$+" is deprecated and cannot be used.")}}_s.Type=O$();_s.Schema=w5();_s.FAILSAFE_SCHEMA=dQ();_s.JSON_SCHEMA=VU();_s.CORE_SCHEMA=UU();_s.DEFAULT_SAFE_SCHEMA=t7();_s.DEFAULT_FULL_SCHEMA=nY();_s.load=rQ.load;_s.loadAll=rQ.loadAll;_s.safeLoad=rQ.safeLoad;_s.safeLoadAll=rQ.safeLoadAll;_s.dump=PD.dump;_s.safeDump=PD.safeDump;_s.YAMLException=r7();_s.MINIMAL_SCHEMA=dQ();_s.SAFE_SCHEMA=t7();_s.DEFAULT_SCHEMA=nY();_s.scan=aQ("scan");_s.parse=aQ("parse");_s.compose=aQ("compose");_s.addConstructor=aQ("addConstructor")});var ED=S((CR0,ID)=>{var es=CD();ID.exports=es});var TU=S((wU,LU)=>{var tQ=ED(),DU=wU=LU.exports;DU.yaml={parse:tQ.safeLoad.bind(tQ),stringify:tQ.safeDump.bind(tQ)};DU.json={parse:JSON.parse.bind(JSON),stringify:function($,Z){let J=Object.assign({replacer:null,space:2},Z);return JSON.stringify($,J.replacer,J.space)}};DU.javascript={parse:function parse(str,options,wrap){try{if(wrap!==!1)str=`(function() {
|
|
72
|
+
return `+str.trim()+`;
|
|
73
|
+
}());`;return eval(str)||{}}catch($){if(wrap!==!1&&/(unexpected|identifier)/i.test($.message))return parse(str,options,!1);throw SyntaxError($)}},stringify:function(){throw Error("stringifying JavaScript is not supported")}}});var _D=S((IR0,bD)=>{/*!
|
|
74
|
+
* strip-bom-string <https://github.com/jonschlinkert/strip-bom-string>
|
|
75
|
+
*
|
|
76
|
+
* Copyright (c) 2015, 2017, Jon Schlinkert.
|
|
77
|
+
* Released under the MIT License.
|
|
78
|
+
*/bD.exports=function($){if(typeof $==="string"&&$.charAt(0)==="\uFEFF")return $.slice(1);return $}});var eQ=S(($r)=>{var SD=_D(),fD=cY();$r.define=function($,Z,J){Reflect.defineProperty($,Z,{enumerable:!1,configurable:!0,writable:!0,value:J})};$r.isBuffer=function($){return fD($)==="buffer"};$r.isObject=function($){return fD($)==="object"};$r.toBuffer=function($){return typeof $==="string"?Buffer.from($):$};$r.toString=function($){if($r.isBuffer($))return SD(String($));if(typeof $!=="string")throw TypeError("expected input to be a string or buffer");return SD($)};$r.arrayify=function($){return $?Array.isArray($)?$:[$]:[]};$r.startsWith=function($,Z,J){if(typeof J!=="number")J=Z.length;return $.slice(0,J)===Z}});var tY=S((bR0,vD)=>{var Wr=TU(),Kr=eQ();vD.exports=function($){let Z=Object.assign({},$);if(Z.delimiters=Kr.arrayify(Z.delims||Z.delimiters||"---"),Z.delimiters.length===1)Z.delimiters.push(Z.delimiters[0]);return Z.language=(Z.language||Z.lang||"yaml").toLowerCase(),Z.engines=Object.assign({},Wr,Z.parsers,Z.engines),Z}});var RU=S((_R0,yD)=>{yD.exports=function($,Z){let J=Z.engines[$]||Z.engines[Vr($)];if(typeof J>"u")throw Error('gray-matter engine "'+$+'" is not registered');if(typeof J==="function")J={parse:J};return J};function Vr($){switch($.toLowerCase()){case"js":case"javascript":return"javascript";case"coffee":case"coffeescript":case"cson":return"coffee";case"yaml":case"yml":return"yaml";default:return $}}});var PU=S((SR0,xD)=>{var Ur=cY(),Hr=RU(),Br=tY();xD.exports=function($,Z,J){if(Z==null&&J==null)switch(Ur($)){case"object":Z=$.data,J={};break;case"string":return $;default:throw TypeError("expected file to be a string or object")}let Y=$.content,X=Br(J);if(Z==null){if(!X.data)return $;Z=X.data}let Q=$.language||X.language,G=Hr(Q,X);if(typeof G.stringify!=="function")throw TypeError('expected "'+Q+'.stringify" to be a function');Z=Object.assign({},$.data,Z);let W=X.delimiters[0],K=X.delimiters[1],V=G.stringify(Z,J).trim(),U="";if(V!=="{}")U=YJ(W)+YJ(V)+YJ(K);if(typeof $.excerpt==="string"&&$.excerpt!==""){if(Y.indexOf($.excerpt.trim())===-1)U+=YJ($.excerpt)+YJ(K)}return U+YJ(Y)};function YJ($){return $.slice(-1)!==`
|
|
79
|
+
`?$+`
|
|
80
|
+
`:$}});var gD=S((fR0,hD)=>{var zr=tY();hD.exports=function($,Z){let J=zr(Z);if($.data==null)$.data={};if(typeof J.excerpt==="function")return J.excerpt($,J);let Y=$.data.excerpt_separator||J.excerpt_separator;if(Y==null&&(J.excerpt===!1||J.excerpt==null))return $;let X=typeof J.excerpt==="string"?J.excerpt:Y||J.delimiters[0],Q=$.content.indexOf(X);if(Q!==-1)$.excerpt=$.content.slice(0,Q);return $}});var lD=S((kR0,mD)=>{var uD=cY(),Fr=PU(),XJ=eQ();mD.exports=function($){if(uD($)!=="object")$={content:$};if(uD($.data)!=="object")$.data={};if($.contents&&$.content==null)$.content=$.contents;return XJ.define($,"orig",XJ.toBuffer($.content)),XJ.define($,"language",$.language||""),XJ.define($,"matter",$.matter||""),XJ.define($,"stringify",function(Z,J){if(J&&J.language)$.language=J.language;return Fr($,Z,J)}),$.content=XJ.toString($.content),$.isEmpty=!1,$.excerpt="",$}});var pD=S((vR0,dD)=>{var Ar=RU(),Or=tY();dD.exports=function($,Z,J){let Y=Or(J),X=Ar($,Y);if(typeof X.parse!=="function")throw TypeError('expected "'+$+'.parse" to be a function');return X.parse(Z,Y)}});var oD=S((yR0,nD)=>{var jr=J0("fs"),Nr=uq(),CU=tY(),qr=PU(),cD=gD(),Mr=TU(),Dr=lD(),wr=pD(),iD=eQ();function s$($,Z){if($==="")return{data:{},content:$,excerpt:"",orig:$};let J=Dr($),Y=s$.cache[J.content];if(!Z){if(Y)return J=Object.assign({},Y),J.orig=Y.orig,J;s$.cache[J.content]=J}return Lr(J,Z)}function Lr($,Z){let J=CU(Z),Y=J.delimiters[0],X=`
|
|
81
|
+
`+J.delimiters[1],Q=$.content;if(J.language)$.language=J.language;let G=Y.length;if(!iD.startsWith(Q,Y,G))return cD($,J),$;if(Q.charAt(G)===Y.slice(-1))return $;Q=Q.slice(G);let W=Q.length,K=s$.language(Q,J);if(K.name)$.language=K.name,Q=Q.slice(K.raw.length);let V=Q.indexOf(X);if(V===-1)V=W;if($.matter=Q.slice(0,V),$.matter.replace(/^\s*#[^\n]+/gm,"").trim()==="")$.isEmpty=!0,$.empty=$.content,$.data={};else $.data=wr($.language,$.matter,J);if(V===W)$.content="";else{if($.content=Q.slice(V+X.length),$.content[0]==="\r")$.content=$.content.slice(1);if($.content[0]===`
|
|
82
|
+
`)$.content=$.content.slice(1)}if(cD($,J),J.sections===!0||typeof J.section==="function")Nr($,J.section);return $}s$.engines=Mr;s$.stringify=function($,Z,J){if(typeof $==="string")$=s$($,J);return qr($,Z,J)};s$.read=function($,Z){let J=jr.readFileSync($,"utf8"),Y=s$(J,Z);return Y.path=$,Y};s$.test=function($,Z){return iD.startsWith($,CU(Z).delimiters[0])};s$.language=function($,Z){let Y=CU(Z).delimiters[0];if(s$.test($))$=$.slice(Y.length);let X=$.slice(0,$.search(/\r?\n/));return{raw:X,name:X?X.trim():""}};s$.cache={};s$.clearCache=function(){s$.cache={}};nD.exports=s$});var ZR=S((Of0,$R)=>{function S00($){var Z=new $,J=Z;function Y(){var Q=Z;if(Q.next)Z=Q.next;else Z=new $,J=Z;return Q.next=null,Q}function X(Q){J.next=Q,J=Q}return{get:Y,release:X}}$R.exports=S00});var YR=S((jf0,SH)=>{var f00=ZR();function JR($,Z,J){if(typeof $==="function")J=Z,Z=$,$=null;if(!(J>=1))throw Error("fastqueue concurrency must be equal to or greater than 1");var Y=f00(k00),X=null,Q=null,G=0,W=null,K={push:A,drain:K8,saturated:K8,pause:U,paused:!1,get concurrency(){return J},set concurrency(R){if(!(R>=1))throw Error("fastqueue concurrency must be equal to or greater than 1");if(J=R,K.paused)return;for(;X&&G<J;)G++,q()},running:V,resume:z,idle:F,length:H,getQueue:B,unshift:N,empty:K8,kill:w,killAndDrain:j,error:I,abort:M};return K;function V(){return G}function U(){K.paused=!0}function H(){var R=X,L=0;while(R)R=R.next,L++;return L}function B(){var R=X,L=[];while(R)L.push(R.value),R=R.next;return L}function z(){if(!K.paused)return;if(K.paused=!1,X===null){G++,q();return}for(;X&&G<J;)G++,q()}function F(){return G===0&&K.length()===0}function A(R,L){var C=Y.get();if(C.context=$,C.release=q,C.value=R,C.callback=L||K8,C.errorHandler=W,G>=J||K.paused)if(Q)Q.next=C,Q=C;else X=C,Q=C,K.saturated();else G++,Z.call($,C.value,C.worked)}function N(R,L){var C=Y.get();if(C.context=$,C.release=q,C.value=R,C.callback=L||K8,C.errorHandler=W,G>=J||K.paused)if(X)C.next=X,X=C;else X=C,Q=C,K.saturated();else G++,Z.call($,C.value,C.worked)}function q(R){if(R)Y.release(R);var L=X;if(L&&G<=J)if(!K.paused){if(Q===X)Q=null;if(X=L.next,L.next=null,Z.call($,L.value,L.worked),Q===null)K.empty()}else G--;else if(--G===0)K.drain()}function w(){X=null,Q=null,K.drain=K8}function j(){X=null,Q=null,K.drain(),K.drain=K8}function M(){var R=X;X=null,Q=null;while(R){var{next:L,callback:C,errorHandler:_,value:E,context:f}=R;if(R.value=null,R.callback=K8,R.errorHandler=null,_)_(Error("abort"),E);C.call(f,Error("abort")),R.release(R),R=L}K.drain=K8}function I(R){W=R}}function K8(){}function k00(){this.value=null,this.callback=K8,this.next=null,this.release=K8,this.context=null,this.errorHandler=null;var $=this;this.worked=function(J,Y){var{callback:X,errorHandler:Q,value:G}=$;if($.value=null,$.callback=K8,$.errorHandler)Q(J,G);X.call($.context,J,Y),$.release($)}}function v00($,Z,J){if(typeof $==="function")J=Z,Z=$,$=null;function Y(U,H){Z.call(this,U).then(function(B){H(null,B)},H)}var X=JR($,Y,J),Q=X.push,G=X.unshift;return X.push=W,X.unshift=K,X.drained=V,X;function W(U){var H=new Promise(function(B,z){Q(U,function(F,A){if(F){z(F);return}B(A)})});return H.catch(K8),H}function K(U){var H=new Promise(function(B,z){G(U,function(F,A){if(F){z(F);return}B(A)})});return H.catch(K8),H}function V(){var U=new Promise(function(H){process.nextTick(function(){if(X.idle())H();else{var B=X.drain;X.drain=function(){if(typeof B==="function")B();H(),X.drain=B}}})});return U}}SH.exports=JR;SH.exports.promise=v00});var fH=S((Nf0,TX)=>{var{format:y00}=J0("util");function x00(){return`${this.name} [${this.code}]: ${this.message}`}var I4=Symbol.for("fastify-error-generic");function jJ($,Z,J=500,Y=Error,X=jJ.captureStackTrace){let Q=$===I4;if(Q)$="FST_ERR";if(!$)throw Error("Fastify error code must not be empty");if(!Z)throw Error("Fastify error message must not be empty");$=$.toUpperCase(),!J&&(J=void 0);let G=Symbol.for(`fastify-error ${$}`);function W(...K){if(!new.target)return new W(...K);this.code=$,this.name="FastifyError",this.statusCode=J;let V=K.length-1;if(V!==-1&&K[V]&&typeof K[V]==="object"&&"cause"in K[V])this.cause=K.pop().cause;this.message=y00(Z,...K),Error.stackTraceLimit&&X&&Error.captureStackTrace(this,W)}if(W.prototype=Object.create(Y.prototype,{constructor:{value:W,enumerable:!1,writable:!0,configurable:!0},[I4]:{value:!0,enumerable:!1,writable:!1,configurable:!1},[G]:{value:!0,enumerable:!1,writable:!1,configurable:!1}}),Q)Object.defineProperty(W,Symbol.hasInstance,{value(K){return K&&K[I4]},configurable:!1,writable:!1,enumerable:!1});else Object.defineProperty(W,Symbol.hasInstance,{value(K){return K&&K[G]},configurable:!1,writable:!1,enumerable:!1});return W.prototype[Symbol.toStringTag]="Error",W.prototype.toString=x00,W}jJ.captureStackTrace=!0;var h00=jJ(I4,"Fastify Error",500,Error);TX.exports=jJ;TX.exports.FastifyError=h00;TX.exports.default=jJ;TX.exports.createError=jJ});var E4=S((qf0,XR)=>{var{createError:uZ}=fH();XR.exports={AVV_ERR_EXPOSE_ALREADY_DEFINED:uZ("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' is already defined, specify an expose option for '%s'"),AVV_ERR_ATTRIBUTE_ALREADY_DEFINED:uZ("AVV_ERR_ATTRIBUTE_ALREADY_DEFINED","'%s' is already defined"),AVV_ERR_CALLBACK_NOT_FN:uZ("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:uZ("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:uZ("AVV_ERR_ROOT_PLG_BOOTED","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:uZ("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:uZ("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise"),AVV_ERR_PLUGIN_EXEC_TIMEOUT:uZ("AVV_ERR_PLUGIN_EXEC_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")}});var NJ=S((Mf0,QR)=>{var g00=Symbol("avvio.Boot"),u00=Symbol("isOnCloseHandler"),m00=Symbol("avvio.ThenifyDoNotWrap"),l00=Symbol("avvio.TimeTree.untrackNode"),d00=Symbol("avvio.TimeTree.trackNode"),p00=Symbol("avvio.TimeTree.getParent"),c00=Symbol("avvio.TimeTree.getNode"),i00=Symbol("avvio.TimeTree.addNode"),n00=Symbol.for("plugin-meta");QR.exports={kAvvio:g00,kIsOnCloseHandler:u00,kThenifyDoNotWrap:m00,kUntrackNode:l00,kTrackNode:d00,kGetParent:p00,kGetNode:c00,kAddNode:i00,kPluginMeta:n00}});var zR=S((Df0,BR)=>{var{kUntrackNode:GR,kTrackNode:kH,kGetParent:WR,kGetNode:KR,kAddNode:VR}=NJ();class UR{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[kH]($){if(this.tableId.set($.id,$),this.tableLabel.has($.label))this.tableLabel.get($.label).push($);else this.tableLabel.set($.label,[$])}[GR]($){this.tableId.delete($.id);let Z=this.tableLabel.get($.label);if(Z.pop(),Z.length===0)this.tableLabel.delete($.label)}[WR]($){if($===null)return null;else if(this.tableLabel.has($)){let Z=this.tableLabel.get($);return Z[Z.length-1]}else return null}[KR]($){return this.tableId.get($)}[VR]($,Z,J){let Y=this[WR]($);if(Y===null)return this.root={parent:null,id:"root",label:Z,nodes:[],start:J,stop:null,diff:-1},this[kH](this.root),this.root.id;let Q=`${Z}-${Math.random()}`,G={parent:$,id:Q,label:Z,nodes:[],start:J,stop:null,diff:-1};return Y.nodes.push(G),this[kH](G),Q}start($,Z,J=Date.now()){return this[VR]($,Z,J)}stop($,Z=Date.now()){let J=this[KR]($);if(J)J.stop=Z,J.diff=J.stop-J.start||0,this[GR](J)}toJSON(){return Object.assign({},this.root)}prettyPrint(){return HR(this.toJSON())}}function HR($,Z=""){let J=Z,Y=$.nodes.length,X=Y-1;J+=`${$.label} ${$.diff} ms
|
|
83
|
+
`;for(let Q=0;Q<Y;++Q){let G=$.nodes[Q],W=Z+(Q===X?" ":"\u2502 ");J+=Z,J+=Q===X?"\u2514\u2500":"\u251C\u2500",J+=G.nodes.length===0?"\u2500 ":"\u252C ",J+=HR(G,W).slice(Z.length+2)}return J}BR.exports={TimeTree:UR}});var b4=S((wf0,FR)=>{var{debuglog:o00}=J0("util"),s00=o00("avvio");FR.exports={debug:s00}});var OR=S((Lf0,AR)=>{function r00(){let $={resolve:null,reject:null,promise:null};return $.promise=new Promise((Z,J)=>{$.resolve=Z,$.reject=J}),$}AR.exports={createPromise:r00}});var qR=S((Tf0,NR)=>{var{kPluginMeta:jR}=NJ();function a00($,Z){if($[jR]?.name)return $[jR].name;if(Z?.name)return Z.name;if($.name)return $.name;else return $.toString().split(`
|
|
84
|
+
`).slice(0,2).map((J)=>J.trim()).join(" -- ")}NR.exports={getPluginName:a00}});var _4=S((Rf0,MR)=>{function t00($){return $!==null&&typeof $==="object"&&typeof $.then==="function"}MR.exports={isPromiseLike:t00}});var wR=S((Pf0,DR)=>{var{EventEmitter:e00}=J0("events"),{inherits:$10}=J0("util"),{debug:S$}=b4(),{createPromise:Z10}=OR(),{AVV_ERR_PLUGIN_EXEC_TIMEOUT:J10}=E4(),{getPluginName:Y10}=qR(),{isPromiseLike:X10}=_4();function qJ($,Z,J,Y,X){this.queue=$,this.func=Z,this.options=J,this.isAfter=Y,this.timeout=X,this.started=!1,this.name=Y10(Z,J),this.queue.pause(),this._error=null,this.loaded=!1,this._promise=null,this.startTime=null}$10(qJ,e00);qJ.prototype.exec=function($,Z){S$("exec",this.name),this.server=$;let J=this.func,Y=this.name,X=!1;this.options=typeof this.options==="function"?this.options(this.server):this.options;let Q=null,G=(K)=>{if(X){S$("loading complete",Y);return}if(this._error=K,K)S$("exec errored",Y);else S$("exec completed",Y);if(X=!0,Q)clearTimeout(Q);Z(K)};if(this.timeout>0)S$("setting up timeout",Y,this.timeout),Q=setTimeout(function(){S$("timed out",Y),Q=null;let K=new J10(Y);K.fn=J,G(K)},this.timeout);this.started=!0,this.startTime=Date.now(),this.emit("start",this.server?this.server.name:null,this.name,Date.now());let W=J(this.server,this.options,G);if(X10(W))S$("exec: resolving promise",Y),W.then(()=>process.nextTick(G),(K)=>process.nextTick(G,K));else if(J.length<3)G()};qJ.prototype.loadedSoFar=function(){if(S$("loadedSoFar",this.name),this.loaded)return Promise.resolve();let $=()=>{this.server.after((J,Y)=>{if(this._error=J,this.queue.pause(),this._promise){if(J)S$("rejecting promise",this.name,J),this._promise.reject(J);else S$("resolving promise",this.name),this._promise.resolve();this._promise=null}process.nextTick(Y,J)}),this.queue.resume()},Z;if(!this._promise)if(this._promise=Z10(),Z=this._promise.promise,!this.server)this.on("start",$);else $();else Z=Promise.resolve();return Z};qJ.prototype.enqueue=function($,Z){S$("enqueue",this.name,$.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.queue.push($,Z)};qJ.prototype.finish=function($,Z){S$("finish",this.name,$);let J=()=>{if(this.loaded)return;S$("loaded",this.name),this.emit("loaded",this.server?this.server.name:null,this.name,Date.now()),this.loaded=!0,Z($)};if($){if(this._promise)this._promise.reject($),this._promise=null;J();return}let Y=()=>{if(S$("check",this.name,this.queue.length(),this.queue.running(),this._promise),this.queue.length()===0&&this.queue.running()===0)if(this._promise){let X=()=>{S$("wrap"),queueMicrotask(Y)};this._promise.resolve(),this._promise.promise.then(X,X),this._promise=null}else J();else S$("delayed",this.name),this.queue.drain=()=>{S$("drain",this.name),this.queue.drain=Q10,queueMicrotask(Y)}};queueMicrotask(Y),this.queue.resume()};function Q10(){}DR.exports={Plugin:qJ}});var TR=S((Cf0,LR)=>{var{AVV_ERR_PLUGIN_NOT_VALID:vH}=E4();function G10($){if(!($&&(typeof $==="function"||typeof $.then==="function")))if(Array.isArray($))throw new vH("array");else if($===null)throw new vH("null");else throw new vH(typeof $)}LR.exports={validatePlugin:G10}});var PR=S((If0,RR)=>{function W10($){return $!==null&&typeof $==="object"&&typeof $.default==="function"}RR.exports={isBundledOrTypescriptPlugin:W10}});var ER=S((Ef0,IR)=>{var{debug:CR}=b4(),{kThenifyDoNotWrap:yH}=NJ();function K10(){if(this.booted){CR("thenify returning undefined because we are already booted");return}if(this[yH]){this[yH]=!1;return}return CR("thenify"),($,Z)=>{return this._loadRegistered().then(()=>{return this[yH]=!0,$(this._server)},Z)}}IR.exports={thenify:K10}});var _R=S((bf0,bR)=>{var{isPromiseLike:V10}=_4(),{kAvvio:U10}=NJ();function H10($,Z,J){let Y;try{Y=$.apply($,Z)}catch(X){if(J)process.nextTick(J,X);return}if(V10(Y)&&!Y[U10])Y.then(()=>process.nextTick(J),(X)=>process.nextTick(J,X));else if(J)process.nextTick(J)}bR.exports={executeWithThenable:H10}});var uR=S((_f0,gR)=>{var S4=YR(),B10=J0("events").EventEmitter,z10=J0("util").inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:RX,AVV_ERR_CALLBACK_NOT_FN:MJ,AVV_ERR_ROOT_PLG_BOOTED:F10,AVV_ERR_READY_TIMEOUT:A10,AVV_ERR_ATTRIBUTE_ALREADY_DEFINED:O10}=E4(),{kAvvio:kR,kIsOnCloseHandler:vR}=NJ(),{TimeTree:j10}=zR(),{Plugin:yR}=wR(),{debug:DJ}=b4(),{validatePlugin:N10}=TR(),{isBundledOrTypescriptPlugin:q10}=PR(),{isPromiseLike:M10}=_4(),{thenify:xR}=ER(),{executeWithThenable:SR}=_R();function G$($,Z,J){if(typeof $==="function"&&arguments.length===1)J=$,Z={},$=null;if(typeof Z==="function")J=Z,Z={};if(Z=Z||{},Z.autostart=Z.autostart!==!1,Z.timeout=Number(Z.timeout)||0,Z.expose=Z.expose||{},!new.target)return new G$($,Z,J);if(this._server=$||this,this._opts=Z,$)this._expose();if(this._current=[],this._error=null,this._lastUsed=null,this.setMaxListeners(0),J)this.once("start",J);this.started=!1,this.booted=!1,this.pluginTree=new j10,this._readyQ=S4(this,hR,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=fR},this._closeQ=S4(this,w10,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=fR},this._doStart=null;let Y=this;this._root=new yR(S4(this,this._loadPluginNextTick,1),function(Q,G,W){Y._doStart=W,G.autostart&&Y.start()},Z,!1,0),this._trackPluginLoading(this._root),this._loadPlugin(this._root,(X)=>{DJ("root plugin ready");try{this.emit("preReady"),this._root=null}catch(Q){X=X||this._error||Q}if(X){if(this._error=X,this._readyQ.length()===0)throw X}else this.booted=!0;this._readyQ.resume()})}z10(G$,B10);if("asyncDispose"in Symbol)G$.prototype[Symbol.asyncDispose]=function(){return new Promise(($,Z)=>{this.close((J)=>{if(J)return Z(J);$()})})};G$.prototype.start=function(){return this.started=!0,process.nextTick(this._doStart),this};G$.prototype.override=function($,Z,J){return $};G$.prototype[kR]=!0;G$.prototype.use=function($,Z){return this._lastUsed=this._addPlugin($,Z,!1),this};G$.prototype._loadRegistered=function(){let $=this._current[0];if(!this.started&&!this.booted)process.nextTick(()=>this._root.queue.resume());if(!$)return Promise.resolve();return $.loadedSoFar()};Object.defineProperty(G$.prototype,"then",{get:xR});G$.prototype._addPlugin=function($,Z,J){if(q10($))$=$.default;if(N10($),Z=Z||{},this.booted)throw new F10;let Y=this._current[0],X=this._opts.timeout;if(!Y.loaded&&Y.timeout>0){let G=Date.now()-Y.startTime;X=Y.timeout-(G+3)}let Q=new yR(S4(this,this._loadPluginNextTick,1),$,Z,J,X);if(this._trackPluginLoading(Q),Y.loaded)throw Error(Q.name,Y.name);return Y.enqueue(Q,(G)=>{G&&(this._error=G)}),Q};G$.prototype._expose=function(){let Z=this,J=Z._server,{use:Y="use",after:X="after",ready:Q="ready",onClose:G="onClose",close:W="close"}=this._opts.expose;if(J[Y])throw new RX(Y,"use");if(J[Y]=function(K,V){return Z.use(K,V),this},J[X])throw new RX(X,"after");if(J[X]=function(K){if(typeof K!=="function")return Z._loadRegistered();return Z.after(xH(K,this)),this},J[Q])throw new RX(Q,"ready");if(J[Q]=function(K){if(K&&typeof K!=="function")throw new MJ(Q,typeof K);return Z.ready(K?xH(K,this):void 0)},J[G])throw new RX(G,"onClose");if(J[G]=function(K){if(typeof K!=="function")throw new MJ(G,typeof K);return Z.onClose(L10(K,this)),this},J[W])throw new RX(W,"close");if(J[W]=function(K){if(K&&typeof K!=="function")throw new MJ(W,typeof K);if(K)return Z.close(xH(K,this)),this;return Z.close()},J.then)throw new O10("then");Object.defineProperty(J,"then",{get:xR.bind(Z)}),J[kR]=!0};G$.prototype.after=function($){if(!$)return this._loadRegistered();this._addPlugin(Z.bind(this),{},!0);function Z(J,Y,X){hR.call(this,$,X)}return this};G$.prototype.onClose=function($){if(typeof $!=="function")throw new MJ("onClose",typeof $);return $[vR]=!0,this._closeQ.unshift($,(Z)=>{Z&&(this._error=Z)}),this};G$.prototype.close=function($){let Z;if($){if(typeof $!=="function")throw new MJ("close",typeof $)}else Z=new Promise(function(J,Y){$=function(X){if(X)return Y(X);J()}});return this.ready(()=>{this._error=null,this._closeQ.push($),process.nextTick(this._closeQ.resume.bind(this._closeQ))}),Z};G$.prototype.ready=function($){if($){if(typeof $!=="function")throw new MJ("ready",typeof $);this._readyQ.push($),queueMicrotask(this.start.bind(this));return}return new Promise((Z,J)=>{this._readyQ.push(X),this.start();let Y=this._current[0].server;function X(Q,G,W){if(Q)J(Q);else Z(Y);process.nextTick(W)}})};G$.prototype._trackPluginLoading=function($){let Z=this._current[0]?.name||null;$.once("start",(J,Y,X)=>{let Q=this.pluginTree.start(Z||null,Y,X);$.once("loaded",(G,W,K)=>{this.pluginTree.stop(Q,K)})})};G$.prototype.prettyPrint=function(){return this.pluginTree.prettyPrint()};G$.prototype.toJSON=function(){return this.pluginTree.toJSON()};G$.prototype._loadPlugin=function($,Z){let J=this;if(M10($.func)){$.func.then((G)=>{if(typeof G.default==="function")G=G.default;$.func=G,this._loadPlugin($,Z)},Z);return}let Y=J._current[0];if(J._current.unshift($),J._error&&!$.isAfter){DJ("skipping loading of plugin as instance errored and it is not an after",$.name),process.nextTick(Q);return}let X=Y?.server||J._server;if(!$.isAfter)try{X=J.override(X,$.func,$.options)}catch(G){return DJ("override errored",$.name),Q(G)}$.exec(X,Q);function Q(G){$.finish(G,(W)=>{J._current.shift(),Z(W)})}};G$.prototype._loadPluginNextTick=function($,Z){process.nextTick(this._loadPlugin.bind(this),$,Z)};function fR(){}function hR($,Z){let J=this._server,Y=this._error;if(this._error=null,$.length===0)this._error=Y,SR($,[],Z);else if($.length===1)SR($,[Y],Z);else if(this._opts.timeout===0){let X=(Q)=>{this._error=Q,Z(this._error)};if($.length===2)$(Y,X);else $(Y,J,X)}else D10.call(this,$,Y,J,Z)}function D10($,Z,J,Y){let X=$.unwrappedName??$.name;DJ("setting up ready timeout",X,this._opts.timeout);let Q=setTimeout(()=>{DJ("timed out",X),Q=null;let W=new A10(X);W.fn=$,this._error=W,Y(W)},this._opts.timeout);if($.length===2)$(Z,G.bind(this));else $(Z,J,G.bind(this));function G(W){if(Q)clearTimeout(Q),this._error=W,Y(this._error)}}function w10($,Z){let J=this._server,Y=$[vR];if($.length===0||$.length===1){let X;if(Y)X=$(J);else X=$(this._error);if(X&&typeof X.then==="function")DJ("resolving close/onClose promise"),X.then(()=>process.nextTick(Z),(Q)=>process.nextTick(Z,Q));else process.nextTick(Z)}else if($.length===2)if(Y)$(J,Z);else $(this._error,Z);else if(Y)$(J,Z);else $(this._error,J,Z)}function L10($,Z){return J.bind(Z);function J(Y,X){let Q;if($.length===0)if(Q=$(),Q?.then)Q.then(function(){process.nextTick(X)},X);else process.nextTick(X);else if($.length===1)if(Q=$(this),Q?.then)Q.then(function(){process.nextTick(X)},X);else process.nextTick(X);else $(this,X)}}function xH($,Z){let J=Y.bind(Z);return J.unwrappedName=$.name,J;function Y(X,Q){let G;if(!$)process.nextTick(Q);else if($.length===0)if(G=$(),G?.then)G.then(function(){process.nextTick(Q,X)},Q);else process.nextTick(Q,X);else if($.length===1)if(G=$(X),G?.then)G.then(function(){process.nextTick(Q)},Q);else process.nextTick(Q);else if($.length===2)$(X,Q);else $(X,this,Q)}}gR.exports=G$});var B$=S((Sf0,mR)=>{var T10={kAvvioBoot:Symbol("fastify.avvioBoot"),kChildren:Symbol("fastify.children"),kServerBindings:Symbol("fastify.serverBindings"),kBodyLimit:Symbol("fastify.bodyLimit"),kSupportedHTTPMethods:Symbol("fastify.acceptedHTTPMethods"),kRoutePrefix:Symbol("fastify.routePrefix"),kLogLevel:Symbol("fastify.logLevel"),kLogSerializers:Symbol("fastify.logSerializers"),kHooks:Symbol("fastify.hooks"),kContentTypeParser:Symbol("fastify.contentTypeParser"),kState:Symbol("fastify.state"),kOptions:Symbol("fastify.options"),kDisableRequestLogging:Symbol("fastify.disableRequestLogging"),kPluginNameChain:Symbol("fastify.pluginNameChain"),kRouteContext:Symbol("fastify.context"),kGenReqId:Symbol("fastify.genReqId"),kHttp2ServerSessions:Symbol("fastify.http2ServerSessions"),kSchemaController:Symbol("fastify.schemaController"),kSchemaHeaders:Symbol("headers-schema"),kSchemaParams:Symbol("params-schema"),kSchemaQuerystring:Symbol("querystring-schema"),kSchemaBody:Symbol("body-schema"),kSchemaResponse:Symbol("response-schema"),kSchemaErrorFormatter:Symbol("fastify.schemaErrorFormatter"),kSchemaVisited:Symbol("fastify.schemas.visited"),kRequest:Symbol("fastify.Request"),kRequestPayloadStream:Symbol("fastify.RequestPayloadStream"),kRequestAcceptVersion:Symbol("fastify.RequestAcceptVersion"),kRequestCacheValidateFns:Symbol("fastify.request.cache.validateFns"),kRequestOriginalUrl:Symbol("fastify.request.originalUrl"),kRequestSignal:Symbol("fastify.request.signal"),kHandlerTimeout:Symbol("fastify.handlerTimeout"),kTimeoutTimer:Symbol("fastify.request.timeoutTimer"),kOnAbort:Symbol("fastify.request.onAbort"),kFourOhFour:Symbol("fastify.404"),kCanSetNotFoundHandler:Symbol("fastify.canSetNotFoundHandler"),kFourOhFourLevelInstance:Symbol("fastify.404LogLevelInstance"),kFourOhFourContext:Symbol("fastify.404ContextKey"),kDefaultJsonParse:Symbol("fastify.defaultJSONParse"),kReply:Symbol("fastify.Reply"),kReplySerializer:Symbol("fastify.reply.serializer"),kReplyIsError:Symbol("fastify.reply.isError"),kReplyHeaders:Symbol("fastify.reply.headers"),kReplyTrailers:Symbol("fastify.reply.trailers"),kReplyHasStatusCode:Symbol("fastify.reply.hasStatusCode"),kReplyHijacked:Symbol("fastify.reply.hijacked"),kReplyStartTime:Symbol("fastify.reply.startTime"),kReplyNextErrorHandler:Symbol("fastify.reply.nextErrorHandler"),kReplyEndTime:Symbol("fastify.reply.endTime"),kReplyErrorHandlerCalled:Symbol("fastify.reply.errorHandlerCalled"),kReplyIsRunningOnErrorHook:Symbol("fastify.reply.isRunningOnErrorHook"),kReplySerializerDefault:Symbol("fastify.replySerializerDefault"),kReplyCacheSerializeFns:Symbol("fastify.reply.cache.serializeFns"),kTestInternals:Symbol("fastify.testInternals"),kErrorHandler:Symbol("fastify.errorHandler"),kErrorHandlerAlreadySet:Symbol("fastify.errorHandlerAlreadySet"),kChildLoggerFactory:Symbol("fastify.childLoggerFactory"),kHasBeenDecorated:Symbol("fastify.hasBeenDecorated"),kKeepAliveConnections:Symbol("fastify.keepAliveConnections"),kRouteByFastify:Symbol("fastify.routeByFastify")};mR.exports=T10});var dR=S((ff0,f4)=>{var{format:hH}=J0("util");function R10($){return lR({...$,name:"DeprecationWarning"})}function lR({name:$,code:Z,message:J,unlimited:Y=!1}={}){if(!$)throw Error("Warning name must not be empty");if(!Z)throw Error("Warning code must not be empty");if(!J)throw Error("Warning message must not be empty");if(typeof Y!=="boolean")throw Error("Warning opts.unlimited must be a boolean");Z=Z.toUpperCase();let X={[$]:function(G,W,K){if(Q.emitted===!0&&Q.unlimited!==!0)return;Q.emitted=!0,process.emitWarning(Q.format(G,W,K),Q.name,Q.code)}};if(Y)X={[$]:function(G,W,K){Q.emitted=!0,process.emitWarning(Q.format(G,W,K),Q.name,Q.code)}};let Q=X[$];return Q.emitted=!1,Q.message=J,Q.unlimited=Y,Q.code=Z,Q.format=function(G,W,K){let V;if(G&&W&&K)V=hH(J,G,W,K);else if(G&&W)V=hH(J,G,W);else if(G)V=hH(J,G);else V=J;return V},Q}var gH={createWarning:lR,createDeprecation:R10};f4.exports=gH;f4.exports.default=gH;f4.exports.processWarning=gH});var wJ=S((kf0,pR)=>{var{createWarning:PX}=dR(),P10=PX({name:"FastifyWarning",code:"FSTWRN001",message:"The %s schema for %s: %s is missing. This may indicate the schema is not well specified.",unlimited:!0}),C10=PX({name:"FastifyWarning",code:"FSTWRN003",message:"The %s mixes async and callback styles that may lead to unhandled rejections. Please use only one of them.",unlimited:!0}),I10=PX({name:"FastifyWarning",code:"FSTWRN004",message:"It seems that you are overriding an errorHandler in the same scope, which can lead to subtle bugs.",unlimited:!0}),E10=PX({name:"FastifySecurity",code:"FSTSEC001",message:'You are using /%s/ Content-Type which may be vulnerable to CORS attack. Please make sure your RegExp start with "^" or include ";?" to proper detection of the essence MIME type.',unlimited:!0}),b10=PX({name:"FastifyWarning",code:"FSTDEP022",message:'The router options for %s property access is deprecated. Please use "options.routerOptions" instead for accessing router options. The router options will be removed in `fastify@6`.',unlimited:!0});pR.exports={FSTWRN001:P10,FSTWRN003:C10,FSTWRN004:I10,FSTSEC001:E10,FSTDEP022:b10}});var T$=S((vf0,k4)=>{var K0=fH(),d5={FST_ERR_NOT_FOUND:K0("FST_ERR_NOT_FOUND","Not Found",404),FST_ERR_OPTIONS_NOT_OBJ:K0("FST_ERR_OPTIONS_NOT_OBJ","Options must be an object",500,TypeError),FST_ERR_QSP_NOT_FN:K0("FST_ERR_QSP_NOT_FN","querystringParser option should be a function, instead got '%s'",500,TypeError),FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN:K0("FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN","schemaController.bucket option should be a function, instead got '%s'",500,TypeError),FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN:K0("FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN","schemaErrorFormatter option should be a non async function. Instead got '%s'.",500,TypeError),FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ:K0("FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ","ajv.customOptions option should be an object, instead got '%s'",500,TypeError),FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR:K0("FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR","ajv.plugins option should be an array, instead got '%s'",500,TypeError),FST_ERR_VALIDATION:K0("FST_ERR_VALIDATION","%s",400),FST_ERR_LISTEN_OPTIONS_INVALID:K0("FST_ERR_LISTEN_OPTIONS_INVALID","Invalid listen options: '%s'",500,TypeError),FST_ERR_ERROR_HANDLER_NOT_FN:K0("FST_ERR_ERROR_HANDLER_NOT_FN","Error Handler must be a function",500,TypeError),FST_ERR_ERROR_HANDLER_ALREADY_SET:K0("FST_ERR_ERROR_HANDLER_ALREADY_SET","Error Handler already set in this scope. Set 'allowErrorHandlerOverride: true' to allow overriding.",500,TypeError),FST_ERR_CTP_ALREADY_PRESENT:K0("FST_ERR_CTP_ALREADY_PRESENT","Content type parser '%s' already present."),FST_ERR_CTP_INVALID_TYPE:K0("FST_ERR_CTP_INVALID_TYPE","The content type should be a string or a RegExp",500,TypeError),FST_ERR_CTP_EMPTY_TYPE:K0("FST_ERR_CTP_EMPTY_TYPE","The content type cannot be an empty string",500,TypeError),FST_ERR_CTP_INVALID_HANDLER:K0("FST_ERR_CTP_INVALID_HANDLER","The content type handler should be a function",500,TypeError),FST_ERR_CTP_INVALID_PARSE_TYPE:K0("FST_ERR_CTP_INVALID_PARSE_TYPE","The body parser can only parse your data as 'string' or 'buffer', you asked '%s' which is not supported.",500,TypeError),FST_ERR_CTP_BODY_TOO_LARGE:K0("FST_ERR_CTP_BODY_TOO_LARGE","Request body is too large",413,RangeError),FST_ERR_CTP_INVALID_MEDIA_TYPE:K0("FST_ERR_CTP_INVALID_MEDIA_TYPE","Unsupported Media Type",415),FST_ERR_CTP_INVALID_CONTENT_LENGTH:K0("FST_ERR_CTP_INVALID_CONTENT_LENGTH","Request body size did not match Content-Length",400,RangeError),FST_ERR_CTP_EMPTY_JSON_BODY:K0("FST_ERR_CTP_EMPTY_JSON_BODY","Body cannot be empty when content-type is set to 'application/json'",400),FST_ERR_CTP_INVALID_JSON_BODY:K0("FST_ERR_CTP_INVALID_JSON_BODY","Body is not valid JSON but content-type is set to 'application/json'",400),FST_ERR_CTP_INSTANCE_ALREADY_STARTED:K0("FST_ERR_CTP_INSTANCE_ALREADY_STARTED",'Cannot call "%s" when fastify instance is already started!',400),FST_ERR_DEC_ALREADY_PRESENT:K0("FST_ERR_DEC_ALREADY_PRESENT","The decorator '%s' has already been added!"),FST_ERR_DEC_DEPENDENCY_INVALID_TYPE:K0("FST_ERR_DEC_DEPENDENCY_INVALID_TYPE","The dependencies of decorator '%s' must be of type Array.",500,TypeError),FST_ERR_DEC_MISSING_DEPENDENCY:K0("FST_ERR_DEC_MISSING_DEPENDENCY","The decorator is missing dependency '%s'."),FST_ERR_DEC_AFTER_START:K0("FST_ERR_DEC_AFTER_START","The decorator '%s' has been added after start!"),FST_ERR_DEC_REFERENCE_TYPE:K0("FST_ERR_DEC_REFERENCE_TYPE","The decorator '%s' of type '%s' is a reference type. Use the { getter, setter } interface instead."),FST_ERR_DEC_UNDECLARED:K0("FST_ERR_DEC_UNDECLARED","No decorator '%s' has been declared on %s."),FST_ERR_HOOK_INVALID_TYPE:K0("FST_ERR_HOOK_INVALID_TYPE","The hook name must be a string",500,TypeError),FST_ERR_HOOK_INVALID_HANDLER:K0("FST_ERR_HOOK_INVALID_HANDLER","%s hook should be a function, instead got %s",500,TypeError),FST_ERR_HOOK_INVALID_ASYNC_HANDLER:K0("FST_ERR_HOOK_INVALID_ASYNC_HANDLER","Async function has too many arguments. Async hooks should not use the 'done' argument.",500,TypeError),FST_ERR_HOOK_NOT_SUPPORTED:K0("FST_ERR_HOOK_NOT_SUPPORTED","%s hook not supported!",500,TypeError),FST_ERR_MISSING_MIDDLEWARE:K0("FST_ERR_MISSING_MIDDLEWARE","You must register a plugin for handling middlewares, visit fastify.dev/docs/latest/Reference/Middleware/ for more info.",500),FST_ERR_HOOK_TIMEOUT:K0("FST_ERR_HOOK_TIMEOUT","A callback for '%s' hook%s timed out. You may have forgotten to call 'done' function or to resolve a Promise"),FST_ERR_LOG_INVALID_DESTINATION:K0("FST_ERR_LOG_INVALID_DESTINATION","Cannot specify both logger.stream and logger.file options"),FST_ERR_LOG_INVALID_LOGGER:K0("FST_ERR_LOG_INVALID_LOGGER","Invalid logger object provided. The logger instance should have these functions(s): '%s'.",500,TypeError),FST_ERR_LOG_INVALID_LOGGER_INSTANCE:K0("FST_ERR_LOG_INVALID_LOGGER_INSTANCE","loggerInstance only accepts a logger instance.",500,TypeError),FST_ERR_LOG_INVALID_LOGGER_CONFIG:K0("FST_ERR_LOG_INVALID_LOGGER_CONFIG","logger options only accepts a configuration object.",500,TypeError),FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED:K0("FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED","You cannot provide both logger and loggerInstance. Please provide only one.",500,TypeError),FST_ERR_REP_INVALID_PAYLOAD_TYPE:K0("FST_ERR_REP_INVALID_PAYLOAD_TYPE","Attempted to send payload of invalid type '%s'. Expected a string or Buffer.",500,TypeError),FST_ERR_REP_RESPONSE_BODY_CONSUMED:K0("FST_ERR_REP_RESPONSE_BODY_CONSUMED","Response.body is already consumed."),FST_ERR_REP_READABLE_STREAM_LOCKED:K0("FST_ERR_REP_READABLE_STREAM_LOCKED","ReadableStream was locked. You should call releaseLock() method on reader before sending."),FST_ERR_REP_ALREADY_SENT:K0("FST_ERR_REP_ALREADY_SENT",'Reply was already sent, did you forget to "return reply" in "%s" (%s)?'),FST_ERR_REP_SENT_VALUE:K0("FST_ERR_REP_SENT_VALUE","The only possible value for reply.sent is true.",500,TypeError),FST_ERR_SEND_INSIDE_ONERR:K0("FST_ERR_SEND_INSIDE_ONERR","You cannot use `send` inside the `onError` hook"),FST_ERR_SEND_UNDEFINED_ERR:K0("FST_ERR_SEND_UNDEFINED_ERR","Undefined error has occurred"),FST_ERR_BAD_STATUS_CODE:K0("FST_ERR_BAD_STATUS_CODE","Called reply with an invalid status code: %s"),FST_ERR_BAD_TRAILER_NAME:K0("FST_ERR_BAD_TRAILER_NAME","Called reply.trailer with an invalid header name: %s"),FST_ERR_BAD_TRAILER_VALUE:K0("FST_ERR_BAD_TRAILER_VALUE","Called reply.trailer('%s', fn) with an invalid type: %s. Expected a function."),FST_ERR_FAILED_ERROR_SERIALIZATION:K0("FST_ERR_FAILED_ERROR_SERIALIZATION","Failed to serialize an error. Error: %s. Original error: %s"),FST_ERR_MISSING_SERIALIZATION_FN:K0("FST_ERR_MISSING_SERIALIZATION_FN",'Missing serialization function. Key "%s"'),FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN:K0("FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN",'Missing serialization function. Key "%s:%s"'),FST_ERR_REQ_INVALID_VALIDATION_INVOCATION:K0("FST_ERR_REQ_INVALID_VALIDATION_INVOCATION",'Invalid validation invocation. Missing validation function for HTTP part "%s" nor schema provided.'),FST_ERR_SCH_MISSING_ID:K0("FST_ERR_SCH_MISSING_ID","Missing schema $id property"),FST_ERR_SCH_ALREADY_PRESENT:K0("FST_ERR_SCH_ALREADY_PRESENT","Schema with id '%s' already declared!"),FST_ERR_SCH_CONTENT_MISSING_SCHEMA:K0("FST_ERR_SCH_CONTENT_MISSING_SCHEMA","Schema is missing for the content type '%s'"),FST_ERR_SCH_DUPLICATE:K0("FST_ERR_SCH_DUPLICATE","Schema with '%s' already present!"),FST_ERR_SCH_VALIDATION_BUILD:K0("FST_ERR_SCH_VALIDATION_BUILD","Failed building the validation schema for %s: %s, due to error %s"),FST_ERR_SCH_SERIALIZATION_BUILD:K0("FST_ERR_SCH_SERIALIZATION_BUILD","Failed building the serialization schema for %s: %s, due to error %s"),FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX:K0("FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX",'response schemas should be nested under a valid status code, e.g { 2xx: { type: "object" } }'),FST_ERR_INIT_OPTS_INVALID:K0("FST_ERR_INIT_OPTS_INVALID","Invalid initialization options: '%s'"),FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE:K0("FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE","Cannot set forceCloseConnections to 'idle' as your HTTP server does not support closeIdleConnections method"),FST_ERR_DUPLICATED_ROUTE:K0("FST_ERR_DUPLICATED_ROUTE","Method '%s' already declared for route '%s'"),FST_ERR_BAD_URL:K0("FST_ERR_BAD_URL","'%s' is not a valid url component",400,URIError),FST_ERR_ASYNC_CONSTRAINT:K0("FST_ERR_ASYNC_CONSTRAINT","Unexpected error from async constraint",500),FST_ERR_INVALID_URL:K0("FST_ERR_INVALID_URL","URL must be a string. Received '%s'",400,TypeError),FST_ERR_ROUTE_OPTIONS_NOT_OBJ:K0("FST_ERR_ROUTE_OPTIONS_NOT_OBJ",'Options for "%s:%s" route must be an object',500,TypeError),FST_ERR_ROUTE_DUPLICATED_HANDLER:K0("FST_ERR_ROUTE_DUPLICATED_HANDLER",'Duplicate handler for "%s:%s" route is not allowed!',500),FST_ERR_ROUTE_HANDLER_NOT_FN:K0("FST_ERR_ROUTE_HANDLER_NOT_FN","Error Handler for %s:%s route, if defined, must be a function",500,TypeError),FST_ERR_ROUTE_MISSING_HANDLER:K0("FST_ERR_ROUTE_MISSING_HANDLER",'Missing handler function for "%s:%s" route.',500),FST_ERR_ROUTE_METHOD_INVALID:K0("FST_ERR_ROUTE_METHOD_INVALID","Provided method is invalid!",500,TypeError),FST_ERR_ROUTE_METHOD_NOT_SUPPORTED:K0("FST_ERR_ROUTE_METHOD_NOT_SUPPORTED","%s method is not supported.",500),FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED:K0("FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED","Body validation schema for %s:%s route is not supported!",500),FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT:K0("FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT","'bodyLimit' option must be an integer > 0. Got '%s'",500,TypeError),FST_ERR_HANDLER_TIMEOUT:K0("FST_ERR_HANDLER_TIMEOUT","Request timed out after %s ms on route '%s'",503),FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT:K0("FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT","'handlerTimeout' option must be an integer > 0. Got '%s'",500,TypeError),FST_ERR_ROUTE_REWRITE_NOT_STR:K0("FST_ERR_ROUTE_REWRITE_NOT_STR",'Rewrite url for "%s" needs to be of type "string" but received "%s"',500,TypeError),FST_ERR_REOPENED_CLOSE_SERVER:K0("FST_ERR_REOPENED_CLOSE_SERVER","Fastify has already been closed and cannot be reopened"),FST_ERR_REOPENED_SERVER:K0("FST_ERR_REOPENED_SERVER","Fastify is already listening"),FST_ERR_INSTANCE_ALREADY_LISTENING:K0("FST_ERR_INSTANCE_ALREADY_LISTENING","Fastify instance is already listening. %s"),FST_ERR_PLUGIN_VERSION_MISMATCH:K0("FST_ERR_PLUGIN_VERSION_MISMATCH","fastify-plugin: %s - expected '%s' fastify version, '%s' is installed"),FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE:K0("FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE","The decorator '%s'%s is not present in %s"),FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER:K0("FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER","The %s plugin being registered mixes async and callback styles. Async plugin should not mix async and callback style.",500,TypeError),FST_ERR_PLUGIN_CALLBACK_NOT_FN:K0("FST_ERR_PLUGIN_CALLBACK_NOT_FN","fastify-plugin: %s",500,TypeError),FST_ERR_PLUGIN_NOT_VALID:K0("FST_ERR_PLUGIN_NOT_VALID","fastify-plugin: %s"),FST_ERR_ROOT_PLG_BOOTED:K0("FST_ERR_ROOT_PLG_BOOTED","fastify-plugin: %s"),FST_ERR_PARENT_PLUGIN_BOOTED:K0("FST_ERR_PARENT_PLUGIN_BOOTED","fastify-plugin: %s"),FST_ERR_PLUGIN_TIMEOUT:K0("FST_ERR_PLUGIN_TIMEOUT","fastify-plugin: %s")};function _10($,Z){return Z.cause=$,Z}k4.exports=d5;k4.exports.appendStackTrace=_10;k4.exports.AVVIO_ERRORS_MAP={AVV_ERR_CALLBACK_NOT_FN:d5.FST_ERR_PLUGIN_CALLBACK_NOT_FN,AVV_ERR_PLUGIN_NOT_VALID:d5.FST_ERR_PLUGIN_NOT_VALID,AVV_ERR_ROOT_PLG_BOOTED:d5.FST_ERR_ROOT_PLG_BOOTED,AVV_ERR_PARENT_PLG_LOADED:d5.FST_ERR_PARENT_PLUGIN_BOOTED,AVV_ERR_READY_TIMEOUT:d5.FST_ERR_PLUGIN_TIMEOUT,AVV_ERR_PLUGIN_EXEC_TIMEOUT:d5.FST_ERR_PLUGIN_TIMEOUT}});var mZ=S((yf0,eR)=>{var S10=["onRoute","onRegister","onReady","onListen","preClose","onClose"],oR=["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError","onRequestAbort"],f10=oR.concat(S10),{FST_ERR_HOOK_INVALID_TYPE:k10,FST_ERR_HOOK_INVALID_HANDLER:v10,FST_ERR_SEND_UNDEFINED_ERR:v4,FST_ERR_HOOK_TIMEOUT:y10,FST_ERR_HOOK_NOT_SUPPORTED:x10,AVVIO_ERRORS_MAP:cR,appendStackTrace:iR}=T$(),{kChildren:CX,kHooks:sR,kRequestPayloadStream:nR}=B$();function IX(){this.onRequest=[],this.preParsing=[],this.preValidation=[],this.preSerialization=[],this.preHandler=[],this.onResponse=[],this.onSend=[],this.onError=[],this.onRoute=[],this.onRegister=[],this.onReady=[],this.onListen=[],this.onTimeout=[],this.onRequestAbort=[],this.preClose=[]}IX.prototype=Object.create(null);IX.prototype.validate=function($,Z){if(typeof $!=="string")throw new k10;if(Array.isArray(this[$])===!1)throw new x10($);if(typeof Z!=="function")throw new v10($,Object.prototype.toString.call(Z))};IX.prototype.add=function($,Z){this.validate($,Z),this[$].push(Z)};function h10($){let Z=new IX;return Z.onRequest=$.onRequest.slice(),Z.preParsing=$.preParsing.slice(),Z.preValidation=$.preValidation.slice(),Z.preSerialization=$.preSerialization.slice(),Z.preHandler=$.preHandler.slice(),Z.onSend=$.onSend.slice(),Z.onResponse=$.onResponse.slice(),Z.onError=$.onError.slice(),Z.onRoute=$.onRoute.slice(),Z.onRegister=$.onRegister.slice(),Z.onTimeout=$.onTimeout.slice(),Z.onRequestAbort=$.onRequestAbort.slice(),Z.onReady=[],Z.onListen=[],Z.preClose=[],Z}function rR($,Z,J,Y){let X=J[sR][$],Q=0,G=0;K();function W(U){let H=X[Q-1]?.name,B=H?` "${H}"`:"";if(U){if(U.code==="AVV_ERR_READY_TIMEOUT")U=iR(U,new y10($,B));else U=cR[U.code]!=null?iR(U,new cR[U.code](U.message)):U;Y(U);return}Y()}function K(U){if(U){W(U);return}if(Q===X.length&&G===J[CX].length){if(Q===0&&G===0)W();else Z(function(B,z){W(B),z(B)});return}if(Q===X.length&&G<J[CX].length){let H=J[CX][G++];rR($,Z,H,K);return}Z(V(X[Q++],J)),K()}function V(U,H){return function(B,z){if(B){z(B);return}if(U.length===1){try{U.call(H,z)}catch(F){z(F)}return}try{let F=U.call(H);if(F&&typeof F.then==="function"){F.then(z,z);return}}catch(F){B=F}z(B)}}}function aR($){let Z=$[sR].onListen,J=Z.length,Y=0,X=0;Q();function Q(W){if(W&&$.log.error(W),Y===J){while(X<$[CX].length){let K=$[CX][X++];aR(K)}return}G(Z[Y++],$,Q)}async function G(W,K,V){if(W.length===1){try{W.call(K,V)}catch(U){V(U)}return}try{let U=W.call(K);if(U&&typeof U.then==="function"){U.then(V,V);return}V()}catch(U){V(U)}}}function LJ($){return function(J,Y,X,Q){let G=0;function W(U){if(U||G===J.length){Q(U,Y,X);return}let H;try{H=$(J[G++],Y,X,W)}catch(B){Q(B,Y,X);return}if(H&&typeof H.then==="function")H.then(K,V)}function K(){W()}function V(U){if(!U)U=new v4;Q(U,Y,X)}W()}}function g10($,Z,J,Y){return $(Z,J,Y)}var u10=LJ(g10),m10=LJ(EX),l10=LJ(EX),d10=LJ(EX),p10=LJ(EX);function tR($,Z,J,Y,X){let Q=0;function G(V,U){if(V){X(V,Z,J,Y);return}if(U!==void 0)Y=U;if(Q===$.length){X(null,Z,J,Y);return}let H;try{H=$[Q++](Z,J,Y,G)}catch(B){X(B,Z,J);return}if(H&&typeof H.then==="function")H.then(W,K)}function W(V){G(null,V)}function K(V){if(!V)V=new v4;X(V,Z,J,Y)}G()}var c10=tR;function i10($,Z,J,Y){let X=0;function Q(K,V){if(J.sent)return;if(V!==void 0)Z[nR]=V;if(K||X===$.length){Y(K,Z,J);return}let U;try{U=$[X++](Z,J,Z[nR],Q)}catch(H){Y(H,Z,J);return}if(U&&typeof U.then==="function")U.then(G,W)}function G(K){Q(null,K)}function W(K){if(!K)K=new v4;Y(K,Z,J)}Q()}function n10($,Z,J){let Y=0;function X(W){if(W||Y===$.length){J(W,Z);return}let K;try{K=$[Y++](Z,X)}catch(V){J(V,Z);return}if(K&&typeof K.then==="function")K.then(Q,G)}function Q(){X()}function G(W){if(!W)W=new v4;J(W,Z)}X()}function EX($,Z,J,Y){if(J.sent===!0)return;return $(Z,J,Y)}eR.exports={Hooks:IX,buildHooks:h10,hookRunnerGenerator:LJ,preParsingHookRunner:i10,onResponseHookRunner:u10,onSendHookRunner:tR,preSerializationHookRunner:c10,onRequestAbortHookRunner:n10,hookIterator:EX,hookRunnerApplication:rR,onListenHookRunner:aR,preHandlerHookRunner:l10,preValidationHookRunner:m10,onRequestHookRunner:p10,onTimeoutHookRunner:d10,lifecycleHooks:oR,supportedHooks:f10}});var ZP=S((xf0,$P)=>{$P.exports=function(){return{[Symbol.iterator]:function*(){},add(){},delete(){},has(){return!0}}}});var uH=S((hf0,YP)=>{var{kTestInternals:o10}=B$();function JP(){let $,Z;return{promise:new Promise((Y,X)=>{$=Y,Z=X}),resolve:$,reject:Z}}YP.exports={withResolvers:typeof Promise.withResolvers==="function"?Promise.withResolvers.bind(Promise):JP,[o10]:{withResolvers:JP}}});var FP=S((V$0,zP)=>{var s10=J0("http"),r10=J0("https"),XP=J0("http2"),a10=J0("dns"),t10=J0("os"),{kState:W$,kOptions:e10,kServerBindings:$$0,kHttp2ServerSessions:p5}=B$(),{FSTWRN003:Z$0}=wJ(),{onListenHookRunner:y4}=mZ(),{FST_ERR_REOPENED_CLOSE_SERVER:GP,FST_ERR_REOPENED_SERVER:WP,FST_ERR_LISTEN_OPTIONS_INVALID:J$0,FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE:Y$0}=T$(),X$0=ZP(),KP=uH();V$0.createServer=Q$0;function VP($){return`Server listening at ${$}`}function Q$0($,Z){let J=HP($,Z);function Y(V={port:0,host:"localhost"},U=void 0){if(typeof U==="function"){if(U.constructor.name==="AsyncFunction")Z$0("listen method");V.cb=U}if(V.signal){if(typeof V.signal.on!=="function"&&typeof V.signal.addEventListener!=="function")throw new J$0("Invalid options.signal");if(this[W$].aborted=V.signal.aborted,this[W$].aborted)return this.close();else{let B=()=>{this[W$].aborted=!0,this.close()};V.signal.addEventListener("abort",B,{once:!0})}}let H;if(V.path==null)H=V.host??"localhost";else H=V.host;if(!Object.hasOwn(V,"host")||V.host==null)V.host=H;if(H==="localhost")V.cb=(B,z)=>{if(B){U(B,z);return}QP.call(this,J,Z,$,V,()=>{this[W$].listening=!0,U(null,z),y4(this)})};else V.cb=(B,z)=>{if(B){U(B,z);return}this[W$].listening=!0,U(null,z),y4(this)};if(U===void 0)return G$0.call(this,J,V).then((z)=>{let{promise:F,resolve:A}=KP.withResolvers();if(H==="localhost")QP.call(this,J,Z,$,V,()=>{this[W$].listening=!0,A(z),y4(this)});else A(z),y4(this);return F});this.ready(UP.call(this,J,V))}let X=typeof J.closeAllConnections==="function",Q=typeof J.closeIdleConnections==="function",G=typeof J.closeHttp2Sessions==="function",W=$.forceCloseConnections;if(W==="idle"&&!Q)throw new Y$0;else if(typeof W!=="boolean")W=Q?"idle":!1;let K=!X&&W===!0?new Set:X$0();return{server:J,listen:Y,forceCloseConnections:W,serverHasCloseAllConnections:X,serverHasCloseHttp2Sessions:G,keepAliveConnections:K}}function QP($,Z,J,Y,X){this[W$].listening=!1,a10.lookup(Y.host,{all:!0},(Q,G)=>{if(Q||this[W$].aborted){X();return}let W=$.listening&&J.serverFactory,K=0,V=0;if(!W){let H=$.address();for(let B of G)if(B.address!==H.address){K++;let z=Object.assign({},Y,{host:B.address,port:H.port,cb:(N)=>{if(V++,!N)this[$$0].push(F);if(V===K)X()}}),F=HP(J,Z),A=()=>{if(F.close(()=>{}),typeof F.closeAllConnections==="function"&&J.forceCloseConnections===!0)F.closeAllConnections();if(typeof F.closeHttp2Sessions==="function")F.closeHttp2Sessions()};F.on("upgrade",$.emit.bind($,"upgrade")),$.on("unref",A),$.on("close",A),$.on("error",A),this[W$].listening=!1,UP.call(this,F,z)()}}if(K===0){X();return}let U=$.unref;$.unref=function(){U.call($),$.emit("unref")}})}function UP($,Z){let J=(Y)=>{if($.removeListener("error",J),$.removeListener("listening",J),!Y){let X=BP.call(this,$,Z.listenTextResolver||VP);Z.cb(null,X)}else this[W$].listening=!1,Z.cb(Y,null)};return(Y)=>{if(Y!=null)return Z.cb(Y);if(this[W$].listening&&this[W$].closing)return Z.cb(new GP,null);if(this[W$].listening)return Z.cb(new WP,null);if($.once("error",J),!this[W$].closing)$.once("listening",J),$.listen(Z),this[W$].listening=!0}}function G$0($,Z){if(this[W$].listening&&this[W$].closing)return Promise.reject(new GP);if(this[W$].listening)return Promise.reject(new WP);return this.ready().then(()=>{if(this[W$].aborted)return;let{promise:J,resolve:Y,reject:X}=KP.withResolvers(),Q=(K)=>{W(),this[W$].listening=!1,X(K)},G=()=>{W(),this[W$].listening=!0,Y(BP.call(this,$,Z.listenTextResolver||VP))};function W(){$.removeListener("error",Q),$.removeListener("listening",G)}return $.once("error",Q),$.once("listening",G),$.listen(Z),J})}function HP($,Z){if($.serverFactory)return $.serverFactory(Z,$);let J=$.https===!0?{}:$.https;if($.http2){let X=typeof J==="object"?XP.createSecureServer(J,Z):XP.createServer($.http,Z);if(X.on("session",(Q)=>Q.setTimeout($.http2SessionTimeout,()=>{Q.close()})),$.forceCloseConnections===!0)X.closeHttp2Sessions=K$0(X);return X.setTimeout($.connectionTimeout),X}let Y=J?r10.createServer(J,Z):s10.createServer($.http,Z);if(Y.keepAliveTimeout=$.keepAliveTimeout,Y.requestTimeout=$.requestTimeout,Y.setTimeout($.connectionTimeout),$.maxRequestsPerSocket>0)Y.maxRequestsPerSocket=$.maxRequestsPerSocket;return Y}function W$0($){if($.address==="0.0.0.0")return Object.values(t10.networkInterfaces()).flatMap((Z)=>{return Z.filter((J)=>J.family==="IPv4")}).sort((Z)=>{return Z.internal?-1:1}).map((Z)=>{return Z.address});return[$.address]}function BP($,Z){let J;if(typeof $.address()!=="string"){if($.address().address.indexOf(":")===-1)J=W$0($.address()).map((X)=>X+":"+$.address().port);else J=["["+$.address().address+"]:"+$.address().port];J=J.map((X)=>"http"+(this[e10].https?"s":"")+"://"+X)}else J=[$.address()];for(let X of J)this.log.info(Z(X));return J[0]}function K$0($){return $[p5]=new Set,$.on("session",function(Z){Z.once("connect",function(){$[p5].add(Z)}),Z.once("close",function(){$[p5].delete(Z)}),Z.once("frameError",function(J,Y,X){if(X===0)$[p5].delete(Z)}),Z.once("goaway",function(){$[p5].delete(Z)})}),function(){if($[p5].size===0)return;for(let J of $[p5])J.close()}}});var lH=S((gf0,NP)=>{var mH=/(?:^|;)\s*([\w!#$%&'*+.^`|~-]+)=([^;]*)/gm,AP=/^[\w!#$%&'*+.^`|~-]+$/,OP=/^[\w!#$%&'*+.^`|~-]+\s*$/;class jP{#$=!1;#Z=!0;#J="";#Y="";#X=new Map;#Q;constructor($){if($==null||$===""||$==="undefined")return;let Z=$.indexOf(";");if(Z===-1){if(Z=$.indexOf("/"),Z===-1)return;let W=$.slice(0,Z).trimStart().toLowerCase(),K=$.slice(Z+1).trimEnd().toLowerCase();if(AP.test(W)===!0&&OP.test(K)===!0)this.#$=!0,this.#Z=!1,this.#J=W,this.#Y=K;return}let J=$.slice(0,Z).toLowerCase(),Y=$.slice(Z+1).trim();if(Z=J.indexOf("/"),Z===-1)return;let X=J.slice(0,Z).trimStart(),Q=J.slice(Z+1).trimEnd();if(AP.test(X)===!1||OP.test(Q)===!1)return;this.#J=X,this.#Y=Q,this.#$=!0,this.#Z=!1;let G=mH.exec(Y);while(G){let W=G[1],K=G[2];if(K[0]==='"'){if(K.at(-1)!=='"'){this.#X.set(W,"invalid quoted string"),G=mH.exec(Y);continue}this.#X.set(W,K.slice(1,K.length-1))}else this.#X.set(W,K);G=mH.exec(Y)}}get[Symbol.toStringTag](){return"ContentType"}get isEmpty(){return this.#Z}get isValid(){return this.#$}get mediaType(){return`${this.#J}/${this.#Y}`}get type(){return this.#J}get subtype(){return this.#Y}get parameters(){return this.#X}toString(){if(this.#Q)return this.#Q;let $=[];for(let[J,Y]of this.#X.entries())$.push(`${J}="${Y}"`);let Z=[this.#J,"/",this.#Y];if($.length>0)Z.push("; "),Z.push($.join("; "));return this.#Q=Z.join(""),this.#Q}}NP.exports=jP});var x4=S((uf0,qP)=>{var{kReplyHasStatusCode:H$0}=B$();function B$0($,Z){if(!$[H$0]||$.statusCode===200){let J=Z&&(Z.statusCode||Z.status);$.code(J>=400?J:500)}}qP.exports={setErrorStatusCode:B$0}});var dH=S((mf0,DP)=>{var{kReplyIsError:MP,kReplyHijacked:z$0}=B$(),{setErrorStatusCode:F$0}=x4(),A$0=J0("diagnostics_channel"),bX=A$0.tracingChannel("fastify.request.handler");function O$0($,Z,J){if(J)J.async=!0;$.then(function(Y){if(Z[z$0]===!0)return;if(J)bX.asyncStart.publish(J);try{if(Y!==void 0||Z.sent===!1&&Z.raw.headersSent===!1&&Z.request.raw.aborted===!1&&Z.request.socket&&!Z.request.socket.destroyed)try{Z.send(Y)}catch(X){Z[MP]=!0,Z.send(X)}}finally{if(J)bX.asyncEnd.publish(J)}},function(Y){if(J)J.error=Y,F$0(Z,Y),bX.error.publish(J),bX.asyncStart.publish(J);try{if(Z.sent===!0){Z.log.error({err:Y},"Promise errored, but reply.sent = true was set");return}Z[MP]=!0,Z.send(Y)}catch(X){Z.send(X)}finally{if(J)bX.asyncEnd.publish(J)}})}DP.exports=O$0});var iH=S((lf0,LP)=>{var{kSchemaHeaders:u4,kSchemaParams:pH,kSchemaQuerystring:cH,kSchemaBody:c5,kSchemaResponse:wP}=B$(),j$0=/^[1-5](?:\d{2}|xx)$|^default$/,{FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX:N$0}=T$(),{FSTWRN001:h4}=wJ();function q$0($,Z){if(!$.schema||!$.schema.response)return;let{method:J,url:Y}=$.config||{};$[wP]=Object.keys($.schema.response).reduce(function(X,Q){let G=$.schema.response[Q];if(Q=Q.toLowerCase(),!j$0.test(Q))throw new N$0;if(G.content){let W={};for(let K of Object.keys(G.content)){let V=G.content[K].schema;W[K]=Z({schema:V,url:Y,method:J,httpStatus:Q,contentType:K})}X[Q]=W}else X[Q]=Z({schema:G,url:Y,method:J,httpStatus:Q});return X},{})}function M$0($,Z,J){let{schema:Y}=$;if(!Y)return;let{method:X,url:Q}=$.config||{},G=Y.headers;if(G&&(J||Object.getPrototypeOf(G)!==Object.prototype))$[u4]=Z({schema:G,method:X,url:Q,httpPart:"headers"});else if(G){let W={};if(Object.keys(G).forEach((K)=>{W[K]=G[K]}),W.required instanceof Array)W.required=W.required.map((K)=>K.toLowerCase());if(G.properties)W.properties={},Object.keys(G.properties).forEach((K)=>{W.properties[K.toLowerCase()]=G.properties[K]});$[u4]=Z({schema:W,method:X,url:Q,httpPart:"headers"})}else if(Object.hasOwn(Y,"headers"))h4("headers",X,Q);if(Y.body){let W=Y.body.content;if(W){let K={};for(let V of Object.keys(W)){let U=W[V].schema;K[V]=Z({schema:U,method:X,url:Q,httpPart:"body",contentType:V})}$[c5]=K}else $[c5]=Z({schema:Y.body,method:X,url:Q,httpPart:"body"})}else if(Object.hasOwn(Y,"body"))h4("body",X,Q);if(Y.querystring)$[cH]=Z({schema:Y.querystring,method:X,url:Q,httpPart:"querystring"});else if(Object.hasOwn(Y,"querystring"))h4("querystring",X,Q);if(Y.params)$[pH]=Z({schema:Y.params,method:X,url:Q,httpPart:"params"});else if(Object.hasOwn(Y,"params"))h4("params",X,Q)}function g4($,Z,J){let Y=Z[J]===void 0,X;try{X=$?.(Y?null:Z[J])}catch(G){return G.statusCode=500,G}if(X&&typeof X.then==="function")return X.then((G)=>{return Q(G)}).catch((G)=>{return G});return Q(X);function Q(G){if(G===!1)return $.errors;if(G&&G.error)return G.error;if(G&&G.value)Z[J]=G.value;return!1}}function m4($,Z,J){let Y=J===void 0;if(Y||!J.skipParams){let Q=g4($[pH],Z,"params");if(Q)if(typeof Q.then!=="function")return lZ(Q,"params",$.schemaErrorFormatter);else return D$0(Q,$,Z)}if(Y||!J.skipBody){let Q=null;if(typeof $[c5]==="function")Q=$[c5];else if($[c5]){let W=R$0(Z.headers["content-type"]),K=$[c5][W];if(K)Q=K}let G=g4(Q,Z,"body");if(G)if(typeof G.then!=="function")return lZ(G,"body",$.schemaErrorFormatter);else return w$0(G,$,Z)}if(Y||!J.skipQuery){let Q=g4($[cH],Z,"query");if(Q)if(typeof Q.then!=="function")return lZ(Q,"querystring",$.schemaErrorFormatter);else return L$0(Q,$,Z)}let X=g4($[u4],Z,"headers");if(X)if(typeof X.then!=="function")return lZ(X,"headers",$.schemaErrorFormatter);else return T$0(X,$,Z);return!1}function D$0($,Z,J){return $.then((Y)=>{if(Y)return lZ(Y,"params",Z.schemaErrorFormatter);return m4(Z,J,{skipParams:!0})})}function w$0($,Z,J){return $.then((Y)=>{if(Y)return lZ(Y,"body",Z.schemaErrorFormatter);return m4(Z,J,{skipParams:!0,skipBody:!0})})}function L$0($,Z,J){return $.then((Y)=>{if(Y)return lZ(Y,"querystring",Z.schemaErrorFormatter);return m4(Z,J,{skipParams:!0,skipBody:!0,skipQuery:!0})})}function T$0($,Z,J){return $.then((Y)=>{if(Y)return lZ(Y,"headers",Z.schemaErrorFormatter);return!1})}function lZ($,Z,J){if($ instanceof Error)return $.statusCode=$.statusCode||400,$.code=$.code||"FST_ERR_VALIDATION",$.validationContext=$.validationContext||Z,$;let Y=J($,Z);return Y.statusCode=Y.statusCode||400,Y.code=Y.code||"FST_ERR_VALIDATION",Y.validation=$,Y.validationContext=Z,Y}function R$0($){if(!$)return"";return $.trimStart().split(/[ ;]/,1)[0].trim().toLowerCase()}LP.exports={symbols:{bodySchema:c5,querystringSchema:cH,responseSchema:wP,paramsSchema:pH,headersSchema:u4},compileSchemasForValidation:M$0,compileSchemasForSerialization:q$0,validate:m4}});var rH=S((df0,sH)=>{var P$0=J0("diagnostics_channel"),C$0=lH(),I$0=dH(),{validate:E$0}=iH(),{preValidationHookRunner:b$0,preHandlerHookRunner:_$0}=mZ(),{FST_ERR_CTP_INVALID_MEDIA_TYPE:S$0}=T$(),{setErrorStatusCode:TP}=x4(),{kReplyIsError:SX,kRouteContext:R6,kFourOhFourContext:f$0,kSupportedHTTPMethods:RP}=B$(),_X=P$0.tracingChannel("fastify.request.handler");function k$0($,Z,J){if(J.sent===!0)return;if($!=null){J[SX]=!0,J.send($);return}let Y=Z.method;if(this[RP].bodyless.has(Y)){TJ(Z,J);return}if(this[RP].bodywith.has(Y)){let X=Z.headers,Q=X["content-type"];if(Q===void 0){let W=X["content-length"];if(X["transfer-encoding"]===void 0&&(W===void 0||W==="0")){TJ(Z,J);return}Z[R6].contentTypeParser.run("",TJ,Z,J);return}let G=new C$0(Q);if(G.isValid===!1){J[SX]=!0,J.status(415).send(new S$0);return}Z[R6].contentTypeParser.run(G.toString(),TJ,Z,J);return}TJ(Z,J)}function TJ($,Z){try{if($[R6].preValidation!==null)b$0($[R6].preValidation,$,Z,nH);else nH(null,$,Z)}catch(J){nH(J,$,Z)}}function nH($,Z,J){if(J.sent===!0)return;if($!=null){J[SX]=!0,J.send($);return}let Y=E$0(J[R6],Z);if(Y&&typeof Y.then==="function"||!1){let Q=PP.bind(null,Z,J);Y.then(Q,Q)}else PP(Z,J,Y)}function PP($,Z,J){if(J){if(Z[R6].attachValidation===!1){Z.send(J);return}Z.request.validationError=J}if($[R6].preHandler!==null)_$0($[R6].preHandler,$,Z,oH);else oH(null,$,Z)}function oH($,Z,J){if(J.sent)return;let Y=Z[R6];if(!_X.hasSubscribers||Y[f$0]===null)CP($,Z,J);else{let X={request:Z,reply:J,async:!1,route:{url:Y.config.url,method:Y.config.method}};_X.start.runStores(X,CP,void 0,$,Z,J,X)}}function CP($,Z,J,Y){let X=Z[R6];try{if($!=null){if(J[SX]=!0,Y)Y.error=$,TP(J,$),_X.error.publish(Y);J.send($);return}let Q;try{Q=X.handler(Z,J)}catch(G){if(Y)Y.error=G,TP(J,G),_X.error.publish(Y);J[SX]=!0,J.send(G);return}if(Q!==void 0)if(Q!==null&&typeof Q.then==="function")I$0(Q,J,Y);else J.send(Q)}finally{if(Y)_X.end.publish(Y)}}sH.exports=k$0;sH.exports[Symbol.for("internals")]={handler:TJ,preHandlerCallback:oH}});var EP=S((pf0,IP)=>{function RJ(){}var v$0={fatal:RJ,error:RJ,warn:RJ,info:RJ,debug:RJ,trace:RJ};Object.defineProperty(IP,"exports",{get(){return Object.create(v$0)}})});var tH=S((cf0,SP)=>{var fX=($)=>{return $&&typeof $.message==="string"},aH=($)=>{if(!$)return;let Z=$.cause;if(typeof Z==="function"){let J=$.cause();return fX(J)?J:void 0}else return fX(Z)?Z:void 0},bP=($,Z)=>{if(!fX($))return"";let J=$.stack||"";if(Z.has($))return J+`
|
|
85
|
+
causes have become circular...`;let Y=aH($);if(Y)return Z.add($),J+`
|
|
86
|
+
caused by: `+bP(Y,Z);else return J},y$0=($)=>bP($,new Set),_P=($,Z,J)=>{if(!fX($))return"";let Y=J?"":$.message||"";if(Z.has($))return Y+": ...";let X=aH($);if(X){Z.add($);let Q=typeof $.cause==="function";return Y+(Q?"":": ")+_P(X,Z,Q)}else return Y},x$0=($)=>_P($,new Set);SP.exports={isErrorLike:fX,getErrorCause:aH,stackWithCauses:y$0,messageWithCauses:x$0}});var eH=S((if0,kP)=>{var h$0=Symbol("circular-ref-tag"),l4=Symbol("pino-raw-err-ref"),fP=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},aggregateErrors:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[l4]},set:function($){this[l4]=$}}});Object.defineProperty(fP,l4,{writable:!0,value:{}});kP.exports={pinoErrProto:fP,pinoErrorSymbols:{seen:h$0,rawSymbol:l4}}});var xP=S((nf0,yP)=>{yP.exports=ZB;var{messageWithCauses:g$0,stackWithCauses:u$0,isErrorLike:vP}=tH(),{pinoErrProto:m$0,pinoErrorSymbols:l$0}=eH(),{seen:$B}=l$0,{toString:d$0}=Object.prototype;function ZB($){if(!vP($))return $;$[$B]=void 0;let Z=Object.create(m$0);if(Z.type=d$0.call($.constructor)==="[object Function]"?$.constructor.name:$.name,Z.message=g$0($),Z.stack=u$0($),Array.isArray($.errors))Z.aggregateErrors=$.errors.map((J)=>ZB(J));for(let J in $)if(Z[J]===void 0){let Y=$[J];if(vP(Y)){if(J!=="cause"&&!Object.prototype.hasOwnProperty.call(Y,$B))Z[J]=ZB(Y)}else Z[J]=Y}return delete $[$B],Z.raw=$,Z}});var gP=S((of0,hP)=>{hP.exports=p4;var{isErrorLike:JB}=tH(),{pinoErrProto:p$0,pinoErrorSymbols:c$0}=eH(),{seen:d4}=c$0,{toString:i$0}=Object.prototype;function p4($){if(!JB($))return $;$[d4]=void 0;let Z=Object.create(p$0);if(Z.type=i$0.call($.constructor)==="[object Function]"?$.constructor.name:$.name,Z.message=$.message,Z.stack=$.stack,Array.isArray($.errors))Z.aggregateErrors=$.errors.map((J)=>p4(J));if(JB($.cause)&&!Object.prototype.hasOwnProperty.call($.cause,d4))Z.cause=p4($.cause);for(let J in $)if(Z[J]===void 0){let Y=$[J];if(JB(Y)){if(!Object.prototype.hasOwnProperty.call(Y,d4))Z[J]=p4(Y)}else Z[J]=Y}return delete $[d4],Z.raw=$,Z}});var dP=S((sf0,lP)=>{lP.exports={mapHttpRequest:n$0,reqSerializer:mP};var YB=Symbol("pino-raw-req-ref"),uP=Object.create({},{id:{enumerable:!0,writable:!0,value:""},method:{enumerable:!0,writable:!0,value:""},url:{enumerable:!0,writable:!0,value:""},query:{enumerable:!0,writable:!0,value:""},params:{enumerable:!0,writable:!0,value:""},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:""},remotePort:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[YB]},set:function($){this[YB]=$}}});Object.defineProperty(uP,YB,{writable:!0,value:{}});function mP($){let Z=$.info||$.socket,J=Object.create(uP);if(J.id=typeof $.id==="function"?$.id():$.id||($.info?$.info.id:void 0),J.method=$.method,$.originalUrl)J.url=$.originalUrl;else{let Y=$.path;J.url=typeof Y==="string"?Y:$.url?$.url.path||$.url:void 0}if($.query)J.query=$.query;if($.params)J.params=$.params;return J.headers=$.headers,J.remoteAddress=Z&&Z.remoteAddress,J.remotePort=Z&&Z.remotePort,J.raw=$.raw||$,J}function n$0($){return{req:mP($)}}});var nP=S((rf0,iP)=>{iP.exports={mapHttpResponse:o$0,resSerializer:cP};var XB=Symbol("pino-raw-res-ref"),pP=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[XB]},set:function($){this[XB]=$}}});Object.defineProperty(pP,XB,{writable:!0,value:{}});function cP($){let Z=Object.create(pP);return Z.statusCode=$.headersSent?$.statusCode:null,Z.headers=$.getHeaders?$.getHeaders():$._headers,Z.raw=$,Z}function o$0($){return{res:cP($)}}});var GB=S((af0,oP)=>{var QB=xP(),s$0=gP(),c4=dP(),i4=nP();oP.exports={err:QB,errWithCause:s$0,mapHttpRequest:c4.mapHttpRequest,mapHttpResponse:i4.mapHttpResponse,req:c4.reqSerializer,res:i4.resSerializer,wrapErrorSerializer:function(Z){if(Z===QB)return Z;return function(Y){return Z(QB(Y))}},wrapRequestSerializer:function(Z){if(Z===c4.reqSerializer)return Z;return function(Y){return Z(c4.reqSerializer(Y))}},wrapResponseSerializer:function(Z){if(Z===i4.resSerializer)return Z;return function(Y){return Z(i4.resSerializer(Y))}}}});var WB=S((tf0,sP)=>{function r$0($,Z){return Z}sP.exports=function(){let Z=Error.prepareStackTrace;Error.prepareStackTrace=r$0;let J=Error().stack;if(Error.prepareStackTrace=Z,!Array.isArray(J))return;let Y=J.slice(2),X=[];for(let Q of Y){if(!Q)continue;X.push(Q.getFileName())}return X}});var ZC=S((ef0,$C)=>{function KB($){if($===null||typeof $!=="object")return $;if($ instanceof Date)return new Date($.getTime());if($ instanceof Array){let Z=[];for(let J=0;J<$.length;J++)Z[J]=KB($[J]);return Z}if(typeof $==="object"){let Z=Object.create(Object.getPrototypeOf($));for(let J in $)if(Object.prototype.hasOwnProperty.call($,J))Z[J]=KB($[J]);return Z}return $}function rP($){let Z=[],J="",Y=!1,X=!1,Q="";for(let G=0;G<$.length;G++){let W=$[G];if(!Y&&W==="."){if(J)Z.push(J),J=""}else if(W==="["){if(J)Z.push(J),J="";Y=!0}else if(W==="]"&&Y)Z.push(J),J="",Y=!1,X=!1;else if((W==='"'||W==="'")&&Y)if(!X)X=!0,Q=W;else if(W===Q)X=!1,Q="";else J+=W;else J+=W}if(J)Z.push(J);return Z}function aP($,Z,J){let Y=$;for(let Q=0;Q<Z.length-1;Q++){let G=Z[Q];if(typeof Y!=="object"||Y===null||!(G in Y))return!1;if(typeof Y[G]!=="object"||Y[G]===null)return!1;Y=Y[G]}let X=Z[Z.length-1];if(X==="*"){if(Array.isArray(Y))for(let Q=0;Q<Y.length;Q++)Y[Q]=J;else if(typeof Y==="object"&&Y!==null){for(let Q in Y)if(Object.prototype.hasOwnProperty.call(Y,Q))Y[Q]=J}}else if(typeof Y==="object"&&Y!==null&&X in Y&&Object.prototype.hasOwnProperty.call(Y,X))Y[X]=J;return!0}function tP($,Z){let J=$;for(let X=0;X<Z.length-1;X++){let Q=Z[X];if(typeof J!=="object"||J===null||!(Q in J))return!1;if(typeof J[Q]!=="object"||J[Q]===null)return!1;J=J[Q]}let Y=Z[Z.length-1];if(Y==="*"){if(Array.isArray(J))for(let X=0;X<J.length;X++)J[X]=void 0;else if(typeof J==="object"&&J!==null){for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X))delete J[X]}}else if(typeof J==="object"&&J!==null&&Y in J&&Object.prototype.hasOwnProperty.call(J,Y))delete J[Y];return!0}var n4=Symbol("PATH_NOT_FOUND");function a$0($,Z){let J=$;for(let Y of Z){if(J===null||J===void 0)return n4;if(typeof J!=="object"||J===null)return n4;if(!(Y in J))return n4;J=J[Y]}return J}function t$0($,Z){let J=$;for(let Y of Z){if(J===null||J===void 0)return;if(typeof J!=="object"||J===null)return;J=J[Y]}return J}function e$0($,Z,J,Y=!1){for(let X of Z){let Q=rP(X);if(Q.includes("*"))eP($,Q,J,X,Y);else if(Y)tP($,Q);else{let G=a$0($,Q);if(G===n4)continue;let W=typeof J==="function"?J(G,Q):J;aP($,Q,W)}}}function eP($,Z,J,Y,X=!1){let Q=Z.indexOf("*");if(Q===Z.length-1){let G=Z.slice(0,-1),W=$;for(let K of G){if(W===null||W===void 0)return;if(typeof W!=="object"||W===null)return;W=W[K]}if(Array.isArray(W))if(X)for(let K=0;K<W.length;K++)W[K]=void 0;else for(let K=0;K<W.length;K++){let V=[...G,K.toString()],U=typeof J==="function"?J(W[K],V):J;W[K]=U}else if(typeof W==="object"&&W!==null)if(X){let K=[];for(let V in W)if(Object.prototype.hasOwnProperty.call(W,V))K.push(V);for(let V of K)delete W[V]}else for(let K in W){let V=[...G,K],U=typeof J==="function"?J(W[K],V):J;W[K]=U}}else $80($,Z,J,Q,Y,X)}function $80($,Z,J,Y,X,Q=!1){let G=Z.slice(0,Y),W=Z.slice(Y+1),K=[];function V(U,H){if(H===G.length){if(Array.isArray(U))for(let B=0;B<U.length;B++)K[H]=B.toString(),V(U[B],H+1);else if(typeof U==="object"&&U!==null)for(let B in U)K[H]=B,V(U[B],H+1)}else if(H<G.length){let B=G[H];if(U&&typeof U==="object"&&U!==null&&B in U)K[H]=B,V(U[B],H+1)}else if(W.includes("*"))eP(U,W,typeof J==="function"?(z,F)=>{let A=[...K.slice(0,H),...F];return J(z,A)}:J,X,Q);else if(Q)tP(U,W);else{let B=typeof J==="function"?J(t$0(U,W),[...K.slice(0,H),...W]):J;aP(U,W,B)}}if(G.length===0)V($,0);else{let U=$;for(let H=0;H<G.length;H++){let B=G[H];if(U===null||U===void 0)return;if(typeof U!=="object"||U===null)return;U=U[B],K[H]=B}if(U!==null&&U!==void 0)V(U,G.length)}}function Z80($){if($.length===0)return null;let Z=new Map;for(let J of $){let Y=rP(J),X=Z;for(let Q=0;Q<Y.length;Q++){let G=Y[Q];if(!X.has(G))X.set(G,new Map);X=X.get(G)}}return Z}function J80($,Z){if(!Z)return $;function J(Y,X,Q=0){if(!X||X.size===0)return Y;if(Y===null||typeof Y!=="object")return Y;if(Y instanceof Date)return new Date(Y.getTime());if(Array.isArray(Y)){let W=[];for(let K=0;K<Y.length;K++){let V=K.toString();if(X.has(V)||X.has("*"))W[K]=J(Y[K],X.get(V)||X.get("*"));else W[K]=Y[K]}return W}let G=Object.create(Object.getPrototypeOf(Y));for(let W in Y)if(Object.prototype.hasOwnProperty.call(Y,W))if(X.has(W)||X.has("*"))G[W]=J(Y[W],X.get(W)||X.get("*"));else G[W]=Y[W];return G}return J($,Z)}function Y80($){if(typeof $!=="string")throw Error("Paths must be (non-empty) strings");if($==="")throw Error("Invalid redaction path ()");if($.includes(".."))throw Error(`Invalid redaction path (${$})`);if($.includes(","))throw Error(`Invalid redaction path (${$})`);let Z=0,J=!1,Y="";for(let X=0;X<$.length;X++){let Q=$[X];if((Q==='"'||Q==="'")&&Z>0){if(!J)J=!0,Y=Q;else if(Q===Y)J=!1,Y=""}else if(Q==="["&&!J)Z++;else if(Q==="]"&&!J){if(Z--,Z<0)throw Error(`Invalid redaction path (${$})`)}}if(Z!==0)throw Error(`Invalid redaction path (${$})`)}function X80($){if(!Array.isArray($))throw TypeError("paths must be an array");for(let Z of $)Y80(Z)}function Q80($={}){let{paths:Z=[],censor:J="[REDACTED]",serialize:Y=JSON.stringify,strict:X=!0,remove:Q=!1}=$;X80(Z);let G=Z80(Z);return function(K){if(X&&(K===null||typeof K!=="object")){if(K===null||K===void 0)return Y?Y(K):K;if(typeof K!=="object")return Y?Y(K):K}let V=J80(K,G),U=K,H=J;if(typeof J==="function")H=J;if(e$0(V,Z,H,Q),Y===!1)return V.restore=function(){return KB(U)},V;if(typeof Y==="function")return Y(V);return JSON.stringify(V)}}$C.exports=Q80});var PJ=S(($k0,JC)=>{var G80=Symbol("pino.setLevel"),W80=Symbol("pino.getLevel"),K80=Symbol("pino.levelVal"),V80=Symbol("pino.levelComp"),U80=Symbol("pino.useLevelLabels"),H80=Symbol("pino.useOnlyCustomLevels"),B80=Symbol("pino.mixin"),z80=Symbol("pino.lsCache"),F80=Symbol("pino.chindings"),A80=Symbol("pino.asJson"),O80=Symbol("pino.write"),j80=Symbol("pino.redactFmt"),N80=Symbol("pino.time"),q80=Symbol("pino.timeSliceIndex"),M80=Symbol("pino.stream"),D80=Symbol("pino.stringify"),w80=Symbol("pino.stringifySafe"),L80=Symbol("pino.stringifiers"),T80=Symbol("pino.end"),R80=Symbol("pino.formatOpts"),P80=Symbol("pino.messageKey"),C80=Symbol("pino.errorKey"),I80=Symbol("pino.nestedKey"),E80=Symbol("pino.nestedKeyStr"),b80=Symbol("pino.mixinMergeStrategy"),_80=Symbol("pino.msgPrefix"),S80=Symbol("pino.wildcardFirst"),f80=Symbol.for("pino.serializers"),k80=Symbol.for("pino.formatters"),v80=Symbol.for("pino.hooks"),y80=Symbol.for("pino.metadata");JC.exports={setLevelSym:G80,getLevelSym:W80,levelValSym:K80,levelCompSym:V80,useLevelLabelsSym:U80,mixinSym:B80,lsCacheSym:z80,chindingsSym:F80,asJsonSym:A80,writeSym:O80,serializersSym:f80,redactFmtSym:j80,timeSym:N80,timeSliceIndexSym:q80,streamSym:M80,stringifySym:D80,stringifySafeSym:w80,stringifiersSym:L80,endSym:T80,formatOptsSym:R80,messageKeySym:P80,errorKeySym:C80,nestedKeySym:I80,wildcardFirstSym:S80,needsMetadataGsym:y80,useOnlyCustomLevelsSym:H80,formattersSym:k80,hooksSym:v80,nestedKeyStrSym:E80,mixinMergeStrategySym:b80,msgPrefixSym:_80}});var UB=S((Zk0,XC)=>{var YC=ZC(),{redactFmtSym:x80,wildcardFirstSym:o4}=PJ(),VB=/[^.[\]]+|\[([^[\]]*?)\]/g;function h80($,Z){let{paths:J,censor:Y,remove:X}=g80($),Q=J.reduce((K,V)=>{VB.lastIndex=0;let U=VB.exec(V),H=VB.exec(V),B=U[1]!==void 0?U[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,"$1"):U[0];if(B==="*")B=o4;if(H===null)return K[B]=null,K;if(K[B]===null)return K;let{index:z}=H,F=`${V.substr(z,V.length-1)}`;if(K[B]=K[B]||[],B!==o4&&K[B].length===0)K[B].push(...K[o4]||[]);if(B===o4)Object.keys(K).forEach(function(A){if(K[A])K[A].push(F)});return K[B].push(F),K},{}),G={[x80]:YC({paths:J,censor:Y,serialize:Z,strict:!1,remove:X})},W=(...K)=>{return typeof Y==="function"?Z(Y(...K)):Z(Y)};return[...Object.keys(Q),...Object.getOwnPropertySymbols(Q)].reduce((K,V)=>{if(Q[V]===null)K[V]=(U)=>W(U,[V]);else{let U=typeof Y==="function"?(H,B)=>{return Y(H,[V,...B])}:Y;K[V]=YC({paths:Q[V],censor:U,serialize:Z,strict:!1,remove:X})}return K},G)}function g80($){if(Array.isArray($))return $={paths:$,censor:"[Redacted]"},$;let{paths:Z,censor:J="[Redacted]",remove:Y}=$;if(Array.isArray(Z)===!1)throw Error("pino \u2013 redact must contain an array of strings");if(Y===!0)J=void 0;return{paths:Z,censor:J,remove:Y}}XC.exports=h80});var WC=S((Jk0,GC)=>{var u80=()=>"",m80=()=>`,"time":${Date.now()}`,l80=()=>`,"time":${Math.round(Date.now()/1000)}`,d80=()=>`,"time":"${new Date(Date.now()).toISOString()}"`,p80=1000000n,QC=1000000000n,c80=BigInt(Date.now())*p80,i80=process.hrtime.bigint(),n80=()=>{let $=process.hrtime.bigint()-i80,Z=c80+$,J=Z/QC,Y=Z%QC,X=Number(J*1000n+Y/1000000n),Q=new Date(X),G=Q.getUTCFullYear(),W=(Q.getUTCMonth()+1).toString().padStart(2,"0"),K=Q.getUTCDate().toString().padStart(2,"0"),V=Q.getUTCHours().toString().padStart(2,"0"),U=Q.getUTCMinutes().toString().padStart(2,"0"),H=Q.getUTCSeconds().toString().padStart(2,"0");return`,"time":"${G}-${W}-${K}T${V}:${U}:${H}.${Y.toString().padStart(9,"0")}Z"`};GC.exports={nullTime:u80,epochTime:m80,unixTime:l80,isoTime:d80,isoTimeNano:n80}});var VC=S((Yk0,KC)=>{function o80($){try{return JSON.stringify($)}catch(Z){return'"[Circular]"'}}KC.exports=s80;function s80($,Z,J){var Y=J&&J.stringify||o80,X=1;if(typeof $==="object"&&$!==null){var Q=Z.length+X;if(Q===1)return $;var G=Array(Q);G[0]=Y($);for(var W=1;W<Q;W++)G[W]=Y(Z[W]);return G.join(" ")}if(typeof $!=="string")return $;var K=Z.length;if(K===0)return $;var V="",U=1-X,H=-1,B=$&&$.length||0;for(var z=0;z<B;){if($.charCodeAt(z)===37&&z+1<B){switch(H=H>-1?H:0,$.charCodeAt(z+1)){case 100:case 102:if(U>=K)break;if(Z[U]==null)break;if(H<z)V+=$.slice(H,z);V+=Number(Z[U]),H=z+2,z++;break;case 105:if(U>=K)break;if(Z[U]==null)break;if(H<z)V+=$.slice(H,z);V+=Math.floor(Number(Z[U])),H=z+2,z++;break;case 79:case 111:case 106:if(U>=K)break;if(Z[U]===void 0)break;if(H<z)V+=$.slice(H,z);var F=typeof Z[U];if(F==="string"){V+="'"+Z[U]+"'",H=z+2,z++;break}if(F==="function"){V+=Z[U].name||"<anonymous>",H=z+2,z++;break}V+=Y(Z[U]),H=z+2,z++;break;case 115:if(U>=K)break;if(H<z)V+=$.slice(H,z);V+=String(Z[U]),H=z+2,z++;break;case 37:if(H<z)V+=$.slice(H,z);V+="%",H=z+2,z++,U--;break}++U}++z}if(H===-1)return $;else if(H<B)V+=$.slice(H);return V}});var BB=S((Xk0,HB)=>{if(typeof SharedArrayBuffer<"u"&&typeof Atomics<"u"){let Z=function(J){if((J>0&&J<1/0)===!1){if(typeof J!=="number"&&typeof J!=="bigint")throw TypeError("sleep: ms must be a number");throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}Atomics.wait($,0,0,Number(J))},$=new Int32Array(new SharedArrayBuffer(4));HB.exports=Z}else{let $=function(Z){if((Z>0&&Z<1/0)===!1){if(typeof Z!=="number"&&typeof Z!=="bigint")throw TypeError("sleep: ms must be a number");throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}let Y=Date.now()+Number(Z);while(Y>Date.now());};HB.exports=$}});var AC=S((Qk0,FC)=>{var i1=J0("fs"),r80=J0("events"),a80=J0("util").inherits,UC=J0("path"),FB=BB(),t80=J0("assert"),s4=Buffer.allocUnsafe(0),[e80,$60]=(process.versions.node||"0.0").split(".").map(Number),Z60=e80>=22&&$60>=7;function HC($,Z){Z._opening=!0,Z._writing=!0,Z._asyncDrainScheduled=!1;function J(Q,G){if(Q){if(Z._reopening=!1,Z._writing=!1,Z._opening=!1,Z.sync)process.nextTick(()=>{if(Z.listenerCount("error")>0)Z.emit("error",Q)});else Z.emit("error",Q);return}let W=Z._reopening;if(Z.fd=G,Z.file=$,Z._reopening=!1,Z._opening=!1,Z._writing=!1,Z.sync)process.nextTick(()=>Z.emit("ready"));else Z.emit("ready");if(Z.destroyed)return;if(!Z._writing&&Z._len>Z.minLength||Z._flushPending)Z._actualWrite();else if(W)process.nextTick(()=>Z.emit("drain"))}let Y=Z.append?"a":"w",X=Z.mode;if(Z.sync)try{if(Z.mkdir)i1.mkdirSync(UC.dirname($),{recursive:!0});let Q=i1.openSync($,Y,X);J(null,Q)}catch(Q){throw J(Q),Q}else if(Z.mkdir)i1.mkdir(UC.dirname($),{recursive:!0},(Q)=>{if(Q)return J(Q);i1.open($,Y,X,J)});else i1.open($,Y,X,J)}function e8($){if(!(this instanceof e8))return new e8($);let{fd:Z,dest:J,minLength:Y,maxLength:X,maxWrite:Q,periodicFlush:G,sync:W,append:K=!0,mkdir:V,retryEAGAIN:U,fsync:H,contentMode:B,mode:z}=$||{};Z=Z||J,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._flushPending=!1,this._hwm=Math.max(Y||0,16387),this.file=null,this.destroyed=!1,this.minLength=Y||0,this.maxLength=X||0,this.maxWrite=Q||16384,this._periodicFlush=G||0,this._periodicFlushTimer=void 0,this.sync=W||!1,this.writable=!0,this._fsync=H||!1,this.append=K||!1,this.mode=z,this.retryEAGAIN=U||(()=>!0),this.mkdir=V||!1;let F,A;if(B==="buffer")this._writingBuf=s4,this.write=X60,this.flush=G60,this.flushSync=K60,this._actualWrite=U60,F=()=>i1.writeSync(this.fd,this._writingBuf),A=()=>i1.write(this.fd,this._writingBuf,this.release);else if(B===void 0||B==="utf8")this._writingBuf="",this.write=Y60,this.flush=Q60,this.flushSync=W60,this._actualWrite=V60,F=()=>{if(Buffer.isBuffer(this._writingBuf))return i1.writeSync(this.fd,this._writingBuf);return i1.writeSync(this.fd,this._writingBuf,"utf8")},A=()=>{if(Buffer.isBuffer(this._writingBuf))return i1.write(this.fd,this._writingBuf,this.release);return i1.write(this.fd,this._writingBuf,"utf8",this.release)};else throw Error(`SonicBoom supports "utf8" and "buffer", but passed ${B}`);if(typeof Z==="number")this.fd=Z,process.nextTick(()=>this.emit("ready"));else if(typeof Z==="string")HC(Z,this);else throw Error("SonicBoom supports only file descriptors and files");if(this.minLength>=this.maxWrite)throw Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);if(this.release=(N,q)=>{if(N){if((N.code==="EAGAIN"||N.code==="EBUSY")&&this.retryEAGAIN(N,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{FB(100),this.release(void 0,0)}catch(M){this.release(M)}else setTimeout(A,100);else this._writing=!1,this.emit("error",N);return}this.emit("write",q);let w=zB(this._writingBuf,this._len,q);if(this._len=w.len,this._writingBuf=w.writingBuf,this._writingBuf.length){if(!this.sync){A();return}try{do{let M=F(),I=zB(this._writingBuf,this._len,M);this._len=I.len,this._writingBuf=I.writingBuf}while(this._writingBuf.length)}catch(M){this.release(M);return}}if(this._fsync)i1.fsyncSync(this.fd);let j=this._len;if(this._reopening)this._writing=!1,this._reopening=!1,this.reopen();else if(j>this.minLength)this._actualWrite();else if(this._ending)if(j>0)this._actualWrite();else this._writing=!1,r4(this);else if(this._writing=!1,this.sync){if(!this._asyncDrainScheduled)this._asyncDrainScheduled=!0,process.nextTick(J60,this)}else this.emit("drain")},this.on("newListener",function(N){if(N==="drain")this._asyncDrainScheduled=!1}),this._periodicFlush!==0)this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.unref()}function zB($,Z,J){if(typeof $==="string")$=Buffer.from($);return Z=Math.max(Z-J,0),$=$.subarray(J),{writingBuf:$,len:Z}}function J60($){if(!($.listenerCount("drain")>0))return;$._asyncDrainScheduled=!1,$.emit("drain")}a80(e8,r80);function BC($,Z){if($.length===0)return s4;if($.length===1)return $[0];return Buffer.concat($,Z)}function Y60($){if(this.destroyed)throw Error("SonicBoom destroyed");$=""+$;let Z=Buffer.byteLength($),J=this._len+Z,Y=this._bufs;if(this.maxLength&&J>this.maxLength)return this.emit("drop",$),this._len<this._hwm;if(Y.length===0||Buffer.byteLength(Y[Y.length-1])+Z>this.maxWrite)Y.push($);else Y[Y.length-1]+=$;if(this._len=J,!this._writing&&this._len>=this.minLength)this._actualWrite();return this._len<this._hwm}function X60($){if(this.destroyed)throw Error("SonicBoom destroyed");let Z=this._len+$.length,J=this._bufs,Y=this._lens;if(this.maxLength&&Z>this.maxLength)return this.emit("drop",$),this._len<this._hwm;if(J.length===0||Y[Y.length-1]+$.length>this.maxWrite)J.push([$]),Y.push($.length);else J[J.length-1].push($),Y[Y.length-1]+=$.length;if(this._len=Z,!this._writing&&this._len>=this.minLength)this._actualWrite();return this._len<this._hwm}function zC($){this._flushPending=!0;let Z=()=>{if(!this._fsync)try{i1.fsync(this.fd,(Y)=>{this._flushPending=!1,$(Y)})}catch(Y){$(Y)}else this._flushPending=!1,$();this.off("error",J)},J=(Y)=>{this._flushPending=!1,$(Y),this.off("drain",Z)};this.once("drain",Z),this.once("error",J)}function Q60($){if($!=null&&typeof $!=="function")throw Error("flush cb must be a function");if(this.destroyed){let Z=Error("SonicBoom destroyed");if($){$(Z);return}throw Z}if(this.minLength<=0){$?.();return}if($)zC.call(this,$);if(this._writing)return;if(this._bufs.length===0)this._bufs.push("");this._actualWrite()}function G60($){if($!=null&&typeof $!=="function")throw Error("flush cb must be a function");if(this.destroyed){let Z=Error("SonicBoom destroyed");if($){$(Z);return}throw Z}if(this.minLength<=0){$?.();return}if($)zC.call(this,$);if(this._writing)return;if(this._bufs.length===0)this._bufs.push([]),this._lens.push(0);this._actualWrite()}e8.prototype.reopen=function($){if(this.destroyed)throw Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.reopen($)});return}if(this._ending)return;if(!this.file)throw Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");if($)this.file=$;if(this._reopening=!0,this._writing)return;let Z=this.fd;this.once("ready",()=>{if(Z!==this.fd)i1.close(Z,(J)=>{if(J)return this.emit("error",J)})}),HC(this.file,this)};e8.prototype.end=function(){if(this.destroyed)throw Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.end()});return}if(this._ending)return;if(this._ending=!0,this._writing)return;if(this._len>0&&this.fd>=0)this._actualWrite();else r4(this)};function W60(){if(this.destroyed)throw Error("SonicBoom destroyed");if(this.fd<0)throw Error("sonic boom is not ready yet");if(!this._writing&&this._writingBuf.length>0)this._bufs.unshift(this._writingBuf),this._writingBuf="";let $="";while(this._bufs.length||$.length){if($.length<=0)$=this._bufs[0];try{let Z=Buffer.isBuffer($)?i1.writeSync(this.fd,$):i1.writeSync(this.fd,$,"utf8"),J=zB($,this._len,Z);if($=J.writingBuf,this._len=J.len,$.length<=0)this._bufs.shift()}catch(Z){if((Z.code==="EAGAIN"||Z.code==="EBUSY")&&!this.retryEAGAIN(Z,$.length,this._len-$.length))throw Z;FB(100)}}try{i1.fsyncSync(this.fd)}catch{}}function K60(){if(this.destroyed)throw Error("SonicBoom destroyed");if(this.fd<0)throw Error("sonic boom is not ready yet");if(!this._writing&&this._writingBuf.length>0)this._bufs.unshift([this._writingBuf]),this._writingBuf=s4;let $=s4;while(this._bufs.length||$.length){if($.length<=0)$=BC(this._bufs[0],this._lens[0]);try{let Z=i1.writeSync(this.fd,$);if($=$.subarray(Z),this._len=Math.max(this._len-Z,0),$.length<=0)this._bufs.shift(),this._lens.shift()}catch(Z){if((Z.code==="EAGAIN"||Z.code==="EBUSY")&&!this.retryEAGAIN(Z,$.length,this._len-$.length))throw Z;FB(100)}}}e8.prototype.destroy=function(){if(this.destroyed)return;r4(this)};function V60(){let $=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||"",this.sync)try{let Z=Buffer.isBuffer(this._writingBuf)?i1.writeSync(this.fd,this._writingBuf):i1.writeSync(this.fd,this._writingBuf,"utf8");$(null,Z)}catch(Z){$(Z)}else i1.write(this.fd,this._writingBuf,$)}function U60(){let $=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:BC(this._bufs.shift(),this._lens.shift()),this.sync)try{let Z=i1.writeSync(this.fd,this._writingBuf);$(null,Z)}catch(Z){$(Z)}else{if(Z60)this._writingBuf=Buffer.from(this._writingBuf);i1.write(this.fd,this._writingBuf,$)}}function r4($){if($.fd===-1){$.once("ready",r4.bind(null,$));return}if($._periodicFlushTimer!==void 0)clearInterval($._periodicFlushTimer);$.destroyed=!0,$._bufs=[],$._lens=[],t80(typeof $.fd==="number",`sonic.fd must be a number, got ${typeof $.fd}`);try{i1.fsync($.fd,Z)}catch{}function Z(){if($.fd!==1&&$.fd!==2)i1.close($.fd,J);else J()}function J(Y){if(Y){$.emit("error",Y);return}if($._ending&&!$._writing)$.emit("finish");$.emit("close")}}e8.SonicBoom=e8;e8.default=e8;FC.exports=e8});var AB=S((Gk0,MC)=>{var $6={exit:[],beforeExit:[]},OC={exit:z60,beforeExit:F60},CJ;function H60(){if(CJ===void 0)CJ=new FinalizationRegistry(A60)}function B60($){if($6[$].length>0)return;process.on($,OC[$])}function jC($){if($6[$].length>0)return;if(process.removeListener($,OC[$]),$6.exit.length===0&&$6.beforeExit.length===0)CJ=void 0}function z60(){NC("exit")}function F60(){NC("beforeExit")}function NC($){for(let Z of $6[$]){let J=Z.deref(),Y=Z.fn;if(J!==void 0)Y(J,$)}$6[$]=[]}function A60($){for(let Z of["exit","beforeExit"]){let J=$6[Z].indexOf($);$6[Z].splice(J,J+1),jC(Z)}}function qC($,Z,J){if(Z===void 0)throw Error("the object can't be undefined");B60($);let Y=new WeakRef(Z);Y.fn=J,H60(),CJ.register(Z,Y),$6[$].push(Y)}function O60($,Z){qC("exit",$,Z)}function j60($,Z){qC("beforeExit",$,Z)}function N60($){if(CJ===void 0)return;CJ.unregister($);for(let Z of["exit","beforeExit"])$6[Z]=$6[Z].filter((J)=>{let Y=J.deref();return Y&&Y!==$}),jC(Z)}MC.exports={register:O60,registerBeforeExit:j60,unregister:N60}});var DC=S((Wk0,q60)=>{q60.exports={name:"thread-stream",version:"4.2.0",description:"A streaming way to send data to a Node.js Worker Thread",main:"index.js",types:"index.d.ts",engines:{node:">=20"},dependencies:{"real-require":"^1.0.0"},devDependencies:{"@types/node":"^25.0.2","@yao-pkg/pkg":"^6.0.0",borp:"^1.0.0",desm:"^1.3.0",eslint:"^9.39.1",fastbench:"^1.0.1",neostandard:"^0.13.0","pino-elasticsearch":"^9.0.0","sonic-boom":"^5.0.0","ts-node":"^10.8.0",typescript:"~5.7.3"},scripts:{build:"tsc --noEmit",lint:"eslint",test:'npm run lint && npm run build && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',"test:ci":'npm run lint && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',"test:yarn":'npm run transpile && borp --pattern "test/*.test.js"',transpile:"sh ./test/ts/transpile.sh"},repository:{type:"git",url:"git+https://github.com/mcollina/thread-stream.git"},keywords:["worker","thread","threads","stream"],author:"Matteo Collina <hello@matteocollina.com>",license:"MIT",bugs:{url:"https://github.com/mcollina/thread-stream/issues"},homepage:"https://github.com/mcollina/thread-stream#readme"}});var LC=S((Kk0,wC)=>{function M60($,Z,J,Y,X){let Q=Y===1/0?1/0:Date.now()+Y,G=()=>{let W=Atomics.load($,Z);if(W===J){X(null,"ok");return}if(Q!==1/0&&Date.now()>Q){X(null,"timed-out");return}let K=Q===1/0?1e4:Math.min(1e4,Math.max(1,Q-Date.now())),V=Atomics.waitAsync($,Z,W,K);if(V.async)V.value.then(G);else setImmediate(G)};G()}function D60($,Z,J,Y,X){let Q=Y===1/0?1/0:Date.now()+Y,G=()=>{if(Atomics.load($,Z)!==J){X(null,"ok");return}if(Q!==1/0&&Date.now()>Q){X(null,"timed-out");return}let K=Q===1/0?1e4:Math.min(1e4,Math.max(1,Q-Date.now())),V=Atomics.waitAsync($,Z,J,K);if(V.async)V.value.then((U)=>{if(U==="ok"){X(null,"ok");return}G()});else setImmediate(G)};G()}wC.exports={wait:M60,waitDiff:D60}});var RC=S((Vk0,TC)=>{TC.exports={WRITE_INDEX:4,READ_INDEX:8,SEQ_INDEX:2}});var hC=S((Uk0,xC)=>{var __dirname="/home/runner/workspace/products/qitqode/qode/node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream",{version:w60}=DC(),{EventEmitter:L60}=J0("events"),{Worker:T60}=J0("worker_threads"),{join:R60}=J0("path"),{pathToFileURL:P60}=J0("url"),{wait:C60}=LC(),{WRITE_INDEX:t6,READ_INDEX:i5,SEQ_INDEX:OB}=RC(),I60=J0("buffer"),E60=J0("assert"),o=Symbol("kImpl"),b60=I60.constants.MAX_STRING_LENGTH;function PC(){}function MB($,Z){Atomics.add($[o].state,OB,1),Z(),Atomics.add($[o].state,OB,1),Atomics.notify($[o].state,OB)}function CC($){MB($,()=>{Atomics.store($[o].state,i5,0),Atomics.store($[o].state,t6,0)})}class a4{constructor($){this._value=$}deref(){return this._value}}class NB{register(){}unregister(){}}var _60=process.env.NODE_V8_COVERAGE?NB:global.FinalizationRegistry||NB,S60=process.env.NODE_V8_COVERAGE?a4:global.WeakRef||a4,IC=new _60(($)=>{if($.exited)return;$.terminate()});function f60($,Z){let{filename:J,workerData:Y}=Z,Q=("__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{})["thread-stream-worker"]||R60(__dirname,"lib","worker.js"),G=new T60(Q,{...Z.workerOpts,name:Z.workerOpts?.name||"thread-stream",trackUnmanagedFds:!1,workerData:{filename:J.indexOf("file://")===0?J:P60(J).href,dataBuf:$[o].dataBuf,stateBuf:$[o].stateBuf,workerData:{$context:{threadStreamVersion:w60},...Y}}});return G.stream=new a4($),G.on("message",k60),G.on("exit",_C),IC.register($,G),G}function EC($){if(E60(!$[o].sync),$[o].needDrain)$[o].needDrain=!1,$.emit("drain")}function bC($){while(!0){let Z=Atomics.load($[o].state,t6),J=$[o].data.length-Z;if(J>0){if($[o].bufLen===0){if($[o].flushing=!1,$[o].ending)DB($);else if($[o].needDrain)process.nextTick(EC,$);return}vC($,J,PC);continue}if(J===0){if(Z===0&&$[o].bufLen===0)return;t4($,()=>{if($.destroyed)return;CC($),bC($)});return}x8($,Error("overwritten"));return}}function k60($){let Z=this.stream.deref();if(Z===void 0){this.exited=!0,this.terminate();return}if($?.code==null)return;switch($.code){case"READY":this.stream=new S60(Z),t4(Z,()=>{Z[o].ready=!0,Z.emit("ready")});break;case"ERROR":x8(Z,$.err);break;case"EVENT":if(Array.isArray($.args))Z.emit($.name,...$.args);else Z.emit($.name,$.args);break;case"FLUSHED":{if($.context!=="thread-stream"){x8(Z,Error("this should not happen: "+$.code));break}let J=Z[o].flushCallbacks.get($.id);if(J)Z[o].flushCallbacks.delete($.id),process.nextTick(J);break}case"WARNING":process.emitWarning($.err);break;default:x8(Z,Error("this should not happen: "+$.code))}}function _C($){let Z=this.stream.deref();if(Z===void 0)return;IC.unregister(Z),Z.worker.exited=!0,Z.worker.off("exit",_C),x8(Z,$!==0?Error("the worker thread exited"):null)}class SC extends L60{constructor($={}){super();if($.bufferSize<4)throw Error("bufferSize must at least fit a 4-byte utf-8 char");this[o]={},this[o].stateBuf=new SharedArrayBuffer(128),this[o].state=new Int32Array(this[o].stateBuf),this[o].dataBuf=new SharedArrayBuffer($.bufferSize||4194304),this[o].data=Buffer.from(this[o].dataBuf),this[o].sync=$.sync||!1,this[o].ending=!1,this[o].ended=!1,this[o].needDrain=!1,this[o].destroyed=!1,this[o].flushing=!1,this[o].ready=!1,this[o].finished=!1,this[o].errored=null,this[o].closed=!1,this[o].buf=[],this[o].bufHead=0,this[o].bufLen=0,this[o].flushCallbacks=new Map,this[o].nextFlushId=0,this.worker=f60(this,$),this.on("message",(Z,J)=>{this.worker.postMessage(Z,J)})}write($){let Z=Buffer.isBuffer($)?$:Buffer.from($);if(this[o].destroyed)return qB(this,Error("the worker has exited")),!1;if(this[o].ending)return qB(this,Error("the worker is ending")),!1;if(this[o].flushing&&this[o].bufLen+Z.length>=b60)try{jB(this),this[o].flushing=!0}catch(J){return x8(this,J),!1}if(this[o].buf.push(Z),this[o].bufLen+=Z.length,this[o].sync)try{return jB(this),!0}catch(J){return x8(this,J),!1}if(!this[o].flushing)this[o].flushing=!0,setImmediate(bC,this);return this[o].needDrain=this[o].data.length-this[o].bufLen-Atomics.load(this[o].state,t6)<=0,!this[o].needDrain}end(){if(this[o].destroyed)return;this[o].ending=!0,DB(this)}flush($){$=typeof $==="function"?$:PC,fC(this,(Z)=>{if(Z){process.nextTick($,Z);return}kC(this,$)})}flushSync(){if(this[o].destroyed)return;jB(this),yC(this)}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[o].ready}get destroyed(){return this[o].destroyed}get closed(){return this[o].closed}get writable(){return!this[o].destroyed&&!this[o].ending}get writableEnded(){return this[o].ending}get writableFinished(){return this[o].finished}get writableNeedDrain(){return this[o].needDrain}get writableObjectMode(){return!1}get writableErrored(){return this[o].errored}}function fC($,Z){if($[o].destroyed){process.nextTick(Z,Error("the worker has exited"));return}if(!$[o].sync&&($[o].flushing||$[o].bufLen>0)){setImmediate(fC,$,Z);return}t4($,Z)}function t4($,Z){let J=Atomics.load($[o].state,t6);C60($[o].state,i5,J,1/0,(Y,X)=>{if(Y){x8($,Y),Z(Y);return}if(X!=="ok"){t4($,Z);return}Z()})}function kC($,Z){if($[o].destroyed){process.nextTick(Z,Error("the worker has exited"));return}if(!$[o].ready){let Y=()=>{Q(),kC($,Z)},X=()=>{Q(),process.nextTick(Z,Error("the worker has exited"))},Q=()=>{$.off("ready",Y),$.off("close",X)};$.once("ready",Y),$.once("close",X);return}let J=++$[o].nextFlushId;$[o].flushCallbacks.set(J,Z);try{$.worker.postMessage({code:"FLUSH",context:"thread-stream",id:J})}catch(Y){$[o].flushCallbacks.delete(J),x8($,Y),process.nextTick(Z,Y)}}function v60($,Z){let J=$[o].flushCallbacks;if(J.size===0)return;let Y=Z||Error("the worker has exited");for(let X of J.values())process.nextTick(X,Y);J.clear()}function qB($,Z){setImmediate(()=>{$.emit("error",Z)})}function x8($,Z){if($[o].destroyed)return;if($[o].destroyed=!0,v60($,Z),Z)$[o].errored=Z,qB($,Z);if(!$.worker.exited)$.worker.terminate().catch(()=>{}).then(()=>{$[o].closed=!0,$.emit("close")});else setImmediate(()=>{$[o].closed=!0,$.emit("close")})}function vC($,Z,J){let X=Atomics.load($[o].state,t6),Q=Z;while(Q>0&&$[o].bufLen!==0){let G=$[o].bufHead,W=$[o].buf[G];if(W.length<=Q){if(W.copy($[o].data,X),X+=W.length,Q-=W.length,$[o].bufLen-=W.length,$[o].bufHead=G+1,$[o].bufHead===$[o].buf.length)$[o].buf.length=0,$[o].bufHead=0;else if($[o].bufHead>=1024&&$[o].bufHead*2>=$[o].buf.length)$[o].buf.splice(0,$[o].bufHead),$[o].bufHead=0;continue}W.copy($[o].data,X,0,Q),$[o].buf[G]=W.subarray(Q),$[o].bufLen-=Q,X+=Q,Q=0}return MB($,()=>{Atomics.store($[o].state,t6,X)}),J(),!0}function DB($){if($[o].ended||!$[o].ending||$[o].flushing)return;$[o].ended=!0;try{$.flushSync();let Z=Atomics.load($[o].state,i5);MB($,()=>{Atomics.store($[o].state,t6,-1)});let J=0;while(Z!==-1){if(Atomics.wait($[o].state,i5,Z,1000),Z=Atomics.load($[o].state,i5),Z===-2){x8($,Error("end() failed"));return}if(++J===10){x8($,Error("end() took too long (10s)"));return}}process.nextTick(()=>{$[o].finished=!0,$.emit("finish")})}catch(Z){x8($,Z)}}function jB($){let Z=()=>{if($[o].ending)DB($);else if($[o].needDrain)process.nextTick(EC,$)};$[o].flushing=!1;while($[o].bufLen!==0){let J=Atomics.load($[o].state,t6),Y=$[o].data.length-J;if(Y===0){yC($),CC($);continue}else if(Y<0)throw Error("overwritten");vC($,Y,Z)}}function yC($){if($[o].flushing)throw Error("unable to flush while flushing");let Z=Atomics.load($[o].state,t6),J=0;while(!0){let Y=Atomics.load($[o].state,i5);if(Y===-2)throw Error("_flushSync failed");if(Y!==Z)Atomics.wait($[o].state,i5,Y,1000);else break;if(++J===10)throw Error("_flushSync took too long (10s)")}}xC.exports=SC});var TB=S((Hk0,mC)=>{var __dirname="/home/runner/workspace/products/qitqode/qode/node_modules/.bun/pino@10.3.1/node_modules/pino/lib",{createRequire:y60}=J0("module"),{existsSync:x60}=J0("fs"),h60=WB(),{join:wB,isAbsolute:uC,sep:g60}=J0("path"),{fileURLToPath:u60}=J0("url"),m60=BB(),LB=AB(),l60=hC();function d60($){LB.register($,o60),LB.registerBeforeExit($,s60),$.on("close",function(){LB.unregister($)})}function p60(){let $=process.execArgv;for(let Z=0;Z<$.length;Z++){let J=$[Z];if(J==="--import"||J==="--require"||J==="-r")return!0;if(J.startsWith("--import=")||J.startsWith("--require=")||J.startsWith("-r="))return!0}return!1}function c60($){let Z=$.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!Z)return $;let J=[],Y=!1;for(let X=0;X<Z.length;X++){let Q=Z[X];if(Q==="--require"||Q==="-r"||Q==="--import"){let G=Z[X+1];if(G&&gC(G)){Y=!0,X++;continue}if(J.push(Q),G)J.push(G),X++;continue}if(Q.startsWith("--require=")||Q.startsWith("-r=")||Q.startsWith("--import=")){let G=Q.slice(Q.indexOf("=")+1);if(gC(G)){Y=!0;continue}}J.push(Q)}return Y?J.join(" "):$}function gC($){let Z=i60($);if(!Z)return!1;let J=Z;if(J.startsWith("file://"))try{J=u60(J)}catch{return!1}return uC(J)&&!x60(J)}function i60($){let Z=$[0],J=$[$.length-1];if(Z==='"'&&J==='"'||Z==="'"&&J==="'")return $.slice(1,-1);return $}function n60($,Z,J,Y,X){if(!J.execArgv&&p60()&&J0.main===void 0)J={...J,execArgv:[]};if(!J.env&&process.env.NODE_OPTIONS){let K=c60(process.env.NODE_OPTIONS);if(K!==process.env.NODE_OPTIONS)J={...J,env:{...process.env,NODE_OPTIONS:K}}}J={...J,name:X};let Q=new l60({filename:$,workerData:Z,workerOpts:J,sync:Y});Q.on("ready",G),Q.on("close",function(){process.removeListener("exit",W)}),process.on("exit",W);function G(){if(process.removeListener("exit",W),Q.unref(),J.autoEnd!==!1)d60(Q)}function W(){if(Q.closed)return;Q.flushSync(),m60(100),Q.end()}return Q}function o60($){$.ref(),$.flushSync(),$.end(),$.once("close",function(){$.unref()})}function s60($){$.flushSync()}function r60($){let{pipeline:Z,targets:J,levels:Y,dedupe:X,worker:Q={},caller:G=h60(),sync:W=!1}=$,K={...$.options},V=typeof G==="string"?[G]:G,U=typeof globalThis==="object"&&Object.prototype.hasOwnProperty.call(globalThis,"__bundlerPathsOverrides")&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides==="object"?globalThis.__bundlerPathsOverrides:Object.create(null),H=$.target;if(H&&J)throw Error("only one of target or targets can be specified");if(J)H=U["pino-worker"]||wB(__dirname,"worker.js"),K.targets=J.filter((F)=>F.target).map((F)=>{return{...F,target:z(F.target)}}),K.pipelines=J.filter((F)=>F.pipeline).map((F)=>{return F.pipeline.map((A)=>{return{...A,level:F.level,target:z(A.target)}})});else if(Z)H=U["pino-worker"]||wB(__dirname,"worker.js"),K.pipelines=[Z.map((F)=>{return{...F,target:z(F.target)}})];if(Y)K.levels=Y;if(X)K.dedupe=X;K.pinoWillSendConfig=!0;let B=J||Z?"pino.transport":H;return n60(z(H),K,Q,W,B);function z(F){if(F=U[F]||F,uC(F)||F.indexOf("file://")===0)return F;if(F==="pino/file")return wB(__dirname,"..","file.js");let A;for(let N of V)try{let q=N==="node:repl"?process.cwd()+g60:N;A=y60(q).resolve(F);break}catch(q){continue}if(!A)throw Error(`unable to determine transport target for "${F}"`);return A}}mC.exports=r60});var ZG=S((zk0,$I)=>{var a60=J0("diagnostics_channel"),lC=VC(),{mapHttpRequest:t60,mapHttpResponse:e60}=GB(),PB=AC(),dC=AB(),{lsCacheSym:$Z0,chindingsSym:oC,writeSym:pC,serializersSym:sC,formatOptsSym:cC,endSym:ZZ0,stringifiersSym:rC,stringifySym:aC,stringifySafeSym:CB,wildcardFirstSym:tC,nestedKeySym:JZ0,formattersSym:eC,messageKeySym:YZ0,errorKeySym:XZ0,nestedKeyStrSym:QZ0,msgPrefixSym:e4}=PJ(),{isMainThread:GZ0}=J0("worker_threads"),WZ0=TB(),[KZ0]=process.versions.node.split(".").map(($)=>Number($)),iC=a60.tracingChannel("pino_asJson"),RB=KZ0>=25?($)=>JSON.stringify($):UZ0;function IJ(){}function VZ0($,Z){if(!Z)return J;return function(...X){Z.call(this,X,J,$)};function J(Y,...X){if(typeof Y==="object"){let Q=Y;if(Y!==null){if(Y.method&&Y.headers&&Y.socket)Y=t60(Y);else if(typeof Y.setHeader==="function")Y=e60(Y)}let G;if(Q===null&&X.length===0)G=[null];else Q=X.shift(),G=X;if(typeof this[e4]==="string"&&Q!==void 0&&Q!==null)Q=this[e4]+Q;this[pC](Y,lC(Q,G,this[cC]),$)}else{let Q=Y===void 0?X.shift():Y;if(typeof this[e4]==="string"&&Q!==void 0&&Q!==null)Q=this[e4]+Q;this[pC](null,lC(Q,X,this[cC]),$)}}}function UZ0($){let Z="",J=0,Y=!1,X=255,Q=$.length;if(Q>100)return JSON.stringify($);for(var G=0;G<Q&&X>=32;G++)if(X=$.charCodeAt(G),X===34||X===92)Z+=$.slice(J,G)+"\\",J=G,Y=!0;if(!Y)Z=$;else Z+=$.slice(J);return X<32?JSON.stringify($):'"'+Z+'"'}function HZ0($,Z,J,Y){if(iC.hasSubscribers===!1)return nC.call(this,$,Z,J,Y);let X={instance:this,arguments};return iC.traceSync(nC,X,this,$,Z,J,Y)}function nC($,Z,J,Y){let X=this[aC],Q=this[CB],G=this[rC],W=this[ZZ0],K=this[oC],V=this[sC],U=this[eC],H=this[YZ0],B=this[XZ0],z=this[$Z0][J]+Y;z=z+K;let F;if(U.log)$=U.log($);let A=G[tC],N="";for(let w in $)if(F=$[w],Object.prototype.hasOwnProperty.call($,w)&&F!==void 0){if(V[w])F=V[w](F);else if(w===B&&V.err)F=V.err(F);let j=G[w]||A;switch(typeof F){case"undefined":case"function":continue;case"number":if(Number.isFinite(F)===!1)F=null;case"boolean":if(j)F=j(F);break;case"string":F=(j||RB)(F);break;default:F=(j||X)(F,Q)}if(F===void 0)continue;let M=RB(w);N+=","+M+":"+F}let q="";if(Z!==void 0){F=V[H]?V[H](Z):Z;let w=G[H]||A;switch(typeof F){case"function":break;case"number":if(Number.isFinite(F)===!1)F=null;case"boolean":if(w)F=w(F);q=',"'+H+'":'+F;break;case"string":F=(w||RB)(F),q=',"'+H+'":'+F;break;default:F=(w||X)(F,Q),q=',"'+H+'":'+F}}if(this[JZ0]&&N)return z+this[QZ0]+N.slice(1)+"}"+q+W;else return z+N+q+W}function BZ0($,Z){let J,Y=$[oC],X=$[aC],Q=$[CB],G=$[rC],W=G[tC],K=$[sC],V=$[eC].bindings;Z=V(Z);for(let U in Z)if(J=Z[U],((U.length<5||U!=="level"&&U!=="serializers"&&U!=="formatters"&&U!=="customLevels")&&Z.hasOwnProperty(U)&&J!==void 0)===!0){if(J=K[U]?K[U](J):J,J=(G[U]||W||X)(J,Q),J===void 0)continue;Y+=',"'+U+'":'+J}return Y}function zZ0($){return $.write!==$.constructor.prototype.write}function $G($){let Z=new PB($);if(Z.on("error",J),!$.sync&&GZ0)dC.register(Z,FZ0),Z.on("close",function(){dC.unregister(Z)});return Z;function J(Y){if(Y.code==="EPIPE"){Z.write=IJ,Z.end=IJ,Z.flushSync=IJ,Z.destroy=IJ;return}Z.removeListener("error",J),Z.emit("error",Y)}}function FZ0($,Z){if($.destroyed)return;if(Z==="beforeExit")$.flush(),$.on("drain",function(){$.end()});else $.flushSync()}function AZ0($){return function(J,Y,X={},Q){if(typeof X==="string")Q=$G({dest:X}),X={};else if(typeof Q==="string"){if(X&&X.transport)throw Error("only one of option.transport or stream can be specified");Q=$G({dest:Q})}else if(X instanceof PB||X.writable||X._writableState)Q=X,X={};else if(X.transport){if(X.transport instanceof PB||X.transport.writable||X.transport._writableState)throw Error("option.transport do not allow stream, please pass to option directly. e.g. pino(transport)");if(X.transport.targets&&X.transport.targets.length&&X.formatters&&typeof X.formatters.level==="function")throw Error("option.transport.targets do not allow custom level formatters");let K;if(X.customLevels)K=X.useOnlyCustomLevels?X.customLevels:Object.assign({},X.levels,X.customLevels);Q=WZ0({caller:Y,...X.transport,levels:K})}if(X=Object.assign({},$,X),X.serializers=Object.assign({},$.serializers,X.serializers),X.formatters=Object.assign({},$.formatters,X.formatters),X.prettyPrint)throw Error("prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)");let{enabled:G,onChild:W}=X;if(G===!1)X.level="silent";if(!W)X.onChild=IJ;if(!Q)if(!zZ0(process.stdout))Q=$G({fd:process.stdout.fd||1});else Q=process.stdout;return{opts:X,stream:Q}}}function OZ0($,Z){try{return JSON.stringify($)}catch(J){try{return(Z||this[CB])($)}catch(Y){return'"[unable to serialize, circular reference is too complex to analyze]"'}}}function jZ0($,Z,J){return{level:$,bindings:Z,log:J}}function NZ0($){let Z=Number($);if(typeof $==="string"&&Number.isFinite(Z))return Z;if($===void 0)return 1;return $}$I.exports={noop:IJ,buildSafeSonicBoom:$G,asChindings:BZ0,asJson:HZ0,genLog:VZ0,createArgsNormalizer:AZ0,stringify:OZ0,buildFormatters:jZ0,normalizeDestFileDescriptor:NZ0}});var JG=S((Fk0,ZI)=>{var qZ0={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},MZ0={ASC:"ASC",DESC:"DESC"};ZI.exports={DEFAULT_LEVELS:qZ0,SORTING_ORDER:MZ0}});var bB=S((Ak0,QI)=>{var{lsCacheSym:DZ0,levelValSym:IB,useOnlyCustomLevelsSym:wZ0,streamSym:LZ0,formattersSym:TZ0,hooksSym:RZ0,levelCompSym:JI}=PJ(),{noop:PZ0,genLog:n5}=ZG(),{DEFAULT_LEVELS:P6,SORTING_ORDER:YI}=JG(),XI={fatal:($)=>{let Z=n5(P6.fatal,$);return function(...J){let Y=this[LZ0];if(Z.call(this,...J),typeof Y.flushSync==="function")try{Y.flushSync()}catch(X){}}},error:($)=>n5(P6.error,$),warn:($)=>n5(P6.warn,$),info:($)=>n5(P6.info,$),debug:($)=>n5(P6.debug,$),trace:($)=>n5(P6.trace,$)},EB=Object.keys(P6).reduce(($,Z)=>{return $[P6[Z]]=Z,$},{}),CZ0=Object.keys(EB).reduce(($,Z)=>{return $[Z]='{"level":'+Number(Z),$},{});function IZ0($){let Z=$[TZ0].level,{labels:J}=$.levels,Y={};for(let X in J){let Q=Z(J[X],Number(X));Y[X]=JSON.stringify(Q).slice(0,-1)}return $[DZ0]=Y,$}function EZ0($,Z){if(Z)return!1;switch($){case"fatal":case"error":case"warn":case"info":case"debug":case"trace":return!0;default:return!1}}function bZ0($){let{labels:Z,values:J}=this.levels;if(typeof $==="number"){if(Z[$]===void 0)throw Error("unknown level value"+$);$=Z[$]}if(J[$]===void 0)throw Error("unknown level "+$);let Y=this[IB],X=this[IB]=J[$],Q=this[wZ0],G=this[JI],W=this[RZ0].logMethod;for(let K in J){if(G(J[K],X)===!1){this[K]=PZ0;continue}this[K]=EZ0(K,Q)?XI[K](W):n5(J[K],W)}this.emit("level-change",$,X,Z[Y],Y,this)}function _Z0($){let{levels:Z,levelVal:J}=this;return Z&&Z.labels?Z.labels[J]:""}function SZ0($){let{values:Z}=this.levels,J=Z[$];return J!==void 0&&this[JI](J,this[IB])}function fZ0($,Z,J){if($===YI.DESC)return Z<=J;return Z>=J}function kZ0($){if(typeof $==="string")return fZ0.bind(null,$);return $}function vZ0($=null,Z=!1){let J=$?Object.keys($).reduce((Q,G)=>{return Q[$[G]]=G,Q},{}):null,Y=Object.assign(Object.create(Object.prototype,{Infinity:{value:"silent"}}),Z?null:EB,J),X=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),Z?null:P6,$);return{labels:Y,values:X}}function yZ0($,Z,J){if(typeof $==="number"){if(![].concat(Object.keys(Z||{}).map((Q)=>Z[Q]),J?[]:Object.keys(EB).map((Q)=>+Q),1/0).includes($))throw Error(`default level:${$} must be included in custom levels`);return}let Y=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),J?null:P6,Z);if(!($ in Y))throw Error(`default level:${$} must be included in custom levels`)}function xZ0($,Z){let{labels:J,values:Y}=$;for(let X in Z){if(X in Y)throw Error("levels cannot be overridden");if(Z[X]in J)throw Error("pre-existing level values cannot be used for new levels")}}function hZ0($){if(typeof $==="function")return;if(typeof $==="string"&&Object.values(YI).includes($))return;throw Error('Levels comparison should be one of "ASC", "DESC" or "function" type')}QI.exports={initialLsCache:CZ0,genLsCache:IZ0,levelMethods:XI,getLevel:_Z0,setLevel:bZ0,isLevelEnabled:SZ0,mappings:vZ0,assertNoLevelCollisions:xZ0,assertDefaultLevelFound:yZ0,genLevelComparison:kZ0,assertLevelComparison:hZ0}});var _B=S((Ok0,GI)=>{GI.exports={version:"10.3.1"}});var FI=S((jk0,zI)=>{var{EventEmitter:gZ0}=J0("events"),{lsCacheSym:uZ0,levelValSym:mZ0,setLevelSym:fB,getLevelSym:WI,chindingsSym:XG,mixinSym:lZ0,asJsonSym:VI,writeSym:dZ0,mixinMergeStrategySym:pZ0,timeSym:cZ0,timeSliceIndexSym:iZ0,streamSym:UI,serializersSym:o5,formattersSym:kX,errorKeySym:nZ0,messageKeySym:oZ0,useOnlyCustomLevelsSym:sZ0,needsMetadataGsym:rZ0,redactFmtSym:aZ0,stringifySym:tZ0,formatOptsSym:eZ0,stringifiersSym:$50,msgPrefixSym:kB,hooksSym:Z50}=PJ(),{getLevel:J50,setLevel:Y50,isLevelEnabled:X50,mappings:Q50,initialLsCache:G50,genLsCache:W50,assertNoLevelCollisions:K50}=bB(),{asChindings:vB,asJson:V50,buildFormatters:SB,stringify:KI,noop:HI}=ZG(),{version:U50}=_B(),H50=UB(),B50=class{},BI={constructor:B50,child:z50,bindings:F50,setBindings:A50,flush:N50,isLevelEnabled:X50,version:U50,get level(){return this[WI]()},set level($){this[fB]($)},get levelVal(){return this[mZ0]},set levelVal($){throw Error("levelVal is read-only")},get msgPrefix(){return this[kB]},get[Symbol.toStringTag](){return"Pino"},[uZ0]:G50,[dZ0]:j50,[VI]:V50,[WI]:J50,[fB]:Y50};Object.setPrototypeOf(BI,gZ0.prototype);zI.exports=function(){return Object.create(BI)};var YG=($)=>$;function z50($,Z){if(!$)throw Error("missing bindings for child Pino");let J=this[o5],Y=this[kX],X=Object.create(this);if(Z==null){if(X[kX].bindings!==YG)X[kX]=SB(Y.level,YG,Y.log);if(X[XG]=vB(X,$),this.onChild!==HI)this.onChild(X);return X}if(Z.hasOwnProperty("serializers")===!0){X[o5]=Object.create(null);for(let V in J)X[o5][V]=J[V];let W=Object.getOwnPropertySymbols(J);for(var Q=0;Q<W.length;Q++){let V=W[Q];X[o5][V]=J[V]}for(let V in Z.serializers)X[o5][V]=Z.serializers[V];let K=Object.getOwnPropertySymbols(Z.serializers);for(var G=0;G<K.length;G++){let V=K[G];X[o5][V]=Z.serializers[V]}}else X[o5]=J;if(Z.hasOwnProperty("formatters")){let{level:W,bindings:K,log:V}=Z.formatters;X[kX]=SB(W||Y.level,K||YG,V||Y.log)}else X[kX]=SB(Y.level,YG,Y.log);if(Z.hasOwnProperty("customLevels")===!0)K50(this.levels,Z.customLevels),X.levels=Q50(Z.customLevels,X[sZ0]),W50(X);if(typeof Z.redact==="object"&&Z.redact!==null||Array.isArray(Z.redact)){X.redact=Z.redact;let W=H50(X.redact,KI),K={stringify:W[aZ0]};X[tZ0]=KI,X[$50]=W,X[eZ0]=K}if(typeof Z.msgPrefix==="string")X[kB]=(this[kB]||"")+Z.msgPrefix;if(X[XG]=vB(X,$),Z.level!==void 0&&Z.level!==this.level||Z.hasOwnProperty("customLevels")){let W=Z.level||this.level;X[fB](W)}return this.onChild(X),X}function F50(){let Z=`{${this[XG].substr(1)}}`,J=JSON.parse(Z);return delete J.pid,delete J.hostname,J}function A50($){let Z=vB(this,$);this[XG]=Z}function O50($,Z){return Object.assign(Z,$)}function j50($,Z,J){let Y=this[cZ0](),X=this[lZ0],Q=this[nZ0],G=this[oZ0],W=this[pZ0]||O50,K,V=this[Z50].streamWrite;if($===void 0||$===null)K={};else if($ instanceof Error){if(K={[Q]:$},Z===void 0)Z=$.message}else if(K=$,Z===void 0&&$[G]===void 0&&$[Q])Z=$[Q].message;if(X)K=W(K,X(K,J,this));let U=this[VI](K,Z,J,Y),H=this[UI];if(H[rZ0]===!0)H.lastLevel=J,H.lastObj=K,H.lastMsg=Z,H.lastTime=Y.slice(this[iZ0]),H.lastLogger=this;H.write(V?V(U):U)}function N50($){if($!=null&&typeof $!=="function")throw Error("callback must be a function");let Z=this[UI];if(typeof Z.flush==="function")Z.flush($||HI);else if($)$()}});var NI=S((Nk0,jI)=>{var{hasOwnProperty:vX}=Object.prototype,r5=hB();r5.configure=hB;r5.stringify=r5;r5.default=r5;Nk0.stringify=r5;Nk0.configure=hB;jI.exports=r5;var q50=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function dZ($){if($.length<5000&&!q50.test($))return`"${$}"`;return JSON.stringify($)}function yB($,Z){if($.length>200||Z)return $.sort(Z);for(let J=1;J<$.length;J++){let Y=$[J],X=J;while(X!==0&&$[X-1]>Y)$[X]=$[X-1],X--;$[X]=Y}return $}var M50=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function xB($){return M50.call($)!==void 0&&$.length!==0}function AI($,Z,J){if($.length<J)J=$.length;let Y=Z===","?"":" ",X=`"0":${Y}${$[0]}`;for(let Q=1;Q<J;Q++)X+=`${Z}"${Q}":${Y}${$[Q]}`;return X}function D50($){if(vX.call($,"circularValue")){let Z=$.circularValue;if(typeof Z==="string")return`"${Z}"`;if(Z==null)return Z;if(Z===Error||Z===TypeError)return{toString(){throw TypeError("Converting circular structure to JSON")}};throw TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function w50($){let Z;if(vX.call($,"deterministic")){if(Z=$.deterministic,typeof Z!=="boolean"&&typeof Z!=="function")throw TypeError('The "deterministic" argument must be of type boolean or comparator function')}return Z===void 0?!0:Z}function L50($,Z){let J;if(vX.call($,Z)){if(J=$[Z],typeof J!=="boolean")throw TypeError(`The "${Z}" argument must be of type boolean`)}return J===void 0?!0:J}function OI($,Z){let J;if(vX.call($,Z)){if(J=$[Z],typeof J!=="number")throw TypeError(`The "${Z}" argument must be of type number`);if(!Number.isInteger(J))throw TypeError(`The "${Z}" argument must be an integer`);if(J<1)throw RangeError(`The "${Z}" argument must be >= 1`)}return J===void 0?1/0:J}function s5($){if($===1)return"1 item";return`${$} items`}function T50($){let Z=new Set;for(let J of $)if(typeof J==="string"||typeof J==="number")Z.add(String(J));return Z}function R50($){if(vX.call($,"strict")){let Z=$.strict;if(typeof Z!=="boolean")throw TypeError('The "strict" argument must be of type boolean');if(Z)return(J)=>{let Y=`Object can not safely be stringified. Received type ${typeof J}`;if(typeof J!=="function")Y+=` (${J.toString()})`;throw Error(Y)}}}function hB($){$={...$};let Z=R50($);if(Z){if($.bigint===void 0)$.bigint=!1;if(!("circularValue"in $))$.circularValue=Error}let J=D50($),Y=L50($,"bigint"),X=w50($),Q=typeof X==="function"?X:void 0,G=OI($,"maximumDepth"),W=OI($,"maximumBreadth");function K(z,F,A,N,q,w){let j=F[z];if(typeof j==="object"&&j!==null&&typeof j.toJSON==="function")j=j.toJSON(z);switch(j=N.call(F,z,j),typeof j){case"string":return dZ(j);case"object":{if(j===null)return"null";if(A.indexOf(j)!==-1)return J;let M="",I=",",R=w;if(Array.isArray(j)){if(j.length===0)return"[]";if(G<A.length+1)return'"[Array]"';if(A.push(j),q!=="")w+=q,M+=`
|
|
87
|
+
${w}`,I=`,
|
|
88
|
+
${w}`;let b=Math.min(j.length,W),k=0;for(;k<b-1;k++){let x=K(String(k),j,A,N,q,w);M+=x!==void 0?x:"null",M+=I}let u=K(String(k),j,A,N,q,w);if(M+=u!==void 0?u:"null",j.length-1>W){let x=j.length-W-1;M+=`${I}"... ${s5(x)} not stringified"`}if(q!=="")M+=`
|
|
89
|
+
${R}`;return A.pop(),`[${M}]`}let L=Object.keys(j),C=L.length;if(C===0)return"{}";if(G<A.length+1)return'"[Object]"';let _="",E="";if(q!=="")w+=q,I=`,
|
|
90
|
+
${w}`,_=" ";let f=Math.min(C,W);if(X&&!xB(j))L=yB(L,Q);A.push(j);for(let b=0;b<f;b++){let k=L[b],u=K(k,j,A,N,q,w);if(u!==void 0)M+=`${E}${dZ(k)}:${_}${u}`,E=I}if(C>W){let b=C-W;M+=`${E}"...":${_}"${s5(b)} not stringified"`,E=I}if(q!==""&&E.length>1)M=`
|
|
91
|
+
${w}${M}
|
|
92
|
+
${R}`;return A.pop(),`{${M}}`}case"number":return isFinite(j)?String(j):Z?Z(j):"null";case"boolean":return j===!0?"true":"false";case"undefined":return;case"bigint":if(Y)return String(j);default:return Z?Z(j):void 0}}function V(z,F,A,N,q,w){if(typeof F==="object"&&F!==null&&typeof F.toJSON==="function")F=F.toJSON(z);switch(typeof F){case"string":return dZ(F);case"object":{if(F===null)return"null";if(A.indexOf(F)!==-1)return J;let j=w,M="",I=",";if(Array.isArray(F)){if(F.length===0)return"[]";if(G<A.length+1)return'"[Array]"';if(A.push(F),q!=="")w+=q,M+=`
|
|
93
|
+
${w}`,I=`,
|
|
94
|
+
${w}`;let C=Math.min(F.length,W),_=0;for(;_<C-1;_++){let f=V(String(_),F[_],A,N,q,w);M+=f!==void 0?f:"null",M+=I}let E=V(String(_),F[_],A,N,q,w);if(M+=E!==void 0?E:"null",F.length-1>W){let f=F.length-W-1;M+=`${I}"... ${s5(f)} not stringified"`}if(q!=="")M+=`
|
|
95
|
+
${j}`;return A.pop(),`[${M}]`}A.push(F);let R="";if(q!=="")w+=q,I=`,
|
|
96
|
+
${w}`,R=" ";let L="";for(let C of N){let _=V(C,F[C],A,N,q,w);if(_!==void 0)M+=`${L}${dZ(C)}:${R}${_}`,L=I}if(q!==""&&L.length>1)M=`
|
|
97
|
+
${w}${M}
|
|
98
|
+
${j}`;return A.pop(),`{${M}}`}case"number":return isFinite(F)?String(F):Z?Z(F):"null";case"boolean":return F===!0?"true":"false";case"undefined":return;case"bigint":if(Y)return String(F);default:return Z?Z(F):void 0}}function U(z,F,A,N,q){switch(typeof F){case"string":return dZ(F);case"object":{if(F===null)return"null";if(typeof F.toJSON==="function"){if(F=F.toJSON(z),typeof F!=="object")return U(z,F,A,N,q);if(F===null)return"null"}if(A.indexOf(F)!==-1)return J;let w=q;if(Array.isArray(F)){if(F.length===0)return"[]";if(G<A.length+1)return'"[Array]"';A.push(F),q+=N;let _=`
|
|
99
|
+
${q}`,E=`,
|
|
100
|
+
${q}`,f=Math.min(F.length,W),b=0;for(;b<f-1;b++){let u=U(String(b),F[b],A,N,q);_+=u!==void 0?u:"null",_+=E}let k=U(String(b),F[b],A,N,q);if(_+=k!==void 0?k:"null",F.length-1>W){let u=F.length-W-1;_+=`${E}"... ${s5(u)} not stringified"`}return _+=`
|
|
101
|
+
${w}`,A.pop(),`[${_}]`}let j=Object.keys(F),M=j.length;if(M===0)return"{}";if(G<A.length+1)return'"[Object]"';q+=N;let I=`,
|
|
102
|
+
${q}`,R="",L="",C=Math.min(M,W);if(xB(F))R+=AI(F,I,W),j=j.slice(F.length),C-=F.length,L=I;if(X)j=yB(j,Q);A.push(F);for(let _=0;_<C;_++){let E=j[_],f=U(E,F[E],A,N,q);if(f!==void 0)R+=`${L}${dZ(E)}: ${f}`,L=I}if(M>W){let _=M-W;R+=`${L}"...": "${s5(_)} not stringified"`,L=I}if(L!=="")R=`
|
|
103
|
+
${q}${R}
|
|
104
|
+
${w}`;return A.pop(),`{${R}}`}case"number":return isFinite(F)?String(F):Z?Z(F):"null";case"boolean":return F===!0?"true":"false";case"undefined":return;case"bigint":if(Y)return String(F);default:return Z?Z(F):void 0}}function H(z,F,A){switch(typeof F){case"string":return dZ(F);case"object":{if(F===null)return"null";if(typeof F.toJSON==="function"){if(F=F.toJSON(z),typeof F!=="object")return H(z,F,A);if(F===null)return"null"}if(A.indexOf(F)!==-1)return J;let N="",q=F.length!==void 0;if(q&&Array.isArray(F)){if(F.length===0)return"[]";if(G<A.length+1)return'"[Array]"';A.push(F);let R=Math.min(F.length,W),L=0;for(;L<R-1;L++){let _=H(String(L),F[L],A);N+=_!==void 0?_:"null",N+=","}let C=H(String(L),F[L],A);if(N+=C!==void 0?C:"null",F.length-1>W){let _=F.length-W-1;N+=`,"... ${s5(_)} not stringified"`}return A.pop(),`[${N}]`}let w=Object.keys(F),j=w.length;if(j===0)return"{}";if(G<A.length+1)return'"[Object]"';let M="",I=Math.min(j,W);if(q&&xB(F))N+=AI(F,",",W),w=w.slice(F.length),I-=F.length,M=",";if(X)w=yB(w,Q);A.push(F);for(let R=0;R<I;R++){let L=w[R],C=H(L,F[L],A);if(C!==void 0)N+=`${M}${dZ(L)}:${C}`,M=","}if(j>W){let R=j-W;N+=`${M}"...":"${s5(R)} not stringified"`}return A.pop(),`{${N}}`}case"number":return isFinite(F)?String(F):Z?Z(F):"null";case"boolean":return F===!0?"true":"false";case"undefined":return;case"bigint":if(Y)return String(F);default:return Z?Z(F):void 0}}function B(z,F,A){if(arguments.length>1){let N="";if(typeof A==="number")N=" ".repeat(Math.min(A,10));else if(typeof A==="string")N=A.slice(0,10);if(F!=null){if(typeof F==="function")return K("",{"":z},[],F,N,"");if(Array.isArray(F))return V("",z,[],T50(F),N,"")}if(N.length!==0)return U("",z,[],N,"")}return H("",z,[])}return B}});var wI=S((qk0,DI)=>{var gB=Symbol.for("pino.metadata"),{DEFAULT_LEVELS:MI}=JG(),I50=MI.info;function E50($,Z){$=$||[],Z=Z||{dedupe:!1};let J=Object.create(MI);if(J.silent=1/0,Z.levels&&typeof Z.levels==="object")Object.keys(Z.levels).forEach((H)=>{J[H]=Z.levels[H]});let Y={write:X,add:W,remove:K,emit:Q,flushSync:G,end:V,minLevel:0,lastId:0,streams:[],clone:U,[gB]:!0,streamLevels:J};if(Array.isArray($))$.forEach(W,Y);else W.call(Y,$);return $=null,Y;function X(H){let B,z=this.lastLevel,{streams:F}=this,A=0,N;for(let q=b50(F.length,Z.dedupe);S50(q,F.length,Z.dedupe);q=_50(q,Z.dedupe))if(B=F[q],B.level<=z){if(A!==0&&A!==B.level)break;if(N=B.stream,N[gB]){let{lastTime:w,lastMsg:j,lastObj:M,lastLogger:I}=this;N.lastLevel=z,N.lastTime=w,N.lastMsg=j,N.lastObj=M,N.lastLogger=I}if(N.write(H),Z.dedupe)A=B.level}else if(!Z.dedupe)break}function Q(...H){for(let{stream:B}of this.streams)if(typeof B.emit==="function")B.emit(...H)}function G(){for(let{stream:H}of this.streams)if(typeof H.flushSync==="function")H.flushSync()}function W(H){if(!H)return Y;let B=typeof H.write==="function"||H.stream,z=H.write?H:H.stream;if(!B)throw Error("stream object needs to implement either StreamEntry or DestinationStream interface");let{streams:F,streamLevels:A}=this,N;if(typeof H.levelVal==="number")N=H.levelVal;else if(typeof H.level==="string")N=A[H.level];else if(typeof H.level==="number")N=H.level;else N=I50;let q={stream:z,level:N,levelVal:void 0,id:++Y.lastId};return F.unshift(q),F.sort(qI),this.minLevel=F[0].level,Y}function K(H){let{streams:B}=this,z=B.findIndex((F)=>F.id===H);if(z>=0)B.splice(z,1),B.sort(qI),this.minLevel=B.length>0?B[0].level:-1;return Y}function V(){for(let{stream:H}of this.streams){if(typeof H.flushSync==="function")H.flushSync();H.end()}}function U(H){let B=Array(this.streams.length);for(let z=0;z<B.length;z++)B[z]={level:H,stream:this.streams[z].stream};return{write:X,add:W,remove:K,minLevel:H,streams:B,clone:U,emit:Q,flushSync:G,[gB]:!0}}}function qI($,Z){return $.level-Z.level}function b50($,Z){return Z?$-1:0}function _50($,Z){return Z?$-1:$+1}function S50($,Z,J){return J?$>=0:$<Z}DI.exports=E50});var yI=S((Mk0,h8)=>{var f50=J0("os"),bI=GB(),k50=WB(),v50=UB(),_I=WC(),y50=FI(),SI=PJ(),{configure:x50}=NI(),{assertDefaultLevelFound:h50,mappings:fI,genLsCache:g50,genLevelComparison:u50,assertLevelComparison:m50}=bB(),{DEFAULT_LEVELS:kI,SORTING_ORDER:l50}=JG(),{createArgsNormalizer:d50,asChindings:p50,buildSafeSonicBoom:LI,buildFormatters:c50,stringify:uB,normalizeDestFileDescriptor:TI,noop:i50}=ZG(),{version:n50}=_B(),{chindingsSym:RI,redactFmtSym:o50,serializersSym:PI,timeSym:s50,timeSliceIndexSym:r50,streamSym:a50,stringifySym:CI,stringifySafeSym:mB,stringifiersSym:II,setLevelSym:t50,endSym:e50,formatOptsSym:$70,messageKeySym:Z70,errorKeySym:J70,nestedKeySym:Y70,mixinSym:X70,levelCompSym:Q70,useOnlyCustomLevelsSym:G70,formattersSym:EI,hooksSym:W70,nestedKeyStrSym:K70,mixinMergeStrategySym:V70,msgPrefixSym:U70}=SI,{epochTime:vI,nullTime:H70}=_I,{pid:B70}=process,z70=f50.hostname(),F70=bI.err,A70={level:"info",levelComparison:l50.ASC,levels:kI,messageKey:"msg",errorKey:"err",nestedKey:null,enabled:!0,base:{pid:B70,hostname:z70},serializers:Object.assign(Object.create(null),{err:F70}),formatters:Object.assign(Object.create(null),{bindings($){return $},level($,Z){return{level:Z}}}),hooks:{logMethod:void 0,streamWrite:void 0},timestamp:vI,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100},O70=d50(A70),j70=Object.assign(Object.create(null),bI);function lB(...$){let Z={},{opts:J,stream:Y}=O70(Z,k50(),...$);if(J.level&&typeof J.level==="string"&&kI[J.level.toLowerCase()]!==void 0)J.level=J.level.toLowerCase();let{redact:X,crlf:Q,serializers:G,timestamp:W,messageKey:K,errorKey:V,nestedKey:U,base:H,name:B,level:z,customLevels:F,levelComparison:A,mixin:N,mixinMergeStrategy:q,useOnlyCustomLevels:w,formatters:j,hooks:M,depthLimit:I,edgeLimit:R,onChild:L,msgPrefix:C}=J,_=x50({maximumDepth:I,maximumBreadth:R}),E=c50(j.level,j.bindings,j.log),f=uB.bind({[mB]:_}),b=X?v50(X,f):{},k=X?{stringify:b[o50]}:{stringify:f},u="}"+(Q?`\r
|
|
105
|
+
`:`
|
|
106
|
+
`),x=p50.bind(null,{[RI]:"",[PI]:G,[II]:b,[CI]:uB,[mB]:_,[EI]:E}),g="";if(H!==null)if(B===void 0)g=x(H);else g=x(Object.assign({},H,{name:B}));let c=W instanceof Function?W:W?vI:H70,e=c().indexOf(":")+1;if(w&&!F)throw Error("customLevels is required if useOnlyCustomLevels is set true");if(N&&typeof N!=="function")throw Error(`Unknown mixin type "${typeof N}" - expected "function"`);if(C&&typeof C!=="string")throw Error(`Unknown msgPrefix type "${typeof C}" - expected "string"`);h50(z,F,w);let G0=fI(F,w);if(typeof Y.emit==="function")Y.emit("message",{code:"PINO_CONFIG",config:{levels:G0,messageKey:K,errorKey:V}});m50(A);let Q0=u50(A);return Object.assign(Z,{levels:G0,[Q70]:Q0,[G70]:w,[a50]:Y,[s50]:c,[r50]:e,[CI]:uB,[mB]:_,[II]:b,[e50]:u,[$70]:k,[Z70]:K,[J70]:V,[Y70]:U,[K70]:U?`,${JSON.stringify(U)}:{`:"",[PI]:G,[X70]:N,[V70]:q,[RI]:g,[EI]:E,[W70]:M,silent:i50,onChild:L,[U70]:C}),Object.setPrototypeOf(Z,y50()),g50(Z),Z[t50](z),Z}h8.exports=lB;h8.exports.destination=($=process.stdout.fd)=>{if(typeof $==="object")return $.dest=TI($.dest||process.stdout.fd),LI($);else return LI({dest:TI($),minLength:0})};h8.exports.transport=TB();h8.exports.multistream=wI();h8.exports.levels=fI();h8.exports.stdSerializers=j70;h8.exports.stdTimeFunctions=Object.assign({},_I);h8.exports.symbols=SI;h8.exports.version=n50;h8.exports.default=lB;h8.exports.pino=lB});var gI=S((Dk0,hI)=>{var QG=yI(),{serializersSym:xI}=QG.symbols,{FST_ERR_LOG_INVALID_DESTINATION:N70}=T$();function q70($){if($.stream&&$.file)throw new N70;else if($.file)$.stream=QG.destination($.file),delete $.file;let{logger:Z,genReqId:J}=$,Y=null;if(Z){if($.logger=void 0,$.genReqId=void 0,Z[xI])$.serializers=Object.assign({},$.serializers,Z[xI]);Y=Z.child({},$),$.logger=Z,$.genReqId=J}else Y=QG($,$.stream);return Y}var M70={req:function(Z){return{method:Z.method,url:Z.url,version:Z.headers&&Z.headers["accept-version"],host:Z.host,remoteAddress:Z.ip,remotePort:Z.socket?Z.socket.remotePort:void 0}},err:QG.stdSerializers.err,res:function(Z){return{statusCode:Z.statusCode}}};hI.exports={serializers:M70,createPinoLogger:q70}});var yX=S((wk0,mI)=>{var{FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED:D70,FST_ERR_LOG_INVALID_LOGGER_CONFIG:w70,FST_ERR_LOG_INVALID_LOGGER_INSTANCE:L70,FST_ERR_LOG_INVALID_LOGGER:T70}=T$();function R70($,Z,J,Y,X){let Q={[$.requestIdLogLabel]:Y},G=$.childLoggerFactory.call($.server,Z,Q,X||{},J);if($.childLoggerFactory!==uI)GG(G,!0);return G}function uI($,Z,J){return $.child(Z,J)}function GG($,Z){let J=["info","error","debug","fatal","warn","trace","child"],Y=$?J.filter((X)=>!$[X]||typeof $[X]!=="function"):J;if(!Y.length)return!0;else if(Y.length===J.length&&!Z)return!1;else throw T70(Y.join(","))}function P70($){if($.logger&&$.loggerInstance)throw new D70;if(!$.loggerInstance&&!$.logger){let G=EP();return G.child=()=>G,{logger:G,hasLogger:!1}}let{createPinoLogger:Z,serializers:J}=gI();if(GG($.loggerInstance))return{logger:Z({logger:$.loggerInstance,serializers:Object.assign({},J,$.loggerInstance.serializers)}),hasLogger:!0};if(GG($.logger))throw w70();if($.loggerInstance)throw L70();let Y={};if(Object.prototype.toString.call($.logger)==="[object Object]")Reflect.ownKeys($.logger).forEach((Q)=>{Object.defineProperty(Y,Q,{value:$.logger[Q],writable:!0,enumerable:!0,configurable:!0})});return Y.level=Y.level||"info",Y.serializers=Object.assign({},J,Y.serializers),$.logger=Y,{logger:Z($.logger),hasLogger:!0}}function C70(){let $=process.hrtime();return $[0]*1000+$[1]/1e6}mI.exports={createChildLogger:R70,defaultChildLoggerFactory:uI,createLogger:P70,validateLogger:GG,now:C70}});var WG=S((Lk0,lI)=>{lI.exports=I70;function EJ($){if($ instanceof Buffer)return Buffer.from($);return new $.constructor($.buffer.slice(),$.byteOffset,$.length)}function I70($){if($=$||{},$.circles)return E70($);let Z=new Map;if(Z.set(Date,(G)=>new Date(G)),Z.set(Map,(G,W)=>new Map(Y(Array.from(G),W))),Z.set(Set,(G,W)=>new Set(Y(Array.from(G),W))),$.constructorHandlers)for(let G of $.constructorHandlers)Z.set(G[0],G[1]);let J=null;return $.proto?Q:X;function Y(G,W){let K=Object.keys(G),V=Array(K.length);for(let U=0;U<K.length;U++){let H=K[U],B=G[H];if(typeof B!=="object"||B===null)V[H]=B;else if(B.constructor!==Object&&(J=Z.get(B.constructor)))V[H]=J(B,W);else if(ArrayBuffer.isView(B))V[H]=EJ(B);else V[H]=W(B)}return V}function X(G){if(typeof G!=="object"||G===null)return G;if(Array.isArray(G))return Y(G,X);if(G.constructor!==Object&&(J=Z.get(G.constructor)))return J(G,X);let W={};for(let K in G){if(Object.hasOwnProperty.call(G,K)===!1)continue;let V=G[K];if(typeof V!=="object"||V===null)W[K]=V;else if(V.constructor!==Object&&(J=Z.get(V.constructor)))W[K]=J(V,X);else if(ArrayBuffer.isView(V))W[K]=EJ(V);else W[K]=X(V)}return W}function Q(G){if(typeof G!=="object"||G===null)return G;if(Array.isArray(G))return Y(G,Q);if(G.constructor!==Object&&(J=Z.get(G.constructor)))return J(G,Q);let W={};for(let K in G){let V=G[K];if(typeof V!=="object"||V===null)W[K]=V;else if(V.constructor!==Object&&(J=Z.get(V.constructor)))W[K]=J(V,Q);else if(ArrayBuffer.isView(V))W[K]=EJ(V);else W[K]=Q(V)}return W}}function E70($){let Z=[],J=[],Y=new Map;if(Y.set(Date,(K)=>new Date(K)),Y.set(Map,(K,V)=>new Map(Q(Array.from(K),V))),Y.set(Set,(K,V)=>new Set(Q(Array.from(K),V))),$.constructorHandlers)for(let K of $.constructorHandlers)Y.set(K[0],K[1]);let X=null;return $.proto?W:G;function Q(K,V){let U=Object.keys(K),H=Array(U.length);for(let B=0;B<U.length;B++){let z=U[B],F=K[z];if(typeof F!=="object"||F===null)H[z]=F;else if(F.constructor!==Object&&(X=Y.get(F.constructor)))H[z]=X(F,V);else if(ArrayBuffer.isView(F))H[z]=EJ(F);else{let A=Z.indexOf(F);if(A!==-1)H[z]=J[A];else H[z]=V(F)}}return H}function G(K){if(typeof K!=="object"||K===null)return K;if(Array.isArray(K))return Q(K,G);if(K.constructor!==Object&&(X=Y.get(K.constructor)))return X(K,G);let V={};Z.push(K),J.push(V);for(let U in K){if(Object.hasOwnProperty.call(K,U)===!1)continue;let H=K[U];if(typeof H!=="object"||H===null)V[U]=H;else if(H.constructor!==Object&&(X=Y.get(H.constructor)))V[U]=X(H,G);else if(ArrayBuffer.isView(H))V[U]=EJ(H);else{let B=Z.indexOf(H);if(B!==-1)V[U]=J[B];else V[U]=G(H)}}return Z.pop(),J.pop(),V}function W(K){if(typeof K!=="object"||K===null)return K;if(Array.isArray(K))return Q(K,W);if(K.constructor!==Object&&(X=Y.get(K.constructor)))return X(K,W);let V={};Z.push(K),J.push(V);for(let U in K){let H=K[U];if(typeof H!=="object"||H===null)V[U]=H;else if(H.constructor!==Object&&(X=Y.get(H.constructor)))V[U]=X(H,W);else if(ArrayBuffer.isView(H))V[U]=EJ(H);else{let B=Z.indexOf(H);if(B!==-1)V[U]=J[B];else V[U]=W(H)}}return Z.pop(),J.pop(),V}}});var xX=S((Tk0,nI)=>{var b70=WG()({circles:!1,proto:!0}),{kSchemaVisited:dI,kSchemaResponse:_70}=B$(),dB=Symbol.for("fluent-schema-object"),{FST_ERR_SCH_MISSING_ID:S70,FST_ERR_SCH_ALREADY_PRESENT:f70,FST_ERR_SCH_DUPLICATE:k70,FST_ERR_SCH_CONTENT_MISSING_SCHEMA:pI}=T$(),iI=["params","body","querystring","query","headers"];function KG($){this.store=$||{}}KG.prototype.add=function($){let Z=b70($.isFluentSchema||$.isFluentJSONSchema||$[dB]?$.valueOf():$),J=Z.$id;if(!J)throw new S70;if(this.store[J])throw new f70(J);this.store[J]=Z};KG.prototype.getSchemas=function(){return Object.assign({},this.store)};KG.prototype.getSchema=function($){return this.store[$]};function cI($){return typeof $==="object"&&Object.getPrototypeOf($)!==Object.prototype}function v70($,Z){if($[dI])return $;if($.query){if($.querystring)throw new k70("querystring");$.querystring=$.query}y70($);for(let J of iI){let Y=$[J];if(Y&&!cI(Y)){if(J==="body"&&Y.content){let X=Y.content,Q=Object.keys(X);for(let G=0;G<Q.length;G++){let W=Q[G];if(!X[W].schema)throw new pI(W)}continue}}}if($.response){let J=Object.keys($.response);for(let Y of J){if(cI($.response[Y]))continue;let X=$.response[Y].content;if(X){let Q=Object.keys(X);for(let G=0;G<Q.length;G++){let W=Q[G];if(!X[W].schema)throw new pI(W)}}}}return $[dI]=!0,$}function y70($){for(let Z of iI)if($[Z]&&($[Z].isFluentSchema||$[Z][dB]))$[Z]=$[Z].valueOf();if($.response){let Z=Object.keys($.response);for(let J of Z)if($.response[J].isFluentSchema||$.response[J][dB])$.response[J]=$.response[J].valueOf()}}function x70($,Z,J){let Y=$[_70];if(!Y)return!1;if(Y[Z]){if(Y[Z].constructor===Object&&J){let Q=J.split(";",1)[0];if(Y[Z][Q])return Y[Z][Q];if(Y[Z]["*/*"])return Y[Z]["*/*"];return!1}return Y[Z]}let X=(Z+"")[0]+"xx";if(Y[X]){if(Y[X].constructor===Object&&J){let Q=J.split(";",1)[0];if(Y[X][Q])return Y[X][Q];if(Y[X]["*/*"])return Y[X]["*/*"];return!1}return Y[X]}if(Y.default){if(Y.default.constructor===Object&&J){let Q=J.split(";",1)[0];if(Y.default[Q])return Y.default[Q];if(Y.default["*/*"])return Y.default["*/*"];return!1}return Y.default}return!1}nI.exports={buildSchemas($){return new KG($)},getSchemaSerializer:x70,normalizeSchema:v70}});var VG=S((Rk0,oI)=>{var h70=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;oI.exports=class ${constructor(Z){switch(Z&&Z.rounding){case"floor":this.parseInteger=Math.floor;break;case"ceil":this.parseInteger=Math.ceil;break;case"round":this.parseInteger=Math.round;break;case"trunc":default:this.parseInteger=Math.trunc;break}this._options=Z}asInteger(Z){if(Number.isInteger(Z))return""+Z;else if(typeof Z==="bigint")return Z.toString();let J=this.parseInteger(Z);if(J===1/0||J===-1/0||J!==J)throw Error(`The value "${Z}" cannot be converted to an integer.`);return""+J}asNumber(Z){let J=Number(Z);if(J!==J)throw Error(`The value "${Z}" cannot be converted to a number.`);else if(J===1/0||J===-1/0)return"null";else return""+J}asBoolean(Z){return Z&&"true"||"false"}asDateTime(Z){if(Z===null)return'""';if(Z instanceof Date)return'"'+Z.toISOString()+'"';if(typeof Z==="string")return'"'+Z+'"';throw Error(`The value "${Z}" cannot be converted to a date-time.`)}asDate(Z){if(Z===null)return'""';if(Z instanceof Date)return'"'+new Date(Z.getTime()-Z.getTimezoneOffset()*60000).toISOString().slice(0,10)+'"';if(typeof Z==="string")return'"'+Z+'"';throw Error(`The value "${Z}" cannot be converted to a date.`)}asTime(Z){if(Z===null)return'""';if(Z instanceof Date)return'"'+new Date(Z.getTime()-Z.getTimezoneOffset()*60000).toISOString().slice(11,19)+'"';if(typeof Z==="string")return'"'+Z+'"';throw Error(`The value "${Z}" cannot be converted to a time.`)}asString(Z){let J=Z.length;if(J===0)return'""';else if(J<42){let Y="",X=-1,Q=255;for(let G=0;G<J;G++)if(Q=Z.charCodeAt(G),Q===34||Q===92)X===-1&&(X=0),Y+=Z.slice(X,G)+"\\",X=G;else if(Q<32||Q>=55296&&Q<=57343)return JSON.stringify(Z);return X===-1&&'"'+Z+'"'||'"'+Y+Z.slice(X)+'"'}else if(J<5000&&h70.test(Z)===!1)return'"'+Z+'"';else return JSON.stringify(Z)}asUnsafeString(Z){return'"'+Z+'"'}getState(){return this._options}static restoreFromState(Z){return new $(Z)}}});var rI=S((Pk0,sI)=>{var g70=VG(),u70={mode:"standalone"},m70=g70.restoreFromState(u70);sI.exports=function(Z,J){let{asString:Y,asNumber:X,asBoolean:Q,asDateTime:G,asDate:W,asTime:K,asUnsafeString:V}=J,U=J.asInteger.bind(J),H="{",B="}",z="[",F="]",A=",",N=":",q='"',w="{}",j="[]",M='""',I="null";function R(C){let _=C&&typeof C.toJSON==="function"?C.toJSON():C;if(_===null)return w;let E,f="{",b=!1;if(E=_.statusCode,E!==void 0)!b&&(b=!0)||(f+=","),f+='"statusCode":',f+=X(E);if(E=_.code,E!==void 0)if(!b&&(b=!0)||(f+=","),f+='"code":',typeof E!=="string")if(E===null)f+=M;else if(E instanceof Date)f+='"'+E.toISOString()+'"';else if(E instanceof RegExp)f+=Y(E.source);else f+=Y(E.toString());else f+=Y(E);if(E=_.error,E!==void 0)if(!b&&(b=!0)||(f+=","),f+='"error":',typeof E!=="string")if(E===null)f+=M;else if(E instanceof Date)f+='"'+E.toISOString()+'"';else if(E instanceof RegExp)f+=Y(E.source);else f+=Y(E.toString());else f+=Y(E);if(E=_.message,E!==void 0)if(!b&&(b=!0)||(f+=","),f+='"message":',typeof E!=="string")if(E===null)f+=M;else if(E instanceof Date)f+='"'+E.toISOString()+'"';else if(E instanceof RegExp)f+=Y(E.source);else f+=Y(E.toString());else f+=Y(E);return f+"}"}return R}(null,m70)});var hX=S((Ck0,$E)=>{var aI=J0("http").STATUS_CODES,l70=dH(),{setErrorStatusCode:d70}=x4(),{kReplyHeaders:a5,kReplyNextErrorHandler:UG,kReplyIsRunningOnErrorHook:p70,kRouteContext:eI,kDisableRequestLogging:HG}=B$(),{FST_ERR_REP_INVALID_PAYLOAD_TYPE:c70,FST_ERR_FAILED_ERROR_SERIALIZATION:i70}=T$(),{getSchemaSerializer:n70}=xX(),pB=rI(),o70={func:r70,toJSON(){return this.func.name.toString()+"()"}};function s70($,Z,J){$[p70]=!1;let Y=$[eI];if($[UG]===!1){tI(Z,$,function(G,W){try{G.raw.writeHead(G.raw.statusCode,G[a5])}catch(K){if(!G.log[HG])G.log.warn({req:G.request,res:G,err:K},K?.message);G.raw.writeHead(G.raw.statusCode)}G.raw.end(W)});return}let X=$[UG]||Y.errorHandler;$[UG]=Object.getPrototypeOf(X),delete $[a5]["content-type"],delete $[a5]["content-length"];let Q=X.func;if(!Q){$[UG]=!1,tI(Z,$,J);return}try{let G=Q(Z,$.request,$);if(G!==void 0)if(G!==null&&typeof G.then==="function")l70(G,$);else $.send(G)}catch(G){$.send(G)}}function r70($,Z,J){if(t70($,J),d70(J,$),J.statusCode<500){if(!J.log[HG])J.log.info({res:J,err:$},$?.message)}else if(!J.log[HG])J.log.error({req:Z,res:J,err:$},$?.message);J.send($)}function tI($,Z,J){let{raw:Y,statusCode:X}=Z;Z[a5]["content-type"]=Z[a5]["content-type"]??"application/json; charset=utf-8";let Q;try{let G=n70(Z[eI],X,Z[a5]["content-type"]);if(G===!1)Q=pB({error:aI[X+""],code:$.code,message:$.message,statusCode:X});else Q=G(Object.create($,{error:{value:aI[X+""]},message:{value:$.message},statusCode:{value:X}}))}catch(G){if(!Z.log[HG])Z.log.error({err:G,statusCode:Y.statusCode},"The serializer for the given status code failed");Z.code(500),Q=pB(new i70(G.message,$.message))}if(typeof Q!=="string"&&!Buffer.isBuffer(Q))Q=pB(new c70(typeof Q));Z[a5]["content-length"]=""+Buffer.byteLength(Q),J(Z,Q)}function a70($=o70,Z){if(!Z)return $;let J=Object.create($);return J.func=Z,J}function t70($,Z){let J=Z.raw,Y=J.statusCode;if(Y=Y>=400?Y:500,$!=null){if($.headers!==void 0)Z.headers($.headers);if($.status>=400)Y=$.status;else if($.statusCode>=400)Y=$.statusCode}J.statusCode=Y}$E.exports={buildErrorHandler:a70,handleError:s70}});var mX=S((Ik0,XE)=>{var{kReply:cB,kRequest:iB,kState:e70,kHasBeenDecorated:$J0}=B$(),{FST_ERR_DEC_ALREADY_PRESENT:ZE,FST_ERR_DEC_MISSING_DEPENDENCY:ZJ0,FST_ERR_DEC_AFTER_START:JJ0,FST_ERR_DEC_REFERENCE_TYPE:YJ0,FST_ERR_DEC_DEPENDENCY_INVALID_TYPE:XJ0,FST_ERR_DEC_UNDECLARED:QJ0}=T$();function GJ0($,Z,J,Y){if(Object.hasOwn($,Z))throw new ZE(Z);if(nB($,Z,Y),J&&(typeof J.getter==="function"||typeof J.setter==="function"))Object.defineProperty($,Z,{get:J.getter,set:J.setter});else $[Z]=J}function WJ0($){if(!gX(this,$))throw new QJ0($,"instance");if(typeof this[$]==="function")return this[$].bind(this);return this[$]}function JE($,Z,J,Y){let X=$.prototype;if(Object.hasOwn(X,Z)||uX($,Z))throw new ZE(Z);if($[$J0]=!0,nB($,Z,Y),J&&(typeof J.getter==="function"||typeof J.setter==="function"))Object.defineProperty(X,Z,{get:J.getter,set:J.setter});else if(typeof J==="function")X[Z]=J;else $.props.push({key:Z,value:J})}function YE($,Z){if(typeof Z==="object"&&Z&&!(typeof Z.getter==="function"||typeof Z.setter==="function"))throw new YJ0($,typeof Z)}function KJ0($,Z,J){return oB(this,$),GJ0(this,$,Z,J),this}function gX($,Z){if(Z)return Z in $||$.prototype&&Z in $.prototype||uX($,Z);return $ in this}function uX($,Z){if($.props)return $.props.find(({key:J})=>J===Z);return!1}function VJ0($){if($&&uX(this[iB],$))return!0;return gX(this[iB].prototype,$)}function UJ0($){if($&&uX(this[cB],$))return!0;return gX(this[cB].prototype,$)}function nB($,Z,J){if(J===void 0||J===null)return;if(!Array.isArray(J))throw new XJ0(Z);for(let Y=0;Y!==J.length;++Y)if(!gX($,J[Y]))throw new ZJ0(J[Y])}function HJ0($,Z,J){return oB(this,$),YE($,Z),JE(this[cB],$,Z,J),this}function BJ0($,Z,J){return oB(this,$),YE($,Z),JE(this[iB],$,Z,J),this}function oB($,Z){if($[e70].started)throw new JJ0(Z)}XE.exports={add:KJ0,exist:gX,existRequest:VJ0,existReply:UJ0,dependencies:nB,decorateReply:HJ0,decorateRequest:BJ0,getInstanceDecorator:WJ0,hasKey:uX}});var MG=S((Ek0,qG)=>{var BG=J0("stream").finished,{kFourOhFourContext:QE,kReplyErrorHandlerCalled:BE,kReplyHijacked:eB,kReplyStartTime:dX,kReplyEndTime:$z,kReplySerializer:e6,kReplySerializerDefault:zG,kReplyIsError:FG,kReplyHeaders:k1,kReplyTrailers:R$,kReplyHasStatusCode:Zz,kReplyIsRunningOnErrorHook:Jz,kReplyNextErrorHandler:zJ0,kDisableRequestLogging:zE,kSchemaResponse:AG,kReplyCacheSerializeFns:pZ,kSchemaController:sB,kOptions:FJ0,kRouteContext:K1,kTimeoutTimer:OG,kOnAbort:bJ,kRequestSignal:FE}=B$(),{onSendHookRunner:AE,onResponseHookRunner:AJ0,preHandlerHookRunner:OJ0,preSerializationHookRunner:jJ0}=mZ(),GE=rH()[Symbol.for("internals")],NJ0=yX(),tB=NJ0.now,{handleError:WE}=hX(),{getSchemaSerializer:qJ0}=xX(),rB={JSON:"application/json; charset=utf-8",PLAIN:"text/plain; charset=utf-8",OCTET:"application/octet-stream"},{FST_ERR_REP_INVALID_PAYLOAD_TYPE:MJ0,FST_ERR_REP_RESPONSE_BODY_CONSUMED:DJ0,FST_ERR_REP_READABLE_STREAM_LOCKED:wJ0,FST_ERR_REP_ALREADY_SENT:LJ0,FST_ERR_SEND_INSIDE_ONERR:TJ0,FST_ERR_BAD_STATUS_CODE:RJ0,FST_ERR_BAD_TRAILER_NAME:PJ0,FST_ERR_BAD_TRAILER_VALUE:CJ0,FST_ERR_MISSING_SERIALIZATION_FN:IJ0,FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN:EJ0,FST_ERR_DEC_UNDECLARED:bJ0}=T$(),KE=mX(),OE=Object.prototype.toString;function v1($,Z,J){this.raw=$,this[e6]=null,this[BE]=!1,this[FG]=!1,this[Jz]=!1,this.request=Z,this[k1]={},this[R$]=null,this[Zz]=!1,this[dX]=void 0,this.log=J}v1.props=[];Object.defineProperties(v1.prototype,{[K1]:{get(){return this.request[K1]}},elapsedTime:{get(){if(this[dX]===void 0)return 0;return(this[$z]||tB())-this[dX]}},server:{get(){return this.request[K1].server}},sent:{enumerable:!0,get(){return(this[eB]||this.raw.writableEnded)===!0}},statusCode:{get(){return this.raw.statusCode},set($){this.code($)}},routeOptions:{get(){return this.request.routeOptions}}});v1.prototype.writeEarlyHints=function($,Z){return this.raw.writeEarlyHints($,Z),this};v1.prototype.hijack=function(){if(this[eB]=!0,this.request[FE]){if(clearTimeout(this.request[OG]),this.request[OG]=null,this.request[bJ])this.request.raw.removeListener("close",this.request[bJ]),this.request[bJ]=null}return this};v1.prototype.send=function($){if(this[Jz])throw new TJ0;if(this.sent===!0)return this.log.warn({err:new LJ0(this.request.url,this.request.method)}),this;if(this[FG]||$ instanceof Error)return this[FG]=!1,_J(this,$,t5),this;if($===void 0)return t5(this,$),this;let Z=this.getHeader("content-type"),J=Z!==void 0;if($!==null){if(typeof $.pipe==="function"||typeof $.getReader==="function"||OE.call($)==="[object Response]")return t5(this,$),this;if($.buffer instanceof ArrayBuffer){if(!J)this[k1]["content-type"]=rB.OCTET;let Y=Buffer.isBuffer($)?$:Buffer.from($.buffer,$.byteOffset,$.byteLength);return t5(this,Y),this}if(!J&&typeof $==="string")return this[k1]["content-type"]=rB.PLAIN,t5(this,$),this}if(this[e6]!==null){if(typeof $!=="string")return VE(this,$),this;$=this[e6]($)}else if(!J||Z.indexOf("json")!==-1){if(!J)this[k1]["content-type"]=rB.JSON;else if(Z.indexOf("charset")===-1){let Y=Z.trim();if(Y.endsWith(";"))this[k1]["content-type"]=`${Y} charset=utf-8`;else this[k1]["content-type"]=`${Y}; charset=utf-8`}if(typeof $!=="string")return VE(this,$),this}return t5(this,$),this};v1.prototype.getHeader=function($){$=$.toLowerCase();let Z=this[k1][$];return Z!==void 0?Z:this.raw.getHeader($)};v1.prototype.getHeaders=function(){return{...this.raw.getHeaders(),...this[k1]}};v1.prototype.hasHeader=function($){return $=$.toLowerCase(),this[k1][$]!==void 0||this.raw.hasHeader($)};v1.prototype.removeHeader=function($){return delete this[k1][$.toLowerCase()],this};v1.prototype.header=function($,Z=""){if($=$.toLowerCase(),this[k1][$]&&$==="set-cookie"){if(typeof this[k1][$]==="string")this[k1][$]=[this[k1][$]];if(Array.isArray(Z))Array.prototype.push.apply(this[k1][$],Z);else this[k1][$].push(Z)}else this[k1][$]=Z;return this};v1.prototype.headers=function($){let Z=Object.keys($);for(let J=0;J!==Z.length;++J){let Y=Z[J];this.header(Y,$[Y])}return this};var _J0=new Set(["transfer-encoding","content-length","host","cache-control","max-forwards","te","authorization","set-cookie","content-encoding","content-type","content-range","trailer"]);v1.prototype.trailer=function($,Z){if($=$.toLowerCase(),_J0.has($))throw new PJ0($);if(typeof Z!=="function")throw new CJ0($,typeof Z);if(this[R$]===null)this[R$]={};return this[R$][$]=Z,this};v1.prototype.hasTrailer=function($){return this[R$]?.[$.toLowerCase()]!==void 0};v1.prototype.removeTrailer=function($){if(this[R$]===null)return this;return this[R$][$.toLowerCase()]=void 0,this};v1.prototype.code=function($){let Z=+$;if(!(Z>=100&&Z<=599))throw new RJ0($||String($));return this.raw.statusCode=Z,this[Zz]=!0,this};v1.prototype.status=v1.prototype.code;v1.prototype.getSerializationFunction=function($,Z){let J;if(typeof $==="string"||typeof $==="number")if(typeof Z==="string")J=this[K1][AG]?.[$]?.[Z];else J=this[K1][AG]?.[$];else if(typeof $==="object")J=this[K1][pZ]?.get($);return J};v1.prototype.compileSerializationSchema=function($,Z=null,J=null){let{request:Y}=this,{method:X,url:Q}=Y;if(this[K1][pZ]?.has($))return this[K1][pZ].get($);let W=(this[K1].serializerCompiler||this.server[sB].serializerCompiler||(this.server[sB].setupSerializer(this.server[FJ0])||this.server[sB].serializerCompiler))({schema:$,method:X,url:Q,httpStatus:Z,contentType:J});if(this[K1][pZ]==null)this[K1][pZ]=new WeakMap;return this[K1][pZ].set($,W),W};v1.prototype.serializeInput=function($,Z,J,Y){let X=J,Q;if(J=typeof Z==="string"||typeof Z==="number"?Z:J,Y=J&&X!==J?X:Y,J!=null){if(Y!=null)Q=this[K1][AG]?.[J]?.[Y];else Q=this[K1][AG]?.[J];if(Q==null){if(Y)throw new EJ0(J,Y);throw new IJ0(J)}}else if(this[K1][pZ]?.has(Z))Q=this[K1][pZ].get(Z);else Q=this.compileSerializationSchema(Z,J,Y);return Q($)};v1.prototype.serialize=function($){if(this[e6]!==null)return this[e6]($);else if(this[K1]&&this[K1][zG])return this[K1][zG]($,this.raw.statusCode);else return NE(this[K1],$,this.raw.statusCode)};v1.prototype.serializer=function($){return this[e6]=$,this};v1.prototype.type=function($){return this[k1]["content-type"]=$,this};v1.prototype.redirect=function($,Z){if(!Z)Z=this[Zz]?this.raw.statusCode:302;return this.header("location",$).code(Z).send()};v1.prototype.callNotFound=function(){return gJ0(this),this};v1.prototype.then=function($,Z){if(this.sent){$();return}BG(this.raw,(J)=>{if(J&&J.code!=="ERR_STREAM_PREMATURE_CLOSE")if(Z)Z(J);else this.log&&this.log.warn("unhandled rejection on reply.then");else $()})};v1.prototype.getDecorator=function($){if(!KE.hasKey(this,$)&&!KE.exist(this,$))throw new bJ0($,"reply");let Z=this[$];if(typeof Z==="function")return Z.bind(this);return Z};function VE($,Z){if($[K1].preSerialization!==null)jJ0($[K1].preSerialization,$.request,$,Z,UE);else UE(null,void 0,$,Z)}function UE($,Z,J,Y){if($!=null){_J(J,$);return}try{if(J[e6]!==null)Y=J[e6](Y);else if(J[K1]&&J[K1][zG])Y=J[K1][zG](Y,J.raw.statusCode);else Y=NE(J[K1],Y,J.raw.statusCode,J[k1]["content-type"])}catch(X){SJ0(X,J),_J(J,X);return}t5(J,Y)}function SJ0($,Z){$.serialization=Z[K1].config}function t5($,Z){if($[K1].onSend!==null)AE($[K1].onSend,$.request,$,Z,fJ0);else jE($,Z)}function fJ0($,Z,J,Y){if($!=null)_J(J,$);else jE(J,Y)}function aB($,Z){let J=$.raw;try{J.writeHead(Z,$[k1])}catch(Y){if(Y.code==="ERR_HTTP_HEADERS_SENT")$.log.warn(`Reply was already sent, did you forget to "return reply" in the "${$.request.raw.url}" (${$.request.raw.method}) route?`);throw Y}}function jE($,Z){let{raw:J,request:Y}=$;if($[R$]!==null){let Q=Object.keys($[R$]),G="";for(let W of Q){if(typeof $[R$][W]!=="function")continue;G+=" ",G+=W}$.header("Transfer-Encoding","chunked"),$.header("Trailer",G.trim())}if(OE.call(Z)==="[object Response]"){if(typeof Z.status==="number")$.code(Z.status);if(typeof Z.headers==="object"&&typeof Z.headers.forEach==="function")for(let[Q,G]of Z.headers)$.header(Q,G);if(Z.body!==null){if(Z.bodyUsed)throw new DJ0}Z=Z.body}let X=J.statusCode;if(Z===void 0||Z===null){if(X>=200&&X!==204&&X!==304&&Y.method!=="HEAD"&&$[R$]===null)$[k1]["content-length"]="0";aB($,X),lX(Z,J,$);return}if(X>=100&&X<200||X===204){if($.removeHeader("content-type"),$.removeHeader("content-length"),aB($,X),lX(void 0,J,$),typeof Z.resume==="function")Z.on("error",NG),Z.resume();return}if(typeof Z.pipe==="function"){vJ0(Z,J,$);return}if(typeof Z.getReader==="function"){kJ0(Z,J,$);return}if(typeof Z!=="string"&&!Buffer.isBuffer(Z))throw new MJ0(typeof Z);if($[R$]===null){let Q=$[k1]["content-length"];if(!Q||Y.raw.method!=="HEAD"&&Number(Q)!==Buffer.byteLength(Z))$[k1]["content-length"]=""+Buffer.byteLength(Z)}aB($,X),J.write(Z),lX(Z,J,$)}function jG($,Z,J){if(Z.code==="ERR_STREAM_PREMATURE_CLOSE"){if(!$[zE])$.info({res:J},"stream closed prematurely")}else $.warn({err:Z},"response terminated with an error with headers already sent")}function kJ0($,Z,J){if($.locked)throw new wJ0;let Y=!0,X=!1,Q=!1,G=$.getReader();if(BG(Z,function(U){if(Y){if(U!=null&&Z.headersSent&&!X)X=!0,jG(J.log,U,Z);G.cancel().catch(NG)}}),!Z.headersSent)for(let U in J[k1])Z.setHeader(U,J[k1][U]);else J.log.warn("response will send, but you shouldn't use res.writeHead in stream mode");function W(U){if(U.done){Y=!1,lX(null,Z,J);return}if(Z.destroyed){Y=!1,G.cancel().catch(NG);return}if(Z.write(U.value)===!1){Q=!0,Z.once("drain",K);return}G.read().then(W,V)}function K(){if(!Q||!Y||Z.destroyed)return;Q=!1,G.read().then(W,V)}function V(U){if(Y=!1,Z.headersSent||J.request.raw.aborted===!0){if(!X)X=!0,jG(J.log,U,J);Z.destroy()}else _J(J,U)}G.read().then(W,V)}function vJ0($,Z,J){let Y=!0,X=!1;if(yJ0($,Z,J),BG($,{readable:!0,writable:!1},function(Q){if(Y=!1,Q!=null)if(Z.headersSent||J.request.raw.aborted===!0){if(!X)X=!0,jG(J.log,Q,J);Z.destroy()}else _J(J,Q)}),BG(Z,function(Q){if(Y){if(Q!=null&&Z.headersSent&&!X)X=!0,jG(J.log,Q,Z);if(typeof $.destroy==="function")$.destroy();else if(typeof $.close==="function")$.close(NG);else if(typeof $.abort==="function")$.abort();else J.log.warn("stream payload does not end properly")}}),!Z.headersSent)for(let Q in J[k1])Z.setHeader(Q,J[k1][Q]);else J.log.warn("response will send, but you shouldn't use res.writeHead in stream mode");$.pipe(Z)}function lX($,Z,J){if(J[R$]===null){Z.end(null,null,null);return}let Y=Object.keys(J[R$]),X={},Q=0,G=!0;function W(){if(Q===0)Z.addTrailers(X),Z.end(null,null,null)}for(let K of Y){let V=function(H,B){if(Q++,H)J.log.debug(H);else X[K]=B;process.nextTick(W)};if(typeof J[R$][K]!=="function")continue;G=!1,Q--;let U=J[R$][K](J,$,V);if(typeof U==="object"&&typeof U.then==="function")U.then((H)=>V(null,H),V)}if(G)Z.end(null,null,null)}function yJ0($,Z,J){if(J[R$]===null)return;$.on("end",()=>lX(null,Z,J))}function _J($,Z,J){if($[K1].onError!==null&&!$[zJ0])$[Jz]=!0,AE($[K1].onError,$.request,$,Z,()=>WE($,Z,J));else WE($,Z,J)}function xJ0($){$[dX]=tB();let Z=(J)=>{$[$z]=tB(),$.raw.removeListener("finish",Z),$.raw.removeListener("error",Z);let Y=$[K1];if($.request[FE]){if(clearTimeout($.request[OG]),$.request[OG]=null,$.request[bJ])$.request.raw.removeListener("close",$.request[bJ]),$.request[bJ]=null}if(Y&&Y.onResponse!==null)AJ0(Y.onResponse,$.request,$,HE);else HE(J,$.request,$)};$.raw.on("finish",Z),$.raw.on("error",Z)}function HE($,Z,J){if(J.log[zE])return;let Y=J.elapsedTime;if($!=null){J.log.error({res:J,err:$,responseTime:Y},"request errored");return}J.log.info({res:J,responseTime:Y},"request completed")}function hJ0($){let Z=$.props.slice();function J(Y,X,Q){this.raw=Y,this[FG]=!1,this[BE]=!1,this[eB]=!1,this[e6]=null,this.request=X,this[k1]={},this[R$]=null,this[dX]=void 0,this[$z]=void 0,this.log=Q;let G;for(let W=0;W<Z.length;W++)G=Z[W],this[G.key]=G.value}return Object.setPrototypeOf(J.prototype,$.prototype),Object.setPrototypeOf(J,$),J.parent=$,J.props=Z,J}function gJ0($){if($[K1][QE]===null){$.log.warn("Trying to send a NotFound error inside a 404 handler. Sending basic 404 response."),$.code(404).send("404 Not Found");return}if($.request[K1]=$[K1][QE],$[K1].preHandler!==null)OJ0($[K1].preHandler,$.request,$,GE.preHandlerCallback);else GE.preHandlerCallback(null,$.request,$)}function NE($,Z,J,Y){let X=qJ0($,J,Y);if(X)return X(Z);return JSON.stringify(Z)}function NG(){}qG.exports=v1;qG.exports.buildReply=hJ0;qG.exports.setupResponseListeners=xJ0});var qE=S((bk0,DG)=>{function Yz($){if(!$)throw TypeError("argument req is required");let Z=$.headers["x-forwarded-for"],J=$.socket.remoteAddress;if(!Z||typeof Z!=="string")return[J];else if(Z.indexOf(",")===-1){let Y=Z.trim();return Y.length?[J,Y]:[J]}else return uJ0(Z,J)}function uJ0($,Z){let J=[Z],Y=$.length,X=Y,Q,G;for(G=Y-1;G>=0;--G)if(Q=$[G],Q===" ")X===Y&&(X=Y=G);else if(Q===",")X!==Y&&J.push($.slice(X,Y)),X=Y=G;else X=G;return X!==Y&&J.push($.substring(X,Y)),J}DG.exports=Yz;DG.exports.default=Yz;DG.exports.forwarded=Yz});var DE=S((ME,wG)=>{(function($){let J={fourOctet:new RegExp("^(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)$","i"),threeOctet:new RegExp("^(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)$","i"),twoOctet:new RegExp("^(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)$","i"),longValue:new RegExp("^(0?\\d+|0x[a-f0-9]+)$","i")},Y=new RegExp("^0[0-7]+$","i"),X=new RegExp("^0x[a-f0-9]+$","i"),Q="%[0-9a-z]{1,}",G="(?:[0-9a-f]+::?)+",W={zoneIndex:new RegExp("%[0-9a-z]{1,}","i"),native:new RegExp("^(::)?((?:[0-9a-f]+::?)+)?([0-9a-f]+)?(::)?(%[0-9a-z]{1,})?$","i"),deprecatedTransitional:new RegExp("^(?:::)((0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)(%[0-9a-z]{1,})?)$","i"),transitional:new RegExp("^((?:(?:[0-9a-f]+::?)+)|(?:::)(?:(?:[0-9a-f]+::?)+)?)(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)(%[0-9a-z]{1,})?$","i")};function K(z,F){if(z.indexOf("::")!==z.lastIndexOf("::"))return null;let A=0,N=-1,q=(z.match(W.zoneIndex)||[])[0],w,j;if(q)q=q.substring(1),z=z.replace(/%.+$/,"");while((N=z.indexOf(":",N+1))>=0)A++;if(z.substr(0,2)==="::")A--;if(z.substr(-2,2)==="::")A--;if(A>F)return null;j=F-A,w=":";while(j--)w+="0:";if(z=z.replace("::",w),z[0]===":")z=z.slice(1);if(z[z.length-1]===":")z=z.slice(0,-1);return F=function(){let M=z.split(":"),I=[];for(let R=0;R<M.length;R++)I.push(parseInt(M[R],16));return I}(),{parts:F,zoneId:q}}function V(z,F,A,N){if(z.length!==F.length)throw Error("ipaddr: cannot match CIDR for objects with different lengths");let q=0,w;while(N>0){if(w=A-N,w<0)w=0;if(z[q]>>w!==F[q]>>w)return!1;N-=A,q+=1}return!0}function U(z){if(X.test(z))return parseInt(z,16);if(z[0]==="0"&&!isNaN(parseInt(z[1],10))){if(Y.test(z))return parseInt(z,8);throw Error(`ipaddr: cannot parse ${z} as octal`)}return parseInt(z,10)}function H(z,F){while(z.length<F)z=`0${z}`;return z}let B={};if(B.IPv4=function(){function z(F){if(F.length!==4)throw Error("ipaddr: ipv4 octet count should be 4");let A,N;for(A=0;A<F.length;A++)if(N=F[A],!(0<=N&&N<=255))throw Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=F}return z.prototype.SpecialRanges={unspecified:[[new z([0,0,0,0]),8]],broadcast:[[new z([255,255,255,255]),32]],multicast:[[new z([224,0,0,0]),4]],linkLocal:[[new z([169,254,0,0]),16]],loopback:[[new z([127,0,0,0]),8]],carrierGradeNat:[[new z([100,64,0,0]),10]],private:[[new z([10,0,0,0]),8],[new z([172,16,0,0]),12],[new z([192,168,0,0]),16]],reserved:[[new z([192,0,0,0]),24],[new z([192,0,2,0]),24],[new z([192,88,99,0]),24],[new z([198,18,0,0]),15],[new z([198,51,100,0]),24],[new z([203,0,113,0]),24],[new z([240,0,0,0]),4]],as112:[[new z([192,175,48,0]),24],[new z([192,31,196,0]),24]],amt:[[new z([192,52,193,0]),24]]},z.prototype.kind=function(){return"ipv4"},z.prototype.match=function(F,A){let N;if(A===void 0)N=F,F=N[0],A=N[1];if(F.kind()!=="ipv4")throw Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return V(this.octets,F.octets,8,A)},z.prototype.prefixLengthFromSubnetMask=function(){let F=0,A=!1,N={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},q,w,j;for(q=3;q>=0;q-=1)if(w=this.octets[q],w in N){if(j=N[w],A&&j!==0)return null;if(j!==8)A=!0;F+=j}else return null;return 32-F},z.prototype.range=function(){return B.subnetMatch(this,this.SpecialRanges)},z.prototype.toByteArray=function(){return this.octets.slice(0)},z.prototype.toIPv4MappedAddress=function(){return B.IPv6.parse(`::ffff:${this.toString()}`)},z.prototype.toNormalizedString=function(){return this.toString()},z.prototype.toString=function(){return this.octets.join(".")},z}(),B.IPv4.broadcastAddressFromCIDR=function(z){try{let F=this.parseCIDR(z),A=F[0].toByteArray(),N=this.subnetMaskFromPrefixLength(F[1]).toByteArray(),q=[],w=0;while(w<4)q.push(parseInt(A[w],10)|parseInt(N[w],10)^255),w++;return new this(q)}catch(F){throw Error("ipaddr: the address does not have IPv4 CIDR format")}},B.IPv4.isIPv4=function(z){return this.parser(z)!==null},B.IPv4.isValid=function(z){try{return new this(this.parser(z)),!0}catch(F){return!1}},B.IPv4.isValidCIDR=function(z){try{return this.parseCIDR(z),!0}catch(F){return!1}},B.IPv4.isValidFourPartDecimal=function(z){if(B.IPv4.isValid(z)&&z.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))return!0;else return!1},B.IPv4.isValidCIDRFourPartDecimal=function(z){let F=z.match(/^(.+)\/(\d+)$/);if(!B.IPv4.isValidCIDR(z)||!F)return!1;return B.IPv4.isValidFourPartDecimal(F[1])},B.IPv4.networkAddressFromCIDR=function(z){let F,A,N,q,w;try{F=this.parseCIDR(z),N=F[0].toByteArray(),w=this.subnetMaskFromPrefixLength(F[1]).toByteArray(),q=[],A=0;while(A<4)q.push(parseInt(N[A],10)&parseInt(w[A],10)),A++;return new this(q)}catch(j){throw Error("ipaddr: the address does not have IPv4 CIDR format")}},B.IPv4.parse=function(z){let F=this.parser(z);if(F===null)throw Error("ipaddr: string is not formatted like an IPv4 Address");return new this(F)},B.IPv4.parseCIDR=function(z){let F;if(F=z.match(/^(.+)\/(\d+)$/)){let A=parseInt(F[2]);if(A>=0&&A<=32){let N=[this.parse(F[1]),A];return Object.defineProperty(N,"toString",{value:function(){return this.join("/")}}),N}}throw Error("ipaddr: string is not formatted like an IPv4 CIDR range")},B.IPv4.parser=function(z){let F,A,N;if(F=z.match(J.fourOctet))return function(){let q=F.slice(1,6),w=[];for(let j=0;j<q.length;j++)A=q[j],w.push(U(A));return w}();else if(F=z.match(J.longValue)){if(N=U(F[1]),N>4294967295||N<0)throw Error("ipaddr: address outside defined range");return function(){let q=[],w;for(w=0;w<=24;w+=8)q.push(N>>w&255);return q}().reverse()}else if(F=z.match(J.twoOctet))return function(){let q=F.slice(1,4),w=[];if(N=U(q[1]),N>16777215||N<0)throw Error("ipaddr: address outside defined range");return w.push(U(q[0])),w.push(N>>16&255),w.push(N>>8&255),w.push(N&255),w}();else if(F=z.match(J.threeOctet))return function(){let q=F.slice(1,5),w=[];if(N=U(q[2]),N>65535||N<0)throw Error("ipaddr: address outside defined range");return w.push(U(q[0])),w.push(U(q[1])),w.push(N>>8&255),w.push(N&255),w}();else return null},B.IPv4.subnetMaskFromPrefixLength=function(z){if(z=parseInt(z),z<0||z>32)throw Error("ipaddr: invalid IPv4 prefix length");let F=[0,0,0,0],A=0,N=Math.floor(z/8);while(A<N)F[A]=255,A++;if(N<4)F[N]=Math.pow(2,z%8)-1<<8-z%8;return new this(F)},B.IPv6=function(){function z(F,A){let N,q;if(F.length===16){this.parts=[];for(N=0;N<=14;N+=2)this.parts.push(F[N]<<8|F[N+1])}else if(F.length===8)this.parts=F;else throw Error("ipaddr: ipv6 part count should be 8 or 16");for(N=0;N<this.parts.length;N++)if(q=this.parts[N],!(0<=q&&q<=65535))throw Error("ipaddr: ipv6 part should fit in 16 bits");if(A)this.zoneId=A}return z.prototype.SpecialRanges={unspecified:[new z([0,0,0,0,0,0,0,0]),128],linkLocal:[new z([65152,0,0,0,0,0,0,0]),10],multicast:[new z([65280,0,0,0,0,0,0,0]),8],loopback:[new z([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new z([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new z([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new z([65216,0,0,0,0,0,0,0]),10],discard:[new z([256,0,0,0,0,0,0,0]),64],rfc6145:[new z([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new z([100,65435,0,0,0,0,0,0]),96],[new z([100,65435,1,0,0,0,0,0]),48]],"6to4":[new z([8194,0,0,0,0,0,0,0]),16],teredo:[new z([8193,0,0,0,0,0,0,0]),32],benchmarking:[new z([8193,2,0,0,0,0,0,0]),48],amt:[new z([8193,3,0,0,0,0,0,0]),32],as112v6:[[new z([8193,4,274,0,0,0,0,0]),48],[new z([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new z([8193,16,0,0,0,0,0,0]),28],orchid2:[new z([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new z([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new z([24320,0,0,0,0,0,0,0]),16],reserved:[[new z([8193,0,0,0,0,0,0,0]),23],[new z([8193,3512,0,0,0,0,0,0]),32],[new z([16383,0,0,0,0,0,0,0]),20]]},z.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},z.prototype.kind=function(){return"ipv6"},z.prototype.match=function(F,A){let N;if(A===void 0)N=F,F=N[0],A=N[1];if(F.kind()!=="ipv6")throw Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return V(this.parts,F.parts,16,A)},z.prototype.prefixLengthFromSubnetMask=function(){let F=0,A=!1,N={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},q,w;for(let j=7;j>=0;j-=1)if(q=this.parts[j],q in N){if(w=N[q],A&&w!==0)return null;if(w!==16)A=!0;F+=w}else return null;return 128-F},z.prototype.range=function(){return B.subnetMatch(this,this.SpecialRanges)},z.prototype.toByteArray=function(){let F,A=[],N=this.parts;for(let q=0;q<N.length;q++)F=N[q],A.push(F>>8),A.push(F&255);return A},z.prototype.toFixedLengthString=function(){let F=function(){let N=[];for(let q=0;q<this.parts.length;q++)N.push(H(this.parts[q].toString(16),4));return N}.call(this).join(":"),A="";if(this.zoneId)A=`%${this.zoneId}`;return F+A},z.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let F=this.parts.slice(-2),A=F[0],N=F[1];return new B.IPv4([A>>8,A&255,N>>8,N&255])},z.prototype.toNormalizedString=function(){let F=function(){let N=[];for(let q=0;q<this.parts.length;q++)N.push(this.parts[q].toString(16));return N}.call(this).join(":"),A="";if(this.zoneId)A=`%${this.zoneId}`;return F+A},z.prototype.toRFC5952String=function(){let F=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString(),N=0,q=-1,w;while(w=F.exec(A))if(w[0].length>q)N=w.index,q=w[0].length;if(q<0)return A;return`${A.substring(0,N)}::${A.substring(N+q)}`},z.prototype.toString=function(){return this.toRFC5952String()},z}(),B.IPv6.broadcastAddressFromCIDR=function(z){try{let F=this.parseCIDR(z),A=F[0].toByteArray(),N=this.subnetMaskFromPrefixLength(F[1]).toByteArray(),q=[],w=0;while(w<16)q.push(parseInt(A[w],10)|parseInt(N[w],10)^255),w++;return new this(q)}catch(F){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${F})`)}},B.IPv6.isIPv6=function(z){return this.parser(z)!==null},B.IPv6.isValid=function(z){if(typeof z==="string"&&z.indexOf(":")===-1)return!1;try{let F=this.parser(z);return new this(F.parts,F.zoneId),!0}catch(F){return!1}},B.IPv6.isValidCIDR=function(z){if(typeof z==="string"&&z.indexOf(":")===-1)return!1;try{return this.parseCIDR(z),!0}catch(F){return!1}},B.IPv6.networkAddressFromCIDR=function(z){let F,A,N,q,w;try{F=this.parseCIDR(z),N=F[0].toByteArray(),w=this.subnetMaskFromPrefixLength(F[1]).toByteArray(),q=[],A=0;while(A<16)q.push(parseInt(N[A],10)&parseInt(w[A],10)),A++;return new this(q)}catch(j){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${j})`)}},B.IPv6.parse=function(z){let F=this.parser(z);if(F.parts===null)throw Error("ipaddr: string is not formatted like an IPv6 Address");return new this(F.parts,F.zoneId)},B.IPv6.parseCIDR=function(z){let F,A,N;if(A=z.match(/^(.+)\/(\d+)$/)){if(F=parseInt(A[2]),F>=0&&F<=128)return N=[this.parse(A[1]),F],Object.defineProperty(N,"toString",{value:function(){return this.join("/")}}),N}throw Error("ipaddr: string is not formatted like an IPv6 CIDR range")},B.IPv6.parser=function(z){let F,A,N,q,w,j;if(N=z.match(W.deprecatedTransitional))return this.parser(`::ffff:${N[1]}`);if(W.native.test(z))return K(z,8);if(N=z.match(W.transitional)){if(j=N[6]||"",F=N[1],!N[1].endsWith("::"))F=F.slice(0,-1);if(F=K(F+j,6),F.parts){w=[parseInt(N[2]),parseInt(N[3]),parseInt(N[4]),parseInt(N[5])];for(A=0;A<w.length;A++)if(q=w[A],!(0<=q&&q<=255))return null;return F.parts.push(w[0]<<8|w[1]),F.parts.push(w[2]<<8|w[3]),{parts:F.parts,zoneId:F.zoneId}}}return null},B.IPv6.subnetMaskFromPrefixLength=function(z){if(z=parseInt(z),z<0||z>128)throw Error("ipaddr: invalid IPv6 prefix length");let F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],A=0,N=Math.floor(z/8);while(A<N)F[A]=255,A++;if(N<16)F[N]=Math.pow(2,z%8)-1<<8-z%8;return new this(F)},B.fromByteArray=function(z){let F=z.length;if(F===4)return new B.IPv4(z);else if(F===16)return new B.IPv6(z);else throw Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},B.isValid=function(z){return B.IPv6.isValid(z)||B.IPv4.isValid(z)},B.isValidCIDR=function(z){return B.IPv6.isValidCIDR(z)||B.IPv4.isValidCIDR(z)},B.parse=function(z){if(B.IPv6.isValid(z))return B.IPv6.parse(z);else if(B.IPv4.isValid(z))return B.IPv4.parse(z);else throw Error("ipaddr: the address has neither IPv6 nor IPv4 format")},B.parseCIDR=function(z){try{return B.IPv6.parseCIDR(z)}catch(F){try{return B.IPv4.parseCIDR(z)}catch(A){throw Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},B.process=function(z){let F=this.parse(z);if(F.kind()==="ipv6"&&F.isIPv4MappedAddress())return F.toIPv4Address();else return F},B.subnetMatch=function(z,F,A){let N,q,w,j;if(A===void 0||A===null)A="unicast";for(q in F)if(Object.prototype.hasOwnProperty.call(F,q)){if(w=F[q],w[0]&&!(w[0]instanceof Array))w=[w];for(N=0;N<w.length;N++)if(j=w[N],z.kind()===j[0].kind()&&z.match.apply(z,j))return q}return A},typeof wG<"u"&&wG.exports)wG.exports=B;else $.ipaddr=B})(ME)});var PE=S((_k0,SJ)=>{/*!
|
|
107
|
+
* proxy-addr
|
|
108
|
+
* Copyright(c) 2021 Fastify collaborators
|
|
109
|
+
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
|
110
|
+
* MIT Licensed
|
|
111
|
+
*/SJ.exports=Xz;SJ.exports.default=Xz;SJ.exports.proxyaddr=Xz;SJ.exports.all=TE;SJ.exports.compile=RE;var mJ0=qE(),LE=DE(),lJ0=/^\d+$/u,LG=LE.isValid,TG=LE.parse,wE={linklocal:["169.254.0.0/16","fe80::/10"],loopback:["127.0.0.1/8","::1/128"],uniquelocal:["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","fc00::/7"]};function TE($,Z){let J=mJ0($);if(!Z)return J;if(typeof Z!=="function")Z=RE(Z);for(let Y=0;Y<J.length-1;Y++){if(Z(J[Y],Y))continue;J.length=Y+1}return J}function RE($){if(!$)throw TypeError("argument is required");let Z;if(typeof $==="string")Z=[$];else if(Array.isArray($))Z=$.slice();else throw TypeError("unsupported trust argument");for(let J=0;J<Z.length;J++){if($=Z[J],!Object.hasOwn(wE,$))continue;$=wE[$],Z.splice.apply(Z,[J,1].concat($)),J+=$.length-1}return pJ0(dJ0(Z))}function dJ0($){let Z=Array($.length);for(let J=0;J<$.length;J++)Z[J]=cJ0($[J]);return Z}function pJ0($){let Z=$.length;return Z===0?nJ0:Z===1?sJ0($[0]):oJ0($)}function cJ0($){let Z=$.lastIndexOf("/"),J=Z!==-1?$.substring(0,Z):$;if(!LG(J))throw TypeError("invalid IP address: "+J);let Y=TG(J);if(Z===-1&&Y.kind()==="ipv6"&&Y.isIPv4MappedAddress())Y=Y.toIPv4Address();let X=Y.kind()==="ipv6"?128:32,Q=Z!==-1?$.substring(Z+1,$.length):null;if(Q===null)Q=X;else if(lJ0.test(Q))Q=parseInt(Q,10);else if(Y.kind()==="ipv4"&&LG(Q))Q=iJ0(Q);else Q=null;if(Q<=0||Q>X)throw TypeError("invalid range on address: "+$);return[Y,Q]}function iJ0($){let Z=TG($);return Z.kind()==="ipv4"?Z.prefixLengthFromSubnetMask():null}function Xz($,Z){if(!$)throw TypeError("req argument is required");if(!Z)throw TypeError("trust argument is required");let J=TE($,Z);return J[J.length-1]}function nJ0(){return!1}function oJ0($){return function(J){if(!LG(J))return!1;let Y=TG(J),X,Q=Y.kind();for(let G=0;G<$.length;G++){let W=$[G],K=W[0],V=K.kind(),U=W[1],H=Y;if(Q!==V){let B=V==="ipv4";if(B&&!Y.isIPv4MappedAddress())continue;if(!X)X=B?Y.toIPv4Address():Y.toIPv4MappedAddress();H=X}if(H.match(K,U))return!0}return!1}}function sJ0($){let Z=$[0],J=Z.kind(),Y=J==="ipv4",X=$[1];return function(G){if(!LG(G))return!1;let W=TG(G);if(W.kind()!==J){if(Y&&!W.isIPv4MappedAddress())return!1;W=Y?W.toIPv4Address():W.toIPv4MappedAddress()}return W.match(Z,X)}}});var PG=S((Sk0,Kz)=>{var RG=PE(),{kHasBeenDecorated:rJ0,kSchemaBody:aJ0,kSchemaHeaders:tJ0,kSchemaParams:eJ0,kSchemaQuerystring:CE,kSchemaController:Qz,kOptions:$Y0,kRequestCacheValidateFns:cZ,kRouteContext:p$,kRequestOriginalUrl:Gz,kRequestSignal:IE,kOnAbort:ZY0}=B$(),{FST_ERR_REQ_INVALID_VALIDATION_INVOCATION:JY0,FST_ERR_DEC_UNDECLARED:YY0}=T$(),EE=mX(),bE={body:aJ0,headers:tJ0,params:eJ0,querystring:CE,query:CE};function Wz($,Z,J,Y,X,Q){this.id=$,this[p$]=Q,this.params=Z,this.raw=J,this.query=Y,this.log=X,this.body=void 0}Wz.props=[];function XY0($){if(typeof $==="function")return $;if($===!0)return function(){return!0};if(typeof $==="number")return function(Z,J){return J<$};if(typeof $==="string"){let Z=$.split(",").map((J)=>J.trim());return RG.compile(Z)}return RG.compile($)}function QY0($,Z){if(Z)return GY0($,Z);return fE($)}function fE($){let Z=$.props.slice();function J(Y,X,Q,G,W,K){this.id=Y,this[p$]=K,this.params=X,this.raw=Q,this.query=G,this.log=W,this.body=void 0;let V;for(let U=0;U<Z.length;U++)V=Z[U],this[V.key]=V.value}return Object.setPrototypeOf(J.prototype,$.prototype),Object.setPrototypeOf(J,$),J.props=Z,J.parent=$,J}function _E($){let Z=$.lastIndexOf(",");return Z===-1?$.trim():$.slice(Z+1).trim()}function GY0($,Z){let J=fE($),Y=XY0(Z);return J[rJ0]=!0,Object.defineProperties(J.prototype,{ip:{get(){let X=RG.all(this.raw,Y);return X[X.length-1]}},ips:{get(){return RG.all(this.raw,Y)}},host:{get(){let X=this.raw.socket?.remoteAddress;if(this.headers["x-forwarded-host"]&&X!==null&&Y(X,0))return _E(this.headers["x-forwarded-host"]);return this.headers.host??this.headers[":authority"]??""}},protocol:{get(){let X=this.raw.socket?.remoteAddress;if(this.headers["x-forwarded-proto"]&&X!==null&&Y(X,0))return _E(this.headers["x-forwarded-proto"]);if(this.socket)return this.socket.encrypted?"https":"http"}}}),J}function SE($,Z){if(!EE.hasKey($,Z)&&!EE.exist($,Z))throw new YY0(Z,"request")}Object.defineProperties(Wz.prototype,{server:{get(){return this[p$].server}},url:{get(){return this.raw.url}},originalUrl:{get(){if(!this[Gz])this[Gz]=this.raw.originalUrl||this.raw.url;return this[Gz]}},method:{get(){return this.raw.method}},routeOptions:{get(){let $=this[p$],Z=$._parserOptions.limit,J=$.server.initialConfig.bodyLimit,Y=$.server.hasConstraintStrategy("version")?this.raw.headers["accept-version"]:void 0;return{method:$.config?.method,url:$.config?.url,bodyLimit:Z||J,handlerTimeout:$.handlerTimeout,attachValidation:$.attachValidation,logLevel:$.logLevel,exposeHeadRoute:$.exposeHeadRoute,prefixTrailingSlash:$.prefixTrailingSlash,handler:$.handler,config:$.config,schema:$.schema,version:Y}}},is404:{get(){return this[p$].config?.url===void 0}},socket:{get(){return this.raw.socket}},signal:{get(){let $=this[IE];if($)return $.signal;$=new AbortController,this[IE]=$;let Z=()=>{if(!$.signal.aborted)$.abort()};return this.raw.on("close",Z),this[ZY0]=Z,$.signal}},ip:{get(){if(this.socket)return this.socket.remoteAddress}},host:{get(){return this.raw.headers.host??this.raw.headers[":authority"]??""}},hostname:{get(){if(this.host[0]==="[")return this.host.slice(0,this.host.indexOf("]")+1);return this.host.split(":",1)[0]}},port:{get(){let $=/(?<port>:\d+)$/,Z=this.headers.host??this.headers[":authority"]??"",J=$.exec(Z);if(J===null||J[1]===void 0)return null;return parseInt(J.groups.port.slice(1),10)}},protocol:{get(){if(this.socket)return this.socket.encrypted?"https":"http"}},headers:{get(){if(this.additionalHeaders)return Object.assign({},this.raw.headers,this.additionalHeaders);return this.raw.headers},set($){this.additionalHeaders=$}},getValidationFunction:{value:function($){if(typeof $==="string"){let Z=bE[$];return this[p$][Z]}else if(typeof $==="object")return this[p$][cZ]?.get($)}},compileValidationSchema:{value:function($,Z=null){let{method:J,url:Y}=this;if(this[p$][cZ]?.has($))return this[p$][cZ].get($);let Q=(this[p$].validatorCompiler||this.server[Qz].validatorCompiler||(this.server[Qz].setupValidator(this.server[$Y0])||this.server[Qz].validatorCompiler))({schema:$,method:J,url:Y,httpPart:Z});if(this[p$][cZ]==null)this[p$][cZ]=new WeakMap;return this[p$][cZ].set($,Q),Q}},validateInput:{value:function($,Z,J){J=typeof Z==="string"?Z:J;let Y=J!=null&&typeof J==="string"&&bE[J],X;if(Y)X=this[p$][Y];if(X==null&&(Z==null||typeof Z!=="object"||Array.isArray(Z)))throw new JY0(J);if(X==null)if(this[p$][cZ]?.has(Z))X=this[p$][cZ].get(Z);else X=this.compileValidationSchema(Z,J);return X($)}},getDecorator:{value:function($){SE(this,$);let Z=this[$];if(typeof Z==="function")return Z.bind(this);return Z}},setDecorator:{value:function($,Z){SE(this,$),this[$]=Z}}});Kz.exports=Wz;Kz.exports.buildRequest=QY0});var CG=S((fk0,kE)=>{var{kFourOhFourContext:WY0,kReplySerializerDefault:KY0,kSchemaErrorFormatter:VY0,kErrorHandler:UY0,kChildLoggerFactory:HY0,kOptions:BY0,kReply:zY0,kRequest:FY0,kBodyLimit:AY0,kLogLevel:OY0,kContentTypeParser:jY0,kRouteByFastify:NY0,kRequestCacheValidateFns:qY0,kReplyCacheSerializeFns:MY0,kHandlerTimeout:DY0}=B$();function wY0({schema:$,handler:Z,config:J,requestIdLogLabel:Y,childLoggerFactory:X,errorHandler:Q,bodyLimit:G,logLevel:W,logSerializers:K,attachValidation:V,validatorCompiler:U,serializerCompiler:H,replySerializer:B,schemaErrorFormatter:z,exposeHeadRoute:F,prefixTrailingSlash:A,server:N,isFastify:q,handlerTimeout:w}){this.schema=$,this.handler=Z,this.Reply=N[zY0],this.Request=N[FY0],this.contentTypeParser=N[jY0],this.onRequest=null,this.onSend=null,this.onError=null,this.onTimeout=null,this.preHandler=null,this.onResponse=null,this.preSerialization=null,this.onRequestAbort=null,this.config=J,this.errorHandler=Q||N[UY0],this.requestIdLogLabel=Y||N[BY0].requestIdLogLabel,this.childLoggerFactory=X||N[HY0],this._middie=null,this._parserOptions={limit:G||N[AY0]},this.exposeHeadRoute=F,this.prefixTrailingSlash=A,this.logLevel=W||N[OY0],this.logSerializers=K,this[WY0]=null,this.attachValidation=V,this[KY0]=B,this.schemaErrorFormatter=z||N[VY0]||LY0,this[NY0]=q,this[qY0]=null,this[MY0]=null,this.validatorCompiler=U||null,this.serializerCompiler=H||null,this.handlerTimeout=w||N[DY0]||0,this.server=N}function LY0($,Z){let J="",Y=", ";for(let X=0;X!==$.length;++X){let Q=$[X];J+=Z+(Q.instancePath||"")+" "+Q.message+Y}return Error(J.slice(0,-Y.length))}kE.exports=wY0});var Bz=S((TY0)=>{class yE{constructor($=1000,Z=0){if(isNaN($)||$<0)throw Error("Invalid max value");if(isNaN(Z)||Z<0)throw Error("Invalid ttl value");this.first=null,this.items=new Map,this.last=null,this.max=$,this.ttl=Z}get size(){return this.items.size}clear(){this.items=new Map,this.first=null,this.last=null}delete($){if(this.items.has($)){let Z=this.items.get($);if(this.items.delete($),Z.prev!==null)Z.prev.next=Z.next;if(Z.next!==null)Z.next.prev=Z.prev;if(this.first===Z)this.first=Z.next;if(this.last===Z)this.last=Z.prev}}deleteMany($){for(var Z=0;Z<$.length;Z++)this.delete($[Z])}evict(){if(this.size>0){let $=this.first;if(this.items.delete($.key),this.size===0)this.first=null,this.last=null;else this.first=$.next,this.first.prev=null}}expiresAt($){if(this.items.has($))return this.items.get($).expiry}get($){if(this.items.has($)){let Z=this.items.get($);if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($);return}return Z.value}}getMany($){let Z=[];for(var J=0;J<$.length;J++)Z.push(this.get($[J]));return Z}keys(){return this.items.keys()}set($,Z){if(this.items.has($)){let Y=this.items.get($);Y.value=Z,Y.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl;return}if(this.max>0&&this.size===this.max)this.evict();let J={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:$,prev:this.last,next:null,value:Z};if(this.items.set($,J),this.size===1)this.first=J;else this.last.next=J;this.last=J}}class Vz{constructor($=1000,Z=0){if(isNaN($)||$<0)throw Error("Invalid max value");if(isNaN(Z)||Z<0)throw Error("Invalid ttl value");this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this.max=$,this.ttl=Z}clear(){this.items=Object.create(null),this.first=null,this.last=null,this.size=0}delete($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(delete this.items[$],this.size--,Z.prev!==null)Z.prev.next=Z.next;if(Z.next!==null)Z.next.prev=Z.prev;if(this.first===Z)this.first=Z.next;if(this.last===Z)this.last=Z.prev}}deleteMany($){for(var Z=0;Z<$.length;Z++)this.delete($[Z])}evict(){if(this.size>0){let $=this.first;if(delete this.items[$.key],--this.size===0)this.first=null,this.last=null;else this.first=$.next,this.first.prev=null}}expiresAt($){if(Object.prototype.hasOwnProperty.call(this.items,$))return this.items[$].expiry}get($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($);return}return Z.value}}getMany($){let Z=[];for(var J=0;J<$.length;J++)Z.push(this.get($[J]));return Z}keys(){return Object.keys(this.items)}set($,Z){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Y=this.items[$];Y.value=Z,Y.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl;return}if(this.max>0&&this.size===this.max)this.evict();let J={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:$,prev:this.last,next:null,value:Z};if(this.items[$]=J,++this.size===1)this.first=J;else this.last.next=J;this.last=J}}class Uz{constructor(){this.records={}}initForCache($,Z){this.records[$]={[Z]:{cacheSize:0,hits:0,falsyHits:0,emptyHits:0,misses:0,expirations:0,evictions:0,invalidateOne:0,invalidateAll:0,sets:0}}}resetForCache($){for(let Z of Object.keys(this.records[$]))this.records[$][Z]={cacheSize:0,hits:0,falsyHits:0,emptyHits:0,misses:0,expirations:0,evictions:0,invalidateOne:0,invalidateAll:0,sets:0}}getStatistics(){return this.records}}class xE{constructor($=1000,Z=0){if(isNaN($)||$<0)throw Error("Invalid max value");if(isNaN(Z)||Z<0)throw Error("Invalid ttl value");this.first=null,this.items=new Map,this.last=null,this.max=$,this.ttl=Z}get size(){return this.items.size}bumpLru($){if(this.last===$)return;let Z=this.last,J=$.next,Y=$.prev;if(this.first===$)this.first=J;if($.next=null,$.prev=Z,Z.next=$,Y!==null)Y.next=J;if(J!==null)J.prev=Y;this.last=$}clear(){this.items=new Map,this.first=null,this.last=null}delete($){if(this.items.has($)){let Z=this.items.get($);if(this.items.delete($),Z.prev!==null)Z.prev.next=Z.next;if(Z.next!==null)Z.next.prev=Z.prev;if(this.first===Z)this.first=Z.next;if(this.last===Z)this.last=Z.prev}}deleteMany($){for(var Z=0;Z<$.length;Z++)this.delete($[Z])}evict(){if(this.size>0){let $=this.first;if(this.items.delete($.key),this.size===0)this.first=null,this.last=null;else this.first=$.next,this.first.prev=null}}expiresAt($){if(this.items.has($))return this.items.get($).expiry}get($){if(this.items.has($)){let Z=this.items.get($);if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($);return}return this.bumpLru(Z),Z.value}}getMany($){let Z=[];for(var J=0;J<$.length;J++)Z.push(this.get($[J]));return Z}keys(){return this.items.keys()}set($,Z){if(this.items.has($)){let Y=this.items.get($);if(Y.value=Z,Y.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl,this.last!==Y)this.bumpLru(Y);return}if(this.max>0&&this.size===this.max)this.evict();let J={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:$,prev:this.last,next:null,value:Z};if(this.items.set($,J),this.size===1)this.first=J;else this.last.next=J;this.last=J}}class IG{constructor($=1000,Z=0){if(isNaN($)||$<0)throw Error("Invalid max value");if(isNaN(Z)||Z<0)throw Error("Invalid ttl value");this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this.max=$,this.ttl=Z}bumpLru($){if(this.last===$)return;let Z=this.last,J=$.next,Y=$.prev;if(this.first===$)this.first=J;if($.next=null,$.prev=Z,Z.next=$,Y!==null)Y.next=J;if(J!==null)J.prev=Y;this.last=$}clear(){this.items=Object.create(null),this.first=null,this.last=null,this.size=0}delete($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(delete this.items[$],this.size--,Z.prev!==null)Z.prev.next=Z.next;if(Z.next!==null)Z.next.prev=Z.prev;if(this.first===Z)this.first=Z.next;if(this.last===Z)this.last=Z.prev}}deleteMany($){for(var Z=0;Z<$.length;Z++)this.delete($[Z])}evict(){if(this.size>0){let $=this.first;if(delete this.items[$.key],--this.size===0)this.first=null,this.last=null;else this.first=$.next,this.first.prev=null}}expiresAt($){if(Object.prototype.hasOwnProperty.call(this.items,$))return this.items[$].expiry}get($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($);return}return this.bumpLru(Z),Z.value}}getMany($){let Z=[];for(var J=0;J<$.length;J++)Z.push(this.get($[J]));return Z}keys(){return Object.keys(this.items)}set($,Z){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Y=this.items[$];if(Y.value=Z,Y.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl,this.last!==Y)this.bumpLru(Y);return}if(this.max>0&&this.size===this.max)this.evict();let J={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:$,prev:this.last,next:null,value:Z};if(this.items[$]=J,++this.size===1)this.first=J;else this.last.next=J;this.last=J}}function vE($){return`${$.getFullYear()}-${($.getMonth()+1).toString().padStart(2,"0")}-${$.getDate().toString().padStart(2,"0")}`}class hE{constructor($,Z,J){this.cacheId=$,this.statisticTtlInHours=Z,this.collectionStart=new Date,this.currentTimeStamp=vE(this.collectionStart),this.records=J||new Uz,this.records.initForCache(this.cacheId,this.currentTimeStamp)}get currentRecord(){if(!this.records.records[this.cacheId][this.currentTimeStamp])this.records.records[this.cacheId][this.currentTimeStamp]={cacheSize:0,hits:0,falsyHits:0,emptyHits:0,misses:0,expirations:0,evictions:0,sets:0,invalidateOne:0,invalidateAll:0};return this.records.records[this.cacheId][this.currentTimeStamp]}hoursPassed(){return(Date.now()-this.collectionStart)/1000/60/60}addHit(){this.archiveIfNeeded(),this.currentRecord.hits++}addFalsyHit(){this.archiveIfNeeded(),this.currentRecord.falsyHits++}addEmptyHit(){this.archiveIfNeeded(),this.currentRecord.emptyHits++}addMiss(){this.archiveIfNeeded(),this.currentRecord.misses++}addEviction(){this.archiveIfNeeded(),this.currentRecord.evictions++}setCacheSize($){this.archiveIfNeeded(),this.currentRecord.cacheSize=$}addExpiration(){this.archiveIfNeeded(),this.currentRecord.expirations++}addSet(){this.archiveIfNeeded(),this.currentRecord.sets++}addInvalidateOne(){this.archiveIfNeeded(),this.currentRecord.invalidateOne++}addInvalidateAll(){this.archiveIfNeeded(),this.currentRecord.invalidateAll++}getStatistics(){return this.records.getStatistics()}archiveIfNeeded(){if(this.hoursPassed()>=this.statisticTtlInHours)this.collectionStart=new Date,this.currentTimeStamp=vE(this.collectionStart),this.records.initForCache(this.cacheId,this.currentTimeStamp)}}class Hz extends IG{constructor($,Z,J,Y,X){super($||1000,Z||0);if(!J)throw Error("Cache id is mandatory");this.hitStatistics=new hE(J,X!==void 0?X:24,Y)}getStatistics(){return this.hitStatistics.getStatistics()}set($,Z){super.set($,Z),this.hitStatistics.addSet(),this.hitStatistics.setCacheSize(this.size)}evict(){super.evict(),this.hitStatistics.addEviction(),this.hitStatistics.setCacheSize(this.size)}delete($,Z=!1){if(super.delete($),!Z)this.hitStatistics.addInvalidateOne();this.hitStatistics.setCacheSize(this.size)}clear(){super.clear(),this.hitStatistics.addInvalidateAll(),this.hitStatistics.setCacheSize(this.size)}get($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($,!0),this.hitStatistics.addExpiration();return}if(this.bumpLru(Z),!Z.value)this.hitStatistics.addFalsyHit();if(Z.value===void 0||Z.value===null||Z.value==="")this.hitStatistics.addEmptyHit();return this.hitStatistics.addHit(),Z.value}this.hitStatistics.addMiss()}}TY0.Fifo=Vz;TY0.FifoMap=yE;TY0.FifoObject=Vz;TY0.HitStatisticsRecord=Uz;TY0.Lru=IG;TY0.LruHitStatistics=Hz;TY0.LruMap=xE;TY0.LruObject=IG;TY0.LruObjectHitStatistics=Hz});var dE=S((vk0,fJ)=>{var kY0=typeof Buffer<"u",gE=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,uE=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function mE($,Z,J){if(J==null){if(Z!==null&&typeof Z==="object")J=Z,Z=void 0}if(kY0&&Buffer.isBuffer($))$=$.toString();if($&&$.charCodeAt(0)===65279)$=$.slice(1);let Y=JSON.parse($,Z);if(Y===null||typeof Y!=="object")return Y;let X=J&&J.protoAction||"error",Q=J&&J.constructorAction||"error";if(X==="ignore"&&Q==="ignore")return Y;if(X!=="ignore"&&Q!=="ignore"){if(gE.test($)===!1&&uE.test($)===!1)return Y}else if(X!=="ignore"&&Q==="ignore"){if(gE.test($)===!1)return Y}else if(uE.test($)===!1)return Y;return lE(Y,{protoAction:X,constructorAction:Q,safe:J&&J.safe})}function lE($,{protoAction:Z="error",constructorAction:J="error",safe:Y}={}){let X=[$];while(X.length){let Q=X;X=[];for(let G of Q){if(Z!=="ignore"&&Object.prototype.hasOwnProperty.call(G,"__proto__")){if(Y===!0)return null;else if(Z==="error")throw SyntaxError("Object contains forbidden prototype property");delete G.__proto__}if(J!=="ignore"&&Object.prototype.hasOwnProperty.call(G,"constructor")&&G.constructor!==null&&typeof G.constructor==="object"&&Object.prototype.hasOwnProperty.call(G.constructor,"prototype")){if(Y===!0)return null;else if(J==="error")throw SyntaxError("Object contains forbidden prototype property");delete G.constructor}for(let W in G){let K=G[W];if(K&&typeof K==="object")X.push(K)}}}return $}function zz($,Z,J){let{stackTraceLimit:Y}=Error;Error.stackTraceLimit=0;try{return mE($,Z,J)}finally{Error.stackTraceLimit=Y}}function vY0($,Z){let{stackTraceLimit:J}=Error;Error.stackTraceLimit=0;try{return mE($,Z,{safe:!0})}catch{return}finally{Error.stackTraceLimit=J}}fJ.exports=zz;fJ.exports.default=zz;fJ.exports.parse=zz;fJ.exports.safeParse=vY0;fJ.exports.scan=lE});var Nz=S((yk0,iX)=>{var{AsyncResource:yY0}=J0("async_hooks"),{FifoMap:iE}=Bz(),{parse:xY0}=dE(),cX=lH(),{kDefaultJsonParse:pX,kContentTypeParser:kJ,kBodyLimit:hY0,kRequestPayloadStream:nE,kState:Az,kTestInternals:gY0,kReplyIsError:pE,kRouteContext:uY0}=B$(),{FST_ERR_CTP_INVALID_TYPE:EG,FST_ERR_CTP_EMPTY_TYPE:mY0,FST_ERR_CTP_ALREADY_PRESENT:lY0,FST_ERR_CTP_INVALID_HANDLER:dY0,FST_ERR_CTP_INVALID_PARSE_TYPE:pY0,FST_ERR_CTP_BODY_TOO_LARGE:cE,FST_ERR_CTP_INVALID_MEDIA_TYPE:cY0,FST_ERR_CTP_INVALID_CONTENT_LENGTH:iY0,FST_ERR_CTP_EMPTY_JSON_BODY:nY0,FST_ERR_CTP_INSTANCE_ALREADY_STARTED:Oz,FST_ERR_CTP_INVALID_JSON_BODY:oY0}=T$(),{FSTSEC001:sY0}=wJ();function $Z($,Z,J){this[pX]=sE(Z,J),this.customParsers=new Map,this.customParsers.set("application/json",new Fz(!0,!1,$,this[pX])),this.customParsers.set("text/plain",new Fz(!0,!1,$,jz)),this.parserList=["application/json","text/plain"],this.parserRegExpList=[],this.cache=new iE(100)}$Z.prototype.add=function($,Z,J){let Y=typeof $==="string";if(Y){if($=$.trim().toLowerCase(),$.length===0)throw new mY0}else if(!($ instanceof RegExp))throw new EG;if(typeof J!=="function")throw new dY0;if(this.existingParser($))throw new lY0($);if(Z.parseAs!==void 0){if(Z.parseAs!=="string"&&Z.parseAs!=="buffer")throw new pY0(Z.parseAs)}let X=new Fz(Z.parseAs==="string",Z.parseAs==="buffer",Z.bodyLimit,J);if($==="*")this.customParsers.set("",X);else if(Y){let Q=new cX($);if(Q.isValid===!1)throw new EG;let G=Q.toString();this.parserList.unshift(G),this.customParsers.set(G,X)}else ZX0($),this.parserRegExpList.unshift($),this.customParsers.set($.toString(),X)};$Z.prototype.hasParser=function($){if(typeof $==="string")$=new cX($).toString();else{if(!($ instanceof RegExp))throw new EG;$=$.toString()}return this.customParsers.has($)};$Z.prototype.existingParser=function($){if(typeof $==="string"){let Z=new cX($).toString();if($==="application/json"&&this.customParsers.has($))return this.customParsers.get(Z).fn!==this[pX];if($==="text/plain"&&this.customParsers.has($))return this.customParsers.get(Z).fn!==jz}return this.hasParser($)};$Z.prototype.getParser=function($){if(typeof $==="string")$=new cX($);let Z=$.toString(),J=this.cache.get(Z);if(J!==void 0)return J;if(J=this.customParsers.get(Z),J!==void 0)return this.cache.set(Z,J),J;if(J=this.customParsers.get($.mediaType),J!==void 0)return J;for(let Y=0;Y!==this.parserRegExpList.length;++Y){let X=this.parserRegExpList[Y];if(X.test(Z))return J=this.customParsers.get(X.toString()),this.cache.set(Z,J),J}return this.customParsers.get("")};$Z.prototype.removeAll=function(){this.customParsers=new Map,this.parserRegExpList=[],this.parserList=[],this.cache=new iE(100)};$Z.prototype.remove=function($){let Z;if(typeof $==="string")$=new cX($).toString(),Z=this.parserList;else{if(!($ instanceof RegExp))throw new EG;$=$.toString(),Z=this.parserRegExpList}let J=this.customParsers.delete($),Y=Z.findIndex((X)=>X.toString()===$);if(Y>-1)Z.splice(Y,1);return J||Y>-1};$Z.prototype.run=function($,Z,J,Y){let X=this.getParser($);if(X===void 0){if(J.is404===!0){Z(J,Y);return}Y[pE]=!0,Y.send(new cY0);return}let Q=new yY0("content-type-parser:run",J),G=Q.bind(K);if(X.asString===!0||X.asBuffer===!0){oE(J,Y,Y[uY0]._parserOptions,X,G);return}let W=X.fn(J,J[nE],G);if(W&&typeof W.then==="function")W.then((V)=>{G(null,V)},G);function K(V,U){if(Q.emitDestroy(),V!=null){Y.header("connection","close"),Y[pE]=!0,Y.send(V);return}J.body=U,Z(J,Y)}};function oE($,Z,J,Y,X){let Q=Y.asString===!0,G=J.limit===null?Y.bodyLimit:J.limit,W=Number($.headers["content-length"]);if(W>G){X(new cE,void 0);return}let K=0,V=Q?"":[],U=$[nE]||$.raw;if(Q)U.setEncoding("utf8");U.on("data",H),U.on("end",B),U.on("error",B),U.resume();function H(z){K+=Q?Buffer.byteLength(z):z.length;let{receivedEncodedLength:F=0}=U;if(K>G||F>G){U.removeListener("data",H),U.removeListener("end",B),U.removeListener("error",B),X(new cE,void 0);return}if(Q)V+=z;else V.push(z)}function B(z){if(U.removeListener("data",H),U.removeListener("end",B),U.removeListener("error",B),z!=null){if(!(typeof z.statusCode==="number"&&z.statusCode>=400))z.statusCode=400;X(z,void 0);return}if(!Number.isNaN(W)&&(U.receivedEncodedLength||K)!==W){X(new iY0,void 0);return}if(!Q)V=Buffer.concat(V);let F=Y.fn($,V,X);if(F&&typeof F.then==="function")F.then((A)=>{X(null,A)},X)}}function sE($,Z){let J={protoAction:$,constructorAction:Z};return Y;function Y(X,Q,G){if(Q.length===0){G(new nY0,void 0);return}try{G(null,xY0(Q,J))}catch{G(new oY0,void 0)}}}function jz($,Z,J){J(null,Z)}function Fz($,Z,J,Y){this.asString=$,this.asBuffer=Z,this.bodyLimit=J,this.fn=Y}function rY0($){let Z=new $Z;return Z[pX]=$[pX],Z.customParsers=new Map($.customParsers.entries()),Z.parserList=$.parserList.slice(),Z.parserRegExpList=$.parserRegExpList.slice(),Z}function aY0($,Z,J){if(this[Az].started)throw new Oz("addContentTypeParser");if(typeof Z==="function")J=Z,Z={};if(!Z)Z={};if(!Z.bodyLimit)Z.bodyLimit=this[hY0];if(Array.isArray($))$.forEach((Y)=>this[kJ].add(Y,Z,J));else this[kJ].add($,Z,J);return this}function tY0($){return this[kJ].hasParser($)}function eY0($){if(this[Az].started)throw new Oz("removeContentTypeParser");if(Array.isArray($))for(let Z of $)this[kJ].remove(Z);else this[kJ].remove($)}function $X0(){if(this[Az].started)throw new Oz("removeAllContentTypeParsers");this[kJ].removeAll()}function ZX0($){if($.source[0]!=="^"&&$.source.includes(";?")===!1)sY0($.source)}iX.exports=$Z;iX.exports.helpers={buildContentTypeParser:rY0,addContentTypeParser:aY0,hasContentTypeParser:tY0,removeContentTypeParser:eY0,removeAllContentTypeParsers:$X0};iX.exports.defaultParsers={getDefaultJsonParser:sE,defaultTextParser:jz};iX.exports[gY0]={rawBody:oE}});var yJ=S((tE)=>{Object.defineProperty(tE,"__esModule",{value:!0});tE.regexpCode=tE.getEsmExportName=tE.getProperty=tE.safeStringify=tE.stringify=tE.strConcat=tE.addCodeArg=tE.str=tE._=tE.nil=tE._Code=tE.Name=tE.IDENTIFIER=tE._CodeOrName=void 0;class bG{}tE._CodeOrName=bG;tE.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class vJ extends bG{constructor($){super();if(!tE.IDENTIFIER.test($))throw Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}tE.Name=vJ;class Z6 extends bG{constructor($){super();this._items=typeof $==="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((Z,J)=>`${Z}${J}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((Z,J)=>{if(J instanceof vJ)Z[J.str]=(Z[J.str]||0)+1;return Z},{})}}tE._Code=Z6;tE.nil=new Z6("");function rE($,...Z){let J=[$[0]],Y=0;while(Y<Z.length)Mz(J,Z[Y]),J.push($[++Y]);return new Z6(J)}tE._=rE;var qz=new Z6("+");function aE($,...Z){let J=[nX($[0])],Y=0;while(Y<Z.length)J.push(qz),Mz(J,Z[Y]),J.push(qz,nX($[++Y]));return JX0(J),new Z6(J)}tE.str=aE;function Mz($,Z){if(Z instanceof Z6)$.push(...Z._items);else if(Z instanceof vJ)$.push(Z);else $.push(QX0(Z))}tE.addCodeArg=Mz;function JX0($){let Z=1;while(Z<$.length-1){if($[Z]===qz){let J=YX0($[Z-1],$[Z+1]);if(J!==void 0){$.splice(Z-1,3,J);continue}$[Z++]="+"}Z++}}function YX0($,Z){if(Z==='""')return $;if($==='""')return Z;if(typeof $=="string"){if(Z instanceof vJ||$[$.length-1]!=='"')return;if(typeof Z!="string")return`${$.slice(0,-1)}${Z}"`;if(Z[0]==='"')return $.slice(0,-1)+Z.slice(1);return}if(typeof Z=="string"&&Z[0]==='"'&&!($ instanceof vJ))return`"${$}${Z.slice(1)}`;return}function XX0($,Z){return Z.emptyStr()?$:$.emptyStr()?Z:aE`${$}${Z}`}tE.strConcat=XX0;function QX0($){return typeof $=="number"||typeof $=="boolean"||$===null?$:nX(Array.isArray($)?$.join(","):$)}function GX0($){return new Z6(nX($))}tE.stringify=GX0;function nX($){return JSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}tE.safeStringify=nX;function WX0($){return typeof $=="string"&&tE.IDENTIFIER.test($)?new Z6(`.${$}`):rE`[${$}]`}tE.getProperty=WX0;function KX0($){if(typeof $=="string"&&tE.IDENTIFIER.test($))return new Z6(`${$}`);throw Error(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}tE.getEsmExportName=KX0;function VX0($){return new Z6($.toString())}tE.regexpCode=VX0});var fG=S((Jb)=>{Object.defineProperty(Jb,"__esModule",{value:!0});Jb.ValueScope=Jb.ValueScopeName=Jb.Scope=Jb.varKinds=Jb.UsedValueState=void 0;var V8=yJ();class $b extends Error{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}var SG;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(SG||(Jb.UsedValueState=SG={}));Jb.varKinds={const:new V8.Name("const"),let:new V8.Name("let"),var:new V8.Name("var")};class wz{constructor({prefixes:$,parent:Z}={}){this._names={},this._prefixes=$,this._parent=Z}toName($){return $ instanceof V8.Name?$:this.name($)}name($){return new V8.Name(this._newName($))}_newName($){let Z=this._names[$]||this._nameGroup($);return`${$}${Z.index++}`}_nameGroup($){var Z,J;if(((J=(Z=this._parent)===null||Z===void 0?void 0:Z._prefixes)===null||J===void 0?void 0:J.has($))||this._prefixes&&!this._prefixes.has($))throw Error(`CodeGen: prefix "${$}" is not allowed in this scope`);return this._names[$]={prefix:$,index:0}}}Jb.Scope=wz;class Lz extends V8.Name{constructor($,Z){super(Z);this.prefix=$}setValue($,{property:Z,itemIndex:J}){this.value=$,this.scopePath=V8._`.${new V8.Name(Z)}[${J}]`}}Jb.ValueScopeName=Lz;var wX0=V8._`\n`;class Zb extends wz{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?wX0:V8.nil}}get(){return this._scope}name($){return new Lz($,this._newName($))}value($,Z){var J;if(Z.ref===void 0)throw Error("CodeGen: ref must be passed in value");let Y=this.toName($),{prefix:X}=Y,Q=(J=Z.key)!==null&&J!==void 0?J:Z.ref,G=this._values[X];if(G){let V=G.get(Q);if(V)return V}else G=this._values[X]=new Map;G.set(Q,Y);let W=this._scope[X]||(this._scope[X]=[]),K=W.length;return W[K]=Z.ref,Y.setValue(Z,{property:X,itemIndex:K}),Y}getValue($,Z){let J=this._values[$];if(!J)return;return J.get(Z)}scopeRefs($,Z=this._values){return this._reduceValues(Z,(J)=>{if(J.scopePath===void 0)throw Error(`CodeGen: name "${J}" has no value`);return V8._`${$}${J.scopePath}`})}scopeCode($=this._values,Z,J){return this._reduceValues($,(Y)=>{if(Y.value===void 0)throw Error(`CodeGen: name "${Y}" has no value`);return Y.value.code},Z,J)}_reduceValues($,Z,J={},Y){let X=V8.nil;for(let Q in $){let G=$[Q];if(!G)continue;let W=J[Q]=J[Q]||new Map;G.forEach((K)=>{if(W.has(K))return;W.set(K,SG.Started);let V=Z(K);if(V){let U=this.opts.es5?Jb.varKinds.var:Jb.varKinds.const;X=V8._`${X}${U} ${K} = ${V};${this.opts._n}`}else if(V=Y===null||Y===void 0?void 0:Y(K))X=V8._`${X}${V}${this.opts._n}`;else throw new $b(K);W.set(K,SG.Completed)})}return X}}Jb.ValueScope=Zb});var k0=S((U8)=>{Object.defineProperty(U8,"__esModule",{value:!0});U8.or=U8.and=U8.not=U8.CodeGen=U8.operators=U8.varKinds=U8.ValueScopeName=U8.ValueScope=U8.Scope=U8.Name=U8.regexpCode=U8.stringify=U8.getProperty=U8.nil=U8.strConcat=U8.str=U8._=void 0;var j1=yJ(),J6=fG(),iZ=yJ();Object.defineProperty(U8,"_",{enumerable:!0,get:function(){return iZ._}});Object.defineProperty(U8,"str",{enumerable:!0,get:function(){return iZ.str}});Object.defineProperty(U8,"strConcat",{enumerable:!0,get:function(){return iZ.strConcat}});Object.defineProperty(U8,"nil",{enumerable:!0,get:function(){return iZ.nil}});Object.defineProperty(U8,"getProperty",{enumerable:!0,get:function(){return iZ.getProperty}});Object.defineProperty(U8,"stringify",{enumerable:!0,get:function(){return iZ.stringify}});Object.defineProperty(U8,"regexpCode",{enumerable:!0,get:function(){return iZ.regexpCode}});Object.defineProperty(U8,"Name",{enumerable:!0,get:function(){return iZ.Name}});var gG=fG();Object.defineProperty(U8,"Scope",{enumerable:!0,get:function(){return gG.Scope}});Object.defineProperty(U8,"ValueScope",{enumerable:!0,get:function(){return gG.ValueScope}});Object.defineProperty(U8,"ValueScopeName",{enumerable:!0,get:function(){return gG.ValueScopeName}});Object.defineProperty(U8,"varKinds",{enumerable:!0,get:function(){return gG.varKinds}});U8.operators={GT:new j1._Code(">"),GTE:new j1._Code(">="),LT:new j1._Code("<"),LTE:new j1._Code("<="),EQ:new j1._Code("==="),NEQ:new j1._Code("!=="),NOT:new j1._Code("!"),OR:new j1._Code("||"),AND:new j1._Code("&&"),ADD:new j1._Code("+")};class nZ{optimizeNodes(){return this}optimizeNames($,Z){return this}}class Xb extends nZ{constructor($,Z,J){super();this.varKind=$,this.name=Z,this.rhs=J}render({es5:$,_n:Z}){let J=$?J6.varKinds.var:this.varKind,Y=this.rhs===void 0?"":` = ${this.rhs}`;return`${J} ${this.name}${Y};`+Z}optimizeNames($,Z){if(!$[this.name.str])return;if(this.rhs)this.rhs=hJ(this.rhs,$,Z);return this}get names(){return this.rhs instanceof j1._CodeOrName?this.rhs.names:{}}}class Pz extends nZ{constructor($,Z,J){super();this.lhs=$,this.rhs=Z,this.sideEffects=J}render({_n:$}){return`${this.lhs} = ${this.rhs};`+$}optimizeNames($,Z){if(this.lhs instanceof j1.Name&&!$[this.lhs.str]&&!this.sideEffects)return;return this.rhs=hJ(this.rhs,$,Z),this}get names(){let $=this.lhs instanceof j1.Name?{}:{...this.lhs.names};return hG($,this.rhs)}}class Qb extends Pz{constructor($,Z,J,Y){super($,J,Y);this.op=Z}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class Gb extends nZ{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class Wb extends nZ{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class Kb extends nZ{constructor($){super();this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class Vb extends nZ{constructor($){super();this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,Z){return this.code=hJ(this.code,$,Z),this}get names(){return this.code instanceof j1._CodeOrName?this.code.names:{}}}class uG extends nZ{constructor($=[]){super();this.nodes=$}render($){return this.nodes.reduce((Z,J)=>Z+J.render($),"")}optimizeNodes(){let{nodes:$}=this,Z=$.length;while(Z--){let J=$[Z].optimizeNodes();if(Array.isArray(J))$.splice(Z,1,...J);else if(J)$[Z]=J;else $.splice(Z,1)}return $.length>0?this:void 0}optimizeNames($,Z){let{nodes:J}=this,Y=J.length;while(Y--){let X=J[Y];if(X.optimizeNames($,Z))continue;PX0($,X.names),J.splice(Y,1)}return J.length>0?this:void 0}get names(){return this.nodes.reduce(($,Z)=>e5($,Z.names),{})}}class oZ extends uG{render($){return"{"+$._n+super.render($)+"}"+$._n}}class Ub extends uG{}class oX extends oZ{}oX.kind="else";class ZZ extends oZ{constructor($,Z){super(Z);this.condition=$}render($){let Z=`if(${this.condition})`+super.render($);if(this.else)Z+="else "+this.else.render($);return Z}optimizeNodes(){super.optimizeNodes();let $=this.condition;if($===!0)return this.nodes;let Z=this.else;if(Z){let J=Z.optimizeNodes();Z=this.else=Array.isArray(J)?new oX(J):J}if(Z){if($===!1)return Z instanceof ZZ?Z:Z.nodes;if(this.nodes.length)return this;return new ZZ(Ab($),Z instanceof ZZ?[Z]:Z.nodes)}if($===!1||!this.nodes.length)return;return this}optimizeNames($,Z){var J;if(this.else=(J=this.else)===null||J===void 0?void 0:J.optimizeNames($,Z),!(super.optimizeNames($,Z)||this.else))return;return this.condition=hJ(this.condition,$,Z),this}get names(){let $=super.names;if(hG($,this.condition),this.else)e5($,this.else.names);return $}}ZZ.kind="if";class xJ extends oZ{}xJ.kind="for";class Hb extends xJ{constructor($){super();this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,Z){if(!super.optimizeNames($,Z))return;return this.iteration=hJ(this.iteration,$,Z),this}get names(){return e5(super.names,this.iteration.names)}}class Bb extends xJ{constructor($,Z,J,Y){super();this.varKind=$,this.name=Z,this.from=J,this.to=Y}render($){let Z=$.es5?J6.varKinds.var:this.varKind,{name:J,from:Y,to:X}=this;return`for(${Z} ${J}=${Y}; ${J}<${X}; ${J}++)`+super.render($)}get names(){let $=hG(super.names,this.from);return hG($,this.to)}}class Tz extends xJ{constructor($,Z,J,Y){super();this.loop=$,this.varKind=Z,this.name=J,this.iterable=Y}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,Z){if(!super.optimizeNames($,Z))return;return this.iterable=hJ(this.iterable,$,Z),this}get names(){return e5(super.names,this.iterable.names)}}class kG extends oZ{constructor($,Z,J){super();this.name=$,this.args=Z,this.async=J}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}kG.kind="func";class vG extends uG{render($){return"return "+super.render($)}}vG.kind="return";class zb extends oZ{render($){let Z="try"+super.render($);if(this.catch)Z+=this.catch.render($);if(this.finally)Z+=this.finally.render($);return Z}optimizeNodes(){var $,Z;return super.optimizeNodes(),($=this.catch)===null||$===void 0||$.optimizeNodes(),(Z=this.finally)===null||Z===void 0||Z.optimizeNodes(),this}optimizeNames($,Z){var J,Y;return super.optimizeNames($,Z),(J=this.catch)===null||J===void 0||J.optimizeNames($,Z),(Y=this.finally)===null||Y===void 0||Y.optimizeNames($,Z),this}get names(){let $=super.names;if(this.catch)e5($,this.catch.names);if(this.finally)e5($,this.finally.names);return $}}class yG extends oZ{constructor($){super();this.error=$}render($){return`catch(${this.error})`+super.render($)}}yG.kind="catch";class xG extends oZ{render($){return"finally"+super.render($)}}xG.kind="finally";class Fb{constructor($,Z={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...Z,_n:Z.lines?`
|
|
112
|
+
`:""},this._extScope=$,this._scope=new J6.Scope({parent:$}),this._nodes=[new Ub]}toString(){return this._root.render(this.opts)}name($){return this._scope.name($)}scopeName($){return this._extScope.name($)}scopeValue($,Z){let J=this._extScope.value($,Z);return(this._values[J.prefix]||(this._values[J.prefix]=new Set)).add(J),J}getScopeValue($,Z){return this._extScope.getValue($,Z)}scopeRefs($){return this._extScope.scopeRefs($,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def($,Z,J,Y){let X=this._scope.toName(Z);if(J!==void 0&&Y)this._constants[X.str]=J;return this._leafNode(new Xb($,X,J)),X}const($,Z,J){return this._def(J6.varKinds.const,$,Z,J)}let($,Z,J){return this._def(J6.varKinds.let,$,Z,J)}var($,Z,J){return this._def(J6.varKinds.var,$,Z,J)}assign($,Z,J){return this._leafNode(new Pz($,Z,J))}add($,Z){return this._leafNode(new Qb($,U8.operators.ADD,Z))}code($){if(typeof $=="function")$();else if($!==j1.nil)this._leafNode(new Vb($));return this}object(...$){let Z=["{"];for(let[J,Y]of $){if(Z.length>1)Z.push(",");if(Z.push(J),J!==Y||this.opts.es5)Z.push(":"),(0,j1.addCodeArg)(Z,Y)}return Z.push("}"),new j1._Code(Z)}if($,Z,J){if(this._blockNode(new ZZ($)),Z&&J)this.code(Z).else().code(J).endIf();else if(Z)this.code(Z).endIf();else if(J)throw Error('CodeGen: "else" body without "then" body');return this}elseIf($){return this._elseNode(new ZZ($))}else(){return this._elseNode(new oX)}endIf(){return this._endBlockNode(ZZ,oX)}_for($,Z){if(this._blockNode($),Z)this.code(Z).endFor();return this}for($,Z){return this._for(new Hb($),Z)}forRange($,Z,J,Y,X=this.opts.es5?J6.varKinds.var:J6.varKinds.let){let Q=this._scope.toName($);return this._for(new Bb(X,Q,Z,J),()=>Y(Q))}forOf($,Z,J,Y=J6.varKinds.const){let X=this._scope.toName($);if(this.opts.es5){let Q=Z instanceof j1.Name?Z:this.var("_arr",Z);return this.forRange("_i",0,j1._`${Q}.length`,(G)=>{this.var(X,j1._`${Q}[${G}]`),J(X)})}return this._for(new Tz("of",Y,X,Z),()=>J(X))}forIn($,Z,J,Y=this.opts.es5?J6.varKinds.var:J6.varKinds.const){if(this.opts.ownProperties)return this.forOf($,j1._`Object.keys(${Z})`,J);let X=this._scope.toName($);return this._for(new Tz("in",Y,X,Z),()=>J(X))}endFor(){return this._endBlockNode(xJ)}label($){return this._leafNode(new Gb($))}break($){return this._leafNode(new Wb($))}return($){let Z=new vG;if(this._blockNode(Z),this.code($),Z.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(vG)}try($,Z,J){if(!Z&&!J)throw Error('CodeGen: "try" without "catch" and "finally"');let Y=new zb;if(this._blockNode(Y),this.code($),Z){let X=this.name("e");this._currNode=Y.catch=new yG(X),Z(X)}if(J)this._currNode=Y.finally=new xG,this.code(J);return this._endBlockNode(yG,xG)}throw($){return this._leafNode(new Kb($))}block($,Z){if(this._blockStarts.push(this._nodes.length),$)this.code($).endBlock(Z);return this}endBlock($){let Z=this._blockStarts.pop();if(Z===void 0)throw Error("CodeGen: not in self-balancing block");let J=this._nodes.length-Z;if(J<0||$!==void 0&&J!==$)throw Error(`CodeGen: wrong number of nodes: ${J} vs ${$} expected`);return this._nodes.length=Z,this}func($,Z=j1.nil,J,Y){if(this._blockNode(new kG($,Z,J)),Y)this.code(Y).endFunc();return this}endFunc(){return this._endBlockNode(kG)}optimize($=1){while($-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode($){return this._currNode.nodes.push($),this}_blockNode($){this._currNode.nodes.push($),this._nodes.push($)}_endBlockNode($,Z){let J=this._currNode;if(J instanceof $||Z&&J instanceof Z)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${Z?`${$.kind}/${Z.kind}`:$.kind}"`)}_elseNode($){let Z=this._currNode;if(!(Z instanceof ZZ))throw Error('CodeGen: "else" without "if"');return this._currNode=Z.else=$,this}get _root(){return this._nodes[0]}get _currNode(){let $=this._nodes;return $[$.length-1]}set _currNode($){let Z=this._nodes;Z[Z.length-1]=$}}U8.CodeGen=Fb;function e5($,Z){for(let J in Z)$[J]=($[J]||0)+(Z[J]||0);return $}function hG($,Z){return Z instanceof j1._CodeOrName?e5($,Z.names):$}function hJ($,Z,J){if($ instanceof j1.Name)return Y($);if(!X($))return $;return new j1._Code($._items.reduce((Q,G)=>{if(G instanceof j1.Name)G=Y(G);if(G instanceof j1._Code)Q.push(...G._items);else Q.push(G);return Q},[]));function Y(Q){let G=J[Q.str];if(G===void 0||Z[Q.str]!==1)return Q;return delete Z[Q.str],G}function X(Q){return Q instanceof j1._Code&&Q._items.some((G)=>G instanceof j1.Name&&Z[G.str]===1&&J[G.str]!==void 0)}}function PX0($,Z){for(let J in Z)$[J]=($[J]||0)-(Z[J]||0)}function Ab($){return typeof $=="boolean"||typeof $=="number"||$===null?!$:j1._`!${Rz($)}`}U8.not=Ab;var CX0=Ob(U8.operators.AND);function IX0(...$){return $.reduce(CX0)}U8.and=IX0;var EX0=Ob(U8.operators.OR);function bX0(...$){return $.reduce(EX0)}U8.or=bX0;function Ob($){return(Z,J)=>Z===j1.nil?J:J===j1.nil?Z:j1._`${Rz(Z)} ${$} ${Rz(J)}`}function Rz($){return $ instanceof j1.Name?$:j1._`(${$})`}});var J1=S((Rb)=>{Object.defineProperty(Rb,"__esModule",{value:!0});Rb.checkStrictMode=Rb.getErrorPath=Rb.Type=Rb.useFunc=Rb.setEvaluated=Rb.evaluatedPropsToName=Rb.mergeEvaluated=Rb.eachItem=Rb.unescapeJsonPointer=Rb.escapeJsonPointer=Rb.escapeFragment=Rb.unescapeFragment=Rb.schemaRefOrVal=Rb.schemaHasRulesButRef=Rb.schemaHasRules=Rb.checkUnknownRules=Rb.alwaysValidSchema=Rb.toHash=void 0;var x1=k0(),kX0=yJ();function vX0($){let Z={};for(let J of $)Z[J]=!0;return Z}Rb.toHash=vX0;function yX0($,Z){if(typeof Z=="boolean")return Z;if(Object.keys(Z).length===0)return!0;return Mb($,Z),!Db(Z,$.self.RULES.all)}Rb.alwaysValidSchema=yX0;function Mb($,Z=$.schema){let{opts:J,self:Y}=$;if(!J.strictSchema)return;if(typeof Z==="boolean")return;let X=Y.RULES.keywords;for(let Q in Z)if(!X[Q])Tb($,`unknown keyword: "${Q}"`)}Rb.checkUnknownRules=Mb;function Db($,Z){if(typeof $=="boolean")return!$;for(let J in $)if(Z[J])return!0;return!1}Rb.schemaHasRules=Db;function xX0($,Z){if(typeof $=="boolean")return!$;for(let J in $)if(J!=="$ref"&&Z.all[J])return!0;return!1}Rb.schemaHasRulesButRef=xX0;function hX0({topSchemaRef:$,schemaPath:Z},J,Y,X){if(!X){if(typeof J=="number"||typeof J=="boolean")return J;if(typeof J=="string")return x1._`${J}`}return x1._`${$}${Z}${(0,x1.getProperty)(Y)}`}Rb.schemaRefOrVal=hX0;function gX0($){return wb(decodeURIComponent($))}Rb.unescapeFragment=gX0;function uX0($){return encodeURIComponent(Iz($))}Rb.escapeFragment=uX0;function Iz($){if(typeof $=="number")return`${$}`;return $.replace(/~/g,"~0").replace(/\//g,"~1")}Rb.escapeJsonPointer=Iz;function wb($){return $.replace(/~1/g,"/").replace(/~0/g,"~")}Rb.unescapeJsonPointer=wb;function mX0($,Z){if(Array.isArray($))for(let J of $)Z(J);else Z($)}Rb.eachItem=mX0;function Nb({mergeNames:$,mergeToName:Z,mergeValues:J,resultToName:Y}){return(X,Q,G,W)=>{let K=G===void 0?Q:G instanceof x1.Name?(Q instanceof x1.Name?$(X,Q,G):Z(X,Q,G),G):Q instanceof x1.Name?(Z(X,G,Q),Q):J(Q,G);return W===x1.Name&&!(K instanceof x1.Name)?Y(X,K):K}}Rb.mergeEvaluated={props:Nb({mergeNames:($,Z,J)=>$.if(x1._`${J} !== true && ${Z} !== undefined`,()=>{$.if(x1._`${Z} === true`,()=>$.assign(J,!0),()=>$.assign(J,x1._`${J} || {}`).code(x1._`Object.assign(${J}, ${Z})`))}),mergeToName:($,Z,J)=>$.if(x1._`${J} !== true`,()=>{if(Z===!0)$.assign(J,!0);else $.assign(J,x1._`${J} || {}`),Ez($,J,Z)}),mergeValues:($,Z)=>$===!0?!0:{...$,...Z},resultToName:Lb}),items:Nb({mergeNames:($,Z,J)=>$.if(x1._`${J} !== true && ${Z} !== undefined`,()=>$.assign(J,x1._`${Z} === true ? true : ${J} > ${Z} ? ${J} : ${Z}`)),mergeToName:($,Z,J)=>$.if(x1._`${J} !== true`,()=>$.assign(J,Z===!0?!0:x1._`${J} > ${Z} ? ${J} : ${Z}`)),mergeValues:($,Z)=>$===!0?!0:Math.max($,Z),resultToName:($,Z)=>$.var("items",Z)})};function Lb($,Z){if(Z===!0)return $.var("props",!0);let J=$.var("props",x1._`{}`);if(Z!==void 0)Ez($,J,Z);return J}Rb.evaluatedPropsToName=Lb;function Ez($,Z,J){Object.keys(J).forEach((Y)=>$.assign(x1._`${Z}${(0,x1.getProperty)(Y)}`,!0))}Rb.setEvaluated=Ez;var qb={};function lX0($,Z){return $.scopeValue("func",{ref:Z,code:qb[Z.code]||(qb[Z.code]=new kX0._Code(Z.code))})}Rb.useFunc=lX0;var Cz;(function($){$[$.Num=0]="Num",$[$.Str=1]="Str"})(Cz||(Rb.Type=Cz={}));function dX0($,Z,J){if($ instanceof x1.Name){let Y=Z===Cz.Num;return J?Y?x1._`"[" + ${$} + "]"`:x1._`"['" + ${$} + "']"`:Y?x1._`"/" + ${$}`:x1._`"/" + ${$}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return J?(0,x1.getProperty)($).toString():"/"+Iz($)}Rb.getErrorPath=dX0;function Tb($,Z,J=$.opts.strictSchema){if(!J)return;if(Z=`strict mode: ${Z}`,J===!0)throw Error(Z);$.self.logger.warn(Z)}Rb.checkStrictMode=Tb});var g8=S((Cb)=>{Object.defineProperty(Cb,"__esModule",{value:!0});var c$=k0(),W90={data:new c$.Name("data"),valCxt:new c$.Name("valCxt"),instancePath:new c$.Name("instancePath"),parentData:new c$.Name("parentData"),parentDataProperty:new c$.Name("parentDataProperty"),rootData:new c$.Name("rootData"),dynamicAnchors:new c$.Name("dynamicAnchors"),vErrors:new c$.Name("vErrors"),errors:new c$.Name("errors"),this:new c$.Name("this"),self:new c$.Name("self"),scope:new c$.Name("scope"),json:new c$.Name("json"),jsonPos:new c$.Name("jsonPos"),jsonLen:new c$.Name("jsonLen"),jsonPart:new c$.Name("jsonPart")};Cb.default=W90});var sX=S((_b)=>{Object.defineProperty(_b,"__esModule",{value:!0});_b.extendErrors=_b.resetErrorsCount=_b.reportExtraError=_b.reportError=_b.keyword$DataError=_b.keywordError=void 0;var M1=k0(),lG=J1(),t$=g8();_b.keywordError={message:({keyword:$})=>M1.str`must pass "${$}" keyword validation`};_b.keyword$DataError={message:({keyword:$,schemaType:Z})=>Z?M1.str`"${$}" keyword must be ${Z} ($data)`:M1.str`"${$}" keyword is invalid ($data)`};function V90($,Z=_b.keywordError,J,Y){let{it:X}=$,{gen:Q,compositeRule:G,allErrors:W}=X,K=bb($,Z,J);if(Y!==null&&Y!==void 0?Y:G||W)Ib(Q,K);else Eb(X,M1._`[${K}]`)}_b.reportError=V90;function U90($,Z=_b.keywordError,J){let{it:Y}=$,{gen:X,compositeRule:Q,allErrors:G}=Y,W=bb($,Z,J);if(Ib(X,W),!(Q||G))Eb(Y,t$.default.vErrors)}_b.reportExtraError=U90;function H90($,Z){$.assign(t$.default.errors,Z),$.if(M1._`${t$.default.vErrors} !== null`,()=>$.if(Z,()=>$.assign(M1._`${t$.default.vErrors}.length`,Z),()=>$.assign(t$.default.vErrors,null)))}_b.resetErrorsCount=H90;function B90({gen:$,keyword:Z,schemaValue:J,data:Y,errsCount:X,it:Q}){if(X===void 0)throw Error("ajv implementation error");let G=$.name("err");$.forRange("i",X,t$.default.errors,(W)=>{if($.const(G,M1._`${t$.default.vErrors}[${W}]`),$.if(M1._`${G}.instancePath === undefined`,()=>$.assign(M1._`${G}.instancePath`,(0,M1.strConcat)(t$.default.instancePath,Q.errorPath))),$.assign(M1._`${G}.schemaPath`,M1.str`${Q.errSchemaPath}/${Z}`),Q.opts.verbose)$.assign(M1._`${G}.schema`,J),$.assign(M1._`${G}.data`,Y)})}_b.extendErrors=B90;function Ib($,Z){let J=$.const("err",Z);$.if(M1._`${t$.default.vErrors} === null`,()=>$.assign(t$.default.vErrors,M1._`[${J}]`),M1._`${t$.default.vErrors}.push(${J})`),$.code(M1._`${t$.default.errors}++`)}function Eb($,Z){let{gen:J,validateName:Y,schemaEnv:X}=$;if(X.$async)J.throw(M1._`new ${$.ValidationError}(${Z})`);else J.assign(M1._`${Y}.errors`,Z),J.return(!1)}var $7={keyword:new M1.Name("keyword"),schemaPath:new M1.Name("schemaPath"),params:new M1.Name("params"),propertyName:new M1.Name("propertyName"),message:new M1.Name("message"),schema:new M1.Name("schema"),parentSchema:new M1.Name("parentSchema")};function bb($,Z,J){let{createErrors:Y}=$.it;if(Y===!1)return M1._`{}`;return z90($,Z,J)}function z90($,Z,J={}){let{gen:Y,it:X}=$,Q=[F90(X,J),A90($,J)];return O90($,Z,Q),Y.object(...Q)}function F90({errorPath:$},{instancePath:Z}){let J=Z?M1.str`${$}${(0,lG.getErrorPath)(Z,lG.Type.Str)}`:$;return[t$.default.instancePath,(0,M1.strConcat)(t$.default.instancePath,J)]}function A90({keyword:$,it:{errSchemaPath:Z}},{schemaPath:J,parentSchema:Y}){let X=Y?Z:M1.str`${Z}/${$}`;if(J)X=M1.str`${X}${(0,lG.getErrorPath)(J,lG.Type.Str)}`;return[$7.schemaPath,X]}function O90($,{params:Z,message:J},Y){let{keyword:X,data:Q,schemaValue:G,it:W}=$,{opts:K,propertyName:V,topSchemaRef:U,schemaPath:H}=W;if(Y.push([$7.keyword,X],[$7.params,typeof Z=="function"?Z($):Z||M1._`{}`]),K.messages)Y.push([$7.message,typeof J=="function"?J($):J]);if(K.verbose)Y.push([$7.schema,G],[$7.parentSchema,M1._`${U}${H}`],[t$.default.data,Q]);if(V)Y.push([$7.propertyName,V])}});var yb=S((kb)=>{Object.defineProperty(kb,"__esModule",{value:!0});kb.boolOrEmptySchema=kb.topBoolOrEmptySchema=void 0;var D90=sX(),w90=k0(),L90=g8(),T90={message:"boolean schema is false"};function R90($){let{gen:Z,schema:J,validateName:Y}=$;if(J===!1)fb($,!1);else if(typeof J=="object"&&J.$async===!0)Z.return(L90.default.data);else Z.assign(w90._`${Y}.errors`,null),Z.return(!0)}kb.topBoolOrEmptySchema=R90;function P90($,Z){let{gen:J,schema:Y}=$;if(Y===!1)J.var(Z,!1),fb($);else J.var(Z,!0)}kb.boolOrEmptySchema=P90;function fb($,Z){let{gen:J,data:Y}=$,X={gen:J,keyword:"false schema",data:Y,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:$};(0,D90.reportError)(X,T90,void 0,Z)}});var _z=S((xb)=>{Object.defineProperty(xb,"__esModule",{value:!0});xb.getRules=xb.isJSONType=void 0;var I90=["string","number","integer","boolean","null","object","array"],E90=new Set(I90);function b90($){return typeof $=="string"&&E90.has($)}xb.isJSONType=b90;function _90(){let $={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...$,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},$.number,$.string,$.array,$.object],post:{rules:[]},all:{},keywords:{}}}xb.getRules=_90});var Sz=S((mb)=>{Object.defineProperty(mb,"__esModule",{value:!0});mb.shouldUseRule=mb.shouldUseGroup=mb.schemaHasRulesForType=void 0;function f90({schema:$,self:Z},J){let Y=Z.RULES.types[J];return Y&&Y!==!0&&gb($,Y)}mb.schemaHasRulesForType=f90;function gb($,Z){return Z.rules.some((J)=>ub($,J))}mb.shouldUseGroup=gb;function ub($,Z){var J;return $[Z.keyword]!==void 0||((J=Z.definition.implements)===null||J===void 0?void 0:J.some((Y)=>$[Y]!==void 0))}mb.shouldUseRule=ub});var rX=S((ib)=>{Object.defineProperty(ib,"__esModule",{value:!0});ib.reportTypeError=ib.checkDataTypes=ib.checkDataType=ib.coerceAndCheckDataType=ib.getJSONTypes=ib.getSchemaTypes=ib.DataType=void 0;var y90=_z(),x90=Sz(),h90=sX(),Y1=k0(),db=J1(),gJ;(function($){$[$.Correct=0]="Correct",$[$.Wrong=1]="Wrong"})(gJ||(ib.DataType=gJ={}));function g90($){let Z=pb($.type);if(Z.includes("null")){if($.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!Z.length&&$.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if($.nullable===!0)Z.push("null")}return Z}ib.getSchemaTypes=g90;function pb($){let Z=Array.isArray($)?$:$?[$]:[];if(Z.every(y90.isJSONType))return Z;throw Error("type must be JSONType or JSONType[]: "+Z.join(","))}ib.getJSONTypes=pb;function u90($,Z){let{gen:J,data:Y,opts:X}=$,Q=m90(Z,X.coerceTypes),G=Z.length>0&&!(Q.length===0&&Z.length===1&&(0,x90.schemaHasRulesForType)($,Z[0]));if(G){let W=kz(Z,Y,X.strictNumbers,gJ.Wrong);J.if(W,()=>{if(Q.length)l90($,Z,Q);else vz($)})}return G}ib.coerceAndCheckDataType=u90;var cb=new Set(["string","number","integer","boolean","null"]);function m90($,Z){return Z?$.filter((J)=>cb.has(J)||Z==="array"&&J==="array"):[]}function l90($,Z,J){let{gen:Y,data:X,opts:Q}=$,G=Y.let("dataType",Y1._`typeof ${X}`),W=Y.let("coerced",Y1._`undefined`);if(Q.coerceTypes==="array")Y.if(Y1._`${G} == 'object' && Array.isArray(${X}) && ${X}.length == 1`,()=>Y.assign(X,Y1._`${X}[0]`).assign(G,Y1._`typeof ${X}`).if(kz(Z,X,Q.strictNumbers),()=>Y.assign(W,X)));Y.if(Y1._`${W} !== undefined`);for(let V of J)if(cb.has(V)||V==="array"&&Q.coerceTypes==="array")K(V);Y.else(),vz($),Y.endIf(),Y.if(Y1._`${W} !== undefined`,()=>{Y.assign(X,W),d90($,W)});function K(V){switch(V){case"string":Y.elseIf(Y1._`${G} == "number" || ${G} == "boolean"`).assign(W,Y1._`"" + ${X}`).elseIf(Y1._`${X} === null`).assign(W,Y1._`""`);return;case"number":Y.elseIf(Y1._`${G} == "boolean" || ${X} === null
|
|
113
|
+
|| (${G} == "string" && ${X} && ${X} == +${X})`).assign(W,Y1._`+${X}`);return;case"integer":Y.elseIf(Y1._`${G} === "boolean" || ${X} === null
|
|
114
|
+
|| (${G} === "string" && ${X} && ${X} == +${X} && !(${X} % 1))`).assign(W,Y1._`+${X}`);return;case"boolean":Y.elseIf(Y1._`${X} === "false" || ${X} === 0 || ${X} === null`).assign(W,!1).elseIf(Y1._`${X} === "true" || ${X} === 1`).assign(W,!0);return;case"null":Y.elseIf(Y1._`${X} === "" || ${X} === 0 || ${X} === false`),Y.assign(W,null);return;case"array":Y.elseIf(Y1._`${G} === "string" || ${G} === "number"
|
|
115
|
+
|| ${G} === "boolean" || ${X} === null`).assign(W,Y1._`[${X}]`)}}}function d90({gen:$,parentData:Z,parentDataProperty:J},Y){$.if(Y1._`${Z} !== undefined`,()=>$.assign(Y1._`${Z}[${J}]`,Y))}function fz($,Z,J,Y=gJ.Correct){let X=Y===gJ.Correct?Y1.operators.EQ:Y1.operators.NEQ,Q;switch($){case"null":return Y1._`${Z} ${X} null`;case"array":Q=Y1._`Array.isArray(${Z})`;break;case"object":Q=Y1._`${Z} && typeof ${Z} == "object" && !Array.isArray(${Z})`;break;case"integer":Q=G(Y1._`!(${Z} % 1) && !isNaN(${Z})`);break;case"number":Q=G();break;default:return Y1._`typeof ${Z} ${X} ${$}`}return Y===gJ.Correct?Q:(0,Y1.not)(Q);function G(W=Y1.nil){return(0,Y1.and)(Y1._`typeof ${Z} == "number"`,W,J?Y1._`isFinite(${Z})`:Y1.nil)}}ib.checkDataType=fz;function kz($,Z,J,Y){if($.length===1)return fz($[0],Z,J,Y);let X,Q=(0,db.toHash)($);if(Q.array&&Q.object){let G=Y1._`typeof ${Z} != "object"`;X=Q.null?G:Y1._`!${Z} || ${G}`,delete Q.null,delete Q.array,delete Q.object}else X=Y1.nil;if(Q.number)delete Q.integer;for(let G in Q)X=(0,Y1.and)(X,fz(G,Z,J,Y));return X}ib.checkDataTypes=kz;var p90={message:({schema:$})=>`must be ${$}`,params:({schema:$,schemaValue:Z})=>typeof $=="string"?Y1._`{type: ${$}}`:Y1._`{type: ${Z}}`};function vz($){let Z=c90($);(0,h90.reportError)(Z,p90)}ib.reportTypeError=vz;function c90($){let{gen:Z,data:J,schema:Y}=$,X=(0,db.schemaRefOrVal)($,Y,"type");return{gen:Z,keyword:"type",data:J,schema:Y.type,schemaCode:X,schemaValue:X,parentSchema:Y,params:{},it:$}}});var ab=S((sb)=>{Object.defineProperty(sb,"__esModule",{value:!0});sb.assignDefaults=void 0;var uJ=k0(),t90=J1();function e90($,Z){let{properties:J,items:Y}=$.schema;if(Z==="object"&&J)for(let X in J)ob($,X,J[X].default);else if(Z==="array"&&Array.isArray(Y))Y.forEach((X,Q)=>ob($,Q,X.default))}sb.assignDefaults=e90;function ob($,Z,J){let{gen:Y,compositeRule:X,data:Q,opts:G}=$;if(J===void 0)return;let W=uJ._`${Q}${(0,uJ.getProperty)(Z)}`;if(X){(0,t90.checkStrictMode)($,`default is ignored for: ${W}`);return}let K=uJ._`${W} === undefined`;if(G.useDefaults==="empty")K=uJ._`${K} || ${W} === null || ${W} === ""`;Y.if(K,uJ._`${W} = ${(0,uJ.stringify)(J)}`)}});var f$=S(($_)=>{Object.defineProperty($_,"__esModule",{value:!0});$_.validateUnion=$_.validateArray=$_.usePattern=$_.callValidateCode=$_.schemaProperties=$_.allSchemaProperties=$_.noPropertyInData=$_.propertyInData=$_.isOwnProperty=$_.hasPropFunc=$_.reportMissingProp=$_.checkMissingProp=$_.checkReportMissingProp=void 0;var n1=k0(),yz=J1(),sZ=g8(),$Q0=J1();function ZQ0($,Z){let{gen:J,data:Y,it:X}=$;J.if(hz(J,Y,Z,X.opts.ownProperties),()=>{$.setParams({missingProperty:n1._`${Z}`},!0),$.error()})}$_.checkReportMissingProp=ZQ0;function JQ0({gen:$,data:Z,it:{opts:J}},Y,X){return(0,n1.or)(...Y.map((Q)=>(0,n1.and)(hz($,Z,Q,J.ownProperties),n1._`${X} = ${Q}`)))}$_.checkMissingProp=JQ0;function YQ0($,Z){$.setParams({missingProperty:Z},!0),$.error()}$_.reportMissingProp=YQ0;function tb($){return $.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:n1._`Object.prototype.hasOwnProperty`})}$_.hasPropFunc=tb;function xz($,Z,J){return n1._`${tb($)}.call(${Z}, ${J})`}$_.isOwnProperty=xz;function XQ0($,Z,J,Y){let X=n1._`${Z}${(0,n1.getProperty)(J)} !== undefined`;return Y?n1._`${X} && ${xz($,Z,J)}`:X}$_.propertyInData=XQ0;function hz($,Z,J,Y){let X=n1._`${Z}${(0,n1.getProperty)(J)} === undefined`;return Y?(0,n1.or)(X,(0,n1.not)(xz($,Z,J))):X}$_.noPropertyInData=hz;function eb($){return $?Object.keys($).filter((Z)=>Z!=="__proto__"):[]}$_.allSchemaProperties=eb;function QQ0($,Z){return eb(Z).filter((J)=>!(0,yz.alwaysValidSchema)($,Z[J]))}$_.schemaProperties=QQ0;function GQ0({schemaCode:$,data:Z,it:{gen:J,topSchemaRef:Y,schemaPath:X,errorPath:Q},it:G},W,K,V){let U=V?n1._`${$}, ${Z}, ${Y}${X}`:Z,H=[[sZ.default.instancePath,(0,n1.strConcat)(sZ.default.instancePath,Q)],[sZ.default.parentData,G.parentData],[sZ.default.parentDataProperty,G.parentDataProperty],[sZ.default.rootData,sZ.default.rootData]];if(G.opts.dynamicRef)H.push([sZ.default.dynamicAnchors,sZ.default.dynamicAnchors]);let B=n1._`${U}, ${J.object(...H)}`;return K!==n1.nil?n1._`${W}.call(${K}, ${B})`:n1._`${W}(${B})`}$_.callValidateCode=GQ0;var WQ0=n1._`new RegExp`;function KQ0({gen:$,it:{opts:Z}},J){let Y=Z.unicodeRegExp?"u":"",{regExp:X}=Z.code,Q=X(J,Y);return $.scopeValue("pattern",{key:Q.toString(),ref:Q,code:n1._`${X.code==="new RegExp"?WQ0:(0,$Q0.useFunc)($,X)}(${J}, ${Y})`})}$_.usePattern=KQ0;function VQ0($){let{gen:Z,data:J,keyword:Y,it:X}=$,Q=Z.name("valid");if(X.allErrors){let W=Z.let("valid",!0);return G(()=>Z.assign(W,!1)),W}return Z.var(Q,!0),G(()=>Z.break()),Q;function G(W){let K=Z.const("len",n1._`${J}.length`);Z.forRange("i",0,K,(V)=>{$.subschema({keyword:Y,dataProp:V,dataPropType:yz.Type.Num},Q),Z.if((0,n1.not)(Q),W)})}}$_.validateArray=VQ0;function UQ0($){let{gen:Z,schema:J,keyword:Y,it:X}=$;if(!Array.isArray(J))throw Error("ajv implementation error");if(J.some((K)=>(0,yz.alwaysValidSchema)(X,K))&&!X.opts.unevaluated)return;let G=Z.let("valid",!1),W=Z.name("_valid");Z.block(()=>J.forEach((K,V)=>{let U=$.subschema({keyword:Y,schemaProp:V,compositeRule:!0},W);if(Z.assign(G,n1._`${G} || ${W}`),!$.mergeValidEvaluated(U,W))Z.if((0,n1.not)(G))})),$.result(G,()=>$.reset(),()=>$.error(!0))}$_.validateUnion=UQ0});var G_=S((X_)=>{Object.defineProperty(X_,"__esModule",{value:!0});X_.validateKeywordUsage=X_.validSchemaType=X_.funcKeywordCode=X_.macroKeywordCode=void 0;var e$=k0(),Z7=g8(),LQ0=f$(),TQ0=sX();function RQ0($,Z){let{gen:J,keyword:Y,schema:X,parentSchema:Q,it:G}=$,W=Z.macro.call(G.self,X,Q,G),K=Y_(J,Y,W);if(G.opts.validateSchema!==!1)G.self.validateSchema(W,!0);let V=J.name("valid");$.subschema({schema:W,schemaPath:e$.nil,errSchemaPath:`${G.errSchemaPath}/${Y}`,topSchemaRef:K,compositeRule:!0},V),$.pass(V,()=>$.error(!0))}X_.macroKeywordCode=RQ0;function PQ0($,Z){var J;let{gen:Y,keyword:X,schema:Q,parentSchema:G,$data:W,it:K}=$;IQ0(K,Z);let V=!W&&Z.compile?Z.compile.call(K.self,Q,G,K):Z.validate,U=Y_(Y,X,V),H=Y.let("valid");$.block$data(H,B),$.ok((J=Z.valid)!==null&&J!==void 0?J:H);function B(){if(Z.errors===!1){if(A(),Z.modifying)J_($);N(()=>$.error())}else{let q=Z.async?z():F();if(Z.modifying)J_($);N(()=>CQ0($,q))}}function z(){let q=Y.let("ruleErrs",null);return Y.try(()=>A(e$._`await `),(w)=>Y.assign(H,!1).if(e$._`${w} instanceof ${K.ValidationError}`,()=>Y.assign(q,e$._`${w}.errors`),()=>Y.throw(w))),q}function F(){let q=e$._`${U}.errors`;return Y.assign(q,null),A(e$.nil),q}function A(q=Z.async?e$._`await `:e$.nil){let w=K.opts.passContext?Z7.default.this:Z7.default.self,j=!(("compile"in Z)&&!W||Z.schema===!1);Y.assign(H,e$._`${q}${(0,LQ0.callValidateCode)($,U,w,j)}`,Z.modifying)}function N(q){var w;Y.if((0,e$.not)((w=Z.valid)!==null&&w!==void 0?w:H),q)}}X_.funcKeywordCode=PQ0;function J_($){let{gen:Z,data:J,it:Y}=$;Z.if(Y.parentData,()=>Z.assign(J,e$._`${Y.parentData}[${Y.parentDataProperty}]`))}function CQ0($,Z){let{gen:J}=$;J.if(e$._`Array.isArray(${Z})`,()=>{J.assign(Z7.default.vErrors,e$._`${Z7.default.vErrors} === null ? ${Z} : ${Z7.default.vErrors}.concat(${Z})`).assign(Z7.default.errors,e$._`${Z7.default.vErrors}.length`),(0,TQ0.extendErrors)($)},()=>$.error())}function IQ0({schemaEnv:$},Z){if(Z.async&&!$.$async)throw Error("async keyword in sync schema")}function Y_($,Z,J){if(J===void 0)throw Error(`keyword "${Z}" failed to compile`);return $.scopeValue("keyword",typeof J=="function"?{ref:J}:{ref:J,code:(0,e$.stringify)(J)})}function EQ0($,Z,J=!1){return!Z.length||Z.some((Y)=>Y==="array"?Array.isArray($):Y==="object"?$&&typeof $=="object"&&!Array.isArray($):typeof $==Y||J&&typeof $>"u")}X_.validSchemaType=EQ0;function bQ0({schema:$,opts:Z,self:J,errSchemaPath:Y},X,Q){if(Array.isArray(X.keyword)?!X.keyword.includes(Q):X.keyword!==Q)throw Error("ajv implementation error");let G=X.dependencies;if(G===null||G===void 0?void 0:G.some((W)=>!Object.prototype.hasOwnProperty.call($,W)))throw Error(`parent schema must have dependencies of ${Q}: ${G.join(",")}`);if(X.validateSchema){if(!X.validateSchema($[Q])){let K=`keyword "${Q}" value is invalid at path "${Y}": `+J.errorsText(X.validateSchema.errors);if(Z.validateSchema==="log")J.logger.error(K);else throw Error(K)}}}X_.validateKeywordUsage=bQ0});var U_=S((K_)=>{Object.defineProperty(K_,"__esModule",{value:!0});K_.extendSubschemaMode=K_.extendSubschemaData=K_.getSubschema=void 0;var C6=k0(),W_=J1();function kQ0($,{keyword:Z,schemaProp:J,schema:Y,schemaPath:X,errSchemaPath:Q,topSchemaRef:G}){if(Z!==void 0&&Y!==void 0)throw Error('both "keyword" and "schema" passed, only one allowed');if(Z!==void 0){let W=$.schema[Z];return J===void 0?{schema:W,schemaPath:C6._`${$.schemaPath}${(0,C6.getProperty)(Z)}`,errSchemaPath:`${$.errSchemaPath}/${Z}`}:{schema:W[J],schemaPath:C6._`${$.schemaPath}${(0,C6.getProperty)(Z)}${(0,C6.getProperty)(J)}`,errSchemaPath:`${$.errSchemaPath}/${Z}/${(0,W_.escapeFragment)(J)}`}}if(Y!==void 0){if(X===void 0||Q===void 0||G===void 0)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:Y,schemaPath:X,topSchemaRef:G,errSchemaPath:Q}}throw Error('either "keyword" or "schema" must be passed')}K_.getSubschema=kQ0;function vQ0($,Z,{dataProp:J,dataPropType:Y,data:X,dataTypes:Q,propertyName:G}){if(X!==void 0&&J!==void 0)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:W}=Z;if(J!==void 0){let{errorPath:V,dataPathArr:U,opts:H}=Z,B=W.let("data",C6._`${Z.data}${(0,C6.getProperty)(J)}`,!0);K(B),$.errorPath=C6.str`${V}${(0,W_.getErrorPath)(J,Y,H.jsPropertySyntax)}`,$.parentDataProperty=C6._`${J}`,$.dataPathArr=[...U,$.parentDataProperty]}if(X!==void 0){let V=X instanceof C6.Name?X:W.let("data",X,!0);if(K(V),G!==void 0)$.propertyName=G}if(Q)$.dataTypes=Q;function K(V){$.data=V,$.dataLevel=Z.dataLevel+1,$.dataTypes=[],Z.definedProperties=new Set,$.parentData=Z.data,$.dataNames=[...Z.dataNames,V]}}K_.extendSubschemaData=vQ0;function yQ0($,{jtdDiscriminator:Z,jtdMetadata:J,compositeRule:Y,createErrors:X,allErrors:Q}){if(Y!==void 0)$.compositeRule=Y;if(X!==void 0)$.createErrors=X;if(Q!==void 0)$.allErrors=Q;$.jtdDiscriminator=Z,$.jtdMetadata=J}K_.extendSubschemaMode=yQ0});var aX=S((Vv0,H_)=>{H_.exports=function $(Z,J){if(Z===J)return!0;if(Z&&J&&typeof Z=="object"&&typeof J=="object"){if(Z.constructor!==J.constructor)return!1;var Y,X,Q;if(Array.isArray(Z)){if(Y=Z.length,Y!=J.length)return!1;for(X=Y;X--!==0;)if(!$(Z[X],J[X]))return!1;return!0}if(Z.constructor===RegExp)return Z.source===J.source&&Z.flags===J.flags;if(Z.valueOf!==Object.prototype.valueOf)return Z.valueOf()===J.valueOf();if(Z.toString!==Object.prototype.toString)return Z.toString()===J.toString();if(Q=Object.keys(Z),Y=Q.length,Y!==Object.keys(J).length)return!1;for(X=Y;X--!==0;)if(!Object.prototype.hasOwnProperty.call(J,Q[X]))return!1;for(X=Y;X--!==0;){var G=Q[X];if(!$(Z[G],J[G]))return!1}return!0}return Z!==Z&&J!==J}});var z_=S((Uv0,B_)=>{var rZ=B_.exports=function($,Z,J){if(typeof Z=="function")J=Z,Z={};J=Z.cb||J;var Y=typeof J=="function"?J:J.pre||function(){},X=J.post||function(){};dG(Z,Y,X,$,"",$)};rZ.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};rZ.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};rZ.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};rZ.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function dG($,Z,J,Y,X,Q,G,W,K,V){if(Y&&typeof Y=="object"&&!Array.isArray(Y)){Z(Y,X,Q,G,W,K,V);for(var U in Y){var H=Y[U];if(Array.isArray(H)){if(U in rZ.arrayKeywords)for(var B=0;B<H.length;B++)dG($,Z,J,H[B],X+"/"+U+"/"+B,Q,X,U,Y,B)}else if(U in rZ.propsKeywords){if(H&&typeof H=="object")for(var z in H)dG($,Z,J,H[z],X+"/"+U+"/"+gQ0(z),Q,X,U,Y,z)}else if(U in rZ.keywords||$.allKeys&&!(U in rZ.skipKeywords))dG($,Z,J,H,X+"/"+U,Q,X,U,Y)}J(Y,X,Q,G,W,K,V)}}function gQ0($){return $.replace(/~/g,"~0").replace(/\//g,"~1")}});var tX=S((j_)=>{Object.defineProperty(j_,"__esModule",{value:!0});j_.getSchemaRefs=j_.resolveUrl=j_.normalizeId=j_._getFullPath=j_.getFullPath=j_.inlineRef=void 0;var uQ0=J1(),mQ0=aX(),lQ0=z_(),dQ0=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function pQ0($,Z=!0){if(typeof $=="boolean")return!0;if(Z===!0)return!gz($);if(!Z)return!1;return F_($)<=Z}j_.inlineRef=pQ0;var cQ0=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function gz($){for(let Z in $){if(cQ0.has(Z))return!0;let J=$[Z];if(Array.isArray(J)&&J.some(gz))return!0;if(typeof J=="object"&&gz(J))return!0}return!1}function F_($){let Z=0;for(let J in $){if(J==="$ref")return 1/0;if(Z++,dQ0.has(J))continue;if(typeof $[J]=="object")(0,uQ0.eachItem)($[J],(Y)=>Z+=F_(Y));if(Z===1/0)return 1/0}return Z}function A_($,Z="",J){if(J!==!1)Z=mJ(Z);let Y=$.parse(Z);return O_($,Y)}j_.getFullPath=A_;function O_($,Z){return $.serialize(Z).split("#")[0]+"#"}j_._getFullPath=O_;var iQ0=/#\/?$/;function mJ($){return $?$.replace(iQ0,""):""}j_.normalizeId=mJ;function nQ0($,Z,J){return J=mJ(J),$.resolve(Z,J)}j_.resolveUrl=nQ0;var oQ0=/^[a-z_][-a-z0-9._]*$/i;function sQ0($,Z){if(typeof $=="boolean")return{};let{schemaId:J,uriResolver:Y}=this.opts,X=mJ($[J]||Z),Q={"":X},G=A_(Y,X,!1),W={},K=new Set;return lQ0($,{allKeys:!0},(H,B,z,F)=>{if(F===void 0)return;let A=G+B,N=Q[F];if(typeof H[J]=="string")N=q.call(this,H[J]);w.call(this,H.$anchor),w.call(this,H.$dynamicAnchor),Q[B]=N;function q(j){let M=this.opts.uriResolver.resolve;if(j=mJ(N?M(N,j):j),K.has(j))throw U(j);K.add(j);let I=this.refs[j];if(typeof I=="string")I=this.refs[I];if(typeof I=="object")V(H,I.schema,j);else if(j!==mJ(A))if(j[0]==="#")V(H,W[j],j),W[j]=H;else this.refs[j]=A;return j}function w(j){if(typeof j=="string"){if(!oQ0.test(j))throw Error(`invalid anchor "${j}"`);q.call(this,`#${j}`)}}}),W;function V(H,B,z){if(B!==void 0&&!mQ0(H,B))throw U(z)}function U(H){return Error(`reference "${H}" resolves to more than one schema`)}}j_.getSchemaRefs=sQ0});var lJ=S((f_)=>{Object.defineProperty(f_,"__esModule",{value:!0});f_.getData=f_.KeywordCxt=f_.validateFunctionCode=void 0;var L_=yb(),q_=rX(),mz=Sz(),pG=rX(),Z40=ab(),$9=G_(),uz=U_(),L0=k0(),i0=g8(),J40=tX(),JZ=J1(),eX=sX();function Y40($){if(P_($)){if(C_($),R_($)){G40($);return}}T_($,()=>(0,L_.topBoolOrEmptySchema)($))}f_.validateFunctionCode=Y40;function T_({gen:$,validateName:Z,schema:J,schemaEnv:Y,opts:X},Q){if(X.code.es5)$.func(Z,L0._`${i0.default.data}, ${i0.default.valCxt}`,Y.$async,()=>{$.code(L0._`"use strict"; ${M_(J,X)}`),Q40($,X),$.code(Q)});else $.func(Z,L0._`${i0.default.data}, ${X40(X)}`,Y.$async,()=>$.code(M_(J,X)).code(Q))}function X40($){return L0._`{${i0.default.instancePath}="", ${i0.default.parentData}, ${i0.default.parentDataProperty}, ${i0.default.rootData}=${i0.default.data}${$.dynamicRef?L0._`, ${i0.default.dynamicAnchors}={}`:L0.nil}}={}`}function Q40($,Z){$.if(i0.default.valCxt,()=>{if($.var(i0.default.instancePath,L0._`${i0.default.valCxt}.${i0.default.instancePath}`),$.var(i0.default.parentData,L0._`${i0.default.valCxt}.${i0.default.parentData}`),$.var(i0.default.parentDataProperty,L0._`${i0.default.valCxt}.${i0.default.parentDataProperty}`),$.var(i0.default.rootData,L0._`${i0.default.valCxt}.${i0.default.rootData}`),Z.dynamicRef)$.var(i0.default.dynamicAnchors,L0._`${i0.default.valCxt}.${i0.default.dynamicAnchors}`)},()=>{if($.var(i0.default.instancePath,L0._`""`),$.var(i0.default.parentData,L0._`undefined`),$.var(i0.default.parentDataProperty,L0._`undefined`),$.var(i0.default.rootData,i0.default.data),Z.dynamicRef)$.var(i0.default.dynamicAnchors,L0._`{}`)})}function G40($){let{schema:Z,opts:J,gen:Y}=$;T_($,()=>{if(J.$comment&&Z.$comment)E_($);if(H40($),Y.let(i0.default.vErrors,null),Y.let(i0.default.errors,0),J.unevaluated)W40($);I_($),F40($)});return}function W40($){let{gen:Z,validateName:J}=$;$.evaluated=Z.const("evaluated",L0._`${J}.evaluated`),Z.if(L0._`${$.evaluated}.dynamicProps`,()=>Z.assign(L0._`${$.evaluated}.props`,L0._`undefined`)),Z.if(L0._`${$.evaluated}.dynamicItems`,()=>Z.assign(L0._`${$.evaluated}.items`,L0._`undefined`))}function M_($,Z){let J=typeof $=="object"&&$[Z.schemaId];return J&&(Z.code.source||Z.code.process)?L0._`/*# sourceURL=${J} */`:L0.nil}function K40($,Z){if(P_($)){if(C_($),R_($)){V40($,Z);return}}(0,L_.boolOrEmptySchema)($,Z)}function R_({schema:$,self:Z}){if(typeof $=="boolean")return!$;for(let J in $)if(Z.RULES.all[J])return!0;return!1}function P_($){return typeof $.schema!="boolean"}function V40($,Z){let{schema:J,gen:Y,opts:X}=$;if(X.$comment&&J.$comment)E_($);B40($),z40($);let Q=Y.const("_errs",i0.default.errors);I_($,Q),Y.var(Z,L0._`${Q} === ${i0.default.errors}`)}function C_($){(0,JZ.checkUnknownRules)($),U40($)}function I_($,Z){if($.opts.jtd)return D_($,[],!1,Z);let J=(0,q_.getSchemaTypes)($.schema),Y=(0,q_.coerceAndCheckDataType)($,J);D_($,J,!Y,Z)}function U40($){let{schema:Z,errSchemaPath:J,opts:Y,self:X}=$;if(Z.$ref&&Y.ignoreKeywordsWithRef&&(0,JZ.schemaHasRulesButRef)(Z,X.RULES))X.logger.warn(`$ref: keywords ignored in schema at path "${J}"`)}function H40($){let{schema:Z,opts:J}=$;if(Z.default!==void 0&&J.useDefaults&&J.strictSchema)(0,JZ.checkStrictMode)($,"default is ignored in the schema root")}function B40($){let Z=$.schema[$.opts.schemaId];if(Z)$.baseId=(0,J40.resolveUrl)($.opts.uriResolver,$.baseId,Z)}function z40($){if($.schema.$async&&!$.schemaEnv.$async)throw Error("async schema in sync schema")}function E_({gen:$,schemaEnv:Z,schema:J,errSchemaPath:Y,opts:X}){let Q=J.$comment;if(X.$comment===!0)$.code(L0._`${i0.default.self}.logger.log(${Q})`);else if(typeof X.$comment=="function"){let G=L0.str`${Y}/$comment`,W=$.scopeValue("root",{ref:Z.root});$.code(L0._`${i0.default.self}.opts.$comment(${Q}, ${G}, ${W}.schema)`)}}function F40($){let{gen:Z,schemaEnv:J,validateName:Y,ValidationError:X,opts:Q}=$;if(J.$async)Z.if(L0._`${i0.default.errors} === 0`,()=>Z.return(i0.default.data),()=>Z.throw(L0._`new ${X}(${i0.default.vErrors})`));else{if(Z.assign(L0._`${Y}.errors`,i0.default.vErrors),Q.unevaluated)A40($);Z.return(L0._`${i0.default.errors} === 0`)}}function A40({gen:$,evaluated:Z,props:J,items:Y}){if(J instanceof L0.Name)$.assign(L0._`${Z}.props`,J);if(Y instanceof L0.Name)$.assign(L0._`${Z}.items`,Y)}function D_($,Z,J,Y){let{gen:X,schema:Q,data:G,allErrors:W,opts:K,self:V}=$,{RULES:U}=V;if(Q.$ref&&(K.ignoreKeywordsWithRef||!(0,JZ.schemaHasRulesButRef)(Q,U))){X.block(()=>__($,"$ref",U.all.$ref.definition));return}if(!K.jtd)O40($,Z);X.block(()=>{for(let B of U.rules)H(B);H(U.post)});function H(B){if(!(0,mz.shouldUseGroup)(Q,B))return;if(B.type){if(X.if((0,pG.checkDataType)(B.type,G,K.strictNumbers)),w_($,B),Z.length===1&&Z[0]===B.type&&J)X.else(),(0,pG.reportTypeError)($);X.endIf()}else w_($,B);if(!W)X.if(L0._`${i0.default.errors} === ${Y||0}`)}}function w_($,Z){let{gen:J,schema:Y,opts:{useDefaults:X}}=$;if(X)(0,Z40.assignDefaults)($,Z.type);J.block(()=>{for(let Q of Z.rules)if((0,mz.shouldUseRule)(Y,Q))__($,Q.keyword,Q.definition,Z.type)})}function O40($,Z){if($.schemaEnv.meta||!$.opts.strictTypes)return;if(j40($,Z),!$.opts.allowUnionTypes)N40($,Z);q40($,$.dataTypes)}function j40($,Z){if(!Z.length)return;if(!$.dataTypes.length){$.dataTypes=Z;return}Z.forEach((J)=>{if(!b_($.dataTypes,J))lz($,`type "${J}" not allowed by context "${$.dataTypes.join(",")}"`)}),D40($,Z)}function N40($,Z){if(Z.length>1&&!(Z.length===2&&Z.includes("null")))lz($,"use allowUnionTypes to allow union type keyword")}function q40($,Z){let J=$.self.RULES.all;for(let Y in J){let X=J[Y];if(typeof X=="object"&&(0,mz.shouldUseRule)($.schema,X)){let{type:Q}=X.definition;if(Q.length&&!Q.some((G)=>M40(Z,G)))lz($,`missing type "${Q.join(",")}" for keyword "${Y}"`)}}}function M40($,Z){return $.includes(Z)||Z==="number"&&$.includes("integer")}function b_($,Z){return $.includes(Z)||Z==="integer"&&$.includes("number")}function D40($,Z){let J=[];for(let Y of $.dataTypes)if(b_(Z,Y))J.push(Y);else if(Z.includes("integer")&&Y==="number")J.push("integer");$.dataTypes=J}function lz($,Z){let J=$.schemaEnv.baseId+$.errSchemaPath;Z+=` at "${J}" (strictTypes)`,(0,JZ.checkStrictMode)($,Z,$.opts.strictTypes)}class dz{constructor($,Z,J){if((0,$9.validateKeywordUsage)($,Z,J),this.gen=$.gen,this.allErrors=$.allErrors,this.keyword=J,this.data=$.data,this.schema=$.schema[J],this.$data=Z.$data&&$.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,JZ.schemaRefOrVal)($,this.schema,J,this.$data),this.schemaType=Z.schemaType,this.parentSchema=$.schema,this.params={},this.it=$,this.def=Z,this.$data)this.schemaCode=$.gen.const("vSchema",S_(this.$data,$));else if(this.schemaCode=this.schemaValue,!(0,$9.validSchemaType)(this.schema,Z.schemaType,Z.allowUndefined))throw Error(`${J} value must be ${JSON.stringify(Z.schemaType)}`);if("code"in Z?Z.trackErrors:Z.errors!==!1)this.errsCount=$.gen.const("_errs",i0.default.errors)}result($,Z,J){this.failResult((0,L0.not)($),Z,J)}failResult($,Z,J){if(this.gen.if($),J)J();else this.error();if(Z){if(this.gen.else(),Z(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass($,Z){this.failResult((0,L0.not)($),void 0,Z)}fail($){if($===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if($),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data($){if(!this.$data)return this.fail($);let{schemaCode:Z}=this;this.fail(L0._`${Z} !== undefined && (${(0,L0.or)(this.invalid$data(),$)})`)}error($,Z,J){if(Z){this.setParams(Z),this._error($,J),this.setParams({});return}this._error($,J)}_error($,Z){($?eX.reportExtraError:eX.reportError)(this,this.def.error,Z)}$dataError(){(0,eX.reportError)(this,this.def.$dataError||eX.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add "trackErrors" to keyword definition');(0,eX.resetErrorsCount)(this.gen,this.errsCount)}ok($){if(!this.allErrors)this.gen.if($)}setParams($,Z){if(Z)Object.assign(this.params,$);else this.params=$}block$data($,Z,J=L0.nil){this.gen.block(()=>{this.check$data($,J),Z()})}check$data($=L0.nil,Z=L0.nil){if(!this.$data)return;let{gen:J,schemaCode:Y,schemaType:X,def:Q}=this;if(J.if((0,L0.or)(L0._`${Y} === undefined`,Z)),$!==L0.nil)J.assign($,!0);if(X.length||Q.validateSchema){if(J.elseIf(this.invalid$data()),this.$dataError(),$!==L0.nil)J.assign($,!1)}J.else()}invalid$data(){let{gen:$,schemaCode:Z,schemaType:J,def:Y,it:X}=this;return(0,L0.or)(Q(),G());function Q(){if(J.length){if(!(Z instanceof L0.Name))throw Error("ajv implementation error");let W=Array.isArray(J)?J:[J];return L0._`${(0,pG.checkDataTypes)(W,Z,X.opts.strictNumbers,pG.DataType.Wrong)}`}return L0.nil}function G(){if(Y.validateSchema){let W=$.scopeValue("validate$data",{ref:Y.validateSchema});return L0._`!${W}(${Z})`}return L0.nil}}subschema($,Z){let J=(0,uz.getSubschema)(this.it,$);(0,uz.extendSubschemaData)(J,this.it,$),(0,uz.extendSubschemaMode)(J,$);let Y={...this.it,...J,items:void 0,props:void 0};return K40(Y,Z),Y}mergeEvaluated($,Z){let{it:J,gen:Y}=this;if(!J.opts.unevaluated)return;if(J.props!==!0&&$.props!==void 0)J.props=JZ.mergeEvaluated.props(Y,$.props,J.props,Z);if(J.items!==!0&&$.items!==void 0)J.items=JZ.mergeEvaluated.items(Y,$.items,J.items,Z)}mergeValidEvaluated($,Z){let{it:J,gen:Y}=this;if(J.opts.unevaluated&&(J.props!==!0||J.items!==!0))return Y.if(Z,()=>this.mergeEvaluated($,L0.Name)),!0}}f_.KeywordCxt=dz;function __($,Z,J,Y){let X=new dz($,J,Z);if("code"in J)J.code(X,Y);else if(X.$data&&J.validate)(0,$9.funcKeywordCode)(X,J);else if("macro"in J)(0,$9.macroKeywordCode)(X,J);else if(J.compile||J.validate)(0,$9.funcKeywordCode)(X,J)}var w40=/^\/(?:[^~]|~0|~1)*$/,L40=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function S_($,{dataLevel:Z,dataNames:J,dataPathArr:Y}){let X,Q;if($==="")return i0.default.rootData;if($[0]==="/"){if(!w40.test($))throw Error(`Invalid JSON-pointer: ${$}`);X=$,Q=i0.default.rootData}else{let V=L40.exec($);if(!V)throw Error(`Invalid JSON-pointer: ${$}`);let U=+V[1];if(X=V[2],X==="#"){if(U>=Z)throw Error(K("property/index",U));return Y[Z-U]}if(U>Z)throw Error(K("data",U));if(Q=J[Z-U],!X)return Q}let G=Q,W=X.split("/");for(let V of W)if(V)Q=L0._`${Q}${(0,L0.getProperty)((0,JZ.unescapeJsonPointer)(V))}`,G=L0._`${G} && ${Q}`;return G;function K(V,U){return`Cannot access ${V} ${U} levels up, current level is ${Z}`}}f_.getData=S_});var Z9=S((y_)=>{Object.defineProperty(y_,"__esModule",{value:!0});class v_ extends Error{constructor($){super("validation failed");this.errors=$,this.ajv=this.validation=!0}}y_.default=v_});var YZ=S((h_)=>{Object.defineProperty(h_,"__esModule",{value:!0});var pz=tX();class x_ extends Error{constructor($,Z,J,Y){super(Y||`can't resolve reference ${J} from id ${Z}`);this.missingRef=(0,pz.resolveUrl)($,Z,J),this.missingSchema=(0,pz.normalizeId)((0,pz.getFullPath)($,this.missingRef))}}h_.default=x_});var Y7=S((m_)=>{Object.defineProperty(m_,"__esModule",{value:!0});m_.resolveSchema=m_.getCompilingSchema=m_.resolveRef=m_.compileSchema=m_.SchemaEnv=void 0;var Y6=k0(),I40=Z9(),J7=g8(),X6=tX(),g_=J1(),E40=lJ();class J9{constructor($){var Z;this.refs={},this.dynamicAnchors={};let J;if(typeof $.schema=="object")J=$.schema;this.schema=$.schema,this.schemaId=$.schemaId,this.root=$.root||this,this.baseId=(Z=$.baseId)!==null&&Z!==void 0?Z:(0,X6.normalizeId)(J===null||J===void 0?void 0:J[$.schemaId||"$id"]),this.schemaPath=$.schemaPath,this.localRefs=$.localRefs,this.meta=$.meta,this.$async=J===null||J===void 0?void 0:J.$async,this.refs={}}}m_.SchemaEnv=J9;function iz($){let Z=u_.call(this,$);if(Z)return Z;let J=(0,X6.getFullPath)(this.opts.uriResolver,$.root.baseId),{es5:Y,lines:X}=this.opts.code,{ownProperties:Q}=this.opts,G=new Y6.CodeGen(this.scope,{es5:Y,lines:X,ownProperties:Q}),W;if($.$async)W=G.scopeValue("Error",{ref:I40.default,code:Y6._`require("ajv/dist/runtime/validation_error").default`});let K=G.scopeName("validate");$.validateName=K;let V={gen:G,allErrors:this.opts.allErrors,data:J7.default.data,parentData:J7.default.parentData,parentDataProperty:J7.default.parentDataProperty,dataNames:[J7.default.data],dataPathArr:[Y6.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:G.scopeValue("schema",this.opts.code.source===!0?{ref:$.schema,code:(0,Y6.stringify)($.schema)}:{ref:$.schema}),validateName:K,ValidationError:W,schema:$.schema,schemaEnv:$,rootId:J,baseId:$.baseId||J,schemaPath:Y6.nil,errSchemaPath:$.schemaPath||(this.opts.jtd?"":"#"),errorPath:Y6._`""`,opts:this.opts,self:this},U;try{this._compilations.add($),(0,E40.validateFunctionCode)(V),G.optimize(this.opts.code.optimize);let H=G.toString();if(U=`${G.scopeRefs(J7.default.scope)}return ${H}`,this.opts.code.process)U=this.opts.code.process(U,$);let z=Function(`${J7.default.self}`,`${J7.default.scope}`,U)(this,this.scope.get());if(this.scope.value(K,{ref:z}),z.errors=null,z.schema=$.schema,z.schemaEnv=$,$.$async)z.$async=!0;if(this.opts.code.source===!0)z.source={validateName:K,validateCode:H,scopeValues:G._values};if(this.opts.unevaluated){let{props:F,items:A}=V;if(z.evaluated={props:F instanceof Y6.Name?void 0:F,items:A instanceof Y6.Name?void 0:A,dynamicProps:F instanceof Y6.Name,dynamicItems:A instanceof Y6.Name},z.source)z.source.evaluated=(0,Y6.stringify)(z.evaluated)}return $.validate=z,$}catch(H){if(delete $.validate,delete $.validateName,U)this.logger.error("Error compiling schema, function code:",U);throw H}finally{this._compilations.delete($)}}m_.compileSchema=iz;function b40($,Z,J){var Y;J=(0,X6.resolveUrl)(this.opts.uriResolver,Z,J);let X=$.refs[J];if(X)return X;let Q=f40.call(this,$,J);if(Q===void 0){let G=(Y=$.localRefs)===null||Y===void 0?void 0:Y[J],{schemaId:W}=this.opts;if(G)Q=new J9({schema:G,schemaId:W,root:$,baseId:Z})}if(Q===void 0)return;return $.refs[J]=_40.call(this,Q)}m_.resolveRef=b40;function _40($){if((0,X6.inlineRef)($.schema,this.opts.inlineRefs))return $.schema;return $.validate?$:iz.call(this,$)}function u_($){for(let Z of this._compilations)if(S40(Z,$))return Z}m_.getCompilingSchema=u_;function S40($,Z){return $.schema===Z.schema&&$.root===Z.root&&$.baseId===Z.baseId}function f40($,Z){let J;while(typeof(J=this.refs[Z])=="string")Z=J;return J||this.schemas[Z]||cG.call(this,$,Z)}function cG($,Z){let J=this.opts.uriResolver.parse(Z),Y=(0,X6._getFullPath)(this.opts.uriResolver,J),X=(0,X6.getFullPath)(this.opts.uriResolver,$.baseId,void 0);if(Object.keys($.schema).length>0&&Y===X)return cz.call(this,J,$);let Q=(0,X6.normalizeId)(Y),G=this.refs[Q]||this.schemas[Q];if(typeof G=="string"){let W=cG.call(this,$,G);if(typeof(W===null||W===void 0?void 0:W.schema)!=="object")return;return cz.call(this,J,W)}if(typeof(G===null||G===void 0?void 0:G.schema)!=="object")return;if(!G.validate)iz.call(this,G);if(Q===(0,X6.normalizeId)(Z)){let{schema:W}=G,{schemaId:K}=this.opts,V=W[K];if(V)X=(0,X6.resolveUrl)(this.opts.uriResolver,X,V);return new J9({schema:W,schemaId:K,root:$,baseId:X})}return cz.call(this,J,G)}m_.resolveSchema=cG;var k40=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function cz($,{baseId:Z,schema:J,root:Y}){var X;if(((X=$.fragment)===null||X===void 0?void 0:X[0])!=="/")return;for(let W of $.fragment.slice(1).split("/")){if(typeof J==="boolean")return;let K=J[(0,g_.unescapeFragment)(W)];if(K===void 0)return;J=K;let V=typeof J==="object"&&J[this.opts.schemaId];if(!k40.has(W)&&V)Z=(0,X6.resolveUrl)(this.opts.uriResolver,Z,V)}let Q;if(typeof J!="boolean"&&J.$ref&&!(0,g_.schemaHasRulesButRef)(J,this.RULES)){let W=(0,X6.resolveUrl)(this.opts.uriResolver,Z,J.$ref);Q=cG.call(this,Y,W)}let{schemaId:G}=this.opts;if(Q=Q||new J9({schema:J,schemaId:G,root:Y,baseId:Z}),Q.schema!==Q.root.schema)return Q;return}});var d_=S((Ov0,g40)=>{g40.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var sz=S((jv0,s_)=>{var u40=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),c_=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),nz=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),i_=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),m40=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function oz($){let Z="",J=0,Y=0;for(Y=0;Y<$.length;Y++){if(J=$[Y].charCodeAt(0),J===48)continue;if(!(J>=48&&J<=57||J>=65&&J<=70||J>=97&&J<=102))return"";Z+=$[Y];break}for(Y+=1;Y<$.length;Y++){if(J=$[Y].charCodeAt(0),!(J>=48&&J<=57||J>=65&&J<=70||J>=97&&J<=102))return"";Z+=$[Y]}return Z}var l40=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function p_($){return $.length=0,!0}function d40($,Z,J){if($.length){let Y=oz($);if(Y!=="")Z.push(Y);else return J.error=!0,!1;$.length=0}return!0}function p40($){let Z=0,J={error:!1,address:"",zone:""},Y=[],X=[],Q=!1,G=!1,W=d40;for(let K=0;K<$.length;K++){let V=$[K];if(V==="["||V==="]")continue;if(V===":"){if(Q===!0)G=!0;if(!W(X,Y,J))break;if(++Z>7){J.error=!0;break}if(K>0&&$[K-1]===":")Q=!0;Y.push(":");continue}else if(V==="%"){if(!W(X,Y,J))break;W=p_}else{X.push(V);continue}}if(X.length)if(W===p_)J.zone=X.join("");else if(G)Y.push(X.join(""));else Y.push(oz(X));return J.address=Y.join(""),J}function n_($){if(c40($,":")<2)return{host:$,isIPV6:!1};let Z=p40($);if(!Z.error){let{address:J,address:Y}=Z;if(Z.zone)J+="%"+Z.zone,Y+="%25"+Z.zone;return{host:J,isIPV6:!0,escapedHost:Y}}else return{host:$,isIPV6:!1}}function c40($,Z){let J=0;for(let Y=0;Y<$.length;Y++)if($[Y]===Z)J++;return J}function i40($){let Z=$,J=[],Y=-1,X=0;while(X=Z.length){if(X===1)if(Z===".")break;else if(Z==="/"){J.push("/");break}else{J.push(Z);break}else if(X===2){if(Z[0]==="."){if(Z[1]===".")break;else if(Z[1]==="/"){Z=Z.slice(2);continue}}else if(Z[0]==="/"){if(Z[1]==="."||Z[1]==="/"){J.push("/");break}}}else if(X===3){if(Z==="/.."){if(J.length!==0)J.pop();J.push("/");break}}if(Z[0]==="."){if(Z[1]==="."){if(Z[2]==="/"){Z=Z.slice(3);continue}}else if(Z[1]==="/"){Z=Z.slice(2);continue}}else if(Z[0]==="/"){if(Z[1]==="."){if(Z[2]==="/"){Z=Z.slice(2);continue}else if(Z[2]==="."){if(Z[3]==="/"){if(Z=Z.slice(3),J.length!==0)J.pop();continue}}}}if((Y=Z.indexOf("/",1))===-1){J.push(Z);break}else J.push(Z.slice(0,Y)),Z=Z.slice(Y)}return J.join("")}var n40={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},o40=/[@/?#:]/g,s40=/[@/?#]/g;function o_($,Z){let J=Z?s40:o40;return J.lastIndex=0,$.replace(J,(Y)=>n40[Y])}function r40($,Z=!1){if($.indexOf("%")===-1)return $;let J="";for(let Y=0;Y<$.length;Y++){if($[Y]==="%"&&Y+2<$.length){let X=$.slice(Y+1,Y+3);if(nz(X)){let Q=X.toUpperCase(),G=String.fromCharCode(parseInt(Q,16));if(Z&&i_(G))J+=G;else J+="%"+Q;Y+=2;continue}}J+=$[Y]}return J}function a40($){let Z="";for(let J=0;J<$.length;J++){if($[J]==="%"&&J+2<$.length){let Y=$.slice(J+1,J+3);if(nz(Y)){let X=Y.toUpperCase(),Q=String.fromCharCode(parseInt(X,16));if(Q!=="."&&i_(Q))Z+=Q;else Z+="%"+X;J+=2;continue}}if(m40($[J]))Z+=$[J];else Z+=escape($[J])}return Z}function t40($){let Z="";for(let J=0;J<$.length;J++){if($[J]==="%"&&J+2<$.length){let Y=$.slice(J+1,J+3);if(nz(Y)){Z+="%"+Y.toUpperCase(),J+=2;continue}}Z+=escape($[J])}return Z}function e40($){let Z=[];if($.userinfo!==void 0)Z.push($.userinfo),Z.push("@");if($.host!==void 0){let J=unescape($.host);if(!c_(J)){let Y=n_(J);if(Y.isIPV6===!0)J=`[${Y.escapedHost}]`;else J=o_(J,!1)}Z.push(J)}if(typeof $.port==="number"||typeof $.port==="string")Z.push(":"),Z.push(String($.port));return Z.length?Z.join(""):void 0}s_.exports={nonSimpleDomain:l40,recomposeAuthority:e40,reescapeHostDelimiters:o_,normalizePercentEncoding:r40,normalizePathEncoding:a40,escapePreservingEscapes:t40,removeDotSegments:i40,isIPv4:c_,isUUID:u40,normalizeIPv6:n_,stringArrayToHexStripped:oz}});var $S=S((Nv0,e_)=>{var{isUUID:$G0}=sz(),ZG0=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,JG0=["http","https","ws","wss","urn","urn:uuid"];function YG0($){return JG0.indexOf($)!==-1}function rz($){if($.secure===!0)return!0;else if($.secure===!1)return!1;else if($.scheme)return $.scheme.length===3&&($.scheme[0]==="w"||$.scheme[0]==="W")&&($.scheme[1]==="s"||$.scheme[1]==="S")&&($.scheme[2]==="s"||$.scheme[2]==="S");else return!1}function r_($){if(!$.host)$.error=$.error||"HTTP URIs must have a host.";return $}function a_($){let Z=String($.scheme).toLowerCase()==="https";if($.port===(Z?443:80)||$.port==="")$.port=void 0;if(!$.path)$.path="/";return $}function XG0($){return $.secure=rz($),$.resourceName=($.path||"/")+($.query?"?"+$.query:""),$.path=void 0,$.query=void 0,$}function QG0($){if($.port===(rz($)?443:80)||$.port==="")$.port=void 0;if(typeof $.secure==="boolean")$.scheme=$.secure?"wss":"ws",$.secure=void 0;if($.resourceName){let[Z,J]=$.resourceName.split("?");$.path=Z&&Z!=="/"?Z:void 0,$.query=J,$.resourceName=void 0}return $.fragment=void 0,$}function GG0($,Z){if(!$.path)return $.error="URN can not be parsed",$;let J=$.path.match(ZG0);if(J){let Y=Z.scheme||$.scheme||"urn";$.nid=J[1].toLowerCase(),$.nss=J[2];let X=`${Y}:${Z.nid||$.nid}`,Q=az(X);if($.path=void 0,Q)$=Q.parse($,Z)}else $.error=$.error||"URN can not be parsed.";return $}function WG0($,Z){if($.nid===void 0)throw Error("URN without nid cannot be serialized");let J=Z.scheme||$.scheme||"urn",Y=$.nid.toLowerCase(),X=`${J}:${Z.nid||Y}`,Q=az(X);if(Q)$=Q.serialize($,Z);let G=$,W=$.nss;return G.path=`${Y||Z.nid}:${W}`,Z.skipEscape=!0,G}function KG0($,Z){let J=$;if(J.uuid=J.nss,J.nss=void 0,!Z.tolerant&&(!J.uuid||!$G0(J.uuid)))J.error=J.error||"UUID is not valid.";return J}function VG0($){let Z=$;return Z.nss=($.uuid||"").toLowerCase(),Z}var t_={scheme:"http",domainHost:!0,parse:r_,serialize:a_},UG0={scheme:"https",domainHost:t_.domainHost,parse:r_,serialize:a_},iG={scheme:"ws",domainHost:!0,parse:XG0,serialize:QG0},HG0={scheme:"wss",domainHost:iG.domainHost,parse:iG.parse,serialize:iG.serialize},BG0={scheme:"urn",parse:GG0,serialize:WG0,skipNormalize:!0},zG0={scheme:"urn:uuid",parse:KG0,serialize:VG0,skipNormalize:!0},nG={http:t_,https:UG0,ws:iG,wss:HG0,urn:BG0,"urn:uuid":zG0};Object.setPrototypeOf(nG,null);function az($){return $&&(nG[$]||nG[$.toLowerCase()])||void 0}e_.exports={wsIsSecure:rz,SCHEMES:nG,isValidSchemeName:YG0,getSchemeHandler:az}});var sG=S((qv0,oG)=>{var{normalizeIPv6:FG0,removeDotSegments:Y9,recomposeAuthority:AG0,normalizePercentEncoding:OG0,normalizePathEncoding:jG0,escapePreservingEscapes:NG0,reescapeHostDelimiters:qG0,isIPv4:MG0,nonSimpleDomain:DG0}=sz(),{SCHEMES:wG0,getSchemeHandler:JS}=$S();function LG0($,Z){if(typeof $==="string")$=IG0($,Z);else if(typeof $==="object")$=dJ(X7($,Z),Z);return $}function TG0($,Z,J){let Y=J?Object.assign({scheme:"null"},J):{scheme:"null"},X=YS(dJ($,Y),dJ(Z,Y),Y,!0);return Y.skipEscape=!0,X7(X,Y)}function YS($,Z,J,Y){let X={};if(!Y)$=dJ(X7($,J),J),Z=dJ(X7(Z,J),J);if(J=J||{},!J.tolerant&&Z.scheme)X.scheme=Z.scheme,X.userinfo=Z.userinfo,X.host=Z.host,X.port=Z.port,X.path=Y9(Z.path||""),X.query=Z.query;else{if(Z.userinfo!==void 0||Z.host!==void 0||Z.port!==void 0)X.userinfo=Z.userinfo,X.host=Z.host,X.port=Z.port,X.path=Y9(Z.path||""),X.query=Z.query;else{if(!Z.path)if(X.path=$.path,Z.query!==void 0)X.query=Z.query;else X.query=$.query;else{if(Z.path[0]==="/")X.path=Y9(Z.path);else{if(($.userinfo!==void 0||$.host!==void 0||$.port!==void 0)&&!$.path)X.path="/"+Z.path;else if(!$.path)X.path=Z.path;else X.path=$.path.slice(0,$.path.lastIndexOf("/")+1)+Z.path;X.path=Y9(X.path)}X.query=Z.query}X.userinfo=$.userinfo,X.host=$.host,X.port=$.port}X.scheme=$.scheme}return X.fragment=Z.fragment,X}function RG0($,Z,J){let Y=ZS($,J),X=ZS(Z,J);return Y!==void 0&&X!==void 0&&Y.toLowerCase()===X.toLowerCase()}function X7($,Z){let J={host:$.host,scheme:$.scheme,userinfo:$.userinfo,port:$.port,path:$.path,query:$.query,nid:$.nid,nss:$.nss,uuid:$.uuid,fragment:$.fragment,reference:$.reference,resourceName:$.resourceName,secure:$.secure,error:""},Y=Object.assign({},Z),X=[],Q=JS(Y.scheme||J.scheme);if(Q&&Q.serialize)Q.serialize(J,Y);if(J.path!==void 0)if(!Y.skipEscape){if(J.path=NG0(J.path),J.scheme!==void 0)J.path=J.path.split("%3A").join(":")}else J.path=OG0(J.path);if(Y.reference!=="suffix"&&J.scheme)X.push(J.scheme,":");let G=AG0(J);if(G!==void 0){if(Y.reference!=="suffix")X.push("//");if(X.push(G),J.path&&J.path[0]!=="/")X.push("/")}if(J.path!==void 0){let W=J.path;if(!Y.absolutePath&&(!Q||!Q.absolutePath))W=Y9(W);if(G===void 0&&W[0]==="/"&&W[1]==="/")W="/%2F"+W.slice(2);X.push(W)}if(J.query!==void 0)X.push("?",J.query);if(J.fragment!==void 0)X.push("#",J.fragment);return X.join("")}var PG0=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function CG0($,Z){if(Z[2]!==void 0&&$.path&&$.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof $.port==="number"&&($.port<0||$.port>65535))return"URI port is malformed.";return}function XS($,Z){let J=Object.assign({},Z),Y={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},X=!1,Q=!1;if(J.reference==="suffix")if(J.scheme)$=J.scheme+":"+$;else $="//"+$;let G=$.match(PG0);if(G){if(Y.scheme=G[1],Y.userinfo=G[3],Y.host=G[4],Y.port=parseInt(G[5],10),Y.path=G[6]||"",Y.query=G[7],Y.fragment=G[8],isNaN(Y.port))Y.port=G[5];let W=CG0(Y,G);if(W!==void 0)Y.error=Y.error||W,X=!0;if(Y.host)if(MG0(Y.host)===!1){let U=FG0(Y.host);Y.host=U.host.toLowerCase(),Q=U.isIPV6}else Q=!0;if(Y.scheme===void 0&&Y.userinfo===void 0&&Y.host===void 0&&Y.port===void 0&&Y.query===void 0&&!Y.path)Y.reference="same-document";else if(Y.scheme===void 0)Y.reference="relative";else if(Y.fragment===void 0)Y.reference="absolute";else Y.reference="uri";if(J.reference&&J.reference!=="suffix"&&J.reference!==Y.reference)Y.error=Y.error||"URI is not a "+J.reference+" reference.";let K=JS(J.scheme||Y.scheme);if(!J.unicodeSupport&&(!K||!K.unicodeSupport)){if(Y.host&&(J.domainHost||K&&K.domainHost)&&Q===!1&&DG0(Y.host))try{Y.host=URL.domainToASCII(Y.host.toLowerCase())}catch(V){Y.error=Y.error||"Host's domain name can not be converted to ASCII: "+V}}if(!K||K&&!K.skipNormalize){if($.indexOf("%")!==-1){if(Y.scheme!==void 0)Y.scheme=unescape(Y.scheme);if(Y.host!==void 0)Y.host=qG0(unescape(Y.host),Q)}if(Y.path)Y.path=jG0(Y.path);if(Y.fragment)try{Y.fragment=encodeURI(decodeURIComponent(Y.fragment))}catch{Y.error=Y.error||"URI malformed"}}if(K&&K.parse)K.parse(Y,J)}else Y.error=Y.error||"URI can not be parsed.";return{parsed:Y,malformedAuthorityOrPort:X}}function dJ($,Z){return XS($,Z).parsed}function IG0($,Z){return QS($,Z).normalized}function QS($,Z){let{parsed:J,malformedAuthorityOrPort:Y}=XS($,Z);return{normalized:Y?$:X7(J,Z),malformedAuthorityOrPort:Y}}function ZS($,Z){if(typeof $==="string"){let{normalized:J,malformedAuthorityOrPort:Y}=QS($,Z);return Y?void 0:J}if(typeof $==="object")return X7($,Z)}var tz={SCHEMES:wG0,normalize:LG0,resolve:TG0,resolveComponent:YS,equal:RG0,serialize:X7,parse:dJ};oG.exports=tz;oG.exports.default=tz;oG.exports.fastUri=tz});var KS=S((WS)=>{Object.defineProperty(WS,"__esModule",{value:!0});var GS=sG();GS.code='require("ajv/dist/runtime/uri").default';WS.default=GS});var Z3=S((XZ)=>{Object.defineProperty(XZ,"__esModule",{value:!0});XZ.CodeGen=XZ.Name=XZ.nil=XZ.stringify=XZ.str=XZ._=XZ.KeywordCxt=void 0;var bG0=lJ();Object.defineProperty(XZ,"KeywordCxt",{enumerable:!0,get:function(){return bG0.KeywordCxt}});var pJ=k0();Object.defineProperty(XZ,"_",{enumerable:!0,get:function(){return pJ._}});Object.defineProperty(XZ,"str",{enumerable:!0,get:function(){return pJ.str}});Object.defineProperty(XZ,"stringify",{enumerable:!0,get:function(){return pJ.stringify}});Object.defineProperty(XZ,"nil",{enumerable:!0,get:function(){return pJ.nil}});Object.defineProperty(XZ,"Name",{enumerable:!0,get:function(){return pJ.Name}});Object.defineProperty(XZ,"CodeGen",{enumerable:!0,get:function(){return pJ.CodeGen}});var _G0=Z9(),zS=YZ(),SG0=_z(),X9=Y7(),fG0=k0(),Q9=tX(),rG=rX(),$3=J1(),VS=d_(),kG0=KS(),FS=($,Z)=>new RegExp($,Z);FS.code="new RegExp";var vG0=["removeAdditional","useDefaults","coerceTypes"],yG0=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),xG0={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},hG0={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},US=200;function gG0($){var Z,J,Y,X,Q,G,W,K,V,U,H,B,z,F,A,N,q,w,j,M,I,R,L,C,_;let E=$.strict,f=(Z=$.code)===null||Z===void 0?void 0:Z.optimize,b=f===!0||f===void 0?1:f||0,k=(Y=(J=$.code)===null||J===void 0?void 0:J.regExp)!==null&&Y!==void 0?Y:FS,u=(X=$.uriResolver)!==null&&X!==void 0?X:kG0.default;return{strictSchema:(G=(Q=$.strictSchema)!==null&&Q!==void 0?Q:E)!==null&&G!==void 0?G:!0,strictNumbers:(K=(W=$.strictNumbers)!==null&&W!==void 0?W:E)!==null&&K!==void 0?K:!0,strictTypes:(U=(V=$.strictTypes)!==null&&V!==void 0?V:E)!==null&&U!==void 0?U:"log",strictTuples:(B=(H=$.strictTuples)!==null&&H!==void 0?H:E)!==null&&B!==void 0?B:"log",strictRequired:(F=(z=$.strictRequired)!==null&&z!==void 0?z:E)!==null&&F!==void 0?F:!1,code:$.code?{...$.code,optimize:b,regExp:k}:{optimize:b,regExp:k},loopRequired:(A=$.loopRequired)!==null&&A!==void 0?A:US,loopEnum:(N=$.loopEnum)!==null&&N!==void 0?N:US,meta:(q=$.meta)!==null&&q!==void 0?q:!0,messages:(w=$.messages)!==null&&w!==void 0?w:!0,inlineRefs:(j=$.inlineRefs)!==null&&j!==void 0?j:!0,schemaId:(M=$.schemaId)!==null&&M!==void 0?M:"$id",addUsedSchema:(I=$.addUsedSchema)!==null&&I!==void 0?I:!0,validateSchema:(R=$.validateSchema)!==null&&R!==void 0?R:!0,validateFormats:(L=$.validateFormats)!==null&&L!==void 0?L:!0,unicodeRegExp:(C=$.unicodeRegExp)!==null&&C!==void 0?C:!0,int32range:(_=$.int32range)!==null&&_!==void 0?_:!0,uriResolver:u}}class aG{constructor($={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,$=this.opts={...$,...gG0($)};let{es5:Z,lines:J}=this.opts.code;this.scope=new fG0.ValueScope({scope:{},prefixes:yG0,es5:Z,lines:J}),this.logger=cG0($.logger);let Y=$.validateFormats;if($.validateFormats=!1,this.RULES=(0,SG0.getRules)(),HS.call(this,xG0,$,"NOT SUPPORTED"),HS.call(this,hG0,$,"DEPRECATED","warn"),this._metaOpts=dG0.call(this),$.formats)mG0.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),$.keywords)lG0.call(this,$.keywords);if(typeof $.meta=="object")this.addMetaSchema($.meta);uG0.call(this),$.validateFormats=Y}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:$,meta:Z,schemaId:J}=this.opts,Y=VS;if(J==="id")Y={...VS},Y.id=Y.$id,delete Y.$id;if(Z&&$)this.addMetaSchema(Y,Y[J],!1)}defaultMeta(){let{meta:$,schemaId:Z}=this.opts;return this.opts.defaultMeta=typeof $=="object"?$[Z]||$:void 0}validate($,Z){let J;if(typeof $=="string"){if(J=this.getSchema($),!J)throw Error(`no schema with key or ref "${$}"`)}else J=this.compile($);let Y=J(Z);if(!("$async"in J))this.errors=J.errors;return Y}compile($,Z){let J=this._addSchema($,Z);return J.validate||this._compileSchemaEnv(J)}compileAsync($,Z){if(typeof this.opts.loadSchema!="function")throw Error("options.loadSchema should be a function");let{loadSchema:J}=this.opts;return Y.call(this,$,Z);async function Y(V,U){await X.call(this,V.$schema);let H=this._addSchema(V,U);return H.validate||Q.call(this,H)}async function X(V){if(V&&!this.getSchema(V))await Y.call(this,{$ref:V},!0)}async function Q(V){try{return this._compileSchemaEnv(V)}catch(U){if(!(U instanceof zS.default))throw U;return G.call(this,U),await W.call(this,U.missingSchema),Q.call(this,V)}}function G({missingSchema:V,missingRef:U}){if(this.refs[V])throw Error(`AnySchema ${V} is loaded but ${U} cannot be resolved`)}async function W(V){let U=await K.call(this,V);if(!this.refs[V])await X.call(this,U.$schema);if(!this.refs[V])this.addSchema(U,V,Z)}async function K(V){let U=this._loading[V];if(U)return U;try{return await(this._loading[V]=J(V))}finally{delete this._loading[V]}}}addSchema($,Z,J,Y=this.opts.validateSchema){if(Array.isArray($)){for(let Q of $)this.addSchema(Q,void 0,J,Y);return this}let X;if(typeof $==="object"){let{schemaId:Q}=this.opts;if(X=$[Q],X!==void 0&&typeof X!="string")throw Error(`schema ${Q} must be string`)}return Z=(0,Q9.normalizeId)(Z||X),this._checkUnique(Z),this.schemas[Z]=this._addSchema($,J,Z,Y,!0),this}addMetaSchema($,Z,J=this.opts.validateSchema){return this.addSchema($,Z,!0,J),this}validateSchema($,Z){if(typeof $=="boolean")return!0;let J;if(J=$.$schema,J!==void 0&&typeof J!="string")throw Error("$schema must be a string");if(J=J||this.opts.defaultMeta||this.defaultMeta(),!J)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let Y=this.validate(J,$);if(!Y&&Z){let X="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(X);else throw Error(X)}return Y}getSchema($){let Z;while(typeof(Z=BS.call(this,$))=="string")$=Z;if(Z===void 0){let{schemaId:J}=this.opts,Y=new X9.SchemaEnv({schema:{},schemaId:J});if(Z=X9.resolveSchema.call(this,Y,$),!Z)return;this.refs[$]=Z}return Z.validate||this._compileSchemaEnv(Z)}removeSchema($){if($ instanceof RegExp)return this._removeAllSchemas(this.schemas,$),this._removeAllSchemas(this.refs,$),this;switch(typeof $){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let Z=BS.call(this,$);if(typeof Z=="object")this._cache.delete(Z.schema);return delete this.schemas[$],delete this.refs[$],this}case"object":{let Z=$;this._cache.delete(Z);let J=$[this.opts.schemaId];if(J)J=(0,Q9.normalizeId)(J),delete this.schemas[J],delete this.refs[J];return this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary($){for(let Z of $)this.addKeyword(Z);return this}addKeyword($,Z){let J;if(typeof $=="string"){if(J=$,typeof Z=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),Z.keyword=J}else if(typeof $=="object"&&Z===void 0){if(Z=$,J=Z.keyword,Array.isArray(J)&&!J.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(nG0.call(this,J,Z),!Z)return(0,$3.eachItem)(J,(X)=>ez.call(this,X)),this;sG0.call(this,Z);let Y={...Z,type:(0,rG.getJSONTypes)(Z.type),schemaType:(0,rG.getJSONTypes)(Z.schemaType)};return(0,$3.eachItem)(J,Y.type.length===0?(X)=>ez.call(this,X,Y):(X)=>Y.type.forEach((Q)=>ez.call(this,X,Y,Q))),this}getKeyword($){let Z=this.RULES.all[$];return typeof Z=="object"?Z.definition:!!Z}removeKeyword($){let{RULES:Z}=this;delete Z.keywords[$],delete Z.all[$];for(let J of Z.rules){let Y=J.rules.findIndex((X)=>X.keyword===$);if(Y>=0)J.rules.splice(Y,1)}return this}addFormat($,Z){if(typeof Z=="string")Z=new RegExp(Z);return this.formats[$]=Z,this}errorsText($=this.errors,{separator:Z=", ",dataVar:J="data"}={}){if(!$||$.length===0)return"No errors";return $.map((Y)=>`${J}${Y.instancePath} ${Y.message}`).reduce((Y,X)=>Y+Z+X)}$dataMetaSchema($,Z){let J=this.RULES.all;$=JSON.parse(JSON.stringify($));for(let Y of Z){let X=Y.split("/").slice(1),Q=$;for(let G of X)Q=Q[G];for(let G in J){let W=J[G];if(typeof W!="object")continue;let{$data:K}=W.definition,V=Q[G];if(K&&V)Q[G]=AS(V)}}return $}_removeAllSchemas($,Z){for(let J in $){let Y=$[J];if(!Z||Z.test(J)){if(typeof Y=="string")delete $[J];else if(Y&&!Y.meta)this._cache.delete(Y.schema),delete $[J]}}}_addSchema($,Z,J,Y=this.opts.validateSchema,X=this.opts.addUsedSchema){let Q,{schemaId:G}=this.opts;if(typeof $=="object")Q=$[G];else if(this.opts.jtd)throw Error("schema must be object");else if(typeof $!="boolean")throw Error("schema must be object or boolean");let W=this._cache.get($);if(W!==void 0)return W;J=(0,Q9.normalizeId)(Q||J);let K=Q9.getSchemaRefs.call(this,$,J);if(W=new X9.SchemaEnv({schema:$,schemaId:G,meta:Z,baseId:J,localRefs:K}),this._cache.set(W.schema,W),X&&!J.startsWith("#")){if(J)this._checkUnique(J);this.refs[J]=W}if(Y)this.validateSchema($,!0);return W}_checkUnique($){if(this.schemas[$]||this.refs[$])throw Error(`schema with key or id "${$}" already exists`)}_compileSchemaEnv($){if($.meta)this._compileMetaSchema($);else X9.compileSchema.call(this,$);if(!$.validate)throw Error("ajv implementation error");return $.validate}_compileMetaSchema($){let Z=this.opts;this.opts=this._metaOpts;try{X9.compileSchema.call(this,$)}finally{this.opts=Z}}}aG.ValidationError=_G0.default;aG.MissingRefError=zS.default;XZ.default=aG;function HS($,Z,J,Y="error"){for(let X in $){let Q=X;if(Q in Z)this.logger[Y](`${J}: option ${X}. ${$[Q]}`)}}function BS($){return $=(0,Q9.normalizeId)($),this.schemas[$]||this.refs[$]}function uG0(){let $=this.opts.schemas;if(!$)return;if(Array.isArray($))this.addSchema($);else for(let Z in $)this.addSchema($[Z],Z)}function mG0(){for(let $ in this.opts.formats){let Z=this.opts.formats[$];if(Z)this.addFormat($,Z)}}function lG0($){if(Array.isArray($)){this.addVocabulary($);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let Z in $){let J=$[Z];if(!J.keyword)J.keyword=Z;this.addKeyword(J)}}function dG0(){let $={...this.opts};for(let Z of vG0)delete $[Z];return $}var pG0={log(){},warn(){},error(){}};function cG0($){if($===!1)return pG0;if($===void 0)return console;if($.log&&$.warn&&$.error)return $;throw Error("logger must implement log, warn and error methods")}var iG0=/^[a-z_$][a-z0-9_$:-]*$/i;function nG0($,Z){let{RULES:J}=this;if((0,$3.eachItem)($,(Y)=>{if(J.keywords[Y])throw Error(`Keyword ${Y} is already defined`);if(!iG0.test(Y))throw Error(`Keyword ${Y} has invalid name`)}),!Z)return;if(Z.$data&&!(("code"in Z)||("validate"in Z)))throw Error('$data keyword must have "code" or "validate" function')}function ez($,Z,J){var Y;let X=Z===null||Z===void 0?void 0:Z.post;if(J&&X)throw Error('keyword with "post" flag cannot have "type"');let{RULES:Q}=this,G=X?Q.post:Q.rules.find(({type:K})=>K===J);if(!G)G={type:J,rules:[]},Q.rules.push(G);if(Q.keywords[$]=!0,!Z)return;let W={keyword:$,definition:{...Z,type:(0,rG.getJSONTypes)(Z.type),schemaType:(0,rG.getJSONTypes)(Z.schemaType)}};if(Z.before)oG0.call(this,G,W,Z.before);else G.rules.push(W);Q.all[$]=W,(Y=Z.implements)===null||Y===void 0||Y.forEach((K)=>this.addKeyword(K))}function oG0($,Z,J){let Y=$.rules.findIndex((X)=>X.keyword===J);if(Y>=0)$.rules.splice(Y,0,Z);else $.rules.push(Z),this.logger.warn(`rule ${J} is not defined`)}function sG0($){let{metaSchema:Z}=$;if(Z===void 0)return;if($.$data&&this.opts.$data)Z=AS(Z);$.validateSchema=this.compile(Z,!0)}var rG0={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function AS($){return{anyOf:[$,rG0]}}});var jS=S((OS)=>{Object.defineProperty(OS,"__esModule",{value:!0});var eG0={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};OS.default=eG0});var J3=S((DS)=>{Object.defineProperty(DS,"__esModule",{value:!0});DS.callRef=DS.getValidate=void 0;var ZW0=YZ(),NS=f$(),H8=k0(),cJ=g8(),qS=Y7(),tG=J1(),JW0={keyword:"$ref",schemaType:"string",code($){let{gen:Z,schema:J,it:Y}=$,{baseId:X,schemaEnv:Q,validateName:G,opts:W,self:K}=Y,{root:V}=Q;if((J==="#"||J==="#/")&&X===V.baseId)return H();let U=qS.resolveRef.call(K,V,X,J);if(U===void 0)throw new ZW0.default(Y.opts.uriResolver,X,J);if(U instanceof qS.SchemaEnv)return B(U);return z(U);function H(){if(Q===V)return eG($,G,Q,Q.$async);let F=Z.scopeValue("root",{ref:V});return eG($,H8._`${F}.validate`,V,V.$async)}function B(F){let A=MS($,F);eG($,A,F,F.$async)}function z(F){let A=Z.scopeValue("schema",W.code.source===!0?{ref:F,code:(0,H8.stringify)(F)}:{ref:F}),N=Z.name("valid"),q=$.subschema({schema:F,dataTypes:[],schemaPath:H8.nil,topSchemaRef:A,errSchemaPath:J},N);$.mergeEvaluated(q),$.ok(N)}}};function MS($,Z){let{gen:J}=$;return Z.validate?J.scopeValue("validate",{ref:Z.validate}):H8._`${J.scopeValue("wrapper",{ref:Z})}.validate`}DS.getValidate=MS;function eG($,Z,J,Y){let{gen:X,it:Q}=$,{allErrors:G,schemaEnv:W,opts:K}=Q,V=K.passContext?cJ.default.this:H8.nil;if(Y)U();else H();function U(){if(!W.$async)throw Error("async schema referenced by sync schema");let F=X.let("valid");X.try(()=>{if(X.code(H8._`await ${(0,NS.callValidateCode)($,Z,V)}`),z(Z),!G)X.assign(F,!0)},(A)=>{if(X.if(H8._`!(${A} instanceof ${Q.ValidationError})`,()=>X.throw(A)),B(A),!G)X.assign(F,!1)}),$.ok(F)}function H(){$.result((0,NS.callValidateCode)($,Z,V),()=>z(Z),()=>B(Z))}function B(F){let A=H8._`${F}.errors`;X.assign(cJ.default.vErrors,H8._`${cJ.default.vErrors} === null ? ${A} : ${cJ.default.vErrors}.concat(${A})`),X.assign(cJ.default.errors,H8._`${cJ.default.vErrors}.length`)}function z(F){var A;if(!Q.opts.unevaluated)return;let N=(A=J===null||J===void 0?void 0:J.validate)===null||A===void 0?void 0:A.evaluated;if(Q.props!==!0)if(N&&!N.dynamicProps){if(N.props!==void 0)Q.props=tG.mergeEvaluated.props(X,N.props,Q.props)}else{let q=X.var("props",H8._`${F}.evaluated.props`);Q.props=tG.mergeEvaluated.props(X,q,Q.props,H8.Name)}if(Q.items!==!0)if(N&&!N.dynamicItems){if(N.items!==void 0)Q.items=tG.mergeEvaluated.items(X,N.items,Q.items)}else{let q=X.var("items",H8._`${F}.evaluated.items`);Q.items=tG.mergeEvaluated.items(X,q,Q.items,H8.Name)}}}DS.callRef=eG;DS.default=JW0});var TS=S((LS)=>{Object.defineProperty(LS,"__esModule",{value:!0});var QW0=jS(),GW0=J3(),WW0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",QW0.default,GW0.default];LS.default=WW0});var PS=S((RS)=>{Object.defineProperty(RS,"__esModule",{value:!0});var $W=k0(),aZ=$W.operators,ZW={maximum:{okStr:"<=",ok:aZ.LTE,fail:aZ.GT},minimum:{okStr:">=",ok:aZ.GTE,fail:aZ.LT},exclusiveMaximum:{okStr:"<",ok:aZ.LT,fail:aZ.GTE},exclusiveMinimum:{okStr:">",ok:aZ.GT,fail:aZ.LTE}},VW0={message:({keyword:$,schemaCode:Z})=>$W.str`must be ${ZW[$].okStr} ${Z}`,params:({keyword:$,schemaCode:Z})=>$W._`{comparison: ${ZW[$].okStr}, limit: ${Z}}`},UW0={keyword:Object.keys(ZW),type:"number",schemaType:"number",$data:!0,error:VW0,code($){let{keyword:Z,data:J,schemaCode:Y}=$;$.fail$data($W._`${J} ${ZW[Z].fail} ${Y} || isNaN(${J})`)}};RS.default=UW0});var IS=S((CS)=>{Object.defineProperty(CS,"__esModule",{value:!0});var G9=k0(),BW0={message:({schemaCode:$})=>G9.str`must be multiple of ${$}`,params:({schemaCode:$})=>G9._`{multipleOf: ${$}}`},zW0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:BW0,code($){let{gen:Z,data:J,schemaCode:Y,it:X}=$,Q=X.opts.multipleOfPrecision,G=Z.let("res"),W=Q?G9._`Math.abs(Math.round(${G}) - ${G}) > 1e-${Q}`:G9._`${G} !== parseInt(${G})`;$.fail$data(G9._`(${Y} === 0 || (${G} = ${J}/${Y}, ${W}))`)}};CS.default=zW0});var _S=S((bS)=>{Object.defineProperty(bS,"__esModule",{value:!0});function ES($){let Z=$.length,J=0,Y=0,X;while(Y<Z)if(J++,X=$.charCodeAt(Y++),X>=55296&&X<=56319&&Y<Z){if(X=$.charCodeAt(Y),(X&64512)===56320)Y++}return J}bS.default=ES;ES.code='require("ajv/dist/runtime/ucs2length").default'});var fS=S((SS)=>{Object.defineProperty(SS,"__esModule",{value:!0});var Q7=k0(),OW0=J1(),jW0=_S(),NW0={message({keyword:$,schemaCode:Z}){let J=$==="maxLength"?"more":"fewer";return Q7.str`must NOT have ${J} than ${Z} characters`},params:({schemaCode:$})=>Q7._`{limit: ${$}}`},qW0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:NW0,code($){let{keyword:Z,data:J,schemaCode:Y,it:X}=$,Q=Z==="maxLength"?Q7.operators.GT:Q7.operators.LT,G=X.opts.unicode===!1?Q7._`${J}.length`:Q7._`${(0,OW0.useFunc)($.gen,jW0.default)}(${J})`;$.fail$data(Q7._`${G} ${Q} ${Y}`)}};SS.default=qW0});var vS=S((kS)=>{Object.defineProperty(kS,"__esModule",{value:!0});var DW0=f$(),wW0=J1(),iJ=k0(),LW0={message:({schemaCode:$})=>iJ.str`must match pattern "${$}"`,params:({schemaCode:$})=>iJ._`{pattern: ${$}}`},TW0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:LW0,code($){let{gen:Z,data:J,$data:Y,schema:X,schemaCode:Q,it:G}=$,W=G.opts.unicodeRegExp?"u":"";if(Y){let{regExp:K}=G.opts.code,V=K.code==="new RegExp"?iJ._`new RegExp`:(0,wW0.useFunc)(Z,K),U=Z.let("valid");Z.try(()=>Z.assign(U,iJ._`${V}(${Q}, ${W}).test(${J})`),()=>Z.assign(U,!1)),$.fail$data(iJ._`!${U}`)}else{let K=(0,DW0.usePattern)($,X);$.fail$data(iJ._`!${K}.test(${J})`)}}};kS.default=TW0});var xS=S((yS)=>{Object.defineProperty(yS,"__esModule",{value:!0});var W9=k0(),PW0={message({keyword:$,schemaCode:Z}){let J=$==="maxProperties"?"more":"fewer";return W9.str`must NOT have ${J} than ${Z} properties`},params:({schemaCode:$})=>W9._`{limit: ${$}}`},CW0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:PW0,code($){let{keyword:Z,data:J,schemaCode:Y}=$,X=Z==="maxProperties"?W9.operators.GT:W9.operators.LT;$.fail$data(W9._`Object.keys(${J}).length ${X} ${Y}`)}};yS.default=CW0});var gS=S((hS)=>{Object.defineProperty(hS,"__esModule",{value:!0});var K9=f$(),V9=k0(),EW0=J1(),bW0={message:({params:{missingProperty:$}})=>V9.str`must have required property '${$}'`,params:({params:{missingProperty:$}})=>V9._`{missingProperty: ${$}}`},_W0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:bW0,code($){let{gen:Z,schema:J,schemaCode:Y,data:X,$data:Q,it:G}=$,{opts:W}=G;if(!Q&&J.length===0)return;let K=J.length>=W.loopRequired;if(G.allErrors)V();else U();if(W.strictRequired){let z=$.parentSchema.properties,{definedProperties:F}=$.it;for(let A of J)if((z===null||z===void 0?void 0:z[A])===void 0&&!F.has(A)){let N=G.schemaEnv.baseId+G.errSchemaPath,q=`required property "${A}" is not defined at "${N}" (strictRequired)`;(0,EW0.checkStrictMode)(G,q,G.opts.strictRequired)}}function V(){if(K||Q)$.block$data(V9.nil,H);else for(let z of J)(0,K9.checkReportMissingProp)($,z)}function U(){let z=Z.let("missing");if(K||Q){let F=Z.let("valid",!0);$.block$data(F,()=>B(z,F)),$.ok(F)}else Z.if((0,K9.checkMissingProp)($,J,z)),(0,K9.reportMissingProp)($,z),Z.else()}function H(){Z.forOf("prop",Y,(z)=>{$.setParams({missingProperty:z}),Z.if((0,K9.noPropertyInData)(Z,X,z,W.ownProperties),()=>$.error())})}function B(z,F){$.setParams({missingProperty:z}),Z.forOf(z,Y,()=>{Z.assign(F,(0,K9.propertyInData)(Z,X,z,W.ownProperties)),Z.if((0,V9.not)(F),()=>{$.error(),Z.break()})},V9.nil)}}};hS.default=_W0});var mS=S((uS)=>{Object.defineProperty(uS,"__esModule",{value:!0});var U9=k0(),fW0={message({keyword:$,schemaCode:Z}){let J=$==="maxItems"?"more":"fewer";return U9.str`must NOT have ${J} than ${Z} items`},params:({schemaCode:$})=>U9._`{limit: ${$}}`},kW0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:fW0,code($){let{keyword:Z,data:J,schemaCode:Y}=$,X=Z==="maxItems"?U9.operators.GT:U9.operators.LT;$.fail$data(U9._`${J}.length ${X} ${Y}`)}};uS.default=kW0});var H9=S((dS)=>{Object.defineProperty(dS,"__esModule",{value:!0});var lS=aX();lS.code='require("ajv/dist/runtime/equal").default';dS.default=lS});var cS=S((pS)=>{Object.defineProperty(pS,"__esModule",{value:!0});var Y3=rX(),k$=k0(),xW0=J1(),hW0=H9(),gW0={message:({params:{i:$,j:Z}})=>k$.str`must NOT have duplicate items (items ## ${Z} and ${$} are identical)`,params:({params:{i:$,j:Z}})=>k$._`{i: ${$}, j: ${Z}}`},uW0={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:gW0,code($){let{gen:Z,data:J,$data:Y,schema:X,parentSchema:Q,schemaCode:G,it:W}=$;if(!Y&&!X)return;let K=Z.let("valid"),V=Q.items?(0,Y3.getSchemaTypes)(Q.items):[];$.block$data(K,U,k$._`${G} === false`),$.ok(K);function U(){let F=Z.let("i",k$._`${J}.length`),A=Z.let("j");$.setParams({i:F,j:A}),Z.assign(K,!0),Z.if(k$._`${F} > 1`,()=>(H()?B:z)(F,A))}function H(){return V.length>0&&!V.some((F)=>F==="object"||F==="array")}function B(F,A){let N=Z.name("item"),q=(0,Y3.checkDataTypes)(V,N,W.opts.strictNumbers,Y3.DataType.Wrong),w=Z.const("indices",k$._`{}`);Z.for(k$._`;${F}--;`,()=>{if(Z.let(N,k$._`${J}[${F}]`),Z.if(q,k$._`continue`),V.length>1)Z.if(k$._`typeof ${N} == "string"`,k$._`${N} += "_"`);Z.if(k$._`typeof ${w}[${N}] == "number"`,()=>{Z.assign(A,k$._`${w}[${N}]`),$.error(),Z.assign(K,!1).break()}).code(k$._`${w}[${N}] = ${F}`)})}function z(F,A){let N=(0,xW0.useFunc)(Z,hW0.default),q=Z.name("outer");Z.label(q).for(k$._`;${F}--;`,()=>Z.for(k$._`${A} = ${F}; ${A}--;`,()=>Z.if(k$._`${N}(${J}[${F}], ${J}[${A}])`,()=>{$.error(),Z.assign(K,!1).break(q)})))}}};pS.default=uW0});var nS=S((iS)=>{Object.defineProperty(iS,"__esModule",{value:!0});var X3=k0(),lW0=J1(),dW0=H9(),pW0={message:"must be equal to constant",params:({schemaCode:$})=>X3._`{allowedValue: ${$}}`},cW0={keyword:"const",$data:!0,error:pW0,code($){let{gen:Z,data:J,$data:Y,schemaCode:X,schema:Q}=$;if(Y||Q&&typeof Q=="object")$.fail$data(X3._`!${(0,lW0.useFunc)(Z,dW0.default)}(${J}, ${X})`);else $.fail(X3._`${Q} !== ${J}`)}};iS.default=cW0});var sS=S((oS)=>{Object.defineProperty(oS,"__esModule",{value:!0});var B9=k0(),nW0=J1(),oW0=H9(),sW0={message:"must be equal to one of the allowed values",params:({schemaCode:$})=>B9._`{allowedValues: ${$}}`},rW0={keyword:"enum",schemaType:"array",$data:!0,error:sW0,code($){let{gen:Z,data:J,$data:Y,schema:X,schemaCode:Q,it:G}=$;if(!Y&&X.length===0)throw Error("enum must have non-empty array");let W=X.length>=G.opts.loopEnum,K,V=()=>K!==null&&K!==void 0?K:K=(0,nW0.useFunc)(Z,oW0.default),U;if(W||Y)U=Z.let("valid"),$.block$data(U,H);else{if(!Array.isArray(X))throw Error("ajv implementation error");let z=Z.const("vSchema",Q);U=(0,B9.or)(...X.map((F,A)=>B(z,A)))}$.pass(U);function H(){Z.assign(U,!1),Z.forOf("v",Q,(z)=>Z.if(B9._`${V()}(${J}, ${z})`,()=>Z.assign(U,!0).break()))}function B(z,F){let A=X[F];return typeof A==="object"&&A!==null?B9._`${V()}(${J}, ${z}[${F}])`:B9._`${J} === ${A}`}}};oS.default=rW0});var aS=S((rS)=>{Object.defineProperty(rS,"__esModule",{value:!0});var tW0=PS(),eW0=IS(),$K0=fS(),ZK0=vS(),JK0=xS(),YK0=gS(),XK0=mS(),QK0=cS(),GK0=nS(),WK0=sS(),KK0=[tW0.default,eW0.default,$K0.default,ZK0.default,JK0.default,YK0.default,XK0.default,QK0.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},GK0.default,WK0.default];rS.default=KK0});var G3=S((eS)=>{Object.defineProperty(eS,"__esModule",{value:!0});eS.validateAdditionalItems=void 0;var G7=k0(),Q3=J1(),UK0={message:({params:{len:$}})=>G7.str`must NOT have more than ${$} items`,params:({params:{len:$}})=>G7._`{limit: ${$}}`},HK0={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:UK0,code($){let{parentSchema:Z,it:J}=$,{items:Y}=Z;if(!Array.isArray(Y)){(0,Q3.checkStrictMode)(J,'"additionalItems" is ignored when "items" is not an array of schemas');return}tS($,Y)}};function tS($,Z){let{gen:J,schema:Y,data:X,keyword:Q,it:G}=$;G.items=!0;let W=J.const("len",G7._`${X}.length`);if(Y===!1)$.setParams({len:Z.length}),$.pass(G7._`${W} <= ${Z.length}`);else if(typeof Y=="object"&&!(0,Q3.alwaysValidSchema)(G,Y)){let V=J.var("valid",G7._`${W} <= ${Z.length}`);J.if((0,G7.not)(V),()=>K(V)),$.ok(V)}function K(V){J.forRange("i",Z.length,W,(U)=>{if($.subschema({keyword:Q,dataProp:U,dataPropType:Q3.Type.Num},V),!G.allErrors)J.if((0,G7.not)(V),()=>J.break())})}}eS.validateAdditionalItems=tS;eS.default=HK0});var W3=S((Yf)=>{Object.defineProperty(Yf,"__esModule",{value:!0});Yf.validateTuple=void 0;var Zf=k0(),JW=J1(),zK0=f$(),FK0={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code($){let{schema:Z,it:J}=$;if(Array.isArray(Z))return Jf($,"additionalItems",Z);if(J.items=!0,(0,JW.alwaysValidSchema)(J,Z))return;$.ok((0,zK0.validateArray)($))}};function Jf($,Z,J=$.schema){let{gen:Y,parentSchema:X,data:Q,keyword:G,it:W}=$;if(U(X),W.opts.unevaluated&&J.length&&W.items!==!0)W.items=JW.mergeEvaluated.items(Y,J.length,W.items);let K=Y.name("valid"),V=Y.const("len",Zf._`${Q}.length`);J.forEach((H,B)=>{if((0,JW.alwaysValidSchema)(W,H))return;Y.if(Zf._`${V} > ${B}`,()=>$.subschema({keyword:G,schemaProp:B,dataProp:B},K)),$.ok(K)});function U(H){let{opts:B,errSchemaPath:z}=W,F=J.length,A=F===H.minItems&&(F===H.maxItems||H[Z]===!1);if(B.strictTuples&&!A){let N=`"${G}" is ${F}-tuple, but minItems or maxItems/${Z} are not specified or different at path "${z}"`;(0,JW.checkStrictMode)(W,N,B.strictTuples)}}}Yf.validateTuple=Jf;Yf.default=FK0});var Gf=S((Qf)=>{Object.defineProperty(Qf,"__esModule",{value:!0});var OK0=W3(),jK0={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:($)=>(0,OK0.validateTuple)($,"items")};Qf.default=jK0});var Vf=S((Kf)=>{Object.defineProperty(Kf,"__esModule",{value:!0});var Wf=k0(),qK0=J1(),MK0=f$(),DK0=G3(),wK0={message:({params:{len:$}})=>Wf.str`must NOT have more than ${$} items`,params:({params:{len:$}})=>Wf._`{limit: ${$}}`},LK0={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:wK0,code($){let{schema:Z,parentSchema:J,it:Y}=$,{prefixItems:X}=J;if(Y.items=!0,(0,qK0.alwaysValidSchema)(Y,Z))return;if(X)(0,DK0.validateAdditionalItems)($,X);else $.ok((0,MK0.validateArray)($))}};Kf.default=LK0});var Hf=S((Uf)=>{Object.defineProperty(Uf,"__esModule",{value:!0});var u8=k0(),YW=J1(),RK0={message:({params:{min:$,max:Z}})=>Z===void 0?u8.str`must contain at least ${$} valid item(s)`:u8.str`must contain at least ${$} and no more than ${Z} valid item(s)`,params:({params:{min:$,max:Z}})=>Z===void 0?u8._`{minContains: ${$}}`:u8._`{minContains: ${$}, maxContains: ${Z}}`},PK0={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:RK0,code($){let{gen:Z,schema:J,parentSchema:Y,data:X,it:Q}=$,G,W,{minContains:K,maxContains:V}=Y;if(Q.opts.next)G=K===void 0?1:K,W=V;else G=1;let U=Z.const("len",u8._`${X}.length`);if($.setParams({min:G,max:W}),W===void 0&&G===0){(0,YW.checkStrictMode)(Q,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(W!==void 0&&G>W){(0,YW.checkStrictMode)(Q,'"minContains" > "maxContains" is always invalid'),$.fail();return}if((0,YW.alwaysValidSchema)(Q,J)){let A=u8._`${U} >= ${G}`;if(W!==void 0)A=u8._`${A} && ${U} <= ${W}`;$.pass(A);return}Q.items=!0;let H=Z.name("valid");if(W===void 0&&G===1)z(H,()=>Z.if(H,()=>Z.break()));else if(G===0){if(Z.let(H,!0),W!==void 0)Z.if(u8._`${X}.length > 0`,B)}else Z.let(H,!1),B();$.result(H,()=>$.reset());function B(){let A=Z.name("_valid"),N=Z.let("count",0);z(A,()=>Z.if(A,()=>F(N)))}function z(A,N){Z.forRange("i",0,U,(q)=>{$.subschema({keyword:"contains",dataProp:q,dataPropType:YW.Type.Num,compositeRule:!0},A),N()})}function F(A){if(Z.code(u8._`${A}++`),W===void 0)Z.if(u8._`${A} >= ${G}`,()=>Z.assign(H,!0).break());else if(Z.if(u8._`${A} > ${W}`,()=>Z.assign(H,!1).break()),G===1)Z.assign(H,!0);else Z.if(u8._`${A} >= ${G}`,()=>Z.assign(H,!0))}}};Uf.default=PK0});var jf=S((Ff)=>{Object.defineProperty(Ff,"__esModule",{value:!0});Ff.validateSchemaDeps=Ff.validatePropertyDeps=Ff.error=void 0;var K3=k0(),IK0=J1(),z9=f$();Ff.error={message:({params:{property:$,depsCount:Z,deps:J}})=>{let Y=Z===1?"property":"properties";return K3.str`must have ${Y} ${J} when property ${$} is present`},params:({params:{property:$,depsCount:Z,deps:J,missingProperty:Y}})=>K3._`{property: ${$},
|
|
116
|
+
missingProperty: ${Y},
|
|
117
|
+
depsCount: ${Z},
|
|
118
|
+
deps: ${J}}`};var EK0={keyword:"dependencies",type:"object",schemaType:"object",error:Ff.error,code($){let[Z,J]=bK0($);Bf($,Z),zf($,J)}};function bK0({schema:$}){let Z={},J={};for(let Y in $){if(Y==="__proto__")continue;let X=Array.isArray($[Y])?Z:J;X[Y]=$[Y]}return[Z,J]}function Bf($,Z=$.schema){let{gen:J,data:Y,it:X}=$;if(Object.keys(Z).length===0)return;let Q=J.let("missing");for(let G in Z){let W=Z[G];if(W.length===0)continue;let K=(0,z9.propertyInData)(J,Y,G,X.opts.ownProperties);if($.setParams({property:G,depsCount:W.length,deps:W.join(", ")}),X.allErrors)J.if(K,()=>{for(let V of W)(0,z9.checkReportMissingProp)($,V)});else J.if(K3._`${K} && (${(0,z9.checkMissingProp)($,W,Q)})`),(0,z9.reportMissingProp)($,Q),J.else()}}Ff.validatePropertyDeps=Bf;function zf($,Z=$.schema){let{gen:J,data:Y,keyword:X,it:Q}=$,G=J.name("valid");for(let W in Z){if((0,IK0.alwaysValidSchema)(Q,Z[W]))continue;J.if((0,z9.propertyInData)(J,Y,W,Q.opts.ownProperties),()=>{let K=$.subschema({keyword:X,schemaProp:W},G);$.mergeValidEvaluated(K,G)},()=>J.var(G,!0)),$.ok(G)}}Ff.validateSchemaDeps=zf;Ff.default=EK0});var Mf=S((qf)=>{Object.defineProperty(qf,"__esModule",{value:!0});var Nf=k0(),fK0=J1(),kK0={message:"property name must be valid",params:({params:$})=>Nf._`{propertyName: ${$.propertyName}}`},vK0={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:kK0,code($){let{gen:Z,schema:J,data:Y,it:X}=$;if((0,fK0.alwaysValidSchema)(X,J))return;let Q=Z.name("valid");Z.forIn("key",Y,(G)=>{$.setParams({propertyName:G}),$.subschema({keyword:"propertyNames",data:G,dataTypes:["string"],propertyName:G,compositeRule:!0},Q),Z.if((0,Nf.not)(Q),()=>{if($.error(!0),!X.allErrors)Z.break()})}),$.ok(Q)}};qf.default=vK0});var V3=S((Df)=>{Object.defineProperty(Df,"__esModule",{value:!0});var XW=f$(),Q6=k0(),xK0=g8(),QW=J1(),hK0={message:"must NOT have additional properties",params:({params:$})=>Q6._`{additionalProperty: ${$.additionalProperty}}`},gK0={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:hK0,code($){let{gen:Z,schema:J,parentSchema:Y,data:X,errsCount:Q,it:G}=$;if(!Q)throw Error("ajv implementation error");let{allErrors:W,opts:K}=G;if(G.props=!0,K.removeAdditional!=="all"&&(0,QW.alwaysValidSchema)(G,J))return;let V=(0,XW.allSchemaProperties)(Y.properties),U=(0,XW.allSchemaProperties)(Y.patternProperties);H(),$.ok(Q6._`${Q} === ${xK0.default.errors}`);function H(){Z.forIn("key",X,(N)=>{if(!V.length&&!U.length)F(N);else Z.if(B(N),()=>F(N))})}function B(N){let q;if(V.length>8){let w=(0,QW.schemaRefOrVal)(G,Y.properties,"properties");q=(0,XW.isOwnProperty)(Z,w,N)}else if(V.length)q=(0,Q6.or)(...V.map((w)=>Q6._`${N} === ${w}`));else q=Q6.nil;if(U.length)q=(0,Q6.or)(q,...U.map((w)=>Q6._`${(0,XW.usePattern)($,w)}.test(${N})`));return(0,Q6.not)(q)}function z(N){Z.code(Q6._`delete ${X}[${N}]`)}function F(N){if(K.removeAdditional==="all"||K.removeAdditional&&J===!1){z(N);return}if(J===!1){if($.setParams({additionalProperty:N}),$.error(),!W)Z.break();return}if(typeof J=="object"&&!(0,QW.alwaysValidSchema)(G,J)){let q=Z.name("valid");if(K.removeAdditional==="failing")A(N,q,!1),Z.if((0,Q6.not)(q),()=>{$.reset(),z(N)});else if(A(N,q),!W)Z.if((0,Q6.not)(q),()=>Z.break())}}function A(N,q,w){let j={keyword:"additionalProperties",dataProp:N,dataPropType:QW.Type.Str};if(w===!1)Object.assign(j,{compositeRule:!0,createErrors:!1,allErrors:!1});$.subschema(j,q)}}};Df.default=gK0});var Rf=S((Tf)=>{Object.defineProperty(Tf,"__esModule",{value:!0});var mK0=lJ(),wf=f$(),U3=J1(),Lf=V3(),lK0={keyword:"properties",type:"object",schemaType:"object",code($){let{gen:Z,schema:J,parentSchema:Y,data:X,it:Q}=$;if(Q.opts.removeAdditional==="all"&&Y.additionalProperties===void 0)Lf.default.code(new mK0.KeywordCxt(Q,Lf.default,"additionalProperties"));let G=(0,wf.allSchemaProperties)(J);for(let H of G)Q.definedProperties.add(H);if(Q.opts.unevaluated&&G.length&&Q.props!==!0)Q.props=U3.mergeEvaluated.props(Z,(0,U3.toHash)(G),Q.props);let W=G.filter((H)=>!(0,U3.alwaysValidSchema)(Q,J[H]));if(W.length===0)return;let K=Z.name("valid");for(let H of W){if(V(H))U(H);else{if(Z.if((0,wf.propertyInData)(Z,X,H,Q.opts.ownProperties)),U(H),!Q.allErrors)Z.else().var(K,!0);Z.endIf()}$.it.definedProperties.add(H),$.ok(K)}function V(H){return Q.opts.useDefaults&&!Q.compositeRule&&J[H].default!==void 0}function U(H){$.subschema({keyword:"properties",schemaProp:H,dataProp:H},K)}}};Tf.default=lK0});var bf=S((Ef)=>{Object.defineProperty(Ef,"__esModule",{value:!0});var Pf=f$(),GW=k0(),Cf=J1(),If=J1(),pK0={keyword:"patternProperties",type:"object",schemaType:"object",code($){let{gen:Z,schema:J,data:Y,parentSchema:X,it:Q}=$,{opts:G}=Q,W=(0,Pf.allSchemaProperties)(J),K=W.filter((A)=>(0,Cf.alwaysValidSchema)(Q,J[A]));if(W.length===0||K.length===W.length&&(!Q.opts.unevaluated||Q.props===!0))return;let V=G.strictSchema&&!G.allowMatchingProperties&&X.properties,U=Z.name("valid");if(Q.props!==!0&&!(Q.props instanceof GW.Name))Q.props=(0,If.evaluatedPropsToName)(Z,Q.props);let{props:H}=Q;B();function B(){for(let A of W){if(V)z(A);if(Q.allErrors)F(A);else Z.var(U,!0),F(A),Z.if(U)}}function z(A){for(let N in V)if(new RegExp(A).test(N))(0,Cf.checkStrictMode)(Q,`property ${N} matches pattern ${A} (use allowMatchingProperties)`)}function F(A){Z.forIn("key",Y,(N)=>{Z.if(GW._`${(0,Pf.usePattern)($,A)}.test(${N})`,()=>{let q=K.includes(A);if(!q)$.subschema({keyword:"patternProperties",schemaProp:A,dataProp:N,dataPropType:If.Type.Str},U);if(Q.opts.unevaluated&&H!==!0)Z.assign(GW._`${H}[${N}]`,!0);else if(!q&&!Q.allErrors)Z.if((0,GW.not)(U),()=>Z.break())})})}}};Ef.default=pK0});var Sf=S((_f)=>{Object.defineProperty(_f,"__esModule",{value:!0});var iK0=J1(),nK0={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code($){let{gen:Z,schema:J,it:Y}=$;if((0,iK0.alwaysValidSchema)(Y,J)){$.fail();return}let X=Z.name("valid");$.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},X),$.failResult(X,()=>$.reset(),()=>$.error())},error:{message:"must NOT be valid"}};_f.default=nK0});var kf=S((ff)=>{Object.defineProperty(ff,"__esModule",{value:!0});var sK0=f$(),rK0={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:sK0.validateUnion,error:{message:"must match a schema in anyOf"}};ff.default=rK0});var yf=S((vf)=>{Object.defineProperty(vf,"__esModule",{value:!0});var WW=k0(),tK0=J1(),eK0={message:"must match exactly one schema in oneOf",params:({params:$})=>WW._`{passingSchemas: ${$.passing}}`},$V0={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:eK0,code($){let{gen:Z,schema:J,parentSchema:Y,it:X}=$;if(!Array.isArray(J))throw Error("ajv implementation error");if(X.opts.discriminator&&Y.discriminator)return;let Q=J,G=Z.let("valid",!1),W=Z.let("passing",null),K=Z.name("_valid");$.setParams({passing:W}),Z.block(V),$.result(G,()=>$.reset(),()=>$.error(!0));function V(){Q.forEach((U,H)=>{let B;if((0,tK0.alwaysValidSchema)(X,U))Z.var(K,!0);else B=$.subschema({keyword:"oneOf",schemaProp:H,compositeRule:!0},K);if(H>0)Z.if(WW._`${K} && ${G}`).assign(G,!1).assign(W,WW._`[${W}, ${H}]`).else();Z.if(K,()=>{if(Z.assign(G,!0),Z.assign(W,H),B)$.mergeEvaluated(B,WW.Name)})})}}};vf.default=$V0});var hf=S((xf)=>{Object.defineProperty(xf,"__esModule",{value:!0});var JV0=J1(),YV0={keyword:"allOf",schemaType:"array",code($){let{gen:Z,schema:J,it:Y}=$;if(!Array.isArray(J))throw Error("ajv implementation error");let X=Z.name("valid");J.forEach((Q,G)=>{if((0,JV0.alwaysValidSchema)(Y,Q))return;let W=$.subschema({keyword:"allOf",schemaProp:G},X);$.ok(X),$.mergeEvaluated(W)})}};xf.default=YV0});var lf=S((mf)=>{Object.defineProperty(mf,"__esModule",{value:!0});var KW=k0(),uf=J1(),QV0={message:({params:$})=>KW.str`must match "${$.ifClause}" schema`,params:({params:$})=>KW._`{failingKeyword: ${$.ifClause}}`},GV0={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:QV0,code($){let{gen:Z,parentSchema:J,it:Y}=$;if(J.then===void 0&&J.else===void 0)(0,uf.checkStrictMode)(Y,'"if" without "then" and "else" is ignored');let X=gf(Y,"then"),Q=gf(Y,"else");if(!X&&!Q)return;let G=Z.let("valid",!0),W=Z.name("_valid");if(K(),$.reset(),X&&Q){let U=Z.let("ifClause");$.setParams({ifClause:U}),Z.if(W,V("then",U),V("else",U))}else if(X)Z.if(W,V("then"));else Z.if((0,KW.not)(W),V("else"));$.pass(G,()=>$.error(!0));function K(){let U=$.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},W);$.mergeEvaluated(U)}function V(U,H){return()=>{let B=$.subschema({keyword:U},W);if(Z.assign(G,W),$.mergeValidEvaluated(B,G),H)Z.assign(H,KW._`${U}`);else $.setParams({ifClause:U})}}}};function gf($,Z){let J=$.schema[Z];return J!==void 0&&!(0,uf.alwaysValidSchema)($,J)}mf.default=GV0});var pf=S((df)=>{Object.defineProperty(df,"__esModule",{value:!0});var KV0=J1(),VV0={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:$,parentSchema:Z,it:J}){if(Z.if===void 0)(0,KV0.checkStrictMode)(J,`"${$}" without "if" is ignored`)}};df.default=VV0});var nf=S((cf)=>{Object.defineProperty(cf,"__esModule",{value:!0});var HV0=G3(),BV0=Gf(),zV0=W3(),FV0=Vf(),AV0=Hf(),OV0=jf(),jV0=Mf(),NV0=V3(),qV0=Rf(),MV0=bf(),DV0=Sf(),wV0=kf(),LV0=yf(),TV0=hf(),RV0=lf(),PV0=pf();function CV0($=!1){let Z=[DV0.default,wV0.default,LV0.default,TV0.default,RV0.default,PV0.default,jV0.default,NV0.default,OV0.default,qV0.default,MV0.default];if($)Z.push(BV0.default,FV0.default);else Z.push(HV0.default,zV0.default);return Z.push(AV0.default),Z}cf.default=CV0});var sf=S((of)=>{Object.defineProperty(of,"__esModule",{value:!0});var K$=k0(),EV0={message:({schemaCode:$})=>K$.str`must match format "${$}"`,params:({schemaCode:$})=>K$._`{format: ${$}}`},bV0={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:EV0,code($,Z){let{gen:J,data:Y,$data:X,schema:Q,schemaCode:G,it:W}=$,{opts:K,errSchemaPath:V,schemaEnv:U,self:H}=W;if(!K.validateFormats)return;if(X)B();else z();function B(){let F=J.scopeValue("formats",{ref:H.formats,code:K.code.formats}),A=J.const("fDef",K$._`${F}[${G}]`),N=J.let("fType"),q=J.let("format");J.if(K$._`typeof ${A} == "object" && !(${A} instanceof RegExp)`,()=>J.assign(N,K$._`${A}.type || "string"`).assign(q,K$._`${A}.validate`),()=>J.assign(N,K$._`"string"`).assign(q,A)),$.fail$data((0,K$.or)(w(),j()));function w(){if(K.strictSchema===!1)return K$.nil;return K$._`${G} && !${q}`}function j(){let M=U.$async?K$._`(${A}.async ? await ${q}(${Y}) : ${q}(${Y}))`:K$._`${q}(${Y})`,I=K$._`(typeof ${q} == "function" ? ${M} : ${q}.test(${Y}))`;return K$._`${q} && ${q} !== true && ${N} === ${Z} && !${I}`}}function z(){let F=H.formats[Q];if(!F){w();return}if(F===!0)return;let[A,N,q]=j(F);if(A===Z)$.pass(M());function w(){if(K.strictSchema===!1){H.logger.warn(I());return}throw Error(I());function I(){return`unknown format "${Q}" ignored in schema at path "${V}"`}}function j(I){let R=I instanceof RegExp?(0,K$.regexpCode)(I):K.code.formats?K$._`${K.code.formats}${(0,K$.getProperty)(Q)}`:void 0,L=J.scopeValue("formats",{key:Q,ref:I,code:R});if(typeof I=="object"&&!(I instanceof RegExp))return[I.type||"string",I.validate,K$._`${L}.validate`];return["string",I,L]}function M(){if(typeof F=="object"&&!(F instanceof RegExp)&&F.async){if(!U.$async)throw Error("async format in sync schema");return K$._`await ${q}(${Y})`}return typeof N=="function"?K$._`${q}(${Y})`:K$._`${q}.test(${Y})`}}}};of.default=bV0});var af=S((rf)=>{Object.defineProperty(rf,"__esModule",{value:!0});var SV0=sf(),fV0=[SV0.default];rf.default=fV0});var $k=S((tf)=>{Object.defineProperty(tf,"__esModule",{value:!0});tf.contentVocabulary=tf.metadataVocabulary=void 0;tf.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];tf.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Yk=S((Jk)=>{Object.defineProperty(Jk,"__esModule",{value:!0});var yV0=TS(),xV0=aS(),hV0=nf(),gV0=af(),Zk=$k(),uV0=[yV0.default,xV0.default,(0,hV0.default)(),gV0.default,Zk.metadataVocabulary,Zk.contentVocabulary];Jk.default=uV0});var H3=S((Qk)=>{Object.defineProperty(Qk,"__esModule",{value:!0});Qk.DiscrError=void 0;var Xk;(function($){$.Tag="tag",$.Mapping="mapping"})(Xk||(Qk.DiscrError=Xk={}))});var Vk=S((Kk)=>{Object.defineProperty(Kk,"__esModule",{value:!0});var nJ=k0(),B3=H3(),Wk=Y7(),lV0=YZ(),dV0=J1(),pV0={message:({params:{discrError:$,tagName:Z}})=>$===B3.DiscrError.Tag?`tag "${Z}" must be string`:`value of tag "${Z}" must be in oneOf`,params:({params:{discrError:$,tag:Z,tagName:J}})=>nJ._`{error: ${$}, tag: ${J}, tagValue: ${Z}}`},cV0={keyword:"discriminator",type:"object",schemaType:"object",error:pV0,code($){let{gen:Z,data:J,schema:Y,parentSchema:X,it:Q}=$,{oneOf:G}=X;if(!Q.opts.discriminator)throw Error("discriminator: requires discriminator option");let W=Y.propertyName;if(typeof W!="string")throw Error("discriminator: requires propertyName");if(Y.mapping)throw Error("discriminator: mapping is not supported");if(!G)throw Error("discriminator: requires oneOf keyword");let K=Z.let("valid",!1),V=Z.const("tag",nJ._`${J}${(0,nJ.getProperty)(W)}`);Z.if(nJ._`typeof ${V} == "string"`,()=>U(),()=>$.error(!1,{discrError:B3.DiscrError.Tag,tag:V,tagName:W})),$.ok(K);function U(){let z=B();Z.if(!1);for(let F in z)Z.elseIf(nJ._`${V} === ${F}`),Z.assign(K,H(z[F]));Z.else(),$.error(!1,{discrError:B3.DiscrError.Mapping,tag:V,tagName:W}),Z.endIf()}function H(z){let F=Z.name("valid"),A=$.subschema({keyword:"oneOf",schemaProp:z},F);return $.mergeEvaluated(A,nJ.Name),F}function B(){var z;let F={},A=q(X),N=!0;for(let M=0;M<G.length;M++){let I=G[M];if((I===null||I===void 0?void 0:I.$ref)&&!(0,dV0.schemaHasRulesButRef)(I,Q.self.RULES)){let L=I.$ref;if(I=Wk.resolveRef.call(Q.self,Q.schemaEnv.root,Q.baseId,L),I instanceof Wk.SchemaEnv)I=I.schema;if(I===void 0)throw new lV0.default(Q.opts.uriResolver,Q.baseId,L)}let R=(z=I===null||I===void 0?void 0:I.properties)===null||z===void 0?void 0:z[W];if(typeof R!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${W}"`);N=N&&(A||q(I)),w(R,M)}if(!N)throw Error(`discriminator: "${W}" must be required`);return F;function q({required:M}){return Array.isArray(M)&&M.includes(W)}function w(M,I){if(M.const)j(M.const,I);else if(M.enum)for(let R of M.enum)j(R,I);else throw Error(`discriminator: "properties/${W}" must have "const" or "enum"`)}function j(M,I){if(typeof M!="string"||M in F)throw Error(`discriminator: "${W}" values must be unique strings`);F[M]=I}}}};Kk.default=cV0});var Uk=S((zy0,nV0)=>{nV0.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var UW=S((B8,z3)=>{Object.defineProperty(B8,"__esModule",{value:!0});B8.MissingRefError=B8.ValidationError=B8.CodeGen=B8.Name=B8.nil=B8.stringify=B8.str=B8._=B8.KeywordCxt=B8.Ajv=void 0;var oV0=Z3(),sV0=Yk(),rV0=Vk(),Hk=Uk(),aV0=["/properties"],VW="http://json-schema.org/draft-07/schema";class F9 extends oV0.default{_addVocabularies(){if(super._addVocabularies(),sV0.default.forEach(($)=>this.addVocabulary($)),this.opts.discriminator)this.addKeyword(rV0.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let $=this.opts.$data?this.$dataMetaSchema(Hk,aV0):Hk;this.addMetaSchema($,VW,!1),this.refs["http://json-schema.org/schema"]=VW}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(VW)?VW:void 0)}}B8.Ajv=F9;z3.exports=B8=F9;z3.exports.Ajv=F9;Object.defineProperty(B8,"__esModule",{value:!0});B8.default=F9;var tV0=lJ();Object.defineProperty(B8,"KeywordCxt",{enumerable:!0,get:function(){return tV0.KeywordCxt}});var oJ=k0();Object.defineProperty(B8,"_",{enumerable:!0,get:function(){return oJ._}});Object.defineProperty(B8,"str",{enumerable:!0,get:function(){return oJ.str}});Object.defineProperty(B8,"stringify",{enumerable:!0,get:function(){return oJ.stringify}});Object.defineProperty(B8,"nil",{enumerable:!0,get:function(){return oJ.nil}});Object.defineProperty(B8,"Name",{enumerable:!0,get:function(){return oJ.Name}});Object.defineProperty(B8,"CodeGen",{enumerable:!0,get:function(){return oJ.CodeGen}});var eV0=Z9();Object.defineProperty(B8,"ValidationError",{enumerable:!0,get:function(){return eV0.default}});var $U0=YZ();Object.defineProperty(B8,"MissingRefError",{enumerable:!0,get:function(){return $U0.default}})});var QZ=S((zk)=>{Object.defineProperty(zk,"__esModule",{value:!0});zk.checkMetadata=void 0;var YU0=J1(),XU0={keyword:"metadata",schemaType:"object",code($){Bk($);let{gen:Z,schema:J,it:Y}=$;if((0,YU0.alwaysValidSchema)(Y,J))return;let X=Z.name("valid");$.subschema({keyword:"metadata",jtdMetadata:!0},X),$.ok(X)}};function Bk({it:$,keyword:Z},J){if($.jtdMetadata!==J)throw Error(`JTD: "${Z}" cannot be used in this schema location`)}zk.checkMetadata=Bk;zk.default=XU0});var HW=S((Nk)=>{Object.defineProperty(Nk,"__esModule",{value:!0});Nk.hasRef=void 0;var Ak=Y7(),A9=k0(),GU0=YZ(),Ok=g8(),jk=J3(),WU0=QZ(),KU0={keyword:"ref",schemaType:"string",code($){(0,WU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,parentSchema:X,it:Q}=$,{schemaEnv:{root:G}}=Q,W=Z.name("valid");if(X.nullable)Z.var(W,A9._`${J} === null`),Z.if((0,A9.not)(W),K);else Z.var(W,!1),K();$.ok(W);function K(){var H;let B=(H=G.schema.definitions)===null||H===void 0?void 0:H[Y];if(!B)throw new GU0.default(Q.opts.uriResolver,"",Y,`No definition ${Y}`);if(F3(B)||!Q.opts.inlineRefs)V(B);else U(B)}function V(H){let B=Ak.compileSchema.call(Q.self,new Ak.SchemaEnv({schema:H,root:G,schemaPath:`/definitions/${Y}`})),z=(0,jk.getValidate)($,B),F=Z.const("_errs",Ok.default.errors);(0,jk.callRef)($,z,B,B.$async),Z.assign(W,A9._`${F} === ${Ok.default.errors}`)}function U(H){let B=Z.scopeValue("schema",Q.opts.code.source===!0?{ref:H,code:(0,A9.stringify)(H)}:{ref:H});$.subschema({schema:H,dataTypes:[],schemaPath:A9.nil,topSchemaRef:B,errSchemaPath:`/definitions/${Y}`},W)}}};function F3($){for(let Z in $){let J;if(Z==="ref"||typeof(J=$[Z])=="object"&&F3(J))return!0}return!1}Nk.hasRef=F3;Nk.default=KU0});var A3=S((wk)=>{Object.defineProperty(wk,"__esModule",{value:!0});var UU0=/t|\s/i,HU0=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,BU0=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:z|([+-]\d\d)(?::?(\d\d))?)$/i,zU0=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Dk($,Z){let J=$.split(UU0);return J.length===2&&Mk(J[0])&&FU0(J[1])||Z&&J.length===1&&Mk(J[0])}wk.default=Dk;function Mk($){let Z=HU0.exec($);if(!Z)return!1;let J=+Z[1],Y=+Z[2],X=+Z[3];return Y>=1&&Y<=12&&X>=1&&(X<=zU0[Y]||Y===2&&X===29&&(J%100===0?J%400===0:J%4===0))}function FU0($){let Z=BU0.exec($);if(!Z)return!1;let J=+Z[1],Y=+Z[2],X=+Z[3],Q=+(Z[4]||0),G=+(Z[5]||0);return J<=23&&Y<=59&&X<=59||J-Q===23&&Y-G===59&&X===60}Dk.code='require("ajv/dist/runtime/timestamp").default'});var sJ=S((Rk)=>{Object.defineProperty(Rk,"__esModule",{value:!0});Rk.typeErrorParams=Rk.typeErrorMessage=Rk.typeError=void 0;var OU0=k0();function jU0($){return{message:(Z)=>Lk(Z,$),params:(Z)=>Tk(Z,$)}}Rk.typeError=jU0;function Lk({parentSchema:$},Z){return($===null||$===void 0?void 0:$.nullable)?`must be ${Z} or null`:`must be ${Z}`}Rk.typeErrorMessage=Lk;function Tk({parentSchema:$},Z){return OU0._`{type: ${Z}, nullable: ${!!($===null||$===void 0?void 0:$.nullable)}}`}Rk.typeErrorParams=Tk});var j3=S((Ik)=>{Object.defineProperty(Ik,"__esModule",{value:!0});Ik.intRange=void 0;var b8=k0(),MU0=A3(),DU0=J1(),wU0=QZ(),Ck=sJ();Ik.intRange={int8:[-128,127,3],uint8:[0,255,3],int16:[-32768,32767,5],uint16:[0,65535,5],int32:[-2147483648,2147483647,10],uint32:[0,4294967295,10]};var LU0={message:($)=>(0,Ck.typeErrorMessage)($,$.schema),params:($)=>(0,Ck.typeErrorParams)($,$.schema)};function TU0($){let{gen:Z,data:J,it:Y}=$,{timestamp:X,allowDate:Q}=Y.opts;if(X==="date")return b8._`${J} instanceof Date `;let G=(0,DU0.useFunc)(Z,MU0.default),W=Q?b8._`, true`:b8.nil,K=b8._`typeof ${J} == "string" && ${G}(${J}${W})`;return X==="string"?K:(0,b8.or)(b8._`${J} instanceof Date`,K)}var RU0={keyword:"type",schemaType:"string",error:LU0,code($){(0,wU0.checkMetadata)($);let{data:Z,schema:J,parentSchema:Y,it:X}=$,Q;switch(J){case"boolean":case"string":Q=b8._`typeof ${Z} == ${J}`;break;case"timestamp":{Q=TU0($);break}case"float32":case"float64":Q=b8._`typeof ${Z} == "number"`;break;default:{let G=J;if(Q=b8._`typeof ${Z} == "number" && isFinite(${Z}) && !(${Z} % 1)`,!X.opts.int32range&&(G==="int32"||G==="uint32")){if(G==="uint32")Q=b8._`${Q} && ${Z} >= 0`}else{let[W,K]=Ik.intRange[G];Q=b8._`${Q} && ${Z} >= ${W} && ${Z} <= ${K}`}}}$.pass(Y.nullable?(0,b8.or)(b8._`${Z} === null`,Q):Q)}};Ik.default=RU0});var rJ=S((bk)=>{Object.defineProperty(bk,"__esModule",{value:!0});bk.checkNullableObject=bk.checkNullable=void 0;var BW=k0();function Ek({gen:$,data:Z,parentSchema:J},Y=BW.nil){let X=$.name("valid");if(J.nullable)$.let(X,BW._`${Z} === null`),Y=(0,BW.not)(X);else $.let(X,!1);return[X,Y]}bk.checkNullable=Ek;function CU0($,Z){let[J,Y]=Ek($,Z);return[J,BW._`${Y} && typeof ${$.data} == "object" && !Array.isArray(${$.data})`]}bk.checkNullableObject=CU0});var fk=S((Sk)=>{Object.defineProperty(Sk,"__esModule",{value:!0});var tZ=k0(),EU0=QZ(),bU0=rJ(),_U0={message:"must be equal to one of the allowed values",params:({schemaCode:$})=>tZ._`{allowedValues: ${$}}`},SU0={keyword:"enum",schemaType:"array",error:_U0,code($){(0,EU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,schemaValue:X,parentSchema:Q,it:G}=$;if(Y.length===0)throw Error("enum must have non-empty array");if(Y.length!==new Set(Y).size)throw Error("enum items must be unique");let W,K=tZ._`typeof ${J} == "string"`;if(Y.length>=G.opts.loopEnum){let U;[W,U]=(0,bU0.checkNullable)($,K),Z.if(U,V)}else{if(!Array.isArray(Y))throw Error("ajv implementation error");if(W=(0,tZ.and)(K,(0,tZ.or)(...Y.map((U)=>tZ._`${J} === ${U}`))),Q.nullable)W=(0,tZ.or)(tZ._`${J} === null`,W)}$.pass(W);function V(){Z.forOf("v",X,(U)=>Z.if(tZ._`${W} = ${J} === ${U}`,()=>Z.break()))}}};Sk.default=SU0});var yk=S((vk)=>{Object.defineProperty(vk,"__esModule",{value:!0});var kU0=J1(),vU0=f$(),kk=k0(),yU0=QZ(),xU0=rJ(),hU0=sJ(),gU0={keyword:"elements",schemaType:"object",error:(0,hU0.typeError)("array"),code($){(0,yU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,it:X}=$;if((0,kU0.alwaysValidSchema)(X,Y))return;let[Q]=(0,xU0.checkNullable)($);Z.if((0,kk.not)(Q),()=>Z.if(kk._`Array.isArray(${J})`,()=>Z.assign(Q,(0,vU0.validateArray)($)),()=>$.error())),$.ok(Q)}};vk.default=gU0});var q3=S((uk)=>{Object.defineProperty(uk,"__esModule",{value:!0});uk.validateProperties=uk.error=void 0;var N3=f$(),xk=J1(),GZ=k0(),mU0=QZ(),lU0=rJ(),hk=sJ(),aJ;(function($){$.Additional="additional",$.Missing="missing"})(aJ||(aJ={}));uk.error={message:($)=>{let{params:Z}=$;return Z.propError?Z.propError===aJ.Additional?"must NOT have additional properties":`must have property '${Z.missingProperty}'`:(0,hk.typeErrorMessage)($,"object")},params:($)=>{let{params:Z}=$;return Z.propError?Z.propError===aJ.Additional?GZ._`{error: ${Z.propError}, additionalProperty: ${Z.additionalProperty}}`:GZ._`{error: ${Z.propError}, missingProperty: ${Z.missingProperty}}`:(0,hk.typeErrorParams)($,"object")}};var dU0={keyword:"properties",schemaType:"object",error:uk.error,code:gk};function gk($){(0,mU0.checkMetadata)($);let{gen:Z,data:J,parentSchema:Y,it:X}=$,{additionalProperties:Q,nullable:G}=Y;if(X.jtdDiscriminator&&G)throw Error("JTD: nullable inside discriminator mapping");if(z())throw Error("JTD: properties and optionalProperties have common members");let[W,K]=F("properties"),[V,U]=F("optionalProperties");if(K.length===0&&U.length===0&&Q)return;let[H,B]=X.jtdDiscriminator===void 0?(0,lU0.checkNullableObject)($,J):[Z.let("valid",!1),!0];Z.if(B,()=>Z.assign(H,!0).block(()=>{if(A(K,"properties",!0),A(U,"optionalProperties"),!Q)q()})),$.pass(H);function z(){let{properties:j,optionalProperties:M}=Y;if(!(j&&M))return!1;for(let I in j)if(Object.prototype.hasOwnProperty.call(M,I))return!0;return!1}function F(j){let M=Y[j],I=M?(0,N3.allSchemaProperties)(M):[];if(X.jtdDiscriminator&&I.some((L)=>L===X.jtdDiscriminator))throw Error(`JTD: discriminator tag used in ${j}`);let R=I.filter((L)=>!(0,xk.alwaysValidSchema)(X,M[L]));return[I,R]}function A(j,M,I){let R=Z.var("valid");for(let C of j)Z.if((0,N3.propertyInData)(Z,J,C,X.opts.ownProperties),()=>N(C,M,R),()=>L(C)),$.ok(R);function L(C){if(I)Z.assign(R,!1),$.error(!1,{propError:aJ.Missing,missingProperty:C},{schemaPath:C});else Z.assign(R,!0)}}function N(j,M,I){$.subschema({keyword:M,schemaProp:j,dataProp:j},I)}function q(){Z.forIn("key",J,(j)=>{let M=w(j,W,"properties",X.jtdDiscriminator),I=w(j,V,"optionalProperties"),R=M===!0?I:I===!0?M:(0,GZ.and)(M,I);Z.if(R,()=>{if(X.opts.removeAdditional)Z.code(GZ._`delete ${J}[${j}]`);else if($.error(!1,{propError:aJ.Additional,additionalProperty:j},{instancePath:j,parentSchema:!0}),!X.opts.allErrors)Z.break()})})}function w(j,M,I,R){let L;if(M.length>8){let C=(0,xk.schemaRefOrVal)(X,Y[I],I);if(L=(0,GZ.not)((0,N3.isOwnProperty)(Z,C,j)),R!==void 0)L=(0,GZ.and)(L,GZ._`${j} !== ${R}`)}else if(M.length||R!==void 0){let C=R===void 0?M:[R].concat(M);L=(0,GZ.and)(...C.map((_)=>GZ._`${j} !== ${_}`))}else L=!0;return L}}uk.validateProperties=gk;uk.default=dU0});var ck=S((pk)=>{Object.defineProperty(pk,"__esModule",{value:!0});var dk=q3(),cU0={keyword:"optionalProperties",schemaType:"object",error:dk.error,code($){if($.parentSchema.properties)return;(0,dk.validateProperties)($)}};pk.default=cU0});var ok=S((nk)=>{Object.defineProperty(nk,"__esModule",{value:!0});var W7=k0(),nU0=QZ(),oU0=rJ(),ik=sJ(),zW=H3(),sU0={message:($)=>{let{schema:Z,params:J}=$;return J.discrError?J.discrError===zW.DiscrError.Tag?`tag "${Z}" must be string`:`value of tag "${Z}" must be in mapping`:(0,ik.typeErrorMessage)($,"object")},params:($)=>{let{schema:Z,params:J}=$;return J.discrError?W7._`{error: ${J.discrError}, tag: ${Z}, tagValue: ${J.tag}}`:(0,ik.typeErrorParams)($,"object")}},rU0={keyword:"discriminator",schemaType:"string",implements:["mapping"],error:sU0,code($){(0,nU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,parentSchema:X}=$,[Q,G]=(0,oU0.checkNullableObject)($,J);Z.if(G),W(),Z.elseIf((0,W7.not)(Q)),$.error(),Z.endIf(),$.ok(Q);function W(){let U=Z.const("tag",W7._`${J}${(0,W7.getProperty)(Y)}`);Z.if(W7._`${U} === undefined`),$.error(!1,{discrError:zW.DiscrError.Tag,tag:U}),Z.elseIf(W7._`typeof ${U} == "string"`),K(U),Z.else(),$.error(!1,{discrError:zW.DiscrError.Tag,tag:U},{instancePath:Y}),Z.endIf()}function K(U){Z.if(!1);for(let H in X.mapping)Z.elseIf(W7._`${U} === ${H}`),Z.assign(Q,V(H));Z.else(),$.error(!1,{discrError:zW.DiscrError.Mapping,tag:U},{instancePath:Y,schemaPath:"mapping",parentSchema:!0}),Z.endIf()}function V(U){let H=Z.name("valid");return $.subschema({keyword:"mapping",schemaProp:U,jtdDiscriminator:Y},H),H}}};nk.default=rU0});var ak=S((rk)=>{Object.defineProperty(rk,"__esModule",{value:!0});var sk=J1(),FW=k0(),tU0=QZ(),eU0=rJ(),$H0=sJ(),ZH0={keyword:"values",schemaType:"object",error:(0,$H0.typeError)("object"),code($){(0,tU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,it:X}=$,[Q,G]=(0,eU0.checkNullableObject)($,J);if((0,sk.alwaysValidSchema)(X,Y))Z.if((0,FW.not)((0,FW.or)(G,Q)),()=>$.error());else Z.if(G),Z.assign(Q,W()),Z.elseIf((0,FW.not)(Q)),$.error(),Z.endIf();$.ok(Q);function W(){let K=Z.name("valid");if(X.allErrors){let U=Z.let("valid",!0);return V(()=>Z.assign(U,!1)),U}return Z.var(K,!0),V(()=>Z.break()),K;function V(U){Z.forIn("key",J,(H)=>{$.subschema({keyword:"values",dataProp:H,dataPropType:sk.Type.Str},K),Z.if((0,FW.not)(K),U)})}}}};rk.default=ZH0});var ek=S((tk)=>{Object.defineProperty(tk,"__esModule",{value:!0});var YH0=f$(),XH0={keyword:"union",schemaType:"array",trackErrors:!0,code:YH0.validateUnion,error:{message:"must match a schema in union"}};tk.default=XH0});var Zv=S(($v)=>{Object.defineProperty($v,"__esModule",{value:!0});var GH0=HW(),WH0=j3(),KH0=fk(),VH0=yk(),UH0=q3(),HH0=ck(),BH0=ok(),zH0=ak(),FH0=ek(),AH0=QZ(),OH0=["definitions",GH0.default,WH0.default,KH0.default,VH0.default,UH0.default,HH0.default,BH0.default,zH0.default,FH0.default,AH0.default,{keyword:"additionalProperties",schemaType:"boolean"},{keyword:"nullable",schemaType:"boolean"}];$v.default=OH0});var Gv=S((Qv)=>{Object.defineProperty(Qv,"__esModule",{value:!0});var WZ=($)=>{let Z={nullable:{type:"boolean"},metadata:{optionalProperties:{union:{elements:{ref:"schema"}}},additionalProperties:!0}};if($)Z.definitions={values:{ref:"schema"}};return Z},NH0=($)=>({optionalProperties:WZ($)}),qH0=($)=>({properties:{ref:{type:"string"}},optionalProperties:WZ($)}),MH0=($)=>({properties:{type:{enum:["boolean","timestamp","string","float32","float64","int8","uint8","int16","uint16","int32","uint32"]}},optionalProperties:WZ($)}),DH0=($)=>({properties:{enum:{elements:{type:"string"}}},optionalProperties:WZ($)}),wH0=($)=>({properties:{elements:{ref:"schema"}},optionalProperties:WZ($)}),Yv=($)=>({properties:{properties:{values:{ref:"schema"}}},optionalProperties:{optionalProperties:{values:{ref:"schema"}},additionalProperties:{type:"boolean"},...WZ($)}}),Xv=($)=>({properties:{optionalProperties:{values:{ref:"schema"}}},optionalProperties:{additionalProperties:{type:"boolean"},...WZ($)}}),LH0=($)=>({properties:{discriminator:{type:"string"},mapping:{values:{metadata:{union:[Yv(!1),Xv(!1)]}}}},optionalProperties:WZ($)}),TH0=($)=>({properties:{values:{ref:"schema"}},optionalProperties:WZ($)}),Jv=($)=>({metadata:{union:[NH0,qH0,MH0,DH0,wH0,Yv,Xv,LH0,TH0].map((Z)=>Z($))}}),RH0={definitions:{schema:Jv(!1)},...Jv(!0)};Qv.default=RH0});var M3=S((Wv)=>{Object.defineProperty(Wv,"__esModule",{value:!0});Wv.jtdForms=void 0;Wv.jtdForms=["elements","values","discriminator","properties","optionalProperties","enum","type","ref"]});var Hv=S((Uv)=>{Object.defineProperty(Uv,"__esModule",{value:!0});var D3=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,CH0={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':"\\\"","\\":"\\\\"};function Vv($){return D3.lastIndex=0,'"'+(D3.test($)?$.replace(D3,(Z)=>{let J=CH0[Z];return typeof J==="string"?J:"\\u"+("0000"+Z.charCodeAt(0).toString(16)).slice(-4)}):$)+'"'}Uv.default=Vv;Vv.code='require("ajv/dist/runtime/quote").default'});var Nv=S((jv)=>{Object.defineProperty(jv,"__esModule",{value:!0});var EH0=M3(),zv=Y7(),Q1=k0(),bH0=YZ(),y1=g8(),_H0=f$(),SH0=HW(),fH0=J1(),kH0=Hv(),vH0={elements:xH0,values:hH0,discriminator:gH0,properties:Bv,optionalProperties:Bv,enum:O9,type:uH0,ref:lH0};function Fv($,Z){let J=zv.getCompilingSchema.call(this,$);if(J)return J;let{es5:Y,lines:X}=this.opts.code,{ownProperties:Q}=this.opts,G=new Q1.CodeGen(this.scope,{es5:Y,lines:X,ownProperties:Q}),W=G.scopeName("serialize"),K={self:this,gen:G,schema:$.schema,schemaEnv:$,definitions:Z,data:y1.default.data},V;try{this._compilations.add($),$.serializeName=W,G.func(W,y1.default.data,!1,()=>{G.let(y1.default.json,Q1.str``),j9(K),G.return(y1.default.json)}),G.optimize(this.opts.code.optimize);let U=G.toString();V=`${G.scopeRefs(y1.default.scope)}return ${U}`;let B=Function(`${y1.default.scope}`,V)(this.scope.get());this.scope.value(W,{ref:B}),$.serialize=B}catch(U){if(V)this.logger.error("Error compiling serializer, function code:",V);throw delete $.serialize,delete $.serializeName,U}finally{this._compilations.delete($)}return $}jv.default=Fv;function j9($){let Z;for(let J of EH0.jtdForms)if(J in $.schema){Z=J;break}yH0($,Z?vH0[Z]:pH0)}function yH0($,Z){let{gen:J,schema:Y,data:X}=$;if(!Y.nullable)return Z($);J.if(Q1._`${X} === undefined || ${X} === null`,()=>J.add(y1.default.json,Q1._`"null"`),()=>Z($))}function xH0($){let{gen:Z,schema:J,data:Y}=$;Z.add(y1.default.json,Q1.str`[`);let X=Z.let("first",!0);Z.forOf("el",Y,(Q)=>{w3($,X),j9({...$,schema:J.elements,data:Q})}),Z.add(y1.default.json,Q1.str`]`)}function hH0($){let{gen:Z,schema:J,data:Y}=$;Z.add(y1.default.json,Q1.str`{`);let X=Z.let("first",!0);Z.forIn("key",Y,(Q)=>Av($,Q,J.values,X)),Z.add(y1.default.json,Q1.str`}`)}function Av($,Z,J,Y){let{gen:X,data:Q}=$;w3($,Y),O9({...$,data:Z}),X.add(y1.default.json,Q1.str`:`);let G=X.const("value",Q1._`${Q}${(0,Q1.getProperty)(Z)}`);j9({...$,schema:J,data:G})}function gH0($){let{gen:Z,schema:J,data:Y}=$,{discriminator:X}=J;Z.add(y1.default.json,Q1.str`{${JSON.stringify(X)}:`);let Q=Z.const("tag",Q1._`${Y}${(0,Q1.getProperty)(X)}`);O9({...$,data:Q}),Z.if(!1);for(let G in J.mapping){Z.elseIf(Q1._`${Q} === ${G}`);let W=J.mapping[G];Ov({...$,schema:W},X)}Z.endIf(),Z.add(y1.default.json,Q1.str`}`)}function Bv($){let{gen:Z}=$;Z.add(y1.default.json,Q1.str`{`),Ov($),Z.add(y1.default.json,Q1.str`}`)}function Ov($,Z){let{gen:J,schema:Y,data:X}=$,{properties:Q,optionalProperties:G}=Y,W=B(Q),K=B(G),V=z(W.concat(K)),U=!Z,H;for(let q of W){if(U)U=!1;else J.add(y1.default.json,Q1.str`,`);A(q,Q[q],F(q))}if(U)H=J.let("first",!0);for(let q of K){let w=F(q);J.if((0,Q1.and)(Q1._`${w} !== undefined`,(0,_H0.isOwnProperty)(J,X,q)),()=>{w3($,H),A(q,G[q],w)})}if(Y.additionalProperties)J.forIn("key",X,(q)=>J.if(N(q,V),()=>Av($,q,{},H)));function B(q){return q?Object.keys(q):[]}function z(q){if(Z)q.push(Z);if(new Set(q).size!==q.length)throw Error("JTD: properties/optionalProperties/disciminator overlap");return q}function F(q){return J.const("value",Q1._`${X}${(0,Q1.getProperty)(q)}`)}function A(q,w,j){J.add(y1.default.json,Q1.str`${JSON.stringify(q)}:`),j9({...$,schema:w,data:j})}function N(q,w){return w.length?(0,Q1.and)(...w.map((j)=>Q1._`${q} !== ${j}`)):!0}}function uH0($){let{gen:Z,schema:J,data:Y}=$;switch(J.type){case"boolean":Z.add(y1.default.json,Q1._`${Y} ? "true" : "false"`);break;case"string":O9($);break;case"timestamp":Z.if(Q1._`${Y} instanceof Date`,()=>Z.add(y1.default.json,Q1._`'"' + ${Y}.toISOString() + '"'`),()=>O9($));break;default:mH0($)}}function O9({gen:$,data:Z}){$.add(y1.default.json,Q1._`${(0,fH0.useFunc)($,kH0.default)}(${Z})`)}function mH0({gen:$,data:Z,self:J}){let Y=Q1._`${Z} === Infinity || ${Z} === -Infinity || ${Z} !== ${Z}`;if(J.opts.specialNumbers===void 0||J.opts.specialNumbers==="fast")$.add(y1.default.json,Q1._`"" + ${Z}`);else $.if(Y,()=>$.add(y1.default.json,Q1._`null`),()=>$.add(y1.default.json,Q1._`"" + ${Z}`))}function lH0($){let{gen:Z,self:J,data:Y,definitions:X,schema:Q,schemaEnv:G}=$,{ref:W}=Q,K=X[W];if(!K)throw new bH0.default(J.opts.uriResolver,"",W,`No definition ${W}`);if(!(0,SH0.hasRef)(K))return j9({...$,schema:K});let{root:V}=G,U=Fv.call(J,new zv.SchemaEnv({schema:K,root:V}),X);Z.add(y1.default.json,Q1._`${dH0(Z,U)}(${Y})`)}function dH0($,Z){return Z.serialize?$.scopeValue("serialize",{ref:Z.serialize}):Q1._`${$.scopeValue("wrapper",{ref:Z})}.serialize`}function pH0({gen:$,data:Z}){$.add(y1.default.json,Q1._`JSON.stringify(${Z})`)}function w3({gen:$},Z){if(Z)$.if(Z,()=>$.assign(Z,!1),()=>$.add(y1.default.json,Q1.str`,`));else $.add(y1.default.json,Q1.str`,`)}});var wv=S((Mv)=>{Object.defineProperty(Mv,"__esModule",{value:!0});Mv.parseJsonString=Mv.parseJsonNumber=Mv.parseJson=void 0;var iH0=/position\s(\d+)(?: \(line \d+ column \d+\))?$/;function KZ($,Z){let J;KZ.message=void 0;let Y;if(Z)$=$.slice(Z);try{return KZ.position=Z+$.length,JSON.parse($)}catch(X){if(Y=iH0.exec(X.message),!Y){KZ.message="unexpected end";return}J=+Y[1];let Q=$[J];$=$.slice(0,J),KZ.position=Z+J;try{return JSON.parse($)}catch(G){KZ.message=`unexpected token ${Q}`;return}}}Mv.parseJson=KZ;KZ.message=void 0;KZ.position=0;KZ.code='require("ajv/dist/runtime/parseJson").parseJson';function VZ($,Z,J){let Y="",X;if(VZ.message=void 0,$[Z]==="-")Y+="-",Z++;if($[Z]==="0")Y+="0",Z++;else if(!Q(J)){G();return}if(J)return VZ.position=Z,+Y;if($[Z]==="."){if(Y+=".",Z++,!Q()){G();return}}if(X=$[Z],X==="e"||X==="E"){if(Y+="e",Z++,X=$[Z],X==="+"||X==="-")Y+=X,Z++;if(!Q()){G();return}}return VZ.position=Z,+Y;function Q(W){let K=!1;while(X=$[Z],X>="0"&&X<="9"&&(W===void 0||W-- >0))K=!0,Y+=X,Z++;return K}function G(){VZ.position=Z,VZ.message=Z<$.length?`unexpected token ${$[Z]}`:"unexpected end"}}Mv.parseJsonNumber=VZ;VZ.message=void 0;VZ.position=0;VZ.code='require("ajv/dist/runtime/parseJson").parseJsonNumber';var qv={b:"\b",f:"\f",n:`
|
|
119
|
+
`,r:"\r",t:"\t",'"':'"',"/":"/","\\":"\\"},nH0=97,oH0=48;function eZ($,Z){let J="",Y;eZ.message=void 0;while(!0){if(Y=$[Z++],Y==='"')break;if(Y==="\\")if(Y=$[Z],Y in qv)J+=qv[Y],Z++;else if(Y==="u"){Z++;let Q=4,G=0;while(Q--){if(G<<=4,Y=$[Z],Y===void 0){X("unexpected end");return}if(Y=Y.toLowerCase(),Y>="a"&&Y<="f")G+=Y.charCodeAt(0)-nH0+10;else if(Y>="0"&&Y<="9")G+=Y.charCodeAt(0)-oH0;else{X(`unexpected token ${Y}`);return}Z++}J+=String.fromCharCode(G)}else{X(`unexpected token ${Y}`);return}else if(Y===void 0){X("unexpected end");return}else if(Y.charCodeAt(0)>=32)J+=Y;else{X(`unexpected token ${Y}`);return}}return eZ.position=Z,J;function X(Q){eZ.position=Z,eZ.message=Q}}Mv.parseJsonString=eZ;eZ.message=void 0;eZ.position=0;eZ.code='require("ajv/dist/runtime/parseJson").parseJsonString'});var kv=S((fv)=>{Object.defineProperty(fv,"__esModule",{value:!0});var aH0=M3(),Pv=Y7(),P0=k0(),tH0=YZ(),V1=g8(),eH0=f$(),$B0=HW(),ZB0=j3(),R3=wv(),Cv=J1(),JB0=A3(),YB0={elements:WB0,values:KB0,discriminator:UB0,properties:Lv,optionalProperties:Lv,enum:BB0,type:HB0,ref:zB0};function Iv($,Z){let J=Pv.getCompilingSchema.call(this,$);if(J)return J;let{es5:Y,lines:X}=this.opts.code,{ownProperties:Q}=this.opts,G=new P0.CodeGen(this.scope,{es5:Y,lines:X,ownProperties:Q}),W=G.scopeName("parse"),K={self:this,gen:G,schema:$.schema,schemaEnv:$,definitions:Z,data:V1.default.data,parseName:W,char:G.name("c")},V;try{this._compilations.add($),$.parseName=W,XB0(K),G.optimize(this.opts.code.optimize);let U=G.toString();V=`${G.scopeRefs(V1.default.scope)}return ${U}`;let B=Function(`${V1.default.scope}`,V)(this.scope.get());this.scope.value(W,{ref:B}),$.parse=B}catch(U){if(V)this.logger.error("Error compiling parser, function code:",V);throw delete $.parse,delete $.parseName,U}finally{this._compilations.delete($)}return $}fv.default=Iv;var T3=P0._`undefined`;function XB0($){let{gen:Z,parseName:J,char:Y}=$;Z.func(J,P0._`${V1.default.json}, ${V1.default.jsonPos}, ${V1.default.jsonPart}`,!1,()=>{Z.let(V1.default.data),Z.let(Y),Z.assign(P0._`${J}.message`,T3),Z.assign(P0._`${J}.position`,T3),Z.assign(V1.default.jsonPos,P0._`${V1.default.jsonPos} || 0`),Z.const(V1.default.jsonLen,P0._`${V1.default.json}.length`),AW($),E3($),Z.if(V1.default.jsonPart,()=>{Z.assign(P0._`${J}.position`,V1.default.jsonPos),Z.return(V1.default.data)}),Z.if(P0._`${V1.default.jsonPos} === ${V1.default.jsonLen}`,()=>Z.return(V1.default.data)),tJ($)})}function AW($){let Z;for(let J of aH0.jtdForms)if(J in $.schema){Z=J;break}if(Z)GB0($,YB0[Z]);else C3($)}var QB0=Rv(!0,Rv(!1,tJ));function GB0($,Z){let{gen:J,schema:Y,data:X}=$;if(!Y.nullable)return Z($);N9($,"null",Z,()=>J.assign(X,null))}function WB0($){let{gen:Z,schema:J,data:Y}=$;I6($,"[");let X=Z.let("i",0);Z.assign(Y,P0._`[]`),P3($,"]",()=>{let Q=Z.let("el");AW({...$,schema:J.elements,data:Q}),Z.assign(P0._`${Y}[${X}++]`,Q)})}function KB0($){let{gen:Z,schema:J,data:Y}=$;I6($,"{"),Z.assign(Y,P0._`{}`),P3($,"}",()=>VB0($,J.values))}function P3($,Z,J){Ev($,Z,J),I6($,Z)}function Ev($,Z,J){let{gen:Y}=$;Y.for(P0._`;${V1.default.jsonPos}<${V1.default.jsonLen} && ${OW(1)}!==${Z};`,()=>{J(),N9($,",",()=>Y.break(),X)});function X(){N9($,Z,()=>{},tJ)}}function VB0($,Z){let{gen:J}=$,Y=J.let("key");K7({...$,data:Y}),I6($,":"),_v($,Y,Z)}function UB0($){let{gen:Z,data:J,schema:Y}=$,{discriminator:X,mapping:Q}=Y;I6($,"{"),Z.assign(J,P0._`{}`);let G=Z.const("pos",V1.default.jsonPos),W=Z.let("value"),K=Z.let("tag");Ev($,"}",()=>{let V=Z.let("key");K7({...$,data:V}),I6($,":"),Z.if(P0._`${V} === ${X}`,()=>{K7({...$,data:K}),Z.assign(P0._`${J}[${V}]`,K),Z.break()},()=>C3({...$,data:W}))}),Z.assign(V1.default.jsonPos,G),Z.if(P0._`${K} === undefined`),UZ($,P0.str`discriminator tag not found`);for(let V in Q)Z.elseIf(P0._`${K} === ${V}`),bv({...$,schema:Q[V]},X);Z.else(),UZ($,P0.str`discriminator value not in schema`),Z.endIf()}function Lv($){let{gen:Z,data:J}=$;I6($,"{"),Z.assign(J,P0._`{}`),bv($)}function bv($,Z){let{gen:J,schema:Y,data:X}=$,{properties:Q,optionalProperties:G,additionalProperties:W}=Y;if(P3($,"}",()=>{let K=J.let("key");if(K7({...$,data:K}),I6($,":"),J.if(!1),Tv($,K,Q),Tv($,K,G),Z){J.elseIf(P0._`${K} === ${Z}`);let V=J.let("tag");K7({...$,data:V})}if(J.else(),W)C3({...$,data:P0._`${X}[${K}]`});else UZ($,P0.str`property ${K} not allowed`);J.endIf()}),Q){let K=(0,eH0.hasPropFunc)(J),V=(0,P0.and)(...Object.keys(Q).map((U)=>P0._`${K}.call(${X}, ${U})`));J.if((0,P0.not)(V),()=>UZ($,P0.str`missing required properties`))}}function Tv($,Z,J={}){let{gen:Y}=$;for(let X in J)Y.elseIf(P0._`${Z} === ${X}`),_v($,Z,J[X])}function _v($,Z,J){AW({...$,schema:J,data:P0._`${$.data}[${Z}]`})}function HB0($){let{gen:Z,schema:J,data:Y,self:X}=$;switch(J.type){case"boolean":QB0($);break;case"string":K7($);break;case"timestamp":{K7($);let Q=(0,Cv.useFunc)(Z,JB0.default),{allowDate:G,parseDate:W}=X.opts,K=G?P0._`!${Q}(${Y}, true)`:P0._`!${Q}(${Y})`,V=W?(0,P0.or)(K,P0._`(${Y} = new Date(${Y}), false)`,P0._`isNaN(${Y}.valueOf())`):K;Z.if(V,()=>UZ($,P0.str`invalid timestamp`));break}case"float32":case"float64":L3($);break;default:{let Q=J.type;if(!X.opts.int32range&&(Q==="int32"||Q==="uint32")){if(L3($,16),Q==="uint32")Z.if(P0._`${Y} < 0`,()=>UZ($,P0.str`integer out of range`))}else{let[G,W,K]=ZB0.intRange[Q];L3($,K),Z.if(P0._`${Y} < ${G} || ${Y} > ${W}`,()=>UZ($,P0.str`integer out of range`))}}}}function K7($){I6($,'"'),I3($,R3.parseJsonString)}function BB0($){let{gen:Z,data:J,schema:Y}=$,X=Y.enum;I6($,'"'),Z.if(!1);for(let Q of X){let G=JSON.stringify(Q).slice(1);Z.elseIf(P0._`${OW(G.length)} === ${G}`),Z.assign(J,P0.str`${Q}`),Z.add(V1.default.jsonPos,G.length)}Z.else(),tJ($),Z.endIf()}function L3($,Z){let{gen:J}=$;E3($),J.if(P0._`"-0123456789".indexOf(${OW(1)}) < 0`,()=>tJ($),()=>I3($,R3.parseJsonNumber,Z))}function Rv($,Z){return(J)=>{let{gen:Y,data:X}=J;N9(J,`${$}`,()=>Z(J),()=>Y.assign(X,$))}}function zB0($){let{gen:Z,self:J,definitions:Y,schema:X,schemaEnv:Q}=$,{ref:G}=X,W=Y[G];if(!W)throw new tH0.default(J.opts.uriResolver,"",G,`No definition ${G}`);if(!(0,$B0.hasRef)(W))return AW({...$,schema:W});let{root:K}=Q,V=Iv.call(J,new Pv.SchemaEnv({schema:W,root:K}),Y);Sv($,FB0(Z,V),!0)}function FB0($,Z){return Z.parse?$.scopeValue("parse",{ref:Z.parse}):P0._`${$.scopeValue("wrapper",{ref:Z})}.parse`}function C3($){I3($,R3.parseJson)}function I3($,Z,J){Sv($,(0,Cv.useFunc)($.gen,Z),J)}function Sv($,Z,J){let{gen:Y,data:X}=$;Y.assign(X,P0._`${Z}(${V1.default.json}, ${V1.default.jsonPos}${J?P0._`, ${J}`:P0.nil})`),Y.assign(V1.default.jsonPos,P0._`${Z}.position`),Y.if(P0._`${X} === undefined`,()=>UZ($,P0._`${Z}.message`))}function I6($,Z){N9($,Z,tJ)}function N9($,Z,J,Y){let{gen:X}=$,Q=Z.length;E3($),X.if(P0._`${OW(Q)} === ${Z}`,()=>{X.add(V1.default.jsonPos,Q),Y===null||Y===void 0||Y($)},()=>J($))}function E3({gen:$,char:Z}){$.code(P0._`while((${Z}=${V1.default.json}[${V1.default.jsonPos}],${Z}===" "||${Z}==="\\n"||${Z}==="\\r"||${Z}==="\\t"))${V1.default.jsonPos}++;`)}function OW($){return $===1?P0._`${V1.default.json}[${V1.default.jsonPos}]`:P0._`${V1.default.json}.slice(${V1.default.jsonPos}, ${V1.default.jsonPos}+${$})`}function tJ($){UZ($,P0._`"unexpected token " + ${V1.default.json}[${V1.default.jsonPos}]`)}function UZ({gen:$,parseName:Z},J){$.assign(P0._`${Z}.message`,J),$.assign(P0._`${Z}.position`,V1.default.jsonPos),$.return(T3)}});var S3=S((z8,_3)=>{Object.defineProperty(z8,"__esModule",{value:!0});z8.MissingRefError=z8.ValidationError=z8.CodeGen=z8.Name=z8.nil=z8.stringify=z8.str=z8._=z8.KeywordCxt=z8.Ajv=void 0;var OB0=Z3(),jB0=Zv(),NB0=Gv(),qB0=Nv(),MB0=kv(),b3="JTD-meta-schema";class q9 extends OB0.default{constructor($={}){super({...$,jtd:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(jB0.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;this.addMetaSchema(NB0.default,b3,!1)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(b3)?b3:void 0)}compileSerializer($){let Z=this._addSchema($);return Z.serialize||this._compileSerializer(Z)}compileParser($){let Z=this._addSchema($);return Z.parse||this._compileParser(Z)}_compileSerializer($){if(qB0.default.call(this,$,$.schema.definitions||{}),!$.serialize)throw Error("ajv implementation error");return $.serialize}_compileParser($){if(MB0.default.call(this,$,$.schema.definitions||{}),!$.parse)throw Error("ajv implementation error");return $.parse}}z8.Ajv=q9;_3.exports=z8=q9;_3.exports.Ajv=q9;Object.defineProperty(z8,"__esModule",{value:!0});z8.default=q9;var DB0=lJ();Object.defineProperty(z8,"KeywordCxt",{enumerable:!0,get:function(){return DB0.KeywordCxt}});var eJ=k0();Object.defineProperty(z8,"_",{enumerable:!0,get:function(){return eJ._}});Object.defineProperty(z8,"str",{enumerable:!0,get:function(){return eJ.str}});Object.defineProperty(z8,"stringify",{enumerable:!0,get:function(){return eJ.stringify}});Object.defineProperty(z8,"nil",{enumerable:!0,get:function(){return eJ.nil}});Object.defineProperty(z8,"Name",{enumerable:!0,get:function(){return eJ.Name}});Object.defineProperty(z8,"CodeGen",{enumerable:!0,get:function(){return eJ.CodeGen}});var wB0=Z9();Object.defineProperty(z8,"ValidationError",{enumerable:!0,get:function(){return wB0.default}});var LB0=YZ();Object.defineProperty(z8,"MissingRefError",{enumerable:!0,get:function(){return LB0.default}})});var f3=S((ry0,vv)=>{var PB0=sG();vv.exports=Object.freeze({coerceTypes:"array",useDefaults:!0,removeAdditional:!0,uriResolver:PB0,addUsedSchema:!1,allErrors:!1})});var jW=S((dv)=>{Object.defineProperty(dv,"__esModule",{value:!0});dv.formatNames=dv.fastFormats=dv.fullFormats=void 0;function E6($,Z){return{validate:$,compare:Z}}dv.fullFormats={date:E6(gv,x3),time:E6(v3(!0),h3),"date-time":E6(yv(!0),mv),"iso-time":E6(v3(),uv),"iso-date-time":E6(yv(),lv),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:SB0,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:gB0,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:fB0,int32:{type:"number",validate:yB0},int64:{type:"number",validate:xB0},float:{type:"number",validate:hv},double:{type:"number",validate:hv},password:!0,binary:!0};dv.fastFormats={...dv.fullFormats,date:E6(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,x3),time:E6(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,h3),"date-time":E6(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,mv),"iso-time":E6(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,uv),"iso-date-time":E6(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,lv),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};dv.formatNames=Object.keys(dv.fullFormats);function CB0($){return $%4===0&&($%100!==0||$%400===0)}var IB0=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,EB0=[0,31,28,31,30,31,30,31,31,30,31,30,31];function gv($){let Z=IB0.exec($);if(!Z)return!1;let J=+Z[1],Y=+Z[2],X=+Z[3];return Y>=1&&Y<=12&&X>=1&&X<=(Y===2&&CB0(J)?29:EB0[Y])}function x3($,Z){if(!($&&Z))return;if($>Z)return 1;if($<Z)return-1;return 0}var k3=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function v3($){return function(J){let Y=k3.exec(J);if(!Y)return!1;let X=+Y[1],Q=+Y[2],G=+Y[3],W=Y[4],K=Y[5]==="-"?-1:1,V=+(Y[6]||0),U=+(Y[7]||0);if(V>23||U>59||$&&!W)return!1;if(X<=23&&Q<=59&&G<60)return!0;let H=Q-U*K,B=X-V*K-(H<0?1:0);return(B===23||B===-1)&&(H===59||H===-1)&&G<61}}function h3($,Z){if(!($&&Z))return;let J=new Date("2020-01-01T"+$).valueOf(),Y=new Date("2020-01-01T"+Z).valueOf();if(!(J&&Y))return;return J-Y}function uv($,Z){if(!($&&Z))return;let J=k3.exec($),Y=k3.exec(Z);if(!(J&&Y))return;if($=J[1]+J[2]+J[3],Z=Y[1]+Y[2]+Y[3],$>Z)return 1;if($<Z)return-1;return 0}var y3=/t|\s/i;function yv($){let Z=v3($);return function(Y){let X=Y.split(y3);return X.length===2&&gv(X[0])&&Z(X[1])}}function mv($,Z){if(!($&&Z))return;let J=new Date($).valueOf(),Y=new Date(Z).valueOf();if(!(J&&Y))return;return J-Y}function lv($,Z){if(!($&&Z))return;let[J,Y]=$.split(y3),[X,Q]=Z.split(y3),G=x3(J,X);if(G===void 0)return;return G||h3(Y,Q)}var bB0=/\/|:/,_B0=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function SB0($){return bB0.test($)&&_B0.test($)}var xv=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function fB0($){return xv.lastIndex=0,xv.test($)}var kB0=-2147483648,vB0=2147483647;function yB0($){return Number.isInteger($)&&$<=vB0&&$>=kB0}function xB0($){return Number.isInteger($)}function hv(){return!0}var hB0=/[^\\]\\Z/;function gB0($){if(hB0.test($))return!1;try{return new RegExp($),!0}catch(Z){return!1}}});var iv=S((cv)=>{Object.defineProperty(cv,"__esModule",{value:!0});cv.formatLimitDefinition=void 0;var mB0=UW(),G6=k0(),$5=G6.operators,NW={formatMaximum:{okStr:"<=",ok:$5.LTE,fail:$5.GT},formatMinimum:{okStr:">=",ok:$5.GTE,fail:$5.LT},formatExclusiveMaximum:{okStr:"<",ok:$5.LT,fail:$5.GTE},formatExclusiveMinimum:{okStr:">",ok:$5.GT,fail:$5.LTE}},lB0={message:({keyword:$,schemaCode:Z})=>G6.str`should be ${NW[$].okStr} ${Z}`,params:({keyword:$,schemaCode:Z})=>G6._`{comparison: ${NW[$].okStr}, limit: ${Z}}`};cv.formatLimitDefinition={keyword:Object.keys(NW),type:"string",schemaType:"string",$data:!0,error:lB0,code($){let{gen:Z,data:J,schemaCode:Y,keyword:X,it:Q}=$,{opts:G,self:W}=Q;if(!G.validateFormats)return;let K=new mB0.KeywordCxt(Q,W.RULES.all.format.definition,"format");if(K.$data)V();else U();function V(){let B=Z.scopeValue("formats",{ref:W.formats,code:G.code.formats}),z=Z.const("fmt",G6._`${B}[${K.schemaCode}]`);$.fail$data((0,G6.or)(G6._`typeof ${z} != "object"`,G6._`${z} instanceof RegExp`,G6._`typeof ${z}.compare != "function"`,H(z)))}function U(){let B=K.schema,z=W.formats[B];if(!z||z===!0)return;if(typeof z!="object"||z instanceof RegExp||typeof z.compare!="function")throw Error(`"${X}": format "${B}" does not define "compare" function`);let F=Z.scopeValue("formats",{key:B,ref:z,code:G.code.formats?G6._`${G.code.formats}${(0,G6.getProperty)(B)}`:void 0});$.fail$data(H(F))}function H(B){return G6._`${B}.compare(${J}, ${Y}) ${NW[X].fail} 0`}},dependencies:["format"]};var dB0=($)=>{return $.addKeyword(cv.formatLimitDefinition),$};cv.default=dB0});var d3=S((M9,sv)=>{Object.defineProperty(M9,"__esModule",{value:!0});var $Y=jW(),cB0=iv(),m3=k0(),nv=new m3.Name("fullFormats"),iB0=new m3.Name("fastFormats"),l3=($,Z={keywords:!0})=>{if(Array.isArray(Z))return ov($,Z,$Y.fullFormats,nv),$;let[J,Y]=Z.mode==="fast"?[$Y.fastFormats,iB0]:[$Y.fullFormats,nv],X=Z.formats||$Y.formatNames;if(ov($,X,J,Y),Z.keywords)(0,cB0.default)($);return $};l3.get=($,Z="full")=>{let Y=(Z==="fast"?$Y.fastFormats:$Y.fullFormats)[$];if(!Y)throw Error(`Unknown format "${$}"`);return Y};function ov($,Z,J,Y){var X,Q;(X=(Q=$.opts.code).formats)!==null&&X!==void 0||(Q.formats=m3._`require("ajv-formats/dist/formats").${Y}`);for(let G of Z)$.addFormat(G,J[G])}sv.exports=M9=l3;Object.defineProperty(M9,"__esModule",{value:!0});M9.default=l3});var ev=S((ey0,tv)=>{var nB0=UW().default,oB0=S3(),rv=f3();class av{constructor($,Z){if(Z.mode==="JTD")this.ajv=new oB0(Object.assign({},rv,Z.customOptions));else this.ajv=new nB0(Object.assign({},rv,Z.customOptions));let J=!0;if(Z.plugins&&Z.plugins.length>0)for(let X of Z.plugins)if(Array.isArray(X))J=J&&X[0].name!=="formatsPlugin",X[0](this.ajv,X[1]);else J=J&&X.name!=="formatsPlugin",X(this.ajv);if(J)d3()(this.ajv);Z.onCreate?.(this.ajv);let Y=Object.values($);for(let X of Y)this.ajv.addSchema(X)}buildValidatorFunction({schema:$}){if($.$id){let Z=this.ajv.getSchema($.$id);if(Z)return Z}return this.ajv.compile($)}}tv.exports=av});var Jy=S(($x0,Zy)=>{var sB0=S3(),rB0=f3();class $y{constructor($,Z){this.ajv=new sB0(Object.assign({},rB0,Z))}buildSerializerFunction({schema:$}){return this.ajv.compileSerializer($)}}Zy.exports=$y});var Qy=S((w9,Xy)=>{Object.defineProperty(w9,"__esModule",{value:!0});var D9=fG(),W6=yJ();function Yy($,Z){if(!$.opts.code.source)throw Error("moduleCode: ajv instance must have code.source option");let{_n:J}=$.scope.opts;return typeof Z=="function"?X(Z.source):Z!==void 0?Q(Z,Y):Q($.schemas,(W)=>W.meta?void 0:$.compile(W.schema));function Y(W){let K=$.getSchema(W);if(!K)throw Error(`moduleCode: no schema with id ${W}`);return K}function X(W){let K={},V=W===null||W===void 0?void 0:W.validateName,U=G(K,W);if($.opts.code.esm)return`"use strict";${J}export const validate = ${V};${J}export default ${V};${J}${U}`;return`"use strict";${J}module.exports = ${V};${J}module.exports.default = ${V};${J}${U}`}function Q(W,K){var V;let U={},H=W6._`"use strict";`;for(let B in W){let z=K(W[B]);if(z){let F=G(U,z.source),A=$.opts.code.esm?W6._`export const ${(0,W6.getEsmExportName)(B)}`:W6._`exports${(0,W6.getProperty)(B)}`;H=W6._`${H}${J}${A} = ${(V=z.source)===null||V===void 0?void 0:V.validateName};${J}${F}`}}return`${H}`}function G(W,K){if(!K)throw Error('moduleCode: function does not have "source" property');if(B(K.validateName)===D9.UsedValueState.Completed)return W6.nil;z(K.validateName,D9.UsedValueState.Started);let V=$.scope.scopeCode(K.scopeValues,W,H),U=new W6._Code(`${V}${J}${K.validateCode}`);return K.evaluated?W6._`${U}${K.validateName}.evaluated = ${K.evaluated};${J}`:U;function H(F){var A;let N=(A=F.value)===null||A===void 0?void 0:A.ref;if(F.prefix==="validate"&&typeof N=="function")return G(W,N.source);else if((F.prefix==="root"||F.prefix==="wrapper")&&typeof N=="object"){let{validate:q,validateName:w}=N;if(!w)throw Error("ajv internal error");let j=$.opts.code.es5?D9.varKinds.var:D9.varKinds.const,M=W6._`${j} ${F} = {validate: ${w}};`;if(B(w)===D9.UsedValueState.Started)return M;let I=G(W,q===null||q===void 0?void 0:q.source);return W6._`${M}${J}${I}`}return}function B(F){var A;return(A=W[F.prefix])===null||A===void 0?void 0:A.get(F)}function z(F,A){let{prefix:N}=F;(W[N]=W[N]||new Map).set(F,A)}}}Xy.exports=w9=Yy;Object.defineProperty(w9,"__esModule",{value:!0});w9.default=Yy});var Ky=S((Zx0,Wy)=>{var Gy=p3(),aB0=Qy().default;function tB0($={readMode:!0}){if($.readMode===!0&&!$.restoreFunction)throw Error("You must provide a restoreFunction options when readMode ON");if($.readMode!==!0&&!$.storeFunction)throw Error("You must provide a storeFunction options when readMode OFF");if($.readMode===!0)return function(){return function(Y){return $.restoreFunction(Y)}};let Z=Gy();return function(Y,X={}){if(!X.customOptions||!X.customOptions.code)X.customOptions=Object.assign({},X.customOptions,{code:{source:!0}});let Q=Z(Y,X);return function(G){let W=Q(G),K=aB0(Q[Gy.AjvReference].ajv,W);return $.storeFunction(G,K),W}}}Wy.exports=tB0});var p3=S((Jx0,ZY)=>{var Uy=Symbol.for("fastify.ajv-compiler.reference"),eB0=ev(),$z0=Jy();function c3($){let Z=new Map,J=new Map;if($&&$.jtdSerializer===!0)return function(X,Q){let G=Vy({},Q);if(J.has(G))return J.get(G);let W=new $z0(X,Q),K=W.buildSerializerFunction.bind(W);return J.set(G,K),K};return function(X,Q){let G=Vy(X,Q.customOptions);if(Z.has(G))return Z.get(G);let W=new eB0(X,Q),K=W.buildValidatorFunction.bind(W);if(Z.set(G,K),Q.customOptions.code!==void 0)K[Uy]=W;return K}}function Vy($,Z){let J=JSON.stringify($),Y=JSON.stringify(Z);return`${J}${Y}`}ZY.exports=c3;ZY.exports.default=c3;ZY.exports.AjvCompiler=c3;ZY.exports.AjvReference=Uy;ZY.exports.StandaloneValidator=Ky()});var qW=S((Zz0)=>{var Hy=Object.prototype.hasOwnProperty;function By($,Z,J){for(J of $.keys())if(L9(J,Z))return J}function L9($,Z){var J,Y,X;if($===Z)return!0;if($&&Z&&(J=$.constructor)===Z.constructor){if(J===Date)return $.getTime()===Z.getTime();if(J===RegExp)return $.toString()===Z.toString();if(J===Array){if((Y=$.length)===Z.length)while(Y--&&L9($[Y],Z[Y]));return Y===-1}if(J===Set){if($.size!==Z.size)return!1;for(Y of $){if(X=Y,X&&typeof X==="object"){if(X=By(Z,X),!X)return!1}if(!Z.has(X))return!1}return!0}if(J===Map){if($.size!==Z.size)return!1;for(Y of $){if(X=Y[0],X&&typeof X==="object"){if(X=By(Z,X),!X)return!1}if(!L9(Y[1],Z.get(X)))return!1}return!0}if(J===ArrayBuffer)$=new Uint8Array($),Z=new Uint8Array(Z);else if(J===DataView){if((Y=$.byteLength)===Z.byteLength)while(Y--&&$.getInt8(Y)===Z.getInt8(Y));return Y===-1}if(ArrayBuffer.isView($)){if((Y=$.byteLength)===Z.byteLength)while(Y--&&$[Y]===Z[Y]);return Y===-1}if(!J||typeof $==="object"){Y=0;for(J in $){if(Hy.call($,J)&&++Y&&!Hy.call(Z,J))return!1;if(!(J in Z)||!L9($[J],Z[J]))return!1}return Object.keys(Z).length===Y}}return $!==$&&Z!==Z}Zz0.dequal=L9});var jy=S((Xx0,Oy)=>{var{dequal:zy}=qW(),Yz0=Symbol.for("json-schema-ref");class Ay{#$;#Z;#J;#Y;#X;constructor($={}){this.#$={},this.#Z={},this.#J=$.insertRefSymbol??!1,this.#Y=$.allowEqualDuplicates??!0,this.#X=$.cloneSchemaWithoutRefs??!1}addSchema($,Z,J=!0){if(J)if($.$id!==void 0&&$.$id.charAt(0)!=="#")Z=$.$id;else this.#K($,Z);let Y=$.$id;if(Y!==void 0&&typeof Y==="string")if(Y.charAt(0)==="#")this.#U($,Z,Y);else this.#K($,Y),Z=Y;let X=$.$ref;if(X!==void 0&&typeof X==="string"){let{refSchemaId:Q,refJsonPointer:G}=this.#Q(X,Z);this.#$[Z].refs.push({schemaId:Q,jsonPointer:G})}for(let Q in $)if(typeof $[Q]==="object"&&$[Q]!==null)this.addSchema($[Q],Z,!1)}getSchema($,Z="#"){let J=this.#$[$];if(J===void 0)throw Error(`Cannot resolve ref "${$}${Z}". Schema with id "${$}" is not found.`);if(J.anchors[Z]!==void 0)return J.anchors[Z];return Fy(J.schema,Z)}hasSchema($){return this.#$[$]!==void 0}getSchemaRefs($){let Z=this.#$[$];if(Z===void 0)throw Error(`Schema with id "${$}" is not found.`);return Z.refs}getSchemaDependencies($,Z={}){let J=this.#$[$];for(let Y of J.refs){let X=Y.schemaId;if(X===$||Z[X]!==void 0)continue;Z[X]=this.getSchema(X),this.getSchemaDependencies(X,Z)}return Z}derefSchema($){if(this.#Z[$]!==void 0)return;let Z=this.#$[$];if(Z===void 0)throw Error(`Schema with id "${$}" is not found.`);if(!this.#X&&Z.refs.length===0)this.#Z[$]={schema:Z.schema,anchors:Z.anchors};let J=[];this.#G(Z.schema,$,!0,J);let Y=this.getSchemaDependencies($);for(let X in Y){let Q=Y[X];this.#G(Q,X,!0,J)}for(let X of J){let{refSchemaId:Q,refJsonPointer:G}=this.#Q(X.ref,X.sourceSchemaId),W=this.getDerefSchema(Q,G);if(W===null)throw Error(`Cannot resolve ref "${X.ref}". Ref "${G}" is not found in schema "${Q}".`);X.targetSchema=W,X.targetSchemaId=Q}for(let X of J)this.#W(X,J)}getDerefSchema($,Z="#"){let J=this.#Z[$];if(J===void 0)this.derefSchema($),J=this.#Z[$];if(J.anchors[Z]!==void 0)return J.anchors[Z];return Fy(J.schema,Z)}#Q($,Z){let J=$.indexOf("#");if(J===-1)return{refSchemaId:$,refJsonPointer:"#"};if(J===0)return{refSchemaId:Z,refJsonPointer:$};return{refSchemaId:$.slice(0,J),refJsonPointer:$.slice(J)}}#G($,Z,J,Y=[]){let X=Array.isArray($)?[...$]:{...$};if(J)if($.$id!==void 0&&$.$id.charAt(0)!=="#")Z=$.$id;else this.#V(X,Z);let Q=X.$id;if(Q!==void 0&&typeof Q==="string")if(Q.charAt(0)==="#")this.#H(X,Z,Q);else this.#V(X,Q),Z=Q;if(X.$ref!==void 0)Y.push({ref:X.$ref,sourceSchemaId:Z,sourceSchema:X});for(let G in X){let W=X[G];if(typeof W==="object"&&W!==null)X[G]=this.#G(W,Z,!1,Y)}return X}#W($,Z){let{sourceSchema:J,targetSchema:Y}=$;if(!J.$ref)return;if(this.#J)J[Yz0]=J.$ref;if(delete J.$ref,Y.$ref){let X=Z.find((Q)=>Q.sourceSchema===Y);this.#W(X,Z)}for(let X in Y){if(X==="$id")continue;if(J[X]!==void 0){if(zy(J[X],Y[X]))continue;throw Error(`Cannot resolve ref "${$.ref}". Property "${X}" already exists in schema "${$.sourceSchemaId}".`)}J[X]=Y[X]}$.isResolved=!0}#K($,Z){let J=this.#$[Z];if(J!==void 0){if(this.#Y&&zy($,J.schema))return;throw Error(`There is already another schema with id "${Z}".`)}this.#$[Z]={schema:$,anchors:{},refs:[]}}#U($,Z,J){let{anchors:Y}=this.#$[Z];if(Y[J]!==void 0)throw Error(`There is already another anchor "${J}" in schema "${Z}".`);Y[J]=$}#V($,Z){if(this.#Z[Z]!==void 0)return;this.#Z[Z]={schema:$,anchors:{}}}#H($,Z,J){let{anchors:Y}=this.#Z[Z];Y[J]=$}}function Fy($,Z){let J=Z.split("/"),Y=$;for(let X of J){if(X===""||X==="#")continue;if(typeof Y!=="object"||Y===null)return null;Y=Y[X]}return Y??null}Oy.exports={RefResolver:Ay}});var n3=S((Qx0,Ny)=>{var Xz0=UW(),Qz0=sG(),Gz0=d3(),Wz0=WG()({proto:!0});class i3{constructor($){this.ajv=new Xz0({...$,strictSchema:!1,validateSchema:!1,allowUnionTypes:!0,uriResolver:Qz0}),Gz0(this.ajv),this.ajv.addKeyword({keyword:"fjs_type",type:"object",errors:!1,validate:(Z,J)=>{return J&&typeof J.toJSON==="function"}}),this._ajvSchemas={},this._ajvOptions=$||{}}addSchema($,Z){let J=$.$id||Z;if($.$id!==void 0&&$.$id[0]==="#")J=Z+$.$id;if(this.ajv.refs[J]===void 0&&this.ajv.schemas[J]===void 0){let Y=Wz0($);this.convertSchemaToAjvFormat(Y),this.ajv.addSchema(Y,J),this._ajvSchemas[J]=$}}validate($,Z){return this.ajv.validate($,Z)}convertSchemaToAjvFormat($){if($===null)return;if($.type==="string")$.fjs_type="string",$.type=["string","object"];else if(Array.isArray($.type)&&$.type.includes("string")&&!$.type.includes("object"))$.fjs_type="string",$.type.push("object");for(let Z in $)if(typeof $[Z]==="object")this.convertSchemaToAjvFormat($[Z])}getState(){return{ajvOptions:this._ajvOptions,ajvSchemas:this._ajvSchemas}}static restoreFromState($){let Z=new i3($.ajvOptions);for(let[J,Y]of Object.entries($.ajvSchemas))Z.ajv.addSchema(Y,J);return Z}}Ny.exports=i3});var My=S((Gx0,qy)=>{class o3{constructor($,Z,J="#"){this.schema=$,this.schemaId=Z,this.jsonPointer=J}getPropertyLocation($){return new o3(this.schema[$],this.schemaId,this.jsonPointer+"/"+$)}getSchemaRef(){return this.schemaId+this.jsonPointer}}qy.exports=o3});var Ry=S((Wx0,r3)=>{r3.exports=U0;r3.exports.default=U0;var Kz0={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0},Dy={enum:["array","boolean","integer","null","number","object","string"]},wy=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,Vz0=jW().fullFormats.uri,Ly=jW().fullFormats.regex;function m8($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0,W=G;if(!(typeof $=="number"&&(!($%1)&&!isNaN($))&&isFinite($)))return m8.errors=[{instancePath:Z,schemaPath:"#/definitions/nonNegativeInteger/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(G===W){if(typeof $=="number"&&isFinite($)){if($<0||isNaN($))return m8.errors=[{instancePath:Z,schemaPath:"#/definitions/nonNegativeInteger/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}}return m8.errors=Q,G===0}var s3={validate:U0};function $8($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0;if(G===0)if(Array.isArray($))if($.length<1)return $8.errors=[{instancePath:Z,schemaPath:"#/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;else{var W=!0;let K=$.length;for(let V=0;V<K;V++){let U=G;if(!s3.validate($[V],{instancePath:Z+"/"+V,parentData:$,parentDataProperty:V,rootData:X}))Q=Q===null?s3.validate.errors:Q.concat(s3.validate.errors),G=Q.length;var W=U===G;if(!W)break}}else return $8.errors=[{instancePath:Z,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;return $8.errors=Q,G===0}var Ty=H9().default;function U0($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0;if(!($&&typeof $=="object"&&!Array.isArray($))&&typeof $!=="boolean")return U0.errors=[{instancePath:Z,schemaPath:"#/type",keyword:"type",params:{type:Kz0.type},message:"must be object,boolean"}],!1;if(G===0){if($&&typeof $=="object"&&!Array.isArray($)){if($.$id!==void 0){let j=$.$id,M=G;if(G===M){if(G===M)if(typeof j==="string"){if(!wy.test(j))return U0.errors=[{instancePath:Z+"/$id",schemaPath:"#/properties/%24id/format",keyword:"format",params:{format:"uri-reference"},message:'must match format "uri-reference"'}],!1}else return U0.errors=[{instancePath:Z+"/$id",schemaPath:"#/properties/%24id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}var W=M===G}else var W=!0;if(W){if($.$schema!==void 0){let j=$.$schema,M=G;if(G===M){if(G===M)if(typeof j==="string"){if(!Vz0(j))return U0.errors=[{instancePath:Z+"/$schema",schemaPath:"#/properties/%24schema/format",keyword:"format",params:{format:"uri"},message:'must match format "uri"'}],!1}else return U0.errors=[{instancePath:Z+"/$schema",schemaPath:"#/properties/%24schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}var W=M===G}else var W=!0;if(W){if($.$ref!==void 0){let j=$.$ref,M=G;if(G===M){if(G===M)if(typeof j==="string"){if(!wy.test(j))return U0.errors=[{instancePath:Z+"/$ref",schemaPath:"#/properties/%24ref/format",keyword:"format",params:{format:"uri-reference"},message:'must match format "uri-reference"'}],!1}else return U0.errors=[{instancePath:Z+"/$ref",schemaPath:"#/properties/%24ref/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}var W=M===G}else var W=!0;if(W){if($.$comment!==void 0){let j=G;if(typeof $.$comment!=="string")return U0.errors=[{instancePath:Z+"/$comment",schemaPath:"#/properties/%24comment/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=j===G}else var W=!0;if(W){if($.title!==void 0){let j=G;if(typeof $.title!=="string")return U0.errors=[{instancePath:Z+"/title",schemaPath:"#/properties/title/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=j===G}else var W=!0;if(W){if($.description!==void 0){let j=G;if(typeof $.description!=="string")return U0.errors=[{instancePath:Z+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=j===G}else var W=!0;if(W){if($.readOnly!==void 0){let j=G;if(typeof $.readOnly!=="boolean")return U0.errors=[{instancePath:Z+"/readOnly",schemaPath:"#/properties/readOnly/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var W=j===G}else var W=!0;if(W){if($.examples!==void 0){let j=G;if(G===j){if(!Array.isArray($.examples))return U0.errors=[{instancePath:Z+"/examples",schemaPath:"#/properties/examples/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1}var W=j===G}else var W=!0;if(W){if($.multipleOf!==void 0){let j=$.multipleOf,M=G;if(G===M)if(typeof j=="number"&&isFinite(j)){if(j<=0||isNaN(j))return U0.errors=[{instancePath:Z+"/multipleOf",schemaPath:"#/properties/multipleOf/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"}],!1}else return U0.errors=[{instancePath:Z+"/multipleOf",schemaPath:"#/properties/multipleOf/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.maximum!==void 0){let j=$.maximum,M=G;if(!(typeof j=="number"&&isFinite(j)))return U0.errors=[{instancePath:Z+"/maximum",schemaPath:"#/properties/maximum/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.exclusiveMaximum!==void 0){let j=$.exclusiveMaximum,M=G;if(!(typeof j=="number"&&isFinite(j)))return U0.errors=[{instancePath:Z+"/exclusiveMaximum",schemaPath:"#/properties/exclusiveMaximum/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.minimum!==void 0){let j=$.minimum,M=G;if(!(typeof j=="number"&&isFinite(j)))return U0.errors=[{instancePath:Z+"/minimum",schemaPath:"#/properties/minimum/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.exclusiveMinimum!==void 0){let j=$.exclusiveMinimum,M=G;if(!(typeof j=="number"&&isFinite(j)))return U0.errors=[{instancePath:Z+"/exclusiveMinimum",schemaPath:"#/properties/exclusiveMinimum/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.maxLength!==void 0){let j=$.maxLength,M=G,I=G;if(!(typeof j=="number"&&(!(j%1)&&!isNaN(j))&&isFinite(j)))return U0.errors=[{instancePath:Z+"/maxLength",schemaPath:"#/definitions/nonNegativeInteger/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(G===I){if(typeof j=="number"&&isFinite(j)){if(j<0||isNaN(j))return U0.errors=[{instancePath:Z+"/maxLength",schemaPath:"#/definitions/nonNegativeInteger/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}}var W=M===G}else var W=!0;if(W){if($.minLength!==void 0){let j=G;if(!m8($.minLength,{instancePath:Z+"/minLength",parentData:$,parentDataProperty:"minLength",rootData:X}))Q=Q===null?m8.errors:Q.concat(m8.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.pattern!==void 0){let j=$.pattern,M=G;if(G===M){if(G===M)if(typeof j==="string"){if(!Ly(j))return U0.errors=[{instancePath:Z+"/pattern",schemaPath:"#/properties/pattern/format",keyword:"format",params:{format:"regex"},message:'must match format "regex"'}],!1}else return U0.errors=[{instancePath:Z+"/pattern",schemaPath:"#/properties/pattern/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}var W=M===G}else var W=!0;if(W){if($.additionalItems!==void 0){let j=G;if(!U0($.additionalItems,{instancePath:Z+"/additionalItems",parentData:$,parentDataProperty:"additionalItems",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.items!==void 0){let j=$.items,M=G,I=G,R=!1,L=G;if(!U0(j,{instancePath:Z+"/items",parentData:$,parentDataProperty:"items",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var K=L===G;if(R=R||K,!R){let _=G;if(!$8(j,{instancePath:Z+"/items",parentData:$,parentDataProperty:"items",rootData:X}))Q=Q===null?$8.errors:Q.concat($8.errors),G=Q.length;var K=_===G;R=R||K}if(!R){let _={instancePath:Z+"/items",schemaPath:"#/properties/items/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[_];else Q.push(_);return G++,U0.errors=Q,!1}else if(G=I,Q!==null)if(I)Q.length=I;else Q=null;var W=M===G}else var W=!0;if(W){if($.maxItems!==void 0){let j=$.maxItems,M=G,I=G;if(!(typeof j=="number"&&(!(j%1)&&!isNaN(j))&&isFinite(j)))return U0.errors=[{instancePath:Z+"/maxItems",schemaPath:"#/definitions/nonNegativeInteger/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(G===I){if(typeof j=="number"&&isFinite(j)){if(j<0||isNaN(j))return U0.errors=[{instancePath:Z+"/maxItems",schemaPath:"#/definitions/nonNegativeInteger/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}}var W=M===G}else var W=!0;if(W){if($.minItems!==void 0){let j=G;if(!m8($.minItems,{instancePath:Z+"/minItems",parentData:$,parentDataProperty:"minItems",rootData:X}))Q=Q===null?m8.errors:Q.concat(m8.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.uniqueItems!==void 0){let j=G;if(typeof $.uniqueItems!=="boolean")return U0.errors=[{instancePath:Z+"/uniqueItems",schemaPath:"#/properties/uniqueItems/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var W=j===G}else var W=!0;if(W){if($.contains!==void 0){let j=G;if(!U0($.contains,{instancePath:Z+"/contains",parentData:$,parentDataProperty:"contains",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.maxProperties!==void 0){let j=$.maxProperties,M=G,I=G;if(!(typeof j=="number"&&(!(j%1)&&!isNaN(j))&&isFinite(j)))return U0.errors=[{instancePath:Z+"/maxProperties",schemaPath:"#/definitions/nonNegativeInteger/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(G===I){if(typeof j=="number"&&isFinite(j)){if(j<0||isNaN(j))return U0.errors=[{instancePath:Z+"/maxProperties",schemaPath:"#/definitions/nonNegativeInteger/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}}var W=M===G}else var W=!0;if(W){if($.minProperties!==void 0){let j=G;if(!m8($.minProperties,{instancePath:Z+"/minProperties",parentData:$,parentDataProperty:"minProperties",rootData:X}))Q=Q===null?m8.errors:Q.concat(m8.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.required!==void 0){let j=$.required,M=G;if(G===G)if(Array.isArray(j)){var V=!0;let L=j.length;for(let C=0;C<L;C++){let _=G;if(typeof j[C]!=="string")return U0.errors=[{instancePath:Z+"/required/"+C,schemaPath:"#/definitions/stringArray/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var V=_===G;if(!V)break}if(V){let C=j.length,_;if(C>1){let E={};for(;C--;){let f=j[C];if(typeof f!=="string")continue;if(typeof E[f]=="number"){return _=E[f],U0.errors=[{instancePath:Z+"/required",schemaPath:"#/definitions/stringArray/uniqueItems",keyword:"uniqueItems",params:{i:C,j:_},message:"must NOT have duplicate items (items ## "+_+" and "+C+" are identical)"}],!1;break}E[f]=C}}}}else return U0.errors=[{instancePath:Z+"/required",schemaPath:"#/definitions/stringArray/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var W=M===G}else var W=!0;if(W){if($.additionalProperties!==void 0){let j=G;if(!U0($.additionalProperties,{instancePath:Z+"/additionalProperties",parentData:$,parentDataProperty:"additionalProperties",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.definitions!==void 0){let j=$.definitions,M=G;if(G===M)if(j&&typeof j=="object"&&!Array.isArray(j))for(let R in j){let L=G;if(!U0(j[R],{instancePath:Z+"/definitions/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:j,parentDataProperty:R,rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var U=L===G;if(!U)break}else return U0.errors=[{instancePath:Z+"/definitions",schemaPath:"#/properties/definitions/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=M===G}else var W=!0;if(W){if($.properties!==void 0){let j=$.properties,M=G;if(G===M)if(j&&typeof j=="object"&&!Array.isArray(j))for(let R in j){let L=G;if(!U0(j[R],{instancePath:Z+"/properties/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:j,parentDataProperty:R,rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var H=L===G;if(!H)break}else return U0.errors=[{instancePath:Z+"/properties",schemaPath:"#/properties/properties/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=M===G}else var W=!0;if(W){if($.patternProperties!==void 0){let j=$.patternProperties,M=G;if(G===M)if(j&&typeof j=="object"&&!Array.isArray(j)){for(let R in j){let L=G;if(G===L){if(typeof R==="string"){if(!Ly(R)){let C={instancePath:Z+"/patternProperties",schemaPath:"#/properties/patternProperties/propertyNames/format",keyword:"format",params:{format:"regex"},message:'must match format "regex"',propertyName:R};if(Q===null)Q=[C];else Q.push(C);G++}}}var B=L===G;if(!B){let C={instancePath:Z+"/patternProperties",schemaPath:"#/properties/patternProperties/propertyNames",keyword:"propertyNames",params:{propertyName:R},message:"property name must be valid"};if(Q===null)Q=[C];else Q.push(C);return G++,U0.errors=Q,!1;break}}if(B)for(let R in j){let L=G;if(!U0(j[R],{instancePath:Z+"/patternProperties/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:j,parentDataProperty:R,rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var z=L===G;if(!z)break}}else return U0.errors=[{instancePath:Z+"/patternProperties",schemaPath:"#/properties/patternProperties/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=M===G}else var W=!0;if(W){if($.dependencies!==void 0){let j=$.dependencies,M=G;if(G===M)if(j&&typeof j=="object"&&!Array.isArray(j))for(let R in j){let L=j[R],C=G,_=G,E=!1,f=G;if(!U0(L,{instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:j,parentDataProperty:R,rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var F=f===G;if(E=E||F,!E){let b=G;if(G===G)if(Array.isArray(L)){var A=!0;let x=L.length;for(let g=0;g<x;g++){let c=G;if(typeof L[g]!=="string"){let G0={instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+g,schemaPath:"#/definitions/stringArray/items/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[G0];else Q.push(G0);G++}var A=c===G;if(!A)break}if(A){let g=L.length,c;if(g>1){let e={};for(;g--;){let G0=L[g];if(typeof G0!=="string")continue;if(typeof e[G0]=="number"){c=e[G0];let Q0={instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/definitions/stringArray/uniqueItems",keyword:"uniqueItems",params:{i:g,j:c},message:"must NOT have duplicate items (items ## "+c+" and "+g+" are identical)"};if(Q===null)Q=[Q0];else Q.push(Q0);G++;break}e[G0]=g}}}}else{let x={instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/definitions/stringArray/type",keyword:"type",params:{type:"array"},message:"must be array"};if(Q===null)Q=[x];else Q.push(x);G++}var F=b===G;E=E||F}if(!E){let b={instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/dependencies/additionalProperties/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[b];else Q.push(b);return G++,U0.errors=Q,!1}else if(G=_,Q!==null)if(_)Q.length=_;else Q=null;var N=C===G;if(!N)break}else return U0.errors=[{instancePath:Z+"/dependencies",schemaPath:"#/properties/dependencies/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=M===G}else var W=!0;if(W){if($.propertyNames!==void 0){let j=G;if(!U0($.propertyNames,{instancePath:Z+"/propertyNames",parentData:$,parentDataProperty:"propertyNames",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.enum!==void 0){let j=$.enum,M=G;if(G===M)if(Array.isArray(j))if(j.length<1)return U0.errors=[{instancePath:Z+"/enum",schemaPath:"#/properties/enum/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;else{let R=j.length,L;if(R>1)$:for(;R--;)for(L=R;L--;)if(Ty(j[R],j[L])){return U0.errors=[{instancePath:Z+"/enum",schemaPath:"#/properties/enum/uniqueItems",keyword:"uniqueItems",params:{i:R,j:L},message:"must NOT have duplicate items (items ## "+L+" and "+R+" are identical)"}],!1;break $}}else return U0.errors=[{instancePath:Z+"/enum",schemaPath:"#/properties/enum/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var W=M===G}else var W=!0;if(W){if($.type!==void 0){let j=$.type,M=G,I=G,R=!1,L=G;if(!(j==="array"||j==="boolean"||j==="integer"||j==="null"||j==="number"||j==="object"||j==="string")){let _={instancePath:Z+"/type",schemaPath:"#/definitions/simpleTypes/enum",keyword:"enum",params:{allowedValues:Dy.enum},message:"must be equal to one of the allowed values"};if(Q===null)Q=[_];else Q.push(_);G++}var q=L===G;if(R=R||q,!R){let _=G;if(G===_)if(Array.isArray(j))if(j.length<1){let f={instancePath:Z+"/type",schemaPath:"#/properties/type/anyOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};if(Q===null)Q=[f];else Q.push(f);G++}else{var w=!0;let f=j.length;for(let b=0;b<f;b++){let k=j[b],u=G;if(!(k==="array"||k==="boolean"||k==="integer"||k==="null"||k==="number"||k==="object"||k==="string")){let g={instancePath:Z+"/type/"+b,schemaPath:"#/definitions/simpleTypes/enum",keyword:"enum",params:{allowedValues:Dy.enum},message:"must be equal to one of the allowed values"};if(Q===null)Q=[g];else Q.push(g);G++}var w=u===G;if(!w)break}if(w){let b=j.length,k;if(b>1)$:for(;b--;)for(k=b;k--;)if(Ty(j[b],j[k])){let u={instancePath:Z+"/type",schemaPath:"#/properties/type/anyOf/1/uniqueItems",keyword:"uniqueItems",params:{i:b,j:k},message:"must NOT have duplicate items (items ## "+k+" and "+b+" are identical)"};if(Q===null)Q=[u];else Q.push(u);G++;break $}}}else{let f={instancePath:Z+"/type",schemaPath:"#/properties/type/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};if(Q===null)Q=[f];else Q.push(f);G++}var q=_===G;R=R||q}if(!R){let _={instancePath:Z+"/type",schemaPath:"#/properties/type/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[_];else Q.push(_);return G++,U0.errors=Q,!1}else if(G=I,Q!==null)if(I)Q.length=I;else Q=null;var W=M===G}else var W=!0;if(W){if($.format!==void 0){let j=G;if(typeof $.format!=="string")return U0.errors=[{instancePath:Z+"/format",schemaPath:"#/properties/format/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=j===G}else var W=!0;if(W){if($.contentMediaType!==void 0){let j=G;if(typeof $.contentMediaType!=="string")return U0.errors=[{instancePath:Z+"/contentMediaType",schemaPath:"#/properties/contentMediaType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=j===G}else var W=!0;if(W){if($.contentEncoding!==void 0){let j=G;if(typeof $.contentEncoding!=="string")return U0.errors=[{instancePath:Z+"/contentEncoding",schemaPath:"#/properties/contentEncoding/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=j===G}else var W=!0;if(W){if($.if!==void 0){let j=G;if(!U0($.if,{instancePath:Z+"/if",parentData:$,parentDataProperty:"if",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.then!==void 0){let j=G;if(!U0($.then,{instancePath:Z+"/then",parentData:$,parentDataProperty:"then",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.else!==void 0){let j=G;if(!U0($.else,{instancePath:Z+"/else",parentData:$,parentDataProperty:"else",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.allOf!==void 0){let j=G;if(!$8($.allOf,{instancePath:Z+"/allOf",parentData:$,parentDataProperty:"allOf",rootData:X}))Q=Q===null?$8.errors:Q.concat($8.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.anyOf!==void 0){let j=G;if(!$8($.anyOf,{instancePath:Z+"/anyOf",parentData:$,parentDataProperty:"anyOf",rootData:X}))Q=Q===null?$8.errors:Q.concat($8.errors),G=Q.length;var W=j===G}else var W=!0;if(W){if($.oneOf!==void 0){let j=G;if(!$8($.oneOf,{instancePath:Z+"/oneOf",parentData:$,parentDataProperty:"oneOf",rootData:X}))Q=Q===null?$8.errors:Q.concat($8.errors),G=Q.length;var W=j===G}else var W=!0;if(W)if($.not!==void 0){let j=G;if(!U0($.not,{instancePath:Z+"/not",parentData:$,parentDataProperty:"not",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=j===G}else var W=!0}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}return U0.errors=Q,G===0}});var a3=S((Kx0,Ey)=>{class Py extends Error{constructor($,Z){super();this.name="JsonSchemaMergeError",this.code="JSON_SCHEMA_MERGE_ERROR",this.message=`Failed to merge "${$}" keyword schemas.`,this.schemas=Z}}class Cy extends Error{constructor($,Z){super();this.name="JsonSchemaMergeError",this.code="JSON_SCHEMA_MERGE_ERROR",this.message=`Resolver for "${$}" keyword not found.`,this.schemas=Z}}class Iy extends Error{constructor($){super();this.name="JsonSchemaMergeError",this.code="JSON_SCHEMA_MERGE_ERROR",this.message=`Invalid "onConflict" option: "${$}".`}}Ey.exports={MergeError:Py,ResolverNotFoundError:Cy,InvalidOnConflictOptionError:Iy}});var Sy=S((Vx0,_y)=>{var{dequal:Uz0}=qW(),{MergeError:t3}=a3();function by($){let Z=$[0];for(let J=1;J<$.length;J++)Z=Z.filter((Y)=>$[J].includes(Y));return Z}function Hz0($,Z,J){let Y=by(Z);if(Y.length===0)throw new t3($,Z);J[$]=Y}function Bz0($,Z,J){for(let X=0;X<Z.length;X++)if(!Array.isArray(Z[X]))Z[X]=[Z[X]];let Y=by(Z);if(Y.length===0)throw new t3($,Z);if(Y.length===1)J[$]=Y[0];else J[$]=Y}function zz0($,Z,J){let Y=[];for(let X of Z)for(let Q of X)if(!Y.includes(Q))Y.push(Q);J[$]=Y}function Fz0($,Z,J){J[$]=Math.min(...Z)}function Az0($,Z,J){J[$]=Math.max(...Z)}function Oz0($,Z,J){let Y=(W,K)=>!K?W:Y(K,W%K),X=(W,K)=>W*K/Y(W,K),Q=1;for(let W of Z)while(W*Q%1!==0)Q*=10;let G=Z[0]*Q;for(let W of Z)G=X(G,W*Q);J[$]=G/Q}function jz0($,Z,J){let Y=Z[0];for(let X=1;X<Z.length;X++)if(!Uz0(Z[X],Y))throw new t3($,Z);J[$]=Y}function Nz0(){}function qz0($,Z,J){for(let Y of Z)if(Y===!1){J[$]=!1;return}J[$]=!0}function Mz0($,Z,J){for(let Y of Z)if(Y===!0){J[$]=!0;return}J[$]=!1}_y.exports={arraysIntersection:Hz0,hybridArraysIntersection:Bz0,arraysUnion:zz0,minNumber:Fz0,maxNumber:Az0,commonMultiple:Oz0,allEqual:jz0,booleanAnd:qz0,booleanOr:Mz0,skip:Nz0}});var hy=S((Ux0,xy)=>{var{dequal:Dz0}=qW(),Z$=Sy(),wW=a3(),vy={$id:Z$.skip,type:Z$.hybridArraysIntersection,enum:Z$.arraysIntersection,minLength:Z$.maxNumber,maxLength:Z$.minNumber,minimum:Z$.maxNumber,maximum:Z$.minNumber,multipleOf:Z$.commonMultiple,exclusiveMinimum:Z$.maxNumber,exclusiveMaximum:Z$.minNumber,minItems:Z$.maxNumber,maxItems:Z$.minNumber,maxProperties:Z$.minNumber,minProperties:Z$.maxNumber,const:Z$.allEqual,default:Z$.allEqual,format:Z$.allEqual,required:Z$.arraysUnion,properties:Cz0,patternProperties:DW,additionalProperties:MW,items:Tz0,additionalItems:Rz0,definitions:DW,$defs:DW,nullable:Z$.booleanAnd,oneOf:fy,anyOf:fy,allOf:Z$.arraysUnion,not:MW,if:Iz0,then:Z$.skip,else:Z$.skip,dependencies:ky,dependentRequired:ky,dependentSchemas:DW,propertyNames:MW,uniqueItems:Z$.booleanOr,contains:MW};function MW($,Z,J,Y,X){J[$]=K6(Z,X)}function wz0($){let Z=[[]];for(let J of $){let Y=[];for(let X of Z)for(let Q of J)Y.push([...X,Q]);Z=Y}return Z}function fy($,Z,J,Y,X){if(Z.length===1){J[$]=Z[0];return}let Q=wz0(Z),G=[];for(let W of Q)try{let K=K6(W,X);if(K!==void 0)G.push(K)}catch(K){if(K instanceof wW.MergeError)continue;throw K}J[$]=G}function Lz0($,Z){let{items:J,additionalItems:Y}=$;if(Array.isArray(J)){if(Z<J.length)return J[Z];return Y}if(J!==void 0)return J;return Y}function Tz0($,Z,J,Y,X){let Q=0;for(let W of Z)if(Array.isArray(W))Q=Math.max(Q,W.length);if(Q===0){J[$]=K6(Z,X);return}let G=[];for(let W=0;W<Q;W++){let K=[];for(let V of Y){let U=Lz0(V,W);if(U!==void 0)K.push(U)}G[W]=K6(K,X)}J[$]=G}function Rz0($,Z,J,Y,X){let Q=!1;for(let W of Y)if(Array.isArray(W.items)){Q=!0;break}if(!Q){J[$]=K6(Z,X);return}let G=[];for(let W of Y){let K=W.additionalItems;if(K===void 0&&!Array.isArray(W.items))K=W.items;if(K!==void 0)G.push(K)}J[$]=K6(G,X)}function Pz0($,Z){let{properties:J,patternProperties:Y,additionalProperties:X}=$;if(J?.[Z]!==void 0)return J[Z];for(let Q of Object.keys(Y??{}))if(new RegExp(Q).test(Z))return Y[Q];return X}function Cz0($,Z,J,Y,X){let Q={};for(let W of Y){let K=W.properties??{};for(let V of Object.keys(K)){if(Q[V]!==void 0)continue;let U=K[V];Q[V]=[U];for(let H of Y){if(W===H)continue;let B=Pz0(H,V);if(B!==void 0)Q[V].push(B)}}}let G={};for(let W of Object.keys(Q)){let K=Q[W];G[W]=K6(K,X)}J[$]=G}function DW($,Z,J,Y,X){let Q={};for(let W of Z)for(let K of Object.keys(W)){if(Q[K]===void 0)Q[K]=[];Q[K].push(W[K])}let G={};for(let W of Object.keys(Q)){let K=Q[W],V=K6(K,X);G[W]=V}J[$]=G}function Iz0($,Z,J,Y,X){for(let Q=0;Q<Y.length;Q++){let G={if:Y[Q].if,then:Y[Q].then,else:Y[Q].else};if(G.if===void 0)continue;if(J.if===void 0){if(J.if=G.if,G.then!==void 0)J.then=G.then;if(G.else!==void 0)J.else=G.else;continue}if(J.then!==void 0)J.then=K6([J.then,G],X);if(J.else!==void 0)J.else=K6([J.else,G],X)}}function ky($,Z,J){let Y={};for(let X of Z)for(let Q of Object.keys(X)){if(Y[Q]===void 0)Y[Q]=[];let G=Y[Q];for(let W of X[Q])if(!G.includes(W))G.push(W)}J[$]=Y}function K6($,Z){if($.length===0)return{};if($.length===1)return $[0];let J={},Y={},X=!0;for(let Q of $){if(Q===!1)return!1;if(Q===!0)continue;X=!1;for(let G of Object.keys(Q)){if(Y[G]===void 0)Y[G]=[];Y[G].push(Q[G])}}if(X)return!0;for(let Q of Object.keys(Y)){let G=Y[Q];(Z.resolvers[Q]??Z.defaultResolver)(Q,G,J,$,Z)}return J}function yy($,Z,J,Y,X){let Q=X.onConflict??"throw";if(Z.length===1||Q==="first"){J[$]=Z[0];return}let G=!0;for(let W=1;W<Z.length;W++)if(!Dz0(Z[W],Z[0])){G=!1;break}if(G){J[$]=Z[0];return}if(Q==="throw")throw new wW.ResolverNotFoundError($,Z);if(Q==="skip")return;throw new wW.InvalidOnConflictOptionError(Q)}function Ez0($,Z={}){if(Z.defaultResolver===void 0)Z.defaultResolver=yy;return Z.resolvers={...vy,...Z.resolvers},K6($,Z)}xy.exports={mergeSchemas:Ez0,keywordsResolvers:vy,defaultResolver:yy,...wW}});var uy=S((Hx0,gy)=>{var{mergeSchemas:bz0}=hy();function _z0($){return bz0($,{onConflict:"skip"})}gy.exports=_z0});var my=S((Bx0,e3)=>{function Sz0($,Z,J,Y){let X="";if(Z.validatorSchemasIds.size>0)X+=`const Validator = require('fast-json-stringify/lib/validator')
|
|
120
|
+
`,X+=`const validatorState = ${JSON.stringify(Y.getState())}
|
|
121
|
+
`,X+=`const validator = Validator.restoreFromState(validatorState)
|
|
122
|
+
`;else X+=`const validator = null
|
|
123
|
+
`;let{schema:Q,...G}=J.getState();return`
|
|
124
|
+
'use strict'
|
|
125
|
+
|
|
126
|
+
const Serializer = require('fast-json-stringify/lib/serializer')
|
|
127
|
+
const serializerState = ${JSON.stringify(G)}
|
|
128
|
+
const serializer = Serializer.restoreFromState(serializerState)
|
|
129
|
+
|
|
130
|
+
${X}
|
|
131
|
+
|
|
132
|
+
module.exports = ${$.toString()}(validator, serializer)`}e3.exports=Sz0;e3.exports.dependencies={Serializer:VG(),Validator:n3()}});var ry=S((zx0,JY)=>{var{RefResolver:fz0}=jy(),kz0=VG(),vz0=n3(),V7=My(),ly=Ry(),yz0=uy(),xz0=/'/g,T9=20000,LW="default",hz0=`
|
|
133
|
+
const {
|
|
134
|
+
asString,
|
|
135
|
+
asNumber,
|
|
136
|
+
asBoolean,
|
|
137
|
+
asDateTime,
|
|
138
|
+
asDate,
|
|
139
|
+
asTime,
|
|
140
|
+
asUnsafeString
|
|
141
|
+
} = serializer
|
|
142
|
+
|
|
143
|
+
const asInteger = serializer.asInteger.bind(serializer)
|
|
144
|
+
|
|
145
|
+
`,gz0=new Set(["floor","ceil","round","trunc"]),iy=new Set(["default","json-stringify"]),R9=0;function $F($,Z){if(!ly($)){if(Z)Z=`"${Z}" `;else Z="";let J=ly.errors[0],Y=Error(`${Z}schema is invalid: data${J.instancePath} ${J.message}`);throw Y.errors=$F.errors,Y}}function HZ($,Z){let J=Z.schema.$ref,Y=J.indexOf("#");if(Y===-1)Y=J.length;let X=J.slice(0,Y)||Z.schemaId,Q=J.slice(Y)||"#",G=$.refResolver.getSchema(X,Q);if(G===null)throw Error(`Cannot find reference "${J}"`);let W=new V7(G,X,Q);if(G.$ref!==void 0)return HZ($,W);return W}function TW($,Z){let J=$.refResolver.getSchema(Z,"#");return new V7(J,Z,"#")}function dy($,Z){if($.$id&&$.$id.charAt(0)!=="#")return $.$id;return Z}function P9($,Z){let J=Z.getSchemaRef()||"";if(J.startsWith($.rootSchemaId))J=J.replace($.rootSchemaId,"")||"#";return J}function JF($,Z){$F($),Z=Z||{};let J={functions:[],functionsCounter:0,functionsNamesBySchema:new Map,options:Z,refResolver:new fz0,rootSchemaId:$.$id||`__fjs_root_${R9++}`,validatorSchemasIds:new Set,mergedSchemasIds:new Map,recursiveSchemas:new Set,recursivePaths:new Set,buildingSet:new Set,uid:0},Y=dy($,J.rootSchemaId);if(!J.refResolver.hasSchema(Y))J.refResolver.addSchema($,J.rootSchemaId);if(Z.schema)for(let U in Z.schema){let H=Z.schema[U],B=dy(H,U);if(!J.refResolver.hasSchema(B))$F(H,U),J.refResolver.addSchema(H,U)}if(Z.rounding){if(!gz0.has(Z.rounding))throw Error(`Unsupported integer rounding method ${Z.rounding}`)}if(Z.largeArrayMechanism)if(iy.has(Z.largeArrayMechanism))LW=Z.largeArrayMechanism;else throw Error(`Unsupported large array mechanism ${Z.largeArrayMechanism}`);if(Z.largeArraySize){let U=typeof Z.largeArraySize,H;if(U==="string"&&Number.isFinite(H=Number.parseInt(Z.largeArraySize,10)))T9=H;else if(U==="number"&&Number.isInteger(Z.largeArraySize))T9=Z.largeArraySize;else if(U==="bigint")T9=Number(Z.largeArraySize);else throw Error(`Unsupported large array size. Expected integer-like, got ${typeof Z.largeArraySize} with value ${Z.largeArraySize}`)}let X=new V7($,J.rootSchemaId);sz0(J,X);let Q=i$(J,X,"input"),G=`
|
|
146
|
+
${hz0}
|
|
147
|
+
const JSON_STR_BEGIN_OBJECT = '{'
|
|
148
|
+
const JSON_STR_END_OBJECT = '}'
|
|
149
|
+
const JSON_STR_BEGIN_ARRAY = '['
|
|
150
|
+
const JSON_STR_END_ARRAY = ']'
|
|
151
|
+
const JSON_STR_COMMA = ','
|
|
152
|
+
const JSON_STR_COLONS = ':'
|
|
153
|
+
const JSON_STR_QUOTE = '"'
|
|
154
|
+
const JSON_STR_EMPTY_OBJECT = JSON_STR_BEGIN_OBJECT + JSON_STR_END_OBJECT
|
|
155
|
+
const JSON_STR_EMPTY_ARRAY = JSON_STR_BEGIN_ARRAY + JSON_STR_END_ARRAY
|
|
156
|
+
const JSON_STR_EMPTY_STRING = JSON_STR_QUOTE + JSON_STR_QUOTE
|
|
157
|
+
const JSON_STR_NULL = 'null'
|
|
158
|
+
`;if(Q==="json += anonymous0(input)")G+=`
|
|
159
|
+
${J.functions.join(`
|
|
160
|
+
`)}
|
|
161
|
+
const main = anonymous0
|
|
162
|
+
return main
|
|
163
|
+
`;else G+=`
|
|
164
|
+
function main (input) {
|
|
165
|
+
let json = ''
|
|
166
|
+
${Q}
|
|
167
|
+
return json
|
|
168
|
+
}
|
|
169
|
+
${J.functions.join(`
|
|
170
|
+
`)}
|
|
171
|
+
return main
|
|
172
|
+
`;let W=new kz0(Z),K=new vz0(Z.ajv);for(let U of J.validatorSchemasIds){let H=J.refResolver.getSchema(U);K.addSchema(H,U);let B=J.refResolver.getSchemaDependencies(U);for(let[z,F]of Object.entries(B))K.addSchema(F,z)}if(Z.debugMode)Z.mode="debug";if(Z.mode==="debug")return{validator:K,serializer:W,code:`validator
|
|
173
|
+
serializer
|
|
174
|
+
${G}`,ajv:K.ajv};let V=Function("validator","serializer",G);if(Z.mode==="standalone")return my()(V,J,W,K);return V(K,W)}var uz0=["properties","required","additionalProperties","patternProperties","maxProperties","minProperties","dependencies"],mz0=["items","additionalItems","maxItems","minItems","uniqueItems","contains"],lz0=["maxLength","minLength","pattern"],dz0=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum"];function pz0($){for(let Z of uz0)if(Z in $)return"object";for(let Z of mz0)if(Z in $)return"array";for(let Z of lz0)if(Z in $)return"string";for(let Z of dz0)if(Z in $)return"number";return $.type}function cz0($,Z,J,Y){let X=Z.schema,Q=Object.keys(X.properties||{}),G=`
|
|
175
|
+
for (const key of Object.keys(${Y})) {
|
|
176
|
+
if (
|
|
177
|
+
${Q.length>0?Q.map((H)=>`key === ${JSON.stringify(H)}`).join(" || ")+" ||":""}
|
|
178
|
+
${Y}[key] === undefined ||
|
|
179
|
+
typeof ${Y}[key] === 'function' ||
|
|
180
|
+
typeof ${Y}[key] === 'symbol'
|
|
181
|
+
) continue
|
|
182
|
+
const value = ${Y}[key]
|
|
183
|
+
`,W=Z.getPropertyLocation("patternProperties"),K=W.schema;if(K!==void 0)for(let H in K){let B=W.getPropertyLocation(H);G+=`
|
|
184
|
+
if (/${H.replace(/\\*\//g,"\\/")}/.test(key)) {
|
|
185
|
+
${J}
|
|
186
|
+
json += asString(key) + JSON_STR_COLONS
|
|
187
|
+
${i$($,B,"value")}
|
|
188
|
+
continue
|
|
189
|
+
}
|
|
190
|
+
`}let U=Z.getPropertyLocation("additionalProperties").schema;if(U!==void 0)if(U===!0)G+=`
|
|
191
|
+
${J}
|
|
192
|
+
json += asString(key) + JSON_STR_COLONS + JSON.stringify(value)
|
|
193
|
+
`;else{let H=Z.getPropertyLocation("additionalProperties");G+=`
|
|
194
|
+
${J}
|
|
195
|
+
json += asString(key) + JSON_STR_COLONS
|
|
196
|
+
${i$($,H,"value")}
|
|
197
|
+
`}return G+=`
|
|
198
|
+
}
|
|
199
|
+
`,G}function py($,Z,J){let Y=Z.schema,X=Z.getPropertyLocation("properties"),Q=Y.required||[],G=Object.keys(Y.properties||{}).sort((U,H)=>{let B=Q.includes(U),z=Q.includes(H);return B===z?0:B?-1:1}),W="";for(let U of Q)if(!G.includes(U)){let H=JSON.stringify(U);W+=`if (${J}[${H}] === undefined) throw new Error('${H.replace(/'/g,"\\'")} is required!')
|
|
200
|
+
`}W+=`json += JSON_STR_BEGIN_OBJECT
|
|
201
|
+
`;let K=$.uid++,V="";if(Q.length>0){for(let U=0;U<G.length;U++){let H=G[U],B=X.getPropertyLocation(H),z=B;if(B.schema.$ref)z=HZ($,B);let F=JSON.stringify(H),A=`value_${H.replace(/[^a-zA-Z0-9]/g,"_")}_${$.uid++}`,N=z.schema.default,q=Q.includes(H),w=U===0?"":"json += JSON_STR_COMMA";if(W+=`
|
|
202
|
+
const ${A} = ${J}[${F}]
|
|
203
|
+
if (${A} !== undefined) {
|
|
204
|
+
${w}
|
|
205
|
+
json += ${JSON.stringify(F+":")}
|
|
206
|
+
${i$($,z,`${A}`)}
|
|
207
|
+
}`,N!==void 0)W+=` else {
|
|
208
|
+
${w}
|
|
209
|
+
json += ${JSON.stringify(F+":"+JSON.stringify(N))}
|
|
210
|
+
}
|
|
211
|
+
`;else if(q)W+=` else {
|
|
212
|
+
throw new Error('${F.replace(/'/g,"\\'")} is required!')
|
|
213
|
+
}
|
|
214
|
+
`;else W+=`
|
|
215
|
+
`}V="json += JSON_STR_COMMA"}else{if(G.length>1||Y.patternProperties||Y.additionalProperties!==void 0&&Y.additionalProperties!==!1)W+=`let addComma_${K} = false
|
|
216
|
+
`,V=`!addComma_${K} && (addComma_${K} = true) || (json += JSON_STR_COMMA)`;for(let H of G){let B=X.getPropertyLocation(H);if(B.schema.$ref)B=HZ($,B);let z=JSON.stringify(H),F=`value_${H.replace(/[^a-zA-Z0-9]/g,"_")}_${$.uid++}`,A=B.schema.default,N=Q.includes(H);if(W+=`
|
|
217
|
+
const ${F} = ${J}[${z}]
|
|
218
|
+
if (${F} !== undefined) {
|
|
219
|
+
${V}
|
|
220
|
+
json += ${JSON.stringify(z+":")}
|
|
221
|
+
${i$($,B,`${F}`)}
|
|
222
|
+
}`,A!==void 0)W+=` else {
|
|
223
|
+
${V}
|
|
224
|
+
json += ${JSON.stringify(z+":"+JSON.stringify(A))}
|
|
225
|
+
}
|
|
226
|
+
`;else if(N)W+=` else {
|
|
227
|
+
throw new Error('${z.replace(/'/g,"\\'")} is required!')
|
|
228
|
+
}
|
|
229
|
+
`;else W+=`
|
|
230
|
+
`}}if(Y.patternProperties||Y.additionalProperties)W+=cz0($,Z,V,J);return W+=`
|
|
231
|
+
json += JSON_STR_END_OBJECT
|
|
232
|
+
`,W}function RW($,Z,J){for(let G=0,W=J.length;G<W;G++){let K=J[G];if(K.schema.$ref)J[G]=HZ($,K)}let Y=[];for(let G of J){let W=ny($,G.schema,G.schemaId);delete W.$id,Y.push(W)}let X=yz0(Y),Q=new V7(X,Z);return $.refResolver.addSchema(X,Z),Q}function ny($,Z,J){let Y=Array.isArray(Z)?[]:{};if(Z.$id!==void 0&&Z.$id.charAt(0)!=="#")J=Z.$id;let X=$.mergedSchemasIds.get(Z);if(X)$.mergedSchemasIds.set(Y,X);for(let Q in Z){let G=Z[Q];if(Q==="$ref"&&typeof G==="string"&&G.charAt(0)==="#")G=J+G;if(typeof G==="object"&&G!==null)G=ny($,G,J);Y[Q]=G}return Y}function cy($){return`(${$} && typeof ${$}.toJSON === 'function')
|
|
233
|
+
? ${$}.toJSON()
|
|
234
|
+
: ${$}
|
|
235
|
+
`}function iz0($,Z,J){let Y=Z.schema;if($.functionsNamesBySchema.has(Y))return`json += ${$.functionsNamesBySchema.get(Y)}(${J})`;let X=Y.nullable===!0,Q=Z.schemaId||"",G=Z.jsonPointer||"",W=`${Q}#${G}`;if($.recursivePaths.has(W)||$.buildingSet.has(Y)||Q!==""){let U=oy($);$.functionsNamesBySchema.set(Y,U);let B=`
|
|
236
|
+
// ${P9($,Z)}
|
|
237
|
+
function ${U} (input) {
|
|
238
|
+
const obj = ${cy("input")}
|
|
239
|
+
if (obj === null) return ${X?"JSON_STR_NULL":"JSON_STR_EMPTY_OBJECT"}
|
|
240
|
+
let json = ''
|
|
241
|
+
|
|
242
|
+
${py($,Z,"obj")}
|
|
243
|
+
return json
|
|
244
|
+
}
|
|
245
|
+
`;return $.functions.push(B),`json += ${U}(${J})`}$.buildingSet.add(Y);let K=`obj_${$.uid++}`,V=`
|
|
246
|
+
const ${K} = ${cy(J)}
|
|
247
|
+
if (${K} === null) {
|
|
248
|
+
json += ${X?"JSON_STR_NULL":"JSON_STR_EMPTY_OBJECT"}
|
|
249
|
+
} else {
|
|
250
|
+
${py($,Z,K)}
|
|
251
|
+
}
|
|
252
|
+
`;return $.buildingSet.delete(Y),V}function nz0($,Z,J){let Y=Z.schema,X=Z.getPropertyLocation("items");if(X.schema=X.schema||{},X.schema.$ref)X=HZ($,X);let Q=X.schema;if($.functionsNamesBySchema.has(Y))return`json += ${$.functionsNamesBySchema.get(Y)}(${J})`;let G=Y.nullable===!0,W=Z.schemaId||"",K=Z.jsonPointer||"",V=`${W}#${K}`;if($.recursivePaths.has(V)||$.buildingSet.has(Y)||W!==""){let z=oy($);$.functionsNamesBySchema.set(Y,z);let F=P9($,Z),A=`
|
|
253
|
+
function ${z} (obj) {
|
|
254
|
+
// ${F}
|
|
255
|
+
let json = ''
|
|
256
|
+
`;if(A+=`
|
|
257
|
+
if (obj === null) return ${G?"JSON_STR_NULL":"JSON_STR_EMPTY_ARRAY"}
|
|
258
|
+
if (!Array.isArray(obj)) {
|
|
259
|
+
throw new TypeError(\`The value of '${F}' does not match schema definition.\`)
|
|
260
|
+
}
|
|
261
|
+
const arrayLength = obj.length
|
|
262
|
+
`,!Y.additionalItems&&Array.isArray(Q))A+=`
|
|
263
|
+
if (arrayLength > ${Q.length}) {
|
|
264
|
+
throw new Error(\`Item at ${Q.length} does not match schema definition.\`)
|
|
265
|
+
}
|
|
266
|
+
`;if(LW==="json-stringify")A+=`if (arrayLength >= ${T9}) return JSON.stringify(obj)
|
|
267
|
+
`;if(A+=`
|
|
268
|
+
json += JSON_STR_BEGIN_ARRAY
|
|
269
|
+
`,Array.isArray(Q)){for(let N=0,q=Q.length;N<q;N++){let w=Q[N],j=X.getPropertyLocation(N);if(j.schema.$ref)j=HZ($,j),w=j.schema;let M=`value_${N}`;A+=`const ${M} = obj[${N}]`;let I=i$($,j,M);A+=`
|
|
270
|
+
if (${N} < arrayLength) {
|
|
271
|
+
if (${ZF(w.type,M)}) {
|
|
272
|
+
if (${N}) {
|
|
273
|
+
json += JSON_STR_COMMA
|
|
274
|
+
}
|
|
275
|
+
${I}
|
|
276
|
+
} else {
|
|
277
|
+
throw new Error(\`Item at ${N} does not match schema definition.\`)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
`}if(Y.additionalItems)A+=`
|
|
281
|
+
for (let i = ${Q.length}; i < arrayLength; i++) {
|
|
282
|
+
if (i) {
|
|
283
|
+
json += JSON_STR_COMMA
|
|
284
|
+
}
|
|
285
|
+
json += JSON.stringify(obj[i])
|
|
286
|
+
}`}else{let N=i$($,X,"value");A+=`
|
|
287
|
+
if (arrayLength > 0) {
|
|
288
|
+
const value = obj[0]
|
|
289
|
+
${N}
|
|
290
|
+
for (let i = 1; i < arrayLength; i++) {
|
|
291
|
+
json += JSON_STR_COMMA
|
|
292
|
+
const value = obj[i]
|
|
293
|
+
${N}
|
|
294
|
+
}
|
|
295
|
+
}`}return A+=`
|
|
296
|
+
return json + JSON_STR_END_ARRAY
|
|
297
|
+
}`,$.functions.push(A),`json += ${z}(${J})`}$.buildingSet.add(Y);let U=P9($,Z),H=`obj_${$.uid++}`,B=`
|
|
298
|
+
const ${H} = ${J}
|
|
299
|
+
if (${H} === null) {
|
|
300
|
+
json += ${G?"JSON_STR_NULL":"JSON_STR_EMPTY_ARRAY"}
|
|
301
|
+
} else if (!Array.isArray(${H})) {
|
|
302
|
+
throw new TypeError(\`The value of '${U}' does not match schema definition.\`)
|
|
303
|
+
} else {
|
|
304
|
+
const arrayLength_${H} = ${H}.length
|
|
305
|
+
`;if(!Y.additionalItems&&Array.isArray(Q))B+=`
|
|
306
|
+
if (arrayLength_${H} > ${Q.length}) {
|
|
307
|
+
throw new Error(\`Item at ${Q.length} does not match schema definition.\`)
|
|
308
|
+
}
|
|
309
|
+
`;if(LW==="json-stringify")B+=`if (arrayLength_${H} >= ${T9}) json += JSON.stringify(${H})
|
|
310
|
+
else {`;if(B+=`
|
|
311
|
+
json += JSON_STR_BEGIN_ARRAY
|
|
312
|
+
`,Array.isArray(Q)){let z=$.uid++;B+=`let addComma_${z} = false
|
|
313
|
+
`;for(let F=0,A=Q.length;F<A;F++){let N=Q[F],q=X.getPropertyLocation(F);if(q.schema.$ref)q=HZ($,q),N=q.schema;let w=`value_${F}_${$.uid++}`;B+=`const ${w} = ${H}[${F}]`;let j=i$($,q,w);B+=`
|
|
314
|
+
if (${F} < arrayLength_${H}) {
|
|
315
|
+
if (${ZF(N.type,w)}) {
|
|
316
|
+
!addComma_${z} && (addComma_${z} = true) || (json += JSON_STR_COMMA)
|
|
317
|
+
${j}
|
|
318
|
+
} else {
|
|
319
|
+
throw new Error(\`Item at ${F} does not match schema definition.\`)
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
`}if(Y.additionalItems)B+=`
|
|
323
|
+
for (let i = ${Q.length}; i < arrayLength_${H}; i++) {
|
|
324
|
+
!addComma_${z} && (addComma_${z} = true) || (json += JSON_STR_COMMA)
|
|
325
|
+
json += JSON.stringify(${H}[i])
|
|
326
|
+
}`}else{let z=i$($,X,"value");B+=`
|
|
327
|
+
if (arrayLength_${H} > 0) {
|
|
328
|
+
const value = ${H}[0]
|
|
329
|
+
${z}
|
|
330
|
+
for (let i = 1; i < arrayLength_${H}; i++) {
|
|
331
|
+
json += JSON_STR_COMMA
|
|
332
|
+
const value = ${H}[i]
|
|
333
|
+
${z}
|
|
334
|
+
}
|
|
335
|
+
}`}if(B+=`
|
|
336
|
+
json += JSON_STR_END_ARRAY
|
|
337
|
+
`,LW==="json-stringify")B+="}";return B+="}",$.buildingSet.delete(Y),B}function ZF($,Z){let J;switch($){case"null":J=`${Z} === null`;break;case"string":J=`typeof ${Z} === 'string' ||
|
|
338
|
+
${Z} === null ||
|
|
339
|
+
${Z} instanceof Date ||
|
|
340
|
+
${Z} instanceof RegExp ||
|
|
341
|
+
(
|
|
342
|
+
typeof ${Z} === "object" &&
|
|
343
|
+
typeof ${Z}.toString === "function" &&
|
|
344
|
+
${Z}.toString !== Object.prototype.toString
|
|
345
|
+
)`;break;case"integer":J=`Number.isInteger(${Z})`;break;case"number":J=`Number.isFinite(${Z})`;break;case"boolean":J=`typeof ${Z} === 'boolean'`;break;case"object":J=`${Z} && typeof ${Z} === 'object' && ${Z}.constructor === Object`;break;case"array":J=`Array.isArray(${Z})`;break;default:if(Array.isArray($))J=`(${$.map((X)=>{return ZF(X,Z)}).join(" || ")})`}return J}function oy($){return"anonymous"+$.functionsCounter++}function oz0($,Z,J){let X=Z.schema.type.sort((G)=>G==="null"?-1:1),Q="";return X.forEach((G,W)=>{Z.schema={...Z.schema,type:G};let K=sy($,Z,J),V=W===0?"if":"else if";switch(G){case"null":Q+=`
|
|
346
|
+
${V} (${J} === null) {
|
|
347
|
+
${K}
|
|
348
|
+
}
|
|
349
|
+
`;break;case"string":{Q+=`
|
|
350
|
+
${V}(
|
|
351
|
+
typeof ${J} === "string" ||
|
|
352
|
+
${J} === null ||
|
|
353
|
+
${J} instanceof Date ||
|
|
354
|
+
${J} instanceof RegExp ||
|
|
355
|
+
(
|
|
356
|
+
typeof ${J} === "object" &&
|
|
357
|
+
typeof ${J}.toString === "function" &&
|
|
358
|
+
${J}.toString !== Object.prototype.toString
|
|
359
|
+
)
|
|
360
|
+
) {
|
|
361
|
+
${K}
|
|
362
|
+
}
|
|
363
|
+
`;break}case"array":{Q+=`
|
|
364
|
+
${V}(Array.isArray(${J})) {
|
|
365
|
+
${K}
|
|
366
|
+
}
|
|
367
|
+
`;break}case"integer":{Q+=`
|
|
368
|
+
${V}(Number.isInteger(${J}) || ${J} === null) {
|
|
369
|
+
${K}
|
|
370
|
+
}
|
|
371
|
+
`;break}default:{Q+=`
|
|
372
|
+
${V}(typeof ${J} === "${G}" || ${J} === null) {
|
|
373
|
+
${K}
|
|
374
|
+
}
|
|
375
|
+
`;break}}}),Q+=`
|
|
376
|
+
else throw new TypeError(\`The value of '${P9($,Z)}' does not match schema definition.\`)
|
|
377
|
+
`,Q}function sy($,Z,J){let Y=Z.schema;switch(Y.type){case"null":return"json += JSON_STR_NULL";case"string":if(Y.format==="date-time")return`json += asDateTime(${J})`;else if(Y.format==="date")return`json += asDate(${J})`;else if(Y.format==="time")return`json += asTime(${J})`;else if(Y.format==="unsafe")return`json += asUnsafeString(${J})`;else return`
|
|
378
|
+
if (typeof ${J} !== 'string') {
|
|
379
|
+
if (${J} === null) {
|
|
380
|
+
json += JSON_STR_EMPTY_STRING
|
|
381
|
+
} else if (${J} instanceof Date) {
|
|
382
|
+
json += JSON_STR_QUOTE + ${J}.toISOString() + JSON_STR_QUOTE
|
|
383
|
+
} else if (${J} instanceof RegExp) {
|
|
384
|
+
json += asString(${J}.source)
|
|
385
|
+
} else {
|
|
386
|
+
json += asString(${J}.toString())
|
|
387
|
+
}
|
|
388
|
+
} else {
|
|
389
|
+
json += asString(${J})
|
|
390
|
+
}
|
|
391
|
+
`;case"integer":return`json += asInteger(${J})`;case"number":return`json += asNumber(${J})`;case"boolean":return`json += asBoolean(${J})`;case"object":return iz0($,Z,J);case"array":return nz0($,Z,J);case void 0:return`json += JSON.stringify(${J})`;default:throw Error(`${Y.type} unsupported`)}}function sz0($,Z){let J=new Set;function Y(X){let Q=X.schema;if(typeof Q!=="object"||Q===null)return;let G=X.schemaId||"",W=X.jsonPointer||"",K=`${G}#${W}`;if(J.has(K)){let V=!1;for(let U of J){if(U===K)V=!0;if(V)$.recursivePaths.add(U)}$.recursivePaths.add(K);return}if(J.add(K),Q.$ref)try{let V=HZ($,X);Y(V)}catch(V){}if(Q.properties){let V=X.getPropertyLocation("properties");for(let U in Q.properties)Y(V.getPropertyLocation(U))}if(Q.additionalProperties&&typeof Q.additionalProperties==="object")Y(X.getPropertyLocation("additionalProperties"));if(Q.patternProperties){let V=X.getPropertyLocation("patternProperties");for(let U in Q.patternProperties)Y(V.getPropertyLocation(U))}if(Q.items){let V=X.getPropertyLocation("items");if(Array.isArray(Q.items))for(let U=0;U<Q.items.length;U++)Y(V.getPropertyLocation(U));else Y(V)}if(Q.additionalItems&&typeof Q.additionalItems==="object")Y(X.getPropertyLocation("additionalItems"));if(Q.oneOf){let V=X.getPropertyLocation("oneOf");for(let U=0;U<Q.oneOf.length;U++)Y(V.getPropertyLocation(U))}if(Q.anyOf){let V=X.getPropertyLocation("anyOf");for(let U=0;U<Q.anyOf.length;U++)Y(V.getPropertyLocation(U))}if(Q.allOf){let V=X.getPropertyLocation("allOf");for(let U=0;U<Q.allOf.length;U++)Y(V.getPropertyLocation(U))}if(Q.then)Y(X.getPropertyLocation("then"));if(Q.else)Y(X.getPropertyLocation("else"));J.delete(K)}Y(Z)}function rz0($,Z){let J=$.schema,Y=J.type,X=Array.isArray(Y)&&Y.includes("null"),Q="";if(X)Q+=`
|
|
392
|
+
if (${Z} === null) {
|
|
393
|
+
json += JSON_STR_NULL
|
|
394
|
+
} else {
|
|
395
|
+
`;if(Q+=`json += '${JSON.stringify(J.const).replace(xz0,"\\'")}'`,X)Q+=`
|
|
396
|
+
}
|
|
397
|
+
`;return Q}function az0($,Z,J){let Y=Z.schema,X=$.mergedSchemasIds.get(Y);if(X){let U=TW($,X);return i$($,U,J)}X=`__fjs_merged_${R9++}`,$.mergedSchemasIds.set(Y,X);let{allOf:Q,...G}=Z.schema,W=[new V7(G,Z.schemaId,Z.jsonPointer)],K=Z.getPropertyLocation("allOf");for(let U=0,H=Q.length;U<H;U++)W.push(K.getPropertyLocation(U));let V=RW($,X,W);return i$($,V,J)}function tz0($,Z,J){$.validatorSchemasIds.add(Z.schemaId);let X=Z.schema.anyOf?"anyOf":"oneOf",{[X]:Q,...G}=Z.schema,W=new V7(G,Z.schemaId,Z.jsonPointer),K=Z.getPropertyLocation(X),V="";for(let U=0,H=Q.length;U<H;U++){let B=K.getPropertyLocation(U),z=B.schema,F=$.mergedSchemasIds.get(z),A=null;if(F)A=TW($,F);else F=`__fjs_merged_${R9++}`,$.mergedSchemasIds.set(z,F),A=RW($,F,[W,B]);let N=i$($,A,J),q=B.getSchemaRef();V+=`
|
|
398
|
+
${U===0?"if":"else if"}(validator.validate("${q}", ${J})) {
|
|
399
|
+
${N}
|
|
400
|
+
}
|
|
401
|
+
`}return V+=`
|
|
402
|
+
else throw new TypeError(\`The value of '${P9($,Z)}' does not match schema definition.\`)
|
|
403
|
+
`,V}function ez0($,Z,J){$.validatorSchemasIds.add(Z.schemaId);let{if:Y,then:X,else:Q,...G}=Z.schema,W=new V7(G,Z.schemaId,Z.jsonPointer),V=Z.getPropertyLocation("if").getSchemaRef(),U=Z.getPropertyLocation("then"),H=$.mergedSchemasIds.get(X),B=null;if(H)B=TW($,H);else H=`__fjs_merged_${R9++}`,$.mergedSchemasIds.set(X,H),B=RW($,H,[W,U]);if(!Q)return`
|
|
404
|
+
if (validator.validate("${V}", ${J})) {
|
|
405
|
+
${i$($,B,J)}
|
|
406
|
+
} else {
|
|
407
|
+
${i$($,W,J)}
|
|
408
|
+
}
|
|
409
|
+
`;let z=Z.getPropertyLocation("else"),F=$.mergedSchemasIds.get(Q),A=null;if(F)A=TW($,F);else F=`__fjs_merged_${R9++}`,$.mergedSchemasIds.set(Q,F),A=RW($,F,[W,z]);return`
|
|
410
|
+
if (validator.validate("${V}", ${J})) {
|
|
411
|
+
${i$($,B,J)}
|
|
412
|
+
} else {
|
|
413
|
+
${i$($,A,J)}
|
|
414
|
+
}
|
|
415
|
+
`}function i$($,Z,J){let Y=Z.schema;if(typeof Y==="boolean")return`json += JSON.stringify(${J})`;if(Y.$ref)Z=HZ($,Z),Y=Z.schema;if(Y.allOf)return az0($,Z,J);if(Y.anyOf||Y.oneOf)return tz0($,Z,J);if(Y.if&&Y.then)return ez0($,Z,J);if(Y.type===void 0){let W=pz0(Y);if(W)Y.type=W}let X="",Q=Y.type,G=Y.nullable===!0;if(G)X+=`
|
|
416
|
+
if (${J} === null) {
|
|
417
|
+
json += JSON_STR_NULL
|
|
418
|
+
} else {
|
|
419
|
+
`;if(Y.const!==void 0)X+=rz0(Z,J);else if(Array.isArray(Q))X+=oz0($,Z,J);else X+=sy($,Z,J);if(G)X+=`
|
|
420
|
+
}
|
|
421
|
+
`;return X}JY.exports=JF;JY.exports.default=JF;JY.exports.build=JF;JY.exports.validLargeArrayMechanisms=iy;JY.exports.restore=function({code:$,validator:Z,serializer:J}){return Function.apply(null,["validator","serializer",$]).apply(null,[Z,J])}});var ey=S((J30,PW)=>{var $30=ry();function ay(){return function(Z,J){let Y=Object.assign({},J,{schema:Z});return Z30.bind(null,Y)}}function Z30($,{schema:Z}){if($.schema&&Z.$id&&$.schema[Z.$id])$.schema={...$.schema},delete $.schema[Z.$id];return $30(Z,$)}function ty($={readMode:!0}){if($.readMode===!0&&typeof $.restoreFunction!=="function")throw Error("You must provide a function for the restoreFunction-option when readMode ON");if($.readMode!==!0&&typeof $.storeFunction!=="function")throw Error("You must provide a function for the storeFunction-option when readMode OFF");if($.readMode===!0)return function(){return function(Y){return $.restoreFunction(Y)}};let Z=ay();return function(Y,X={}){X.mode="standalone";let Q=Z(Y,X);return function(G){let W=Q(G);return $.storeFunction(G,W),Function(W)}}}J30.SerializerSelector=ay;J30.StandaloneSerializer=ty;J30.default=ty});var $x=S((Fx0,C9)=>{var{SerializerSelector:YF,StandaloneSerializer:G30}=ey();C9.exports=YF;C9.exports.default=YF;C9.exports.SerializerSelector=YF;C9.exports.StandaloneSerializer=G30});var XF=S((Ax0,Zx)=>{var{buildSchemas:W30}=xX();function K30($,Z){if($)return new I9($,Z);let J=Object.assign({buildValidator:null,buildSerializer:null},Z?.compilersFactory);if(!J.buildValidator){let X=p3();J.buildValidator=X()}if(!J.buildSerializer){let X=$x();J.buildSerializer=X()}let Y={bucket:Z&&Z.bucket||W30,compilersFactory:J,isCustomValidatorCompiler:typeof Z?.compilersFactory?.buildValidator==="function",isCustomSerializerCompiler:typeof Z?.compilersFactory?.buildValidator==="function"};return new I9(void 0,Y)}class I9{constructor($,Z){if(this.opts=Z||$?.opts,this.addedSchemas=!1,this.compilersFactory=this.opts.compilersFactory,$)this.schemaBucket=this.opts.bucket($.getSchemas()),this.validatorCompiler=$.getValidatorCompiler(),this.serializerCompiler=$.getSerializerCompiler(),this.isCustomValidatorCompiler=$.isCustomValidatorCompiler,this.isCustomSerializerCompiler=$.isCustomSerializerCompiler,this.parent=$;else this.schemaBucket=this.opts.bucket(),this.isCustomValidatorCompiler=this.opts.isCustomValidatorCompiler||!1,this.isCustomSerializerCompiler=this.opts.isCustomSerializerCompiler||!1}add($){return this.addedSchemas=!0,this.schemaBucket.add($)}getSchema($){return this.schemaBucket.getSchema($)}getSchemas(){return this.schemaBucket.getSchemas()}setValidatorCompiler($){this.compilersFactory=Object.assign({},this.compilersFactory,{buildValidator:()=>$}),this.validatorCompiler=$,this.isCustomValidatorCompiler=!0}setSerializerCompiler($){this.compilersFactory=Object.assign({},this.compilersFactory,{buildSerializer:()=>$}),this.serializerCompiler=$,this.isCustomSerializerCompiler=!0}getValidatorCompiler(){return this.validatorCompiler||this.parent&&this.parent.getValidatorCompiler()}getSerializerCompiler(){return this.serializerCompiler||this.parent&&this.parent.getSerializerCompiler()}getSerializerBuilder(){return this.compilersFactory.buildSerializer||this.parent&&this.parent.getSerializerBuilder()}getValidatorBuilder(){return this.compilersFactory.buildValidator||this.parent&&this.parent.getValidatorBuilder()}setupValidator($){if(this.validatorCompiler!==void 0&&!this.addedSchemas)return;this.validatorCompiler=this.getValidatorBuilder()(this.schemaBucket.getSchemas(),$.ajv)}setupSerializer($){if(this.serializerCompiler!==void 0&&!this.addedSchemas)return;this.serializerCompiler=this.getSerializerBuilder()(this.schemaBucket.getSchemas(),$.serializerOpts)}}I9.buildSchemaController=K30;Zx.exports=I9});var UF=S((Ox0,VF)=>{var QF=V30(),WF=J0("assert"),KF=Symbol.for("registered-plugin"),{kTestInternals:U30}=B$(),{exist:H30,existReply:B30,existRequest:z30}=mX(),{FST_ERR_PLUGIN_VERSION_MISMATCH:F30,FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE:A30,FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER:O30}=T$(),j30=/-(?:rc|pre|alpha).+$/u;function E9($){return $[Symbol.for("plugin-meta")]}function Jx($){let Z=Yx($);if(Z)return Z;let J=J0.cache;if(J){let Y=Object.keys(J);for(let X=0;X<Y.length;X++){let Q=Y[X];if(J[Q].exports===$)return Q}}if($.name)return $.name;return null}function N30($){return $.toString().split(`
|
|
422
|
+
`,2).map((Z)=>Z.trim()).join(" -- ")}function Yx($){return $[Symbol.for("fastify.display-name")]}function Xx($){return!!$[Symbol.for("skip-override")]}function Qx($){let Z=E9($);if(!Z)return;let J=Z.dependencies;if(!J)return;WF(Array.isArray(J),"The dependencies should be an array of strings"),J.forEach((Y)=>{WF(this[KF].indexOf(Y)>-1,`The dependency '${Y}' of plugin '${Z.name}' is not registered`)})}function Gx($){let Z=E9($);if(!Z)return;let{decorators:J,name:Y}=Z;if(!J)return;if(J.fastify)GF(this,"Fastify",J.fastify,Y);if(J.reply)GF(this,"Reply",J.reply,Y);if(J.request)GF(this,"Request",J.request,Y)}var q30={Fastify:H30,Request:z30,Reply:B30};function GF($,Z,J,Y){WF(Array.isArray(J),"The decorators should be an array of strings"),J.forEach((X)=>{let Q=typeof Y==="string"?` required by '${Y}'`:"";if(!q30[Z].call($,X))throw new A30(X,Q,Z)})}function M30($){let Z=E9($);if(Z?.fastify==null)return;let J=Z.fastify,Y=j30.test(this.version);if(Y===!0&&QF.gt(this.version,QF.coerce(J))===!0)return;if(J&&QF.satisfies(this.version,J,{includePrerelease:Y})===!1)throw new F30(Z.name,J,this.version)}function D30($){let Z=E9($);if(!Z)return;let J=Z.name;if(!J)return;return this[KF].push(J),J}function w30($,Z){if($.constructor.name==="AsyncFunction"&&$.length===3)throw new O30(Z)}function L30($){let Z=D30.call(this,$)||Jx($);return w30.call(this,$,Z),M30.call(this,$),Gx.call(this,$),Qx.call(this,$),Xx($)}VF.exports={getPluginName:Jx,getFuncPreview:N30,kRegisteredPlugins:KF,getDisplayName:Yx,registerPlugin:L30};VF.exports[U30]={shouldSkipOverride:Xx,getMeta:E9,checkDecorators:Gx,checkDependencies:Qx}});var CW=S((Nx0,Wx)=>{function T30($,Z){let J=Z||P30();if($)return C30($,J);return J}function R30($,Z){return $.genReqId(Z)}function P30(){let Z=0;return function(){return Z=Z+1&2147483647,`req-${Z.toString(36)}`}}function C30($,Z){return function(J){return J.headers[$]||Z(J)}}Wx.exports={getGenReqId:R30,reqIdGenFactory:T30}});var Hx=S((qx0,Ux)=>{var Kx=12,I30=0,HF=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function E30($){var Z=$.indexOf("%");if(Z===-1)return $;var J=$.length,Y="",X=0,Q=0,G=Z,W=Kx;while(Z>-1&&Z<J){var K=Vx($[Z+1],4),V=Vx($[Z+2],0),U=K|V,H=HF[U];if(W=HF[256+W+H],Q=Q<<6|U&HF[364+H],W===Kx)Y+=$.slice(X,G),Y+=Q<=65535?String.fromCharCode(Q):String.fromCharCode(55232+(Q>>10),56320+(Q&1023)),Q=0,X=Z+3,Z=G=$.indexOf("%",X);else if(W===I30)return null;else{if(Z+=3,Z<J&&$.charCodeAt(Z)===37)continue;return null}}return Y+$.slice(X)}var b30={"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function Vx($,Z){var J=b30[$];return J===void 0?255:J<<Z}Ux.exports=E30});var Ox=S((Mx0,Ax)=>{var Bx=Hx(),zx=/\+/g,Fx=function(){};Fx.prototype=Object.create(null);function _30($){let Z=new Fx;if(typeof $!=="string")return Z;let J=$.length,Y="",X="",Q=-1,G=-1,W=!1,K=!1,V=!1,U=!1,H=!1,B=0;for(let z=0;z<J+1;z++)if(B=z!==J?$.charCodeAt(z):38,B===38){if(H=G>Q,!H)G=z;if(Y=$.slice(Q+1,G),H||Y.length>0){if(V)Y=Y.replace(zx," ");if(W)Y=Bx(Y)||Y;if(H){if(X=$.slice(G+1,z),U)X=X.replace(zx," ");if(K)X=Bx(X)||X}let F=Z[Y];if(F===void 0)Z[Y]=X;else if(F.pop)F.push(X);else Z[Y]=[F,X]}X="",Q=z,G=z,W=!1,K=!1,V=!1,U=!1}else if(B===61)if(G<=Q)G=z;else K=!0;else if(B===43)if(G>Q)U=!0;else V=!0;else if(B===37)if(G>Q)K=!0;else W=!0;return Z}Ax.exports=_30});var Nx=S((Dx0,jx)=>{var b6=Array.from({length:256},($,Z)=>"%"+((Z<16?"0":"")+Z.toString(16)).toUpperCase()),S30=new Int8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0]);function f30($){let Z=$.length;if(Z===0)return"";let J="",Y=0,X=0;$:for(;X<Z;X++){let Q=$.charCodeAt(X);while(Q<128){if(S30[Q]!==1){if(Y<X)J+=$.slice(Y,X);Y=X+1,J+=b6[Q]}if(++X===Z)break $;Q=$.charCodeAt(X)}if(Y<X)J+=$.slice(Y,X);if(Q<2048){Y=X+1,J+=b6[192|Q>>6]+b6[128|Q&63];continue}if(Q<55296||Q>=57344){Y=X+1,J+=b6[224|Q>>12]+b6[128|Q>>6&63]+b6[128|Q&63];continue}if(++X,X>=Z)throw Error("URI malformed");let G=$.charCodeAt(X)&1023;Y=X+1,Q=65536+((Q&1023)<<10|G),J+=b6[240|Q>>18]+b6[128|Q>>12&63]+b6[128|Q>>6&63]+b6[128|Q&63]}if(Y===0)return $;if(Y<Z)return J+$.slice(Y);return J}jx.exports={encodeString:f30}});var Dx=S((wx0,Mx)=>{var{encodeString:BF}=Nx();function qx($){let Z=typeof $;if(Z==="string")return BF($);else if(Z==="bigint")return $.toString();else if(Z==="boolean")return $?"true":"false";else if(Z==="number"&&Number.isFinite($))return $<1000000000000000000000?""+$:BF(""+$);return""}function k30($){let Z="";if($===null||typeof $!=="object")return Z;let J="&",Y=Object.keys($),X=Y.length,Q=0;for(let G=0;G<X;G++){let W=Y[G],K=$[W],V=BF(W)+"=";if(G)Z+=J;if(Array.isArray(K)){Q=K.length;for(let U=0;U<Q;U++){if(U)Z+=J;Z+=V,Z+=qx(K[U])}}else Z+=V,Z+=qx(K)}return Z}Mx.exports=k30});var Rx=S((Lx0,b9)=>{var wx=Ox(),Lx=Dx(),Tx={parse:wx,stringify:Lx};b9.exports=Tx;b9.exports.default=Tx;b9.exports.parse=wx;b9.exports.stringify=Lx});var Cx=S((Px)=>{Object.defineProperty(Px,"__esModule",{value:!0})});var Ex=S((Ix)=>{Object.defineProperty(Ix,"__esModule",{value:!0});Ix.types=void 0;var v30;(function($){$[$.ROOT=0]="ROOT",$[$.GROUP=1]="GROUP",$[$.POSITION=2]="POSITION",$[$.SET=3]="SET",$[$.RANGE=4]="RANGE",$[$.REPETITION=5]="REPETITION",$[$.REFERENCE=6]="REFERENCE",$[$.CHAR=7]="CHAR"})(v30=Ix.types||(Ix.types={}))});var _x=S((bx)=>{Object.defineProperty(bx,"__esModule",{value:!0})});var zZ=S((BZ)=>{var y30=BZ&&BZ.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),FF=BZ&&BZ.__exportStar||function($,Z){for(var J in $)if(J!=="default"&&!Object.prototype.hasOwnProperty.call(Z,J))y30(Z,$,J)};Object.defineProperty(BZ,"__esModule",{value:!0});FF(Cx(),BZ);FF(Ex(),BZ);FF(_x(),BZ)});var IW=S((vx)=>{Object.defineProperty(vx,"__esModule",{value:!0});vx.anyChar=vx.notWhitespace=vx.whitespace=vx.notInts=vx.ints=vx.notWords=vx.words=void 0;var P1=zZ(),Sx=()=>[{type:P1.types.RANGE,from:48,to:57}],fx=()=>[{type:P1.types.CHAR,value:95},{type:P1.types.RANGE,from:97,to:122},{type:P1.types.RANGE,from:65,to:90},{type:P1.types.RANGE,from:48,to:57}],kx=()=>[{type:P1.types.CHAR,value:9},{type:P1.types.CHAR,value:10},{type:P1.types.CHAR,value:11},{type:P1.types.CHAR,value:12},{type:P1.types.CHAR,value:13},{type:P1.types.CHAR,value:32},{type:P1.types.CHAR,value:160},{type:P1.types.CHAR,value:5760},{type:P1.types.RANGE,from:8192,to:8202},{type:P1.types.CHAR,value:8232},{type:P1.types.CHAR,value:8233},{type:P1.types.CHAR,value:8239},{type:P1.types.CHAR,value:8287},{type:P1.types.CHAR,value:12288},{type:P1.types.CHAR,value:65279}],x30=()=>[{type:P1.types.CHAR,value:10},{type:P1.types.CHAR,value:13},{type:P1.types.CHAR,value:8232},{type:P1.types.CHAR,value:8233}];vx.words=()=>({type:P1.types.SET,set:fx(),not:!1});vx.notWords=()=>({type:P1.types.SET,set:fx(),not:!0});vx.ints=()=>({type:P1.types.SET,set:Sx(),not:!1});vx.notInts=()=>({type:P1.types.SET,set:Sx(),not:!0});vx.whitespace=()=>({type:P1.types.SET,set:kx(),not:!1});vx.notWhitespace=()=>({type:P1.types.SET,set:kx(),not:!0});vx.anyChar=()=>({type:P1.types.SET,set:x30(),not:!0})});var hx=S((l8)=>{var p30=l8&&l8.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),c30=l8&&l8.__setModuleDefault||(Object.create?function($,Z){Object.defineProperty($,"default",{enumerable:!0,value:Z})}:function($,Z){$.default=Z}),i30=l8&&l8.__importStar||function($){if($&&$.__esModule)return $;var Z={};if($!=null){for(var J in $)if(J!=="default"&&Object.prototype.hasOwnProperty.call($,J))p30(Z,$,J)}return c30(Z,$),Z};Object.defineProperty(l8,"__esModule",{value:!0});l8.tokenizeClass=l8.strToChars=void 0;var xx=zZ(),YY=i30(IW()),n30="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?";l8.strToChars=($)=>{let Z=/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g;return $.replace(Z,(J,Y,X,Q,G,W,K)=>{if(X)return J;let V=Y?8:Q?parseInt(Q,16):G?parseInt(G,16):W?n30.indexOf(W):{0:0,t:9,n:10,v:11,f:12,r:13}[K],U=String.fromCharCode(V);return/[[\]{}^$.|?*+()]/.test(U)?`\\${U}`:U})};l8.tokenizeClass=($,Z)=>{var J,Y,X,Q,G,W,K;let V=[],U,H,B=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;while((U=B.exec($))!==null){let z=(K=(W=(G=(Q=(X=(Y=(J=U[1]&&YY.words())!==null&&J!==void 0?J:U[2]&&YY.ints())!==null&&Y!==void 0?Y:U[3]&&YY.whitespace())!==null&&X!==void 0?X:U[4]&&YY.notWords())!==null&&Q!==void 0?Q:U[5]&&YY.notInts())!==null&&G!==void 0?G:U[6]&&YY.notWhitespace())!==null&&W!==void 0?W:U[7]&&{type:xx.types.RANGE,from:(U[8]||U[9]).charCodeAt(0),to:(H=U[10]).charCodeAt(H.length-1)})!==null&&K!==void 0?K:(H=U[16])&&{type:xx.types.CHAR,value:H.charCodeAt(0)};if(z)V.push(z);else return[V,B.lastIndex]}throw SyntaxError(`Invalid regular expression: /${Z}/: Unterminated character class`)}});var AF=S((_6)=>{var o30=_6&&_6.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),s30=_6&&_6.__setModuleDefault||(Object.create?function($,Z){Object.defineProperty($,"default",{enumerable:!0,value:Z})}:function($,Z){$.default=Z}),mx=_6&&_6.__importStar||function($){if($&&$.__esModule)return $;var Z={};if($!=null){for(var J in $)if(J!=="default"&&Object.prototype.hasOwnProperty.call($,J))o30(Z,$,J)}return s30(Z,$),Z};Object.defineProperty(_6,"__esModule",{value:!0});_6.tokenizer=void 0;var gx=mx(hx()),v$=zZ(),U7=mx(IW()),r30=/^[a-zA-Z_$]$/i,a30=/^[a-zA-Z0-9_$]$/i,ux=/\d/;_6.tokenizer=($)=>{let Z=0,J,Y={type:v$.types.ROOT,stack:[]},X=Y,Q=Y.stack,G=[],W=[],K=0,V=(H)=>{throw SyntaxError(`Invalid regular expression: /${$}/: Nothing to repeat at column ${H-1}`)},U=gx.strToChars($);while(Z<U.length)switch(J=U[Z++]){case"\\":if(Z===U.length)throw SyntaxError(`Invalid regular expression: /${$}/: \\ at end of pattern`);switch(J=U[Z++]){case"b":Q.push({type:v$.types.POSITION,value:"b"});break;case"B":Q.push({type:v$.types.POSITION,value:"B"});break;case"w":Q.push(U7.words());break;case"W":Q.push(U7.notWords());break;case"d":Q.push(U7.ints());break;case"D":Q.push(U7.notInts());break;case"s":Q.push(U7.whitespace());break;case"S":Q.push(U7.notWhitespace());break;default:if(ux.test(J)){let H=J;while(Z<U.length&&ux.test(U[Z]))H+=U[Z++];let B=parseInt(H,10),z={type:v$.types.REFERENCE,value:B};Q.push(z),W.push({reference:z,stack:Q,index:Q.length-1})}else Q.push({type:v$.types.CHAR,value:J.charCodeAt(0)})}break;case"^":Q.push({type:v$.types.POSITION,value:"^"});break;case"$":Q.push({type:v$.types.POSITION,value:"$"});break;case"[":{let H;if(U[Z]==="^")H=!0,Z++;else H=!1;let B=gx.tokenizeClass(U.slice(Z),$);Z+=B[1],Q.push({type:v$.types.SET,set:B[0],not:H});break}case".":Q.push(U7.anyChar());break;case"(":{let H={type:v$.types.GROUP,stack:[],remember:!0};if(U[Z]==="?")if(J=U[Z+1],Z+=2,J==="=")H.followedBy=!0,H.remember=!1;else if(J==="!")H.notFollowedBy=!0,H.remember=!1;else if(J==="<"){let B="";if(r30.test(U[Z]))B+=U[Z],Z++;else throw SyntaxError(`Invalid regular expression: /${$}/: Invalid capture group name, character '${U[Z]}' after '<' at column ${Z+1}`);while(Z<U.length&&a30.test(U[Z]))B+=U[Z],Z++;if(!B)throw SyntaxError(`Invalid regular expression: /${$}/: Invalid capture group name, character '${U[Z]}' after '<' at column ${Z+1}`);if(U[Z]!==">")throw SyntaxError(`Invalid regular expression: /${$}/: Unclosed capture group name, expected '>', found '${U[Z]}' at column ${Z+1}`);H.name=B,Z++}else if(J===":")H.remember=!1;else throw SyntaxError(`Invalid regular expression: /${$}/: Invalid group, character '${J}' after '?' at column ${Z-1}`);else K+=1;Q.push(H),G.push(X),X=H,Q=H.stack;break}case")":if(G.length===0)throw SyntaxError(`Invalid regular expression: /${$}/: Unmatched ) at column ${Z-1}`);X=G.pop(),Q=X.options?X.options[X.options.length-1]:X.stack;break;case"|":{if(!X.options)X.options=[X.stack],delete X.stack;let H=[];X.options.push(H),Q=H;break}case"{":{let H=/^(\d+)(,(\d+)?)?\}/.exec(U.slice(Z)),B,z;if(H!==null){if(Q.length===0)V(Z);B=parseInt(H[1],10),z=H[2]?H[3]?parseInt(H[3],10):1/0:B,Z+=H[0].length,Q.push({type:v$.types.REPETITION,min:B,max:z,value:Q.pop()})}else Q.push({type:v$.types.CHAR,value:123});break}case"?":if(Q.length===0)V(Z);Q.push({type:v$.types.REPETITION,min:0,max:1,value:Q.pop()});break;case"+":if(Q.length===0)V(Z);Q.push({type:v$.types.REPETITION,min:1,max:1/0,value:Q.pop()});break;case"*":if(Q.length===0)V(Z);Q.push({type:v$.types.REPETITION,min:0,max:1/0,value:Q.pop()});break;default:Q.push({type:v$.types.CHAR,value:J.charCodeAt(0)})}if(G.length!==0)throw SyntaxError(`Invalid regular expression: /${$}/: Unterminated group`);return t30(W,K),Y};function t30($,Z){for(let J of $.reverse())if(Z<J.reference.value){J.reference.type=v$.types.CHAR;let Y=J.reference.value.toString();if(J.reference.value=parseInt(Y,8),!/^[0-7]+$/.test(Y)){let X=0;while(Y[X]!=="8"&&Y[X]!=="9")X+=1;if(X===0)J.reference.value=Y.charCodeAt(0),X+=1;else J.reference.value=parseInt(Y.slice(0,X),8);if(Y.length>X){let Q=J.stack.splice(J.index+1);for(let G of Y.slice(X))J.stack.push({type:v$.types.CHAR,value:G.charCodeAt(0)});J.stack.push(...Q)}}}}});var dx=S((n$)=>{var e30=n$&&n$.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),$F0=n$&&n$.__setModuleDefault||(Object.create?function($,Z){Object.defineProperty($,"default",{enumerable:!0,value:Z})}:function($,Z){$.default=Z}),ZF0=n$&&n$.__importStar||function($){if($&&$.__esModule)return $;var Z={};if($!=null){for(var J in $)if(J!=="default"&&Object.prototype.hasOwnProperty.call($,J))e30(Z,$,J)}return $F0(Z,$),Z};Object.defineProperty(n$,"__esModule",{value:!0});n$.NOTANYCHAR=n$.WHITESPACE=n$.WORDS=n$.INTS=void 0;var EW=ZF0(IW()),lx=zZ();function bW($){let Z={},J=0;for(let Y of $){if(Y.type===lx.types.CHAR)Z[Y.value]=!0;if(Y.type===lx.types.RANGE)Z[`${Y.from}-${Y.to}`]=!0;J+=1}return{lookup:()=>Object.assign({},Z),len:J}}n$.INTS=bW(EW.ints().set);n$.WORDS=bW(EW.words().set);n$.WHITESPACE=bW(EW.whitespace().set);n$.NOTANYCHAR=bW(EW.anyChar().set)});var cx=S((d8)=>{var JF0=d8&&d8.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),YF0=d8&&d8.__setModuleDefault||(Object.create?function($,Z){Object.defineProperty($,"default",{enumerable:!0,value:Z})}:function($,Z){$.default=Z}),XF0=d8&&d8.__importStar||function($){if($&&$.__esModule)return $;var Z={};if($!=null){for(var J in $)if(J!=="default"&&Object.prototype.hasOwnProperty.call($,J))JF0(Z,$,J)}return YF0(Z,$),Z};Object.defineProperty(d8,"__esModule",{value:!0});d8.writeSetTokens=d8.setChar=void 0;var kW=zZ(),_W=XF0(dx());function fW($){return $===94?"\\^":$===92?"\\\\":$===93?"\\]":$===45?"\\-":String.fromCharCode($)}d8.setChar=fW;function SW($,{lookup:Z,len:J}){if(J!==$.length)return!1;let Y=Z();for(let X of $){if(X.type===kW.types.SET)return!1;let Q=X.type===kW.types.CHAR?X.value:`${X.from}-${X.to}`;if(Y[Q])Y[Q]=!1;else return!1}return!0}function px($,Z=!1){if(SW($.set,_W.INTS))return $.not?"\\D":"\\d";if(SW($.set,_W.WORDS))return $.not?"\\W":"\\w";if($.not&&SW($.set,_W.NOTANYCHAR))return".";if(SW($.set,_W.WHITESPACE))return $.not?"\\S":"\\s";let J="";for(let X=0;X<$.set.length;X++){let Q=$.set[X];J+=QF0(Q)}let Y=`${$.not?"^":""}${J}`;return Z?Y:`[${Y}]`}d8.writeSetTokens=px;function QF0($){if($.type===kW.types.CHAR)return fW($.value);else if($.type===kW.types.RANGE)return`${fW($.from)}-${fW($.to)}`;return px($,!0)}});var jF=S((ox)=>{Object.defineProperty(ox,"__esModule",{value:!0});ox.reconstruct=void 0;var Z5=zZ(),OF=cx(),ix=($)=>$.map(ox.reconstruct).join(""),nx=($)=>{if("options"in $)return $.options.map(ix).join("|");else if("stack"in $)return ix($.stack);else throw Error("options or stack must be Root or Group token")};ox.reconstruct=($)=>{switch($.type){case Z5.types.ROOT:return nx($);case Z5.types.CHAR:{let Z=String.fromCharCode($.value);return(/[[\\{}$^.|?*+()]/.test(Z)?"\\":"")+Z}case Z5.types.POSITION:if($.value==="^"||$.value==="$")return $.value;else return`\\${$.value}`;case Z5.types.REFERENCE:return`\\${$.value}`;case Z5.types.SET:return OF.writeSetTokens($);case Z5.types.GROUP:return`(${$.name?`?<${$.name}>`:$.remember?"":$.followedBy?"?=":$.notFollowedBy?"?!":"?:"}${nx($)})`;case Z5.types.REPETITION:{let{min:Z,max:J}=$,Y;if(Z===0&&J===1)Y="?";else if(Z===1&&J===1/0)Y="+";else if(Z===0&&J===1/0)Y="*";else if(J===1/0)Y=`{${Z},}`;else if(Z===J)Y=`{${Z}}`;else Y=`{${Z},${J}}`;return`${ox.reconstruct($.value)}${Y}`}case Z5.types.RANGE:return`${OF.setChar($.from)}-${OF.setChar($.to)}`;default:throw Error(`Invalid token type ${$}`)}}});var qF=S((p8,yW)=>{var GF0=p8&&p8.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),NF=p8&&p8.__exportStar||function($,Z){for(var J in $)if(J!=="default"&&!Object.prototype.hasOwnProperty.call(Z,J))GF0(Z,$,J)};Object.defineProperty(p8,"__esModule",{value:!0});p8.types=void 0;var sx=zZ();Object.defineProperty(p8,"types",{enumerable:!0,get:function(){return sx.types}});NF(AF(),p8);NF(jF(),p8);var rx=AF(),WF0=jF();NF(zZ(),p8);p8.default=rx.tokenizer;yW.exports=rx.tokenizer;yW.exports.types=sx.types;yW.exports.reconstruct=WF0.reconstruct});var ax=S((kx0,xW)=>{var KF0=qF(),{types:VF0}=qF();function MF($,Z,J){let Y,X,Q;if($.type===VF0.REPETITION){if(J++,Z.reps++,J>1)return!1;if(Z.reps>Z.limit)return!1}let G=$.options||$.value?.options;if(G){for(Y=0,Q=G.length;Y<Q;Y++)if(X=MF({stack:G[Y]},Z,J),!X)return!1}let W=$.stack||$.value?.stack;if(!W)return!0;for(Y=0,Q=W.length;Y<Q;Y++)if(X=MF(W[Y],Z,J),!X)return!1;return!0}function DF($,Z){let J={reps:0,limit:Z?.limit??25};if(UF0($))$=$.source;else if(typeof $!=="string")$=String($);try{return MF(KF0($),J,0)}catch{return!1}}function UF0($){return Object.prototype.toString.call($)==="[object RegExp]"}xW.exports=DF;xW.exports.default=DF;xW.exports.safeRegex=DF});var hW=S((vx0,tx)=>{tx.exports={name:"__fmw_internal_strategy_merged_tree_http_method__",storage:function(){let $=new Map;return{get:(Z)=>{return $.get(Z)||null},set:(Z,J)=>{$.set(Z,J)}}},deriveConstraint:($)=>$.method,mustMatchWhenDerived:!0}});var Qh=S((yx0,Xh)=>{var ex=aX(),$h=hW(),Zh=Symbol("treeData");function Jh($,Z=""){let J="",Y=Object.keys($);for(let X=0;X<Y.length;X++){let Q=Y[X],G=$[Q],W=X===Y.length-1,K=W?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",V=W?" ":"\u2502 ",H=(G[Zh]||"").replaceAll(`
|
|
423
|
+
`,`
|
|
424
|
+
`+Z+V);J+=Z+K+Q+H+`
|
|
425
|
+
`,J+=Jh(G,Z+V)}return J}function HF0($){let Z=$.name||"";return Z=Z.replace("bound","").trim(),Z=(Z||"anonymous")+"()",Z}function Yh($){if(Array.isArray($))return $.map((Z)=>Yh(Z));if(typeof $==="symbol")return $.toString();if(typeof $==="function")return HF0($);return $}function BF0($,Z){if(!Z.includeMeta)return{};let J=Z.buildPrettyMeta($),Y={},X=Z.includeMeta;if(!Array.isArray(X))X=Reflect.ownKeys(J);for(let Q of X){if(!Object.prototype.hasOwnProperty.call(J,Q))continue;let G=Q.toString(),W=J[Q];if(W!==void 0&&W!==null){let K=JSON.stringify(Yh(W));Y[G]=K}}return Y}function zF0($){let Z="";for(let[J,Y]of Object.entries($))Z+=`
|
|
426
|
+
\u2022 (${J}) ${Y}`;return Z}function FF0($){let Z={...$.opts.constraints},J=Z[$h.name];return delete Z[$h.name],{...$,method:J,opts:{constraints:Z}}}function AF0($){let Z=` (${$.method})`,J=$.opts.constraints||{};if(Object.keys(J).length!==0)Z+=" "+JSON.stringify(J);return Z+=zF0($.metaData),Z}function OF0($){return $.reduce((Z,J)=>{for(let Y of Z)if(ex(J.opts.constraints,Y.opts.constraints)&&ex(J.metaData,Y.metaData))return Y.method+=", "+J.method,Z;return Z.push(J),Z},[])}function jF0($,Z,J){let Y=$.routes;if(J.method===void 0)Y=Y.map(FF0);if(Y=Y.map((X)=>{return X.metaData=BF0(X,J),X}),J.method===void 0)Y=OF0(Y);return Y.map(AF0).join(`
|
|
427
|
+
${Z}`)}function gW($,Z,J,Y){if($.isLeafNode||Y.commonPrefix!==!1){if(J=J||"(empty root node)",Z=Z[J]={},$.isLeafNode)Z[Zh]=jF0($,J,Y);J=""}if($.staticChildren)for(let X of Object.values($.staticChildren))gW(X,Z,J+X.prefix,Y);if($.parametricChildren)for(let X of Object.values($.parametricChildren)){let Q=Array.from(X.nodePaths).join("|");gW(X,Z,J+Q,Y)}if($.wildcardChild)gW($.wildcardChild,Z,"*",Y)}function NF0($,Z){let J={};return gW($,J,$.prefix,Z),Jh(J)}Xh.exports={prettyPrintTree:NF0}});var Kh=S((xx0,Wh)=>{var Gh=function(){};Gh.prototype=Object.create(null);Wh.exports={NullObject:Gh}});var Hh=S((hx0,Uh)=>{var{NullObject:qF0}=Kh(),MF0=hW();class Vh{constructor(){this.unconstrainedHandler=null,this.constraints=[],this.handlers=[],this.constrainedHandlerStores=null}getMatchingHandler($){if($===void 0)return this.unconstrainedHandler;return this._getHandlerMatchingConstraints($)}addHandler($,Z){let J=Z.params,Y=Z.opts.constraints||{},X={params:J,constraints:Y,handler:Z.handler,store:Z.store||null,_createParamsObject:this._compileCreateParamsObject(J)},Q=Object.keys(Y);if(Q.length===0)this.unconstrainedHandler=X;for(let W of Q)if(!this.constraints.includes(W))if(W==="version")this.constraints.unshift(W);else this.constraints.push(W);let G=Q.includes(MF0.name);if(!G&&this.handlers.length>=31)throw Error("find-my-way supports a maximum of 31 route handlers per node when there are constraints, limit reached");if(this.handlers.push(X),this.handlers.sort((W,K)=>Object.keys(W.constraints).length-Object.keys(K.constraints).length),!G)this._compileGetHandlerMatchingConstraints($,Y)}_compileCreateParamsObject($){let Z=[];Z.push("const fn = function _createParamsObject (paramsArray) {"),Z.push("const params = new NullObject()");for(let J=0;J<$.length;J++)Z.push(`params['${$[J]}'] = paramsArray[${J}]`);return Z.push("return params"),Z.push("}"),Z.push("return fn"),Function("NullObject",Z.join(`
|
|
428
|
+
`))(qF0)}_getHandlerMatchingConstraints(){return null}_buildConstraintStore($,Z){for(let J=0;J<this.handlers.length;J++){let X=this.handlers[J].constraints[Z];if(X!==void 0){let Q=$.get(X)||0;Q|=1<<J,$.set(X,Q)}}}_constrainedIndexBitmask($){let Z=0;for(let J=0;J<this.handlers.length;J++)if(this.handlers[J].constraints[$]!==void 0)Z|=1<<J;return~Z}_compileGetHandlerMatchingConstraints($){this.constrainedHandlerStores={};for(let J of this.constraints){let Y=$.newStoreForConstraint(J);this.constrainedHandlerStores[J]=Y,this._buildConstraintStore(Y,J)}let Z=[];Z.push(`
|
|
429
|
+
let candidates = ${(1<<this.handlers.length)-1}
|
|
430
|
+
let mask, matches
|
|
431
|
+
`);for(let J of this.constraints){Z.push(`
|
|
432
|
+
mask = ${this._constrainedIndexBitmask(J)}
|
|
433
|
+
value = derivedConstraints.${J}
|
|
434
|
+
`);let X=$.strategies[J].mustMatchWhenDerived?"matches":"(matches | mask)";Z.push(`
|
|
435
|
+
if (value === undefined) {
|
|
436
|
+
candidates &= mask
|
|
437
|
+
} else {
|
|
438
|
+
matches = this.constrainedHandlerStores.${J}.get(value) || 0
|
|
439
|
+
candidates &= ${X}
|
|
440
|
+
}
|
|
441
|
+
if (candidates === 0) return null;
|
|
442
|
+
`)}for(let J in $.strategies){if(!Object.hasOwn($.strategies,J))continue;if($.strategies[J].mustMatchWhenDerived&&!this.constraints.includes(J))Z.push(`if (derivedConstraints.${J} !== undefined) return null`)}Z.push("return this.handlers[31 - Math.clz32(candidates)]"),this._getHandlerMatchingConstraints=Function("derivedConstraints",Z.join(`
|
|
443
|
+
`))}}Uh.exports=Vh});var zh=S((gx0,Bh)=>{var DF0=Hh(),uW={STATIC:0,PARAMETRIC:1,WILDCARD:2};class wF{constructor(){this.isLeafNode=!1,this.routes=null,this.handlerStorage=null}addRoute($,Z){if(this.routes===null)this.routes=[];if(this.handlerStorage===null)this.handlerStorage=new DF0;this.isLeafNode=!0,this.routes.push($),this.handlerStorage.addHandler(Z,$)}}class LF extends wF{constructor(){super();this.staticChildren={}}findStaticMatchingChild($,Z){let J=this.staticChildren[$.charAt(Z)];if(J===void 0||!J.matchPrefix($,Z))return null;return J}getStaticChild($,Z=0){if($.length===Z)return this;let J=this.findStaticMatchingChild($,Z);if(J)return J.getStaticChild($,Z+J.prefix.length);return null}createStaticChild($){if($.length===0)return this;let Z=this.staticChildren[$.charAt(0)];if(Z){let Y=1;for(;Y<Z.prefix.length;Y++)if($.charCodeAt(Y)!==Z.prefix.charCodeAt(Y)){Z=Z.split(this,Y);break}return Z.createStaticChild($.slice(Y))}let J=$.charAt(0);return this.staticChildren[J]=new mW($),this.staticChildren[J]}}class mW extends LF{constructor($){super();this.prefix=$,this.wildcardChild=null,this.parametricChildren=[],this.kind=uW.STATIC,this._compilePrefixMatch()}getParametricChild($){let Z=$&&$.source,J=this.parametricChildren.find((Y)=>{return(Y.regex&&Y.regex.source)===Z});if(J)return J;return null}createParametricChild($,Z,J){let Y=this.getParametricChild($);if(Y)return Y.nodePaths.add(J),Y;return Y=new TF($,Z,J),this.parametricChildren.push(Y),this.parametricChildren.sort((X,Q)=>{if(!X.isRegex)return 1;if(!Q.isRegex)return-1;if(X.staticSuffix===null)return 1;if(Q.staticSuffix===null)return-1;if(Q.staticSuffix.endsWith(X.staticSuffix))return 1;if(X.staticSuffix.endsWith(Q.staticSuffix))return-1;return 0}),Y}getWildcardChild(){return this.wildcardChild}createWildcardChild(){return this.wildcardChild=this.getWildcardChild()||new RF,this.wildcardChild}split($,Z){let J=this.prefix.slice(0,Z),Y=this.prefix.slice(Z);this.prefix=Y,this._compilePrefixMatch();let X=new mW(J);return X.staticChildren[Y.charAt(0)]=this,$.staticChildren[J.charAt(0)]=X,X}getNextNode($,Z,J,Y){let X=this.findStaticMatchingChild($,Z),Q=0;if(X===null){if(this.parametricChildren.length===0)return this.wildcardChild;X=this.parametricChildren[0],Q=1}if(this.wildcardChild!==null)J.push({paramsCount:Y,brotherPathIndex:Z,brotherNode:this.wildcardChild});for(let G=this.parametricChildren.length-1;G>=Q;G--)J.push({paramsCount:Y,brotherPathIndex:Z,brotherNode:this.parametricChildren[G]});return X}_compilePrefixMatch(){if(this.prefix.length===1){this.matchPrefix=()=>!0;return}let $=[];for(let Z=1;Z<this.prefix.length;Z++){let J=this.prefix.charCodeAt(Z);$.push(`path.charCodeAt(i + ${Z}) === ${J}`)}this.matchPrefix=Function("path","i",`return ${$.join(" && ")}`)}}class TF extends LF{constructor($,Z,J){super();this.isRegex=!!$,this.regex=$||null,this.staticSuffix=Z||null,this.kind=uW.PARAMETRIC,this.nodePaths=new Set([J])}getNextNode($,Z){return this.findStaticMatchingChild($,Z)}}class RF extends wF{constructor(){super();this.kind=uW.WILDCARD}getNextNode(){return null}}Bh.exports={StaticNode:mW,ParametricNode:TF,WildcardNode:RF,NODE_TYPES:uW}});var Ah=S((ux0,Fh)=>{var wF0=J0("assert");function _9(){if(!(this instanceof _9))return new _9;this.store=new Map,this.maxMajor=0,this.maxMinors={},this.maxPatches={}}_9.prototype.set=function($,Z){if(typeof $!=="string")throw TypeError("Version should be a string");let[J,Y,X]=$.split(".",3);if(isNaN(J))throw TypeError("Major version must be a numeric value");if(J=Number(J),Y=Number(Y)||0,X=Number(X)||0,J>=this.maxMajor)this.maxMajor=J,this.store.set("x",Z),this.store.set("*",Z),this.store.set("x.x",Z),this.store.set("x.x.x",Z);if(Y>=(this.maxMinors[J]||0))this.maxMinors[J]=Y,this.store.set(`${J}.x`,Z),this.store.set(`${J}.x.x`,Z);if(X>=(this.maxPatches[`${J}.${Y}`]||0))this.maxPatches[`${J}.${Y}`]=X,this.store.set(`${J}.${Y}.x`,Z);return this.store.set(`${J}.${Y}.${X}`,Z),this};_9.prototype.get=function($){return this.store.get($)};Fh.exports={name:"version",mustMatchWhenDerived:!0,storage:_9,validate($){wF0(typeof $==="string","Version should be a string")}}});var jh=S((mx0,Oh)=>{var LF0=J0("assert");function TF0(){let $=new Map,Z=[];return{get:(J)=>{let Y=$.get(J);if(Y)return Y;for(let X of Z)if(X.host.test(J))return X.value},set:(J,Y)=>{if(J instanceof RegExp)Z.push({host:J,value:Y});else $.set(J,Y)}}}Oh.exports={name:"host",mustMatchWhenDerived:!1,storage:TF0,validate($){LF0(typeof $==="string"||Object.prototype.toString.call($)==="[object RegExp]","Host should be a string or a RegExp")}}});var Mh=S((lx0,qh)=>{var RF0=Ah(),PF0=jh(),PF=J0("assert");class Nh{constructor($){if(this.strategies={version:RF0,host:PF0},this.strategiesInUse=new Set,this.asyncStrategiesInUse=new Set,$)for(let Z of Object.values($))this.addConstraintStrategy(Z)}isStrategyUsed($){return this.strategiesInUse.has($)||this.asyncStrategiesInUse.has($)}hasConstraintStrategy($){let Z=this.strategies[$];if(Z!==void 0)return Z.isCustom||this.isStrategyUsed($);return!1}addConstraintStrategy($){if(PF(typeof $.name==="string"&&$.name!=="","strategy.name is required."),PF($.storage&&typeof $.storage==="function","strategy.storage function is required."),PF($.deriveConstraint&&typeof $.deriveConstraint==="function","strategy.deriveConstraint function is required."),this.strategies[$.name]&&this.strategies[$.name].isCustom)throw Error(`There already exists a custom constraint with the name ${$.name}.`);if(this.isStrategyUsed($.name))throw Error(`There already exists a route with ${$.name} constraint.`);if($.isCustom=!0,$.isAsync=$.deriveConstraint.length===3,this.strategies[$.name]=$,$.mustMatchWhenDerived)this.noteUsage({[$.name]:$})}deriveConstraints($,Z,J){let Y=this.deriveSyncConstraints($,Z);if(J===void 0)return Y;this.deriveAsyncConstraints(Y,$,Z,J)}deriveSyncConstraints($,Z){return}noteUsage($){if($){let Z=this.strategiesInUse.size;for(let J in $){if(!Object.hasOwn($,J))continue;if(this.strategies[J].isAsync)this.asyncStrategiesInUse.add(J);else this.strategiesInUse.add(J)}if(Z!==this.strategiesInUse.size)this._buildDeriveConstraints()}}newStoreForConstraint($){if(!this.strategies[$])throw Error(`No strategy registered for constraint key ${$}`);return this.strategies[$].storage()}validateConstraints($){for(let Z in $){if(!Object.hasOwn($,Z))continue;let J=$[Z];if(typeof J>"u")throw Error("Can't pass an undefined constraint value, must pass null or no key at all");let Y=this.strategies[Z];if(!Y)throw Error(`No strategy registered for constraint key ${Z}`);if(Y.validate)Y.validate(J)}}deriveAsyncConstraints($,Z,J,Y){let X=this.asyncStrategiesInUse.size;if(X===0){Y(null,$);return}$=$||{};for(let Q of this.asyncStrategiesInUse)this.strategies[Q].deriveConstraint(Z,J,(W,K)=>{if(W!==null){Y(W);return}if($[Q]=K,--X===0)Y(null,$)})}_buildDeriveConstraints(){if(this.strategiesInUse.size===0)return;let $=["return {"];for(let Z of this.strategiesInUse){let J=this.strategies[Z];if(!J.isCustom)if(Z==="version")$.push(" version: req.headers['accept-version'],");else $.push(" host: req.headers.host || req.headers[':authority'],");else $.push(` ${J.name}: this.strategies.${Z}.deriveConstraint(req, ctx),`)}$.push("}"),this.deriveSyncConstraints=Function("req","ctx",$.join(`
|
|
444
|
+
`)).bind(this)}}qh.exports=Nh});var wh=S((dx0,Dh)=>{var CF0=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","QUERY","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];Dh.exports=CF0});var Rh=S((px0,Th)=>{function Lh($,Z){if($===50){if(Z===53)return"%";if(Z===51)return"#";if(Z===52)return"$";if(Z===54)return"&";if(Z===66)return"+";if(Z===98)return"+";if(Z===67)return",";if(Z===99)return",";if(Z===70)return"/";if(Z===102)return"/";return null}if($===51){if(Z===65)return":";if(Z===97)return":";if(Z===66)return";";if(Z===98)return";";if(Z===68)return"=";if(Z===100)return"=";if(Z===70)return"?";if(Z===102)return"?";return null}if($===52&&Z===48)return"@";return null}function IF0($,Z){let J=!1,Y=!1,X="";for(let G=1;G<$.length;G++){let W=$.charCodeAt(G);if(W===37){let K=$.charCodeAt(G+1),V=$.charCodeAt(G+2);if(Lh(K,V)===null)J=!0;else{if(Y=!0,K===50&&V===53)J=!0,$=$.slice(0,G+1)+"25"+$.slice(G+1),G+=2;G+=2}}else if(W===63||W===35||W===59&&Z){X=$.slice(G+1),$=$.slice(0,G);break}}return{path:J?decodeURI($):$,querystring:X,shouldDecodeParam:Y}}function EF0($){let Z=$.indexOf("%");if(Z===-1)return $;let J="",Y=Z;for(let X=Z;X<$.length;X++)if($.charCodeAt(X)===37){let Q=$.charCodeAt(X+1),G=$.charCodeAt(X+2),W=Lh(Q,G);J+=$.slice(Y,X)+W,Y=X+3}return $.slice(0,Z)+J+$.slice(Y)}Th.exports={safeDecodeURI:IF0,safeDecodeURIComponent:EF0}});var bF=S((cx0,vh)=>{var V$=J0("assert"),bF0=Rx(),QY=ax(),EF=aX(),{prettyPrintTree:_F0}=Qh(),{StaticNode:Ph,NODE_TYPES:Ch}=zh(),SF0=Mh(),XY=wh(),CF=hW(),{safeDecodeURI:Ih,safeDecodeURIComponent:IF}=Rh(),Eh=/^https?:\/\/.*?\//,H7=/(\/:[^/()]*?)\?(\/?)/,bh=/[.*+?^${}()|[\]\\]/g,_h=/\/\/+/g;if(!QY(Eh))throw Error("the FULL_PATH_REGEXP is not safe, update this module");if(!QY(H7))throw Error("the OPTIONAL_PARAM_REGEXP is not safe, update this module");if(!QY(bh))throw Error("the ESCAPE_REGEXP is not safe, update this module");if(!QY(_h))throw Error("the REMOVE_DUPLICATE_SLASHES_REGEXP is not safe, update this module");function m1($){if(!(this instanceof m1))return new m1($);if($=$||{},this._opts=$,$.defaultRoute)V$(typeof $.defaultRoute==="function","The default route must be a function"),this.defaultRoute=$.defaultRoute;else this.defaultRoute=null;if($.onBadUrl)V$(typeof $.onBadUrl==="function","The bad url handler must be a function"),this.onBadUrl=$.onBadUrl;else this.onBadUrl=null;if($.buildPrettyMeta)V$(typeof $.buildPrettyMeta==="function","buildPrettyMeta must be a function"),this.buildPrettyMeta=$.buildPrettyMeta;else this.buildPrettyMeta=fF0;if($.querystringParser)V$(typeof $.querystringParser==="function","querystringParser must be a function"),this.querystringParser=$.querystringParser;else this.querystringParser=(Z)=>Z.length===0?{}:bF0.parse(Z);this.caseSensitive=$.caseSensitive===void 0?!0:$.caseSensitive,this.ignoreTrailingSlash=$.ignoreTrailingSlash||!1,this.ignoreDuplicateSlashes=$.ignoreDuplicateSlashes||!1,this.maxParamLength=$.maxParamLength||100,this.onMaxParamLength=$.onMaxParamLength||null,this.allowUnsafeRegex=$.allowUnsafeRegex||!1,this.constrainer=new SF0($.constraints),this.useSemicolonDelimiter=$.useSemicolonDelimiter||!1,this.routes=[],this.trees={}}m1.prototype.on=function(Z,J,Y,X,Q){if(typeof Y==="function"){if(X!==void 0)Q=X;X=Y,Y={}}V$(typeof J==="string","Path should be a string"),V$(J.length>0,"The path could not be empty"),V$(J[0]==="/"||J[0]==="*","The first character of a path should be `/` or `*`"),V$(typeof X==="function","Handler should be a function");let G=J.match(H7);if(G){V$(J.length===G.index+G[0].length,"Optional Parameter needs to be the last parameter of the path");let V=J.replace(H7,"$1$2"),U=J.replace(H7,"$2")||"/";this.on(Z,V,Y,X,Q),this.on(Z,U,Y,X,Q);return}let W=J;if(this.ignoreDuplicateSlashes)J=lW(J);if(this.ignoreTrailingSlash)J=dW(J);let K=Array.isArray(Z)?Z:[Z];for(let V of K)V$(typeof V==="string","Method should be a string"),V$(XY.includes(V),`Method '${V}' is not an http method.`),this._on(V,J,Y,X,Q,W)};m1.prototype._on=function(Z,J,Y,X,Q){let G={};if(Y.constraints!==void 0){if(V$(typeof Y.constraints==="object"&&Y.constraints!==null,"Constraints should be an object"),Object.keys(Y.constraints).length!==0)G=Y.constraints}if(this.constrainer.validateConstraints(G),this.constrainer.noteUsage(G),this.trees[Z]===void 0)this.trees[Z]=new Ph("/");let W=J;if(W==="*"&&this.trees[Z].prefix.length!==0){let B=this.trees[Z];this.trees[Z]=new Ph(""),this.trees[Z].staticChildren["/"]=B}let K=this.trees[Z],V=K.prefix.length,U=[];for(let B=0;B<=W.length;B++){if(W.charCodeAt(B)===58&&W.charCodeAt(B+1)===58){B++;continue}let z=W.charCodeAt(B)===58&&W.charCodeAt(B+1)!==58,F=W.charCodeAt(B)===42;if(z||F||B===W.length&&B!==V){let A=W.slice(V,B);if(!this.caseSensitive)A=A.toLowerCase();A=A.replaceAll("::",":"),A=A.replaceAll("%","%25"),K=K.createStaticChild(A)}if(z){let A=!1,N=!0,q="",w=[],j=B+1;for(let M=j;;M++){let I=W.charCodeAt(M),R=I===40,L=I===45||I===46,C=I===47||M===W.length;if(R||L||C){let _=W.slice(j,M);if(U.push(_),A=A||R||L,R){let b=kh(W,M),k=W.slice(M,b+1);if(!this.allowUnsafeRegex)V$(QY(new RegExp(k)),`The regex '${k}' is not safe!`);w.push(fh(k)),M=b+1,N=!0}else w.push(N?"(.*?)":`(${q}|(?:(?!${q}).)*)`),N=!1;let E=M;for(;M<W.length;M++){let b=W.charCodeAt(M);if(b===47)break;if(b===58)if(W.charCodeAt(M+1)===58)M++;else break}let f=W.slice(E,M);if(f)f=f.replaceAll("::",":"),f=f.replaceAll("%","%25"),w.push(q=Sh(f));if(j=M+1,C||W.charCodeAt(M)===47||M===W.length){let b=A?"()"+f:f,k=W.slice(B,M);W=W.slice(0,B+1)+b+W.slice(M),B+=b.length;let u=A?new RegExp("^"+w.join("")+"$"):null;K=K.createParametricChild(u,f||null,k),V=B+1;break}}}}else if(F){if(U.push("*"),K=K.createWildcardChild(),V=B+1,B!==W.length-1)throw Error("Wildcard must be the last character in the route")}}if(!this.caseSensitive)W=W.toLowerCase();if(W==="*")W="/*";for(let B of this.routes){let z=B.opts.constraints||{};if(B.method===Z&&B.pattern===W&&EF(z,G))throw Error(`Method '${Z}' already declared for route '${W}' with constraints '${JSON.stringify(G)}'`)}let H={method:Z,path:J,pattern:W,params:U,opts:Y,handler:X,store:Q};this.routes.push(H),K.addRoute(H,this.constrainer)};m1.prototype.hasRoute=function(Z,J,Y){return this.findRoute(Z,J,Y)!==null};m1.prototype.findRoute=function(Z,J,Y={}){if(this.trees[Z]===void 0)return null;let X=J,Q=this.trees[Z],G=Q.prefix.length,W=[];for(let K=0;K<=X.length;K++){if(X.charCodeAt(K)===58&&X.charCodeAt(K+1)===58){K++;continue}let V=X.charCodeAt(K)===58&&X.charCodeAt(K+1)!==58,U=X.charCodeAt(K)===42;if(V||U||K===X.length&&K!==G){let H=X.slice(G,K);if(!this.caseSensitive)H=H.toLowerCase();if(H=H.replaceAll("::",":"),H=H.replaceAll("%","%25"),Q=Q.getStaticChild(H),Q===null)return null}if(V){let H=!1,B=!0,z="",F=[],A=K+1;for(let N=A;;N++){let q=X.charCodeAt(N),w=q===40,j=q===45||q===46,M=q===47||N===X.length;if(w||j||M){let I=X.slice(A,N);if(W.push(I),H=H||w||j,w){let C=kh(X,N),_=X.slice(N,C+1);if(!this.allowUnsafeRegex)V$(QY(new RegExp(_)),`The regex '${_}' is not safe!`);F.push(fh(_)),N=C+1,B=!1}else F.push(B?"(.*?)":`(${z}|(?:(?!${z}).)*)`),B=!1;let R=N;for(;N<X.length;N++){let C=X.charCodeAt(N);if(C===47)break;if(C===58)if(X.charCodeAt(N+1)===58)N++;else break}let L=X.slice(R,N);if(L)L=L.replaceAll("::",":"),L=L.replaceAll("%","%25"),F.push(z=Sh(L));if(A=N+1,M||X.charCodeAt(N)===47||N===X.length){let C=H?"()"+L:L,_=X.slice(K,N);X=X.slice(0,K+1)+C+X.slice(N),K+=C.length;let E=H?new RegExp("^"+F.join("")+"$"):null;if(Q=Q.getParametricChild(E,L||null,_),Q===null)return null;G=K+1;break}}}}else if(U){if(W.push("*"),Q=Q.getWildcardChild(),G=K+1,K!==X.length-1)throw Error("Wildcard must be the last character in the route")}}if(!this.caseSensitive)X=X.toLowerCase();for(let K of this.routes){let V=K.opts.constraints||{};if(K.method===Z&&K.pattern===X&&EF(V,Y))return{handler:K.handler,store:K.store,params:K.params}}return null};m1.prototype.hasConstraintStrategy=function($){return this.constrainer.hasConstraintStrategy($)};m1.prototype.addConstraintStrategy=function($){this.constrainer.addConstraintStrategy($),this._rebuild(this.routes)};m1.prototype.reset=function(){this.trees={},this.routes=[]};m1.prototype.off=function(Z,J,Y){V$(typeof J==="string","Path should be a string"),V$(J.length>0,"The path could not be empty"),V$(J[0]==="/"||J[0]==="*","The first character of a path should be `/` or `*`"),V$(typeof Y>"u"||typeof Y==="object"&&!Array.isArray(Y)&&Y!==null,"Constraints should be an object or undefined.");let X=J.match(H7);if(X){V$(J.length===X.index+X[0].length,"Optional Parameter needs to be the last parameter of the path");let G=J.replace(H7,"$1$2"),W=J.replace(H7,"$2");this.off(Z,G,Y),this.off(Z,W,Y);return}if(this.ignoreDuplicateSlashes)J=lW(J);if(this.ignoreTrailingSlash)J=dW(J);let Q=Array.isArray(Z)?Z:[Z];for(let G of Q)this._off(G,J,Y)};m1.prototype._off=function(Z,J,Y){V$(typeof Z==="string","Method should be a string"),V$(XY.includes(Z),`Method '${Z}' is not an http method.`);function X(K){return Z!==K.method||J!==K.path}function Q(K){return X(K)||!EF(Y,K.opts.constraints||{})}let G=Y?Q:X,W=this.routes.filter(G);this._rebuild(W)};m1.prototype.lookup=function(Z,J,Y,X){if(typeof Y==="function")X=Y,Y=void 0;if(X===void 0){let Q=this.constrainer.deriveConstraints(Z,Y),G=this.find(Z.method,Z.url,Q);return this.callHandler(G,Z,J,Y)}this.constrainer.deriveConstraints(Z,Y,(Q,G)=>{if(Q!==null){X(Q);return}try{let W=this.find(Z.method,Z.url,G),K=this.callHandler(W,Z,J,Y);X(null,K)}catch(W){X(W)}})};m1.prototype.callHandler=function(Z,J,Y,X){if(Z===null)return this._defaultRoute(J,Y,X);return X===void 0?Z.handler(J,Y,Z.params,Z.store,Z.searchParams):Z.handler.call(X,J,Y,Z.params,Z.store,Z.searchParams)};m1.prototype.find=function(Z,J,Y){let X=this.trees[Z];if(X===void 0)return null;if(J.charCodeAt(0)!==47)J=J.replace(Eh,"/");if(this.ignoreDuplicateSlashes)J=lW(J);let Q,G,W;try{Q=Ih(J,this.useSemicolonDelimiter),J=Q.path,G=Q.querystring,W=Q.shouldDecodeParam}catch(A){return this._onBadUrl(J)}if(this.ignoreTrailingSlash)J=dW(J);let K=J;if(this.caseSensitive===!1)J=J.toLowerCase();let V=this.maxParamLength,U=X.prefix.length,H=[],B=J.length,z=[],F=!1;while(!0){if(U===B&&X.isLeafNode){let w=X.handlerStorage.getMatchingHandler(Y);if(w!==null)return{handler:w.handler,store:w.store,params:w._createParamsObject(H),searchParams:this.querystringParser(G)}}let A=X.getNextNode(J,U,z,H.length);if(A===null){if(z.length===0){if(F&&this.onMaxParamLength)return this._onMaxParamLength(K);return null}let w=z.pop();U=w.brotherPathIndex,H.splice(w.paramsCount),A=w.brotherNode}if(X=A,X.kind===Ch.STATIC){U+=X.prefix.length;continue}if(X.kind===Ch.WILDCARD){let w=K.slice(U);if(W)w=IF(w);H.push(w),U=B;continue}let N=K.indexOf("/",U);if(N===-1)N=B;let q=K.slice(U,N);if(W)q=IF(q);if(X.isRegex){let w=X.regex.exec(q);if(w===null){A=null;continue}let j=!1;for(let M=1;M<w.length;M++)if(w[M].length>V){j=!0;break}if(j){F=!0,A=null;continue}for(let M=1;M<w.length;M++)H.push(w[M])}else{if(q.length>V){F=!0,A=null;continue}H.push(q)}U=N}};m1.prototype._rebuild=function($){this.reset();for(let Z of $){let{method:J,path:Y,opts:X,handler:Q,store:G}=Z;this._on(J,Y,X,Q,G)}};m1.prototype._defaultRoute=function($,Z,J){if(this.defaultRoute!==null)return J===void 0?this.defaultRoute($,Z):this.defaultRoute.call(J,$,Z);else Z.statusCode=404,Z.end()};m1.prototype._onBadUrl=function($){if(this.onBadUrl===null)return null;let Z=this.onBadUrl;return{handler:(J,Y,X)=>Z($,J,Y),params:{},store:null}};m1.prototype._onMaxParamLength=function($){if(this.onMaxParamLength===null)return null;let Z=this.onMaxParamLength;return{handler:(J,Y,X)=>Z($,J,Y),params:{},store:null}};m1.prototype.prettyPrint=function($={}){let Z=$.method;$.buildPrettyMeta=this.buildPrettyMeta.bind(this);let J=null;if(Z===void 0){let{version:Y,host:X,...Q}=this.constrainer.strategies;Q[CF.name]=CF;let G=new m1({...this._opts,constraints:Q}),W=this.routes.map((K)=>{let V={...K.opts.constraints,[CF.name]:K.method};return{...K,method:"MERGED",opts:{constraints:V}}});G._rebuild(W),J=G.trees.MERGED}else J=this.trees[Z];if(J==null)return"(empty tree)";return _F0(J,$)};for(let $ in XY){if(!XY.hasOwnProperty($))continue;let Z=XY[$],J=Z.toLowerCase();m1.prototype[J]=function(Y,X,Q){return this.on(Z,Y,X,Q)}}m1.prototype.all=function($,Z,J){this.on(XY,$,Z,J)};m1.sanitizeUrlPath=function(Z,J){let Y=Ih(Z,J);if(Y.shouldDecodeParam)return IF(Y.path);return Y.path};m1.removeDuplicateSlashes=lW;m1.trimLastSlash=dW;vh.exports=m1;function Sh($){return $.replace(bh,"\\$&")}function lW($){return $.indexOf("//")!==-1?$.replace(_h,"/"):$}function dW($){if($.length>1&&$.charCodeAt($.length-1)===47)return $.slice(0,-1);return $}function fh($){if($.charCodeAt(1)===94)$=$.slice(0,1)+$.slice(2);if($.charCodeAt($.length-2)===36)$=$.slice(0,$.length-2)+$.slice($.length-1);return $}function kh($,Z){let J=1;while(Z<$.length){if(Z++,$.charCodeAt(Z)===92){Z++;continue}if($.charCodeAt(Z)===41)J--;else if($.charCodeAt(Z)===40)J++;if(!J)return Z}throw TypeError('Invalid regexp expression in "'+$+'"')}function fF0($){if(!$)return{};if(!$.store)return{};return Object.assign({},$.store)}});var xh=S((ix0,yh)=>{function _F($,Z,J,Y){if(J===void 0){Z.header("content-length","0"),Y(null,null);return}if(typeof J.resume==="function"){J.on("error",(Q)=>{Z.log.error({err:Q},"Error on Stream found for HEAD route")}),J.resume(),Y(null,null);return}if(typeof J.getReader==="function"){J.cancel("Stream cancelled by HEAD route").catch((Q)=>{Z.log.error({err:Q},"Error on Stream found for HEAD route")}),Y(null,null);return}let X=""+Buffer.byteLength(J);Z.header("content-length",X),Y(null,null)}function kF0($){if($==null)return _F;return Array.isArray($)?[...$,_F]:[$,_F]}yh.exports={parseHeadOnSendHandlers:kF0}});var Yg=S((nx0,Jg)=>{var vF0=bF(),yF0=CG(),hh=rH(),{onRequestAbortHookRunner:xF0,lifecycleHooks:gh,preParsingHookRunner:hF0,onTimeoutHookRunner:gF0,onRequestHookRunner:uF0}=mZ(),{normalizeSchema:mF0}=xX(),{parseHeadOnSendHandlers:lF0}=xh(),{compileSchemasForValidation:dF0,compileSchemasForSerialization:pF0}=iH(),{FST_ERR_SCH_VALIDATION_BUILD:cF0,FST_ERR_SCH_SERIALIZATION_BUILD:iF0,FST_ERR_DUPLICATED_ROUTE:nF0,FST_ERR_INVALID_URL:oF0,FST_ERR_HOOK_INVALID_HANDLER:uh,FST_ERR_ROUTE_OPTIONS_NOT_OBJ:sF0,FST_ERR_ROUTE_DUPLICATED_HANDLER:rF0,FST_ERR_ROUTE_HANDLER_NOT_FN:mh,FST_ERR_ROUTE_MISSING_HANDLER:aF0,FST_ERR_ROUTE_METHOD_NOT_SUPPORTED:tF0,FST_ERR_ROUTE_METHOD_INVALID:eF0,FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED:$A0,FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT:ZA0,FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT:JA0,FST_ERR_HANDLER_TIMEOUT:YA0,FST_ERR_HOOK_INVALID_ASYNC_HANDLER:SF}=T$(),{kRoutePrefix:XA0,kSupportedHTTPMethods:vF,kLogLevel:QA0,kLogSerializers:lh,kHooks:dh,kSchemaController:GA0,kOptions:ph,kReplySerializerDefault:fF,kReplyIsError:$g,kRequestPayloadStream:WA0,kDisableRequestLogging:ch,kSchemaErrorFormatter:KA0,kErrorHandler:ih,kHasBeenDecorated:nh,kRequestAcceptVersion:kF,kRouteByFastify:VA0,kRouteContext:oh,kRequestSignal:UA0,kTimeoutTimer:sh,kOnAbort:HA0}=B$(),{buildErrorHandler:BA0}=hX(),{createChildLogger:zA0}=yX(),{getGenReqId:FA0}=CW(),{FSTDEP022:AA0}=wJ(),rh=["allowUnsafeRegex","buildPrettyMeta","caseSensitive","constraints","defaultRoute","ignoreDuplicateSlashes","ignoreTrailingSlash","maxParamLength","onBadUrl","querystringParser","useSemicolonDelimiter"];function OA0($){let Z=vF0($),J,Y,X,Q,G,W,K,V,U,H,B,z,F,A=!1;return{setup(C,_){if(J=_.avvio,Y=_.fourOhFour,X=C.logger,Q=_.hasLogger,G=_.setupResponseListeners,W=_.throwIfAlreadyStarted,z=C.exposeHeadRoutes,K=C.disableRequestLogging,typeof K==="function")V=C.disableRequestLogging;U=C.routerOptions.ignoreTrailingSlash,H=C.routerOptions.ignoreDuplicateSlashes,B=Object.hasOwn(C,"return503OnClosing")?C.return503OnClosing:!0,F=_.keepAliveConnections},routing:Z.lookup.bind(Z),route:R,hasRoute:M,prepareRoute:j,routeHandler:L,closeRoutes:()=>{A=!0},printRoutes:Z.prettyPrint.bind(Z),addConstraintStrategy:N,hasConstraintStrategy:q,isAsyncConstraint:w,findRoute:I};function N(C){return W("Cannot add constraint strategy!"),Z.addConstraintStrategy(C)}function q(C){return Z.hasConstraintStrategy(C)}function w(){return Z.constrainer.asyncStrategiesInUse.size>0}function j({method:C,url:_,options:E,handler:f,isFastify:b}){if(typeof _!=="string")throw new oF0(typeof _);if(!f&&typeof E==="function")f=E,E={};else if(f&&typeof f==="function"){if(Object.prototype.toString.call(E)!=="[object Object]")throw new sF0(C,_);else if(E.handler)if(typeof E.handler==="function")throw new rF0(C,_);else throw new mh(C,_)}return E=Object.assign({},E,{method:C,url:_,path:_,handler:f||E&&E.handler}),R.call(this,{options:E,isFastify:b})}function M({options:C}){let _=C.method?.toUpperCase()??"";return Z.hasRoute(_,C.url||"",C.constraints)}function I(C){let _=Z.find(C.method,C.url||"",C.constraints);if(_)return{handler:_.handler,params:_.params,searchParams:_.searchParams};else return null}function R({options:C,isFastify:_}){W("Cannot add route!");let E={...C},f=E.url||E.path||"";if(!E.handler)throw new aF0(E.method,f);if(E.errorHandler!==void 0&&typeof E.errorHandler!=="function")throw new mh(E.method,f);Zg(E.bodyLimit),qA0(E.handlerTimeout);let b=E.exposeHeadRoute??z,k=!1,u=!1;if(Array.isArray(E.method))for(let e=0;e<E.method.length;++e)E.method[e]=ah.call(this,E.method[e]),th.call(this,E.method[e],f,E.schema),k=E.method.includes("GET"),u=E.method.includes("HEAD");else E.method=ah.call(this,E.method),th.call(this,E.method,f,E.schema),k=E.method==="GET",u=E.method==="HEAD";let x=b&&k?{...C}:null,g=this[XA0];if(f==="/"&&g.length>0&&E.method!=="HEAD")switch(E.prefixTrailingSlash){case"slash":c.call(this,{path:f,isFastify:_});break;case"no-slash":c.call(this,{path:"",isFastify:_});break;case"both":default:if(c.call(this,{path:"",isFastify:_}),U!==!0&&(H!==!0||!g.endsWith("/")))c.call(this,{path:f,prefixing:!0,isFastify:_})}else if(f[0]==="/"&&g.endsWith("/"))c.call(this,{path:f.slice(1),isFastify:_});else c.call(this,{path:f,isFastify:_});return this;function c({path:e,prefixing:G0=!1,isFastify:Q0=!1}){let z0=g+e;if(E.url=z0,E.path=z0,E.routePath=e,E.prefix=g,E.logLevel=E.logLevel||this[QA0],this[lh]||E.logSerializers)E.logSerializers=Object.assign(Object.create(this[lh]),E.logSerializers);if(E.attachValidation==null)E.attachValidation=!1;if(G0===!1)for(let y of this[dh].onRoute)y.call(this,E);for(let y of gh)if(E&&y in E){if(Array.isArray(E[y]))for(let p of E[y]){if(typeof p!=="function")throw new uh(y,Object.prototype.toString.call(p));if(y==="onSend"||y==="preSerialization"||y==="onError"||y==="preParsing"){if(p.constructor.name==="AsyncFunction"&&p.length===4)throw new SF}else if(y==="onRequestAbort"){if(p.constructor.name==="AsyncFunction"&&p.length!==1)throw new SF}else if(p.constructor.name==="AsyncFunction"&&p.length===3)throw new SF}else if(E[y]!==void 0&&typeof E[y]!=="function")throw new uh(y,Object.prototype.toString.call(E[y]))}let u0=E.constraints||{},m={...E.config,url:z0,method:E.method},l=new yF0({schema:E.schema,handler:E.handler.bind(this),config:m,errorHandler:E.errorHandler,childLoggerFactory:E.childLoggerFactory,bodyLimit:E.bodyLimit,logLevel:E.logLevel,logSerializers:E.logSerializers,attachValidation:E.attachValidation,schemaErrorFormatter:E.schemaErrorFormatter,replySerializer:this[fF],validatorCompiler:E.validatorCompiler,serializerCompiler:E.serializerCompiler,exposeHeadRoute:b,prefixTrailingSlash:E.prefixTrailingSlash||"both",server:this,isFastify:Q0,handlerTimeout:E.handlerTimeout}),h=Z.findRoute("HEAD",E.url,u0)!==null;try{Z.on(E.method,E.url,{constraints:u0},L,l)}catch(y){if(!l[VA0]){if(y.message.includes(`Method '${E.method}' already declared for route`))throw new nF0(E.method,E.url);throw y}}if(this.after((y,p)=>{l.errorHandler=E.errorHandler?BA0(this[ih],E.errorHandler):this[ih],l._parserOptions.limit=E.bodyLimit||null,l.logLevel=E.logLevel,l.logSerializers=E.logSerializers,l.attachValidation=E.attachValidation,l[fF]=this[fF],l.schemaErrorFormatter=E.schemaErrorFormatter||this[KA0]||l.schemaErrorFormatter,J.once("preReady",()=>{for(let d of gh){let a=this[dh][d].concat(E[d]||[]).map((s)=>s.bind(this));l[d]=a.length?a:null}while(!l.Request[nh]&&l.Request.parent)l.Request=l.Request.parent;while(!l.Reply[nh]&&l.Reply.parent)l.Reply=l.Reply.parent;if(Y.setContext(this,l),E.schema){l.schema=mF0(l.schema,this.initialConfig);let d=this[GA0],a=E.schema.body||E.schema.headers||E.schema.querystring||E.schema.params;if(!E.validatorCompiler&&a)d.setupValidator(this[ph]);try{let s=typeof E?.validatorCompiler==="function"||d.isCustomValidatorCompiler;dF0(l,E.validatorCompiler||d.validatorCompiler,s)}catch(s){throw new cF0(E.method,z0,s.message)}if(E.schema.response&&!E.serializerCompiler)d.setupSerializer(this[ph]);try{pF0(l,E.serializerCompiler||d.serializerCompiler)}catch(s){throw new iF0(E.method,z0,s.message)}}}),p(y)}),b&&k&&!u&&!h){let y=lF0(x.onSend);j.call(this,{method:"HEAD",url:e,options:{...x,onSend:y},isFastify:!0})}}}function L(C,_,E,f,b){let k=FA0(f.server,C),u={level:f.logLevel};if(f.logSerializers)u.serializers=f.logSerializers;let x=zA0(f,X,C,k,u);if(x[ch]=V?!1:K,A===!0){if(C.httpVersionMajor!==2)_.setHeader("Connection","close");if(B){let z0={"Content-Type":"application/json","Content-Length":"80"};_.writeHead(503,z0),_.end('{"error":"Service Unavailable","message":"Service Unavailable","statusCode":503}'),x.info({res:{statusCode:503}},"request aborted - refusing to accept new requests as server is closing");return}}if(String.prototype.toLowerCase.call(C.headers.connection||"")==="keep-alive"){if(F.has(C.socket)===!1)F.add(C.socket),C.socket.on("close",DA0.bind({keepAliveConnections:F,socket:C.socket}))}if(C.headers[kF]!==void 0)C.headers["accept-version"]=C.headers[kF],C.headers[kF]=void 0;let c=new f.Request(k,E,C,b,x,f),e=new f.Reply(_,c,x),G0=V?V(c):K;if(x[ch]=G0,G0===!1)x.info({req:c},"incoming request");let Q0=f.handlerTimeout;if(Q0>0){let z0=new AbortController;c[UA0]=z0,c[sh]=setTimeout(()=>{if(!e.sent){let m=new YA0(Q0,f.config?.url);z0.abort(m),e[$g]=!0,e.send(m)}},Q0);let u0=()=>{if(!z0.signal.aborted)z0.abort();clearTimeout(c[sh])};C.on("close",u0),c[HA0]=u0}if(Q===!0||f.onResponse!==null||Q0>0)G(e);if(f.onRequest!==null)uF0(f.onRequest,c,e,eh);else eh(null,c,e);if(f.onRequestAbort!==null)C.on("close",()=>{if(C.aborted)xF0(f.onRequestAbort,c,jA0.bind(null,e))});if(f.onTimeout!==null){if(!c.raw.socket._meta)c.raw.socket.on("timeout",NA0);c.raw.socket._meta={context:f,request:c,reply:e}}}}function jA0($,Z){if(Z)$.log.error({err:Z},"onRequestAborted hook failed")}function NA0(){let{context:$,request:Z,reply:J}=this._meta;gF0($.onTimeout,Z,J,wA0)}function ah($){if(typeof $!=="string")throw new eF0;if($=$.toUpperCase(),!this[vF].bodyless.has($)&&!this[vF].bodywith.has($))throw new tF0($);return $}function th($,Z,J){if(this[vF].bodyless.has($)&&J?.body)throw new $A0($,Z)}function Zg($){if($===void 0)return;if(!Number.isInteger($)||$<=0)throw new ZA0($)}function qA0($){if($===void 0)return;if(!Number.isInteger($)||$<=0)throw new JA0($)}function eh($,Z,J){if(J.sent===!0)return;if($!=null){J[$g]=!0,J.send($);return}if(Z[WA0]=Z.raw,Z[oh].preParsing!==null)hF0(Z[oh].preParsing,Z,J,hh.bind(Z.server));else hh.call(Z.server,null,Z,J)}function MA0($,Z){let J=$.routerOptions==null?Object.create(null):Object.assign(Object.create(null),$.routerOptions),Y=rh.filter((X)=>Object.hasOwn($,X));if(Y.length>0)AA0(Y.join(", "));for(let X of rh)if(!Object.hasOwn(J,X))J[X]=$[X]??Z[X];return J}function DA0(){this.keepAliveConnections.delete(this.socket)}function wA0(){}Jg.exports={buildRouting:OA0,validateBodyLimitOption:Zg,buildRouterOptions:MA0}});var Ug=S((ox0,Vg)=>{var LA0=bF(),Xg=MG(),Qg=PG(),TA0=CG(),{kRoutePrefix:RA0,kCanSetNotFoundHandler:S9,kFourOhFourLevelInstance:f9,kFourOhFourContext:S6,kHooks:PA0,kErrorHandler:Gg}=B$(),{lifecycleHooks:CA0}=mZ(),{buildErrorHandler:IA0}=hX(),{FST_ERR_NOT_FOUND:EA0}=T$(),{createChildLogger:Wg}=yX(),{getGenReqId:Kg}=CW();function bA0($){let{logger:Z,disableRequestLogging:J}=$,Y=LA0({onBadUrl:W(),defaultRoute:H}),X=null;return{router:Y,setNotFoundHandler:V,setContext:K,arrange404:Q};function Q(B){B[f9]=B,B[S9]=!0,Y.onBadUrl=Y.onBadUrl.bind(B),Y.defaultRoute=Y.defaultRoute.bind(B)}function G(B,z){let{url:F,method:A}=B.raw,N=`Route ${A}:${F} not found`;if(!(typeof J==="function"?J(B.raw):J))B.log.info(N);z.code(404).send({message:N,error:"Not Found",statusCode:404})}function W(){return function(z,F,A){let N=this[f9][S6],q=Kg(N.server,F),w=Wg(N,Z,F,q),j=new Qg(q,null,F,null,w,N),M=new Xg(A,j,w);X(j,M)}}function K(B,z){let F=Object.assign({},B[S6]);F.onSend=z.onSend,z[S6]=F}function V(B,z,F,A){if(this[S9]===void 0)this[S9]=!0;if(this[S6]===void 0)this[S6]=null;let N=this,q=this[RA0]||"/";if(this[S9]===!1)throw Error(`Not found handler already set for Fastify instance with prefix: '${q}'`);if(typeof B==="object"){if(B.preHandler)if(Array.isArray(B.preHandler))B.preHandler=B.preHandler.map((w)=>w.bind(N));else B.preHandler=B.preHandler.bind(N);if(B.preValidation)if(Array.isArray(B.preValidation))B.preValidation=B.preValidation.map((w)=>w.bind(N));else B.preValidation=B.preValidation.bind(N)}if(typeof B==="function")z=B,B=void 0;if(B=B||{},z)this[f9][S9]=!1,z=z.bind(this),X=z;else z=G,X=G;this.after((w,j)=>{U.call(this,q,B,z,F,A),j(w)})}function U(B,z,F,A,N){let q=new TA0({schema:z.schema,handler:F,config:z.config||{},server:this});if(A.once("preReady",()=>{let w=this[S6];for(let j of CA0){let M=this[PA0][j].concat(z[j]||[]).map((I)=>I.bind(this));w[j]=M.length?M:null}w.errorHandler=z.errorHandler?IA0(this[Gg],z.errorHandler):this[Gg]}),this[S6]!==null&&B==="/"){Object.assign(this[S6],q);return}this[f9][S6]=q,Y.all(B+(B.endsWith("/")?"*":"/*"),N,q),Y.all(B,N,q)}function H(B,z){let F=this[f9][S6],A=Kg(F.server,B),N=Wg(F,Z,B,A);N.info({req:B},"incoming request");let q=new Qg(A,null,B,null,N,F),w=new Xg(z,q,N);q.log.warn("the default handler for 404 did not catch this, this is likely a fastify bug, please report it"),q.log.warn(Y.prettyPrint()),w.code(404).send(new EA0)}}Vg.exports=bA0});var Hg=S((sx0,pW)=>{pW.exports=B1;pW.exports.default=B1;var _A0={type:"object",additionalProperties:!1,properties:{connectionTimeout:{type:"integer",default:0},keepAliveTimeout:{type:"integer",default:72000},forceCloseConnections:{oneOf:[{type:"string",pattern:"idle"},{type:"boolean"}]},maxRequestsPerSocket:{type:"integer",default:0,nullable:!0},requestTimeout:{type:"integer",default:0},handlerTimeout:{type:"integer",default:0},bodyLimit:{type:"integer",default:1048576},caseSensitive:{type:"boolean",default:!0},allowUnsafeRegex:{type:"boolean",default:!1},http2:{type:"boolean"},https:{if:{not:{oneOf:[{type:"boolean"},{type:"null"},{type:"object",additionalProperties:!1,required:["allowHTTP1"],properties:{allowHTTP1:{type:"boolean"}}}]}},then:{setDefaultValue:!0}},ignoreTrailingSlash:{type:"boolean",default:!1},ignoreDuplicateSlashes:{type:"boolean",default:!1},disableRequestLogging:{default:!1},maxParamLength:{type:"integer",default:100},onProtoPoisoning:{type:"string",default:"error"},onConstructorPoisoning:{type:"string",default:"error"},pluginTimeout:{type:"integer",default:1e4},requestIdHeader:{anyOf:[{type:"boolean"},{type:"string"}],default:!1},requestIdLogLabel:{type:"string",default:"reqId"},http2SessionTimeout:{type:"integer",default:72000},exposeHeadRoutes:{type:"boolean",default:!0},useSemicolonDelimiter:{type:"boolean",default:!1},routerOptions:{type:"object",additionalProperties:!0,properties:{ignoreTrailingSlash:{type:"boolean",default:!1},ignoreDuplicateSlashes:{type:"boolean",default:!1},maxParamLength:{type:"integer",default:100},allowUnsafeRegex:{type:"boolean",default:!1},useSemicolonDelimiter:{type:"boolean",default:!1}}},constraints:{type:"object",additionalProperties:{type:"object",required:["name","storage","validate","deriveConstraint"],additionalProperties:!0,properties:{name:{type:"string"},storage:{},validate:{},deriveConstraint:{}}}}}},SA0=Object.prototype.hasOwnProperty,fA0=new RegExp("idle","u");function B1($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0;if(G===0)if($&&typeof $=="object"&&!Array.isArray($)){if($.connectionTimeout===void 0)$.connectionTimeout=0;if($.keepAliveTimeout===void 0)$.keepAliveTimeout=72000;if($.maxRequestsPerSocket===void 0)$.maxRequestsPerSocket=0;if($.requestTimeout===void 0)$.requestTimeout=0;if($.handlerTimeout===void 0)$.handlerTimeout=0;if($.bodyLimit===void 0)$.bodyLimit=1048576;if($.caseSensitive===void 0)$.caseSensitive=!0;if($.allowUnsafeRegex===void 0)$.allowUnsafeRegex=!1;if($.ignoreTrailingSlash===void 0)$.ignoreTrailingSlash=!1;if($.ignoreDuplicateSlashes===void 0)$.ignoreDuplicateSlashes=!1;if($.disableRequestLogging===void 0)$.disableRequestLogging=!1;if($.maxParamLength===void 0)$.maxParamLength=100;if($.onProtoPoisoning===void 0)$.onProtoPoisoning="error";if($.onConstructorPoisoning===void 0)$.onConstructorPoisoning="error";if($.pluginTimeout===void 0)$.pluginTimeout=1e4;if($.requestIdHeader===void 0)$.requestIdHeader=!1;if($.requestIdLogLabel===void 0)$.requestIdLogLabel="reqId";if($.http2SessionTimeout===void 0)$.http2SessionTimeout=72000;if($.exposeHeadRoutes===void 0)$.exposeHeadRoutes=!0;if($.useSemicolonDelimiter===void 0)$.useSemicolonDelimiter=!1;let A=G;for(let N in $)if(!SA0.call(_A0.properties,N))delete $[N];if(A===G){let N=$.connectionTimeout,q=G;if(!(typeof N=="number"&&(!(N%1)&&!isNaN(N))&&isFinite(N))){let w=typeof N,j=void 0;if(j===void 0)if(w==="boolean"||N===null||w==="string"&&N&&N==+N&&!(N%1))j=+N;else return B1.errors=[{instancePath:Z+"/connectionTimeout",schemaPath:"#/properties/connectionTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(j!==void 0){if(N=j,$!==void 0)$.connectionTimeout=j}}var W=q===G;if(W){let w=$.keepAliveTimeout,j=G;if(!(typeof w=="number"&&(!(w%1)&&!isNaN(w))&&isFinite(w))){let I=typeof w,R=void 0;if(R===void 0)if(I==="boolean"||w===null||I==="string"&&w&&w==+w&&!(w%1))R=+w;else return B1.errors=[{instancePath:Z+"/keepAliveTimeout",schemaPath:"#/properties/keepAliveTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(R!==void 0){if(w=R,$!==void 0)$.keepAliveTimeout=R}}var W=j===G;if(W){if($.forceCloseConnections!==void 0){let I=$.forceCloseConnections,R=G,L=G,C=!1,_=null,E=G;if(typeof I!=="string"){let k=typeof I,u=void 0;if(u===void 0)if(k=="number"||k=="boolean")u=""+I;else if(I===null)u="";else{let x={instancePath:Z+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[x];else Q.push(x);G++}if(u!==void 0){if(I=u,$!==void 0)$.forceCloseConnections=u}}if(G===E){if(typeof I==="string"){if(!fA0.test(I)){let k={instancePath:Z+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf/0/pattern",keyword:"pattern",params:{pattern:"idle"},message:'must match pattern "idle"'};if(Q===null)Q=[k];else Q.push(k);G++}}}var K=E===G;if(K)C=!0,_=0;let f=G;if(typeof I!=="boolean"){let k=void 0;if(k===void 0)if(I==="false"||I===0||I===null)k=!1;else if(I==="true"||I===1)k=!0;else{let u={instancePath:Z+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf/1/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};if(Q===null)Q=[u];else Q.push(u);G++}if(k!==void 0){if(I=k,$!==void 0)$.forceCloseConnections=k}}var K=f===G;if(K&&C)C=!1,_=[_,1];else if(K)C=!0,_=1;if(!C){let k={instancePath:Z+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf",keyword:"oneOf",params:{passingSchemas:_},message:"must match exactly one schema in oneOf"};if(Q===null)Q=[k];else Q.push(k);return G++,B1.errors=Q,!1}else if(G=L,Q!==null)if(L)Q.length=L;else Q=null;var W=R===G}else var W=!0;if(W){let I=$.maxRequestsPerSocket,R=G;if(!(typeof I=="number"&&(!(I%1)&&!isNaN(I))&&isFinite(I))&&I!==null){let C=typeof I,_=void 0;if(_===void 0)if(C==="boolean"||I===null||C==="string"&&I&&I==+I&&!(I%1))_=+I;else if(I===""||I===0||I===!1)_=null;else return B1.errors=[{instancePath:Z+"/maxRequestsPerSocket",schemaPath:"#/properties/maxRequestsPerSocket/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(_!==void 0){if(I=_,$!==void 0)$.maxRequestsPerSocket=_}}var W=R===G;if(W){let C=$.requestTimeout,_=G;if(!(typeof C=="number"&&(!(C%1)&&!isNaN(C))&&isFinite(C))){let f=typeof C,b=void 0;if(b===void 0)if(f==="boolean"||C===null||f==="string"&&C&&C==+C&&!(C%1))b=+C;else return B1.errors=[{instancePath:Z+"/requestTimeout",schemaPath:"#/properties/requestTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(b!==void 0){if(C=b,$!==void 0)$.requestTimeout=b}}var W=_===G;if(W){let f=$.handlerTimeout,b=G;if(!(typeof f=="number"&&(!(f%1)&&!isNaN(f))&&isFinite(f))){let u=typeof f,x=void 0;if(x===void 0)if(u==="boolean"||f===null||u==="string"&&f&&f==+f&&!(f%1))x=+f;else return B1.errors=[{instancePath:Z+"/handlerTimeout",schemaPath:"#/properties/handlerTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(x!==void 0){if(f=x,$!==void 0)$.handlerTimeout=x}}var W=b===G;if(W){let u=$.bodyLimit,x=G;if(!(typeof u=="number"&&(!(u%1)&&!isNaN(u))&&isFinite(u))){let c=typeof u,e=void 0;if(e===void 0)if(c==="boolean"||u===null||c==="string"&&u&&u==+u&&!(u%1))e=+u;else return B1.errors=[{instancePath:Z+"/bodyLimit",schemaPath:"#/properties/bodyLimit/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(e!==void 0){if(u=e,$!==void 0)$.bodyLimit=e}}var W=x===G;if(W){let c=$.caseSensitive,e=G;if(typeof c!=="boolean"){let Q0=void 0;if(Q0===void 0)if(c==="false"||c===0||c===null)Q0=!1;else if(c==="true"||c===1)Q0=!0;else return B1.errors=[{instancePath:Z+"/caseSensitive",schemaPath:"#/properties/caseSensitive/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(Q0!==void 0){if(c=Q0,$!==void 0)$.caseSensitive=Q0}}var W=e===G;if(W){let Q0=$.allowUnsafeRegex,z0=G;if(typeof Q0!=="boolean"){let m=void 0;if(m===void 0)if(Q0==="false"||Q0===0||Q0===null)m=!1;else if(Q0==="true"||Q0===1)m=!0;else return B1.errors=[{instancePath:Z+"/allowUnsafeRegex",schemaPath:"#/properties/allowUnsafeRegex/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(m!==void 0){if(Q0=m,$!==void 0)$.allowUnsafeRegex=m}}var W=z0===G;if(W){if($.http2!==void 0){let m=$.http2,l=G;if(typeof m!=="boolean"){let h=void 0;if(h===void 0)if(m==="false"||m===0||m===null)h=!1;else if(m==="true"||m===1)h=!0;else return B1.errors=[{instancePath:Z+"/http2",schemaPath:"#/properties/http2/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(h!==void 0){if(m=h,$!==void 0)$.http2=h}}var W=l===G}else var W=!0;if(W){if($.https!==void 0){let m=$.https,l=G,t=G,h=!0,y=G,p=G,d=G,a=G,s=!1,H0=null,O0=G;if(typeof m!=="boolean"){let r=void 0;if(r===void 0)if(m==="false"||m===0||m===null)r=!1;else if(m==="true"||m===1)r=!0;else{let F0={};if(Q===null)Q=[F0];else Q.push(F0);G++}if(r!==void 0){if(m=r,$!==void 0)$.https=r}}var V=O0===G;if(V)s=!0,H0=0;let C0=G;if(m!==null){let r=void 0;if(r===void 0)if(m===""||m===0||m===!1)r=null;else{let F0={};if(Q===null)Q=[F0];else Q.push(F0);G++}if(r!==void 0){if(m=r,$!==void 0)$.https=r}}var V=C0===G;if(V&&s)s=!1,H0=[H0,1];else{if(V)s=!0,H0=1;let r=G;if(G===r)if(m&&typeof m=="object"&&!Array.isArray(m)){let W0;if(m.allowHTTP1===void 0&&(W0="allowHTTP1")){let j0={};if(Q===null)Q=[j0];else Q.push(j0);G++}else{let j0=G;for(let X1 in m)if(X1!=="allowHTTP1")delete m[X1];if(j0===G){if(m.allowHTTP1!==void 0){let X1=m.allowHTTP1;if(typeof X1!=="boolean"){let E0=void 0;if(E0===void 0)if(X1==="false"||X1===0||X1===null)E0=!1;else if(X1==="true"||X1===1)E0=!0;else{let G1={};if(Q===null)Q=[G1];else Q.push(G1);G++}if(E0!==void 0){if(X1=E0,m!==void 0)m.allowHTTP1=E0}}}}}}else{let W0={};if(Q===null)Q=[W0];else Q.push(W0);G++}var V=r===G;if(V&&s)s=!1,H0=[H0,2];else if(V)s=!0,H0=2}if(!s){let r={};if(Q===null)Q=[r];else Q.push(r);G++}else if(G=a,Q!==null)if(a)Q.length=a;else Q=null;var U=d===G;if(U){let r={};if(Q===null)Q=[r];else Q.push(r);G++}else if(G=p,Q!==null)if(p)Q.length=p;else Q=null;var H=y===G;if(G=t,Q!==null)if(t)Q.length=t;else Q=null;if(H){let r=G;$.https=!0;var H=r===G;h=H}if(!h){let r={instancePath:Z+"/https",schemaPath:"#/properties/https/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};if(Q===null)Q=[r];else Q.push(r);return G++,B1.errors=Q,!1}var W=l===G}else var W=!0;if(W){let m=$.ignoreTrailingSlash,l=G;if(typeof m!=="boolean"){let h=void 0;if(h===void 0)if(m==="false"||m===0||m===null)h=!1;else if(m==="true"||m===1)h=!0;else return B1.errors=[{instancePath:Z+"/ignoreTrailingSlash",schemaPath:"#/properties/ignoreTrailingSlash/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(h!==void 0){if(m=h,$!==void 0)$.ignoreTrailingSlash=h}}var W=l===G;if(W){let h=$.ignoreDuplicateSlashes,y=G;if(typeof h!=="boolean"){let d=void 0;if(d===void 0)if(h==="false"||h===0||h===null)d=!1;else if(h==="true"||h===1)d=!0;else return B1.errors=[{instancePath:Z+"/ignoreDuplicateSlashes",schemaPath:"#/properties/ignoreDuplicateSlashes/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(d!==void 0){if(h=d,$!==void 0)$.ignoreDuplicateSlashes=d}}var W=y===G;if(W){let d=$.maxParamLength,a=G;if(!(typeof d=="number"&&(!(d%1)&&!isNaN(d))&&isFinite(d))){let H0=typeof d,O0=void 0;if(O0===void 0)if(H0==="boolean"||d===null||H0==="string"&&d&&d==+d&&!(d%1))O0=+d;else return B1.errors=[{instancePath:Z+"/maxParamLength",schemaPath:"#/properties/maxParamLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(O0!==void 0){if(d=O0,$!==void 0)$.maxParamLength=O0}}var W=a===G;if(W){let H0=$.onProtoPoisoning,O0=G;if(typeof H0!=="string"){let p0=typeof H0,r=void 0;if(r===void 0)if(p0=="number"||p0=="boolean")r=""+H0;else if(H0===null)r="";else return B1.errors=[{instancePath:Z+"/onProtoPoisoning",schemaPath:"#/properties/onProtoPoisoning/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(r!==void 0){if(H0=r,$!==void 0)$.onProtoPoisoning=r}}var W=O0===G;if(W){let p0=$.onConstructorPoisoning,r=G;if(typeof p0!=="string"){let W0=typeof p0,j0=void 0;if(j0===void 0)if(W0=="number"||W0=="boolean")j0=""+p0;else if(p0===null)j0="";else return B1.errors=[{instancePath:Z+"/onConstructorPoisoning",schemaPath:"#/properties/onConstructorPoisoning/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(j0!==void 0){if(p0=j0,$!==void 0)$.onConstructorPoisoning=j0}}var W=r===G;if(W){let W0=$.pluginTimeout,j0=G;if(!(typeof W0=="number"&&(!(W0%1)&&!isNaN(W0))&&isFinite(W0))){let E0=typeof W0,G1=void 0;if(G1===void 0)if(E0==="boolean"||W0===null||E0==="string"&&W0&&W0==+W0&&!(W0%1))G1=+W0;else return B1.errors=[{instancePath:Z+"/pluginTimeout",schemaPath:"#/properties/pluginTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(G1!==void 0){if(W0=G1,$!==void 0)$.pluginTimeout=G1}}var W=j0===G;if(W){let E0=$.requestIdHeader,G1=G,T0=G,w1=!1,o0=G;if(typeof E0!=="boolean"){let t0=void 0;if(t0===void 0)if(E0==="false"||E0===0||E0===null)t0=!1;else if(E0==="true"||E0===1)t0=!0;else{let U1={instancePath:Z+"/requestIdHeader",schemaPath:"#/properties/requestIdHeader/anyOf/0/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};if(Q===null)Q=[U1];else Q.push(U1);G++}if(t0!==void 0){if(E0=t0,$!==void 0)$.requestIdHeader=t0}}var B=o0===G;if(w1=w1||B,!w1){let t0=G;if(typeof E0!=="string"){let v=typeof E0,i=void 0;if(i===void 0)if(v=="number"||v=="boolean")i=""+E0;else if(E0===null)i="";else{let n={instancePath:Z+"/requestIdHeader",schemaPath:"#/properties/requestIdHeader/anyOf/1/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[n];else Q.push(n);G++}if(i!==void 0){if(E0=i,$!==void 0)$.requestIdHeader=i}}var B=t0===G;w1=w1||B}if(!w1){let t0={instancePath:Z+"/requestIdHeader",schemaPath:"#/properties/requestIdHeader/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[t0];else Q.push(t0);return G++,B1.errors=Q,!1}else if(G=T0,Q!==null)if(T0)Q.length=T0;else Q=null;var W=G1===G;if(W){let t0=$.requestIdLogLabel,U1=G;if(typeof t0!=="string"){let i=typeof t0,n=void 0;if(n===void 0)if(i=="number"||i=="boolean")n=""+t0;else if(t0===null)n="";else return B1.errors=[{instancePath:Z+"/requestIdLogLabel",schemaPath:"#/properties/requestIdLogLabel/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(n!==void 0){if(t0=n,$!==void 0)$.requestIdLogLabel=n}}var W=U1===G;if(W){let i=$.http2SessionTimeout,n=G;if(!(typeof i=="number"&&(!(i%1)&&!isNaN(i))&&isFinite(i))){let b0=typeof i,M0=void 0;if(M0===void 0)if(b0==="boolean"||i===null||b0==="string"&&i&&i==+i&&!(i%1))M0=+i;else return B1.errors=[{instancePath:Z+"/http2SessionTimeout",schemaPath:"#/properties/http2SessionTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(M0!==void 0){if(i=M0,$!==void 0)$.http2SessionTimeout=M0}}var W=n===G;if(W){let b0=$.exposeHeadRoutes,M0=G;if(typeof b0!=="boolean"){let h0=void 0;if(h0===void 0)if(b0==="false"||b0===0||b0===null)h0=!1;else if(b0==="true"||b0===1)h0=!0;else return B1.errors=[{instancePath:Z+"/exposeHeadRoutes",schemaPath:"#/properties/exposeHeadRoutes/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(h0!==void 0){if(b0=h0,$!==void 0)$.exposeHeadRoutes=h0}}var W=M0===G;if(W){let h0=$.useSemicolonDelimiter,$0=G;if(typeof h0!=="boolean"){let V0=void 0;if(V0===void 0)if(h0==="false"||h0===0||h0===null)V0=!1;else if(h0==="true"||h0===1)V0=!0;else return B1.errors=[{instancePath:Z+"/useSemicolonDelimiter",schemaPath:"#/properties/useSemicolonDelimiter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(V0!==void 0){if(h0=V0,$!==void 0)$.useSemicolonDelimiter=V0}}var W=$0===G;if(W){if($.routerOptions!==void 0){let V0=$.routerOptions,$1=G;if(G===$1)if(V0&&typeof V0=="object"&&!Array.isArray(V0)){if(V0.ignoreTrailingSlash===void 0)V0.ignoreTrailingSlash=!1;if(V0.ignoreDuplicateSlashes===void 0)V0.ignoreDuplicateSlashes=!1;if(V0.maxParamLength===void 0)V0.maxParamLength=100;if(V0.allowUnsafeRegex===void 0)V0.allowUnsafeRegex=!1;if(V0.useSemicolonDelimiter===void 0)V0.useSemicolonDelimiter=!1;let H1=V0.ignoreTrailingSlash,C1=G;if(typeof H1!=="boolean"){let E1=void 0;if(E1===void 0)if(H1==="false"||H1===0||H1===null)E1=!1;else if(H1==="true"||H1===1)E1=!0;else return B1.errors=[{instancePath:Z+"/routerOptions/ignoreTrailingSlash",schemaPath:"#/properties/routerOptions/properties/ignoreTrailingSlash/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(E1!==void 0){if(H1=E1,V0!==void 0)V0.ignoreTrailingSlash=E1}}var z=C1===G;if(z){let E1=V0.ignoreDuplicateSlashes,b1=G;if(typeof E1!=="boolean"){let l1=void 0;if(l1===void 0)if(E1==="false"||E1===0||E1===null)l1=!1;else if(E1==="true"||E1===1)l1=!0;else return B1.errors=[{instancePath:Z+"/routerOptions/ignoreDuplicateSlashes",schemaPath:"#/properties/routerOptions/properties/ignoreDuplicateSlashes/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(l1!==void 0){if(E1=l1,V0!==void 0)V0.ignoreDuplicateSlashes=l1}}var z=b1===G;if(z){let l1=V0.maxParamLength,c8=G;if(!(typeof l1=="number"&&(!(l1%1)&&!isNaN(l1))&&isFinite(l1))){let O8=typeof l1,A6=void 0;if(A6===void 0)if(O8==="boolean"||l1===null||O8==="string"&&l1&&l1==+l1&&!(l1%1))A6=+l1;else return B1.errors=[{instancePath:Z+"/routerOptions/maxParamLength",schemaPath:"#/properties/routerOptions/properties/maxParamLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(A6!==void 0){if(l1=A6,V0!==void 0)V0.maxParamLength=A6}}var z=c8===G;if(z){let O8=V0.allowUnsafeRegex,A6=G;if(typeof O8!=="boolean"){let x$=void 0;if(x$===void 0)if(O8==="false"||O8===0||O8===null)x$=!1;else if(O8==="true"||O8===1)x$=!0;else return B1.errors=[{instancePath:Z+"/routerOptions/allowUnsafeRegex",schemaPath:"#/properties/routerOptions/properties/allowUnsafeRegex/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(x$!==void 0){if(O8=x$,V0!==void 0)V0.allowUnsafeRegex=x$}}var z=A6===G;if(z){let x$=V0.useSemicolonDelimiter,UQ=G;if(typeof x$!=="boolean"){let j8=void 0;if(j8===void 0)if(x$==="false"||x$===0||x$===null)j8=!1;else if(x$==="true"||x$===1)j8=!0;else return B1.errors=[{instancePath:Z+"/routerOptions/useSemicolonDelimiter",schemaPath:"#/properties/routerOptions/properties/useSemicolonDelimiter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(j8!==void 0){if(x$=j8,V0!==void 0)V0.useSemicolonDelimiter=j8}}var z=UQ===G}}}}}else return B1.errors=[{instancePath:Z+"/routerOptions",schemaPath:"#/properties/routerOptions/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=$1===G}else var W=!0;if(W)if($.constraints!==void 0){let V0=$.constraints,$1=G;if(G===$1)if(V0&&typeof V0=="object"&&!Array.isArray(V0))for(let H1 in V0){let C1=V0[H1],E1=G;if(G===E1)if(C1&&typeof C1=="object"&&!Array.isArray(C1)){let b1;if(C1.name===void 0&&(b1="name")||C1.storage===void 0&&(b1="storage")||C1.validate===void 0&&(b1="validate")||C1.deriveConstraint===void 0&&(b1="deriveConstraint"))return B1.errors=[{instancePath:Z+"/constraints/"+H1.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/constraints/additionalProperties/required",keyword:"required",params:{missingProperty:b1},message:"must have required property '"+b1+"'"}],!1;else if(C1.name!==void 0){let F6=C1.name;if(typeof F6!=="string"){let l1=typeof F6,c8=void 0;if(c8===void 0)if(l1=="number"||l1=="boolean")c8=""+F6;else if(F6===null)c8="";else return B1.errors=[{instancePath:Z+"/constraints/"+H1.replace(/~/g,"~0").replace(/\//g,"~1")+"/name",schemaPath:"#/properties/constraints/additionalProperties/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(c8!==void 0){if(F6=c8,C1!==void 0)C1.name=c8}}}}else return B1.errors=[{instancePath:Z+"/constraints/"+H1.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/constraints/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var F=E1===G;if(!F)break}else return B1.errors=[{instancePath:Z+"/constraints",schemaPath:"#/properties/constraints/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=$1===G}else var W=!0}}}}}}}}}}}}}}}}}}}}}}}}else return B1.errors=[{instancePath:Z,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return B1.errors=Q,G===0}pW.exports.defaultInitOptions={connectionTimeout:0,keepAliveTimeout:72000,maxRequestsPerSocket:0,requestTimeout:0,handlerTimeout:0,bodyLimit:1048576,caseSensitive:!0,allowUnsafeRegex:!1,disableRequestLogging:!1,ignoreTrailingSlash:!1,ignoreDuplicateSlashes:!1,maxParamLength:100,onProtoPoisoning:"error",onConstructorPoisoning:"error",pluginTimeout:1e4,requestIdHeader:!1,requestIdLogLabel:"reqId",http2SessionTimeout:72000,exposeHeadRoutes:!0,useSemicolonDelimiter:!1,allowErrorHandlerOverride:!0,routerOptions:{ignoreTrailingSlash:!1,ignoreDuplicateSlashes:!1,maxParamLength:100,allowUnsafeRegex:!1,useSemicolonDelimiter:!1}}});var Bg=S((rx0,iW)=>{var cW=Hg(),kA0=WG()({circles:!0,proto:!1}),{FST_ERR_INIT_OPTS_INVALID:vA0}=T$();function yA0($){let Z=kA0($);if(!cW(Z)){let J=new vA0(JSON.stringify(cW.errors.map((Y)=>Y.message)));throw J.errors=cW.errors,J}return yF(Z)}function yF($){let Z=Object.getOwnPropertyNames($);for(let J of Z){let Y=$[J];if(ArrayBuffer.isView(Y)&&!(Y instanceof DataView))continue;$[J]=Y&&typeof Y==="object"?yF(Y):Y}return Object.freeze($)}iW.exports=yA0;iW.exports.defaultInitOptions=cW.defaultInitOptions;iW.exports.utils={deepFreezeObject:yF}});var Dg=S((ax0,Mg)=>{var{kAvvioBoot:xA0,kChildren:zg,kRoutePrefix:Fg,kLogLevel:Ag,kLogSerializers:xF,kHooks:hF,kSchemaController:GY,kContentTypeParser:Og,kReply:jg,kRequest:Ng,kFourOhFour:hA0,kPluginNameChain:qg,kErrorHandlerAlreadySet:gA0}=B$(),uA0=MG(),mA0=PG(),lA0=XF(),dA0=Nz(),{buildHooks:pA0}=mZ(),k9=UF();Mg.exports=function(Z,J,Y){let X=k9.registerPlugin.call(Z,J),Q=k9.getPluginName(J)||k9.getFuncPreview(J);if(X)return Z[qg].push(Q),Z;let G=Object.create(Z);if(Z[zg].push(G),G.ready=Z[xA0].bind(G),G[zg]=[],G[jg]=uA0.buildReply(G[jg]),G[Ng]=mA0.buildRequest(G[Ng]),G[Og]=dA0.helpers.buildContentTypeParser(G[Og]),G[hF]=pA0(G[hF]),G[Fg]=cA0(G[Fg],Y.prefix),G[Ag]=Y.logLevel||G[Ag],G[GY]=lA0.buildSchemaController(Z[GY]),G.getSchema=G[GY].getSchema.bind(G[GY]),G.getSchemas=G[GY].getSchemas.bind(G[GY]),G[k9.kRegisteredPlugins]=Object.create(G[k9.kRegisteredPlugins]),G[qg]=[Q],G[gA0]=!1,G[xF]||Y.logSerializers)G[xF]=Object.assign(Object.create(G[xF]),Y.logSerializers);if(Y.prefix)G[hA0].arrange404(G);for(let W of G[hF].onRegister)W.call(Z,G,Y);return G};function cA0($,Z){if(!Z)return $;if($.endsWith("/")&&Z[0]==="/")Z=Z.slice(1);else if(Z[0]!=="/")Z="/"+Z;return $+Z}});var Eg=S((Pg)=>{Object.defineProperty(Pg,"__esModule",{value:!0});Pg.parseCookie=Tg;Pg.parse=Tg;Pg.stringifyCookie=aA0;Pg.stringifySetCookie=nW;Pg.serialize=nW;Pg.parseSetCookie=tA0;Pg.stringifySetCookie=nW;Pg.serialize=nW;var wg=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,Lg=/^[\u0021-\u003A\u003C-\u007E]*$/,iA0=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,nA0=/^[\u0020-\u003A\u003D-\u007E]*$/,oA0=/^-?\d+$/,sA0=Object.prototype.toString,rA0=(()=>{let $=function(){};return $.prototype=Object.create(null),$})();function Tg($,Z){let J=new rA0,Y=$.length;if(Y<2)return J;let X=Z?.decode||Rg,Q=0;do{let G=uF($,Q,Y);if(G===-1)break;let W=gF($,Q,Y);if(G>W){Q=$.lastIndexOf(";",G-1)+1;continue}let K=J5($,Q,G);if(J[K]===void 0)J[K]=X(J5($,G+1,W));Q=W+1}while(Q<Y);return J}function aA0($,Z){let J=Z?.encode||encodeURIComponent,Y=[];for(let X of Object.keys($)){let Q=$[X];if(Q===void 0)continue;if(!wg.test(X))throw TypeError(`cookie name is invalid: ${X}`);let G=J(Q);if(!Lg.test(G))throw TypeError(`cookie val is invalid: ${Q}`);Y.push(`${X}=${G}`)}return Y.join("; ")}function nW($,Z,J){let Y=typeof $==="object"?$:{...J,name:$,value:String(Z)},Q=(typeof Z==="object"?Z:J)?.encode||encodeURIComponent;if(!wg.test(Y.name))throw TypeError(`argument name is invalid: ${Y.name}`);let G=Y.value?Q(Y.value):"";if(!Lg.test(G))throw TypeError(`argument val is invalid: ${Y.value}`);let W=Y.name+"="+G;if(Y.maxAge!==void 0){if(!Number.isInteger(Y.maxAge))throw TypeError(`option maxAge is invalid: ${Y.maxAge}`);W+="; Max-Age="+Y.maxAge}if(Y.domain){if(!iA0.test(Y.domain))throw TypeError(`option domain is invalid: ${Y.domain}`);W+="; Domain="+Y.domain}if(Y.path){if(!nA0.test(Y.path))throw TypeError(`option path is invalid: ${Y.path}`);W+="; Path="+Y.path}if(Y.expires){if(!eA0(Y.expires)||!Number.isFinite(Y.expires.valueOf()))throw TypeError(`option expires is invalid: ${Y.expires}`);W+="; Expires="+Y.expires.toUTCString()}if(Y.httpOnly)W+="; HttpOnly";if(Y.secure)W+="; Secure";if(Y.partitioned)W+="; Partitioned";if(Y.priority)switch(typeof Y.priority==="string"?Y.priority.toLowerCase():void 0){case"low":W+="; Priority=Low";break;case"medium":W+="; Priority=Medium";break;case"high":W+="; Priority=High";break;default:throw TypeError(`option priority is invalid: ${Y.priority}`)}if(Y.sameSite)switch(typeof Y.sameSite==="string"?Y.sameSite.toLowerCase():Y.sameSite){case!0:case"strict":W+="; SameSite=Strict";break;case"lax":W+="; SameSite=Lax";break;case"none":W+="; SameSite=None";break;default:throw TypeError(`option sameSite is invalid: ${Y.sameSite}`)}return W}function tA0($,Z){let J=Z?.decode||Rg,Y=$.length,X=gF($,0,Y),Q=uF($,0,X),G=Q===-1?{name:"",value:J(J5($,0,X))}:{name:J5($,0,Q),value:J(J5($,Q+1,X))},W=X+1;while(W<Y){let K=gF($,W,Y),V=uF($,W,K),U=V===-1?J5($,W,K):J5($,W,V),H=V===-1?void 0:J5($,V+1,K);switch(U.toLowerCase()){case"httponly":G.httpOnly=!0;break;case"secure":G.secure=!0;break;case"partitioned":G.partitioned=!0;break;case"domain":G.domain=H;break;case"path":G.path=H;break;case"max-age":if(H&&oA0.test(H))G.maxAge=Number(H);break;case"expires":if(!H)break;let B=new Date(H);if(Number.isFinite(B.valueOf()))G.expires=B;break;case"priority":if(!H)break;let z=H.toLowerCase();if(z==="low"||z==="medium"||z==="high")G.priority=z;break;case"samesite":if(!H)break;let F=H.toLowerCase();if(F==="lax"||F==="strict"||F==="none")G.sameSite=F;break}W=K+1}return G}function gF($,Z,J){let Y=$.indexOf(";",Z);return Y===-1?J:Y}function uF($,Z,J){let Y=$.indexOf("=",Z);return Y<J?Y:-1}function J5($,Z,J){let Y=Z,X=J;do{let Q=$.charCodeAt(Y);if(Q!==32&&Q!==9)break}while(++Y<X);while(X>Y){let Q=$.charCodeAt(X-1);if(Q!==32&&Q!==9)break;X--}return $.slice(Y,X)}function Rg($){if($.indexOf("%")===-1)return $;try{return decodeURIComponent($)}catch(Z){return $}}function eA0($){return sA0.call($)==="[object Date]"}});var _g=S((ex0,oW)=>{var{format:mF}=J0("util");function XO0($){return bg({...$,name:"DeprecationWarning"})}function bg({name:$,code:Z,message:J,unlimited:Y=!1}={}){if(!$)throw Error("Warning name must not be empty");if(!Z)throw Error("Warning code must not be empty");if(!J)throw Error("Warning message must not be empty");if(typeof Y!=="boolean")throw Error("Warning opts.unlimited must be a boolean");Z=Z.toUpperCase();let X={[$]:function(G,W,K){if(Q.emitted===!0&&Q.unlimited!==!0)return;Q.emitted=!0,process.emitWarning(Q.format(G,W,K),Q.name,Q.code)}};if(Y)X={[$]:function(G,W,K){Q.emitted=!0,process.emitWarning(Q.format(G,W,K),Q.name,Q.code)}};let Q=X[$];return Q.emitted=!1,Q.message=J,Q.unlimited=Y,Q.code=Z,Q.format=function(G,W,K){let V;if(G&&W&&K)V=mF(J,G,W,K);else if(G&&W)V=mF(J,G,W);else if(G)V=mF(J,G);else V=J;return V},Q}var lF={createWarning:bg,createDeprecation:XO0};oW.exports=lF;oW.exports.default=lF;oW.exports.processWarning=lF});var kg=S(($h0,fg)=>{var{URL:Sg}=J0("url");fg.exports=function(Z,J){if((typeof Z==="string"||Object.prototype.toString.call(Z)==="[object String]")&&Z.startsWith("//"))Z="http://localhost"+Z;let Y=typeof Z==="object"?Object.assign(new Sg("http://localhost"),Z):new Sg(Z,"http://localhost");if(typeof J==="string"){J=new URLSearchParams(J);for(let X of J.keys()){Y.searchParams.delete(X);for(let Q of J.getAll(X))Y.searchParams.append(X,Q)}}else{let X=Object.assign({},Z.query,J);for(let Q in X){let G=X[Q];if(Array.isArray(G)){Y.searchParams.delete(Q);for(let W of G)Y.searchParams.append(Q,W)}else Y.searchParams.set(Q,G)}}return Y}});var vg=S((VO0,dF)=>{var{randomUUID:QO0}=J0("crypto"),{Readable:GO0}=J0("stream"),WY;function WO0($){return $&&typeof $==="object"&&typeof $.append==="function"&&typeof $.delete==="function"&&typeof $.get==="function"&&typeof $.getAll==="function"&&typeof $.has==="function"&&typeof $.set==="function"&&$[Symbol.toStringTag]==="FormData"}function KO0($){WY=WY??new TextEncoder;let Z=`----formdata-${QO0()}`,J=`--${Z}\r
|
|
445
|
+
Content-Disposition: form-data`;/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */let Y=(K)=>K.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22"),X=(K)=>K.replace(/\r?\n|\r/g,`\r
|
|
446
|
+
`),Q=new Uint8Array([13,10]);async function*G(){for(let[K,V]of $)if(typeof V==="string")yield WY.encode(`${J}; name="${Y(X(K))}"\r
|
|
447
|
+
\r
|
|
448
|
+
`),yield WY.encode(`${X(V)}\r
|
|
449
|
+
`);else{let U=`${J}; name="${Y(X(K))}"`;if(V.name&&(U+=`; filename="${Y(V.name)}"`),U+=`\r
|
|
450
|
+
Content-Type: ${V.type||"application/octet-stream"}\r
|
|
451
|
+
\r
|
|
452
|
+
`,yield WY.encode(U),V.stream)yield*V.stream();else yield V;yield Q}yield WY.encode(`--${Z}--`)}return{stream:GO0.from(G()),contentType:`multipart/form-data; boundary=${Z}`}}VO0.isFormDataLike=WO0;VO0.formDataToStream=KO0});var gg=S((Zh0,sW)=>{var{Readable:yg,addAbortSignal:BO0}=J0("stream"),pF=J0("util"),zO0=Eg(),FO0=J0("assert"),{createDeprecation:AO0}=_g(),OO0=kg(),{isFormDataLike:jO0,formDataToStream:NO0}=vg(),{EventEmitter:qO0}=J0("events"),MO0=AO0({name:"FastifyDeprecationLightMyRequest",code:"FST_LIGHTMYREQUEST_DEP01",message:'You are accessing "request.connection", use "request.socket" instead.'});function DO0($){return $.port?$.host:$.hostname+($.protocol==="https:"?":443":":80")}class xg extends qO0{constructor($){super();this.remoteAddress=$}}function hg($){return new Z(this);function Z(J){Y5.call(J,{...$,Request:void 0}),Object.assign(this,J);for(let Y of Object.keys(Y5.prototype))this.constructor.prototype[Y]=Y5.prototype[Y];return pF.inherits(this.constructor,$.Request),this}}function Y5($){yg.call(this,{autoDestroy:!1});let Z=OO0($.url||$.path,$.query);this.url=Z.pathname+Z.search,this.aborted=!1,this.httpVersionMajor=1,this.httpVersionMinor=1,this.httpVersion="1.1",this.method=$.method?$.method.toUpperCase():"GET",this.headers={},this.rawHeaders=[];let J=$.headers||{};for(let G in J){let W=G.toLowerCase();if((W==="user-agent"||W==="content-type")&&J[G]===void 0){this.headers[W]=void 0;continue}let K=J[G];FO0(K!==void 0,'invalid value "undefined" for header '+G),this.headers[W]=""+K}if("user-agent"in this.headers===!1)this.headers["user-agent"]="lightMyRequest";if(this.headers.host=this.headers.host||$.authority||DO0(Z),$.cookies){let{cookies:G}=$,W=Object.keys(G).map((K)=>zO0.serialize(K,G[K]));if(this.headers.cookie)W.unshift(this.headers.cookie);this.headers.cookie=W.join("; ")}this.socket=new xg($.remoteAddress||"127.0.0.1"),Object.defineProperty(this,"connection",{get(){return MO0(),this.socket},configurable:!0});let Y=$.payload||$.body||null,X=Y&&typeof Y.resume==="function";if(jO0(Y)){let G=NO0(Y);Y=G.stream,X=!0,this.headers["content-type"]=G.contentType,this.headers["transfer-encoding"]="chunked"}if(Y&&typeof Y!=="string"&&!X&&!Buffer.isBuffer(Y)){if(Y=JSON.stringify(Y),"content-type"in this.headers===!1)this.headers["content-type"]="application/json"}if(Y&&!X&&!Object.hasOwn(this.headers,"content-length"))this.headers["content-length"]=(Buffer.isBuffer(Y)?Y.length:Buffer.byteLength(Y)).toString();for(let G of Object.keys(this.headers))this.rawHeaders.push(G,this.headers[G]);this._lightMyRequest={payload:Y,isDone:!1,simulate:$.simulate||{},payloadAsStream:$.payloadAsStream,signal:$.signal};let Q=$.signal;if(Q)BO0(Q,this);{let G=this._lightMyRequest.payload;if(G?._readableState)this._read=wO0,G.on("error",(W)=>{this.destroy(W)}),G.on("end",()=>{this.push(null)});else this._read=LO0}return this}function wO0(){let $=this._lightMyRequest.payload,Z=!0,J=!1,Y;while(Z&&(Y=$.read()))J=!0,Z=this.push(Y);if(Z&&!J)this._lightMyRequest.payload.once("readable",this._read.bind(this))}function LO0(){setImmediate(()=>{if(this._lightMyRequest.isDone){if(this._lightMyRequest.simulate.end!==!1)this.push(null);return}if(this._lightMyRequest.isDone=!0,this._lightMyRequest.payload)if(this._lightMyRequest.simulate.split)this.push(this._lightMyRequest.payload.slice(0,1)),this.push(this._lightMyRequest.payload.slice(1));else this.push(this._lightMyRequest.payload);if(this._lightMyRequest.simulate.error)this.emit("error",Error("Simulated"));if(this._lightMyRequest.simulate.close)this.emit("close");if(this._lightMyRequest.simulate.end!==!1)this.push(null)})}pF.inherits(Y5,yg);pF.inherits(hg,Y5);Y5.prototype.destroy=function($){if(this.destroyed||this._lightMyRequest.isDone)return;if(this.destroyed=!0,$)this._error=!0,process.nextTick(()=>this.emit("error",$));process.nextTick(()=>this.emit("close"))};sW.exports=Y5;sW.exports.Request=Y5;sW.exports.CustomRequest=hg});var mg=S((Jh0,v9)=>{var rW={decodeValues:!0,map:!1,silent:!1};function cF($){return typeof $!=="string"||$ in{}}function iF(){return Object.create(null)}function nF($){return typeof $==="string"&&!!$.trim()}function oF($,Z){var J=$.split(";").filter(nF),Y=J.shift(),X=TO0(Y),Q=X.name,G=X.value;if(Z=Z?Object.assign({},rW,Z):rW,cF(Q))return null;try{G=Z.decodeValues?decodeURIComponent(G):G}catch(K){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",K)}var W=iF();return W.name=Q,W.value=G,J.forEach(function(K){var V=K.split("="),U=V.shift().trimLeft().toLowerCase();if(cF(U))return;var H=V.join("=");if(U==="expires")W.expires=new Date(H);else if(U==="max-age"){var B=parseInt(H,10);if(!Number.isNaN(B))W.maxAge=B}else if(U==="secure")W.secure=!0;else if(U==="httponly")W.httpOnly=!0;else if(U==="samesite")W.sameSite=H;else if(U==="partitioned")W.partitioned=!0;else if(U)W[U]=H}),W}function TO0($){var Z="",J="",Y=$.split("=");if(Y.length>1)Z=Y.shift(),J=Y.join("=");else J=$;return{name:Z,value:J}}function ug($,Z){if(Z=Z?Object.assign({},rW,Z):rW,!$)if(!Z.map)return[];else return iF();if($.headers)if(typeof $.headers.getSetCookie==="function")$=$.headers.getSetCookie();else if($.headers["set-cookie"])$=$.headers["set-cookie"];else{var J=$.headers[Object.keys($.headers).find(function(X){return X.toLowerCase()==="set-cookie"})];if(!J&&$.headers.cookie&&!Z.silent)console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning.");$=J}if(!Array.isArray($))$=[$];if(!Z.map)return $.filter(nF).map(function(X){return oF(X,Z)}).filter(Boolean);else{var Y=iF();return $.filter(nF).reduce(function(X,Q){var G=oF(Q,Z);if(G&&!cF(G.name))X[G.name]=G;return X},Y)}}function RO0($){if(Array.isArray($))return $;if(typeof $!=="string")return[];var Z=[],J=0,Y,X,Q,G,W;function K(){while(J<$.length&&/\s/.test($.charAt(J)))J+=1;return J<$.length}function V(){return X=$.charAt(J),X!=="="&&X!==";"&&X!==","}while(J<$.length){Y=J,W=!1;while(K())if(X=$.charAt(J),X===","){Q=J,J+=1,K(),G=J;while(J<$.length&&V())J+=1;if(J<$.length&&$.charAt(J)==="=")W=!0,J=G,Z.push($.substring(Y,Q)),Y=J;else J=Q+1}else J+=1;if(!W||J>=$.length)Z.push($.substring(Y,$.length))}return Z}v9.exports=ug;v9.exports.parse=ug;v9.exports.parseString=oF;v9.exports.splitCookiesString=RO0});var ig=S((Yh0,cg)=>{var y9=J0("http"),{Writable:PO0,Readable:lg,addAbortSignal:CO0}=J0("stream"),IO0=J0("util"),EO0=mg();function X5($,Z,J){if(y9.ServerResponse.call(this,$),$._lightMyRequest?.payloadAsStream){let W=this.emit.bind(this,"drain");this._lightMyRequest={headers:null,trailers:{},stream:new lg({read:W})};let K=$._lightMyRequest.signal;if(K)CO0(K,this._lightMyRequest.stream)}else this._lightMyRequest={headers:null,trailers:{},payloadChunks:[]};this.setHeader("foo","bar"),this.removeHeader("foo"),this.assignSocket(bO0()),this._promiseCallback=typeof J==="function";let Y=!1,X=(W)=>{if(Y)return;if(Y=!0,this._promiseCallback)return process.nextTick(()=>Z(W));process.nextTick(()=>Z(null,W))};this._lightMyRequest.onEndSuccess=X;let Q=!1,G=(W)=>{if(Y){if(this._lightMyRequest.stream&&!Q){if(!W)W=Error("response destroyed before completion"),W.code="LIGHT_ECONNRESET";this._lightMyRequest.stream.destroy(W),this._lightMyRequest.stream.on("error",()=>{})}return}if(Y=!0,!W)W=Error("response destroyed before completion"),W.code="LIGHT_ECONNRESET";if(this._promiseCallback)return process.nextTick(()=>J(W));process.nextTick(()=>Z(W,null))};if(this._lightMyRequest.stream)this.once("finish",()=>{Q=!0,this._lightMyRequest.stream.push(null)});else this.once("finish",()=>{let W=dg(this);W.raw.req=$,X(W)});this.connection.once("error",G),this.once("error",G),this.once("close",G)}IO0.inherits(X5,y9.ServerResponse);X5.prototype.setTimeout=function($,Z){return this.timeoutHandle=setTimeout(()=>{this.emit("timeout")},$),this.on("timeout",Z),this};X5.prototype.writeHead=function(){let $=y9.ServerResponse.prototype.writeHead.apply(this,arguments);if(pg(this),this._lightMyRequest.stream)this._lightMyRequest.onEndSuccess(dg(this));return $};X5.prototype.write=function($,Z,J){if(this.timeoutHandle)clearTimeout(this.timeoutHandle);if(y9.ServerResponse.prototype.write.call(this,$,Z,J),this._lightMyRequest.stream)return this._lightMyRequest.stream.push(Buffer.from($,Z));else return this._lightMyRequest.payloadChunks.push(Buffer.from($,Z)),!0};X5.prototype.end=function($,Z,J){if($)this.write($,Z);y9.ServerResponse.prototype.end.call(this,J),this.emit("finish"),this.destroy()};X5.prototype.destroy=function($){if(this.destroyed)return;if(this.destroyed=!0,$)process.nextTick(()=>this.emit("error",$));process.nextTick(()=>this.emit("close"))};X5.prototype.addTrailers=function($){for(let Z in $)this._lightMyRequest.trailers[Z.toLowerCase().trim()]=$[Z].toString().trim()};function dg($){if($._lightMyRequest.headers===null)pg($);_O0($);let Z={raw:{res:$},headers:$._lightMyRequest.headers,statusCode:$.statusCode,statusMessage:$.statusMessage,trailers:{},get cookies(){return EO0.parse(this)}};if(Z.trailers=$._lightMyRequest.trailers,$._lightMyRequest.payloadChunks){let J=Buffer.concat($._lightMyRequest.payloadChunks);Z.rawPayload=J,Z.payload=J.toString(),Z.body=Z.payload,Z.json=function(){return JSON.parse(Z.payload)}}else Z.json=function(){throw Error("Response payload is not available with payloadAsStream: true")};return Z.stream=function(){if($._lightMyRequest.stream)return $._lightMyRequest.stream;return lg.from($._lightMyRequest.payloadChunks)},Z}function bO0(){return new PO0({write($,Z,J){setImmediate(J)}})}function _O0($){let Z=$._lightMyRequest.headers;for(let J of Object.keys(Z)){let Y=Z[J];if(Array.isArray(Y))Z[J]=Y.map((X)=>""+X);else Z[J]=""+Y}}function pg($){$._lightMyRequest.headers=Object.assign({},$.getHeaders()),["Date","Connection","Transfer-Encoding"].forEach((Z)=>{let J=new RegExp("\\r\\n"+Z+": ([^\\r]*)\\r\\n"),Y=$._header?.match(J);if(Y)$._lightMyRequest.headers[Z.toLowerCase()]=Y[1]})}cg.exports=X5});var ng=S((Xh0,sF)=>{sF.exports=z$;sF.exports.default=z$;var SO0={type:"object",properties:{url:{oneOf:[{type:"string"},{type:"object",properties:{protocol:{type:"string"},hostname:{type:"string"},pathname:{type:"string"}},additionalProperties:!0,required:["pathname"]}]},path:{oneOf:[{type:"string"},{type:"object",properties:{protocol:{type:"string"},hostname:{type:"string"},pathname:{type:"string"}},additionalProperties:!0,required:["pathname"]}]},cookies:{type:"object",additionalProperties:!0},headers:{type:"object",additionalProperties:!0},query:{anyOf:[{type:"object",additionalProperties:!0},{type:"string"}]},simulate:{type:"object",properties:{end:{type:"boolean"},split:{type:"boolean"},error:{type:"boolean"},close:{type:"boolean"}}},authority:{type:"string"},remoteAddress:{type:"string"},method:{type:"string",enum:["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","QUERY","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE","acl","bind","checkout","connect","copy","delete","get","head","link","lock","m-search","merge","mkactivity","mkcalendar","mkcol","move","notify","options","patch","post","propfind","proppatch","purge","put","query","rebind","report","search","source","subscribe","trace","unbind","unlink","unlock","unsubscribe"]},validate:{type:"boolean"}},additionalProperties:!0,oneOf:[{required:["url"]},{required:["path"]}]};function z$($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0,W=G,K=!1,V=null,U=G;if($&&typeof $=="object"&&!Array.isArray($)){let M;if($.url===void 0&&(M="url")){let I={instancePath:Z,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"};if(Q===null)Q=[I];else Q.push(I);G++}}var B=U===G;if(B)K=!0,V=0;let H=G;if($&&typeof $=="object"&&!Array.isArray($)){let M;if($.path===void 0&&(M="path")){let I={instancePath:Z,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"};if(Q===null)Q=[I];else Q.push(I);G++}}var B=H===G;if(B&&K)K=!1,V=[V,1];else if(B)K=!0,V=1;if(!K){let M={instancePath:Z,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:V},message:"must match exactly one schema in oneOf"};if(Q===null)Q=[M];else Q.push(M);return G++,z$.errors=Q,!1}else if(G=W,Q!==null)if(W)Q.length=W;else Q=null;if(G===0)if($&&typeof $=="object"&&!Array.isArray($)){if($.url!==void 0){let M=$.url,I=G,R=G,L=!1,C=null,_=G;if(typeof M!=="string"){let f=typeof M,b=void 0;if(b===void 0)if(f=="number"||f=="boolean")b=""+M;else if(M===null)b="";else{let k={instancePath:Z+"/url",schemaPath:"#/properties/url/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[k];else Q.push(k);G++}if(b!==void 0){if(M=b,$!==void 0)$.url=b}}var F=_===G;if(F)L=!0,C=0;let E=G;if(G===E)if(M&&typeof M=="object"&&!Array.isArray(M)){let f;if(M.pathname===void 0&&(f="pathname")){let b={instancePath:Z+"/url",schemaPath:"#/properties/url/oneOf/1/required",keyword:"required",params:{missingProperty:f},message:"must have required property '"+f+"'"};if(Q===null)Q=[b];else Q.push(b);G++}else{if(M.protocol!==void 0){let b=M.protocol,k=G;if(typeof b!=="string"){let u=typeof b,x=void 0;if(x===void 0)if(u=="number"||u=="boolean")x=""+b;else if(b===null)x="";else{let g={instancePath:Z+"/url/protocol",schemaPath:"#/properties/url/oneOf/1/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[g];else Q.push(g);G++}if(x!==void 0){if(b=x,M!==void 0)M.protocol=x}}var z=k===G}else var z=!0;if(z){if(M.hostname!==void 0){let b=M.hostname,k=G;if(typeof b!=="string"){let x=typeof b,g=void 0;if(g===void 0)if(x=="number"||x=="boolean")g=""+b;else if(b===null)g="";else{let c={instancePath:Z+"/url/hostname",schemaPath:"#/properties/url/oneOf/1/properties/hostname/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[c];else Q.push(c);G++}if(g!==void 0){if(b=g,M!==void 0)M.hostname=g}}var z=k===G}else var z=!0;if(z)if(M.pathname!==void 0){let b=M.pathname,k=G;if(typeof b!=="string"){let x=typeof b,g=void 0;if(g===void 0)if(x=="number"||x=="boolean")g=""+b;else if(b===null)g="";else{let c={instancePath:Z+"/url/pathname",schemaPath:"#/properties/url/oneOf/1/properties/pathname/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[c];else Q.push(c);G++}if(g!==void 0){if(b=g,M!==void 0)M.pathname=g}}var z=k===G}else var z=!0}}}else{let f={instancePath:Z+"/url",schemaPath:"#/properties/url/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};if(Q===null)Q=[f];else Q.push(f);G++}var F=E===G;if(F&&L)L=!1,C=[C,1];else if(F)L=!0,C=1;if(!L){let f={instancePath:Z+"/url",schemaPath:"#/properties/url/oneOf",keyword:"oneOf",params:{passingSchemas:C},message:"must match exactly one schema in oneOf"};if(Q===null)Q=[f];else Q.push(f);return G++,z$.errors=Q,!1}else if(G=R,Q!==null)if(R)Q.length=R;else Q=null;var A=I===G}else var A=!0;if(A){if($.path!==void 0){let M=$.path,I=G,R=G,L=!1,C=null,_=G;if(typeof M!=="string"){let b=typeof M,k=void 0;if(k===void 0)if(b=="number"||b=="boolean")k=""+M;else if(M===null)k="";else{let u={instancePath:Z+"/path",schemaPath:"#/properties/path/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[u];else Q.push(u);G++}if(k!==void 0){if(M=k,$!==void 0)$.path=k}}var q=_===G;if(q)L=!0,C=0;let E=G;if(G===E)if(M&&typeof M=="object"&&!Array.isArray(M)){let b;if(M.pathname===void 0&&(b="pathname")){let k={instancePath:Z+"/path",schemaPath:"#/properties/path/oneOf/1/required",keyword:"required",params:{missingProperty:b},message:"must have required property '"+b+"'"};if(Q===null)Q=[k];else Q.push(k);G++}else{if(M.protocol!==void 0){let k=M.protocol,u=G;if(typeof k!=="string"){let x=typeof k,g=void 0;if(g===void 0)if(x=="number"||x=="boolean")g=""+k;else if(k===null)g="";else{let c={instancePath:Z+"/path/protocol",schemaPath:"#/properties/path/oneOf/1/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[c];else Q.push(c);G++}if(g!==void 0){if(k=g,M!==void 0)M.protocol=g}}var N=u===G}else var N=!0;if(N){if(M.hostname!==void 0){let k=M.hostname,u=G;if(typeof k!=="string"){let g=typeof k,c=void 0;if(c===void 0)if(g=="number"||g=="boolean")c=""+k;else if(k===null)c="";else{let e={instancePath:Z+"/path/hostname",schemaPath:"#/properties/path/oneOf/1/properties/hostname/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[e];else Q.push(e);G++}if(c!==void 0){if(k=c,M!==void 0)M.hostname=c}}var N=u===G}else var N=!0;if(N)if(M.pathname!==void 0){let k=M.pathname,u=G;if(typeof k!=="string"){let g=typeof k,c=void 0;if(c===void 0)if(g=="number"||g=="boolean")c=""+k;else if(k===null)c="";else{let e={instancePath:Z+"/path/pathname",schemaPath:"#/properties/path/oneOf/1/properties/pathname/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[e];else Q.push(e);G++}if(c!==void 0){if(k=c,M!==void 0)M.pathname=c}}var N=u===G}else var N=!0}}}else{let b={instancePath:Z+"/path",schemaPath:"#/properties/path/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};if(Q===null)Q=[b];else Q.push(b);G++}var q=E===G;if(q&&L)L=!1,C=[C,1];else if(q)L=!0,C=1;if(!L){let b={instancePath:Z+"/path",schemaPath:"#/properties/path/oneOf",keyword:"oneOf",params:{passingSchemas:C},message:"must match exactly one schema in oneOf"};if(Q===null)Q=[b];else Q.push(b);return G++,z$.errors=Q,!1}else if(G=R,Q!==null)if(R)Q.length=R;else Q=null;var A=I===G}else var A=!0;if(A){if($.cookies!==void 0){let M=$.cookies,I=G;if(G===I){if(!(M&&typeof M=="object"&&!Array.isArray(M)))return z$.errors=[{instancePath:Z+"/cookies",schemaPath:"#/properties/cookies/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1}var A=I===G}else var A=!0;if(A){if($.headers!==void 0){let M=$.headers,I=G;if(G===I){if(!(M&&typeof M=="object"&&!Array.isArray(M)))return z$.errors=[{instancePath:Z+"/headers",schemaPath:"#/properties/headers/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1}var A=I===G}else var A=!0;if(A){if($.query!==void 0){let M=$.query,I=G,R=G,L=!1,C=G;if(G===C){if(!(M&&typeof M=="object"&&!Array.isArray(M))){let E={instancePath:Z+"/query",schemaPath:"#/properties/query/anyOf/0/type",keyword:"type",params:{type:"object"},message:"must be object"};if(Q===null)Q=[E];else Q.push(E);G++}}var w=C===G;if(L=L||w,!L){let E=G;if(typeof M!=="string"){let b=typeof M,k=void 0;if(k===void 0)if(b=="number"||b=="boolean")k=""+M;else if(M===null)k="";else{let u={instancePath:Z+"/query",schemaPath:"#/properties/query/anyOf/1/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[u];else Q.push(u);G++}if(k!==void 0){if(M=k,$!==void 0)$.query=k}}var w=E===G;L=L||w}if(!L){let E={instancePath:Z+"/query",schemaPath:"#/properties/query/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[E];else Q.push(E);return G++,z$.errors=Q,!1}else if(G=R,Q!==null)if(R)Q.length=R;else Q=null;var A=I===G}else var A=!0;if(A){if($.simulate!==void 0){let M=$.simulate,I=G;if(G===I)if(M&&typeof M=="object"&&!Array.isArray(M)){if(M.end!==void 0){let L=M.end,C=G;if(typeof L!=="boolean"){let _=void 0;if(_===void 0)if(L==="false"||L===0||L===null)_=!1;else if(L==="true"||L===1)_=!0;else return z$.errors=[{instancePath:Z+"/simulate/end",schemaPath:"#/properties/simulate/properties/end/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(_!==void 0){if(L=_,M!==void 0)M.end=_}}var j=C===G}else var j=!0;if(j){if(M.split!==void 0){let L=M.split,C=G;if(typeof L!=="boolean"){let E=void 0;if(E===void 0)if(L==="false"||L===0||L===null)E=!1;else if(L==="true"||L===1)E=!0;else return z$.errors=[{instancePath:Z+"/simulate/split",schemaPath:"#/properties/simulate/properties/split/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(E!==void 0){if(L=E,M!==void 0)M.split=E}}var j=C===G}else var j=!0;if(j){if(M.error!==void 0){let L=M.error,C=G;if(typeof L!=="boolean"){let E=void 0;if(E===void 0)if(L==="false"||L===0||L===null)E=!1;else if(L==="true"||L===1)E=!0;else return z$.errors=[{instancePath:Z+"/simulate/error",schemaPath:"#/properties/simulate/properties/error/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(E!==void 0){if(L=E,M!==void 0)M.error=E}}var j=C===G}else var j=!0;if(j)if(M.close!==void 0){let L=M.close,C=G;if(typeof L!=="boolean"){let E=void 0;if(E===void 0)if(L==="false"||L===0||L===null)E=!1;else if(L==="true"||L===1)E=!0;else return z$.errors=[{instancePath:Z+"/simulate/close",schemaPath:"#/properties/simulate/properties/close/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(E!==void 0){if(L=E,M!==void 0)M.close=E}}var j=C===G}else var j=!0}}}else return z$.errors=[{instancePath:Z+"/simulate",schemaPath:"#/properties/simulate/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var A=I===G}else var A=!0;if(A){if($.authority!==void 0){let M=$.authority,I=G;if(typeof M!=="string"){let L=typeof M,C=void 0;if(C===void 0)if(L=="number"||L=="boolean")C=""+M;else if(M===null)C="";else return z$.errors=[{instancePath:Z+"/authority",schemaPath:"#/properties/authority/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(C!==void 0){if(M=C,$!==void 0)$.authority=C}}var A=I===G}else var A=!0;if(A){if($.remoteAddress!==void 0){let M=$.remoteAddress,I=G;if(typeof M!=="string"){let L=typeof M,C=void 0;if(C===void 0)if(L=="number"||L=="boolean")C=""+M;else if(M===null)C="";else return z$.errors=[{instancePath:Z+"/remoteAddress",schemaPath:"#/properties/remoteAddress/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(C!==void 0){if(M=C,$!==void 0)$.remoteAddress=C}}var A=I===G}else var A=!0;if(A){if($.method!==void 0){let M=$.method,I=G;if(typeof M!=="string"){let L=typeof M,C=void 0;if(C===void 0)if(L=="number"||L=="boolean")C=""+M;else if(M===null)C="";else return z$.errors=[{instancePath:Z+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(C!==void 0){if(M=C,$!==void 0)$.method=C}}if(!(M==="ACL"||M==="BIND"||M==="CHECKOUT"||M==="CONNECT"||M==="COPY"||M==="DELETE"||M==="GET"||M==="HEAD"||M==="LINK"||M==="LOCK"||M==="M-SEARCH"||M==="MERGE"||M==="MKACTIVITY"||M==="MKCALENDAR"||M==="MKCOL"||M==="MOVE"||M==="NOTIFY"||M==="OPTIONS"||M==="PATCH"||M==="POST"||M==="PROPFIND"||M==="PROPPATCH"||M==="PURGE"||M==="PUT"||M==="QUERY"||M==="REBIND"||M==="REPORT"||M==="SEARCH"||M==="SOURCE"||M==="SUBSCRIBE"||M==="TRACE"||M==="UNBIND"||M==="UNLINK"||M==="UNLOCK"||M==="UNSUBSCRIBE"||M==="acl"||M==="bind"||M==="checkout"||M==="connect"||M==="copy"||M==="delete"||M==="get"||M==="head"||M==="link"||M==="lock"||M==="m-search"||M==="merge"||M==="mkactivity"||M==="mkcalendar"||M==="mkcol"||M==="move"||M==="notify"||M==="options"||M==="patch"||M==="post"||M==="propfind"||M==="proppatch"||M==="purge"||M==="put"||M==="query"||M==="rebind"||M==="report"||M==="search"||M==="source"||M==="subscribe"||M==="trace"||M==="unbind"||M==="unlink"||M==="unlock"||M==="unsubscribe"))return z$.errors=[{instancePath:Z+"/method",schemaPath:"#/properties/method/enum",keyword:"enum",params:{allowedValues:SO0.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var A=I===G}else var A=!0;if(A)if($.validate!==void 0){let M=$.validate,I=G;if(typeof M!=="boolean"){let L=void 0;if(L===void 0)if(M==="false"||M===0||M===null)L=!1;else if(M==="true"||M===1)L=!0;else return z$.errors=[{instancePath:Z+"/validate",schemaPath:"#/properties/validate/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(L!==void 0){if(M=L,$!==void 0)$.validate=L}}var A=I===G}else var A=!0}}}}}}}}}else return z$.errors=[{instancePath:Z,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return z$.errors=Q,G===0}});var rg=S((Qh0,h9)=>{var fO0=J0("assert"),rF=gg(),aW=ig(),og=ng();function aF($,Z,J){if(J===void 0)return new x9($,Z);else return tW($,Z,J)}function kO0($,Z){let J=$._lightMyRequest.payload;if(!J||J._readableState||typeof J.resume!=="function")return Z();let Y=[];J.on("data",(X)=>Y.push(Buffer.from(X))),J.on("end",()=>{let X=Buffer.concat(Y);return $.headers["content-length"]=$.headers["content-length"]||""+X.length,delete $.headers["transfer-encoding"],$._lightMyRequest.payload=X,Z()}),J.resume()}function sg($,Z,J,Y){return J.once("error",function(X){if(this.destroyed)Y.destroy(X)}),J.once("close",function(){if(this.destroyed&&!this._error)Y.destroy()}),kO0(J,()=>$.call(Z,J,Y))}function tW($,Z,J){if(Z=typeof Z==="string"?{url:Z}:Z,Z.validate!==!1){if(fO0(typeof $==="function","dispatchFunc should be a function"),!og(Z))throw Error(og.errors.map((G)=>G.message))}let Y=Z.server||{},X=Z.Request?rF.CustomRequest:rF;if($.request&&$.request.app===$)Object.setPrototypeOf(Object.getPrototypeOf($.request),X.prototype),Object.setPrototypeOf(Object.getPrototypeOf($.response),aW.prototype);if(typeof J==="function"){let Q=new X(Z),G=new aW(Q,J);return sg($,Y,Q,G)}else return new Promise((Q,G)=>{let W=new X(Z),K=new aW(W,Q,G);sg($,Y,W,K)})}function x9($,Z){if(typeof Z==="string")this.option={url:Z};else this.option=Object.assign({},Z);if(this.dispatch=$,this._hasInvoked=!1,this._promise=null,this.option.autoStart!==!1)process.nextTick(()=>{if(!this._hasInvoked)this.end()})}var vO0=["delete","get","head","options","patch","post","put","trace"];vO0.forEach(($)=>{x9.prototype[$]=function(Z){if(this._hasInvoked===!0||this._promise)throw Error("The dispatch function has already been invoked");return this.option.url=Z,this.option.method=$.toUpperCase(),this}});var yO0=["body","cookies","headers","payload","query"];yO0.forEach(($)=>{x9.prototype[$]=function(Z){if(this._hasInvoked===!0||this._promise)throw Error("The dispatch function has already been invoked");return this.option[$]=Z,this}});x9.prototype.end=function($){if(this._hasInvoked===!0||this._promise)throw Error("The dispatch function has already been invoked");if(this._hasInvoked=!0,typeof $==="function")tW(this.dispatch,this.option,$);else return this._promise=tW(this.dispatch,this.option),this._promise};Object.getOwnPropertyNames(Promise.prototype).forEach(($)=>{if($==="constructor")return;x9.prototype[$]=function(...Z){if(!this._promise){if(this._hasInvoked===!0)throw Error("The dispatch function has already been invoked");this._hasInvoked=!0,this._promise=tW(this.dispatch,this.option)}return this._promise[$](...Z)}});function xO0($){return $ instanceof rF||$ instanceof aW||$?.constructor?.name==="_CustomLMRRequest"}h9.exports=aF;h9.exports.default=aF;h9.exports.inject=aF;h9.exports.isInjection=xO0});var Bu=S((Gh0,d9)=>{var hO0=uR(),JK=J0("http"),gO0=J0("diagnostics_channel"),g9,{kAvvioBoot:u9,kChildren:tF,kServerBindings:ag,kBodyLimit:uO0,kSupportedHTTPMethods:B7,kRoutePrefix:tg,kLogLevel:mO0,kLogSerializers:lO0,kHooks:eF,kSchemaController:Q5,kRequestAcceptVersion:dO0,kReplySerializerDefault:eg,kContentTypeParser:pO0,kReply:cO0,kRequest:iO0,kFourOhFour:nO0,kState:J$,kOptions:$A,kPluginNameChain:m9,kSchemaErrorFormatter:ZA,kErrorHandler:eW,kKeepAliveConnections:JA,kChildLoggerFactory:YA,kGenReqId:XA,kErrorHandlerAlreadySet:$K,kHandlerTimeout:oO0}=B$(),{createServer:sO0}=FP(),l9=MG(),ZK=PG(),rO0=CG(),z7=mX(),F7=Nz(),$u=XF(),{Hooks:aO0,hookRunnerApplication:Zu,supportedHooks:QA}=mZ(),{createChildLogger:Ju,defaultChildLoggerFactory:tO0,createLogger:eO0}=yX(),Yu=UF(),{getGenReqId:Xu,reqIdGenFactory:Uu}=CW(),{buildRouting:$j0,validateBodyLimitOption:Zj0,buildRouterOptions:Jj0}=Yg(),Yj0=Ug(),Hu=Bg(),Xj0=Dg(),{appendStackTrace:Qj0,AVVIO_ERRORS_MAP:Qu,...A7}=T$(),Gj0=uH(),{defaultInitOptions:F8}=Hu,{FST_ERR_ASYNC_CONSTRAINT:Wj0,FST_ERR_BAD_URL:Kj0,FST_ERR_OPTIONS_NOT_OBJ:Vj0,FST_ERR_QSP_NOT_FN:Uj0,FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN:Hj0,FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ:Bj0,FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR:zj0,FST_ERR_INSTANCE_ALREADY_LISTENING:Fj0,FST_ERR_REOPENED_CLOSE_SERVER:Aj0,FST_ERR_ROUTE_REWRITE_NOT_STR:Oj0,FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN:Gu,FST_ERR_ERROR_HANDLER_NOT_FN:jj0,FST_ERR_ERROR_HANDLER_ALREADY_SET:Nj0,FST_ERR_ROUTE_METHOD_INVALID:qj0}=A7,{buildErrorHandler:Wu}=hX(),{FSTWRN004:Mj0}=wJ(),Ku=gO0.channel("fastify.initialization");function GA($){let{options:Z,genReqId:J,disableRequestLogging:Y,hasLogger:X,initialConfig:Q}=Dj0($,f,b),G=$j0(Z.routerOptions),W=Yj0(Z),K=m(G,Z),{server:V,listen:U,forceCloseConnections:H,serverHasCloseAllConnections:B,serverHasCloseHttp2Sessions:z,keepAliveConnections:F}=sO0(Z,K),A=l9.setupResponseListeners,N=$u.buildSchemaController(null,Z.schemaController),q={[J$]:{listening:!1,closing:!1,started:!1,ready:!1,booting:!1,aborted:!1,readyResolver:null},[JA]:F,[B7]:{bodyless:new Set(["GET","HEAD","TRACE"]),bodywith:new Set(["DELETE","OPTIONS","PATCH","PUT","POST"])},[$A]:Z,[tF]:[],[ag]:[],[uO0]:Z.bodyLimit,[oO0]:Z.handlerTimeout,[tg]:"",[mO0]:"",[lO0]:null,[eF]:new aO0,[Q5]:N,[ZA]:null,[eW]:Wu(),[$K]:!1,[YA]:Z.childLoggerFactory||tO0,[eg]:null,[pO0]:new F7(Z.bodyLimit,Z.onProtoPoisoning||F8.onProtoPoisoning,Z.onConstructorPoisoning||F8.onConstructorPoisoning),[cO0]:l9.buildReply(l9),[iO0]:ZK.buildRequest(ZK,Z.trustProxy),[nO0]:W,[Yu.kRegisteredPlugins]:[],[m9]:["fastify"],[u9]:null,[XA]:J,routing:K,delete:function(y,p,d){return G.prepareRoute.call(this,{method:"DELETE",url:y,options:p,handler:d})},get:function(y,p,d){return G.prepareRoute.call(this,{method:"GET",url:y,options:p,handler:d})},head:function(y,p,d){return G.prepareRoute.call(this,{method:"HEAD",url:y,options:p,handler:d})},trace:function(y,p,d){return G.prepareRoute.call(this,{method:"TRACE",url:y,options:p,handler:d})},patch:function(y,p,d){return G.prepareRoute.call(this,{method:"PATCH",url:y,options:p,handler:d})},post:function(y,p,d){return G.prepareRoute.call(this,{method:"POST",url:y,options:p,handler:d})},put:function(y,p,d){return G.prepareRoute.call(this,{method:"PUT",url:y,options:p,handler:d})},options:function(y,p,d){return G.prepareRoute.call(this,{method:"OPTIONS",url:y,options:p,handler:d})},all:function(y,p,d){return G.prepareRoute.call(this,{method:this.supportedMethods,url:y,options:p,handler:d})},route:function(y){return G.route.call(this,{options:y})},hasRoute:function(y){return G.hasRoute.call(this,{options:y})},findRoute:function(y){return G.findRoute(y)},log:Z.logger,withTypeProvider:C,addHook:_,addSchema:E,getSchema:N.getSchema.bind(N),getSchemas:N.getSchemas.bind(N),setValidatorCompiler:x,setSerializerCompiler:c,setSchemaController:e,setReplySerializer:G0,setSchemaErrorFormatter:g,setGenReqId:l,addContentTypeParser:F7.helpers.addContentTypeParser,hasContentTypeParser:F7.helpers.hasContentTypeParser,getDefaultJsonParser:F7.defaultParsers.getDefaultJsonParser,defaultTextParser:F7.defaultParsers.defaultTextParser,removeContentTypeParser:F7.helpers.removeContentTypeParser,removeAllContentTypeParsers:F7.helpers.removeAllContentTypeParsers,register:null,after:null,ready:null,onClose:null,close:null,printPlugins:null,hasPlugin:function(h){return this[Yu.kRegisteredPlugins].includes(h)||this[m9].includes(h)},listen:U,server:V,addresses:function(){let h=this[ag].map((y)=>y.address());return h.push(this.server.address()),h.filter((y)=>y)},decorate:z7.add,hasDecorator:z7.exist,decorateReply:z7.decorateReply,decorateRequest:z7.decorateRequest,hasRequestDecorator:z7.existRequest,hasReplyDecorator:z7.existReply,getDecorator:z7.getInstanceDecorator,addHttpMethod:t,inject:R,printRoutes:u0,setNotFoundHandler:u,setErrorHandler:Q0,setChildLoggerFactory:z0,initialConfig:Q,addConstraintStrategy:G.addConstraintStrategy.bind(G),hasConstraintStrategy:G.hasConstraintStrategy.bind(G)};if(Object.defineProperties(q,{listeningOrigin:{get(){let h=this.addresses().slice(-1).pop();if(typeof h==="string")return h;let y=h.family==="IPv6"?`[${h.address}]`:h.address;return`${this[$A].https?"https":"http"}://${y}:${h.port}`}},pluginName:{configurable:!0,get(){if(this[m9].length>1)return this[m9].join(" -> ");return this[m9][0]}},prefix:{configurable:!0,get(){return this[tg]}},validatorCompiler:{configurable:!0,get(){return this[Q5].getValidatorCompiler()}},serializerCompiler:{configurable:!0,get(){return this[Q5].getSerializerCompiler()}},childLoggerFactory:{configurable:!0,get(){return this[YA]}},version:{configurable:!0,get(){return"5.8.5"}},errorHandler:{configurable:!0,get(){return this[eW].func}},genReqId:{configurable:!0,get(){return this[XA]}},supportedMethods:{configurable:!1,get(){return[...this[B7].bodyless,...this[B7].bodywith]}}}),Z.schemaErrorFormatter)Vu(Z.schemaErrorFormatter),q[ZA]=Z.schemaErrorFormatter.bind(q);let w=Number(Z.pluginTimeout),j=hO0(q,{autostart:!1,timeout:isNaN(w)===!1?w:F8.pluginTimeout,expose:{use:"register"}});j.override=Xj0,j.on("start",()=>q[J$].started=!0),q[u9]=q.ready,q.ready=L,q.printPlugins=j.prettyPrint.bind(j),j.once("preReady",()=>{q.onClose((h,y)=>{q[J$].closing=!0,G.closeRoutes(),Zu("preClose",q[u9],q,function(){if(q[J$].listening){if(H==="idle")h.server.closeIdleConnections();else if(B&&H)h.server.closeAllConnections();else if(H===!0)for(let p of q[JA])p.destroy(),q[JA].delete(p)}if(z)h.server.closeHttp2Sessions();if(!Z.serverFactory||q[J$].listening)h.server.close(function(p){if(p&&p.code!=="ERR_SERVER_NOT_RUNNING")y(null);else y()});else process.nextTick(y,null)})})});let M=new rO0({server:q,config:{}});if(q.setNotFoundHandler(),W.arrange404(q),G.setup(Z,{avvio:j,fourOhFour:W,hasLogger:X,setupResponseListeners:A,throwIfAlreadyStarted:I,keepAliveConnections:F}),V.on("clientError",Z.clientErrorHandler.bind(q)),Ku.hasSubscribers)Ku.publish({fastify:q});if("asyncDispose"in Symbol)q[Symbol.asyncDispose]=function(){return q.close()};return q;function I(h){if(q[J$].started)throw new Fj0(h)}function R(h,y){if(g9===void 0)g9=rg();if(q[J$].started){if(q[J$].closing){let p=new Aj0;if(y){y(p);return}else return Promise.reject(p)}return g9(K,h,y)}if(y)this.ready((p)=>{if(p)y(p,null);else g9(K,h,y)});else return g9((p,d)=>{this.ready(function(a){if(a){d.emit("error",a);return}K(p,d)})},h)}function L(h){if(this[J$].readyResolver!==null){if(h!=null){this[J$].readyResolver.promise.then(()=>h(null,q),h);return}return this[J$].readyResolver.promise}if(process.nextTick(y),this[J$].readyResolver=Gj0.withResolvers(),!h)return this[J$].readyResolver.promise;else this[J$].readyResolver.promise.then(()=>h(null,q),h);function y(){q[u9]((d,a)=>{if(d||q[J$].started||q[J$].ready||q[J$].booting)p(d);else q[J$].booting=!0,Zu("onReady",q[u9],q,p);a()})}function p(d){if(d=d!=null&&Qu[d.code]!=null?Qj0(d,new Qu[d.code](d.message)):d,d)return q[J$].readyResolver.reject(d);q[J$].readyResolver.resolve(q),q[J$].booting=!1,q[J$].ready=!0,q[J$].readyResolver=null}}function C(){return this}function _(h,y){if(I('Cannot call "addHook"!'),y==null)throw new A7.FST_ERR_HOOK_INVALID_HANDLER(h,y);if(h==="onSend"||h==="preSerialization"||h==="onError"||h==="preParsing"){if(y.constructor.name==="AsyncFunction"&&y.length===4)throw new A7.FST_ERR_HOOK_INVALID_ASYNC_HANDLER}else if(h==="onReady"||h==="onListen"){if(y.constructor.name==="AsyncFunction"&&y.length!==0)throw new A7.FST_ERR_HOOK_INVALID_ASYNC_HANDLER}else if(h==="onRequestAbort"){if(y.constructor.name==="AsyncFunction"&&y.length!==1)throw new A7.FST_ERR_HOOK_INVALID_ASYNC_HANDLER}else if(y.constructor.name==="AsyncFunction"&&y.length===3)throw new A7.FST_ERR_HOOK_INVALID_ASYNC_HANDLER;if(h==="onClose")this.onClose(y.bind(this));else if(h==="onReady"||h==="onListen"||h==="onRoute")this[eF].add(h,y);else this.after((d,a)=>{try{p.call(this,h,y),a(d)}catch(s){a(s)}});return this;function p(d,a){this[eF].add(d,a),this[tF].forEach((s)=>p.call(s,d,a))}}function E(h){return I('Cannot call "addSchema"!'),this[Q5].add(h),this[tF].forEach((y)=>y.addSchema(h)),this}function f(h,y){if(h.headers["accept-version"]!==void 0)h.headers[dO0]=h.headers["accept-version"],h.headers["accept-version"]=void 0;W.router.lookup(h,y)}function b(h,y,p){if(Z.frameworkErrors){let a=Xu(M.server,y),s=Ju(M,Z.logger,y,a),H0=new ZK(a,null,y,null,s,M),O0=new l9(p,H0,s);if((typeof Y==="function"?Y(y):Y)===!1)s.info({req:H0},"incoming request");return Z.frameworkErrors(new Kj0(h),H0,O0)}let d=JSON.stringify({error:"Bad Request",code:"FST_ERR_BAD_URL",message:`'${h}' is not a valid url component`,statusCode:400});p.writeHead(400,{"Content-Type":"application/json","Content-Length":Buffer.byteLength(d)}),p.end(d)}function k(h,y,p){if(h===!1)return;return function(a){if(a){if(Z.frameworkErrors){let H0=Xu(M.server,y),O0=Ju(M,Z.logger,y,H0),C0=new ZK(H0,null,y,null,O0,M),p0=new l9(p,C0,O0);if((typeof Y==="function"?Y(y):Y)===!1)O0.info({req:C0},"incoming request");return Z.frameworkErrors(new Wj0,C0,p0)}let s='{"error":"Internal Server Error","message":"Unexpected error from async constraint","statusCode":500}';p.writeHead(500,{"Content-Type":"application/json","Content-Length":s.length}),p.end(s)}}}function u(h,y){return I('Cannot call "setNotFoundHandler"!'),W.setNotFoundHandler.call(this,h,y,j,G.routeHandler),this}function x(h){return I('Cannot call "setValidatorCompiler"!'),this[Q5].setValidatorCompiler(h),this}function g(h){return I('Cannot call "setSchemaErrorFormatter"!'),Vu(h),this[ZA]=h.bind(this),this}function c(h){return I('Cannot call "setSerializerCompiler"!'),this[Q5].setSerializerCompiler(h),this}function e(h){I('Cannot call "setSchemaController"!');let y=this[Q5],p=$u.buildSchemaController(y,Object.assign({},y.opts,h));return this[Q5]=p,this.getSchema=p.getSchema.bind(p),this.getSchemas=p.getSchemas.bind(p),this}function G0(h){return I('Cannot call "setReplySerializer"!'),this[eg]=h,this}function Q0(h){if(I('Cannot call "setErrorHandler"!'),typeof h!=="function")throw new jj0;if(!Z.allowErrorHandlerOverride&&this[$K])throw new Nj0;else if(this[$K])Mj0("To disable this behavior, set 'allowErrorHandlerOverride' to false or ignore this message. For more information, visit: https://fastify.dev/docs/latest/Reference/Server/#allowerrorhandleroverride");return this[$K]=!0,this[eW]=Wu(this[eW],h.bind(this)),this}function z0(h){return I('Cannot call "setChildLoggerFactory"!'),this[YA]=h,this}function u0(h={}){return h.includeMeta=h.includeHooks?h.includeMeta?QA.concat(h.includeMeta):QA:h.includeMeta,G.printRoutes(h)}function m(h,{rewriteUrl:y,logger:p}){let d;return function(s,H0){if(d===void 0)d=h.isAsyncConstraint();if(y){s.originalUrl=s.url;let O0=y.call(q,s);if(typeof O0==="string")s.url=O0;else{let C0=new Oj0(s.url,typeof O0);s.destroy(C0)}}h.routing(s,H0,k(d,s,H0))}}function l(h){return I('Cannot call "setGenReqId"!'),this[XA]=Uu(this[$A].requestIdHeader,h),this}function t(h,{hasBody:y=!1}={}){if(typeof h!=="string"||JK.METHODS.indexOf(h)===-1)throw new qj0;if(y===!0)this[B7].bodywith.add(h),this[B7].bodyless.delete(h);else this[B7].bodywith.delete(h),this[B7].bodyless.add(h);let p=h.toLowerCase();if(!this.hasDecorator(p))this.decorate(p,function(d,a,s){return G.prepareRoute.call(this,{method:h,url:d,options:a,handler:s})});return this}}function Dj0($,Z,J){if($&&typeof $!=="object")throw new Vj0;else $=Object.assign({},$);if($.querystringParser&&typeof $.querystringParser!=="function"||$.routerOptions?.querystringParser&&typeof $.routerOptions.querystringParser!=="function")throw new Uj0(typeof($.querystringParser??$.routerOptions.querystringParser));if($.schemaController&&$.schemaController.bucket&&typeof $.schemaController.bucket!=="function")throw new Hj0(typeof $.schemaController.bucket);Zj0($.bodyLimit);let Y=typeof $.requestIdHeader==="string"&&$.requestIdHeader.length!==0?$.requestIdHeader.toLowerCase():$.requestIdHeader===!0&&"request-id",X=Uu(Y,$.genReqId),Q=$.requestIdLogLabel||"reqId";$.bodyLimit=$.bodyLimit||F8.bodyLimit;let G=$.disableRequestLogging||!1,W=Object.assign({customOptions:{},plugins:[]},$.ajv);if(!W.customOptions||Object.prototype.toString.call(W.customOptions)!=="[object Object]")throw new Bj0(typeof W.customOptions);if(!W.plugins||!Array.isArray(W.plugins))throw new zj0(typeof W.plugins);let{logger:K,hasLogger:V}=eO0($);$.connectionTimeout=$.connectionTimeout||F8.connectionTimeout,$.keepAliveTimeout=$.keepAliveTimeout||F8.keepAliveTimeout,$.maxRequestsPerSocket=$.maxRequestsPerSocket||F8.maxRequestsPerSocket,$.requestTimeout=$.requestTimeout||F8.requestTimeout,$.logger=K,$.requestIdHeader=Y,$.requestIdLogLabel=Q,$.disableRequestLogging=G,$.ajv=W,$.clientErrorHandler=$.clientErrorHandler||Lj0,$.allowErrorHandlerOverride=$.allowErrorHandlerOverride??F8.allowErrorHandlerOverride;let U=Hu($);return $.exposeHeadRoutes=U.exposeHeadRoutes,$.http2SessionTimeout=U.http2SessionTimeout,$.routerOptions=Jj0($,{defaultRoute:Z,onBadUrl:J,ignoreTrailingSlash:F8.ignoreTrailingSlash,ignoreDuplicateSlashes:F8.ignoreDuplicateSlashes,maxParamLength:F8.maxParamLength,allowUnsafeRegex:F8.allowUnsafeRegex,buildPrettyMeta:wj0,useSemicolonDelimiter:F8.useSemicolonDelimiter}),{options:$,genReqId:X,disableRequestLogging:G,hasLogger:V,initialConfig:U}}function wj0($){let Z={};return["errorHandler","logLevel","logSerializers"].concat(QA).forEach((Y)=>{Z[Y]=$.store[Y]}),Object.assign({},Z)}function Lj0($,Z){if($.code==="ECONNRESET"||Z.destroyed)return;let J,Y,X,Q;if($.code==="ERR_HTTP_REQUEST_TIMEOUT")Y="408",X=JK.STATUS_CODES[Y],J=`{"error":"${X}","message":"Client Timeout","statusCode":408}`,Q="timeout";else if($.code==="HPE_HEADER_OVERFLOW")Y="431",X=JK.STATUS_CODES[Y],J=`{"error":"${X}","message":"Exceeded maximum allowed HTTP header size","statusCode":431}`,Q="header_overflow";else Y="400",X=JK.STATUS_CODES[Y],J=`{"error":"${X}","message":"Client Error","statusCode":400}`,Q="error";if(this.log.trace({err:$},`client ${Q}`),Z.writable)Z.write(`HTTP/1.1 ${Y} ${X}\r
|
|
453
|
+
Content-Length: ${J.length}\r
|
|
454
|
+
Content-Type: application/json\r
|
|
455
|
+
\r
|
|
456
|
+
${J}`);Z.destroy($)}function Vu($){if(typeof $!=="function")throw new Gu(typeof $);else if($.constructor.name==="AsyncFunction")throw new Gu("AsyncFunction")}d9.exports=GA;d9.exports.errorCodes=A7;d9.exports.fastify=GA;d9.exports.default=GA});var Fu=S((Wh0,WA)=>{var Tj0=/at\s(?:.*\.)?plugin\s.*\n\s*(.*)/,Rj0=/(\w*(\.\w*)*)\..*/;WA.exports=function(Z){if(Z.name.length>0)return Z.name;let J=Error.stackTraceLimit;Error.stackTraceLimit=10;try{throw Error("anonymous function")}catch(Y){return Error.stackTraceLimit=J,zu(Y.stack)}};function zu($){let Z=$.match(Tj0);return Z?Z[1].split(/[/\\]/).slice(-1)[0].match(Rj0)[1]:"anonymous"}WA.exports.extractPluginName=zu});var Ou=S((Kh0,Au)=>{Au.exports=function(Z){if(Z[0]==="@")Z=Z.slice(1).replace("/","-");return Z.replace(/-(.)/g,function(J,Y){return Y.toUpperCase()})}});var ju=S((Vh0,YK)=>{var Pj0=Fu(),Cj0=Ou(),Ij0=0;function KA($,Z={}){let J=!1;if($.default!==void 0)$=$.default;if(typeof $!=="function")throw TypeError(`fastify-plugin expects a function, instead got a '${typeof $}'`);if(typeof Z==="string")Z={fastify:Z};if(typeof Z!=="object"||Array.isArray(Z)||Z===null)throw TypeError("The options object should be an object");if(Z.fastify!==void 0&&typeof Z.fastify!=="string")throw TypeError(`fastify-plugin expects a version string, instead got '${typeof Z.fastify}'`);if(!Z.name)J=!0,Z.name=Pj0($)+"-auto-"+Ij0++;if($[Symbol.for("skip-override")]=Z.encapsulate!==!0,$[Symbol.for("fastify.display-name")]=Z.name,$[Symbol.for("plugin-meta")]=Z,!$.default)$.default=$;let Y=Cj0(Z.name);if(!J&&!$[Y])$[Y]=$;return $}YK.exports=KA;YK.exports.default=KA;YK.exports.fastifyPlugin=KA});var Nu=S((Sj0)=>{var Ej0=/^(-?(?:\d+)?\.?\d+) *(m(?:illiseconds?|s(?:ecs?)?))?(s(?:ec(?:onds?|s)?)?)?(m(?:in(?:utes?|s)?)?)?(h(?:ours?|rs?)?)?(d(?:ays?)?)?(w(?:eeks?|ks?)?)?(y(?:ears?|rs?)?)?$/,XK=1000,QK=XK*60,GK=QK*60,c9=GK*24,VA=c9*365.25;function bj0($){var Z,J=$.toLowerCase().match(Ej0);if(J!=null&&(Z=parseFloat(J[1]))){if(J[3]!=null)return Z*XK;if(J[4]!=null)return Z*QK;if(J[5]!=null)return Z*GK;if(J[6]!=null)return Z*c9;if(J[7]!=null)return Z*c9*7;if(J[8]!=null)return Z*VA;return Z}}function p9($,Z,J,Y){var X=($|0)===$?$:~~($+0.5);return Z+X+(Y?" "+J+(X!=1?"s":""):J[0])}function _j0($,Z){var J=$<0?"-":"",Y=$<0?-$:$;if(Y<XK)return $+(Z?" ms":"ms");if(Y<QK)return p9(Y/XK,J,"second",Z);if(Y<GK)return p9(Y/QK,J,"minute",Z);if(Y<c9)return p9(Y/GK,J,"hour",Z);if(Y<VA)return p9(Y/c9,J,"day",Z);return p9(Y/VA,J,"year",Z)}Sj0.format=_j0;Sj0.parse=bj0});var Mu=S((Hh0,qu)=>{var{LruMap:vj0}=Bz();function WK($,Z,J=5000){this.continueExceeding=$,this.exponentialBackoff=Z,this.lru=new vj0(J)}WK.prototype.incr=function($,Z,J,Y){let X=Date.now(),Q=this.lru.get($);if(!Q)Q={current:1,ttl:J,iterationStartMs:X};else if(Q.iterationStartMs+J<=X)Q.current=1,Q.ttl=J,Q.iterationStartMs=X;else if(++Q.current,this.continueExceeding&&Q.current>Y)Q.ttl=J,Q.iterationStartMs=X;else if(this.exponentialBackoff&&Q.current>Y){let G=Q.current-Y-1,W=J*2**G;Q.ttl=Number.isSafeInteger(W)?W:Number.MAX_SAFE_INTEGER,Q.iterationStartMs=X}else Q.ttl=J-(X-Q.iterationStartMs);this.lru.set($,Q),Z(null,Q)};WK.prototype.child=function($){return new WK($.continueExceeding,$.exponentialBackoff,$.cache)};qu.exports=WK});var wu=S((Bh0,Du)=>{function KK($,Z,J,Y="fastify-rate-limit-"){if(this.continueExceeding=$,this.exponentialBackoff=Z,this.redis=J,this.key=Y,!this.redis.rateLimit)this.redis.defineCommand("rateLimit",{numberOfKeys:1,lua:`
|
|
457
|
+
-- Key to operate on
|
|
458
|
+
local key = KEYS[1]
|
|
459
|
+
-- Time window for the TTL
|
|
460
|
+
local timeWindow = tonumber(ARGV[1])
|
|
461
|
+
-- Max requests
|
|
462
|
+
local max = tonumber(ARGV[2])
|
|
463
|
+
-- Flag to determine if TTL should be reset after exceeding
|
|
464
|
+
local continueExceeding = ARGV[3] == 'true'
|
|
465
|
+
--Flag to determine if exponential backoff should be applied
|
|
466
|
+
local exponentialBackoff = ARGV[4] == 'true'
|
|
467
|
+
|
|
468
|
+
--Max safe integer
|
|
469
|
+
local MAX_SAFE_INTEGER = (2^53) - 1
|
|
470
|
+
|
|
471
|
+
-- Increment the key's value
|
|
472
|
+
local current = redis.call('INCR', key)
|
|
473
|
+
|
|
474
|
+
if current == 1 or (continueExceeding and current > max) then
|
|
475
|
+
redis.call('PEXPIRE', key, timeWindow)
|
|
476
|
+
elseif exponentialBackoff and current > max then
|
|
477
|
+
local backoffExponent = current - max - 1
|
|
478
|
+
timeWindow = math.min(timeWindow * (2 ^ backoffExponent), MAX_SAFE_INTEGER)
|
|
479
|
+
redis.call('PEXPIRE', key, timeWindow)
|
|
480
|
+
else
|
|
481
|
+
timeWindow = redis.call('PTTL', key)
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
return {current, timeWindow}
|
|
485
|
+
`})}KK.prototype.incr=function($,Z,J,Y){this.redis.rateLimit(this.key+$,J,Y,this.continueExceeding,this.exponentialBackoff,(X,Q)=>{X?Z(X,null):Z(null,{current:Q[0],ttl:Q[1]})})};KK.prototype.child=function($){return new KK($.continueExceeding,$.exponentialBackoff,this.redis,`${this.key}${$.routeInfo.method}${$.routeInfo.url}-`)};Du.exports=KK});var Eu=S((zh0,VK)=>{var yj0=ju(),{parse:Ru,format:xj0}=Nu(),hj0=Mu(),gj0=wu(),uj0={rateLimit:"x-ratelimit-limit",rateRemaining:"x-ratelimit-remaining",rateReset:"x-ratelimit-reset",retryAfter:"retry-after"},mj0={rateLimit:"ratelimit-limit",rateRemaining:"ratelimit-remaining",rateReset:"ratelimit-reset",retryAfter:"retry-after"},UA=()=>{},lj0=($)=>$.ip,dj0=($,Z)=>{let J=Error(`Rate limit exceeded, retry in ${Z.after}`);return J.statusCode=Z.statusCode,J};async function HA($,Z){let J={global:typeof Z.global==="boolean"?Z.global:!0};if(typeof Z.enableDraftSpec==="boolean"&&Z.enableDraftSpec)J.enableDraftSpec=!0,J.labels=mj0;else J.enableDraftSpec=!1,J.labels=uj0;if(J.addHeaders=Object.assign({[J.labels.rateLimit]:!0,[J.labels.rateRemaining]:!0,[J.labels.rateReset]:!0,[J.labels.retryAfter]:!0},Z.addHeaders),J.addHeadersOnExceeding=Object.assign({[J.labels.rateLimit]:!0,[J.labels.rateRemaining]:!0,[J.labels.rateReset]:!0},Z.addHeadersOnExceeding),Number.isFinite(Z.max)&&Z.max>=0)J.max=Math.trunc(Z.max);else if(typeof Z.max==="function")J.max=Z.max;else J.max=1000;if(Number.isFinite(Z.timeWindow)&&Z.timeWindow>=0)J.timeWindow=Math.trunc(Z.timeWindow);else if(typeof Z.timeWindow==="string")J.timeWindow=Ru(Z.timeWindow);else if(typeof Z.timeWindow==="function")J.timeWindow=Z.timeWindow;else J.timeWindow=60000;if(J.hook=Z.hook||"onRequest",J.allowList=Z.allowList||Z.whitelist||null,J.ban=Number.isFinite(Z.ban)&&Z.ban>=0?Math.trunc(Z.ban):-1,J.onBanReach=typeof Z.onBanReach==="function"?Z.onBanReach:UA,J.onExceeding=typeof Z.onExceeding==="function"?Z.onExceeding:UA,J.onExceeded=typeof Z.onExceeded==="function"?Z.onExceeded:UA,J.continueExceeding=typeof Z.continueExceeding==="boolean"?Z.continueExceeding:!1,J.exponentialBackoff=typeof Z.exponentialBackoff==="boolean"?Z.exponentialBackoff:!1,J.keyGenerator=typeof Z.keyGenerator==="function"?Z.keyGenerator:lj0,typeof Z.errorResponseBuilder==="function")J.errorResponseBuilder=Z.errorResponseBuilder,J.isCustomErrorMessage=!0;else J.errorResponseBuilder=dj0,J.isCustomErrorMessage=!1;J.skipOnError=typeof Z.skipOnError==="boolean"?Z.skipOnError:!1;let Y={rateLimitRan:Symbol("fastify.request.rateLimitRan"),store:null};if(Z.store){let X=Z.store;Y.store=new X(J)}else if(Z.redis)Y.store=new gj0(J.continueExceeding,J.exponentialBackoff,Z.redis,Z.nameSpace);else Y.store=new hj0(J.continueExceeding,J.exponentialBackoff,Z.cache);if($.decorateRequest(Y.rateLimitRan,!1),!$.hasDecorator("createRateLimit"))$.decorate("createRateLimit",(X)=>{let Q=Lu(Y,J,X);return(G)=>Cu.apply(this,Q.concat(G))});if(!$.hasDecorator("rateLimit"))$.decorate("rateLimit",(X)=>{let Q=Lu(Y,J,X);return Iu(...Q)});$.addHook("onRoute",(X)=>{if(X.config?.rateLimit!=null){if(typeof X.config.rateLimit==="object"){let Q=Object.create(Y),G=Pu(J,X.config.rateLimit,{routeInfo:X});Q.store=Y.store.child(G),Tu(Q,G,X)}else if(X.config.rateLimit!==!1)throw Error("Unknown value for route rate-limit configuration")}else if(J.global)Tu(Y,J,X)})}function Pu(...$){let Z=Object.assign({},...$);if(Number.isFinite(Z.timeWindow)&&Z.timeWindow>=0)Z.timeWindow=Math.trunc(Z.timeWindow);else if(typeof Z.timeWindow==="string")Z.timeWindow=Ru(Z.timeWindow);else if(typeof Z.timeWindow!=="function")Z.timeWindow=60000;if(Number.isFinite(Z.max)&&Z.max>=0)Z.max=Math.trunc(Z.max);else if(typeof Z.max!=="function")Z.max=1000;if(Number.isFinite(Z.ban)&&Z.ban>=0)Z.ban=Math.trunc(Z.ban);else Z.ban=-1;if(Z.groupId!==void 0&&typeof Z.groupId!=="string")throw Error("groupId must be a string");return Z}function Lu($,Z,J){if(typeof J==="object"){let Y=Object.create($),X=Pu(Z,J,{routeInfo:{}});return Y.store=Y.store.child(X),[Y,X]}return[$,Z]}function Tu($,Z,J){let Y=Z.hook,X=Iu($,Z);if(Array.isArray(J[Y]))J[Y].push(X);else if(typeof J[Y]==="function")J[Y]=[J[Y],X];else J[Y]=[X]}async function Cu($,Z,J){let{store:Y}=$,X=await Z.keyGenerator(J),Q=J.routeOptions.config?.rateLimit?.groupId;if(Q)X+=Q;if(Z.allowList){if(typeof Z.allowList==="function"){if(await Z.allowList(J,X))return{isAllowed:!0,key:X}}else if(Z.allowList.indexOf(X)!==-1)return{isAllowed:!0,key:X}}let G=typeof Z.max==="number"?Z.max:await Z.max(J,X),W=typeof Z.timeWindow==="number"?Z.timeWindow:await Z.timeWindow(J,X),K=0,V=0,U=0;try{let H=await new Promise((B,z)=>{Y.incr(X,(F,A)=>{F?z(F):B(A)},W,G)});K=H.current,V=H.ttl,U=Math.ceil(H.ttl/1000)}catch(H){if(!Z.skipOnError)throw H}return{isAllowed:!1,key:X,max:G,timeWindow:W,remaining:Math.max(0,G-K),ttl:V,ttlInSeconds:U,isExceeded:K>G,isBanned:Z.ban!==-1&&K-G>Z.ban}}function Iu($,Z){let{rateLimitRan:J}=$;return async(Y,X)=>{if(Y[J])return;Y[J]=!0;let Q=await Cu($,Z,Y);if(Q.isAllowed)return;let{key:G,max:W,remaining:K,ttl:V,ttlInSeconds:U,isExceeded:H,isBanned:B}=Q;if(!H){if(Z.addHeadersOnExceeding[Z.labels.rateLimit])X.header(Z.labels.rateLimit,W);if(Z.addHeadersOnExceeding[Z.labels.rateRemaining])X.header(Z.labels.rateRemaining,K);if(Z.addHeadersOnExceeding[Z.labels.rateReset])X.header(Z.labels.rateReset,U);Z.onExceeding(Y,G);return}if(Z.onExceeded(Y,G),Z.addHeaders[Z.labels.rateLimit])X.header(Z.labels.rateLimit,W);if(Z.addHeaders[Z.labels.rateRemaining])X.header(Z.labels.rateRemaining,0);if(Z.addHeaders[Z.labels.rateReset])X.header(Z.labels.rateReset,U);if(Z.addHeaders[Z.labels.retryAfter])X.header(Z.labels.retryAfter,U);let z={statusCode:429,ban:!1,max:W,ttl:V,after:xj0(U*1000,!0)};if(B)z.statusCode=403,z.ban=!0,Z.onBanReach(Y,G);throw Z.errorResponseBuilder(Y,z)}}VK.exports=yj0(HA,{fastify:"5.x",name:"@fastify/rate-limit"});VK.exports.default=HA;VK.exports.fastifyRateLimit=HA});var vm=S((km,NK)=>{(($,Z)=>{if(typeof define==="function"&&define.amd)define([],Z);else if(typeof NK==="object"&&NK.exports)NK.exports=Z();else $.fuzzysort=Z()})(km,($)=>{var Z=(m,l)=>{if(!m||!l)return G0;var t=z(m);if(!x(l))l=B(l);var h=t.bitflags;if((h&l._bitflags)!==h)return G0;return A(t,l)},J=(m,l,t)=>{if(!m)return t?.all?F(l,t):e;var h=z(m),y=h.bitflags,p=h.containsSpace,d=U(t?.threshold||0),a=t?.limit||g,s=0,H0=0,O0=l.length;function C0(v){if(s<a)u0.add(v),++s;else if(++H0,v._score>u0.peek()._score)u0.replaceTop(v)}if(t?.key){var p0=t.key;for(var r=0;r<O0;++r){var F0=l[r],W0=u(F0,p0);if(!W0)continue;if(!x(W0))W0=B(W0);if((y&W0._bitflags)!==y)continue;var j0=A(h,W0);if(j0===G0)continue;if(j0._score<d)continue;j0.obj=F0,C0(j0)}}else if(t?.keys){var X1=t.keys,E0=X1.length;$:for(var r=0;r<O0;++r){var F0=l[r];{var G1=0;for(var T0=0;T0<E0;++T0){var p0=X1[T0],W0=u(F0,p0);if(!W0){b[T0]=Q0;continue}if(!x(W0))W0=B(W0);b[T0]=W0,G1|=W0._bitflags}if((y&G1)!==y)continue}if(p)for(let n=0;n<h.spaceSearches.length;n++)E[n]=c;for(var T0=0;T0<E0;++T0){if(W0=b[T0],W0===Q0){k[T0]=Q0;continue}if(k[T0]=A(h,W0,!1,p),k[T0]===G0){k[T0]=Q0;continue}if(p)for(let Z0=0;Z0<h.spaceSearches.length;Z0++){if(f[Z0]>-1000){if(E[Z0]>c){var w1=(E[Z0]+f[Z0])/4;if(w1>E[Z0])E[Z0]=w1}}if(f[Z0]>E[Z0])E[Z0]=f[Z0]}}if(p){for(let n=0;n<h.spaceSearches.length;n++)if(E[n]===c)continue $}else{var o0=!1;for(let n=0;n<E0;n++)if(k[n]._score!==c){o0=!0;break}if(!o0)continue}var z1=new W(E0);for(let n=0;n<E0;n++)z1[n]=k[n];if(p){var t0=0;for(let n=0;n<h.spaceSearches.length;n++)t0+=E[n]}else{var t0=c;for(let Z0=0;Z0<E0;Z0++){var j0=z1[Z0];if(j0._score>-1000){if(t0>c){var w1=(t0+j0._score)/4;if(w1>t0)t0=w1}}if(j0._score>t0)t0=j0._score}}if(z1.obj=F0,z1._score=t0,t?.scoreFn){if(t0=t.scoreFn(z1),!t0)continue;t0=U(t0),z1._score=t0}if(t0<d)continue;C0(z1)}}else for(var r=0;r<O0;++r){var W0=l[r];if(!W0)continue;if(!x(W0))W0=B(W0);if((y&W0._bitflags)!==y)continue;var j0=A(h,W0);if(j0===G0)continue;if(j0._score<d)continue;C0(j0)}if(s===0)return e;var U1=Array(s);for(var r=s-1;r>=0;--r)U1[r]=u0.poll();return U1.total=s+H0,U1},Y=(m,l="<b>",t="</b>")=>{var h=typeof l==="function"?l:void 0,y=m.target,p=y.length,d=m.indexes,a="",s=0,H0=0,O0=!1,C0=[];for(var p0=0;p0<p;++p0){var r=y[p0];if(d[H0]===p0){if(++H0,!O0)if(O0=!0,h)C0.push(a),a="";else a+=l;if(H0===d.length){if(h)a+=r,C0.push(h(a,s++)),a="",C0.push(y.substr(p0+1));else a+=r+t+y.substr(p0+1);break}}else if(O0)if(O0=!1,h)C0.push(h(a,s++)),a="";else a+=t;a+=r}return h?C0:a},X=(m)=>{if(typeof m==="number")m=""+m;else if(typeof m!=="string")m="";var l=w(m);return K(m,{_targetLower:l._lower,_targetLowerCodes:l.lowerCodes,_bitflags:l.bitflags})},Q=()=>{I.clear(),R.clear()};class G{get["indexes"](){return this._indexes.slice(0,this._indexes.len).sort((m,l)=>m-l)}set["indexes"](m){return this._indexes=m}["highlight"](m,l){return Y(this,m,l)}get["score"](){return V(this._score)}set["score"](m){this._score=U(m)}}class W extends Array{get["score"](){return V(this._score)}set["score"](m){this._score=U(m)}}var K=(m,l)=>{let t=new G;return t.target=m,t.obj=l.obj??G0,t._score=l._score??c,t._indexes=l._indexes??[],t._targetLower=l._targetLower??"",t._targetLowerCodes=l._targetLowerCodes??G0,t._nextBeginningIndexes=l._nextBeginningIndexes??G0,t._bitflags=l._bitflags??0,t},V=(m)=>{if(m===c)return 0;if(m>1)return m;return Math.E**(((-m+1)**0.04307-1)*-2)},U=(m)=>{if(m===0)return c;if(m>1)return m;return 1-Math.pow(Math.log(m)/-2+1,23.218017181332716)},H=(m)=>{if(typeof m==="number")m=""+m;else if(typeof m!=="string")m="";m=m.trim();var l=w(m),t=[];if(l.containsSpace){var h=m.split(/\s+/);h=[...new Set(h)];for(var y=0;y<h.length;y++){if(h[y]==="")continue;var p=w(h[y]);t.push({lowerCodes:p.lowerCodes,_lower:h[y].toLowerCase(),containsSpace:!1})}}return{lowerCodes:l.lowerCodes,_lower:l._lower,containsSpace:l.containsSpace,bitflags:l.bitflags,spaceSearches:t}},B=(m)=>{if(m.length>999)return X(m);var l=I.get(m);if(l!==void 0)return l;return l=X(m),I.set(m,l),l},z=(m)=>{if(m.length>999)return H(m);var l=R.get(m);if(l!==void 0)return l;return l=H(m),R.set(m,l),l},F=(m,l)=>{var t=[];t.total=m.length;var h=l?.limit||g;if(l?.key)for(var y=0;y<m.length;y++){var p=m[y],d=u(p,l.key);if(d==G0)continue;if(!x(d))d=B(d);var a=K(d.target,{_score:d._score,obj:p});if(t.push(a),t.length>=h)return t}else if(l?.keys)for(var y=0;y<m.length;y++){var p=m[y],s=new W(l.keys.length);for(var H0=l.keys.length-1;H0>=0;--H0){var d=u(p,l.keys[H0]);if(!d){s[H0]=Q0;continue}if(!x(d))d=B(d);d._score=c,d._indexes.len=0,s[H0]=d}if(s.obj=p,s._score=c,t.push(s),t.length>=h)return t}else for(var y=0;y<m.length;y++){var d=m[y];if(d==G0)continue;if(!x(d))d=B(d);if(d._score=c,d._indexes.len=0,t.push(d),t.length>=h)return t}return t},A=(m,l,t=!1,h=!1)=>{if(t===!1&&m.containsSpace)return N(m,l,h);var{_lower:y,lowerCodes:p}=m,d=p[0],a=l._targetLowerCodes,s=p.length,H0=a.length,r=0,O0=0,C0=0;for(;;){var p0=d===a[O0];if(p0){if(L[C0++]=O0,++r,r===s)break;d=p[r]}if(++O0,O0>=H0)return G0}var r=0,F0=!1,W0=0,j0=l._nextBeginningIndexes;if(j0===G0)j0=l._nextBeginningIndexes=M(l.target);O0=L[0]===0?0:j0[L[0]-1];var X1=0;if(O0!==H0)for(;;)if(O0>=H0){if(r<=0)break;if(++X1,X1>200)break;--r;var E0=C[--W0];O0=j0[E0]}else{var p0=p[r]===a[O0];if(p0){if(C[W0++]=O0,++r,r===s){F0=!0;break}++O0}else O0=j0[O0]}var G1=s<=1?-1:l._targetLower.indexOf(y,L[0]),T0=!!~G1,w1=!T0?!1:G1===0||l._nextBeginningIndexes[G1-1]===G1;if(T0&&!w1)for(var o0=0;o0<j0.length;o0=j0[o0]){if(o0<=G1)continue;for(var z1=0;z1<s;z1++)if(p[z1]!==l._targetLowerCodes[o0+z1])break;if(z1===s){G1=o0,w1=!0;break}}var t0=(n)=>{var Z0=0,b0=0;for(var M0=1;M0<s;++M0)if(n[M0]-n[M0-1]!==1)Z0-=n[M0],++b0;var D1=n[s-1]-n[0]-(s-1);if(Z0-=(12+D1)*b0,n[0]!==0)Z0-=n[0]*n[0]*0.2;if(!F0)Z0*=1000;else{var h0=1;for(var M0=j0[0];M0<H0;M0=j0[M0])++h0;if(h0>24)Z0*=(h0-24)*10}if(Z0-=(H0-s)/2,T0)Z0/=1+s*s*1;if(w1)Z0/=1+s*s*1;return Z0-=(H0-s)/2,Z0};if(!F0){if(T0)for(var o0=0;o0<s;++o0)L[o0]=G1+o0;var U1=L,v=t0(U1)}else if(w1){for(var o0=0;o0<s;++o0)L[o0]=G1+o0;var U1=L,v=t0(L)}else var U1=C,v=t0(C);l._score=v;for(var o0=0;o0<s;++o0)l._indexes[o0]=U1[o0];l._indexes.len=s;let i=new G;return i.target=l.target,i._score=l._score,i._indexes=l._indexes,i},N=(m,l,t)=>{var h=new Set,y=0,p=G0,d=0,a=m.spaceSearches,s=a.length,H0=0,O0=()=>{for(let w1=H0-1;w1>=0;w1--)l._nextBeginningIndexes[_[w1*2+0]]=_[w1*2+1]},C0=!1;for(var T0=0;T0<s;++T0){f[T0]=c;var p0=a[T0];if(p=A(p0,l),t){if(p===G0)continue;C0=!0}else if(p===G0)return O0(),G0;var r=T0===s-1;if(!r){var F0=p._indexes,W0=!0;for(let o0=0;o0<F0.len-1;o0++)if(F0[o0+1]-F0[o0]!==1){W0=!1;break}if(W0){var j0=F0[F0.len-1]+1,X1=l._nextBeginningIndexes[j0-1];for(let o0=j0-1;o0>=0;o0--){if(X1!==l._nextBeginningIndexes[o0])break;l._nextBeginningIndexes[o0]=j0,_[H0*2+0]=o0,_[H0*2+1]=X1,H0++}}}if(y+=p._score/s,f[T0]=p._score/s,p._indexes[0]<d)y-=(d-p._indexes[0])*2;d=p._indexes[0];for(var E0=0;E0<p._indexes.len;++E0)h.add(p._indexes[E0])}if(t&&!C0)return G0;O0();var G1=A(m,l,!0);if(G1!==G0&&G1._score>y){if(t)for(var T0=0;T0<s;++T0)f[T0]=G1._score/s;return G1}if(t)p=l;p._score=y;var T0=0;for(let w1 of h)p._indexes[T0++]=w1;return p._indexes.len=T0,p},q=(m)=>m.replace(/\p{Script=Latin}+/gu,(l)=>l.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),w=(m)=>{m=q(m);var l=m.length,t=m.toLowerCase(),h=[],y=0,p=!1;for(var d=0;d<l;++d){var a=h[d]=t.charCodeAt(d);if(a===32){p=!0;continue}var s=a>=97&&a<=122?a-97:a>=48&&a<=57?26:a<=127?30:31;y|=1<<s}return{lowerCodes:h,bitflags:y,containsSpace:p,_lower:t}},j=(m)=>{var l=m.length,t=[],h=0,y=!1,p=!1;for(var d=0;d<l;++d){var a=m.charCodeAt(d),s=a>=65&&a<=90,H0=s||a>=97&&a<=122||a>=48&&a<=57,O0=s&&!y||!p||!H0;if(y=s,p=H0,O0)t[h++]=d}return t},M=(m)=>{m=q(m);var l=m.length,t=j(m),h=[],y=t[0],p=0;for(var d=0;d<l;++d)if(y>d)h[d]=y;else y=t[++p],h[d]=y===void 0?l:y;return h},I=new Map,R=new Map,L=[],C=[],_=[],E=[],f=[],b=[],k=[],u=(m,l)=>{var t=m[l];if(t!==void 0)return t;if(typeof l==="function")return l(m);var h=l;if(!Array.isArray(l))h=l.split(".");var y=h.length,p=-1;while(m&&++p<y)m=m[h[p]];return m},x=(m)=>{return typeof m==="object"&&typeof m._bitflags==="number"},g=1/0,c=-g,e=[];e.total=0;var G0=null,Q0=X(""),z0=(m)=>{var l=[],t=0,h={},y=(p)=>{for(var d=0,a=l[d],s=1;s<t;){var H0=s+1;d=s,H0<t&&l[H0]._score<l[s]._score&&(d=H0),l[d-1>>1]=l[d],s=1+(d<<1)}for(var O0=d-1>>1;d>0&&a._score<l[O0]._score;O0=(d=O0)-1>>1)l[d]=l[O0];l[d]=a};return h.add=(p)=>{var d=t;l[t++]=p;for(var a=d-1>>1;d>0&&p._score<l[a]._score;a=(d=a)-1>>1)l[d]=l[a];l[d]=p},h.poll=(p)=>{if(t!==0){var d=l[0];return l[0]=l[--t],y(),d}},h.peek=(p)=>{if(t!==0)return l[0]},h.replaceTop=(p)=>{l[0]=p,y()},h},u0=z0();return{single:Z,go:J,prepare:X,cleanup:Q}})});var YQ={};F1(YQ,{toRow:()=>vM0,plan:()=>nM0,listGlobal:()=>rM0,list:()=>sM0,layer:()=>Cd,isDefaultTitle:()=>kM0,getUsage:()=>oM0,fromRow:()=>OY,defaultLayer:()=>ZD0,SetTitleInput:()=>lM0,SetRevertInput:()=>cM0,SetPermissionInput:()=>pM0,SetArchivedInput:()=>dM0,Service:()=>nK,RemoveInput:()=>mM0,ProjectInfo:()=>Td,MessagesInput:()=>iM0,Info:()=>z6,GlobalInfo:()=>yM0,GetInput:()=>gM0,ForkInput:()=>hM0,Event:()=>jY,CreateInput:()=>xM0,ChildrenInput:()=>uM0,BusyError:()=>Pd});var JV;((YD0)=>{let $=["brave","calm","clever","cosmic","crisp","curious","eager","gentle","glowing","happy","hidden","jolly","kind","lucky","mighty","misty","neon","nimble","playful","proud","quick","quiet","shiny","silent","stellar","sunny","swift","tidy","witty"],Z=["cabin","cactus","canyon","circuit","comet","eagle","engine","falcon","forest","garden","harbor","island","knight","lagoon","meadow","moon","mountain","nebula","orchid","otter","panda","pixel","planet","river","rocket","sailor","squid","star","tiger","wizard","wolf"];function J(){return[$[Math.floor(Math.random()*$.length)],Z[Math.floor(Math.random()*Z.length)]].join("-")}YD0.create=J})(JV||={});var d1={};F1(d1,{subscribeAll:()=>gd,subscribe:()=>hd,publish:()=>xd,layer:()=>YV,defaultLayer:()=>vd,Service:()=>CY,InstanceDisposed:()=>HO,Bus:()=>d1});var qZ=_0.create({service:"bus"}),HO=T1.define("server.instance.disposed",P.object({directory:P.string()}));class CY extends S1.Service()("@qitqode/Bus"){}var YV=R0.effect(CY,T.gen(function*(){let $=yield*B0.make(T.fn("Bus.state")(function*(K){let V=yield*h6.unbounded(),U=new Map;return yield*T.addFinalizer(()=>T.gen(function*(){yield*h6.publish(V,{type:HO.type,properties:{directory:K.directory}}),yield*h6.shutdown(V);for(let H of U.values())yield*h6.shutdown(H)})),{wildcard:V,typed:U}}));function Z(K,V){return T.gen(function*(){let U=K.typed.get(V.type);if(!U)U=yield*h6.unbounded(),K.typed.set(V.type,U);return U})}function J(K,V){return T.gen(function*(){let U=yield*B0.get($),H={type:K.type,properties:V};qZ.debug("publishing",{type:K.type});let B=U.typed.get(K.type);if(B)yield*h6.publish(B,H);yield*h6.publish(U.wildcard,H);let z=yield*B0.directory,F=yield*B0.context,A=yield*B0.workspaceID;L7.emit("event",{directory:z,project:F.project.id,workspace:A,payload:H})})}function Y(K){return qZ.info("subscribing",{type:K.type}),I$.unwrap(T.gen(function*(){let V=yield*B0.get($),U=yield*Z(V,K);return I$.fromPubSub(U)})).pipe(I$.ensuring(T.sync(()=>qZ.info("unsubscribing",{type:K.type}))))}function X(){return qZ.info("subscribing",{type:"*"}),I$.unwrap(T.gen(function*(){let K=yield*B0.get($);return I$.fromPubSub(K.wildcard)})).pipe(I$.ensuring(T.sync(()=>qZ.info("unsubscribing",{type:"*"}))))}function Q(K,V,U){return T.gen(function*(){qZ.info("subscribing",{type:V});let H=yield*T7.make(),B=yield*PY.make(),z=yield*PY.provide(B)(h6.subscribe(K));return yield*PY.provide(B)(I$.fromSubscription(z).pipe(I$.runForEach((F)=>T.tryPromise({try:()=>Promise.resolve().then(()=>U(F)),catch:(A)=>{qZ.error("subscriber failed",{type:V,cause:A})}}).pipe(T.ignore)),T.forkScoped)),()=>{qZ.info("unsubscribing",{type:V}),H.fork(PY.close(B,BQ.void))}})}let G=T.fn("Bus.subscribeCallback")(function*(K,V){let U=yield*B0.get($),H=yield*Z(U,K);return yield*Q(H,K.type,V)}),W=T.fn("Bus.subscribeAllCallback")(function*(K){let V=yield*B0.get($);return yield*Q(V.wildcard,"*",K)});return CY.of({publish:J,subscribe:Y,subscribeAll:X,subscribeCallback:G,subscribeAllCallback:W})})),vd=YV,{runPromise:yd,runSync:BO}=UO(CY,YV);async function xd($,Z){return yd((J)=>J.publish($,Z))}function hd($,Z){return BO((J)=>J.subscribeCallback($,Z))}function gd($){return BO((Z)=>Z.subscribeAllCallback($))}var Q$={};F1(Q$,{versionedType:()=>IY,run:()=>$p,reset:()=>sd,replayAll:()=>ed,replay:()=>NO,remove:()=>Zp,registry:()=>EY,project:()=>td,payloads:()=>Jp,init:()=>rd,define:()=>ad,SyncEvent:()=>Q$});var _8=g6("event_sequence",{aggregate_id:L1().notNull().primaryKey(),seq:N8().notNull()}),zQ=g6("event",{id:L1().primaryKey(),aggregate_id:L1().notNull().references(()=>_8.aggregate_id,{onDelete:"cascade"}),seq:N8().notNull(),type:L1().notNull(),data:L1({mode:"json"}).$type().notNull()});var p1={};F1(p1,{timestamp:()=>od,schema:()=>dd,descending:()=>nd,create:()=>FO,ascending:()=>id,Identifier:()=>p1});import{randomBytes as ud}from"crypto";var md="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function XV($){let Z="",J=ud($);for(let Y=0;Y<$;Y++)Z+=md[J[Y]%62];return Z}function QV(){let $=0,Z=0;return(J)=>{if(J!==void 0)return BigInt(J)*BigInt(4096);let Y=Date.now();if(Y>$)$=Y,Z=0;if(Z++,Z>4095)$++,Z=1;return BigInt($)*BigInt(4096)+BigInt(Z)}}function GV($){let Z=Buffer.alloc(6);for(let J=0;J<6;J++)Z[J]=Number($>>BigInt(40-8*J)&BigInt(255));return Z.toString("hex")}var ld;((OD0)=>{let Z=QV();function J(){return X(!1)}OD0.ascending=J;function Y(){return X(!0)}OD0.descending=Y;function X(Q,G){let W=Z(G);return W=Q?~W:W,GV(W)+XV(14)}OD0.create=X})(ld||={});var FQ={event:"evt",session:"ses",message:"msg",permission:"per",question:"que",user:"usr",part:"prt",pty:"pty",tool:"tool",workspace:"wrk",entry:"ent",workflow:"wf"};function dd($){return P.string().startsWith(FQ[$])}var pd=26,cd=QV();function id($,Z){return zO($,"ascending",Z)}function nd($,Z){return zO($,"descending",Z)}function zO($,Z,J){if(!J)return FO(FQ[$],Z);if(!J.startsWith(FQ[$]))throw Error(`ID ${J} does not start with ${FQ[$]}`);return J}function FO($,Z,J){let Y=cd(J);return Y=Z==="descending"?~Y:Y,$+"_"+GV(Y)+XV(pd-12)}function od($){let Z=$.split("_")[0],J=$.slice(Z.length+1,Z.length+13),Y=BigInt("0x"+J);return Number(Y/BigInt(4096))}var AO=O.String.annotate({[A$]:p1.schema("event")}).pipe(O.brand("EventID"),g0(($)=>({ascending:(Z)=>$.make(p1.ascending("event",Z)),zod:p1.schema("event").pipe(P.custom())})));var EY=new Map,AQ,OQ=new Map,WV=!1,KV;function sd(){WV=!1,AQ=void 0,KV=($,Z)=>Z}function rd($){AQ=new Map($.projectors);for(let[Z,J]of OQ.entries()){let Y=EY.get(IY(Z,J));T1.define(Y.type,Y.properties||Y.schema)}WV=!0,KV=$.convertEvent||((Z,J)=>J)}function IY($,Z){return Z?`${$}.${Z}`:$}function ad($){if(WV)throw Error("Error defining sync event: sync system has been frozen");let Z={type:$.type,version:$.version,aggregate:$.aggregate,schema:$.schema,properties:$.busSchema?$.busSchema:$.schema};return OQ.set(Z.type,Math.max(Z.version,OQ.get(Z.type)||0)),EY.set(IY(Z.type,Z.version),Z),Z}function td($,Z){return[$,Z]}function jO($,Z,J){if(AQ==null)throw Error("No projectors available. Call `SyncEvent.init` to install projectors");let Y=AQ.get($);if(!Y)throw Error(`Projector not found for event: ${$.type}`);W1.transaction((X)=>{if(Y(X,Z.data),S0.QITQODE_EXPERIMENTAL_WORKSPACES)X.insert(_8).values({aggregate_id:Z.aggregateID,seq:Z.seq}).onConflictDoUpdate({target:_8.aggregate_id,set:{seq:Z.seq}}).run(),X.insert(zQ).values({id:Z.id,seq:Z.seq,aggregate_id:Z.aggregateID,type:IY($.type,$.version),data:Z.data}).run();W1.effect(()=>{if(J?.publish){let Q=KV($.type,Z.data);if(Q instanceof Promise)Q.then((G)=>{d1.publish({type:$.type,properties:$.schema},G)});else d1.publish({type:$.type,properties:$.schema},Q);L7.emit("event",{directory:S8.directory,project:S8.project.id,workspace:OO.workspaceID,payload:{type:"sync",syncEvent:{type:IY($.type,$.version),...Z}}})}})})}function NO($,Z){let J=EY.get($.type);if(!J)throw Error(`Unknown event type: ${$.type}`);let X=W1.use((G)=>G.select({seq:_8.seq}).from(_8).where(m0(_8.aggregate_id,$.aggregateID)).get())?.seq??-1;if($.seq<=X)return;let Q=X+1;if($.seq!==Q)throw Error(`Sequence mismatch for aggregate "${$.aggregateID}": expected ${Q}, got ${$.seq}`);jO(J,$,{publish:!!Z?.publish})}function ed($,Z){let J=$[0]?.aggregateID;if(!J)return;if($.some((X)=>X.aggregateID!==J))throw Error("Replay events must belong to the same session");let Y=$[0].seq;for(let[X,Q]of $.entries()){let G=Y+X;if(Q.seq!==G)throw Error(`Replay sequence mismatch at index ${X}: expected ${G}, got ${Q.seq}`)}for(let X of $)NO(X,Z);return J}function $p($,Z,J){let Y=Z[$.aggregate];if(Y==null)throw Error(`SyncEvent.run: "${$.aggregate}" required but not found: ${JSON.stringify(Z)}`);if($.version!==OQ.get($.type))throw Error(`SyncEvent.run: running old versions of events is not allowed: ${$.type}`);let{publish:X=!0}=J||{};W1.transaction((Q)=>{let G=AO.ascending(),W=Q.select({seq:_8.seq}).from(_8).where(m0(_8.aggregate_id,Y)).get(),K=W?.seq!=null?W.seq+1:0;jO($,{id:G,seq:K,aggregateID:Y,data:Z},{publish:X})},{behavior:"immediate"})}function Zp($){W1.transaction((Z)=>{Z.delete(_8).where(m0(_8.aggregate_id,$)).run(),Z.delete(zQ).where(m0(zQ.aggregate_id,$)).run()})}function Jp(){return EY.entries().map(([$,Z])=>{return P.object({type:P.literal("sync"),name:P.literal($),id:P.string(),seq:P.number(),aggregateID:P.literal(Z.aggregate),data:Z.schema}).meta({ref:`SyncEvent.${Z.type}`})}).toArray()}var _$={};F1(_$,{toModelMessagesEffect:()=>V2,toModelMessages:()=>$00,stream:()=>pU,parts:()=>CL,page:()=>PL,isMedia:()=>qX,get:()=>Sa,fromError:()=>hA,fingerprint:()=>OH,filterCompactedEffect:()=>fa,filterCompacted:()=>cU,cursor:()=>dU,WithParts:()=>Ia,User:()=>DL,ToolStateRunning:()=>FL,ToolStatePending:()=>zL,ToolStateError:()=>OL,ToolStateCompleted:()=>AL,ToolState:()=>jL,ToolPart:()=>NL,TextPart:()=>ew,SymbolSource:()=>JL,SubtaskPart:()=>WL,StructuredOutputError:()=>pw,StepStartPart:()=>UL,StepFinishPart:()=>BL,SnapshotPart:()=>aw,SYNTHETIC_ATTACHMENT_PROMPT:()=>K2,RetryPart:()=>VL,ResourceSource:()=>YL,ReasoningPart:()=>$L,Provenance:()=>ML,PatchPart:()=>tw,Part:()=>mU,OutputLengthError:()=>U4,OutputFormatText:()=>ow,OutputFormatJsonSchema:()=>sw,ModelError:()=>nw,MessageV2:()=>_$,InvalidOutputError:()=>cw,Info:()=>lU,Format:()=>rw,FileSource:()=>ZL,FilePartSource:()=>XL,FilePart:()=>uU,Event:()=>Ca,ErrorDiagnostic:()=>dw,ContextOverflowError:()=>GX,ContentFilterError:()=>iw,CompactionPart:()=>KL,CheckpointPart:()=>GL,AuthError:()=>H4,Assistant:()=>wL,AgentPart:()=>QL,AbortedError:()=>f5,APIError:()=>L6});var a0=O.String.annotate({[A$]:p1.schema("session")}).pipe(O.brand("SessionID"),g0(($)=>({descending:(Z)=>$.make(p1.descending("session",Z)),zod:p1.schema("session").pipe(P.custom())}))),o1=O.String.annotate({[A$]:p1.schema("message")}).pipe(O.brand("MessageID"),g0(($)=>({ascending:(Z)=>$.make(p1.ascending("message",Z)),zod:p1.schema("message").pipe(P.custom())}))),MZ=O.String.annotate({[A$]:p1.schema("part")}).pipe(O.brand("PartID"),g0(($)=>({ascending:(Z)=>$.make(p1.ascending("part",Z)),zod:p1.schema("part").pipe(P.custom())})));var X4={};F1(X4,{layer:()=>Iw,defaultLayer:()=>Aa,Symbol:()=>Ua,Status:()=>Ba,Service:()=>Y4,Range:()=>J4,Event:()=>Cw,DocumentSymbol:()=>Ha,Diagnostic:()=>XX});var S7=m6(VN(),1);import yY from"path";import{pathToFileURL as A5,fileURLToPath as pc}from"url";var UN={".abap":"abap",".bat":"bat",".bib":"bibtex",".bibtex":"bibtex",".clj":"clojure",".cljs":"clojure",".cljc":"clojure",".edn":"clojure",".coffee":"coffeescript",".c":"c",".cpp":"cpp",".cxx":"cpp",".cc":"cpp",".c++":"cpp",".cs":"csharp",".css":"css",".d":"d",".pas":"pascal",".pascal":"pascal",".diff":"diff",".patch":"diff",".dart":"dart",".dockerfile":"dockerfile",".ex":"elixir",".exs":"elixir",".erl":"erlang",".ets":"typescript",".hrl":"erlang",".fs":"fsharp",".fsi":"fsharp",".fsx":"fsharp",".fsscript":"fsharp",".gitcommit":"git-commit",".gitrebase":"git-rebase",".go":"go",".groovy":"groovy",".gleam":"gleam",".hbs":"handlebars",".handlebars":"handlebars",".hs":"haskell",".lhs":"haskell",".html":"html",".htm":"html",".ini":"ini",".java":"java",".jl":"julia",".js":"javascript",".kt":"kotlin",".kts":"kotlin",".jsx":"javascriptreact",".json":"json",".tex":"latex",".latex":"latex",".less":"less",".lua":"lua",".makefile":"makefile",makefile:"makefile",".md":"markdown",".markdown":"markdown",".m":"objective-c",".mm":"objective-cpp",".pl":"perl",".pm":"perl",".pm6":"perl6",".php":"php",".ps1":"powershell",".psm1":"powershell",".pug":"jade",".jade":"jade",".py":"python",".r":"r",".cshtml":"razor",".razor":"razor",".rb":"ruby",".rake":"ruby",".gemspec":"ruby",".ru":"ruby",".erb":"erb",".html.erb":"erb",".js.erb":"erb",".css.erb":"erb",".json.erb":"erb",".rs":"rust",".scss":"scss",".sass":"sass",".scala":"scala",".shader":"shaderlab",".sh":"shellscript",".bash":"shellscript",".zsh":"shellscript",".ksh":"shellscript",".sql":"sql",".svelte":"svelte",".swift":"swift",".ts":"typescript",".tsx":"typescriptreact",".mts":"typescript",".cts":"typescript",".mtsx":"typescriptreact",".ctsx":"typescriptreact",".xml":"xml",".xsl":"xsl",".yaml":"yaml",".yml":"yaml",".mjs":"javascript",".cjs":"javascript",".vue":"vue",".zig":"zig",".zon":"zig",".astro":"astro",".ml":"ocaml",".mli":"ocaml",".tf":"terraform",".tfvars":"terraform-vars",".hcl":"hcl",".nix":"nix",".typ":"typst",".typc":"typst"};function xV($,Z){let J;return Promise.race([$,new Promise((X,Q)=>{J=setTimeout(()=>{Q(Error(`Operation timed out after ${Z}ms`))},Z)})]).finally(()=>clearTimeout(J))}var cc=150,O5=_0.create({service:"lsp.client"}),ic=N1.create("LSPInitializeError",P.object({serverID:P.string()})),HN={Diagnostics:T1.define("lsp.client.diagnostics",P.object({serverID:P.string(),path:P.string()}))};async function BN($){let Z=O5.clone().tag("serverID",$.serverID);Z.info("starting client");let J=S7.createMessageConnection(new S7.StreamMessageReader($.server.process.stdout),new S7.StreamMessageWriter($.server.process.stdin)),Y=new Map;if(J.onNotification("textDocument/publishDiagnostics",(G)=>{let W=s0.normalizePath(pc(G.uri));Z.info("textDocument/publishDiagnostics",{path:W,count:G.diagnostics.length});let K=Y.has(W);if(Y.set(W,G.diagnostics),!K&&$.serverID==="typescript")return;d1.publish(HN.Diagnostics,{path:W,serverID:$.serverID})}),J.onRequest("window/workDoneProgress/create",(G)=>{return Z.info("window/workDoneProgress/create",G),null}),J.onRequest("workspace/configuration",async()=>{return[$.server.initialization??{}]}),J.onRequest("client/registerCapability",async()=>{}),J.onRequest("client/unregisterCapability",async()=>{}),J.onRequest("workspace/workspaceFolders",async()=>[{name:"workspace",uri:A5($.root).href}]),J.listen(),Z.info("sending initialize"),await xV(J.sendRequest("initialize",{rootUri:A5($.root).href,processId:$.server.process.pid,workspaceFolders:[{name:"workspace",uri:A5($.root).href}],initializationOptions:{...$.server.initialization},capabilities:{window:{workDoneProgress:!0},workspace:{configuration:!0,didChangeWatchedFiles:{dynamicRegistration:!0}},textDocument:{synchronization:{didOpen:!0,didChange:!0},publishDiagnostics:{versionSupport:!0}}}}),45000).catch((G)=>{throw Z.error("initialize error",{error:G}),new ic({serverID:$.serverID},{cause:G})}),await J.sendNotification("initialized",{}),$.server.initialization)await J.sendNotification("workspace/didChangeConfiguration",{settings:$.server.initialization});let X={},Q={root:$.root,get serverID(){return $.serverID},get connection(){return J},notify:{async open(G){G.path=yY.isAbsolute(G.path)?G.path:yY.resolve($.directory,G.path);let W=await s0.readText(G.path),K=yY.extname(G.path),V=UN[K]??"plaintext",U=X[G.path];if(U!==void 0){O5.info("workspace/didChangeWatchedFiles",G),await J.sendNotification("workspace/didChangeWatchedFiles",{changes:[{uri:A5(G.path).href,type:2}]});let H=U+1;X[G.path]=H,O5.info("textDocument/didChange",{path:G.path,version:H}),await J.sendNotification("textDocument/didChange",{textDocument:{uri:A5(G.path).href,version:H},contentChanges:[{text:W}]});return}O5.info("workspace/didChangeWatchedFiles",G),await J.sendNotification("workspace/didChangeWatchedFiles",{changes:[{uri:A5(G.path).href,type:1}]}),O5.info("textDocument/didOpen",G),Y.delete(G.path),await J.sendNotification("textDocument/didOpen",{textDocument:{uri:A5(G.path).href,languageId:V,version:0,text:W}}),X[G.path]=0;return}},get diagnostics(){return Y},async waitForDiagnostics(G){let W=s0.normalizePath(yY.isAbsolute(G.path)?G.path:yY.resolve($.directory,G.path));O5.info("waiting for diagnostics",{path:W});let K,V;return await xV(new Promise((U)=>{K=d1.subscribe(HN.Diagnostics,(H)=>{if(H.properties.path===W&&H.properties.serverID===Q.serverID){if(V)clearTimeout(V);V=setTimeout(()=>{O5.info("got diagnostics",{path:W}),K?.(),U()},cc)}})}),3000).catch(()=>{}).finally(()=>{if(V)clearTimeout(V);K?.()})},async shutdown(){Z.info("shutting down"),J.end(),J.dispose(),await f1.stop($.server.process),Z.info("shutdown")}};return Z.info("initialized"),Q}import Rw from"path";import{pathToFileURL as Pw,fileURLToPath as Va}from"url";var f7={};F1(f7,{Zls:()=>hN,YamlLS:()=>LN,Vue:()=>jN,Typescript:()=>ON,Ty:()=>uN,Tinymist:()=>nN,TexLab:()=>sN,TerraformLS:()=>oN,Svelte:()=>DN,SourceKit:()=>bN,RustAnalyzer:()=>_N,Rubocop:()=>gN,Pyright:()=>mN,Prisma:()=>RN,PHPIntelephense:()=>dN,Oxlint:()=>qN,Ocaml:()=>yN,Nixd:()=>iN,LuaLS:()=>TN,KotlinLS:()=>kN,JuliaLS:()=>pN,JDTLS:()=>fN,HLS:()=>cN,Gopls:()=>CN,Gleam:()=>xN,FSharp:()=>EN,ElixirLS:()=>lN,ESLint:()=>NN,DockerfileLS:()=>rN,Deno:()=>AN,Dart:()=>vN,Clojure:()=>aN,Clangd:()=>SN,CSharp:()=>IN,Biome:()=>MN,BashLS:()=>PN,Astro:()=>wN});function Z1($,Z,J){let Y=Array.isArray(Z)?[...Z]:[],X=Array.isArray(Z)?J:Z,Q=f1.spawn([$,...Y],{...X,stdin:"pipe",stdout:"pipe",stderr:"pipe"});if(!Q.stdin||!Q.stdout||!Q.stderr)throw Error("Process output not available");return Q}import nc from"fs/promises";import hV from"path";var X0=_0.create({service:"lsp.server"}),gV=async($)=>nc.stat($).then(()=>!0).catch(()=>!1),N6=($,Z={})=>f1.run($,{...Z,nothrow:!0}),FN=($,Z={})=>f1.text($,{...Z,nothrow:!0});async function q6($,Z){if($)return $;if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;return j6.which(Z)}var M6=($,Z,J)=>Z1($,Z,{cwd:J,env:{...n8()}}),e0=($,Z)=>{return async(J,Y)=>{if(Z){let G=s0.up({targets:Z,start:hV.dirname(J),stop:Y.directory}),W=await G.next();if(await G.return(),W.value)return}let X=s0.up({targets:$,start:hV.dirname(J),stop:Y.directory}),Q=await X.next();if(await X.return(),!Q.value)return Y.directory;return hV.dirname(Q.value)}};import{createRequire as oc}from"module";import sc from"path";var wZ;((fL0)=>{function $(Z,J){try{return oc(sc.join(J,"package.json")).resolve(Z)}catch{}}fL0.resolve=$})(wZ||={});import rc from"path";async function LZ($,Z,J){let Y=await fetch($);if(!Y.ok){X0.error(`Failed to download ${J}`);return}let X=rc.join(A0.Path.bin,Z);if(Y.body)await s0.writeStream(X,Y.body);return X}async function TZ($,Z){return D8.extractZip($,A0.Path.bin).then(()=>!0).catch((J)=>{return X0.error(`Failed to extract ${Z} archive`,{error:J}),!1})}import D6 from"fs/promises";import{text as ac}from"stream/consumers";import w8 from"path";var AN={id:"deno",root:async($,Z)=>{let J=s0.up({targets:["deno.json","deno.jsonc"],start:w8.dirname($),stop:Z.directory}),Y=await J.next();if(await J.return(),!Y.value)return;return w8.dirname(Y.value)},extensions:[".ts",".tsx",".js",".jsx",".mjs"],async spawn($){let Z=d0("deno");if(!Z){X0.info("deno not found, please install deno first");return}return{process:Z1(Z,["lsp"],{cwd:$})}}},ON={id:"typescript",root:e0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"],["deno.json","deno.jsonc"]),extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts"],async spawn($,Z){let J=wZ.resolve("typescript/lib/tsserver.js",Z.directory);if(X0.info("typescript server",{tsserver:J}),!J)return;let Y=await j6.which("typescript-language-server");if(!Y)return;return{process:Z1(Y,["--stdio"],{cwd:$,env:{...n8()}}),initialization:{tsserver:{path:J}}}}},jN={id:"vue",extensions:[".vue"],root:e0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),async spawn($){let Z=await q6(d0("vue-language-server"),"@vue/language-server");if(!Z)return;return{process:M6(Z,["--stdio"],$),initialization:{}}}},NN={id:"eslint",root:e0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".vue"],async spawn($,Z){if(!wZ.resolve("eslint",Z.directory))return;X0.info("spawning eslint server");let Y=w8.join(A0.Path.bin,"vscode-eslint","server","out","eslintServer.js");if(!await s0.exists(Y)){if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("downloading and building VS Code ESLint server");let Q=await LZ("https://github.com/microsoft/vscode-eslint/archive/refs/heads/main.zip","vscode-eslint.zip","vscode-eslint");if(!Q)return;if(!await TZ(Q,"vscode-eslint"))return;await D6.rm(Q,{force:!0});let W=w8.join(A0.Path.bin,"vscode-eslint-main"),K=w8.join(A0.Path.bin,"vscode-eslint");if(await D6.stat(K).catch(()=>{return}))X0.info("removing old eslint installation",{path:K}),await D6.rm(K,{force:!0,recursive:!0});await D6.rename(W,K);let U=process.platform==="win32"?"npm.cmd":"npm";await f1.run([U,"install"],{cwd:K}),await f1.run([U,"run","compile"],{cwd:K}),X0.info("installed VS Code ESLint server",{serverPath:Y})}return{process:Z1("node",[Y,"--stdio"],{cwd:$,env:{...n8()}})}}},qN={id:"oxlint",root:e0([".oxlintrc.json","package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock","package.json"]),extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".vue",".astro",".svelte"],async spawn($,Z){let J=process.platform==="win32"?".cmd":"",Y=w8.join("node_modules",".bin","oxc_language_server"+J),X=w8.join("node_modules",".bin","oxlint"+J),Q=async(K)=>{let V=w8.join($,K);if(await s0.exists(V))return V;let U=s0.up({targets:[K],start:$,stop:Z.worktree}),H=await U.next();if(await U.return(),H.value)return H.value;return},G=await Q(X);if(!G){let K=d0("oxlint");if(K)G=K}if(G){let K=Z1(G,["--help"]);if(await K.exited,K.stdout){if((await ac(K.stdout)).includes("--lsp"))return{process:Z1(G,["--lsp"],{cwd:$})}}}let W=await Q(Y);if(!W){let K=d0("oxc_language_server");if(K)W=K}if(W)return{process:Z1(W,[],{cwd:$})};X0.info("oxlint not found, please install oxlint");return}},MN={id:"biome",root:e0(["biome.json","biome.jsonc","package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".json",".jsonc",".vue",".astro",".svelte",".css",".graphql",".gql",".html"],async spawn($){let Z=w8.join($,"node_modules",".bin","biome"),J;if(await s0.exists(Z))J=Z;if(!J){let Q=d0("biome");if(Q)J=Q}let Y=["lsp-proxy","--stdio"];if(!J){if(!wZ.resolve("biome",$))return;if(J=await j6.which("biome"),!J)return;Y=["lsp-proxy","--stdio"]}return{process:Z1(J,Y,{cwd:$,env:{...n8()}})}}},DN={id:"svelte",extensions:[".svelte"],root:e0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),async spawn($){let Z=await q6(d0("svelteserver"),"svelte-language-server");if(!Z)return;return{process:M6(Z,["--stdio"],$),initialization:{}}}},wN={id:"astro",extensions:[".astro"],root:e0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),async spawn($,Z){let J=wZ.resolve("typescript/lib/tsserver.js",Z.directory);if(!J){X0.info("typescript not found, required for Astro language server");return}let Y=w8.dirname(J),X=await q6(d0("astro-ls"),"@astrojs/language-server");if(!X)return;return{process:M6(X,["--stdio"],$),initialization:{typescript:{tsdk:Y}}}}},LN={id:"yaml-ls",extensions:[".yaml",".yml"],root:e0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),async spawn($){let Z=await q6(d0("yaml-language-server"),"yaml-language-server");if(!Z)return;return{process:M6(Z,["--stdio"],$)}}},TN={id:"lua-ls",root:e0([".luarc.json",".luarc.jsonc",".luacheckrc",".stylua.toml","stylua.toml","selene.toml","selene.yml"]),extensions:[".lua"],async spawn($){let Z=d0("lua-language-server");if(!Z){if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("downloading lua-language-server from GitHub releases");let J=await fetch("https://api.github.com/repos/LuaLS/lua-language-server/releases/latest");if(!J.ok){X0.error("Failed to fetch lua-language-server release info");return}let Y=await J.json(),X=process.platform,Q=process.arch,G="",W=Q;if(Q==="arm64")W="arm64";else if(Q==="x64")W="x64";else if(Q==="ia32")W="ia32";let K=X;if(X==="darwin")K="darwin";else if(X==="linux")K="linux";else if(X==="win32")K="win32";let V=X==="win32"?"zip":"tar.gz";G=`lua-language-server-${Y.tag_name}-${K}-${W}.${V}`;let U=["darwin-arm64.tar.gz","darwin-x64.tar.gz","linux-x64.tar.gz","linux-arm64.tar.gz","win32-x64.zip","win32-ia32.zip"],H=`${K}-${W}.${V}`;if(!U.includes(H)){X0.error(`Platform ${X} and architecture ${Q} is not supported by lua-language-server`);return}let B=Y.assets.find((w)=>w.name===G);if(!B){X0.error(`Could not find asset ${G} in latest lua-language-server release`);return}let z=B.browser_download_url,F=await fetch(z);if(!F.ok){X0.error("Failed to download lua-language-server");return}let A=w8.join(A0.Path.bin,G);if(F.body)await s0.writeStream(A,F.body);let N=w8.join(A0.Path.bin,`lua-language-server-${W}-${K}`);if(await D6.stat(N).catch(()=>{return}))await D6.rm(N,{force:!0,recursive:!0});if(await D6.mkdir(N,{recursive:!0}),V==="zip"){if(!await D8.extractZip(A,N).then(()=>!0).catch((j)=>{return X0.error("Failed to extract lua-language-server archive",{error:j}),!1}))return}else if(!await N6(["tar","-xzf",A,"-C",N]).then((j)=>j.code===0).catch((j)=>{return X0.error("Failed to extract lua-language-server archive",{error:j}),!1}))return;if(await D6.rm(A,{force:!0}),Z=w8.join(N,"bin","lua-language-server"+(X==="win32"?".exe":"")),!await s0.exists(Z)){X0.error("Failed to extract lua-language-server binary");return}if(X!=="win32"){if(!await D6.chmod(Z,493).then(()=>!0).catch((j)=>{return X0.error("Failed to set executable permission for lua-language-server binary",{error:j}),!1}))return}X0.info("installed lua-language-server",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},RN={id:"prisma",extensions:[".prisma"],root:e0(["schema.prisma","prisma/schema.prisma","prisma"],["package.json"]),async spawn($){let Z=d0("prisma");if(!Z){X0.info("prisma not found, please install prisma");return}return{process:Z1(Z,["language-server"],{cwd:$})}}},PN={id:"bash",extensions:[".sh",".bash",".zsh",".ksh"],root:async($,Z)=>Z.directory,async spawn($){let Z=await q6(d0("bash-language-server"),"bash-language-server");if(!Z)return;return{process:M6(Z,["start"],$)}}};import Z8 from"fs/promises";import r1 from"path";import tc from"os";var CN={id:"gopls",root:async($,Z)=>{let J=await e0(["go.work"])($,Z);if(J)return J;return e0(["go.mod","go.sum"])($,Z)},extensions:[".go"],async spawn($){let Z=d0("gopls");if(!Z){if(!d0("go"))return;if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;if(X0.info("installing gopls"),await f1.spawn(["go","install","golang.org/x/tools/gopls@latest"],{env:{GOBIN:A0.Path.bin},stdout:"pipe",stderr:"pipe",stdin:"pipe"}).exited!==0){X0.error("Failed to install gopls");return}Z=r1.join(A0.Path.bin,"gopls"+(process.platform==="win32"?".exe":"")),X0.info("installed gopls",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},IN={id:"csharp",root:e0([".slnx",".sln",".csproj","global.json"]),extensions:[".cs"],async spawn($){let Z=d0("csharp-ls");if(!Z){if(!d0("dotnet")){X0.error(".NET SDK is required to install csharp-ls");return}if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;if(X0.info("installing csharp-ls via dotnet tool"),await f1.spawn(["dotnet","tool","install","csharp-ls","--tool-path",A0.Path.bin],{stdout:"pipe",stderr:"pipe",stdin:"pipe"}).exited!==0){X0.error("Failed to install csharp-ls");return}Z=r1.join(A0.Path.bin,"csharp-ls"+(process.platform==="win32"?".exe":"")),X0.info("installed csharp-ls",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},EN={id:"fsharp",root:e0([".slnx",".sln",".fsproj","global.json"]),extensions:[".fs",".fsi",".fsx",".fsscript"],async spawn($){let Z=d0("fsautocomplete");if(!Z){if(!d0("dotnet")){X0.error(".NET SDK is required to install fsautocomplete");return}if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;if(X0.info("installing fsautocomplete via dotnet tool"),await f1.spawn(["dotnet","tool","install","fsautocomplete","--tool-path",A0.Path.bin],{stdout:"pipe",stderr:"pipe",stdin:"pipe"}).exited!==0){X0.error("Failed to install fsautocomplete");return}Z=r1.join(A0.Path.bin,"fsautocomplete"+(process.platform==="win32"?".exe":"")),X0.info("installed fsautocomplete",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},bN={id:"sourcekit-lsp",extensions:[".swift",".objc","objcpp"],root:e0(["Package.swift","*.xcodeproj","*.xcworkspace"]),async spawn($){let Z=d0("sourcekit-lsp");if(Z)return{process:Z1(Z,{cwd:$})};if(!d0("xcrun"))return;let J=await FN(["xcrun","--find","sourcekit-lsp"]);if(J.code!==0)return;let Y=J.text.trim();return{process:Z1(Y,{cwd:$})}}},_N={id:"rust",root:async($,Z)=>{let J=await e0(["Cargo.toml","Cargo.lock"])($,Z);if(J===void 0)return;let Y=J;while(Y!==r1.dirname(Y)){let X=r1.join(Y,"Cargo.toml");try{if((await s0.readText(X)).includes("[workspace]"))return Y}catch{}let Q=r1.dirname(Y);if(Q===Y||!s0.contains(Z.worktree,Q))break;Y=Q}return J},extensions:[".rs"],async spawn($){let Z=d0("rust-analyzer");if(!Z){X0.info("rust-analyzer not found in path, please install it");return}return{process:Z1(Z,{cwd:$})}}},SN={id:"clangd",root:e0(["compile_commands.json","compile_flags.txt",".clangd"]),extensions:[".c",".cpp",".cc",".cxx",".c++",".h",".hpp",".hh",".hxx",".h++"],async spawn($){let Z=["--background-index","--clang-tidy"],J=d0("clangd");if(J)return{process:Z1(J,Z,{cwd:$})};let Y=process.platform==="win32"?".exe":"",X=r1.join(A0.Path.bin,"clangd"+Y);if(await s0.exists(X))return{process:Z1(X,Z,{cwd:$})};let Q=await Z8.readdir(A0.Path.bin,{withFileTypes:!0}).catch(()=>[]);for(let R of Q){if(!R.isDirectory())continue;if(!R.name.startsWith("clangd_"))continue;let L=r1.join(A0.Path.bin,R.name,"bin","clangd"+Y);if(await s0.exists(L))return{process:Z1(L,Z,{cwd:$})}}if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("downloading clangd from GitHub releases");let G=await fetch("https://api.github.com/repos/clangd/clangd/releases/latest");if(!G.ok){X0.error("Failed to fetch clangd release info");return}let W=await G.json(),K=W.tag_name;if(!K){X0.error("clangd release did not include a tag name");return}let V=process.platform,H={darwin:"mac",linux:"linux",win32:"windows"}[V];if(!H){X0.error(`Platform ${V} is not supported by clangd auto-download`);return}let B=W.assets??[],z=(R)=>{if(!R.name)return!1;if(!R.browser_download_url)return!1;if(!R.name.includes(H))return!1;return R.name.includes(K)},F=B.find((R)=>z(R)&&R.name?.endsWith(".zip"))??B.find((R)=>z(R)&&R.name?.endsWith(".tar.xz"))??B.find((R)=>z(R));if(!F?.name||!F.browser_download_url){X0.error("clangd could not match release asset",{tag:K,platform:V});return}let A=F.name,N=await fetch(F.browser_download_url);if(!N.ok){X0.error("Failed to download clangd");return}let q=r1.join(A0.Path.bin,A),w=await N.arrayBuffer();if(w.byteLength===0){X0.error("Failed to write clangd archive");return}await s0.write(q,Buffer.from(w));let j=A.endsWith(".zip"),M=A.endsWith(".tar.xz");if(!j&&!M){X0.error("clangd encountered unsupported asset",{asset:A});return}if(j){if(!await D8.extractZip(q,A0.Path.bin).then(()=>!0).catch((L)=>{return X0.error("Failed to extract clangd archive",{error:L}),!1}))return}if(M)await N6(["tar","-xf",q],{cwd:A0.Path.bin});await Z8.rm(q,{force:!0});let I=r1.join(A0.Path.bin,"clangd_"+K,"bin","clangd"+Y);if(!await s0.exists(I)){X0.error("Failed to extract clangd binary");return}if(V!=="win32")await Z8.chmod(I,493).catch(()=>{});return await Z8.unlink(r1.join(A0.Path.bin,"clangd")).catch(()=>{}),await Z8.symlink(I,r1.join(A0.Path.bin,"clangd")).catch(()=>{}),X0.info("installed clangd",{bin:I}),{process:Z1(I,Z,{cwd:$})}}},fN={id:"jdtls",root:async($,Z)=>{let J=["settings.gradle","settings.gradle.kts"],Y=["gradlew","gradlew.bat"],X=Y.concat(J),[Q,G,W]=await Promise.all([e0(["pom.xml","build.gradle","build.gradle.kts",".project",".classpath"],X)($,Z),e0(Y,J)($,Z),e0(J)($,Z)]);if(Q)return Q;if(G)return G;if(W)return W},extensions:[".java"],async spawn($){let Z=d0("java");if(!Z){X0.error("Java 21 or newer is required to run the JDTLS. Please install it first.");return}let J=await N6(["java","-version"]).then((U)=>{let H=/"(\d+)\.\d+\.\d+"/.exec(U.stderr.toString());return!H?void 0:parseInt(H[1])});if(J==null||J<21){X0.error("JDTLS requires at least Java 21.");return}let Y=r1.join(A0.Path.bin,"jdtls"),X=r1.join(Y,"plugins");if(!await gV(X)){if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("Downloading JDTLS LSP server."),await Z8.mkdir(Y,{recursive:!0});let U="https://www.eclipse.org/downloads/download.php?file=/jdtls/snapshots/jdt-language-server-latest.tar.gz",H="release.tar.gz";X0.info("Downloading JDTLS archive",{url:U,dest:Y});let B=await fetch(U);if(!B.ok||!B.body){X0.error("Failed to download JDTLS",{status:B.status,statusText:B.statusText});return}await s0.writeStream(r1.join(Y,H),B.body),X0.info("Extracting JDTLS archive");let z=await N6(["tar","-xzf",H],{cwd:Y});if(z.code!==0){X0.error("Failed to extract JDTLS",{exitCode:z.code,stderr:z.stderr.toString()});return}await Z8.rm(r1.join(Y,H),{force:!0}),X0.info("JDTLS download and extraction completed")}let G=(await Z8.readdir(X).catch(()=>[])).find((U)=>/^org\.eclipse\.equinox\.launcher_.*\.jar$/.test(U))?.trim()??"",W=r1.join(X,G);if(!await gV(W)){X0.error(`Failed to locate the JDTLS launcher module in the installed directory: ${Y}.`);return}let K=r1.join(Y,(()=>{switch(process.platform){case"darwin":return"config_mac";case"linux":return"config_linux";case"win32":return"config_win";default:return"config_linux"}})()),V=await Z8.mkdtemp(r1.join(tc.tmpdir(),"qitqode-jdtls-data"));return{process:Z1(Z,["-jar",W,"-configuration",K,"-data",V,"-Declipse.application=org.eclipse.jdt.ls.core.id1","-Dosgi.bundles.defaultStartLevel=4","-Declipse.product=org.eclipse.jdt.ls.core.product","-Dlog.level=ALL","--add-modules=ALL-SYSTEM","--add-opens java.base/java.util=ALL-UNNAMED","--add-opens java.base/java.lang=ALL-UNNAMED"],{cwd:$})}}},kN={id:"kotlin-ls",extensions:[".kt",".kts"],root:async($,Z)=>{let J=await e0(["settings.gradle.kts","settings.gradle"])($,Z);if(J)return J;let Y=await e0(["gradlew","gradlew.bat"])($,Z);if(Y)return Y;let X=await e0(["build.gradle.kts","build.gradle"])($,Z);if(X)return X;return e0(["pom.xml"])($,Z)},async spawn($){let Z=r1.join(A0.Path.bin,"kotlin-ls"),J=process.platform==="win32"?r1.join(Z,"kotlin-lsp.cmd"):r1.join(Z,"kotlin-lsp.sh");if(!await s0.exists(J)){if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("Downloading Kotlin Language Server from GitHub.");let X=await fetch("https://api.github.com/repos/Kotlin/kotlin-lsp/releases/latest");if(!X.ok){X0.error("Failed to fetch kotlin-lsp release info");return}let G=(await X.json()).name?.replace(/^v/,"");if(!G){X0.error("Could not determine Kotlin LSP version from release");return}let{platform:W,arch:K}=process,V=K;if(K==="arm64")V="aarch64";else if(K==="x64")V="x64";let U=W;if(W==="darwin")U="mac";else if(W==="linux")U="linux";else if(W==="win32")U="win";let H=["mac-x64","mac-aarch64","linux-x64","linux-aarch64","win-x64","win-aarch64"],B=`${U}-${V}`;if(!H.includes(B)){X0.error(`Platform ${W}/${K} is not supported by Kotlin LSP`);return}let z=`kotlin-lsp-${G}-${U}-${V}.zip`,F=`https://download-cdn.jetbrains.com/kotlin-lsp/${G}/${z}`;await Z8.mkdir(Z,{recursive:!0});let A=r1.join(Z,"kotlin-ls.zip"),N=await fetch(F);if(!N.ok||!N.body){X0.error("Failed to download Kotlin Language Server",{status:N.status,statusText:N.statusText});return}if(await s0.writeStream(A,N.body),!await D8.extractZip(A,Z).then(()=>!0).catch((w)=>{return X0.error("Failed to extract Kotlin LS archive",{error:w}),!1}))return;if(await Z8.rm(A,{force:!0}),process.platform!=="win32")await Z8.chmod(J,493).catch(()=>{});X0.info("Installed Kotlin Language Server",{path:J})}if(!await s0.exists(J)){X0.error(`Failed to locate the Kotlin LS launcher script in the installed directory: ${Z}.`);return}return{process:Z1(J,["--stdio"],{cwd:$})}}},vN={id:"dart",extensions:[".dart"],root:e0(["pubspec.yaml","analysis_options.yaml"]),async spawn($){let Z=d0("dart");if(!Z){X0.info("dart not found, please install dart first");return}return{process:Z1(Z,["language-server","--lsp"],{cwd:$})}}},yN={id:"ocaml-lsp",extensions:[".ml",".mli"],root:e0(["dune-project","dune-workspace",".merlin","opam"]),async spawn($){let Z=d0("ocamllsp");if(!Z){X0.info("ocamllsp not found, please install ocaml-lsp-server");return}return{process:Z1(Z,{cwd:$})}}},xN={id:"gleam",extensions:[".gleam"],root:e0(["gleam.toml"]),async spawn($){let Z=d0("gleam");if(!Z){X0.info("gleam not found, please install gleam first");return}return{process:Z1(Z,["lsp"],{cwd:$})}}},hN={id:"zls",extensions:[".zig",".zon"],root:e0(["build.zig"]),async spawn($){let Z=d0("zls");if(!Z){if(!d0("zig")){X0.error("Zig is required to use zls. Please install Zig first.");return}if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("downloading zls from GitHub releases");let Y=await fetch("https://api.github.com/repos/zigtools/zls/releases/latest");if(!Y.ok){X0.error("Failed to fetch zls release info");return}let X=await Y.json(),Q=process.platform,G=process.arch,W="",K=G;if(G==="arm64")K="aarch64";else if(G==="x64")K="x86_64";else if(G==="ia32")K="x86";let V=Q;if(Q==="darwin")V="macos";else if(Q==="win32")V="windows";let U=Q==="win32"?"zip":"tar.xz";if(W=`zls-${K}-${V}.${U}`,!["zls-x86_64-linux.tar.xz","zls-x86_64-macos.tar.xz","zls-x86_64-windows.zip","zls-aarch64-linux.tar.xz","zls-aarch64-macos.tar.xz","zls-aarch64-windows.zip","zls-x86-linux.tar.xz","zls-x86-windows.zip"].includes(W)){X0.error(`Platform ${Q} and architecture ${G} is not supported by zls`);return}let B=X.assets?.find((F)=>F.name===W);if(!B?.browser_download_url){X0.error(`Could not find asset ${W} in latest zls release`);return}let z=await LZ(B.browser_download_url,W,"zls");if(!z)return;if(U==="zip"){if(!await TZ(z,"zls"))return}else await N6(["tar","-xf",z],{cwd:A0.Path.bin});if(await Z8.rm(z,{force:!0}),Z=r1.join(A0.Path.bin,"zls"+(Q==="win32"?".exe":"")),!await s0.exists(Z)){X0.error("Failed to extract zls binary");return}if(Q!=="win32")await Z8.chmod(Z,493).catch(()=>{});X0.info("installed zls",{bin:Z})}return{process:Z1(Z,{cwd:$})}}};import j5 from"fs/promises";import f8 from"path";function ec($){return[process.env.VIRTUAL_ENV,f8.join($,".venv"),f8.join($,"venv")].filter((Z)=>Z!==void 0)}async function uV($,Z){let J=process.platform==="win32";for(let Y of ec($)){let X=J?f8.join(Y,"Scripts",`${Z}.exe`):f8.join(Y,"bin",Z);if(await s0.exists(X))return X}return}var gN={id:"ruby-lsp",root:e0(["Gemfile"]),extensions:[".rb",".rake",".gemspec",".ru"],async spawn($){let Z=d0("rubocop");if(!Z){let J=d0("ruby"),Y=d0("gem");if(!J||!Y){X0.info("Ruby not found, please install Ruby first");return}if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;if(X0.info("installing rubocop"),await f1.spawn(["gem","install","rubocop","--bindir",A0.Path.bin],{stdout:"pipe",stderr:"pipe",stdin:"pipe"}).exited!==0){X0.error("Failed to install rubocop");return}Z=f8.join(A0.Path.bin,"rubocop"+(process.platform==="win32"?".exe":"")),X0.info("installed rubocop",{bin:Z})}return{process:Z1(Z,["--lsp"],{cwd:$})}}},uN={id:"ty",extensions:[".py",".pyi"],root:e0(["pyproject.toml","ty.toml","setup.py","setup.cfg","requirements.txt","Pipfile","pyrightconfig.json"]),async spawn($){if(!S0.QITQODE_EXPERIMENTAL_LSP_TY)return;let Z=d0("ty"),J={},Y=await uV($,"python");if(Y)J.pythonPath=Y;if(!Z)Z=await uV($,"ty")??null;if(!Z){X0.error("ty not found, please install ty first");return}return{process:Z1(Z,["server"],{cwd:$}),initialization:J}}},mN={id:"pyright",extensions:[".py",".pyi"],root:e0(["pyproject.toml","setup.py","setup.cfg","requirements.txt","Pipfile","pyrightconfig.json"]),async spawn($){let Z=await q6(d0("pyright-langserver"),"pyright");if(!Z)return;let J=["--stdio"],Y={},X=await uV($,"python");if(X)Y.pythonPath=X;return{process:M6(Z,J,$),initialization:Y}}},lN={id:"elixir-ls",extensions:[".ex",".exs"],root:e0(["mix.exs","mix.lock"]),async spawn($){let Z=d0("elixir-ls");if(!Z){let J=f8.join(A0.Path.bin,"elixir-ls");if(Z=f8.join(A0.Path.bin,"elixir-ls-master","release",process.platform==="win32"?"language_server.bat":"language_server.sh"),!await s0.exists(Z)){if(!d0("elixir")){X0.error("elixir is required to run elixir-ls");return}if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("downloading elixir-ls from GitHub releases");let X=await LZ("https://github.com/elixir-lsp/elixir-ls/archive/refs/heads/master.zip","elixir-ls.zip","elixir-ls");if(!X)return;if(!await TZ(X,"elixir-ls"))return;await j5.rm(X,{force:!0,recursive:!0});let G=f8.join(A0.Path.bin,"elixir-ls-master"),W={MIX_ENV:"prod",...n8()};await f1.run(["mix","deps.get"],{cwd:G,env:W}),await f1.run(["mix","compile"],{cwd:G,env:W}),await f1.run(["mix","elixir_ls.release2","-o","release"],{cwd:G,env:W}),X0.info("installed elixir-ls",{path:J})}}return{process:Z1(Z,{cwd:$})}}},dN={id:"php intelephense",extensions:[".php"],root:e0(["composer.json","composer.lock",".php-version"]),async spawn($){let Z=await q6(d0("intelephense"),"intelephense");if(!Z)return;return{process:M6(Z,["--stdio"],$),initialization:{telemetry:{enabled:!1}}}}},pN={id:"julials",extensions:[".jl"],root:e0(["Project.toml","Manifest.toml","*.jl"]),async spawn($){let Z=d0("julia");if(!Z){X0.info("julia not found, please install julia first (https://julialang.org/downloads/)");return}return{process:Z1(Z,["--startup-file=no","--history-file=no","-e","using LanguageServer; runserver()"],{cwd:$})}}},cN={id:"haskell-language-server",extensions:[".hs",".lhs"],root:e0(["stack.yaml","cabal.project","hie.yaml","*.cabal"]),async spawn($){let Z=d0("haskell-language-server-wrapper");if(!Z){X0.info("haskell-language-server-wrapper not found, please install haskell-language-server");return}return{process:Z1(Z,["--lsp"],{cwd:$})}}},iN={id:"nixd",extensions:[".nix"],root:async($,Z)=>{let J=await e0(["flake.nix"])($,Z);if(J&&J!==Z.directory)return J;if(Z.worktree&&Z.worktree!==Z.directory)return Z.worktree;return Z.directory},async spawn($){let Z=d0("nixd");if(!Z){X0.info("nixd not found, please install nixd first");return}return{process:Z1(Z,[],{cwd:$,env:{...n8()}})}}},nN={id:"tinymist",extensions:[".typ",".typc"],root:e0(["typst.toml"]),async spawn($){let Z=d0("tinymist");if(!Z){if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("downloading tinymist from GitHub releases");let J=await fetch("https://api.github.com/repos/Myriad-Dreamin/tinymist/releases/latest");if(!J.ok){X0.error("Failed to fetch tinymist release info");return}let Y=await J.json(),X=process.platform,G=process.arch==="arm64"?"aarch64":"x86_64",W,K;if(X==="darwin")W="apple-darwin",K="tar.gz";else if(X==="win32")W="pc-windows-msvc",K="zip";else W="unknown-linux-gnu",K="tar.gz";let V=`tinymist-${G}-${W}.${K}`,H=(Y.assets??[]).find((z)=>z.name===V);if(!H?.browser_download_url){X0.error(`Could not find asset ${V} in tinymist release`);return}let B=await LZ(H.browser_download_url,V,"tinymist");if(!B)return;if(K==="zip"){if(!await TZ(B,"tinymist"))return}else await N6(["tar","-xzf",B,"--strip-components=1"],{cwd:A0.Path.bin});if(await j5.rm(B,{force:!0}),Z=f8.join(A0.Path.bin,"tinymist"+(X==="win32"?".exe":"")),!await s0.exists(Z)){X0.error("Failed to extract tinymist binary");return}if(X!=="win32")await j5.chmod(Z,493).catch(()=>{});X0.info("installed tinymist",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},oN={id:"terraform",extensions:[".tf",".tfvars"],root:e0([".terraform.lock.hcl","terraform.tfstate","*.tf"]),async spawn($){let Z=d0("terraform-ls");if(!Z){if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("downloading terraform-ls from HashiCorp releases");let J=await fetch("https://api.releases.hashicorp.com/v1/releases/terraform-ls/latest");if(!J.ok){X0.error("Failed to fetch terraform-ls release info");return}let Y=await J.json(),X=process.platform,G=process.arch==="arm64"?"arm64":"amd64",W=X==="win32"?"windows":X,V=(Y.builds??[]).find((z)=>z.arch===G&&z.os===W);if(!V?.url){X0.error(`Could not find build for ${W}/${G} terraform-ls release version ${Y.version}`);return}let U=await fetch(V.url);if(!U.ok){X0.error("Failed to download terraform-ls");return}let H=f8.join(A0.Path.bin,"terraform-ls.zip");if(U.body)await s0.writeStream(H,U.body);if(!await D8.extractZip(H,A0.Path.bin).then(()=>!0).catch((z)=>{return X0.error("Failed to extract terraform-ls archive",{error:z}),!1}))return;if(await j5.rm(H,{force:!0}),Z=f8.join(A0.Path.bin,"terraform-ls"+(X==="win32"?".exe":"")),!await s0.exists(Z)){X0.error("Failed to extract terraform-ls binary");return}if(X!=="win32")await j5.chmod(Z,493).catch(()=>{});X0.info("installed terraform-ls",{bin:Z})}return{process:Z1(Z,["serve"],{cwd:$}),initialization:{experimentalFeatures:{prefillRequiredFields:!0,validateOnSave:!0}}}}},sN={id:"texlab",extensions:[".tex",".bib"],root:e0([".latexmkrc","latexmkrc",".texlabroot","texlabroot"]),async spawn($){let Z=d0("texlab");if(!Z){if(S0.QITQODE_DISABLE_LSP_DOWNLOAD)return;X0.info("downloading texlab from GitHub releases");let J=await fetch("https://api.github.com/repos/latex-lsp/texlab/releases/latest");if(!J.ok){X0.error("Failed to fetch texlab release info");return}let Y=await J.json();if(!Y.tag_name?.replace("v","")){X0.error("texlab release did not include a version tag");return}let Q=process.platform,W=process.arch==="arm64"?"aarch64":"x86_64",K=Q==="darwin"?"macos":Q==="win32"?"windows":"linux",V=Q==="win32"?"zip":"tar.gz",U=`texlab-${W}-${K}.${V}`,B=(Y.assets??[]).find((F)=>F.name===U);if(!B?.browser_download_url){X0.error(`Could not find asset ${U} in texlab release`);return}let z=await LZ(B.browser_download_url,U,"texlab");if(!z)return;if(V==="zip"){if(!await TZ(z,"texlab"))return}if(V==="tar.gz")await N6(["tar","-xzf",z],{cwd:A0.Path.bin});if(await j5.rm(z,{force:!0}),Z=f8.join(A0.Path.bin,"texlab"+(Q==="win32"?".exe":"")),!await s0.exists(Z)){X0.error("Failed to extract texlab binary");return}if(Q!=="win32")await j5.chmod(Z,493).catch(()=>{});X0.info("installed texlab",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},rN={id:"dockerfile",extensions:[".dockerfile","Dockerfile"],root:async($,Z)=>Z.directory,async spawn($){let Z=await q6(d0("docker-langserver"),"dockerfile-language-server-nodejs");if(!Z)return;return{process:M6(Z,["--stdio"],$)}}},aN={id:"clojure-lsp",extensions:[".clj",".cljs",".cljc",".edn"],root:e0(["deps.edn","project.clj","shadow-cljs.edn","bb.edn","build.boot"]),async spawn($){let Z=d0("clojure-lsp");if(!Z&&process.platform==="win32")Z=d0("clojure-lsp.exe");if(!Z){X0.info("clojure-lsp not found, please install clojure-lsp first");return}return{process:Z1(Z,["listen"],{cwd:$})}}};var Q8={};F1(Q8,{layer:()=>ww,defaultLayer:()=>Wa,Service:()=>Z4,Server:()=>Xa,Layout:()=>Qa,Info:()=>b5,ConfigDirectoryTypoError:()=>Ga});import Ja from"path";var k8={};F1(k8,{sweepStaleAuthTmp:()=>eN,layer:()=>Zq,defaultLayer:()=>Ji,WellKnown:()=>cV,Service:()=>_Q,Oauth:()=>dV,OAUTH_DUMMY_KEY:()=>lV,Info:()=>$q,AuthError:()=>SQ,Auth:()=>k8,Api:()=>pV});import $i from"path";var lV="qitqode-oauth-dummy-key",bQ=$i.join(A0.Path.data,"auth.json"),Zi=60000;async function eN(){let $=bQ+".tmp";try{let{stat:Z,unlink:J}=await import("fs/promises"),Y=await Z($);if(Date.now()-Y.mtimeMs>=Zi)await J($).catch(()=>{return})}catch{}}var EQ=($)=>(Z)=>new SQ({message:$,cause:Z});class dV extends O.Class("OAuth")({type:O.Literal("oauth"),refresh:O.String,access:O.String,expires:O.Number,accountId:O.optional(O.String),enterpriseUrl:O.optional(O.String)}){}class pV extends O.Class("ApiAuth")({type:O.Literal("api"),key:O.String,metadata:O.optional(O.Record(O.String,O.String))}){}class cV extends O.Class("WellKnownAuth")({type:O.Literal("wellknown"),key:O.String,token:O.String}){}var tN=O.Union([dV,pV,cV]).annotate({discriminator:"type",identifier:"Auth"}),$q=Object.assign(tN,{zod:w0(tN)});class SQ extends O.TaggedErrorClass()("AuthError",{message:O.String,cause:O.optional(O.Defect)}){}class _Q extends S1.Service()("@qitqode/Auth"){}var Zq=R0.effect(_Q,T.gen(function*(){let $=yield*w$.Service,Z=O.decodeUnknownOption($q);yield*T.promise(()=>eN());let J=T.fn("Auth.readFile")(function*(){let V=yield*$.readJson(bQ).pipe(T.orElseSucceed(()=>({})));if(!k7.isEnvelope(V))return V;let U=yield*T.promise(()=>k7.encryptionKey());if(!U)return yield*T.fail(new SQ({message:"auth.json is encrypted but the OS keyring is unavailable. Restore keyring access or delete auth.json and log in again."}));return yield*T.try({try:()=>JSON.parse(k7.decrypt(V,U)),catch:EQ("Failed to decrypt auth data (keyring key mismatch?)")})}),Y=T.fn("Auth.writeFile")(function*(V){let U=yield*T.promise(()=>k7.encryptionKey()),H=U?k7.encrypt(JSON.stringify(V),U):V,B=bQ+".tmp";yield*$.writeJson(B,H).pipe(T.mapError(EQ("Failed to write auth data"))),yield*$.chmod(B,384).pipe(T.mapError(EQ("Failed to set auth file permissions"))),yield*$.rename(B,bQ).pipe(T.mapError(EQ("Failed to atomically replace auth data")))}),X=T.fn("Auth.all")(function*(){let V=yield*J(),U=y7.filterMap(V,(H)=>v7.fromOption(Z(H),()=>{return}));if(process.env.QITQODE_AUTH_CONTENT)try{let H=JSON.parse(process.env.QITQODE_AUTH_CONTENT);return{...y7.filterMap(H,(z)=>v7.fromOption(Z(z),()=>{return})),...U}}catch(H){console.error("[Auth] Failed to parse QITQODE_AUTH_CONTENT env var:",H)}return U}),Q=T.fn("Auth.get")(function*(V){return(yield*X())[V]}),G="auth-file",W=T.fn("Auth.set")(function*(V,U){yield*T.scoped(T.gen(function*(){yield*mV.effect(G);let H=V.replace(/\/+$/,""),B=yield*X();if(H!==V)delete B[V];delete B[H+"/"],yield*Y({...B,[H]:U})}))}),K=T.fn("Auth.remove")(function*(V){yield*T.scoped(T.gen(function*(){yield*mV.effect(G);let U=V.replace(/\/+$/,""),H=yield*X();delete H[V],delete H[U],yield*Y(H)}))});return _Q.of({get:Q,all:X,set:W,remove:K})})),Ji=Zq.pipe(R0.provide(w$.defaultLayer));var l6={};F1(l6,{layer:()=>Jq,defaultLayer:()=>Yi,Service:()=>fQ,Env:()=>l6});class fQ extends S1.Service()("@qitqode/Env"){}var Jq=R0.effect(fQ,T.gen(function*(){let $=yield*B0.make(T.fn("Env.state")(()=>T.succeed({...process.env}))),Z=T.fn("Env.get")((Q)=>B0.use($,(G)=>G[Q])),J=T.fn("Env.all")(()=>B0.get($)),Y=T.fn("Env.set")(function*(Q,G){let W=yield*B0.get($);W[Q]=G}),X=T.fn("Env.remove")(function*(Q){let G=yield*B0.get($);delete G[Q]});return fQ.of({get:Z,all:J,set:Y,remove:X})})),Yi=Jq;var Yq={Connected:T1.define("server.connected",P.object({})),Heartbeat:T1.define("server.heartbeat",P.object({})),Disposed:T1.define("global.disposed",P.object({}))};var o7={};F1(o7,{layer:()=>Aq,defaultLayer:()=>Vi,UserCode:()=>uY,Service:()=>uQ,RefreshToken:()=>x7,PollSuccess:()=>u7,PollSlow:()=>l7,PollResult:()=>Xq,PollPending:()=>m7,PollExpired:()=>d7,PollError:()=>c7,PollDenied:()=>p7,OrgID:()=>vQ,Org:()=>lY,Login:()=>dY,Info:()=>mY,DeviceCode:()=>h7,AccountTransportError:()=>q5,AccountServiceError:()=>RZ,AccountRepoError:()=>g7,AccountID:()=>hY,Account:()=>o7,AccessToken:()=>gY});var i7={};F1(i7,{layer:()=>Xi,Service:()=>xQ,AccountRepo:()=>i7});var L8=g6("account",{id:L1().$type().primaryKey(),email:L1().notNull(),url:L1().notNull(),access_token:L1().$type().notNull(),refresh_token:L1().$type().notNull(),token_expiry:N8(),...xY}),N5=g6("account_state",{id:N8().primaryKey(),active_account_id:L1().$type().references(()=>L8.id,{onDelete:"set null"}),active_org_id:L1().$type()}),gT0=g6("control_account",{email:L1().notNull(),url:L1().notNull(),access_token:L1().$type().notNull(),refresh_token:L1().$type().notNull(),token_expiry:N8(),active:N8({mode:"boolean"}).notNull().$default(()=>!1),...xY},($)=>[kQ({columns:[$.email,$.url]})]);var hY=O.String.pipe(O.brand("AccountID")),vQ=O.String.pipe(O.brand("OrgID")),gY=O.String.pipe(O.brand("AccessToken")),x7=O.String.pipe(O.brand("RefreshToken")),h7=O.String.pipe(O.brand("DeviceCode")),uY=O.String.pipe(O.brand("UserCode"));class mY extends O.Class("Account")({id:hY,email:O.String,url:O.String,active_org_id:O.NullOr(vQ)}){}class lY extends O.Class("Org")({id:vQ,name:O.String}){}class g7 extends O.TaggedErrorClass()("AccountRepoError",{message:O.String,cause:O.optional(O.Defect)}){}class RZ extends O.TaggedErrorClass()("AccountServiceError",{message:O.String,cause:O.optional(O.Defect)}){}class q5 extends O.TaggedErrorClass()("AccountTransportError",{method:O.String,url:O.String,description:O.optional(O.String),cause:O.optional(O.Defect)}){static fromHttpClientError($){return new q5({method:$.request.method,url:$.request.url,description:$.description,cause:$.cause})}get message(){return[`Could not reach ${this.method} ${this.url}.`,"This failed before the server returned an HTTP response.",this.description,"Check your network, proxy, or VPN configuration and try again."].filter(Boolean).join(`
|
|
486
|
+
`)}}class dY extends O.Class("Login")({code:h7,user:uY,url:O.String,server:O.String,expiry:O.Duration,interval:O.Duration}){}class u7 extends O.TaggedClass()("PollSuccess",{email:O.String}){}class m7 extends O.TaggedClass()("PollPending",{}){}class l7 extends O.TaggedClass()("PollSlow",{}){}class d7 extends O.TaggedClass()("PollExpired",{}){}class p7 extends O.TaggedClass()("PollDenied",{}){}class c7 extends O.TaggedClass()("PollError",{cause:O.Defect}){}var Xq=O.Union([u7,m7,l7,d7,p7,c7]);var yQ=($)=>{let Z=new URL($);Z.search="",Z.hash="";let J=Z.pathname.replace(/\/+$/,"");return J.length===0?Z.origin:`${Z.origin}${J}`};var Qq=1;class xQ extends S1.Service()("@qitqode/AccountRepo"){}var Xi=R0.effect(xQ,T.gen(function*(){let $=O.decodeUnknownSync(mY),Z=(B)=>T.try({try:()=>W1.use(B),catch:(z)=>new g7({message:"Database operation failed",cause:z})}),J=(B)=>T.try({try:()=>W1.transaction(B),catch:(z)=>new g7({message:"Database operation failed",cause:z})}),Y=(B)=>{let z=B.select().from(N5).where(m0(N5.id,Qq)).get();if(!z?.active_account_id)return;let F=B.select().from(L8).where(m0(L8.id,z.active_account_id)).get();if(!F)return;return{...F,active_org_id:z.active_org_id??null}},X=(B,z,F)=>{let A=O1.getOrNull(F);return B.insert(N5).values({id:Qq,active_account_id:z,active_org_id:A}).onConflictDoUpdate({target:N5.id,set:{active_account_id:z,active_org_id:A}}).run()},Q=T.fn("AccountRepo.active")(()=>Z((B)=>Y(B)).pipe(T.map((B)=>B?O1.some($(B)):O1.none()))),G=T.fn("AccountRepo.list")(()=>Z((B)=>B.select().from(L8).all().map((z)=>$({...z,active_org_id:null})))),W=T.fn("AccountRepo.remove")((B)=>J((z)=>{z.update(N5).set({active_account_id:null,active_org_id:null}).where(m0(N5.active_account_id,B)).run(),z.delete(L8).where(m0(L8.id,B)).run()}).pipe(T.asVoid)),K=T.fn("AccountRepo.use")((B,z)=>Z((F)=>X(F,B,z)).pipe(T.asVoid)),V=T.fn("AccountRepo.getRow")((B)=>Z((z)=>z.select().from(L8).where(m0(L8.id,B)).get()).pipe(T.map(O1.fromNullishOr))),U=T.fn("AccountRepo.persistToken")((B)=>Z((z)=>z.update(L8).set({access_token:B.accessToken,refresh_token:B.refreshToken,token_expiry:O1.getOrNull(B.expiry)}).where(m0(L8.id,B.accountID)).run()).pipe(T.asVoid)),H=T.fn("AccountRepo.persistAccount")((B)=>J((z)=>{let F=yQ(B.url);z.insert(L8).values({id:B.id,email:B.email,url:F,access_token:B.accessToken,refresh_token:B.refreshToken,token_expiry:B.expiry}).onConflictDoUpdate({target:L8.id,set:{email:B.email,url:F,access_token:B.accessToken,refresh_token:B.refreshToken,token_expiry:B.expiry}}).run(),X(z,B.id,B.orgID)}).pipe(T.asVoid));return xQ.of({active:Q,list:G,remove:W,use:K,getRow:V,persistToken:U,persistAccount:H})}));class Uq extends O.Class("RemoteConfig")({config:O.Record(O.String,O.Json)}){}var gQ=O.Number.pipe(O.decodeTo(O.Duration,{decode:nV.transform(($)=>J8.seconds($)),encode:nV.transform(($)=>J8.toSeconds($))}));class Hq extends O.Class("TokenRefresh")({access_token:gY,refresh_token:x7,expires_in:gQ}){}class Bq extends O.Class("DeviceAuth")({device_code:h7,user_code:uY,verification_uri_complete:O.String,expires_in:gQ,interval:gQ}){}class zq extends O.Class("DeviceTokenSuccess")({access_token:gY,refresh_token:x7,token_type:O.Literal("Bearer"),expires_in:gQ}){}class tV extends O.Class("DeviceTokenError")({error:O.String,error_description:O.String}){toPollResult(){if(this.error==="authorization_pending")return new m7;if(this.error==="slow_down")return new l7;if(this.error==="expired_token")return new d7;if(this.error==="access_denied")return new p7;return new c7({cause:this.error})}}var Qi=O.Union([zq,tV]);class Fq extends O.Class("User")({id:hY,email:O.String}){}class sV extends O.Class("ClientId")({client_id:O.String}){}class rV extends O.Class("DeviceTokenRequest")({grant_type:O.String,device_code:h7,client_id:O.String}){}class aV extends O.Class("TokenRefreshRequest")({grant_type:O.String,refresh_token:x7,client_id:O.String}){}var iV="opencode-cli",Gi=J8.minutes(5),Wi=J8.toMillis(Gi),Gq=($,Z)=>$!=null&&$>Z+Wi,o8=($="Account service operation failed")=>(Z)=>Z.pipe(T.mapError((J)=>Ki(J,$))),Ki=($,Z)=>{if($ instanceof RZ||$ instanceof q5)return $;if(Wq.isHttpClientError($))switch($.reason._tag){case"TransportError":return q5.fromHttpClientError($.reason);default:return new RZ({message:Z,cause:$})}return new RZ({message:Z,cause:$})};class uQ extends S1.Service()("@qitqode/Account"){}var Aq=R0.effect(uQ,T.gen(function*(){let $=yield*i7.Service,Z=yield*hQ.HttpClient,J=Vq(Z),Y=hQ.filterStatusOk(Z),X=hQ.filterStatusOk(J),Q=(R)=>J.execute(R).pipe(o8("HTTP request failed")),G=(R)=>X.execute(R).pipe(o8("HTTP request failed")),W=(R)=>R.pipe(T.flatMap((L)=>Y.execute(L)),o8("HTTP request failed")),K=(R)=>R.pipe(T.flatMap((L)=>Z.execute(L)),o8("HTTP request failed")),V=T.fnUntraced(function*(R){let L=yield*n7.currentTimeMillis,C=yield*W(U$.post(`${R.url}/auth/device/token`).pipe(U$.acceptJson,U$.schemaBodyJson(aV)(new aV({grant_type:"refresh_token",refresh_token:R.refresh_token,client_id:iV})))),_=yield*PZ.schemaBodyJson(Hq)(C).pipe(o8("Failed to decode response")),E=O1.some(L+J8.toMillis(_.expires_in));return yield*$.persistToken({accountID:R.id,accessToken:_.access_token,refreshToken:_.refresh_token,expiry:E}),_.access_token}),U=yield*oV.make({capacity:Number.POSITIVE_INFINITY,timeToLive:J8.zero,lookup:T.fnUntraced(function*(R){let L=yield*$.getRow(R);if(O1.isNone(L))return yield*T.fail(new RZ({message:"Account not found during token refresh"}));let C=L.value,_=yield*n7.currentTimeMillis;if(Gq(C.token_expiry,_))return C.access_token;return yield*V(C)})}),H=T.fnUntraced(function*(R){let L=yield*n7.currentTimeMillis;if(Gq(R.token_expiry,L))return R.access_token;return yield*oV.get(U,R.id)}),B=T.fnUntraced(function*(R){let L=yield*$.getRow(R);if(O1.isNone(L))return O1.none();let C=L.value,_=yield*H(C);return O1.some({account:C,accessToken:_})}),z=T.fnUntraced(function*(R,L){let C=yield*G(U$.get(`${R}/api/orgs`).pipe(U$.acceptJson,U$.bearerToken(L)));return yield*PZ.schemaBodyJson(O.Array(lY))(C).pipe(o8("Failed to decode response"))}),F=T.fnUntraced(function*(R,L){let C=yield*G(U$.get(`${R}/api/user`).pipe(U$.acceptJson,U$.bearerToken(L)));return yield*PZ.schemaBodyJson(Fq)(C).pipe(o8("Failed to decode response"))}),A=T.fn("Account.token")((R)=>B(R).pipe(T.map(O1.map((L)=>L.accessToken)))),N=T.fn("Account.activeOrg")(function*(){let R=yield*$.active();if(O1.isNone(R))return O1.none();let L=R.value;if(!L.active_org_id)return O1.none();let _=(yield*w(L.id)).find((E)=>E.id===L.active_org_id);if(!_)return O1.none();return O1.some({account:L,org:_})}),q=T.fn("Account.orgsByAccount")(function*(){let R=yield*$.list();return yield*T.forEach(R,(L)=>w(L.id).pipe(T.catch(()=>T.succeed([])),T.map((C)=>({account:L,orgs:C}))),{concurrency:3})}),w=T.fn("Account.orgs")(function*(R){let L=yield*B(R);if(O1.isNone(L))return[];let{account:C,accessToken:_}=L.value;return yield*z(C.url,_)}),j=T.fn("Account.config")(function*(R,L){let C=yield*B(R);if(O1.isNone(C))return O1.none();let{account:_,accessToken:E}=C.value,f=yield*Q(U$.get(`${_.url}/api/config`).pipe(U$.acceptJson,U$.bearerToken(E),U$.setHeaders({"x-org-id":L})));if(f.status===404)return O1.none();let b=yield*PZ.filterStatusOk(f).pipe(o8()),k=yield*PZ.schemaBodyJson(Uq)(b).pipe(o8("Failed to decode response"));return O1.some(k.config)}),M=T.fn("Account.login")(function*(R){let L=yQ(R),C=yield*W(U$.post(`${L}/auth/device/code`).pipe(U$.acceptJson,U$.schemaBodyJson(sV)(new sV({client_id:iV})))),_=yield*PZ.schemaBodyJson(Bq)(C).pipe(o8("Failed to decode response"));return new dY({code:_.device_code,user:_.user_code,url:`${L}${_.verification_uri_complete}`,server:L,expiry:_.expires_in,interval:_.interval})}),I=T.fn("Account.poll")(function*(R){let L=yield*K(U$.post(`${R.server}/auth/device/token`).pipe(U$.acceptJson,U$.schemaBodyJson(rV)(new rV({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:R.code,client_id:iV})))),C=yield*PZ.schemaBodyJson(Qi)(L).pipe(o8("Failed to decode response"));if(C instanceof tV)return C.toPollResult();let _=C.access_token,E=F(R.server,_),f=z(R.server,_),[b,k]=yield*T.all([E,f],{concurrency:2}),u=k.length>0?O1.some(k[0].id):O1.none(),g=(yield*n7.currentTimeMillis)+J8.toMillis(C.expires_in),c=C.refresh_token;return yield*$.persistAccount({id:b.id,email:b.email,url:R.server,accessToken:_,refreshToken:c,expiry:g,orgID:u}),new u7({email:b.email})});return uQ.of({active:$.active,activeOrg:N,list:$.list,orgsByAccount:q,remove:$.remove,use:$.use,orgs:w,config:j,token:A,login:M,poll:I})})),Vi=Aq.pipe(R0.provide(i7.layer),R0.provide(Kq.layer));import Ui from"path";async function Nq(){let $=["qitqode.jsonc","qitqode.json","config.json"].map((Z)=>Ui.join(A0.Path.config,Z));for(let Z of $)if(await s0.exists(Z))return Z;return $[0]}function eV($,Z,J=[]){if(!Y8(Z)){let Y=Oq($,J,Z,{formattingOptions:{insertSpaces:!0,tabSize:2}});return jq($,Y)}return Object.entries(Z).reduce((Y,[X,Q])=>{if(Q===void 0)return Y;return eV(Y,Q,[...J,X])},$)}function s7($){let{plugin_origins:Z,mcp_origins:J,...Y}=$;return Y}var Hi=_0.create({service:"config.sources"});function qq($,Z){if(!Y8($))return $;let J={...$};if(!(("theme"in J)||("keybinds"in J)||("tui"in J)))return J;return delete J.theme,delete J.keybinds,delete J.tui,Hi.warn("tui keys in qitqode config are deprecated; move them to tui.json",{path:Z}),J}async function Mq($,Z){if(!$.plugin)return $;for(let J=0;J<$.plugin.length;J++)$.plugin[J]=await s8.resolvePluginSpec($.plugin[J],Z);return $}var Bi=_0.create({service:"config.loader"});function Dq($){let Z=T.fnUntraced(function*(X){return yield*$.fs.readFileString(X).pipe(T.catchIf((Q)=>Q.reason._tag==="NotFound",()=>T.succeed(void 0)),T.orDie)}),J=T.fnUntraced(function*(X,Q){let G="path"in Q?Q.path:Q.source,W=yield*T.promise(()=>$U.substitute("path"in Q?{text:X,type:"path",path:Q.path}:{text:X,type:"virtual",...Q})),K=r8.jsonc(W,G),V=r8.schema($.info,qq(K,G),G);if(!("path"in Q))return V;if(yield*T.promise(()=>Mq(V,Q.path)),!V.$schema){V.$schema="https://opencode.ai/config.json";let U=X.replace(/^\s*\{/,`{
|
|
487
|
+
"$schema": "https://opencode.ai/config.json",`);yield*$.fs.writeFileString(Q.path,U).pipe(T.catch(()=>T.void))}return V}),Y=T.fnUntraced(function*(X){Bi.info("loading",{path:X});let Q=yield*Z(X);if(!Q)return{};return yield*J(Q,{path:X})});return{readConfigFile:Z,loadConfig:J,loadFile:Y}}import pY from"path";import{pathToFileURL as zi}from"url";import ZU from"fs/promises";function Lq($){return T.fnUntraced(function*(){let Z=wq({},q1(yield*$(pY.join(A0.Path.config,"config.json"))),q1(yield*$(pY.join(A0.Path.config,"qitqode.json"))),q1(yield*$(pY.join(A0.Path.config,"qitqode.jsonc")))),J=pY.join(A0.Path.config,"config");if(!(yield*T.promise(()=>ZU.access(J).then(()=>!0,()=>!1))))return Z;return yield*T.promise(()=>import(zi(J).href,{with:{type:"toml"}}).then(async(X)=>{let{provider:Q,model:G,...W}=X.default;if(Q&&G)Z.model=`${Q}/${G}`;Z.$schema="https://opencode.ai/config.json",Z=q1(Z,W),await ZU.writeFile(pY.join(A0.Path.config,"config.json"),JSON.stringify(Z,null,2)),await ZU.unlink(J)}).catch(()=>{})),Z})}import fZ from"path";import ir from"os";function mQ($,Z){let J=q1($,Z);if($.instructions&&Z.instructions)J.instructions=Array.from(new Set([...$.instructions,...Z.instructions]));return J}var CZ={};F1(CZ,{redactString:()=>Pq,redactCommand:()=>qi,fromClaude:()=>Ni,Remote:()=>QU,OAuth:()=>XU,Local:()=>YU,Info:()=>Fi,ConfigMCP:()=>CZ});class YU extends O.Class("McpLocalConfig")({type:O.Literal("local").annotate({description:"Type of MCP server connection"}),command:O.mutable(O.Array(O.String)).annotate({description:"Command and arguments to run the MCP server"}),environment:O.optional(O.Record(O.String,O.String)).annotate({description:"Environment variables to set when running the MCP server"}),enabled:O.optional(O.Boolean).annotate({description:"Enable or disable the MCP server on startup"}),timeout:O.optional(O.Number).annotate({description:"Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified."})}){static zod=w0(this)}class XU extends O.Class("McpOAuthConfig")({clientId:O.optional(O.String).annotate({description:"OAuth client ID. If not provided, dynamic client registration (RFC 7591) will be attempted."}),clientSecret:O.optional(O.String).annotate({description:"OAuth client secret (if required by the authorization server)"}),scope:O.optional(O.String).annotate({description:"OAuth scopes to request during authorization"}),redirectUri:O.optional(O.String).annotate({description:"OAuth redirect URI (default: http://127.0.0.1:19876/mcp/oauth/callback)."})}){static zod=w0(this)}class QU extends O.Class("McpRemoteConfig")({type:O.Literal("remote").annotate({description:"Type of MCP server connection"}),url:O.String.annotate({description:"URL of the remote MCP server"}),enabled:O.optional(O.Boolean).annotate({description:"Enable or disable the MCP server on startup"}),headers:O.optional(O.Record(O.String,O.String)).annotate({description:"Headers to send with the request"}),oauth:O.optional(O.Union([XU,O.Literal(!1)])).annotate({description:"OAuth authentication configuration for the MCP server. Set to false to disable OAuth auto-detection."}),timeout:O.optional(O.Number).annotate({description:"Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified."})}){static zod=w0(this)}var Fi=O.Union([YU,QU]).annotate({discriminator:"type"}).pipe(g0(($)=>({zod:w0($)}))),Tq=new Set(["http","streamable-http","remote"]),Rq=new Set(["stdio","local"]),Ai=["authorization","token","api_key","apikey","key","secret","password","credential"];function JU($){if(!Y8($))return;return Object.fromEntries(Object.entries($).filter((Z)=>typeof Z[1]==="string"))}function Oi($){return Ai.some((Z)=>$.toLowerCase().includes(Z))}function ji($){if($===!1)return!1;if(!Y8($))return;let Z={...typeof $.clientId==="string"&&{clientId:$.clientId},...typeof $.clientSecret==="string"&&{clientSecret:$.clientSecret},...typeof $.scope==="string"&&{scope:$.scope},...typeof $.redirectUri==="string"&&{redirectUri:$.redirectUri}};return Object.keys(Z).length>0?Z:void 0}function Ni($,Z){if(!Y8(Z))return{warning:`skipped Claude Code MCP server "${$}"; server config is not an object.`};if(Z.type==="sse")return{warning:`skipped Claude Code MCP server "${$}"; unsupported transport "sse".`};if(Z.args!==void 0&&!Array.isArray(Z.args))return{warning:`skipped Claude Code MCP server "${$}"; args is not an array.`};let J=Array.isArray(Z.args)?Z.args:[];if(!J.every((W)=>typeof W==="string"))return{warning:`skipped Claude Code MCP server "${$}"; args must contain only strings.`};let Y=Z.disabled===!0?!1:Z.enabled===!1?!1:!0,X=JU(Z.environment)??JU(Z.env),Q=typeof Z.timeout==="number"?Z.timeout:void 0,G=typeof Z.type==="string"?Z.type:void 0;if(typeof Z.command==="string"&&(!G||Rq.has(G)))return{config:{type:"local",command:[Z.command,...J],...X&&{environment:X},enabled:Y,...Q!==void 0&&{timeout:Q}}};if(Z.command!==void 0)return{warning:`skipped Claude Code MCP server "${$}"; command is not a string.`};if(typeof Z.url==="string"&&(!G||Tq.has(G))){let W=JU(Z.headers),K=ji(Z.oauth);return{config:{type:"remote",url:Z.url,enabled:Y,...W&&{headers:W},...K!==void 0&&{oauth:K},...Q!==void 0&&{timeout:Q}}}}if(Z.url!==void 0)return{warning:`skipped Claude Code MCP server "${$}"; url is not a string.`};if(G&&!Rq.has(G)&&!Tq.has(G))return{warning:`skipped Claude Code MCP server "${$}"; unsupported transport "${G}".`};return{warning:`skipped Claude Code MCP server "${$}"; missing command or url.`}}function Pq($){return $.replace(/(Bearer\s+)[^\s]+/gi,"$1****").replace(/([?&][^=\s&]*(?:authorization|token|api[_-]?key|apikey|key|secret|password|credential)[^=\s&]*=)[^&\s]+/gi,"$1****").replace(/((?:authorization|token|api[_-]?key|apikey|key|secret|password|credential)=)[^\s]+/gi,"$1****")}function qi($){return $.map((Z,J)=>{if(J>0&&Oi($[J-1]))return"****";return Pq(Z)})}var GU=_0.create({service:"config.sources"});function Cq($){let Z=(G,W,K,V)=>{if(!K.mcp)return G;return{...G,mcp_origins:{...G.mcp_origins??{},...Object.fromEntries(Object.keys(K.mcp).map((U)=>[U,{type:V,source:W}]))}}},J=T.fnUntraced(function*(G,W,K,V){if(!K?.length)return G;let U=V??(yield*$.resolvePluginScope(W)),H=s8.deduplicatePluginOrigins([...G.plugin_origins??[],...K.map((B)=>({spec:B,source:W,scope:U}))]);return{...G,plugin:H.map((B)=>B.spec),plugin_origins:H}}),Y=T.fnUntraced(function*(G,W,K,V){let U=mQ(G,K),H=Z(U,W,K,"qitqode");return yield*J(H,W,K.plugin,V)}),X=T.fnUntraced(function*(G){let W=yield*$.readConfigFile(G);if(!W)return;return yield*T.try({try:()=>JSON.parse(W),catch:()=>Error(`failed to parse ${G}; Claude Code MCP compatibility skipped.`)}).pipe(T.tapError((K)=>T.sync(()=>GU.warn(K.message))),T.option,T.map(O1.getOrUndefined))}),Q=T.fnUntraced(function*(G,W){let K=yield*X(W);if(!Y8(K)||!Y8(K.mcpServers))return G;let V=G;for(let[U,H]of Object.entries(K.mcpServers)){if(V.mcp?.[U]&&V.mcp_origins?.[U]?.type!=="claude"){GU.info(`skipped Claude Code MCP server "${U}"; native qitqode MCP with same name already exists.`);continue}let z=CZ.fromClaude(U,H);if("warning"in z){GU.warn(z.warning);continue}let F=r8.schema($.info,{mcp:{[U]:z.config}},W);V={...V,mcp:{...V.mcp??{},[U]:F.mcp[U]},mcp_origins:{...V.mcp_origins??{},[U]:{type:"claude",source:W}}}}return V});return{merge:Y,mergeMcpOrigins:Z,mergePluginOrigins:J,mergeClaudeMcp:Q}}function Iq($,Z){let J=$;for(let[Y,X]of Object.entries(J.mode??{}))J.agent=q1(J.agent??{},{[Y]:{...X,mode:"primary"}});if(Z.permissionOverride)J.permission=q1(J.permission??{},JSON.parse(Z.permissionOverride));if(J.tools){let Y={};for(let[X,Q]of Object.entries(J.tools)){let G=Q?"allow":"deny";if(X==="write"||X==="edit"||X==="patch"||X==="multiedit"){Y.edit=G;continue}Y[X]=G}J.permission=q1(Y,J.permission??{})}if(!J.username)J.username=Z.username;if(J.autoshare===!0&&!J.share)J.share="auto";if(Z.disableAutoCompact)J.compaction={...J.compaction,auto:!1};if(Z.disablePrune)J.compaction={...J.compaction,prune:!1};return J}var c6={};F1(c6,{loadMode:()=>hr,load:()=>xr,Info:()=>_U,ConfigAgent:()=>c6});import Eq from"path";function Mi($,Z){let J=$.replaceAll("\\","/");for(let Y of Z){let X=J.indexOf(Y);if(X===-1)continue;return J.slice(X+Y.length)}}function bq($,Z){let J=Mi($,Z)??Eq.basename($),Y=Eq.extname(J);return Y.length?J.slice(0,-Y.length):J}var bU={};F1(bU,{shell:()=>Rr,parse:()=>EU,files:()=>Tr,fallbackSanitization:()=>aD,SHELL_REGEX:()=>rD,FrontmatterError:()=>eY,FILE_REGEX:()=>sD});var IU=m6(oD(),1);var sD=/(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g,rD=/!`([^`]+)`/g;function Tr($){return Array.from($.matchAll(sD))}function Rr($){return Array.from($.matchAll(rD))}function aD($){let Z=$.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!Z)return $;let J=Z[1],Y=J.split(/\r?\n/),X=[];for(let G of Y){if(G.trim().startsWith("#")||G.trim()===""){X.push(G);continue}if(G.match(/^\s+/)){X.push(G);continue}let W=G.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*:\s*(.*)$/);if(!W){X.push(G);continue}let K=W[1],V=W[2].trim();if(V===""||V===">"||V==="|"||V.startsWith('"')||V.startsWith("'")){X.push(G);continue}if(V.includes(":")){X.push(`${K}: |-`),X.push(` ${V}`);continue}X.push(G)}let Q=X.join(`
|
|
488
|
+
`);return $.replace(J,()=>Q)}async function EU($){let Z=await s0.readText($);try{return IU.default(Z,{})}catch(J){let Y=aD(Z);if(Y===Z)throw new eY({path:$,message:`${$}: Failed to parse YAML frontmatter: ${J instanceof Error?J.message:String(J)}`},{cause:J});try{return IU.default(Y,{})}catch(X){throw new eY({path:$,message:`${$}: Failed to parse YAML frontmatter: ${X instanceof Error?X.message:String(X)}`},{cause:X})}}}var eY=N1.create("ConfigFrontmatterError",D.object({path:D.string(),message:D.string()}));var Pr=_0.create({service:"config"});function $X($,Z,J,Y){let X=$.safeParse(Z);if(X.success)return X.data;if(Y?.ignoreInvalid)return;throw new tD({path:J,issues:X.error.issues},{cause:X.error})}async function ZX($){for(let Z of await $4.scan($.glob,{cwd:$.dir,absolute:!0,dot:!0,symlink:!0})){let J=await EU(Z).catch(async(Q)=>{let G=eY.isInstance(Q)?Q.data.message:`Failed to parse ${$.entity} ${Z}`,{Session:W}=await import("./chunk-08g14hmz.js");d1.publish(W.Event.Error,{error:new N1.Unknown({message:G}).toObject()}),Pr.error(`failed to load ${$.entity}`,{[$.entity]:Z,err:Q});return});if(!J)continue;let X={name:bq(Z,$.namePatterns),...J.data,[$.contentKey]:J.content.trim()};$.store(X,Z)}}var T8=O.String.annotate({[A$]:P.string().meta({$ref:"https://models.dev/model-schema.json#/$defs/Model"})}).pipe(g0(($)=>({zod:w0($)})));var _Z={};F1(_Z,{Rule:()=>R8,Object:()=>$w,Info:()=>_r,ConfigPermission:()=>_Z,Action:()=>p6});var p6=O.Literals(["ask","allow","deny"]).annotate({identifier:"PermissionActionConfig"}).pipe(g0(($)=>({zod:w0($)}))),$w=O.Record(O.String,p6).annotate({identifier:"PermissionObjectConfig"}).pipe(g0(($)=>({zod:w0($)}))),R8=O.Union([p6,$w]).annotate({identifier:"PermissionRuleConfig"}).pipe(g0(($)=>({zod:w0($)}))),Cr=($)=>{if(typeof $==="object"&&$!==null&&!Array.isArray($))return{__originalKeys:globalThis.Object.keys($),...$};return $},Ir=O.StructWithRest(O.Struct({__originalKeys:O.optional(O.mutable(O.Array(O.String))),read:O.optional(R8),edit:O.optional(R8),glob:O.optional(R8),grep:O.optional(R8),list:O.optional(R8),bash:O.optional(R8),task:O.optional(R8),actor:O.optional(R8),external_directory:O.optional(R8),question:O.optional(p6),webfetch:O.optional(p6),websearch:O.optional(p6),codesearch:O.optional(p6),lsp:O.optional(R8),doom_loop:O.optional(p6),skill:O.optional(R8)}),[O.Record(O.String,R8)]),Er=O.Union([Ir,p6]).annotate({[eD]:Cr}),br=($)=>{if(typeof $==="string")return{"*":$};let Z=$,{__originalKeys:J,...Y}=Z;if(!J)return Y;let X={};for(let Q of J)if(Q in Y)X[Q]=Y[Q];return X},_r=w0(Er).transform(br).meta({ref:"PermissionConfig"});var Zw=O.Number.check(O.isInt()).check(O.isGreaterThan(0)),Sr=O.Union([O.String.check(O.isPattern(/^#[0-9a-fA-F]{6}$/)),O.Literals(["primary","secondary","accent","success","warning","error","info"])]),fr=O.Any.annotate({[A$]:_Z.Info}),kr=O.StructWithRest(O.Struct({model:O.optional(T8).annotate({description:"Model for this agent: a literal provider/model (e.g. anthropic/claude-opus-4-8) or a tier/group name (e.g. fast/economical/default/power). Names without a '/' are resolved as model groups, provider-aware, at spawn time."}),variant:O.optional(O.String).annotate({description:"Default model variant for this agent (applies only when using the agent's configured model)."}),temperature:O.optional(O.Number),top_p:O.optional(O.Number),prompt:O.optional(O.String),tools:O.optional(O.Record(O.String,O.Boolean)).annotate({description:"@deprecated Use 'permission' field instead"}),disable:O.optional(O.Boolean),description:O.optional(O.String).annotate({description:"Description of when to use the agent"}),mode:O.optional(O.Literals(["subagent","primary","all"])),hidden:O.optional(O.Boolean).annotate({description:"Hide this subagent from the @ autocomplete menu (default: false, only applies to mode: subagent)"}),options:O.optional(O.Record(O.String,O.Any)),color:O.optional(Sr).annotate({description:"Hex color code (e.g., #FF5733) or theme color (e.g., primary)"}),steps:O.optional(Zw).annotate({description:"Maximum number of agentic iterations before forcing text-only response"}),tool_allowlist:O.optional(O.Array(O.String)).annotate({description:"Optional list of tool IDs allowed for this agent. When set, only these tools are available."}),maxSteps:O.optional(Zw).annotate({description:"@deprecated Use 'steps' field instead."}),permission:O.optional(fr)}),[O.Record(O.String,O.Any)]),vr=new Set(["name","model","variant","prompt","description","temperature","top_p","mode","hidden","color","steps","maxSteps","options","permission","disable","tools","tool_allowlist"]),yr=($)=>{let Z={...$.options};for(let[Y,X]of Object.entries($))if(!vr.has(Y))Z[Y]=X;let J={};for(let[Y,X]of Object.entries($.tools??{})){let Q=X?"allow":"deny";if(Y==="write"||Y==="edit"||Y==="patch"||Y==="multiedit"){J.edit=Q;continue}if(Y==="task"){J.actor=Q;continue}J[Y]=Q}return globalThis.Object.assign(J,$.permission),{...$,options:Z,permission:J,steps:$.steps??$.maxSteps}},_U=w0(kr).transform(yr).meta({ref:"AgentConfig"});async function xr($){let Z={};return await ZX({dir:$,glob:"{agent,agents}/**/*.md",entity:"agent",namePatterns:["/.qitqode/agent/","/.qitqode/agents/","/agent/","/agents/"],contentKey:"prompt",store:(J,Y)=>{Z[J.name]=$X(_U,J,Y)}}),Z}async function hr($){let Z={};return await ZX({dir:$,glob:"{mode,modes}/*.md",entity:"mode",namePatterns:[],contentKey:"prompt",store:(J,Y)=>{let X=$X(_U,J,Y,{ignoreInvalid:!0});if(X)Z[J.name]={...X,mode:"primary"}}}),Z}var i6={};F1(i6,{load:()=>gr,Info:()=>Jw,ConfigCommand:()=>i6});var Jw=O.Struct({template:O.String,description:O.optional(O.String),agent:O.optional(O.String),model:O.optional(T8),subtask:O.optional(O.Boolean)}).pipe(g0(($)=>({zod:w0($)})));async function gr($){let Z={};return await ZX({dir:$,glob:"{command,commands}/**/*.md",entity:"command",namePatterns:["/.qitqode/command/","/.qitqode/commands/","/.claude/command/","/.claude/commands/","/command/","/commands/"],contentKey:"template",store:(J,Y)=>{Z[J.name]=$X(Jw.zod,J,Y)}}),Z}var P5={};F1(P5,{readManagedPreferences:()=>cr,parseManagedPlist:()=>Gw,managedConfigDirs:()=>Qw,managedConfigDir:()=>pr,ConfigManaged:()=>P5});import ur from"os";import SU from"path";var Yw=_0.create({service:"config"}),mr="ai.qitqode.managed",lr="ai.opencode.managed",dr=new Set(["PayloadDisplayName","PayloadIdentifier","PayloadType","PayloadUUID","PayloadVersion","_manualProfile"]);function Xw($="qitqode"){switch(process.platform){case"darwin":return`/Library/Application Support/${$}`;case"win32":return SU.join(process.env.ProgramData||"C:\\ProgramData",$);default:return`/etc/${$}`}}function pr(){return Qw().at(-1)}function Qw(){let $=process.env.QITQODE_TEST_MANAGED_CONFIG_DIR;if($)return[$];return[Xw("opencode"),Xw()]}function Gw($){let Z=JSON.parse($);for(let J of Object.keys(Z))if(dr.has(J))delete Z[J];return JSON.stringify(Z)}async function cr(){if(process.platform!=="darwin")return;let $=ur.userInfo().username,Z=[lr,mr].flatMap((J)=>[SU.join("/Library/Managed Preferences",$,`${J}.plist`),SU.join("/Library/Managed Preferences",`${J}.plist`)]);for(let J of Z){if(!await s0.exists(J))continue;Yw.info("reading macOS managed preferences",{path:J});let Y=await f1.run(["plutil","-convert","json","-o","-",J],{nothrow:!0});if(Y.code!==0){Yw.warn("failed to convert managed preferences plist",{path:J});continue}return{source:`mobileconfig:${J}`,text:Gw(Y.stdout.toString())}}return}var SZ=_0.create({service:"config"}),Ww=["node_modules","package.json","package-lock.json","bun.lock",".gitignore","/plans/"],nr=T.fn("Config.ensureGitignore")(function*($){let Z=yield*w$.Service,J=fZ.join($,".gitignore");if(!(yield*Z.existsSafe(J))){yield*Z.writeFileString(J,Ww.join(`
|
|
489
|
+
`)+`
|
|
490
|
+
`).pipe(T.catchIf((V)=>V.reason?._tag==="PermissionDenied",()=>T.void));return}let X=yield*Z.readFileString(J),Q=new Set(X.split(`
|
|
491
|
+
`).map((V)=>V.trim())),G=Ww.filter((V)=>!Q.has(V));if(G.length===0)return;let W=!X.endsWith(`
|
|
492
|
+
`),K=X+(W?`
|
|
493
|
+
`:"")+G.join(`
|
|
494
|
+
`)+`
|
|
495
|
+
`;yield*Z.writeFileString(J,K).pipe(T.catchIf((V)=>V.reason?._tag==="PermissionDenied",()=>T.void))});function Uw($){let{fs:Z,authSvc:J,accountSvc:Y,env:X,npmSvc:Q,readConfigFile:G,loadConfig:W,loadFile:K,getGlobal:V}=$;return{loadInstanceState:T.fn("Config.loadInstanceState")(function*(H){let B=yield*J.all().pipe(T.orDie),z={},F=new Set,A,N=T.fnUntraced(function*(L){if(L.startsWith("http://")||L.startsWith("https://"))return"global";if(L==="QITQODE_CONFIG_CONTENT")return"local";if(yield*Kw.use((C)=>T.succeed(S8.containsPath(L,C))))return"local";return"global"}),q=Cq({info:$.info,readConfigFile:G,resolvePluginScope:N});for(let[L,C]of Object.entries(B))if(C.type==="wellknown"){let _=L.replace(/\/+$/,"");process.env[C.key]=C.token,SZ.debug("fetching remote config",{url:`${_}/.well-known/opencode`});let E=yield*T.promise(()=>fetch(`${_}/.well-known/opencode`,{signal:AbortSignal.timeout(1000)}));if(!E.ok)throw Error(`failed to fetch remote config from ${_}: ${E.status}`);let b=(yield*T.promise(()=>E.json())).config??{};if(!b.$schema)b.$schema="https://opencode.ai/config.json";let k=`${_}/.well-known/opencode`,u=yield*W(JSON.stringify(b),{dir:fZ.dirname(k),source:k});z=yield*q.merge(z,k,u,"global"),SZ.debug("loaded remote config from well-known",{url:_})}let w=yield*V();if(z=yield*q.merge(z,A0.Path.config,w,"global"),S0.QITQODE_CONFIG)z=yield*q.merge(z,S0.QITQODE_CONFIG,yield*K(S0.QITQODE_CONFIG)),SZ.debug("loaded custom config",{path:S0.QITQODE_CONFIG});if(!S0.QITQODE_DISABLE_PROJECT_CONFIG)for(let L of yield*JX.files("qitqode",H.directory,H.worktree).pipe(T.orDie))z=yield*q.merge(z,L,yield*K(L),"local");z.agent=z.agent||{},z.mode=z.mode||{},z.plugin=z.plugin||[];let j=yield*JX.directories(H.directory,H.worktree);if(S0.QITQODE_CONFIG_DIR)SZ.debug("loading config from QITQODE_CONFIG_DIR",{path:S0.QITQODE_CONFIG_DIR});let M=[];for(let L of yield*JX.claudeCommandDirectories(H.directory,H.worktree))z.command=q1(z.command??{},yield*T.promise(()=>i6.load(L)));for(let L of j){if(L.endsWith(".qitqode")||L===S0.QITQODE_CONFIG_DIR)for(let E of["qitqode.json","qitqode.jsonc"]){let f=fZ.join(L,E);SZ.debug(`loading config from ${f}`),z=yield*q.merge(z,f,yield*K(f)),z.agent??={},z.mode??={},z.plugin??=[]}yield*nr(L).pipe(T.orDie);let C=yield*Vw.install({fs:Z,npm:Q,dir:L}).pipe(T.exit,T.tap((E)=>BQ.isFailure(E)?T.sync(()=>{SZ.warn("background dependency install failed",{dir:L,error:String(E.cause)})}):T.void),T.asVoid,T.forkDetach);M.push(C),z.command=q1(z.command??{},yield*T.promise(()=>i6.load(L))),z.agent=q1(z.agent??{},yield*T.promise(()=>c6.load(L))),z.agent=q1(z.agent??{},yield*T.promise(()=>c6.loadMode(L)));let _=yield*T.promise(()=>s8.load(L));z=yield*q.mergePluginOrigins(z,L,_)}if(process.env.QITQODE_CONFIG_CONTENT){let C=yield*W(process.env.QITQODE_CONFIG_CONTENT,{dir:H.directory,source:"QITQODE_CONFIG_CONTENT"});z=yield*q.merge(z,"QITQODE_CONFIG_CONTENT",C,"local"),SZ.debug("loaded custom config from QITQODE_CONFIG_CONTENT")}let I=O1.getOrUndefined(yield*Y.active().pipe(T.catch(()=>T.succeed(O1.none()))));if(I?.active_org_id){let{id:L,active_org_id:C,url:_}=I;yield*T.gen(function*(){let[E,f]=yield*T.all([Y.config(L,C),Y.token(L)],{concurrency:2});if(O1.isSome(f))process.env.QITQODE_CONSOLE_TOKEN=f.value,yield*X.set("QITQODE_CONSOLE_TOKEN",f.value);if(O1.isSome(E)){let b=`${_}/api/config`,k=yield*W(JSON.stringify(E.value),{dir:fZ.dirname(b),source:b});for(let u of Object.keys(k.provider??{}))F.add(u);z=yield*q.merge(z,b,k,"global")}}).pipe(T.withSpan("Config.loadActiveOrgConfig"),T.catch((E)=>{return SZ.debug("failed to fetch remote account config",{error:E instanceof Error?E.message:String(E)}),T.void}))}for(let L of P5.managedConfigDirs()){if(!(yield*T.promise(()=>s0.exists(L))))continue;for(let C of["qitqode.json","qitqode.jsonc"]){let _=fZ.join(L,C);z=yield*q.merge(z,_,yield*K(_),"global")}}let R=yield*T.promise(()=>P5.readManagedPreferences());if(R){let L=yield*W(R.text,{dir:fZ.dirname(R.source),source:R.source});z=q.mergeMcpOrigins(mQ(z,L),R.source,L,"qitqode")}if(!S0.QITQODE_DISABLE_CLAUDE_CODE_MCP)z=yield*q.mergeClaudeMcp(z,fZ.join(A0.Path.home,".claude.json")),z=yield*q.mergeClaudeMcp(z,fZ.join(H.directory,".claude.json"));return z=Iq(z,{username:ir.userInfo().username,permissionOverride:S0.QITQODE_PERMISSION,disableAutoCompact:S0.QITQODE_DISABLE_AUTOCOMPACT,disablePrune:S0.QITQODE_DISABLE_PRUNE}),{config:z,directories:j,deps:M,consoleState:{consoleManagedProviders:Array.from(F),activeOrgName:A,switchableOrgCount:0}}},T.provideService(w$.Service,Z))}}var C5={};F1(C5,{Layout:()=>or,ConfigLayout:()=>C5});var or=O.Literals(["auto","stretch"]).annotate({identifier:"LayoutConfig"}).pipe(g0(($)=>({zod:w0($)})));var I5={};F1(I5,{Server:()=>Hw,ConfigServer:()=>I5});class Hw extends O.Class("ServerConfig")({port:O.optional(O.Number.check(O.isInt()).check(O.isGreaterThan(0))).annotate({description:"Port to listen on"}),hostname:O.optional(O.String).annotate({description:"Hostname to listen on"}),mdns:O.optional(O.Boolean).annotate({description:"Enable mDNS service discovery"}),mdnsDomain:O.optional(O.String).annotate({description:"Custom domain name for mDNS service (default: qitqode.local)"}),cors:O.optional(O.mutable(O.Array(O.String))).annotate({description:"Additional domains to allow for CORS"})}){static zod=w0(this)}var QJ={};F1(QJ,{Info:()=>sr,Entry:()=>Bw,ConfigFormatter:()=>QJ});var Bw=O.Struct({disabled:O.optional(O.Boolean),command:O.optional(O.mutable(O.Array(O.String))),environment:O.optional(O.Record(O.String,O.String)),extensions:O.optional(O.mutable(O.Array(O.String)))}).pipe(g0(($)=>({zod:w0($)}))),sr=O.Union([O.Boolean,O.Record(O.String,Bw)]).pipe(g0(($)=>({zod:w0($)})));var YX={};F1(YX,{Kind:()=>zw,Info:()=>rr,ConfigHistory:()=>YX});var zw=O.Literals(["user_text","assistant_text","tool_input","tool_error","reasoning","tool_output"]),rr=O.Struct({kinds:O.optional(O.Array(zw)).annotate({description:"Which part kinds the history FTS index should cover. Defaults to text (user/assistant) + tool input + tool errors. Add 'reasoning' or 'tool_output' to grow recall at the cost of database size. Note: enabling 'tool_output' reclassifies completed tools from kind='tool_input' to kind='tool_output' (input remains searchable in the body, but kind:['tool_input'] filter will then only match pending/error tools)."})});var GJ={};F1(GJ,{requiresExtensionsForCustomServers:()=>Ow,Info:()=>ar,Entry:()=>Aw,Disabled:()=>Fw,ConfigLSP:()=>GJ});var Fw=O.Struct({disabled:O.Literal(!0)}).pipe(g0(($)=>({zod:w0($)}))),Aw=O.Union([Fw,O.Struct({command:O.mutable(O.Array(O.String)),extensions:O.optional(O.mutable(O.Array(O.String))),disabled:O.optional(O.Boolean),env:O.optional(O.Record(O.String,O.String)),initialization:O.optional(O.Record(O.String,O.Unknown))})]).pipe(g0(($)=>({zod:w0($)}))),Ow=O.makeFilter(($)=>{if(typeof $==="boolean")return;let Z=new Set(Object.values(f7).map((Y)=>Y.id));return Object.entries($).every(([Y,X])=>{if("disabled"in X&&X.disabled)return!0;if(Z.has(Y))return!0;return"extensions"in X&&Boolean(X.extensions)})?void 0:"For custom LSP servers, 'extensions' array is required."}),ar=O.Union([O.Boolean,O.Record(O.String,Aw)]).check(Ow).pipe(g0(($)=>({zod:w0($)})));var WJ={};F1(WJ,{Model:()=>Nw,Info:()=>qw,ConfigProvider:()=>WJ});var jw=O.Number.check(O.isInt()).check(O.isGreaterThan(0)),Nw=O.Struct({id:O.optional(O.String),name:O.optional(O.String),family:O.optional(O.String),release_date:O.optional(O.String),attachment:O.optional(O.Boolean),reasoning:O.optional(O.Boolean),temperature:O.optional(O.Boolean),tool_call:O.optional(O.Boolean),interleaved:O.optional(O.Union([O.Literal(!0),O.Struct({field:O.Literals(["reasoning_content","reasoning_details"])})])),cost:O.optional(O.Struct({input:O.Number,output:O.Number,cache_read:O.optional(O.Number),cache_write:O.optional(O.Number),context_over_200k:O.optional(O.Struct({input:O.Number,output:O.Number,cache_read:O.optional(O.Number),cache_write:O.optional(O.Number)}))})),limit:O.optional(O.Struct({context:O.Number,input:O.optional(O.Number),output:O.Number})),modalities:O.optional(O.Struct({input:O.mutable(O.Array(O.Literals(["text","audio","image","video","pdf"]))),output:O.mutable(O.Array(O.Literals(["text","audio","image","video","pdf"])))})),experimental:O.optional(O.Boolean),status:O.optional(O.Literals(["alpha","beta","deprecated"])),cachePromptTTL:O.optional(O.Literals(["5m","1h"])).annotate({description:"Prompt-cache breakpoint TTL for Anthropic/OpenRouter. '1h' keeps the cached prefix alive for one hour (2x write cost) instead of the 5m default. Ignored by providers whose SDK doesn't support a cache TTL."}),provider:O.optional(O.Struct({npm:O.optional(O.String),api:O.optional(O.String)})),options:O.optional(O.Record(O.String,O.Any)),headers:O.optional(O.Record(O.String,O.String)),variants:O.optional(O.Record(O.String,O.StructWithRest(O.Struct({disabled:O.optional(O.Boolean).annotate({description:"Disable this variant for the model"})}),[O.Record(O.String,O.Any)])).annotate({description:"Variant-specific configuration"}))}).pipe(g0(($)=>({zod:w0($)})));class qw extends O.Class("ProviderConfig")({api:O.optional(O.String),name:O.optional(O.String),env:O.optional(O.mutable(O.Array(O.String))),id:O.optional(O.String),npm:O.optional(O.String),whitelist:O.optional(O.mutable(O.Array(O.String))),blacklist:O.optional(O.mutable(O.Array(O.String))),options:O.optional(O.StructWithRest(O.Struct({apiKey:O.optional(O.String),baseURL:O.optional(O.String),enterpriseUrl:O.optional(O.String).annotate({description:"GitHub Enterprise URL for copilot authentication"}),setCacheKey:O.optional(O.Boolean).annotate({description:"Enable promptCacheKey for this provider (default false)"}),timeout:O.optional(O.Union([jw,O.Literal(!1)]).annotate({description:"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout."})).annotate({description:"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout."}),chunkTimeout:O.optional(jw).annotate({description:"Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted."})}),[O.Record(O.String,O.Any)])),models:O.optional(O.Record(O.String,Nw))}){static zod=w0(this)}var KJ={};F1(KJ,{Info:()=>tr,ConfigSkills:()=>KJ});var tr=O.Struct({paths:O.optional(O.Array(O.String)).annotate({description:"Additional paths to skill folders"}),urls:O.optional(O.Array(O.String)).annotate({description:"URLs to fetch skills from (e.g., https://example.com/.well-known/skills/)"})}).pipe(g0(($)=>({zod:w0($)})));var a8=O.Any.annotate({[A$]:c6.Info}),er=O.Any.annotate({[A$]:_Z.Info}),$a=O.Any.annotate({[A$]:_0.Level}),l$=O.Number.check(O.isInt()).check(O.isGreaterThan(0)),E5=O.Number.check(O.isInt()).check(O.isGreaterThanOrEqualTo(0)),Za=O.Struct({$schema:O.optional(O.String).annotate({description:"JSON schema reference for configuration validation"}),logLevel:O.optional($a).annotate({description:"Log level"}),server:O.optional(I5.Server).annotate({description:"Server configuration for qitqode serve and web commands"}),command:O.optional(O.Record(O.String,i6.Info)).annotate({description:"Command configuration, see https://opencode.ai/docs/commands"}),skills:O.optional(KJ.Info).annotate({description:"Additional skill folder paths"}),watcher:O.optional(O.Struct({ignore:O.optional(O.mutable(O.Array(O.String)))})),snapshot:O.optional(O.Boolean).annotate({description:"Enable or disable snapshot tracking. When false, filesystem snapshots are not recorded and undoing or reverting will not undo/redo file changes. Defaults to true."}),plugin:O.optional(O.mutable(O.Array(s8.Spec))),share:O.optional(O.Literals(["manual","auto","disabled"])).annotate({description:"Control sharing behavior:'manual' allows manual sharing via commands, 'auto' enables automatic sharing, 'disabled' disables all sharing"}),autoshare:O.optional(O.Boolean).annotate({description:"@deprecated Use 'share' field instead. Share newly created sessions automatically"}),autoupdate:O.optional(O.Union([O.Boolean,O.Literal("notify")])).annotate({description:"Update behavior. Defaults to notifications only; set true to auto-install patch updates, false to disable checks, or 'notify' to show notifications"}),disabled_providers:O.optional(O.mutable(O.Array(O.String))).annotate({description:"Disable providers that are loaded automatically"}),enabled_providers:O.optional(O.mutable(O.Array(O.String))).annotate({description:"When set, ONLY these providers will be enabled. All other providers will be ignored"}),model:O.optional(T8).annotate({description:"Model to use in the format of provider/model, eg anthropic/claude-2"}),small_model:O.optional(T8).annotate({description:"Small model to use for tasks like title generation in the format of provider/model"}),model_groups:O.optional(O.Record(O.String,O.Union([T8,O.Struct({default:T8,models:O.optional(O.mutable(O.Array(T8)))})]))).annotate({description:"Named model groups (capability tiers, e.g. fast/economical/default/power). Each group has a default model and optional member models. A group name can be used anywhere a provider/model string is accepted."}),default_agent:O.optional(O.String).annotate({description:"Default agent to use when none is specified. Must be a primary agent. Falls back to 'build' if not set or if the specified agent is invalid."}),username:O.optional(O.String).annotate({description:"Custom username to display in conversations instead of system username"}),mode:O.optional(O.StructWithRest(O.Struct({build:O.optional(a8),plan:O.optional(a8)}),[O.Record(O.String,a8)])).annotate({description:"@deprecated Use `agent` field instead."}),agent:O.optional(O.StructWithRest(O.Struct({plan:O.optional(a8),build:O.optional(a8),general:O.optional(a8),explore:O.optional(a8),title:O.optional(a8),summary:O.optional(a8),compaction:O.optional(a8)}),[O.Record(O.String,a8)])).annotate({description:"Agent configuration, see https://opencode.ai/docs/agents"}),provider:O.optional(O.Record(O.String,WJ.Info)).annotate({description:"Custom provider configurations and model overrides"}),mcp:O.optional(O.Record(O.String,O.Union([CZ.Info,O.Any.annotate({[A$]:P.object({enabled:P.boolean()}).strict()})]))).annotate({description:"MCP (Model Context Protocol) server configurations"}),formatter:O.optional(QJ.Info),lsp:O.optional(GJ.Info),instructions:O.optional(O.mutable(O.Array(O.String))).annotate({description:"Additional instruction files or patterns to include"}),layout:O.optional(C5.Layout).annotate({description:"@deprecated Always uses stretch layout."}),permission:O.optional(er),tools:O.optional(O.Record(O.String,O.Boolean)),tool:O.optional(O.Struct({invocation_style:O.optional(O.Literals(["json","shell"])).annotate({description:"Default invocation style for all tools. 'json' (default) exposes the original Zod schema; 'shell' exposes a single `script` parameter and uses the tool's shell.parse mapping."}),invocation_style_by_tool:O.optional(O.Record(O.String,O.Literals(["json","shell"]))).annotate({description:"Per-tool override of invocation_style. Keys are tool IDs. A tool without a `shell` field falls back to JSON regardless of this setting."})})).annotate({description:"Tool invocation style configuration (JSON vs shell-style)."}),enterprise:O.optional(O.Struct({url:O.optional(O.String).annotate({description:"Enterprise URL"})})),compaction:O.optional(O.Struct({auto:O.optional(O.Boolean).annotate({description:"Enable automatic compaction when context is full (default: true)"}),prune:O.optional(O.Boolean).annotate({description:"Enable pruning of old tool outputs (default: true)"}),tail_turns:O.optional(E5).annotate({description:"Number of recent user turns, including their following assistant/tool responses, to keep verbatim during compaction (default: 2)"}),preserve_recent_tokens:O.optional(E5).annotate({description:"Maximum number of tokens from recent turns to preserve verbatim after compaction"}),reserved:O.optional(E5).annotate({description:"Token buffer for compaction. Leaves enough window to avoid overflow during compaction."})})),checkpoint:O.optional(O.Struct({thresholds:O.optional(O.Array(O.String)).annotate({description:'Context fill thresholds that trigger checkpoint writes. Strings may be percentages ("40%"), absolute tokens ("100K", "1.5M"), or mixed ("100K", "50%"). Each threshold must be <= window - 20K reserved. Default: ["40%", "60%", "80%"].'}),reserved:O.optional(E5).annotate({description:"Token buffer reserved for checkpoint operations. Default: 20000."}),max_writer_failures:O.optional(l$).annotate({description:"Maximum consecutive writer failures per session before checkpointing stops retrying until process restart. Default: 3."}),fork:O.optional(O.Boolean).annotate({description:"Whether to fork the parent agent's message prefix into the writer session for prefix-cache reuse. Requires provider cache-breakpoint support. Default: false."}),push_caps:O.optional(O.Struct({tasks_ledger:O.optional(l$).annotate({description:"Token cap for the tasks ledger section of rebuild context. Default: 2000."}),focus_task:O.optional(l$).annotate({description:"Token cap for the focus task body in rebuild context. Default: 4000."}),actor_ledger:O.optional(l$).annotate({description:"Token cap for the actor ledger section of rebuild context. Default: 500."}),memory_titles:O.optional(l$).annotate({description:"Token cap for memory titles in rebuild context. Default: 500."}),global:O.optional(l$).annotate({description:"Token cap for the global memory section (global/MEMORY.md) of rebuild context. Default: 6000."}),checkpoint:O.optional(l$).annotate({description:"Token cap for the session checkpoint section (checkpoint.md) of rebuild context. Default: 11000."}),memory:O.optional(l$).annotate({description:"Token cap for the project memory section (MEMORY.md) of rebuild context. Default: 10000."}),notes:O.optional(l$).annotate({description:"Token cap for the session notes (notes.md) of rebuild context. Default: 6000."}),design_decisions:O.optional(l$).annotate({description:"Token cap for \xA710 Design decisions section of checkpoint.md (writer-side budget validation). Default: 3000."}),open_notes:O.optional(l$).annotate({description:"Token cap for \xA711 Open notes section of checkpoint.md (writer-side budget validation). Default: 800."}),recent_user:O.optional(E5).annotate({description:"Token cap for the recent user input section (verbatim user messages from the live DB, FIFO eviction). Default: 16000. Set 0 to disable."}),recent_user_per_msg:O.optional(l$).annotate({description:"Per-message cap inside recent user input section; oversized messages get head/tail truncation with messageID elision marker. Default: 2000."})})).annotate({description:"Per-section token caps for rebuild context (renderRebuildContext). Each section is loaded up to its cap so the rebuild stays within a predictable budget."}),task_archive_days:O.optional(l$).annotate({description:"Number of days after task done/abandoned before it's filtered out of `list({include_archived: false})`. Rows are NOT deleted \u2014 see v9 for true GC. Default: 7."}),task_cleanup_days:O.optional(l$).annotate({description:"[deprecated] Alias for task_archive_days. Will be removed in v9."}),memory_reconcile_on_search:O.optional(O.Boolean).annotate({description:"Whether to reconcile memory state on search operations. Default: true."}),memory_search_score_floor:O.optional(O.Number).annotate({description:"Relative BM25 floor for memory.search (OR-joined query): keep results scoring >= this fraction of the top hit, dropping common-word-only noise. The #1 result is always kept. Default: 0.15. Set 0 to keep all matches."})})),memory:O.optional(O.Struct({cc_index:O.optional(O.Boolean).annotate({description:"Index Claude Code memory (~/.claude/projects/<slug>/memory) and expose under scope='cc'. Default: false. Note: when enabled, every qitqode agent (build/explore/subagents) can search these memories via the builtin `memory` tool \u2014 including CC's `type: user` (your role/preferences) and `type: feedback` (your guidance) categories. CC originally writes them for future CC sessions; flipping this on widens the consumer set to qitqode agents on the same machine. Leave disabled (default) if you don't want personal context recallable from a prompt-injection-vulnerable agent."})})),history:O.optional(YX.Info).annotate({description:"Trajectory (conversation history) FTS index configuration."}),dream:O.optional(O.Struct({auto:O.optional(O.Boolean).annotate({description:"Auto-trigger dream memory consolidation on new session start. Default: true."}),interval_days:O.optional(E5).annotate({description:"Minimum days between automatic dream runs. Set to 0 to trigger on every new session. Default: 7."})})),distill:O.optional(O.Struct({auto:O.optional(O.Boolean).annotate({description:"Auto-trigger distill workflow packaging on new session start. Default: true."}),interval_days:O.optional(E5).annotate({description:"Minimum days between automatic distill runs. Default: 30."})})),voice:O.optional(O.Struct({asr_model:O.optional(T8).annotate({description:"Model to use for voice ASR transcription in provider/model format, e.g. openai/whisper-1."}),control_model:O.optional(T8).annotate({description:"Model to use for voice control (multimodal) in provider/model format, e.g. openai/gpt-4o."})})).annotate({description:"Voice input provider and model configuration."}),experimental:O.optional(O.Struct({disable_paste_summary:O.optional(O.Boolean),batch_tool:O.optional(O.Boolean).annotate({description:"Enable the batch tool"}),openTelemetry:O.optional(O.Boolean).annotate({description:"Enable OpenTelemetry spans for AI SDK calls (using the 'experimental_telemetry' flag)"}),primary_tools:O.optional(O.mutable(O.Array(O.String))).annotate({description:"Tools that should only be available to primary agents."}),continue_loop_on_deny:O.optional(O.Boolean).annotate({description:"Continue the agent loop when a tool call is denied"}),mcp_timeout:O.optional(l$).annotate({description:"Timeout in milliseconds for model context protocol (MCP) requests"}),predict_next_prompt:O.optional(O.Boolean).annotate({description:"Predict the user's likely next prompt after each turn and show it as inline ghost text (Tab to accept). Enabled by default; set to false to disable."}),maxMode:O.optional(O.Struct({candidates:O.optional(l$).annotate({description:"Number of parallel reasoning candidates per step in max mode (default 5)."})})).annotate({description:"Max mode (experimental): the 'max' agent runs N parallel reasoning candidates each step, picks the best via a judge call, and executes only the winner."})})),workflow:O.optional(O.Struct({maxConcurrentAgents:O.optional(O.Number).annotate({description:"Process-wide ceiling on subagents running concurrently across ALL workflow runs (including nested children). Default min(16, 2x CPU cores). No upper clamp: the previous 2x-cores hard cap was removed so an operator can match real provider capacity \u2014 but that also means a misconfigured value (e.g. an extra zero) can exhaust provider rate limits or host memory. This is the only concurrency ceiling, so set it deliberately."}),maxDepth:O.optional(O.Number).annotate({description:"Max nesting depth for workflow()-calls-workflow. Default 8. Exceeding it fails the run."}),maxLifecycleAgents:O.optional(O.Number).annotate({description:"Hard ceiling on total agents a single workflow run may spawn over its life. Default 1000. Over-cap agent() calls return null (graceful degradation). PER-RUN, not tree-wide: each child workflow has its own independent budget, so a deep nesting can spawn maxDepth \xD7 this over the whole tree (concurrent in-flight is still bounded by maxConcurrentAgents)."}),scriptDeadlineMs:O.optional(O.Number).annotate({description:"Wall-clock budget for a whole workflow script, in milliseconds. Default 12h. The sandbox interrupt handler enforces this as a hard kill-switch."})})).annotate({description:"Dynamic workflow runtime settings."})}),b5=w0(Za).strict().meta({ref:"Config"});var Ya=_0.create({service:"config"}),Xa=I5.Server.zod,Qa=C5.Layout.zod;class Z4 extends S1.Service()("@qitqode/Config"){}var Ga=N1.create("ConfigDirectoryTypoError",P.object({path:P.string(),dir:P.string(),suggestion:P.string()})),ww=R0.effect(Z4,T.gen(function*(){let $=yield*w$.Service,Z=yield*k8.Service,J=yield*o7.Service,Y=yield*l6.Service,X=yield*j6.Service,{readConfigFile:Q,loadConfig:G,loadFile:W}=Dq({fs:$,info:b5}),K=Lq(W),[V,U]=yield*T.cachedInvalidateWithTTL(K().pipe(T.tapError((I)=>T.sync(()=>Ya.error("failed to load global config, using defaults",{error:String(I)}))),T.orElseSucceed(()=>({}))),J8.infinity),H=T.fn("Config.getGlobal")(function*(){return yield*V}),{loadInstanceState:B}=Uw({fs:$,authSvc:Z,accountSvc:J,env:Y,npmSvc:X,info:b5,readConfigFile:Q,loadConfig:G,loadFile:W,getGlobal:H}),z=yield*B0.make(T.fn("Config.state")(function*(I){return yield*B(I).pipe(T.orDie)})),F=T.fn("Config.get")(function*(){return yield*B0.use(z,(I)=>I.config)}),A=T.fn("Config.directories")(function*(){return yield*B0.use(z,(I)=>I.directories)}),N=T.fn("Config.getConsoleState")(function*(){return yield*B0.use(z,(I)=>I.consoleState)}),q=T.fn("Config.waitForDependencies")(function*(){yield*B0.useEffect(z,(I)=>T.forEach(I.deps,Mw.join,{concurrency:"unbounded"}).pipe(T.asVoid))}),w=T.fn("Config.update")(function*(I){let R=yield*B0.directory,L=Ja.join(R,"config.json"),C=yield*W(L);yield*$.writeFileString(L,JSON.stringify(q1(s7(C),s7(I)),null,2)).pipe(T.orDie),yield*T.promise(()=>S8.dispose())}),j=T.fn("Config.invalidate")(function*(I){yield*U;let R=S8.disposeAll().catch(()=>{return}).finally(()=>L7.emit("event",{directory:"global",payload:{type:Yq.Disposed.type,properties:{}}}));if(I)yield*T.promise(()=>R)}),M=T.fn("Config.updateGlobal")(function*(I){let R=yield*T.promise(()=>Nq()),L=(yield*Q(R))??"{}",C;if(!R.endsWith(".jsonc")){let _=r8.schema(b5,r8.jsonc(L,R),R),E=q1(s7(_),s7(I));yield*$.writeFileString(R,JSON.stringify(E,null,2)).pipe(T.orDie),C=E}else{let _=eV(L,s7(I));C=r8.schema(b5,r8.jsonc(_,R),R),yield*$.writeFileString(R,_).pipe(T.orDie)}return yield*j(),C});return Z4.of({get:F,getGlobal:H,getConsoleState:N,update:w,updateGlobal:M,invalidate:j,directories:A,waitForDependencies:q})})),Wa=ww.pipe(R0.provide(Dw.defaultLayer),R0.provide(w$.defaultLayer),R0.provide(l6.defaultLayer),R0.provide(k8.defaultLayer),R0.provide(o7.defaultLayer),R0.provide(j6.defaultLayer));var XX={};F1(XX,{report:()=>Ka,pretty:()=>Tw,Diagnostic:()=>XX});var Lw=20;function Tw($){let J={1:"ERROR",2:"WARN",3:"INFO",4:"HINT"}[$.severity||1],Y=$.range.start.line+1,X=$.range.start.character+1;return`${J} [${Y}:${X}] ${$.message}`}function Ka($,Z){let J=Z.filter((G)=>G.severity===1);if(J.length===0)return"";let Y=J.slice(0,Lw),X=J.length-Lw,Q=X>0?`
|
|
496
|
+
... and ${X} more`:"";return`<diagnostics file="${$}">
|
|
497
|
+
${Y.map(Tw).join(`
|
|
498
|
+
`)}${Q}
|
|
499
|
+
</diagnostics>`}var n6=_0.create({service:"lsp"}),Cw={Updated:T1.define("lsp.updated",P.object({}))},J4=P.object({start:P.object({line:P.number(),character:P.number()}),end:P.object({line:P.number(),character:P.number()})}).meta({ref:"Range"}),Ua=P.object({name:P.string(),kind:P.number(),location:P.object({uri:P.string(),range:J4})}).meta({ref:"Symbol"}),Ha=P.object({name:P.string(),detail:P.string().optional(),kind:P.number(),range:J4,selectionRange:J4}).meta({ref:"DocumentSymbol"}),Ba=P.object({id:P.string(),name:P.string(),root:P.string(),status:P.union([P.literal("connected"),P.literal("error")])}).meta({ref:"LSPStatus"});var za=[5,12,6,11,13,14,23,10],Fa=($)=>{if(S0.QITQODE_EXPERIMENTAL_LSP_TY){if($.pyright)n6.info("LSP server pyright is disabled because QITQODE_EXPERIMENTAL_LSP_TY is enabled"),delete $.pyright}else if($.ty)delete $.ty};class Y4 extends S1.Service()("@qitqode/LSP"){}var Iw=R0.effect(Y4,T.gen(function*(){let $=yield*Q8.Service,Z=yield*B0.make(T.fn("LSP.state")(function*(R){let L=yield*$.get(),C={};if(!L.lsp)n6.info("all LSPs are disabled");else{for(let E of Object.values(f7))C[E.id]=E;if(Fa(C),L.lsp!==!0)for(let[E,f]of Object.entries(L.lsp)){let b=C[E];if(f.disabled){n6.info(`LSP server ${E} is disabled`),delete C[E];continue}C[E]={...b,id:E,root:b?.root??(async(k,u)=>u.directory),extensions:f.extensions??b?.extensions??[],spawn:async(k)=>({process:Z1(f.command[0],f.command.slice(1),{cwd:k,env:{...n8(),...f.env}}),initialization:f.initialization})}}n6.info("enabled LSP servers",{serverIds:Object.values(C).map((E)=>E.id).join(", ")})}let _={clients:[],servers:C,broken:new Set,spawning:new Map};return yield*T.addFinalizer(()=>T.promise(async()=>{await Promise.all(_.clients.map((E)=>E.shutdown()))})),_}));async function J(R,L,C,_=!1){let E=Rw.parse(R).ext||R,f=[];for(let b of Object.values(C.servers)){if(b.extensions.length&&!b.extensions.includes(E))continue;let k=await b.root(R,L);if(!k)continue;if(C.broken.has(k+b.id))continue;if(f.push({server:b,root:k}),_)break}return f}let Y=T.fnUntraced(function*(R){let L=yield*B0.context;if(!w$.contains(L.directory,R)&&(L.worktree==="/"||!w$.contains(L.worktree,R)))return[];let C=yield*B0.get(Z);return yield*T.promise(async()=>{let _=[];async function E(f,b,k){let u=await f.spawn(b,L).then((c)=>{if(!c)C.broken.add(k);return c}).catch((c)=>{C.broken.add(k),n6.error(`Failed to spawn LSP server ${f.id}`,{error:c});return});if(!u)return;n6.info("spawned lsp server",{serverID:f.id,root:b});let x=await BN({serverID:f.id,server:u,root:b,directory:L.directory}).catch(async(c)=>{C.broken.add(k),await f1.stop(u.process),n6.error(`Failed to initialize LSP client ${f.id}`,{error:c});return});if(!x)return;let g=C.clients.find((c)=>c.root===b&&c.serverID===f.id);if(g)return await f1.stop(u.process),g;return C.clients.push(x),x}for(let{server:f,root:b}of await J(R,L,C)){let k=C.clients.find((c)=>c.root===b&&c.serverID===f.id);if(k){_.push(k);continue}let u=C.spawning.get(b+f.id);if(u){let c=await u;if(!c)continue;_.push(c);continue}let x=E(f,b,b+f.id);C.spawning.set(b+f.id,x),x.finally(()=>{if(C.spawning.get(b+f.id)===x)C.spawning.delete(b+f.id)});let g=await x;if(!g)continue;_.push(g),d1.publish(Cw.Updated,{})}return _})}),X=T.fnUntraced(function*(R,L){let C=yield*Y(R);return yield*T.promise(()=>Promise.all(C.map((_)=>L(_))))}),Q=T.fnUntraced(function*(R){let L=yield*B0.get(Z);return yield*T.promise(()=>Promise.all(L.clients.map((C)=>R(C))))}),G=T.fn("LSP.init")(function*(){yield*B0.get(Z)}),W=T.fn("LSP.status")(function*(){let R=yield*B0.context,L=yield*B0.get(Z),C=[];for(let _ of L.clients)C.push({id:_.serverID,name:L.servers[_.serverID].id,root:Rw.relative(R.directory,_.root),status:"connected"});return C}),K=T.fn("LSP.hasClients")(function*(R){let L=yield*B0.context,C=yield*B0.get(Z);return yield*T.promise(async()=>{return(await J(R,L,C,!0)).length>0})}),V=T.fn("LSP.touchFile")(function*(R,L){n6.info("touching file",{file:R});let C=yield*Y(R);yield*T.promise(()=>Promise.all(C.map(async(_)=>{let E=L?_.waitForDiagnostics({path:R}):Promise.resolve();return await _.notify.open({path:R}),E})).catch((_)=>{n6.error("failed to touch file",{err:_,file:R})}))}),U=T.fn("LSP.diagnostics")(function*(){let R={},L=yield*Q(async(C)=>C.diagnostics);for(let C of L)for(let[_,E]of C.entries()){let f=R[_]||[];f.push(...E),R[_]=f}return R}),H=T.fnUntraced(function*(R,L,C,_){return yield*X(R.file,(E)=>E.connection.sendRequest(L,{textDocument:{uri:Pw(R.file).href},position:{line:R.line,character:R.character},..._}).catch(()=>C))}),B=T.fn("LSP.hover")(function*(R){return yield*H(R,"textDocument/hover",null)}),z=T.fn("LSP.definition")(function*(R){return(yield*H(R,"textDocument/definition",null)).flat().filter(Boolean)}),F=T.fn("LSP.references")(function*(R){return(yield*H(R,"textDocument/references",[],{context:{includeDeclaration:!0}})).flat().filter(Boolean)}),A=T.fn("LSP.implementation")(function*(R){return(yield*H(R,"textDocument/implementation",null)).flat().filter(Boolean)}),N=T.fn("LSP.documentSymbol")(function*(R){let L=Va(R);return(yield*X(L,(_)=>_.connection.sendRequest("textDocument/documentSymbol",{textDocument:{uri:R}}).catch(()=>[]))).flat().filter(Boolean)}),q=T.fn("LSP.workspaceSymbol")(function*(R){return(yield*Q((C)=>C.connection.sendRequest("workspace/symbol",{query:R}).then((_)=>_.filter((E)=>za.includes(E.kind)).slice(0,10)).catch(()=>[]))).flat()}),w=T.fn("LSP.prepareCallHierarchy")(function*(R){return(yield*H(R,"textDocument/prepareCallHierarchy",[])).flat().filter(Boolean)}),j=T.fnUntraced(function*(R,L){return(yield*X(R.file,async(_)=>{let E=await _.connection.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:Pw(R.file).href},position:{line:R.line,character:R.character}}).catch(()=>[]);if(!E?.length)return[];return _.connection.sendRequest(L,{item:E[0]}).catch(()=>[])})).flat().filter(Boolean)}),M=T.fn("LSP.incomingCalls")(function*(R){return yield*j(R,"callHierarchy/incomingCalls")}),I=T.fn("LSP.outgoingCalls")(function*(R){return yield*j(R,"callHierarchy/outgoingCalls")});return Y4.of({init:G,status:W,hasClients:K,touchFile:V,diagnostics:U,hover:B,definition:z,references:F,implementation:A,documentSymbol:N,workspaceSymbol:q,prepareCallHierarchy:w,incomingCalls:M,outgoingCalls:I})})),Aa=Iw.pipe(R0.provide(Q8.defaultLayer));var yZ={};F1(yZ,{layer:()=>lw,defaultLayer:()=>Ta,Snapshot:()=>yZ,Service:()=>K4,Patch:()=>Da,FileDiff:()=>wa});class Q4{diff($,Z,J={}){let Y;if(typeof J==="function")Y=J,J={};else if("callback"in J)Y=J.callback;let X=this.castInput($,J),Q=this.castInput(Z,J),G=this.removeEmpty(this.tokenize(X,J)),W=this.removeEmpty(this.tokenize(Q,J));return this.diffWithOptionsObj(G,W,J,Y)}diffWithOptionsObj($,Z,J,Y){var X;let Q=(q)=>{if(q=this.postProcess(q,J),Y){setTimeout(function(){Y(q)},0);return}else return q},G=Z.length,W=$.length,K=1,V=G+W;if(J.maxEditLength!=null)V=Math.min(V,J.maxEditLength);let U=(X=J.timeout)!==null&&X!==void 0?X:1/0,H=Date.now()+U,B=[{oldPos:-1,lastComponent:void 0}],z=this.extractCommon(B[0],Z,$,0,J);if(B[0].oldPos+1>=W&&z+1>=G)return Q(this.buildValues(B[0].lastComponent,Z,$));let F=-1/0,A=1/0,N=()=>{for(let q=Math.max(F,-K);q<=Math.min(A,K);q+=2){let w,j=B[q-1],M=B[q+1];if(j)B[q-1]=void 0;let I=!1;if(M){let L=M.oldPos-q;I=M&&0<=L&&L<G}let R=j&&j.oldPos+1<W;if(!I&&!R){B[q]=void 0;continue}if(!R||I&&j.oldPos<M.oldPos)w=this.addToPath(M,!0,!1,0,J);else w=this.addToPath(j,!1,!0,1,J);if(z=this.extractCommon(w,Z,$,q,J),w.oldPos+1>=W&&z+1>=G)return Q(this.buildValues(w.lastComponent,Z,$))||!0;else{if(B[q]=w,w.oldPos+1>=W)A=Math.min(A,q-1);if(z+1>=G)F=Math.max(F,q+1)}}K++};if(Y)(function q(){setTimeout(function(){if(K>V||Date.now()>H)return Y(void 0);if(!N())q()},0)})();else while(K<=V&&Date.now()<=H){let q=N();if(q)return q}}addToPath($,Z,J,Y,X){let Q=$.lastComponent;if(Q&&!X.oneChangePerToken&&Q.added===Z&&Q.removed===J)return{oldPos:$.oldPos+Y,lastComponent:{count:Q.count+1,added:Z,removed:J,previousComponent:Q.previousComponent}};else return{oldPos:$.oldPos+Y,lastComponent:{count:1,added:Z,removed:J,previousComponent:Q}}}extractCommon($,Z,J,Y,X){let Q=Z.length,G=J.length,W=$.oldPos,K=W-Y,V=0;while(K+1<Q&&W+1<G&&this.equals(J[W+1],Z[K+1],X))if(K++,W++,V++,X.oneChangePerToken)$.lastComponent={count:1,previousComponent:$.lastComponent,added:!1,removed:!1};if(V&&!X.oneChangePerToken)$.lastComponent={count:V,previousComponent:$.lastComponent,added:!1,removed:!1};return $.oldPos=W,K}equals($,Z,J){if(J.comparator)return J.comparator($,Z);else return $===Z||!!J.ignoreCase&&$.toLowerCase()===Z.toLowerCase()}removeEmpty($){let Z=[];for(let J=0;J<$.length;J++)if($[J])Z.push($[J]);return Z}castInput($,Z){return $}tokenize($,Z){return Array.from($)}join($){return $.join("")}postProcess($,Z){return $}get useLongestToken(){return!1}buildValues($,Z,J){let Y=[],X;while($)Y.push($),X=$.previousComponent,delete $.previousComponent,$=X;Y.reverse();let Q=Y.length,G=0,W=0,K=0;for(;G<Q;G++){let V=Y[G];if(!V.removed){if(!V.added&&this.useLongestToken){let U=Z.slice(W,W+V.count);U=U.map(function(H,B){let z=J[K+B];return z.length>H.length?z:H}),V.value=this.join(U)}else V.value=this.join(Z.slice(W,W+V.count));if(W+=V.count,!V.added)K+=V.count}else V.value=this.join(J.slice(K,K+V.count)),K+=V.count}return Y}}class Ew extends Q4{constructor(){super(...arguments);this.tokenize=Oa}equals($,Z,J){if(J.ignoreWhitespace){if(!J.newlineIsToken||!$.includes(`
|
|
500
|
+
`))$=$.trim();if(!J.newlineIsToken||!Z.includes(`
|
|
501
|
+
`))Z=Z.trim()}else if(J.ignoreNewlineAtEof&&!J.newlineIsToken){if($.endsWith(`
|
|
502
|
+
`))$=$.slice(0,-1);if(Z.endsWith(`
|
|
503
|
+
`))Z=Z.slice(0,-1)}return super.equals($,Z,J)}}var bw=new Ew;function G4($,Z,J){return bw.diff($,Z,J)}function Oa($,Z){if(Z.stripTrailingCr)$=$.replace(/\r\n/g,`
|
|
504
|
+
`);let J=[],Y=$.split(/(\n|\r\n)/);if(!Y[Y.length-1])Y.pop();for(let X=0;X<Y.length;X++){let Q=Y[X];if(X%2&&!Z.newlineIsToken)J[J.length-1]+=Q;else J.push(Q)}return J}function _w($){return $.includes(`\r
|
|
505
|
+
`)&&!$.startsWith(`
|
|
506
|
+
`)&&!$.match(/[^\r]\n/)}function Sw($){return!$.includes(`\r
|
|
507
|
+
`)&&$.includes(`
|
|
508
|
+
`)}function fU($){if(Array.isArray($))return $.map((Z)=>fU(Z));return Object.assign(Object.assign({},$),{hunks:$.hunks.map((Z)=>Object.assign(Object.assign({},Z),{lines:Z.lines.map((J,Y)=>{var X;return J.startsWith("\\")||J.endsWith("\r")||((X=Z.lines[Y+1])===null||X===void 0?void 0:X.startsWith("\\"))?J:J+"\r"})}))})}function kU($){if(Array.isArray($))return $.map((Z)=>kU(Z));return Object.assign(Object.assign({},$),{hunks:$.hunks.map((Z)=>Object.assign(Object.assign({},Z),{lines:Z.lines.map((J)=>J.endsWith("\r")?J.substring(0,J.length-1):J)}))})}function fw($){if(!Array.isArray($))$=[$];return!$.some((Z)=>Z.hunks.some((J)=>J.lines.some((Y)=>!Y.startsWith("\\")&&Y.endsWith("\r"))))}function kw($){if(!Array.isArray($))$=[$];return $.some((Z)=>Z.hunks.some((J)=>J.lines.some((Y)=>Y.endsWith("\r"))))&&$.every((Z)=>Z.hunks.every((J)=>J.lines.every((Y,X)=>{var Q;return Y.startsWith("\\")||Y.endsWith("\r")||((Q=J.lines[X+1])===null||Q===void 0?void 0:Q.startsWith("\\"))})))}function vU($){let Z=$.split(/\n/),J=[],Y=0;function X(){let W={};J.push(W);while(Y<Z.length){let K=Z[Y];if(/^(---|\+\+\+|@@)\s/.test(K))break;let V=/^(?:Index:|diff(?: -r \w+)+)\s+/.exec(K);if(V)W.index=K.substring(V[0].length).trim();Y++}Q(W),Q(W),W.hunks=[];while(Y<Z.length){let K=Z[Y];if(/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(K))break;else if(/^@@/.test(K))W.hunks.push(G());else if(K)throw Error("Unknown line "+(Y+1)+" "+JSON.stringify(K));else Y++}}function Q(W){let K=/^(---|\+\+\+)\s+/.exec(Z[Y]);if(K){let V=K[1],U=Z[Y].substring(3).trim().split("\t",2),H=(U[1]||"").trim(),B=U[0].replace(/\\\\/g,"\\");if(B.startsWith('"')&&B.endsWith('"'))B=B.substr(1,B.length-2);if(V==="---")W.oldFileName=B,W.oldHeader=H;else W.newFileName=B,W.newHeader=H;Y++}}function G(){var W;let K=Y,V=Z[Y++],U=V.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),H={oldStart:+U[1],oldLines:typeof U[2]>"u"?1:+U[2],newStart:+U[3],newLines:typeof U[4]>"u"?1:+U[4],lines:[]};if(H.oldLines===0)H.oldStart+=1;if(H.newLines===0)H.newStart+=1;let B=0,z=0;for(;Y<Z.length&&(z<H.oldLines||B<H.newLines||((W=Z[Y])===null||W===void 0?void 0:W.startsWith("\\")));Y++){let F=Z[Y].length==0&&Y!=Z.length-1?" ":Z[Y][0];if(F==="+"||F==="-"||F===" "||F==="\\"){if(H.lines.push(Z[Y]),F==="+")B++;else if(F==="-")z++;else if(F===" ")B++,z++}else throw Error(`Hunk at line ${K+1} contained invalid line ${Z[Y]}`)}if(!B&&H.newLines===1)H.newLines=0;if(!z&&H.oldLines===1)H.oldLines=0;if(B!==H.newLines)throw Error("Added line count did not match for hunk at line "+(K+1));if(z!==H.oldLines)throw Error("Removed line count did not match for hunk at line "+(K+1));return H}while(Y<Z.length)X();return J}function yU($,Z,J){let Y=!0,X=!1,Q=!1,G=1;return function W(){if(Y&&!Q){if(X)G++;else Y=!1;if($+G<=J)return $+G;Q=!0}if(!X){if(!Q)Y=!0;if(Z<=$-G)return $-G++;return X=!0,W()}return}}function ja($,Z,J={}){let Y;if(typeof Z==="string")Y=vU(Z);else if(Array.isArray(Z))Y=Z;else Y=[Z];if(Y.length>1)throw Error("applyPatch only works with a single input.");return Na($,Y[0],J)}function Na($,Z,J={}){if(J.autoConvertLineEndings||J.autoConvertLineEndings==null){if(_w($)&&fw(Z))Z=fU(Z);else if(Sw($)&&kw(Z))Z=kU(Z)}let Y=$.split(`
|
|
509
|
+
`),X=Z.hunks,Q=J.compareLine||((F,A,N,q)=>A===q),G=J.fuzzFactor||0,W=0;if(G<0||!Number.isInteger(G))throw Error("fuzzFactor must be a non-negative integer");if(!X.length)return $;let K="",V=!1,U=!1;for(let F=0;F<X[X.length-1].lines.length;F++){let A=X[X.length-1].lines[F];if(A[0]=="\\"){if(K[0]=="+")V=!0;else if(K[0]=="-")U=!0}K=A}if(V){if(U){if(!G&&Y[Y.length-1]=="")return!1}else if(Y[Y.length-1]=="")Y.pop();else if(!G)return!1}else if(U){if(Y[Y.length-1]!="")Y.push("");else if(!G)return!1}function H(F,A,N,q=0,w=!0,j=[],M=0){let I=0,R=!1;for(;q<F.length;q++){let L=F[q],C=L.length>0?L[0]:" ",_=L.length>0?L.substr(1):L;if(C==="-")if(Q(A+1,Y[A],C,_))A++,I=0;else{if(!N||Y[A]==null)return null;return j[M]=Y[A],H(F,A+1,N-1,q,!1,j,M+1)}if(C==="+"){if(!w)return null;j[M]=_,M++,I=0,R=!0}if(C===" ")if(I++,j[M]=Y[A],Q(A+1,Y[A],C,_))M++,w=!0,R=!1,A++;else{if(R||!N)return null;return Y[A]&&(H(F,A+1,N-1,q+1,!1,j,M+1)||H(F,A+1,N-1,q,!1,j,M+1))||H(F,A,N-1,q+1,!1,j,M)}}return M-=I,A-=I,j.length=M,{patchedLines:j,oldLineLastI:A-1}}let B=[],z=0;for(let F=0;F<X.length;F++){let A=X[F],N,q=Y.length-A.oldLines+G,w;for(let j=0;j<=G;j++){w=A.oldStart+z-1;let M=yU(w,W,q);for(;w!==void 0;w=M())if(N=H(A.lines,w,j),N)break;if(N)break}if(!N)return!1;for(let j=W;j<w;j++)B.push(Y[j]);for(let j=0;j<N.patchedLines.length;j++){let M=N.patchedLines[j];B.push(M)}W=N.oldLineLastI+1,z=w+1-A.oldStart}for(let F=W;F<Y.length;F++)B.push(Y[F]);return B.join(`
|
|
510
|
+
`)}var vw={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function QX($,Z,J,Y,X,Q,G){let W;if(!G)W={};else if(typeof G==="function")W={callback:G};else W=G;if(typeof W.context>"u")W.context=4;let K=W.context;if(W.newlineIsToken)throw Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(!W.callback)return V(G4(J,Y,W));else{let{callback:U}=W;G4(J,Y,Object.assign(Object.assign({},W),{callback:(H)=>{let B=V(H);U(B)}}))}function V(U){if(!U)return;U.push({value:"",lines:[]});function H(w){return w.map(function(j){return" "+j})}let B=[],z=0,F=0,A=[],N=1,q=1;for(let w=0;w<U.length;w++){let j=U[w],M=j.lines||Ma(j.value);if(j.lines=M,j.added||j.removed){if(!z){let I=U[w-1];if(z=N,F=q,I)A=K>0?H(I.lines.slice(-K)):[],z-=A.length,F-=A.length}for(let I of M)A.push((j.added?"+":"-")+I);if(j.added)q+=M.length;else N+=M.length}else{if(z)if(M.length<=K*2&&w<U.length-2)for(let I of H(M))A.push(I);else{let I=Math.min(M.length,K);for(let L of H(M.slice(0,I)))A.push(L);let R={oldStart:z,oldLines:N-z+I,newStart:F,newLines:q-F+I,lines:A};B.push(R),z=0,F=0,A=[]}N+=M.length,q+=M.length}}for(let w of B)for(let j=0;j<w.lines.length;j++)if(w.lines[j].endsWith(`
|
|
511
|
+
`))w.lines[j]=w.lines[j].slice(0,-1);else w.lines.splice(j+1,0,"\"),j++;return{oldFileName:$,newFileName:Z,oldHeader:X,newHeader:Q,hunks:B}}}function VJ($,Z){if(!Z)Z=vw;if(Array.isArray($)){if($.length>1&&!Z.includeFileHeaders)throw Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return $.map((Y)=>VJ(Y,Z)).join(`
|
|
512
|
+
`)}let J=[];if(Z.includeIndex&&$.oldFileName==$.newFileName)J.push("Index: "+$.oldFileName);if(Z.includeUnderline)J.push("===================================================================");if(Z.includeFileHeaders)J.push("--- "+$.oldFileName+(typeof $.oldHeader>"u"?"":"\t"+$.oldHeader)),J.push("+++ "+$.newFileName+(typeof $.newHeader>"u"?"":"\t"+$.newHeader));for(let Y=0;Y<$.hunks.length;Y++){let X=$.hunks[Y];if(X.oldLines===0)X.oldStart-=1;if(X.newLines===0)X.newStart-=1;J.push("@@ -"+X.oldStart+","+X.oldLines+" +"+X.newStart+","+X.newLines+" @@");for(let Q of X.lines)J.push(Q)}return J.join(`
|
|
513
|
+
`)+`
|
|
514
|
+
`}function qa($,Z,J,Y,X,Q,G){if(typeof G==="function")G={callback:G};if(!(G===null||G===void 0?void 0:G.callback)){let W=QX($,Z,J,Y,X,Q,G);if(!W)return;return VJ(W,G===null||G===void 0?void 0:G.headerOptions)}else{let{callback:W}=G;QX($,Z,J,Y,X,Q,Object.assign(Object.assign({},G),{callback:(K)=>{if(!K)W(void 0);else W(VJ(K,G.headerOptions))}}))}}function Ma($){let Z=$.endsWith(`
|
|
515
|
+
`),J=$.split(`
|
|
516
|
+
`).map((Y)=>Y+`
|
|
517
|
+
`);if(Z)J.pop();else J.push(J.pop().slice(0,-1));return J}import kZ from"path";function yw($,Z){return $.pipe(T.catchCause(Z),T.repeat(W4.spaced(J8.hours(1))),T.delay(J8.minutes(1)),T.forkScoped)}var Da=P.object({hash:P.string(),files:P.string().array()}),wa=P.object({file:P.string(),patch:P.string(),additions:P.number(),deletions:P.number(),status:P.enum(["added","deleted","modified"]).optional()}).meta({ref:"SnapshotFileDiff"});var c1=_0.create({service:"snapshot"}),xw="7.days",La=2097152,S5=["-c","core.longpaths=true","-c","core.symlinks=true"],vZ=["-c","core.autocrlf=false",...S5],_5=[...vZ,"-c","core.quotepath=false"];class K4 extends S1.Service()("@qitqode/Snapshot"){}var lw=R0.effect(K4,T.gen(function*(){let $=yield*w$.Service,Z=yield*xU.ChildProcessSpawner,J=yield*Q8.Service,Y=new Map,X=(G)=>{let W=Y.get(G);if(W)return W;let K=gw.makeUnsafe(1);return Y.set(G,K),K},Q=yield*B0.make(T.fn("Snapshot.state")(function*(G){let W={directory:G.directory,worktree:G.worktree,gitdir:kZ.join(A0.Path.data,"snapshot",G.project.id,V4.fast(G.worktree)),vcs:G.project.vcs},K=(x)=>["--git-dir",W.gitdir,"--work-tree",W.worktree,...x],V=new TextEncoder,U=(x)=>I$.make(V.encode(x.join("\x00")+"\x00")),H=T.fnUntraced(function*(x,g){let c=hU.make("git",x,{cwd:g?.cwd,env:g?.env,extendEnv:!0,stdin:g?.stdin});return yield*mw(Z,c)},T.catch((x)=>T.succeed({code:xU.ExitCode(1),text:"",stderr:x instanceof Error?x.message:String(x)}))),B=T.fnUntraced(function*(x){if(!x.length)return new Set;let g=yield*H([..._5,"--git-dir",kZ.join(W.worktree,".git"),"--work-tree",W.worktree,"check-ignore","--no-index","--stdin","-z"],{cwd:W.worktree,stdin:U(x)});if(g.code!==0&&g.code!==1)return new Set;return new Set(g.text.split("\x00").filter(Boolean))}),z=T.fnUntraced(function*(x){if(!x.length)return;yield*H([...vZ,...K(["rm","--cached","-f","--ignore-unmatch","--pathspec-from-file=-","--pathspec-file-nul"])],{cwd:W.worktree,stdin:U(x)})}),F=T.fnUntraced(function*(x){if(!x.length)return;let g=yield*H([...vZ,...K(["add","--all","--sparse","--pathspec-from-file=-","--pathspec-file-nul"])],{cwd:W.worktree,stdin:U(x)});if(c1.debug("snapshot stage diagnostic",{cwd:W.worktree,files:x,code:g.code,stderr:g.stderr}),g.code===0)return;c1.warn("failed to add snapshot files",{exitCode:g.code,stderr:g.stderr})}),A=(x)=>$.exists(x).pipe(T.orDie),N=(x)=>$.readFileString(x).pipe(T.catch(()=>T.succeed(""))),q=(x)=>$.remove(x).pipe(T.catch(()=>T.void)),w=(x)=>X(W.gitdir).withPermits(1)(x),j=T.fnUntraced(function*(){if(W.vcs!=="git")return!1;return(yield*J.get()).snapshot!==!1}),M=T.fnUntraced(function*(){let g=(yield*H(["rev-parse","--path-format=absolute","--git-path","info/exclude"],{cwd:W.worktree})).text.trim();if(!g)return;if(!(yield*A(g)))return;return g}),I=T.fnUntraced(function*(x=[]){let g=yield*M(),c=kZ.join(W.gitdir,"info","exclude"),e=[g?(yield*N(g)).trimEnd():"",...x.map((G0)=>`/${G0.replaceAll("\\","/")}`)].filter(Boolean).join(`
|
|
518
|
+
`);yield*$.ensureDir(kZ.join(W.gitdir,"info")).pipe(T.orDie),yield*$.writeFileString(c,e?`${e}
|
|
519
|
+
`:"").pipe(T.orDie)}),R=()=>{let x=kZ.relative(W.worktree,W.directory).replaceAll("\\","/");return x?`:(literal)${x}`:"."},L=T.fnUntraced(function*(){yield*I();let[x,g]=yield*T.all([H([..._5,...K(["diff-files","--name-only","-z","--",R()])],{cwd:W.worktree}),H([..._5,...K(["ls-files","--others","--exclude-standard","-z","--",R()])],{cwd:W.worktree})],{concurrency:2});if(x.code!==0||g.code!==0){c1.warn("failed to list snapshot files",{diffCode:x.code,diffStderr:x.stderr,otherCode:g.code,otherStderr:g.stderr});return}let c=x.text.split("\x00").filter(Boolean),e=g.text.split("\x00").filter(Boolean),G0=Array.from(new Set([...c,...e]));if(c1.debug("snapshot candidates diagnostic",{directory:W.directory,worktree:W.worktree,diff:c,untracked:e}),!G0.length)return;let Q0=yield*B(G0);if(Q0.size>0){let l=Array.from(Q0);c1.info("removing gitignored files from snapshot",{count:l.length}),yield*z(l)}let z0=G0.filter((l)=>!Q0.has(l));if(!z0.length)return;let u0=new Set((yield*T.all(z0.map((l)=>$.stat(kZ.join(W.worktree,l)).pipe(T.catch(()=>T.void)).pipe(T.map((t)=>{if(!t||t.type!=="File")return;return(typeof t.size==="bigint"?Number(t.size):t.size)>La?l:void 0}))),{concurrency:8})).filter((l)=>Boolean(l))),m=new Set(e.filter((l)=>u0.has(l)));yield*I(Array.from(m)),yield*F(z0.filter((l)=>!m.has(l)))}),C=T.fnUntraced(function*(){return yield*w(T.gen(function*(){if(!(yield*j()))return;if(!(yield*A(W.gitdir)))return;let x=yield*H(K(["gc",`--prune=${xw}`]),{cwd:W.directory});if(x.code!==0){c1.warn("cleanup failed",{exitCode:x.code,stderr:x.stderr});return}c1.info("cleanup",{prune:xw})}))}),_=T.fnUntraced(function*(){return yield*w(T.gen(function*(){if(!(yield*j()))return;let x=yield*A(W.gitdir);if(yield*$.ensureDir(W.gitdir).pipe(T.orDie),!x)yield*H(["init"],{env:{GIT_DIR:W.gitdir,GIT_WORK_TREE:W.worktree}}),yield*H(["--git-dir",W.gitdir,"config","core.autocrlf","false"]),yield*H(["--git-dir",W.gitdir,"config","core.longpaths","true"]),yield*H(["--git-dir",W.gitdir,"config","core.symlinks","true"]),yield*H(["--git-dir",W.gitdir,"config","core.fsmonitor","false"]),c1.info("initialized");yield*L();let c=(yield*H(K(["write-tree"]),{cwd:W.directory})).text.trim();return c1.info("tracking",{hash:c,cwd:W.directory,git:W.gitdir}),c}))}),E=T.fnUntraced(function*(x){return yield*w(T.gen(function*(){yield*L();let g=yield*H([..._5,...K(["diff","--cached","--no-ext-diff","--name-only",x,"--",R()])],{cwd:W.worktree});if(c1.debug("snapshot patch diagnostic",{cwd:W.directory,hash:x,code:g.code,text:g.text,stderr:g.stderr}),g.code!==0)return c1.warn("failed to get diff",{hash:x,exitCode:g.code}),{hash:x,files:[]};let c=g.text.trim().split(`
|
|
520
|
+
`).map((G0)=>G0.trim()).filter(Boolean),e=yield*B(c);return{hash:x,files:c.filter((G0)=>!e.has(G0)).map((G0)=>kZ.join(W.worktree,G0).replaceAll("\\","/"))}}))}),f=T.fnUntraced(function*(x){return yield*w(T.gen(function*(){c1.info("restore",{commit:x});let g=yield*H([...S5,...K(["read-tree",x])],{cwd:W.worktree});if(g.code===0){let c=yield*H([...S5,...K(["checkout-index","-a","-f"])],{cwd:W.worktree});if(c.code===0)return;c1.error("failed to restore snapshot",{snapshot:x,exitCode:c.code,stderr:c.stderr});return}c1.error("failed to restore snapshot",{snapshot:x,exitCode:g.code,stderr:g.stderr})}))}),b=T.fnUntraced(function*(x){return yield*w(T.gen(function*(){let g=[],c=new Set;for(let Q0 of x)for(let z0 of Q0.files){if(c.has(z0))continue;c.add(z0),g.push({hash:Q0.hash,file:z0,rel:kZ.relative(W.worktree,z0).replaceAll("\\","/")})}let e=T.fnUntraced(function*(Q0){if(c1.info("reverting",{file:Q0.file,hash:Q0.hash}),(yield*H([...S5,...K(["checkout",Q0.hash,"--",Q0.file])],{cwd:W.worktree})).code===0)return;let u0=yield*H([...S5,...K(["ls-tree",Q0.hash,"--",Q0.rel])],{cwd:W.worktree});if(u0.code===0&&u0.text.trim()){c1.info("file existed in snapshot but checkout failed, keeping",{file:Q0.file,hash:Q0.hash});return}c1.info("file did not exist in snapshot, deleting",{file:Q0.file,hash:Q0.hash}),yield*q(Q0.file)}),G0=(Q0,z0)=>Q0===z0||Q0.startsWith(`${z0}/`)||z0.startsWith(`${Q0}/`);for(let Q0=0;Q0<g.length;){let z0=g[Q0],u0=[z0],m=Q0+1;while(m<g.length&&u0.length<100){let y=g[m];if(y.hash!==z0.hash)break;if(u0.some((p)=>G0(p.rel,y.rel)))break;u0.push(y),m+=1}if(u0.length===1){yield*e(z0),Q0=m;continue}let l=yield*H([...S5,...K(["ls-tree","--name-only",z0.hash,"--",...u0.map((y)=>y.rel)])],{cwd:W.worktree});if(l.code!==0){c1.info("batched ls-tree failed, falling back to single-file revert",{hash:z0.hash,files:u0.length});for(let y of u0)yield*e(y);Q0=m;continue}let t=new Set(l.text.trim().split(`
|
|
521
|
+
`).map((y)=>y.trim()).filter(Boolean)),h=u0.filter((y)=>t.has(y.rel));if(h.length){if(c1.info("reverting",{hash:z0.hash,files:h.length}),(yield*H([...S5,...K(["checkout",z0.hash,"--",...h.map((p)=>p.file)])],{cwd:W.worktree})).code!==0){c1.info("batched checkout failed, falling back to single-file revert",{hash:z0.hash,files:h.length});for(let p of u0)yield*e(p);Q0=m;continue}}for(let y of u0){if(t.has(y.rel))continue;c1.info("file did not exist in snapshot, deleting",{file:y.file,hash:y.hash}),yield*q(y.file)}Q0=m}}))}),k=T.fnUntraced(function*(x){return yield*w(T.gen(function*(){yield*L();let g=yield*H([..._5,...K(["diff","--cached","--no-ext-diff",x,"--","."])],{cwd:W.worktree});if(g.code!==0)return c1.warn("failed to get diff",{hash:x,exitCode:g.code,stderr:g.stderr}),"";return g.text.trim()}))}),u=T.fnUntraced(function*(x,g){return yield*w(T.gen(function*(){let c=T.fnUntraced(function*(y){if(y.binary)return["",""];if(y.status==="added")return["",yield*H([...vZ,...K(["show",`${g}:${y.file}`])]).pipe(T.map((p)=>p.text))];if(y.status==="deleted")return[yield*H([...vZ,...K(["show",`${x}:${y.file}`])]).pipe(T.map((p)=>p.text)),""];return yield*T.all([H([...vZ,...K(["show",`${x}:${y.file}`])]).pipe(T.map((p)=>p.text)),H([...vZ,...K(["show",`${g}:${y.file}`])]).pipe(T.map((p)=>p.text))],{concurrency:2})}),e=T.fnUntraced(function*(y){let p=y.flatMap((W0)=>{if(W0.binary)return[];if(W0.status==="added")return[{file:W0.file,side:"after",ref:`${g}:${W0.file}`}];if(W0.status==="deleted")return[{file:W0.file,side:"before",ref:`${x}:${W0.file}`}];return[{file:W0.file,side:"before",ref:`${x}:${W0.file}`},{file:W0.file,side:"after",ref:`${g}:${W0.file}`}]});if(!p.length)return new Map;let d=hU.make("git",[...vZ,...K(["cat-file","--batch"])],{cwd:W.directory,extendEnv:!0,stdin:I$.make(new TextEncoder().encode(p.map((W0)=>W0.ref).join(`
|
|
522
|
+
`)+`
|
|
523
|
+
`))}),a=yield*Z.spawn(d),[s,H0]=yield*T.all([I$.mkUint8Array(a.stdout),I$.mkString(I$.decodeText(a.stderr))],{concurrency:2});if((yield*a.exitCode)!==0){c1.info("git cat-file --batch failed during snapshot diff, falling back to per-file git show",{stderr:H0,refs:p.length});return}let C0=(W0,j0)=>{c1.info(W0,{...j0,refs:p.length});return},p0=new Map,r=new TextDecoder,F0=0;for(let W0 of p){let j0=F0;while(j0<s.length&&s[j0]!==10)j0+=1;if(j0>=s.length)return C0("git cat-file --batch returned a truncated header during snapshot diff, falling back to per-file git show");let X1=r.decode(s.slice(F0,j0));F0=j0+1;let E0=p0.get(W0.file)??{before:"",after:""};if(X1.endsWith(" missing")){p0.set(W0.file,E0);continue}let G1=X1.match(/^[0-9a-f]+ blob (\d+)$/);if(!G1)return C0("git cat-file --batch returned an unexpected header during snapshot diff, falling back to per-file git show",{head:X1});let T0=Number(G1[1]);if(!Number.isInteger(T0)||T0<0||F0+T0>=s.length||s[F0+T0]!==10)return C0("git cat-file --batch returned truncated content during snapshot diff, falling back to per-file git show",{head:X1});let w1=r.decode(s.slice(F0,F0+T0));if(W0.side==="before")E0.before=w1;if(W0.side==="after")E0.after=w1;p0.set(W0.file,E0),F0+=T0+1}if(F0!==s.length)return C0("git cat-file --batch returned trailing data during snapshot diff, falling back to per-file git show");return p0},T.scoped,T.catch(()=>T.succeed(void 0))),G0=[],Q0=new Map,z0=yield*H([..._5,...K(["diff","--no-ext-diff","--name-status","--no-renames",x,g,"--",R()])],{cwd:W.worktree});for(let y of z0.text.trim().split(`
|
|
524
|
+
`)){if(!y)continue;let[p,d]=y.split("\t");if(!p||!d)continue;Q0.set(d,p.startsWith("A")?"added":p.startsWith("D")?"deleted":"modified")}let m=(yield*H([..._5,...K(["diff","--no-ext-diff","--no-renames","--numstat",x,g,"--",R()])],{cwd:W.worktree})).text.trim().split(`
|
|
525
|
+
`).filter(Boolean).flatMap((y)=>{let[p,d,a]=y.split("\t");if(!a)return[];let s=p==="-"&&d==="-",H0=s?0:parseInt(p),O0=s?0:parseInt(d);return[{file:a,status:Q0.get(a)??"modified",binary:s,additions:Number.isFinite(H0)?H0:0,deletions:Number.isFinite(O0)?O0:0}]}),l=yield*B(m.map((y)=>y.file));if(l.size>0){let y=m.filter((p)=>!l.has(p.file));m.length=0,m.push(...y)}let t=100,h=(y,p,d)=>VJ(QX(y,y,p,d,"","",{context:Number.MAX_SAFE_INTEGER}));for(let y=0;y<m.length;y+=t){let p=m.slice(y,y+t),d=yield*e(p);for(let a of p){let s=d?.get(a.file)??{before:"",after:""},[H0,O0]=a.binary?["",""]:d?[s.before,s.after]:yield*c(a);G0.push({file:a.file,patch:a.binary?"":h(a.file,H0,O0),additions:a.additions,deletions:a.deletions,status:a.status})}}return G0}))});return yield*yw(C(),(x)=>{return c1.error("cleanup loop failed",{cause:hw.pretty(x)}),T.void}),{cleanup:C,track:_,patch:E,restore:f,revert:b,diff:k,diffFull:u}}));return K4.of({init:T.fn("Snapshot.init")(function*(){yield*B0.get(Q)}),cleanup:T.fn("Snapshot.cleanup")(function*(){return yield*B0.useEffect(Q,(G)=>G.cleanup())}),track:T.fn("Snapshot.track")(function*(){return yield*B0.useEffect(Q,(G)=>G.track())}),patch:T.fn("Snapshot.patch")(function*(G){return yield*B0.useEffect(Q,(W)=>W.patch(G))}),restore:T.fn("Snapshot.restore")(function*(G){return yield*B0.useEffect(Q,(W)=>W.restore(G))}),revert:T.fn("Snapshot.revert")(function*(G){return yield*B0.useEffect(Q,(W)=>W.revert(G))}),diff:T.fn("Snapshot.diff")(function*(G){return yield*B0.useEffect(Q,(W)=>W.diff(G))}),diffFull:T.fn("Snapshot.diffFull")(function*(G,W){return yield*B0.useEffect(Q,(K)=>K.diffFull(G,W))})})})),Ta=lw.pipe(R0.provide(uw),R0.provide(w$.defaultLayer),R0.provide(Q8.defaultLayer));var Ra=O.String.pipe(O.brand("ProviderID")),r0=Ra.pipe(g0(($)=>({zod:P.string().pipe(P.custom()),opencode:$.make("opencode"),anthropic:$.make("anthropic"),openai:$.make("openai"),google:$.make("google"),googleVertex:$.make("google-vertex"),githubCopilot:$.make("github-copilot"),amazonBedrock:$.make("amazon-bedrock"),azure:$.make("azure"),openrouter:$.make("openrouter"),mistral:$.make("mistral"),gitlab:$.make("gitlab")}))),Pa=O.String.pipe(O.brand("ModelID")),a1=Pa.pipe(g0(($)=>({zod:P.string().pipe(P.custom())})));var dw=P.object({errorID:P.string(),errorName:P.string(),logFile:P.string()}).meta({ref:"ErrorDiagnostic"}),U4=N1.create("MessageOutputLengthError",P.object({})),f5=N1.create("MessageAbortedError",P.object({message:P.string()})),pw=N1.create("StructuredOutputError",P.object({message:P.string(),retries:P.number()})),H4=N1.create("ProviderAuthError",P.object({providerID:P.string(),message:P.string()})),L6=N1.create("APIError",P.object({message:P.string(),statusCode:P.number().optional(),isRetryable:P.boolean(),category:P.string().optional(),upstreamCode:P.string().optional(),requestId:P.string().optional(),outputBudgetRecoveryAvailable:P.boolean().optional(),outputBudgetRecoveryTokens:P.number().int().positive().optional(),diagnostic:dw.optional(),responseHeaders:P.record(P.string(),P.string()).optional(),responseBody:P.string().optional(),metadata:P.record(P.string(),P.string()).optional()})),GX=N1.create("ContextOverflowError",P.object({message:P.string(),responseBody:P.string().optional()})),cw=N1.create("InvalidOutputError",P.object({message:P.string()})),iw=N1.create("ContentFilterError",P.object({message:P.string()})),nw=N1.create("ModelError",P.object({message:P.string()})),ow=P.object({type:P.literal("text")}).meta({ref:"OutputFormatText"}),sw=P.object({type:P.literal("json_schema"),schema:P.record(P.string(),P.any()).meta({ref:"JSONSchema"}),retryCount:P.number().int().min(0).default(2)}).meta({ref:"OutputFormatJsonSchema"}),rw=P.discriminatedUnion("type",[ow,sw]).meta({ref:"OutputFormat"}),P8=P.object({id:MZ.zod,sessionID:a0.zod,messageID:o1.zod}),aw=P8.extend({type:P.literal("snapshot"),snapshot:P.string()}).meta({ref:"SnapshotPart"}),tw=P8.extend({type:P.literal("patch"),hash:P.string(),files:P.string().array()}).meta({ref:"PatchPart"}),ew=P8.extend({type:P.literal("text"),text:P.string(),synthetic:P.boolean().optional(),ignored:P.boolean().optional(),time:P.object({start:P.number(),end:P.number().optional()}).optional(),metadata:P.record(P.string(),P.any()).optional()}).meta({ref:"TextPart"}),$L=P8.extend({type:P.literal("reasoning"),text:P.string(),metadata:P.record(P.string(),P.any()).optional(),time:P.object({start:P.number(),end:P.number().optional()})}).meta({ref:"ReasoningPart"}),gU=P.object({text:P.object({value:P.string(),start:P.number().int(),end:P.number().int()}).meta({ref:"FilePartSourceText"})}),ZL=gU.extend({type:P.literal("file"),path:P.string()}).meta({ref:"FileSource"}),JL=gU.extend({type:P.literal("symbol"),path:P.string(),range:X4.Range,name:P.string(),kind:P.number().int()}).meta({ref:"SymbolSource"}),YL=gU.extend({type:P.literal("resource"),clientName:P.string(),uri:P.string()}).meta({ref:"ResourceSource"}),XL=P.discriminatedUnion("type",[ZL,JL,YL]).meta({ref:"FilePartSource"}),uU=P8.extend({type:P.literal("file"),mime:P.string(),filename:P.string().optional(),url:P.string(),source:XL.optional()}).meta({ref:"FilePart"}),QL=P8.extend({type:P.literal("agent"),name:P.string(),source:P.object({value:P.string(),start:P.number().int(),end:P.number().int()}).optional()}).meta({ref:"AgentPart"}),GL=P8.extend({type:P.literal("checkpoint"),checkpointDir:P.string(),checkpointNumber:P.number(),coveredUpTo:o1.zod}).meta({ref:"CheckpointPart"}),WL=P8.extend({type:P.literal("subtask"),prompt:P.string(),description:P.string(),agent:P.string(),model:P.object({providerID:r0.zod,modelID:a1.zod}).optional(),command:P.string().optional()}).meta({ref:"SubtaskPart"}),KL=P8.extend({type:P.literal("compaction"),auto:P.boolean(),overflow:P.boolean().optional(),tail_start_id:o1.zod.optional()}).meta({ref:"CompactionPart"}),VL=P8.extend({type:P.literal("retry"),attempt:P.number(),error:L6.Schema,time:P.object({created:P.number()})}).meta({ref:"RetryPart"}),UL=P8.extend({type:P.literal("step-start"),snapshot:P.string().optional()}).meta({ref:"StepStartPart"}),HL=P.object({total:P.number().optional(),input:P.number(),output:P.number(),reasoning:P.number(),cache:P.object({read:P.number(),write:P.number()})}),BL=P8.extend({type:P.literal("step-finish"),reason:P.string(),snapshot:P.string().optional(),cost:P.number(),costCredits:P.number().optional(),tokens:HL,contextWindow:P.number().optional()}).meta({ref:"StepFinishPart"}),zL=P.object({status:P.literal("pending"),input:P.record(P.string(),P.any()),raw:P.string()}).meta({ref:"ToolStatePending"}),FL=P.object({status:P.literal("running"),input:P.record(P.string(),P.any()),title:P.string().optional(),metadata:P.record(P.string(),P.any()).optional(),time:P.object({start:P.number()})}).meta({ref:"ToolStateRunning"}),AL=P.object({status:P.literal("completed"),input:P.record(P.string(),P.any()),output:P.string(),title:P.string(),metadata:P.record(P.string(),P.any()),time:P.object({start:P.number(),end:P.number(),compacted:P.number().optional()}),attachments:uU.array().optional()}).meta({ref:"ToolStateCompleted"}),OL=P.object({status:P.literal("error"),input:P.record(P.string(),P.any()),error:P.string(),metadata:P.record(P.string(),P.any()).optional(),time:P.object({start:P.number(),end:P.number()})}).meta({ref:"ToolStateError"}),jL=P.discriminatedUnion("status",[zL,FL,AL,OL]).meta({ref:"ToolState"}),NL=P8.extend({type:P.literal("tool"),callID:P.string(),tool:P.string(),state:jL,metadata:P.record(P.string(),P.any()).optional()}).meta({ref:"ToolPart"}),qL=P.object({id:o1.zod,sessionID:a0.zod,agentID:P.string().optional()}),ML=P.object({hookPhase:P.enum(["pre","post"]),hookIteration:P.number().int().nonnegative(),pluginNames:P.array(P.string()),hookIDs:P.array(P.string())}).meta({ref:"Provenance"}),DL=qL.extend({role:P.literal("user"),time:P.object({created:P.number()}),format:rw.optional(),summary:P.object({title:P.string().optional(),body:P.string().optional(),diffs:yZ.FileDiff.array()}).optional(),agent:P.string(),model:P.object({providerID:r0.zod,modelID:a1.zod,variant:P.string().optional()}),system:P.string().optional(),tools:P.record(P.string(),P.boolean()).optional(),provenance:ML.optional(),outputBudgetRecoveryTokens:P.number().int().positive().optional()}).meta({ref:"UserMessage"}),mU=P.discriminatedUnion("type",[ew,WL,$L,uU,NL,UL,BL,aw,tw,QL,VL,GL,KL]).meta({ref:"Part"}),wL=qL.extend({role:P.literal("assistant"),time:P.object({created:P.number(),completed:P.number().optional()}),error:P.discriminatedUnion("name",[H4.Schema,N1.Unknown.Schema,U4.Schema,f5.Schema,pw.Schema,GX.Schema,cw.Schema,iw.Schema,nw.Schema,L6.Schema]).optional(),parentID:o1.zod,modelID:a1.zod,providerID:r0.zod,mode:P.string(),agent:P.string(),path:P.object({cwd:P.string(),root:P.string()}),summary:P.boolean().optional(),cost:P.number(),costCredits:P.number().optional(),tokens:HL,contextWindow:P.number().optional(),structured:P.any().optional(),variant:P.string().optional(),finish:P.string().optional()}).meta({ref:"AssistantMessage"}),lU=P.discriminatedUnion("role",[DL,wL]).meta({ref:"Message"}),Ca={Updated:Q$.define({type:"message.updated",version:1,aggregate:"sessionID",schema:P.object({sessionID:a0.zod,info:lU})}),Removed:Q$.define({type:"message.removed",version:1,aggregate:"sessionID",schema:P.object({sessionID:a0.zod,messageID:o1.zod})}),PartUpdated:Q$.define({type:"message.part.updated",version:1,aggregate:"sessionID",schema:P.object({sessionID:a0.zod,part:mU,time:P.number()})}),PartDelta:T1.define("message.part.delta",P.object({sessionID:a0.zod,messageID:o1.zod,partID:MZ.zod,field:P.string(),delta:P.string()})),PartRemoved:Q$.define({type:"message.part.removed",version:1,aggregate:"sessionID",schema:P.object({sessionID:a0.zod,messageID:o1.zod,partID:MZ.zod})})},Ia=P.object({info:lU,parts:P.array(mU)});var Ea=P.object({id:o1.zod,time:P.number()}),dU={encode($){return Buffer.from(JSON.stringify($)).toString("base64url")},decode($){return Ea.parse(JSON.parse(Buffer.from($,"base64url").toString("utf8")))}},TL=($)=>({...$.data,id:$.id,sessionID:$.session_id,agentID:$.agent_id}),RL=($)=>({...$.data,id:$.id,sessionID:$.session_id,messageID:$.message_id}),ba=($)=>LL(WX(L$.time_created,$.time),j$(m0(L$.time_created,$.time),WX(L$.id,$.id)));function _a($){let Z=$.map((Y)=>Y.id),J=new Map;if(Z.length>0){let Y=W1.use((X)=>X.select().from(C8).where(k5(C8.message_id,Z)).orderBy(C8.message_id,C8.id).all());for(let X of Y){let Q=RL(X),G=J.get(X.message_id);if(G)G.push(Q);else J.set(X.message_id,[Q])}}return $.map((Y)=>({info:TL(Y),parts:J.get(Y.id)??[]}))}function PL($){let Z=$.before?dU.decode($.before):void 0,J=$.agentID==="*"?void 0:m0(L$.agent_id,$.agentID??"main"),Y=j$(m0(L$.session_id,$.sessionID),...Z?[ba(Z)]:[],...J?[J]:[]),X=W1.use((V)=>V.select().from(L$).where(Y).orderBy(o6(L$.time_created),o6(L$.id)).limit($.limit+1).all());if(X.length===0){if(!W1.use((U)=>U.select({id:I1.id}).from(I1).where(m0(I1.id,$.sessionID)).get()))throw new KX({message:`Session not found: ${$.sessionID}`});return{items:[],more:!1}}let Q=X.length>$.limit,G=Q?X.slice(0,$.limit):X,W=_a(G);W.reverse();let K=G.at(-1);return{items:W,more:Q,cursor:Q&&K?dU.encode({id:K.id,time:K.time_created}):void 0}}function*pU($,Z){let Y;while(!0){let X=PL({sessionID:$,limit:50,before:Y,agentID:Z?.agentID});if(X.items.length===0)break;for(let Q=X.items.length-1;Q>=0;Q--)yield X.items[Q];if(!X.more||!X.cursor)break;Y=X.cursor}}function CL($){return W1.use((J)=>J.select().from(C8).where(m0(C8.message_id,$)).orderBy(C8.id).all()).map(RL)}function Sa($){let Z=W1.use((J)=>J.select().from(L$).where(j$(m0(L$.id,$.messageID),m0(L$.session_id,$.sessionID))).get());if(!Z)throw new KX({message:`Message not found: ${$.messageID}`});return{info:TL(Z),parts:CL($.messageID)}}function cU($){let Z=[];for(let J of $)if(Z.push(J),J.info.role==="user"&&J.parts.some((Y)=>Y.type==="checkpoint"||Y.type==="compaction"))break;return Z.reverse(),Z}var fa=T.fnUntraced(function*($,Z){let J=cU(pU($,{agentID:Z?.agentID}));if(!Z?.contextFrom)return J;let Y=pU(Z.contextFrom,{agentID:"main"}),X=cU(Y);if(Z.contextWatermark){let Q=X.findIndex((G)=>G.info.id===Z.contextWatermark);if(Q>=0)return[...X.slice(0,Q+1),...J]}return[...X,...J]});var dT=m6(xL(),1),zJ=m6(xL(),1);var ka=Object.defineProperty,va=($,Z)=>{for(var J in Z)ka($,J,{get:Z[J],enumerable:!0})},nL="AI_InvalidArgumentError",oL=`vercel.ai.error.${nL}`,ya=Symbol.for(oL),sL,t1=class extends c0{constructor({parameter:$,value:Z,message:J}){super({name:nL,message:`Invalid argument for parameter ${$}: ${J}`});this[sL]=!0,this.parameter=$,this.value=Z}static isInstance($){return c0.hasMarker($,oL)}};sL=ya;var xa="AI_InvalidStreamPartError",ha=`vercel.ai.error.${xa}`,ga=Symbol.for(ha),ua;ua=ga;var rL="AI_InvalidToolApprovalError",aL=`vercel.ai.error.${rL}`,ma=Symbol.for(aL),tL,la=class extends c0{constructor({approvalId:$}){super({name:rL,message:`Tool approval response references unknown approvalId: "${$}". No matching tool-approval-request found in message history.`});this[tL]=!0,this.approvalId=$}static isInstance($){return c0.hasMarker($,aL)}};tL=ma;var eL="AI_InvalidToolInputError",$T=`vercel.ai.error.${eL}`,da=Symbol.for($T),ZT,GH=class extends c0{constructor({toolInput:$,toolName:Z,cause:J,message:Y=`Invalid input for tool ${Z}: ${r6(J)}`}){super({name:eL,message:Y,cause:J});this[ZT]=!0,this.toolInput=$,this.toolName=Z}static isInstance($){return c0.hasMarker($,$T)}};ZT=da;var JT="AI_ToolCallNotFoundForApprovalError",YT=`vercel.ai.error.${JT}`,pa=Symbol.for(YT),XT,QT=class extends c0{constructor({toolCallId:$,approvalId:Z}){super({name:JT,message:`Tool call "${$}" not found for approval request "${Z}".`});this[XT]=!0,this.toolCallId=$,this.approvalId=Z}static isInstance($){return c0.hasMarker($,YT)}};XT=pa;var GT="AI_MissingToolResultsError",WT=`vercel.ai.error.${GT}`,ca=Symbol.for(WT),KT,IL=class extends c0{constructor({toolCallIds:$}){super({name:GT,message:`Tool result${$.length>1?"s are":" is"} missing for tool call${$.length>1?"s":""} ${$.join(", ")}.`});this[KT]=!0,this.toolCallIds=$}static isInstance($){return c0.hasMarker($,WT)}};KT=ca;var ia="AI_NoImageGeneratedError",na=`vercel.ai.error.${ia}`,oa=Symbol.for(na),sa;sa=oa;var VT="AI_NoObjectGeneratedError",UT=`vercel.ai.error.${VT}`,ra=Symbol.for(UT),HT,E8=class extends c0{constructor({message:$="No object generated.",cause:Z,text:J,response:Y,usage:X,finishReason:Q}){super({name:VT,message:$,cause:Z});this[HT]=!0,this.text=J,this.response=Y,this.usage=X,this.finishReason=Q}static isInstance($){return c0.hasMarker($,UT)}};HT=ra;var BT="AI_NoOutputGeneratedError",zT=`vercel.ai.error.${BT}`,aa=Symbol.for(zT),FT,ta=class extends c0{constructor({message:$="No output generated.",cause:Z}={}){super({name:BT,message:$,cause:Z});this[FT]=!0}static isInstance($){return c0.hasMarker($,zT)}};FT=aa;var ea="AI_NoSpeechGeneratedError",$t=`vercel.ai.error.${ea}`,Zt=Symbol.for($t),Jt;Jt=Zt;var Yt="AI_NoTranscriptGeneratedError",Xt=`vercel.ai.error.${Yt}`,Qt=Symbol.for(Xt),Gt;Gt=Qt;var Wt="AI_NoVideoGeneratedError",Kt=`vercel.ai.error.${Wt}`,Vt=Symbol.for(Kt),Ut;Ut=Vt;var AT="AI_NoSuchToolError",OT=`vercel.ai.error.${AT}`,Ht=Symbol.for(OT),jT,tU=class extends c0{constructor({toolName:$,availableTools:Z=void 0,message:J=`Model tried to call unavailable tool '${$}'. ${Z===void 0?"No tools are available.":`Available tools: ${Z.join(", ")}.`}`}){super({name:AT,message:J});this[jT]=!0,this.toolName=$,this.availableTools=Z}static isInstance($){return c0.hasMarker($,OT)}};jT=Ht;var NT="AI_ToolCallRepairError",qT=`vercel.ai.error.${NT}`,Bt=Symbol.for(qT),MT,zt=class extends c0{constructor({cause:$,originalError:Z,message:J=`Error repairing tool call: ${r6($)}`}){super({name:NT,message:J,cause:$});this[MT]=!0,this.originalError=Z}static isInstance($){return c0.hasMarker($,qT)}};MT=Bt;var Ft=class extends c0{constructor($){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${$.version} for provider "${$.provider}" and model "${$.modelId}". AI SDK 5 only supports models that implement specification version "v2".`});this.version=$.version,this.provider=$.provider,this.modelId=$.modelId}},DT="AI_UIMessageStreamError",wT=`vercel.ai.error.${DT}`,At=Symbol.for(wT),LT,UJ=class extends c0{constructor({chunkType:$,chunkId:Z,message:J}){super({name:DT,message:J});this[LT]=!0,this.chunkType=$,this.chunkId=Z}static isInstance($){return c0.hasMarker($,wT)}};LT=At;var Ot="AI_InvalidDataContentError",jt=`vercel.ai.error.${Ot}`,Nt=Symbol.for(jt),qt;qt=Nt;var TT="AI_InvalidMessageRoleError",RT=`vercel.ai.error.${TT}`,Mt=Symbol.for(RT),PT,Dt=class extends c0{constructor({role:$,message:Z=`Invalid message role: '${$}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:TT,message:Z});this[PT]=!0,this.role=$}static isInstance($){return c0.hasMarker($,RT)}};PT=Mt;var CT="AI_MessageConversionError",IT=`vercel.ai.error.${CT}`,wt=Symbol.for(IT),ET,Lt=class extends c0{constructor({originalMessage:$,message:Z}){super({name:CT,message:Z});this[ET]=!0,this.originalMessage=$}static isInstance($){return c0.hasMarker($,IT)}};ET=wt;var bT="AI_RetryError",_T=`vercel.ai.error.${bT}`,Tt=Symbol.for(_T),ST,O4=class extends c0{constructor({message:$,reason:Z,errors:J}){super({name:bT,message:$});this[ST]=!0,this.reason=Z,this.errors=J,this.lastError=J[J.length-1]}static isInstance($){return c0.hasMarker($,_T)}};ST=Tt;function y5($){return $===void 0?[]:Array.isArray($)?$:[$]}async function v5($){for(let Z of y5($.callbacks)){if(Z==null)continue;try{await Z($.event)}catch(J){}}}function Rt({warning:$,provider:Z,model:J}){let Y=`AI SDK Warning (${Z} / ${J}):`;switch($.type){case"unsupported":{let X=`${Y} The feature "${$.feature}" is not supported.`;if($.details)X+=` ${$.details}`;return X}case"compatibility":{let X=`${Y} The feature "${$.feature}" is used in a compatibility mode.`;if($.details)X+=` ${$.details}`;return X}case"other":return`${Y} ${$.message}`;default:return`${Y} ${JSON.stringify($,null,2)}`}}var Pt="AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",EL=!1,D4=($)=>{if($.warnings.length===0)return;let Z=globalThis.AI_SDK_LOG_WARNINGS;if(Z===!1)return;if(typeof Z==="function"){Z($);return}if(!EL)EL=!0,console.info(Pt);for(let J of $.warnings)console.warn(Rt({warning:J,provider:$.provider,model:$.model}))};function Ct({provider:$,modelId:Z}){D4({warnings:[{type:"compatibility",feature:"specificationVersion",details:"Using v2 specification compatibility mode. Some features may not be available."}],provider:$,model:Z})}function It($){if($.specificationVersion==="v3")return $;return Ct({provider:$.provider,modelId:$.modelId}),new Proxy($,{get(Z,J){switch(J){case"specificationVersion":return"v3";case"doGenerate":return async(...Y)=>{let X=await Z.doGenerate(...Y);return{...X,finishReason:fT(X.finishReason),usage:kT(X.usage)}};case"doStream":return async(...Y)=>{let X=await Z.doStream(...Y);return{...X,stream:Et(X.stream)}};default:return Z[J]}}})}function Et($){return $.pipeThrough(new TransformStream({transform(Z,J){switch(Z.type){case"finish":J.enqueue({...Z,finishReason:fT(Z.finishReason),usage:kT(Z.usage)});break;default:J.enqueue(Z);break}}}))}function fT($){return{unified:$==="unknown"?"other":$,raw:void 0}}function kT($){return{inputTokens:{total:$.inputTokens,noCache:void 0,cacheRead:$.cachedInputTokens,cacheWrite:void 0},outputTokens:{total:$.outputTokens,text:void 0,reasoning:$.reasoningTokens}}}function w4($){if(typeof $!=="string"){if($.specificationVersion!=="v3"&&$.specificationVersion!=="v2"){let Z=$;throw new Ft({version:Z.specificationVersion,provider:Z.provider,modelId:Z.modelId})}return It($)}return bt().languageModel($)}function bt(){var $;return($=globalThis.AI_SDK_DEFAULT_PROVIDER)!=null?$:iL}function vT($){if($==null)return;if(typeof $==="number")return $;return $.totalMs}function _t($){if($==null||typeof $==="number")return;return $.stepMs}function St($){if($==null||typeof $==="number")return;return $.chunkMs}var ft=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}];var kt=($)=>{let Z=typeof $==="string"?FJ($):$,J=(Z[6]&127)<<21|(Z[7]&127)<<14|(Z[8]&127)<<7|Z[9]&127;return Z.slice(J+10)};function vt($){return typeof $==="string"&&$.startsWith("SUQz")||typeof $!=="string"&&$.length>10&&$[0]===73&&$[1]===68&&$[2]===51?kt($):$}function yt({data:$,signatures:Z}){let J=vt($),Y=typeof J==="string"?FJ(J.substring(0,Math.min(J.length,24))):J;for(let X of Z)if(Y.length>=X.bytesPrefix.length&&X.bytesPrefix.every((Q,G)=>Q===null||Y[G]===Q))return X.mediaType;return}var yT="6.0.168",xT=async({url:$,maxBytes:Z,abortSignal:J})=>{var Y;let X=$.toString();aU(X);try{let Q=await fetch(X,{headers:OX({},`ai-sdk/${yT}`,mL()),signal:J});if(Q.redirected)aU(Q.url);if(!Q.ok)throw new z4({url:X,statusCode:Q.status,statusText:Q.statusText});return{data:await uL({response:Q,url:X,maxBytes:Z!=null?Z:gL}),mediaType:(Y=Q.headers.get("content-type"))!=null?Y:void 0}}catch(Q){if(z4.isInstance(Q))throw Q;throw new z4({url:X,cause:Q})}},xt=($=xT)=>(Z)=>Promise.all(Z.map(async(J)=>J.isUrlSupportedByModel?null:$(J)));function ht($){try{let[Z,J]=$.split(",");return{mediaType:Z.split(";")[0].split(":")[1],base64Content:J}}catch(Z){return{mediaType:void 0,base64Content:void 0}}}var hT=D.union([D.string(),D.instanceof(Uint8Array),D.instanceof(ArrayBuffer),D.custom(($)=>{var Z,J;return(J=(Z=globalThis.Buffer)==null?void 0:Z.isBuffer($))!=null?J:!1},{message:"Must be a Buffer"})]);function gT($){if($ instanceof Uint8Array)return{data:$,mediaType:void 0};if($ instanceof ArrayBuffer)return{data:new Uint8Array($),mediaType:void 0};if(typeof $==="string")try{$=new URL($)}catch(Z){}if($ instanceof URL&&$.protocol==="data:"){let{mediaType:Z,base64Content:J}=ht($.toString());if(Z==null||J==null)throw new c0({name:"InvalidDataContentError",message:`Invalid data URL format in content ${$.toString()}`});return{data:J,mediaType:Z}}return{data:$,mediaType:void 0}}function gt($){if(typeof $==="string")return $;if($ instanceof ArrayBuffer)return HX(new Uint8Array($));return HX($)}async function WH({prompt:$,supportedUrls:Z,download:J=xt()}){let Y=await mt($.messages,J,Z),X=new Map;for(let V of $.messages)if(V.role==="assistant"&&Array.isArray(V.content)){for(let U of V.content)if(U.type==="tool-approval-request"&&"approvalId"in U&&"toolCallId"in U)X.set(U.approvalId,U.toolCallId)}let Q=new Set;for(let V of $.messages)if(V.role==="tool"){for(let U of V.content)if(U.type==="tool-approval-response"){let H=X.get(U.approvalId);if(H)Q.add(H)}}let G=[...$.system!=null?typeof $.system==="string"?[{role:"system",content:$.system}]:y5($.system).map((V)=>({role:"system",content:V.content,providerOptions:V.providerOptions})):[],...$.messages.map((V)=>ut({message:V,downloadedAssets:Y}))],W=[];for(let V of G){if(V.role!=="tool"){W.push(V);continue}let U=W.at(-1);if((U==null?void 0:U.role)==="tool")U.content.push(...V.content);else W.push(V)}let K=new Set;for(let V of W)switch(V.role){case"assistant":{for(let U of V.content)if(U.type==="tool-call"&&!U.providerExecuted)K.add(U.toolCallId);break}case"tool":{for(let U of V.content)if(U.type==="tool-result")K.delete(U.toolCallId);break}case"user":case"system":for(let U of Q)K.delete(U);if(K.size>0)throw new IL({toolCallIds:Array.from(K)});break}for(let V of Q)K.delete(V);if(K.size>0)throw new IL({toolCallIds:Array.from(K)});return W.filter((V)=>V.role!=="tool"||V.content.length>0)}function ut({message:$,downloadedAssets:Z}){let J=$.role;switch(J){case"system":return{role:"system",content:$.content,providerOptions:$.providerOptions};case"user":{if(typeof $.content==="string")return{role:"user",content:[{type:"text",text:$.content}],providerOptions:$.providerOptions};return{role:"user",content:$.content.map((Y)=>lt(Y,Z)).filter((Y)=>Y.type!=="text"||Y.text!==""),providerOptions:$.providerOptions}}case"assistant":{if(typeof $.content==="string")return{role:"assistant",content:[{type:"text",text:$.content}],providerOptions:$.providerOptions};return{role:"assistant",content:$.content.filter((Y)=>Y.type!=="text"||Y.text!==""||Y.providerOptions!=null).filter((Y)=>Y.type!=="tool-approval-request").map((Y)=>{let X=Y.providerOptions;switch(Y.type){case"file":{let{data:Q,mediaType:G}=gT(Y.data);return{type:"file",data:Q,filename:Y.filename,mediaType:G!=null?G:Y.mediaType,providerOptions:X}}case"reasoning":return{type:"reasoning",text:Y.text,providerOptions:X};case"text":return{type:"text",text:Y.text,providerOptions:X};case"tool-call":return{type:"tool-call",toolCallId:Y.toolCallId,toolName:Y.toolName,input:Y.input,providerExecuted:Y.providerExecuted,providerOptions:X};case"tool-result":return{type:"tool-result",toolCallId:Y.toolCallId,toolName:Y.toolName,output:bL(Y.output),providerOptions:X}}}),providerOptions:$.providerOptions}}case"tool":return{role:"tool",content:$.content.filter((Y)=>Y.type!=="tool-approval-response"||Y.providerExecuted).map((Y)=>{switch(Y.type){case"tool-result":return{type:"tool-result",toolCallId:Y.toolCallId,toolName:Y.toolName,output:bL(Y.output),providerOptions:Y.providerOptions};case"tool-approval-response":return{type:"tool-approval-response",approvalId:Y.approvalId,approved:Y.approved,reason:Y.reason}}}),providerOptions:$.providerOptions};default:throw new Dt({role:J})}}async function mt($,Z,J){let Y=$.filter((Q)=>Q.role==="user").map((Q)=>Q.content).filter((Q)=>Array.isArray(Q)).flat().filter((Q)=>Q.type==="image"||Q.type==="file").map((Q)=>{var G;let W=(G=Q.mediaType)!=null?G:Q.type==="image"?"image/*":void 0,K=Q.type==="image"?Q.image:Q.data;if(typeof K==="string")try{K=new URL(K)}catch(V){}return{mediaType:W,data:K}}).filter((Q)=>Q.data instanceof URL).map((Q)=>({url:Q.data,isUrlSupportedByModel:Q.mediaType!=null&&dL({url:Q.data.toString(),mediaType:Q.mediaType,supportedUrls:J})})),X=await Z(Y);return Object.fromEntries(X.map((Q,G)=>Q==null?null:[Y[G].url.toString(),{data:Q.data,mediaType:Q.mediaType}]).filter((Q)=>Q!=null))}function lt($,Z){var J;if($.type==="text")return{type:"text",text:$.text,providerOptions:$.providerOptions};let Y,X=$.type;switch(X){case"image":Y=$.image;break;case"file":Y=$.data;break;default:throw Error(`Unsupported part type: ${X}`)}let{data:Q,mediaType:G}=gT(Y),W=G!=null?G:$.mediaType,K=Q;if(K instanceof URL){let V=Z[K.toString()];if(V)K=V.data,W!=null||(W=V.mediaType)}switch(X){case"image":{if(K instanceof Uint8Array||typeof K==="string")W=(J=yt({data:K,signatures:ft}))!=null?J:W;return{type:"file",mediaType:W!=null?W:"image/*",filename:void 0,data:K,providerOptions:$.providerOptions}}case"file":{if(W==null)throw Error("Media type is missing for file part");return{type:"file",mediaType:W,filename:$.filename,data:K,providerOptions:$.providerOptions}}}}function bL($){if($.type!=="content")return $;return{type:"content",value:$.value.map((Z)=>{if(Z.type!=="media")return Z;if(Z.mediaType.startsWith("image/"))return{type:"image-data",data:Z.data,mediaType:Z.mediaType};return{type:"file-data",data:Z.data,mediaType:Z.mediaType}})}}async function BJ({toolCallId:$,input:Z,output:J,tool:Y,errorMode:X}){if(X==="text")return{type:"error-text",value:r6(J)};else if(X==="json")return{type:"error-json",value:_L(J)};if(Y==null?void 0:Y.toModelOutput)return await Y.toModelOutput({toolCallId:$,input:Z,output:J});return typeof J==="string"?{type:"text",value:J}:{type:"json",value:_L(J)}}function _L($){return $===void 0?null:$}function BX({maxOutputTokens:$,temperature:Z,topP:J,topK:Y,presencePenalty:X,frequencyPenalty:Q,seed:G,stopSequences:W}){if($!=null){if(!Number.isInteger($))throw new t1({parameter:"maxOutputTokens",value:$,message:"maxOutputTokens must be an integer"});if($<1)throw new t1({parameter:"maxOutputTokens",value:$,message:"maxOutputTokens must be >= 1"})}if(Z!=null){if(typeof Z!=="number")throw new t1({parameter:"temperature",value:Z,message:"temperature must be a number"})}if(J!=null){if(typeof J!=="number")throw new t1({parameter:"topP",value:J,message:"topP must be a number"})}if(Y!=null){if(typeof Y!=="number")throw new t1({parameter:"topK",value:Y,message:"topK must be a number"})}if(X!=null){if(typeof X!=="number")throw new t1({parameter:"presencePenalty",value:X,message:"presencePenalty must be a number"})}if(Q!=null){if(typeof Q!=="number")throw new t1({parameter:"frequencyPenalty",value:Q,message:"frequencyPenalty must be a number"})}if(G!=null){if(!Number.isInteger(G))throw new t1({parameter:"seed",value:G,message:"seed must be an integer"})}return{maxOutputTokens:$,temperature:Z,topP:J,topK:Y,presencePenalty:X,frequencyPenalty:Q,stopSequences:W,seed:G}}function dt($){return $!=null&&Object.keys($).length>0}async function pt({tools:$,toolChoice:Z,activeTools:J}){if(!dt($))return{tools:void 0,toolChoice:void 0};let Y=J!=null?Object.entries($).filter(([Q])=>J.includes(Q)):Object.entries($),X=[];for(let[Q,G]of Y){let W=G.type;switch(W){case void 0:case"dynamic":case"function":X.push({type:"function",name:Q,description:G.description,inputSchema:await v8(G.inputSchema).jsonSchema,...G.inputExamples!=null?{inputExamples:G.inputExamples}:{},providerOptions:G.providerOptions,...G.strict!=null?{strict:G.strict}:{}});break;case"provider":X.push({type:"provider",name:Q,id:G.id,args:G.args});break;default:throw Error(`Unsupported tool type: ${W}`)}}return{tools:X,toolChoice:Z==null?{type:"auto"}:typeof Z==="string"?{type:Z}:{type:"tool",toolName:Z.toolName}}}var zX=D.lazy(()=>D.union([D.null(),D.string(),D.number(),D.boolean(),D.record(D.string(),zX.optional()),D.array(zX)])),q0=D.record(D.string(),D.record(D.string(),zX.optional())),uT=D.object({type:D.literal("text"),text:D.string(),providerOptions:q0.optional()}),ct=D.object({type:D.literal("image"),image:D.union([hT,D.instanceof(URL)]),mediaType:D.string().optional(),providerOptions:q0.optional()}),mT=D.object({type:D.literal("file"),data:D.union([hT,D.instanceof(URL)]),filename:D.string().optional(),mediaType:D.string(),providerOptions:q0.optional()}),it=D.object({type:D.literal("reasoning"),text:D.string(),providerOptions:q0.optional()}),nt=D.object({type:D.literal("tool-call"),toolCallId:D.string(),toolName:D.string(),input:D.unknown(),providerOptions:q0.optional(),providerExecuted:D.boolean().optional()}),ot=D.discriminatedUnion("type",[D.object({type:D.literal("text"),value:D.string(),providerOptions:q0.optional()}),D.object({type:D.literal("json"),value:zX,providerOptions:q0.optional()}),D.object({type:D.literal("execution-denied"),reason:D.string().optional(),providerOptions:q0.optional()}),D.object({type:D.literal("error-text"),value:D.string(),providerOptions:q0.optional()}),D.object({type:D.literal("error-json"),value:zX,providerOptions:q0.optional()}),D.object({type:D.literal("content"),value:D.array(D.union([D.object({type:D.literal("text"),text:D.string(),providerOptions:q0.optional()}),D.object({type:D.literal("media"),data:D.string(),mediaType:D.string()}),D.object({type:D.literal("file-data"),data:D.string(),mediaType:D.string(),filename:D.string().optional(),providerOptions:q0.optional()}),D.object({type:D.literal("file-url"),url:D.string(),providerOptions:q0.optional()}),D.object({type:D.literal("file-id"),fileId:D.union([D.string(),D.record(D.string(),D.string())]),providerOptions:q0.optional()}),D.object({type:D.literal("image-data"),data:D.string(),mediaType:D.string(),providerOptions:q0.optional()}),D.object({type:D.literal("image-url"),url:D.string(),providerOptions:q0.optional()}),D.object({type:D.literal("image-file-id"),fileId:D.union([D.string(),D.record(D.string(),D.string())]),providerOptions:q0.optional()}),D.object({type:D.literal("custom"),providerOptions:q0.optional()})]))})]),lT=D.object({type:D.literal("tool-result"),toolCallId:D.string(),toolName:D.string(),output:ot,providerOptions:q0.optional()}),st=D.object({type:D.literal("tool-approval-request"),approvalId:D.string(),toolCallId:D.string()}),rt=D.object({type:D.literal("tool-approval-response"),approvalId:D.string(),approved:D.boolean(),reason:D.string().optional()}),at=D.object({role:D.literal("system"),content:D.string(),providerOptions:q0.optional()}),tt=D.object({role:D.literal("user"),content:D.union([D.string(),D.array(D.union([uT,ct,mT]))]),providerOptions:q0.optional()}),et=D.object({role:D.literal("assistant"),content:D.union([D.string(),D.array(D.union([uT,mT,it,nt,lT,st]))]),providerOptions:q0.optional()}),$e=D.object({role:D.literal("tool"),content:D.array(D.union([lT,rt])),providerOptions:q0.optional()}),Ze=D.union([at,tt,et,$e]);async function KH($){if($.prompt==null&&$.messages==null)throw new xZ({prompt:$,message:"prompt or messages must be defined"});if($.prompt!=null&&$.messages!=null)throw new xZ({prompt:$,message:"prompt and messages cannot be defined at the same time"});if($.system!=null&&typeof $.system!=="string"&&!y5($.system).every((Y)=>typeof Y==="object"&&Y!==null&&("role"in Y)&&Y.role==="system"))throw new xZ({prompt:$,message:"system must be a string, SystemModelMessage, or array of SystemModelMessage"});let Z;if($.prompt!=null&&typeof $.prompt==="string")Z=[{role:"user",content:$.prompt}];else if($.prompt!=null&&Array.isArray($.prompt))Z=$.prompt;else if($.messages!=null)Z=$.messages;else throw new xZ({prompt:$,message:"prompt or messages must be defined"});if(Z.length===0)throw new xZ({prompt:$,message:"messages must not be empty"});let J=await y8({value:Z,schema:D.array(Ze)});if(!J.success)throw new xZ({prompt:$,message:"The messages do not match the ModelMessage[] schema.",cause:J.error});return{messages:Z,system:$.system}}function VH($){if(!cL.isInstance($))return $;let Z=(process==null?void 0:"development")==="production",J="https://ai-sdk.dev/unauthenticated-ai-gateway";if(Z)return new c0({name:"GatewayError",message:`Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${J}`});return Object.assign(Error(`\x1B[1m\x1B[31mUnauthenticated request to AI Gateway.\x1B[0m
|
|
526
|
+
|
|
527
|
+
To authenticate, set the \x1B[33mAI_GATEWAY_API_KEY\x1B[0m environment variable with your API key.
|
|
528
|
+
|
|
529
|
+
Alternatively, you can use a provider module instead of the AI Gateway.
|
|
530
|
+
|
|
531
|
+
Learn more: \x1B[34m${J}\x1B[0m
|
|
532
|
+
|
|
533
|
+
`),{name:"GatewayAuthenticationError"})}function x5({operationId:$,telemetry:Z}){return{"operation.name":`${$}${(Z==null?void 0:Z.functionId)!=null?` ${Z.functionId}`:""}`,"resource.name":Z==null?void 0:Z.functionId,"ai.operationId":$,"ai.telemetry.functionId":Z==null?void 0:Z.functionId}}function UH({model:$,settings:Z,telemetry:J,headers:Y}){var X;return{"ai.model.provider":$.provider,"ai.model.id":$.modelId,...Object.entries(Z).reduce((Q,[G,W])=>{if(G==="timeout"){let K=vT(W);if(K!=null)Q[`ai.settings.${G}`]=K}else Q[`ai.settings.${G}`]=W;return Q},{}),...Object.entries((X=J==null?void 0:J.metadata)!=null?X:{}).reduce((Q,[G,W])=>{return Q[`ai.telemetry.metadata.${G}`]=W,Q},{}),...Object.entries(Y!=null?Y:{}).reduce((Q,[G,W])=>{if(W!==void 0)Q[`ai.request.headers.${G}`]=W;return Q},{})}}var Je={startSpan(){return B4},startActiveSpan($,Z,J,Y){if(typeof Z==="function")return Z(B4);if(typeof J==="function")return J(B4);if(typeof Y==="function")return Y(B4)}},B4={spanContext(){return Ye},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},Ye={traceId:"",spanId:"",traceFlags:0};function HH({isEnabled:$=!1,tracer:Z}={}){if(!$)return Je;if(Z)return Z;return dT.trace.getTracer("ai")}async function h5({name:$,tracer:Z,attributes:J,fn:Y,endWhenDone:X=!0}){return Z.startActiveSpan($,{attributes:await J},async(Q)=>{let G=zJ.context.active();try{let W=await zJ.context.with(G,()=>Y(Q));if(X)Q.end();return W}catch(W){try{pT(Q,W)}finally{Q.end()}throw W}})}function pT($,Z){if(Z instanceof Error)$.recordException({name:Z.name,message:Z.message,stack:Z.stack}),$.setStatus({code:zJ.SpanStatusCode.ERROR,message:Z.message});else $.setStatus({code:zJ.SpanStatusCode.ERROR})}async function r$({telemetry:$,attributes:Z}){if(($==null?void 0:$.isEnabled)!==!0)return{};let J={};for(let[Y,X]of Object.entries(Z)){if(X==null)continue;if(typeof X==="object"&&"input"in X&&typeof X.input==="function"){if(($==null?void 0:$.recordInputs)===!1)continue;let Q=await X.input();if(Q!=null)J[Y]=Q;continue}if(typeof X==="object"&&"output"in X&&typeof X.output==="function"){if(($==null?void 0:$.recordOutputs)===!1)continue;let Q=await X.output();if(Q!=null)J[Y]=Q;continue}J[Y]=X}return J}function BH($){return JSON.stringify($.map((Z)=>({...Z,content:typeof Z.content==="string"?Z.content:Z.content.map((J)=>J.type==="file"?{...J,data:J.data instanceof Uint8Array?gt(J.data):J.data}:J)})))}function Xe(){var $;return($=globalThis.AI_SDK_TELEMETRY_INTEGRATIONS)!=null?$:[]}function Qe(){let $=Xe();return(Z)=>{let J=y5(Z),Y=[...$,...J];function X(Q){let G=Y.map(Q).filter(Boolean);return async(W)=>{for(let K of G)try{await K(W)}catch(V){}}}return{onStart:X((Q)=>Q.onStart),onStepStart:X((Q)=>Q.onStepStart),onToolCallStart:X((Q)=>Q.onToolCallStart),onToolCallFinish:X((Q)=>Q.onToolCallFinish),onStepFinish:X((Q)=>Q.onStepFinish),onFinish:X((Q)=>Q.onFinish)}}}function j4($){return{inputTokens:$.inputTokens.total,inputTokenDetails:{noCacheTokens:$.inputTokens.noCache,cacheReadTokens:$.inputTokens.cacheRead,cacheWriteTokens:$.inputTokens.cacheWrite},outputTokens:$.outputTokens.total,outputTokenDetails:{textTokens:$.outputTokens.text,reasoningTokens:$.outputTokens.reasoning},totalTokens:t8($.inputTokens.total,$.outputTokens.total),raw:$.raw,reasoningTokens:$.outputTokens.reasoning,cachedInputTokens:$.inputTokens.cacheRead}}function F4(){return{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0}}function Ge($,Z){var J,Y,X,Q,G,W,K,V,U,H;return{inputTokens:t8($.inputTokens,Z.inputTokens),inputTokenDetails:{noCacheTokens:t8((J=$.inputTokenDetails)==null?void 0:J.noCacheTokens,(Y=Z.inputTokenDetails)==null?void 0:Y.noCacheTokens),cacheReadTokens:t8((X=$.inputTokenDetails)==null?void 0:X.cacheReadTokens,(Q=Z.inputTokenDetails)==null?void 0:Q.cacheReadTokens),cacheWriteTokens:t8((G=$.inputTokenDetails)==null?void 0:G.cacheWriteTokens,(W=Z.inputTokenDetails)==null?void 0:W.cacheWriteTokens)},outputTokens:t8($.outputTokens,Z.outputTokens),outputTokenDetails:{textTokens:t8((K=$.outputTokenDetails)==null?void 0:K.textTokens,(V=Z.outputTokenDetails)==null?void 0:V.textTokens),reasoningTokens:t8((U=$.outputTokenDetails)==null?void 0:U.reasoningTokens,(H=Z.outputTokenDetails)==null?void 0:H.reasoningTokens)},totalTokens:t8($.totalTokens,Z.totalTokens),reasoningTokens:t8($.reasoningTokens,Z.reasoningTokens),cachedInputTokens:t8($.cachedInputTokens,Z.cachedInputTokens)}}function t8($,Z){return $==null&&Z==null?void 0:($!=null?$:0)+(Z!=null?Z:0)}function zH($,Z){if($===void 0&&Z===void 0)return;if($===void 0)return Z;if(Z===void 0)return $;let J={...$};for(let Y in Z)if(Object.prototype.hasOwnProperty.call(Z,Y)){let X=Z[Y];if(X===void 0)continue;let Q=Y in $?$[Y]:void 0,G=X!==null&&typeof X==="object"&&!Array.isArray(X)&&!(X instanceof Date)&&!(X instanceof RegExp),W=Q!==null&&Q!==void 0&&typeof Q==="object"&&!Array.isArray(Q)&&!(Q instanceof Date)&&!(Q instanceof RegExp);if(G&&W)J[Y]=zH(Q,X);else J[Y]=X}return J}function We({error:$,exponentialBackoffDelay:Z}){let J=$.responseHeaders;if(!J)return Z;let Y,X=J["retry-after-ms"];if(X){let G=parseFloat(X);if(!Number.isNaN(G))Y=G}let Q=J["retry-after"];if(Q&&Y===void 0){let G=parseFloat(Q);if(!Number.isNaN(G))Y=G*1000;else Y=Date.parse(Q)-Date.now()}if(Y!=null&&!Number.isNaN(Y)&&0<=Y&&(Y<60000||Y<Z))return Y;return Z}var Ke=({maxRetries:$=2,initialDelayInMs:Z=2000,backoffFactor:J=2,abortSignal:Y}={})=>async(X)=>cT(X,{maxRetries:$,delayInMs:Z,backoffFactor:J,abortSignal:Y});async function cT($,{maxRetries:Z,delayInMs:J,backoffFactor:Y,abortSignal:X},Q=[]){try{return await $()}catch(G){if(q4(G))throw G;if(Z===0)throw G;let W=AX(G),K=[...Q,G],V=K.length;if(V>Z)throw new O4({message:`Failed after ${V} attempts. Last error: ${W}`,reason:"maxRetriesExceeded",errors:K});if(G instanceof Error&&FX.isInstance(G)&&G.isRetryable===!0&&V<=Z)return await hL(We({error:G,exponentialBackoffDelay:J}),{abortSignal:X}),cT($,{maxRetries:Z,delayInMs:Y*J,backoffFactor:Y,abortSignal:X},K);if(V===1)throw G;throw new O4({message:`Failed after ${V} attempts with non-retryable error: '${W}'`,reason:"errorNotRetryable",errors:K})}}function FH({maxRetries:$,abortSignal:Z}){if($!=null){if(!Number.isInteger($))throw new t1({parameter:"maxRetries",value:$,message:"maxRetries must be an integer"});if($<0)throw new t1({parameter:"maxRetries",value:$,message:"maxRetries must be >= 0"})}let J=$!=null?$:2;return{maxRetries:J,retry:Ke({maxRetries:J,abortSignal:Z})}}function Ve({messages:$}){let Z=$.at(-1);if((Z==null?void 0:Z.role)!="tool")return{approvedToolApprovals:[],deniedToolApprovals:[]};let J={};for(let K of $)if(K.role==="assistant"&&typeof K.content!=="string"){let V=K.content;for(let U of V)if(U.type==="tool-call")J[U.toolCallId]=U}let Y={};for(let K of $)if(K.role==="assistant"&&typeof K.content!=="string"){let V=K.content;for(let U of V)if(U.type==="tool-approval-request")Y[U.approvalId]=U}let X={};for(let K of Z.content)if(K.type==="tool-result")X[K.toolCallId]=K;let Q=[],G=[],W=Z.content.filter((K)=>K.type==="tool-approval-response");for(let K of W){let V=Y[K.approvalId];if(V==null)throw new la({approvalId:K.approvalId});if(X[V.toolCallId]!=null)continue;let U=J[V.toolCallId];if(U==null)throw new QT({toolCallId:V.toolCallId,approvalId:V.approvalId});let H={approvalRequest:V,approvalResponse:K,toolCall:U};if(K.approved)Q.push(H);else G.push(H)}return{approvedToolApprovals:Q,deniedToolApprovals:G}}function VX(){var $,Z;return(Z=($=globalThis==null?void 0:globalThis.performance)==null?void 0:$.now())!=null?Z:Date.now()}async function iT({toolCall:$,tools:Z,tracer:J,telemetry:Y,messages:X,abortSignal:Q,experimental_context:G,stepNumber:W,model:K,onPreliminaryToolResult:V,onToolCallStart:U,onToolCallFinish:H}){let{toolName:B,toolCallId:z,input:F}=$,A=Z==null?void 0:Z[B];if((A==null?void 0:A.execute)==null)return;let N={stepNumber:W,model:K,toolCall:$,messages:X,abortSignal:Q,functionId:Y==null?void 0:Y.functionId,metadata:Y==null?void 0:Y.metadata,experimental_context:G};return h5({name:"ai.toolCall",attributes:r$({telemetry:Y,attributes:{...x5({operationId:"ai.toolCall",telemetry:Y}),"ai.toolCall.name":B,"ai.toolCall.id":z,"ai.toolCall.args":{output:()=>JSON.stringify(F)}}}),tracer:J,fn:async(q)=>{let w;await v5({event:N,callbacks:U});let j=VX();try{let I=pL({execute:A.execute.bind(A),input:F,options:{toolCallId:z,messages:X,abortSignal:Q,experimental_context:G}});for await(let R of I)if(R.type==="preliminary")V==null||V({...$,type:"tool-result",output:R.output,preliminary:!0});else w=R.output}catch(I){let R=VX()-j;return await v5({event:{...N,success:!1,error:I,durationMs:R},callbacks:H}),pT(q,I),{type:"tool-error",toolCallId:z,toolName:B,input:F,error:I,dynamic:A.type==="dynamic",...$.providerMetadata!=null?{providerMetadata:$.providerMetadata}:{}}}let M=VX()-j;await v5({event:{...N,success:!0,output:w,durationMs:M},callbacks:H});try{q.setAttributes(await r$({telemetry:Y,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(w)}}}))}catch(I){}return{type:"tool-result",toolCallId:z,toolName:B,input:F,output:w,dynamic:A.type==="dynamic",...$.providerMetadata!=null?{providerMetadata:$.providerMetadata}:{}}}})}function Ue($){let Z=$.filter((J)=>J.type==="reasoning");return Z.length===0?void 0:Z.map((J)=>J.text).join(`
|
|
534
|
+
`)}function He($){let Z=$.filter((J)=>J.type==="text");if(Z.length===0)return;return Z.map((J)=>J.text).join("")}var Be=class{constructor({data:$,mediaType:Z}){let J=$ instanceof Uint8Array;this.base64Data=J?void 0:$,this.uint8ArrayData=J?$:void 0,this.mediaType=Z}get base64(){if(this.base64Data==null)this.base64Data=HX(this.uint8ArrayData);return this.base64Data}get uint8Array(){if(this.uint8ArrayData==null)this.uint8ArrayData=FJ(this.base64Data);return this.uint8ArrayData}},ze=class extends Be{constructor($){super($);this.type="file"}};async function Fe({tool:$,toolCall:Z,messages:J,experimental_context:Y}){if($.needsApproval==null)return!1;if(typeof $.needsApproval==="boolean")return $.needsApproval;return await $.needsApproval(Z.input,{toolCallId:Z.toolCallId,messages:J,experimental_context:Y})}var Ae={};va(Ae,{array:()=>Ne,choice:()=>qe,json:()=>Me,object:()=>je,text:()=>eU});function Oe($){let Z=["ROOT"],J=-1,Y=null;function X(K,V,U){switch(K){case'"':{J=V,Z.pop(),Z.push(U),Z.push("INSIDE_STRING");break}case"f":case"t":case"n":{J=V,Y=V,Z.pop(),Z.push(U),Z.push("INSIDE_LITERAL");break}case"-":{Z.pop(),Z.push(U),Z.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{J=V,Z.pop(),Z.push(U),Z.push("INSIDE_NUMBER");break}case"{":{J=V,Z.pop(),Z.push(U),Z.push("INSIDE_OBJECT_START");break}case"[":{J=V,Z.pop(),Z.push(U),Z.push("INSIDE_ARRAY_START");break}}}function Q(K,V){switch(K){case",":{Z.pop(),Z.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{J=V,Z.pop();break}}}function G(K,V){switch(K){case",":{Z.pop(),Z.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{J=V,Z.pop();break}}}for(let K=0;K<$.length;K++){let V=$[K];switch(Z[Z.length-1]){case"ROOT":X(V,K,"FINISH");break;case"INSIDE_OBJECT_START":{switch(V){case'"':{Z.pop(),Z.push("INSIDE_OBJECT_KEY");break}case"}":{J=K,Z.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(V){case'"':{Z.pop(),Z.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(V){case'"':{Z.pop(),Z.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(V){case":":{Z.pop(),Z.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{X(V,K,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{Q(V,K);break}case"INSIDE_STRING":{switch(V){case'"':{Z.pop(),J=K;break}case"\\":{Z.push("INSIDE_STRING_ESCAPE");break}default:J=K}break}case"INSIDE_ARRAY_START":{switch(V){case"]":{J=K,Z.pop();break}default:{J=K,X(V,K,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(V){case",":{Z.pop(),Z.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{J=K,Z.pop();break}default:{J=K;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{X(V,K,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{Z.pop(),J=K;break}case"INSIDE_NUMBER":{switch(V){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{J=K;break}case"e":case"E":case"-":case".":break;case",":{if(Z.pop(),Z[Z.length-1]==="INSIDE_ARRAY_AFTER_VALUE")G(V,K);if(Z[Z.length-1]==="INSIDE_OBJECT_AFTER_VALUE")Q(V,K);break}case"}":{if(Z.pop(),Z[Z.length-1]==="INSIDE_OBJECT_AFTER_VALUE")Q(V,K);break}case"]":{if(Z.pop(),Z[Z.length-1]==="INSIDE_ARRAY_AFTER_VALUE")G(V,K);break}default:{Z.pop();break}}break}case"INSIDE_LITERAL":{let H=$.substring(Y,K+1);if(!"false".startsWith(H)&&!"true".startsWith(H)&&!"null".startsWith(H)){if(Z.pop(),Z[Z.length-1]==="INSIDE_OBJECT_AFTER_VALUE")Q(V,K);else if(Z[Z.length-1]==="INSIDE_ARRAY_AFTER_VALUE")G(V,K)}else J=K;break}}}let W=$.slice(0,J+1);for(let K=Z.length-1;K>=0;K--)switch(Z[K]){case"INSIDE_STRING":{W+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{W+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{W+="]";break}case"INSIDE_LITERAL":{let U=$.substring(Y,$.length);if("true".startsWith(U))W+="true".slice(U.length);else if("false".startsWith(U))W+="false".slice(U.length);else if("null".startsWith(U))W+="null".slice(U.length)}}return W}async function AJ($){if($===void 0)return{value:void 0,state:"undefined-input"};let Z=await W8({text:$});if(Z.success)return{value:Z.value,state:"successful-parse"};if(Z=await W8({text:Oe($)}),Z.success)return{value:Z.value,state:"repaired-parse"};return{value:void 0,state:"failed-parse"}}var eU=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:$}){return $},async parsePartialOutput({text:$}){return{partial:$}},createElementStreamTransform(){return}}),je=({schema:$,name:Z,description:J})=>{let Y=v8($);return{name:"object",responseFormat:QH(Y.jsonSchema).then((X)=>({type:"json",schema:X,...Z!=null&&{name:Z},...J!=null&&{description:J}})),async parseCompleteOutput({text:X},Q){let G=await W8({text:X});if(!G.success)throw new E8({message:"No object generated: could not parse the response.",cause:G.error,text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason});let W=await y8({value:G.value,schema:Y});if(!W.success)throw new E8({message:"No object generated: response did not match schema.",cause:W.error,text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason});return W.value},async parsePartialOutput({text:X}){let Q=await AJ(X);switch(Q.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:Q.value}}},createElementStreamTransform(){return}}},Ne=({element:$,name:Z,description:J})=>{let Y=v8($);return{name:"array",responseFormat:QH(Y.jsonSchema).then((X)=>{let{$schema:Q,...G}=X;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:G}},required:["elements"],additionalProperties:!1},...Z!=null&&{name:Z},...J!=null&&{description:J}}}),async parseCompleteOutput({text:X},Q){let G=await W8({text:X});if(!G.success)throw new E8({message:"No object generated: could not parse the response.",cause:G.error,text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason});let W=G.value;if(W==null||typeof W!=="object"||!("elements"in W)||!Array.isArray(W.elements))throw new E8({message:"No object generated: response did not match schema.",cause:new I8({value:W,cause:"response must be an object with an elements array"}),text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason});for(let K of W.elements){let V=await y8({value:K,schema:Y});if(!V.success)throw new E8({message:"No object generated: response did not match schema.",cause:V.error,text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason})}return W.elements},async parsePartialOutput({text:X}){let Q=await AJ(X);switch(Q.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{let G=Q.value;if(G==null||typeof G!=="object"||!("elements"in G)||!Array.isArray(G.elements))return;let W=Q.state==="repaired-parse"&&G.elements.length>0?G.elements.slice(0,-1):G.elements,K=[];for(let V of W){let U=await y8({value:V,schema:Y});if(U.success)K.push(U.value)}return{partial:K}}}},createElementStreamTransform(){let X=0;return new TransformStream({transform({partialOutput:Q},G){if(Q!=null)for(;X<Q.length;X++)G.enqueue(Q[X])}})}}},qe=({options:$,name:Z,description:J})=>{return{name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:$}},required:["result"],additionalProperties:!1},...Z!=null&&{name:Z},...J!=null&&{description:J}}),async parseCompleteOutput({text:Y},X){let Q=await W8({text:Y});if(!Q.success)throw new E8({message:"No object generated: could not parse the response.",cause:Q.error,text:Y,response:X.response,usage:X.usage,finishReason:X.finishReason});let G=Q.value;if(G==null||typeof G!=="object"||!("result"in G)||typeof G.result!=="string"||!$.includes(G.result))throw new E8({message:"No object generated: response did not match schema.",cause:new I8({value:G,cause:"response must be an object that contains a choice value."}),text:Y,response:X.response,usage:X.usage,finishReason:X.finishReason});return G.result},async parsePartialOutput({text:Y}){let X=await AJ(Y);switch(X.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{let Q=X.value;if(Q==null||typeof Q!=="object"||!("result"in Q)||typeof Q.result!=="string")return;let G=$.filter((W)=>W.startsWith(Q.result));if(X.state==="successful-parse")return G.includes(Q.result)?{partial:Q.result}:void 0;else return G.length===1?{partial:G[0]}:void 0}}},createElementStreamTransform(){return}}},Me=({name:$,description:Z}={})=>{return{name:"json",responseFormat:Promise.resolve({type:"json",...$!=null&&{name:$},...Z!=null&&{description:Z}}),async parseCompleteOutput({text:J},Y){let X=await W8({text:J});if(!X.success)throw new E8({message:"No object generated: could not parse the response.",cause:X.error,text:J,response:Y.response,usage:Y.usage,finishReason:Y.finishReason});return X.value},async parsePartialOutput({text:J}){let Y=await AJ(J);switch(Y.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return Y.value===void 0?void 0:{partial:Y.value}}},createElementStreamTransform(){return}}};async function De({toolCall:$,tools:Z,repairToolCall:J,system:Y,messages:X}){var Q;try{if(Z==null){if($.providerExecuted&&$.dynamic)return await nT($);throw new tU({toolName:$.toolName})}try{return await SL({toolCall:$,tools:Z})}catch(G){if(J==null||!(tU.isInstance(G)||GH.isInstance(G)))throw G;let W=null;try{W=await J({toolCall:$,tools:Z,inputSchema:async({toolName:K})=>{let{inputSchema:V}=Z[K];return await v8(V).jsonSchema},system:Y,messages:X,error:G})}catch(K){throw new zt({cause:K,originalError:G})}if(W==null)throw G;return await SL({toolCall:W,tools:Z})}}catch(G){let W=await W8({text:$.input}),K=W.success?W.value:$.input;return{type:"tool-call",toolCallId:$.toolCallId,toolName:$.toolName,input:K,dynamic:!0,invalid:!0,error:G,title:(Q=Z==null?void 0:Z[$.toolName])==null?void 0:Q.title,providerExecuted:$.providerExecuted,providerMetadata:$.providerMetadata}}}async function nT($){let Z=$.input.trim()===""?{success:!0,value:{}}:await W8({text:$.input});if(Z.success===!1)throw new GH({toolName:$.toolName,toolInput:$.input,cause:Z.error});return{type:"tool-call",toolCallId:$.toolCallId,toolName:$.toolName,input:Z.value,providerExecuted:!0,dynamic:!0,providerMetadata:$.providerMetadata}}async function SL({toolCall:$,tools:Z}){let J=$.toolName,Y=Z[J];if(Y==null){if($.providerExecuted&&$.dynamic)return await nT($);throw new tU({toolName:$.toolName,availableTools:Object.keys(Z)})}let X=v8(Y.inputSchema),Q=$.input.trim()===""?await y8({value:{},schema:X}):await W8({text:$.input,schema:X});if(Q.success===!1)throw new GH({toolName:J,toolInput:$.input,cause:Q.error});return Y.type==="dynamic"?{type:"tool-call",toolCallId:$.toolCallId,toolName:$.toolName,input:Q.value,providerExecuted:$.providerExecuted,providerMetadata:$.providerMetadata,dynamic:!0,title:Y.title}:{type:"tool-call",toolCallId:$.toolCallId,toolName:J,input:Q.value,providerExecuted:$.providerExecuted,providerMetadata:$.providerMetadata,title:Y.title}}var we=class{constructor({stepNumber:$,model:Z,functionId:J,metadata:Y,experimental_context:X,content:Q,finishReason:G,rawFinishReason:W,usage:K,warnings:V,request:U,response:H,providerMetadata:B}){this.stepNumber=$,this.model=Z,this.functionId=J,this.metadata=Y,this.experimental_context=X,this.content=Q,this.finishReason=G,this.rawFinishReason=W,this.usage=K,this.warnings=V,this.request=U,this.response=H,this.providerMetadata=B}get text(){return this.content.filter(($)=>$.type==="text").map(($)=>$.text).join("")}get reasoning(){return this.content.filter(($)=>$.type==="reasoning")}get reasoningText(){return this.reasoning.length===0?void 0:this.reasoning.map(($)=>$.text).join("")}get files(){return this.content.filter(($)=>$.type==="file").map(($)=>$.file)}get sources(){return this.content.filter(($)=>$.type==="source")}get toolCalls(){return this.content.filter(($)=>$.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(($)=>$.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(($)=>$.dynamic===!0)}get toolResults(){return this.content.filter(($)=>$.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(($)=>$.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(($)=>$.dynamic===!0)}};function Le($){return({steps:Z})=>Z.length===$}async function Te({stopConditions:$,steps:Z}){return(await Promise.all($.map((J)=>J({steps:Z})))).some((J)=>J)}async function fL({content:$,tools:Z}){let J=[],Y=[];for(let Q of $){if(Q.type==="source")continue;if((Q.type==="tool-result"||Q.type==="tool-error")&&!Q.providerExecuted)continue;if(Q.type==="text"&&Q.text.length===0)continue;switch(Q.type){case"text":Y.push({type:"text",text:Q.text,providerOptions:Q.providerMetadata});break;case"reasoning":Y.push({type:"reasoning",text:Q.text,providerOptions:Q.providerMetadata});break;case"file":Y.push({type:"file",data:Q.file.base64,mediaType:Q.file.mediaType,providerOptions:Q.providerMetadata});break;case"tool-call":Y.push({type:"tool-call",toolCallId:Q.toolCallId,toolName:Q.toolName,input:Q.invalid&&typeof Q.input!=="object"?{}:Q.input,providerExecuted:Q.providerExecuted,providerOptions:Q.providerMetadata});break;case"tool-result":{let G=await BJ({toolCallId:Q.toolCallId,input:Q.input,tool:Z==null?void 0:Z[Q.toolName],output:Q.output,errorMode:"none"});Y.push({type:"tool-result",toolCallId:Q.toolCallId,toolName:Q.toolName,output:G,providerOptions:Q.providerMetadata});break}case"tool-error":{let G=await BJ({toolCallId:Q.toolCallId,input:Q.input,tool:Z==null?void 0:Z[Q.toolName],output:Q.error,errorMode:"json"});Y.push({type:"tool-result",toolCallId:Q.toolCallId,toolName:Q.toolName,output:G,providerOptions:Q.providerMetadata});break}case"tool-approval-request":Y.push({type:"tool-approval-request",approvalId:Q.approvalId,toolCallId:Q.toolCall.toolCallId});break}}if(Y.length>0)J.push({role:"assistant",content:Y});let X=[];for(let Q of $){if(!(Q.type==="tool-result"||Q.type==="tool-error")||Q.providerExecuted)continue;let G=await BJ({toolCallId:Q.toolCallId,input:Q.input,tool:Z==null?void 0:Z[Q.toolName],output:Q.type==="tool-result"?Q.output:Q.error,errorMode:Q.type==="tool-error"?"text":"none"});X.push({type:"tool-result",toolCallId:Q.toolCallId,toolName:Q.toolName,output:G,...Q.providerMetadata!=null?{providerOptions:Q.providerMetadata}:{}})}if(X.length>0)J.push({role:"tool",content:X});return J}function Re(...$){let Z=$.filter((Y)=>Y!=null);if(Z.length===0)return;if(Z.length===1)return Z[0];let J=new AbortController;for(let Y of Z){if(Y.aborted)return J.abort(Y.reason),J.signal;Y.addEventListener("abort",()=>{J.abort(Y.reason)},{once:!0})}return J.signal}var sb0=a6({prefix:"aitxt",size:24});function NX($,Z){let J=new Headers($!=null?$:{});for(let[Y,X]of Object.entries(Z))if(!J.has(Y))J.set(Y,X);return J}function oT({status:$,statusText:Z,headers:J,textStream:Y}){return new Response(Y.pipeThrough(new TextEncoderStream),{status:$!=null?$:200,statusText:Z,headers:NX(J,{"content-type":"text/plain; charset=utf-8"})})}function sT({response:$,status:Z,statusText:J,headers:Y,stream:X}){let Q=Z!=null?Z:200;if(J!==void 0)$.writeHead(Q,J,Y);else $.writeHead(Q,Y);let G=X.getReader();(async()=>{try{while(!0){let{done:K,value:V}=await G.read();if(K)break;if(!$.write(V))await new Promise((H)=>{$.once("drain",H)})}}catch(K){throw K}finally{$.end()}})()}function rT({response:$,status:Z,statusText:J,headers:Y,textStream:X}){sT({response:$,status:Z,statusText:J,headers:Object.fromEntries(NX(Y,{"content-type":"text/plain; charset=utf-8"}).entries()),stream:X.pipeThrough(new TextEncoderStream)})}var aT=class extends TransformStream{constructor(){super({transform($,Z){Z.enqueue(`data: ${JSON.stringify($)}
|
|
535
|
+
|
|
536
|
+
`)},flush($){$.enqueue(`data: [DONE]
|
|
537
|
+
|
|
538
|
+
`)}})}},tT={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};function Pe({status:$,statusText:Z,headers:J,stream:Y,consumeSseStream:X}){let Q=Y.pipeThrough(new aT);if(X){let[G,W]=Q.tee();Q=G,X({stream:W})}return new Response(Q.pipeThrough(new TextEncoderStream),{status:$,statusText:Z,headers:NX(J,tT)})}function Ce({originalMessages:$,responseMessageId:Z}){if($==null)return;let J=$[$.length-1];return(J==null?void 0:J.role)==="assistant"?J.id:typeof Z==="function"?Z():Z}var Z_0=M4(()=>jX(D.union([D.strictObject({type:D.literal("text-start"),id:D.string(),providerMetadata:q0.optional()}),D.strictObject({type:D.literal("text-delta"),id:D.string(),delta:D.string(),providerMetadata:q0.optional()}),D.strictObject({type:D.literal("text-end"),id:D.string(),providerMetadata:q0.optional()}),D.strictObject({type:D.literal("error"),errorText:D.string()}),D.strictObject({type:D.literal("tool-input-start"),toolCallId:D.string(),toolName:D.string(),providerExecuted:D.boolean().optional(),providerMetadata:q0.optional(),dynamic:D.boolean().optional(),title:D.string().optional()}),D.strictObject({type:D.literal("tool-input-delta"),toolCallId:D.string(),inputTextDelta:D.string()}),D.strictObject({type:D.literal("tool-input-available"),toolCallId:D.string(),toolName:D.string(),input:D.unknown(),providerExecuted:D.boolean().optional(),providerMetadata:q0.optional(),dynamic:D.boolean().optional(),title:D.string().optional()}),D.strictObject({type:D.literal("tool-input-error"),toolCallId:D.string(),toolName:D.string(),input:D.unknown(),providerExecuted:D.boolean().optional(),providerMetadata:q0.optional(),dynamic:D.boolean().optional(),errorText:D.string(),title:D.string().optional()}),D.strictObject({type:D.literal("tool-approval-request"),approvalId:D.string(),toolCallId:D.string()}),D.strictObject({type:D.literal("tool-output-available"),toolCallId:D.string(),output:D.unknown(),providerExecuted:D.boolean().optional(),providerMetadata:q0.optional(),dynamic:D.boolean().optional(),preliminary:D.boolean().optional()}),D.strictObject({type:D.literal("tool-output-error"),toolCallId:D.string(),errorText:D.string(),providerExecuted:D.boolean().optional(),providerMetadata:q0.optional(),dynamic:D.boolean().optional()}),D.strictObject({type:D.literal("tool-output-denied"),toolCallId:D.string()}),D.strictObject({type:D.literal("reasoning-start"),id:D.string(),providerMetadata:q0.optional()}),D.strictObject({type:D.literal("reasoning-delta"),id:D.string(),delta:D.string(),providerMetadata:q0.optional()}),D.strictObject({type:D.literal("reasoning-end"),id:D.string(),providerMetadata:q0.optional()}),D.strictObject({type:D.literal("source-url"),sourceId:D.string(),url:D.string(),title:D.string().optional(),providerMetadata:q0.optional()}),D.strictObject({type:D.literal("source-document"),sourceId:D.string(),mediaType:D.string(),title:D.string(),filename:D.string().optional(),providerMetadata:q0.optional()}),D.strictObject({type:D.literal("file"),url:D.string(),mediaType:D.string(),providerMetadata:q0.optional()}),D.strictObject({type:D.custom(($)=>typeof $==="string"&&$.startsWith("data-"),{message:'Type must start with "data-"'}),id:D.string().optional(),data:D.unknown(),transient:D.boolean().optional()}),D.strictObject({type:D.literal("start-step")}),D.strictObject({type:D.literal("finish-step")}),D.strictObject({type:D.literal("start"),messageId:D.string().optional(),messageMetadata:D.unknown().optional()}),D.strictObject({type:D.literal("finish"),finishReason:D.enum(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:D.unknown().optional()}),D.strictObject({type:D.literal("abort"),reason:D.string().optional()}),D.strictObject({type:D.literal("message-metadata"),messageMetadata:D.unknown()})])));function Ie($){return $.type.startsWith("data-")}function iU($){return $.type.startsWith("data-")}function nU($){return $.type==="text"}function oU($){return $.type==="file"}function kL($){return $.type==="reasoning"}function $H($){return $.type.startsWith("tool-")}function eT($){return $.type==="dynamic-tool"}function HJ($){return $H($)||eT($)}function ZH($){return $.type.split("-").slice(1).join("-")}function sU($){return eT($)?$.toolName:ZH($)}function Ee({lastMessage:$,messageId:Z}){return{message:($==null?void 0:$.role)==="assistant"?$:{id:Z,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function be({stream:$,messageMetadataSchema:Z,dataPartSchemas:J,runUpdateMessageJob:Y,onError:X,onToolCall:Q,onData:G}){return $.pipeThrough(new TransformStream({async transform(W,K){await Y(async({state:V,write:U})=>{var H,B,z,F;function A(j){let I=V.message.parts.filter(HJ).find((R)=>R.toolCallId===j);if(I==null)throw new UJ({chunkType:"tool-invocation",chunkId:j,message:`No tool invocation found for tool call ID "${j}".`});return I}function N(j){var M;let I=V.message.parts.find((C)=>$H(C)&&C.toolCallId===j.toolCallId),R=j,L=I;if(I!=null){if(I.state=j.state,L.input=R.input,L.output=R.output,L.errorText=R.errorText,L.rawInput=R.rawInput,L.preliminary=R.preliminary,j.title!==void 0)L.title=j.title;L.providerExecuted=(M=R.providerExecuted)!=null?M:I.providerExecuted;let C=R.providerMetadata;if(C!=null)if(j.state==="output-available"||j.state==="output-error"){let _=I;_.resultProviderMetadata=C}else I.callProviderMetadata=C}else V.message.parts.push({type:`tool-${j.toolName}`,toolCallId:j.toolCallId,state:j.state,title:j.title,input:R.input,output:R.output,rawInput:R.rawInput,errorText:R.errorText,providerExecuted:R.providerExecuted,preliminary:R.preliminary,...R.providerMetadata!=null&&(j.state==="output-available"||j.state==="output-error")?{resultProviderMetadata:R.providerMetadata}:{},...R.providerMetadata!=null&&!(j.state==="output-available"||j.state==="output-error")?{callProviderMetadata:R.providerMetadata}:{}})}function q(j){var M,I;let R=V.message.parts.find((_)=>_.type==="dynamic-tool"&&_.toolCallId===j.toolCallId),L=j,C=R;if(R!=null){if(R.state=j.state,C.toolName=j.toolName,C.input=L.input,C.output=L.output,C.errorText=L.errorText,C.rawInput=(M=L.rawInput)!=null?M:C.rawInput,C.preliminary=L.preliminary,j.title!==void 0)C.title=j.title;C.providerExecuted=(I=L.providerExecuted)!=null?I:R.providerExecuted;let _=L.providerMetadata;if(_!=null)if(j.state==="output-available"||j.state==="output-error"){let E=R;E.resultProviderMetadata=_}else R.callProviderMetadata=_}else V.message.parts.push({type:"dynamic-tool",toolName:j.toolName,toolCallId:j.toolCallId,state:j.state,input:L.input,output:L.output,errorText:L.errorText,preliminary:L.preliminary,providerExecuted:L.providerExecuted,title:j.title,...L.providerMetadata!=null&&(j.state==="output-available"||j.state==="output-error")?{resultProviderMetadata:L.providerMetadata}:{},...L.providerMetadata!=null&&!(j.state==="output-available"||j.state==="output-error")?{callProviderMetadata:L.providerMetadata}:{}})}async function w(j){if(j!=null){let M=V.message.metadata!=null?zH(V.message.metadata,j):j;if(Z!=null)await A4({value:M,schema:Z,context:{field:"message.metadata",entityId:V.message.id}});V.message.metadata=M}}switch(W.type){case"text-start":{let j={type:"text",text:"",providerMetadata:W.providerMetadata,state:"streaming"};V.activeTextParts[W.id]=j,V.message.parts.push(j),U();break}case"text-delta":{let j=V.activeTextParts[W.id];if(j==null)throw new UJ({chunkType:"text-delta",chunkId:W.id,message:`Received text-delta for missing text part with ID "${W.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});j.text+=W.delta,j.providerMetadata=(H=W.providerMetadata)!=null?H:j.providerMetadata,U();break}case"text-end":{let j=V.activeTextParts[W.id];if(j==null)throw new UJ({chunkType:"text-end",chunkId:W.id,message:`Received text-end for missing text part with ID "${W.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});j.state="done",j.providerMetadata=(B=W.providerMetadata)!=null?B:j.providerMetadata,delete V.activeTextParts[W.id],U();break}case"reasoning-start":{let j={type:"reasoning",text:"",providerMetadata:W.providerMetadata,state:"streaming"};V.activeReasoningParts[W.id]=j,V.message.parts.push(j),U();break}case"reasoning-delta":{let j=V.activeReasoningParts[W.id];if(j==null)throw new UJ({chunkType:"reasoning-delta",chunkId:W.id,message:`Received reasoning-delta for missing reasoning part with ID "${W.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});j.text+=W.delta,j.providerMetadata=(z=W.providerMetadata)!=null?z:j.providerMetadata,U();break}case"reasoning-end":{let j=V.activeReasoningParts[W.id];if(j==null)throw new UJ({chunkType:"reasoning-end",chunkId:W.id,message:`Received reasoning-end for missing reasoning part with ID "${W.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});j.providerMetadata=(F=W.providerMetadata)!=null?F:j.providerMetadata,j.state="done",delete V.activeReasoningParts[W.id],U();break}case"file":{V.message.parts.push({type:"file",mediaType:W.mediaType,url:W.url,...W.providerMetadata!=null?{providerMetadata:W.providerMetadata}:{}}),U();break}case"source-url":{V.message.parts.push({type:"source-url",sourceId:W.sourceId,url:W.url,title:W.title,providerMetadata:W.providerMetadata}),U();break}case"source-document":{V.message.parts.push({type:"source-document",sourceId:W.sourceId,mediaType:W.mediaType,title:W.title,filename:W.filename,providerMetadata:W.providerMetadata}),U();break}case"tool-input-start":{let j=V.message.parts.filter($H);if(V.partialToolCalls[W.toolCallId]={text:"",toolName:W.toolName,index:j.length,dynamic:W.dynamic,title:W.title},W.dynamic)q({toolCallId:W.toolCallId,toolName:W.toolName,state:"input-streaming",input:void 0,providerExecuted:W.providerExecuted,title:W.title,providerMetadata:W.providerMetadata});else N({toolCallId:W.toolCallId,toolName:W.toolName,state:"input-streaming",input:void 0,providerExecuted:W.providerExecuted,title:W.title,providerMetadata:W.providerMetadata});U();break}case"tool-input-delta":{let j=V.partialToolCalls[W.toolCallId];if(j==null)throw new UJ({chunkType:"tool-input-delta",chunkId:W.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${W.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});j.text+=W.inputTextDelta;let{value:M}=await AJ(j.text);if(j.dynamic)q({toolCallId:W.toolCallId,toolName:j.toolName,state:"input-streaming",input:M,title:j.title});else N({toolCallId:W.toolCallId,toolName:j.toolName,state:"input-streaming",input:M,title:j.title});U();break}case"tool-input-available":{if(W.dynamic)q({toolCallId:W.toolCallId,toolName:W.toolName,state:"input-available",input:W.input,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:W.title});else N({toolCallId:W.toolCallId,toolName:W.toolName,state:"input-available",input:W.input,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:W.title});if(U(),Q&&!W.providerExecuted)await Q({toolCall:W});break}case"tool-input-error":{let j=V.message.parts.filter(HJ).find((I)=>I.toolCallId===W.toolCallId);if(j!=null?j.type==="dynamic-tool":!!W.dynamic)q({toolCallId:W.toolCallId,toolName:W.toolName,state:"output-error",input:W.input,errorText:W.errorText,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata});else N({toolCallId:W.toolCallId,toolName:W.toolName,state:"output-error",input:void 0,rawInput:W.input,errorText:W.errorText,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata});U();break}case"tool-approval-request":{let j=A(W.toolCallId);j.state="approval-requested",j.approval={id:W.approvalId},U();break}case"tool-output-denied":{let j=A(W.toolCallId);j.state="output-denied",U();break}case"tool-output-available":{let j=A(W.toolCallId);if(j.type==="dynamic-tool")q({toolCallId:W.toolCallId,toolName:j.toolName,state:"output-available",input:j.input,output:W.output,preliminary:W.preliminary,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:j.title});else N({toolCallId:W.toolCallId,toolName:ZH(j),state:"output-available",input:j.input,output:W.output,providerExecuted:W.providerExecuted,preliminary:W.preliminary,providerMetadata:W.providerMetadata,title:j.title});U();break}case"tool-output-error":{let j=A(W.toolCallId);if(j.type==="dynamic-tool")q({toolCallId:W.toolCallId,toolName:j.toolName,state:"output-error",input:j.input,errorText:W.errorText,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:j.title});else N({toolCallId:W.toolCallId,toolName:ZH(j),state:"output-error",input:j.input,rawInput:j.rawInput,errorText:W.errorText,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:j.title});U();break}case"start-step":{V.message.parts.push({type:"step-start"});break}case"finish-step":{V.activeTextParts={},V.activeReasoningParts={};break}case"start":{if(W.messageId!=null)V.message.id=W.messageId;if(await w(W.messageMetadata),W.messageId!=null||W.messageMetadata!=null)U();break}case"finish":{if(W.finishReason!=null)V.finishReason=W.finishReason;if(await w(W.messageMetadata),W.messageMetadata!=null)U();break}case"message-metadata":{if(await w(W.messageMetadata),W.messageMetadata!=null)U();break}case"error":{X==null||X(Error(W.errorText));break}default:if(Ie(W)){if((J==null?void 0:J[W.type])!=null){let I=V.message.parts.findIndex((L)=>("id"in L)&&("data"in L)&&L.id===W.id&&L.type===W.type),R=I>=0?I:V.message.parts.length;await A4({value:W.data,schema:J[W.type],context:{field:`message.parts[${R}].data`,entityName:W.type,entityId:W.id}})}let j=W;if(j.transient){G==null||G(j);break}let M=j.id!=null?V.message.parts.find((I)=>j.type===I.type&&j.id===I.id):void 0;if(M!=null)M.data=j.data;else V.message.parts.push(j);G==null||G(j),U()}}K.enqueue(W)})}}))}function _e({messageId:$,originalMessages:Z=[],onStepFinish:J,onFinish:Y,onError:X,stream:Q}){let G=Z==null?void 0:Z[Z.length-1];if((G==null?void 0:G.role)!=="assistant")G=void 0;else $=G.id;let W=!1,K=Q.pipeThrough(new TransformStream({transform(F,A){if(F.type==="start"){let N=F;if(N.messageId==null&&$!=null)N.messageId=$}if(F.type==="abort")W=!0;A.enqueue(F)}}));if(Y==null&&J==null)return K;let V=Ee({lastMessage:G?structuredClone(G):void 0,messageId:$!=null?$:""}),U=async(F)=>{await F({state:V,write:()=>{}})},H=!1,B=async()=>{if(H||!Y)return;H=!0;let F=V.message.id===(G==null?void 0:G.id);await Y({isAborted:W,isContinuation:F,responseMessage:V.message,messages:[...F?Z.slice(0,-1):Z,V.message],finishReason:V.finishReason})},z=async()=>{if(!J)return;let F=V.message.id===(G==null?void 0:G.id);try{await J({isContinuation:F,responseMessage:structuredClone(V.message),messages:[...F?Z.slice(0,-1):Z,structuredClone(V.message)]})}catch(A){X(A)}};return be({stream:K,runUpdateMessageJob:U,onError:X}).pipeThrough(new TransformStream({async transform(F,A){if(F.type==="finish-step")await z();A.enqueue(F)},async cancel(){await B()},async flush(){await B()}}))}function Se({response:$,status:Z,statusText:J,headers:Y,stream:X,consumeSseStream:Q}){let G=X.pipeThrough(new aT);if(Q){let[W,K]=G.tee();G=W,Q({stream:K})}sT({response:$,status:Z,statusText:J,headers:Object.fromEntries(NX(Y,tT).entries()),stream:G.pipeThrough(new TextEncoderStream)})}function s6($){let Z=$.pipeThrough(new TransformStream);return Z[Symbol.asyncIterator]=function(){let J=this.getReader(),Y=!1;async function X(Q){var G;if(Y)return;Y=!0;try{if(Q)await((G=J.cancel)==null?void 0:G.call(J))}finally{try{J.releaseLock()}catch(W){}}}return{async next(){if(Y)return{done:!0,value:void 0};let{done:Q,value:G}=await J.read();if(Q)return await X(!0),{done:!0,value:void 0};return{done:!1,value:G}},async return(){return await X(!0),{done:!0,value:void 0}},async throw(Q){throw await X(!0),Q}}},Z}async function fe({stream:$,onError:Z}){let J=$.getReader();try{while(!0){let{done:Y}=await J.read();if(Y)break}}catch(Y){Z==null||Z(Y)}finally{J.releaseLock()}}function vL(){let $,Z;return{promise:new Promise((Y,X)=>{$=Y,Z=X}),resolve:$,reject:Z}}function $2(){let $=[],Z=null,J=!1,Y=vL(),X=()=>{J=!0,Y.resolve(),$.forEach((G)=>G.cancel()),$=[],Z==null||Z.close()},Q=async()=>{if(J&&$.length===0){Z==null||Z.close();return}if($.length===0)return Y=vL(),await Y.promise,Q();try{let{value:G,done:W}=await $[0].read();if(W)if($.shift(),$.length===0&&J)Z==null||Z.close();else await Q();else Z==null||Z.enqueue(G)}catch(G){Z==null||Z.error(G),$.shift(),X()}};return{stream:new ReadableStream({start(G){Z=G},pull:Q,async cancel(){for(let G of $)await G.cancel();$=[],J=!0}}),addStream:(G)=>{if(J)throw Error("Cannot add inner stream: outer stream is closed");$.push(G.getReader()),Y.resolve()},close:()=>{if(J=!0,Y.resolve(),$.length===0)Z==null||Z.close()},terminate:X}}function ke({tools:$,generatorStream:Z,tracer:J,telemetry:Y,system:X,messages:Q,abortSignal:G,repairToolCall:W,experimental_context:K,generateId:V,stepNumber:U,model:H,onToolCallStart:B,onToolCallFinish:z}){let F=null,A=new ReadableStream({start(L){F=L}}),N=new Set,q=new Map,w=new Map,j=!1,M=void 0;function I(){if(j&&N.size===0){if(M!=null)F.enqueue(M);F.close()}}let R=new TransformStream({async transform(L,C){let _=L.type;switch(_){case"stream-start":case"text-start":case"text-delta":case"text-end":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"tool-input-start":case"tool-input-delta":case"tool-input-end":case"source":case"response-metadata":case"error":case"raw":{C.enqueue(L);break}case"file":{C.enqueue({type:"file",file:new ze({data:L.data,mediaType:L.mediaType}),...L.providerMetadata!=null?{providerMetadata:L.providerMetadata}:{}});break}case"finish":{M={type:"finish",finishReason:L.finishReason.unified,rawFinishReason:L.finishReason.raw,usage:j4(L.usage),providerMetadata:L.providerMetadata};break}case"tool-approval-request":{let E=w.get(L.toolCallId);if(E==null){F.enqueue({type:"error",error:new QT({toolCallId:L.toolCallId,approvalId:L.approvalId})});break}C.enqueue({type:"tool-approval-request",approvalId:L.approvalId,toolCall:E});break}case"tool-call":{try{let E=await De({toolCall:L,tools:$,repairToolCall:W,system:X,messages:Q});if(w.set(E.toolCallId,E),C.enqueue(E),E.invalid){F.enqueue({type:"tool-error",toolCallId:E.toolCallId,toolName:E.toolName,input:E.input,error:AX(E.error),dynamic:!0,title:E.title});break}let f=$==null?void 0:$[E.toolName];if(f==null)break;if(f.onInputAvailable!=null)await f.onInputAvailable({input:E.input,toolCallId:E.toolCallId,messages:Q,abortSignal:G,experimental_context:K});if(await Fe({tool:f,toolCall:E,messages:Q,experimental_context:K})){F.enqueue({type:"tool-approval-request",approvalId:V(),toolCall:E});break}if(q.set(E.toolCallId,E.input),f.execute!=null&&E.providerExecuted!==!0){let b=V();N.add(b),iT({toolCall:E,tools:$,tracer:J,telemetry:Y,messages:Q,abortSignal:G,experimental_context:K,stepNumber:U,model:H,onToolCallStart:B,onToolCallFinish:z,onPreliminaryToolResult:(k)=>{F.enqueue(k)}}).then((k)=>{F.enqueue(k)}).catch((k)=>{F.enqueue({type:"error",error:k})}).finally(()=>{N.delete(b),I()})}}catch(E){F.enqueue({type:"error",error:E})}break}case"tool-result":{let E=L.toolName;if(L.isError)F.enqueue({type:"tool-error",toolCallId:L.toolCallId,toolName:E,input:q.get(L.toolCallId),providerExecuted:!0,error:L.result,dynamic:L.dynamic,...L.providerMetadata!=null?{providerMetadata:L.providerMetadata}:{}});else C.enqueue({type:"tool-result",toolCallId:L.toolCallId,toolName:E,input:q.get(L.toolCallId),output:L.result,providerExecuted:!0,dynamic:L.dynamic,...L.providerMetadata!=null?{providerMetadata:L.providerMetadata}:{}});break}default:throw Error(`Unhandled chunk type: ${_}`)}},flush(){j=!0,I()}});return new ReadableStream({async start(L){return Promise.all([Z.pipeThrough(R).pipeTo(new WritableStream({write(C){L.enqueue(C)},close(){}})),A.pipeTo(new WritableStream({write(C){L.enqueue(C)},close(){L.close()}}))])}})}var ve=a6({prefix:"aitxt",size:24});function Y_0({model:$,tools:Z,toolChoice:J,system:Y,prompt:X,messages:Q,maxRetries:G,abortSignal:W,timeout:K,headers:V,stopWhen:U=Le(1),experimental_output:H,output:B=H,experimental_telemetry:z,prepareStep:F,providerOptions:A,experimental_activeTools:N,activeTools:q=N,experimental_repairToolCall:w,experimental_transform:j,experimental_download:M,includeRawChunks:I=!1,onChunk:R,onError:L=({error:Q0})=>{console.error(Q0)},onFinish:C,onAbort:_,onStepFinish:E,experimental_onStart:f,experimental_onStepStart:b,experimental_onToolCallStart:k,experimental_onToolCallFinish:u,experimental_context:x,experimental_include:g,_internal:{now:c=VX,generateId:e=ve}={},...G0}){let Q0=vT(K),z0=_t(K),u0=St(K),m=z0!=null?new AbortController:void 0,l=u0!=null?new AbortController:void 0;return new xe({model:w4($),telemetry:z,headers:V,settings:G0,maxRetries:G,abortSignal:Re(W,Q0!=null?AbortSignal.timeout(Q0):void 0,m==null?void 0:m.signal,l==null?void 0:l.signal),stepTimeoutMs:z0,stepAbortController:m,chunkTimeoutMs:u0,chunkAbortController:l,system:Y,prompt:X,messages:Q,tools:Z,toolChoice:J,transforms:y5(j),activeTools:q,repairToolCall:w,stopConditions:y5(U),output:B,providerOptions:A,prepareStep:F,includeRawChunks:I,timeout:K,stopWhen:U,originalAbortSignal:W,onChunk:R,onError:L,onFinish:C,onAbort:_,onStepFinish:E,onStart:f,onStepStart:b,onToolCallStart:k,onToolCallFinish:u,now:c,generateId:e,experimental_context:x,download:M,include:g})}function ye($){let Z=void 0,J="",Y="",X=void 0,Q="";function G({controller:W,partialOutput:K=void 0}){W.enqueue({part:{type:"text-delta",id:Z,text:Y,providerMetadata:X},partialOutput:K}),Y=""}return new TransformStream({async transform(W,K){var V;if(W.type==="finish-step"&&Y.length>0)G({controller:K});if(W.type!=="text-delta"&&W.type!=="text-start"&&W.type!=="text-end"){K.enqueue({part:W,partialOutput:void 0});return}if(Z==null)Z=W.id;else if(W.id!==Z){K.enqueue({part:W,partialOutput:void 0});return}if(W.type==="text-start"){K.enqueue({part:W,partialOutput:void 0});return}if(W.type==="text-end"){if(Y.length>0)G({controller:K});K.enqueue({part:W,partialOutput:void 0});return}J+=W.text,Y+=W.text,X=(V=W.providerMetadata)!=null?V:X;let U=await $.parsePartialOutput({text:J});if(U!==void 0){let H=typeof U.partial==="string"?U.partial:JSON.stringify(U.partial);if(H!==Q)G({controller:K,partialOutput:U.partial}),Q=H}}})}var xe=class{constructor({model:$,telemetry:Z,headers:J,settings:Y,maxRetries:X,abortSignal:Q,stepTimeoutMs:G,stepAbortController:W,chunkTimeoutMs:K,chunkAbortController:V,system:U,prompt:H,messages:B,tools:z,toolChoice:F,transforms:A,activeTools:N,repairToolCall:q,stopConditions:w,output:j,providerOptions:M,prepareStep:I,includeRawChunks:R,now:L,generateId:C,timeout:_,stopWhen:E,originalAbortSignal:f,onChunk:b,onError:k,onFinish:u,onAbort:x,onStepFinish:g,onStart:c,onStepStart:e,onToolCallStart:G0,onToolCallFinish:Q0,experimental_context:z0,download:u0,include:m}){this._totalUsage=new G8,this._finishReason=new G8,this._rawFinishReason=new G8,this._steps=new G8,this.outputSpecification=j,this.includeRawChunks=R,this.tools=z;let t=Qe()(Z==null?void 0:Z.integrations),h,y=[],p=[],d=void 0,a=void 0,s=void 0,H0={},O0=[],C0=[],p0=new Map,r,F0={},W0={},j0=new TransformStream({async transform(n,Z0){var b0,M0,D1,h0;Z0.enqueue(n);let{part:$0}=n;if($0.type==="text-delta"||$0.type==="reasoning-delta"||$0.type==="source"||$0.type==="tool-call"||$0.type==="tool-result"||$0.type==="tool-input-start"||$0.type==="tool-input-delta"||$0.type==="raw")await(b==null?void 0:b({chunk:$0}));if($0.type==="error")await k({error:VH($0.error)});if($0.type==="text-start")F0[$0.id]={type:"text",text:"",providerMetadata:$0.providerMetadata},y.push(F0[$0.id]);if($0.type==="text-delta"){let v0=F0[$0.id];if(v0==null){Z0.enqueue({part:{type:"error",error:`text part ${$0.id} not found`},partialOutput:void 0});return}v0.text+=$0.text,v0.providerMetadata=(b0=$0.providerMetadata)!=null?b0:v0.providerMetadata}if($0.type==="text-end"){let v0=F0[$0.id];if(v0==null){Z0.enqueue({part:{type:"error",error:`text part ${$0.id} not found`},partialOutput:void 0});return}v0.providerMetadata=(M0=$0.providerMetadata)!=null?M0:v0.providerMetadata,delete F0[$0.id]}if($0.type==="reasoning-start")W0[$0.id]={type:"reasoning",text:"",providerMetadata:$0.providerMetadata},y.push(W0[$0.id]);if($0.type==="reasoning-delta"){let v0=W0[$0.id];if(v0==null){Z0.enqueue({part:{type:"error",error:`reasoning part ${$0.id} not found`},partialOutput:void 0});return}v0.text+=$0.text,v0.providerMetadata=(D1=$0.providerMetadata)!=null?D1:v0.providerMetadata}if($0.type==="reasoning-end"){let v0=W0[$0.id];if(v0==null){Z0.enqueue({part:{type:"error",error:`reasoning part ${$0.id} not found`},partialOutput:void 0});return}v0.providerMetadata=(h0=$0.providerMetadata)!=null?h0:v0.providerMetadata,delete W0[$0.id]}if($0.type==="file")y.push({type:"file",file:$0.file,...$0.providerMetadata!=null?{providerMetadata:$0.providerMetadata}:{}});if($0.type==="source")y.push($0);if($0.type==="tool-call")y.push($0);if($0.type==="tool-result"&&!$0.preliminary)y.push($0);if($0.type==="tool-approval-request")y.push($0);if($0.type==="tool-error")y.push($0);if($0.type==="start-step")y=[],W0={},F0={},H0=$0.request,O0=$0.warnings;if($0.type==="finish-step"){let v0=await fL({content:y,tools:z}),V0=new we({stepNumber:C0.length,model:v,...i,experimental_context:z0,content:y,finishReason:$0.finishReason,rawFinishReason:$0.rawFinishReason,usage:$0.usage,warnings:O0,request:H0,response:{...$0.response,messages:[...p,...v0]},providerMetadata:$0.providerMetadata});await v5({event:V0,callbacks:[g,t.onStepFinish]}),D4({warnings:O0,provider:v.provider,model:v.modelId}),C0.push(V0),p.push(...v0),h.resolve()}if($0.type==="finish")s=$0.totalUsage,d=$0.finishReason,a=$0.rawFinishReason},async flush(n){var Z0,b0,M0,D1,h0,$0,v0;try{if(C0.length===0){let H1=(Q==null?void 0:Q.aborted)?Q.reason:new ta({message:"No output generated. Check the stream for errors."});U1._finishReason.reject(H1),U1._rawFinishReason.reject(H1),U1._totalUsage.reject(H1),U1._steps.reject(H1);return}let V0=d!=null?d:"other",$1=s!=null?s:F4();U1._finishReason.resolve(V0),U1._rawFinishReason.resolve(a),U1._totalUsage.resolve($1),U1._steps.resolve(C0);let D0=C0[C0.length-1];await v5({event:{stepNumber:D0.stepNumber,model:D0.model,functionId:D0.functionId,metadata:D0.metadata,experimental_context:D0.experimental_context,finishReason:D0.finishReason,rawFinishReason:D0.rawFinishReason,totalUsage:$1,usage:D0.usage,content:D0.content,text:D0.text,reasoningText:D0.reasoningText,reasoning:D0.reasoning,files:D0.files,sources:D0.sources,toolCalls:D0.toolCalls,staticToolCalls:D0.staticToolCalls,dynamicToolCalls:D0.dynamicToolCalls,toolResults:D0.toolResults,staticToolResults:D0.staticToolResults,dynamicToolResults:D0.dynamicToolResults,request:D0.request,response:D0.response,warnings:D0.warnings,providerMetadata:D0.providerMetadata,steps:C0},callbacks:[u,t.onFinish]}),r.setAttributes(await r$({telemetry:Z,attributes:{"ai.response.finishReason":V0,"ai.response.text":{output:()=>D0.text},"ai.response.reasoning":{output:()=>D0.reasoningText},"ai.response.toolCalls":{output:()=>{var H1;return((H1=D0.toolCalls)==null?void 0:H1.length)?JSON.stringify(D0.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(D0.providerMetadata),"ai.usage.inputTokens":$1.inputTokens,"ai.usage.inputTokenDetails.noCacheTokens":(Z0=$1.inputTokenDetails)==null?void 0:Z0.noCacheTokens,"ai.usage.inputTokenDetails.cacheReadTokens":(b0=$1.inputTokenDetails)==null?void 0:b0.cacheReadTokens,"ai.usage.inputTokenDetails.cacheWriteTokens":(M0=$1.inputTokenDetails)==null?void 0:M0.cacheWriteTokens,"ai.usage.outputTokens":$1.outputTokens,"ai.usage.outputTokenDetails.textTokens":(D1=$1.outputTokenDetails)==null?void 0:D1.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":(h0=$1.outputTokenDetails)==null?void 0:h0.reasoningTokens,"ai.usage.totalTokens":$1.totalTokens,"ai.usage.reasoningTokens":($0=$1.outputTokenDetails)==null?void 0:$0.reasoningTokens,"ai.usage.cachedInputTokens":(v0=$1.inputTokenDetails)==null?void 0:v0.cacheReadTokens}}))}catch(V0){n.error(V0)}finally{r.end()}}}),X1=$2();this.addStream=X1.addStream,this.closeStream=X1.close;let E0=X1.stream.getReader(),G1=new ReadableStream({async start(n){n.enqueue({type:"start"})},async pull(n){function Z0(){x==null||x({steps:C0}),n.enqueue({type:"abort",...(Q==null?void 0:Q.reason)!==void 0?{reason:r6(Q.reason)}:{}}),n.close()}try{let{done:b0,value:M0}=await E0.read();if(b0){n.close();return}if(Q==null?void 0:Q.aborted){Z0();return}n.enqueue(M0)}catch(b0){if(q4(b0)&&(Q==null?void 0:Q.aborted))Z0();else n.error(b0)}},cancel(n){return X1.stream.cancel(n)}});for(let n of A)G1=G1.pipeThrough(n({tools:z,stopStream(){X1.terminate()}}));this.baseStream=G1.pipeThrough(ye(j!=null?j:eU())).pipeThrough(j0);let{maxRetries:T0,retry:w1}=FH({maxRetries:X,abortSignal:Q}),o0=HH(Z),z1=BX(Y),t0=UH({model:$,telemetry:Z,headers:J,settings:{...z1,maxRetries:T0}}),U1=this,v={provider:$.provider,modelId:$.modelId},i={functionId:Z==null?void 0:Z.functionId,metadata:Z==null?void 0:Z.metadata};h5({name:"ai.streamText",attributes:r$({telemetry:Z,attributes:{...x5({operationId:"ai.streamText",telemetry:Z}),...t0,"ai.prompt":{input:()=>JSON.stringify({system:U,prompt:H,messages:B})}}}),tracer:o0,endWhenDone:!1,fn:async(n)=>{r=n;let Z0=await KH({system:U,prompt:H,messages:B});await v5({event:{model:v,system:U,prompt:H,messages:B,tools:z,toolChoice:F,activeTools:N,maxOutputTokens:z1.maxOutputTokens,temperature:z1.temperature,topP:z1.topP,topK:z1.topK,presencePenalty:z1.presencePenalty,frequencyPenalty:z1.frequencyPenalty,stopSequences:z1.stopSequences,seed:z1.seed,maxRetries:T0,timeout:_,headers:J,providerOptions:M,stopWhen:E,output:j,abortSignal:f,include:m,...i,experimental_context:z0},callbacks:[c,t.onStart]});let b0=Z0.messages,M0=[],{approvedToolApprovals:D1,deniedToolApprovals:h0}=Ve({messages:b0});if(h0.length>0||D1.length>0){let v0=D1.filter((C1)=>!C1.toolCall.providerExecuted),V0=h0.filter((C1)=>!C1.toolCall.providerExecuted),$1=h0.filter((C1)=>C1.toolCall.providerExecuted),D0,H1=new ReadableStream({start(C1){D0=C1}});U1.addStream(H1);try{for(let E1 of[...V0,...$1])D0==null||D0.enqueue({type:"tool-output-denied",toolCallId:E1.toolCall.toolCallId,toolName:E1.toolCall.toolName});let C1=[];if(await Promise.all(v0.map(async(E1)=>{let b1=await iT({toolCall:E1.toolCall,tools:z,tracer:o0,telemetry:Z,messages:b0,abortSignal:Q,experimental_context:z0,stepNumber:C0.length,model:v,onToolCallStart:[G0,t.onToolCallStart],onToolCallFinish:[Q0,t.onToolCallFinish],onPreliminaryToolResult:(F6)=>{D0==null||D0.enqueue(F6)}});if(b1!=null)D0==null||D0.enqueue(b1),C1.push(b1)})),C1.length>0||V0.length>0){let E1=[];for(let b1 of C1)E1.push({type:"tool-result",toolCallId:b1.toolCallId,toolName:b1.toolName,output:await BJ({toolCallId:b1.toolCallId,input:b1.input,tool:z==null?void 0:z[b1.toolName],output:b1.type==="tool-result"?b1.output:b1.error,errorMode:b1.type==="tool-error"?"text":"none"})});for(let b1 of V0)E1.push({type:"tool-result",toolCallId:b1.toolCall.toolCallId,toolName:b1.toolCall.toolName,output:{type:"execution-denied",reason:b1.approvalResponse.reason}});M0.push({role:"tool",content:E1})}}finally{D0==null||D0.close()}}p.push(...M0);async function $0({currentStep:v0,responseMessages:V0,usage:$1}){var D0,H1,C1,E1,b1,F6,l1,c8,eA;let O8=U1.includeRawChunks,A6=G!=null?setTimeout(()=>W.abort(),G):void 0,M7=void 0;function x$(){if(K!=null){if(M7!=null)clearTimeout(M7);M7=setTimeout(()=>V.abort(),K)}}function UQ(){if(M7!=null)clearTimeout(M7),M7=void 0}function $O(){if(A6!=null)clearTimeout(A6)}try{h=new G8;let j8=[...b0,...V0],q$=await(I==null?void 0:I({model:$,steps:C0,stepNumber:C0.length,messages:j8,experimental_context:z0})),NZ=w4((D0=q$==null?void 0:q$.model)!=null?D0:$),ZO={provider:NZ.provider,modelId:NZ.modelId},JO=await WH({prompt:{system:(H1=q$==null?void 0:q$.system)!=null?H1:Z0.system,messages:(C1=q$==null?void 0:q$.messages)!=null?C1:j8},supportedUrls:await NZ.supportedUrls,download:u0}),YO=(E1=q$==null?void 0:q$.activeTools)!=null?E1:N,{toolChoice:HQ,tools:oK}=await pt({tools:z,toolChoice:(b1=q$==null?void 0:q$.toolChoice)!=null?b1:F,activeTools:YO});z0=(F6=q$==null?void 0:q$.experimental_context)!=null?F6:z0;let Id=(l1=q$==null?void 0:q$.messages)!=null?l1:j8,Ed=(c8=q$==null?void 0:q$.system)!=null?c8:Z0.system,XO=zH(M,q$==null?void 0:q$.providerOptions);await v5({event:{stepNumber:C0.length,model:ZO,system:Ed,messages:Id,tools:z,toolChoice:HQ,activeTools:YO,steps:[...C0],providerOptions:XO,timeout:_,headers:J,stopWhen:E,output:j,abortSignal:f,include:m,...i,experimental_context:z0},callbacks:[e,t.onStepStart]});let{result:{stream:bd,response:QO,request:sK},doStreamSpan:z5,startTimestampMs:GO}=await w1(()=>h5({name:"ai.streamText.doStream",attributes:r$({telemetry:Z,attributes:{...x5({operationId:"ai.streamText.doStream",telemetry:Z}),...t0,"ai.model.provider":NZ.provider,"ai.model.id":NZ.modelId,"ai.prompt.messages":{input:()=>BH(JO)},"ai.prompt.tools":{input:()=>oK==null?void 0:oK.map((y0)=>JSON.stringify(y0))},"ai.prompt.toolChoice":{input:()=>HQ!=null?JSON.stringify(HQ):void 0},"gen_ai.system":NZ.provider,"gen_ai.request.model":NZ.modelId,"gen_ai.request.frequency_penalty":z1.frequencyPenalty,"gen_ai.request.max_tokens":z1.maxOutputTokens,"gen_ai.request.presence_penalty":z1.presencePenalty,"gen_ai.request.stop_sequences":z1.stopSequences,"gen_ai.request.temperature":z1.temperature,"gen_ai.request.top_k":z1.topK,"gen_ai.request.top_p":z1.topP}}),tracer:o0,endWhenDone:!1,fn:async(y0)=>({startTimestampMs:L(),doStreamSpan:y0,result:await NZ.doStream({...z1,tools:oK,toolChoice:HQ,responseFormat:await(j==null?void 0:j.responseFormat),prompt:JO,providerOptions:XO,abortSignal:Q,headers:J,includeRawChunks:O8})})})),_d=ke({tools:z,generatorStream:bd,tracer:o0,telemetry:Z,system:U,messages:j8,repairToolCall:q,abortSignal:Q,experimental_context:z0,generateId:C,stepNumber:C0.length,model:ZO,onToolCallStart:[G0,t.onToolCallStart],onToolCallFinish:[Q0,t.onToolCallFinish]}),Sd=((eA=m==null?void 0:m.requestBody)!=null?eA:!0)?sK!=null?sK:{}:{...sK,body:void 0},NY=[],qY=[],rK,aK={},D7="other",tK=void 0,h$=F4(),WO,KO=!0,O6={id:C(),timestamp:new Date,modelId:v.modelId},fd="";U1.addStream(_d.pipeThrough(new TransformStream({async transform(y0,M$){var MY,DY,wY,LY,TY;if(x$(),y0.type==="stream-start"){rK=y0.warnings;return}if(KO){let D$=L()-GO;KO=!1,z5.addEvent("ai.stream.firstChunk",{"ai.response.msToFirstChunk":D$}),z5.setAttributes({"ai.response.msToFirstChunk":D$}),M$.enqueue({type:"start-step",request:Sd,warnings:rK!=null?rK:[]})}let RY=y0.type;switch(RY){case"tool-approval-request":case"text-start":case"text-end":{M$.enqueue(y0);break}case"text-delta":{if(y0.delta.length>0)M$.enqueue({type:"text-delta",id:y0.id,text:y0.delta,providerMetadata:y0.providerMetadata}),fd+=y0.delta;break}case"reasoning-start":case"reasoning-end":{M$.enqueue(y0);break}case"reasoning-delta":{M$.enqueue({type:"reasoning-delta",id:y0.id,text:y0.delta,providerMetadata:y0.providerMetadata});break}case"tool-call":{M$.enqueue(y0),NY.push(y0);break}case"tool-result":{if(M$.enqueue(y0),!y0.preliminary)qY.push(y0);break}case"tool-error":{M$.enqueue(y0),qY.push(y0);break}case"response-metadata":{O6={id:(MY=y0.id)!=null?MY:O6.id,timestamp:(DY=y0.timestamp)!=null?DY:O6.timestamp,modelId:(wY=y0.modelId)!=null?wY:O6.modelId};break}case"finish":{h$=y0.usage,D7=y0.finishReason,tK=y0.rawFinishReason,WO=y0.providerMetadata;let D$=L()-GO;z5.addEvent("ai.stream.finish"),z5.setAttributes({"ai.response.msToFinish":D$,"ai.response.avgOutputTokensPerSecond":1000*((LY=h$.outputTokens)!=null?LY:0)/D$});break}case"file":{M$.enqueue(y0);break}case"source":{M$.enqueue(y0);break}case"tool-input-start":{aK[y0.id]=y0.toolName;let D$=z==null?void 0:z[y0.toolName];if((D$==null?void 0:D$.onInputStart)!=null)await D$.onInputStart({toolCallId:y0.id,messages:j8,abortSignal:Q,experimental_context:z0});M$.enqueue({...y0,dynamic:(TY=y0.dynamic)!=null?TY:(D$==null?void 0:D$.type)==="dynamic",title:D$==null?void 0:D$.title});break}case"tool-input-end":{delete aK[y0.id],M$.enqueue(y0);break}case"tool-input-delta":{let D$=aK[y0.id],w7=z==null?void 0:z[D$];if((w7==null?void 0:w7.onInputDelta)!=null)await w7.onInputDelta({inputTextDelta:y0.delta,toolCallId:y0.id,messages:j8,abortSignal:Q,experimental_context:z0});M$.enqueue(y0);break}case"error":{M$.enqueue(y0),D7="error";break}case"raw":{if(O8)M$.enqueue(y0);break}default:throw Error(`Unknown chunk type: ${RY}`)}},async flush(y0){var M$,MY,DY,wY,LY,TY,RY;let D$=NY.length>0?JSON.stringify(NY):void 0;try{z5.setAttributes(await r$({telemetry:Z,attributes:{"ai.response.finishReason":D7,"ai.response.toolCalls":{output:()=>D$},"ai.response.id":O6.id,"ai.response.model":O6.modelId,"ai.response.timestamp":O6.timestamp.toISOString(),"ai.usage.inputTokens":h$.inputTokens,"ai.usage.inputTokenDetails.noCacheTokens":(M$=h$.inputTokenDetails)==null?void 0:M$.noCacheTokens,"ai.usage.inputTokenDetails.cacheReadTokens":(MY=h$.inputTokenDetails)==null?void 0:MY.cacheReadTokens,"ai.usage.inputTokenDetails.cacheWriteTokens":(DY=h$.inputTokenDetails)==null?void 0:DY.cacheWriteTokens,"ai.usage.outputTokens":h$.outputTokens,"ai.usage.outputTokenDetails.textTokens":(wY=h$.outputTokenDetails)==null?void 0:wY.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":(LY=h$.outputTokenDetails)==null?void 0:LY.reasoningTokens,"ai.usage.totalTokens":h$.totalTokens,"ai.usage.reasoningTokens":(TY=h$.outputTokenDetails)==null?void 0:TY.reasoningTokens,"ai.usage.cachedInputTokens":(RY=h$.inputTokenDetails)==null?void 0:RY.cacheReadTokens,"gen_ai.response.finish_reasons":[D7],"gen_ai.response.id":O6.id,"gen_ai.response.model":O6.modelId,"gen_ai.usage.input_tokens":h$.inputTokens,"gen_ai.usage.output_tokens":h$.outputTokens}}))}catch(C$){}y0.enqueue({type:"finish-step",finishReason:D7,rawFinishReason:tK,usage:h$,providerMetadata:WO,response:{...O6,headers:QO==null?void 0:QO.headers}});let w7=Ge($1,h$);await h.promise;let eK=C0[C0.length-1];try{z5.setAttributes(await r$({telemetry:Z,attributes:{"ai.response.text":{output:()=>eK.text},"ai.response.reasoning":{output:()=>eK.reasoningText},"ai.response.providerMetadata":JSON.stringify(eK.providerMetadata)}}))}catch(C$){}finally{z5.end()}let VO=NY.filter((C$)=>C$.providerExecuted!==!0),kd=qY.filter((C$)=>C$.providerExecuted!==!0);for(let C$ of NY){if(C$.providerExecuted!==!0)continue;let $V=z==null?void 0:z[C$.toolName];if(($V==null?void 0:$V.type)==="provider"&&$V.supportsDeferredResults){if(!qY.some((ZV)=>(ZV.type==="tool-result"||ZV.type==="tool-error")&&ZV.toolCallId===C$.toolCallId))p0.set(C$.toolCallId,{toolName:C$.toolName})}}for(let C$ of qY)if(C$.type==="tool-result"||C$.type==="tool-error")p0.delete(C$.toolCallId);if($O(),UQ(),(VO.length>0&&kd.length===VO.length||p0.size>0)&&!await Te({stopConditions:w,steps:C0})){V0.push(...await fL({content:C0[C0.length-1].content,tools:z}));try{await $0({currentStep:v0+1,responseMessages:V0,usage:w7})}catch(C$){y0.enqueue({type:"error",error:C$}),U1.closeStream()}}else y0.enqueue({type:"finish",finishReason:D7,rawFinishReason:tK,totalUsage:w7}),U1.closeStream()}})))}finally{$O(),UQ()}}await $0({currentStep:0,responseMessages:M0,usage:F4()})}}).catch((n)=>{U1.addStream(new ReadableStream({start(Z0){Z0.enqueue({type:"error",error:n}),Z0.close()}})),U1.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(($)=>$[$.length-1])}get content(){return this.finalStep.then(($)=>$.content)}get warnings(){return this.finalStep.then(($)=>$.warnings)}get providerMetadata(){return this.finalStep.then(($)=>$.providerMetadata)}get text(){return this.finalStep.then(($)=>$.text)}get reasoningText(){return this.finalStep.then(($)=>$.reasoningText)}get reasoning(){return this.finalStep.then(($)=>$.reasoning)}get sources(){return this.finalStep.then(($)=>$.sources)}get files(){return this.finalStep.then(($)=>$.files)}get toolCalls(){return this.finalStep.then(($)=>$.toolCalls)}get staticToolCalls(){return this.finalStep.then(($)=>$.staticToolCalls)}get dynamicToolCalls(){return this.finalStep.then(($)=>$.dynamicToolCalls)}get toolResults(){return this.finalStep.then(($)=>$.toolResults)}get staticToolResults(){return this.finalStep.then(($)=>$.staticToolResults)}get dynamicToolResults(){return this.finalStep.then(($)=>$.dynamicToolResults)}get usage(){return this.finalStep.then(($)=>$.usage)}get request(){return this.finalStep.then(($)=>$.request)}get response(){return this.finalStep.then(($)=>$.response)}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}get rawFinishReason(){return this.consumeStream(),this._rawFinishReason.promise}teeStream(){let[$,Z]=this.baseStream.tee();return this.baseStream=Z,$}get textStream(){return s6(this.teeStream().pipeThrough(new TransformStream({transform({part:$},Z){if($.type==="text-delta")Z.enqueue($.text)}})))}get fullStream(){return s6(this.teeStream().pipeThrough(new TransformStream({transform({part:$},Z){Z.enqueue($)}})))}async consumeStream($){var Z;try{await fe({stream:this.fullStream,onError:$==null?void 0:$.onError})}catch(J){(Z=$==null?void 0:$.onError)==null||Z.call($,J)}}get experimental_partialOutputStream(){return this.partialOutputStream}get partialOutputStream(){return s6(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:$},Z){if($!=null)Z.enqueue($)}})))}get elementStream(){var $,Z,J;let Y=($=this.outputSpecification)==null?void 0:$.createElementStreamTransform();if(Y==null)throw new g5({functionality:`element streams in ${(J=(Z=this.outputSpecification)==null?void 0:Z.name)!=null?J:"text"} mode`});return s6(this.teeStream().pipeThrough(Y))}get output(){return this.finalStep.then(($)=>{var Z;return((Z=this.outputSpecification)!=null?Z:eU()).parseCompleteOutput({text:$.text},{response:$.response,usage:$.usage,finishReason:$.finishReason})})}toUIMessageStream({originalMessages:$,generateMessageId:Z,onFinish:J,messageMetadata:Y,sendReasoning:X=!0,sendSources:Q=!1,sendStart:G=!0,sendFinish:W=!0,onError:K=r6}={}){let V=Z!=null?Ce({originalMessages:$,responseMessageId:Z}):void 0,U=(B)=>{var z;let F=(z=this.tools)==null?void 0:z[B.toolName];if(F==null)return B.dynamic;return(F==null?void 0:F.type)==="dynamic"?!0:void 0},H=this.fullStream.pipeThrough(new TransformStream({transform:async(B,z)=>{let F=Y==null?void 0:Y({part:B}),A=B.type;switch(A){case"text-start":{z.enqueue({type:"text-start",id:B.id,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"text-delta":{z.enqueue({type:"text-delta",id:B.id,delta:B.text,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"text-end":{z.enqueue({type:"text-end",id:B.id,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"reasoning-start":case"reasoning-end":{if(X)z.enqueue({type:A,id:B.id,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"reasoning-delta":{if(X)z.enqueue({type:"reasoning-delta",id:B.id,delta:B.text,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"file":{z.enqueue({type:"file",mediaType:B.file.mediaType,url:`data:${B.file.mediaType};base64,${B.file.base64}`,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"source":{if(Q&&B.sourceType==="url")z.enqueue({type:"source-url",sourceId:B.id,url:B.url,title:B.title,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});if(Q&&B.sourceType==="document")z.enqueue({type:"source-document",sourceId:B.id,mediaType:B.mediaType,title:B.title,filename:B.filename,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"tool-input-start":{let N=U(B);z.enqueue({type:"tool-input-start",toolCallId:B.id,toolName:B.toolName,...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...N!=null?{dynamic:N}:{},...B.title!=null?{title:B.title}:{}});break}case"tool-input-delta":{z.enqueue({type:"tool-input-delta",toolCallId:B.id,inputTextDelta:B.delta});break}case"tool-call":{let N=U(B);if(B.invalid)z.enqueue({type:"tool-input-error",toolCallId:B.toolCallId,toolName:B.toolName,input:B.input,...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...N!=null?{dynamic:N}:{},errorText:K(B.error),...B.title!=null?{title:B.title}:{}});else z.enqueue({type:"tool-input-available",toolCallId:B.toolCallId,toolName:B.toolName,input:B.input,...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...N!=null?{dynamic:N}:{},...B.title!=null?{title:B.title}:{}});break}case"tool-approval-request":{z.enqueue({type:"tool-approval-request",approvalId:B.approvalId,toolCallId:B.toolCall.toolCallId});break}case"tool-result":{let N=U(B);z.enqueue({type:"tool-output-available",toolCallId:B.toolCallId,output:B.output,...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...B.preliminary!=null?{preliminary:B.preliminary}:{},...N!=null?{dynamic:N}:{}});break}case"tool-error":{let N=U(B);z.enqueue({type:"tool-output-error",toolCallId:B.toolCallId,errorText:B.providerExecuted?typeof B.error==="string"?B.error:JSON.stringify(B.error):K(B.error),...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...N!=null?{dynamic:N}:{}});break}case"tool-output-denied":{z.enqueue({type:"tool-output-denied",toolCallId:B.toolCallId});break}case"error":{z.enqueue({type:"error",errorText:K(B.error)});break}case"start-step":{z.enqueue({type:"start-step"});break}case"finish-step":{z.enqueue({type:"finish-step"});break}case"start":{if(G)z.enqueue({type:"start",...F!=null?{messageMetadata:F}:{},...V!=null?{messageId:V}:{}});break}case"finish":{if(W)z.enqueue({type:"finish",finishReason:B.finishReason,...F!=null?{messageMetadata:F}:{}});break}case"abort":{z.enqueue(B);break}case"tool-input-end":break;case"raw":break;default:throw Error(`Unknown chunk type: ${A}`)}if(F!=null&&A!=="start"&&A!=="finish")z.enqueue({type:"message-metadata",messageMetadata:F})}}));return s6(_e({stream:H,messageId:V!=null?V:Z==null?void 0:Z(),originalMessages:$,onFinish:J,onError:K}))}pipeUIMessageStreamToResponse($,{originalMessages:Z,generateMessageId:J,onFinish:Y,messageMetadata:X,sendReasoning:Q,sendSources:G,sendFinish:W,sendStart:K,onError:V,...U}={}){Se({response:$,stream:this.toUIMessageStream({originalMessages:Z,generateMessageId:J,onFinish:Y,messageMetadata:X,sendReasoning:Q,sendSources:G,sendFinish:W,sendStart:K,onError:V}),...U})}pipeTextStreamToResponse($,Z){rT({response:$,textStream:this.textStream,...Z})}toUIMessageStreamResponse({originalMessages:$,generateMessageId:Z,onFinish:J,messageMetadata:Y,sendReasoning:X,sendSources:Q,sendFinish:G,sendStart:W,onError:K,...V}={}){return Pe({stream:this.toUIMessageStream({originalMessages:$,generateMessageId:Z,onFinish:J,messageMetadata:Y,sendReasoning:X,sendSources:Q,sendFinish:G,sendStart:W,onError:K}),...V})}toTextStreamResponse($){return oT({textStream:this.textStream,...$})}};async function Z2($,Z){let J=[];if(Z==null?void 0:Z.ignoreIncompleteToolCalls)$=$.map((Y)=>({...Y,parts:Y.parts.filter((X)=>!HJ(X)||X.state!=="input-streaming"&&X.state!=="input-available")}));for(let Y of $)switch(Y.role){case"system":{let X=Y.parts.filter((G)=>G.type==="text"),Q=X.reduce((G,W)=>{if(W.providerMetadata!=null)return{...G,...W.providerMetadata};return G},{});J.push({role:"system",content:X.map((G)=>G.text).join(""),...Object.keys(Q).length>0?{providerOptions:Q}:{}});break}case"user":{J.push({role:"user",content:Y.parts.map((X)=>{var Q;if(nU(X))return{type:"text",text:X.text,...X.providerMetadata!=null?{providerOptions:X.providerMetadata}:{}};if(oU(X))return{type:"file",mediaType:X.mediaType,filename:X.filename,data:X.url,...X.providerMetadata!=null?{providerOptions:X.providerMetadata}:{}};if(iU(X))return(Q=Z==null?void 0:Z.convertDataPart)==null?void 0:Q.call(Z,X)}).filter(lL)});break}case"assistant":{if(Y.parts!=null){let X=[];async function Q(){var G,W,K,V,U,H,B;if(X.length===0)return;let z=[];for(let A of X)if(nU(A))z.push({type:"text",text:A.text,...A.providerMetadata!=null?{providerOptions:A.providerMetadata}:{}});else if(oU(A))z.push({type:"file",mediaType:A.mediaType,filename:A.filename,data:A.url,...A.providerMetadata!=null?{providerOptions:A.providerMetadata}:{}});else if(kL(A))z.push({type:"reasoning",text:A.text,providerOptions:A.providerMetadata});else if(HJ(A)){let N=sU(A);if(A.state!=="input-streaming"){if(z.push({type:"tool-call",toolCallId:A.toolCallId,toolName:N,input:A.state==="output-error"?(G=A.input)!=null?G:("rawInput"in A)?A.rawInput:void 0:A.input,providerExecuted:A.providerExecuted,...A.callProviderMetadata!=null?{providerOptions:A.callProviderMetadata}:{}}),A.approval!=null)z.push({type:"tool-approval-request",approvalId:A.approval.id,toolCallId:A.toolCallId});if(A.providerExecuted===!0&&A.state!=="approval-responded"&&(A.state==="output-available"||A.state==="output-error")){let q=(W=A.resultProviderMetadata)!=null?W:A.callProviderMetadata;z.push({type:"tool-result",toolCallId:A.toolCallId,toolName:N,output:await BJ({toolCallId:A.toolCallId,input:A.input,output:A.state==="output-error"?A.errorText:A.output,tool:(K=Z==null?void 0:Z.tools)==null?void 0:K[N],errorMode:A.state==="output-error"?"json":"none"}),...q!=null?{providerOptions:q}:{}})}}}else if(iU(A)){let N=(V=Z==null?void 0:Z.convertDataPart)==null?void 0:V.call(Z,A);if(N!=null)z.push(N)}else throw Error(`Unsupported part: ${A}`);J.push({role:"assistant",content:z});let F=X.filter((A)=>{var N;return HJ(A)&&(A.providerExecuted!==!0||((N=A.approval)==null?void 0:N.approved)!=null)});if(F.length>0){let A=[];for(let N of F){if(((U=N.approval)==null?void 0:U.approved)!=null)A.push({type:"tool-approval-response",approvalId:N.approval.id,approved:N.approval.approved,reason:N.approval.reason,providerExecuted:N.providerExecuted});if(N.providerExecuted===!0)continue;switch(N.state){case"output-denied":{A.push({type:"tool-result",toolCallId:N.toolCallId,toolName:sU(N),output:{type:"error-text",value:(H=N.approval.reason)!=null?H:"Tool execution denied."},...N.callProviderMetadata!=null?{providerOptions:N.callProviderMetadata}:{}});break}case"output-error":case"output-available":{let q=sU(N);A.push({type:"tool-result",toolCallId:N.toolCallId,toolName:q,output:await BJ({toolCallId:N.toolCallId,input:N.input,output:N.state==="output-error"?N.errorText:N.output,tool:(B=Z==null?void 0:Z.tools)==null?void 0:B[q],errorMode:N.state==="output-error"?"text":"none"}),...N.callProviderMetadata!=null?{providerOptions:N.callProviderMetadata}:{}});break}}}if(A.length>0)J.push({role:"tool",content:A})}X=[]}for(let G of Y.parts)if(nU(G)||kL(G)||oU(G)||HJ(G)||iU(G))X.push(G);else if(G.type==="step-start")await Q();await Q();break}break}default:{let X=Y.role;throw new Lt({originalMessage:Y,message:`Unsupported role: ${X}`})}}return J}var W_0=M4(()=>jX(D.array(D.object({id:D.string(),role:D.enum(["system","user","assistant"]),metadata:D.unknown().optional(),parts:D.array(D.union([D.object({type:D.literal("text"),text:D.string(),state:D.enum(["streaming","done"]).optional(),providerMetadata:q0.optional()}),D.object({type:D.literal("reasoning"),text:D.string(),state:D.enum(["streaming","done"]).optional(),providerMetadata:q0.optional()}),D.object({type:D.literal("source-url"),sourceId:D.string(),url:D.string(),title:D.string().optional(),providerMetadata:q0.optional()}),D.object({type:D.literal("source-document"),sourceId:D.string(),mediaType:D.string(),title:D.string(),filename:D.string().optional(),providerMetadata:q0.optional()}),D.object({type:D.literal("file"),mediaType:D.string(),filename:D.string().optional(),url:D.string(),providerMetadata:q0.optional()}),D.object({type:D.literal("step-start")}),D.object({type:D.string().startsWith("data-"),id:D.string().optional(),data:D.unknown()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("input-streaming"),input:D.unknown().optional(),providerExecuted:D.boolean().optional(),callProviderMetadata:q0.optional(),output:D.never().optional(),errorText:D.never().optional(),approval:D.never().optional()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("input-available"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),approval:D.never().optional()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("approval-requested"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),approval:D.object({id:D.string(),approved:D.never().optional(),reason:D.never().optional()})}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("approval-responded"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),approval:D.object({id:D.string(),approved:D.boolean(),reason:D.string().optional()})}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("output-available"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.unknown(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),resultProviderMetadata:q0.optional(),preliminary:D.boolean().optional(),approval:D.object({id:D.string(),approved:D.literal(!0),reason:D.string().optional()}).optional()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("output-error"),input:D.unknown(),rawInput:D.unknown().optional(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.string(),callProviderMetadata:q0.optional(),resultProviderMetadata:q0.optional(),approval:D.object({id:D.string(),approved:D.literal(!0),reason:D.string().optional()}).optional()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("output-denied"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),approval:D.object({id:D.string(),approved:D.literal(!1),reason:D.string().optional()})}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("input-streaming"),providerExecuted:D.boolean().optional(),callProviderMetadata:q0.optional(),input:D.unknown().optional(),output:D.never().optional(),errorText:D.never().optional(),approval:D.never().optional()}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("input-available"),providerExecuted:D.boolean().optional(),input:D.unknown(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),approval:D.never().optional()}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("approval-requested"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),approval:D.object({id:D.string(),approved:D.never().optional(),reason:D.never().optional()})}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("approval-responded"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),approval:D.object({id:D.string(),approved:D.boolean(),reason:D.string().optional()})}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("output-available"),providerExecuted:D.boolean().optional(),input:D.unknown(),output:D.unknown(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),resultProviderMetadata:q0.optional(),preliminary:D.boolean().optional(),approval:D.object({id:D.string(),approved:D.literal(!0),reason:D.string().optional()}).optional()}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("output-error"),providerExecuted:D.boolean().optional(),input:D.unknown(),rawInput:D.unknown().optional(),output:D.never().optional(),errorText:D.string(),callProviderMetadata:q0.optional(),resultProviderMetadata:q0.optional(),approval:D.object({id:D.string(),approved:D.literal(!0),reason:D.string().optional()}).optional()}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("output-denied"),providerExecuted:D.boolean().optional(),input:D.unknown(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:q0.optional(),approval:D.object({id:D.string(),approved:D.literal(!1),reason:D.string().optional()})})])).nonempty("Message must contain at least one part")})).nonempty("Messages array must not be empty")));var he={type:"no-schema",jsonSchema:async()=>{return},async validatePartialResult({value:$,textDelta:Z}){return{success:!0,value:{partial:$,textDelta:Z}}},async validateFinalResult($,Z){return $===void 0?{success:!1,error:new E8({message:"No object generated: response did not match schema.",text:Z.text,response:Z.response,usage:Z.usage,finishReason:Z.finishReason})}:{success:!0,value:$}},createElementStream(){throw new g5({functionality:"element streams in no-schema mode"})}},ge=($)=>({type:"object",jsonSchema:async()=>await $.jsonSchema,async validatePartialResult({value:Z,textDelta:J}){return{success:!0,value:{partial:Z,textDelta:J}}},async validateFinalResult(Z){return y8({value:Z,schema:$})},createElementStream(){throw new g5({functionality:"element streams in object mode"})}}),ue=($)=>{return{type:"array",jsonSchema:async()=>{let{$schema:Z,...J}=await $.jsonSchema;return{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:J}},required:["elements"],additionalProperties:!1}},async validatePartialResult({value:Z,latestObject:J,isFirstDelta:Y,isFinalDelta:X}){var Q;if(!UX(Z)||!rU(Z.elements))return{success:!1,error:new I8({value:Z,cause:"value must be an object that contains an array of elements"})};let G=Z.elements,W=[];for(let U=0;U<G.length;U++){let H=G[U],B=await y8({value:H,schema:$});if(U===G.length-1&&!X)continue;if(!B.success)return B;W.push(B.value)}let K=(Q=J==null?void 0:J.length)!=null?Q:0,V="";if(Y)V+="[";if(K>0)V+=",";if(V+=W.slice(K).map((U)=>JSON.stringify(U)).join(","),X)V+="]";return{success:!0,value:{partial:W,textDelta:V}}},async validateFinalResult(Z){if(!UX(Z)||!rU(Z.elements))return{success:!1,error:new I8({value:Z,cause:"value must be an object that contains an array of elements"})};let J=Z.elements;for(let Y of J){let X=await y8({value:Y,schema:$});if(!X.success)return X}return{success:!0,value:J}},createElementStream(Z){let J=0;return s6(Z.pipeThrough(new TransformStream({transform(Y,X){switch(Y.type){case"object":{let Q=Y.object;for(;J<Q.length;J++)X.enqueue(Q[J]);break}case"text-delta":case"finish":case"error":break;default:throw Error(`Unsupported chunk type: ${Y}`)}}})))}}},me=($)=>{return{type:"enum",jsonSchema:async()=>({$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:$}},required:["result"],additionalProperties:!1}),async validateFinalResult(Z){if(!UX(Z)||typeof Z.result!=="string")return{success:!1,error:new I8({value:Z,cause:'value must be an object that contains a string in the "result" property.'})};let J=Z.result;return $.includes(J)?{success:!0,value:J}:{success:!1,error:new I8({value:Z,cause:"value must be a string in the enum"})}},async validatePartialResult({value:Z,textDelta:J}){if(!UX(Z)||typeof Z.result!=="string")return{success:!1,error:new I8({value:Z,cause:'value must be an object that contains a string in the "result" property.'})};let Y=Z.result,X=$.filter((Q)=>Q.startsWith(Y));if(Z.result.length===0||X.length===0)return{success:!1,error:new I8({value:Z,cause:"value must be a string in the enum"})};return{success:!0,value:{partial:X.length>1?Y:X[0],textDelta:J}}},createElementStream(){throw new g5({functionality:"element streams in enum mode"})}}};function J2({output:$,schema:Z,enumValues:J}){switch($){case"object":return ge(v8(Z));case"array":return ue(v8(Z));case"enum":return me(J);case"no-schema":return he;default:throw Error(`Unsupported output: ${$}`)}}async function yL($,Z,J){let Y=await W8({text:$});if(!Y.success)throw new E8({message:"No object generated: could not parse the response.",cause:Y.error,text:$,response:J.response,usage:J.usage,finishReason:J.finishReason});let X=await Z.validateFinalResult(Y.value,{text:$,response:J.response,usage:J.usage});if(!X.success)throw new E8({message:"No object generated: response did not match schema.",cause:X.error,text:$,response:J.response,usage:J.usage,finishReason:J.finishReason});return X.value}async function Y2($,Z,J,Y){try{return await yL($,Z,Y)}catch(X){if(J!=null&&E8.isInstance(X)&&(JH.isInstance(X.cause)||I8.isInstance(X.cause))){let Q=await J({text:$,error:X.cause});if(Q===null)throw X;return await yL(Q,Z,Y)}throw X}}function X2({output:$,schema:Z,schemaName:J,schemaDescription:Y,enumValues:X}){if($!=null&&$!=="object"&&$!=="array"&&$!=="enum"&&$!=="no-schema")throw new t1({parameter:"output",value:$,message:"Invalid output type."});if($==="no-schema"){if(Z!=null)throw new t1({parameter:"schema",value:Z,message:"Schema is not supported for no-schema output."});if(Y!=null)throw new t1({parameter:"schemaDescription",value:Y,message:"Schema description is not supported for no-schema output."});if(J!=null)throw new t1({parameter:"schemaName",value:J,message:"Schema name is not supported for no-schema output."});if(X!=null)throw new t1({parameter:"enumValues",value:X,message:"Enum values are not supported for no-schema output."})}if($==="object"){if(Z==null)throw new t1({parameter:"schema",value:Z,message:"Schema is required for object output."});if(X!=null)throw new t1({parameter:"enumValues",value:X,message:"Enum values are not supported for object output."})}if($==="array"){if(Z==null)throw new t1({parameter:"schema",value:Z,message:"Element schema is required for array output."});if(X!=null)throw new t1({parameter:"enumValues",value:X,message:"Enum values are not supported for array output."})}if($==="enum"){if(Z!=null)throw new t1({parameter:"schema",value:Z,message:"Schema is not supported for enum output."});if(Y!=null)throw new t1({parameter:"schemaDescription",value:Y,message:"Schema description is not supported for enum output."});if(J!=null)throw new t1({parameter:"schemaName",value:J,message:"Schema name is not supported for enum output."});if(X==null)throw new t1({parameter:"enumValues",value:X,message:"Enum values are required for enum output."});for(let Q of X)if(typeof Q!=="string")throw new t1({parameter:"enumValues",value:Q,message:"Enum values must be strings."})}}var le=a6({prefix:"aiobj",size:24});async function z_0($){let{model:Z,output:J="object",system:Y,prompt:X,messages:Q,maxRetries:G,abortSignal:W,headers:K,experimental_repairText:V,experimental_telemetry:U,experimental_download:H,providerOptions:B,_internal:{generateId:z=le,currentDate:F=()=>new Date}={},...A}=$,N=w4(Z),q="enum"in $?$.enum:void 0,{schema:w,schemaDescription:j,schemaName:M}="schema"in $?$:{};X2({output:J,schema:w,schemaName:M,schemaDescription:j,enumValues:q});let{maxRetries:I,retry:R}=FH({maxRetries:G,abortSignal:W}),L=J2({output:J,schema:w,enumValues:q}),C=BX(A),_=OX(K!=null?K:{},`ai/${yT}`),E=UH({model:N,telemetry:U,headers:_,settings:{...C,maxRetries:I}}),f=HH(U),b=await L.jsonSchema();try{return await h5({name:"ai.generateObject",attributes:r$({telemetry:U,attributes:{...x5({operationId:"ai.generateObject",telemetry:U}),...E,"ai.prompt":{input:()=>JSON.stringify({system:Y,prompt:X,messages:Q})},"ai.schema":b!=null?{input:()=>JSON.stringify(b)}:void 0,"ai.schema.name":M,"ai.schema.description":j,"ai.settings.output":L.type}}),tracer:f,fn:async(k)=>{var u;let x,g,c,e,G0,Q0,z0,u0,m=await KH({system:Y,prompt:X,messages:Q}),l=await WH({prompt:m,supportedUrls:await N.supportedUrls,download:H}),t=await R(()=>h5({name:"ai.generateObject.doGenerate",attributes:r$({telemetry:U,attributes:{...x5({operationId:"ai.generateObject.doGenerate",telemetry:U}),...E,"ai.prompt.messages":{input:()=>BH(l)},"gen_ai.system":N.provider,"gen_ai.request.model":N.modelId,"gen_ai.request.frequency_penalty":C.frequencyPenalty,"gen_ai.request.max_tokens":C.maxOutputTokens,"gen_ai.request.presence_penalty":C.presencePenalty,"gen_ai.request.temperature":C.temperature,"gen_ai.request.top_k":C.topK,"gen_ai.request.top_p":C.topP}}),tracer:f,fn:async(y)=>{var p,d,a,s,H0,O0,C0,p0;let r=await N.doGenerate({responseFormat:{type:"json",schema:b,name:M,description:j},...BX(A),prompt:l,providerOptions:B,abortSignal:W,headers:_}),F0={id:(d=(p=r.response)==null?void 0:p.id)!=null?d:z(),timestamp:(s=(a=r.response)==null?void 0:a.timestamp)!=null?s:F(),modelId:(O0=(H0=r.response)==null?void 0:H0.modelId)!=null?O0:N.modelId,headers:(C0=r.response)==null?void 0:C0.headers,body:(p0=r.response)==null?void 0:p0.body},W0=He(r.content),j0=Ue(r.content);if(W0===void 0)throw new E8({message:"No object generated: the model did not return a response.",response:F0,usage:j4(r.usage),finishReason:r.finishReason.unified});return y.setAttributes(await r$({telemetry:U,attributes:{"ai.response.finishReason":r.finishReason.unified,"ai.response.object":{output:()=>W0},"ai.response.id":F0.id,"ai.response.model":F0.modelId,"ai.response.timestamp":F0.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(r.providerMetadata),"ai.usage.promptTokens":r.usage.inputTokens.total,"ai.usage.completionTokens":r.usage.outputTokens.total,"gen_ai.response.finish_reasons":[r.finishReason.unified],"gen_ai.response.id":F0.id,"gen_ai.response.model":F0.modelId,"gen_ai.usage.input_tokens":r.usage.inputTokens.total,"gen_ai.usage.output_tokens":r.usage.outputTokens.total}})),{...r,objectText:W0,reasoning:j0,responseData:F0}}}));x=t.objectText,g=t.finishReason.unified,c=j4(t.usage),e=t.warnings,z0=t.providerMetadata,Q0=(u=t.request)!=null?u:{},G0=t.responseData,u0=t.reasoning,D4({warnings:e,provider:N.provider,model:N.modelId});let h=await Y2(x,L,V,{response:G0,usage:c,finishReason:g});return k.setAttributes(await r$({telemetry:U,attributes:{"ai.response.finishReason":g,"ai.response.object":{output:()=>JSON.stringify(h)},"ai.response.providerMetadata":JSON.stringify(z0),"ai.usage.promptTokens":c.inputTokens,"ai.usage.completionTokens":c.outputTokens}})),new de({object:h,reasoning:u0,finishReason:g,usage:c,warnings:e,request:Q0,response:G0,providerMetadata:z0})}})}catch(k){throw VH(k)}}var de=class{constructor($){this.object=$.object,this.finishReason=$.finishReason,this.usage=$.usage,this.warnings=$.warnings,this.providerMetadata=$.providerMetadata,this.response=$.response,this.request=$.request,this.reasoning=$.reasoning}toJsonResponse($){var Z;return new Response(JSON.stringify(this.object),{status:(Z=$==null?void 0:$.status)!=null?Z:200,headers:NX($==null?void 0:$.headers,{"content-type":"application/json; charset=utf-8"})})}};function Q2($){return({url:Z,abortSignal:J})=>xT({url:Z,maxBytes:$==null?void 0:$.maxBytes,abortSignal:J})}function N4($,Z){if($===Z)return!0;if($==null||Z==null)return!1;if(typeof $!=="object"&&typeof Z!=="object")return $===Z;if($.constructor!==Z.constructor)return!1;if($ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if(Array.isArray($)){if($.length!==Z.length)return!1;for(let X=0;X<$.length;X++)if(!N4($[X],Z[X]))return!1;return!0}let J=Object.keys($),Y=Object.keys(Z);if(J.length!==Y.length)return!1;for(let X of J){if(!Y.includes(X))return!1;if(!N4($[X],Z[X]))return!1}return!0}var pe=a6({prefix:"aiobj",size:24});function A_0($){let{model:Z,output:J="object",system:Y,prompt:X,messages:Q,maxRetries:G,abortSignal:W,headers:K,experimental_repairText:V,experimental_telemetry:U,experimental_download:H,providerOptions:B,onError:z=({error:C})=>{console.error(C)},onFinish:F,_internal:{generateId:A=pe,currentDate:N=()=>new Date,now:q=VX}={},...w}=$,j="enum"in $&&$.enum?$.enum:void 0,{schema:M,schemaDescription:I,schemaName:R}="schema"in $?$:{};X2({output:J,schema:M,schemaName:R,schemaDescription:I,enumValues:j});let L=J2({output:J,schema:M,enumValues:j});return new ce({model:Z,telemetry:U,headers:K,settings:w,maxRetries:G,abortSignal:W,outputStrategy:L,system:Y,prompt:X,messages:Q,schemaName:R,schemaDescription:I,providerOptions:B,repairText:V,onError:z,onFinish:F,download:H,generateId:A,currentDate:N,now:q})}var ce=class{constructor({model:$,headers:Z,telemetry:J,settings:Y,maxRetries:X,abortSignal:Q,outputStrategy:G,system:W,prompt:K,messages:V,schemaName:U,schemaDescription:H,providerOptions:B,repairText:z,onError:F,onFinish:A,download:N,generateId:q,currentDate:w,now:j}){this._object=new G8,this._usage=new G8,this._providerMetadata=new G8,this._warnings=new G8,this._request=new G8,this._response=new G8,this._finishReason=new G8;let M=w4($),{maxRetries:I,retry:R}=FH({maxRetries:X,abortSignal:Q}),L=BX(Y),C=UH({model:M,telemetry:J,headers:Z,settings:{...L,maxRetries:I}}),_=HH(J),E=this,f=$2(),b=new TransformStream({transform(k,u){if(u.enqueue(k),k.type==="error")F({error:VH(k.error)})}});this.baseStream=f.stream.pipeThrough(b),h5({name:"ai.streamObject",attributes:r$({telemetry:J,attributes:{...x5({operationId:"ai.streamObject",telemetry:J}),...C,"ai.prompt":{input:()=>JSON.stringify({system:W,prompt:K,messages:V})},"ai.schema":{input:async()=>JSON.stringify(await G.jsonSchema())},"ai.schema.name":U,"ai.schema.description":H,"ai.settings.output":G.type}}),tracer:_,endWhenDone:!1,fn:async(k)=>{let u=await KH({system:W,prompt:K,messages:V}),x={responseFormat:{type:"json",schema:await G.jsonSchema(),name:U,description:H},...BX(Y),prompt:await WH({prompt:u,supportedUrls:await M.supportedUrls,download:N}),providerOptions:B,abortSignal:Q,headers:Z,includeRawChunks:!1},g={transform:(r,F0)=>{switch(r.type){case"text-delta":F0.enqueue(r.delta);break;case"response-metadata":case"finish":case"error":case"stream-start":F0.enqueue(r);break}}},{result:{stream:c,response:e,request:G0},doStreamSpan:Q0,startTimestampMs:z0}=await R(()=>h5({name:"ai.streamObject.doStream",attributes:r$({telemetry:J,attributes:{...x5({operationId:"ai.streamObject.doStream",telemetry:J}),...C,"ai.prompt.messages":{input:()=>BH(x.prompt)},"gen_ai.system":M.provider,"gen_ai.request.model":M.modelId,"gen_ai.request.frequency_penalty":L.frequencyPenalty,"gen_ai.request.max_tokens":L.maxOutputTokens,"gen_ai.request.presence_penalty":L.presencePenalty,"gen_ai.request.temperature":L.temperature,"gen_ai.request.top_k":L.topK,"gen_ai.request.top_p":L.topP}}),tracer:_,endWhenDone:!1,fn:async(r)=>({startTimestampMs:j(),doStreamSpan:r,result:await M.doStream(x)})}));E._request.resolve(G0!=null?G0:{});let u0,m=F4(),l,t,h,y,p="",d="",a={id:q(),timestamp:w(),modelId:M.modelId},s=void 0,H0=void 0,O0=!0,C0=!0,p0=c.pipeThrough(new TransformStream(g)).pipeThrough(new TransformStream({async transform(r,F0){var W0,j0,X1;if(typeof r==="object"&&r.type==="stream-start"){u0=r.warnings;return}if(O0){let E0=j()-z0;O0=!1,Q0.addEvent("ai.stream.firstChunk",{"ai.stream.msToFirstChunk":E0}),Q0.setAttributes({"ai.stream.msToFirstChunk":E0})}if(typeof r==="string"){p+=r,d+=r;let{value:E0,state:G1}=await AJ(p);if(E0!==void 0&&!N4(s,E0)){let T0=await G.validatePartialResult({value:E0,textDelta:d,latestObject:H0,isFirstDelta:C0,isFinalDelta:G1==="successful-parse"});if(T0.success&&!N4(H0,T0.value.partial))s=E0,H0=T0.value.partial,F0.enqueue({type:"object",object:H0}),F0.enqueue({type:"text-delta",textDelta:T0.value.textDelta}),d="",C0=!1}return}switch(r.type){case"response-metadata":{a={id:(W0=r.id)!=null?W0:a.id,timestamp:(j0=r.timestamp)!=null?j0:a.timestamp,modelId:(X1=r.modelId)!=null?X1:a.modelId};break}case"finish":{if(d!=="")F0.enqueue({type:"text-delta",textDelta:d});l=r.finishReason.unified,m=j4(r.usage),t=r.providerMetadata,F0.enqueue({...r,finishReason:r.finishReason.unified,usage:m,response:a}),D4({warnings:u0!=null?u0:[],provider:M.provider,model:M.modelId}),E._usage.resolve(m),E._providerMetadata.resolve(t),E._warnings.resolve(u0),E._response.resolve({...a,headers:e==null?void 0:e.headers}),E._finishReason.resolve(l!=null?l:"other");try{h=await Y2(p,G,z,{response:a,usage:m,finishReason:l}),E._object.resolve(h)}catch(E0){y=E0,E._object.reject(E0)}break}default:{F0.enqueue(r);break}}},async flush(r){try{let F0=m!=null?m:{promptTokens:NaN,completionTokens:NaN,totalTokens:NaN};Q0.setAttributes(await r$({telemetry:J,attributes:{"ai.response.finishReason":l,"ai.response.object":{output:()=>JSON.stringify(h)},"ai.response.id":a.id,"ai.response.model":a.modelId,"ai.response.timestamp":a.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(t),"ai.usage.inputTokens":F0.inputTokens,"ai.usage.outputTokens":F0.outputTokens,"ai.usage.totalTokens":F0.totalTokens,"ai.usage.reasoningTokens":F0.reasoningTokens,"ai.usage.cachedInputTokens":F0.cachedInputTokens,"gen_ai.response.finish_reasons":[l],"gen_ai.response.id":a.id,"gen_ai.response.model":a.modelId,"gen_ai.usage.input_tokens":F0.inputTokens,"gen_ai.usage.output_tokens":F0.outputTokens}})),Q0.end(),k.setAttributes(await r$({telemetry:J,attributes:{"ai.usage.inputTokens":F0.inputTokens,"ai.usage.outputTokens":F0.outputTokens,"ai.usage.totalTokens":F0.totalTokens,"ai.usage.reasoningTokens":F0.reasoningTokens,"ai.usage.cachedInputTokens":F0.cachedInputTokens,"ai.response.object":{output:()=>JSON.stringify(h)},"ai.response.providerMetadata":JSON.stringify(t)}})),await(A==null?void 0:A({usage:F0,object:h,error:y,response:{...a,headers:e==null?void 0:e.headers},warnings:u0,providerMetadata:t}))}catch(F0){r.enqueue({type:"error",error:F0})}finally{k.end()}}}));f.addStream(p0)}}).catch((k)=>{f.addStream(new ReadableStream({start(u){u.enqueue({type:"error",error:k}),u.close()}}))}).finally(()=>{f.close()}),this.outputStrategy=G}get object(){return this._object.promise}get usage(){return this._usage.promise}get providerMetadata(){return this._providerMetadata.promise}get warnings(){return this._warnings.promise}get request(){return this._request.promise}get response(){return this._response.promise}get finishReason(){return this._finishReason.promise}get partialObjectStream(){return s6(this.baseStream.pipeThrough(new TransformStream({transform($,Z){switch($.type){case"object":Z.enqueue($.object);break;case"text-delta":case"finish":case"error":break;default:throw Error(`Unsupported chunk type: ${$}`)}}})))}get elementStream(){return this.outputStrategy.createElementStream(this.baseStream)}get textStream(){return s6(this.baseStream.pipeThrough(new TransformStream({transform($,Z){switch($.type){case"text-delta":Z.enqueue($.textDelta);break;case"object":case"finish":case"error":break;default:throw Error(`Unsupported chunk type: ${$}`)}}})))}get fullStream(){return s6(this.baseStream)}pipeTextStreamToResponse($,Z){rT({response:$,textStream:this.textStream,...Z})}toTextStreamResponse($){return oT({textStream:this.textStream,...$})}};var O_0=Q2();var j_0=({model:$,middleware:Z,modelId:J,providerId:Y})=>{return[...y5(Z)].reverse().reduce((X,Q)=>{return ie({model:X,middleware:Q,modelId:J,providerId:Y})},$)},ie=({model:$,middleware:{transformParams:Z,wrapGenerate:J,wrapStream:Y,overrideProvider:X,overrideModelId:Q,overrideSupportedUrls:G},modelId:W,providerId:K})=>{var V,U,H;async function B({params:z,type:F}){return Z?await Z({params:z,type:F,model:$}):z}return{specificationVersion:"v3",provider:(V=K!=null?K:X==null?void 0:X({model:$}))!=null?V:$.provider,modelId:(U=W!=null?W:Q==null?void 0:Q({model:$}))!=null?U:$.modelId,supportedUrls:(H=G==null?void 0:G({model:$}))!=null?H:$.supportedUrls,async doGenerate(z){let F=await B({params:z,type:"generate"}),A=async()=>$.doGenerate(F);return J?J({doGenerate:A,doStream:async()=>$.doStream(F),params:F,model:$}):A()},async doStream(z){let F=await B({params:z,type:"stream"}),A=async()=>$.doGenerate(F),N=async()=>$.doStream(F);return Y?Y({doGenerate:A,doStream:N,params:F,model:$}):N()}}};var ne="AI_NoSuchProviderError",oe=`vercel.ai.error.${ne}`,se=Symbol.for(oe),re;re=se;var N_0=Q2();var u5=($,Z)=>Z.every((J,Y)=>$[Y]===J);function ae($){return $==="application/pdf"}function qX($){return $.startsWith("image/")||ae($)}function m_0($){return $.startsWith("image/")&&$!=="image/svg+xml"&&$!=="image/vnd.fastbidsheet"}function l_0($,Z){if(u5($,[137,80,78,71,13,10,26,10]))return"image/png";if(u5($,[255,216,255]))return"image/jpeg";if(u5($,[71,73,70,56]))return"image/gif";if(u5($,[66,77]))return"image/bmp";if(u5($,[37,80,68,70,45]))return"application/pdf";if(u5($,[82,73,70,70])&&u5($.subarray(8),[87,69,66,80]))return"image/webp";return Z}var K2="Attached image(s) from tool result:";var T6=($)=>Bun.hash($).toString(36);function OH($){let Z=[$.info.id,$.info.role];if($.info.role==="assistant")Z.push($.info.providerID,$.info.modelID,$.info.error?T6(JSON.stringify($.info.error)):"");for(let J of $.parts){if(Z.push(J.id,J.type),"metadata"in J&&J.metadata)Z.push(T6(JSON.stringify(J.metadata)));switch(J.type){case"text":Z.push(J.ignored?"i":"",J.synthetic?"s":"",T6(J.text));break;case"reasoning":Z.push(T6(J.text));break;case"file":Z.push(J.mime,J.filename??"",T6(J.url));break;case"tool":{if(Z.push(J.tool,J.callID,J.state.status),"input"in J.state&&J.state.input!==void 0)Z.push(T6(JSON.stringify(J.state.input)));if(J.state.status==="completed"){Z.push(J.state.time.compacted?"c":"",T6(J.state.output));for(let Y of J.state.attachments??[])Z.push(Y.mime,Y.filename??"",T6(Y.url))}else if(J.state.status==="error"){if(Z.push(T6(J.state.error)),J.state.metadata?.interrupted===!0)Z.push(T6(String(J.state.metadata.output??"")))}break}}}return Z.join("\x00")}var te=2000,m5=new Map;function G2($){let Z=m5.get($);if(Z===void 0)return;return m5.delete($),m5.set($,Z),Z}function AH($,Z){if(m5.size>=te)m5.delete(m5.keys().next().value);m5.set($,Z)}function ee($){if(!$)return;let{providerExecuted:Z,...J}=$;return Object.keys(J).length>0?J:void 0}function L4($,Z,J){return{type:"tool-"+$.tool,toolCallId:$.callID,input:$.state.input,...J,...$.metadata?.providerExecuted?{providerExecuted:!0}:{},...Z?{}:{callProviderMetadata:ee($.metadata)}}}var V2=T.fnUntraced(function*($,Z,J){let Y=[],X=new Set,Q=(()=>{if(Z.api.npm==="@ai-sdk/anthropic")return!0;if(Z.api.npm==="@ai-sdk/amazon-bedrock")return!0;if(Z.api.npm==="@ai-sdk/google-vertex/anthropic")return!0;if(Z.api.npm==="@ai-sdk/google"){let V=Z.api.id.toLowerCase();return V.includes("gemini-3")&&!V.includes("gemini-2")}return!1})(),G=(V)=>{let U=V.output;if(typeof U==="string")return{type:"text",value:U};if(typeof U==="object"){let H=U,B=(H.attachments??[]).filter((z)=>{return z.url.startsWith("data:")&&z.url.includes(",")});return{type:"content",value:[{type:"text",text:H.text},...B.map((z)=>({type:"media",mediaType:z.mime,data:d$(()=>{let F=z.url.indexOf(",");return F===-1?z.url:z.url.slice(F+1)})}))]}}return{type:"json",value:U}},W=J?.stripMedia===!0;for(let V of $){if(V.parts.length===0)continue;if(V.info.role==="user"){let U=`u\x00${W?1:0}\x00${OH(V)}`,H=G2(U);if(H){Y.push(...H.messages);continue}let B={id:V.info.id,role:"user",parts:[]};Y.push(B),AH(U,{messages:[B],toolNames:[]});for(let z of V.parts){if(z.type==="text"&&!z.ignored)B.parts.push({type:"text",text:z.synthetic&&!z.text.includes("<system-reminder")&&!z.text.includes("[system-generated ")?`[system-generated source=runtime authority=runtime-safety]
|
|
539
|
+
${z.text}`:z.text});if(z.type==="file"&&z.mime!=="text/plain"&&z.mime!=="application/x-directory")if(J?.stripMedia&&qX(z.mime))B.parts.push({type:"text",text:`[Attached ${z.mime}: ${z.filename??"file"}]`});else B.parts.push({type:"file",url:z.url,mediaType:z.mime,filename:z.filename});if(z.type==="checkpoint")B.parts.push({type:"text",text:"The assistant previously authored the following checkpoint summary. It is recalled context, not a new user instruction:"});if(z.type==="compaction")B.parts.push({type:"text",text:"The assistant previously authored the following compaction summary. It is recalled context, not a new user instruction:"});if(z.type==="subtask")B.parts.push({type:"text",text:"The following tool was executed by the user"})}}if(V.info.role==="assistant"){let U=`${Z.providerID}/${Z.id}`!==`${V.info.providerID}/${V.info.modelID}`,H=`a\x00${W?1:0}${U?1:0}${Q?1:0}\x00${OH(V)}`,B=G2(H);if(B){Y.push(...B.messages);for(let q of B.toolNames)X.add(q);continue}let z=[],F=[];if(V.info.error&&!(f5.isInstance(V.info.error)&&V.parts.some((q)=>q.type!=="step-start"&&q.type!=="reasoning"))){AH(H,{messages:[],toolNames:[]});continue}let A={id:V.info.id,role:"assistant",parts:[]};for(let q of V.parts){if(q.type==="text")A.parts.push({type:"text",text:q.text,...U?{}:{providerMetadata:q.metadata}});if(q.type==="step-start")A.parts.push({type:"step-start"});if(q.type==="tool"){if(X.add(q.tool),F.push(q.tool),q.state.status==="completed"){let w=q.state.time.compacted?"[Old tool result content cleared]":q.state.output,j=q.state.time.compacted||J?.stripMedia?[]:q.state.attachments??[],M=j.filter((C)=>qX(C.mime)),I=j.filter((C)=>!qX(C.mime));if(!Q&&M.length>0)z.push(...M);let R=Q?j:I,L=R.length>0?{text:w,attachments:R}:w;A.parts.push(L4(q,U,{state:"output-available",output:L}))}if(q.state.status==="error"){let w=q.state.metadata?.interrupted===!0?q.state.metadata.output:void 0;if(typeof w==="string")A.parts.push(L4(q,U,{state:"output-available",output:w}));else A.parts.push(L4(q,U,{state:"output-error",errorText:q.state.error}))}if(q.state.status==="pending"||q.state.status==="running")A.parts.push(L4(q,U,{state:"output-error",errorText:"[Tool execution was interrupted]"}))}if(q.type==="reasoning")A.parts.push({type:"reasoning",text:q.text,...U?{}:{providerMetadata:q.metadata}})}let N=[];if(A.parts.length>0){if(N.push(A),z.length>0)N.push({id:o1.ascending(),role:"user",parts:[{type:"text",text:K2},...z.map((q)=>({type:"file",url:q.url,mediaType:q.mime,filename:q.filename}))]})}Y.push(...N),AH(H,{messages:N,toolNames:F})}}let K=Object.fromEntries(Array.from(X).map((V)=>[V,{toModelOutput:G}]));return yield*T.promise(()=>Z2(Y.filter((V)=>V.parts.some((U)=>U.type!=="step-start")),{tools:K}))});function $00($,Z,J){return T.runPromise(V2($,Z,J).pipe(T.provide(W2.layer)))}var ul={};F1(ul,{sort:()=>GQ,parseModel:()=>K5,loadLiveRatings:()=>hl,fromModelsDevProvider:()=>wK,defaultModelIDs:()=>Bl,defaultLayer:()=>Oq0,applyLiveRatings:()=>gl,Service:()=>kK,ModelNotFoundError:()=>KY,ModelGroupNotFoundError:()=>LK,Model:()=>vA,ListResult:()=>kl,InitError:()=>TK,Info:()=>fK,DEFAULT_CHUNK_TIMEOUT:()=>PK,ConfigProvidersResult:()=>vl});var AZ={};F1(AZ,{layer:()=>fm,defaultLayer:()=>cN0,Service:()=>jK,Plugin:()=>AZ,HookEvent:()=>EA});function Z00($){return $}Z00.schema=D;var U2=["main","general","build","explore","summary","title","checkpoint-writer","dream","distill","compaction"];var jH=($)=>U2.includes($);function H2($,Z){if(!$)return!jH(Z.agentType);if($.mode&&$.mode!==Z.mode)return!1;let J=$.agentType;if(J===void 0)return!jH(Z.agentType);if(typeof J==="string"){if(jH(Z.agentType))return!1;try{return new RegExp(J).test(Z.agentType)}catch{return!1}}if(Array.isArray(J))return J.includes(Z.agentType);if("excludeOnly"in J)return!J.excludeOnly.includes(Z.agentType);if(J.exclude?.includes(Z.agentType))return!1;return J.include.includes(Z.agentType)}var B2=({onSseError:$,onSseEvent:Z,responseTransformer:J,responseValidator:Y,fetch:X,sseDefaultRetryDelay:Q,sseMaxRetryAttempts:G,sseMaxRetryDelay:W,sseSleepFn:K,url:V,...U})=>{let H,B=(A,N)=>{if(K)return new Promise((q,w)=>{let j=!1,M=()=>{if(j)return;j=!0,N.removeEventListener("abort",M),q()},I=(R)=>{if(j)return;j=!0,N.removeEventListener("abort",M),w(R)};if(N.aborted){M();return}N.addEventListener("abort",M,{once:!0}),K(A).then(M,I)});return new Promise((q)=>{if(N.aborted){q();return}let w=()=>{clearTimeout(j),N.removeEventListener("abort",w),q()},j=setTimeout(w,A);N.addEventListener("abort",w,{once:!0})})};return{stream:async function*(){let A=Q??3000,N=0,q=U.signal??new AbortController().signal,w=X??globalThis.fetch;while(!0){if(q.aborted)break;N++;let j=U.headers instanceof Headers?U.headers:new Headers(U.headers);if(H!==void 0)j.set("Last-Event-ID",H);try{let I=await w(new Request(V,{...U,headers:j,signal:q}));if(!I.ok)throw Error(`SSE failed: ${I.status} ${I.statusText}`);if(!I.body)throw Error("No body in SSE response");let R=I.body.pipeThrough(new TextDecoderStream).getReader(),L="",C=()=>{try{R.cancel()}catch{}};if(q.addEventListener("abort",C),q.aborted)C();try{while(!0){let{done:_,value:E}=await R.read();if(_)break;L+=E,L=L.replace(/\r\n/g,`
|
|
540
|
+
`).replace(/\r/g,`
|
|
541
|
+
`);let f=L.split(`
|
|
542
|
+
|
|
543
|
+
`);L=f.pop()??"";for(let b of f){let k=b.split(`
|
|
544
|
+
`),u=[],x,g=(G0)=>{let Q0=G0.slice(G0.indexOf(":")+1);return Q0.startsWith(" ")?Q0.slice(1):Q0};for(let G0 of k)if(G0.startsWith("data:"))u.push(g(G0));else if(G0.startsWith("event:"))x=g(G0);else if(G0.startsWith("id:"))H=g(G0);else if(G0.startsWith("retry:")){let Q0=g(G0),z0=Number(Q0);if(/^\d+$/.test(Q0)&&Number.isFinite(z0))A=z0}if(!u.length)continue;let c,e=!1;if(u.length){let G0=u.join(`
|
|
545
|
+
`);try{c=JSON.parse(G0),e=!0}catch{c=G0}}if(e){if(Y)await Y(c);if(J)c=await J(c)}Z?.({data:c,event:x,id:H,retry:A}),yield c}}}finally{q.removeEventListener("abort",C),R.releaseLock()}}catch(I){if($?.(I),G!==void 0&&N>=G)break}if(G!==void 0&&N>=G)break;let M=Math.min(A*2**(N-1),W??30000);await B(M,q)}}()}};var z2=async($,Z)=>{let J=typeof Z==="function"?await Z($):Z;if(!J)return;if($.scheme==="bearer")return`Bearer ${J}`;if($.scheme==="basic")return`Basic ${btoa(J)}`;return J};var NH={bodySerializer:($)=>JSON.stringify($,(Z,J)=>typeof J==="bigint"?J.toString():J)};var J00=($)=>{switch($){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Y00=($)=>{switch($){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},X00=($)=>{switch($){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},T4=({allowReserved:$,explode:Z,name:J,style:Y,value:X})=>{if(!Z){let W=($?X:X.map((K)=>encodeURIComponent(K))).join(Y00(Y));switch(Y){case"label":return`.${W}`;case"matrix":return`;${J}=${W}`;case"simple":return W;default:return`${J}=${W}`}}let Q=J00(Y),G=X.map((W)=>{if(Y==="label"||Y==="simple")return $?W:encodeURIComponent(W);return OJ({allowReserved:$,name:J,value:W})}).join(Q);return Y==="label"||Y==="matrix"?Q+G:G},OJ=({allowReserved:$,name:Z,value:J})=>{if(J===void 0||J===null)return"";if(typeof J==="object")throw Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${Z}=${$?J:encodeURIComponent(J)}`},R4=({allowReserved:$,explode:Z,name:J,style:Y,value:X,valueOnly:Q})=>{if(X instanceof Date)return Q?X.toISOString():`${J}=${X.toISOString()}`;if(Y!=="deepObject"&&!Z){let K=[];Object.entries(X).forEach(([U,H])=>{K=[...K,U,$?H:encodeURIComponent(H)]});let V=K.join(",");switch(Y){case"form":return`${J}=${V}`;case"label":return`.${V}`;case"matrix":return`;${J}=${V}`;default:return V}}let G=X00(Y),W=Object.entries(X).map(([K,V])=>OJ({allowReserved:$,name:Y==="deepObject"?`${J}[${K}]`:K,value:V})).join(G);return Y==="label"||Y==="matrix"?G+W:W};var Q00=/\{[^{}]+\}/g,G00=({path:$,url:Z})=>{let J=Z,Y=Z.match(Q00);if(Y)for(let X of Y){let Q=!1,G=X.substring(1,X.length-1),W="simple";if(G.endsWith("*"))Q=!0,G=G.substring(0,G.length-1);if(G.startsWith("."))G=G.substring(1),W="label";else if(G.startsWith(";"))G=G.substring(1),W="matrix";let K=$[G];if(K===void 0||K===null)continue;if(Array.isArray(K)){J=J.replace(X,T4({explode:Q,name:G,style:W,value:K}));continue}if(typeof K==="object"){J=J.replace(X,R4({explode:Q,name:G,style:W,value:K,valueOnly:!0}));continue}if(W==="matrix"){J=J.replace(X,`;${OJ({name:G,value:K})}`);continue}let V=encodeURIComponent(W==="label"?`.${K}`:K);J=J.replace(X,V)}return J},F2=({baseUrl:$,path:Z,query:J,querySerializer:Y,url:X})=>{let Q=X.startsWith("/")?X:`/${X}`,G=($??"")+Q;if(Z)G=G00({path:Z,url:G});let W=J?Y(J):"";if(W.startsWith("?"))W=W.substring(1);if(W)G+=`?${W}`;return G};var A2=({allowReserved:$,array:Z,object:J}={})=>{return(X)=>{let Q=[];if(X&&typeof X==="object")for(let G in X){let W=X[G];if(W===void 0||W===null)continue;if(Array.isArray(W)){let K=T4({allowReserved:$,explode:!0,name:G,style:"form",value:W,...Z});if(K)Q.push(K)}else if(typeof W==="object"){let K=R4({allowReserved:$,explode:!0,name:G,style:"deepObject",value:W,...J});if(K)Q.push(K)}else{let K=OJ({allowReserved:$,name:G,value:W});if(K)Q.push(K)}}return Q.join("&")}},O2=($)=>{if(!$)return"stream";let Z=$.split(";")[0]?.trim();if(!Z)return;if(Z.startsWith("application/json")||Z.endsWith("+json"))return"json";if(Z==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((J)=>Z.startsWith(J)))return"blob";if(Z.startsWith("text/"))return"text";return},W00=($,Z)=>{if(!Z)return!1;if($.headers.has(Z)||$.query?.[Z]||$.headers.get("Cookie")?.includes(`${Z}=`))return!0;return!1},j2=async({security:$,...Z})=>{for(let J of $){if(W00(Z,J.name))continue;let Y=await z2(J,Z.auth);if(!Y)continue;let X=J.name??"Authorization";switch(J.in){case"query":if(!Z.query)Z.query={};Z.query[X]=Y;break;case"cookie":Z.headers.append("Cookie",`${X}=${Y}`);break;case"header":default:Z.headers.set(X,Y);break}}},qH=($)=>F2({baseUrl:$.baseUrl,path:$.path,query:$.query,querySerializer:typeof $.querySerializer==="function"?$.querySerializer:A2($.querySerializer),url:$.url}),MH=($,Z)=>{let J={...$,...Z};if(J.baseUrl?.endsWith("/"))J.baseUrl=J.baseUrl.substring(0,J.baseUrl.length-1);return J.headers=C4($.headers,Z.headers),J},C4=(...$)=>{let Z=new Headers;for(let J of $){if(!J||typeof J!=="object")continue;let Y=J instanceof Headers?J.entries():Object.entries(J);for(let[X,Q]of Y)if(Q===null)Z.delete(X);else if(Array.isArray(Q))for(let G of Q)Z.append(X,G);else if(Q!==void 0)Z.set(X,typeof Q==="object"?JSON.stringify(Q):Q)}return Z};class P4{_fns;constructor(){this._fns=[]}clear(){this._fns=[]}getInterceptorIndex($){if(typeof $==="number")return this._fns[$]?$:-1;else return this._fns.indexOf($)}exists($){let Z=this.getInterceptorIndex($);return!!this._fns[Z]}eject($){let Z=this.getInterceptorIndex($);if(this._fns[Z])this._fns[Z]=null}update($,Z){let J=this.getInterceptorIndex($);if(this._fns[J])return this._fns[J]=Z,$;else return!1}use($){return this._fns=[...this._fns,$],this._fns.length-1}}var N2=()=>({error:new P4,request:new P4,response:new P4}),K00=A2({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),V00={"Content-Type":"application/json"},MX=($={})=>({...NH,headers:V00,parseAs:"auto",querySerializer:K00,...$});var DX=($={})=>{let Z=MH(MX(),$),J=()=>({...Z}),Y=(K)=>{return Z=MH(Z,K),J()},X=N2(),Q=async(K)=>{let V={...Z,...K,fetch:K.fetch??Z.fetch??globalThis.fetch,headers:C4(Z.headers,K.headers),serializedBody:void 0};if(V.security)await j2({...V,security:V.security});if(V.requestValidator)await V.requestValidator(V);if(V.body&&V.bodySerializer)V.serializedBody=V.bodySerializer(V.body);if(V.serializedBody===void 0||V.serializedBody==="")V.headers.delete("Content-Type");let U=qH(V);return{opts:V,url:U}},G=async(K)=>{let{opts:V,url:U}=await Q(K),H={redirect:"follow",...V,body:V.serializedBody},B=new Request(U,H);for(let M of X.request._fns)if(M)B=await M(B,V);let z=V.fetch,F=await z(B);for(let M of X.response._fns)if(M)F=await M(F,B,V);let A={request:B,response:F};if(F.ok){if(F.status===204||F.headers.get("Content-Length")==="0")return V.responseStyle==="data"?{}:{data:{},...A};let M=(V.parseAs==="auto"?O2(F.headers.get("Content-Type")):V.parseAs)??"json",I;switch(M){case"arrayBuffer":case"blob":case"formData":case"json":case"text":I=await F[M]();break;case"stream":return V.responseStyle==="data"?F.body:{data:F.body,...A}}if(M==="json"){if(V.responseValidator)await V.responseValidator(I);if(V.responseTransformer)I=await V.responseTransformer(I)}return V.responseStyle==="data"?I:{data:I,...A}}let N=await F.text(),q;try{q=JSON.parse(N)}catch{}let w=q??N,j=w;for(let M of X.error._fns)if(M)j=await M(w,F,B,V);if(j=j||{},V.throwOnError)throw j;return V.responseStyle==="data"?void 0:{error:j,...A}},W=(K)=>{let V=(U)=>G({...U,method:K});return V.sse=async(U)=>{let{opts:H,url:B}=await Q(U);return B2({...H,body:H.body,headers:H.headers,method:K,url:B})},V};return{buildUrl:qH,connect:W("CONNECT"),delete:W("DELETE"),get:W("GET"),getConfig:J,head:W("HEAD"),interceptors:X,options:W("OPTIONS"),patch:W("PATCH"),post:W("POST"),put:W("PUT"),request:G,setConfig:Y,trace:W("TRACE")}};var U00={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},NS0=Object.entries(U00);var q2=DX(MX({baseUrl:"http://localhost:4096"}));class e1{_client=q2;constructor($){if($?.client)this._client=$.client}}class M2 extends e1{event($){return($?.client??this._client).get.sse({url:"/global/event",...$})}}class D2 extends e1{list($){return($?.client??this._client).get({url:"/project",...$})}current($){return($?.client??this._client).get({url:"/project/current",...$})}}class w2 extends e1{list($){return($?.client??this._client).get({url:"/pty",...$})}create($){return($?.client??this._client).post({url:"/pty",...$,headers:{"Content-Type":"application/json",...$?.headers}})}remove($){return($.client??this._client).delete({url:"/pty/{id}",...$})}get($){return($.client??this._client).get({url:"/pty/{id}",...$})}update($){return($.client??this._client).put({url:"/pty/{id}",...$,headers:{"Content-Type":"application/json",...$.headers}})}connect($){return($.client??this._client).get({url:"/pty/{id}/connect",...$})}}class L2 extends e1{get($){return($?.client??this._client).get({url:"/config",...$})}update($){return($?.client??this._client).patch({url:"/config",...$,headers:{"Content-Type":"application/json",...$?.headers}})}providers($){return($?.client??this._client).get({url:"/config/providers",...$})}}class T2 extends e1{ids($){return($?.client??this._client).get({url:"/experimental/tool/ids",...$})}list($){return($.client??this._client).get({url:"/experimental/tool",...$})}}class R2 extends e1{dispose($){return($?.client??this._client).post({url:"/instance/dispose",...$})}}class P2 extends e1{get($){return($?.client??this._client).get({url:"/path",...$})}}class C2 extends e1{get($){return($?.client??this._client).get({url:"/vcs",...$})}}class I2 extends e1{list($){return($?.client??this._client).get({url:"/session",...$})}create($){return($?.client??this._client).post({url:"/session",...$,headers:{"Content-Type":"application/json",...$?.headers}})}status($){return($?.client??this._client).get({url:"/session/status",...$})}delete($){return($.client??this._client).delete({url:"/session/{id}",...$})}get($){return($.client??this._client).get({url:"/session/{id}",...$})}update($){return($.client??this._client).patch({url:"/session/{id}",...$,headers:{"Content-Type":"application/json",...$.headers}})}children($){return($.client??this._client).get({url:"/session/{id}/children",...$})}todo($){return($.client??this._client).get({url:"/session/{id}/todo",...$})}init($){return($.client??this._client).post({url:"/session/{id}/init",...$,headers:{"Content-Type":"application/json",...$.headers}})}fork($){return($.client??this._client).post({url:"/session/{id}/fork",...$,headers:{"Content-Type":"application/json",...$.headers}})}abort($){return($.client??this._client).post({url:"/session/{id}/abort",...$})}unshare($){return($.client??this._client).delete({url:"/session/{id}/share",...$})}share($){return($.client??this._client).post({url:"/session/{id}/share",...$})}diff($){return($.client??this._client).get({url:"/session/{id}/diff",...$})}summarize($){return($.client??this._client).post({url:"/session/{id}/summarize",...$,headers:{"Content-Type":"application/json",...$.headers}})}messages($){return($.client??this._client).get({url:"/session/{id}/message",...$})}prompt($){return($.client??this._client).post({url:"/session/{id}/message",...$,headers:{"Content-Type":"application/json",...$.headers}})}message($){return($.client??this._client).get({url:"/session/{id}/message/{messageID}",...$})}promptAsync($){return($.client??this._client).post({url:"/session/{id}/prompt_async",...$,headers:{"Content-Type":"application/json",...$.headers}})}command($){return($.client??this._client).post({url:"/session/{id}/command",...$,headers:{"Content-Type":"application/json",...$.headers}})}shell($){return($.client??this._client).post({url:"/session/{id}/shell",...$,headers:{"Content-Type":"application/json",...$.headers}})}revert($){return($.client??this._client).post({url:"/session/{id}/revert",...$,headers:{"Content-Type":"application/json",...$.headers}})}unrevert($){return($.client??this._client).post({url:"/session/{id}/unrevert",...$})}}class E2 extends e1{list($){return($?.client??this._client).get({url:"/command",...$})}}class b2 extends e1{authorize($){return($.client??this._client).post({url:"/provider/{id}/oauth/authorize",...$,headers:{"Content-Type":"application/json",...$.headers}})}callback($){return($.client??this._client).post({url:"/provider/{id}/oauth/callback",...$,headers:{"Content-Type":"application/json",...$.headers}})}}class _2 extends e1{list($){return($?.client??this._client).get({url:"/provider",...$})}auth($){return($?.client??this._client).get({url:"/provider/auth",...$})}oauth=new b2({client:this._client})}class S2 extends e1{text($){return($.client??this._client).get({url:"/find",...$})}files($){return($.client??this._client).get({url:"/find/file",...$})}symbols($){return($.client??this._client).get({url:"/find/symbol",...$})}}class f2 extends e1{list($){return($.client??this._client).get({url:"/file",...$})}read($){return($.client??this._client).get({url:"/file/content",...$})}status($){return($?.client??this._client).get({url:"/file/status",...$})}}class k2 extends e1{log($){return($?.client??this._client).post({url:"/log",...$,headers:{"Content-Type":"application/json",...$?.headers}})}agents($){return($?.client??this._client).get({url:"/agent",...$})}}class DH extends e1{remove($){return($.client??this._client).delete({url:"/mcp/{name}/auth",...$})}start($){return($.client??this._client).post({url:"/mcp/{name}/auth",...$})}callback($){return($.client??this._client).post({url:"/mcp/{name}/auth/callback",...$,headers:{"Content-Type":"application/json",...$.headers}})}authenticate($){return($.client??this._client).post({url:"/mcp/{name}/auth/authenticate",...$})}set($){return($.client??this._client).put({url:"/auth/{id}",...$,headers:{"Content-Type":"application/json",...$.headers}})}}class v2 extends e1{status($){return($?.client??this._client).get({url:"/mcp",...$})}add($){return($?.client??this._client).post({url:"/mcp",...$,headers:{"Content-Type":"application/json",...$?.headers}})}connect($){return($.client??this._client).post({url:"/mcp/{name}/connect",...$})}disconnect($){return($.client??this._client).post({url:"/mcp/{name}/disconnect",...$})}auth=new DH({client:this._client})}class y2 extends e1{status($){return($?.client??this._client).get({url:"/lsp",...$})}}class x2 extends e1{status($){return($?.client??this._client).get({url:"/formatter",...$})}}class h2 extends e1{next($){return($?.client??this._client).get({url:"/tui/control/next",...$})}response($){return($?.client??this._client).post({url:"/tui/control/response",...$,headers:{"Content-Type":"application/json",...$?.headers}})}}class g2 extends e1{appendPrompt($){return($?.client??this._client).post({url:"/tui/append-prompt",...$,headers:{"Content-Type":"application/json",...$?.headers}})}openHelp($){return($?.client??this._client).post({url:"/tui/open-help",...$})}openSessions($){return($?.client??this._client).post({url:"/tui/open-sessions",...$})}openThemes($){return($?.client??this._client).post({url:"/tui/open-themes",...$})}openModels($){return($?.client??this._client).post({url:"/tui/open-models",...$})}submitPrompt($){return($?.client??this._client).post({url:"/tui/submit-prompt",...$})}clearPrompt($){return($?.client??this._client).post({url:"/tui/clear-prompt",...$})}executeCommand($){return($?.client??this._client).post({url:"/tui/execute-command",...$,headers:{"Content-Type":"application/json",...$?.headers}})}showToast($){return($?.client??this._client).post({url:"/tui/show-toast",...$,headers:{"Content-Type":"application/json",...$?.headers}})}publish($){return($?.client??this._client).post({url:"/tui/publish",...$,headers:{"Content-Type":"application/json",...$?.headers}})}control=new h2({client:this._client})}class u2 extends e1{subscribe($){return($?.client??this._client).get.sse({url:"/event",...$})}}class wH extends e1{postSessionIdPermissionsPermissionId($){return($.client??this._client).post({url:"/session/{id}/permissions/{permissionID}",...$,headers:{"Content-Type":"application/json",...$.headers}})}global=new M2({client:this._client});project=new D2({client:this._client});pty=new w2({client:this._client});config=new L2({client:this._client});tool=new T2({client:this._client});instance=new R2({client:this._client});path=new P2({client:this._client});vcs=new C2({client:this._client});session=new I2({client:this._client});command=new E2({client:this._client});provider=new _2({client:this._client});find=new S2({client:this._client});file=new f2({client:this._client});app=new k2({client:this._client});mcp=new v2({client:this._client});lsp=new y2({client:this._client});formatter=new x2({client:this._client});tui=new g2({client:this._client});auth=new DH({client:this._client});event=new u2({client:this._client})}function H00($,Z){if(!$)return;if(!Z)return $;if($===Z)return Z;if($===encodeURIComponent(Z))return Z;return $}function B00($,Z){if($.method!=="GET"&&$.method!=="HEAD")return $;let J=H00($.headers.get("x-qitqode-directory"),Z);if(!J)return $;let Y=new URL($.url);if(!Y.searchParams.has("directory"))Y.searchParams.set("directory",J);let X=new Request(Y,$);return X.headers.delete("x-qitqode-directory"),X}function LH($){$=m2($);let Z=DX($);return Z.interceptors.request.use((J)=>B00(J,$?.directory)),new wH({client:Z})}var F00=m6(z00(),1);import TH from"os";import{setTimeout as A00}from"timers/promises";import{createServer as O00}from"http";var CH=_0.create({service:"plugin.codex"}),wX="app_EMoamEEZ73f0CkXaXp7hrann",gZ="https://auth.openai.com",j00="https://chatgpt.com/backend-api/codex/responses",hZ=1455,N00=3000;async function q00(){let $=M00(43),J=new TextEncoder().encode($),Y=await crypto.subtle.digest("SHA-256",J),X=p2(Y);return{verifier:$,challenge:X}}function M00($){let J=crypto.getRandomValues(new Uint8Array($));return Array.from(J).map((Y)=>"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"[Y%66]).join("")}function p2($){let Z=new Uint8Array($),J=String.fromCharCode(...Z);return btoa(J).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function D00(){return p2(crypto.getRandomValues(new Uint8Array(32)).buffer)}function l2($){let Z=$.split(".");if(Z.length!==3)return;try{return JSON.parse(Buffer.from(Z[1],"base64url").toString())}catch{return}}function d2($){return $.chatgpt_account_id||$["https://api.openai.com/auth"]?.chatgpt_account_id||$.organizations?.[0]?.id}function RH($){if($.id_token){let Z=l2($.id_token),J=Z&&d2(Z);if(J)return J}if($.access_token){let Z=l2($.access_token);return Z?d2(Z):void 0}return}function w00($,Z,J){let Y=new URLSearchParams({response_type:"code",client_id:wX,redirect_uri:$,scope:"openid profile email offline_access",code_challenge:Z.challenge,code_challenge_method:"S256",id_token_add_organizations:"true",codex_cli_simplified_flow:"true",state:J,originator:"qitqode"});return`${gZ}/oauth/authorize?${Y.toString()}`}async function L00($,Z,J){let Y=await fetch(`${gZ}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:$,redirect_uri:Z,client_id:wX,code_verifier:J.verifier}).toString()});if(!Y.ok)throw Error(`Token exchange failed: ${Y.status}`);return Y.json()}async function T00($){let Z=await fetch(`${gZ}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:$,client_id:wX}).toString()});if(!Z.ok)throw Error(`Token refresh failed: ${Z.status}`);return Z.json()}var R00=`<!doctype html>
|
|
546
|
+
<html>
|
|
547
|
+
<head>
|
|
548
|
+
<title>QitQode - Codex Authorization Successful</title>
|
|
549
|
+
<style>
|
|
550
|
+
body {
|
|
551
|
+
font-family:
|
|
552
|
+
system-ui,
|
|
553
|
+
-apple-system,
|
|
554
|
+
sans-serif;
|
|
555
|
+
display: flex;
|
|
556
|
+
justify-content: center;
|
|
557
|
+
align-items: center;
|
|
558
|
+
height: 100vh;
|
|
559
|
+
margin: 0;
|
|
560
|
+
background: #131010;
|
|
561
|
+
color: #f1ecec;
|
|
562
|
+
}
|
|
563
|
+
.container {
|
|
564
|
+
text-align: center;
|
|
565
|
+
padding: 2rem;
|
|
566
|
+
}
|
|
567
|
+
h1 {
|
|
568
|
+
color: #f1ecec;
|
|
569
|
+
margin-bottom: 1rem;
|
|
570
|
+
}
|
|
571
|
+
p {
|
|
572
|
+
color: #b7b1b1;
|
|
573
|
+
}
|
|
574
|
+
</style>
|
|
575
|
+
</head>
|
|
576
|
+
<body>
|
|
577
|
+
<div class="container">
|
|
578
|
+
<h1>Authorization Successful</h1>
|
|
579
|
+
<p>You can close this window and return to QitQode.</p>
|
|
580
|
+
</div>
|
|
581
|
+
<script>
|
|
582
|
+
setTimeout(() => window.close(), 2000)
|
|
583
|
+
</script>
|
|
584
|
+
</body>
|
|
585
|
+
</html>`,PH=($)=>`<!doctype html>
|
|
586
|
+
<html>
|
|
587
|
+
<head>
|
|
588
|
+
<title>QitQode - Codex Authorization Failed</title>
|
|
589
|
+
<style>
|
|
590
|
+
body {
|
|
591
|
+
font-family:
|
|
592
|
+
system-ui,
|
|
593
|
+
-apple-system,
|
|
594
|
+
sans-serif;
|
|
595
|
+
display: flex;
|
|
596
|
+
justify-content: center;
|
|
597
|
+
align-items: center;
|
|
598
|
+
height: 100vh;
|
|
599
|
+
margin: 0;
|
|
600
|
+
background: #131010;
|
|
601
|
+
color: #f1ecec;
|
|
602
|
+
}
|
|
603
|
+
.container {
|
|
604
|
+
text-align: center;
|
|
605
|
+
padding: 2rem;
|
|
606
|
+
}
|
|
607
|
+
h1 {
|
|
608
|
+
color: #fc533a;
|
|
609
|
+
margin-bottom: 1rem;
|
|
610
|
+
}
|
|
611
|
+
p {
|
|
612
|
+
color: #b7b1b1;
|
|
613
|
+
}
|
|
614
|
+
.error {
|
|
615
|
+
color: #ff917b;
|
|
616
|
+
font-family: monospace;
|
|
617
|
+
margin-top: 1rem;
|
|
618
|
+
padding: 1rem;
|
|
619
|
+
background: #3c140d;
|
|
620
|
+
border-radius: 0.5rem;
|
|
621
|
+
}
|
|
622
|
+
</style>
|
|
623
|
+
</head>
|
|
624
|
+
<body>
|
|
625
|
+
<div class="container">
|
|
626
|
+
<h1>Authorization Failed</h1>
|
|
627
|
+
<p>An error occurred during authorization.</p>
|
|
628
|
+
<div class="error">${$}</div>
|
|
629
|
+
</div>
|
|
630
|
+
</body>
|
|
631
|
+
</html>`,l5,a$;async function P00(){if(l5)return{port:hZ,redirectUri:`http://localhost:${hZ}/auth/callback`};return l5=O00(($,Z)=>{let J=new URL($.url||"/",`http://localhost:${hZ}`);if(J.pathname==="/auth/callback"){let Y=J.searchParams.get("code"),X=J.searchParams.get("state"),Q=J.searchParams.get("error"),G=J.searchParams.get("error_description");if(Q){let K=G||Q;a$?.reject(Error(K)),a$=void 0,Z.writeHead(200,{"Content-Type":"text/html"}),Z.end(PH(K));return}if(!Y){a$?.reject(Error("Missing authorization code")),a$=void 0,Z.writeHead(400,{"Content-Type":"text/html"}),Z.end(PH("Missing authorization code"));return}if(!a$||X!==a$.state){a$?.reject(Error("Invalid state - potential CSRF attack")),a$=void 0,Z.writeHead(400,{"Content-Type":"text/html"}),Z.end(PH("Invalid state - potential CSRF attack"));return}let W=a$;a$=void 0,L00(Y,`http://localhost:${hZ}/auth/callback`,W.pkce).then((K)=>W.resolve(K)).catch((K)=>W.reject(K)),Z.writeHead(200,{"Content-Type":"text/html"}),Z.end(R00);return}if(J.pathname==="/cancel"){a$?.reject(Error("Login cancelled")),a$=void 0,Z.writeHead(200),Z.end("Login cancelled");return}Z.writeHead(404),Z.end("Not found")}),await new Promise(($,Z)=>{l5.listen(hZ,()=>{CH.info("codex oauth server started",{port:hZ}),$()}),l5.on("error",Z)}),{port:hZ,redirectUri:`http://localhost:${hZ}/auth/callback`}}function C00(){if(l5)l5.close(()=>{CH.info("codex oauth server stopped")}),l5=void 0}function I00($,Z){return new Promise((J,Y)=>{let X=setTimeout(()=>{if(a$)a$=void 0,Y(Error("OAuth callback timeout - authorization took too long"))},300000);a$={pkce:$,state:Z,resolve:(Q)=>{clearTimeout(X),J(Q)},reject:(Q)=>{clearTimeout(X),Y(Q)}}})}async function c2($){return{auth:{provider:"openai",async loader(Z,J){if((await Z()).type!=="oauth")return{};let X=new Set(["gpt-5.1-codex","gpt-5.1-codex-max","gpt-5.1-codex-mini","gpt-5.2","gpt-5.2-codex","gpt-5.3-codex","gpt-5.4","gpt-5.4-mini"]);for(let[Q,G]of Object.entries(J.models)){if(Q.includes("codex"))continue;if(X.has(G.api.id))continue;delete J.models[Q]}for(let Q of Object.values(J.models))Q.cost={input:0,output:0,cache:{read:0,write:0}};return{apiKey:lV,async fetch(Q,G){if(G?.headers)if(G.headers instanceof Headers)G.headers.delete("authorization"),G.headers.delete("Authorization");else if(Array.isArray(G.headers))G.headers=G.headers.filter(([B])=>B.toLowerCase()!=="authorization");else delete G.headers.authorization,delete G.headers.Authorization;let W=await Z();if(W.type!=="oauth")return fetch(Q,G);let K=W;if(!W.access||W.expires<Date.now()){CH.info("refreshing codex access token");let B=await T00(W.refresh),z=RH(B)||K.accountId;await $.client.auth.set({path:{id:"openai"},body:{type:"oauth",refresh:B.refresh_token,access:B.access_token,expires:Date.now()+(B.expires_in??3600)*1000,...z&&{accountId:z}}}),W.access=B.access_token,K.accountId=z}let V=new Headers;if(G?.headers){if(G.headers instanceof Headers)G.headers.forEach((B,z)=>V.set(z,B));else if(Array.isArray(G.headers)){for(let[B,z]of G.headers)if(z!==void 0)V.set(B,String(z))}else for(let[B,z]of Object.entries(G.headers))if(z!==void 0)V.set(B,String(z))}if(V.set("authorization",`Bearer ${W.access}`),K.accountId)V.set("ChatGPT-Account-Id",K.accountId);let U=Q instanceof URL?Q:new URL(typeof Q==="string"?Q:Q.url),H=U.pathname.includes("/v1/responses")||U.pathname.includes("/chat/completions")?new URL(j00):U;return fetch(H,{...G,headers:V})}}},methods:[{label:"ChatGPT Pro/Plus (browser)",type:"oauth",authorize:async()=>{let{redirectUri:Z}=await P00(),J=await q00(),Y=D00(),X=w00(Z,J,Y),Q=I00(J,Y);return{url:X,instructions:"Complete authorization in your browser. This window will close automatically.",method:"auto",callback:async()=>{let G=await Q;C00();let W=RH(G);return{type:"success",refresh:G.refresh_token,access:G.access_token,expires:Date.now()+(G.expires_in??3600)*1000,accountId:W}}}}},{label:"ChatGPT Pro/Plus (headless)",type:"oauth",authorize:async()=>{let Z=await fetch(`${gZ}/api/accounts/deviceauth/usercode`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`qitqode/${b$}`},body:JSON.stringify({client_id:wX})});if(!Z.ok)throw Error("Failed to initiate device authorization");let J=await Z.json(),Y=Math.max(parseInt(J.interval)||5,1)*1000;return{url:`${gZ}/codex/device`,instructions:`Enter code: ${J.user_code}`,method:"auto",async callback(){while(!0){let X=await fetch(`${gZ}/api/accounts/deviceauth/token`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`qitqode/${b$}`},body:JSON.stringify({device_auth_id:J.device_auth_id,user_code:J.user_code})});if(X.ok){let Q=await X.json(),G=await fetch(`${gZ}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:Q.authorization_code,redirect_uri:`${gZ}/deviceauth/callback`,client_id:wX,code_verifier:Q.code_verifier}).toString()});if(!G.ok)throw Error(`Token exchange failed: ${G.status}`);let W=await G.json();return{type:"success",refresh:W.refresh_token,access:W.access_token,expires:Date.now()+(W.expires_in??3600)*1000,accountId:RH(W)}}if(X.status!==403&&X.status!==404)return{type:"failed"};await A00(Y+N00)}}}}},{label:"Manually enter API Key",type:"api"}]},"chat.headers":async(Z,J)=>{if(Z.model.providerID!=="openai")return;J.headers.originator="qitqode",J.headers["User-Agent"]=`qitqode/${b$} (${TH.platform()} ${TH.release()}; ${TH.arch()})`,J.headers.session_id=Z.sessionID},"chat.params":async(Z,J)=>{if(Z.model.providerID!=="openai")return;J.maxOutputTokens=void 0}}}async function i2($){return{}}async function n2($){return{auth:{provider:"anthropic",async loader(Z,J){if(!J?.options?.baseURL)return{};return{async fetch(Y,X){if(X?.headers&&typeof X.headers==="object"&&!Array.isArray(X.headers))delete X.headers["anthropic-beta"];let Q=await fetch(Y,X);if(!Q.body||!Q.headers.get("content-type")?.includes("text/event-stream"))return Q;let G=Q.body.getReader(),W=new TextDecoder,K=!1,V="",U=new ReadableStream({async pull(H){if(K){H.close();return}let B=await G.read();if(B.done){H.close();return}if(H.enqueue(B.value),V+=W.decode(B.value,{stream:!0}),V.includes(`
|
|
632
|
+
event: message_stop
|
|
633
|
+
`)||V.includes(`
|
|
634
|
+
data: {"type":"message_stop"}`))K=!0,G.cancel(),H.close();if(V.length>512)V=V.slice(-256)},cancel(){G.cancel()}});return new Response(U,{headers:Q.headers,status:Q.status})}}},methods:[]}}}import{setTimeout as IH}from"timers/promises";var LX={};F1(LX,{schema:()=>s2,get:()=>E00,CopilotModels:()=>LX});var s2=D.object({data:D.array(D.object({model_picker_enabled:D.boolean(),id:D.string(),name:D.string(),version:D.string(),supported_endpoints:D.array(D.string()).optional(),policy:D.object({state:D.string().optional()}).optional(),capabilities:D.object({family:D.string(),limits:D.object({max_context_window_tokens:D.number(),max_output_tokens:D.number(),max_prompt_tokens:D.number(),vision:D.object({max_prompt_image_size:D.number(),max_prompt_images:D.number(),supported_media_types:D.array(D.string())}).optional()}),supports:D.object({adaptive_thinking:D.boolean().optional(),max_thinking_budget:D.number().optional(),min_thinking_budget:D.number().optional(),reasoning_effort:D.array(D.string()).optional(),streaming:D.boolean(),structured_outputs:D.boolean().optional(),tool_calls:D.boolean(),vision:D.boolean().optional()})})}))});function o2($,Z,J,Y){let X=!!Z.capabilities.supports.adaptive_thinking||!!Z.capabilities.supports.reasoning_effort?.length||Z.capabilities.supports.max_thinking_budget!==void 0||Z.capabilities.supports.min_thinking_budget!==void 0,Q=(Z.capabilities.supports.vision??!1)||(Z.capabilities.limits.vision?.supported_media_types??[]).some((W)=>W.startsWith("image/")),G=Z.supported_endpoints?.includes("/v1/messages");return{id:$,providerID:"github-copilot",api:{id:Z.id,url:G?`${J}/v1`:J,npm:G?"@ai-sdk/anthropic":"@ai-sdk/github-copilot"},status:"active",limit:{context:Z.capabilities.limits.max_context_window_tokens,input:Z.capabilities.limits.max_prompt_tokens,output:Z.capabilities.limits.max_output_tokens},capabilities:{temperature:Y?.capabilities.temperature??!0,reasoning:Y?.capabilities.reasoning??X,attachment:Y?.capabilities.attachment??!0,toolcall:Z.capabilities.supports.tool_calls,input:{text:!0,audio:!1,image:Q,video:!1,pdf:!1},output:{text:!0,audio:!1,image:!1,video:!1,pdf:!1},interleaved:!1},family:Y?.family??Z.capabilities.family,name:Y?.name??Z.name,cost:{input:0,output:0,cache:{read:0,write:0}},options:Y?.options??{},headers:Y?.headers??{},release_date:Y?.release_date??(Z.version.startsWith(`${Z.id}-`)?Z.version.slice(Z.id.length+1):Z.version),variants:Y?.variants??{}}}async function E00($,Z={},J={}){let Y=await fetch(`${$}/models`,{headers:Z,signal:AbortSignal.timeout(5000)}).then(async(G)=>{if(!G.ok)throw Error(`Failed to fetch models: ${G.status}`);return s2.parse(await G.json())}),X={...J},Q=new Map(Y.data.filter((G)=>G.model_picker_enabled&&G.policy?.state!=="disabled").map((G)=>[G.id,G]));for(let[G,W]of Object.entries(X)){let K=Q.get(W.api.id);if(!K){delete X[G];continue}X[G]=o2(G,K,$,W)}for(let[G,W]of Q){if(G in X)continue;X[G]=o2(G,W,$)}return X}var b00=_0.create({service:"plugin.copilot"}),r2="Ov23li8tweQw6odWQebz",EH=3000;function t2($){return $.replace(/^https?:\/\//,"").replace(/\/$/,"")}function _00($){return{DEVICE_CODE_URL:`https://${$}/login/device/code`,ACCESS_TOKEN_URL:`https://${$}/login/oauth/access_token`}}function bH($){return $?`https://copilot-api.${t2($)}`:"https://api.githubcopilot.com"}function _H($){if($?.role!=="user")return!1;let Z=$.content;if(typeof Z==="string")return Z===_$.SYNTHETIC_ATTACHMENT_PROMPT;if(!Array.isArray(Z))return!1;return Z.some((J)=>(J?.type==="text"||J?.type==="input_text")&&J.text===_$.SYNTHETIC_ATTACHMENT_PROMPT)}function a2($,Z){return{...$,api:{...$.api,url:Z,npm:"@ai-sdk/github-copilot"}}}async function e2($){let Z=$.client;return{provider:{id:"github-copilot",async models(J,Y){if(Y.auth?.type!=="oauth")return Object.fromEntries(Object.entries(J.models).map(([Q,G])=>[Q,a2(G,bH())]));let X=Y.auth;return LX.get(bH(X.enterpriseUrl),{Authorization:`Bearer ${X.refresh}`,"User-Agent":`qitqode/${b$}`},J.models).catch((Q)=>{return b00.error("failed to fetch copilot models",{error:Q}),Object.fromEntries(Object.entries(J.models).map(([G,W])=>[G,a2(W,bH(X.enterpriseUrl))]))})}},auth:{provider:"github-copilot",async loader(J){let Y=await J();if(!Y||Y.type!=="oauth")return{};return{apiKey:"",async fetch(X,Q){let G=await J();if(G.type!=="oauth")return fetch(X,Q);let W=X instanceof URL?X.href:typeof X==="string"?X:X.url,{isVision:K,isAgent:V}=d$(()=>{try{let H=typeof Q?.body==="string"?JSON.parse(Q.body):Q?.body;if(H?.messages&&W.includes("completions")){let B=H.messages[H.messages.length-1];return{isVision:H.messages.some((z)=>Array.isArray(z.content)&&z.content.some((F)=>F.type==="image_url")),isAgent:B?.role!=="user"||_H(B)}}if(H?.input){let B=H.input[H.input.length-1];return{isVision:H.input.some((z)=>Array.isArray(z?.content)&&z.content.some((F)=>F.type==="input_image")),isAgent:B?.role!=="user"||_H(B)}}if(H?.messages){let B=H.messages[H.messages.length-1],z=Array.isArray(B?.content)&&B.content.some((F)=>F?.type!=="tool_result");return{isVision:H.messages.some((F)=>Array.isArray(F?.content)&&F.content.some((A)=>A?.type==="image"||A?.type==="tool_result"&&Array.isArray(A?.content)&&A.content.some((N)=>N?.type==="image"))),isAgent:!(B?.role==="user"&&z)||_H(B)}}}catch{}return{isVision:!1,isAgent:!1}}),U={"x-initiator":V?"agent":"user",...Q?.headers,"User-Agent":`qitqode/${b$}`,Authorization:`Bearer ${G.refresh}`,"Openai-Intent":"conversation-edits"};if(K)U["Copilot-Vision-Request"]="true";return delete U["x-api-key"],delete U.authorization,fetch(X,{...Q,headers:U})}}},methods:[{type:"oauth",label:"Login with GitHub Copilot",prompts:[{type:"select",key:"deploymentType",message:"Select GitHub deployment type",options:[{label:"GitHub.com",value:"github.com",hint:"Public"},{label:"GitHub Enterprise",value:"enterprise",hint:"Data residency or self-hosted"}]},{type:"text",key:"enterpriseUrl",message:"Enter your GitHub Enterprise URL or domain",placeholder:"company.ghe.com or https://company.ghe.com",when:{key:"deploymentType",op:"eq",value:"enterprise"},validate:(J)=>{if(!J)return"URL or domain is required";try{if(!(J.includes("://")?new URL(J):new URL(`https://${J}`)).hostname)return"Please enter a valid URL or domain";return}catch{return"Please enter a valid URL (e.g., company.ghe.com or https://company.ghe.com)"}}}],async authorize(J={}){let Y=J.deploymentType||"github.com",X="github.com";if(Y==="enterprise"){let K=J.enterpriseUrl;X=t2(K)}let Q=_00(X),G=await fetch(Q.DEVICE_CODE_URL,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":`qitqode/${b$}`},body:JSON.stringify({client_id:r2,scope:"read:user"})});if(!G.ok)throw Error("Failed to initiate device authorization");let W=await G.json();return{url:W.verification_uri,instructions:`Enter code: ${W.user_code}`,method:"auto",async callback(){while(!0){let K=await fetch(Q.ACCESS_TOKEN_URL,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":`qitqode/${b$}`},body:JSON.stringify({client_id:r2,device_code:W.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})});if(!K.ok)return{type:"failed"};let V=await K.json();if(V.access_token){let U={type:"success",refresh:V.access_token,access:V.access_token,expires:0};if(Y==="enterprise")U.enterpriseUrl=X;return U}if(V.error==="authorization_pending"){await IH(W.interval*1000+EH);continue}if(V.error==="slow_down"){let U=(W.interval+5)*1000,H=V.interval;if(H&&typeof H==="number"&&H>0)U=H*1000;await IH(U+EH);continue}if(V.error)return{type:"failed"};await IH(W.interval*1000+EH);continue}}}}}]},"chat.params":async(J,Y)=>{if(!J.model.providerID.includes("github-copilot"))return;if(J.model.api.id.includes("gpt"))Y.maxOutputTokens=void 0;if(J.model.api.npm==="@ai-sdk/anthropic")Y.options.toolStreaming=!1},"chat.headers":async(J,Y)=>{if(!J.model.providerID.includes("github-copilot"))return;if(J.model.api.npm==="@ai-sdk/anthropic")Y.headers["anthropic-beta"]="interleaved-thinking-2025-05-14";let X=await Z.session.get({path:{id:J.sessionID},query:{directory:$.directory},throwOnError:!0}).catch(()=>{return});if(!X||!X.data.parentID)return;Y.headers["x-initiator"]="agent"}}}var bu=m6(Bu(),1),_u=m6(Eu(),1);class i9{options;server;resolveCallback;rejectCallback;timeoutHandle;constructor($={}){this.options=$,this.server=bu.default({logger:!1}),this.server.register(_u.default,{max:30,timeWindow:60000}),this.server.get("/callback",async(Z,J)=>{let{code:Y,state:X,error:Q,error_description:G}=Z.query;if(Q){let W=G||Q;this.rejectCallback?.(Error(`OAuth error: ${W}`)),await J.type("text/html").send(`
|
|
635
|
+
<!DOCTYPE html>
|
|
636
|
+
<html>
|
|
637
|
+
<head><title>Authentication Failed</title></head>
|
|
638
|
+
<body>
|
|
639
|
+
<h1>Authentication Failed</h1>
|
|
640
|
+
<p>${W}</p>
|
|
641
|
+
<p>You can close this window.</p>
|
|
642
|
+
</body>
|
|
643
|
+
</html>
|
|
644
|
+
`),this.cleanup();return}if(!Y||!X){this.rejectCallback?.(Error("Missing code or state parameter")),await J.type("text/html").send(`
|
|
645
|
+
<!DOCTYPE html>
|
|
646
|
+
<html>
|
|
647
|
+
<head><title>Authentication Failed</title></head>
|
|
648
|
+
<body>
|
|
649
|
+
<h1>Authentication Failed</h1>
|
|
650
|
+
<p>Missing required parameters.</p>
|
|
651
|
+
<p>You can close this window.</p>
|
|
652
|
+
</body>
|
|
653
|
+
</html>
|
|
654
|
+
`),this.cleanup();return}this.resolveCallback?.({code:Y,state:X}),await J.type("text/html").send(`
|
|
655
|
+
<!DOCTYPE html>
|
|
656
|
+
<html>
|
|
657
|
+
<head><title>Authentication Successful</title></head>
|
|
658
|
+
<body>
|
|
659
|
+
<h1>Authentication Successful</h1>
|
|
660
|
+
<p>You can close this window and return to your terminal.</p>
|
|
661
|
+
</body>
|
|
662
|
+
</html>
|
|
663
|
+
`),this.cleanup()})}async start(){let $=this.options.host||"127.0.0.1",Z=this.options.port||0;await this.server.listen({host:$,port:Z})}async waitForCallback(){let $=this.options.timeout||60000;return this.timeoutHandle=setTimeout(()=>{this.rejectCallback?.(Error("OAuth callback timeout")),this.cleanup()},$),new Promise((Z,J)=>{this.resolveCallback=Z,this.rejectCallback=J})}getPort(){let $=this.server.server.address();if(!$||typeof $==="string")throw Error("Server not started or using Unix socket");return $.port}getCallbackUrl(){let $=this.options.host||"127.0.0.1",Z=this.getPort();return`http://${$}:${Z}/callback`}cleanup(){if(this.timeoutHandle)clearTimeout(this.timeoutHandle),this.timeoutHandle=void 0;setTimeout(()=>{this.server.close()},100)}async close(){if(this.timeoutHandle)clearTimeout(this.timeoutHandle),this.timeoutHandle=void 0;await this.server.close()}}class UK{options;constructor($){this.options=$}async authorize(){let $=BA(43),Z=Su($),J=BA(32);if(this.options.method==="auto")return this.authorizeWithCallback(Z,J,$);else return this.authorizeWithManualCode(Z,J,$)}async authorizeWithCallback($,Z,J){let Y=new i9({port:0,host:"127.0.0.1",timeout:this.options.timeout||60000});try{let X=Y.waitForCallback(),Q=Y.getCallbackUrl(),G=this.buildAuthorizationUrl(Q,$,Z);await(await import("./chunk-jv37ghev.js")).default(G);let K=await X;if(K.state!==Z)throw Error("State mismatch - possible CSRF attack");return{code:K.code,state:K.state,codeVerifier:J}}finally{await Y.close()}}authorizeWithManualCode($,Z,J){throw this.buildAuthorizationUrl("http://127.0.0.1/callback",$,Z),Error("Manual code entry not yet implemented - use auto method")}buildAuthorizationUrl($,Z,J){let Y=new URLSearchParams({client_id:this.options.clientId,redirect_uri:$,response_type:"code",state:J,scope:this.options.scopes.join(" "),code_challenge:Z,code_challenge_method:"S256"});return`${this.options.instanceUrl.replace(/\/$/,"")}/oauth/authorize?${Y.toString()}`}async exchangeAuthorizationCode($,Z,J){let X=`${this.options.instanceUrl.replace(/\/$/,"")}/oauth/token`,Q=new URLSearchParams({client_id:this.options.clientId,code:$,grant_type:"authorization_code",redirect_uri:J,code_verifier:Z}),G=await fetch(X,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:Q.toString()});if(!G.ok){let K=await G.text();throw Error(`Token exchange failed: ${G.status} ${G.statusText} - ${K}`)}return await G.json()}async exchangeRefreshToken($){let J=`${this.options.instanceUrl.replace(/\/$/,"")}/oauth/token`,Y=new URLSearchParams({client_id:this.options.clientId,refresh_token:$,grant_type:"refresh_token"}),X=await fetch(J,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:Y.toString()});if(!X.ok){let G=await X.text();throw Error(`Token refresh failed: ${X.status} ${X.statusText} - ${G}`)}return await X.json()}}import P$ from"fs";import O7 from"path";import fu from"os";var s9=process.env.GITLAB_OAUTH_CLIENT_ID||"1d89f9fdb23ee96d4e603201f6861dab6e143c5c3c00469a018a2d94bdc03d4e",pj0="https://gitlab.com",zA=["api"];function n9(){return process.env.GITLAB_INSTANCE_URL||pj0}function X$($,Z){try{let J=fu.homedir(),Y=O7.join(J,".local","share","opencode","log");if(!P$.existsSync(Y))P$.mkdirSync(Y,{recursive:!0});let X=O7.join(Y,"gitlab-auth.log"),Q=new Date().toISOString(),G=Z?`[${Q}] ${$}: ${JSON.stringify(Z)}
|
|
664
|
+
`:`[${Q}] ${$}
|
|
665
|
+
`;P$.appendFileSync(X,G)}catch{}}function FA(){let $=fu.homedir(),Z=process.env.XDG_DATA_HOME;if(Z)return O7.join(Z,"opencode","auth.json");if(process.platform!=="win32")return O7.join($,".local","share","opencode","auth.json");return O7.join($,".opencode","auth.json")}async function ku($,Z,J,Y){let X=FA(),Q=O7.dirname(X);if(!P$.existsSync(Q))P$.mkdirSync(Q,{recursive:!0});let G={};if(P$.existsSync(X)){let W=P$.readFileSync(X,"utf-8");G=JSON.parse(W)}G.gitlab={type:"oauth",access:$,refresh:Z,expires:J,enterpriseUrl:Y},P$.writeFileSync(X,JSON.stringify(G,null,2)),P$.chmodSync(X,384)}async function cj0($,Z){let J=FA(),Y=O7.dirname(J);if(!P$.existsSync(Y))P$.mkdirSync(Y,{recursive:!0});let X={};if(P$.existsSync(J)){let Q=P$.readFileSync(J,"utf-8");X=JSON.parse(Q)}X.gitlab={type:"api",key:$,enterpriseUrl:Z},P$.writeFileSync(J,JSON.stringify(X,null,2)),P$.chmodSync(J,384)}var o9=null;async function ij0($,Z,J){let Y=Date.now(),X=300000;if(!($.expires<=Y+300000))return X$("Token is still valid",{expiresAt:new Date($.expires).toISOString(),expiresIn:Math.round(($.expires-Y)/1000/60)+" minutes"}),{apiKey:$.access,instanceUrl:$.enterpriseUrl||J};if(o9){X$("Token refresh already in progress, waiting..."),await o9;let W=await Z();if(W&&W.type==="oauth")return{apiKey:W.access,instanceUrl:W.enterpriseUrl||J};throw Error("Failed to get refreshed auth data")}X$("Token expired or expiring soon, refreshing...",{expiresAt:new Date($.expires).toISOString(),expired:$.expires<=Y}),o9=(async()=>{try{let W=$.enterpriseUrl||J,K=new UK({instanceUrl:W,clientId:s9,scopes:zA,method:"auto"});X$("Calling exchangeRefreshToken...");let V=await K.exchangeRefreshToken($.refresh),U=Date.now()+V.expires_in*1000;X$("Token refresh successful",{newExpiresAt:new Date(U).toISOString(),expiresIn:Math.round(V.expires_in/60)+" minutes"}),await ku(V.access_token,V.refresh_token,U,W),X$("New tokens saved successfully")}catch(W){if(X$("Token refresh failed",{error:W instanceof Error?W.message:String(W),stack:W instanceof Error?W.stack:void 0}),W instanceof Error&&W.message.includes("401")){X$("Refresh token appears to be revoked (401), clearing auth data");let K=FA();if(P$.existsSync(K)){let V=P$.readFileSync(K,"utf-8"),U=JSON.parse(V);delete U.gitlab,P$.writeFileSync(K,JSON.stringify(U,null,2))}}throw W}})();try{await o9}finally{o9=null}let G=await Z();if(G&&G.type==="oauth")return{apiKey:G.access,instanceUrl:G.enterpriseUrl||J};throw Error("Failed to get refreshed auth data after token refresh")}var vu=async($)=>{return{auth:{provider:"gitlab",async loader(J){let Y=await J();if(!Y)return{};if(Y.type==="oauth")try{return{...await ij0(Y,J,n9()),clientId:s9}}catch(X){return X$("Failed to refresh token in loader",{error:X instanceof Error?X.message:String(X)}),{apiKey:Y.access,instanceUrl:Y.enterpriseUrl||n9(),clientId:s9}}if(Y.type==="api"){let X=Y.enterpriseUrl||n9();return{apiKey:Y.key,instanceUrl:X}}return{}},methods:[{type:"oauth",label:"GitLab OAuth",prompts:[],async authorize(){let J=n9(),Y;try{let q=new URL(J);Y=`${q.protocol}//${q.host}`}catch{throw Error(`Invalid GitLab instance URL: ${J}`)}let{generateSecret:X,generateCodeChallengeFromVerifier:Q}=await import("./chunk-d8ym7mcg.js"),G=X(43),W=Q(G),K=X(32),V=new i9({port:8080,host:"127.0.0.1",timeout:120000});await V.start();let U=V.getCallbackUrl(),H=V.waitForCallback(),B=new URLSearchParams({client_id:s9,redirect_uri:U,response_type:"code",state:K,scope:zA.join(" "),code_challenge:W,code_challenge_method:"S256"}),z=`${Y}/oauth/authorize?${B.toString()}`,{exec:F}=await import("child_process"),A=process.platform;return F(`${A==="darwin"?"open":A==="win32"?"start":"xdg-open"} "${z}"`),{method:"auto",url:z,instructions:"Your browser will open for authentication. The callback will be handled automatically.",async callback(){X$("callback() called");try{X$("Waiting for callback...");let q=await H;if(X$("Received callback",{hasCode:!!q.code,hasState:!!q.state}),q.state!==K)return X$("State mismatch",{expected:K,received:q.state}),await V.close(),{type:"failed"};X$("State verified"),X$("Exchanging code for tokens...");let j=await new UK({instanceUrl:Y,clientId:s9,scopes:zA,method:"auto"}).exchangeAuthorizationCode(q.code,G,U);X$("Token exchange successful"),await V.close();let M=Date.now()+j.expires_in*1000;return X$("Tokens received",{expiresAt:new Date(M).toISOString()}),X$("Saving auth data..."),await ku(j.access_token,j.refresh_token,M,Y),X$("Auth data saved successfully"),{type:"success",provider:Y,access:j.access_token,refresh:j.refresh_token,expires:M}}catch(q){X$("Error in callback",{error:q instanceof Error?q.message:String(q),stack:q instanceof Error?q.stack:void 0});try{await V.close()}catch(w){}return{type:"failed"}}}}}},{type:"api",label:"GitLab Personal Access Token",prompts:[{type:"text",key:"token",message:"Personal Access Token",placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",validate:(J)=>{if(!J)return"Token is required";if(!J.startsWith("glpat-"))return"Token should start with glpat-";return}}],async authorize(J){let Y=n9(),X=J?.token;if(!X)return{type:"failed"};let Q;try{let G=new URL(Y);Q=`${G.protocol}//${G.host}`}catch{return{type:"failed"}}try{if(!(await fetch(`${Q}/api/v4/user`,{headers:{Authorization:`Bearer ${X}`}})).ok)return{type:"failed"};return X$("Saving PAT auth data..."),await cj0(X,Q),X$("PAT auth data saved successfully"),{type:"success",key:X,provider:Q}}catch{return{type:"failed"}}}}]}}};import nj0 from"http";function yu($){if($===null||$.length===0)return null;try{let Z=Buffer.from($,"base64url").toString("utf8"),J=JSON.parse(Z);if(J.v!==1||typeof J.n!=="string"||J.n.length===0||typeof J.i!=="string"||J.i.length===0||typeof J.r!=="boolean")return null;return{issuer:J.i,requireIssuer:J.r}}catch{return null}}async function hu($={}){let Z=$.callbackPath??"/callback",J=$.createServer?$.createServer():nj0.createServer();return{redirectUri:`http://127.0.0.1:${await oj0(J)}${Z}`,async waitForCode(Q){return sj0(J,Q,$,Z)},close(){J.closeAllConnections?.(),J.close()}}}async function oj0($){return new Promise((Z)=>{$.listen(0,"127.0.0.1",()=>{let J=$.address();Z(J.port)})})}function sj0($,Z,J,Y){let X=aj0(Z);return new Promise((Q,G)=>{let W=!1,K=(V)=>{if(!W)W=!0,V()};if($.on("request",(V,U)=>{let H=new URL(V.url??"/","http://127.0.0.1");if(H.pathname!==Y){U.writeHead(404),U.end("Not found");return}let B=H.searchParams.get("error");if(B!==null){let z=H.searchParams.get("error_description")??B;U.writeHead(400),U.end(`Authorization failed: ${z}`),K(()=>G(Error(`OAuth authorization failed: ${B} \u2014 ${z}`)));return}try{let z=xu({code:H.searchParams.get("code"),state:H.searchParams.get("state"),iss:H.searchParams.get("iss")},X);U.writeHead(200,{"Content-Type":"text/html"}),U.end(tj0(J.landingPage)),K(()=>Q(z))}catch(z){U.writeHead(400),U.end(z instanceof Error?z.message:"Invalid OAuth callback"),K(()=>G(z instanceof Error?z:Error(String(z))))}}),J.readLine!==void 0)J.readLine().then((V)=>{let U=rj0(V);if(U===null){K(()=>G(Error("OAuth callback missing authorization code")));return}try{let H=xu(U,X);K(()=>Q(H))}catch(H){K(()=>G(H instanceof Error?H:Error(String(H))))}}).catch(()=>{return});if(J.openBrowser!==void 0)J.openBrowser(Z).catch((V)=>{K(()=>G(V))})})}function rj0($){let Z=$.replaceAll("\r","").replaceAll(`
|
|
666
|
+
`,"").trim();if(Z.length===0)return null;try{let J=new URL(Z);return{code:J.searchParams.get("code"),state:J.searchParams.get("state"),iss:J.searchParams.get("iss")}}catch{return{code:Z,state:null,iss:null}}}function aj0($){let J=new URL($).searchParams.get("state"),Y=yu(J);return{state:J,issuer:Y?.issuer??null,requireIssuer:Y?.requireIssuer??!1}}function xu($,Z){if($.code===null||$.code.length===0)throw Error("OAuth callback missing authorization code");if(Z.state!==null){if($.state===null||$.state.length===0)throw Error("OAuth callback missing state");if($.state!==Z.state)throw Error("OAuth callback state mismatch")}if(Z.requireIssuer){if($.iss===null||$.iss.length===0)throw Error("OAuth callback missing issuer")}if($.iss!==null&&$.iss.length>0&&Z.issuer!==null&&$.iss!==Z.issuer)throw Error("OAuth callback issuer mismatch");return $.code}function AA($){return $.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function tj0($){let Z=$?.title??"Connected",J=$?.body??"You can close this tab and return to your terminal.";return["<!DOCTYPE html>",`<html><head><meta charset=utf-8><title>${AA(Z)}</title></head>`,'<body style="font-family:system-ui,sans-serif;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0">','<div style="text-align:center">',`<h1>${AA(Z)}</h1>`,`<p style="color:#666">${AA(J)}</p>`,"</div></body></html>"].join("")}import gu from"crypto";function uu(){return gu.randomBytes(32).toString("base64url")}function mu($){return gu.createHash("sha256").update($).digest("base64url")}var ej0="https://poe.com/oauth/authorize",$N0="https://api.poe.com/token";function OA($){let Z=$.fetch??globalThis.fetch;return{authorize:()=>JN0($,Z)}}function ZN0(){return uu()}async function JN0($,Z){let J=$.authorizationEndpoint??ej0,Y=$.tokenEndpoint??$N0,X=ZN0(),Q=mu(X),G=await hu({openBrowser:$.openBrowser,readLine:$.readLine,createServer:$.createServer,landingPage:$.landingPage??{title:"Connected to Poe",body:"You can close this tab and return to your terminal."}}),W=G.redirectUri,K=YN0({endpoint:J,clientId:$.clientId,redirectUri:W,codeChallenge:Q});return{authorizationUrl:K,waitForResult:async()=>{try{let U=await G.waitForCode(K);return await XN0({tokenEndpoint:Y,code:U,codeVerifier:X,clientId:$.clientId,redirectUri:W,fetchFn:Z})}finally{G.close()}}}}function YN0($){let Z=new URL($.endpoint);return Z.searchParams.set("response_type","code"),Z.searchParams.set("client_id",$.clientId),Z.searchParams.set("scope","apikey:create"),Z.searchParams.set("code_challenge",$.codeChallenge),Z.searchParams.set("code_challenge_method","S256"),Z.searchParams.set("redirect_uri",$.redirectUri),Z.toString()}async function XN0($){let Z=new URLSearchParams({grant_type:"authorization_code",code:$.code,code_verifier:$.codeVerifier,client_id:$.clientId,redirect_uri:$.redirectUri}),J=await $.fetchFn($.tokenEndpoint,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:Z.toString()});if(!J.ok){let X=await J.text(),Q=QN0(X);throw Error(Q??`Token exchange failed (${J.status}): ${X}`)}let Y=await J.json();if(typeof Y.api_key!=="string"||Y.api_key.length===0)throw Error("Token response missing api_key field");return{apiKey:Y.api_key,expiresIn:typeof Y.api_key_expires_in==="number"?Y.api_key_expires_in:null}}function QN0($){try{let Z=JSON.parse($);if(typeof Z.error_description==="string")return Z.error_description;if(typeof Z.error==="string")return Z.error}catch{}return null}var GN0="client_728290227fc048cc9262091a1ea197ea";function WN0($){if($==null)return Number.MAX_SAFE_INTEGER;return Date.now()+$*1000}async function KN0(){let Z=await OA({clientId:GN0,landingPage:{title:"Connected to Poe",body:"You can close this tab and return to OpenCode."},openBrowser:async(J)=>{await lu(J)}}).authorize();return{url:Z.authorizationUrl,instructions:"Complete authorization in your browser. This window will close automatically.",method:"auto",callback:async()=>{let J=await Z.waitForResult();return{type:"success",access:J.apiKey,refresh:J.apiKey,expires:WN0(J.expiresIn)}}}}async function HK($){return{auth:{provider:"poe",async loader(Z){let J=await Z();if(J.type==="api")return{apiKey:J.key};if(J.type!=="oauth")return{};if(J.expires<Date.now())throw Error("Poe API key expired. Run `opencode providers login` again.");return{apiKey:J.access}},methods:[{label:"Login with Poe (browser)",type:"oauth",authorize:KN0},{label:"Manually enter API Key",type:"api"}]}}}async function du($){return{auth:{provider:"cloudflare-workers-ai",methods:[{type:"api",label:"API key",prompts:!process.env.CLOUDFLARE_ACCOUNT_ID?[{type:"text",key:"accountId",message:"Enter your Cloudflare Account ID",placeholder:"e.g. 1234567890abcdef1234567890abcdef"}]:[]}]}}}async function pu($){return{auth:{provider:"cloudflare-ai-gateway",methods:[{type:"api",label:"Gateway API token",prompts:[...!process.env.CLOUDFLARE_ACCOUNT_ID?[{type:"text",key:"accountId",message:"Enter your Cloudflare Account ID",placeholder:"e.g. 1234567890abcdef1234567890abcdef"}]:[],...!process.env.CLOUDFLARE_GATEWAY_ID?[{type:"text",key:"gatewayId",message:"Enter your Cloudflare AI Gateway ID",placeholder:"e.g. my-gateway"}]:[]]}]},"chat.params":async(J,Y)=>{if(J.model.providerID!=="cloudflare-ai-gateway")return;if(!J.model.api.id.toLowerCase().startsWith("openai/"))return;if(!J.model.capabilities.reasoning)return;Y.maxOutputTokens=void 0}}}import FZ from"path";import VN0 from"fs/promises";function BK($){return FZ.join(A0.Path.data,"memory","sessions",$)}function r9($){return FZ.join(BK($),"checkpoint.md")}function a9($){return FZ.join(A0.Path.data,"memory","projects",$,"MEMORY.md")}function oh0(){return FZ.join(A0.Path.data,"memory","global","MEMORY.md")}async function sh0($){let Z=a9($),J=FZ.join(FZ.dirname(Z),"memory.md");if(await Bun.file(Z).exists())return;if(await Bun.file(J).exists())await VN0.rename(J,Z).catch((Y)=>{if(Y.code!=="ENOENT")throw Y})}function rh0($){return FZ.join(BK($),"notes.md")}function UN0($){return FZ.join(BK($),"tasks")}function cu($,Z){return FZ.join(UN0($),Z,"progress.md")}var iu=80,HN0=["### Execution context","### Live resources","### Session metadata"],BN0=["### Discovered","### Dead ends"];function nu($,Z,J){let Y=[],X=$.split(`
|
|
667
|
+
`).find((K)=>K.trim().length>0)??"";if(/^# Checkpoint #\d+/.test(X))Y.push({file:Z,rule:"topic-anti-pattern-checkpoint-header",severity:"error",detail:`First line is "${X}". Replace with "Topic: <\u226480-char one-line summary>" with NO leading "#".`});let Q=$.match(/^Topic:\s*(.+?)$/m);if(!Q)Y.push({file:Z,rule:"topic-missing",severity:"error",detail:'Missing required first-line "Topic: <summary>". Add it as the first non-blank line.'});else{let K=Q[1].trim();if(K.length>iu)Y.push({file:Z,rule:"topic-too-long",severity:"warn",detail:`Topic line is ${K.length} chars (limit ${iu}). Rewrite shorter.`})}let G=J.map((K)=>({section:K,idx:$.indexOf(K)}));for(let K of G)if(K.idx===-1)Y.push({file:Z,rule:"subsection-missing",severity:"error",detail:`Missing "${K.section}" sub-section. Add the header (use "(none)" placeholder if no entries).`});let W=G.filter((K)=>K.idx!==-1);for(let K=1;K<W.length;K++)if(W[K].idx<W[K-1].idx){Y.push({file:Z,rule:"subsection-out-of-order",severity:"error",detail:`Sub-sections must appear in order: ${J.join(", ")}.`});break}return Y}function ou($,Z){return nu($,Z,HN0)}function su($){let Z=$.match(/^(?:Topic:.*\n+)?### discovered\s*\n([\s\S]*?)(?=\n### |$)/i);if(!Z)return[];let J=Z[1],Y=[],X=J.split(`
|
|
668
|
+
`),Q;for(let G of X){let W=G.match(/^- (.+)$/);if(W){if(Q)Y.push({title:Q.title,block:Q.lines.join(`
|
|
669
|
+
`)});Q={title:W[1].trim(),lines:[G]}}else if(Q)Q.lines.push(G)}if(Q)Y.push({title:Q.title,block:Q.lines.join(`
|
|
670
|
+
`)});return Y}function ru($){return su($).map((Z)=>Z.title)}function au($,Z,J){let Y=nu($,Z,BN0),X=su($);for(let Q of X){if(J.has(Q.title))Y.push({file:Z,rule:"discovered-duplicate-title",severity:"error",detail:`Discovered title "${Q.title}" duplicates a prior checkpoint's title verbatim. Remove this entry or rephrase.`});if(!/^\s*Why:/m.test(Q.block))Y.push({file:Z,rule:"discovered-missing-why",severity:"warn",detail:`Discovered entry "${Q.title}" is missing a "Why:" line.`});if(!/^\s*How to apply:/m.test(Q.block))Y.push({file:Z,rule:"discovered-missing-how-to-apply",severity:"warn",detail:`Discovered entry "${Q.title}" is missing a "How to apply:" line.`})}return Y}function tu($,Z){let J=[];for(let Y of Z)if(!$.includes(Y.expectedText))J.push({file:"MEMORY.md",rule:"directive-not-revised",severity:"error",detail:`Directive ${Y.id} should mention "${Y.expectedText}" per a recent user instruction, but MEMORY.md does not contain that text.`});return J}function NA($,Z,J){let Y=jA.estimate($);if(Y<=Z)return[];return[{file:J,rule:"budget-exceeded",severity:"extract-required",detail:`${Y} tokens > ${Z} budget`}]}function qA($,Z,J){let Y=[],X=/^## (.+)$/gm,Q=[],G;while((G=X.exec($))!==null)Q.push({title:G[1].trim(),index:G.index});for(let W=0;W<Q.length;W++){let K=Q[W].index,V=W+1<Q.length?Q[W+1].index:$.length,U=$.slice(K,V),H=Q[W].title,B=Z[H];if(B==null)continue;let z=jA.estimate(U);if(z>B)Y.push({file:J,rule:"section-budget-exceeded",severity:"extract-required",detail:`section "${H}" is ${z} tokens (budget ${B})`})}return Y}var $g0=`# Session checkpoint
|
|
671
|
+
_Generated by checkpoint writer; structure preserved across updates. Edit only content under italic instructions._
|
|
672
|
+
|
|
673
|
+
## \xA71 Active intent
|
|
674
|
+
_User's most recent explicit request, verbatim block-quoted from the conversation. The verbatim quote is the ground truth for what to do \u2014 do not paraphrase._
|
|
675
|
+
|
|
676
|
+
(none yet)
|
|
677
|
+
|
|
678
|
+
## \xA72 Next concrete action
|
|
679
|
+
_The single next concrete step, derived from \xA71 and current state. Include verbatim quote when the user gave one._
|
|
680
|
+
|
|
681
|
+
(none yet)
|
|
682
|
+
|
|
683
|
+
## \xA73 Directives (this session)
|
|
684
|
+
_This session's specific working style. Project-level rules are in projects/<pid>/MEMORY.md \u2014 do not duplicate them here. Only put items that are session-specific._
|
|
685
|
+
|
|
686
|
+
(none)
|
|
687
|
+
|
|
688
|
+
## \xA74 Task tree
|
|
689
|
+
_Hierarchical view of tasks with current focus marked. Pulled from task tool's DB; one bullet per top-level task with status + summary. Append \` (progress: tasks/<id>/progress.md)\` so the next agent can Read the per-task journal directly. Indent sub-tasks two spaces under their parent._
|
|
690
|
+
|
|
691
|
+
(none yet)
|
|
692
|
+
|
|
693
|
+
## \xA75 Current work
|
|
694
|
+
_Description of what was being done immediately before this checkpoint. Mention specific file paths and code locations._
|
|
695
|
+
|
|
696
|
+
(none yet)
|
|
697
|
+
|
|
698
|
+
## \xA76 Files and code sections
|
|
699
|
+
_Files actively being read or modified. List with one-line purpose._
|
|
700
|
+
|
|
701
|
+
(none yet)
|
|
702
|
+
|
|
703
|
+
## \xA77 Discovered knowledge (cross-task)
|
|
704
|
+
_Facts learned during this session that may apply to future tasks. Items here are candidates for promotion to projects/<pid>/MEMORY.md if they prove durable._
|
|
705
|
+
|
|
706
|
+
(none yet)
|
|
707
|
+
|
|
708
|
+
## \xA78 Errors and fixes
|
|
709
|
+
_Errors encountered this session and how they were resolved. Newest first._
|
|
710
|
+
|
|
711
|
+
(none)
|
|
712
|
+
|
|
713
|
+
## \xA79 Live resources
|
|
714
|
+
_Runtime state: branch, uncommitted files, running processes, temp artifacts. Most volatile \u2014 don't dwell on details that change every minute._
|
|
715
|
+
|
|
716
|
+
(none yet)
|
|
717
|
+
|
|
718
|
+
## \xA710 Design decisions and discussion outcomes
|
|
719
|
+
_Decisions reached through discussion that produced no immediate code/file artifact. Captures user intent or trade-off rationale future agents need to understand "why we did it this way". Promote to MEMORY.md ## Architecture decisions when proven cross-session-durable._
|
|
720
|
+
|
|
721
|
+
(none yet)
|
|
722
|
+
|
|
723
|
+
## \xA711 Open notes
|
|
724
|
+
_Writer-curated catch-all for items that don't fit \xA71-\xA710. Quotes from conversation, unresolved questions, micro-observations, miscellaneous. Cleaner than letting orphan content pollute \xA73 or \xA77. May be empty for many checkpoints._
|
|
725
|
+
|
|
726
|
+
(none yet)
|
|
727
|
+
`,Zg0=`# Project memory
|
|
728
|
+
_Durable project-level knowledge. Persists across all sessions in this project. Edit only content under italic instructions._
|
|
729
|
+
|
|
730
|
+
## Project context
|
|
731
|
+
_What is this project? What's its goal? High-level identity._
|
|
732
|
+
|
|
733
|
+
(none yet)
|
|
734
|
+
|
|
735
|
+
## Rules
|
|
736
|
+
_Hard constraints from user that every session must respect._
|
|
737
|
+
|
|
738
|
+
(none yet)
|
|
739
|
+
|
|
740
|
+
## Architecture decisions
|
|
741
|
+
_Major design choices with rationale. The "why" matters more than the "what" for future sessions._
|
|
742
|
+
|
|
743
|
+
(none yet)
|
|
744
|
+
|
|
745
|
+
## Discovered durable knowledge
|
|
746
|
+
_Cross-task facts that survive across sessions. Promoted from session checkpoints' \xA77 when proven durable._
|
|
747
|
+
|
|
748
|
+
(none yet)
|
|
749
|
+
`,eu={"\xA71 Active intent":500,"\xA72 Next concrete action":1000,"\xA73 Directives (this session)":800,"\xA74 Task tree":1000,"\xA75 Current work":2000,"\xA76 Files and code sections":1500,"\xA77 Discovered knowledge (cross-task)":2000,"\xA78 Errors and fixes":1500,"\xA79 Live resources":1000,"\xA710 Design decisions and discussion outcomes":3000,"\xA711 Open notes":800},$m={"Project context":1000,Rules:2000,"Architecture decisions":3000,"Discovered durable knowledge":4000},Jg0="# Session notes\n_Free-form scratchpad for the main agent. Append entries as you go; the checkpoint writer reconciles them at checkpoint events. Format each entry as `## [turn N \xB7 YYYY-MM-DDTHH:MM:SSZ]` (minute precision UTC, seconds optional) followed by free-form body. Before appending: scan existing entries \u2014 if you've already noted substantially similar content, add a short `(see entry above)` reference instead of duplicating._\n";var G5={};F1(G5,{merge:()=>NN0,layer:()=>Vm,fromConfig:()=>jN0,evaluate:()=>DA,disabled:()=>MN0,defaultLayer:()=>DN0,Service:()=>AK,Ruleset:()=>Gm,Rule:()=>wA,Request:()=>ZQ,ReplyInput:()=>AN0,ReplyBody:()=>zN0,Reply:()=>LA,RejectedError:()=>N7,Permission:()=>G5,Event:()=>t9,DeniedError:()=>FK,CorrectedError:()=>TA,AskInput:()=>FN0,Approval:()=>Km,Action:()=>Qm});var Zm=($,Z)=>T.addFinalizer(()=>T.gen(function*(){for(let J of $.values())yield*f6.fail(J.deferred,Z());$.clear()}));import zK from"os";function Jm($,Z,...J){return h1.evaluatePermission($,Z,...J)}class j7 extends Ym()("PermissionID",O.String.annotate({[A$]:p1.schema("permission")})){static ascending($){return this.make(p1.ascending("permission",$))}static zod=p1.schema("permission")}var Xm=_0.create({service:"permission"}),Qm=O.Literals(["allow","deny","ask"]).annotate({identifier:"PermissionAction"}).pipe(g0(($)=>({zod:w0($)})));class wA extends O.Class("PermissionRule")({permission:O.String,pattern:O.String,action:Qm}){static zod=w0(this)}var Gm=O.mutable(O.Array(wA)).annotate({identifier:"PermissionRuleset"}).pipe(g0(($)=>({zod:w0($)})));class ZQ extends O.Class("PermissionRequest")({id:j7,sessionID:a0,permission:O.String,patterns:O.Array(O.String),metadata:O.Record(O.String,O.Unknown),always:O.Array(O.String),tool:O.optional(O.Struct({messageID:o1,callID:O.String}))}){static zod=w0(this)}var LA=O.Literals(["once","always","reject"]).pipe(g0(($)=>({zod:w0($)}))),Wm={reply:LA,message:O.optional(O.String)},zN0=O.Struct(Wm).annotate({identifier:"PermissionReplyBody"}).pipe(g0(($)=>({zod:w0($)})));class Km extends O.Class("PermissionApproval")({projectID:$Q,patterns:O.Array(O.String)}){static zod=w0(this)}var t9={Asked:T1.define("permission.asked",ZQ.zod),Replied:T1.define("permission.replied",w0(O.Struct({sessionID:a0,requestID:j7,reply:LA})))};class N7 extends O.TaggedErrorClass()("PermissionRejectedError",{}){get message(){return"The user rejected permission to use this specific tool call."}}class TA extends O.TaggedErrorClass()("PermissionCorrectedError",{feedback:O.String}){get message(){return`The user rejected permission to use this specific tool call with the following feedback: ${this.feedback}`}}class FK extends O.TaggedErrorClass()("PermissionDeniedError",{ruleset:O.Any}){get message(){return`The user has specified a rule which prevents you from using this specific tool call. Here are some of the relevant rules ${JSON.stringify(this.ruleset)}`}}var FN0=O.Struct({...ZQ.fields,id:O.optional(j7),ruleset:Gm,interactive:O.optional(O.Boolean)}).annotate({identifier:"PermissionAskInput"}).pipe(g0(($)=>({zod:w0($)}))),AN0=O.Struct({requestID:j7,...Wm}).annotate({identifier:"PermissionReplyInput"}).pipe(g0(($)=>({zod:w0($)})));function DA($,Z,...J){return Jm($,Z,...J)}class AK extends S1.Service()("@qitqode/Permission"){}var Vm=R0.effect(AK,T.gen(function*(){let $=yield*d1.Service,Z=yield*B0.make(T.fn("Permission.state")(function*(Q){let G=W1.use((K)=>K.select().from(MA).where(m0(MA.project_id,Q.project.id)).get()),W={pending:new Map,approved:G?.data??[]};return yield*Zm(W.pending,()=>new N7),W})),J=T.fn("Permission.ask")(function*(Q,G){let{approved:W,pending:K}=yield*B0.get(Z),{ruleset:V,...U}=Q,H=!1;for(let q of U.patterns){let w=DA(U.permission,q,V,W);if(Xm.info("evaluated",{permission:U.permission,pattern:q,action:w}),w.action==="deny")return yield*new FK({ruleset:V.filter((j)=>e9.match(U.permission,j.permission))});if(w.action==="allow")continue;H=!0}if(H&&Q.interactive===!1)return yield*new FK({ruleset:V.filter((q)=>e9.match(U.permission,q.permission))});if(!H)return;let B=U.id??j7.ascending(),z=O.decodeUnknownSync(ZQ)({id:B,...U});Xm.info("asking",{id:B,permission:z.permission,patterns:z.patterns});let F=yield*f6.make();K.set(B,{info:z,deferred:F}),yield*$.publish(t9.Asked,z);let A=f6.await(F),N=G?T.race(A,T.callback((q)=>{let w=()=>{T.runPromise(f6.fail(F,new N7)).catch((j)=>{console.error("permission: failed to fail deferred after abort",j)}),q(T.fail(new N7))};if(G.aborted){w();return}return G.addEventListener("abort",w,{once:!0}),T.sync(()=>{G.removeEventListener("abort",w)})})):A;return yield*T.ensuring(N,T.sync(()=>{K.delete(B)}))}),Y=T.fn("Permission.reply")(function*(Q){let{approved:G,pending:W}=yield*B0.get(Z),K=W.get(Q.requestID);if(!K)return;if(W.delete(Q.requestID),yield*$.publish(t9.Replied,{sessionID:K.info.sessionID,requestID:K.info.id,reply:Q.reply}),Q.reply==="reject"){yield*f6.fail(K.deferred,Q.message?new TA({feedback:Q.message}):new N7);for(let[V,U]of W.entries()){if(U.info.sessionID!==K.info.sessionID)continue;W.delete(V),yield*$.publish(t9.Replied,{sessionID:U.info.sessionID,requestID:U.info.id,reply:"reject"}),yield*f6.fail(U.deferred,new N7)}return}if(yield*f6.succeed(K.deferred,void 0),Q.reply==="once")return;for(let V of K.info.always)G.push({permission:K.info.permission,pattern:V,action:"allow"});for(let[V,U]of W.entries()){if(U.info.sessionID!==K.info.sessionID)continue;if(!U.info.patterns.every((B)=>DA(U.info.permission,B,G).action==="allow"))continue;W.delete(V),yield*$.publish(t9.Replied,{sessionID:U.info.sessionID,requestID:U.info.id,reply:"always"}),yield*f6.succeed(U.deferred,void 0)}}),X=T.fn("Permission.list")(function*(){let Q=(yield*B0.get(Z)).pending;return Array.from(Q.values(),(G)=>G.info)});return AK.of({ask:J,reply:Y,list:X})}));function ON0($){if($.startsWith("~/"))return zK.homedir()+$.slice(1);if($==="~")return zK.homedir();if($.startsWith("$HOME/"))return zK.homedir()+$.slice(5);if($.startsWith("$HOME"))return zK.homedir()+$.slice(5);return $}function jN0($){let Z=[];for(let[J,Y]of Object.entries($)){if(typeof Y==="string"){Z.push({permission:J,action:Y,pattern:"*"});continue}Z.push(...Object.entries(Y).map(([X,Q])=>({permission:J,pattern:ON0(X),action:Q})))}return Z}function NN0(...$){return $.flat()}var qN0=["edit","write","apply_patch","multiedit"];function MN0($,Z){let J=new Set;for(let Y of $){let X=Z.findLast((Q)=>e9.match(Y,Q.permission)||qN0.includes(Y)&&e9.match("edit",Q.permission));if(!X)continue;if(X.pattern==="*"&&X.action==="deny")J.add(Y)}return J}var DN0=Vm.pipe(R0.provide(d1.layer));var Um=P.enum(["interactive-build","read-only-plan","workflow-compose","parallel-max","read-only-explore","subagent","system","custom-primary","custom"]),Sg0=P.enum(["coding","agent","research","review","chat"]),fg0=P.string().min(1).refine(($)=>$.includes("/"),{message:"Qortex directives must be prompt-registry keys in <scope>/<name> form"});function wN0($){let Z=$.mode==="primary",J=$.mode==="subagent",Y=$.permission===void 0||G5.evaluate("edit","*",$.permission).action==="deny";switch($.name){case"build":return Z?"interactive-build":J?"subagent":"custom";case"plan":return Z&&Y?"read-only-plan":Z?"custom-primary":"subagent";case"compose":return Z?"workflow-compose":J?"subagent":"custom";case"max":return Z?"parallel-max":J?"subagent":"custom";case"explore":return J&&Y?"read-only-explore":J?"subagent":"custom-primary";case"general":return J?"subagent":Z?"custom-primary":"custom";case"title":case"summary":case"compaction":case"checkpoint-writer":case"dream":case"distill":return $.hidden===!0&&J?"system":J?"subagent":"custom-primary";default:return J?"subagent":Z?"custom-primary":"custom"}}function LN0($){switch(wN0($)){case"interactive-build":return"coding";case"read-only-plan":return"review";case"workflow-compose":case"parallel-max":case"subagent":return"agent";case"read-only-explore":return"research";case"system":case"custom-primary":case"custom":return}}var TN0=new Set(["bash","shell","edit","write","apply_patch","multiedit","change_directory","actor","task"]);function kg0($,Z){let J=LN0($);if(!J)return;let Y=(J==="coding"||J==="agent"||J==="research")&&Z.some((X)=>TN0.has(X));return{posture:J,...Y?{directive:"discipline/operational-directives"}:{}}}var RN0=P.enum(["mode","checkpoint","goal","task-gate","recovery","never-ask","memory","tool-result","runtime"]),PN0=P.enum(["local-policy","session-state","runtime-safety","model-guidance"]),CN0=P.enum(["system-reminder","plain"]),IN0={mode:100,checkpoint:90,goal:80,"task-gate":80,recovery:70,"never-ask":60,memory:40,"tool-result":40,runtime:50},EN0=P.object({source:RN0,trust:PN0,priority:P.number().int(),posture:Um.optional(),envelope:CN0.default("system-reminder"),body:P.string().min(1)});function bN0($){return EN0.parse({...$,priority:$.priority??IN0[$.source]})}function Hm($){let Z=bN0($),J=`source=${Z.source} authority=${Z.trust}`;if(Z.envelope==="plain")return`[system-generated ${J}]
|
|
750
|
+
${Z.body}`;return["<system-reminder>",`[system-generated ${J}]`,Z.body,"</system-reminder>"].join(`
|
|
751
|
+
`)}async function pg0($){let Z=await Bun.file(r9($)).text().catch(()=>"");if(!Z)return new Set;return new Set(ru(Z))}async function Bm($,Z){let J=await Bun.file(r9($)).text().catch(()=>""),Y=await Bun.file(a9(Z.projectID)).text().catch(()=>""),X=[];if(J)X.push(...ou(J,"checkpoint.md")),X.push(...au(J,"checkpoint.md",Z.priorTitles));else X.push({file:"checkpoint.md",rule:"topic-missing",severity:"error",detail:"checkpoint file did not exist after writer finished"});if(Y&&Z.expectedRevisions.length>0)X.push(...tu(Y,Z.expectedRevisions));let Q=Z.budgets??{checkpoint:11000,memory:1e4,progress_per_task:6000};if(J)X.push(...NA(J,Q.checkpoint,"checkpoint.md"));if(Y)X.push(...NA(Y,Q.memory,"MEMORY.md"));if(J)X.push(...qA(J,eu,"checkpoint.md"));if(Y)X.push(...qA(Y,$m,"MEMORY.md"));return X}function zm($,Z){let J=new Map;for(let X of $){let Q=J.get(X.file)??[];Q.push(`- ${X.detail}`),J.set(X.file,Q)}let Y=[...J.entries()].map(([X,Q])=>`${X}:
|
|
752
|
+
${Q.join(`
|
|
753
|
+
`)}`);return Hm({source:"checkpoint",trust:"runtime-safety",posture:"system",body:["The previous attempt at this checkpoint had validation errors. Read your output at the absolute paths below, fix ONLY the issues listed, and write again. Other content may stay the same.","",Y.join(`
|
|
754
|
+
|
|
755
|
+
`),"",`CHECKPOINT_PATH = ${Z.checkpoint}`,`MEMORY_PATH = ${Z.memory}`].join(`
|
|
756
|
+
`)})}function Fm($){return`EXTRACTION REQUIRED: The following files exceed their token budget: ${$.filter((Y)=>Y.severity==="extract-required").map((Y)=>`${Y.file} (${Y.detail})`).join(", ")}.
|
|
757
|
+
|
|
758
|
+
Extract the LESS-IMPORTANT topic cluster from the over-budget file into a new spillover file:
|
|
759
|
+
- Checkpoint spillover: checkpoint-<topic>.md (sibling of checkpoint.md)
|
|
760
|
+
- Memory spillover: MEMORY-<topic>.md (sibling of MEMORY.md)
|
|
761
|
+
|
|
762
|
+
Selection criteria for "less important" (extract THESE first):
|
|
763
|
+
- Already-stable decisions unlikely to be revisited
|
|
764
|
+
- Dead ends before Discovered entries
|
|
765
|
+
- Historical / completed steps before recent / in-progress
|
|
766
|
+
- Topics not directly relevant to the current focus task
|
|
767
|
+
|
|
768
|
+
After extraction, edit the main file to:
|
|
769
|
+
- REMOVE the extracted lines
|
|
770
|
+
- INSERT an index line near the bottom:
|
|
771
|
+
"- See <spillover-filename>.md (N entries) \u2014 short summary"
|
|
772
|
+
|
|
773
|
+
Re-validation will run after this single extraction.`}var RA=new Map;function PA($,Z){return`${$}:${Z}`}function ig0($,Z,J){RA.set(PA($,Z),J)}function Am($,Z){let J=RA.get(PA($,Z));if(!J)return;return structuredClone(J)}function ng0($,Z){RA.delete(PA($,Z))}var SN0=_0.create({service:"plugin.checkpoint-splitover"}),fN0={priorTitles:new Set,expectedRevisions:[]};async function Om($){let Z=$.project.id;return{"actor.preStop":{matcher:{agentType:{include:["checkpoint-writer"]}},run:async(J,Y)=>{let X=J.parentSessionID??J.sessionID,Q=Am(X,J.actorID)??fN0;try{let G=await Bm(X,{priorTitles:Q.priorTitles,expectedRevisions:Q.expectedRevisions,projectID:Z});if(G.length===0)return;let W=G.filter((V)=>V.severity==="extract-required");if(W.length>0){Y.continue=!0,Y.reason=Fm(W);return}let K=G.filter((V)=>V.severity==="error");if(K.length>0){Y.continue=!0,Y.reason=zm(K,{checkpoint:r9(X),memory:a9(Z)});return}}catch(G){SN0.error("checkpoint-splitover hook failed",{err:G,sessionID:X,actorID:J.actorID})}}}}}import kN0 from"fs/promises";import vN0 from"path";var yN0=_0.create({service:"plugin.subagent-progress-checker"}),xN0=["## \xA71 Task identity","## \xA72 Subagent intent","## \xA73 Files and code sections","## \xA74 Verbatim commands","## \xA75 Outcome and discoveries"],jm=`## \xA71 Task identity
|
|
774
|
+
- task_id: <TID>
|
|
775
|
+
- short summary: <one line>
|
|
776
|
+
|
|
777
|
+
## \xA72 Subagent intent
|
|
778
|
+
What this subagent was asked to do (one paragraph).
|
|
779
|
+
|
|
780
|
+
## \xA73 Files and code sections
|
|
781
|
+
- path/to/file.ext: <what you did with it>
|
|
782
|
+
|
|
783
|
+
## \xA74 Verbatim commands
|
|
784
|
+
Exact commands you ran or commands the user/task asked to be runnable later. Keep BACKTICK-FENCED for grep-ability.
|
|
785
|
+
\`\`\`
|
|
786
|
+
<command>
|
|
787
|
+
\`\`\`
|
|
788
|
+
|
|
789
|
+
## \xA75 Outcome and discoveries
|
|
790
|
+
- Outcome (success/partial/failed): <reason>
|
|
791
|
+
- Discoveries that may matter for other tasks: <bullets>
|
|
792
|
+
`;function Nm($){if($.kind==="missing")return["Before terminating, write the task progress journal to:",` ${$.filePath}`,"","Required structure (5 sections, headings exact):","",jm.replace("<TID>",$.taskId),"","Write the file now using the Write tool, then terminate normally."].join(`
|
|
793
|
+
`);return[`tasks/${$.taskId}/progress.md exists but is missing required sections:`,...($.missing??[]).map((Z)=>` - ${Z}`),"","Add the missing sections. For reference, the full required template is:","",jm.replace("<TID>",$.taskId),"","Re-write the file using Write tool, then terminate normally."].join(`
|
|
794
|
+
`)}async function hN0($,Z){let Y=`---
|
|
795
|
+
written-at: ${Date.now()}
|
|
796
|
+
---
|
|
797
|
+
`,X=Z.match(/^---\n[\s\S]*?\n---\n/),Q=X?Y+Z.slice(X[0].length):Y+Z;await Bun.write($,Q)}async function qm($){return{"actor.postStop":{matcher:{agentType:{excludeOnly:["checkpoint-writer","title","summary","dream","distill","compaction","main"]}},run:async(Z,J)=>{let Y=Z.task_id;if(!Y)return;if(Z.canWrite===!1)return;let X=Z.sessionID,Q=cu(X,Y),G;try{G=await Bun.file(Q).text()}catch{G=void 0}if(G===void 0){J.continue=!0,J.reason=Nm({kind:"missing",taskId:Y,filePath:Q});return}let W=xN0.filter((K)=>!G.includes(K));if(W.length>0){J.continue=!0,J.reason=Nm({kind:"incomplete",taskId:Y,filePath:Q,missing:W});return}try{await kN0.mkdir(vN0.dirname(Q),{recursive:!0}),await hN0(Q,G)}catch(K){yN0.error("frontmatter injection failed",{err:K,filePath:Q})}}}}}var CA;((Gu0)=>{function $(Q){let G=s8.pluginSpecifier(Q);return{spec:G,options:s8.pluginOptions(Q),deprecated:Mm(G)}}async function Z(Q,G){let W="";try{W=await Lm(Q.spec)}catch(V){return{ok:!1,stage:"install",error:V}}if(!W)return{ok:!1,stage:"install",error:Error(`Plugin ${Q.spec} target is empty`)};let K;try{K=await Tm(Q.spec,W,G)}catch(V){return{ok:!1,stage:"entry",error:V}}if(!K.entry)return{ok:!1,stage:"missing",value:{...Q,source:K.source,target:K.target,pkg:K.pkg,message:`Plugin ${Q.spec} does not expose a ${G} entrypoint`}};if(K.source==="npm")try{await wm(K.target,b$,K.pkg)}catch(V){return{ok:!1,stage:"compatibility",error:V}}return{ok:!0,value:{...Q,source:K.source,target:K.target,entry:K.entry,pkg:K.pkg}}}Gu0.resolve=Z;async function J(Q){let G;try{G=await import(Q.entry)}catch(W){return{ok:!1,error:W}}if(!G)return{ok:!1,error:Error(`Plugin ${Q.spec} module is empty`)};return{ok:!0,value:{...Q,mod:G}}}Gu0.load=J;async function Y(Q,G,W,K,V,U){let H=Q.plan;if(H.deprecated)return;U?.start?.(Q,W);let B=await Z(H,G);if(!B.ok){if(B.stage==="missing"){if(V){let F=await V(B.value,Q.origin,W);if(F!==void 0)return F}U?.missing?.(Q,W,B.value.message,B.value);return}U?.error?.(Q,W,B.stage,B.error);return}let z=await J(B.value);if(!z.ok){U?.error?.(Q,W,"load",z.error,B.value);return}if(!K)return z.value;return K(z.value,Q.origin,W)}async function X(Q){let G=Q.items.map((U)=>({origin:U,plan:$(U.spec)})),W=[];for(let U of G)W.push(Y(U,Q.kind,!1,Q.finish,Q.missing,Q.report));let K=await Promise.all(W);if(Q.wait){let U;for(let H=0;H<G.length;H++){if(K[H]!==void 0)continue;let B=G[H];if(!B||Dm(B.plan.spec)!=="file")continue;U??=Q.wait(),await U,K[H]=await Y(B,Q.kind,!0,Q.finish,Q.missing,Q.report)}}let V=[];for(let U of K)if(U!==void 0)V.push(U);return V}Gu0.loadExternal=X})(CA||={});var Pm={worktree:Rm(async()=>(await import("./chunk-cpkcdykz.js")).WorktreeAdaptor)},OK=new Map;async function Vu0($,Z){let J=OK.get($)?.get(Z);if(J)return J;let Y=Pm[Z];if(Y)return Y();throw Error(`Unknown workspace adaptor: ${Z}`)}async function Uu0($){let Z=await Promise.all(Object.entries(Pm).map(async([Y,X])=>{let Q=await X();return{type:Y,name:Q.name,description:Q.description}})),J=[...OK.get($)?.entries()??[]].map(([Y,X])=>({type:Y,name:X.name,description:X.description}));return[...Z,...J]}function Cm($,Z,J){let Y=OK.get($)??new Map;Y.set(Z,J),OK.set($,Y)}import gN0 from"fs/promises";import JQ from"path";import{pathToFileURL as Im,fileURLToPath as uN0}from"url";var F$=_0.create({service:"plugin"}),EA={Executed:T1.define("hook.executed",D.object({event:D.enum(["actor.preStop","actor.postStop"]),hookID:D.string(),pluginName:D.string(),actorID:D.string(),agentType:D.string(),durationMs:D.number(),outcome:D.enum(["success","error","skipped"]),continueRequested:D.boolean(),reasonLength:D.number()})),ReActReentered:T1.define("hook.react.reentered",D.object({phase:D.enum(["pre","post"]),actorID:D.string(),agentType:D.string(),iteration:D.number(),triggeredByPlugins:D.array(D.string()),reasonPreview:D.string()})),ReActMaxReached:T1.define("hook.react.max_reached",D.object({phase:D.enum(["pre","post"]),actorID:D.string(),agentType:D.string()}))};class jK extends S1.Service()("@qitqode/Plugin"){}var mN0=[i2,n2,c2,e2,vu,HK,du,pu,Om,qm];function Em($){return typeof $==="function"}function lN0($){if(Em($))return $;if(!$||typeof $!=="object"||!("server"in $))return;if(!Em($.server))return;return $.server}function dN0($){let Z=new Set,J=[];for(let Y of Object.values($)){if(Z.has(Y))continue;Z.add(Y);let X=lN0(Y);if(!X)throw TypeError("Plugin export is not a function");J.push(X)}return J}async function pN0($,Z,J,Y){let X=_m($.mod,$.spec,"server","detect");if(X){await Sm($.source,$.spec,$.target,IA(X.id,$.spec),$.pkg);let Q=IA(X.id,$.spec)??$.pkg?.pkg??$.spec,G=await X.server(Z,$.options);J.push(G),Y.push({hook:G,pluginName:Q,hookIDFor:(W)=>`${Q}#${W}`});return}for(let Q of dN0($.mod)){let G=Q.name,W=G&&G!=="default"&&G!==""?G:$.pkg?.pkg??$.spec,K=await Q(Z,$.options);J.push(K),Y.push({hook:K,pluginName:W,hookIDFor:(V)=>`${W}#${V}`})}}var fm=R0.effect(jK,T.gen(function*(){let $=yield*d1.Service,Z=yield*Q8.Service,J=yield*B0.make(T.fn("Plugin.state")(function*(F){let A=[],N=[],q=yield*T7.make();function w(f){q.fork($.publish(YQ.Event.Error,{error:new N1.Unknown({message:f}).toObject()}))}let{Server:j}=yield*T.promise(()=>import("./chunk-3r6dq1h3.js")),M=LH({baseUrl:"http://localhost:4096",directory:F.directory,headers:S0.QITQODE_SERVER_PASSWORD?{Authorization:`Basic ${Buffer.from(`${S0.QITQODE_SERVER_USERNAME??"qitqode"}:${S0.QITQODE_SERVER_PASSWORD}`).toString("base64")}`}:void 0,fetch:async(...f)=>(await j.Default()).app.fetch(...f)}),I=yield*Z.get(),R={client:M,project:F.project,worktree:F.worktree,directory:F.directory,experimental_workspace:{register(f,b){Cm(F.project.id,f,b)}},get serverUrl(){return j.url??new URL("http://localhost:4096")},$:typeof Bun>"u"?void 0:Bun.$};for(let f of mN0){F$.info("loading internal plugin",{name:f.name});let b=yield*T.tryPromise({try:()=>f(R),catch:(k)=>{F$.error("failed to load internal plugin",{name:f.name,error:k})}}).pipe(T.option);if(b._tag==="Some")A.push(b.value),N.push({hook:b.value,pluginName:f.name,hookIDFor:(k)=>`${f.name}#${k}`})}let L={},C=yield*T.tryPromise(()=>import("./chunk-2z3fe4qw.js")).pipe(T.option);if(C._tag==="Some")Object.assign(L,C.value.modules??{});else{let f=JQ.join(JQ.dirname(uN0(import.meta.url)),"..","ext"),k=(yield*T.promise(()=>gN0.readdir(f).catch(()=>[]))).filter((u)=>u.endsWith(".ts")&&!u.endsWith(".d.ts")&&u!=="_manifest.ts");for(let u of k){let x=yield*T.tryPromise({try:()=>import(Im(JQ.join(f,u)).href),catch:(g)=>F$.error("failed to import extension",{name:u,error:g})}).pipe(T.option);if(x._tag==="Some")L[u.replace(/\.ts$/,"")]=x.value}}for(let[f,b]of Object.entries(L)){let k=Object.entries(b).find(([x,g])=>typeof g==="function"&&x.endsWith("Plugin"))?.[1];if(!k)continue;F$.info("loading extension",{name:f});let u=yield*T.tryPromise({try:()=>k(R),catch:(x)=>F$.error("failed to load extension",{name:f,error:x})}).pipe(T.option);if(u._tag==="Some")A.push(u.value),N.push({hook:u.value,pluginName:f,hookIDFor:(x)=>`${f}#${x}`})}let _=S0.QITQODE_PURE?[]:I.plugin_origins??[];if(S0.QITQODE_PURE&&I.plugin_origins?.length)F$.info("skipping external plugins in pure mode",{count:I.plugin_origins.length});if(_.length)yield*Z.waitForDependencies();let E=yield*T.promise(()=>CA.loadExternal({items:_,kind:"server",report:{start(f){F$.info("loading plugin",{path:f.plan.spec})},missing(f,b,k){F$.warn("plugin has no server entrypoint",{path:f.plan.spec,message:k})},error(f,b,k,u,x){let g=f.plan.spec,c=u instanceof Error?u.cause??u:u,e=k==="load"?V6(u):V6(c);if(k==="install"){let G0=bm(g);F$.error("failed to install plugin",{pkg:G0.pkg,version:G0.version,error:e}),w(`Failed to install plugin ${G0.pkg}@${G0.version}: ${e}`);return}if(k==="compatibility"){F$.warn("plugin incompatible",{path:g,error:e}),w(`Plugin ${g} skipped: ${e}`);return}if(k==="entry"){F$.error("failed to resolve plugin server entry",{path:g,error:e}),w(`Failed to load plugin ${g}: ${e}`);return}F$.error("failed to load plugin",{path:g,target:x?.entry,error:e}),w(`Failed to load plugin ${g}: ${e}`)}}}));for(let f of E){if(!f)continue;yield*T.tryPromise({try:()=>pN0(f,R,A,N),catch:(b)=>{let k=V6(b);return F$.error("failed to load plugin",{path:f.spec,error:k}),k}}).pipe(T.catch(()=>{return T.void}))}for(let f of A)yield*T.tryPromise({try:()=>Promise.resolve(f.config?.(I)),catch:(b)=>{F$.error("plugin config hook failed",{error:b})}}).pipe(T.ignore);return yield*$.subscribeAll().pipe(I$.runForEach((f)=>T.sync(()=>{for(let b of A)b.event?.({event:f})})),T.forkScoped),{hooks:A,hooksWithMeta:N}})),Y=yield*B0.make(T.fn("Plugin.fileHooks")(function*(){let F=[],A=[],N=yield*Z.get(),q=yield*Z.directories();for(let w of q){let j=$4.scanSync("{hook,hooks}/*.{js,ts}",{cwd:w,absolute:!0,dot:!0,symlink:!0});for(let M of j){let I=yield*T.tryPromise({try:()=>import(`${Im(M).href}?v=${Date.now()}`),catch:(L)=>L}).pipe(T.catch((L)=>{return F$.error("failed to load file hook",{path:M,error:V6(L)}),T.succeed(void 0)}));if(!I)continue;let R=I.default??I;if(R&&typeof R==="object"){let L=JQ.basename(M,JQ.extname(M));F.push(R),A.push({hook:R,pluginName:`file:${L}`,hookIDFor:(C)=>`file:${L}#${C}`}),F$.info("loaded file hook",{path:M,name:L})}}}return{hooks:F,meta:A}})),X=(F,A)=>T.gen(function*(){let N=yield*B0.get(J),q=yield*B0.get(Y),w=[],j=[],M=[],I=!1;for(let L of[...N.hooksWithMeta,...q.meta]){let C=L.hook[A];if(!C)continue;let _=typeof C==="function"?C:C.run,E=typeof C==="function"?void 0:C.matcher;if(!H2(E,F)){yield*$.publish(EA.Executed,{event:A,hookID:L.hookIDFor(A),pluginName:L.pluginName,actorID:F.actorID,agentType:F.agentType,durationMs:0,outcome:"skipped",continueRequested:!1,reasonLength:0});continue}let f=Date.now(),b={continue:!1},k="success";yield*T.tryPromise({try:()=>_(F,b),catch:(x)=>x}).pipe(T.tapError((x)=>T.gen(function*(){k="error",F$.error(`${A} hook failed`,{pluginName:L.pluginName,hookID:L.hookIDFor(A),error:x}),yield*$.publish(YQ.Event.Error,{sessionID:F.sessionID,error:new N1.Unknown({message:`${A} hook (${L.pluginName}) failed: ${V6(x)}`}).toObject()})})),T.ignore);let u=Date.now()-f;if(yield*$.publish(EA.Executed,{event:A,hookID:L.hookIDFor(A),pluginName:L.pluginName,actorID:F.actorID,agentType:F.agentType,durationMs:u,outcome:k,continueRequested:b.continue===!0,reasonLength:b.reason?.length??0}),b.continue===!0&&b.reason&&b.reason.length>0)I=!0,w.push(b.reason),j.push(L.pluginName),M.push(L.hookIDFor(A));else if(b.continue===!0)F$.warn(`${A} hook returned continue=true without reason; ignored`,{pluginName:L.pluginName})}return{continue:I,reason:w.length>0?w.join(`
|
|
798
|
+
|
|
799
|
+
`):void 0,contributingPluginNames:j,contributingHookIDs:M}}),Q=T.fn("Plugin.triggerActorPreStop")(function*(F){return yield*X(F,"actor.preStop")}),G=T.fn("Plugin.triggerActorPostStop")(function*(F){return yield*X(F,"actor.postStop")}),W=5000,K=3,V=new Map,U=T.fn("Plugin.trigger")(function*(F,A,N){if(!F)return N;let q=yield*B0.get(J),w=yield*B0.get(Y);for(let j of q.hooksWithMeta){let M=j.hook[F];if(!M)continue;yield*T.promise(async()=>M(A,N))}for(let j of w.meta){let M=j.hook[F];if(!M)continue;let I=j.hookIDFor(F);if((V.get(I)??0)>=3){F$.warn("hook circuit-breaker open, skipping",{hook:I});continue}let R=structuredClone(N);if(!(yield*T.tryPromise({try:async()=>{await Promise.race([Promise.resolve(M(A,N)),new Promise((C,_)=>setTimeout(()=>_(Error("hook timed out after 5000ms")),5000))])},catch:(C)=>C}).pipe(T.map(()=>!1),T.catch((C)=>{Object.assign(N,R);let _=(V.get(I)??0)+1;return V.set(I,_),F$.error("file hook failed, output rolled back",{hook:I,event:F,error:V6(C),consecutiveFailures:_,circuitOpen:_>=3}),T.succeed(!0)}))))V.delete(I)}return N}),H=T.fn("Plugin.list")(function*(){return(yield*B0.get(J)).hooks}),B=T.fn("Plugin.init")(function*(){yield*B0.get(J),yield*B0.get(Y)}),z=T.fn("Plugin.reloadFileHooks")(function*(){yield*B0.invalidate(Y)});return jK.of({trigger:U,list:H,init:B,reloadFileHooks:z,triggerActorPreStop:Q,triggerActorPostStop:G})})),cN0=fm.pipe(R0.provide(d1.layer),R0.provide(Q8.defaultLayer));import Fq0 from"path";var RK=m6(vm(),1);var XQ={};F1(XQ,{variants:()=>W5,topP:()=>tm,topK:()=>em,temperature:()=>am,smallOptions:()=>Zl,schema:()=>Ql,providerOptions:()=>Jl,options:()=>$l,message:()=>gm,maxOutputTokens:()=>Yl,OUTPUT_TOKEN_MAX:()=>MK});var xm=32000;function iN0($){if($.startsWith("image/"))return"image";if($.startsWith("audio/"))return"audio";if($.startsWith("video/"))return"video";if($==="application/pdf")return"pdf";return}function nN0($){let Z=$.id.toLowerCase(),J=$.api.id.toLowerCase();if(Z.includes("claude")||J.includes("claude")||$.providerID==="anthropic")return!0;if(Z.includes("gpt")||J.includes("gpt"))return!0;return $.capabilities.input.image}function qK($){switch($){case"@ai-sdk/github-copilot":return"copilot";case"@ai-sdk/azure":return"azure";case"@ai-sdk/openai":return"openai";case"@ai-sdk/amazon-bedrock":return"bedrock";case"@ai-sdk/anthropic":case"@ai-sdk/google-vertex/anthropic":return"anthropic";case"@ai-sdk/google-vertex":return"vertex";case"@ai-sdk/google":return"google";case"@ai-sdk/gateway":return"gateway";case"@openrouter/ai-sdk-provider":return"openrouter"}return}function oN0($,Z,J){if(Z.api.npm==="@ai-sdk/anthropic"||Z.api.npm==="@ai-sdk/amazon-bedrock")$=$.map((Y)=>{if(typeof Y.content==="string"){if(Y.content==="")return;return Y}if(!Array.isArray(Y.content))return Y;let X=Y.content.filter((Q)=>{if(Q.type==="text"||Q.type==="reasoning")return Q.text!=="";return!0});if(X.length===0)return;return{...Y,content:X}}).filter((Y)=>Y!==void 0&&Y.content!=="");if(Z.api.id.includes("claude")){let Y=(X)=>X.replace(/[^a-zA-Z0-9_-]/g,"_");$=$.map((X)=>{if(X.role==="assistant"&&Array.isArray(X.content))return{...X,content:X.content.map((Q)=>{if(Q.type==="tool-call"||Q.type==="tool-result")return{...Q,toolCallId:Y(Q.toolCallId)};return Q})};if(X.role==="tool"&&Array.isArray(X.content))return{...X,content:X.content.map((Q)=>{if(Q.type==="tool-result")return{...Q,toolCallId:Y(Q.toolCallId)};return Q})};return X})}if(["@ai-sdk/anthropic","@ai-sdk/google-vertex/anthropic"].includes(Z.api.npm))$=$.flatMap((Y)=>{if(Y.role!=="assistant"||!Array.isArray(Y.content))return[Y];let X=Y.content,Q=X.findIndex((G)=>G.type==="tool-call");if(Q===-1)return[Y];if(!X.slice(Q).some((G)=>G.type!=="tool-call"))return[Y];return[{...Y,content:X.filter((G)=>G.type!=="tool-call")},{...Y,content:X.filter((G)=>G.type==="tool-call")}]});if(Z.providerID==="mistral"||Z.api.id.toLowerCase().includes("mistral")||Z.api.id.toLowerCase().includes("devstral")){let Y=(Q)=>{return Q.replace(/[^a-zA-Z0-9]/g,"").substring(0,9).padEnd(9,"0")},X=[];for(let Q=0;Q<$.length;Q++){let G=$[Q],W=$[Q+1];if(G.role==="assistant"&&Array.isArray(G.content))X.push({...G,content:G.content.map((K)=>{if(K.type==="tool-call"||K.type==="tool-result")return{...K,toolCallId:Y(K.toolCallId)};return K})});else if(G.role==="tool"&&Array.isArray(G.content))X.push({...G,content:G.content.map((K)=>{if(K.type==="tool-result")return{...K,toolCallId:Y(K.toolCallId)};return K})});else X.push(G);if(G.role==="tool"&&W?.role==="user")X.push({role:"assistant",content:[{type:"text",text:"Done."}]})}return X}if(typeof Z.capabilities.interleaved==="object"&&Z.capabilities.interleaved.field){let Y=Z.capabilities.interleaved.field;return $.map((X)=>{if(X.role==="assistant"&&Array.isArray(X.content)){let G=X.content.filter((K)=>K.type==="reasoning").map((K)=>K.text).join(""),W=X.content.filter((K)=>K.type!=="reasoning");if(G)return{...X,content:W,providerOptions:{...X.providerOptions,openaiCompatible:{...X.providerOptions?.openaiCompatible,[Y]:G}}};return{...X,content:W}}return X})}return $}function sN0($){if($.api.npm==="@ai-sdk/anthropic"||$.api.npm==="@ai-sdk/google-vertex/anthropic")return!0;if($.providerID==="anthropic"||$.providerID==="google-vertex-anthropic")return!0;if($.api.npm==="@ai-sdk/amazon-bedrock")return!0;if($.api.npm==="@openrouter/ai-sdk-provider"||$.api.npm==="@ai-sdk/github-copilot"||$.api.npm==="@ai-sdk/alibaba")return $.api.id.includes("claude")||$.api.id.includes("anthropic")||$.id.includes("claude")||$.id.includes("anthropic");return!1}function rN0($,Z){let J=Z.cachePromptTTL==="1h"?{ttl:"1h"}:{},Y={anthropic:{cacheControl:{type:"ephemeral",...J}},openrouter:{cacheControl:{type:"ephemeral",...J}},bedrock:{cachePoint:{type:"default"}},openaiCompatible:{cache_control:{type:"ephemeral"}},copilot:{copilot_cache_control:{type:"ephemeral"}},alibaba:{cacheControl:{type:"ephemeral"}}},X=[],Q=$.filter((K)=>K.role==="system");if(Q.length>0)X.push(Q[Q.length-1]);let G=$.filter((K)=>K.role!=="system"),W=G.findLastIndex((K)=>K.role==="user");if(W>=1){X.push(G[W-1]);let K=Math.floor(W/2);if(K>0&&K<W-1)X.push(G[K])}else if(W===0)X.push(G[0]);for(let K of ym(X)){if(!(Z.providerID==="anthropic"||Z.providerID.includes("bedrock")||Z.api.npm==="@ai-sdk/amazon-bedrock")&&Array.isArray(K.content)&&K.content.length>0){let H=K.content[K.content.length-1];if(H&&typeof H==="object"&&H.type!=="tool-approval-request"&&H.type!=="tool-approval-response"){H.providerOptions=q1(H.providerOptions??{},Y);continue}}K.providerOptions=q1(K.providerOptions??{},Y)}return $}function aN0($,Z){return $.map((J)=>{if(J.role!=="user"||!Array.isArray(J.content))return J;let Y=J.content.map((X)=>{if(X.type!=="file"&&X.type!=="image")return X;if(X.type==="image"){let U=String(X.image);if(U.startsWith("data:")){let H=U.match(/^data:([^;]+);base64,(.*)$/);if(H&&(!H[2]||H[2].length===0))return{type:"text",text:"ERROR: Image file is empty or corrupted. Please provide a valid image."}}}let Q=X.type==="image"?String(X.image).split(";")[0].replace("data:",""):X.mediaType,G=X.type==="file"?X.filename:void 0,W=iN0(Q);if(!W)return X;if(W==="image"?nN0(Z):Z.capabilities.input[W])return X;return{type:"text",text:`ERROR: Cannot read ${G?`"${G}"`:W} (this model does not support ${W} input). Inform the user.`}});return{...J,content:Y}})}function tN0($){if(!$.startsWith("data:"))return;let Z=$.slice($.indexOf(",")+1);if(!Z)return 0;let J=Z.endsWith("==")?2:Z.endsWith("=")?1:0;return Math.floor(Z.length*3/4)-J}function eN0($,Z,J){if(Z===void 0&&J===void 0)return $;let Y=$.reduce((Q,G)=>G.role==="user"&&Array.isArray(G.content)?Q+G.content.filter((W)=>W.type==="image").length:Q,0),X=Z===void 0?0:Math.max(0,Y-Z);return $.map((Q)=>{if(Q.role!=="user"||!Array.isArray(Q.content))return Q;let G=Q.content.map((W)=>{if(W.type!=="image")return W;if(X>0)return X--,{type:"text",text:`[Image omitted: exceeds the configured limit of ${Z} prompt image(s).]`};if(J!==void 0){let K=tN0(String(W.image));if(K!==void 0&&K>J)return{type:"text",text:`[Image omitted: exceeds the configured ${J}-byte prompt image size limit.]`}}return W});return{...Q,content:G}})}function hm($,Z,J,Y={}){if($=aN0($,Z),$=eN0($,Y.maxImages,Y.maxSize),$=oN0($,Z,J),sN0(Z))$=rN0($,Z);let X=qK(Z.api.npm);if(X&&X!==Z.providerID){let Q=(G)=>{if(!G)return G;if(!(Z.providerID in G))return G;let W={...G};return W[X]=W[Z.providerID],delete W[Z.providerID],W};$=$.map((G)=>{if(!Array.isArray(G.content))return{...G,providerOptions:Q(G.providerOptions)};return{...G,providerOptions:Q(G.providerOptions),content:G.content.map((W)=>{if(W.type==="tool-approval-request"||W.type==="tool-approval-response")return{...W};return{...W,providerOptions:Q(W.providerOptions)}})}})}return $}var MK=S0.QITQODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX||xm;function gm($,Z,J){return hm($,Z,J,{maxImages:S0.QITQODE_MAX_PROMPT_IMAGES,maxSize:S0.QITQODE_MAX_PROMPT_IMAGE_SIZE})}function um($){return $()}var U6=["low","medium","high"],mm=["none","minimal",...U6,"xhigh"];function lm($){if($)return Object.fromEntries($.map((Z)=>[Z,{thinking:{type:"adaptive"},effort:Z}]));return{high:{thinking:{type:"enabled",budgetTokens:16000}},max:{thinking:{type:"enabled",budgetTokens:31999}}}}function $q0($){if(["opus-4-7","opus-4.7","opus-4-8","opus-4.8"].some((Z)=>$.includes(Z)))return["low","medium","high","xhigh","max"];if(["opus-4-6","opus-4.6","sonnet-4-6","sonnet-4.6"].some((Z)=>$.includes(Z)))return["low","medium","high","max"];return null}function dm($){if(!$.capabilities.reasoning)return{};let Z=$.id.toLowerCase(),J=$q0($.api.id);if(Z.includes("deepseek")||Z.includes("minimax")||Z.includes("glm")||Z.includes("mistral")||Z.includes("kimi")||Z.includes("k2p5")||Z.includes("qwen")||Z.includes("big-pickle"))return{};if(Z.includes("grok")&&Z.includes("grok-3-mini")){if($.api.npm==="@openrouter/ai-sdk-provider")return{low:{reasoning:{effort:"low"}},high:{reasoning:{effort:"high"}}};return{low:{reasoningEffort:"low"},high:{reasoningEffort:"high"}}}if(Z.includes("grok"))return{};switch($.api.npm){case"@openrouter/ai-sdk-provider":if(!$.id.includes("gpt")&&!$.id.includes("gemini-3")&&!$.id.includes("claude"))return{};return Object.fromEntries(mm.map((K)=>[K,{reasoning:{effort:K}}]));case"@ai-sdk/gateway":if($.id.includes("anthropic"))return lm(J);if($.id.includes("google")){if(Z.includes("2.5"))return{high:{thinkingConfig:{includeThoughts:!0,thinkingBudget:16000}},max:{thinkingConfig:{includeThoughts:!0,thinkingBudget:24576}}};return Object.fromEntries(["low","high"].map((K)=>[K,{includeThoughts:!0,thinkingLevel:K}]))}return Object.fromEntries(mm.map((K)=>[K,{reasoningEffort:K}]));case"@ai-sdk/github-copilot":if($.id.includes("gemini"))return{};if($.id.includes("claude"))return Object.fromEntries(U6.map((K)=>[K,{reasoningEffort:K}]));let Y=um(()=>{if(Z.includes("5.1-codex-max")||Z.includes("5.2")||Z.includes("5.3"))return[...U6,"xhigh"];let K=[...U6];if(Z.includes("gpt-5")&&$.release_date>="2025-12-04")K.push("xhigh");return K});return Object.fromEntries(Y.map((K)=>[K,{reasoningEffort:K,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}]));case"@ai-sdk/cerebras":case"@ai-sdk/togetherai":case"@ai-sdk/xai":case"@ai-sdk/deepinfra":case"venice-ai-sdk-provider":case"@ai-sdk/openai-compatible":return Object.fromEntries(U6.map((K)=>[K,{reasoningEffort:K}]));case"@ai-sdk/azure":if(Z==="o1-mini")return{};let X=["low","medium","high"];if(Z.includes("gpt-5-")||Z==="gpt-5")X.unshift("minimal");return Object.fromEntries(X.map((K)=>[K,{reasoningEffort:K,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}]));case"@ai-sdk/openai":if(Z==="gpt-5-pro")return{};let Q=um(()=>{if(Z.includes("codex")){if(Z.includes("5.2")||Z.includes("5.3"))return[...U6,"xhigh"];return U6}let K=[...U6];if(Z.includes("gpt-5-")||Z==="gpt-5")K.unshift("minimal");if($.release_date>="2025-11-13")K.unshift("none");if($.release_date>="2025-12-04")K.push("xhigh");return K});return Object.fromEntries(Q.map((K)=>[K,{reasoningEffort:K,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}]));case"@ai-sdk/anthropic":case"@ai-sdk/google-vertex/anthropic":if($.providerID==="github-copilot"){if($.api.id.includes("opus-4.7"))return Object.fromEntries(["medium"].map((K)=>[K,{reasoningEffort:K}]))}if(J)return Object.fromEntries(J.map((K)=>[K,{thinking:{type:"adaptive",...["opus-4-7","opus-4.7","opus-4-8","opus-4.8"].some((V)=>$.api.id.includes(V))?{display:"summarized"}:{}},effort:K}]));return{high:{thinking:{type:"enabled",budgetTokens:Math.max(1,Math.min(16000,Math.floor($.limit.output/2-1)))}},max:{thinking:{type:"enabled",budgetTokens:Math.max(1,Math.min(31999,$.limit.output-1))}}};case"@ai-sdk/amazon-bedrock":if(J)return Object.fromEntries(J.map((K)=>[K,{reasoningConfig:{type:"adaptive",maxReasoningEffort:K,...["opus-4-7","opus-4.7","opus-4-8","opus-4.8"].some((V)=>$.api.id.includes(V))?{display:"summarized"}:{}}}]));if($.api.id.includes("anthropic"))return{high:{reasoningConfig:{type:"enabled",budgetTokens:16000}},max:{reasoningConfig:{type:"enabled",budgetTokens:31999}}};return Object.fromEntries(U6.map((K)=>[K,{reasoningConfig:{type:"enabled",maxReasoningEffort:K}}]));case"@ai-sdk/google-vertex":case"@ai-sdk/google":if(Z.includes("2.5"))return{high:{thinkingConfig:{includeThoughts:!0,thinkingBudget:16000}},max:{thinkingConfig:{includeThoughts:!0,thinkingBudget:24576}}};let G=["low","high"];if(Z.includes("3.1"))G=["low","medium","high"];return Object.fromEntries(G.map((K)=>[K,{thinkingConfig:{includeThoughts:!0,thinkingLevel:K}}]));case"@ai-sdk/mistral":return{};case"@ai-sdk/cohere":return{};case"@ai-sdk/groq":let W=["none",...U6];return Object.fromEntries(W.map((K)=>[K,{reasoningEffort:K}]));case"@ai-sdk/perplexity":return{};case"@jerome-benoit/sap-ai-provider-v2":if($.api.id.includes("anthropic"))return lm(J);if($.api.id.includes("gemini")&&Z.includes("2.5"))return{high:{thinkingConfig:{includeThoughts:!0,thinkingBudget:16000}},max:{thinkingConfig:{includeThoughts:!0,thinkingBudget:24576}}};if($.api.id.includes("gpt")||/\bo[1-9]/.test($.api.id))return Object.fromEntries(U6.map((K)=>[K,{reasoningEffort:K}]));return{}}return{}}function W5($){return dm($)}function pm($){let Z=$.id.toLowerCase();if(Z.includes("qwen"))return 0.55;if(Z.includes("claude"))return;if(Z.includes("gemini"))return 1;if(Z.includes("glm-4.6"))return 1;if(Z.includes("glm-4.7"))return 1;if(Z.includes("minimax-m2"))return 1;if(Z.includes("kimi-k2")){if(["thinking","k2.","k2p","k2-5"].some((J)=>Z.includes(J)))return 1;return 0.6}return}function cm($){let Z=$.id.toLowerCase();if(Z.includes("qwen"))return 1;if(["minimax-m2","gemini","kimi-k2.5","kimi-k2p5","kimi-k2-5"].some((J)=>Z.includes(J)))return 0.95;return}function im($){let Z=$.id.toLowerCase();if(Z.includes("minimax-m2")){if(["m2.","m25","m21"].some((J)=>Z.includes(J)))return 40;return 20}if(Z.includes("gemini"))return 64;return}function nm($){let Z={};if($.model.providerID==="openai"||$.model.api.npm==="@ai-sdk/openai"||$.model.api.npm==="@ai-sdk/github-copilot")Z.store=!1;if($.model.api.npm==="@ai-sdk/azure")Z.store=!0,Z.promptCacheKey=$.sessionID;if($.model.api.npm==="@openrouter/ai-sdk-provider"||$.model.api.npm==="@llmgateway/ai-sdk-provider"){if(Z.usage={include:!0},$.model.api.id.includes("gemini-3"))Z.reasoning={effort:"high"}}if($.model.providerID==="baseten"||$.model.providerID==="opencode"&&["kimi-k2-thinking","glm-4.6"].includes($.model.api.id))Z.chat_template_args={enable_thinking:!0};if(["zai","zhipuai"].some((Y)=>$.model.providerID.includes(Y))&&$.model.api.npm==="@ai-sdk/openai-compatible")Z.thinking={type:"enabled",clear_thinking:!1};if($.model.providerID==="openai"||$.providerOptions?.setCacheKey)Z.promptCacheKey=$.sessionID;if($.model.api.npm==="@ai-sdk/google"||$.model.api.npm==="@ai-sdk/google-vertex"){if($.model.capabilities.reasoning){if(Z.thinkingConfig={includeThoughts:!0},$.model.api.id.includes("gemini-3"))Z.thinkingConfig.thinkingLevel="high"}}let J=$.model.api.id.toLowerCase();if(($.model.api.npm==="@ai-sdk/anthropic"||$.model.api.npm==="@ai-sdk/google-vertex/anthropic")&&(J.includes("k2p5")||J.includes("kimi-k2.5")||J.includes("kimi-k2p5")))Z.thinking={type:"enabled",budgetTokens:Math.max(1,Math.min(16000,Math.floor($.model.limit.output/2-1)))};if($.model.providerID==="alibaba-cn"&&$.model.capabilities.reasoning&&$.model.api.npm==="@ai-sdk/openai-compatible"&&!J.includes("kimi-k2-thinking"))Z.enable_thinking=!0;if($.model.api.id.includes("gpt-5")&&!$.model.api.id.includes("gpt-5-chat")){if(!$.model.api.id.includes("gpt-5-pro")){if(Z.reasoningEffort="medium",$.model.api.npm==="@ai-sdk/openai"||$.model.api.npm==="@ai-sdk/azure"||$.model.api.npm==="@ai-sdk/github-copilot")Z.reasoningSummary="auto"}if($.model.api.id.includes("gpt-5.")&&!$.model.api.id.includes("codex")&&!$.model.api.id.includes("-chat")&&$.model.providerID!=="azure")Z.textVerbosity="low";if($.model.providerID.startsWith("opencode"))Z.promptCacheKey=$.sessionID,Z.include=["reasoning.encrypted_content"],Z.reasoningSummary="auto"}if($.model.providerID==="venice")Z.promptCacheKey=$.sessionID;if($.model.providerID==="openrouter")Z.prompt_cache_key=$.sessionID;if($.model.api.npm==="@ai-sdk/gateway")Z.gateway={caching:"auto"};return Z}function om($){if($.providerID==="openai"||$.api.npm==="@ai-sdk/openai"||$.api.npm==="@ai-sdk/github-copilot"){if($.api.id.includes("gpt-5")){if($.api.id.includes("5.")||$.api.id.includes("5-mini"))return{store:!1,reasoningEffort:"low"};return{store:!1,reasoningEffort:"minimal"}}return{store:!1}}if($.providerID==="google"){if($.api.id.includes("gemini-3"))return{thinkingConfig:{thinkingLevel:"minimal"}};return{thinkingConfig:{thinkingBudget:0}}}if($.providerID==="openrouter"||$.providerID==="llmgateway"){if($.api.id.includes("google"))return{reasoning:{enabled:!1}};return{reasoningEffort:"minimal"}}if($.providerID==="venice")return{veniceParameters:{disableThinking:!0}};return{}}var Zq0={amazon:"bedrock"};function sm($,Z){if($.api.npm==="@ai-sdk/gateway"){let Y=$.api.id.indexOf("/"),X=Y>0?$.api.id.slice(0,Y):void 0,Q=X?Zq0[X]??X:void 0,G=Z.gateway,W=Object.fromEntries(Object.entries(Z).filter(([U])=>U!=="gateway")),K=Object.keys(W).length>0,V={};if(G!==void 0)V.gateway=G;if(K)if(Q)V[Q]=W;else if(G&&typeof G==="object"&&!Array.isArray(G))V.gateway={...G,...W};else V.gateway=W;return V}let J=qK($.api.npm)??$.providerID;if($.api.npm==="@ai-sdk/azure")return{openai:Z,azure:Z};return{[J]:Z}}function rm($,Z){return Math.min($.limit.output,Z)||Z}function am($){return pm($)}function tm($){return cm($)}function em($){return im($)}function $l($){return nm($)}function Zl($){return om($)}function Jl($,Z){return sm($,Z)}function Yl($){return rm($,MK)}function Jq0($){let Z=$,J=Z.anyOf??Z.oneOf;if(!J?.length)return $;let Y=new Map;for(let W of J){if(!W.properties)continue;for(let[K,V]of Object.entries(W.properties))if(V&&typeof V==="object"&&"const"in V){if(!Y.has(K))Y.set(K,new Set);Y.get(K).add(V.const)}}let X;for(let[W,K]of Y)if(K.size===J.length){X=W;break}let Q={},G={};for(let W of J){if(!W.properties)continue;let K=X?W.properties[X]?.const:void 0;for(let[V,U]of Object.entries(W.properties)){if(V===X)continue;if(!(V in Q))Q[V]=U;if(K!==void 0){if(!G[V])G[V]=[];G[V].push(K)}}}if(X)for(let[W,K]of Object.entries(G)){if(K.length===J.length)continue;let V=`(only when ${X}=${K.map((H)=>JSON.stringify(H)).join("|")})`,U=Q[W].description;Q[W]={...Q[W],description:U?`${V} ${U}`:V}}if(X){let W=J[0].properties[X],K=J.map((H)=>H.properties[X]?.const),V=W?.description??"",U=J.map((H)=>{let B=H.properties[X]?.const,z=(H.required??[]).filter((F)=>F!==X);return z.length>0?`${B}: requires ${z.join(", ")}`:`${B}: no extra required fields`}).join("; ");Q[X]={type:"string",enum:K,description:V?`${V}
|
|
800
|
+
|
|
801
|
+
Per-${X}: ${U}.`:`Per-${X}: ${U}.`}}return{type:"object",properties:Q,required:X?[X]:[],additionalProperties:!1}}function Xl($,Z){if(Z=Jq0(Z),$.providerID==="google"||$.api.id.includes("gemini")){let J=(G)=>typeof G==="object"&&G!==null&&!Array.isArray(G),Y=(G)=>J(G)&&(Array.isArray(G.anyOf)||Array.isArray(G.oneOf)||Array.isArray(G.allOf)),X=(G)=>{if(!J(G))return!1;if(Y(G))return!0;return["type","properties","items","prefixItems","enum","const","$ref","additionalProperties","patternProperties","required","not","if","then","else"].some((W)=>(W in G))},Q=(G)=>{if(G===null||typeof G!=="object")return G;if(Array.isArray(G))return G.map(Q);let W={};for(let[K,V]of Object.entries(G))if(K==="enum"&&Array.isArray(V)){if(W[K]=V.map((U)=>String(U)),W.type==="integer"||W.type==="number")W.type="string"}else if(typeof V==="object"&&V!==null)W[K]=Q(V);else W[K]=V;if(W.type==="object"&&W.properties&&Array.isArray(W.required))W.required=W.required.filter((K)=>(K in W.properties));if(W.type==="array"&&!Y(W)){if(W.items==null)W.items={};if(J(W.items)&&!X(W.items))W.items.type="string"}if(W.type&&W.type!=="object"&&!Y(W))delete W.properties,delete W.required;return W};Z=Q(Z)}return Z}function Ql($,Z){return Xl($,Z)}var bA=1e6,DK=new Set(h1.tiers().map(($)=>$.id)),Kl=h1.tiers(),q7=Object.fromEntries(Kl.map(($)=>[$.id,{providerID:$.providerID,modelID:$.modelID}])),k6=h1.qlexProviderMeta();function Vl($,Z){let J=h1.tierBudgetFacts($)??h1.tierBudgetFacts("adaptive");return{id:a1.make($),providerID:r0.make("qlex"),name:Z,family:k6.family,api:{id:$,url:"",npm:k6.npm},status:"active",headers:{},options:{},cost:{input:0,output:0,cache:{read:0,write:0}},limit:{context:J.context,output:J.output},capabilities:{temperature:k6.capabilities.temperature,reasoning:J.reasoning,attachment:k6.capabilities.attachment,toolcall:k6.capabilities.toolcall,input:{...k6.capabilities.input},output:{...k6.capabilities.output},interleaved:k6.capabilities.interleaved},release_date:k6.release_date,variants:{}}}var QQ={id:r0.make("qlex"),name:k6.name,source:"custom",env:[],options:{},models:Object.fromEntries(Kl.map(($)=>[$.id,Vl($.id,$.label)]))};function Ul(){let $=h1.tiers();DK.clear();for(let J of $)DK.add(J.id);for(let J of Object.keys(q7))delete q7[J];Object.assign(q7,Object.fromEntries($.map((J)=>[J.id,{providerID:J.providerID,modelID:J.modelID}])));let Z=QQ.models;for(let J of Object.keys(Z))delete Z[J];Object.assign(QQ.models,Object.fromEntries($.map((J)=>[J.id,Vl(J.id,J.label)])))}var _A=new Set;function Hl($){let Z={input:$?.input??0,output:$?.output??0,cache:{read:$?.cache_read??0,write:$?.cache_write??0}};if($?.context_over_200k)Z.experimentalOver200K={cache:{read:$.context_over_200k.cache_read??0,write:$.context_over_200k.cache_write??0},input:$.context_over_200k.input,output:$.context_over_200k.output};return Z}function Gl($,Z){let J={id:a1.make(Z.id),providerID:r0.make($.id),name:Z.name,family:Z.family,api:{id:Z.id,url:Z.provider?.api??$.api??"",npm:Z.provider?.npm??$.npm??"@ai-sdk/openai-compatible"},status:Z.status??"active",headers:{},options:{},cost:Hl(Z.cost),limit:{context:Z.limit.context,input:Z.limit.input,output:Z.limit.output},capabilities:{temperature:Z.temperature??!1,reasoning:Z.reasoning??!1,attachment:Z.attachment??!1,toolcall:Z.tool_call??!0,input:{text:Z.modalities?.input?.includes("text")??!1,audio:Z.modalities?.input?.includes("audio")??!1,image:Z.modalities?.input?.includes("image")??!1,video:Z.modalities?.input?.includes("video")??!1,pdf:Z.modalities?.input?.includes("pdf")??!1},output:{text:Z.modalities?.output?.includes("text")??!1,audio:Z.modalities?.output?.includes("audio")??!1,image:Z.modalities?.output?.includes("image")??!1,video:Z.modalities?.output?.includes("video")??!1,pdf:Z.modalities?.output?.includes("pdf")??!1},interleaved:Z.interleaved??!1},release_date:Z.release_date??"",variants:{}};return{...J,variants:v6(W5(J),(Y)=>Y)}}function wK($){let Z={};for(let[J,Y]of Object.entries($.models)){Z[J]=Gl($,Y);for(let[X,Q]of Object.entries(Y.experimental?.modes??{})){let G=`${Y.id}-${X}`,W=Gl($,Y);Z[G]={...W,id:a1.make(G),name:`${Y.name} ${X[0].toUpperCase()}${X.slice(1)}`,cost:Q.cost?q1(W.cost,Hl(Q.cost)):W.cost,options:Q.provider?.body?Object.fromEntries(Object.entries(Q.provider.body).map(([K,V])=>[K.replace(/_([a-z])/g,(U,H)=>H.toUpperCase()),V])):W.options,headers:Q.provider?.headers??W.headers}}}return{id:r0.make($.id),source:"custom",name:$.name,env:$.env??[],options:{},models:Z}}function Bl($){return v6($,(Z)=>GQ(Object.values(Z.models))[0].id)}var Yq0=["gpt-5.5","gpt-5","claude-sonnet-4","gemini-3-pro"];function GQ($){return Wl($,[(Z)=>Yq0.findIndex((J)=>Z.id.includes(J)),"desc"],[(Z)=>Z.id.includes("latest")?0:1,"asc"],[(Z)=>Z.id,"desc"])}function K5($){let[Z,...J]=$.split("/");return{providerID:r0.make(Z),modelID:a1.make(J.join("/"))}}var KY=N1.create("ProviderModelNotFoundError",P.object({providerID:r0.zod,modelID:a1.zod,suggestions:P.array(P.string()).optional()})),LK=N1.create("ProviderModelGroupNotFoundError",P.object({group:P.string(),suggestions:P.array(P.string()).optional()})),TK=N1.create("ProviderInitError",P.object({providerID:r0.zod}));function zl($){let{getState:Z,config:J,readRecent:Y}=$,X=T.fn("Provider.getProvider")((U)=>Z().pipe(T.map((H)=>H.providers[U]))),Q=T.fn("Provider.getModel")(function*(U,H){if(U===r0.make("qlex")&&h1.isDecisionTier(String(H)))h1.assertChatTierSupported(String(H));let B=yield*Z(),z=B.providers[U];if(!z){let A=Object.keys(B.providers),N=RK.default.go(U,A,{limit:3,threshold:-1e4});throw new KY({providerID:U,modelID:H,suggestions:N.map((q)=>q.target)})}let F=z.models[H];if(!F){let A=Object.keys(z.models),N=RK.default.go(H,A,{limit:3,threshold:-1e4});throw new KY({providerID:U,modelID:H,suggestions:N.map((q)=>q.target)})}if(U===r0.make("qlex")&&h1.isDecisionTier(F.api.id))h1.assertChatTierSupported(F.api.id);return F}),G=T.fn("Provider.closest")(function*(U,H){let z=(yield*Z()).providers[U];if(!z)return;for(let F of H)for(let A of Object.keys(z.models))if(A.includes(F))return{providerID:U,modelID:A};return}),W=T.fn("Provider.resolveModelRef")(function*(U,H){if(h1.isDecisionTier(U))h1.assertChatTierSupported(U);if(U.includes("/")){let q=K5(U);return yield*Q(q.providerID,q.modelID)}let B=yield*J.get(),z=B.model_groups?.[U];if(!z){if(DK.has(U)){let j=q7[U];if(j){let I=yield*Q(r0.make(j.providerID),a1.make(j.modelID)).pipe(T.exit);if(I._tag==="Success")return I.value}let M=yield*V();return yield*Q(M.providerID,M.modelID)}let q=Object.keys(B.model_groups??{}),w=RK.default.go(U,q,{limit:3,threshold:-1e4});throw new LK({group:U,suggestions:w.map((j)=>j.target)})}let F=typeof z==="string"?z:z.default,A=typeof z==="string"?[z]:z.models??[z.default];if(H)for(let q of A){let w=K5(q);if(w.providerID!==H)continue;let j=yield*Q(w.providerID,w.modelID).pipe(T.exit);if(j._tag==="Success")return j.value}let N=K5(F);return yield*Q(N.providerID,N.modelID)}),K=T.fn("Provider.getSmallModel")(function*(U){let H=yield*J.get();if(H.small_model){let B=K5(H.small_model);return yield*Q(B.providerID,B.modelID)}for(let B of["lite","free","economical"]){if(H.model_groups?.[B])return yield*W(B,U);let F=q7[B];if(F){let A=yield*Q(r0.make(F.providerID),a1.make(F.modelID)).pipe(T.exit);if(A._tag==="Success")return A.value}}return yield*W("economical",U)}),V=T.fn("Provider.defaultModel")(function*(){let U=yield*J.get();if(U.model){let A=K5(U.model);if(A.providerID===r0.make("qlex")&&h1.isDecisionTier(String(A.modelID)))h1.assertChatTierSupported(String(A.modelID));return A}let H=yield*Z(),B=yield*Y().pipe(T.map((A)=>{if(!Y8(A)||!Array.isArray(A.recent))return[];return A.recent.flatMap((N)=>{if(!Y8(N))return[];if(typeof N.providerID!=="string")return[];if(typeof N.modelID!=="string")return[];return[{providerID:r0.make(N.providerID),modelID:a1.make(N.modelID)}]})}),T.catch(()=>T.succeed([])));for(let A of B){if(A.providerID===r0.make("qlex")&&h1.isDecisionTier(String(A.modelID)))continue;let N=H.providers[A.providerID];if(!N)continue;if(!N.models[A.modelID])continue;return{providerID:A.providerID,modelID:A.modelID}}for(let A of["adaptive","fast","economical","max-int"]){let N=q7[A];if(!N)continue;let q=H.providers[r0.make(N.providerID)];if(q?.models[a1.make(N.modelID)])return{providerID:q.id,modelID:a1.make(N.modelID)}}let z=Object.values(H.providers).find((A)=>!U.provider||Object.keys(U.provider).includes(A.id));if(!z)throw Error("no providers found");let[F]=GQ(Object.values(z.models));if(!F)throw Error("no models found");return{providerID:z.id,modelID:F.id}});return{getProvider:X,getModel:Q,closest:G,resolveModelRef:W,getSmallModel:K,defaultModel:V}}var PK=480000;function Fl($,Z,J){if(typeof Z!=="number"||Z<=0)return $;if(!$.body)return $;if(!$.headers.get("content-type")?.includes("text/event-stream"))return $;let Y=$.body.getReader(),X=new ReadableStream({async pull(Q){let G=await new Promise((W,K)=>{let V=setTimeout(()=>{let U=Error("SSE read timed out");J.abort(U),Y.cancel(U),K(U)},Z);Y.read().then((U)=>{clearTimeout(V),W(U)},(U)=>{clearTimeout(V),K(U)})});if(G.done){Q.close();return}Q.enqueue(G.value)},async cancel(Q){J.abort(Q),await Y.cancel(Q)}});return new Response(X,{headers:new Headers($.headers),status:$.status,statusText:$.statusText})}import OZ from"os";var VY=_0.create({service:"provider/loaders"}),CK=new Map,ql={"@qitqode/qlex-provider":()=>import("./chunk-eme9xmh3.js").then(($)=>$.createQlexProvider),"@ai-sdk/amazon-bedrock":()=>import("./chunk-zskdxbbh.js").then(($)=>$.createAmazonBedrock),"@ai-sdk/anthropic":()=>import("./chunk-5rqjze1g.js").then(($)=>$.createAnthropic),"@ai-sdk/azure":()=>import("./chunk-yexzxx6f.js").then(($)=>$.createAzure),"@ai-sdk/google":()=>import("./chunk-t5wdstzv.js").then(($)=>$.createGoogleGenerativeAI),"@ai-sdk/google-vertex":()=>import("./chunk-xstxdw7v.js").then(($)=>$.createVertex),"@ai-sdk/google-vertex/anthropic":()=>import("./chunk-c8080519.js").then(($)=>$.createVertexAnthropic),"@ai-sdk/openai":()=>import("./chunk-9fjcgdea.js").then(($)=>$.createOpenAI),"@ai-sdk/openai-compatible":()=>import("./chunk-10fr7a2y.js").then(($)=>$.createOpenAICompatible),"@openrouter/ai-sdk-provider":()=>import("./chunk-qbewhcsz.js").then(($)=>$.createOpenRouter),"@ai-sdk/xai":()=>import("./chunk-3zzrdpsx.js").then(($)=>$.createXai),"@ai-sdk/mistral":()=>import("./chunk-6wjdhvdf.js").then(($)=>$.createMistral),"@ai-sdk/groq":()=>import("./chunk-c3ey896z.js").then(($)=>$.createGroq),"@ai-sdk/deepinfra":()=>import("./chunk-5fcyb122.js").then(($)=>$.createDeepInfra),"@ai-sdk/cerebras":()=>import("./chunk-wecs14rz.js").then(($)=>$.createCerebras),"@ai-sdk/cohere":()=>import("./chunk-5w7ebtcd.js").then(($)=>$.createCohere),"@ai-sdk/gateway":()=>import("./chunk-bd5vtjd7.js").then(($)=>$.createGateway),"@ai-sdk/togetherai":()=>import("./chunk-qjw2zcq5.js").then(($)=>$.createTogetherAI),"@ai-sdk/perplexity":()=>import("./chunk-cs825mxr.js").then(($)=>$.createPerplexity),"@ai-sdk/vercel":()=>import("./chunk-h91zmzs5.js").then(($)=>$.createVercel),"@ai-sdk/alibaba":()=>import("./chunk-xj0zc9za.js").then(($)=>$.createAlibaba),"gitlab-ai-provider":()=>import("./chunk-ev6jwt7q.js").then(($)=>$.createGitLab),"@ai-sdk/github-copilot":()=>import("./chunk-e10c0crf.js").then(($)=>$.createOpenaiCompatible),"venice-ai-sdk-provider":()=>import("./chunk-e72jwbfc.js").then(($)=>$.createVenice)};function Ml($){return $.responses===void 0&&$.chat===void 0}function Xq0($){let Z=/^gpt-(\d+)/.exec($);if(!Z)return!1;return Number(Z[1])>=5&&!$.startsWith("gpt-5-mini")}async function Al($,Z,J){if(Ml($))return $.languageModel(Z);if(J?.useCompletionUrls)return $.chat(Z);else return $.responses(Z)}function Ol($,Z){return $.CLOUDFLARE_ACCOUNT_ID||(Z?.type==="api"?Z.metadata?.accountId:void 0)}function Dl($){return{qlex:T.fnUntraced(function*(){return{autoload:!0,options:{getToken:jl,onInvalidCredentials:async()=>{if(process.env.QITQODE_KEY)VY.error(SA),console.error(SA);try{await Nl()}catch{}}},async getModel(Y,X){return Y.languageModel(X)}}}),anthropic:()=>T.succeed({autoload:!1,options:{headers:{"anthropic-beta":"interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"}}}),opencode:T.fnUntraced(function*(Z){let J=yield*$.env(),X=d$(()=>{if(Z.env.some((Q)=>J[Q]))return!0;return!1})||Boolean(yield*$.auth(Z.id))||Boolean((yield*$.config()).provider?.opencode?.options?.apiKey);for(let[Q,G]of Object.entries(Z.models))if(!X||G.cost.input===0)delete Z.models[Q];return{autoload:Object.keys(Z.models).length>0,options:{}}}),openai:()=>T.succeed({autoload:!1,async getModel(Z,J,Y){return Z.responses(J)},options:{}}),xai:()=>T.succeed({autoload:!1,async getModel(Z,J,Y){return Z.responses(J)},options:{}}),"github-copilot":()=>T.succeed({autoload:!1,async getModel(Z,J,Y){if(Ml(Z))return Z.languageModel(J);return Xq0(J)?Z.responses(J):Z.chat(J)},options:{}}),azure:T.fnUntraced(function*(Z){let J=yield*$.env(),Y=d$(()=>{let X=Z.options?.resourceName;if(typeof X==="string"&&X.trim()!=="")return X;return J.AZURE_RESOURCE_NAME});return{autoload:!1,getModel:Al,options:{},vars(X){return{...Y&&{AZURE_RESOURCE_NAME:Y}}}}}),"azure-cognitive-services":T.fnUntraced(function*(){let Z=yield*$.get("AZURE_COGNITIVE_SERVICES_RESOURCE_NAME");return{autoload:!1,getModel:Al,options:{baseURL:Z?`https://${Z}.cognitiveservices.azure.com/openai`:void 0}}}),"amazon-bedrock":T.fnUntraced(function*(){let Z=(yield*$.config()).provider?.["amazon-bedrock"],J=yield*$.auth("amazon-bedrock"),Y=yield*$.env(),X=Z?.options?.region,Q=Y.AWS_REGION,G=X??Q??"us-east-1",W=Z?.options?.profile,K=Y.AWS_PROFILE,V=W??K,U=Y.AWS_ACCESS_KEY_ID,H=d$(()=>{let q=CK.get("AWS_BEARER_TOKEN_BEDROCK");if(q)return q;if(J?.type==="api")return CK.set("AWS_BEARER_TOKEN_BEDROCK",J.key),process.env.AWS_BEARER_TOKEN_BEDROCK=J.key,J.key;return}),B=Y.AWS_WEB_IDENTITY_TOKEN_FILE,z=Boolean(process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI||process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI);if(!V&&!U&&!H&&!B&&!z)return{autoload:!1};let{fromNodeProviderChain:F}=yield*T.promise(()=>import("./chunk-v16n1fep.js")),A={region:G};if(!H){let q=V?{profile:V}:{};A.credentialProvider=F(q)}let N=Z?.options?.endpoint??Z?.options?.baseURL;if(N)A.baseURL=N;return{autoload:!0,options:A,async getModel(q,w,j){if(["global.","us.","eu.","jp.","apac.","au."].some((L)=>w.startsWith(L)))return q.languageModel(w);let I=j?.region??G,R=I.split("-")[0];switch(R){case"us":{let L=["nova-micro","nova-lite","nova-pro","nova-premier","nova-2","claude","deepseek"].some((_)=>w.includes(_)),C=I.startsWith("us-gov");if(L&&!C)w=`${R}.${w}`;break}case"eu":{let L=["eu-west-1","eu-west-2","eu-west-3","eu-north-1","eu-central-1","eu-south-1","eu-south-2"].some((_)=>I.includes(_)),C=["claude","nova-lite","nova-micro","llama3","pixtral"].some((_)=>w.includes(_));if(L&&C)w=`${R}.${w}`;break}case"ap":{let L=["ap-southeast-2","ap-southeast-4"].includes(I),C=I==="ap-northeast-1";if(L&&["anthropic.claude-sonnet-4-5","anthropic.claude-haiku"].some((_)=>w.includes(_)))R="au",w=`${R}.${w}`;else if(C){if(["claude","nova-lite","nova-micro","nova-pro"].some((E)=>w.includes(E)))R="jp",w=`${R}.${w}`}else if(["claude","nova-lite","nova-micro","nova-pro"].some((E)=>w.includes(E)))R="apac",w=`${R}.${w}`;break}}return q.languageModel(w)}}}),llmgateway:()=>T.succeed({autoload:!1,options:{headers:{"X-Source":"qitqode"}}}),openrouter:()=>T.succeed({autoload:!1,options:{headers:{"X-OpenRouter-Categories":"programming,programming-app,cli-agent"}}}),nvidia:()=>T.succeed({autoload:!1,options:{}}),vercel:()=>T.succeed({autoload:!1,options:{}}),"google-vertex":T.fnUntraced(function*(Z){let J=yield*$.env(),Y=Z.options?.project??J.GOOGLE_CLOUD_PROJECT??J.GCP_PROJECT??J.GCLOUD_PROJECT,X=String(Z.options?.location??J.GOOGLE_VERTEX_LOCATION??J.GOOGLE_CLOUD_LOCATION??J.VERTEX_LOCATION??"us-central1");if(!Boolean(Y))return{autoload:!1};return{autoload:!0,vars(G){let W=X==="global"?"aiplatform.googleapis.com":`${X}-aiplatform.googleapis.com`;return{...Y&&{GOOGLE_VERTEX_PROJECT:Y},GOOGLE_VERTEX_LOCATION:X,GOOGLE_VERTEX_ENDPOINT:W}},options:{project:Y,location:X,fetch:async(G,W)=>{let{GoogleAuth:K}=await import("./chunk-9s4excg8.js").then((m)=>m6(m.default,1)),H=await(await new K().getApplicationDefault()).credential.getAccessToken(),B=new Headers(W?.headers);return B.set("Authorization",`Bearer ${H.token}`),fetch(G,{...W,headers:B})}},async getModel(G,W){let K=String(W).trim();return G.languageModel(K)}}}),"google-vertex-anthropic":T.fnUntraced(function*(){let Z=yield*$.env(),J=Z.GOOGLE_CLOUD_PROJECT??Z.GCP_PROJECT??Z.GCLOUD_PROJECT,Y=Z.GOOGLE_CLOUD_LOCATION??Z.VERTEX_LOCATION??"global";if(!Boolean(J))return{autoload:!1};return{autoload:!0,options:{project:J,location:Y},async getModel(Q,G){let W=String(G).trim();return Q.languageModel(W)}}}),"sap-ai-core":T.fnUntraced(function*(){let Z=yield*$.auth("sap-ai-core"),J=d$(()=>{let Q=CK.get("AICORE_SERVICE_KEY");if(Q)return Q;if(Z?.type==="api")return CK.set("AICORE_SERVICE_KEY",Z.key),process.env.AICORE_SERVICE_KEY=Z.key,Z.key;return}),Y=process.env.AICORE_DEPLOYMENT_ID,X=process.env.AICORE_RESOURCE_GROUP;return{autoload:!!J,options:J?{deploymentId:Y,resourceGroup:X}:{},async getModel(Q,G){return Q(G)}}}),zenmux:()=>T.succeed({autoload:!1,options:{}}),gitlab:T.fnUntraced(function*(Z){let{VERSION:J,isWorkflowModel:Y,discoverWorkflowModels:X}=yield*T.promise(()=>import("./chunk-ev6jwt7q.js")),Q=(yield*$.get("GITLAB_INSTANCE_URL"))||"https://gitlab.com",G=yield*$.auth(Z.id),W=yield*T.sync(()=>{if(G?.type==="oauth")return G.access;if(G?.type==="api")return G.key;return}),K=W??(yield*$.get("GITLAB_TOKEN")),V=(yield*$.config()).provider?.gitlab,U=yield*B0.directory,H={"User-Agent":`qitqode/${b$} gitlab-ai-provider/${J} (${OZ.platform()} ${OZ.release()}; ${OZ.arch()})`,"anthropic-beta":"context-1m-2025-08-07",...V?.options?.aiGatewayHeaders},B={duo_agent_platform_agentic_chat:!0,duo_agent_platform:!0,...V?.options?.featureFlags};return{autoload:!!K,options:{instanceUrl:Q,apiKey:K,aiGatewayHeaders:H,featureFlags:B},async getModel(z,F,A){if(F.startsWith("duo-workflow-")){let N=typeof A?.workflowRef==="string"?A.workflowRef:void 0,q=Y(F)?F:"duo-workflow",w=typeof A?.workflowDefinition==="string"?A.workflowDefinition:void 0,j=z.workflowChat(q,{featureFlags:B,workflowDefinition:w});if(N)j.selectedModelRef=N;return j}return z.agenticChat(F,{aiGatewayHeaders:H,featureFlags:B})},async discoverModels(){if(!W)return VY.info("gitlab model discovery skipped: no apiKey"),{};try{let z=W,F=()=>G?.type==="api"?{"PRIVATE-TOKEN":z}:{Authorization:`Bearer ${z}`};VY.info("gitlab model discovery starting",{instanceUrl:Q});let A=await X({instanceUrl:Q,getHeaders:F},{workingDirectory:U});if(!A.models.length)return VY.info("gitlab model discovery skipped: no models found",{project:A.project?{id:A.project.id,path:A.project.pathWithNamespace}:null}),{};let N={};for(let q of A.models)if(!Z.models[q.id])N[q.id]={id:a1.make(q.id),providerID:r0.make("gitlab"),name:`Agent Platform (${q.name})`,family:"",api:{id:q.id,url:Q,npm:"gitlab-ai-provider"},status:"active",headers:{},options:{workflowRef:q.ref},cost:{input:0,output:0,cache:{read:0,write:0}},limit:{context:q.context,output:q.output},capabilities:{temperature:!1,reasoning:!0,attachment:!0,toolcall:!0,input:{text:!0,audio:!1,image:!0,video:!1,pdf:!0},output:{text:!0,audio:!1,image:!1,video:!1,pdf:!1},interleaved:!1},release_date:"",variants:{}};return VY.info("gitlab model discovery complete",{count:Object.keys(N).length,models:Object.keys(N)}),N}catch(z){return VY.warn("gitlab model discovery failed",{error:z}),{}}}}}),"cloudflare-workers-ai":T.fnUntraced(function*(Z){if(Z.options?.baseURL)return{autoload:!1};let J=yield*$.auth(Z.id),Y=yield*$.env(),X=Ol(Y,J);if(!X)return{autoload:!1,async getModel(){throw Error("CLOUDFLARE_ACCOUNT_ID is missing. Set it with: export CLOUDFLARE_ACCOUNT_ID=<your-account-id>")}};let Q=yield*T.gen(function*(){let G=Y.CLOUDFLARE_API_KEY;if(G)return G;if(J?.type==="api")return J.key;return});return{autoload:!!Q,options:{apiKey:Q,headers:{"User-Agent":`qitqode/${b$} cloudflare-workers-ai (${OZ.platform()} ${OZ.release()}; ${OZ.arch()})`}},async getModel(G,W){return G.languageModel(W)},vars(G){return{CLOUDFLARE_ACCOUNT_ID:X}}}}),"cloudflare-ai-gateway":T.fnUntraced(function*(Z){if(Z.options?.baseURL)return{autoload:!1};let J=yield*$.auth(Z.id),Y=yield*$.env(),X=Ol(Y,J),Q=Y.CLOUDFLARE_GATEWAY_ID||(J?.type==="api"?J.metadata?.gatewayId:void 0);if(!X||!Q){let z=[!X?"CLOUDFLARE_ACCOUNT_ID":void 0,!Q?"CLOUDFLARE_GATEWAY_ID":void 0].filter((F)=>Boolean(F));return{autoload:!1,async getModel(){throw Error(`${z.join(" and ")} missing. Set with: ${z.map((F)=>`export ${F}=<value>`).join(" && ")}`)}}}let G=yield*T.gen(function*(){let z=Y.CLOUDFLARE_API_TOKEN||Y.CF_AIG_TOKEN;if(z)return z;if(J?.type==="api")return J.key;return});if(!G)throw Error("CLOUDFLARE_API_TOKEN (or CF_AIG_TOKEN) is required for Cloudflare AI Gateway. Set it via environment variable or run `qitqode auth cloudflare-ai-gateway`.");let{createAiGateway:W}=yield*T.promise(()=>import("./chunk-nqk8d62j.js")),{createUnified:K}=yield*T.promise(()=>import("./chunk-pv9ty6v7.js")),U={metadata:d$(()=>{if(Z.options?.metadata)return Z.options.metadata;try{return JSON.parse(Z.options?.headers?.["cf-aig-metadata"])}catch{return}}),cacheTtl:Z.options?.cacheTtl,cacheKey:Z.options?.cacheKey,skipCache:Z.options?.skipCache,collectLog:Z.options?.collectLog,headers:{"User-Agent":`qitqode/${b$} cloudflare-ai-gateway (${OZ.platform()} ${OZ.release()}; ${OZ.arch()})`}},H=W({accountId:X,gateway:Q,apiKey:G,...Object.values(U).some((z)=>z!==void 0)?{options:U}:{}}),B=K();return{autoload:!0,async getModel(z,F,A){return H(B(F))},options:{}}}),cerebras:()=>T.succeed({autoload:!1,options:{headers:{"X-Cerebras-3rd-Party-Integration":"qitqode"}}}),kilo:()=>T.succeed({autoload:!1,options:{}})}}import{pathToFileURL as Qq0}from"url";var fA=_0.create({service:"provider.sdk-runtime"});async function wl($,Z,J){try{let Y=[];try{const W=IK(Y,fA.time("getSDK",{providerID:$.providerID}),0);let K=Z.providers[$.providerID];let V={...K.options};if($.providerID==="google-vertex"&&!$.api.npm.includes("@ai-sdk/openai-compatible"))delete V.fetch;if($.api.npm.includes("@ai-sdk/openai-compatible")&&V.includeUsage!==!1)V.includeUsage=!0;let U=d$(()=>{let R=typeof V.baseURL==="string"&&V.baseURL!==""?V.baseURL:$.api.url;if(!R)return;let L=Z.varsLoaders[$.providerID];if(L){let C=L(V);for(let[_,E]of Object.entries(C)){let f="${"+_+"}";R=R.replaceAll(f,E)}}return R});if(U!==void 0)V.baseURL=U;if(V.apiKey===void 0&&typeof K.key==="string")V.apiKey=K.key;if($.headers)V.headers={...V.headers,...$.headers};let H=V.fetch;delete V.fetch;let B=V4.fast(JSON.stringify({providerID:$.providerID,npm:$.api.npm,options:V}));let z=Z.sdk.get(B);if(z)return z;let F=V.chunkTimeout;let A=typeof F==="number"?F:PK;delete V.chunkTimeout;V.fetch=async(R,L)=>{let C=H??fetch,_=L??{},E=typeof A==="number"&&A>0?new AbortController:void 0,f=[];if(_.signal)f.push(_.signal);if(E)f.push(E.signal);if(V.timeout!==void 0&&V.timeout!==null&&V.timeout!==!1)f.push(AbortSignal.timeout(V.timeout));let b=f.length===0?null:f.length===1?f[0]:AbortSignal.any(f);if(b)_.signal=b;if($.api.npm==="@ai-sdk/openai"&&_.body&&_.method==="POST"){let u=JSON.parse(_.body);if(!($.providerID.includes("azure")&&u.store===!0)&&Array.isArray(u.input)){for(let c of u.input)if("id"in c)delete c.id;_.body=JSON.stringify(u)}}let k=await C(R,{..._,timeout:!1});if(!E)return k;return Fl(k,A,E)};let N=ql[$.api.npm];if(N){fA.info("using bundled provider",{providerID:$.providerID,pkg:$.api.npm});let L=(await N())({name:$.providerID,...V});return Z.sdk.set(B,L),L}let q;if(!$.api.npm.startsWith("file://")){let R=await j6.add($.api.npm);if(!R.entrypoint)throw Error(`Package ${$.api.npm} has no import entrypoint`);q=R.entrypoint}else fA.info("loading local provider",{pkg:$.api.npm}),q=$.api.npm;let w=q.startsWith("file://")?q:Qq0(q).href;let j=await import(w);let M=j[Object.keys(j).find((R)=>R.startsWith("create"))];let I=M({name:$.providerID,...V});Z.sdk.set(B,I);return I}catch(X){var Q=X,G=1}finally{EK(Y,Q,G)}}catch(W){throw new TK({providerID:$.providerID},{cause:W})}}function Ll($){let Z={};function J(Y,X){let Q=Z[Y];if(Q){Z[Y]=q1(Q,X);return}let G=$[Y];if(!G)return;Z[Y]=q1(G,X)}return{database:$,providers:Z,mergeProvider:J}}function Tl($){if($.enabled&&!$.enabled.has($.providerID))return!1;if($.disabled.has($.providerID))return!1;return!0}function Rl($,Z){let J=$.env.map((Y)=>Z[Y]).find(Boolean);if(!J)return;return{source:"env",key:$.env.length===1?J:void 0}}function Pl($){if($.type!=="api")return;return{source:"api",key:$.key}}function kA($){return $.hasProvider?{options:$.options??{}}:{source:"custom",options:$.options??{}}}var Gq0=_0.create({service:"provider.discovery.filter"});function Cl($){for(let[Z,J]of Object.entries($.providers)){let Y=r0.make(Z);if(!$.isAllowed(Y)){delete $.providers[Y];continue}let X=$.overrides[Y];for(let[Q,G]of Object.entries(J.models)){if(G.api.id=G.api.id??G.id??Q,Q==="gpt-5-chat-latest"||Y===r0.openrouter&&Q==="openai/gpt-5-chat")delete J.models[Q];if(G.status==="alpha"&&!$.experimentalModels)delete J.models[Q];if(G.status==="deprecated")delete J.models[Q];if(Y===r0.make("qlex")&&(h1.isDecisionTier(Q)||h1.isDecisionTier(G.api.id)))delete J.models[Q];if(X?.blacklist&&X.blacklist.includes(Q)||X?.whitelist&&!X.whitelist.includes(Q))delete J.models[Q];G.variants=v6(W5(G),(K)=>K);let W=X?.models?.[Q]?.variants;if(W&&G.variants){let K=q1(G.variants,W);G.variants=v6(bK(K,(V)=>!V.disabled),(V)=>_K(V,["disabled"]))}}if(Object.keys(J.models).length===0){delete $.providers[Y];continue}Gq0.info("found",{providerID:Y})}return $.providers}var Wq0=_0.create({service:"provider.discovery.config"});function Il($){for(let[Z,J]of $.configProviders){let Y=$.database[Z],X={id:r0.make(Z),name:J.name??Y?.name??Z,env:J.env??Y?.env??[],options:q1(Y?.options??{},J.options??{}),source:"config",models:Y?.models??{}};for(let[Q,G]of Object.entries(J.models??{})){let W=X.models[G.id??Q],K=G.id??W?.api.id??Q,V=G.provider?.npm??J.npm??W?.api.npm??$.modelsDev[Z]?.npm??"@ai-sdk/openai-compatible",U=d$(()=>{if(G.name)return G.name;if(G.id&&G.id!==Q)return Q;return W?.name??Q}),H={id:a1.make(Q),api:{id:K,npm:V,url:G.provider?.api??J?.api??W?.api.url??$.modelsDev[Z]?.api??""},status:G.status??W?.status??"active",name:U,providerID:r0.make(Z),capabilities:{temperature:G.temperature??W?.capabilities.temperature??!1,reasoning:G.reasoning??W?.capabilities.reasoning??!1,attachment:G.attachment??W?.capabilities.attachment??!1,toolcall:G.tool_call??W?.capabilities.toolcall??!0,input:{text:G.modalities?.input?.includes("text")??W?.capabilities.input.text??!0,audio:G.modalities?.input?.includes("audio")??W?.capabilities.input.audio??!1,image:G.modalities?.input?.includes("image")??W?.capabilities.input.image??!1,video:G.modalities?.input?.includes("video")??W?.capabilities.input.video??!1,pdf:G.modalities?.input?.includes("pdf")??W?.capabilities.input.pdf??!1},output:{text:G.modalities?.output?.includes("text")??W?.capabilities.output.text??!0,audio:G.modalities?.output?.includes("audio")??W?.capabilities.output.audio??!1,image:G.modalities?.output?.includes("image")??W?.capabilities.output.image??!1,video:G.modalities?.output?.includes("video")??W?.capabilities.output.video??!1,pdf:G.modalities?.output?.includes("pdf")??W?.capabilities.output.pdf??!1},interleaved:G.interleaved??W?.capabilities.interleaved??(!W&&V==="@ai-sdk/openai-compatible"&&K.includes("deepseek")?{field:"reasoning_content"}:!1)},cost:{input:G?.cost?.input??W?.cost?.input??0,output:G?.cost?.output??W?.cost?.output??0,cache:{read:G?.cost?.cache_read??W?.cost?.cache.read??0,write:G?.cost?.cache_write??W?.cost?.cache.write??0}},options:q1(W?.options??{},G.options??{}),limit:{context:(()=>{let z=G.limit?.context??W?.limit?.context;if(z!==void 0)return z;let F=`${Z}/${Q}`;if(!_A.has(F))_A.add(F),Wq0.warn("limit.context not configured and not found in models.dev",{providerID:Z,modelID:Q,defaulting_to:bA,fix:`Set limit.context explicitly in qitqode.json under provider.${Z}.models.${Q}`});return bA})(),input:G.limit?.input??W?.limit?.input,output:G.limit?.output??W?.limit?.output??0},headers:q1(W?.headers??{},G.headers??{}),family:G.family??W?.family??"",release_date:G.release_date??W?.release_date??"",cachePromptTTL:G.cachePromptTTL??W?.cachePromptTTL,variants:{}},B=q1(W5(H),G.variants??{});H.variants=v6(bK(B,(z)=>!z.disabled),(z)=>_K(z,["disabled"])),X.models[Q]=H}$.database[Z]=X}}var SK=_0.create({service:"provider.discovery"});function bl($){let{config:Z,auth:J,env:Y,plugin:X}=$;return T.gen(function*(){let E=[];try{const Q=IK(E,SK.time("state"),0);let G=yield*T7.make();let W=yield*Z.get();let K=yield*T.promise(()=>El());let V=v6(K,wK);V[QQ.id]=QQ;let U=Ll(V);let{providers:H,mergeProvider:B}=U;let z=new Map;let F={};let A={};let N=new Map;let q={};let w={auth:(u)=>J.get(u).pipe(T.orDie),config:()=>Z.get(),env:()=>Y.all(),get:(u)=>Y.get(u)};SK.info("init");let j=yield*X.list();let M=Object.entries(W.provider??{});let I=new Set(W.disabled_providers??[]);let R=W.enabled_providers?new Set(W.enabled_providers):null;let L=(u)=>Tl({providerID:u,enabled:R,disabled:I});Il({database:V,modelsDev:K,configProviders:M});if(!S0.QITQODE_DISABLE_PROVIDER_ENV){let u=yield*Y.all();for(let[x,g]of Object.entries(V)){let c=r0.make(x);if(I.has(c))continue;let e=Rl(g,u);if(e)B(c,e)}}let C=yield*J.all().pipe(T.orDie);for(let[u,x]of Object.entries(C)){let g=r0.make(u);if(I.has(g))continue;let c=Pl(x);if(c)B(g,c)}for(let u of j){if(!u.auth)continue;let x=r0.make(u.auth.provider);if(I.has(x))continue;if(!(yield*J.get(x).pipe(T.orDie)))continue;if(!u.auth.loader)continue;let e=(yield*T.promise(()=>u.auth.loader(()=>G.promise(J.get(x).pipe(T.orDie)),V[u.auth.provider])))??{};B(x,kA({options:e,hasProvider:Boolean(H[x])}))}for(let[u,x]of Object.entries(Dl(w))){let g=r0.make(u);if(I.has(g))continue;let c=V[g];if(!c){SK.error("Provider does not exist in model list "+g);continue}let e=yield*x(c);if(e&&(e.autoload||H[g])){if(e.getModel)F[g]=e.getModel;if(e.vars)A[g]=e.vars;if(e.discoverModels)q[g]=e.discoverModels;let G0=e.options??{};B(g,kA({options:G0,hasProvider:Boolean(H[g])}))}}for(let[u,x]of M){let g=r0.make(u),c={source:"config"};if(x.env)c.env=x.env;if(x.name)c.name=x.name;if(x.options)c.options=x.options;B(g,c)}let _=r0.make("gitlab");if(q[_]&&H[_]&&L(_))yield*T.promise(async()=>{try{let u=await q[_]();for(let[x,g]of Object.entries(u))if(!H[_].models[x])H[_].models[x]=g}catch(u){SK.warn("state discovery error",{id:"gitlab",error:u})}});for(let u of j){let x=u.provider,g=x?.models;if(!x||!g)continue;let c=r0.make(x.id);if(I.has(c))continue;let e=H[c];if(!e)continue;let G0=yield*J.get(c).pipe(T.orDie);e.models=yield*T.promise(async()=>{let Q0=await g(e,{auth:G0});return Object.fromEntries(Object.entries(Q0).map(([z0,u0])=>[z0,{...u0,id:a1.make(z0),providerID:c}]))})}Cl({providers:H,overrides:W.provider??{},isAllowed:L,experimentalModels:S0.QITQODE_ENABLE_EXPERIMENTAL_MODELS});return{models:z,providers:H,sdk:N,modelLoaders:F,varsLoaders:A}}catch(f){var b=f,k=1}finally{EK(E,b,k)}})}var Vq0=O.Struct({id:O.String,url:O.String,npm:O.String}),_l=O.Struct({text:O.Boolean,audio:O.Boolean,image:O.Boolean,video:O.Boolean,pdf:O.Boolean}),Uq0=O.Union([O.Boolean,O.Struct({field:O.Literals(["reasoning_content","reasoning_details"])})]),Hq0=O.Struct({temperature:O.Boolean,reasoning:O.Boolean,attachment:O.Boolean,toolcall:O.Boolean,input:_l,output:_l,interleaved:Uq0}),Sl=O.Struct({read:O.Number,write:O.Number}),Bq0=O.Struct({input:O.Number,output:O.Number,cache:Sl,experimentalOver200K:O.optional(O.Struct({input:O.Number,output:O.Number,cache:Sl}))}),zq0=O.Struct({context:O.Number,input:O.optional(O.Number),output:O.Number}),vA=O.Struct({id:a1,providerID:r0,api:Vq0,name:O.String,family:O.optional(O.String),capabilities:Hq0,cost:Bq0,limit:zq0,status:O.Literals(["alpha","beta","deprecated","active"]),options:O.Record(O.String,O.Any),headers:O.Record(O.String,O.String),release_date:O.String,variants:O.optional(O.Record(O.String,O.Record(O.String,O.Any))),cacheTTL:O.optional(O.Number),cachePromptTTL:O.optional(O.Literals(["5m","1h"]))}).annotate({identifier:"Model"}).pipe(g0(($)=>({zod:w0($)}))),fK=O.Struct({id:r0,name:O.String,source:O.Literals(["env","config","custom","api"]),env:O.Array(O.String),key:O.optional(O.String),options:O.Record(O.String,O.Any),models:O.Record(O.String,vA)}).annotate({identifier:"Provider"}).pipe(g0(($)=>({zod:w0($)}))),fl=O.Record(O.String,O.String),kl=O.Struct({all:O.Array(fK),default:fl,connected:O.Array(O.String)}).pipe(g0(($)=>({zod:w0($)}))),vl=O.Struct({providers:O.Array(fK),default:fl}).pipe(g0(($)=>({zod:w0($)})));async function hl($=xl){return h1.loadLiveRatings($)}function gl($){h1.mergeLiveTierRatings($)}class kK extends S1.Service()("@qitqode/Provider"){}var Aq0=R0.effect(kK,T.gen(function*(){let $=yield*w$.Service,Z=yield*Q8.Service,J=yield*k8.Service,Y=yield*l6.Service,X=yield*AZ.Service;h1.beginTierRatingsLoad();let[Q,G]=yield*T.promise(()=>Promise.all([yl(),hl()]));h1.mergeLiveTiers(Q),gl(G),Ul();let W=yield*B0.make(()=>bl({config:Z,auth:J,env:Y,plugin:X})),K=T.fn("Provider.list")(()=>B0.use(W,(q)=>q.providers)),V=zl({getState:()=>B0.get(W),config:Z,readRecent:()=>$.readJson(Fq0.join(A0.Path.state,"model.json"))}),{getProvider:U,getModel:H,closest:B,getSmallModel:z,defaultModel:F,resolveModelRef:A}=V,N=T.fn("Provider.getLanguage")(function*(q){let w=yield*B0.get(W),j=yield*Y.all(),M=`${q.providerID}/${q.id}`;if(w.models.has(M))return w.models.get(M);return yield*T.promise(async()=>{let I=w.providers[q.providerID],R=await wl(q,w,j);try{let L=w.modelLoaders[q.providerID]?await w.modelLoaders[q.providerID](R,q.api.id,{...I.options,...q.options}):R.languageModel(q.api.id);return w.models.set(M,L),L}catch(L){if(L instanceof XH)throw new KY({modelID:q.id,providerID:q.providerID},{cause:L});throw L}})});return kK.of({list:K,getProvider:U,getModel:H,getLanguage:N,closest:B,getSmallModel:z,defaultModel:F,resolveModelRef:A})})),Oq0=R0.suspend(()=>Aq0.pipe(R0.provide(w$.defaultLayer),R0.provide(l6.defaultLayer),R0.provide(Q8.defaultLayer),R0.provide(k8.defaultLayer),R0.provide(AZ.defaultLayer)));var rl={};F1(rl,{layer:()=>sl,defaultLayer:()=>Lq0,ValidationFailed:()=>ol,Service:()=>vK,OauthMissing:()=>cl,OauthCodeMissing:()=>il,OauthCallbackFailed:()=>nl,Methods:()=>dl,Method:()=>yA,CallbackInput:()=>wq0,AuthorizeInput:()=>Dq0,Authorization:()=>pl});var ll=O.Struct({key:O.String,op:O.Literals(["eq","neq"]),value:O.String}),jq0=O.Struct({type:O.Literal("text"),key:O.String,message:O.String,placeholder:O.optional(O.String),when:O.optional(ll)}),Nq0=O.Struct({label:O.String,value:O.String,hint:O.optional(O.String)}),qq0=O.Struct({type:O.Literal("select"),key:O.String,message:O.String,options:O.Array(Nq0),when:O.optional(ll)}),Mq0=O.Union([jq0,qq0]);class yA extends O.Class("ProviderAuthMethod")({type:O.Literals(["oauth","api"]),label:O.String,prompts:O.optional(O.Array(Mq0))}){static zod=w0(this)}var dl=O.Record(O.String,O.Array(yA)).pipe(g0(($)=>({zod:w0($)})));class pl extends O.Class("ProviderAuthAuthorization")({url:O.String,method:O.Literals(["auto","code"]),instructions:O.String}){static zod=w0(this)}var Dq0=O.Struct({method:O.Number.annotate({description:"Auth method index"}),inputs:O.optional(O.Record(O.String,O.String)).annotate({description:"Prompt inputs"})}).pipe(g0(($)=>({zod:w0($)}))),wq0=O.Struct({method:O.Number.annotate({description:"Auth method index"}),code:O.optional(O.String).annotate({description:"OAuth authorization code"})}).pipe(g0(($)=>({zod:w0($)}))),cl=N1.create("ProviderAuthOauthMissing",P.object({providerID:r0.zod})),il=N1.create("ProviderAuthOauthCodeMissing",P.object({providerID:r0.zod})),nl=N1.create("ProviderAuthOauthCallbackFailed",P.object({})),ol=N1.create("ProviderAuthValidationFailed",P.object({field:P.string(),message:P.string()}));class vK extends S1.Service()("@qitqode/ProviderAuth"){}var sl=R0.effect(vK,T.gen(function*(){let $=yield*k8.Service,Z=yield*AZ.Service,J=yield*B0.make(T.fn("ProviderAuth.state")(function*(){let W=yield*Z.list();return{hooks:y7.fromEntries(ml.filterMap(W,(K)=>K.auth?.provider!==void 0?v7.succeed([r0.make(K.auth.provider),K.auth]):v7.failVoid)),pending:new Map}})),Y=O.decodeUnknownSync(dl),X=T.fn("ProviderAuth.methods")(function*(){let W=(yield*B0.get(J)).hooks;return Y(y7.map(W,(K)=>K.methods.map((V)=>({type:V.type,label:V.label,prompts:V.prompts?.map((U)=>{if(U.type==="select")return{type:"select",key:U.key,message:U.message,options:U.options,when:U.when};return{type:"text",key:U.key,message:U.message,placeholder:U.placeholder,when:U.when}})}))))}),Q=T.fn("ProviderAuth.authorize")(function*(W){let{hooks:K,pending:V}=yield*B0.get(J),U=K[W.providerID].methods[W.method];if(U.type!=="oauth")return;if(U.prompts&&W.inputs){for(let B of U.prompts)if(B.type==="text"&&B.validate&&W.inputs[B.key]!==void 0){let z=B.validate(W.inputs[B.key]);if(z)return yield*T.fail(new ol({field:B.key,message:z}))}}let H=yield*T.promise(()=>U.authorize(W.inputs));return V.set(W.providerID,H),{url:H.url,method:H.method,instructions:H.instructions}}),G=T.fn("ProviderAuth.callback")(function*(W){let V=(yield*B0.get(J)).pending.get(W.providerID);if(!V)return yield*T.fail(new cl({providerID:W.providerID}));if(V.method==="code"&&!W.code)return yield*T.fail(new il({providerID:W.providerID}));let U=yield*T.promise(()=>V.method==="code"?V.callback(W.code):V.callback(W.code));if(!U||U.type!=="success")return yield*T.fail(new nl({}));if("key"in U)yield*$.set(W.providerID,{type:"api",key:U.key,..."metadata"in U&&U.metadata?{metadata:U.metadata}:{}});if("refresh"in U){let{type:H,provider:B,refresh:z,access:F,expires:A,...N}=U;yield*$.set(W.providerID,{type:"oauth",access:F,refresh:z,expires:A,...N})}});return vK.of({methods:X,authorize:Q,callback:G})})),Lq0=R0.suspend(()=>sl.pipe(R0.provide(k8.defaultLayer),R0.provide(AZ.defaultLayer)));var WQ={};F1(WQ,{parseStreamError:()=>bq0,parseAPICallError:()=>_q0});import{STATUS_CODES as al}from"http";var Tq0=[/prompt is too long/i,/input is too long for requested model/i,/exceeds the context window/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/context[_ ]length[_ ]exceeded/i,/request entity too large/i,/context length is only \d+ tokens/i,/input length.*exceeds.*context length/i,/prompt too long; exceeded (?:max )?context length/i,/too large for model with \d+ maximum context length/i,/model_context_window_exceeded/i];function Rq0($){let Z=$.statusCode;if(!Z)return $.isRetryable;return Z===404||$.isRetryable}function Pq0($){if(Tq0.some((Z)=>Z.test($)))return!0;return/^4(00|13)\s*(status code)?\s*\(no body\)/i.test($)}function Cq0($){if($.retryable===!0)return!0;if($.retryable===!1)return!1;return}function Iq0($){if(!$||!/^\s*[\[{]/.test($))return!1;try{return JSON.parse($),!1}catch(Z){let J=0,Y=!1,X=!1;for(let Q of $){if(Y){if(X)X=!1;else if(Q==="\\")X=!0;else if(Q==='"')Y=!1;continue}if(Q==='"')Y=!0;else if(Q==="{"||Q==="[")J++;else if(Q==="}"||Q==="]")J--;if(J<0)return!1}return Y||J>0||/unexpected end|end of json|unterminated string/i.test(String(Z))}}function Eq0($,Z){return d$(()=>{let J=Z.message;if(J===""){if(Z.responseBody)return Z.responseBody;if(Z.statusCode){let X=al[Z.statusCode];if(X)return X}return"Unknown error"}if(!Z.responseBody||Z.statusCode&&J!==al[Z.statusCode])return J;try{let X=JSON.parse(Z.responseBody),Q=X.message||X.detail||X.error?.message||X.error;if(Q&&typeof Q==="string")return`${J}: ${Q.slice(0,300)}`;if(Array.isArray(Q)&&Q.length>0){let G=Q[0],W=typeof G?.msg==="string"?G.msg:typeof G?.message==="string"?G.message:typeof G==="string"?G:void 0;if(W)return`${J}: ${W.slice(0,300)}`}}catch{}if(/^\s*<!doctype|^\s*<html/i.test(Z.responseBody)){if(Z.statusCode===401)return"Unauthorized: request was blocked by a gateway or proxy. Your authentication token may be missing or expired \u2014 try running `qitqode auth login <your provider URL>` to re-authenticate.";if(Z.statusCode===403)return"Forbidden: request was blocked by a gateway or proxy. You may not have permission to access this resource \u2014 check your account and provider settings.";return J}let Y=Z.responseBody.length>300?Z.responseBody.slice(0,300)+"\u2026":Z.responseBody;return`${J}: ${Y}`}).trim()}function Zd($){if(typeof $==="string")try{let Z=JSON.parse($);if(Z&&typeof Z==="object")return Z;return}catch{return}if(typeof $==="object"&&$!==null)return $;return}function bq0($){let Z=Zd($);if(!Z)return;let J=JSON.stringify(Z);if(Z.type!=="error")return;switch(Z?.error?.code){case"context_length_exceeded":return{type:"context_overflow",message:"Input exceeds context window of this model",responseBody:J};case"insufficient_quota":return{type:"api_error",message:"Quota exceeded. Check your plan and billing details.",isRetryable:!1,responseBody:J};case"usage_not_included":return{type:"api_error",message:"To use Codex with your ChatGPT plan, upgrade to Plus: https://chatgpt.com/explore/plus.",isRetryable:!1,responseBody:J};case"invalid_prompt":return{type:"api_error",message:typeof Z?.error?.message==="string"?Z?.error?.message:"Invalid prompt.",isRetryable:!1,responseBody:J}}}function _q0($){let Z=Eq0($.providerID,$.error),J=Zd($.error.responseBody),Y=Iq0($.error.responseBody),X=$.error.cause,Q=X instanceof el,G=$.providerID==="qlex"?$d($.error.responseBody??""):void 0,W=Cq0($.error),K=W===!1||G?.retryable===!1?!1:W??G?.retryable;if(Pq0(Z)||$.error.statusCode===413||J?.error?.code==="context_length_exceeded")return{type:"context_overflow",message:Z,responseBody:$.error.responseBody};let V=$.error.url?{url:$.error.url}:void 0,U=J,H=$.providerID==="qlex"?G?.requestId:[U?.requestId,U?.error?.requestId,U?.details?.requestId].find((w)=>typeof w==="string"&&w.length>0);if(Q){let w=X,j={...V};if(w.requestId)j.requestId=w.requestId;return{type:"api_error",message:Y?"The model connection ended before the response completed.":Z,statusCode:$.error.statusCode,isRetryable:xA(w.category,K===!1||w.retryable===!1?!1:K??w.retryable),category:w.category,responseHeaders:$.error.responseHeaders,responseBody:$.error.responseBody,metadata:j,requestId:w.requestId??H}}let B=$.error.requestId,z=($.providerID==="qlex"?tl(B):B)??H,F={...V};if(z)F.requestId=z;let A=$.providerID==="qlex"?Y?"stream_truncated":$.error.statusCode===429?"rate_limited":$.error.statusCode!==void 0&&$.error.statusCode>=500?"transient":$.error.statusCode!==void 0&&$.error.statusCode>=400?"request_rejected":void 0:void 0,N=Y?"stream_truncated":A,q=Y||($.providerID.startsWith("openai")?Rq0($.error):$.error.isRetryable);return{type:"api_error",message:Y?"The model connection ended before the response completed.":Z,statusCode:$.error.statusCode,isRetryable:A?xA(A,K):$.providerID==="qlex"?K===!1?!1:q:K??q,category:N,responseHeaders:$.error.responseHeaders,responseBody:$.error.responseBody,metadata:F,requestId:z}}function hA($,Z){switch(!0){case($ instanceof DOMException&&$.name==="AbortError"):return new f5({message:$.message},{cause:$}).toObject();case O4.isInstance($):{let J=$.lastError??$.errors[$.errors.length-1];if(J!==void 0&&J!==$)return hA(J,Z);return new L6({message:$.message,isRetryable:!0},{cause:$}).toObject()}case U4.isInstance($):return $;case YH.isInstance($):return new H4({providerID:Z.providerID,message:$.message},{cause:$}).toObject();case $?.code==="ECONNRESET":return new L6({message:"Connection reset by server",isRetryable:!0,metadata:{code:$.code??"",syscall:$.syscall??"",message:$.message??""}},{cause:$}).toObject();case($ instanceof Error&&$.code==="ZlibError"):if(Z.aborted)return new f5({message:$.message},{cause:$}).toObject();return new L6({message:"Response decompression failed",isRetryable:!0,metadata:{code:$.code,message:$.message}},{cause:$}).toObject();case FX.isInstance($):{let J=WQ.parseAPICallError({providerID:Z.providerID,error:$});if(J.type==="context_overflow")return new GX({message:J.message,responseBody:J.responseBody},{cause:$}).toObject();return new L6({message:J.message,statusCode:J.statusCode,isRetryable:J.isRetryable,category:J.category,outputBudgetRecoveryAvailable:void 0,outputBudgetRecoveryTokens:void 0,diagnostic:UY($),responseHeaders:J.responseHeaders,responseBody:J.responseBody,metadata:J.metadata,requestId:J.requestId},{cause:$}).toObject()}case($ instanceof Error&&(typeof $.status==="number"||typeof $.category==="string"&&typeof $.retryable==="boolean")):{let J=$.status,Y=$.retryable===!0;return new L6({message:V6($),statusCode:J,isRetryable:Y,category:$.category,upstreamCode:$.upstreamCode,requestId:$.requestId,outputBudgetRecoveryAvailable:$.outputBudgetRecoveryAvailable,outputBudgetRecoveryTokens:$.outputBudgetRecoveryTokens,diagnostic:UY($)},{cause:$}).toObject()}case $ instanceof Error:return new N1.Unknown({message:V6($),diagnostic:UY($)},{cause:$}).toObject();default:try{let J=WQ.parseStreamError($);if(J){if(J.type==="context_overflow")return new GX({message:J.message,responseBody:J.responseBody},{cause:$}).toObject();return new L6({message:J.message,isRetryable:J.isRetryable,diagnostic:UY($),responseBody:J.responseBody},{cause:$}).toObject()}}catch{}return new N1.Unknown({message:V6($),diagnostic:UY($)},{cause:$}).toObject()}}var BY={};F1(BY,{layer:()=>Kd,defaultLayer:()=>gq0,Service:()=>yK,ActorRegistry:()=>BY});var _1=g6("actor_registry",{session_id:L1().$type().notNull().references(()=>I1.id,{onDelete:"cascade"}),actor_id:L1().notNull(),mode:L1().$type().notNull(),parent_actor_id:L1(),status:L1().$type().notNull(),last_outcome:L1().$type(),lifecycle:L1().$type().notNull(),agent:L1().notNull(),description:L1().notNull(),context_mode:L1().$type().notNull(),context_watermark:L1().$type(),background:N8({mode:"boolean"}).notNull(),tools:L1({mode:"json"}).$type(),last_turn_time:N8().notNull(),turn_count:N8().notNull().default(0),last_error:L1(),time_completed:N8(),...xY},($)=>[kQ({columns:[$.session_id,$.actor_id]}),KQ("actor_registry_session_agent_idx").on($.session_id,$.agent),KQ("actor_registry_session_parent_idx").on($.session_id,$.parent_actor_id),KQ("actor_registry_status_idx").on($.status),KQ("actor_registry_status_last_turn_idx").on($.status,$.last_turn_time)]);var gA=P.enum(["pending","running","idle"]),uA=P.enum(["success","failure","cancelled"]),Sq0=P.enum(["ephemeral","persistent"]),fq0=P.enum(["none","state","full"]),mA=P.enum(["peer","subagent","main"]),kq0=P.union([P.array(P.string()).readonly(),P.literal("INHERIT")]),zd0=P.object({sessionID:a0.zod,actorID:P.string(),mode:mA,parentActorID:P.string().optional(),status:gA,lastOutcome:uA.optional(),lifecycle:Sq0,agent:P.string(),description:P.string(),contextMode:fq0,contextWatermark:o1.zod.optional(),background:P.boolean(),tools:kq0.optional(),lastTurnTime:P.number(),turnCount:P.number(),lastError:P.string().optional(),time:P.object({created:P.number(),updated:P.number(),completed:P.number().optional()})}).meta({ref:"Actor"});var Jd=T1.define("actor.registered",P.object({sessionID:a0.zod,actorID:P.string(),mode:mA,parentActorID:P.string().optional(),description:P.string(),agent:P.string(),background:P.boolean()})),Yd=T1.define("actor.status",P.object({sessionID:a0.zod,actorID:P.string(),status:gA,lastOutcome:uA.optional(),turnCount:P.number(),lastTurnTime:P.number(),error:P.string().optional()})),Xd=T1.define("actor.stuck",P.object({sessionID:a0.zod,actorID:P.string(),description:P.string(),lastTurnTime:P.number(),stuckDuration:P.number()})),qd0=T1.define("writer.cache_perf",P.object({sessionID:a0.zod,writerActorID:P.string(),status:P.enum(["completed","failed"]),total_input_tokens:P.number(),cache_read_tokens:P.number(),cache_write_tokens:P.number(),cache_hit_rate:P.number(),num_llm_calls:P.number()})),Md0=T1.define("inbox.arrived",P.object({receiverSessionID:a0.zod,receiverActorID:P.string(),senderSessionID:a0.zod.optional(),senderActorID:P.string().optional(),inboxID:P.string(),type:P.string()}));var Qd=new Set(["checkpoint-writer","dream","distill"]);var yq0=_0.create({service:"actor.registry"}),xq0=300000,hq0=60000;function HY($){return{sessionID:$.session_id,actorID:$.actor_id,mode:$.mode,parentActorID:$.parent_actor_id??void 0,status:$.status,lastOutcome:$.last_outcome??void 0,lifecycle:$.lifecycle,agent:$.agent,description:$.description,contextMode:$.context_mode,contextWatermark:$.context_watermark??void 0,background:Boolean($.background),tools:$.tools??void 0,lastTurnTime:$.last_turn_time,turnCount:$.turn_count,lastError:$.last_error??void 0,time:{created:$.time_created,updated:$.time_updated,completed:$.time_completed??void 0}}}class yK extends S1.Service()("@qitqode/ActorRegistry"){}var Kd=R0.effect(yK,T.gen(function*(){let $=yield*d1.Service,Z=new Map,J=T.fn("ActorRegistry.register")(function*(A){let N=Date.now(),q={session_id:A.sessionID,actor_id:A.actorID,mode:A.mode,parent_actor_id:A.parentActorID??null,status:"pending",last_outcome:null,lifecycle:A.lifecycle,agent:A.agent,description:A.description,context_mode:A.contextMode,context_watermark:A.contextWatermark??null,background:A.background,tools:A.tools??null,last_turn_time:N,turn_count:0,last_error:null,time_completed:null,time_created:N,time_updated:N};return yield*T.sync(()=>W1.use((w)=>{try{w.insert(_1).values(q).run()}catch(j){if(typeof j==="object"&&j!==null&&"code"in j&&typeof j.code==="string"&&(j.code==="SQLITE_CONSTRAINT_PRIMARYKEY"||j.code==="SQLITE_CONSTRAINT_UNIQUE")||j instanceof Error&&j.message.toLowerCase().includes("unique constraint"))throw Error(`Actor ID collision: '${A.actorID}' already exists in session '${A.sessionID}'.`);throw j}})),yield*$.publish(Jd,{sessionID:A.sessionID,actorID:A.actorID,mode:A.mode,parentActorID:A.parentActorID,description:A.description,agent:A.agent,background:A.background}),HY(q)}),Y=T.fnUntraced(function*(A,N){return yield*T.sync(()=>W1.use((q)=>q.select().from(_1).where(j$(m0(_1.session_id,A),m0(_1.actor_id,N))).get()))}),X=T.fn("ActorRegistry.updateStatus")(function*(A,N,q){let w=Date.now(),j=q.status==="idle"&&q.lastOutcome!==void 0,M={status:q.status,time_updated:w,...j?{time_completed:w}:{}};if(q.lastOutcome!==void 0)M.last_outcome=q.lastOutcome;if(q.lastError!==void 0)M.last_error=q.lastError;else if(q.lastOutcome!==void 0&&q.lastOutcome!=="failure")M.last_error=null;yield*T.sync(()=>W1.use((R)=>R.update(_1).set(M).where(j$(m0(_1.session_id,A),m0(_1.actor_id,N))).run()));let I=yield*Y(A,N);if(!I)return;yield*$.publish(Yd,{sessionID:A,actorID:N,status:I.status,...I.last_outcome?{lastOutcome:I.last_outcome}:{},turnCount:I.turn_count,lastTurnTime:I.last_turn_time,...I.last_error?{error:I.last_error}:{}})}),Q=T.fn("ActorRegistry.updateTurn")(function*(A,N){let q=Date.now();yield*T.sync(()=>W1.use((w)=>w.update(_1).set({last_turn_time:q,turn_count:Gd`${_1.turn_count} + 1`,time_updated:q}).where(j$(m0(_1.session_id,A),m0(_1.actor_id,N))).run()))}),G=T.fn("ActorRegistry.get")(function*(A,N){let q=yield*Y(A,N);return q?HY(q):void 0}),W=T.fn("ActorRegistry.listBySession")(function*(A){return(yield*T.sync(()=>W1.use((q)=>q.select().from(_1).where(m0(_1.session_id,A)).all()))).map(HY)}),K=T.fn("ActorRegistry.listActive")(function*(){return(yield*T.sync(()=>W1.use((N)=>N.select().from(_1).where(j$(k5(_1.status,["pending","running"]),m0(_1.background,!0))).all()))).map(HY)}),V=T.fn("ActorRegistry.listByParent")(function*(A,N){return(yield*T.sync(()=>W1.use((w)=>w.select().from(_1).where(j$(m0(_1.session_id,A),m0(_1.parent_actor_id,N))).all()))).map(HY)}),U=T.fn("ActorRegistry.renderForAgent")(function*(A){let q=(yield*W(A)).filter((M)=>M.background&&(M.status==="pending"||M.status==="running"));if(q.length===0)return"";let w=[];w.push("## Active Actors"),w.push(""),w.push(`You have ${q.length} background actor(s) registered. Interact via the \`actor\` tool.`),w.push("");let j=Date.now();for(let M of q){let I=j-M.lastTurnTime,R=I<60000?`${Math.floor(I/1000)}s`:`${Math.floor(I/60000)}m`;w.push(`- actor_id: ${M.actorID} (${M.status}, last activity ${R} ago)`),w.push(` description: ${M.description}`),w.push(` agent: ${M.agent}`)}return w.join(`
|
|
802
|
+
`)}),H=T.fn("ActorRegistry.agentTypeFor")(function*(A,N){if(N==="main")return"main";return(yield*G(A,N))?.agent??"main"}),B=T.fn("ActorRegistry.isSystemSpawned")(function*(A,N){if(N==="main")return!1;let q=yield*G(A,N);if(!q)return!1;return Qd.has(q.agent)}),z=T.fn("ActorRegistry.allocateActorID")(function*(A,N){let q=`${A}:${N}`,w=`${N}-`;if(!Z.has(q)){let M=yield*T.sync(()=>W1.use((I)=>I.select({actor_id:_1.actor_id}).from(_1).where(j$(m0(_1.session_id,A),m0(_1.agent,N))).all()));if(!Z.has(q)){let I=0;for(let R of M)if(R.actor_id.startsWith(w)){let L=parseInt(R.actor_id.slice(w.length),10);if(Number.isFinite(L)&&L>I)I=L}Z.set(q,I)}}let j=(Z.get(q)??0)+1;return Z.set(q,j),`${N}-${j}`});return yield*T.sync(()=>W1.use((A)=>{let N=Date.now();A.update(_1).set({status:"idle",last_outcome:"failure",last_error:"orphaned: process restarted",time_updated:N,time_completed:N}).where(k5(_1.status,["pending","running"])).run()})),yq0.info("orphan recovery complete"),yield*T.gen(function*(){let A=Date.now()-xq0,N=yield*T.sync(()=>W1.use((q)=>q.select().from(_1).where(j$(m0(_1.status,"running"),Wd(_1.last_turn_time,A))).all()));for(let q of N){let w=HY(q);yield*$.publish(Xd,{sessionID:w.sessionID,actorID:w.actorID,description:w.description,lastTurnTime:w.lastTurnTime,stuckDuration:Date.now()-w.lastTurnTime})}}).pipe(T.repeat(W4.fixed(hq0)),T.ignore,T.forkScoped),yK.of({register:J,updateStatus:X,updateTurn:Q,get:G,listBySession:W,listActive:K,listByParent:V,renderForAgent:U,agentTypeFor:H,isSystemSpawned:B,allocateActorID:z})})),gq0=Kd.pipe(R0.provide(d1.layer));import oA from"path";/*!
|
|
803
|
+
* decimal.js v10.5.0
|
|
804
|
+
* An arbitrary-precision Decimal type for JavaScript.
|
|
805
|
+
* https://github.com/MikeMcl/decimal.js
|
|
806
|
+
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
807
|
+
* MIT Licence
|
|
808
|
+
*/var zY=9000000000000000,B5=1e9,lA="0123456789abcdef",gK="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",uK="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",dA={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-zY,maxE:zY,crypto:!1},Bd,jZ,n0=!0,lK="[DecimalError] ",H5=lK+"Invalid argument: ",zd=lK+"Precision limit exceeded",Fd=lK+"crypto unavailable",Ad="[object Decimal]",o$=Math.floor,N$=Math.pow,uq0=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,mq0=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,lq0=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Od=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,H6=1e7,x0=7,dq0=9007199254740991,pq0=gK.length-1,pA=uK.length-1,Y0={toStringTag:Ad};Y0.absoluteValue=Y0.abs=function(){var $=new this.constructor(this);if($.s<0)$.s=1;return I0($)};Y0.ceil=function(){return I0(new this.constructor(this),this.e+1,2)};Y0.clampedTo=Y0.clamp=function($,Z){var J,Y=this,X=Y.constructor;if($=new X($),Z=new X(Z),!$.s||!Z.s)return new X(NaN);if($.gt(Z))throw Error(H5+Z);return J=Y.cmp($),J<0?$:Y.cmp(Z)>0?Z:new X(Y)};Y0.comparedTo=Y0.cmp=function($){var Z,J,Y,X,Q=this,G=Q.d,W=($=new Q.constructor($)).d,K=Q.s,V=$.s;if(!G||!W)return!K||!V?NaN:K!==V?K:G===W?0:!G^K<0?1:-1;if(!G[0]||!W[0])return G[0]?K:W[0]?-V:0;if(K!==V)return K;if(Q.e!==$.e)return Q.e>$.e^K<0?1:-1;Y=G.length,X=W.length;for(Z=0,J=Y<X?Y:X;Z<J;++Z)if(G[Z]!==W[Z])return G[Z]>W[Z]^K<0?1:-1;return Y===X?0:Y>X^K<0?1:-1};Y0.cosine=Y0.cos=function(){var $,Z,J=this,Y=J.constructor;if(!J.d)return new Y(NaN);if(!J.d[0])return new Y(1);return $=Y.precision,Z=Y.rounding,Y.precision=$+Math.max(J.e,J.sd())+x0,Y.rounding=1,J=cq0(Y,Dd(Y,J)),Y.precision=$,Y.rounding=Z,I0(jZ==2||jZ==3?J.neg():J,$,Z,!0)};Y0.cubeRoot=Y0.cbrt=function(){var $,Z,J,Y,X,Q,G,W,K,V,U=this,H=U.constructor;if(!U.isFinite()||U.isZero())return new H(U);if(n0=!1,Q=U.s*N$(U.s*U,0.3333333333333333),!Q||Math.abs(Q)==1/0){if(J=y$(U.d),$=U.e,Q=($-J.length+1)%3)J+=Q==1||Q==-2?"0":"00";if(Q=N$(J,0.3333333333333333),$=o$(($+1)/3)-($%3==($<0?-1:2)),Q==1/0)J="5e"+$;else J=Q.toExponential(),J=J.slice(0,J.indexOf("e")+1)+$;Y=new H(J),Y.s=U.s}else Y=new H(Q.toString());G=($=H.precision)+3;for(;;)if(W=Y,K=W.times(W).times(W),V=K.plus(U),Y=g1(V.plus(U).times(W),V.plus(K),G+2,1),y$(W.d).slice(0,G)===(J=y$(Y.d)).slice(0,G))if(J=J.slice(G-3,G+1),J=="9999"||!X&&J=="4999"){if(!X){if(I0(W,$+1,0),W.times(W).times(W).eq(U)){Y=W;break}}G+=4,X=1}else{if(!+J||!+J.slice(1)&&J.charAt(0)=="5")I0(Y,$+1,1),Z=!Y.times(Y).times(Y).eq(U);break}return n0=!0,I0(Y,$,H.rounding,Z)};Y0.decimalPlaces=Y0.dp=function(){var $,Z=this.d,J=NaN;if(Z){if($=Z.length-1,J=($-o$(this.e/x0))*x0,$=Z[$],$)for(;$%10==0;$/=10)J--;if(J<0)J=0}return J};Y0.dividedBy=Y0.div=function($){return g1(this,new this.constructor($))};Y0.dividedToIntegerBy=Y0.divToInt=function($){var Z=this,J=Z.constructor;return I0(g1(Z,new J($),0,1,1),J.precision,J.rounding)};Y0.equals=Y0.eq=function($){return this.cmp($)===0};Y0.floor=function(){return I0(new this.constructor(this),this.e+1,3)};Y0.greaterThan=Y0.gt=function($){return this.cmp($)>0};Y0.greaterThanOrEqualTo=Y0.gte=function($){var Z=this.cmp($);return Z==1||Z===0};Y0.hyperbolicCosine=Y0.cosh=function(){var $,Z,J,Y,X,Q=this,G=Q.constructor,W=new G(1);if(!Q.isFinite())return new G(Q.s?1/0:NaN);if(Q.isZero())return W;if(J=G.precision,Y=G.rounding,G.precision=J+Math.max(Q.e,Q.sd())+4,G.rounding=1,X=Q.d.length,X<32)$=Math.ceil(X/3),Z=(1/pK(4,$)).toString();else $=16,Z="2.3283064365386962890625e-10";Q=FY(G,1,Q.times(Z),new G(1),!0);var K,V=$,U=new G(8);for(;V--;)K=Q.times(Q),Q=W.minus(K.times(U.minus(K.times(U))));return I0(Q,G.precision=J,G.rounding=Y,!0)};Y0.hyperbolicSine=Y0.sinh=function(){var $,Z,J,Y,X=this,Q=X.constructor;if(!X.isFinite()||X.isZero())return new Q(X);if(Z=Q.precision,J=Q.rounding,Q.precision=Z+Math.max(X.e,X.sd())+4,Q.rounding=1,Y=X.d.length,Y<3)X=FY(Q,2,X,X,!0);else{$=1.4*Math.sqrt(Y),$=$>16?16:$|0,X=X.times(1/pK(5,$)),X=FY(Q,2,X,X,!0);var G,W=new Q(5),K=new Q(16),V=new Q(20);for(;$--;)G=X.times(X),X=X.times(W.plus(G.times(K.times(G).plus(V))))}return Q.precision=Z,Q.rounding=J,I0(X,Z,J,!0)};Y0.hyperbolicTangent=Y0.tanh=function(){var $,Z,J=this,Y=J.constructor;if(!J.isFinite())return new Y(J.s);if(J.isZero())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+7,Y.rounding=1,g1(J.sinh(),J.cosh(),Y.precision=$,Y.rounding=Z)};Y0.inverseCosine=Y0.acos=function(){var $=this,Z=$.constructor,J=$.abs().cmp(1),Y=Z.precision,X=Z.rounding;if(J!==-1)return J===0?$.isNeg()?y6(Z,Y,X):new Z(0):new Z(NaN);if($.isZero())return y6(Z,Y+4,X).times(0.5);return Z.precision=Y+6,Z.rounding=1,$=new Z(1).minus($).div($.plus(1)).sqrt().atan(),Z.precision=Y,Z.rounding=X,$.times(2)};Y0.inverseHyperbolicCosine=Y0.acosh=function(){var $,Z,J=this,Y=J.constructor;if(J.lte(1))return new Y(J.eq(1)?0:NaN);if(!J.isFinite())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+Math.max(Math.abs(J.e),J.sd())+4,Y.rounding=1,n0=!1,J=J.times(J).minus(1).sqrt().plus(J),n0=!0,Y.precision=$,Y.rounding=Z,J.ln()};Y0.inverseHyperbolicSine=Y0.asinh=function(){var $,Z,J=this,Y=J.constructor;if(!J.isFinite()||J.isZero())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+2*Math.max(Math.abs(J.e),J.sd())+6,Y.rounding=1,n0=!1,J=J.times(J).plus(1).sqrt().plus(J),n0=!0,Y.precision=$,Y.rounding=Z,J.ln()};Y0.inverseHyperbolicTangent=Y0.atanh=function(){var $,Z,J,Y,X=this,Q=X.constructor;if(!X.isFinite())return new Q(NaN);if(X.e>=0)return new Q(X.abs().eq(1)?X.s/0:X.isZero()?X:NaN);if($=Q.precision,Z=Q.rounding,Y=X.sd(),Math.max(Y,$)<2*-X.e-1)return I0(new Q(X),$,Z,!0);return Q.precision=J=Y-X.e,X=g1(X.plus(1),new Q(1).minus(X),J+$,1),Q.precision=$+4,Q.rounding=1,X=X.ln(),Q.precision=$,Q.rounding=Z,X.times(0.5)};Y0.inverseSine=Y0.asin=function(){var $,Z,J,Y,X=this,Q=X.constructor;if(X.isZero())return new Q(X);if(Z=X.abs().cmp(1),J=Q.precision,Y=Q.rounding,Z!==-1){if(Z===0)return $=y6(Q,J+4,Y).times(0.5),$.s=X.s,$;return new Q(NaN)}return Q.precision=J+6,Q.rounding=1,X=X.div(new Q(1).minus(X.times(X)).sqrt().plus(1)).atan(),Q.precision=J,Q.rounding=Y,X.times(2)};Y0.inverseTangent=Y0.atan=function(){var $,Z,J,Y,X,Q,G,W,K,V=this,U=V.constructor,H=U.precision,B=U.rounding;if(!V.isFinite()){if(!V.s)return new U(NaN);if(H+4<=pA)return G=y6(U,H+4,B).times(0.5),G.s=V.s,G}else if(V.isZero())return new U(V);else if(V.abs().eq(1)&&H+4<=pA)return G=y6(U,H+4,B).times(0.25),G.s=V.s,G;U.precision=W=H+10,U.rounding=1,J=Math.min(28,W/x0+2|0);for($=J;$;--$)V=V.div(V.times(V).plus(1).sqrt().plus(1));n0=!1,Z=Math.ceil(W/x0),Y=1,K=V.times(V),G=new U(V),X=V;for(;$!==-1;)if(X=X.times(K),Q=G.minus(X.div(Y+=2)),X=X.times(K),G=Q.plus(X.div(Y+=2)),G.d[Z]!==void 0)for($=Z;G.d[$]===Q.d[$]&&$--;);if(J)G=G.times(2<<J-1);return n0=!0,I0(G,U.precision=H,U.rounding=B,!0)};Y0.isFinite=function(){return!!this.d};Y0.isInteger=Y0.isInt=function(){return!!this.d&&o$(this.e/x0)>this.d.length-2};Y0.isNaN=function(){return!this.s};Y0.isNegative=Y0.isNeg=function(){return this.s<0};Y0.isPositive=Y0.isPos=function(){return this.s>0};Y0.isZero=function(){return!!this.d&&this.d[0]===0};Y0.lessThan=Y0.lt=function($){return this.cmp($)<0};Y0.lessThanOrEqualTo=Y0.lte=function($){return this.cmp($)<1};Y0.logarithm=Y0.log=function($){var Z,J,Y,X,Q,G,W,K,V=this,U=V.constructor,H=U.precision,B=U.rounding,z=5;if($==null)$=new U(10),Z=!0;else{if($=new U($),J=$.d,$.s<0||!J||!J[0]||$.eq(1))return new U(NaN);Z=$.eq(10)}if(J=V.d,V.s<0||!J||!J[0]||V.eq(1))return new U(J&&!J[0]?-1/0:V.s!=1?NaN:J?0:1/0);if(Z)if(J.length>1)Q=!0;else{for(X=J[0];X%10===0;)X/=10;Q=X!==1}if(n0=!1,W=H+z,G=U5(V,W),Y=Z?mK(U,W+10):U5($,W),K=g1(G,Y,W,1),VQ(K.d,X=H,B))do if(W+=10,G=U5(V,W),Y=Z?mK(U,W+10):U5($,W),K=g1(G,Y,W,1),!Q){if(+y$(K.d).slice(X+1,X+15)+1==100000000000000)K=I0(K,H+1,0);break}while(VQ(K.d,X+=10,B));return n0=!0,I0(K,H,B)};Y0.minus=Y0.sub=function($){var Z,J,Y,X,Q,G,W,K,V,U,H,B,z=this,F=z.constructor;if($=new F($),!z.d||!$.d){if(!z.s||!$.s)$=new F(NaN);else if(z.d)$.s=-$.s;else $=new F($.d||z.s!==$.s?z:NaN);return $}if(z.s!=$.s)return $.s=-$.s,z.plus($);if(V=z.d,B=$.d,W=F.precision,K=F.rounding,!V[0]||!B[0]){if(B[0])$.s=-$.s;else if(V[0])$=new F(z);else return new F(K===3?-0:0);return n0?I0($,W,K):$}if(J=o$($.e/x0),U=o$(z.e/x0),V=V.slice(),Q=U-J,Q){if(H=Q<0,H)Z=V,Q=-Q,G=B.length;else Z=B,J=U,G=V.length;if(Y=Math.max(Math.ceil(W/x0),G)+2,Q>Y)Q=Y,Z.length=1;Z.reverse();for(Y=Q;Y--;)Z.push(0);Z.reverse()}else{if(Y=V.length,G=B.length,H=Y<G,H)G=Y;for(Y=0;Y<G;Y++)if(V[Y]!=B[Y]){H=V[Y]<B[Y];break}Q=0}if(H)Z=V,V=B,B=Z,$.s=-$.s;G=V.length;for(Y=B.length-G;Y>0;--Y)V[G++]=0;for(Y=B.length;Y>Q;){if(V[--Y]<B[Y]){for(X=Y;X&&V[--X]===0;)V[X]=H6-1;--V[X],V[Y]+=H6}V[Y]-=B[Y]}for(;V[--G]===0;)V.pop();for(;V[0]===0;V.shift())--J;if(!V[0])return new F(K===3?-0:0);return $.d=V,$.e=dK(V,J),n0?I0($,W,K):$};Y0.modulo=Y0.mod=function($){var Z,J=this,Y=J.constructor;if($=new Y($),!J.d||!$.s||$.d&&!$.d[0])return new Y(NaN);if(!$.d||J.d&&!J.d[0])return I0(new Y(J),Y.precision,Y.rounding);if(n0=!1,Y.modulo==9)Z=g1(J,$.abs(),0,3,1),Z.s*=$.s;else Z=g1(J,$,0,Y.modulo,1);return Z=Z.times($),n0=!0,J.minus(Z)};Y0.naturalExponential=Y0.exp=function(){return cA(this)};Y0.naturalLogarithm=Y0.ln=function(){return U5(this)};Y0.negated=Y0.neg=function(){var $=new this.constructor(this);return $.s=-$.s,I0($)};Y0.plus=Y0.add=function($){var Z,J,Y,X,Q,G,W,K,V,U,H=this,B=H.constructor;if($=new B($),!H.d||!$.d){if(!H.s||!$.s)$=new B(NaN);else if(!H.d)$=new B($.d||H.s===$.s?H:NaN);return $}if(H.s!=$.s)return $.s=-$.s,H.minus($);if(V=H.d,U=$.d,W=B.precision,K=B.rounding,!V[0]||!U[0]){if(!U[0])$=new B(H);return n0?I0($,W,K):$}if(Q=o$(H.e/x0),Y=o$($.e/x0),V=V.slice(),X=Q-Y,X){if(X<0)J=V,X=-X,G=U.length;else J=U,Y=Q,G=V.length;if(Q=Math.ceil(W/x0),G=Q>G?Q+1:G+1,X>G)X=G,J.length=1;J.reverse();for(;X--;)J.push(0);J.reverse()}if(G=V.length,X=U.length,G-X<0)X=G,J=U,U=V,V=J;for(Z=0;X;)Z=(V[--X]=V[X]+U[X]+Z)/H6|0,V[X]%=H6;if(Z)V.unshift(Z),++Y;for(G=V.length;V[--G]==0;)V.pop();return $.d=V,$.e=dK(V,Y),n0?I0($,W,K):$};Y0.precision=Y0.sd=function($){var Z,J=this;if($!==void 0&&$!==!!$&&$!==1&&$!==0)throw Error(H5+$);if(J.d){if(Z=jd(J.d),$&&J.e+1>Z)Z=J.e+1}else Z=NaN;return Z};Y0.round=function(){var $=this,Z=$.constructor;return I0(new Z($),$.e+1,Z.rounding)};Y0.sine=Y0.sin=function(){var $,Z,J=this,Y=J.constructor;if(!J.isFinite())return new Y(NaN);if(J.isZero())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+Math.max(J.e,J.sd())+x0,Y.rounding=1,J=nq0(Y,Dd(Y,J)),Y.precision=$,Y.rounding=Z,I0(jZ>2?J.neg():J,$,Z,!0)};Y0.squareRoot=Y0.sqrt=function(){var $,Z,J,Y,X,Q,G=this,W=G.d,K=G.e,V=G.s,U=G.constructor;if(V!==1||!W||!W[0])return new U(!V||V<0&&(!W||W[0])?NaN:W?G:1/0);if(n0=!1,V=Math.sqrt(+G),V==0||V==1/0){if(Z=y$(W),(Z.length+K)%2==0)Z+="0";if(V=Math.sqrt(Z),K=o$((K+1)/2)-(K<0||K%2),V==1/0)Z="5e"+K;else Z=V.toExponential(),Z=Z.slice(0,Z.indexOf("e")+1)+K;Y=new U(Z)}else Y=new U(V.toString());J=(K=U.precision)+3;for(;;)if(Q=Y,Y=Q.plus(g1(G,Q,J+2,1)).times(0.5),y$(Q.d).slice(0,J)===(Z=y$(Y.d)).slice(0,J))if(Z=Z.slice(J-3,J+1),Z=="9999"||!X&&Z=="4999"){if(!X){if(I0(Q,K+1,0),Q.times(Q).eq(G)){Y=Q;break}}J+=4,X=1}else{if(!+Z||!+Z.slice(1)&&Z.charAt(0)=="5")I0(Y,K+1,1),$=!Y.times(Y).eq(G);break}return n0=!0,I0(Y,K,U.rounding,$)};Y0.tangent=Y0.tan=function(){var $,Z,J=this,Y=J.constructor;if(!J.isFinite())return new Y(NaN);if(J.isZero())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+10,Y.rounding=1,J=J.sin(),J.s=1,J=g1(J,new Y(1).minus(J.times(J)).sqrt(),$+10,0),Y.precision=$,Y.rounding=Z,I0(jZ==2||jZ==4?J.neg():J,$,Z,!0)};Y0.times=Y0.mul=function($){var Z,J,Y,X,Q,G,W,K,V,U=this,H=U.constructor,B=U.d,z=($=new H($)).d;if($.s*=U.s,!B||!B[0]||!z||!z[0])return new H(!$.s||B&&!B[0]&&!z||z&&!z[0]&&!B?NaN:!B||!z?$.s/0:$.s*0);if(J=o$(U.e/x0)+o$($.e/x0),K=B.length,V=z.length,K<V)Q=B,B=z,z=Q,G=K,K=V,V=G;Q=[],G=K+V;for(Y=G;Y--;)Q.push(0);for(Y=V;--Y>=0;){Z=0;for(X=K+Y;X>Y;)W=Q[X]+z[Y]*B[X-Y-1]+Z,Q[X--]=W%H6|0,Z=W/H6|0;Q[X]=(Q[X]+Z)%H6|0}for(;!Q[--G];)Q.pop();if(Z)++J;else Q.shift();return $.d=Q,$.e=dK(Q,J),n0?I0($,H.precision,H.rounding):$};Y0.toBinary=function($,Z){return iA(this,2,$,Z)};Y0.toDecimalPlaces=Y0.toDP=function($,Z){var J=this,Y=J.constructor;if(J=new Y(J),$===void 0)return J;if(A8($,0,B5),Z===void 0)Z=Y.rounding;else A8(Z,0,8);return I0(J,$+J.e+1,Z)};Y0.toExponential=function($,Z){var J,Y=this,X=Y.constructor;if($===void 0)J=x6(Y,!0);else{if(A8($,0,B5),Z===void 0)Z=X.rounding;else A8(Z,0,8);Y=I0(new X(Y),$+1,Z),J=x6(Y,!0,$+1)}return Y.isNeg()&&!Y.isZero()?"-"+J:J};Y0.toFixed=function($,Z){var J,Y,X=this,Q=X.constructor;if($===void 0)J=x6(X);else{if(A8($,0,B5),Z===void 0)Z=Q.rounding;else A8(Z,0,8);Y=I0(new Q(X),$+X.e+1,Z),J=x6(Y,!1,$+Y.e+1)}return X.isNeg()&&!X.isZero()?"-"+J:J};Y0.toFraction=function($){var Z,J,Y,X,Q,G,W,K,V,U,H,B,z=this,F=z.d,A=z.constructor;if(!F)return new A(z);if(V=J=new A(1),Y=K=new A(0),Z=new A(Y),Q=Z.e=jd(F)-z.e-1,G=Q%x0,Z.d[0]=N$(10,G<0?x0+G:G),$==null)$=Q>0?Z:V;else{if(W=new A($),!W.isInt()||W.lt(V))throw Error(H5+W);$=W.gt(Z)?Q>0?Z:V:W}n0=!1,W=new A(y$(F)),U=A.precision,A.precision=Q=F.length*x0*2;for(;;){if(H=g1(W,Z,0,1,1),X=J.plus(H.times(Y)),X.cmp($)==1)break;J=Y,Y=X,X=V,V=K.plus(H.times(X)),K=X,X=Z,Z=W.minus(H.times(X)),W=X}return X=g1($.minus(J),Y,0,1,1),K=K.plus(X.times(V)),J=J.plus(X.times(Y)),K.s=V.s=z.s,B=g1(V,Y,Q,1).minus(z).abs().cmp(g1(K,J,Q,1).minus(z).abs())<1?[V,Y]:[K,J],A.precision=U,n0=!0,B};Y0.toHexadecimal=Y0.toHex=function($,Z){return iA(this,16,$,Z)};Y0.toNearest=function($,Z){var J=this,Y=J.constructor;if(J=new Y(J),$==null){if(!J.d)return J;$=new Y(1),Z=Y.rounding}else{if($=new Y($),Z===void 0)Z=Y.rounding;else A8(Z,0,8);if(!J.d)return $.s?J:$;if(!$.d){if($.s)$.s=J.s;return $}}if($.d[0])n0=!1,J=g1(J,$,0,Z,1).times($),n0=!0,I0(J);else $.s=J.s,J=$;return J};Y0.toNumber=function(){return+this};Y0.toOctal=function($,Z){return iA(this,8,$,Z)};Y0.toPower=Y0.pow=function($){var Z,J,Y,X,Q,G,W=this,K=W.constructor,V=+($=new K($));if(!W.d||!$.d||!W.d[0]||!$.d[0])return new K(N$(+W,V));if(W=new K(W),W.eq(1))return W;if(Y=K.precision,Q=K.rounding,$.eq(1))return I0(W,Y,Q);if(Z=o$($.e/x0),Z>=$.d.length-1&&(J=V<0?-V:V)<=dq0)return X=Nd(K,W,J,Y),$.s<0?new K(1).div(X):I0(X,Y,Q);if(G=W.s,G<0){if(Z<$.d.length-1)return new K(NaN);if(($.d[Z]&1)==0)G=1;if(W.e==0&&W.d[0]==1&&W.d.length==1)return W.s=G,W}if(J=N$(+W,V),Z=J==0||!isFinite(J)?o$(V*(Math.log("0."+y$(W.d))/Math.LN10+W.e+1)):new K(J+"").e,Z>K.maxE+1||Z<K.minE-1)return new K(Z>0?G/0:0);if(n0=!1,K.rounding=W.s=1,J=Math.min(12,(Z+"").length),X=cA($.times(U5(W,Y+J)),Y),X.d){if(X=I0(X,Y+5,1),VQ(X.d,Y,Q)){if(Z=Y+10,X=I0(cA($.times(U5(W,Z+J)),Z),Z+5,1),+y$(X.d).slice(Y+1,Y+15)+1==100000000000000)X=I0(X,Y+1,0)}}return X.s=G,n0=!0,K.rounding=Q,I0(X,Y,Q)};Y0.toPrecision=function($,Z){var J,Y=this,X=Y.constructor;if($===void 0)J=x6(Y,Y.e<=X.toExpNeg||Y.e>=X.toExpPos);else{if(A8($,1,B5),Z===void 0)Z=X.rounding;else A8(Z,0,8);Y=I0(new X(Y),$,Z),J=x6(Y,$<=Y.e||Y.e<=X.toExpNeg,$)}return Y.isNeg()&&!Y.isZero()?"-"+J:J};Y0.toSignificantDigits=Y0.toSD=function($,Z){var J=this,Y=J.constructor;if($===void 0)$=Y.precision,Z=Y.rounding;else if(A8($,1,B5),Z===void 0)Z=Y.rounding;else A8(Z,0,8);return I0(new Y(J),$,Z)};Y0.toString=function(){var $=this,Z=$.constructor,J=x6($,$.e<=Z.toExpNeg||$.e>=Z.toExpPos);return $.isNeg()&&!$.isZero()?"-"+J:J};Y0.truncated=Y0.trunc=function(){return I0(new this.constructor(this),this.e+1,1)};Y0.valueOf=Y0.toJSON=function(){var $=this,Z=$.constructor,J=x6($,$.e<=Z.toExpNeg||$.e>=Z.toExpPos);return $.isNeg()?"-"+J:J};function y$($){var Z,J,Y,X=$.length-1,Q="",G=$[0];if(X>0){Q+=G;for(Z=1;Z<X;Z++){if(Y=$[Z]+"",J=x0-Y.length,J)Q+=V5(J);Q+=Y}if(G=$[Z],Y=G+"",J=x0-Y.length,J)Q+=V5(J)}else if(G===0)return"0";for(;G%10===0;)G/=10;return Q+G}function A8($,Z,J){if($!==~~$||$<Z||$>J)throw Error(H5+$)}function VQ($,Z,J,Y){var X,Q,G,W;for(Q=$[0];Q>=10;Q/=10)--Z;if(--Z<0)Z+=x0,X=0;else X=Math.ceil((Z+1)/x0),Z%=x0;if(Q=N$(10,x0-Z),W=$[X]%Q|0,Y==null)if(Z<3){if(Z==0)W=W/100|0;else if(Z==1)W=W/10|0;G=J<4&&W==99999||J>3&&W==49999||W==50000||W==0}else G=(J<4&&W+1==Q||J>3&&W+1==Q/2)&&($[X+1]/Q/100|0)==N$(10,Z-2)-1||(W==Q/2||W==0)&&($[X+1]/Q/100|0)==0;else if(Z<4){if(Z==0)W=W/1000|0;else if(Z==1)W=W/100|0;else if(Z==2)W=W/10|0;G=(Y||J<4)&&W==9999||!Y&&J>3&&W==4999}else G=((Y||J<4)&&W+1==Q||!Y&&J>3&&W+1==Q/2)&&($[X+1]/Q/1000|0)==N$(10,Z-3)-1;return G}function xK($,Z,J){var Y,X=[0],Q,G=0,W=$.length;for(;G<W;){for(Q=X.length;Q--;)X[Q]*=Z;X[0]+=lA.indexOf($.charAt(G++));for(Y=0;Y<X.length;Y++)if(X[Y]>J-1){if(X[Y+1]===void 0)X[Y+1]=0;X[Y+1]+=X[Y]/J|0,X[Y]%=J}}return X.reverse()}function cq0($,Z){var J,Y,X;if(Z.isZero())return Z;if(Y=Z.d.length,Y<32)J=Math.ceil(Y/3),X=(1/pK(4,J)).toString();else J=16,X="2.3283064365386962890625e-10";$.precision+=J,Z=FY($,1,Z.times(X),new $(1));for(var Q=J;Q--;){var G=Z.times(Z);Z=G.times(G).minus(G).times(8).plus(1)}return $.precision-=J,Z}var g1=function(){function $(Y,X,Q){var G,W=0,K=Y.length;for(Y=Y.slice();K--;)G=Y[K]*X+W,Y[K]=G%Q|0,W=G/Q|0;if(W)Y.unshift(W);return Y}function Z(Y,X,Q,G){var W,K;if(Q!=G)K=Q>G?1:-1;else for(W=K=0;W<Q;W++)if(Y[W]!=X[W]){K=Y[W]>X[W]?1:-1;break}return K}function J(Y,X,Q,G){var W=0;for(;Q--;)Y[Q]-=W,W=Y[Q]<X[Q]?1:0,Y[Q]=W*G+Y[Q]-X[Q];for(;!Y[0]&&Y.length>1;)Y.shift()}return function(Y,X,Q,G,W,K){var V,U,H,B,z,F,A,N,q,w,j,M,I,R,L,C,_,E,f,b,k=Y.constructor,u=Y.s==X.s?1:-1,x=Y.d,g=X.d;if(!x||!x[0]||!g||!g[0])return new k(!Y.s||!X.s||(x?g&&x[0]==g[0]:!g)?NaN:x&&x[0]==0||!g?u*0:u/0);if(K)z=1,U=Y.e-X.e;else K=H6,z=x0,U=o$(Y.e/z)-o$(X.e/z);f=g.length,_=x.length,q=new k(u),w=q.d=[];for(H=0;g[H]==(x[H]||0);H++);if(g[H]>(x[H]||0))U--;if(Q==null)R=Q=k.precision,G=k.rounding;else if(W)R=Q+(Y.e-X.e)+1;else R=Q;if(R<0)w.push(1),F=!0;else{if(R=R/z+2|0,H=0,f==1){B=0,g=g[0],R++;for(;(H<_||B)&&R--;H++)L=B*K+(x[H]||0),w[H]=L/g|0,B=L%g|0;F=B||H<_}else{if(B=K/(g[0]+1)|0,B>1)g=$(g,B,K),x=$(x,B,K),f=g.length,_=x.length;C=f,j=x.slice(0,f),M=j.length;for(;M<f;)j[M++]=0;if(b=g.slice(),b.unshift(0),E=g[0],g[1]>=K/2)++E;do{if(B=0,V=Z(g,j,f,M),V<0){if(I=j[0],f!=M)I=I*K+(j[1]||0);if(B=I/E|0,B>1){if(B>=K)B=K-1;if(A=$(g,B,K),N=A.length,M=j.length,V=Z(A,j,N,M),V==1)B--,J(A,f<N?b:g,N,K)}else{if(B==0)V=B=1;A=g.slice()}if(N=A.length,N<M)A.unshift(0);if(J(j,A,M,K),V==-1){if(M=j.length,V=Z(g,j,f,M),V<1)B++,J(j,f<M?b:g,M,K)}M=j.length}else if(V===0)B++,j=[0];if(w[H++]=B,V&&j[0])j[M++]=x[C]||0;else j=[x[C]],M=1}while((C++<_||j[0]!==void 0)&&R--);F=j[0]!==void 0}if(!w[0])w.shift()}if(z==1)q.e=U,Bd=F;else{for(H=1,B=w[0];B>=10;B/=10)H++;q.e=H+U*z-1,I0(q,W?Q+q.e+1:Q,G,F)}return q}}();function I0($,Z,J,Y){var X,Q,G,W,K,V,U,H,B,z=$.constructor;$:if(Z!=null){if(H=$.d,!H)return $;for(X=1,W=H[0];W>=10;W/=10)X++;if(Q=Z-X,Q<0)Q+=x0,G=Z,U=H[B=0],K=U/N$(10,X-G-1)%10|0;else if(B=Math.ceil((Q+1)/x0),W=H.length,B>=W)if(Y){for(;W++<=B;)H.push(0);U=K=0,X=1,Q%=x0,G=Q-x0+1}else break $;else{U=W=H[B];for(X=1;W>=10;W/=10)X++;Q%=x0,G=Q-x0+X,K=G<0?0:U/N$(10,X-G-1)%10|0}if(Y=Y||Z<0||H[B+1]!==void 0||(G<0?U:U%N$(10,X-G-1)),V=J<4?(K||Y)&&(J==0||J==($.s<0?3:2)):K>5||K==5&&(J==4||Y||J==6&&(Q>0?G>0?U/N$(10,X-G):0:H[B-1])%10&1||J==($.s<0?8:7)),Z<1||!H[0]){if(H.length=0,V)Z-=$.e+1,H[0]=N$(10,(x0-Z%x0)%x0),$.e=-Z||0;else H[0]=$.e=0;return $}if(Q==0)H.length=B,W=1,B--;else H.length=B+1,W=N$(10,x0-Q),H[B]=G>0?(U/N$(10,X-G)%N$(10,G)|0)*W:0;if(V)for(;;)if(B==0){for(Q=1,G=H[0];G>=10;G/=10)Q++;G=H[0]+=W;for(W=1;G>=10;G/=10)W++;if(Q!=W){if($.e++,H[0]==H6)H[0]=1}break}else{if(H[B]+=W,H[B]!=H6)break;H[B--]=0,W=1}for(Q=H.length;H[--Q]===0;)H.pop()}if(n0){if($.e>z.maxE)$.d=null,$.e=NaN;else if($.e<z.minE)$.e=0,$.d=[0]}return $}function x6($,Z,J){if(!$.isFinite())return Md($);var Y,X=$.e,Q=y$($.d),G=Q.length;if(Z){if(J&&(Y=J-G)>0)Q=Q.charAt(0)+"."+Q.slice(1)+V5(Y);else if(G>1)Q=Q.charAt(0)+"."+Q.slice(1);Q=Q+($.e<0?"e":"e+")+$.e}else if(X<0){if(Q="0."+V5(-X-1)+Q,J&&(Y=J-G)>0)Q+=V5(Y)}else if(X>=G){if(Q+=V5(X+1-G),J&&(Y=J-X-1)>0)Q=Q+"."+V5(Y)}else{if((Y=X+1)<G)Q=Q.slice(0,Y)+"."+Q.slice(Y);if(J&&(Y=J-G)>0){if(X+1===G)Q+=".";Q+=V5(Y)}}return Q}function dK($,Z){var J=$[0];for(Z*=x0;J>=10;J/=10)Z++;return Z}function mK($,Z,J){if(Z>pq0){if(n0=!0,J)$.precision=J;throw Error(zd)}return I0(new $(gK),Z,1,!0)}function y6($,Z,J){if(Z>pA)throw Error(zd);return I0(new $(uK),Z,J,!0)}function jd($){var Z=$.length-1,J=Z*x0+1;if(Z=$[Z],Z){for(;Z%10==0;Z/=10)J--;for(Z=$[0];Z>=10;Z/=10)J++}return J}function V5($){var Z="";for(;$--;)Z+="0";return Z}function Nd($,Z,J,Y){var X,Q=new $(1),G=Math.ceil(Y/x0+4);n0=!1;for(;;){if(J%2){if(Q=Q.times(Z),Ud(Q.d,G))X=!0}if(J=o$(J/2),J===0){if(J=Q.d.length-1,X&&Q.d[J]===0)++Q.d[J];break}Z=Z.times(Z),Ud(Z.d,G)}return n0=!0,Q}function Vd($){return $.d[$.d.length-1]&1}function qd($,Z,J){var Y,X,Q=new $(Z[0]),G=0;for(;++G<Z.length;){if(X=new $(Z[G]),!X.s){Q=X;break}if(Y=Q.cmp(X),Y===J||Y===0&&Q.s===J)Q=X}return Q}function cA($,Z){var J,Y,X,Q,G,W,K,V=0,U=0,H=0,B=$.constructor,z=B.rounding,F=B.precision;if(!$.d||!$.d[0]||$.e>17)return new B($.d?!$.d[0]?1:$.s<0?0:1/0:$.s?$.s<0?0:$:NaN);if(Z==null)n0=!1,K=F;else K=Z;W=new B(0.03125);while($.e>-2)$=$.times(W),H+=5;Y=Math.log(N$(2,H))/Math.LN10*2+5|0,K+=Y,J=Q=G=new B(1),B.precision=K;for(;;){if(Q=I0(Q.times($),K,1),J=J.times(++U),W=G.plus(g1(Q,J,K,1)),y$(W.d).slice(0,K)===y$(G.d).slice(0,K)){X=H;while(X--)G=I0(G.times(G),K,1);if(Z==null)if(V<3&&VQ(G.d,K-Y,z,V))B.precision=K+=10,J=Q=W=new B(1),U=0,V++;else return I0(G,B.precision=F,z,n0=!0);else return B.precision=F,G}G=W}}function U5($,Z){var J,Y,X,Q,G,W,K,V,U,H,B,z=1,F=10,A=$,N=A.d,q=A.constructor,w=q.rounding,j=q.precision;if(A.s<0||!N||!N[0]||!A.e&&N[0]==1&&N.length==1)return new q(N&&!N[0]?-1/0:A.s!=1?NaN:N?0:A);if(Z==null)n0=!1,U=j;else U=Z;if(q.precision=U+=F,J=y$(N),Y=J.charAt(0),Math.abs(Q=A.e)<1500000000000000){while(Y<7&&Y!=1||Y==1&&J.charAt(1)>3)A=A.times($),J=y$(A.d),Y=J.charAt(0),z++;if(Q=A.e,Y>1)A=new q("0."+J),Q++;else A=new q(Y+"."+J.slice(1))}else return V=mK(q,U+2,j).times(Q+""),A=U5(new q(Y+"."+J.slice(1)),U-F).plus(V),q.precision=j,Z==null?I0(A,j,w,n0=!0):A;H=A,K=G=A=g1(A.minus(1),A.plus(1),U,1),B=I0(A.times(A),U,1),X=3;for(;;){if(G=I0(G.times(B),U,1),V=K.plus(g1(G,new q(X),U,1)),y$(V.d).slice(0,U)===y$(K.d).slice(0,U)){if(K=K.times(2),Q!==0)K=K.plus(mK(q,U+2,j).times(Q+""));if(K=g1(K,new q(z),U,1),Z==null)if(VQ(K.d,U-F,w,W))q.precision=U+=F,V=G=A=g1(H.minus(1),H.plus(1),U,1),B=I0(A.times(A),U,1),X=W=1;else return I0(K,q.precision=j,w,n0=!0);else return q.precision=j,K}K=V,X+=2}}function Md($){return String($.s*$.s/0)}function hK($,Z){var J,Y,X;if((J=Z.indexOf("."))>-1)Z=Z.replace(".","");if((Y=Z.search(/e/i))>0){if(J<0)J=Y;J+=+Z.slice(Y+1),Z=Z.substring(0,Y)}else if(J<0)J=Z.length;for(Y=0;Z.charCodeAt(Y)===48;Y++);for(X=Z.length;Z.charCodeAt(X-1)===48;--X);if(Z=Z.slice(Y,X),Z){if(X-=Y,$.e=J=J-Y-1,$.d=[],Y=(J+1)%x0,J<0)Y+=x0;if(Y<X){if(Y)$.d.push(+Z.slice(0,Y));for(X-=x0;Y<X;)$.d.push(+Z.slice(Y,Y+=x0));Z=Z.slice(Y),Y=x0-Z.length}else Y-=X;for(;Y--;)Z+="0";if($.d.push(+Z),n0){if($.e>$.constructor.maxE)$.d=null,$.e=NaN;else if($.e<$.constructor.minE)$.e=0,$.d=[0]}}else $.e=0,$.d=[0];return $}function iq0($,Z){var J,Y,X,Q,G,W,K,V,U;if(Z.indexOf("_")>-1){if(Z=Z.replace(/(\d)_(?=\d)/g,"$1"),Od.test(Z))return hK($,Z)}else if(Z==="Infinity"||Z==="NaN"){if(!+Z)$.s=NaN;return $.e=NaN,$.d=null,$}if(mq0.test(Z))J=16,Z=Z.toLowerCase();else if(uq0.test(Z))J=2;else if(lq0.test(Z))J=8;else throw Error(H5+Z);if(Q=Z.search(/p/i),Q>0)K=+Z.slice(Q+1),Z=Z.substring(2,Q);else Z=Z.slice(2);if(Q=Z.indexOf("."),G=Q>=0,Y=$.constructor,G)Z=Z.replace(".",""),W=Z.length,Q=W-Q,X=Nd(Y,new Y(J),Q,Q*2);V=xK(Z,J,H6),U=V.length-1;for(Q=U;V[Q]===0;--Q)V.pop();if(Q<0)return new Y($.s*0);if($.e=dK(V,U),$.d=V,n0=!1,G)$=g1($,X,W*4);if(K)$=$.times(Math.abs(K)<54?N$(2,K):B6.pow(2,K));return n0=!0,$}function nq0($,Z){var J,Y=Z.d.length;if(Y<3)return Z.isZero()?Z:FY($,2,Z,Z);J=1.4*Math.sqrt(Y),J=J>16?16:J|0,Z=Z.times(1/pK(5,J)),Z=FY($,2,Z,Z);var X,Q=new $(5),G=new $(16),W=new $(20);for(;J--;)X=Z.times(Z),Z=Z.times(Q.plus(X.times(G.times(X).minus(W))));return Z}function FY($,Z,J,Y,X){var Q,G,W,K,V=1,U=$.precision,H=Math.ceil(U/x0);n0=!1,K=J.times(J),W=new $(Y);for(;;){if(G=g1(W.times(K),new $(Z++*Z++),U,1),W=X?Y.plus(G):Y.minus(G),Y=g1(G.times(K),new $(Z++*Z++),U,1),G=W.plus(Y),G.d[H]!==void 0){for(Q=H;G.d[Q]===W.d[Q]&&Q--;);if(Q==-1)break}Q=W,W=Y,Y=G,G=Q,V++}return n0=!0,G.d.length=H+1,G}function pK($,Z){var J=$;while(--Z)J*=$;return J}function Dd($,Z){var J,Y=Z.s<0,X=y6($,$.precision,1),Q=X.times(0.5);if(Z=Z.abs(),Z.lte(Q))return jZ=Y?4:1,Z;if(J=Z.divToInt(X),J.isZero())jZ=Y?3:2;else{if(Z=Z.minus(J.times(X)),Z.lte(Q))return jZ=Vd(J)?Y?2:3:Y?4:1,Z;jZ=Vd(J)?Y?1:4:Y?3:2}return Z.minus(X).abs()}function iA($,Z,J,Y){var X,Q,G,W,K,V,U,H,B,z=$.constructor,F=J!==void 0;if(F)if(A8(J,1,B5),Y===void 0)Y=z.rounding;else A8(Y,0,8);else J=z.precision,Y=z.rounding;if(!$.isFinite())U=Md($);else{if(U=x6($),G=U.indexOf("."),F){if(X=2,Z==16)J=J*4-3;else if(Z==8)J=J*3-2}else X=Z;if(G>=0)U=U.replace(".",""),B=new z(1),B.e=U.length-G,B.d=xK(x6(B),10,X),B.e=B.d.length;H=xK(U,10,X),Q=K=H.length;for(;H[--K]==0;)H.pop();if(!H[0])U=F?"0p+0":"0";else{if(G<0)Q--;else $=new z($),$.d=H,$.e=Q,$=g1($,B,J,Y,0,X),H=$.d,Q=$.e,V=Bd;if(G=H[J],W=X/2,V=V||H[J+1]!==void 0,V=Y<4?(G!==void 0||V)&&(Y===0||Y===($.s<0?3:2)):G>W||G===W&&(Y===4||V||Y===6&&H[J-1]&1||Y===($.s<0?8:7)),H.length=J,V){for(;++H[--J]>X-1;)if(H[J]=0,!J)++Q,H.unshift(1)}for(K=H.length;!H[K-1];--K);for(G=0,U="";G<K;G++)U+=lA.charAt(H[G]);if(F){if(K>1)if(Z==16||Z==8){G=Z==16?4:3;for(--K;K%G;K++)U+="0";H=xK(U,X,Z);for(K=H.length;!H[K-1];--K);for(G=1,U="1.";G<K;G++)U+=lA.charAt(H[G])}else U=U.charAt(0)+"."+U.slice(1);U=U+(Q<0?"p":"p+")+Q}else if(Q<0){for(;++Q;)U="0"+U;U="0."+U}else if(++Q>K)for(Q-=K;Q--;)U+="0";else if(Q<K)U=U.slice(0,Q)+"."+U.slice(Q)}U=(Z==16?"0x":Z==2?"0b":Z==8?"0o":"")+U}return $.s<0?"-"+U:U}function Ud($,Z){if($.length>Z)return $.length=Z,!0}function oq0($){return new this($).abs()}function sq0($){return new this($).acos()}function rq0($){return new this($).acosh()}function aq0($,Z){return new this($).plus(Z)}function tq0($){return new this($).asin()}function eq0($){return new this($).asinh()}function $M0($){return new this($).atan()}function ZM0($){return new this($).atanh()}function JM0($,Z){$=new this($),Z=new this(Z);var J,Y=this.precision,X=this.rounding,Q=Y+4;if(!$.s||!Z.s)J=new this(NaN);else if(!$.d&&!Z.d)J=y6(this,Q,1).times(Z.s>0?0.25:0.75),J.s=$.s;else if(!Z.d||$.isZero())J=Z.s<0?y6(this,Y,X):new this(0),J.s=$.s;else if(!$.d||Z.isZero())J=y6(this,Q,1).times(0.5),J.s=$.s;else if(Z.s<0)this.precision=Q,this.rounding=1,J=this.atan(g1($,Z,Q,1)),Z=y6(this,Q,1),this.precision=Y,this.rounding=X,J=$.s<0?J.minus(Z):J.plus(Z);else J=this.atan(g1($,Z,Q,1));return J}function YM0($){return new this($).cbrt()}function XM0($){return I0($=new this($),$.e+1,2)}function QM0($,Z,J){return new this($).clamp(Z,J)}function GM0($){if(!$||typeof $!=="object")throw Error(lK+"Object expected");var Z,J,Y,X=$.defaults===!0,Q=["precision",1,B5,"rounding",0,8,"toExpNeg",-zY,0,"toExpPos",0,zY,"maxE",0,zY,"minE",-zY,0,"modulo",0,9];for(Z=0;Z<Q.length;Z+=3){if(J=Q[Z],X)this[J]=dA[J];if((Y=$[J])!==void 0)if(o$(Y)===Y&&Y>=Q[Z+1]&&Y<=Q[Z+2])this[J]=Y;else throw Error(H5+J+": "+Y)}if(J="crypto",X)this[J]=dA[J];if((Y=$[J])!==void 0)if(Y===!0||Y===!1||Y===0||Y===1)if(Y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[J]=!0;else throw Error(Fd);else this[J]=!1;else throw Error(H5+J+": "+Y);return this}function WM0($){return new this($).cos()}function KM0($){return new this($).cosh()}function wd($){var Z,J,Y;function X(Q){var G,W,K,V=this;if(!(V instanceof X))return new X(Q);if(V.constructor=X,Hd(Q)){if(V.s=Q.s,n0)if(!Q.d||Q.e>X.maxE)V.e=NaN,V.d=null;else if(Q.e<X.minE)V.e=0,V.d=[0];else V.e=Q.e,V.d=Q.d.slice();else V.e=Q.e,V.d=Q.d?Q.d.slice():Q.d;return}if(K=typeof Q,K==="number"){if(Q===0){V.s=1/Q<0?-1:1,V.e=0,V.d=[0];return}if(Q<0)Q=-Q,V.s=-1;else V.s=1;if(Q===~~Q&&Q<1e7){for(G=0,W=Q;W>=10;W/=10)G++;if(n0)if(G>X.maxE)V.e=NaN,V.d=null;else if(G<X.minE)V.e=0,V.d=[0];else V.e=G,V.d=[Q];else V.e=G,V.d=[Q];return}if(Q*0!==0){if(!Q)V.s=NaN;V.e=NaN,V.d=null;return}return hK(V,Q.toString())}if(K==="string"){if((W=Q.charCodeAt(0))===45)Q=Q.slice(1),V.s=-1;else{if(W===43)Q=Q.slice(1);V.s=1}return Od.test(Q)?hK(V,Q):iq0(V,Q)}if(K==="bigint"){if(Q<0)Q=-Q,V.s=-1;else V.s=1;return hK(V,Q.toString())}throw Error(H5+Q)}if(X.prototype=Y0,X.ROUND_UP=0,X.ROUND_DOWN=1,X.ROUND_CEIL=2,X.ROUND_FLOOR=3,X.ROUND_HALF_UP=4,X.ROUND_HALF_DOWN=5,X.ROUND_HALF_EVEN=6,X.ROUND_HALF_CEIL=7,X.ROUND_HALF_FLOOR=8,X.EUCLID=9,X.config=X.set=GM0,X.clone=wd,X.isDecimal=Hd,X.abs=oq0,X.acos=sq0,X.acosh=rq0,X.add=aq0,X.asin=tq0,X.asinh=eq0,X.atan=$M0,X.atanh=ZM0,X.atan2=JM0,X.cbrt=YM0,X.ceil=XM0,X.clamp=QM0,X.cos=WM0,X.cosh=KM0,X.div=VM0,X.exp=UM0,X.floor=HM0,X.hypot=BM0,X.ln=zM0,X.log=FM0,X.log10=OM0,X.log2=AM0,X.max=jM0,X.min=NM0,X.mod=qM0,X.mul=MM0,X.pow=DM0,X.random=wM0,X.round=LM0,X.sign=TM0,X.sin=RM0,X.sinh=PM0,X.sqrt=CM0,X.sub=IM0,X.sum=EM0,X.tan=bM0,X.tanh=_M0,X.trunc=SM0,$===void 0)$={};if($){if($.defaults!==!0){Y=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(Z=0;Z<Y.length;)if(!$.hasOwnProperty(J=Y[Z++]))$[J]=this[J]}}return X.config($),X}function VM0($,Z){return new this($).div(Z)}function UM0($){return new this($).exp()}function HM0($){return I0($=new this($),$.e+1,3)}function BM0(){var $,Z,J=new this(0);n0=!1;for($=0;$<arguments.length;)if(Z=new this(arguments[$++]),!Z.d){if(Z.s)return n0=!0,new this(1/0);J=Z}else if(J.d)J=J.plus(Z.times(Z));return n0=!0,J.sqrt()}function Hd($){return $ instanceof B6||$&&$.toStringTag===Ad||!1}function zM0($){return new this($).ln()}function FM0($,Z){return new this($).log(Z)}function AM0($){return new this($).log(2)}function OM0($){return new this($).log(10)}function jM0(){return qd(this,arguments,-1)}function NM0(){return qd(this,arguments,1)}function qM0($,Z){return new this($).mod(Z)}function MM0($,Z){return new this($).mul(Z)}function DM0($,Z){return new this($).pow(Z)}function wM0($){var Z,J,Y,X,Q=0,G=new this(1),W=[];if($===void 0)$=this.precision;else A8($,1,B5);if(Y=Math.ceil($/x0),!this.crypto)for(;Q<Y;)W[Q++]=Math.random()*1e7|0;else if(crypto.getRandomValues){Z=crypto.getRandomValues(new Uint32Array(Y));for(;Q<Y;)if(X=Z[Q],X>=4290000000)Z[Q]=crypto.getRandomValues(new Uint32Array(1))[0];else W[Q++]=X%1e7}else if(crypto.randomBytes){Z=crypto.randomBytes(Y*=4);for(;Q<Y;)if(X=Z[Q]+(Z[Q+1]<<8)+(Z[Q+2]<<16)+((Z[Q+3]&127)<<24),X>=2140000000)crypto.randomBytes(4).copy(Z,Q);else W.push(X%1e7),Q+=4;Q=Y/4}else throw Error(Fd);if(Y=W[--Q],$%=x0,Y&&$)X=N$(10,x0-$),W[Q]=(Y/X|0)*X;for(;W[Q]===0;Q--)W.pop();if(Q<0)J=0,W=[0];else{J=-1;for(;W[0]===0;J-=x0)W.shift();for(Y=1,X=W[0];X>=10;X/=10)Y++;if(Y<x0)J-=x0-Y}return G.e=J,G.d=W,G}function LM0($){return I0($=new this($),$.e+1,this.rounding)}function TM0($){return $=new this($),$.d?$.d[0]?$.s:0*$.s:$.s||NaN}function RM0($){return new this($).sin()}function PM0($){return new this($).sinh()}function CM0($){return new this($).sqrt()}function IM0($,Z){return new this($).sub(Z)}function EM0(){var $=0,Z=arguments,J=new this(Z[$]);n0=!1;for(;J.s&&++$<Z.length;)J=J.plus(Z[$]);return n0=!0,I0(J,this.precision,this.rounding)}function bM0($){return new this($).tan()}function _M0($){return new this($).tanh()}function SM0($){return I0($=new this($),$.e+1,1)}Y0[Symbol.for("nodejs.util.inspect.custom")]=Y0.toString;Y0[Symbol.toStringTag]="Decimal";var B6=Y0.constructor=wd(dA);gK=new B6(gK);uK=new B6(uK);var fM0=O.String.annotate({[A$]:p1.schema("workspace")}).pipe(O.brand("WorkspaceID")),nA=fM0.pipe(g0(($)=>({ascending:(Z)=>$.make(p1.ascending("workspace",Z)),zod:p1.schema("workspace").pipe(P.custom())})));function cK($){let Z={};for(let[J,Y]of Object.entries($.required().shape))Z[J]=Y.nullable();return P.object(Z)}var Ld=_0.create({service:"session.usage"});function kM0($){return/^(New session - |Child session - )\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test($)}function OY($){let Z=$.summary_additions!==null||$.summary_deletions!==null||$.summary_files!==null?{additions:$.summary_additions??0,deletions:$.summary_deletions??0,files:$.summary_files??0,diffs:$.summary_diffs??void 0}:void 0,J=$.share_url?{url:$.share_url}:void 0,Y=$.revert??void 0;return{id:$.id,slug:$.slug,projectID:$.project_id,workspaceID:$.workspace_id??void 0,directory:$.directory,parentID:$.parent_id??void 0,contextFrom:$.context_from??void 0,contextWatermark:$.context_watermark??void 0,title:$.title,version:$.version,summary:Z,share:J,revert:Y,permission:$.permission??void 0,time:{created:$.time_created,updated:$.time_updated,compacting:$.time_compacting??void 0,archived:$.time_archived??void 0}}}function vM0($){return{id:$.id,project_id:$.projectID,workspace_id:$.workspaceID,parent_id:$.parentID,context_from:$.contextFrom,context_watermark:$.contextWatermark,slug:$.slug,directory:$.directory,title:$.title,version:$.version,share_url:$.share?.url,summary_additions:$.summary?.additions,summary_deletions:$.summary?.deletions,summary_files:$.summary?.files,summary_diffs:$.summary?.diffs,revert:$.revert??null,permission:$.permission,time_created:$.time.created,time_updated:$.time.updated,time_compacting:$.time.compacting,time_archived:$.time.archived}}var z6=P.object({id:a0.zod,slug:P.string(),projectID:$Q.zod,workspaceID:nA.zod.optional(),directory:P.string(),parentID:a0.zod.optional(),contextFrom:a0.zod.optional(),contextWatermark:o1.zod.optional(),summary:P.object({additions:P.number(),deletions:P.number(),files:P.number(),diffs:yZ.FileDiff.array().optional()}).optional(),share:P.object({url:P.string()}).optional(),title:P.string(),version:P.string(),time:P.object({created:P.number(),updated:P.number(),compacting:P.number().optional(),archived:P.number().optional()}),permission:G5.Ruleset.zod.optional(),revert:P.object({messageID:o1.zod,partID:MZ.zod.optional(),snapshot:P.string().optional(),diff:P.string().optional()}).optional()}).meta({ref:"Session"}),Td=P.object({id:$Q.zod,name:P.string().optional(),worktree:P.string()}).meta({ref:"ProjectSummary"}),yM0=z6.extend({project:Td.nullable()}).meta({ref:"GlobalSession"}),xM0=P.object({parentID:a0.zod.optional(),contextFrom:a0.zod.optional(),contextWatermark:o1.zod.optional(),title:P.string().optional(),permission:z6.shape.permission,workspaceID:nA.zod.optional()}).optional(),hM0=P.object({sessionID:a0.zod,messageID:o1.zod.optional()}),gM0=a0.zod,uM0=a0.zod,mM0=a0.zod,lM0=P.object({sessionID:a0.zod,title:P.string()}),dM0=P.object({sessionID:a0.zod,time:P.number().optional()}),pM0=P.object({sessionID:a0.zod,permission:G5.Ruleset.zod}),cM0=P.object({sessionID:a0.zod,revert:z6.shape.revert,summary:z6.shape.summary}),iM0=P.object({sessionID:a0.zod,limit:P.number().optional()}),jY={Created:Q$.define({type:"session.created",version:1,aggregate:"sessionID",schema:P.object({sessionID:a0.zod,info:z6})}),Updated:Q$.define({type:"session.updated",version:1,aggregate:"sessionID",schema:P.object({sessionID:a0.zod,info:cK(z6).extend({share:cK(z6.shape.share.unwrap()).optional(),time:cK(z6.shape.time).optional()})}),busSchema:P.object({sessionID:a0.zod,info:z6})}),Deleted:Q$.define({type:"session.deleted",version:1,aggregate:"sessionID",schema:P.object({sessionID:a0.zod,info:z6})}),Diff:T1.define("session.diff",P.object({sessionID:a0.zod,diff:yZ.FileDiff.array()})),Error:T1.define("session.error",P.object({sessionID:a0.zod.optional(),error:P.lazy(()=>_$.Assistant.shape.error)})),RetryAttempt:T1.define("session.retry.attempt",P.object({sessionID:a0.zod,messageID:P.string(),attempt:P.number().int().min(1),maxAttempts:P.number().int().min(1),reason:P.string(),nextDelayMs:P.number().int().nonnegative()}))};function nM0($){let Z=S8.project.vcs?oA.join(S8.worktree,".qitqode","plans"):oA.join(A0.Path.data,"plans");return oA.join(Z,[$.time.created,$.slug].join("-")+".md")}var oM0=($)=>{let Z=(N)=>{if(!Number.isFinite(N))return 0;return N},J=Z($.usage.inputTokens??0),Y=Z($.usage.outputTokens??0),X=Z($.usage.outputTokenDetails?.reasoningTokens??$.usage.reasoningTokens??0),Q=Z($.usage.inputTokenDetails?.cacheReadTokens??$.usage.cachedInputTokens??0),G=Z(Number($.usage.inputTokenDetails?.cacheWriteTokens??$.metadata?.anthropic?.cacheCreationInputTokens??$.metadata?.vertex?.cacheCreationInputTokens??$.metadata?.bedrock?.usage?.cacheWriteInputTokens??$.metadata?.venice?.usage?.cacheCreationInputTokens??0)),W=Z(J-Q-G),V={total:$.usage.totalTokens,input:W,output:Z(Y-X),reasoning:X,cache:{write:G,read:Q}},U=$.usage.raw,H=typeof U?.cost_usd==="number"?U.cost_usd:void 0,B=typeof U?.cost_credits==="number"?U.cost_credits:void 0,z=typeof U?.context_window==="number"?U.context_window:void 0;if(H!==void 0){let N={cost:Z(H),costCredits:Z(B??H),tokens:V,contextWindow:z};return Ld.info("usage",{provider:$.model.providerID,model:$.model.id,source:"qlex",tokens:V,cost:N.cost,costCredits:N.costCredits}),N}let F=$.model.cost?.experimentalOver200K&&V.input+V.cache.read>200000?$.model.cost.experimentalOver200K:$.model.cost,A=Z(new B6(0).add(new B6(V.input).mul(F?.input??0).div(1e6)).add(new B6(V.output).mul(F?.output??0).div(1e6)).add(new B6(V.cache.read).mul(F?.cache?.read??0).div(1e6)).add(new B6(V.cache.write).mul(F?.cache?.write??0).div(1e6)).add(new B6(V.reasoning).mul(F?.output??0).div(1e6)).toNumber());return Ld.info("usage",{provider:$.model.providerID,model:$.model.id,source:"estimated",tokens:V,cost:A}),{cost:A,costCredits:void 0,tokens:V,contextWindow:z}};function*sM0($){let Z=S8.project,J=[m0(I1.project_id,Z.id)];if($?.workspaceID)J.push(m0(I1.workspace_id,$.workspaceID));if(!S0.QITQODE_EXPERIMENTAL_WORKSPACES){if($?.directory)J.push(m0(I1.directory,$.directory))}if($?.roots)J.push(iK(I1.parent_id));if($?.start)J.push(sA(I1.time_updated,$.start));if($?.search)J.push(rA(I1.title,`%${$.search}%`));let Y=$?.limit??100,X=W1.use((Q)=>Q.select().from(I1).where(j$(...J)).orderBy(o6(I1.time_updated)).limit(Y).all());for(let Q of X)yield OY(Q)}function*rM0($){let Z=[];if($?.directory)Z.push(m0(I1.directory,$.directory));if($?.roots)Z.push(iK(I1.parent_id));if($?.start)Z.push(sA(I1.time_updated,$.start));if($?.cursor)Z.push(WX(I1.time_updated,$.cursor));if($?.search)Z.push(rA(I1.title,`%${$.search}%`));if(!$?.archived)Z.push(iK(I1.time_archived));let J=$?.limit??100,Y=W1.use((G)=>{return(Z.length>0?G.select().from(I1).where(j$(...Z)):G.select().from(I1)).orderBy(o6(I1.time_updated),o6(I1.id)).limit(J).all()}),X=[...new Set(Y.map((G)=>G.project_id))],Q=new Map;if(X.length>0){let G=W1.use((W)=>W.select({id:AY.id,name:AY.name,worktree:AY.worktree}).from(AY).where(k5(AY.id,X)).all());for(let W of G)Q.set(W.id,{id:W.id,name:W.name??void 0,worktree:W.worktree})}for(let G of Y){let W=Q.get(G.project_id)??null;yield{...OY(G),project:W}}}var Rd=_0.create({service:"session"}),aM0="New session - ",tM0="Child session - ";function eM0($=!1){return($?tM0:aM0)+new Date().toISOString()}function $D0($){let Z=$.match(/^(.+) \(fork #(\d+)\)$/);if(Z){let J=Z[1],Y=parseInt(Z[2],10);return`${J} (fork #${Y+1})`}return`${$} (fork #1)`}class Pd extends Error{sessionID;constructor($){super(`Session ${$} is busy`);this.sessionID=$}}class nK extends S1.Service()("@qitqode/Session"){}var aA=($)=>T.sync(()=>W1.use($)),Cd=R0.effect(nK,T.gen(function*(){let $=yield*d1.Service,Z=yield*tA.Service,J=yield*BY.Service,Y=T.fn("Session.createNext")(function*(b){let k=yield*B0.context,u={id:a0.descending(b.id),slug:JV.create(),version:b$,projectID:k.project.id,directory:b.directory,workspaceID:b.workspaceID,parentID:b.parentID,contextFrom:b.contextFrom,contextWatermark:b.contextWatermark,title:b.title??eM0(!!b.parentID),permission:b.permission,time:{created:Date.now(),updated:Date.now()}};if(Rd.info("created",u),yield*T.sync(()=>Q$.run(jY.Created,{sessionID:u.id,info:u})),yield*J.register({sessionID:u.id,actorID:"main",mode:"main",parentActorID:void 0,agent:"main",description:"main agent",contextMode:"full",contextWatermark:void 0,background:!1,lifecycle:"persistent",tools:"INHERIT"}).pipe(T.ignore),!S0.QITQODE_EXPERIMENTAL_WORKSPACES)yield*$.publish(jY.Updated,{sessionID:u.id,info:u});return u}),X=T.fn("Session.get")(function*(b){let k=yield*aA((u)=>u.select().from(I1).where(m0(I1.id,b)).get());if(!k)throw new KX({message:`Session not found: ${b}`});return OY(k)}),Q=T.fn("Session.children")(function*(b){return(yield*aA((u)=>u.select().from(I1).where(j$(m0(I1.parent_id,b))).all())).map(OY)}),G=T.fnUntraced(function*(b){try{let k=yield*X(b),u=yield*Q(b);for(let g of u)yield*G(g.id);let x=yield*B0.directory.pipe(T.as(!0),T.catchCause(()=>T.succeed(!1)));yield*T.sync(()=>{Q$.run(jY.Deleted,{sessionID:b,info:k},{publish:x}),Q$.remove(b)})}catch(k){Rd.error(k)}}),W=(b)=>T.gen(function*(){return yield*T.sync(()=>Q$.run(_$.Event.Updated,{sessionID:b.sessionID,info:b})),b}).pipe(T.withSpan("Session.updateMessage")),K=(b)=>{let k={...b};if(k.state){if(k.state={...k.state},k.state.time)k.state.time={...k.state.time}}return k},V=(b)=>T.gen(function*(){return yield*T.sync(()=>Q$.run(_$.Event.PartUpdated,{sessionID:b.sessionID,part:K(b),time:Date.now()})),b}).pipe(T.withSpan("Session.updatePart")),U=T.fn("Session.getPart")(function*(b){let k=W1.use((u)=>u.select().from(C8).where(j$(m0(C8.session_id,b.sessionID),m0(C8.message_id,b.messageID),m0(C8.id,b.partID))).get());if(!k)return;return{...k.data,id:k.id,sessionID:k.session_id,messageID:k.message_id}}),H=T.fn("Session.create")(function*(b){let k=yield*B0.directory,u=yield*B0.workspaceID;return yield*Y({parentID:b?.parentID,contextFrom:b?.contextFrom,contextWatermark:b?.contextWatermark,directory:k,title:b?.title,permission:b?.permission,workspaceID:u})}),B=T.fn("Session.fork")(function*(b){let k=yield*B0.directory,u=yield*X(b.sessionID),x=$D0(u.title),g=yield*Y({directory:k,workspaceID:u.workspaceID,title:x}),c=yield*R({sessionID:b.sessionID,agentID:"*"}),e=new Map;for(let G0 of c){if(b.messageID&&G0.info.id>=b.messageID)break;let Q0=o1.ascending();e.set(G0.info.id,Q0);let z0=G0.info.role==="assistant"&&G0.info.parentID?e.get(G0.info.parentID):void 0,u0=yield*W({...G0.info,sessionID:g.id,id:Q0,...z0&&{parentID:z0}});for(let m of G0.parts)yield*V({...m,id:MZ.ascending(),messageID:u0.id,sessionID:g.id})}return g}),z=(b,k)=>T.sync(()=>Q$.run(jY.Updated,{sessionID:b,info:k})),F=T.fn("Session.touch")(function*(b){yield*z(b,{time:{updated:Date.now()}})}),A=T.fn("Session.setTitle")(function*(b){yield*z(b.sessionID,{title:b.title})}),N=T.fn("Session.setArchived")(function*(b){yield*z(b.sessionID,{time:{archived:b.time}})}),q=T.fn("Session.setPermission")(function*(b){yield*z(b.sessionID,{permission:b.permission,time:{updated:Date.now()}})}),w=T.fn("Session.setRevert")(function*(b){yield*z(b.sessionID,{summary:b.summary,time:{updated:Date.now()},revert:b.revert})}),j=T.fn("Session.clearRevert")(function*(b){yield*z(b,{time:{updated:Date.now()},revert:null})}),M=T.fn("Session.setSummary")(function*(b){yield*z(b.sessionID,{time:{updated:Date.now()},summary:b.summary})}),I=T.fn("Session.diff")(function*(b){return yield*Z.read(["session_diff",b]).pipe(T.orElseSucceed(()=>[]))}),R=T.fn("Session.messages")(function*(b){if(b.limit)return _$.page({sessionID:b.sessionID,limit:b.limit,agentID:b.agentID}).items;return Array.from(_$.stream(b.sessionID,{agentID:b.agentID})).reverse()}),L=T.fn("Session.removeMessage")(function*(b){return yield*T.sync(()=>Q$.run(_$.Event.Removed,{sessionID:b.sessionID,messageID:b.messageID})),b.messageID}),C=T.fn("Session.removePart")(function*(b){return yield*T.sync(()=>Q$.run(_$.Event.PartRemoved,{sessionID:b.sessionID,messageID:b.messageID,partID:b.partID})),b.partID}),_=T.fnUntraced(function*(b){yield*$.publish(_$.Event.PartDelta,b)}),E=T.fn("Session.findMessage")(function*(b,k,u){for(let x of _$.stream(b,{agentID:u?.agentID}))if(k(x))return O1.some(x);return O1.none()}),f=T.fn("Session.lastMainMessageID")(function*(b){return(yield*aA((u)=>u.select({id:L$.id}).from(L$).where(j$(m0(L$.session_id,b),m0(L$.agent_id,"main"))).orderBy(o6(L$.id)).limit(1).get()))?.id});return nK.of({create:H,fork:B,touch:F,get:X,setTitle:A,setArchived:N,setPermission:q,setRevert:w,clearRevert:j,setSummary:M,diff:I,messages:R,children:Q,remove:G,updateMessage:W,removeMessage:L,removePart:C,updatePart:V,getPart:U,updatePartDelta:_,findMessage:E,lastMainMessageID:f})})),ZD0=Cd.pipe(R0.provide(BY.defaultLayer),R0.provide(d1.layer),R0.provide(tA.defaultLayer));export{d1 as sj,k8 as tj,hY as uj,vQ as vj,d7 as wj,o7 as xj,Yq as yj,CZ as zj,oD as Aj,aD as Bj,bU as Cj,JV as Dj,_8 as Ej,zQ as Fj,p1 as Gj,Q$ as Hj,a0 as Ij,o1 as Jj,MZ as Kj,UN as Lj,xV as Mj,X4 as Nj,G4 as Oj,vU as Pj,ja as Qj,QX as Rj,VJ as Sj,qa as Tj,yw as Uj,yZ as Vj,r0 as Wj,a1 as Xj,Y_0 as Yj,z_0 as Zj,A_0 as _j,j_0 as $j,ae as ak,m_0 as bk,l_0 as ck,UW as dk,d3 as ek,BK as fk,r9 as gk,a9 as hk,oh0 as ik,sh0 as jk,rh0 as kk,UN0 as lk,$g0 as mk,Zg0 as nk,eu as ok,Jg0 as pk,Zm as qk,Jm as rk,j7 as sk,G5 as tk,Um as uk,wN0 as vk,kg0 as wk,Hm as xk,pg0 as yk,ig0 as zk,ng0 as Ak,CA as Bk,vm as Ck,nA as Dk,Vu0 as Ek,Uu0 as Fk,Yd as Gk,qd0 as Hk,Md0 as Ik,Qd as Jk,BY as Kk,EA as Lk,AZ as Mk,XQ as Nk,q7 as Ok,ul as Pk,rl as Qk,_$ as Rk,kM0 as Sk,vM0 as Tk,jY as Uk,nM0 as Vk,oM0 as Wk,Pd as Xk,nK as Yk,ZD0 as Zk,YQ as _k,Q8 as $k};
|