@desplega.ai/agent-swarm 2.14.0 → 2.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-q1vz4hh2.js +17 -0
- package/dist/{acp-targets-23exz4z4.js → acp-targets-d44eerh4.js} +10 -10
- package/dist/{actions-zcr25x27.js → actions-z4k4bvss.js} +28 -28
- package/dist/{agent-fs-provision-7fa9e12e.js → agent-fs-provision-aan1cgpx.js} +4 -4
- package/dist/{amp-adapter-s7ytmv6b.js → amp-adapter-wac3py0p.js} +3 -3
- package/dist/{anthropic-messages-vdd1zmha.js → anthropic-messages-njt2r5m4.js} +28 -27
- package/dist/{app-5d3sz1hy.js → app-wax6qz5e.js} +10 -10
- package/dist/{approval-notifications-7qgkzkzx.js → approval-notifications-6fvkhnma.js} +11 -11
- package/dist/{assistant-p2yvhc3j.js → assistant-e8fe08zx.js} +29 -29
- package/dist/{azure-openai-responses-jeaas6x0.js → azure-openai-responses-6ewf9rwp.js} +6 -6
- package/dist/{boot-args-schema-ry6cb0p7.js → boot-args-schema-rv97cmnt.js} +1 -1
- package/dist/{boot-reembed-c9643ms3.js → boot-reembed-bcn7frk9.js} +1 -1
- package/dist/{boot-reembed-2hkm3vz2.js → boot-reembed-xakrdy6y.js} +1 -1
- package/dist/{boot-scrub-sweep-3ycxr51t.js → boot-scrub-sweep-20t8akhf.js} +2 -2
- package/dist/{boot-seeds-2hzvvzg0.js → boot-seeds-48rr6r29.js} +4 -4
- package/dist/{boxd-9py3x0jb.js → boxd-tjpxwecx.js} +3 -3
- package/dist/{claude-adapter-dnkww93e.js → claude-adapter-0wzwntrj.js} +12 -13
- package/dist/{claude-managed-adapter-yk0cr5x6.js → claude-managed-adapter-4xcgt46w.js} +4 -4
- package/dist/{claude-managed-setup-4byxpp47.js → claude-managed-setup-91cyktw7.js} +7 -7
- package/dist/{claude-sdk-session-4wf3dbvs.js → claude-sdk-session-ngj4dce5.js} +11144 -12464
- package/dist/{cli-gcyws2bp.js → cli-021hrewp.js} +2 -2
- package/dist/{cli-wvgg7r4j.js → cli-08gfvs58.js} +2 -2
- package/dist/{cli-2zjxake1.js → cli-0kyjrbaa.js} +4 -4
- package/dist/{cli-rp1n2xpd.js → cli-0nvqg1hb.js} +1 -1
- package/dist/{cli-vxmmttmt.js → cli-0nz04gqv.js} +50 -50
- package/dist/{cli-vr4eyq6p.js → cli-0rrft7s3.js} +538 -410
- package/dist/{cli-mw1tmn3x.js → cli-1d9q7qrn.js} +7 -7
- package/dist/{cli-84xn7bgz.js → cli-1t5vhrpv.js} +1 -1
- package/dist/{cli-hzhv7yac.js → cli-1zbj28py.js} +1 -1
- package/dist/{cli-z8t4485r.js → cli-2ja7eadd.js} +2 -2
- package/dist/{cli-r04ve9xw.js → cli-2r62jy9s.js} +1 -1
- package/dist/{cli-9fwznq4p.js → cli-3ffzr65w.js} +7 -7
- package/dist/{cli-2ckwgs7q.js → cli-3kdgm393.js} +5 -5
- package/dist/{cli-jwnac23b.js → cli-3vc518cw.js} +1 -1
- package/dist/{cli-6p8p2e6r.js → cli-5188hq0a.js} +1286 -31
- package/dist/{cli-zcghfsdg.js → cli-53gt8wfv.js} +1 -1
- package/dist/{cli-930zbczq.js → cli-5njmmmer.js} +3 -3
- package/dist/{cli-dw9rtjm3.js → cli-5rw7nt99.js} +3061 -727
- package/dist/{cli-6c61yjwy.js → cli-5xx353cy.js} +7554 -1534
- package/dist/{cli-2ap1the6.js → cli-65k149j5.js} +2 -2
- package/dist/{cli-v41kn3cd.js → cli-6prwz0zn.js} +4427 -5566
- package/dist/{cli-yd7e590v.js → cli-6zpn5hmp.js} +12 -12
- package/dist/{cli-ty3gha1p.js → cli-7b9bwrfg.js} +2 -2
- package/dist/{cli-2414h5r9.js → cli-7dpdq7yh.js} +11428 -1914
- package/dist/{cli-r9d2tya0.js → cli-7qkbab03.js} +5 -5
- package/dist/{cli-7ca8hczj.js → cli-7svwhw1a.js} +1 -1
- package/dist/cli-7wwewkf4.js +37 -0
- package/dist/{cli-ejnhs815.js → cli-83hynhes.js} +17 -13
- package/dist/{cli-rs1rzwp4.js → cli-8crn0510.js} +1 -1
- package/dist/{cli-f2rwt43y.js → cli-8ee7xt75.js} +13 -13
- package/dist/{cli-9j47sgzy.js → cli-8ef94zm2.js} +2 -2
- package/dist/{cli-9fvk9mv8.js → cli-8gr1bg9t.js} +1 -1
- package/dist/{cli-b0m3bg0f.js → cli-9j1qcs0b.js} +1 -1
- package/dist/{cli-ad00h1st.js → cli-9mvfvggt.js} +7 -7
- package/dist/{cli-xh5fpmg8.js → cli-9txap41q.js} +101 -18
- package/dist/{cli-24wervhz.js → cli-aktk3qt6.js} +3 -3
- package/dist/{cli-6ajyhxh7.js → cli-an8bpy60.js} +2 -2
- package/dist/{cli-meydjstb.js → cli-azptj8xe.js} +5591 -69
- package/dist/cli-c0rt16vk.js +15 -0
- package/dist/{cli-w4bvtxet.js → cli-c6vhcknq.js} +7 -7
- package/dist/{cli-2savn6mm.js → cli-cczffwak.js} +7 -7
- package/dist/{cli-ze1ndjs4.js → cli-cgmka83w.js} +3 -3
- package/dist/{cli-kc7vd07m.js → cli-d13qgcct.js} +3699 -1733
- package/dist/{cli-k3facve0.js → cli-d5nvy1jy.js} +1 -1
- package/dist/{cli-edxfzgah.js → cli-dev6f0px.js} +4 -4
- package/dist/{cli-0e914dp9.js → cli-dzhht0vq.js} +3 -3
- package/dist/{cli-m0ea8ggd.js → cli-e13kbyq0.js} +2 -2
- package/dist/{cli-73rmgm45.js → cli-e2k0ej0d.js} +2 -2
- package/dist/cli-ek8b88kv.js +9740 -0
- package/dist/{cli-0k7ppk9k.js → cli-ertcjw6z.js} +281 -46
- package/dist/{cli-qrwjk4xy.js → cli-f3ta4e67.js} +5 -5
- package/dist/{cli-1nfabrt4.js → cli-f4xv7s0t.js} +7 -7
- package/dist/{cli-phe2vcw5.js → cli-fdam1t9b.js} +171 -104
- package/dist/{cli-gc6b94tj.js → cli-fe8he9cy.js} +2 -2
- package/dist/{cli-spfz393q.js → cli-feh37wgs.js} +598 -219
- package/dist/{cli-ebqx630g.js → cli-fjzjtqna.js} +35 -18
- package/dist/{cli-37p61fcg.js → cli-fs9t2m2k.js} +18 -20
- package/dist/{cli-7w1fs01q.js → cli-g03x26q6.js} +2 -2
- package/dist/{cli-879txsac.js → cli-gnkzh8ed.js} +4 -4
- package/dist/{cli-v4z5v3jd.js → cli-gy0r7gb8.js} +514 -337
- package/dist/{cli-s4pccby1.js → cli-h0edykd1.js} +1 -1
- package/dist/{cli-pq0kv31y.js → cli-h364asjc.js} +9 -9
- package/dist/{cli-69szn7w7.js → cli-h3xcfp4c.js} +93 -54
- package/dist/{cli-jcnc5ret.js → cli-h8k5801a.js} +73 -27
- package/dist/{cli-6yy4fepf.js → cli-h96yp7xv.js} +4 -4
- package/dist/{cli-q5n3deaf.js → cli-hab0bvrh.js} +1 -1
- package/dist/{cli-g6a696c0.js → cli-j3wqt73b.js} +4 -4
- package/dist/{cli-wym6rxgt.js → cli-jfgaz10x.js} +10 -15
- package/dist/{cli-shyhb4t5.js → cli-jrhvywah.js} +53 -52
- package/dist/{cli-qkbevqer.js → cli-jrxt5j0n.js} +3 -3
- package/dist/{cli-7b7rxz22.js → cli-jw7n9pct.js} +5 -2
- package/dist/{cli-8vbxjzk0.js → cli-k9kfck3s.js} +3 -3
- package/dist/{cli-yjb3cddd.js → cli-kkwq5b12.js} +1 -1
- package/dist/{cli-39t9d248.js → cli-kz8rar0g.js} +1 -1
- package/dist/{cli-rzbsh6bw.js → cli-n15fhd43.js} +1 -1
- package/dist/{cli-1jx0srjt.js → cli-nc842kc9.js} +1921 -80
- package/dist/{cli-9j1t3kf6.js → cli-nmj4phcg.js} +2 -2
- package/dist/{cli-t9pzz2eq.js → cli-ntmjzyte.js} +4 -1
- package/dist/{cli-adzmmcvf.js → cli-praaw1wh.js} +2 -2
- package/dist/{cli-f9g96z28.js → cli-q44p4869.js} +11 -11
- package/dist/{cli-fww016hh.js → cli-q58qt9dw.js} +1711 -7287
- package/dist/{cli-njvpngc6.js → cli-qqz5z36e.js} +3 -3
- package/dist/{cli-096aftq6.js → cli-r7rpy2xz.js} +7 -7
- package/dist/cli-rcqgr0hs.js +30 -0
- package/dist/{cli-ph95yejc.js → cli-rjc464jg.js} +2 -2
- package/dist/{cli-md4tn21h.js → cli-rw3m83j4.js} +40 -26
- package/dist/cli-rwcj6wt3.js +1291 -0
- package/dist/{cli-srq69pn1.js → cli-ryn4y478.js} +1 -1
- package/dist/{cli-jgq9xptq.js → cli-s48k2rzx.js} +4 -4
- package/dist/{cli-cbg0j1yt.js → cli-s90wcbk9.js} +3 -3
- package/dist/{cli-2ayk9gn8.js → cli-svcy72s5.js} +2 -2
- package/dist/{cli-4dyzzkfb.js → cli-swtwbg85.js} +944 -170
- package/dist/{cli-mv8ft7b0.js → cli-t1bqpzgz.js} +3 -3
- package/dist/{cli-tc165vrb.js → cli-t5jbjq61.js} +4 -3
- package/dist/{cli-enavhq6r.js → cli-tbrjvrrg.js} +1 -1
- package/dist/{cli-mz7ycqn8.js → cli-td2h8zej.js} +6 -6
- package/dist/{cli-9t7syepg.js → cli-ttatvwn6.js} +1 -1
- package/dist/{cli-ayxxkk3p.js → cli-txxcf9s1.js} +8 -8
- package/dist/{cli-q4z9s6zs.js → cli-v7az4d1g.js} +2 -2
- package/dist/cli-vqt44168.js +14 -0
- package/dist/{cli-q457ga28.js → cli-vs9h3vw2.js} +14 -14
- package/dist/{cli-snxhtehz.js → cli-w2fg8kjc.js} +7 -8
- package/dist/{cli-wd7b5hgc.js → cli-w81s97bn.js} +1 -1
- package/dist/{cli-bqfx72e6.js → cli-wkzrknpt.js} +1 -1
- package/dist/{cli-cg1q8ymp.js → cli-wqpvfq2m.js} +1 -1
- package/dist/{cli-kg63yp1r.js → cli-wz7qj1jy.js} +19 -19
- package/dist/{cli-3wsabyt0.js → cli-x5t54ytt.js} +2 -2
- package/dist/{cli-r495stwd.js → cli-xd6ntv7x.js} +2 -2
- package/dist/{cli-wvbaq052.js → cli-xphbv66z.js} +10 -3
- package/dist/{cli-a49frv85.js → cli-xxgqn93n.js} +3753 -1186
- package/dist/{cli-91amj3md.js → cli-z209g721.js} +111 -87
- package/dist/{cli-3mhdmcd4.js → cli-z5andw8k.js} +1 -1
- package/dist/{cli-7g5qj2ca.js → cli-zcb64xzv.js} +1 -1
- package/dist/{cli-0h6m6z5g.js → cli-zr2sc5tr.js} +1 -1
- package/dist/{cli-krk8y8c7.js → cli-zrm0610v.js} +1833 -518
- package/dist/cli.js +73 -73
- package/dist/{cloudflare-workers-ai-system-one-w3m0fbf8.js → cloudflare-workers-ai-system-one-kb0tq22h.js} +2 -2
- package/dist/{codex-adapter-eq61radw.js → codex-adapter-0c1ynrmt.js} +9 -9
- package/dist/{codex-hook-8nmepvz6.js → codex-hook-w5nmtrn2.js} +2 -2
- package/dist/{codex-login-vbd9707w.js → codex-login-67qarfcg.js} +1 -1
- package/dist/{codex-session-runner-rfx355h4.js → codex-session-runner-z4t9z7yy.js} +10 -10
- package/dist/{commands-d1z0sx62.js → commands-h0jxqdhk.js} +3 -3
- package/dist/{controller-9hz6d8x3.js → controller-4ygy66hv.js} +4 -4
- package/dist/{controllers-connect-tz07d2xr.js → controllers-connect-ynbvv8pv.js} +28 -28
- package/dist/core-mj9fzrcm.js +41 -0
- package/dist/{cursor-adapter-ef22ze3j.js → cursor-adapter-9e4d6658.js} +2 -2
- package/dist/{db-gd81d68c.js → db-bg0hxjq1.js} +3 -3
- package/dist/{db-vrckks6q.js → db-q12gmpns.js} +2 -2
- package/dist/{devin-adapter-kdt6a2bh.js → devin-adapter-tn1twrha.js} +1 -1
- package/dist/{devtools-qxfgbsqz.js → devtools-t8my9az6.js} +1 -1
- package/dist/{dispatcher-76as8w2t.js → dispatcher-v5dbfscq.js} +24 -24
- package/dist/{docker-51ta7jsh.js → docker-6007r2fj.js} +2 -2
- package/dist/{dsh-adapter-ypfvcdyz.js → dsh-adapter-z3fneea1.js} +2 -2
- package/dist/{e2b-05kn3kpq.js → e2b-k3kb8b52.js} +4 -4
- package/dist/{e2b-dm9r8hpy.js → e2b-p269awh6.js} +5 -5
- package/dist/{easter-egg-3d-sg21j15g.js → easter-egg-3d-y49v5z90.js} +1 -1
- package/dist/{embedding-space-zsdw37bb.js → embedding-space-mjt5ksq0.js} +5 -5
- package/dist/{embeddings-p4e3e1m6.js → embeddings-td9hgnc5.js} +1 -1
- package/dist/emscripten-module-Q67P5WYC-3sde6cre.js +2458 -0
- package/dist/{event-bus-tvf2grf4.js → event-bus-pawddp92.js} +1 -1
- package/dist/{execute-nztd0af0.js → execute-z8nc8bba.js} +1 -1
- package/dist/{external-channel-717yzn4d.js → external-channel-pjenc2ag.js} +2 -2
- package/dist/ffi-cbfmmtqk.js +85 -0
- package/dist/fx-adapter-pjeztp0n.js +20 -0
- package/dist/getMachineId-bsd-hjs2tbdp.js +36 -0
- package/dist/getMachineId-darwin-kzbvr8s3.js +40 -0
- package/dist/getMachineId-linux-embmcq2c.js +26 -0
- package/dist/getMachineId-unsupported-jvznc6d4.js +20 -0
- package/dist/getMachineId-win-qr8z0b13.js +36 -0
- package/dist/{google-generative-ai-sw77egmr.js → google-generative-ai-tf3w7557.js} +11 -16
- package/dist/{google-vertex-rrw93g8h.js → google-vertex-9pj87bd8.js} +15 -17
- package/dist/grok-adapter-davbhx8t.js +20 -0
- package/dist/handlers-rf130hnp.js +39 -0
- package/dist/heartbeat-9hmvqxk0.js +49 -0
- package/dist/hook-0b1jqs2t.js +21 -0
- package/dist/{hook-ctz0xmp3.js → hook-1n0sjv8p.js} +10 -11
- package/dist/{http-zregegrx.js → http-vykejyjx.js} +432 -170
- package/dist/{index-7dgxveck.js → index-07d66kdm.js} +3 -3
- package/dist/index-0hgjxqz8.js +10584 -0
- package/dist/{index-rz8ve510.js → index-0nt39qwy.js} +2 -2
- package/dist/{index-ym9fgxad.js → index-2xbxq71g.js} +2 -2
- package/dist/{index-42jq9yy3.js → index-3j8hffkb.js} +12327 -7450
- package/dist/index-8w09aggw.js +43 -0
- package/dist/{index-5kx15d19.js → index-b3wy4jzs.js} +1 -1
- package/dist/{index-kzdqn3dd.js → index-dt9vr7tb.js} +3143 -760
- package/dist/{index-maddg9ys.js → index-ezfas4jj.js} +5858 -15337
- package/dist/index-g2jntx15.js +38 -0
- package/dist/{index-x9qf8dg7.js → index-j6sqtb83.js} +105 -75
- package/dist/{index-m6g8q65g.js → index-na0tczq0.js} +9268 -10220
- package/dist/{index-whysn1wf.js → index-p9dkwhwe.js} +1 -1
- package/dist/{index-126v2d0t.js → index-pe2etczf.js} +6 -2918
- package/dist/{index-mtnbhe12.js → index-q60mhcpd.js} +23631 -19921
- package/dist/index-qffex5k4.js +41 -0
- package/dist/index-qrp11tp9.js +4 -0
- package/dist/{index-kdmkfjt7.js → index-ryyrg0d8.js} +3426 -2333
- package/dist/{index-t17p395x.js → index-sf06w57a.js} +13 -13
- package/dist/{index-evay0xyk.js → index-vybnwd5v.js} +1 -1
- package/dist/{index-fdym6ryb.js → index-wsf1f5pe.js} +28 -28
- package/dist/{k8s-ejkk0aw7.js → k8s-mr1r12th.js} +2 -2
- package/dist/{keepalive-zdqay870.js → keepalive-86z0tzzf.js} +4 -4
- package/dist/lead-edmwagkn.js +81 -0
- package/dist/{llama-cpp-classify-yvb8vh7w.js → llama-cpp-classify-wd7htn1x.js} +2 -2
- package/dist/{maintenance-t5ndg11m.js → maintenance-19h6tfwz.js} +1 -1
- package/dist/{mistral-conversations-w4bncwbt.js → mistral-conversations-txjmc64f.js} +7 -7
- package/dist/module-ES6BEMUI-44w9s1dx.js +1210 -0
- package/dist/{multipart-parser-xevcstye.js → multipart-parser-xqbgwrav.js} +1 -1
- package/dist/{node-0as4n1ef.js → node-q4628t0b.js} +1 -1
- package/dist/{oauth-refresh-sweep-y9zyd7t6.js → oauth-refresh-sweep-6nmyrv32.js} +3 -3
- package/dist/{object-webhooks-mkca91s0.js → object-webhooks-2kynmdf8.js} +7 -7
- package/dist/{onboard-ss995244.js → onboard-zbpm96mn.js} +7 -7
- package/dist/{openai-codex-responses-70g39cgz.js → openai-codex-responses-6ckhys6r.js} +35 -29
- package/dist/{openai-completions-cv3hp4h5.js → openai-completions-c9dsq9jh.js} +15 -15
- package/dist/{openai-decisions-fyq1p9f9.js → openai-decisions-9vzvv10c.js} +2 -2
- package/dist/{openai-responses-trsvnks6.js → openai-responses-bhfmt9sa.js} +6 -6
- package/dist/{opencode-adapter-mwpz0278.js → opencode-adapter-fyqcbdra.js} +8 -8
- package/dist/{openrouter-images-0jj12a2q.js → openrouter-images-hkk5p580.js} +3 -3
- package/dist/otel-impl-txa20w1h.js +11178 -0
- package/dist/{pending-2sxh1t6j.js → pending-4rxawq8y.js} +25 -25
- package/dist/{pi-messages-zk3g4esn.js → pi-messages-py3f96p7.js} +5 -5
- package/dist/{pi-mono-adapter-sfb7zy43.js → pi-mono-adapter-rnsed1xa.js} +24 -27
- package/dist/{pricing-refresh-h79bg4cf.js → pricing-refresh-4314hwtw.js} +2 -2
- package/dist/{rbac-roles-ckq0czp4.js → rbac-roles-fztcm8ky.js} +2 -2
- package/dist/{rbac-roles-jg2e260w.js → rbac-roles-msqt7a3k.js} +3 -3
- package/dist/{render-v2-ymbshmn0.js → render-v2-w49wtecg.js} +10 -10
- package/dist/{resume-jdhnt4jk.js → resume-gwgtp4m3.js} +13 -13
- package/dist/{runtime-y28jhhnf.js → runtime-kkebz8yq.js} +1 -1
- package/dist/{session-access-k4ta5hvp.js → session-access-kjb19m2w.js} +5 -5
- package/dist/{session-source-backfill-528j4s8j.js → session-source-backfill-805p4wqr.js} +3 -3
- package/dist/{setup-d6pj82fr.js → setup-q8y168c8.js} +3 -3
- package/dist/thread-buffer-yqbffd0t.js +40 -0
- package/dist/{token-util-pjgekqxr.js → token-util-hnzceyn9.js} +1 -1
- package/dist/{token-pgr2w4s3.js → token-xnc02n6w.js} +21 -14
- package/dist/{tree-visibility-kjxv3nxk.js → tree-visibility-qj323994.js} +2 -2
- package/dist/{typesafe-system-one-qkvkgrcz.js → typesafe-system-one-avrdb4zm.js} +2 -2
- package/dist/{user-merge-jobs-rabbncf6.js → user-merge-jobs-qfp40f2s.js} +3 -3
- package/dist/{virtual-modules-22k51txd.js → virtual-modules-nzxegw0a.js} +7 -7
- package/dist/{work-objects-xtjbar3r.js → work-objects-hs089w60.js} +26 -26
- package/dist/{worker-follow-up-fg48vk6d.js → worker-follow-up-zwgg20sr.js} +24 -24
- package/dist/worker-kg4g7rnx.js +81 -0
- package/dist/{x-vfsqypht.js → x-k29vmskt.js} +2 -2
- package/openapi.json +59 -3
- package/package.json +53 -52
- package/plugin/commands/create-pr.md +5 -2
- package/plugin/pi-skills/create-pr/SKILL.md +5 -2
- package/src/apps/sync.ts +7 -2
- package/src/be/db/model-profiles.ts +103 -12
- package/src/be/db/tasks/read.ts +5 -0
- package/src/be/db/workflow-runs.ts +12 -8
- package/src/be/db.ts +18 -5
- package/src/be/migrations/367_workflow_run_principal.sql +5 -0
- package/src/be/model-group-resolution.ts +134 -0
- package/src/be/model-tier-resolution.ts +120 -17
- package/src/be/model-validation.ts +9 -1
- package/src/be/runtime-pools/routing.ts +22 -8
- package/src/be/scripts/extract-schema.ts +7 -0
- package/src/be/swarm-config-guard.ts +20 -7
- package/src/be/task-auto-title-listener.ts +2 -2
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/post-bridge.ts +27 -28
- package/src/http/active-sessions.ts +7 -0
- package/src/http/agents.ts +7 -0
- package/src/http/api-keys.ts +7 -0
- package/src/http/approval-requests.ts +4 -0
- package/src/http/budgets.ts +2 -0
- package/src/http/codex-oauth-keep-warm.ts +6 -2
- package/src/http/config.ts +1 -0
- package/src/http/context.ts +4 -0
- package/src/http/db-query.ts +11 -2
- package/src/http/events.ts +2 -0
- package/src/http/fs.ts +1 -0
- package/src/http/integrations.ts +4 -0
- package/src/http/mcp-bridge.ts +1 -0
- package/src/http/memory.ts +3 -0
- package/src/http/metrics.ts +16 -0
- package/src/http/oauth-locks.ts +8 -0
- package/src/http/operator-actor.ts +3 -8
- package/src/http/page-proxy.ts +16 -0
- package/src/http/pages.ts +9 -0
- package/src/http/poll.ts +21 -1
- package/src/http/pricing.ts +2 -0
- package/src/http/prompt-templates.ts +34 -0
- package/src/http/repos.ts +3 -1
- package/src/http/schedules.ts +33 -3
- package/src/http/script-runs.ts +24 -0
- package/src/http/scripts.ts +1 -0
- package/src/http/session-data.ts +2 -0
- package/src/http/status.ts +1 -0
- package/src/http/tasks.ts +28 -1
- package/src/http/trackers/jira.ts +2 -0
- package/src/http/trackers/linear.ts +4 -0
- package/src/http/users.ts +18 -0
- package/src/http/webhooks.ts +12 -0
- package/src/http/workflow-events.ts +26 -6
- package/src/http/workflows.ts +40 -0
- package/src/http/x.ts +4 -0
- package/src/linear/app.ts +3 -2
- package/src/linear/client.ts +5 -1
- package/src/linear/host.ts +40 -0
- package/src/linear/oauth.ts +3 -2
- package/src/linear/sync.ts +4 -3
- package/src/otel-impl.ts +8 -5
- package/src/prompts/base-prompt.ts +10 -6
- package/src/prompts/session-templates.ts +3 -3
- package/src/providers/acp-targets.ts +1 -1
- package/src/providers/amp-adapter.ts +11 -9
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/rbac/legacy-policy.ts +2 -0
- package/src/rbac/permissions.ts +5 -0
- package/src/realtime/browser.generated.txt +1 -1
- package/src/scheduler/schedule-task.ts +1 -0
- package/src/scripts-runtime/quickjs-compat.ts +44 -10
- package/src/scripts-runtime/types/swarm-extension.d.ts +2 -0
- package/src/slack/config.ts +4 -0
- package/src/slack/render-v2.ts +52 -24
- package/src/slack/responses.ts +2 -1
- package/src/slack/reviewed-deliverables.ts +251 -0
- package/src/tasks/follow-up-gate.ts +142 -38
- package/src/tasks/worker-follow-up.ts +126 -37
- package/src/tests/amp-adapter.test.ts +57 -9
- package/src/tests/base-prompt.test.ts +36 -2
- package/src/tests/check-pr-body.test.ts +408 -93
- package/src/tests/compose-dev-object-store.test.ts +13 -0
- package/src/tests/compose-example-object-store.test.ts +67 -0
- package/src/tests/db-query.test.ts +8 -4
- package/src/tests/db-retention-defaults.test.ts +28 -3
- package/src/tests/e2b-dispatch.test.ts +7 -1
- package/src/tests/entrypoint-repo-autoclone-args.test.ts +10 -0
- package/src/tests/follow-up-gate-shadow.test.ts +268 -10
- package/src/tests/linear-outbound-sync.test.ts +59 -25
- package/src/tests/operator-actor-keyless.test.ts +103 -0
- package/src/tests/otel-event-loop-and-logs.test.ts +1 -1
- package/src/tests/profile-tier-alias.test.ts +9 -3
- package/src/tests/quickjs-compat.test.ts +40 -4
- package/src/tests/rbac-route-verbs-e2e.test.ts +142 -0
- package/src/tests/runner-repo-clone-args.test.ts +15 -6
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/slack-render-v2.test.ts +52 -8
- package/src/tests/workflow-definition-pinning.test.ts +2 -0
- package/src/tests/workflow-hitl-routing.test.ts +67 -5
- package/src/tests/workflow-replay.test.ts +13 -1
- package/src/tests/workflow-system-one-extraction.test.ts +21 -0
- package/src/tests/workflow-wait-filter.test.ts +7 -7
- package/src/tests/worktree-reaper.test.ts +15 -4
- package/src/tests/x402-client.test.ts +82 -0
- package/src/tools/memory-rate.ts +2 -2
- package/src/tools/prompt-templates/delete.ts +22 -1
- package/src/tools/prompt-templates/set.ts +15 -1
- package/src/tools/schedules/create-schedule.ts +20 -3
- package/src/tools/schedules/patch-schedule.ts +30 -4
- package/src/tools/schedules/update-schedule.ts +30 -4
- package/src/tools/send-task.ts +17 -3
- package/src/tools/slack-post.ts +7 -2
- package/src/tools/slack-reply.ts +6 -2
- package/src/tools/task-action.ts +16 -3
- package/src/tools/utils.ts +1 -1
- package/src/types.ts +10 -0
- package/src/utils/amp-models.ts +20 -4
- package/src/utils/constants.ts +5 -4
- package/src/utils/secret-scrubber.ts +6 -4
- package/src/utils/task-citations.ts +11 -0
- package/src/workflows/engine.ts +41 -8
- package/src/workflows/executors/agent-task.ts +13 -2
- package/src/workflows/executors/code-match.ts +11 -31
- package/src/workflows/executors/script.ts +13 -0
- package/src/workflows/executors/sub-workflow.ts +5 -7
- package/src/workflows/executors/swarm-script.ts +4 -5
- package/src/workflows/executors/system-one-extraction.ts +9 -6
- package/src/workflows/executors/wait.ts +1 -1
- package/src/workflows/foreach-driver.ts +5 -1
- package/src/workflows/model-validation.ts +13 -1
- package/src/workflows/predicate-sandbox.ts +171 -0
- package/src/workflows/resume.ts +21 -4
- package/src/workflows/retry-poller.ts +1 -1
- package/src/workflows/run-principal.ts +51 -0
- package/src/workflows/wait-filter.ts +14 -192
- package/src/x402/client.ts +38 -17
- package/templates/skills/code-quality/content.md +1 -1
- package/templates/skills/heartbeat-runbook/content.md +1 -0
- package/templates/skills/pages/content.md +36 -12
- package/templates/skills/slack-interaction/content.md +4 -0
- package/templates/skills/swarm-docs/content.md +47 -41
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/dist/acp-adapter-99n6z9ky.js +0 -17
- package/dist/cli-5ss6qqt9.js +0 -45
- package/dist/cli-dzzh58sy.js +0 -6996
- package/dist/cli-e8trbfx1.js +0 -15
- package/dist/cli-j9ccfveb.js +0 -1849
- package/dist/cli-mna6pmfx.js +0 -1485
- package/dist/cli-r8ddn0hf.js +0 -25583
- package/dist/core-dynsv289.js +0 -41
- package/dist/fx-adapter-9k0hptnz.js +0 -20
- package/dist/getMachineId-bsd-637a7rbk.js +0 -36
- package/dist/getMachineId-darwin-9vytrcnn.js +0 -36
- package/dist/getMachineId-linux-mkzsvyyz.js +0 -29
- package/dist/getMachineId-unsupported-4cfs2n11.js +0 -19
- package/dist/getMachineId-win-154s3qma.js +0 -38
- package/dist/grok-adapter-skdj2pce.js +0 -20
- package/dist/handlers-5btjqkz6.js +0 -39
- package/dist/heartbeat-vfb1gy84.js +0 -49
- package/dist/hook-eh52p7yd.js +0 -22
- package/dist/index-7w8p6em0.js +0 -41
- package/dist/index-t56y945n.js +0 -4
- package/dist/index-vfemrwwk.js +0 -10002
- package/dist/index-vz4semsx.js +0 -38
- package/dist/index-y3s0xp2v.js +0 -43
- package/dist/lead-6cscw8a5.js +0 -82
- package/dist/otel-impl-6n6vva3x.js +0 -28205
- package/dist/thread-buffer-9w6x5zec.js +0 -40
- package/dist/worker-g4aj93dt.js +0 -82
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import"./cli-
|
|
2
|
-
import"./cli-
|
|
1
|
+
import"./cli-5188hq0a.js";
|
|
2
|
+
import"./cli-65k149j5.js";
|
|
3
3
|
import {
|
|
4
4
|
auditAssetKeys,
|
|
5
5
|
init_asset_key_audit,
|
|
@@ -249,6 +249,8 @@ import {
|
|
|
249
249
|
checkProfileForAgent,
|
|
250
250
|
formatProfileCheckFailures,
|
|
251
251
|
init_model_profile_check,
|
|
252
|
+
resolveGroupForAgent,
|
|
253
|
+
init_model_group_resolution,
|
|
252
254
|
startTaskSearchBackfill,
|
|
253
255
|
stopTaskSearchBackfill,
|
|
254
256
|
init_search_index,
|
|
@@ -275,6 +277,7 @@ import {
|
|
|
275
277
|
MAX_MODEL_PROFILE_FALLBACKS,
|
|
276
278
|
modelProfileFallbacksError,
|
|
277
279
|
taskProfileError,
|
|
280
|
+
modelGroupRefError,
|
|
278
281
|
scheduleProfileUpdate,
|
|
279
282
|
init_model_profiles,
|
|
280
283
|
refreshActiveSessionOnActivity2,
|
|
@@ -544,7 +547,7 @@ import {
|
|
|
544
547
|
countScriptRunJournalSteps2,
|
|
545
548
|
countScriptRunJournalAgentTaskSteps2,
|
|
546
549
|
init_db4
|
|
547
|
-
} from "./cli-
|
|
550
|
+
} from "./cli-zrm0610v.js";
|
|
548
551
|
import {
|
|
549
552
|
PRIMARY_ROLE_NAMES2,
|
|
550
553
|
OperatorGrantedTargetError2,
|
|
@@ -558,7 +561,7 @@ import {
|
|
|
558
561
|
assertNotLastAdmin2,
|
|
559
562
|
setUserRoles2,
|
|
560
563
|
init_rbac_roles
|
|
561
|
-
} from "./cli-
|
|
564
|
+
} from "./cli-x5t54ytt.js";
|
|
562
565
|
import {
|
|
563
566
|
MAX_MODEL_GROUP_MEMBERS,
|
|
564
567
|
listModelGroups,
|
|
@@ -568,24 +571,25 @@ import {
|
|
|
568
571
|
modelGroupReferences,
|
|
569
572
|
deleteModelGroup,
|
|
570
573
|
init_model_groups
|
|
571
|
-
} from "./cli-
|
|
574
|
+
} from "./cli-jrxt5j0n.js";
|
|
572
575
|
import {
|
|
573
576
|
requestModelCatalogRefresh2,
|
|
574
577
|
init_pricing_refresh
|
|
575
|
-
} from "./cli-
|
|
578
|
+
} from "./cli-svcy72s5.js";
|
|
576
579
|
import {
|
|
577
580
|
workflowEventBus2,
|
|
578
581
|
init_event_bus
|
|
579
|
-
} from "./cli-
|
|
582
|
+
} from "./cli-0nvqg1hb.js";
|
|
580
583
|
import {
|
|
581
584
|
shouldBlockChannel2,
|
|
582
585
|
init_external_channel
|
|
583
|
-
} from "./cli-
|
|
584
|
-
import"./cli-
|
|
585
|
-
import"./cli-
|
|
586
|
-
import
|
|
586
|
+
} from "./cli-2ja7eadd.js";
|
|
587
|
+
import"./cli-1t5vhrpv.js";
|
|
588
|
+
import"./cli-0rrft7s3.js";
|
|
589
|
+
import {
|
|
590
|
+
require_dist7
|
|
591
|
+
} from "./cli-ek8b88kv.js";
|
|
587
592
|
import {
|
|
588
|
-
require_dist4,
|
|
589
593
|
getSlackConnectionState,
|
|
590
594
|
init_connection_state,
|
|
591
595
|
getSlackInboundDiagnostics,
|
|
@@ -621,7 +625,7 @@ import {
|
|
|
621
625
|
startSlackApp2,
|
|
622
626
|
stopSlackApp2,
|
|
623
627
|
init_app4
|
|
624
|
-
} from "./cli-
|
|
628
|
+
} from "./cli-q58qt9dw.js";
|
|
625
629
|
import {
|
|
626
630
|
reconcileAgentMaxTasksPolicy,
|
|
627
631
|
upsertSwarmConfigWithPolicyMirror,
|
|
@@ -635,12 +639,12 @@ import {
|
|
|
635
639
|
reconcileAgentStatusFromRuntimes,
|
|
636
640
|
listRuntimeInstancesForPool,
|
|
637
641
|
init_multi_runtime
|
|
638
|
-
} from "./cli-
|
|
642
|
+
} from "./cli-cczffwak.js";
|
|
639
643
|
import {
|
|
640
644
|
retryFailedRun2,
|
|
641
645
|
cancelWorkflowRun2,
|
|
642
646
|
init_resume
|
|
643
|
-
} from "./cli-
|
|
647
|
+
} from "./cli-fdam1t9b.js";
|
|
644
648
|
import {
|
|
645
649
|
safeParse,
|
|
646
650
|
getObjectShape,
|
|
@@ -760,6 +764,8 @@ import {
|
|
|
760
764
|
init_retry,
|
|
761
765
|
ExtensionConfigError,
|
|
762
766
|
init_loader,
|
|
767
|
+
isExtensionBridgedEvent,
|
|
768
|
+
init_post_bridge,
|
|
763
769
|
ExtensionLifecycleError,
|
|
764
770
|
setExtensionLoopbackBaseUrl,
|
|
765
771
|
enableExtension,
|
|
@@ -894,6 +900,8 @@ import {
|
|
|
894
900
|
handleJiraWebhook,
|
|
895
901
|
init_webhook,
|
|
896
902
|
init_jira,
|
|
903
|
+
linearApiUrl,
|
|
904
|
+
init_host,
|
|
897
905
|
handleAgentSessionEvent,
|
|
898
906
|
handleIssueUpdate,
|
|
899
907
|
handleIssueDelete,
|
|
@@ -1156,7 +1164,7 @@ import {
|
|
|
1156
1164
|
getEnabledCapabilities,
|
|
1157
1165
|
createServer,
|
|
1158
1166
|
init_server
|
|
1159
|
-
} from "./cli-
|
|
1167
|
+
} from "./cli-d13qgcct.js";
|
|
1160
1168
|
import {
|
|
1161
1169
|
getFileStorageProvider2,
|
|
1162
1170
|
init_registry2
|
|
@@ -1182,7 +1190,7 @@ import {
|
|
|
1182
1190
|
resolvePoolDelivery2,
|
|
1183
1191
|
createPoolAgent2,
|
|
1184
1192
|
init_db2
|
|
1185
|
-
} from "./cli-
|
|
1193
|
+
} from "./cli-f3ta4e67.js";
|
|
1186
1194
|
import {
|
|
1187
1195
|
warnIfCorsAllowsAnyOrigin,
|
|
1188
1196
|
isOriginAllowedForCredentials,
|
|
@@ -1231,7 +1239,7 @@ import {
|
|
|
1231
1239
|
describeRequestRoute,
|
|
1232
1240
|
route,
|
|
1233
1241
|
init_route_def
|
|
1234
|
-
} from "./cli-
|
|
1242
|
+
} from "./cli-c6vhcknq.js";
|
|
1235
1243
|
import {
|
|
1236
1244
|
startPoolRouting,
|
|
1237
1245
|
stopPoolRouting,
|
|
@@ -1244,29 +1252,29 @@ import {
|
|
|
1244
1252
|
checkHeartbeatChecklist2,
|
|
1245
1253
|
runHeartbeatSweep2,
|
|
1246
1254
|
stopHeartbeat2
|
|
1247
|
-
} from "./cli-
|
|
1248
|
-
import"./cli-
|
|
1255
|
+
} from "./cli-rw3m83j4.js";
|
|
1256
|
+
import"./cli-021hrewp.js";
|
|
1249
1257
|
import {
|
|
1250
1258
|
runtimeSupervisorStatus,
|
|
1251
1259
|
startRuntimeSupervisor,
|
|
1252
1260
|
stopRuntimeSupervisor
|
|
1253
|
-
} from "./cli-
|
|
1261
|
+
} from "./cli-8ee7xt75.js";
|
|
1254
1262
|
import {
|
|
1255
1263
|
TASK_TITLE_TIMEOUT_MS,
|
|
1256
1264
|
generateTaskTitle
|
|
1257
|
-
} from "./cli-
|
|
1265
|
+
} from "./cli-k9kfck3s.js";
|
|
1258
1266
|
import"./cli-ns59dc6r.js";
|
|
1259
1267
|
import {
|
|
1260
1268
|
ACP_TARGET_IDS
|
|
1261
|
-
} from "./cli-
|
|
1269
|
+
} from "./cli-tbrjvrrg.js";
|
|
1262
1270
|
import {
|
|
1263
1271
|
reasoningCapability,
|
|
1264
1272
|
supportedReasoningLevels
|
|
1265
|
-
} from "./cli-
|
|
1273
|
+
} from "./cli-08gfvs58.js";
|
|
1266
1274
|
import {
|
|
1267
1275
|
MAX_RATE_LIMIT_RESET_MS,
|
|
1268
1276
|
MAX_SPEND_CAP_HOLD_MS
|
|
1269
|
-
} from "./cli-
|
|
1277
|
+
} from "./cli-8crn0510.js";
|
|
1270
1278
|
import {
|
|
1271
1279
|
AgentFsRequestError2,
|
|
1272
1280
|
resolveAgentFsSharedContext2,
|
|
@@ -1277,10 +1285,10 @@ import {
|
|
|
1277
1285
|
agentFsRequest2,
|
|
1278
1286
|
resolveApiUrl2,
|
|
1279
1287
|
init_agent_fs_provision
|
|
1280
|
-
} from "./cli-
|
|
1288
|
+
} from "./cli-5njmmmer.js";
|
|
1281
1289
|
import {
|
|
1282
1290
|
Anthropic
|
|
1283
|
-
} from "./cli-
|
|
1291
|
+
} from "./cli-ertcjw6z.js";
|
|
1284
1292
|
import {
|
|
1285
1293
|
isLeadChannelMonitoringEnabled,
|
|
1286
1294
|
SIMILARITY_THRESHOLD,
|
|
@@ -1288,19 +1296,19 @@ import {
|
|
|
1288
1296
|
isUnknownModelError,
|
|
1289
1297
|
checkProviderPoolKey,
|
|
1290
1298
|
writeSkillsToFilesystem
|
|
1291
|
-
} from "./cli-
|
|
1299
|
+
} from "./cli-cgmka83w.js";
|
|
1292
1300
|
import {
|
|
1293
1301
|
objectWebhookSecret2,
|
|
1294
1302
|
handleObjectWebhookEvent2,
|
|
1295
1303
|
init_object_webhooks
|
|
1296
|
-
} from "./cli-
|
|
1297
|
-
import"./cli-
|
|
1304
|
+
} from "./cli-gnkzh8ed.js";
|
|
1305
|
+
import"./cli-1d9q7qrn.js";
|
|
1298
1306
|
import {
|
|
1299
1307
|
LOOKUP_USER_TEAM2,
|
|
1300
1308
|
isUserAllowed2,
|
|
1301
1309
|
init_handlers
|
|
1302
|
-
} from "./cli-
|
|
1303
|
-
import"./cli-
|
|
1310
|
+
} from "./cli-txxcf9s1.js";
|
|
1311
|
+
import"./cli-dev6f0px.js";
|
|
1304
1312
|
import {
|
|
1305
1313
|
createUserMergeJob2,
|
|
1306
1314
|
getUserMergeJob2,
|
|
@@ -1309,7 +1317,7 @@ import {
|
|
|
1309
1317
|
findFailedUserMergeJob2,
|
|
1310
1318
|
requeueUserMergeJob2,
|
|
1311
1319
|
runUserMergeJobs2
|
|
1312
|
-
} from "./cli-
|
|
1320
|
+
} from "./cli-qqz5z36e.js";
|
|
1313
1321
|
import {
|
|
1314
1322
|
isCodexOAuthConfigKey
|
|
1315
1323
|
} from "./cli-j4bwnpkm.js";
|
|
@@ -1339,8 +1347,8 @@ import {
|
|
|
1339
1347
|
init_person_responder,
|
|
1340
1348
|
handleApprovalRequests,
|
|
1341
1349
|
init_approval_requests
|
|
1342
|
-
} from "./cli-
|
|
1343
|
-
import"./cli-
|
|
1350
|
+
} from "./cli-83hynhes.js";
|
|
1351
|
+
import"./cli-hab0bvrh.js";
|
|
1344
1352
|
import {
|
|
1345
1353
|
RATING_MODEL_MAX_LENGTH,
|
|
1346
1354
|
REFERENCES_SOURCE_MAX_LENGTH,
|
|
@@ -1441,7 +1449,7 @@ import {
|
|
|
1441
1449
|
init_typecheck,
|
|
1442
1450
|
parseSkillContent,
|
|
1443
1451
|
init_skill_parser
|
|
1444
|
-
} from "./cli-
|
|
1452
|
+
} from "./cli-gy0r7gb8.js";
|
|
1445
1453
|
import {
|
|
1446
1454
|
signalProcessGroup,
|
|
1447
1455
|
detachedProcessGroup,
|
|
@@ -1458,17 +1466,17 @@ import {
|
|
|
1458
1466
|
forceRefreshAuthorizationOrThrow,
|
|
1459
1467
|
forceRefreshTokenOrThrow,
|
|
1460
1468
|
init_ensure_token
|
|
1461
|
-
} from "./cli-
|
|
1469
|
+
} from "./cli-e13kbyq0.js";
|
|
1462
1470
|
import {
|
|
1463
1471
|
PRIMITIVE_KINDS,
|
|
1464
1472
|
ObjectsError,
|
|
1465
1473
|
recordObjectVersion,
|
|
1466
1474
|
init_objects
|
|
1467
|
-
} from "./cli-
|
|
1475
|
+
} from "./cli-s48k2rzx.js";
|
|
1468
1476
|
import {
|
|
1469
1477
|
agentFsClientFor,
|
|
1470
1478
|
init_agent_fs_identity
|
|
1471
|
-
} from "./cli-
|
|
1479
|
+
} from "./cli-an8bpy60.js";
|
|
1472
1480
|
import {
|
|
1473
1481
|
FilesError,
|
|
1474
1482
|
normalizeFilesError,
|
|
@@ -1477,7 +1485,7 @@ import {
|
|
|
1477
1485
|
AgentFsProvider,
|
|
1478
1486
|
init_agent_fs_provider
|
|
1479
1487
|
} from "./cli-skd2c4ej.js";
|
|
1480
|
-
import"./cli-
|
|
1488
|
+
import"./cli-ryn4y478.js";
|
|
1481
1489
|
import {
|
|
1482
1490
|
automationIntegrationFixUrl,
|
|
1483
1491
|
preflightAutomation,
|
|
@@ -1499,7 +1507,7 @@ import {
|
|
|
1499
1507
|
definitionNodeIds,
|
|
1500
1508
|
validateDefinition,
|
|
1501
1509
|
init_definition2
|
|
1502
|
-
} from "./cli-
|
|
1510
|
+
} from "./cli-h8k5801a.js";
|
|
1503
1511
|
import {
|
|
1504
1512
|
_fetchHolder,
|
|
1505
1513
|
CLIENT_ID,
|
|
@@ -1515,7 +1523,7 @@ import {
|
|
|
1515
1523
|
loadAllCodexOAuthSlots,
|
|
1516
1524
|
getValidCodexOAuth,
|
|
1517
1525
|
init_storage
|
|
1518
|
-
} from "./cli-
|
|
1526
|
+
} from "./cli-kz8rar0g.js";
|
|
1519
1527
|
import {
|
|
1520
1528
|
isMultiRuntimeEnabled,
|
|
1521
1529
|
init_multi_runtime2
|
|
@@ -1527,11 +1535,10 @@ import {
|
|
|
1527
1535
|
import {
|
|
1528
1536
|
createRuntimeProvider,
|
|
1529
1537
|
init_runtime_providers
|
|
1530
|
-
} from "./cli-
|
|
1538
|
+
} from "./cli-0kyjrbaa.js";
|
|
1531
1539
|
import {
|
|
1532
1540
|
require_content_type
|
|
1533
|
-
} from "./cli-
|
|
1534
|
-
import"./cli-b0m3bg0f.js";
|
|
1541
|
+
} from "./cli-nc842kc9.js";
|
|
1535
1542
|
import {
|
|
1536
1543
|
hasSessionAccess,
|
|
1537
1544
|
getSessionRoot,
|
|
@@ -1541,13 +1548,13 @@ import {
|
|
|
1541
1548
|
toSessionSharesState,
|
|
1542
1549
|
setSessionShares,
|
|
1543
1550
|
init_session_shares
|
|
1544
|
-
} from "./cli-
|
|
1545
|
-
import"./cli-
|
|
1551
|
+
} from "./cli-3vc518cw.js";
|
|
1552
|
+
import"./cli-9j1qcs0b.js";
|
|
1546
1553
|
import {
|
|
1547
1554
|
import_websocket,
|
|
1548
1555
|
import_websocket_server,
|
|
1549
1556
|
init_wrapper2
|
|
1550
|
-
} from "./cli-
|
|
1557
|
+
} from "./cli-rcqgr0hs.js";
|
|
1551
1558
|
import {
|
|
1552
1559
|
registerSessionTokenConnection,
|
|
1553
1560
|
init_session_token_connections,
|
|
@@ -1577,7 +1584,11 @@ import {
|
|
|
1577
1584
|
revokeAllAgentSessionTokens,
|
|
1578
1585
|
fingerprintApiKey,
|
|
1579
1586
|
init_users
|
|
1580
|
-
} from "./cli-
|
|
1587
|
+
} from "./cli-praaw1wh.js";
|
|
1588
|
+
import {
|
|
1589
|
+
resolveGitHubHost,
|
|
1590
|
+
init_github_host
|
|
1591
|
+
} from "./cli-9ttx00s3.js";
|
|
1581
1592
|
import {
|
|
1582
1593
|
CORE_TOOLS,
|
|
1583
1594
|
init_tool_config
|
|
@@ -1590,30 +1601,26 @@ import {
|
|
|
1590
1601
|
providerAccountTelemetrySchema,
|
|
1591
1602
|
rateLimitReplacementSchema,
|
|
1592
1603
|
init_provider_account_telemetry
|
|
1593
|
-
} from "./cli-
|
|
1604
|
+
} from "./cli-wqpvfq2m.js";
|
|
1594
1605
|
import {
|
|
1595
1606
|
CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
|
|
1596
1607
|
CODEX_AUTH_WATCH_NAMESPACE,
|
|
1597
1608
|
codexAuthBenchMarkerKey,
|
|
1598
1609
|
init_codex_auth_failure
|
|
1599
1610
|
} from "./cli-fw2w0kva.js";
|
|
1600
|
-
import {
|
|
1601
|
-
resolveGitHubHost,
|
|
1602
|
-
init_github_host
|
|
1603
|
-
} from "./cli-9ttx00s3.js";
|
|
1604
1611
|
import {
|
|
1605
1612
|
IDENTITY_FIELD_BUDGETS,
|
|
1606
1613
|
IdentityFieldBudgetError,
|
|
1607
1614
|
init_identity_field_budget
|
|
1608
|
-
} from "./cli-
|
|
1609
|
-
import {
|
|
1610
|
-
getSlackConfiguration,
|
|
1611
|
-
init_config5
|
|
1612
|
-
} from "./cli-t9pzz2eq.js";
|
|
1615
|
+
} from "./cli-jfgaz10x.js";
|
|
1613
1616
|
import {
|
|
1614
1617
|
isSteeringEnabled2,
|
|
1615
1618
|
init_steering_enabled
|
|
1616
1619
|
} from "./cli-4sydckyj.js";
|
|
1620
|
+
import {
|
|
1621
|
+
getSlackConfiguration,
|
|
1622
|
+
init_config5
|
|
1623
|
+
} from "./cli-ntmjzyte.js";
|
|
1617
1624
|
import {
|
|
1618
1625
|
SUBSCRIPTION_PLANS_CHECKED_AT,
|
|
1619
1626
|
SUBSCRIPTION_PLANS,
|
|
@@ -1636,7 +1643,11 @@ import {
|
|
|
1636
1643
|
splitCredentialPool,
|
|
1637
1644
|
selectCredential,
|
|
1638
1645
|
init_credentials2
|
|
1639
|
-
} from "./cli-
|
|
1646
|
+
} from "./cli-w81s97bn.js";
|
|
1647
|
+
import {
|
|
1648
|
+
getOpenRouterAttributionHeaders,
|
|
1649
|
+
init_openrouter_base_url
|
|
1650
|
+
} from "./cli-dfyv0jdy.js";
|
|
1640
1651
|
import {
|
|
1641
1652
|
interpolate,
|
|
1642
1653
|
init_template2,
|
|
@@ -1646,11 +1657,7 @@ import {
|
|
|
1646
1657
|
resolveTemplate,
|
|
1647
1658
|
init_resolver,
|
|
1648
1659
|
init_session_templates
|
|
1649
|
-
} from "./cli-
|
|
1650
|
-
import {
|
|
1651
|
-
getOpenRouterAttributionHeaders,
|
|
1652
|
-
init_openrouter_base_url
|
|
1653
|
-
} from "./cli-dfyv0jdy.js";
|
|
1660
|
+
} from "./cli-aktk3qt6.js";
|
|
1654
1661
|
import {
|
|
1655
1662
|
ASSET_KEY_MAX_LENGTH,
|
|
1656
1663
|
AssetKeyError,
|
|
@@ -1827,7 +1834,7 @@ import {
|
|
|
1827
1834
|
KvKeySchema,
|
|
1828
1835
|
KvEntrySchema,
|
|
1829
1836
|
init_types5
|
|
1830
|
-
} from "./cli-
|
|
1837
|
+
} from "./cli-t5jbjq61.js";
|
|
1831
1838
|
import {
|
|
1832
1839
|
init_zod
|
|
1833
1840
|
} from "./cli-96234j5w.js";
|
|
@@ -1863,7 +1870,6 @@ import {
|
|
|
1863
1870
|
getConfiguredAppUrls,
|
|
1864
1871
|
getAppUrl,
|
|
1865
1872
|
getLocalDevAppOrigins,
|
|
1866
|
-
getMcpBaseUrl,
|
|
1867
1873
|
setApiLoopbackBaseUrl,
|
|
1868
1874
|
getScriptApiBaseUrl,
|
|
1869
1875
|
getPublicMcpBaseUrl,
|
|
@@ -1882,7 +1888,7 @@ import {
|
|
|
1882
1888
|
import {
|
|
1883
1889
|
init_package,
|
|
1884
1890
|
package_default
|
|
1885
|
-
} from "./cli-
|
|
1891
|
+
} from "./cli-jrhvywah.js";
|
|
1886
1892
|
import {
|
|
1887
1893
|
realtimeBus,
|
|
1888
1894
|
init_bus
|
|
@@ -1898,7 +1904,7 @@ import {
|
|
|
1898
1904
|
registerVolatileSecret,
|
|
1899
1905
|
registerEnvSecrets,
|
|
1900
1906
|
init_secret_scrubber
|
|
1901
|
-
} from "./cli-
|
|
1907
|
+
} from "./cli-7qkbab03.js";
|
|
1902
1908
|
import {
|
|
1903
1909
|
__toESM
|
|
1904
1910
|
} from "./cli-242037k3.js";
|
|
@@ -5021,7 +5027,7 @@ async function titleTask(taskId, env, generate) {
|
|
|
5021
5027
|
const result = await generate({
|
|
5022
5028
|
task: task.task,
|
|
5023
5029
|
env,
|
|
5024
|
-
apiUrl:
|
|
5030
|
+
apiUrl: getScriptApiBaseUrl(),
|
|
5025
5031
|
apiKey: getApiKey(),
|
|
5026
5032
|
callerTag: `task-title:${task.source}`,
|
|
5027
5033
|
signal: AbortSignal.timeout(TASK_TITLE_TIMEOUT_MS)
|
|
@@ -7011,7 +7017,8 @@ var createActiveSession = route({
|
|
|
7011
7017
|
responses: {
|
|
7012
7018
|
201: { description: "Session created", schema: object2({ session: ActiveSessionSchema }) },
|
|
7013
7019
|
400: { description: "Validation error" }
|
|
7014
|
-
}
|
|
7020
|
+
},
|
|
7021
|
+
rbac: { ungated: "worker runner bookkeeping for its own active session; no user flow writes it" }
|
|
7015
7022
|
});
|
|
7016
7023
|
var deleteSessionByTask = route({
|
|
7017
7024
|
method: "delete",
|
|
@@ -7023,7 +7030,8 @@ var deleteSessionByTask = route({
|
|
|
7023
7030
|
params: object2({ taskId: string2() }),
|
|
7024
7031
|
responses: {
|
|
7025
7032
|
200: { description: "Session deleted", schema: object2({ deleted: boolean() }) }
|
|
7026
|
-
}
|
|
7033
|
+
},
|
|
7034
|
+
rbac: { ungated: "worker runner bookkeeping for its own active session; no user flow writes it" }
|
|
7027
7035
|
});
|
|
7028
7036
|
var deleteSessionById = route({
|
|
7029
7037
|
method: "delete",
|
|
@@ -7035,7 +7043,8 @@ var deleteSessionById = route({
|
|
|
7035
7043
|
params: object2({ id: string2() }),
|
|
7036
7044
|
responses: {
|
|
7037
7045
|
200: { description: "Session deleted", schema: object2({ deleted: boolean() }) }
|
|
7038
|
-
}
|
|
7046
|
+
},
|
|
7047
|
+
rbac: { ungated: "worker runner bookkeeping for its own active session; no user flow writes it" }
|
|
7039
7048
|
});
|
|
7040
7049
|
var heartbeatSession = route({
|
|
7041
7050
|
method: "put",
|
|
@@ -7047,7 +7056,8 @@ var heartbeatSession = route({
|
|
|
7047
7056
|
params: object2({ taskId: string2() }),
|
|
7048
7057
|
responses: {
|
|
7049
7058
|
200: { description: "Heartbeat updated", schema: object2({ updated: boolean() }) }
|
|
7050
|
-
}
|
|
7059
|
+
},
|
|
7060
|
+
rbac: { ungated: "worker runner bookkeeping for its own active session; no user flow writes it" }
|
|
7051
7061
|
});
|
|
7052
7062
|
var updateProviderSession = route({
|
|
7053
7063
|
method: "put",
|
|
@@ -7060,7 +7070,8 @@ var updateProviderSession = route({
|
|
|
7060
7070
|
body: object2({ providerSessionId: string2().min(1) }),
|
|
7061
7071
|
responses: {
|
|
7062
7072
|
200: { description: "Provider session ID updated", schema: object2({ updated: boolean() }) }
|
|
7063
|
-
}
|
|
7073
|
+
},
|
|
7074
|
+
rbac: { ungated: "worker runner bookkeeping for its own active session; no user flow writes it" }
|
|
7064
7075
|
});
|
|
7065
7076
|
var cleanupSessions = route({
|
|
7066
7077
|
method: "post",
|
|
@@ -7075,7 +7086,8 @@ var cleanupSessions = route({
|
|
|
7075
7086
|
}).optional(),
|
|
7076
7087
|
responses: {
|
|
7077
7088
|
200: { description: "Cleanup result", schema: object2({ cleaned: number2().int() }) }
|
|
7078
|
-
}
|
|
7089
|
+
},
|
|
7090
|
+
rbac: { ungated: "worker runner bookkeeping for its own active session; no user flow writes it" }
|
|
7079
7091
|
});
|
|
7080
7092
|
var recoverOrphanedTasks = route({
|
|
7081
7093
|
method: "post",
|
|
@@ -7094,7 +7106,8 @@ var recoverOrphanedTasks = route({
|
|
|
7094
7106
|
schema: object2({ recovered: number2().int(), tasks: array2(AgentTaskSchema) })
|
|
7095
7107
|
},
|
|
7096
7108
|
403: { description: "Can only recover orphaned tasks for the calling agent" }
|
|
7097
|
-
}
|
|
7109
|
+
},
|
|
7110
|
+
rbac: { ungated: "worker runner bookkeeping for its own active session; no user flow writes it" }
|
|
7098
7111
|
});
|
|
7099
7112
|
async function handleActiveSessions(req, res, pathSegments, queryParams, myAgentId) {
|
|
7100
7113
|
if (listActiveSessions.match(req.method, pathSegments)) {
|
|
@@ -7360,10 +7373,7 @@ function getOperatorActor(req, res) {
|
|
|
7360
7373
|
}
|
|
7361
7374
|
const rawKey = extractBearer(req);
|
|
7362
7375
|
const swarmKey = getApiKey();
|
|
7363
|
-
if (!swarmKey) {
|
|
7364
|
-
return { kind: "operator", id: fingerprintApiKey("") };
|
|
7365
|
-
}
|
|
7366
|
-
if (!rawKey || !verifyTokenEquality(swarmKey, rawKey)) {
|
|
7376
|
+
if (!swarmKey || !rawKey || !verifyTokenEquality(swarmKey, rawKey)) {
|
|
7367
7377
|
jsonError(res, "Unauthorized", 401);
|
|
7368
7378
|
return null;
|
|
7369
7379
|
}
|
|
@@ -7934,7 +7944,8 @@ var registerAgent = route({
|
|
|
7934
7944
|
410: {
|
|
7935
7945
|
description: "An operator deleted this agent id (`agent_deleted`); the worker must stop"
|
|
7936
7946
|
}
|
|
7937
|
-
}
|
|
7947
|
+
},
|
|
7948
|
+
rbac: { ungated: "worker self-registration at boot; no user flow calls it" }
|
|
7938
7949
|
});
|
|
7939
7950
|
var setAgentHarnessProviderRoute = route({
|
|
7940
7951
|
method: "patch",
|
|
@@ -7951,7 +7962,8 @@ var setAgentHarnessProviderRoute = route({
|
|
|
7951
7962
|
200: { description: "Updated agent row", schema: AgentWithCapacitySchema },
|
|
7952
7963
|
400: { description: "Validation error (unknown provider)" },
|
|
7953
7964
|
404: { description: "Agent not found" }
|
|
7954
|
-
}
|
|
7965
|
+
},
|
|
7966
|
+
rbac: { permission: "config.write.any" }
|
|
7955
7967
|
});
|
|
7956
7968
|
var LocalHarnessProviderSchema = _enum2([
|
|
7957
7969
|
"claude",
|
|
@@ -8033,7 +8045,8 @@ var updateAgentRuntimeRoute = route({
|
|
|
8033
8045
|
},
|
|
8034
8046
|
400: { description: "Validation error, or `{ error, check }` when the profile check fails" },
|
|
8035
8047
|
404: { description: "Agent not found" }
|
|
8036
|
-
}
|
|
8048
|
+
},
|
|
8049
|
+
rbac: { permission: "config.write.any" }
|
|
8037
8050
|
});
|
|
8038
8051
|
|
|
8039
8052
|
class ClaudeTransportConflictError extends Error {
|
|
@@ -8124,7 +8137,8 @@ var updateAgentNameRoute = route({
|
|
|
8124
8137
|
200: { description: "Agent updated", schema: AgentWithCapacitySchema },
|
|
8125
8138
|
404: { description: "Agent not found" },
|
|
8126
8139
|
409: { description: "Name conflict" }
|
|
8127
|
-
}
|
|
8140
|
+
},
|
|
8141
|
+
rbac: { permission: "agent.profile.update.any" }
|
|
8128
8142
|
});
|
|
8129
8143
|
var getAgentSetupScript = route({
|
|
8130
8144
|
method: "get",
|
|
@@ -8228,7 +8242,8 @@ var updateAgentProfileRoute = route({
|
|
|
8228
8242
|
})
|
|
8229
8243
|
},
|
|
8230
8244
|
404: { description: "Agent not found, or changedByAgentId names no agent" }
|
|
8231
|
-
}
|
|
8245
|
+
},
|
|
8246
|
+
rbac: { permission: "agent.profile.update.any" }
|
|
8232
8247
|
});
|
|
8233
8248
|
var updateAgentActivityRoute = route({
|
|
8234
8249
|
method: "put",
|
|
@@ -8239,7 +8254,8 @@ var updateAgentActivityRoute = route({
|
|
|
8239
8254
|
params: object2({ id: string2() }),
|
|
8240
8255
|
responses: {
|
|
8241
8256
|
204: { description: "Activity updated" }
|
|
8242
|
-
}
|
|
8257
|
+
},
|
|
8258
|
+
rbac: { ungated: "worker telemetry ingest; no user flow writes it" }
|
|
8243
8259
|
});
|
|
8244
8260
|
var getAgent = route({
|
|
8245
8261
|
method: "get",
|
|
@@ -8279,7 +8295,8 @@ var updateAgentCredentialStatusRoute = route({
|
|
|
8279
8295
|
},
|
|
8280
8296
|
400: { description: "Missing X-Runtime-Instance-ID in multi-runtime mode" },
|
|
8281
8297
|
404: { description: "Agent not found" }
|
|
8282
|
-
}
|
|
8298
|
+
},
|
|
8299
|
+
rbac: { ungated: "worker telemetry ingest; no user flow writes it" }
|
|
8283
8300
|
});
|
|
8284
8301
|
var getAgentCredentialStatusRoute = route({
|
|
8285
8302
|
method: "get",
|
|
@@ -9432,7 +9449,8 @@ var reportUsage = route({
|
|
|
9432
9449
|
400: { description: "Validation error" },
|
|
9433
9450
|
401: { description: "Unauthorized" }
|
|
9434
9451
|
},
|
|
9435
|
-
auth: { apiKey: true }
|
|
9452
|
+
auth: { apiKey: true },
|
|
9453
|
+
rbac: { ungated: "worker credential-pool bookkeeping; no user flow calls it" }
|
|
9436
9454
|
});
|
|
9437
9455
|
var SpendCapSchema = object2({
|
|
9438
9456
|
limitUsd: number2().nullable(),
|
|
@@ -9459,7 +9477,8 @@ var reportRateLimit = route({
|
|
|
9459
9477
|
400: { description: "Validation error" },
|
|
9460
9478
|
401: { description: "Unauthorized" }
|
|
9461
9479
|
},
|
|
9462
|
-
auth: { apiKey: true }
|
|
9480
|
+
auth: { apiKey: true },
|
|
9481
|
+
rbac: { ungated: "worker credential-pool bookkeeping; no user flow calls it" }
|
|
9463
9482
|
});
|
|
9464
9483
|
var reportValidation = route({
|
|
9465
9484
|
method: "post",
|
|
@@ -9850,7 +9869,10 @@ var setKeyName = route({
|
|
|
9850
9869
|
401: { description: "Unauthorized" },
|
|
9851
9870
|
404: { description: "Key not found" }
|
|
9852
9871
|
},
|
|
9853
|
-
auth: { apiKey: true }
|
|
9872
|
+
auth: { apiKey: true },
|
|
9873
|
+
rbac: {
|
|
9874
|
+
ungated: "credential display metadata on a pooled key; no verb covers it, so user roles need admin"
|
|
9875
|
+
}
|
|
9854
9876
|
});
|
|
9855
9877
|
var clearRateLimitRoute = route({
|
|
9856
9878
|
method: "post",
|
|
@@ -9879,7 +9901,8 @@ var clearRateLimitRoute = route({
|
|
|
9879
9901
|
400: { description: "Validation error" },
|
|
9880
9902
|
401: { description: "Unauthorized" }
|
|
9881
9903
|
},
|
|
9882
|
-
auth: { apiKey: true }
|
|
9904
|
+
auth: { apiKey: true },
|
|
9905
|
+
rbac: { ungated: "worker credential-pool bookkeeping; no user flow calls it" }
|
|
9883
9906
|
});
|
|
9884
9907
|
var listPlans = route({
|
|
9885
9908
|
method: "get",
|
|
@@ -10647,7 +10670,8 @@ var upsertBudgetRoute = route({
|
|
|
10647
10670
|
responses: {
|
|
10648
10671
|
200: { description: "Budget upserted", schema: BudgetSchema },
|
|
10649
10672
|
400: { description: "Validation error" }
|
|
10650
|
-
}
|
|
10673
|
+
},
|
|
10674
|
+
rbac: { ungated: "spend controls: no verb covers them, so user roles need admin" }
|
|
10651
10675
|
});
|
|
10652
10676
|
var deleteBudgetRoute = route({
|
|
10653
10677
|
method: "delete",
|
|
@@ -10659,7 +10683,8 @@ var deleteBudgetRoute = route({
|
|
|
10659
10683
|
responses: {
|
|
10660
10684
|
204: { description: "Budget deleted" },
|
|
10661
10685
|
404: { description: "Budget not configured" }
|
|
10662
|
-
}
|
|
10686
|
+
},
|
|
10687
|
+
rbac: { ungated: "spend controls: no verb covers them, so user roles need admin" }
|
|
10663
10688
|
});
|
|
10664
10689
|
async function handleBudgets(req, res, pathSegments, queryParams, _myAgentId) {
|
|
10665
10690
|
if (listBudgets.match(req.method, pathSegments)) {
|
|
@@ -12577,6 +12602,9 @@ var keepWarmRoute = route({
|
|
|
12577
12602
|
description: "Per-slot keep-warm outcomes",
|
|
12578
12603
|
schema: object2({ results: array2(slotOutcomeSchema) })
|
|
12579
12604
|
}
|
|
12605
|
+
},
|
|
12606
|
+
rbac: {
|
|
12607
|
+
ungated: "internal OAuth refresh coordination between API processes and workers; no user flow calls it"
|
|
12580
12608
|
}
|
|
12581
12609
|
});
|
|
12582
12610
|
async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
|
|
@@ -12585,7 +12613,7 @@ async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
|
|
|
12585
12613
|
const parsed = await keepWarmRoute.parse(req, res, pathSegments, new URLSearchParams);
|
|
12586
12614
|
if (!parsed)
|
|
12587
12615
|
return true;
|
|
12588
|
-
const apiUrl =
|
|
12616
|
+
const apiUrl = getScriptApiBaseUrl();
|
|
12589
12617
|
const apiKey = getApiKey();
|
|
12590
12618
|
const maxAgeMs = keepWarmMaxAgeMs();
|
|
12591
12619
|
const slots = await loadAllCodexOAuthSlots(apiUrl, apiKey);
|
|
@@ -13212,7 +13240,10 @@ var postContext = route({
|
|
|
13212
13240
|
400: { description: "Validation error" },
|
|
13213
13241
|
404: { description: "Task not found" }
|
|
13214
13242
|
},
|
|
13215
|
-
auth: { apiKey: true, agentId: true }
|
|
13243
|
+
auth: { apiKey: true, agentId: true },
|
|
13244
|
+
rbac: {
|
|
13245
|
+
ungated: "worker runner endpoint for its own task; the route's session posture gates any user caller"
|
|
13246
|
+
}
|
|
13216
13247
|
});
|
|
13217
13248
|
var getContext = route({
|
|
13218
13249
|
method: "get",
|
|
@@ -13407,7 +13438,8 @@ var createEventRoute = route({
|
|
|
13407
13438
|
},
|
|
13408
13439
|
400: { description: "Validation error" }
|
|
13409
13440
|
},
|
|
13410
|
-
auth: { apiKey: true }
|
|
13441
|
+
auth: { apiKey: true },
|
|
13442
|
+
rbac: { ungated: "worker telemetry ingest; no user flow writes it" }
|
|
13411
13443
|
});
|
|
13412
13444
|
var createEventsBatchRoute = route({
|
|
13413
13445
|
method: "post",
|
|
@@ -13426,7 +13458,8 @@ var createEventsBatchRoute = route({
|
|
|
13426
13458
|
},
|
|
13427
13459
|
400: { description: "Validation error" }
|
|
13428
13460
|
},
|
|
13429
|
-
auth: { apiKey: true }
|
|
13461
|
+
auth: { apiKey: true },
|
|
13462
|
+
rbac: { ungated: "worker telemetry ingest; no user flow writes it" }
|
|
13430
13463
|
});
|
|
13431
13464
|
var getEventsRoute = route({
|
|
13432
13465
|
method: "get",
|
|
@@ -13658,6 +13691,7 @@ declare module "swarm-extension" {
|
|
|
13658
13691
|
modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;
|
|
13659
13692
|
effort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
|
|
13660
13693
|
profile?: string | undefined;
|
|
13694
|
+
modelGroup?: string | undefined;
|
|
13661
13695
|
fallbackHops?:
|
|
13662
13696
|
| {
|
|
13663
13697
|
from: string;
|
|
@@ -13847,6 +13881,7 @@ declare module "swarm-extension" {
|
|
|
13847
13881
|
resolvedEffort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
|
|
13848
13882
|
profile?: string | undefined;
|
|
13849
13883
|
resolvedProfile?: string | undefined;
|
|
13884
|
+
modelGroup?: string | undefined;
|
|
13850
13885
|
fallbackHops?:
|
|
13851
13886
|
| {
|
|
13852
13887
|
from: string;
|
|
@@ -18193,7 +18228,8 @@ var ensureAgentCredentialsRoute = route({
|
|
|
18193
18228
|
400: { description: "Missing agent id" },
|
|
18194
18229
|
500: { description: "Provisioning failed" }
|
|
18195
18230
|
},
|
|
18196
|
-
auth: { apiKey: true, agentId: true }
|
|
18231
|
+
auth: { apiKey: true, agentId: true },
|
|
18232
|
+
rbac: { ungated: "worker-only: needs X-Agent-ID, which a user token cannot send" }
|
|
18197
18233
|
});
|
|
18198
18234
|
var inviteMemberRoute = route({
|
|
18199
18235
|
method: "post",
|
|
@@ -19355,7 +19391,7 @@ init_zod();
|
|
|
19355
19391
|
|
|
19356
19392
|
// src/slack/app-icon.ts
|
|
19357
19393
|
init_app4();
|
|
19358
|
-
var import_web_api = __toESM(
|
|
19394
|
+
var import_web_api = __toESM(require_dist7(), 1);
|
|
19359
19395
|
var TTL_MS = 60 * 60 * 1000;
|
|
19360
19396
|
var REQUEST_TIMEOUT_MS = 2500;
|
|
19361
19397
|
var cached = null;
|
|
@@ -19599,6 +19635,9 @@ var claudeManagedTestRoute = route({
|
|
|
19599
19635
|
description: "Connection result — `{ ok: true, agentName, model }` on success or `{ ok: false, error }` on any failure (missing config, Anthropic API error). Always 200 OK.",
|
|
19600
19636
|
schema: ClaudeManagedTestResultSchema
|
|
19601
19637
|
}
|
|
19638
|
+
},
|
|
19639
|
+
rbac: {
|
|
19640
|
+
ungated: "connection test that resolves integration secrets server-side; no verb covers it, so user roles need admin"
|
|
19602
19641
|
}
|
|
19603
19642
|
});
|
|
19604
19643
|
var mcpUserConfigRoute = route({
|
|
@@ -24243,7 +24282,8 @@ var searchMemory = route({
|
|
|
24243
24282
|
schema: object2({ results: array2(MemorySearchResultItemSchema) })
|
|
24244
24283
|
},
|
|
24245
24284
|
400: { description: "Missing query or agent ID" }
|
|
24246
|
-
}
|
|
24285
|
+
},
|
|
24286
|
+
rbac: { ungated: "worker-only: needs X-Agent-ID, which a user token cannot send" }
|
|
24247
24287
|
});
|
|
24248
24288
|
var MemoryEditResultSchema = object2({
|
|
24249
24289
|
memory: AgentMemorySchema,
|
|
@@ -24286,6 +24326,7 @@ var reEmbedMemory = route({
|
|
|
24286
24326
|
summary: "Re-embed all memories using the current embedding provider",
|
|
24287
24327
|
tags: ["Memory"],
|
|
24288
24328
|
auth: { apiKey: true },
|
|
24329
|
+
rbac: { permission: "memory.reembed" },
|
|
24289
24330
|
body: object2({
|
|
24290
24331
|
agentId: string2().uuid().optional().describe("Re-embed only this agent's memories. Omit for all."),
|
|
24291
24332
|
batchSize: number2().int().min(1).max(100).default(20).describe("Memories per batch")
|
|
@@ -24676,7 +24717,8 @@ var rateMemory = route({
|
|
|
24676
24717
|
},
|
|
24677
24718
|
400: { description: "Validation error or explicit-self R6 spam-guard rejection" },
|
|
24678
24719
|
409: { description: "Duplicate explicit-self rating for (taskId, memoryId)" }
|
|
24679
|
-
}
|
|
24720
|
+
},
|
|
24721
|
+
rbac: { ungated: "worker-only: needs X-Agent-ID, which a user token cannot send" }
|
|
24680
24722
|
});
|
|
24681
24723
|
var RetrievalListRowSchema = object2({
|
|
24682
24724
|
id: string2(),
|
|
@@ -25588,6 +25630,9 @@ var createMetricRoute = route({
|
|
|
25588
25630
|
201: { description: "Metric created", schema: metricIdVersionSchema },
|
|
25589
25631
|
400: { description: "Invalid metric definition" },
|
|
25590
25632
|
409: { description: "Slug already exists for this agent" }
|
|
25633
|
+
},
|
|
25634
|
+
rbac: {
|
|
25635
|
+
ungated: "metric definitions: open to agents like the metric tools; no verb covers them, so user roles need admin"
|
|
25591
25636
|
}
|
|
25592
25637
|
});
|
|
25593
25638
|
var listMetricsRoute = route({
|
|
@@ -25637,6 +25682,9 @@ var updateMetricRoute = route({
|
|
|
25637
25682
|
responses: {
|
|
25638
25683
|
200: { description: "Metric updated", schema: metricIdVersionSchema },
|
|
25639
25684
|
404: { description: "Metric not found" }
|
|
25685
|
+
},
|
|
25686
|
+
rbac: {
|
|
25687
|
+
ungated: "metric definitions: open to agents like the metric tools; no verb covers them, so user roles need admin"
|
|
25640
25688
|
}
|
|
25641
25689
|
});
|
|
25642
25690
|
var deleteMetricRoute = route({
|
|
@@ -25649,6 +25697,9 @@ var deleteMetricRoute = route({
|
|
|
25649
25697
|
responses: {
|
|
25650
25698
|
204: { description: "Metric deleted" },
|
|
25651
25699
|
404: { description: "Metric not found" }
|
|
25700
|
+
},
|
|
25701
|
+
rbac: {
|
|
25702
|
+
ungated: "metric definitions: open to agents like the metric tools; no verb covers them, so user roles need admin"
|
|
25652
25703
|
}
|
|
25653
25704
|
});
|
|
25654
25705
|
var metricRunWidgetResultSchema = object2({
|
|
@@ -25680,6 +25731,9 @@ var runMetricRoute = route({
|
|
|
25680
25731
|
200: { description: "Metric result", schema: metricRunResultSchema },
|
|
25681
25732
|
400: { description: "Invalid or disallowed query" },
|
|
25682
25733
|
404: { description: "Metric not found" }
|
|
25734
|
+
},
|
|
25735
|
+
rbac: {
|
|
25736
|
+
ungated: "metric definitions: open to agents like the metric tools; no verb covers them, so user roles need admin"
|
|
25683
25737
|
}
|
|
25684
25738
|
});
|
|
25685
25739
|
var listMetricVersionsRoute = route({
|
|
@@ -26766,6 +26820,7 @@ init_db4();
|
|
|
26766
26820
|
init_oauth();
|
|
26767
26821
|
init_ensure_token();
|
|
26768
26822
|
init_wrapper();
|
|
26823
|
+
init_host();
|
|
26769
26824
|
var APP_USER_ID_NAMESPACE = "integration:linear:bot-app-user-id";
|
|
26770
26825
|
async function getLinearOAuthConfig() {
|
|
26771
26826
|
const app = await getOAuthApp("linear");
|
|
@@ -26785,7 +26840,7 @@ async function getLinearAuthorizationUrl(finalRedirect, userId) {
|
|
|
26785
26840
|
}
|
|
26786
26841
|
async function captureLinearAppUserId(accessToken) {
|
|
26787
26842
|
const query = `query { viewer { id organization { id } } }`;
|
|
26788
|
-
const res = await fetch("
|
|
26843
|
+
const res = await fetch(linearApiUrl("/graphql"), {
|
|
26789
26844
|
method: "POST",
|
|
26790
26845
|
headers: {
|
|
26791
26846
|
"Content-Type": "application/json",
|
|
@@ -26815,7 +26870,7 @@ async function captureLinearAppUserId(accessToken) {
|
|
|
26815
26870
|
}
|
|
26816
26871
|
async function revokeLinearToken(accessToken) {
|
|
26817
26872
|
try {
|
|
26818
|
-
const res = await fetch("
|
|
26873
|
+
const res = await fetch(linearApiUrl("/oauth/revoke"), {
|
|
26819
26874
|
method: "POST",
|
|
26820
26875
|
headers: { Authorization: `Bearer ${accessToken}` }
|
|
26821
26876
|
});
|
|
@@ -27232,6 +27287,9 @@ var acquireLockRoute = route({
|
|
|
27232
27287
|
},
|
|
27233
27288
|
409: { description: "Lock is currently held by another caller" },
|
|
27234
27289
|
400: { description: "Validation error" }
|
|
27290
|
+
},
|
|
27291
|
+
rbac: {
|
|
27292
|
+
ungated: "internal OAuth refresh coordination between API processes and workers; no user flow calls it"
|
|
27235
27293
|
}
|
|
27236
27294
|
});
|
|
27237
27295
|
var releaseLockRoute = route({
|
|
@@ -27245,6 +27303,9 @@ var releaseLockRoute = route({
|
|
|
27245
27303
|
responses: {
|
|
27246
27304
|
204: { description: "Released (a mismatched/expired owner is a no-op, also 204)" },
|
|
27247
27305
|
400: { description: "Validation error" }
|
|
27306
|
+
},
|
|
27307
|
+
rbac: {
|
|
27308
|
+
ungated: "internal OAuth refresh coordination between API processes and workers; no user flow calls it"
|
|
27248
27309
|
}
|
|
27249
27310
|
});
|
|
27250
27311
|
async function handleOAuthLocks(req, res, pathSegments, queryParams) {
|
|
@@ -28311,7 +28372,8 @@ var postTestConnection = route({
|
|
|
28311
28372
|
400: { description: "Validation error" },
|
|
28312
28373
|
401: { description: "Unauthorized" }
|
|
28313
28374
|
},
|
|
28314
|
-
auth: { apiKey: true }
|
|
28375
|
+
auth: { apiKey: true },
|
|
28376
|
+
rbac: { ungated: "reads worker-reported credential status over POST; writes nothing" }
|
|
28315
28377
|
});
|
|
28316
28378
|
async function handleStatus(req, res, pathSegments, queryParams) {
|
|
28317
28379
|
if (getStatus.match(req.method, pathSegments)) {
|
|
@@ -28716,7 +28778,10 @@ route({
|
|
|
28716
28778
|
},
|
|
28717
28779
|
401: { description: "No or invalid page-session cookie" }
|
|
28718
28780
|
},
|
|
28719
|
-
auth: { apiKey: false }
|
|
28781
|
+
auth: { apiKey: false },
|
|
28782
|
+
rbac: {
|
|
28783
|
+
ungated: "the page-session cookie is the credential; the handler allowlists the target and re-issues it to /api/*"
|
|
28784
|
+
}
|
|
28720
28785
|
});
|
|
28721
28786
|
route({
|
|
28722
28787
|
method: "put",
|
|
@@ -28732,7 +28797,10 @@ route({
|
|
|
28732
28797
|
},
|
|
28733
28798
|
401: { description: "No or invalid page-session cookie" }
|
|
28734
28799
|
},
|
|
28735
|
-
auth: { apiKey: false }
|
|
28800
|
+
auth: { apiKey: false },
|
|
28801
|
+
rbac: {
|
|
28802
|
+
ungated: "the page-session cookie is the credential; the handler allowlists the target and re-issues it to /api/*"
|
|
28803
|
+
}
|
|
28736
28804
|
});
|
|
28737
28805
|
route({
|
|
28738
28806
|
method: "delete",
|
|
@@ -28748,7 +28816,10 @@ route({
|
|
|
28748
28816
|
},
|
|
28749
28817
|
401: { description: "No or invalid page-session cookie" }
|
|
28750
28818
|
},
|
|
28751
|
-
auth: { apiKey: false }
|
|
28819
|
+
auth: { apiKey: false },
|
|
28820
|
+
rbac: {
|
|
28821
|
+
ungated: "the page-session cookie is the credential; the handler allowlists the target and re-issues it to /api/*"
|
|
28822
|
+
}
|
|
28752
28823
|
});
|
|
28753
28824
|
route({
|
|
28754
28825
|
method: "patch",
|
|
@@ -28764,7 +28835,10 @@ route({
|
|
|
28764
28835
|
},
|
|
28765
28836
|
401: { description: "No or invalid page-session cookie" }
|
|
28766
28837
|
},
|
|
28767
|
-
auth: { apiKey: false }
|
|
28838
|
+
auth: { apiKey: false },
|
|
28839
|
+
rbac: {
|
|
28840
|
+
ungated: "the page-session cookie is the credential; the handler allowlists the target and re-issues it to /api/*"
|
|
28841
|
+
}
|
|
28768
28842
|
});
|
|
28769
28843
|
var PROXY_PREFIX = "/@swarm/api/";
|
|
28770
28844
|
var PAGE_ID_REQUEST_HEADER = "x-swarm-page-id";
|
|
@@ -29154,6 +29228,7 @@ var AgentTaskSummarySchema = AgentTaskSchema.pick({
|
|
|
29154
29228
|
resolvedEffort: true,
|
|
29155
29229
|
profile: true,
|
|
29156
29230
|
resolvedProfile: true,
|
|
29231
|
+
modelGroup: true,
|
|
29157
29232
|
provider: true,
|
|
29158
29233
|
requestedByUserId: true,
|
|
29159
29234
|
progress: true,
|
|
@@ -29295,6 +29370,7 @@ var createTask = route({
|
|
|
29295
29370
|
allowCustomModel: boolean().optional(),
|
|
29296
29371
|
effort: ReasoningEffortSchema.optional(),
|
|
29297
29372
|
profile: string2().trim().min(1).optional(),
|
|
29373
|
+
modelGroup: string2().trim().min(1).optional(),
|
|
29298
29374
|
draft: boolean().optional()
|
|
29299
29375
|
}).superRefine((body, ctx) => {
|
|
29300
29376
|
if ((body.agentId !== undefined || body.offeredTo !== undefined) && !body.routingReason) {
|
|
@@ -29372,6 +29448,9 @@ var updateSession = route({
|
|
|
29372
29448
|
responses: {
|
|
29373
29449
|
200: { description: "Session ID updated", schema: AgentTaskSchema },
|
|
29374
29450
|
404: { description: "Task not found" }
|
|
29451
|
+
},
|
|
29452
|
+
rbac: {
|
|
29453
|
+
ungated: "worker runner endpoint for its own task; the route's session posture gates any user caller"
|
|
29375
29454
|
}
|
|
29376
29455
|
});
|
|
29377
29456
|
var cancelTaskRoute = route({
|
|
@@ -29568,6 +29647,7 @@ var updateTaskProgressRoute = route({
|
|
|
29568
29647
|
session: { taskParam: "id" },
|
|
29569
29648
|
summary: "Update task progress text",
|
|
29570
29649
|
tags: ["Tasks"],
|
|
29650
|
+
rbac: { permission: "task.progress.write" },
|
|
29571
29651
|
params: object2({ id: string2() }),
|
|
29572
29652
|
body: object2({ progress: string2().min(1) }),
|
|
29573
29653
|
responses: {
|
|
@@ -29605,6 +29685,9 @@ var finishTask = route({
|
|
|
29605
29685
|
description: "Differing terminal result text was discarded",
|
|
29606
29686
|
schema: FinishTaskConflictSchema
|
|
29607
29687
|
}
|
|
29688
|
+
},
|
|
29689
|
+
rbac: {
|
|
29690
|
+
ungated: "worker runner endpoint for its own task; the route's session posture gates any user caller"
|
|
29608
29691
|
}
|
|
29609
29692
|
});
|
|
29610
29693
|
var listPausedTasks = route({
|
|
@@ -29714,6 +29797,9 @@ var supersedeTaskRoute = route({
|
|
|
29714
29797
|
400: { description: "Task not in_progress" },
|
|
29715
29798
|
403: { description: "Task belongs to another agent" },
|
|
29716
29799
|
404: { description: "Task not found" }
|
|
29800
|
+
},
|
|
29801
|
+
rbac: {
|
|
29802
|
+
ungated: "worker runner endpoint for its own task; the route's session posture gates any user caller"
|
|
29717
29803
|
}
|
|
29718
29804
|
});
|
|
29719
29805
|
var updateTaskVcsRoute = route({
|
|
@@ -29735,7 +29821,10 @@ var updateTaskVcsRoute = route({
|
|
|
29735
29821
|
403: { description: "Task belongs to another token agent" },
|
|
29736
29822
|
404: { description: "Task not found" }
|
|
29737
29823
|
},
|
|
29738
|
-
auth: { apiKey: true }
|
|
29824
|
+
auth: { apiKey: true },
|
|
29825
|
+
rbac: {
|
|
29826
|
+
ungated: "worker runner endpoint for its own task; the route's session posture gates any user caller"
|
|
29827
|
+
}
|
|
29739
29828
|
});
|
|
29740
29829
|
var updateTaskTitleRoute = route({
|
|
29741
29830
|
method: "patch",
|
|
@@ -29985,6 +30074,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
29985
30074
|
}
|
|
29986
30075
|
const profileError = await taskProfileError({
|
|
29987
30076
|
profile: parsed.body.profile,
|
|
30077
|
+
modelGroup: parsed.body.modelGroup,
|
|
29988
30078
|
...splitLegacyModelAlias({ model: parsed.body.model, modelTier: parsed.body.modelTier }),
|
|
29989
30079
|
agentId: defaultAgentId,
|
|
29990
30080
|
vcsRepo: vcsRepo ?? parentTask?.vcsRepo
|
|
@@ -30033,7 +30123,8 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
30033
30123
|
modelTier: parsed.body.modelTier
|
|
30034
30124
|
}),
|
|
30035
30125
|
effort: parsed.body.effort,
|
|
30036
|
-
profile: parsed.body.profile
|
|
30126
|
+
profile: parsed.body.profile,
|
|
30127
|
+
modelGroup: parsed.body.modelGroup
|
|
30037
30128
|
}, { origin: "rest", allowCustomModel: parsed.body.allowCustomModel });
|
|
30038
30129
|
const task = claim ? await getDbClient2().transaction(async () => {
|
|
30039
30130
|
if (await findAcceptedTaskCreate(claim))
|
|
@@ -30082,6 +30173,10 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
30082
30173
|
jsonError(res, error.message, 400);
|
|
30083
30174
|
return true;
|
|
30084
30175
|
}
|
|
30176
|
+
if (modelGroupRefError(error)) {
|
|
30177
|
+
jsonError(res, `Unknown model group "${parsed.body.modelGroup}"`, 400);
|
|
30178
|
+
return true;
|
|
30179
|
+
}
|
|
30085
30180
|
if (modelProfileRefError(error) === "missing") {
|
|
30086
30181
|
jsonError(res, `Unknown model profile "${parsed.body.profile}"`, 400);
|
|
30087
30182
|
return true;
|
|
@@ -31067,6 +31162,9 @@ var createPageRoute = route({
|
|
|
31067
31162
|
},
|
|
31068
31163
|
400: { description: "Invalid body, unknown theme, or invalid themeTokens" },
|
|
31069
31164
|
409: { description: "Slug already exists for this agent" }
|
|
31165
|
+
},
|
|
31166
|
+
rbac: {
|
|
31167
|
+
ungated: "agents publish pages like the create-page tool; no verb covers page writes, so user roles need admin"
|
|
31070
31168
|
}
|
|
31071
31169
|
});
|
|
31072
31170
|
var getPageRoute = route({
|
|
@@ -31143,6 +31241,9 @@ var updatePageRoute = route({
|
|
|
31143
31241
|
400: { description: "Unknown theme or invalid themeTokens" },
|
|
31144
31242
|
404: { description: "Page not found" },
|
|
31145
31243
|
413: { description: "Payload too large" }
|
|
31244
|
+
},
|
|
31245
|
+
rbac: {
|
|
31246
|
+
ungated: "agents publish pages like the create-page tool; no verb covers page writes, so user roles need admin"
|
|
31146
31247
|
}
|
|
31147
31248
|
});
|
|
31148
31249
|
var PageFeedbackCommentSchema = object2({
|
|
@@ -31196,7 +31297,8 @@ var deletePageRoute = route({
|
|
|
31196
31297
|
responses: {
|
|
31197
31298
|
204: { description: "Page deleted" },
|
|
31198
31299
|
404: { description: "Page not found" }
|
|
31199
|
-
}
|
|
31300
|
+
},
|
|
31301
|
+
rbac: { permission: "page.delete.any" }
|
|
31200
31302
|
});
|
|
31201
31303
|
var listPagesRoute = route({
|
|
31202
31304
|
method: "get",
|
|
@@ -34327,6 +34429,7 @@ init_api_drain();
|
|
|
34327
34429
|
init_budget_admission();
|
|
34328
34430
|
init_budget_refusal_notify();
|
|
34329
34431
|
init_db4();
|
|
34432
|
+
init_model_group_resolution();
|
|
34330
34433
|
init_model_profile_check();
|
|
34331
34434
|
init_model_tier_resolution();
|
|
34332
34435
|
init_model_validation2();
|
|
@@ -34628,7 +34731,8 @@ var commitCursorsRoute = route({
|
|
|
34628
34731
|
schema: object2({ success: literal2(true), committed: number2().int().nonnegative() })
|
|
34629
34732
|
},
|
|
34630
34733
|
400: { description: "Invalid request" }
|
|
34631
|
-
}
|
|
34734
|
+
},
|
|
34735
|
+
rbac: { ungated: "lead worker commits its channel-activity cursors; no user flow calls it" }
|
|
34632
34736
|
});
|
|
34633
34737
|
async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
|
|
34634
34738
|
const runtimeInstanceId = ((h) => Array.isArray(h) ? h[0] : h)(req.headers["x-runtime-instance-id"]);
|
|
@@ -34841,7 +34945,17 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
34841
34945
|
profileOk.set(memoKey, ok);
|
|
34842
34946
|
return ok;
|
|
34843
34947
|
};
|
|
34844
|
-
const
|
|
34948
|
+
const groupOk = new Map;
|
|
34949
|
+
const passesGroupCheck = async (group, vcsRepo) => {
|
|
34950
|
+
const memoKey = JSON.stringify([group, vcsRepo ?? null]);
|
|
34951
|
+
const cached = groupOk.get(memoKey);
|
|
34952
|
+
if (cached !== undefined)
|
|
34953
|
+
return cached;
|
|
34954
|
+
const ok = (await resolveGroupForAgent(group, myAgentId, { vcsRepo, includeRepoSecrets })).kind !== "none";
|
|
34955
|
+
groupOk.set(memoKey, ok);
|
|
34956
|
+
return ok;
|
|
34957
|
+
};
|
|
34958
|
+
const unassignedIds = await getUnassignedTaskIdsForAgent2(myAgentId, 5, async (task) => await poolTaskRunsOnHarness(task, harness) && (task.profile ? await passesProfileCheck(task.profile, task.vcsRepo) : !task.modelGroup || await passesGroupCheck(task.modelGroup, task.vcsRepo)));
|
|
34845
34959
|
if (unassignedIds.length > 0) {
|
|
34846
34960
|
if (probe)
|
|
34847
34961
|
return NEEDS_WRITE;
|
|
@@ -35367,7 +35481,8 @@ var insertPricing = route({
|
|
|
35367
35481
|
201: { description: "Pricing row inserted", schema: PricingRowSchema },
|
|
35368
35482
|
400: { description: "Validation error" },
|
|
35369
35483
|
409: { description: "Duplicate (provider, model, tokenClass, effectiveFrom)" }
|
|
35370
|
-
}
|
|
35484
|
+
},
|
|
35485
|
+
rbac: { ungated: "spend controls: no verb covers them, so user roles need admin" }
|
|
35371
35486
|
});
|
|
35372
35487
|
var deletePricing = route({
|
|
35373
35488
|
method: "delete",
|
|
@@ -35381,7 +35496,8 @@ var deletePricing = route({
|
|
|
35381
35496
|
responses: {
|
|
35382
35497
|
204: { description: "Pricing row deleted" },
|
|
35383
35498
|
404: { description: "Pricing row not found" }
|
|
35384
|
-
}
|
|
35499
|
+
},
|
|
35500
|
+
rbac: { ungated: "spend controls: no verb covers them, so user roles need admin" }
|
|
35385
35501
|
});
|
|
35386
35502
|
async function handlePricing(req, res, pathSegments, queryParams, _myAgentId) {
|
|
35387
35503
|
if (listAllPricing.match(req.method, pathSegments)) {
|
|
@@ -35481,8 +35597,12 @@ init_registry3();
|
|
|
35481
35597
|
init_resolver();
|
|
35482
35598
|
init_types5();
|
|
35483
35599
|
init_template2();
|
|
35600
|
+
init_request_principal();
|
|
35484
35601
|
init_route_def();
|
|
35485
35602
|
init_utils2();
|
|
35603
|
+
function templateOwner(template) {
|
|
35604
|
+
return { kind: "owned", ownerAgentId: template?.scope === "agent" ? template.scopeId : null };
|
|
35605
|
+
}
|
|
35486
35606
|
var VariableDefinitionSchema = object2({
|
|
35487
35607
|
name: string2(),
|
|
35488
35608
|
description: string2(),
|
|
@@ -35571,7 +35691,8 @@ var previewRoute = route({
|
|
|
35571
35691
|
},
|
|
35572
35692
|
400: { description: "Validation error" }
|
|
35573
35693
|
},
|
|
35574
|
-
auth: { apiKey: true }
|
|
35694
|
+
auth: { apiKey: true },
|
|
35695
|
+
rbac: { ungated: "read-only render over POST; open to agents like the prompt-template tools" }
|
|
35575
35696
|
});
|
|
35576
35697
|
var renderRoute = route({
|
|
35577
35698
|
method: "post",
|
|
@@ -35589,7 +35710,8 @@ var renderRoute = route({
|
|
|
35589
35710
|
200: { description: "Fully resolved and interpolated template", schema: ResolveResultSchema },
|
|
35590
35711
|
400: { description: "Validation error" }
|
|
35591
35712
|
},
|
|
35592
|
-
auth: { apiKey: true }
|
|
35713
|
+
auth: { apiKey: true },
|
|
35714
|
+
rbac: { ungated: "read-only render over POST; open to agents like the prompt-template tools" }
|
|
35593
35715
|
});
|
|
35594
35716
|
var checkoutRoute = route({
|
|
35595
35717
|
method: "post",
|
|
@@ -35607,7 +35729,8 @@ var checkoutRoute = route({
|
|
|
35607
35729
|
400: { description: "Validation error" },
|
|
35608
35730
|
404: { description: "Template or version not found" }
|
|
35609
35731
|
},
|
|
35610
|
-
auth: { apiKey: true }
|
|
35732
|
+
auth: { apiKey: true },
|
|
35733
|
+
rbac: { permission: "prompt-template.write" }
|
|
35611
35734
|
});
|
|
35612
35735
|
var resetRoute = route({
|
|
35613
35736
|
method: "post",
|
|
@@ -35623,7 +35746,8 @@ var resetRoute = route({
|
|
|
35623
35746
|
},
|
|
35624
35747
|
404: { description: "Template not found or no code default available" }
|
|
35625
35748
|
},
|
|
35626
|
-
auth: { apiKey: true }
|
|
35749
|
+
auth: { apiKey: true },
|
|
35750
|
+
rbac: { permission: "prompt-template.write" }
|
|
35627
35751
|
});
|
|
35628
35752
|
var getByIdRoute = route({
|
|
35629
35753
|
method: "get",
|
|
@@ -35659,7 +35783,8 @@ var deleteByIdRoute = route({
|
|
|
35659
35783
|
400: { description: "Cannot delete default template" },
|
|
35660
35784
|
404: { description: "Template not found" }
|
|
35661
35785
|
},
|
|
35662
|
-
auth: { apiKey: true }
|
|
35786
|
+
auth: { apiKey: true },
|
|
35787
|
+
rbac: { permission: "prompt-template.write" }
|
|
35663
35788
|
});
|
|
35664
35789
|
var listRoute3 = route({
|
|
35665
35790
|
method: "get",
|
|
@@ -35703,7 +35828,8 @@ var upsertRoute = route({
|
|
|
35703
35828
|
},
|
|
35704
35829
|
400: { description: "Validation error" }
|
|
35705
35830
|
},
|
|
35706
|
-
auth: { apiKey: true }
|
|
35831
|
+
auth: { apiKey: true },
|
|
35832
|
+
rbac: { permission: "prompt-template.write" }
|
|
35707
35833
|
});
|
|
35708
35834
|
async function handlePromptTemplates(req, res, pathSegments, queryParams) {
|
|
35709
35835
|
if (resolvedRoute.match(req.method, pathSegments)) {
|
|
@@ -35775,6 +35901,10 @@ ${templateBody}` : templateBody;
|
|
|
35775
35901
|
const parsed = await checkoutRoute.parse(req, res, pathSegments, queryParams);
|
|
35776
35902
|
if (!parsed)
|
|
35777
35903
|
return true;
|
|
35904
|
+
const target = await getPromptTemplateById2(parsed.params.id);
|
|
35905
|
+
if (await refuseAgentTokenWithout(req, res, "prompt-template.write", templateOwner(target))) {
|
|
35906
|
+
return true;
|
|
35907
|
+
}
|
|
35778
35908
|
try {
|
|
35779
35909
|
const template = await checkoutPromptTemplate2(parsed.params.id, parsed.body.version);
|
|
35780
35910
|
checkoutRoute.respond(res, 200, { template: toPromptTemplateResponse(template) });
|
|
@@ -35797,6 +35927,9 @@ ${templateBody}` : templateBody;
|
|
|
35797
35927
|
jsonError(res, `Prompt template ${parsed.params.id} not found`, 404);
|
|
35798
35928
|
return true;
|
|
35799
35929
|
}
|
|
35930
|
+
if (await refuseAgentTokenWithout(req, res, "prompt-template.write", templateOwner(existing))) {
|
|
35931
|
+
return true;
|
|
35932
|
+
}
|
|
35800
35933
|
const definition = getTemplateDefinition(existing.eventType);
|
|
35801
35934
|
if (!definition) {
|
|
35802
35935
|
jsonError(res, `No code default found for event type "${existing.eventType}"`, 404);
|
|
@@ -35828,6 +35961,10 @@ ${templateBody}` : templateBody;
|
|
|
35828
35961
|
const parsed = await deleteByIdRoute.parse(req, res, pathSegments, queryParams);
|
|
35829
35962
|
if (!parsed)
|
|
35830
35963
|
return true;
|
|
35964
|
+
const target = await getPromptTemplateById2(parsed.params.id);
|
|
35965
|
+
if (await refuseAgentTokenWithout(req, res, "prompt-template.write", templateOwner(target))) {
|
|
35966
|
+
return true;
|
|
35967
|
+
}
|
|
35831
35968
|
try {
|
|
35832
35969
|
const deleted = await deletePromptTemplate2(parsed.params.id);
|
|
35833
35970
|
if (!deleted) {
|
|
@@ -35876,6 +36013,9 @@ ${templateBody}` : templateBody;
|
|
|
35876
36013
|
jsonError(res, "Agent/repo scope requires scopeId", 400);
|
|
35877
36014
|
return true;
|
|
35878
36015
|
}
|
|
36016
|
+
if (await refuseAgentTokenWithout(req, res, "prompt-template.write", templateOwner({ scope, scopeId: scopeId ?? null }))) {
|
|
36017
|
+
return true;
|
|
36018
|
+
}
|
|
35879
36019
|
try {
|
|
35880
36020
|
const template = await getDbClient2().transaction(async () => upsertPromptTemplate2({
|
|
35881
36021
|
eventType,
|
|
@@ -35905,7 +36045,7 @@ init_users();
|
|
|
35905
36045
|
init_rbac();
|
|
35906
36046
|
|
|
35907
36047
|
// src/realtime/browser.generated.txt
|
|
35908
|
-
var browser_generated_default = "var J=()=>new Map,Er=(e)=>{let t=J();return e.forEach((r,n)=>{t.set(n,r)}),t},me=(e,t,r)=>{let n=e.get(t);if(n===void 0)e.set(t,n=r());return n},mi=(e,t)=>{let r=[];for(let[n,o]of e)r.push(t(o,n));return r},gi=(e,t)=>{for(let[r,n]of e)if(t(n,r))return!0;return!1};var Ie=()=>new Set;var Ar=(e)=>e[e.length-1];var yi=(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r])},ge=Array.from,Or=(e,t)=>{for(let r=0;r<e.length;r++)if(!t(e[r],r,e))return!1;return!0},Tr=(e,t)=>{for(let r=0;r<e.length;r++)if(t(e[r],r,e))return!0;return!1};var xi=(e,t)=>{let r=Array(e);for(let n=0;n<e;n++)r[n]=t(n,r);return r};var Me=Array.isArray;class fo{constructor(){this._observers=J()}on(e,t){return me(this._observers,e,Ie).add(t),t}once(e,t){let r=(...n)=>{this.off(e,r),t(...n)};this.on(e,r)}off(e,t){let r=this._observers.get(e);if(r!==void 0){if(r.delete(t),r.size===0)this._observers.delete(e)}}emit(e,t){return ge((this._observers.get(e)||J()).values()).forEach((r)=>r(...t))}destroy(){this._observers=J()}}var K=Math.floor;var Ve=Math.abs;var Pr=(e,t)=>e<t?e:t,Ee=(e,t)=>e>t?e:t;var Zr=(e)=>e!==0?e<0:1/e<0;var po=1,ho=2,Cr=4,Dr=8;var ot=32,ie=64,M=128;var jt=31,Lt=63,Ae=127;var _i=2147483647;var{MAX_SAFE_INTEGER:st,MIN_SAFE_INTEGER:go}=Number;var wi=Number.isInteger||((e)=>typeof e===\"number\"&&isFinite(e)&&K(e)===e);var{fromCharCode:xo,fromCodePoint:Kp}=String,Cy=xo(65535),qp=(e)=>e.toLowerCase(),Gp=/^\\s*/g,Wp=(e)=>e.replace(Gp,\"\"),Hp=/([A-Z])/g,_o=(e,t)=>Wp(e.replace(Hp,(r)=>`${t}${qp(r)}`));var Yp=(e)=>{let t=unescape(encodeURIComponent(e)),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.codePointAt(o);return n},ct=typeof TextEncoder<\"u\"?new TextEncoder:null,Xp=(e)=>ct.encode(e),bi=ct?Xp:Yp;var it=typeof TextDecoder>\"u\"?null:new TextDecoder(\"utf-8\",{fatal:!0,ignoreBOM:!0});if(it&&it.decode(new Uint8Array).length===1)it=null;var ki=(e,t)=>xi(t,()=>e).join(\"\");class ut{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Bt=()=>new ut;var Qp=(e)=>{let t=e.cpos;for(let r=0;r<e.bufs.length;r++)t+=e.bufs[r].length;return t};var ce=(e)=>{let t=new Uint8Array(Qp(e)),r=0;for(let n=0;n<e.bufs.length;n++){let o=e.bufs[n];t.set(o,r),r+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),r),t},ed=(e,t)=>{let r=e.cbuf.length;if(r-e.cpos<t)e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Ee(r,t)*2),e.cpos=0},N=(e,t)=>{let r=e.cbuf.length;if(e.cpos===r)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(r*2),e.cpos=0;e.cbuf[e.cpos++]=t};var Ur=N;var w=(e,t)=>{while(t>Ae)N(e,M|Ae&t),t=K(t/128);N(e,Ae&t)},Rr=(e,t)=>{let r=Zr(t);if(r)t=-t;N(e,(t>Lt?M:0)|(r?ie:0)|Lt&t),t=K(t/64);while(t>0)N(e,(t>Ae?M:0)|Ae&t),t=K(t/128)},wo=new Uint8Array(30000),td=wo.length/3,rd=(e,t)=>{if(t.length<td){let r=ct.encodeInto(t,wo).written||0;w(e,r);for(let n=0;n<r;n++)N(e,wo[n])}else W(e,bi(t))},nd=(e,t)=>{let r=unescape(encodeURIComponent(t)),n=r.length;w(e,n);for(let o=0;o<n;o++)N(e,r.codePointAt(o))},Fe=ct&&ct.encodeInto?rd:nd;var Mt=(e,t)=>{let r=e.cbuf.length,n=e.cpos,o=Pr(r-n,t.length),s=t.length-o;if(e.cbuf.set(t.subarray(0,o),n),e.cpos+=o,s>0)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Ee(r*2,s)),e.cbuf.set(t.subarray(o)),e.cpos=s},W=(e,t)=>{w(e,t.byteLength),Mt(e,t)},bo=(e,t)=>{ed(e,t);let r=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,r},od=(e,t)=>bo(e,4).setFloat32(0,t,!1),sd=(e,t)=>bo(e,8).setFloat64(0,t,!1),id=(e,t)=>bo(e,8).setBigInt64(0,t,!1);var vi=new DataView(new ArrayBuffer(4)),cd=(e)=>(vi.setFloat32(0,e),vi.getFloat32(0)===e),at=(e,t)=>{switch(typeof t){case\"string\":N(e,119),Fe(e,t);break;case\"number\":if(wi(t)&&Ve(t)<=_i)N(e,125),Rr(e,t);else if(cd(t))N(e,124),od(e,t);else N(e,123),sd(e,t);break;case\"bigint\":N(e,122),id(e,t);break;case\"object\":if(t===null)N(e,126);else if(Me(t)){N(e,117),w(e,t.length);for(let r=0;r<t.length;r++)at(e,t[r])}else if(t instanceof Uint8Array)N(e,116),W(e,t);else{N(e,118);let r=Object.keys(t);w(e,r.length);for(let n=0;n<r.length;n++){let o=r[n];Fe(e,o),at(e,t[o])}}break;case\"boolean\":N(e,t?120:121);break;default:N(e,127)}};class jr extends ut{constructor(e){super();this.w=e,this.s=null,this.count=0}write(e){if(this.s===e)this.count++;else{if(this.count>0)w(this,this.count-1);this.count=1,this.w(this,e),this.s=e}}}var Si=(e)=>{if(e.count>0){if(Rr(e.encoder,e.count===1?e.s:-e.s),e.count>1)w(e.encoder,e.count-2)}};class lt{constructor(){this.encoder=new ut,this.s=0,this.count=0}write(e){if(this.s===e)this.count++;else Si(this),this.count=1,this.s=e}toUint8Array(){return Si(this),ce(this.encoder)}}var $i=(e)=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);if(Rr(e.encoder,t),e.count>1)w(e.encoder,e.count-2)}};class Vt{constructor(){this.encoder=new ut,this.s=0,this.count=0,this.diff=0}write(e){if(this.diff===e-this.s)this.s=e,this.count++;else $i(this),this.count=1,this.diff=e-this.s,this.s=e}toUint8Array(){return $i(this),ce(this.encoder)}}class ko{constructor(){this.sarr=[],this.s=\"\",this.lensE=new lt}write(e){if(this.s+=e,this.s.length>19)this.sarr.push(this.s),this.s=\"\";this.lensE.write(e.length)}toUint8Array(){let e=new ut;return this.sarr.push(this.s),this.s=\"\",Fe(e,this.sarr.join(\"\")),Mt(e,this.lensE.toUint8Array()),ce(e)}}var X=(e)=>Error(e),Q=()=>{throw X(\"Method unimplemented\")},H=()=>{throw X(\"Unexpected case\")};var zi=X(\"Unexpected end of array\"),Ii=X(\"Integer out of Range\");class Ft{constructor(e){this.arr=e,this.pos=0}}var qe=(e)=>new Ft(e),Ei=(e)=>e.pos!==e.arr.length;var ud=(e,t)=>{let r=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,r},Y=(e)=>ud(e,_(e));var Je=(e)=>e.arr[e.pos++];var _=(e)=>{let t=0,r=1,n=e.arr.length;while(e.pos<n){let o=e.arr[e.pos++];if(t=t+(o&Ae)*r,r*=128,o<M)return t;if(t>st)throw Ii}throw zi},Lr=(e)=>{let t=e.arr[e.pos++],r=t&Lt,n=64,o=(t&ie)>0?-1:1;if((t&M)===0)return o*r;let s=e.arr.length;while(e.pos<s){if(t=e.arr[e.pos++],r=r+(t&Ae)*n,n*=128,t<M)return o*r;if(r>st)throw Ii}throw zi};var ld=(e)=>{let t=_(e);if(t===0)return\"\";else{let r=String.fromCodePoint(Je(e));if(--t<100)while(t--)r+=String.fromCodePoint(Je(e));else while(t>0){let n=t<1e4?t:1e4,o=e.arr.subarray(e.pos,e.pos+n);e.pos+=n,r+=String.fromCodePoint.apply(null,o),t-=n}return decodeURIComponent(escape(r))}},fd=(e)=>it.decode(Y(e)),Ke=it?fd:ld;var So=(e,t)=>{let r=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,r},pd=(e)=>So(e,4).getFloat32(0,!1),dd=(e)=>So(e,8).getFloat64(0,!1),hd=(e)=>So(e,8).getBigInt64(0,!1);var md=[(e)=>{return},(e)=>null,Lr,pd,dd,hd,(e)=>!1,(e)=>!0,Ke,(e)=>{let t=_(e),r={};for(let n=0;n<t;n++){let o=Ke(e);r[o]=ft(e)}return r},(e)=>{let t=_(e),r=[];for(let n=0;n<t;n++)r.push(ft(e));return r},Y],ft=(e)=>md[127-Je(e)](e);class Br extends Ft{constructor(e,t){super(e);this.reader=t,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Ei(this))this.count=_(this)+1;else this.count=-1;return this.count--,this.s}}class pt extends Ft{constructor(e){super(e);this.s=0,this.count=0}read(){if(this.count===0){this.s=Lr(this);let e=Zr(this.s);if(this.count=1,e)this.s=-this.s,this.count=_(this)+2}return this.count--,this.s}}class Jt extends Ft{constructor(e){super(e);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Lr(this),t=e&1;if(this.diff=K(e/2),this.count=1,t)this.count=_(this)+2}return this.s+=this.diff,this.count--,this.s}}class $o{constructor(e){this.decoder=new pt(e),this.str=Ke(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}var Uy=crypto.subtle,Ai=crypto.getRandomValues.bind(crypto);var zo=()=>Ai(new Uint32Array(1))[0];var yd=[1e7]+-1000+-4000+-8000+-100000000000,Oi=()=>yd.replace(/[018]/g,(e)=>(e^zo()&15>>e/4).toString(16));var Ti=Date.now;var Io=(e)=>new Promise(e);var Ly=Promise.all.bind(Promise);var Eo=(e)=>e===void 0?null:e;class Pi{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}var Zi=new Pi,kd=!0;try{if(typeof localStorage<\"u\"&&localStorage)Zi=localStorage,kd=!1}catch(e){}var Ci=Zi;var Ge=Symbol(\"Equality\"),Mr=(e,t)=>e===t||!!e?.[Ge]?.(t)||!1;var Di=(e)=>typeof e===\"object\",{assign:Ni,keys:Sd}=Object;var Ui=(e,t)=>{for(let r in e)t(e[r],r)};var Kt=(e)=>Sd(e).length;var Ri=(e)=>{for(let t in e)return!1;return!0},dt=(e,t)=>{for(let r in e)if(!t(e[r],r))return!1;return!0},qt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Oo=(e,t)=>e===t||Kt(e)===Kt(t)&&dt(e,(r,n)=>(r!==void 0||qt(t,n))&&Mr(t[n],r)),$d=Object.freeze,To=(e)=>{for(let t in e){let r=e[t];if(typeof r===\"object\"||typeof r===\"function\")To(e[t])}return $d(e)};var Wt=(e,t,r=0)=>{try{for(;r<e.length;r++)e[r](...t)}finally{if(r<e.length)Wt(e,t,r+1)}};var ji=(e)=>e;var Gt=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Ge]!=null)return e[Ge](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let r of e)if(!t.has(r))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let r of e.keys())if(!t.has(r)||!Gt(e.get(r),t.get(r)))return!1;break}case void 0:case Object:if(Kt(e)!==Kt(t))return!1;for(let r in e)if(!qt(e,r)||!Gt(e[r],t[r]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Gt(e[r],t[r]))return!1;break;default:return!1}return!0},Li=(e,t)=>t.includes(e);var Ht=typeof process<\"u\"&&process.release&&/node|io\\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<\"u\"?process:0)===\"[object process]\";var By=typeof navigator<\"u\"?/Mac/.test(navigator.platform):!1,ye,zd=[],Id=()=>{if(ye===void 0)if(Ht){ye=J();let e=process.argv,t=null;for(let r=0;r<e.length;r++){let n=e[r];if(n[0]===\"-\"){if(t!==null)ye.set(t,\"\");t=n}else if(t!==null)ye.set(t,n),t=null;else zd.push(n)}if(t!==null)ye.set(t,\"\")}else if(typeof location===\"object\")ye=J(),(location.search||\"?\").slice(1).split(\"&\").forEach((e)=>{if(e.length!==0){let[t,r]=e.split(\"=\");ye.set(`--${_o(t,\"-\")}`,r),ye.set(`-${_o(t,\"-\")}`,r)}});else ye=J();return ye},Co=(e)=>Id().has(e);var Yt=(e)=>Ht?Eo(process.env[e.toUpperCase().replaceAll(\"-\",\"_\")]):Eo(Ci.getItem(e));var Bi=(e)=>Co(\"--\"+e)||Yt(e)!==null,Mi=Bi(\"production\"),Ed=Ht&&Li(process.env.FORCE_COLOR,[\"true\",\"1\",\"2\"]),Vi=Ed||!Co(\"--no-colors\")&&!Bi(\"no-color\")&&(!Ht||process.stdout.isTTY)&&(!Ht||Co(\"--color\")||Yt(\"COLORTERM\")!==null||(Yt(\"TERM\")||\"\").includes(\"color\"));var Ad=(e)=>new Uint8Array(e);var Fi=(e)=>{let t=Ad(e.byteLength);return t.set(e),t};class Ji{constructor(e,t){this.left=e,this.right=t}}var xe=(e,t)=>new Ji(e,t);var No=(e)=>e.next()>=0.5,Vr=(e,t,r)=>K(e.next()*(r+1-t)+t);var Uo=(e,t,r)=>K(e.next()*(r+1-t)+t);var Ro=(e,t,r)=>Uo(e,t,r);var Pd=(e)=>xo(Ro(e,97,122)),Ki=(e,t=0,r=20)=>{let n=Ro(e,t,r),o=\"\";for(let s=0;s<n;s++)o+=Pd(e);return o};var Fr=(e,t)=>t[Ro(e,0,t.length-1)];var Cd=Symbol(\"0schema\");class Gi{constructor(){this._rerrs=[]}extend(e,t,r,n=null){this._rerrs.push({path:e,expected:t,has:r,message:n})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let r=this._rerrs[t];e.push(ki(\" \",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:\"\"}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`\n`)}}var jo=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor)return!1;if(e[Ge])return Mr(e,t);if(Me(e))return Or(e,(r)=>Tr(t,(n)=>jo(r,n)));else if(Di(e))return dt(e,(r,n)=>jo(r,t[n]));return!1};class V{static _dilutes=!1;extends(e){let[t,r]=[this.shape,e.shape];if(this.constructor._dilutes)[r,t]=[t,r];return jo(t,r)}equals(e){return this.constructor===e.constructor&&Gt(this.shape,e.shape)}[Cd](){return!0}[Ge](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Q()}get nullable(){return yt(this,Qr)}get optional(){return new Lo(this)}cast(e){return qi(e,this),e}expect(e){return qi(e,this),e}}class qr extends V{constructor(e,t){super();this.shape=e,this._c=t}check(e,t=void 0){let r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?\"Constructor match failed\":\"Check failed\"),r}}var T=(e,t=null)=>new qr(e,t),Vy=T(qr);class Gr extends V{constructor(e){super();this.shape=e}check(e,t){let r=this.shape(e);return!r&&t?.extend(null,\"custom prop\",e?.constructor.name,\"failed to check custom prop\"),r}}var Z=(e)=>new Gr(e),Fy=T(Gr);class Qt extends V{constructor(e){super();this.shape=e}check(e,t){let r=this.shape.some((n)=>n===e);return!r&&t?.extend(null,this.shape.join(\" | \"),e.toString()),r}}var Wr=(...e)=>new Qt(e),Wi=T(Qt),Dd=RegExp.escape||((e)=>e.replace(/[().|&,$^[\\]]/g,(t)=>\"\\\\\"+t)),Hi=(e)=>{if(gt.check(e))return[Dd(e)];if(Wi.check(e))return e.shape.map((t)=>t+\"\");if(oc.check(e))return[\"[+-]?\\\\d+.?\\\\d*\"];if(sc.check(e))return[\".*\"];if(Jr.check(e))return e.shape.map(Hi).flat(1);H()};class Yi extends V{constructor(e){super();this.shape=e,this._r=new RegExp(\"^\"+e.map(Hi).map((t)=>`(${t.join(\"|\")})`).join(\"\")+\"$\")}check(e,t){let r=this._r.exec(e)!=null;return!r&&t?.extend(null,this._r.toString(),e.toString(),\"String doesn't match string template.\"),r}}var Jy=T(Yi),Nd=Symbol(\"optional\");class Lo extends V{constructor(e){super();this.shape=e}check(e,t){let r=e===void 0||this.shape.check(e);return!r&&t?.extend(null,\"undefined (optional)\",\"()\"),r}get[Nd](){return!0}}var Ud=T(Lo);class Bo extends V{check(e,t){return t?.extend(null,\"never\",typeof e),!1}}var Ky=new Bo,qy=T(Bo);class Hr extends V{constructor(e,t=!1){super();this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new Hr(this.shape,!0)}check(e,t){if(e==null)return t?.extend(null,\"object\",\"null\"),!1;return dt(this.shape,(r,n)=>{let o=this._isPartial&&!qt(e,n)||r.check(e[n],t);return!o&&t?.extend(n.toString(),r.toString(),typeof e[n],\"Object property does not match\"),o})}}var Rd=(e)=>new Hr(e),jd=T(Hr),Ld=Z((e)=>e!=null&&(e.constructor===Object||e.constructor==null));class Mo extends V{constructor(e,t){super();this.shape={keys:e,values:t}}check(e,t){return e!=null&&dt(e,(r,n)=>{let o=this.shape.keys.check(n,t);return!o&&t?.extend(n+\"\",\"Record\",typeof e,o?\"Key doesn't match schema\":\"Value doesn't match value\"),o&&this.shape.values.check(r,t)})}}var Xi=(e,t)=>new Mo(e,t),Bd=T(Mo);class Vo extends V{constructor(e){super();this.shape=e}check(e,t){return e!=null&&dt(this.shape,(r,n)=>{let o=r.check(e[n],t);return!o&&t?.extend(n.toString(),\"Tuple\",typeof r),o})}}var Md=(...e)=>new Vo(e),Gy=T(Vo);class Fo extends V{constructor(e){super();this.shape=e.length===1?e[0]:new Yr(e)}check(e,t){let r=Me(e)&&Or(e,(n)=>this.shape.check(n));return!r&&t?.extend(null,\"Array\",\"\"),r}}var Qi=(...e)=>new Fo(e),Vd=T(Fo),Fd=Z((e)=>Me(e));class Jo extends V{constructor(e,t){super();this.shape=e,this._c=t}check(e,t){let r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name),r}}var Jd=(e,t=null)=>new Jo(e,t),Wy=T(Jo),Kd=Jd(V);class ec extends V{constructor(e){super();this.len=e.length-1,this.args=Md(...e.slice(-1)),this.res=e[this.len]}check(e,t){let r=e.constructor===Function&&e.length<=this.len;return!r&&t?.extend(null,\"function\",typeof e),r}}var qd=T(ec),Gd=Z((e)=>typeof e===\"function\");class tc extends V{constructor(e){super();this.shape=e}check(e,t){let r=Or(this.shape,(n)=>n.check(e,t));return!r&&t?.extend(null,\"Intersectinon\",typeof e),r}}var Hy=T(tc,(e)=>e.shape.length>0);class Yr extends V{static _dilutes=!0;constructor(e){super();this.shape=e}check(e,t){let r=Tr(this.shape,(n)=>n.check(e,t));return t?.extend(null,\"Union\",typeof e),r}}var yt=(...e)=>e.findIndex((t)=>Jr.check(t))>=0?yt(...e.map((t)=>Xt(t)).map((t)=>Jr.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new Yr(e),Jr=T(Yr),rc=()=>!0,Kr=Z(rc),Wd=T(Gr,(e)=>e.shape===rc),Ko=Z((e)=>typeof e===\"bigint\"),Hd=Z((e)=>e===Ko),nc=Z((e)=>typeof e===\"symbol\"),Yy=Z((e)=>e===nc),mt=Z((e)=>typeof e===\"number\"),oc=Z((e)=>e===mt),gt=Z((e)=>typeof e===\"string\"),sc=Z((e)=>e===gt),Xr=Z((e)=>typeof e===\"boolean\"),Yd=Z((e)=>e===Xr),ic=Wr(void 0),Xy=T(Qt,(e)=>e.shape.length===1&&e.shape[0]===void 0),Qy=Wr(void 0);var Qr=Wr(null),Xd=T(Qt,(e)=>e.shape.length===1&&e.shape[0]===null),ex=T(Uint8Array),tx=T(qr,(e)=>e.shape===Uint8Array),Qd=yt(mt,gt,Qr,ic,Ko,Xr,nc),rx=(()=>{let e=Qi(Kr),t=Xi(gt,Kr),r=yt(mt,gt,Qr,Xr,e,t);return e.shape=r,t.shape.values=r,r})(),Xt=(e)=>{if(Kd.check(e))return e;else if(Ld.check(e)){let t={};for(let r in e)t[r]=Xt(e[r]);return Rd(t)}else if(Fd.check(e))return yt(...e.map(Xt));else if(Qd.check(e))return Wr(e);else if(Gd.check(e))return T(e);H()},qi=Mi?()=>{}:(e,t)=>{let r=new Gi;if(!t.check(e,r))throw X(`Expected value to be of type ${t.constructor.name}.\n${r.toString()}`)};class cc{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Xt(e),h:t}),this}else(e){return this.if(Kr,e)}done(){return(e,t)=>{for(let r=0;r<this.patterns.length;r++){let n=this.patterns[r];if(n.if.check(e))return n.h(e,t)}throw X(\"Unhandled pattern\")}}}var eh=(e)=>new cc(e),ac=eh(Kr).if(oc,(e,t)=>Vr(t,go,st)).if(sc,(e,t)=>Ki(t)).if(Yd,(e,t)=>No(t)).if(Hd,(e,t)=>BigInt(Vr(t,go,st))).if(Jr,(e,t)=>ht(t,Fr(t,e.shape))).if(jd,(e,t)=>{let r={};for(let n in e.shape){let o=e.shape[n];if(Ud.check(o)){if(No(t))continue;o=o.shape}r[n]=ac(o,t)}return r}).if(Vd,(e,t)=>{let r=[],n=Uo(t,0,42);for(let o=0;o<n;o++)r.push(ht(t,e.shape));return r}).if(Wi,(e,t)=>Fr(t,e.shape)).if(Xd,(e,t)=>null).if(qd,(e,t)=>{let r=ht(t,e.res);return()=>r}).if(Wd,(e,t)=>ht(t,Fr(t,[mt,gt,Qr,ic,Ko,Xr,Qi(mt),Xi(yt(\"a\",\"b\",\"c\"),mt)]))).if(Bd,(e,t)=>{let r={},n=Vr(t,0,3);for(let o=0;o<n;o++){let s=ht(t,e.shape.keys),i=ht(t,e.shape.values);r[s]=i}return r}).done(),ht=(e,t)=>ac(Xt(t),e);var We=typeof document<\"u\"?document:{};var nx=Z((e)=>e.nodeType===sh);var ox=typeof DOMParser<\"u\"?new DOMParser:null;var sx=Z((e)=>e.nodeType===rh);var ix=Z((e)=>e.nodeType===nh);var uc=(e)=>mi(e,(t,r)=>`${r}:${t};`).join(\"\");var{ELEMENT_NODE:rh,TEXT_NODE:nh,CDATA_SECTION_NODE:cx,COMMENT_NODE:ax,DOCUMENT_NODE:oh,DOCUMENT_TYPE_NODE:ux,DOCUMENT_FRAGMENT_NODE:sh}=We,lx=Z((e)=>e.nodeType===oh);var _e=Symbol;var er=_e(),tr=_e(),qo=_e(),Go=_e(),Wo=_e(),rr=_e(),Ho=_e(),xt=_e(),Yo=_e(),lc=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],r=[],n=0;for(;n<e.length;n++){let o=e[n];if(o===void 0)break;else if(o.constructor===String||o.constructor===Number)t.push(o);else if(o.constructor===Object)break}if(n>0)r.push(t.join(\"\"));for(;n<e.length;n++){let o=e[n];if(!(o instanceof Symbol))r.push(o)}return r};var fx=Ti();var uh={[er]:xe(\"font-weight\",\"bold\"),[tr]:xe(\"font-weight\",\"normal\"),[qo]:xe(\"color\",\"blue\"),[Wo]:xe(\"color\",\"green\"),[Go]:xe(\"color\",\"grey\"),[rr]:xe(\"color\",\"red\"),[Ho]:xe(\"color\",\"purple\"),[xt]:xe(\"color\",\"orange\"),[Yo]:xe(\"color\",\"black\")},lh=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],r=[],n=J(),o=[],s=0;for(;s<e.length;s++){let i=e[s],c=uh[i];if(c!==void 0)n.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=uc(n);if(s>0||a.length>0)t.push(\"%c\"+i),r.push(a);else t.push(i)}else break}}if(s>0)o=r,o.unshift(t.join(\"\"));for(;s<e.length;s++){let i=e[s];if(!(i instanceof Symbol))o.push(i)}return o},fc=Vi?lh:lc,pc=(...e)=>{console.log(...fc(e)),hc.forEach((t)=>t.print(e))},dc=(...e)=>{console.warn(...fc(e)),e.unshift(xt),hc.forEach((t)=>t.print(e))};var hc=Ie();var mc=(e)=>({[Symbol.iterator](){return this},next:e}),gc=(e,t)=>mc(()=>{let r;do r=e.next();while(!r.done&&!t(r.value));return r}),en=(e,t)=>mc(()=>{let{done:r,value:n}=e.next();return{done:r,value:r?void 0:t(n)}});class ir{constructor(e,t){this.clock=e,this.len=t}}class bt{constructor(){this.clients=new Map}}var Ec=(e,t,r)=>t.clients.forEach((n,o)=>{let s=e.doc.store.clients.get(o);if(s!=null){let i=s[s.length-1],c=i.id.clock+i.length;for(let a=0,l=n[a];a<n.length&&l.clock<c;l=n[++a])Bc(e,s,l.clock,l.len,r)}}),dh=(e,t)=>{let r=0,n=e.length-1;while(r<=n){let o=K((r+n)/2),s=e[o],i=s.clock;if(i<=t){if(t<i+s.len)return o;r=o+1}else n=o-1}return null},Ac=(e,t)=>{let r=e.clients.get(t.client);return r!==void 0&&dh(r,t.clock)!==null},rs=(e)=>{e.clients.forEach((t)=>{t.sort((o,s)=>o.clock-s.clock);let r,n;for(r=1,n=1;r<t.length;r++){let o=t[n-1],s=t[r];if(o.clock+o.len>=s.clock)t[n-1]=new ir(o.clock,Ee(o.len,s.clock+s.len-o.clock));else{if(n<r)t[n]=s;n++}}t.length=n})},hh=(e)=>{let t=new bt;for(let r=0;r<e.length;r++)e[r].clients.forEach((n,o)=>{if(!t.clients.has(o)){let s=n.slice();for(let i=r+1;i<e.length;i++)yi(s,e[i].clients.get(o)||[]);t.clients.set(o,s)}});return rs(t),t},cn=(e,t,r,n)=>{me(e.clients,t,()=>[]).push(new ir(r,n))},Oc=()=>new bt,mh=(e)=>{let t=Oc();return e.clients.forEach((r,n)=>{let o=[];for(let s=0;s<r.length;s++){let i=r[s];if(i.deleted){let c=i.id.clock,a=i.length;if(s+1<r.length)for(let l=r[s+1];s+1<r.length&&l.deleted;l=r[++s+1])a+=l.length;o.push(new ir(c,a))}}if(o.length>0)t.clients.set(n,o)}),t},kt=(e,t)=>{w(e.restEncoder,t.clients.size),ge(t.clients.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{e.resetDsCurVal(),w(e.restEncoder,r);let o=n.length;w(e.restEncoder,o);for(let s=0;s<o;s++){let i=n[s];e.writeDsClock(i.clock),e.writeDsLen(i.len)}})},ns=(e)=>{let t=new bt,r=_(e.restDecoder);for(let n=0;n<r;n++){e.resetDsCurVal();let o=_(e.restDecoder),s=_(e.restDecoder);if(s>0){let i=me(t.clients,o,()=>[]);for(let c=0;c<s;c++)i.push(new ir(e.readDsClock(),e.readDsLen()))}}return t},yc=(e,t,r)=>{let n=new bt,o=_(e.restDecoder);for(let s=0;s<o;s++){e.resetDsCurVal();let i=_(e.restDecoder),c=_(e.restDecoder),a=r.clients.get(i)||[],l=U(r,i);for(let u=0;u<c;u++){let f=e.readDsClock(),p=f+e.readDsLen();if(f<l){if(l<p)cn(n,i,l,p-l);let d=we(a,f),h=a[d];if(!h.deleted&&h.id.clock<f)a.splice(d+1,0,mn(t,h,f-h.id.clock)),d++;while(d<a.length)if(h=a[d++],h.id.clock<p){if(!h.deleted){if(p<h.id.clock+h.length)a.splice(d,0,mn(t,h,p-h.id.clock));h.delete(t)}}else break}else cn(n,i,f,p-f)}}if(n.clients.size>0){let s=new Ne;return w(s.restEncoder,0),kt(s,n),s.toUint8Array()}return null};var Tc=zo;class ke extends fo{constructor({guid:e=Oi(),collectionid:t=null,gc:r=!0,gcFilter:n=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:i=!0}={}){super();this.gc=r,this.gcFilter=n,this.clientID=Tc(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new us,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Io((a)=>{this.on(\"load\",()=>{this.isLoaded=!0,a(this)})});let c=()=>Io((a)=>{let l=(u)=>{if(u===void 0||u===!0)this.off(\"sync\",l),a()};this.on(\"sync\",l)});this.on(\"sync\",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit(\"load\",[this])}),this.whenSynced=c()}load(){let e=this._item;if(e!==null&&!this.shouldLoad)v(e.parent.doc,(t)=>{t.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ge(this.subdocs).map((e)=>e.guid))}transact(e,t=null){return v(this,e,t)}get(e,t=R){let r=me(this.share,e,()=>{let o=new t;return o._integrate(this,null),o}),n=r.constructor;if(t!==R&&n!==t)if(n===R){let o=new t;o._map=r._map,r._map.forEach((s)=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=\"\"){return this.get(e,re)}getText(e=\"\"){return this.get(e,ae)}getMap(e=\"\"){return this.get(e,q)}getXmlElement(e=\"\"){return this.get(e,wt)}getXmlFragment(e=\"\"){return this.get(e,Xe)}toJSON(){let e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,ge(this.subdocs).forEach((t)=>t.destroy());let e=this._item;if(e!==null){this._item=null;let t=e.content;t.doc=new ke({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,v(e.parent.doc,(r)=>{let n=t.doc;if(!e.deleted)r.subdocsAdded.add(n);r.subdocsRemoved.add(this)},null,!0)}this.emit(\"destroyed\",[!0]),this.emit(\"destroy\",[this]),super.destroy()}}class os{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return _(this.restDecoder)}readDsLen(){return _(this.restDecoder)}}class ss extends os{readLeftID(){return b(_(this.restDecoder),_(this.restDecoder))}readRightID(){return b(_(this.restDecoder),_(this.restDecoder))}readClient(){return _(this.restDecoder)}readInfo(){return Je(this.restDecoder)}readString(){return Ke(this.restDecoder)}readParentInfo(){return _(this.restDecoder)===1}readTypeRef(){return _(this.restDecoder)}readLen(){return _(this.restDecoder)}readAny(){return ft(this.restDecoder)}readBuf(){return Fi(Y(this.restDecoder))}readJSON(){return JSON.parse(Ke(this.restDecoder))}readKey(){return Ke(this.restDecoder)}}class Pc{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=_(this.restDecoder),this.dsCurrVal}readDsLen(){let e=_(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ye extends Pc{constructor(e){super(e);this.keys=[],_(e),this.keyClockDecoder=new Jt(Y(e)),this.clientDecoder=new pt(Y(e)),this.leftClockDecoder=new Jt(Y(e)),this.rightClockDecoder=new Jt(Y(e)),this.infoDecoder=new Br(Y(e),Je),this.stringDecoder=new $o(Y(e)),this.parentInfoDecoder=new Br(Y(e),Je),this.typeRefDecoder=new pt(Y(e)),this.lenDecoder=new pt(Y(e))}readLeftID(){return new He(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new He(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return ft(this.restDecoder)}readBuf(){return Y(this.restDecoder)}readJSON(){return ft(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];else{let t=this.stringDecoder.read();return this.keys.push(t),t}}}class is{constructor(){this.restEncoder=Bt()}toUint8Array(){return ce(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){w(this.restEncoder,e)}writeDsLen(e){w(this.restEncoder,e)}}class vt extends is{writeLeftID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeRightID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeClient(e){w(this.restEncoder,e)}writeInfo(e){Ur(this.restEncoder,e)}writeString(e){Fe(this.restEncoder,e)}writeParentInfo(e){w(this.restEncoder,e?1:0)}writeTypeRef(e){w(this.restEncoder,e)}writeLen(e){w(this.restEncoder,e)}writeAny(e){at(this.restEncoder,e)}writeBuf(e){W(this.restEncoder,e)}writeJSON(e){Fe(this.restEncoder,JSON.stringify(e))}writeKey(e){Fe(this.restEncoder,e)}}class cs{constructor(){this.restEncoder=Bt(),this.dsCurrVal=0}toUint8Array(){return ce(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,w(this.restEncoder,t)}writeDsLen(e){if(e===0)H();w(this.restEncoder,e-1),this.dsCurrVal+=e}}class Ne extends cs{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Vt,this.clientEncoder=new lt,this.leftClockEncoder=new Vt,this.rightClockEncoder=new Vt,this.infoEncoder=new jr(Ur),this.stringEncoder=new ko,this.parentInfoEncoder=new jr(Ur),this.typeRefEncoder=new lt,this.lenEncoder=new lt}toUint8Array(){let e=Bt();return w(e,0),W(e,this.keyClockEncoder.toUint8Array()),W(e,this.clientEncoder.toUint8Array()),W(e,this.leftClockEncoder.toUint8Array()),W(e,this.rightClockEncoder.toUint8Array()),W(e,ce(this.infoEncoder)),W(e,this.stringEncoder.toUint8Array()),W(e,ce(this.parentInfoEncoder)),W(e,this.typeRefEncoder.toUint8Array()),W(e,this.lenEncoder.toUint8Array()),Mt(e,ce(this.restEncoder)),ce(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){at(this.restEncoder,e)}writeBuf(e){W(this.restEncoder,e)}writeJSON(e){at(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);if(t===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e);else this.keyClockEncoder.write(t)}}var gh=(e,t,r,n)=>{n=Ee(n,t[0].id.clock);let o=we(t,n);w(e.restEncoder,t.length-o),e.writeClient(r),w(e.restEncoder,n);let s=t[o];s.write(e,n-s.id.clock);for(let i=o+1;i<t.length;i++)t[i].write(e,0)},as=(e,t,r)=>{let n=new Map;r.forEach((o,s)=>{if(U(t,s)>o)n.set(s,o)}),yn(t).forEach((o,s)=>{if(!r.has(s))n.set(s,0)}),w(e.restEncoder,n.size),ge(n.entries()).sort((o,s)=>s[0]-o[0]).forEach(([o,s])=>{gh(e,t.clients.get(o),o,s)})},yh=(e,t)=>{let r=J(),n=_(e.restDecoder);for(let o=0;o<n;o++){let s=_(e.restDecoder),i=Array(s),c=e.readClient(),a=_(e.restDecoder);r.set(c,{i:0,refs:i});for(let l=0;l<s;l++){let u=e.readInfo();switch(jt&u){case 0:{let f=e.readLen();i[l]=new ee(b(c,a),f),a+=f;break}case 10:{let f=_(e.restDecoder);i[l]=new te(b(c,a),f),a+=f;break}default:{let f=(u&(ie|M))===0,p=new C(b(c,a),null,(u&M)===M?e.readLeftID():null,null,(u&ie)===ie?e.readRightID():null,f?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,f&&(u&ot)===ot?e.readString():null,pa(e,u));i[l]=p,a+=p.length}}}}return r},xh=(e,t,r)=>{let n=[],o=ge(r.keys()).sort((d,h)=>d-h);if(o.length===0)return null;let s=()=>{if(o.length===0)return null;let d=r.get(o[o.length-1]);while(d.refs.length===d.i)if(o.pop(),o.length>0)d=r.get(o[o.length-1]);else return null;return d},i=s();if(i===null)return null;let c=new us,a=new Map,l=(d,h)=>{let g=a.get(d);if(g==null||g>h)a.set(d,h)},u=i.refs[i.i++],f=new Map,p=()=>{for(let d of n){let h=d.id.client,g=r.get(h);if(g)g.i--,c.clients.set(h,g.refs.slice(g.i)),r.delete(h),g.i=0,g.refs=[];else c.clients.set(h,[d]);o=o.filter((x)=>x!==h)}n.length=0};while(!0){if(u.constructor!==te){let h=me(f,u.id.client,()=>U(t,u.id.client))-u.id.clock;if(h<0)n.push(u),l(u.id.client,u.id.clock-1),p();else{let g=u.getMissing(e,t);if(g!==null){n.push(u);let x=r.get(g)||{refs:[],i:0};if(x.refs.length===x.i)l(g,U(t,g)),p();else{u=x.refs[x.i++];continue}}else if(h===0||h<u.length)u.integrate(e,h),f.set(u.id.client,u.id.clock+u.length)}}if(n.length>0)u=n.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else if(i=s(),i===null)break;else u=i.refs[i.i++]}if(c.clients.size>0){let d=new Ne;return as(d,c,new Map),w(d.restEncoder,0),{missing:a,update:d.toUint8Array()}}return null},_h=(e,t)=>as(e,t.doc.store,t.beforeState),wh=(e,t,r,n=new Ye(e))=>v(t,(o)=>{o.local=!1;let s=!1,i=o.doc,c=i.store,a=yh(n,i),l=xh(o,c,a),u=c.pendingStructs;if(u){for(let[p,d]of u.missing)if(d<U(c,p)){s=!0;break}if(l){for(let[p,d]of l.missing){let h=u.missing.get(p);if(h==null||h>d)u.missing.set(p,d)}u.update=an([u.update,l.update])}}else c.pendingStructs=l;let f=yc(n,o,c);if(c.pendingDs){let p=new Ye(qe(c.pendingDs));_(p.restDecoder);let d=yc(p,o,c);if(f&&d)c.pendingDs=an([f,d]);else c.pendingDs=f||d}else c.pendingDs=f;if(s){let p=c.pendingStructs.update;c.pendingStructs=null,Zc(o.doc,p)}},r,!1);var Zc=(e,t,r,n=Ye)=>{let o=qe(t);wh(o,e,r,new n(o))},gn=(e,t,r)=>Zc(e,t,r,ss),bh=(e,t,r=new Map)=>{as(e,t.store,r),kt(e,mh(t.store))},kh=(e,t=new Uint8Array([0]),r=new Ne)=>{let n=Cc(t);bh(r,e,n);let o=[r.toUint8Array()];if(e.store.pendingDs)o.push(e.store.pendingDs);if(e.store.pendingStructs)o.push(Dh(e.store.pendingStructs.update,t));if(o.length>1){if(r.constructor===vt)return Zh(o.map((s,i)=>i===0?s:Uh(s)));else if(r.constructor===Ne)return an(o)}return o[0]},St=(e,t)=>kh(e,t,new vt),vh=(e)=>{let t=new Map,r=_(e.restDecoder);for(let n=0;n<r;n++){let o=_(e.restDecoder),s=_(e.restDecoder);t.set(o,s)}return t},Cc=(e)=>vh(new os(qe(e))),Dc=(e,t)=>(w(e.restEncoder,t.size),ge(t.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{w(e.restEncoder,r),w(e.restEncoder,n)}),e),Sh=(e,t)=>Dc(e,yn(t.store)),$h=(e,t=new cs)=>{if(e instanceof Map)Dc(t,e);else Sh(t,e);return t.toUint8Array()},Nc=(e)=>$h(e,new is);class Uc{constructor(){this.l=[]}}var xc=()=>new Uc,_c=(e,t)=>e.l.push(t),wc=(e,t)=>{let r=e.l,n=r.length;if(e.l=r.filter((o)=>t!==o),n===e.l.length)console.error(\"[yjs] Tried to remove event handler that doesn't exist.\")},Rc=(e,t,r)=>Wt(e.l,[t,r]);class He{constructor(e,t){this.client=e,this.clock=t}}var tn=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,b=(e,t)=>new He(e,t);var zh=(e)=>{for(let[t,r]of e.doc.share.entries())if(r===e)return t;throw H()};class jc{constructor(e,t){this.ds=e,this.sv=t}}var Ih=(e,t)=>new jc(e,t),kx=Ih(Oc(),new Map);var _t=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Ac(t.ds,e.id),es=(e,t)=>{let r=me(e.meta,es,Ie),n=e.doc.store;if(!r.has(t))t.sv.forEach((o,s)=>{if(o<U(n,s))Ue(e,b(s,o))}),Ec(e,t.ds,(o)=>{}),r.add(t)};class us{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var yn=(e)=>{let t=new Map;return e.clients.forEach((r,n)=>{let o=r[r.length-1];t.set(n,o.id.clock+o.length)}),t},U=(e,t)=>{let r=e.clients.get(t);if(r===void 0)return 0;let n=r[r.length-1];return n.id.clock+n.length},Lc=(e,t)=>{let r=e.clients.get(t.id.client);if(r===void 0)r=[],e.clients.set(t.id.client,r);else{let n=r[r.length-1];if(n.id.clock+n.length!==t.id.clock)throw H()}r.push(t)},we=(e,t)=>{let r=0,n=e.length-1,o=e[n],s=o.id.clock;if(s===t)return n;let i=K(t/(s+o.length-1)*n);while(r<=n){if(o=e[i],s=o.id.clock,s<=t){if(t<s+o.length)return i;r=i+1}else n=i-1;i=K((r+n)/2)}throw H()},Eh=(e,t)=>{let r=e.clients.get(t.client);return r[we(r,t.clock)]},Xo=Eh,ts=(e,t,r)=>{let n=we(t,r),o=t[n];if(o.id.clock<r&&o instanceof C)return t.splice(n+1,0,mn(e,o,r-o.id.clock)),n+1;return n},Ue=(e,t)=>{let r=e.doc.store.clients.get(t.client);return r[ts(e,r,t.clock)]},bc=(e,t,r)=>{let n=t.clients.get(r.client),o=we(n,r.clock),s=n[o];if(r.clock!==s.id.clock+s.length-1&&s.constructor!==ee)n.splice(o+1,0,mn(e,s,r.clock-s.id.clock+1));return s},Ah=(e,t,r)=>{let n=e.clients.get(t.id.client);n[we(n,t.id.clock)]=r},Bc=(e,t,r,n,o)=>{if(n===0)return;let s=r+n,i=ts(e,t,r),c;do{if(c=t[i++],s<c.id.clock+c.length)ts(e,t,s);o(c)}while(i<t.length&&t[i].id.clock<s)};class Mc{constructor(e,t,r){this.doc=e,this.deleteSet=new bt,this.beforeState=yn(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var kc=(e,t)=>{if(t.deleteSet.clients.size===0&&!gi(t.afterState,(r,n)=>t.beforeState.get(n)!==r))return!1;return rs(t.deleteSet),_h(e,t),kt(e,t.deleteSet),!0},vc=(e,t,r)=>{let n=t._item;if(n===null||n.id.clock<(e.beforeState.get(n.id.client)||0)&&!n.deleted)me(e.changed,t,Ie).add(r)},on=(e,t)=>{let r=e[t],n=e[t-1],o=t;for(;o>0;r=n,n=e[--o-1]){if(n.deleted===r.deleted&&n.constructor===r.constructor){if(n.mergeWith(r)){if(r instanceof C&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,n);continue}}break}let s=t-o;if(s)e.splice(t+1-s,s);return s},Oh=(e,t,r)=>{for(let[n,o]of e.clients.entries()){let s=t.clients.get(n);for(let i=o.length-1;i>=0;i--){let c=o[i],a=c.clock+c.len;for(let l=we(s,c.clock),u=s[l];l<s.length&&u.id.clock<a;u=s[++l]){let f=s[l];if(c.clock+c.len<=f.id.clock)break;if(f instanceof C&&f.deleted&&!f.keep&&r(f))f.gc(t,!1)}}}},Th=(e,t)=>{e.clients.forEach((r,n)=>{let o=t.clients.get(n);for(let s=r.length-1;s>=0;s--){let i=r[s],c=Pr(o.length-1,1+we(o,i.clock+i.len-1));for(let a=c,l=o[a];a>0&&l.id.clock>=i.clock;l=o[a])a-=1+on(o,a)}})};var Vc=(e,t)=>{if(t<e.length){let r=e[t],n=r.doc,o=n.store,{deleteSet:s,_mergeStructs:i}=r;try{rs(s),r.afterState=yn(r.doc.store),n.emit(\"beforeObserverCalls\",[r,n]);let c=[];r.changed.forEach((a,l)=>c.push(()=>{if(l._item===null||!l._item.deleted)l._callObserver(r,a)})),c.push(()=>{r.changedParentTypes.forEach((a,l)=>{if(l._dEH.l.length>0&&(l._item===null||!l._item.deleted))a=a.filter((u)=>u.target._item===null||!u.target._item.deleted),a.forEach((u)=>{u.currentTarget=l,u._path=null}),a.sort((u,f)=>u.path.length-f.path.length),c.push(()=>{Rc(l._dEH,a,r)})}),c.push(()=>n.emit(\"afterTransaction\",[r,n])),c.push(()=>{if(r._needFormattingCleanup)Gh(r)})}),Wt(c,[])}finally{if(n.gc)Oh(s,o,n.gcFilter);Th(s,o),r.afterState.forEach((u,f)=>{let p=r.beforeState.get(f)||0;if(p!==u){let d=o.clients.get(f),h=Ee(we(d,p),1);for(let g=d.length-1;g>=h;)g-=1+on(d,g)}});for(let u=i.length-1;u>=0;u--){let{client:f,clock:p}=i[u].id,d=o.clients.get(f),h=we(d,p);if(h+1<d.length){if(on(d,h+1)>1)continue}if(h>0)on(d,h)}if(!r.local&&r.afterState.get(n.clientID)!==r.beforeState.get(n.clientID))pc(xt,er,\"[yjs] \",tr,rr,\"Changed the client-id because another client seems to be using it.\"),n.clientID=Tc();if(n.emit(\"afterTransactionCleanup\",[r,n]),n._observers.has(\"update\")){let u=new vt;if(kc(u,r))n.emit(\"update\",[u.toUint8Array(),r.origin,n,r])}if(n._observers.has(\"updateV2\")){let u=new Ne;if(kc(u,r))n.emit(\"updateV2\",[u.toUint8Array(),r.origin,n,r])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:l}=r;if(c.size>0||l.size>0||a.size>0)c.forEach((u)=>{if(u.clientID=n.clientID,u.collectionid==null)u.collectionid=n.collectionid;n.subdocs.add(u)}),l.forEach((u)=>n.subdocs.delete(u)),n.emit(\"subdocs\",[{loaded:a,added:c,removed:l},n,r]),l.forEach((u)=>u.destroy());if(e.length<=t+1)n._transactionCleanups=[],n.emit(\"afterAllTransactions\",[n,e]);else Vc(e,t+1)}}},v=(e,t,r=null,n=!0)=>{let o=e._transactionCleanups,s=!1,i=null;if(e._transaction===null){if(s=!0,e._transaction=new Mc(e,r,n),o.push(e._transaction),o.length===1)e.emit(\"beforeAllTransactions\",[e]);e.emit(\"beforeTransaction\",[e._transaction,e])}try{i=t(e._transaction)}finally{if(s){let c=e._transaction===o[0];if(e._transaction=null,c)Vc(o,0)}}return i};function*Ph(e){let t=_(e.restDecoder);for(let r=0;r<t;r++){let n=_(e.restDecoder),o=e.readClient(),s=_(e.restDecoder);for(let i=0;i<n;i++){let c=e.readInfo();if(c===10){let a=_(e.restDecoder);yield new te(b(o,s),a),s+=a}else if((jt&c)!==0){let a=(c&(ie|M))===0,l=new C(b(o,s),null,(c&M)===M?e.readLeftID():null,null,(c&ie)===ie?e.readRightID():null,a?e.readParentInfo()?e.readString():e.readLeftID():null,a&&(c&ot)===ot?e.readString():null,pa(e,c));yield l,s+=l.length}else{let a=e.readLen();yield new ee(b(o,s),a),s+=a}}}}class xn{constructor(e,t){this.gen=Ph(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===te);return this.curr}}class _n{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}var Zh=(e)=>an(e,ss,vt);var Ch=(e,t)=>{if(e.constructor===ee){let{client:r,clock:n}=e.id;return new ee(b(r,n+t),e.length-t)}else if(e.constructor===te){let{client:r,clock:n}=e.id;return new te(b(r,n+t),e.length-t)}else{let r=e,{client:n,clock:o}=r.id;return new C(b(n,o+t),null,b(n,o+t-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(t))}},an=(e,t=Ye,r=Ne)=>{if(e.length===1)return e[0];let n=e.map((u)=>new t(qe(u))),o=n.map((u)=>new xn(u,!0)),s=null,i=new r,c=new _n(i);while(!0){if(o=o.filter((p)=>p.curr!==null),o.sort((p,d)=>{if(p.curr.id.client===d.curr.id.client){let h=p.curr.id.clock-d.curr.id.clock;if(h===0)return p.curr.constructor===d.curr.constructor?0:p.curr.constructor===te?1:-1;else return h}else return d.curr.id.client-p.curr.id.client}),o.length===0)break;let u=o[0],f=u.curr.id.client;if(s!==null){let p=u.curr,d=!1;while(p!==null&&p.id.clock+p.length<=s.struct.id.clock+s.struct.length&&p.id.client>=s.struct.id.client)p=u.next(),d=!0;if(p===null||p.id.client!==f||d&&p.id.clock>s.struct.id.clock+s.struct.length)continue;if(f!==s.struct.id.client)Ce(c,s.struct,s.offset),s={struct:p,offset:0},u.next();else if(s.struct.id.clock+s.struct.length<p.id.clock)if(s.struct.constructor===te)s.struct.length=p.id.clock+p.length-s.struct.id.clock;else{Ce(c,s.struct,s.offset);let h=p.id.clock-s.struct.id.clock-s.struct.length;s={struct:new te(b(f,s.struct.id.clock+s.struct.length),h),offset:0}}else{let h=s.struct.id.clock+s.struct.length-p.id.clock;if(h>0)if(s.struct.constructor===te)s.struct.length-=h;else p=Ch(p,h);if(!s.struct.mergeWith(p))Ce(c,s.struct,s.offset),s={struct:p,offset:0},u.next()}}else s={struct:u.curr,offset:0},u.next();for(let p=u.curr;p!==null&&p.id.client===f&&p.id.clock===s.struct.id.clock+s.struct.length&&p.constructor!==te;p=u.next())Ce(c,s.struct,s.offset),s={struct:p,offset:0}}if(s!==null)Ce(c,s.struct,s.offset),s=null;ls(c);let a=n.map((u)=>ns(u)),l=hh(a);return kt(i,l),i.toUint8Array()},Dh=(e,t,r=Ye,n=Ne)=>{let o=Cc(t),s=new n,i=new _n(s),c=new r(qe(e)),a=new xn(c,!1);while(a.curr){let u=a.curr,f=u.id.client,p=o.get(f)||0;if(a.curr.constructor===te){a.next();continue}if(u.id.clock+u.length>p){Ce(i,u,Ee(p-u.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===f)Ce(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===f&&a.curr.id.clock+a.curr.length<=p)a.next()}ls(i);let l=ns(c);return kt(s,l),s.toUint8Array()};var Fc=(e)=>{if(e.written>0)e.clientStructs.push({written:e.written,restEncoder:ce(e.encoder.restEncoder)}),e.encoder.restEncoder=Bt(),e.written=0},Ce=(e,t,r)=>{if(e.written>0&&e.currClient!==t.id.client)Fc(e);if(e.written===0)e.currClient=t.id.client,e.encoder.writeClient(t.id.client),w(e.encoder.restEncoder,t.id.clock+r);t.write(e.encoder,r),e.written++},ls=(e)=>{Fc(e);let t=e.encoder.restEncoder;w(t,e.clientStructs.length);for(let r=0;r<e.clientStructs.length;r++){let n=e.clientStructs[r];w(t,n.written),Mt(t,n.restEncoder)}},Nh=(e,t,r,n)=>{let o=new r(qe(e)),s=new xn(o,!1),i=new n,c=new _n(i);for(let l=s.curr;l!==null;l=s.next())Ce(c,t(l),0);ls(c);let a=ns(o);return kt(i,a),i.toUint8Array()};var Uh=(e)=>Nh(e,ji,Ye,vt),Sc=\"You must not compute changes after the event-handler fired.\";class cr{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Rh(this.currentTarget,this.target))}deletes(e){return Ac(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(Sc);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach((n)=>{if(n!==null){let o=t._map.get(n),s,i;if(this.adds(o)){let c=o.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(o))if(c!==null&&this.deletes(c))s=\"delete\",i=Ar(c.content.getContent());else return;else if(c!==null&&this.deletes(c))s=\"update\",i=Ar(c.content.getContent());else s=\"add\",i=void 0}else if(this.deletes(o))s=\"delete\",i=Ar(o.content.getContent());else return;e.set(n,{action:s,oldValue:i})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(Sc);let t=this.target,r=Ie(),n=Ie(),o=[];if(e={added:r,deleted:n,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let i=null,c=()=>{if(i)o.push(i)};for(let a=t._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,n.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),r.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=e}return e}}var Rh=(e,t)=>{let r=[];while(t._item!==null&&t!==e){if(t._item.parentSub!==null)r.unshift(t._item.parentSub);else{let n=0,o=t._item.parent._start;while(o!==t._item&&o!==null){if(!o.deleted&&o.countable)n+=o.length;o=o.right}r.unshift(n)}t=t._item.parent}return r},F=()=>{dc(\"Invalid access: Add Yjs type to a document before reading data.\")},Jc=80,fs=0;class Kc{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=fs++}}var jh=(e)=>{e.timestamp=fs++},qc=(e,t,r)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=r,e.timestamp=fs++},Lh=(e,t,r)=>{if(e.length>=Jc){let n=e.reduce((o,s)=>o.timestamp<s.timestamp?o:s);return qc(n,t,r),n}else{let n=new Kc(t,r);return e.push(n),n}},wn=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let r=e._searchMarker.length===0?null:e._searchMarker.reduce((s,i)=>Ve(t-s.index)<Ve(t-i.index)?s:i),n=e._start,o=0;if(r!==null)n=r.p,o=r.index,jh(r);while(n.right!==null&&o<t){if(!n.deleted&&n.countable){if(t<o+n.length)break;o+=n.length}n=n.right}while(n.left!==null&&o>t)if(n=n.left,!n.deleted&&n.countable)o-=n.length;while(n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock)if(n=n.left,!n.deleted&&n.countable)o-=n.length;if(r!==null&&Ve(r.index-o)<n.parent.length/Jc)return qc(r,n,o),r;else return Lh(e._searchMarker,n,o)},nr=(e,t,r)=>{for(let n=e.length-1;n>=0;n--){let o=e[n];if(r>0){let s=o.p;s.marker=!1;while(s&&(s.deleted||!s.countable))if(s=s.left,s&&!s.deleted&&s.countable)o.index-=s.length;if(s===null||s.marker===!0){e.splice(n,1);continue}o.p=s,s.marker=!0}if(t<o.index||r>0&&t===o.index)o.index=Ee(t,o.index+r)}};var bn=(e,t,r)=>{let n=e,o=t.changedParentTypes;while(!0){if(me(o,e,()=>[]).push(r),e._item===null)break;e=e._item.parent}Rc(n._eH,r,t)};class R{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=xc(),this._dEH=xc(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Q()}clone(){throw Q()}_write(e){}get _first(){let e=this._start;while(e!==null&&e.deleted)e=e.right;return e}_callObserver(e,t){if(!e.local&&this._searchMarker)this._searchMarker.length=0}observe(e){_c(this._eH,e)}observeDeep(e){_c(this._dEH,e)}unobserve(e){wc(this._eH,e)}unobserveDeep(e){wc(this._dEH,e)}toJSON(){}}var Gc=(e,t,r)=>{if(e.doc??F(),t<0)t=e._length+t;if(r<0)r=e._length+r;let n=r-t,o=[],s=e._start;while(s!==null&&n>0){if(s.countable&&!s.deleted){let i=s.content.getContent();if(i.length<=t)t-=i.length;else{for(let c=t;c<i.length&&n>0;c++)o.push(i[c]),n--;t=0}}s=s.right}return o},Wc=(e)=>{e.doc??F();let t=[],r=e._start;while(r!==null){if(r.countable&&!r.deleted){let n=r.content.getContent();for(let o=0;o<n.length;o++)t.push(n[o])}r=r.right}return t};var or=(e,t)=>{let r=0,n=e._start;e.doc??F();while(n!==null){if(n.countable&&!n.deleted){let o=n.content.getContent();for(let s=0;s<o.length;s++)t(o[s],r++,e)}n=n.right}},Hc=(e,t)=>{let r=[];return or(e,(n,o)=>{r.push(t(n,o,e))}),r},Bh=(e)=>{let t=e._start,r=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(t!==null&&t.deleted)t=t.right;if(t===null)return{done:!0,value:void 0};r=t.content.getContent(),n=0,t=t.right}let o=r[n++];if(r.length<=n)r=null;return{done:!1,value:o}}}},Yc=(e,t)=>{e.doc??F();let r=wn(e,t),n=e._start;if(r!==null)n=r.p,t-=r.index;for(;n!==null;n=n.right)if(!n.deleted&&n.countable){if(t<n.length)return n.content.getContent()[t];t-=n.length}},un=(e,t,r,n)=>{let o=r,s=e.doc,{clientID:i,store:c}=s,a=r===null?t._start:r.right,l=[],u=()=>{if(l.length>0)o=new C(b(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Qe(l)),o.integrate(e,0),l=[]};n.forEach((f)=>{if(f===null)l.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(f);break;default:switch(u(),f.constructor){case Uint8Array:case ArrayBuffer:o=new C(b(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new ar(new Uint8Array(f))),o.integrate(e,0);break;case ke:o=new C(b(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new ur(f)),o.integrate(e,0);break;default:if(f instanceof R)o=new C(b(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Oe(f)),o.integrate(e,0);else throw Error(\"Unexpected content type in insert operation\")}}}),u()},Xc=()=>X(\"Length exceeded!\"),Qc=(e,t,r,n)=>{if(r>t._length)throw Xc();if(r===0){if(t._searchMarker)nr(t._searchMarker,r,n.length);return un(e,t,null,n)}let o=r,s=wn(t,r),i=t._start;if(s!==null){if(i=s.p,r-=s.index,r===0)i=i.prev,r+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(r<=i.length){if(r<i.length)Ue(e,b(i.id.client,i.id.clock+r));break}r-=i.length}if(t._searchMarker)nr(t._searchMarker,o,n.length);return un(e,t,i,n)},Mh=(e,t,r)=>{let o=(t._searchMarker||[]).reduce((s,i)=>i.index>s.index?i:s,{index:0,p:t._start}).p;if(o)while(o.right)o=o.right;return un(e,t,o,r)},ea=(e,t,r,n)=>{if(n===0)return;let o=r,s=n,i=wn(t,r),c=t._start;if(i!==null)c=i.p,r-=i.index;for(;c!==null&&r>0;c=c.right)if(!c.deleted&&c.countable){if(r<c.length)Ue(e,b(c.id.client,c.id.clock+r));r-=c.length}while(n>0&&c!==null){if(!c.deleted){if(n<c.length)Ue(e,b(c.id.client,c.id.clock+n));c.delete(e),n-=c.length}c=c.right}if(n>0)throw Xc();if(t._searchMarker)nr(t._searchMarker,o,-s+n)},ln=(e,t,r)=>{let n=t._map.get(r);if(n!==void 0)n.delete(e)},ps=(e,t,r,n)=>{let o=t._map.get(r)||null,s=e.doc,i=s.clientID,c;if(n==null)c=new Qe([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Qe([n]);break;case Uint8Array:c=new ar(n);break;case ke:c=new ur(n);break;default:if(n instanceof R)c=new Oe(n);else throw Error(\"Unexpected content type\")}new C(b(i,U(s.store,i)),o,o&&o.lastId,null,null,t,r,c).integrate(e,0)},ds=(e,t)=>{e.doc??F();let r=e._map.get(t);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},ta=(e)=>{let t={};return e.doc??F(),e._map.forEach((r,n)=>{if(!r.deleted)t[n]=r.content.getContent()[r.length-1]}),t},ra=(e,t)=>{e.doc??F();let r=e._map.get(t);return r!==void 0&&!r.deleted};var Vh=(e,t)=>{let r={};return e._map.forEach((n,o)=>{let s=n;while(s!==null&&(!t.sv.has(s.id.client)||s.id.clock>=(t.sv.get(s.id.client)||0)))s=s.left;if(s!==null&&_t(s,t))r[o]=s.content.getContent()[s.length-1]}),r},rn=(e)=>(e.doc??F(),gc(e._map.entries(),(t)=>!t[1].deleted));class na extends cr{}class re extends R{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(e){let t=new re;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new re}clone(){let e=new re;return e.insert(0,this.toArray().map((t)=>t instanceof R?t.clone():t)),e}get length(){return this.doc??F(),this._length}_callObserver(e,t){super._callObserver(e,t),bn(this,e,new na(this,e))}insert(e,t){if(this.doc!==null)v(this.doc,(r)=>{Qc(r,this,e,t)});else this._prelimContent.splice(e,0,...t)}push(e){if(this.doc!==null)v(this.doc,(t)=>{Mh(t,this,e)});else this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){if(this.doc!==null)v(this.doc,(r)=>{ea(r,this,e,t)});else this._prelimContent.splice(e,t)}get(e){return Yc(this,e)}toArray(){return Wc(this)}slice(e=0,t=this.length){return Gc(this,e,t)}toJSON(){return this.map((e)=>e instanceof R?e.toJSON():e)}map(e){return Hc(this,e)}forEach(e){or(this,e)}[Symbol.iterator](){return Bh(this)}_write(e){e.writeTypeRef(fm)}}var Fh=(e)=>new re;class oa extends cr{constructor(e,t,r){super(e,t);this.keysChanged=r}}class q extends R{constructor(e){super();if(this._prelimContent=null,e===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,n)=>{this.set(n,r)}),this._prelimContent=null}_copy(){return new q}clone(){let e=new q;return this.forEach((t,r)=>{e.set(r,t instanceof R?t.clone():t)}),e}_callObserver(e,t){bn(this,e,new oa(this,e,t))}toJSON(){this.doc??F();let e={};return this._map.forEach((t,r)=>{if(!t.deleted){let n=t.content.getContent()[t.length-1];e[r]=n instanceof R?n.toJSON():n}}),e}get size(){return[...rn(this)].length}keys(){return en(rn(this),(e)=>e[0])}values(){return en(rn(this),(e)=>e[1].content.getContent()[e[1].length-1])}entries(){return en(rn(this),(e)=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??F(),this._map.forEach((t,r)=>{if(!t.deleted)e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){if(this.doc!==null)v(this.doc,(t)=>{ln(t,this,e)});else this._prelimContent.delete(e)}set(e,t){if(this.doc!==null)v(this.doc,(r)=>{ps(r,this,e,t)});else this._prelimContent.set(e,t);return t}get(e){return ds(this,e)}has(e){return ra(this,e)}clear(){if(this.doc!==null)v(this.doc,(e)=>{this.forEach(function(t,r,n){ln(e,n,r)})});else this._prelimContent.clear()}_write(e){e.writeTypeRef(pm)}}var Jh=(e)=>new q,De=(e,t)=>e===t||typeof e===\"object\"&&typeof t===\"object\"&&e&&t&&Oo(e,t);class fn{constructor(e,t,r,n){this.left=e,this.right=t,this.index=r,this.currentAttributes=n}forward(){if(this.right===null)H();switch(this.right.content.constructor){case D:if(!this.right.deleted)$t(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var $c=(e,t,r)=>{while(t.right!==null&&r>0){switch(t.right.content.constructor){case D:if(!t.right.deleted)$t(t.currentAttributes,t.right.content);break;default:if(!t.right.deleted){if(r<t.right.length)Ue(e,b(t.right.id.client,t.right.id.clock+r));t.index+=t.right.length,r-=t.right.length}break}t.left=t.right,t.right=t.right.right}return t},nn=(e,t,r,n)=>{let o=new Map,s=n?wn(t,r):null;if(s){let i=new fn(s.p.left,s.p,s.index,o);return $c(e,i,r-s.index)}else{let i=new fn(null,t._start,0,o);return $c(e,i,r)}},sa=(e,t,r,n)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===D&&De(n.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)n.delete(r.right.content.key);r.forward()}let o=e.doc,s=o.clientID;n.forEach((i,c)=>{let{left:a,right:l}=r,u=new C(b(s,U(o.store,s)),a,a&&a.lastId,l,l&&l.id,t,null,new D(c,i));u.integrate(e,0),r.right=u,r.forward()})},$t=(e,t)=>{let{key:r,value:n}=t;if(n===null)e.delete(r);else e.set(r,n)},ia=(e,t)=>{while(!0){if(e.right===null)break;else if(e.right.deleted||e.right.content.constructor===D&&De(t[e.right.content.key]??null,e.right.content.value));else break;e.forward()}},ca=(e,t,r,n)=>{let o=e.doc,s=o.clientID,i=new Map;for(let c in n){let a=n[c],l=r.currentAttributes.get(c)??null;if(!De(l,a)){i.set(c,l);let{left:u,right:f}=r;r.right=new C(b(s,U(o.store,s)),u,u&&u.lastId,f,f&&f.id,t,null,new D(c,a)),r.right.integrate(e,0),r.forward()}}return i},Qo=(e,t,r,n,o)=>{r.currentAttributes.forEach((p,d)=>{if(o[d]===void 0)o[d]=null});let s=e.doc,i=s.clientID;ia(r,o);let c=ca(e,t,r,o),a=n.constructor===String?new be(n):n instanceof R?new Oe(n):new et(n),{left:l,right:u,index:f}=r;if(t._searchMarker)nr(t._searchMarker,r.index,a.getLength());u=new C(b(i,U(s.store,i)),l,l&&l.lastId,u,u&&u.id,t,null,a),u.integrate(e,0),r.right=u,r.index=f,r.forward(),sa(e,t,r,c)},zc=(e,t,r,n,o)=>{let s=e.doc,i=s.clientID;ia(r,o);let c=ca(e,t,r,o);e:while(r.right!==null&&(n>0||c.size>0&&(r.right.deleted||r.right.content.constructor===D))){if(!r.right.deleted)switch(r.right.content.constructor){case D:{let{key:a,value:l}=r.right.content,u=o[a];if(u!==void 0){if(De(u,l))c.delete(a);else{if(n===0)break e;c.set(a,l)}r.right.delete(e)}else r.currentAttributes.set(a,l);break}default:if(n<r.right.length)Ue(e,b(r.right.id.client,r.right.id.clock+n));n-=r.right.length;break}r.forward()}if(n>0){let a=\"\";for(;n>0;n--)a+=`\n`;r.right=new C(b(i,U(s.store,i)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,t,null,new be(a)),r.right.integrate(e,0),r.forward()}sa(e,t,r,c)},aa=(e,t,r,n,o)=>{let s=t,i=J();while(s&&(!s.countable||s.deleted)){if(!s.deleted&&s.content.constructor===D){let l=s.content;i.set(l.key,l)}s=s.right}let c=0,a=!1;while(t!==s){if(r===t)a=!0;if(!t.deleted){let l=t.content;switch(l.constructor){case D:{let{key:u,value:f}=l,p=n.get(u)??null;if(i.get(u)!==l||p===f){if(t.delete(e),c++,!a&&(o.get(u)??null)===f&&p!==f)if(p===null)o.delete(u);else o.set(u,p)}if(!a&&!t.deleted)$t(o,l);break}}}t=t.right}return c},Kh=(e,t)=>{while(t&&t.right&&(t.right.deleted||!t.right.countable))t=t.right;let r=new Set;while(t&&(t.deleted||!t.countable)){if(!t.deleted&&t.content.constructor===D){let n=t.content.key;if(r.has(n))t.delete(e);else r.add(n)}t=t.left}},qh=(e)=>{let t=0;return v(e.doc,(r)=>{let{_start:n,_start:o}=e,s=J(),i=Er(s);while(o){if(o.deleted===!1)switch(o.content.constructor){case D:$t(i,o.content);break;default:t+=aa(r,n,o,s,i),s=Er(i),n=o;break}o=o.right}}),t},Gh=(e)=>{let t=new Set,r=e.doc;for(let[n,o]of e.afterState.entries()){let s=e.beforeState.get(n)||0;if(o===s)continue;Bc(e,r.store.clients.get(n),s,o,(i)=>{if(!i.deleted&&i.content.constructor===D&&i.constructor!==ee)t.add(i.parent)})}v(r,(n)=>{Ec(e,e.deleteSet,(o)=>{if(o instanceof ee||!o.parent._hasFormatting||t.has(o.parent))return;let s=o.parent;if(o.content.constructor===D)t.add(s);else Kh(n,o)});for(let o of t)qh(o)})},Ic=(e,t,r)=>{let n=r,o=Er(t.currentAttributes),s=t.right;while(r>0&&t.right!==null){if(t.right.deleted===!1)switch(t.right.content.constructor){case Oe:case et:case be:if(r<t.right.length)Ue(e,b(t.right.id.client,t.right.id.clock+r));r-=t.right.length,t.right.delete(e);break}t.forward()}if(s)aa(e,s,t.right,o,t.currentAttributes);let i=(t.left||t.right).parent;if(i._searchMarker)nr(i._searchMarker,t.index,-n+r);return t};class ua extends cr{constructor(e,t,r){super(e,t);this.childListChanged=!1,this.keysChanged=new Set,r.forEach((n)=>{if(n===null)this.childListChanged=!0;else this.keysChanged.add(n)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];v(e,(r)=>{let n=new Map,o=new Map,s=this.target._start,i=null,c={},a=\"\",l=0,u=0,f=()=>{if(i!==null){let p=null;switch(i){case\"delete\":if(u>0)p={delete:u};u=0;break;case\"insert\":if(typeof a===\"object\"||a.length>0){if(p={insert:a},n.size>0)p.attributes={},n.forEach((d,h)=>{if(d!==null)p.attributes[h]=d})}a=\"\";break;case\"retain\":if(l>0){if(p={retain:l},!Ri(c))p.attributes=Ni({},c)}l=0;break}if(p)t.push(p);i=null}};while(s!==null){switch(s.content.constructor){case Oe:case et:if(this.adds(s)){if(!this.deletes(s))f(),i=\"insert\",a=s.content.getContent()[0],f()}else if(this.deletes(s)){if(i!==\"delete\")f(),i=\"delete\";u+=1}else if(!s.deleted){if(i!==\"retain\")f(),i=\"retain\";l+=1}break;case be:if(this.adds(s)){if(!this.deletes(s)){if(i!==\"insert\")f(),i=\"insert\";a+=s.content.str}}else if(this.deletes(s)){if(i!==\"delete\")f(),i=\"delete\";u+=s.length}else if(!s.deleted){if(i!==\"retain\")f(),i=\"retain\";l+=s.length}break;case D:{let{key:p,value:d}=s.content;if(this.adds(s)){if(!this.deletes(s)){let h=n.get(p)??null;if(!De(h,d)){if(i===\"retain\")f();if(De(d,o.get(p)??null))delete c[p];else c[p]=d}else if(d!==null)s.delete(r)}}else if(this.deletes(s)){o.set(p,d);let h=n.get(p)??null;if(!De(h,d)){if(i===\"retain\")f();c[p]=h}}else if(!s.deleted){o.set(p,d);let h=c[p];if(h!==void 0){if(!De(h,d)){if(i===\"retain\")f();if(d===null)delete c[p];else c[p]=d}else if(h!==null)s.delete(r)}}if(!s.deleted){if(i===\"insert\")f();$t(n,s.content)}break}}s=s.right}f();while(t.length>0){let p=t[t.length-1];if(p.retain!==void 0&&p.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class ae extends R{constructor(e){super();this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??F(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach((r)=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ae}clone(){let e=new ae;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let r=new ua(this,e,t);if(bn(this,e,r),!e.local&&this._hasFormatting)e._needFormattingCleanup=!0}toString(){this.doc??F();let e=\"\",t=this._start;while(t!==null){if(!t.deleted&&t.countable&&t.content.constructor===be)e+=t.content.str;t=t.right}return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){if(this.doc!==null)v(this.doc,(r)=>{let n=new fn(null,this._start,0,new Map);for(let o=0;o<e.length;o++){let s=e[o];if(s.insert!==void 0){let i=!t&&typeof s.insert===\"string\"&&o===e.length-1&&n.right===null&&s.insert.slice(-1)===`\n`?s.insert.slice(0,-1):s.insert;if(typeof i!==\"string\"||i.length>0)Qo(r,this,n,i,s.attributes||{})}else if(s.retain!==void 0)zc(r,this,n,s.retain,s.attributes||{});else if(s.delete!==void 0)Ic(r,n,s.delete)}});else this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??F();let n=[],o=new Map,s=this.doc,i=\"\",c=this._start;function a(){if(i.length>0){let u={},f=!1;o.forEach((d,h)=>{f=!0,u[h]=d});let p={insert:i};if(f)p.attributes=u;n.push(p),i=\"\"}}let l=()=>{while(c!==null){if(_t(c,e)||t!==void 0&&_t(c,t))switch(c.content.constructor){case be:{let u=o.get(\"ychange\");if(e!==void 0&&!_t(c,e)){if(u===void 0||u.user!==c.id.client||u.type!==\"removed\")a(),o.set(\"ychange\",r?r(\"removed\",c.id):{type:\"removed\"})}else if(t!==void 0&&!_t(c,t)){if(u===void 0||u.user!==c.id.client||u.type!==\"added\")a(),o.set(\"ychange\",r?r(\"added\",c.id):{type:\"added\"})}else if(u!==void 0)a(),o.delete(\"ychange\");i+=c.content.str;break}case Oe:case et:{a();let u={insert:c.content.getContent()[0]};if(o.size>0){let f={};u.attributes=f,o.forEach((p,d)=>{f[d]=p})}n.push(u);break}case D:if(_t(c,e))a(),$t(o,c.content);break}c=c.right}a()};if(e||t)v(s,(u)=>{if(e)es(u,e);if(t)es(u,t);l()},\"cleanup\");else l();return n}insert(e,t,r){if(t.length<=0)return;let n=this.doc;if(n!==null)v(n,(o)=>{let s=nn(o,this,e,!r);if(!r)r={},s.currentAttributes.forEach((i,c)=>{r[c]=i});Qo(o,this,s,t,r)});else this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){let n=this.doc;if(n!==null)v(n,(o)=>{let s=nn(o,this,e,!r);Qo(o,this,s,t,r||{})});else this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;let r=this.doc;if(r!==null)v(r,(n)=>{Ic(n,nn(n,this,e,!0),t)});else this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;let n=this.doc;if(n!==null)v(n,(o)=>{let s=nn(o,this,e,!1);if(s.right===null)return;zc(o,this,s,t,r)});else this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){if(this.doc!==null)v(this.doc,(t)=>{ln(t,this,e)});else this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){if(this.doc!==null)v(this.doc,(r)=>{ps(r,this,e,t)});else this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return ds(this,e)}getAttributes(){return ta(this)}_write(e){e.writeTypeRef(dm)}}var Wh=(e)=>new ae;class sn{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??F()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===wt||t.constructor===Xe)&&t._start!==null)e=t._start;else while(e!==null){let r=e.next;if(r!==null){e=r;break}else if(e.parent===this._root)e=null;else e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));if(this._firstCall=!1,e===null)return{value:void 0,done:!0};return this._currentNode=e,{value:e.content.type,done:!1}}}class Xe extends R{constructor(){super();this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Xe}clone(){let e=new Xe;return e.insert(0,this.toArray().map((t)=>t instanceof R?t.clone():t)),e}get length(){return this.doc??F(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new sn(this,e)}querySelector(e){e=e.toUpperCase();let r=new sn(this,(n)=>n.nodeName&&n.nodeName.toUpperCase()===e).next();if(r.done)return null;else return r.value}querySelectorAll(e){return e=e.toUpperCase(),ge(new sn(this,(t)=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){bn(this,e,new la(this,t,e))}toString(){return Hc(this,(e)=>e.toString()).join(\"\")}toJSON(){return this.toString()}toDOM(e=document,t={},r){let n=e.createDocumentFragment();if(r!==void 0)r._createAssociation(n,this);return or(this,(o)=>{n.insertBefore(o.toDOM(e,t,r),null)}),n}insert(e,t){if(this.doc!==null)v(this.doc,(r)=>{Qc(r,this,e,t)});else this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)v(this.doc,(r)=>{let n=e&&e instanceof R?e._item:e;un(r,this,n,t)});else{let r=this._prelimContent,n=e===null?0:r.findIndex((o)=>o===e)+1;if(n===0&&e!==null)throw X(\"Reference item not found\");r.splice(n,0,...t)}}delete(e,t=1){if(this.doc!==null)v(this.doc,(r)=>{ea(r,this,e,t)});else this._prelimContent.splice(e,t)}toArray(){return Wc(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Yc(this,e)}slice(e=0,t=this.length){return Gc(this,e,t)}forEach(e){or(this,e)}_write(e){e.writeTypeRef(mm)}}var Hh=(e)=>new Xe;class wt extends Xe{constructor(e=\"UNDEFINED\"){super();this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,n)=>{this.setAttribute(n,r)}),this._prelimAttrs=null}_copy(){return new wt(this.nodeName)}clone(){let e=new wt(this.nodeName),t=this.getAttributes();return Ui(t,(r,n)=>{e.setAttribute(n,r)}),e.insert(0,this.toArray().map((r)=>r instanceof R?r.clone():r)),e}toString(){let e=this.getAttributes(),t=[],r=[];for(let i in e)r.push(i);r.sort();let n=r.length;for(let i=0;i<n;i++){let c=r[i];t.push(c+'=\"'+e[c]+'\"')}let o=this.nodeName.toLocaleLowerCase(),s=t.length>0?\" \"+t.join(\" \"):\"\";return`<${o}${s}>${super.toString()}</${o}>`}removeAttribute(e){if(this.doc!==null)v(this.doc,(t)=>{ln(t,this,e)});else this._prelimAttrs.delete(e)}setAttribute(e,t){if(this.doc!==null)v(this.doc,(r)=>{ps(r,this,e,t)});else this._prelimAttrs.set(e,t)}getAttribute(e){return ds(this,e)}hasAttribute(e){return ra(this,e)}getAttributes(e){return e?Vh(this,e):ta(this)}toDOM(e=document,t={},r){let n=e.createElement(this.nodeName),o=this.getAttributes();for(let s in o){let i=o[s];if(typeof i===\"string\")n.setAttribute(s,i)}if(or(this,(s)=>{n.appendChild(s.toDOM(e,t,r))}),r!==void 0)r._createAssociation(n,this);return n}_write(e){e.writeTypeRef(hm),e.writeKey(this.nodeName)}}var Yh=(e)=>new wt(e.readKey());class la extends cr{constructor(e,t,r){super(e,r);this.childListChanged=!1,this.attributesChanged=new Set,t.forEach((n)=>{if(n===null)this.childListChanged=!0;else this.attributesChanged.add(n)})}}class pn extends q{constructor(e){super();this.hookName=e}_copy(){return new pn(this.hookName)}clone(){let e=new pn(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){let n=t[this.hookName],o;if(n!==void 0)o=n.createDom(this);else o=document.createElement(this.hookName);if(o.setAttribute(\"data-yjs-hook\",this.hookName),r!==void 0)r._createAssociation(o,this);return o}_write(e){e.writeTypeRef(gm),e.writeKey(this.hookName)}}var Xh=(e)=>new pn(e.readKey());class dn extends ae{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new dn}clone(){let e=new dn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){let n=e.createTextNode(this.toString());if(r!==void 0)r._createAssociation(n,this);return n}toString(){return this.toDelta().map((e)=>{let t=[];for(let n in e.attributes){let o=[];for(let s in e.attributes[n])o.push({key:s,value:e.attributes[n][s]});o.sort((s,i)=>s.key<i.key?-1:1),t.push({nodeName:n,attrs:o})}t.sort((n,o)=>n.nodeName<o.nodeName?-1:1);let r=\"\";for(let n=0;n<t.length;n++){let o=t[n];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){let i=o.attrs[s];r+=` ${i.key}=\"${i.value}\"`}r+=\">\"}r+=e.insert;for(let n=t.length-1;n>=0;n--)r+=`</${t[n].nodeName}>`;return r}).join(\"\")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(ym)}}var Qh=(e)=>new dn;class kn{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Q()}mergeWith(e){return!1}write(e,t,r){throw Q()}integrate(e,t){throw Q()}}var em=0;class ee extends kn{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){if(t>0)this.id.clock+=t,this.length-=t;Lc(e.doc.store,this)}write(e,t){e.writeInfo(em),e.writeLen(this.length-t)}getMissing(e,t){return null}}class ar{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ar(this.content)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}var tm=(e)=>new ar(e.readBuf());class sr{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new sr(this.len)}splice(e){let t=new sr(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){cn(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}var rm=(e)=>new sr(e.readLen()),fa=(e,t)=>new ke({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class ur{constructor(e){if(e._item)console.error(\"This document was already integrated as a sub-document. You should create a second instance instead with the same guid.\");this.doc=e;let t={};if(this.opts=t,!e.gc)t.gc=!1;if(e.autoLoad)t.autoLoad=!0;if(e.meta!==null)t.meta=e.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new ur(fa(this.doc.guid,this.opts))}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){if(this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad)e.subdocsLoaded.add(this.doc)}delete(e){if(e.subdocsAdded.has(this.doc))e.subdocsAdded.delete(this.doc);else e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}var nm=(e)=>new ur(fa(e.readString(),e.readAny()));class et{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new et(this.embed)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}var om=(e)=>new et(e.readJSON());class D{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new D(this.key,this.value)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){let r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}var sm=(e)=>new D(e.readKey(),e.readJSON());class hn{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new hn(this.arr)}splice(e){let t=new hn(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let n=t;n<r;n++){let o=this.arr[n];e.writeString(o===void 0?\"undefined\":JSON.stringify(o))}}getRef(){return 2}}var im=(e)=>{let t=e.readLen(),r=[];for(let n=0;n<t;n++){let o=e.readString();if(o===\"undefined\")r.push(void 0);else r.push(JSON.parse(o))}return new hn(r)},cm=Yt(\"node_env\")===\"development\";class Qe{constructor(e){this.arr=e,cm&&To(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qe(this.arr)}splice(e){let t=new Qe(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let n=t;n<r;n++){let o=this.arr[n];e.writeAny(o)}}getRef(){return 8}}var am=(e)=>{let t=e.readLen(),r=[];for(let n=0;n<t;n++)r.push(e.readAny());return new Qe(r)};class be{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(\"\")}isCountable(){return!0}copy(){return new be(this.str)}splice(e){let t=new be(this.str.slice(e));this.str=this.str.slice(0,e);let r=this.str.charCodeAt(e-1);if(r>=55296&&r<=56319)this.str=this.str.slice(0,e-1)+\"�\",t.str=\"�\"+t.str.slice(1);return t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}var um=(e)=>new be(e.readString()),lm=[Fh,Jh,Wh,Yh,Hh,Xh,Qh],fm=0,pm=1,dm=2,hm=3,mm=4,gm=5,ym=6;class Oe{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Oe(this.type._copy())}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;while(t!==null){if(!t.deleted)t.delete(e);else if(t.id.clock<(e.beforeState.get(t.id.client)||0))e._mergeStructs.push(t);t=t.right}this.type._map.forEach((r)=>{if(!r.deleted)r.delete(e);else if(r.id.clock<(e.beforeState.get(r.id.client)||0))e._mergeStructs.push(r)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;while(t!==null)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach((r)=>{while(r!==null)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}var xm=(e)=>new Oe(lm[e.readTypeRef()](e));var mn=(e,t,r)=>{let{client:n,clock:o}=t.id,s=new C(b(n,o+r),t,b(n,o+r-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(r));if(t.deleted)s.markDeleted();if(t.keep)s.keep=!0;if(t.redone!==null)s.redone=b(t.redone.client,t.redone.clock+r);if(t.right=s,s.right!==null)s.right.left=s;if(e._mergeStructs.push(s),s.parentSub!==null&&s.right===null)s.parent._map.set(s.parentSub,s);return t.length=r,s};class C extends kn{constructor(e,t,r,n,o,s,i,c){super(e,c.getLength());this.origin=r,this.left=t,this.right=n,this.rightOrigin=o,this.parent=s,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?ho:0}set marker(e){if((this.info&Dr)>0!==e)this.info^=Dr}get marker(){return(this.info&Dr)>0}get keep(){return(this.info&po)>0}set keep(e){if(this.keep!==e)this.info^=po}get countable(){return(this.info&ho)>0}get deleted(){return(this.info&Cr)>0}set deleted(e){if(this.deleted!==e)this.info^=Cr}markDeleted(){this.info|=Cr}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=U(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=U(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===He&&this.id.client!==this.parent.client&&this.parent.clock>=U(t,this.parent.client))return this.parent.client;if(this.origin)this.left=bc(e,t,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=Ue(e,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===ee||this.right&&this.right.constructor===ee)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===C)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===C)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===He){let r=Xo(t,this.parent);if(r.constructor===ee)this.parent=null;else this.parent=r.content.type}return null}integrate(e,t){if(t>0)this.id.clock+=t,this.left=bc(e,e.doc.store,b(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,n;if(r!==null)n=r.right;else if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start;let o=new Set,s=new Set;while(n!==null&&n!==this.right){if(s.add(n),o.add(n),tn(this.origin,n.origin)){if(n.id.client<this.id.client)r=n,o.clear();else if(tn(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&s.has(Xo(e.doc.store,n.origin))){if(!o.has(Xo(e.doc.store,n.origin)))r=n,o.clear()}else break;n=n.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start,this.parent._start=this;this.right=r}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(e)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(Lc(e.doc.store,this),this.content.integrate(e,this),vc(e,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(e)}else new ee(this.id,this.length).integrate(e,0)}get next(){let e=this.right;while(e!==null&&e.deleted)e=e.right;return e}get prev(){let e=this.left;while(e!==null&&e.deleted)e=e.left;return e}get lastId(){return this.length===1?this.id:b(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&tn(e.origin,this.lastId)&&this.right===e&&tn(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;if(t)t.forEach((r)=>{if(r.p===e){if(r.p=this,!this.deleted&&this.countable)r.index-=this.length}});if(e.keep)this.keep=!0;if(this.right=e.right,this.right!==null)this.right.left=this;return this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;if(this.countable&&this.parentSub===null)t._length-=this.length;this.markDeleted(),cn(e.deleteSet,this.id.client,this.id.clock,this.length),vc(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw H();if(this.content.gc(e),t)Ah(e,this,new ee(this.id,this.length));else this.content=new sr(this.length)}write(e,t){let r=t>0?b(this.id.client,this.id.clock+t-1):this.origin,n=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&jt|(r===null?0:M)|(n===null?0:ie)|(o===null?0:ot);if(e.writeInfo(s),r!==null)e.writeLeftID(r);if(n!==null)e.writeRightID(n);if(r===null&&n===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=zh(i);e.writeParentInfo(!0),e.writeString(a)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else if(i.constructor===String)e.writeParentInfo(!0),e.writeString(i);else if(i.constructor===He)e.writeParentInfo(!1),e.writeLeftID(i);else H();if(o!==null)e.writeString(o)}this.content.write(e,t)}}var pa=(e,t)=>_m[t&jt](e),_m=[()=>{H()},rm,im,tm,um,om,sm,xm,am,nm,()=>{H()}],wm=10;class te extends kn{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){H()}write(e,t){e.writeInfo(wm),w(e.restEncoder,this.length-t)}getMissing(e,t){return null}}var da=typeof globalThis<\"u\"?globalThis:typeof window<\"u\"?window:typeof global<\"u\"?global:{},ha=\"__ $YJS$ __\";if(da[ha]===!0)console.error(\"Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438\");da[ha]=!0;function fr(e){let t=Object.values(e).filter((n)=>typeof n===\"number\");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ms(e,t=\"|\"){return e.map((r)=>xs(r)).join(t)}function pr(e,t){if(typeof t===\"bigint\")return t.toString();return t}class ga{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function dr(e){return new ga(e)}function ya(e){return e===null||e===void 0}function vn(e){let t=e.startsWith(\"^\")?1:0,r=e.endsWith(\"$\")?e.length-1:e.length;return e.slice(t,r)}function xa(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-n)<o)return 0;return r-n}function ue(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function hr(e){let t=Object.getOwnPropertyDescriptor(e,\"shape\");return t?.get?t.get.raw:t?.value}function Te(e){return hr(e._zod.def)??e._zod.def.shape}function _a(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return ue(this,t,n),n},enumerable:!0,configurable:!0})}function wa(e,t,r){if(t in e)ue(e,t,r);else e[t]=r}function tt(e,t,r,n){let o=Te(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);if(!i.enumerable)continue;if(i.get)_a(e,s,()=>{let c=t._zod.def.shape[s];return n?n(c,s):c});else wa(e,s,n?n(i.value,s):i.value)}}function bm(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)_a(e,r,()=>t[r]);else wa(e,r,n.value)}}function ne(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function ba(e){return JSON.stringify(e)}function ka(e){return e.toLowerCase().trim().replace(/[^\\w\\s-]/g,\"\").replace(/[\\s_-]+/g,\"-\").replace(/^-+|-+$/g,\"\")}var gs=\"captureStackTrace\"in Error?Error.captureStackTrace:(...e)=>{};function zt(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}var va=dr(()=>{if(oe.jitless)return!1;if(typeof navigator<\"u\"&&navigator?.userAgent?.includes(\"Cloudflare\"))return!1;try{return new Function(\"\"),!0}catch(e){return!1}});function It(e){if(zt(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!==\"function\")return!0;let r=t.prototype;if(zt(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,\"isPrototypeOf\")===!1)return!1;return!0}function ys(e){if(It(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Sa=new Set([\"string\",\"number\",\"symbol\"]);function je(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function ve(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function y(e){let t=e;if(!t)return{};if(typeof t===\"string\")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}if(delete t.message,typeof t.error===\"string\")return{...t,error:()=>t.error};return t}function xs(e){if(typeof e===\"bigint\")return e.toString()+\"n\";if(typeof e===\"string\")return`\"${e}\"`;return`${e}`}function $a(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===\"optional\")}var Sn=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),_s={int64:[BigInt(\"-9223372036854775808\"),BigInt(\"9223372036854775807\")],uint64:[BigInt(0),BigInt(\"18446744073709551615\")]};function km(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(\".pick() cannot be used on object schemas containing refinements\");let s={};return tt(s,e,$n(e,t)),ve(e,ne(r,{shape:s,checks:[]}))}function $n(e,t){let r=Te(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw Error(`Unrecognized key: \"${String(o)}\"`);if(t[o])n.push(o)}return n}function vm(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(\".omit() cannot be used on object schemas containing refinements\");let s=new Set($n(e,t)),i={};return tt(i,e,Reflect.ownKeys(Te(e)).filter((c)=>!s.has(c))),ve(e,ne(r,{shape:i,checks:[]}))}function Sm(e,t){if(!It(t))throw Error(\"Invalid input to extend: expected a plain object\");let r=e._zod.def.checks;if(r&&r.length>0){let o=Te(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw Error(\"Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.\")}return ve(e,ne(e._zod.def,{shape:za(e,t)}))}function za(e,t){let r={};return tt(r,e,Reflect.ownKeys(Te(e))),bm(r,t),r}function $m(e,t){if(!It(t))throw Error(\"Invalid input to safeExtend: expected a plain object\");return ve(e,ne(e._zod.def,{shape:za(e,t)}))}function zm(e,t){if(!t?._zod?.def)throw Error(\"Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.\");if(e._zod.def.checks?.length)throw Error(\".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.\");let r={};tt(r,e,Reflect.ownKeys(Te(e))),tt(r,t,Reflect.ownKeys(Te(t)));let n=ne(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ve(e,n)}function Ia(e,t,r,n=\"partial\"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${n}() cannot be used on object schemas containing refinements`);let c=r?new Set($n(t,r)):void 0,a={};return tt(a,t,Reflect.ownKeys(Te(t)),e&&((l,u)=>c&&!c.has(u)?l:new e({type:\"optional\",innerType:l}))),ve(t,ne(t._zod.def,{shape:a,checks:[]}))}function Im(e,t,r){let n=r?new Set($n(t,r)):void 0,o={};return tt(o,t,Reflect.ownKeys(Te(t)),(s,i)=>n&&!n.has(i)?s:new e({type:\"nonoptional\",innerType:s})),ve(t,ne(t._zod.def,{shape:o}))}function Se(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ea(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function zn(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function lr(e){return typeof e===\"string\"?e:e?.message}function ws(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;if(o>=0)t.push([o,r])}return t}function In(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Le(e,t,r){var n;let o=e.inst?._zod?.traits;if(o?.has(\"$ZodType\"))if(o.has(\"$ZodCheck\"))(n=e).schema??(n.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:lr(e.inst?._zod.def?.error?.(e))??lr(s?.(e))??lr(t?.error?.(e))??lr(r.customError?.(e))??lr(r.localeError?.(e))??\"Invalid input\",c={};for(let a of Object.keys(e)){if(a===\"inst\"||a===\"schema\"||a===\"continue\"||a===\"input\"||a===\"__proto__\")continue;c[a]=e[a]}if(c.path??(c.path=[]),c.message=i,t?.reportInput)c.input=e.input;return c}var Em=/[\\uD800-\\uDBFF]/;function En(e){let t=e.length;if(!Em.test(e))return t;let r=t;for(let n=0;n<t-1;n++)if((e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320)r--,n++;return r}function An(e){if(Array.isArray(e))return\"array\";if(typeof e===\"string\")return\"string\";return\"unknown\"}function Aa(e){let t=typeof e;switch(t){case\"number\":return Number.isNaN(e)?\"nan\":\"number\";case\"object\":{if(e===null)return\"null\";if(Array.isArray(e))return\"array\";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&\"constructor\"in r&&r.constructor)return r.constructor.name}}return t}function rt(...e){let[t,r,n]=e;if(typeof t===\"string\")return{message:t,code:\"custom\",input:r,inst:n};return{...t}}function Oa(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else Am(e,r,n.value)}}function Pe(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function On(e,t,r){return Pe(e,t,r,!1)}function Ta(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Pe(this,r,n(this))},set(o){Pe(this,r,o)}})}return t}function Am(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Pe(this,t,r.bind(this))},set(n){Pe(this,t,n)}})}function Om(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var hs,Re=!1,Tm={configurable:!0,get(){Re=!0;return}};function k(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&hs!==e._zod){hs=void 0;return}hs=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Tm);let o=Re;Re=!1;try{let s=r(this);if(Re)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Re=Re||o,s}catch(s){throw delete this[t],Re=Re||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Pm(e,t,r,n){let o=Om(e,t);if(!o)return;Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Zm=\"~constantCatch\";function Pa(e){let t=()=>e;return t[Zm]=!0,t}var Za;var bs={value:void 0,enumerable:!1},Ca=\"captureStackTrace\"in Error?Error:null;function Cm(e){let t=Ca;if(t){let r=t.stackTraceLimit;if(typeof r===\"number\"){try{t.stackTraceLimit=0}catch{return Ca=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function m(e,t,r,n){let o={};function s(p){this.def=p,this.constr=f,this.traits=new Set}s.prototype=o;let i=r,c=i&&new WeakSet;function a(p,d){if(!p._zod){bs.value=new s(d);try{Object.defineProperty(p,\"_zod\",bs)}finally{bs.value=void 0}}else if(p._zod.traits.has(e))return;if(p._zod.traits.add(e),t(p,d),c){let g=Object.getPrototypeOf(p),x=p._zod.constr.prototype,S=g;while(S&&S!==x)S=Object.getPrototypeOf(S);let de=S??g;if(!c.has(de))c.add(de),Oa(de,i)}let h=f.prototype;for(let g in h){if(!Object.prototype.hasOwnProperty.call(h,g))continue;if(!(g in p))p[g]=h[g].bind(p)}}let l=n?.Parent??Object;class u extends l{}Object.defineProperty(u,\"name\",{value:e});function f(p){let d=n?.Parent?Cm(u):this;a(d,p);let h=d._zod.deferred;if(h){for(let x of h)x();d._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;if(g)g(d);return d}return Object.defineProperty(f,\"init\",{value:a}),Object.defineProperty(f,Symbol.hasInstance,{value:(p)=>{if(n?.Parent&&p instanceof n.Parent)return!0;return p?._zod?.traits?.has(e)}}),Object.defineProperty(f,\"name\",{value:e}),f}class $e extends Error{constructor(){super(\"Encountered Promise during synchronous parse. Use .parseAsync() instead.\")}}class mr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name=\"ZodEncodeError\"}}(Za=globalThis).__zod_globalConfig??(Za.__zod_globalConfig={});var oe=globalThis.__zod_globalConfig;function fe(e){if(e)Object.assign(oe,e);return oe}function Dm(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,pr,2)),e.message}function Nm(e){this._zod.message=e}var Um={get:Dm,set:Nm,enumerable:!0,configurable:!0},vs={value:void 0,enumerable:!1},Da=new WeakSet([Object.prototype,Error.prototype]),Na=(e,t)=>{e.name=\"$ZodError\",vs.value=t,Object.defineProperty(e,\"issues\",vs),vs.value=void 0,Object.defineProperty(e,\"message\",Um);let r=Object.getPrototypeOf(e);if(!Da.has(r))Da.add(r),Object.defineProperty(r,\"toString\",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,\"toString\",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,\"toString\",{value:n,configurable:!0,writable:!0})}})},Ua=m(\"$ZodError\",Na),zx=m(\"$ZodError\",Na,void 0,{Parent:Error});function Rm(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t===\"__proto__\")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function Ra(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)Rm(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function ja(e,t=(r)=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code===\"invalid_union\"&&i.errors.length)i.errors.map((c)=>n({issues:c},[...s,...i.path]));else if(i.code===\"invalid_key\")n({issues:i.issues},[...s,...i.path]);else if(i.code===\"invalid_element\")n({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)r._errors.push(t(i));else{let a=r,l=0;while(l<c.length){let u=c[l],f=l===c.length-1;if(u===\"_errors\"){if(f)a._errors.push(t(i));l++;continue}if(!Object.prototype.hasOwnProperty.call(a,u))Object.defineProperty(a,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=a[u];if(f)p._errors.push(t(i));a=p,l++}}}};return n(e),r}function Tn(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Pn=(e)=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},c=r._zod.run({value:n,issues:[]},i);if(c instanceof Promise)throw new $e;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((l)=>Le(l,i,fe())));throw gs(a,s?.callee??t),a}return c.value};return t};var Zn=(e)=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},c=r._zod.run({value:n,issues:[]},i);if(c instanceof Promise)c=await c;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((l)=>Le(l,i,fe())));throw gs(a,s?.callee??t),a}return c.value};return t};var Cn=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new $e;return s.issues.length?La(e,s.issues,o):{success:!0,data:s.value}};function La(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>Le(o,r,fe()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var Dn=(e)=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)s=await s;return s.issues.length?La(e,s.issues,o):{success:!0,data:s.value}};var jm=Symbol.for(\"zod.compile.invalid\"),Lm=Symbol.for(\"zod.compile.fallback\"),Ss=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==jm)return!0;if(n.definite===!0&&r===void 0)return!1}return Bm(e,t,r)};function Bm(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o)n[Lm]=!0,s=o({value:t,issues:[]},n);else s=e._zod.run({value:t,issues:[]},n);if(s instanceof Promise)throw new $e;return s.issues.length===0}var $s=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);if(o instanceof Promise)o=await o;return o.issues.length===0},Ba=(e)=>{let t=Pn(e),r=(n,o,s,i)=>{let c=s?{...s,direction:\"backward\"}:{direction:\"backward\"};return t(n,o,c,Tn(r,i))};return r};var Ma=(e)=>{let t=Pn(e),r=(n,o,s,i)=>t(n,o,s,Tn(r,i));return r};var Va=(e)=>{let t=Zn(e),r=async(n,o,s,i)=>{let c=s?{...s,direction:\"backward\"}:{direction:\"backward\"};return await t(n,o,c,Tn(r,i))};return r};var Fa=(e)=>{let t=Zn(e),r=async(n,o,s,i)=>await t(n,o,s,Tn(r,i));return r};var Ja=(e)=>(t,r,n)=>{let o=n?{...n,direction:\"backward\"}:{direction:\"backward\"};return Cn(e)(t,r,o)};var Ka=(e)=>(t,r,n)=>Cn(e)(t,r,n);var qa=(e)=>async(t,r,n)=>{let o=n?{...n,direction:\"backward\"}:{direction:\"backward\"};return Dn(e)(t,r,o)};var Ga=(e)=>async(t,r,n)=>Dn(e)(t,r,n);var Wa=/^[cC][0-9a-z]{6,}$/,Ha=/^[0-9a-z]+$/,Ya=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Xa=/^[0-9a-vA-V]{20}$/,Qa=/^[A-Za-z0-9]{27}$/,eu=/^[a-zA-Z0-9_-]{21}$/;function tu(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ru=/^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$/;var nu=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Is=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var ou=/^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/;var Mm=\"^(?=[\\\\s\\\\S]*[\\\\p{Extended_Pictographic}\\\\p{Regional_Indicator}\\\\u20E3])[\\\\p{Extended_Pictographic}\\\\p{Emoji_Component}]+$\";function su(){return new RegExp(Mm,\"u\")}var iu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var au=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$/,uu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fu=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var pu=/^https?$/,du=/^\\+[1-9]\\d{6,14}$/;var hu=\"(?:(?:\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\\\d|30)|(?:02)-(?:0[1-9]|1\\\\d|2[0-8])))\";function Vm(e){return new RegExp(`^${e}$`)}var mu=Vm(hu);function zs(e){return typeof e.precision===\"number\"?e.precision===-1?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d\":e.precision===0?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\":`(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\\\\.\\\\d{${e.precision}}`:e.seconds?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d(?:\\\\.\\\\d+)?\":\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d(?::[0-5]\\\\d(?:\\\\.\\\\d+)?)?\"}function gu(e){return new RegExp(`^${zs(e)}$`)}function yu(e){let t=[\"Z\"];if(e.offset)t.push(\"([+-](?:[01]\\\\d|2[0-3]):[0-5]\\\\d)\");let r=`${zs({precision:e.precision,seconds:!0})}(?:${t.join(\"|\")})`,n=e.local?`${r}|${zs({precision:e.precision})}`:r;return new RegExp(`^${hu}T(?:${n})$`)}var xu=/^[\\s\\S]{0,}$/;var Es=/^-?\\d+(?:\\.\\d+)?$/;var _u=/^[^A-Z]*$/,wu=/^[^a-z]*$/;var L=m(\"$ZodCheck\",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var As=(e)=>{let t=e.value;return!ya(t)&&t.length!==void 0},Nn={number:\"number\",bigint:\"bigint\",object:\"date\"},Os=m(\"$ZodCheckLessThan\",(e,t)=>{L.init(e,t);let r=Nn[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:Nn[typeof n.value]??r,code:\"too_big\",maximum:typeof t.value===\"object\"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ts=m(\"$ZodCheckGreaterThan\",(e,t)=>{L.init(e,t);let r=Nn[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:Nn[typeof n.value]??r,code:\"too_small\",minimum:typeof t.value===\"object\"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bu=m(\"$ZodCheckMultipleOf\",(e,t)=>{L.init(e,t),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error(\"Cannot mix number and bigint in multiple_of check.\");if(typeof r.value===\"bigint\"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):xa(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:\"not_multiple_of\",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),ku=m(\"$ZodCheckNumberFormat\",(e,t)=>{L.init(e,t),t.format=t.format||\"float64\";let r=t.format?.includes(\"int\"),n=r?\"int\":\"number\",[o,s]=Sn[t.format];e._zod.check=(i)=>{let c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:\"invalid_type\",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)i.issues.push({input:c,code:\"too_big\",maximum:Number.MAX_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:n,inclusive:!0,continue:!t.abort});else i.issues.push({input:c,code:\"too_small\",minimum:Number.MIN_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(c<o)i.issues.push({origin:\"number\",input:c,code:\"too_small\",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(c>s)i.issues.push({origin:\"number\",input:c,code:\"too_big\",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var vu=m(\"$ZodCheckMaxLength\",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=As),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o===\"string\"&&s>t.maximum?En(o):s)<=t.maximum)return;let c=An(o);n.issues.push({origin:c,code:\"too_big\",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Su=m(\"$ZodCheckMinLength\",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=As),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o===\"string\"&&s>=t.minimum&&s<t.minimum*2?En(o):s)>=t.minimum)return;let c=An(o);n.issues.push({origin:c,code:\"too_small\",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),$u=m(\"$ZodCheckLengthEquals\",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=As),e._zod.check=(n)=>{let o=n.value,s=o.length,i=typeof o===\"string\"&&s>=t.length&&s<=t.length*2?En(o):s;if(i===t.length)return;let c=An(o),a=i>t.length;n.issues.push({origin:c,...a?{code:\"too_big\",maximum:t.length}:{code:\"too_small\",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yr=m(\"$ZodCheckStringFormat\",(e,t)=>{var r,n;if(L.init(e,t),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),zu=m(\"$ZodCheckRegex\",(e,t)=>{yr.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"regex\",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Iu=m(\"$ZodCheckLowerCase\",(e,t)=>{t.pattern??(t.pattern=_u),yr.init(e,t)}),Eu=m(\"$ZodCheckUpperCase\",(e,t)=>{t.pattern??(t.pattern=wu),yr.init(e,t)}),Au=m(\"$ZodCheckIncludes\",(e,t)=>{L.init(e,t);let r=je(t.includes),n=new RegExp(typeof t.position===\"number\"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:\"includes\",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Ou=m(\"$ZodCheckStartsWith\",(e,t)=>{L.init(e,t);let r=new RegExp(`^${je(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"starts_with\",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Tu=m(\"$ZodCheckEndsWith\",(e,t)=>{L.init(e,t);let r=new RegExp(`.*${je(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"ends_with\",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Pu=m(\"$ZodCheckOverwrite\",(e,t)=>{L.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Ps{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e===\"function\"){e(this,{execution:\"sync\"}),e(this,{execution:\"async\"});return}let r=e.split(`\n`).filter((s)=>s),n=Math.min(...r.map((s)=>s.length-s.trimStart().length)),o=r.map((s)=>s.slice(n)).map((s)=>\" \".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let e=Function,t=this?.content??[\"\"];return new e(...Object.keys(this.closed),`return function (${this.args.join(\", \")}) {\n${t.join(`\n`)}\n};`)(...Object.values(this.closed))}}var Cu={major:4,minor:6,patch:7};var A=m(\"$ZodType\",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Cu;let n=e._zod.def.checks,o=e._zod.traits.has(\"$ZodCheck\")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(c,a,l)=>{if(c.memo)return c;let u=Se(c),f;for(let p of a){if(p._zod.def.when){if(Ea(c))continue;if(!p._zod.def.when(c))continue}else if(u)continue;let d=c.issues.length,h=p._zod.check(c);if(h instanceof Promise&&l?.async===!1)throw new $e;if(f||h instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await h,c.issues.length===d)return;if(In(c.issues,d,e),!u)u=Se(c,d)});else{if(c.issues.length===d)continue;if(In(c.issues,d,e),!u)u=Se(c,d)}}if(f)return f.then(()=>c);return c},i=(c,a,l)=>{if(Se(c))return c.aborted=!0,c;let u=s(a,o,l);if(u instanceof Promise){if(l.async===!1)throw new $e;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction===\"backward\"){let u=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>i(f,c,a));return i(u,c,a)}let l=e._zod.parse(c,a);if(l instanceof Promise){if(a.async===!1)throw new $e;return l.then((u)=>s(u,o,a))}return s(l,o,a)}}},{get \"~standard\"(){return On(this,\"~standard\",Cs(this))},set \"~standard\"(e){Pe(this,\"~standard\",e)}}),Ju=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>Le(r,t,fe()))}:{value:e.value};async function Jm(e,t){let r={async:!0};return Ju(await e._zod.run({value:t,issues:[]},r),r)}function Cs(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Ju(n,r)}catch(n){}return Jm(e,t)},vendor:\"zod\",version:1}}var Ln=m(\"$ZodString\",(e,t)=>{A.init(e,t),e._zod.pattern=t.pattern??xu,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value===\"string\")return r;return r.issues.push({expected:\"string\",code:\"invalid_type\",input:r.value,inst:e}),r}}),I=m(\"$ZodStringFormat\",(e,t)=>{yr.init(e,t),Ln.init(e,t)}),Ku=m(\"$ZodGUID\",(e,t)=>{t.pattern??(t.pattern=nu),I.init(e,t)}),qu=m(\"$ZodUUID\",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: \"${t.version}\"`);t.pattern??(t.pattern=Is(n))}else t.pattern??(t.pattern=Is());I.init(e,t)}),Gu=m(\"$ZodEmail\",(e,t)=>{t.pattern??(t.pattern=ou),I.init(e,t)}),Wu=1,Rn=2;function Hu(e){try{if(typeof URL<\"u\"&&typeof URL.canParse===\"function\")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Km(e,t){if(!(\"normalize\"in t)&&!(\"hostname\"in t)&&!(\"protocol\"in t))return Hu(e)||Rn;return qm(e,t)}function qm(e,t){if(!t.normalize&&t.protocol?.source===pu.source&&!/^https?:\\/\\//i.test(e))return Wu;try{if(typeof URL<\"u\"){let r=URL;if(typeof r.parse===\"function\")return r.parse(e)??Rn}return new URL(e)}catch{return Rn}}var Gm=/[\\t\\n\\r]/g;function Du(e){return e.replace(Gm,\"\")}function Wm(e,t){return t.lastIndex=0,t.test(e.hostname)}function Hm(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(\":\")?e.protocol.slice(0,-1):e.protocol)}var Yu=m(\"$ZodURL\",(e,t)=>{I.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=Km(n,t);if(o===Wu){r.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid URL format\",input:r.value,inst:e,continue:!t.abort});return}if(o===Rn){r.issues.push({code:\"invalid_format\",format:\"url\",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Du(n);return}if(t.hostname&&!Wm(o,t.hostname))r.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid hostname\",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!Hm(o,t.protocol))r.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid protocol\",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?o.href:Du(n);return}catch(n){r.issues.push({code:\"invalid_format\",format:\"url\",input:r.value,inst:e,continue:!t.abort})}}}),Xu=m(\"$ZodEmoji\",(e,t)=>{t.pattern??(t.pattern=su()),I.init(e,t)}),Qu=m(\"$ZodNanoID\",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?eu:tu(t.length)),I.init(e,t)}),el=m(\"$ZodCUID\",(e,t)=>{t.pattern??(t.pattern=Wa),I.init(e,t)}),tl=m(\"$ZodCUID2\",(e,t)=>{t.pattern??(t.pattern=Ha),I.init(e,t)}),rl=m(\"$ZodULID\",(e,t)=>{t.pattern??(t.pattern=Ya),I.init(e,t)}),nl=m(\"$ZodXID\",(e,t)=>{t.pattern??(t.pattern=Xa),I.init(e,t)}),ol=m(\"$ZodKSUID\",(e,t)=>{t.pattern??(t.pattern=Qa),I.init(e,t)}),sl=m(\"$ZodISODateTime\",(e,t)=>{t.pattern??(t.pattern=yu(t)),I.init(e,t)}),il=m(\"$ZodISODate\",(e,t)=>{t.pattern??(t.pattern=mu),I.init(e,t)}),cl=m(\"$ZodISOTime\",(e,t)=>{t.pattern??(t.pattern=gu(t)),I.init(e,t)}),al=m(\"$ZodISODuration\",(e,t)=>{t.pattern??(t.pattern=ru),I.init(e,t)}),ul=m(\"$ZodIPv4\",(e,t)=>{t.pattern??(t.pattern=iu),I.init(e,t)}),Ym=/^[0-9a-fA-F:.]+$/;function ll(e){if(!Ym.test(e))return!1;return Hu(`http://[${e}]`)}var fl=m(\"$ZodIPv6\",(e,t)=>{t.pattern??(t.pattern=cu),I.init(e,t),e._zod.check=(r)=>{if(!ll(r.value))r.issues.push({code:\"invalid_format\",format:\"ipv6\",input:r.value,inst:e,continue:!t.abort})}});var pl=m(\"$ZodCIDRv4\",(e,t)=>{t.pattern??(t.pattern=au),I.init(e,t)});function Xm(e){let t=e.split(\"/\");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);if(`${o}`!==n)return!1;if(o<0||o>128)return!1;return ll(r)}var dl=m(\"$ZodCIDRv6\",(e,t)=>{t.pattern??(t.pattern=uu),I.init(e,t),e._zod.check=(r)=>{if(!Xm(r.value))r.issues.push({code:\"invalid_format\",format:\"cidrv6\",input:r.value,inst:e,continue:!t.abort})}});function hl(e){if(e===\"\")return!0;if(/\\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ds=/^[0-9a-zA-Z+/]*={0,2}$/,ml=m(\"$ZodBase64\",(e,t)=>{t.pattern??(t.pattern=Ds),I.init(e,t),e._zod.check=(r)=>{if(hl(r.value))return;r.issues.push({code:\"invalid_format\",format:\"base64\",input:r.value,inst:e,continue:!t.abort})}}),Bn=/^[A-Za-z0-9_-]*$/;function Qm(e){if(!Bn.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n===\"-\"?\"+\":\"/\"),r=t.padEnd(Math.ceil(t.length/4)*4,\"=\");return hl(r)}var gl=m(\"$ZodBase64URL\",(e,t)=>{t.pattern??(t.pattern=Bn),I.init(e,t),e._zod.check=(r)=>{if(Qm(r.value))return;r.issues.push({code:\"invalid_format\",format:\"base64url\",input:r.value,inst:e,continue:!t.abort})}}),yl=m(\"$ZodE164\",(e,t)=>{t.pattern??(t.pattern=du),I.init(e,t)});function eg(e,t=null){try{let r=e.split(\".\");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if(\"typ\"in o&&o?.typ!==\"JWT\")return!1;if(!o.alg)return!1;if(t&&(!(\"alg\"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var xl=m(\"$ZodJWT\",(e,t)=>{I.init(e,t),e._zod.check=(r)=>{if(eg(r.value,t.alg))return;r.issues.push({code:\"invalid_format\",format:\"jwt\",input:r.value,inst:e,continue:!t.abort})}});var Ns=m(\"$ZodNumber\",(e,t)=>{A.init(e,t),e._zod.pattern=Es,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let o=r.value;if(typeof o===\"number\"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o===\"number\"?Number.isNaN(o)?\"NaN\":!Number.isFinite(o)?String(o):void 0:void 0;return r.issues.push({expected:\"number\",code:\"invalid_type\",input:o,inst:e,...s?{received:s}:{}}),r}}),_l=m(\"$ZodNumberFormat\",(e,t)=>{ku.init(e,t),Ns.init(e,t)});var wl=m(\"$ZodUnknown\",(e,t)=>{A.init(e,t),e._zod.parse=(r)=>r}),bl=m(\"$ZodNever\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:\"never\",code:\"invalid_type\",input:r.value,inst:e}),r)});function tg(e,t){let r=ws(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map((s)=>s[0])),o=e._zod.parse;e._zod.parse=(s,i)=>{let c=t(s.value);if(c>n&&!i?.skipChecks&&i?.direction!==\"backward\"){for(let[a,l]of ws(e._zod.def.checks))if(c>a&&l._zod.def.when(s)){let u=s.issues.length;return l._zod.check(s),s.issues[u].continue=!1,In(s.issues,u,e),s}}return o(s,i)}}var rg=(e)=>Array.isArray(e)?e.length:-1;function Nu(e,t,r){if(e.issues.length)t.issues.push(...zn(r,e.issues));t.value[r]=e.value}var kl=m(\"$ZodArray\",(e,t)=>{A.init(e,t);let r=oe.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:\"array\",code:\"invalid_type\",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],c=o?.abortEarly;for(let a=0;a<s.length;a++){let l=s[a],u=t.element._zod.run({value:l,issues:[]},o);if(u instanceof Promise)i.push(u.then((f)=>Nu(f,n,a)));else if(Nu(u,n,a),c&&u.issues.length!==0&&Se(u))break}if(i.length)return Promise.all(i).then(()=>n);return n},tg(e,rg)});function jn(e,t,r,n,o,s){let i=r in n,c=s===\"optional\";if(!i&&c&&o===\"optional\")return;if(e.issues.length){if(o!==void 0&&c&&!i)return;t.issues.push(...zn(r,e.issues))}if(!i&&o===void 0){if(!e.issues.length)t.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:void 0,path:[r]});return}if(e.value===void 0){if(i||o===\"defaulted\"&&!c)t.value[r]=void 0}else t.value[r]=e.value}var ng=[];function vl(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:ng,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has(\"$ZodType\"))throw Error(`Invalid element at key \"${String(i)}\": expected a Zod schema`);let s=$a(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Sl(e,t,r,n,o,s,i){let c=[],a=o.keySet,l=o.catchall._zod,u=l.def.type,{optin:f,optout:p}=l,d=0;for(let h in t){if(i&&r.issues.length!==d){if(Se(r,d))break;d=r.issues.length}if(a.has(h))continue;if(h===\"__proto__\"){if(u===\"never\")c.push(h);continue}if(u===\"never\"){c.push(h);continue}let g=l.run({value:t[h],issues:[]},n);if(g instanceof Promise)e.push(g.then((x)=>jn(x,r,h,t,f,p)));else jn(g,r,h,t,f,p)}if(c.length)r.issues.push({code:\"unrecognized_keys\",keys:c,input:t,inst:s,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var og=m(\"$ZodObject\",(e,t)=>{A.init(e,t);let r=Object.getOwnPropertyDescriptor(t,\"shape\"),n=r?.get?r.get.raw:t.shape??{};if(n){let l=()=>{let u={...n};return Object.defineProperty(t,\"shape\",{value:u}),l.raw=u,u};l.raw=n,Object.defineProperty(t,\"shape\",{get:l})}let o=dr(()=>vl(t));k(e,\"propValues\",(l)=>{let u=l.def.shape,f={};for(let p in u){let d=u[p]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,p))ue(f,p,new Set);for(let h of d.values)f[p].add(h);if(d.optin!==void 0)f[p].add(void 0)}}return f});let s=zt,i=t.catchall,c,a=oe.memoizer;a?.attach(e),e._zod.parse=(l,u)=>{c??(c=o.value);let f=l.value;if(!s(f))return l.issues.push({expected:\"object\",code:\"invalid_type\",input:f,inst:e}),l;l.value=a?a.alloc(e,l,{},u):{};let p=[],d=c.shape,h=u?.abortEarly,g=l.issues.length;for(let x of c.allKeys){if(h&&l.issues.length!==g){if(Se(l,g))break;g=l.issues.length}if(x===\"__proto__\")continue;let S=d[x],de=S._zod.optin,Ct=S._zod.optout,Dt=S._zod.run({value:f[x],issues:[]},u);if(Dt instanceof Promise)p.push(Dt.then((P)=>jn(P,l,x,f,de,Ct)));else jn(Dt,l,x,f,de,Ct)}if(!i)return p.length?Promise.all(p).then(()=>l):l;return Sl(p,f,l,u,o.value,e,h===!0)}}),$l=m(\"$ZodObjectJIT\",(e,t)=>{og.init(e,t);let r=e._zod.parse,n=dr(()=>vl(t)),o=oe.memoizer,s=(d)=>{let h=n.value,g=h.symbolKeys,x=new Ps([\"payload\",\"ctx\"],{shape:d,inst:e,memo:o,syms:g}),S=(P)=>`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`,de=(P,z)=>`\n let ${P}_ab = false;\n for (let i = 0; i < ${P}.issues.length; i++) {\n const iss = ${P}.issues[i];\n iss.path = iss.path ? [${z}, ...iss.path] : [${z}];\n payload.issues.push(iss);\n if (iss.continue !== true) ${P}_ab = true;\n }\n if (${P}_ab && ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }`;x.write(\"const input = payload.value;\");let Ct=Object.create(null),Dt=0;for(let P of h.allKeys)Ct[P]=`key_${Dt++}`;x.write(o?\"const newResult = memo.alloc(inst, payload, {}, ctx);\":\"const newResult = {};\");for(let P of h.allKeys){if(P===\"__proto__\")continue;let z=Ct[P],he=typeof P===\"symbol\"?`syms[${g.indexOf(P)}]`:ba(P),ao=`${he} in input`,di=d[P],uo=di?._zod?.optin,hi=uo!==void 0,Fp=di?._zod?.optout===\"optional\";if(x.write(`const ${z} = ${S(he)};`),hi&&Fp){let Jp=uo===\"optional\"?`${z}_present`:`${z}.value !== undefined || ${z}_present`;x.write(`\n const ${z}_present = ${ao};\n if (!${z}.issues.length || ${z}_present) {\n if (${z}.issues.length) {${de(z,he)}\n }\n\n if (${Jp}) {\n newResult[${he}] = ${z}.value;\n }\n }\n\n `)}else if(!hi)x.write(`\n const ${z}_present = ${ao};\n if (${z}.issues.length) {${de(z,he)}\n }\n if (!${z}_present && !${z}.issues.length) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [${he}]\n });\n if (ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }\n }\n\n if (${z}_present) {\n newResult[${he}] = ${z}.value;\n }\n\n `);else if(x.write(`\n if (${z}.issues.length) {${de(z,he)}\n }\n `),uo===\"defaulted\")x.write(`newResult[${he}] = ${z}.value;`);else x.write(`\n if (${z}.value !== undefined || ${ao}) {\n newResult[${he}] = ${z}.value;\n }\n `)}return x.write(\"payload.value = newResult;\"),x.write(\"return payload;\"),x.compile()},i,c=zt,a=!oe.jitless,u=a&&va.value,f=t.catchall,p;e._zod.parse=(d,h)=>{p??(p=n.value);let g=d.value;if(!c(g))return d.issues.push({expected:\"object\",code:\"invalid_type\",input:g,inst:e}),d;if(a&&u&&h?.async===!1&&h.jitless!==!0){if(!i)i=s(t.shape);if(d=i(d,h),!f)return d;return Sl([],g,d,h,p,e,h?.abortEarly===!0)}return r(d,h)}});function Uu(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter((s)=>!Se(s));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:\"invalid_union\",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((i)=>Le(i,n,fe())))}),t}var Us=m(\"$ZodUnion\",(e,t)=>{A.init(e,t),k(e,\"optin\",(n)=>n.def.options.some((o)=>o._zod.optin===\"defaulted\")?\"defaulted\":n.def.options.some((o)=>o._zod.optin!==void 0)?\"optional\":void 0),k(e,\"optout\",(n)=>n.def.options.some((o)=>o._zod.optout===\"optional\")?\"optional\":void 0),k(e,\"values\",(n)=>{if(n.def.options.every((o)=>o._zod.values))return new Set(n.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),k(e,\"pattern\",(n)=>{if(n.def.options.every((o)=>o._zod.pattern)){let o=n.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${o.map((s)=>vn(s.source)).join(\"|\")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:n.value,issues:[]},o);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}if(!s)return Uu(i,n,e,o);return Promise.all(i).then((c)=>Uu(c,n,e,o))}});function sg(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw Error(`Invalid discriminated union option at index \"${e.options.indexOf(r)}\"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value \"${String(o)}\"`);t.set(o,null)}else t.set(o,r)}return t}var zl=m(\"$ZodDiscriminatedUnion\",(e,t)=>{t.inclusive=!1,Us.init(e,t);let r=e._zod.parse;k(e,\"propValues\",(o)=>{let s={},i=0;for(let c of o.def.options){let a=c._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index \"${o.def.options.indexOf(c)}\"`);if(a[o.def.discriminator]?.has(void 0))i++;for(let[l,u]of Object.entries(a)){if(!Object.prototype.hasOwnProperty.call(s,l))ue(s,l,new Set);for(let f of u)s[l].add(f)}}if(!o.def.unionFallback&&i>1)s[o.def.discriminator]?.delete(void 0);return s}),t.options.forEach((o,s)=>{let i=hr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index \"${s}\"`)});let n=dr(()=>sg(t));e._zod.parse=(o,s)=>{let i=o.value;if(!zt(i))return o.issues.push({code:\"invalid_type\",expected:\"object\",input:i,inst:e}),o;let c=i?.[t.discriminator],a=n.value.get(c);if(a&&(c!==void 0||s.direction!==\"backward\"))return a._zod.run(o,s);if(t.unionFallback||s.direction===\"backward\")return r(o,s);return o.issues.push({code:\"invalid_union\",errors:[],note:\"No matching discriminator\",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter((l)=>n.value.get(l)!==null),input:i,path:[t.discriminator],inst:e}),o}}),Il=m(\"$ZodIntersection\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([a,l])=>Ru(r,a,l));return Ru(r,s,i)}});function Zs(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(It(e)&&It(t)){let r=Object.keys(t),n=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,\"__proto__\"))delete o.__proto__;for(let s of n){if(s===\"__proto__\")continue;let i=Zs(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Zs(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Ru(e,t,r){let n=new Map,o,s=new Map,i=(l,u)=>{let f;if(l.code===\"unrecognized_keys\"&&!l.path?.length)o??(o=l),f=l.keys;else if(l.code===\"invalid_key\"&&l.origin===\"record\"&&l.path?.length===1){let p=String(l.path[0]);if(!s.has(p))s.set(p,l);f=[p]}else return!1;for(let p of f){if(!n.has(p))n.set(p,{});n.get(p)[u]=!0}return!0};for(let l of t.issues)if(!i(l,\"l\"))e.issues.push(l);for(let l of r.issues)if(!i(l,\"r\"))e.issues.push(l);let c=[...n].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(c.length){let l=o?c.filter((u)=>o.keys.includes(u)):[];if(l.length)e.issues.push({...o,keys:l});for(let u of c)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let a=Zs(t.value,r.value);if(!a.valid){if(Se(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}var El=m(\"$ZodEnum\",(e,t)=>{A.init(e,t);let r=fr(t.entries),n=new Set(r);e._zod.values=n,k(e,\"pattern\",(o)=>{let s=fr(o.def.entries).filter((i)=>Sa.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>je(i.toString())).join(\"|\")})$`:\"^[^\\\\s\\\\S]$\")}),e._zod.parse=(o,s)=>{let i=o.value;if(n.has(i))return o;return o.issues.push({code:\"invalid_value\",values:r,input:i,inst:e}),o}}),Al=m(\"$ZodLiteral\",(e,t)=>{A.init(e,t);let r=new Set(t.values);e._zod.values=r,k(e,\"pattern\",(n)=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map((s)=>typeof s===\"string\"?je(s):s?je(s.toString()):String(s)).join(\"|\")})$`:\"^[^\\\\s\\\\S]$\")}),e._zod.parse=(n,o)=>{let s=n.value;if(r.has(s))return n;return n.issues.push({code:\"invalid_value\",values:t.values,input:s,inst:e}),n}});var Ol=m(\"$ZodTransform\",(e,t)=>{A.init(e,t),e._zod.optin=\"optional\",oe.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")throw new mr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((i)=>(r.value=i,r));if(o instanceof Promise)throw new $e;return r.value=o,r}});function ju(e,t){return e.value=t.issues.length?void 0:t.value,e}var Rs=m(\"$ZodOptional\",(e,t)=>{A.init(e,t),k(e,\"optin\",(r)=>r.def.innerType._zod.optin===\"defaulted\"?\"defaulted\":\"optional\"),e._zod.optout=\"optional\",k(e,\"values\",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),k(e,\"pattern\",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${vn(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!==\"defaulted\")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>ju(r,s));return ju(r,o)}return t.innerType._zod.run(r,n)}}),Tl=m(\"$ZodExactOptional\",(e,t)=>{Rs.init(e,t),k(e,\"values\",(r)=>r.def.innerType._zod.values),k(e,\"pattern\",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Pl=m(\"$ZodNullable\",(e,t)=>{A.init(e,t),k(e,\"optin\",(r)=>r.def.innerType._zod.optin),k(e,\"optout\",(r)=>r.def.innerType._zod.optout),k(e,\"pattern\",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${vn(n.source)}|null)$`):void 0}),k(e,\"values\",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),Zl=m(\"$ZodDefault\",(e,t)=>{A.init(e,t),e._zod.optin=\"defaulted\",k(e,\"values\",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Lu(s,t));return Lu(o,t)}});function Lu(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Cl=m(\"$ZodPrefault\",(e,t)=>{A.init(e,t),e._zod.optin=\"defaulted\",k(e,\"values\",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),Dl=m(\"$ZodNonOptional\",(e,t)=>{A.init(e,t),k(e,\"values\",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Bu(s,e));return Bu(o,e)}});function Bu(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:e.value,inst:t});return e}function Mu(e,t,r,n){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>Le(o,n,fe()))},input:e.value}),e}var Nl=m(\"$ZodCatch\",(e,t)=>{A.init(e,t),k(e,\"optin\",(r)=>r.def.innerType._zod.optin===\"defaulted\"?\"defaulted\":\"optional\"),k(e,\"optout\",(r)=>r.def.innerType._zod.optout),k(e,\"values\",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>Mu(r,s,t,n));return Mu(r,o,t,n)}});var Ul=m(\"$ZodPipe\",(e,t)=>{A.init(e,t),k(e,\"values\",(r)=>r.def.in._zod.values),k(e,\"optin\",(r)=>r.def.in._zod.optin),k(e,\"optout\",(r)=>r.def.out._zod.optout),k(e,\"propValues\",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction===\"backward\"){let s=t.out._zod.run(r,n);if(s instanceof Promise)return s.then((i)=>Un(i,t.in,n));return Un(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Un(s,t.out,n));return Un(o,t.out,n)}});function Un(e,t,r){if(e.issues.some((n)=>n.code!==\"unrecognized_keys\"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var Rl=m(\"$ZodReadonly\",(e,t)=>{A.init(e,t),k(e,\"propValues\",(r)=>r.def.innerType._zod.propValues),k(e,\"values\",(r)=>r.def.innerType._zod.values),k(e,\"optin\",(r)=>r.def.innerType?._zod?.optin),k(e,\"optout\",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(Vu);return Vu(o)}});function Vu(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var jl=m(\"$ZodCustom\",(e,t)=>{L.init(e,t),A.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((s)=>Fu(s,r,n,e));Fu(o,r,n,e);return}});function Fu(e,t,r,n){if(!e){let o={code:\"custom\",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(rt(o))}}class Bl extends Error{constructor(){super(\"Cannot parse a reference cycle that closes through a transform\");this.name=\"ZodCyclicError\"}}var Ls=\"~memo\",Ll=[];function Ml(e){return e!==null&&typeof e===\"object\"}function js(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Vl=new WeakMap,xr=0,Fn=1,_r=2;function Jn(e,t,r){let n=Vl.get(e);if(n!==void 0)return n?_r:xr;if(t.has(e))return _r;t.add(e);let o=xr,s=(u)=>{if(o!==_r&&u?._zod){let f=Jn(u,t,r);if(f>o)o=f}},i=(u,f)=>{let p=xr;for(let d of Reflect.ownKeys(u)){let h=Object.getOwnPropertyDescriptor(u,d);if(f&&!h.enumerable)continue;let g=h.get?Fn:h.value?._zod?Jn(h.value,t,r):xr;if(g>p)p=g}return p},c=(u)=>{if(u>o)o=u},a=e._zod.def,l=a.type;switch(l){case\"object\":{let u=hr(a);c(u?i(u,!0):Fn),s(a.catchall);break}case\"array\":s(a.element);break;case\"tuple\":for(let u of a.items)s(u);s(a.rest);break;case\"record\":case\"map\":s(a.keyType),s(a.valueType);break;case\"set\":s(a.valueType);break;case\"union\":for(let u of a.options)s(u);break;case\"intersection\":s(a.left),s(a.right);break;case\"optional\":case\"nullable\":case\"default\":case\"prefault\":case\"catch\":case\"readonly\":case\"nonoptional\":case\"promise\":case\"success\":s(a.innerType);break;case\"pipe\":s(a.in),s(a.out);break;case\"function\":s(a.input),s(a.output);break;case\"lazy\":{let u=a._cachedInner??(r?e._zod.innerType:void 0);c(u?Jn(u,t,!1):Fn);break}case\"template_literal\":case\"string\":case\"number\":case\"int\":case\"boolean\":case\"bigint\":case\"symbol\":case\"undefined\":case\"null\":case\"void\":case\"never\":case\"any\":case\"unknown\":case\"date\":case\"nan\":case\"enum\":case\"literal\":case\"file\":case\"transform\":case\"custom\":break;default:for(let u in a){let f=Object.getOwnPropertyDescriptor(a,u);if(!f||f.get)continue;let p=f.value;if(!p||typeof p!==\"object\")continue;if(p._zod)s(p);else if(Array.isArray(p))for(let d of p)s(d)}}return t.delete(e),ig(e,o)}function ig(e,t){if(t!==Fn)Vl.set(e,t===_r);return t}function cg(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Mn,Vn=[],ag={alloc(e,t,r){let n=Mn;if(!n)return r;Mn=void 0;let o={value:r,issues:null};return n.set(t.value,o),Vn.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!==\"backward\"&&ug(s,o.value))throw new Bl;return r(o,s)};if(e._zod.parse=n,e._zod.run===r)e._zod.run=n})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,c=(a,l)=>{if(r===void 0){let S=Jn(e,new Set,!1);if(S===xr){if(e._zod.parse=i,e._zod.run===c)e._zod.run=i;return i(a,l)}if(S===_r||n)r=!0;else n=!0}let u=a.value;if(!Ml(u))return i(a,l);let f=l[Ls];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[Ls]=f;let p;if(o===l)p=s;else p=cg(f,e),o=l,s=p;let d=p.get(u);if(d){if(a.value=d.value,d.issues){if(d.issues.length)a.issues.push(...js(d.issues))}else a.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return a}Mn=p;let h=Vn.length,g=i(a,l);Mn=void 0;let x=Vn.length>h?Vn.pop():void 0;if(g instanceof Promise)return g.then((S)=>{if(x)x.issues=S.issues.length?js(S.issues):Ll;return S});if(x)x.issues=g.issues.length?js(g.issues):Ll;return g};if(e._zod.parse=c,e._zod.run===i)e._zod.run=c})}};function Fl(){return ag}function ug(e,t){let r=e[Ls]?.backEdges;return r!==void 0&&Ml(t)&&r.has(t)}var lg=()=>{let e={string:{unit:\"characters\",verb:\"to have\"},file:{unit:\"bytes\",verb:\"to have\"},array:{unit:\"items\",verb:\"to have\"},set:{unit:\"items\",verb:\"to have\"},map:{unit:\"entries\",verb:\"to have\"}};function t(s){return e[s]??null}let r={regex:\"input\",email:\"email address\",url:\"URL\",emoji:\"emoji\",uuid:\"UUID\",uuidv4:\"UUIDv4\",uuidv6:\"UUIDv6\",nanoid:\"nanoid\",guid:\"GUID\",cuid:\"cuid\",cuid2:\"cuid2\",ulid:\"ULID\",xid:\"XID\",ksuid:\"KSUID\",datetime:\"ISO datetime\",date:\"ISO date\",time:\"ISO time\",duration:\"ISO duration\",ipv4:\"IPv4 address\",ipv6:\"IPv6 address\",mac:\"MAC address\",cidrv4:\"IPv4 range\",cidrv6:\"IPv6 range\",base64:\"base64-encoded string\",base64url:\"base64url-encoded string\",json_string:\"JSON string\",e164:\"E.164 number\",currency_code:\"currency code\",credit_card:\"credit card number\",iban:\"IBAN\",jwt:\"JWT\",template_literal:\"input\"},n={nan:\"NaN\"};function o(s,i){if(s===\"number\"&&typeof i===\"number\"&&!Number.isFinite(i))return String(i);return n[s]??s}return(s)=>{switch(s.code){case\"invalid_type\":{let i=o(s.expected),c=Aa(s.input),a=o(c,s.input);return`Invalid input: expected ${i}, received ${a}`}case\"invalid_value\":if(s.values.length===1)return`Invalid input: expected ${xs(s.values[0])}`;return`Invalid option: expected one of ${ms(s.values,\"|\")}`;case\"too_big\":{let i=s.exact?\"exactly \":s.inclusive?\"<=\":\"<\",c=t(s.origin);if(c)return`Too big: expected ${s.origin??\"value\"} to have ${i}${s.maximum.toString()} ${c.unit??\"elements\"}`;return`Too big: expected ${s.origin??\"value\"} to be ${i}${s.maximum.toString()}`}case\"too_small\":{let i=s.exact?\"exactly \":s.inclusive?\">=\":\">\",c=t(s.origin);if(c)return`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${c.unit}`;return`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case\"invalid_format\":{let i=s;if(i.format===\"starts_with\")return`Invalid string: must start with \"${i.prefix}\"`;if(i.format===\"ends_with\")return`Invalid string: must end with \"${i.suffix}\"`;if(i.format===\"includes\")return`Invalid string: must include \"${i.includes}\"`;if(i.format===\"regex\")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??s.format}`}case\"not_multiple_of\":return`Invalid number: must be a multiple of ${s.divisor}`;case\"unrecognized_keys\":return`Unrecognized key${s.keys.length>1?\"s\":\"\"}: ${ms(s.keys,\", \")}`;case\"invalid_key\":return`Invalid key in ${s.origin}`;case\"invalid_union\":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((c)=>`'${c}'`).join(\" | \")}`;if(s.inclusive===!1)return\"Invalid input: more than one option matched\";return\"Invalid input\";case\"invalid_element\":return`Invalid value in ${s.origin}`;default:return\"Invalid input\"}}};function Bs(){return{localeError:lg()}}var Jl;class Kl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r===\"object\"&&\"id\"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t===\"object\"&&\"id\"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function fg(){return new Kl}(Jl=globalThis).__zod_globalRegistry??(Jl.__zod_globalRegistry=fg());var nt=globalThis.__zod_globalRegistry;function ql(e){if(e.checks)e.checks=[...e.checks];return e}function Gl(e,t){return new e(ql({type:\"string\",...y(t)}))}function Wl(e,t){return new e({type:\"string\",format:\"email\",check:\"string_format\",abort:!1,...y(t)})}function Hl(e,t){return new e({type:\"string\",format:\"guid\",check:\"string_format\",abort:!1,...y(t)})}function Yl(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,...y(t)})}function Xl(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v4\",...y(t)})}function Ql(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v6\",...y(t)})}function ef(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v7\",...y(t)})}function tf(e,t){return new e({type:\"string\",format:\"url\",check:\"string_format\",abort:!1,...y(t)})}function rf(e,t){return new e({type:\"string\",format:\"emoji\",check:\"string_format\",abort:!1,...y(t)})}function nf(e,t){return new e({type:\"string\",format:\"nanoid\",check:\"string_format\",abort:!1,...y(t)})}function of(e,t){return new e({type:\"string\",format:\"cuid\",check:\"string_format\",abort:!1,...y(t)})}function sf(e,t){return new e({type:\"string\",format:\"cuid2\",check:\"string_format\",abort:!1,...y(t)})}function cf(e,t){return new e({type:\"string\",format:\"ulid\",check:\"string_format\",abort:!1,...y(t)})}function af(e,t){return new e({type:\"string\",format:\"xid\",check:\"string_format\",abort:!1,...y(t)})}function uf(e,t){return new e({type:\"string\",format:\"ksuid\",check:\"string_format\",abort:!1,...y(t)})}function lf(e,t){return new e({type:\"string\",format:\"ipv4\",check:\"string_format\",abort:!1,...y(t)})}function ff(e,t){return new e({type:\"string\",format:\"ipv6\",check:\"string_format\",abort:!1,...y(t)})}function pf(e,t){return new e({type:\"string\",format:\"cidrv4\",check:\"string_format\",abort:!1,...y(t)})}function df(e,t){return new e({type:\"string\",format:\"cidrv6\",check:\"string_format\",abort:!1,...y(t)})}function hf(e,t){return new e({type:\"string\",format:\"base64\",check:\"string_format\",abort:!1,...y(t)})}function mf(e,t){return new e({type:\"string\",format:\"base64url\",check:\"string_format\",abort:!1,...y(t)})}function gf(e,t){return new e({type:\"string\",format:\"e164\",check:\"string_format\",abort:!1,...y(t)})}function yf(e,t){return new e({type:\"string\",format:\"jwt\",check:\"string_format\",abort:!1,...y(t)})}function xf(e,t){return new e({type:\"string\",format:\"datetime\",check:\"string_format\",offset:!1,local:!1,precision:null,...y(t)})}function _f(e,t){return new e({type:\"string\",format:\"date\",check:\"string_format\",...y(t)})}function wf(e,t){return new e({type:\"string\",format:\"time\",check:\"string_format\",precision:null,...y(t)})}function bf(e,t){return new e({type:\"string\",format:\"duration\",check:\"string_format\",...y(t)})}function kf(e,t){return new e(ql({type:\"number\",checks:[],...y(t)}))}function vf(e,t){return new e({type:\"number\",check:\"number_format\",abort:!1,format:\"safeint\",...y(t)})}function Sf(e){return new e({type:\"unknown\"})}function $f(e,t){return new e({type:\"never\",...y(t)})}function Kn(e,t){return new Os({check:\"less_than\",...y(t),value:e,inclusive:!1})}function wr(e,t){return new Os({check:\"less_than\",...y(t),value:e,inclusive:!0})}function qn(e,t){return new Ts({check:\"greater_than\",...y(t),value:e,inclusive:!1})}function br(e,t){return new Ts({check:\"greater_than\",...y(t),value:e,inclusive:!0})}function Gn(e,t){return new bu({check:\"multiple_of\",...y(t),value:e})}function Wn(e,t){return new vu({check:\"max_length\",...y(t),maximum:e})}function Et(e,t){return new Su({check:\"min_length\",...y(t),minimum:e})}function Hn(e,t){return new $u({check:\"length_equals\",...y(t),length:e})}function Ms(e,t){return new zu({check:\"string_format\",format:\"regex\",...y(t),pattern:e})}function Vs(e){return new Iu({check:\"string_format\",format:\"lowercase\",...y(e)})}function Fs(e){return new Eu({check:\"string_format\",format:\"uppercase\",...y(e)})}function Js(e,t){return new Au({check:\"string_format\",format:\"includes\",...y(t),includes:e})}function Ks(e,t){return new Ou({check:\"string_format\",format:\"starts_with\",...y(t),prefix:e})}function qs(e,t){return new Tu({check:\"string_format\",format:\"ends_with\",...y(t),suffix:e})}function Be(e){return new Pu({check:\"overwrite\",tx:e})}function Gs(e){return Be((t)=>t.normalize(e))}function Ws(){return Be((e)=>e.trim())}function Hs(){return Be((e)=>e.toLowerCase())}function Ys(){return Be((e)=>e.toUpperCase())}function Xs(){return Be((e)=>ka(e))}function zf(e,t,r){return new e({type:\"array\",element:t,...y(r)})}function If(e,t,r){return new e({type:\"custom\",check:\"custom\",fn:t,...y(r)})}function Ef(e,t){let r=pg((n)=>(n.addIssue=(o)=>{if(typeof o===\"string\")n.issues.push(rt(o,n.value,r._zod.def));else{let s=o;if(s.fatal)s.continue=!1;if(s.code??(s.code=\"custom\"),!(\"input\"in s))s.input=n.value;s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(rt(s))}},e(n.value,n)),t);return r}function pg(e,t){let r=new L({check:\"custom\",...y(t)});return r._zod.check=e,r}function kr(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))ue(e,n,r[n]);return e}function ei(e){let t=e?.target??\"draft-2020-12\";if(t===\"draft-4\")t=\"draft-04\";if(t===\"draft-7\")t=\"draft-07\";return{processors:e.processors??{},metadataRegistry:e?.metadata??nt,target:t,unrepresentable:e?.unrepresentable??\"throw\",override:e?.override??(()=>{}),io:e?.io??\"output\",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??\"ref\",reused:e?.reused??\"inline\",intersections:[],deferred:[],external:e?.external??void 0}}function Ze(e,t,r,n,o){let s=typeof t.unrepresentable===\"function\"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s===\"any\")return!1;if(s===void 0||s===\"throw\")throw Error(o);return Object.assign(r,s),!0}function j(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,u);else{let p=i.schema,d=t.processors[o.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);d(e,t,p,u)}let f=e._zod.parent;if(f){if(!i.ref)i.ref=f;j(f,t,u),t.seen.get(f).isParent=!0}}let a=t.metadataRegistry.get(e);if(a)kr(i.schema,a);if(t.io===\"input\"&&G(e))delete i.schema.examples,delete i.schema.default;if(t.io===\"input\"&&\"_prefault\"in i.schema)(n=i.schema).default??(n.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function Af(e){return e.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}function ti(e,t){let r=e.seen.get(t);if(!r)throw Error(\"Unprocessed schema. This is a bug in Zod.\");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=n.get(c);if(a&&a!==i[0])throw Error(`Duplicate schema id \"${c}\" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,i[0])}}let o=(i)=>{let c=e.target===\"draft-2020-12\"?\"$defs\":\"definitions\";if(e.external){let f=e.external.registry.get(i[0])?.id,p=e.external.uri??((h)=>h);if(f)return{ref:p(f)};let d=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=d,{defId:d,ref:`${p(\"__shared\")}#/${c}/${Af(d)}`}}let a=\"#\",l=`${a}/${c}/`;if(i[1]===r&&!i[1].schema.id)return{ref:a};let u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Af(u)}},s=(i)=>{if(i[1].schema.$ref)return;let c=i[1],{ref:a,defId:l}=o(i);if(c.def={...c.schema},l)c.defId=l;let u=c.schema;for(let f in u)delete u[f];u.$ref=a};if(e.cycles===\"throw\")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join(\"/\")}/<root>\n\nSet the \\`cycles\\` parameter to \\`\"ref\"\\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1){if(e.reused===\"ref\")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Pf(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!==\"object\")return;Pf(n);let o=Object.keys(n);if(o.length!==1||o[0]!==\"type\")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!==\"string\")return;if(!r.includes(i))r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Zf=new Set([\"type\",\"properties\",\"required\",\"additionalProperties\"]),Of=[\"oneOf\",\"anyOf\"];function Tf(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!==\"object\"||t===null)return null;return Object.keys(t).length?t:null}function Qs(e){let t=[];for(let s of e){if(typeof s!==\"object\"||s.type!==\"object\")return null;for(let i in s)if(!Zf.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let c=[];for(let l of t){let u=l.properties?.[i]??Tf(l);if(u===null||u===void 0)continue;if(!c.some((f)=>JSON.stringify(f)===JSON.stringify(u)))c.push(u)}let a=c.length===1?c[0]:Qs(c)??{allOf:c};ue(r,i,a)}for(let i of s.required??[])n.add(i)}let o={type:\"object\",properties:r};if(n.size)o.required=[...n];if(t.every((s)=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let c=Tf(i);if(c&&!s.some((a)=>JSON.stringify(a)===JSON.stringify(c)))s.push(c)}if(s.length===1)o.additionalProperties=s[0];else if(s.length>1)o.additionalProperties={allOf:s}}return o}function dg(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Zf)if(o in e)return;let r=t.filter((o)=>Of.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=Qs(t);else{let o=r[0],s=Of.find((a)=>Array.isArray(o[a]));if(Object.keys(o).length!==1)return;let i=t.filter((a)=>a!==o),c=o[s].map((a)=>Qs([...i,a]));if(c.some((a)=>!a))return;n={[s]:c}}if(!n)return;delete e.allOf,kr(e,n)}function ri(e,t){let r=e.seen.get(t);if(!r)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let n=(c)=>{let a=e.seen.get(c);if(a.ref===null)return;let l=a.def??a.schema,u={...l},f=a.ref;if(a.ref=null,f){n(f);let d=e.seen.get(f),h=d.schema;if(h.$ref&&(e.target===\"draft-07\"||e.target===\"draft-04\"||e.target===\"openapi-3.0\"))l.allOf=l.allOf??[],l.allOf.push(h);else kr(l,h);if(kr(l,u),c._zod.parent===f)for(let x in l){if(x===\"$ref\"||x===\"allOf\")continue;if(!(x in u))delete l[x]}if(h.$ref&&d.def)for(let x in l){if(x===\"$ref\"||x===\"allOf\")continue;if(x in d.def&&JSON.stringify(l[x])===JSON.stringify(d.def[x]))delete l[x]}}let p=c._zod.parent;if(p&&p!==f){n(p);let d=e.seen.get(p);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let h in l){if(h===\"$ref\"||h===\"allOf\")continue;if(h in d.def&&JSON.stringify(l[h])===JSON.stringify(d.def[h]))delete l[h]}}}e.override({zodSchema:c,jsonSchema:l,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())n(c[0]);if(e.target!==\"openapi-3.0\")for(let c of e.seen.entries())Pf(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let a of e.seen.values())for(let l of[a.schema,a.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=c.get(u);if(f)f.push(l);else c.set(u,[l])}for(let a of e.intersections)for(let l of c.get(a)??[])dg(l)}}let o={};if(e.target===\"draft-2020-12\")o.$schema=\"https://json-schema.org/draft/2020-12/schema\";else if(e.target===\"draft-07\")o.$schema=\"http://json-schema.org/draft-07/schema#\";else if(e.target===\"draft-04\")o.$schema=\"http://json-schema.org/draft-04/schema#\";else if(e.target===\"openapi-3.0\");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error(\"Schema is missing an `id` property\");o.$id=e.external.uri(c)}kr(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let a=c[1];if(a.def&&a.defId){if(a.def.id===a.defId)delete a.def.id;ue(i,a.defId,a.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target===\"draft-2020-12\")o.$defs=i;else o.definitions=i;try{let c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,\"~standard\",{value:{...t[\"~standard\"],jsonSchema:{input:vr(t,\"input\",e.processors),output:vr(t,\"output\",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error(\"Error converting schema to JSON.\")}}function G(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type===\"transform\")return!0;if(n.type===\"array\")return G(n.element,r);if(n.type===\"set\")return G(n.valueType,r);if(n.type===\"lazy\")return G(n.getter(),r);if(n.type===\"promise\"||n.type===\"optional\"||n.type===\"nonoptional\"||n.type===\"nullable\"||n.type===\"readonly\"||n.type===\"default\"||n.type===\"prefault\"||n.type===\"catch\")return G(n.innerType,r);if(n.type===\"intersection\")return G(n.left,r)||G(n.right,r);if(n.type===\"record\"||n.type===\"map\")return G(n.keyType,r)||G(n.valueType,r);if(n.type===\"pipe\"){if(e._zod.traits.has(\"$ZodCodec\"))return!0;return G(n.in,r)||G(n.out,r)}if(n.type===\"object\"){for(let o in n.shape)if(G(n.shape[o],r))return!0;return!1}if(n.type===\"union\"){for(let o of n.options)if(G(o,r))return!0;return!1}if(n.type===\"tuple\"){for(let o of n.items)if(G(o,r))return!0;if(n.rest&&G(n.rest,r))return!0;return!1}return!1}var Cf=(e,t={})=>(r)=>{let n=ei({...r,processors:t});return j(e,n),ti(n,e),ri(n,e)},vr=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=ei({...o??{},target:s,io:t,processors:r});return j(e,i),ti(i,e),ri(i,e)};var At=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},Ot=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Df=(e,t)=>{At(e,\"minimum\",t),Ot(e,\"maximum\",t)},jf=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Lf=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Bf=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Mf=(e,t)=>{if(e.format=t,t.includes(\"int\"))e.isInt=!0},Nf=(e,t)=>At(e,\"minimum\",t.minimum),Uf=(e,t)=>Ot(e,\"maximum\",t.maximum),Rf=(e)=>(t,r)=>{Mf(t,r.format);let[n,o]=e[r.format];At(t,\"minimum\",n),Ot(t,\"maximum\",o)},hg={greater_than:(e,t)=>At(e,t.inclusive?\"minimum\":\"exclusiveMinimum\",t.value),less_than:(e,t)=>Ot(e,t.inclusive?\"maximum\":\"exclusiveMaximum\",t.value),multiple_of:(e,t)=>jf(e,t.value),number_format:Rf(Sn),bigint_format:Rf(_s),min_length:Nf,max_length:Uf,length_equals:(e,t)=>Df(e,t.length),min_size:Nf,max_size:Uf,size_equals:(e,t)=>Df(e,t.size),string_format:(e,t)=>{if(Mf(e,t.format),t.pattern)Lf(e,t.pattern);if(t.format===\"base64\"||t.format===\"base64url\")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>Bf(e,t.mime)};function pe(e){let t={},r=e._zod.def,n=e._zod.traits.has(\"$ZodCheck\")?[e,...r.checks??[]]:r.checks??[];for(let s of n)hg[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)At(t,\"minimum\",o.minimum);if(o.exclusiveMinimum!==void 0)At(t,\"exclusiveMinimum\",o.exclusiveMinimum);if(o.maximum!==void 0)Ot(t,\"maximum\",o.maximum);if(o.exclusiveMaximum!==void 0)Ot(t,\"exclusiveMaximum\",o.exclusiveMaximum);if(o.multipleOf!==void 0)jf(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes(\"int\"))t.isInt=!0}if(o.mime)Bf(t,o.mime);for(let s of o.patterns??[])Lf(t,s);return t}var mg={guid:\"uuid\",url:\"uri\",datetime:\"date-time\",json_string:\"json-string\",regex:\"\"},gg=new Map([[Ds,lu],[Bn,fu]]),yg=(e)=>gg.get(e)??e,Vf=(e,t,r,n)=>{let o=r;o.type=\"string\";let{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:l,laxFormat:u}=pe(e);if(typeof s===\"number\")o.minLength=s;if(typeof i===\"number\")o.maxLength=i;if(c){if(o.format=mg[c]??c,o.format===\"\")delete o.format;if(c===\"time\"||u)delete o.format}if(l)o.contentEncoding=l;if(a&&a.size>0){let f=[...a].map(yg);if(f.length===1)o.pattern=f[0].source;else if(f.length>1)o.allOf=[...f.map((p)=>({...t.target===\"draft-07\"||t.target===\"draft-04\"||t.target===\"openapi-3.0\"?{type:\"string\"}:{},pattern:p.source}))]}},Ff=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:c,exclusiveMaximum:a,exclusiveMinimum:l,isInt:u}=pe(e);o.type=u?\"integer\":\"number\";let f=typeof l===\"number\"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof a===\"number\"&&a<=(i??Number.POSITIVE_INFINITY),d=t.target===\"draft-04\"||t.target===\"openapi-3.0\";if(f)if(d)o.minimum=l,o.exclusiveMinimum=!0;else o.exclusiveMinimum=l;else if(typeof s===\"number\")o.minimum=s;if(p)if(d)o.maximum=a,o.exclusiveMaximum=!0;else o.exclusiveMaximum=a;else if(typeof i===\"number\")o.maximum=i;if(c){let h=new Set;for(let S of c)if(Number.isFinite(S)&&S!==0)h.add(Math.abs(S));else Ze(e,t,o,n,`A multipleOf divisor of ${S} cannot be represented in JSON Schema`);let[g,...x]=h;if(g!==void 0)o.multipleOf=g;if(x.length)o.allOf=[...o.allOf??[],...x.map((S)=>({multipleOf:S}))]}};var Jf=(e,t,r,n)=>{r.not={}};var Kf=(e,t,r,n)=>{};var qf=(e,t,r,n)=>{let o=e._zod.def,s=fr(o.entries);if(s.length===0){r.not={};return}if(s.every((i)=>typeof i===\"number\"))r.type=\"number\";if(s.every((i)=>typeof i===\"string\"))r.type=\"string\";r.enum=s},Gf=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Ze(e,t,r,n,\"Literal `undefined` cannot be represented in JSON Schema\"))return}else if(typeof i===\"bigint\"){if(Ze(e,t,r,n,\"BigInt literals cannot be represented in JSON Schema\"))return;s.push(Number(i))}else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(r.type=i===null?\"null\":typeof i,t.target===\"draft-04\"||t.target===\"openapi-3.0\")r.enum=[i];else r.const=i}else{if(s.every((i)=>typeof i===\"number\"))r.type=\"number\";if(s.every((i)=>typeof i===\"string\"))r.type=\"string\";if(s.every((i)=>typeof i===\"boolean\"))r.type=\"boolean\";if(s.every((i)=>i===null))r.type=\"null\";r.enum=s}};var Wf=(e,t,r,n)=>{Ze(e,t,r,n,\"Custom types cannot be represented in JSON Schema\")};var Hf=(e,t,r,n)=>{Ze(e,t,r,n,\"Transforms cannot be represented in JSON Schema\")};var Yf=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:c}=pe(e);if(typeof i===\"number\")o.minItems=i;if(typeof c===\"number\")o.maxItems=c;o.type=\"array\",o.items=j(s.element,t,{...n,path:[...n.path,\"items\"]})};function ni(e){let t=e._zod.def;if(t.type===\"pipe\"&&t.in._zod.traits.has(\"$ZodTransform\"))return ni(t.out);if(t.type===\"catch\")return ni(t.innerType);return e._zod.optin}var Xf=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Ze(e,t,o,n,\"Symbol keys cannot be represented in JSON Schema\"))return;o.type=\"object\",o.properties={};for(let l in i)ue(o.properties,l,j(i[l],t,{...n,path:[...n.path,\"properties\",l]}));let a=[];for(let l of Object.keys(i)){let u=s.shape[l];if(t.io===\"input\"?ni(u)===void 0:u._zod.optout===void 0)a.push(l)}if(a.length>0)o.required=a;if(s.catchall?._zod.def.type===\"never\")o.additionalProperties=!1;else if(!s.catchall){if(t.io===\"output\")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=j(s.catchall,t,{...n,path:[...n.path,\"additionalProperties\"]})},Qf=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((c,a)=>j(c,t,{...n,path:[...n.path,s?\"oneOf\":\"anyOf\",a]}));if(s)r.oneOf=i;else r.anyOf=i},ep=(e,t,r,n)=>{let o=e._zod.def,s=j(o.left,t,{...n,path:[...n.path,\"allOf\",0]}),i=j(o.right,t,{...n,path:[...n.path,\"allOf\",1]}),c=(l)=>(\"allOf\"in l)&&Object.keys(l).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];r.allOf=a,t.intersections.push(a)};var tp=(e,t,r,n)=>{let o=e._zod.def,s=j(o.innerType,t,n),i=t.seen.get(e);if(t.target===\"openapi-3.0\")i.ref=o.innerType,r.nullable=!0;else r.anyOf=[s,{type:\"null\"}]},rp=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},oi=Symbol();function np(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(c,a)=>{if(typeof a!==\"bigint\")return a;return s=!0,null});if(!s)return JSON.parse(i);return Ze(t,r,n,o,\"BigInt defaults cannot be represented in JSON Schema\"),oi}var op=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=np(o.defaultValue,e,t,r,n);if(i!==oi)r.default=i},sp=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!==\"input\")return;let i=np(o.defaultValue,e,t,r,n);if(i!==oi)r._prefault=i},ip=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Ze(e,t,r,n,\"Dynamic catch values are not supported in JSON Schema\");return}r.default=i},cp=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has(\"$ZodTransform\"),i=t.io===\"input\"?s?o.out:o.in:o.out;j(i,t,n);let c=t.seen.get(e);c.ref=i},ap=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var si=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var up=new WeakSet([Object.prototype,Error.prototype]);function Yn(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var $g=(e,t)=>{Ua.init(e,t),e.name=\"ZodError\";let r=Object.getPrototypeOf(e);if(up.has(r))return;up.add(r),Yn(r,\"format\",(n)=>(o)=>ja(n,o)),Yn(r,\"flatten\",(n)=>(o)=>Ra(n,o)),Yn(r,\"addIssue\",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,pr,2)}),Yn(r,\"addIssues\",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,pr,2)}),Object.defineProperty(r,\"isEmpty\",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var se=m(\"ZodError\",$g,void 0,{Parent:Error});var lp=Pn(se),fp=Zn(se),pp=Cn(se),dp=Dn(se),hp=Ba(se),mp=Ma(se),gp=Va(se),yp=Fa(se),xp=Ja(se),_p=Ka(se),wp=qa(se),bp=Ga(se);function Ig(){if(!oe.localeError)fe(Bs())}function ai(){if(!oe.memoizer)fe({memoizer:Fl()})}var O=m(\"ZodType\",(e,t)=>(Ig(),A.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ne(t,{checks:[...t.checks??[],...e.map((r)=>typeof r===\"function\"?{_zod:{check:r,def:{check:\"custom\"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ve(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(vy(e,t))},superRefine(e,t){return this.check(Sy(e,t))},overwrite(e){return this.check(Be(e))},optional(){return vp(this)},exactOptional(){return ly(this)},nullable(){return Sp(this)},nullish(){return vp(Sp(this))},nonoptional(e){return gy(this,e)},array(){return Sr(this)},or(e){return li([this,e])},and(e){return sy(this,e)},transform(e){return $p(this,uy(e))},default(e){return dy(this,e)},prefault(e){return my(this,e)},catch(e){return xy(this,e)},pipe(e){return $p(this,e)},readonly(){return by(this)},describe(e){let t=this.clone();return nt.add(t,{description:e}),t},meta(...e){if(e.length===0)return nt.get(this);let t=this.clone();return nt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get \"~standard\"(){return On(this,\"~standard\",{...Cs(this),jsonSchema:{input:vr(this,\"input\"),output:vr(this,\"output\")}})},set \"~standard\"(e){Pe(this,\"~standard\",e)},parse:function e(t,r){return lp(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await fp(this,t,r,{callee:e})},safeParse(e,t){return pp(this,e,t)},async safeParseAsync(e,t){return dp(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Pe(this,\"spa\",e)},validate(e,t){return Ss(this,e,t)},validateAsync(e,t){return $s(this,e,t)},encode:function e(t,r){return hp(this,t,r,{callee:e})},decode:function e(t,r){return mp(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await gp(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await yp(this,t,r,{callee:e})},safeEncode(e,t){return xp(this,e,t)},safeDecode(e,t){return _p(this,e,t)},async safeEncodeAsync(e,t){return wp(this,e,t)},async safeDecodeAsync(e,t){return bp(this,e,t)},toJSONSchema(e){return Cf(this,{})(e)},get description(){return nt.get(this)?.description},get _def(){return this._zod.def}}),zp=m(\"_ZodString\",(e,t)=>{Ln.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vf(e,r,n,o)},Ta({format:(e)=>pe(e).format??null,minLength:(e)=>pe(e).minimum??null,maxLength:(e)=>pe(e).maximum??null},{regex(...e){return this.check(Ms(...e))},includes(...e){return this.check(Js(...e))},startsWith(...e){return this.check(Ks(...e))},endsWith(...e){return this.check(qs(...e))},min(...e){return this.check(Et(...e))},max(...e){return this.check(Wn(...e))},length(...e){return this.check(Hn(...e))},nonempty(...e){return this.check(Et(1,...e))},lowercase(e){return this.check(Vs(e))},uppercase(e){return this.check(Fs(e))},trim(){return this.check(Ws())},normalize(...e){return this.check(Gs(...e))},toLowerCase(){return this.check(Hs())},toUpperCase(){return this.check(Ys())},slugify(){return this.check(Xs())}})),Eg=m(\"ZodString\",(e,t)=>{Ln.init(e,t),zp.init(e,t)},{email(e){return this.check(Wl(Zg,e))},url(e){return this.check(tf(Dg,e))},jwt(e){return this.check(yf(Hg,e))},emoji(e){return this.check(rf(Ng,e))},guid(e){return this.check(Hl(Cg,e))},uuid(e){return this.check(Yl(Xn,e))},uuidv4(e){return this.check(Xl(Xn,e))},uuidv6(e){return this.check(Ql(Xn,e))},uuidv7(e){return this.check(ef(Xn,e))},nanoid(e){return this.check(nf(Ug,e))},cuid(e){return this.check(of(Rg,e))},cuid2(e){return this.check(sf(jg,e))},ulid(e){return this.check(cf(Lg,e))},base64(e){return this.check(hf(qg,e))},base64url(e){return this.check(mf(Gg,e))},xid(e){return this.check(af(Bg,e))},ksuid(e){return this.check(uf(Mg,e))},ipv4(e){return this.check(lf(Vg,e))},ipv6(e){return this.check(ff(Fg,e))},cidrv4(e){return this.check(pf(Jg,e))},cidrv6(e){return this.check(df(Kg,e))},e164(e){return this.check(gf(Wg,e))},datetime(e){return this.check(xf(Ag,e))},date(e){return this.check(_f(Og,e))},time(e){return this.check(wf(Tg,e))},duration(e){return this.check(bf(Pg,e))}});function ui(e){return Gl(Eg,e)}var E=m(\"ZodStringFormat\",(e,t)=>{I.init(e,t),zp.init(e,t)}),Ag=m(\"ZodISODateTime\",(e,t)=>{sl.init(e,t),E.init(e,t)}),Og=m(\"ZodISODate\",(e,t)=>{il.init(e,t),E.init(e,t)}),Tg=m(\"ZodISOTime\",(e,t)=>{cl.init(e,t),E.init(e,t)}),Pg=m(\"ZodISODuration\",(e,t)=>{al.init(e,t),E.init(e,t)}),Zg=m(\"ZodEmail\",(e,t)=>{Gu.init(e,t),E.init(e,t)});var Cg=m(\"ZodGUID\",(e,t)=>{Ku.init(e,t),E.init(e,t)});var Xn=m(\"ZodUUID\",(e,t)=>{qu.init(e,t),E.init(e,t)});var Dg=m(\"ZodURL\",(e,t)=>{Yu.init(e,t),E.init(e,t)});var Ng=m(\"ZodEmoji\",(e,t)=>{Xu.init(e,t),E.init(e,t)});var Ug=m(\"ZodNanoID\",(e,t)=>{Qu.init(e,t),E.init(e,t)});var Rg=m(\"ZodCUID\",(e,t)=>{el.init(e,t),E.init(e,t)});var jg=m(\"ZodCUID2\",(e,t)=>{tl.init(e,t),E.init(e,t)});var Lg=m(\"ZodULID\",(e,t)=>{rl.init(e,t),E.init(e,t)});var Bg=m(\"ZodXID\",(e,t)=>{nl.init(e,t),E.init(e,t)});var Mg=m(\"ZodKSUID\",(e,t)=>{ol.init(e,t),E.init(e,t)});var Vg=m(\"ZodIPv4\",(e,t)=>{ul.init(e,t),E.init(e,t)});var Fg=m(\"ZodIPv6\",(e,t)=>{fl.init(e,t),E.init(e,t)});var Jg=m(\"ZodCIDRv4\",(e,t)=>{pl.init(e,t),E.init(e,t)});var Kg=m(\"ZodCIDRv6\",(e,t)=>{dl.init(e,t),E.init(e,t)});var qg=m(\"ZodBase64\",(e,t)=>{ml.init(e,t),E.init(e,t)});var Gg=m(\"ZodBase64URL\",(e,t)=>{gl.init(e,t),E.init(e,t)});var Wg=m(\"ZodE164\",(e,t)=>{yl.init(e,t),E.init(e,t)});var Hg=m(\"ZodJWT\",(e,t)=>{xl.init(e,t),E.init(e,t)});var Ip=m(\"ZodNumber\",(e,t)=>{Ns.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ff(e,r,n,o),e.isFinite=!0},Ta({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=pe(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=pe(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=pe(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>pe(e).format??null},{gt(e,t){return this.check(qn(e,t))},gte(e,t){return this.check(br(e,t))},min(e,t){return this.check(br(e,t))},lt(e,t){return this.check(Kn(e,t))},lte(e,t){return this.check(wr(e,t))},max(e,t){return this.check(wr(e,t))},int(e){return this.check(kp(e))},safe(e){return this.check(kp(e))},positive(e){return this.check(qn(0,e))},nonnegative(e){return this.check(br(0,e))},negative(e){return this.check(Kn(0,e))},nonpositive(e){return this.check(wr(0,e))},multipleOf(e,t){return this.check(Gn(e,t))},step(e,t){return this.check(Gn(e,t))},finite(){return this}}));function Tt(e){return kf(Ip,e)}var Yg=m(\"ZodNumberFormat\",(e,t)=>{_l.init(e,t),Ip.init(e,t)});function kp(e){return vf(Yg,e)}var Xg=m(\"ZodUnknown\",(e,t)=>{wl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kf(e,r,n,o)});function Qn(){return Sf(Xg)}var Qg=m(\"ZodNever\",(e,t)=>{bl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jf(e,r,n,o)});function ey(e){return $f(Qg,e)}var ty=m(\"ZodArray\",(e,t)=>{ai(),kl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yf(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Et(e,t))},nonempty(e){return this.check(Et(1,e))},max(e,t){return this.check(Wn(e,t))},length(e,t){return this.check(Hn(e,t))},unwrap(){return this.element}});function Sr(e,t){return zf(ty,e,t)}var ry=m(\"ZodObject\",(e,t)=>{ai(),$l.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xf(e,r,n,o),Pm(e,\"shape\",(r)=>r._zod.def.shape,!1)},{keyof(){return iy(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ne(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ne(this._zod.def,{catchall:Qn()}))},loose(){return this.clone(ne(this._zod.def,{catchall:Qn()}))},strict(){return this.clone(ne(this._zod.def,{catchall:ey()}))},strip(){return this.clone(ne(this._zod.def,{catchall:void 0}))},extend(e){return Sm(this,e)},safeExtend(e){return $m(this,e)},merge(e){return zm(this,e)},pick(e){return km(this,e)},omit(e){return vm(this,e)},partial(...e){return Ia(Op,this,e[0])},exactPartial(...e){return Ia(Tp,this,e[0],\"exactPartial\")},required(...e){return Im(Pp,this,e[0])}});function Pt(e,t){let r={type:\"object\",shape:e??{},...y(t)};return new ry(r)}var Ep=m(\"ZodUnion\",(e,t)=>{Us.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qf(e,r,n,o),e.options=t.options});function li(e,t){return new Ep({type:\"union\",options:e,...y(t)})}var ny=m(\"ZodDiscriminatedUnion\",(e,t)=>{Ep.init(e,t),zl.init(e,t)});function Ap(e,t,r){return new ny({type:\"union\",options:t,discriminator:e,...y(r)})}var oy=m(\"ZodIntersection\",(e,t)=>{Il.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ep(e,r,n,o)});function sy(e,t){return new oy({type:\"intersection\",left:e,right:t})}var ci=m(\"ZodEnum\",(e,t)=>{El.init(e,t),O.init(e,t),e._zod.processJSONSchema=(n,o,s)=>qf(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new ci({...t,checks:[],...y(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new ci({...t,checks:[],...y(o),entries:s})}});function iy(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new ci({type:\"enum\",entries:r,...y(t)})}var cy=m(\"ZodLiteral\",(e,t)=>{Al.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gf(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,\"value\",{get(){if(t.values.length>1)throw Error(\"This schema contains multiple valid literal values. Use `.values` instead.\");return t.values[0]}})});function Zt(e,t){return new cy({type:\"literal\",values:Array.isArray(e)?e:[e],...y(t)})}var ay=m(\"ZodTransform\",(e,t)=>{ai(),Ol.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hf(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")throw new mr(e.constructor.name);r.addIssue=(s)=>{if(typeof s===\"string\")r.issues.push(rt(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;if(i.code??(i.code=\"custom\"),!(\"input\"in i))i.input=r.value;i.inst??(i.inst=e),r.issues.push(rt(i))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((s)=>(r.value=s,r));return r.value=o,r}});function uy(e){return new ay({type:\"transform\",transform:e})}var Op=m(\"ZodOptional\",(e,t)=>{Rs.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>si(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function vp(e){return new Op({type:\"optional\",innerType:e})}var Tp=m(\"ZodExactOptional\",(e,t)=>{Tl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>si(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ly(e){return new Tp({type:\"optional\",innerType:e})}var fy=m(\"ZodNullable\",(e,t)=>{Pl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Sp(e){return new fy({type:\"nullable\",innerType:e})}var py=m(\"ZodDefault\",(e,t)=>{Zl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>op(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function dy(e,t){return new py({type:\"default\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():ys(t)}})}var hy=m(\"ZodPrefault\",(e,t)=>{Cl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function my(e,t){return new hy({type:\"prefault\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():ys(t)}})}var Pp=m(\"ZodNonOptional\",(e,t)=>{Dl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function gy(e,t){return new Pp({type:\"nonoptional\",innerType:e,...y(t)})}var yy=m(\"ZodCatch\",(e,t)=>{Nl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ip(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xy(e,t){return new yy({type:\"catch\",innerType:e,catchValue:typeof t===\"function\"?t:Pa(t)})}var _y=m(\"ZodPipe\",(e,t)=>{Ul.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cp(e,r,n,o),e.in=t.in,e.out=t.out});function $p(e,t){return new _y({type:\"pipe\",in:e,out:t})}var wy=m(\"ZodReadonly\",(e,t)=>{Rl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ap(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function by(e){return new wy({type:\"readonly\",innerType:e})}var ky=m(\"ZodCustom\",(e,t)=>{jl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wf(e,r,n,o)});function vy(e,t={}){return If(ky,e,t)}function Sy(e,t){return Ef(e,t)}var zr=32,oo=new Set([\"__proto__\",\"constructor\",\"prototype\"]),$y=li([ui().min(1).max(512).refine((e)=>!oo.has(e),\"unsafe path key\"),Tt().int().nonnegative()]),$r=Sr($y).min(1).max(zr);function Ir(e,t=0){if(t>zr)return!1;if(e===null||typeof e===\"boolean\"||typeof e===\"string\")return!0;if(typeof e===\"number\")return Number.isFinite(e);if(Array.isArray(e))return e.every((n)=>Ir(n,t+1));if(typeof e!==\"object\")return!1;let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)return!1;return Object.entries(e).every(([n,o])=>!oo.has(n)&&Ir(o,t+1))}var Zp=Qn().refine(Ir,\"value must be safe JSON\"),zy=Ap(\"type\",[Pt({type:Zt(\"set\"),path:$r,value:Zp}),Pt({type:Zt(\"delete\"),path:$r}),Pt({type:Zt(\"insert\"),path:$r,index:Tt().int().nonnegative(),values:Sr(Zp).min(1)}),Pt({type:Zt(\"increment\"),path:$r,by:Tt().finite()}),Pt({type:Zt(\"text\"),path:$r,index:Tt().int().nonnegative(),deleteCount:Tt().int().nonnegative().optional(),insert:ui().optional()})]).superRefine((e,t)=>{if(e.type===\"text\"&&(e.deleteCount??0)===0&&(e.insert??\"\").length===0)t.addIssue({code:\"custom\",message:\"text operation must insert or delete content\"})});function ro(e){if(Array.isArray(e)){let t=new re;return t.insert(0,e.map(ro)),t}if(e!==null&&typeof e===\"object\"){let t=new q;for(let[r,n]of Object.entries(e))t.set(r,ro(n));return t}return e}function fi(e,t=0){if(t>zr)throw Error(\"room document exceeds the maximum nesting depth\");if(e instanceof q){let r=Object.create(null);for(let[n,o]of e.entries()){if(oo.has(n))throw Error(`room document contains unsafe key \"${n}\"`);r[n]=fi(o,t+1)}return r}if(e instanceof re)return e.toArray().map((r)=>fi(r,t+1));if(e instanceof ae)return e.toString();if(!Ir(e))throw Error(\"room document contains a non-JSON value\");return e}function so(e){return fi(e.getMap(\"root\"))}function B(e){return e.map(String).join(\".\")}function Up(e){if(e.length===0||e.length>zr)throw Error(`room path must contain 1 to ${zr} segments`);for(let t of e)if(typeof t===\"string\"){if(t.length===0||t.length>512||oo.has(t))throw Error(`invalid room path segment \"${t}\"`)}else if(!Number.isInteger(t)||t<0)throw Error(`invalid room array index ${String(t)}`)}function Rp(e,t,r){if(e instanceof q){if(typeof t!==\"string\")throw Error(`expected an object key at \"${B(r)}\"`);if(!e.has(t))throw Error(`room path does not exist: \"${B(r)}\"`);return e.get(t)}if(typeof t!==\"number\"||t>=e.length)throw Error(`invalid array index at \"${B(r)}\"`);return e.get(t)}function io(e,t){Up(t);let r=e.getMap(\"root\");for(let n=0;n<t.length-1;n+=1){if(!(r instanceof q)&&!(r instanceof re))throw Error(`room path crosses a scalar at \"${B(t.slice(0,n+1))}\"`);r=Rp(r,t[n],t.slice(0,n+1))}if(!(r instanceof q)&&!(r instanceof re))throw Error(`room path parent is not a container: \"${B(t)}\"`);return{parent:r,key:t[t.length-1]}}function eo(e,t){let{parent:r,key:n}=io(e,t);return Rp(r,n,t)}function Cp(e,t,r){let{parent:n,key:o}=io(e,t),s=ro(r);if(n instanceof q){if(typeof o!==\"string\")throw Error(`expected an object key at \"${B(t)}\"`);n.set(o,s);return}if(typeof o!==\"number\"||o>=n.length)throw Error(`invalid array index at \"${B(t)}\"`);n.delete(o,1),n.insert(o,[s])}function Iy(e,t){let{parent:r,key:n}=io(e,t);if(r instanceof q){if(typeof n!==\"string\")throw Error(`expected an object key at \"${B(t)}\"`);if(!r.has(n))throw Error(`room path does not exist: \"${B(t)}\"`);r.delete(n);return}if(typeof n!==\"number\"||n>=r.length)throw Error(`invalid array index at \"${B(t)}\"`);r.delete(n,1)}function Dp(e,t){e.transact(()=>{for(let r of t)switch(r.type){case\"set\":Cp(e,r.path,r.value);break;case\"delete\":Iy(e,r.path);break;case\"insert\":{Up(r.path);let n=eo(e,r.path);if(!(n instanceof re))throw Error(`insert target is not an array: \"${B(r.path)}\"`);if(r.index>n.length)throw Error(`insert index is outside the array: \"${B(r.path)}\"`);n.insert(r.index,r.values.map(ro));break}case\"increment\":{let n=eo(e,r.path);if(typeof n!==\"number\"||!Number.isFinite(n))throw Error(`increment target is not a finite number: \"${B(r.path)}\"`);let o=n+r.by;if(!Number.isFinite(o))throw Error(`increment result is not finite: \"${B(r.path)}\"`);Cp(e,r.path,o);break}case\"text\":{let n=eo(e,r.path),o;if(n instanceof ae)o=n;else if(typeof n===\"string\"){o=new ae(n);let{parent:i,key:c}=io(e,r.path);if(i instanceof q&&typeof c===\"string\")i.set(c,o);else if(i instanceof re&&typeof c===\"number\"&&c<i.length)i.delete(c,1),i.insert(c,[o]);else throw Error(`invalid text path: \"${B(r.path)}\"`)}else throw Error(`text target is not a string: \"${B(r.path)}\"`);let s=r.deleteCount??0;if(r.index>o.length||r.index+s>o.length)throw Error(`text range is outside the string: \"${B(r.path)}\"`);if(s>0)o.delete(r.index,s);if(r.insert)o.insert(r.index,r.insert);break}}})}function Ey(e,t){let r=Sr(zy).min(1).parse(t),n=new ke({gc:!0});try{gn(n,St(e)),Dp(n,r),so(n)}finally{n.destroy()}let o=Nc(e);return Dp(e,r),St(e,o)}function no(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,s)=>no(o,t[s]));if(e===null||t===null||typeof e!==\"object\"||typeof t!==\"object\")return!1;let r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((o)=>Object.hasOwn(t,o)&&no(e[o],t[o]))}function Ay(e,t){if(no(e,t))return!0;if(e!==null&&t!==null&&!Array.isArray(e)&&!Array.isArray(t)&&typeof e===\"object\"&&typeof t===\"object\"&&Object.hasOwn(e,\"id\")&&Object.hasOwn(t,\"id\")){let r=e.id;return(typeof r===\"string\"||typeof r===\"number\")&&Object.is(r,t.id)}return!1}function pi(e){if(e!==null&&!Array.isArray(e)&&typeof e===\"object\"&&(typeof e.id===\"string\"||typeof e.id===\"number\"))return`id:${typeof e.id}:${String(e.id)}`;return`value:${JSON.stringify(e)}`}function Np(e){let t=[],r=new Set;for(let n of e){if(n===null||Array.isArray(n)||typeof n!==\"object\"||typeof n.id!==\"string\"&&typeof n.id!==\"number\")return null;let o=pi(n);if(r.has(o))return null;r.add(o),t.push(o)}return t}function Oy(e,t){let r=new Map;for(let s=0;s<t.length;s+=1){let i=pi(t[s]),c=r.get(i);if(c)c.push(s);else r.set(i,[s])}let n=[],o=-1;for(let s=0;s<e.length;s+=1){let i=r.get(pi(e[s]));while(i?.length&&i[0]<=o)i.shift();let c=i?.shift();if(c===void 0)continue;if(!Ay(e[s],t[c]))continue;n.push([s,c]),o=c}return n}function Ty(e,t){try{return eo(e,t)}catch{return}}function to(e,t,r,n,o){if(no(t,r))return;if(t!==null&&r!==null&&!Array.isArray(t)&&!Array.isArray(r)&&typeof t===\"object\"&&typeof r===\"object\"){for(let s of Object.keys(t))if(!Object.hasOwn(r,s))o.push({type:\"delete\",path:[...n,s]});for(let[s,i]of Object.entries(r))if(!Object.hasOwn(t,s))o.push({type:\"set\",path:[...n,s],value:i});else to(e,t[s],i,[...n,s],o);return}if(Array.isArray(t)&&Array.isArray(r)){let s=Np(t),i=Np(r),c=s!==null&&i!==null&&(s.length!==i.length||s.some((f,p)=>f!==i[p]));if(t.length===r.length&&!c){for(let f=0;f<r.length;f+=1)to(e,t[f],r[f],[...n,f],o);return}let a=0,l=0,u=0;for(let[f,p]of[...Oy(t,r),[t.length,r.length]]){let d=f-a;for(let g=0;g<d;g+=1)o.push({type:\"delete\",path:[...n,u]});let h=r.slice(l,p);if(h.length>0)o.push({type:\"insert\",path:n,index:u,values:h}),u+=h.length;if(f<t.length&&p<r.length)to(e,t[f],r[p],[...n,u],o),u+=1;a=f+1,l=p+1}return}if(typeof t===\"string\"&&typeof r===\"string\"&&Ty(e,n)instanceof ae){let s=0;while(s<t.length&&s<r.length&&t[s]===r[s])s+=1;let i=0;while(i<t.length-s&&i<r.length-s&&t[t.length-1-i]===r[r.length-1-i])i+=1;o.push({type:\"text\",path:n,index:s,deleteCount:t.length-s-i,insert:r.slice(s,r.length-i)});return}o.push({type:\"set\",path:n,value:r})}function jp(e,t){let r=so(e),n=structuredClone(r),o=t(n);if(o!==null&&(typeof o===\"object\"||typeof o===\"function\")&&typeof o.then===\"function\")throw Error(\"room change callback must be synchronous\");if(!Ir(n)||Array.isArray(n))throw Error(\"room state must be a safe JSON object\");let s=[];if(to(e,r,n,[],s),s.length>0)Ey(e,s);return s}function Lp(e){let t=\"\";for(let r=0;r<e.length;r+=8192)t+=String.fromCharCode(...e.subarray(r,r+8192));return btoa(t)}function Py(e){return Uint8Array.from(atob(e),(t)=>t.charCodeAt(0))}class co{handlers=new Map;on(e,t){let r=this.handlers.get(e)??new Set;return r.add(t),this.handlers.set(e,r),()=>r.delete(t)}emit(e,t){for(let r of this.handlers.get(e)??[])r(t)}}class Bp extends co{socket;rooms=new Map;channels=new Map;pending=new Map;nextId=0;opening;retry;stopped=!1;me;async open(){if(this.socket?.readyState===WebSocket.OPEN)return;if(this.opening)return this.opening;let e=location.pathname.match(/^\\/p\\/([^/.]+)/);if(!e)throw Error(\"Realtime rooms require a Swarm page\");let t=new URL(\"/@swarm/realtime\",location.href);return t.protocol=location.protocol===\"https:\"?\"wss:\":\"ws:\",t.searchParams.set(\"pageId\",decodeURIComponent(e[1])),this.opening=new Promise((r,n)=>{let o=new WebSocket(t);this.socket=o,o.onopen=()=>{this.opening=void 0,r()},o.onerror=()=>n(Error(\"Realtime connection failed\")),o.onmessage=(s)=>{let i=JSON.parse(s.data),c=i;if(c.seq)o.send(JSON.stringify({ack:c.seq}));if(c.type===\"hello\")this.me=c.me;if(c.type===\"room\")this.rooms.get(c.name??\"\")?.receive(i);if(c.type===\"presence\")this.rooms.get(c.name??\"\")?.receivePresence(c.peers);if(c.type===\"channel\")this.channels.get(c.name??\"\")?.emit(\"message\",c.data);if(c.type===\"deleted\")this.rooms.get(c.name??\"\")?.deleted();if(c.id!==void 0){let a=this.pending.get(c.id);if(a)if(clearTimeout(a.timer),this.pending.delete(c.id),c.type===\"error\")a.reject(Error(c.error));else a.resolve(c)}},o.onclose=()=>{this.opening=void 0,n(Error(\"Realtime connection closed\"));for(let s of this.pending.values())clearTimeout(s.timer),s.reject(Error(\"Realtime connection closed\"));if(this.pending.clear(),!this.stopped)this.retry=setTimeout(()=>{this.reconnect()},1000)}}),this.opening}async reconnect(){try{await this.open();for(let e of this.rooms.values())await e.join(!0);for(let e of this.channels.keys())await this.request({op:\"subscribe\",name:e})}catch(e){for(let t of this.rooms.values())t.emit(\"error\",e)}}async request(e){await this.open();let t=++this.nextId;return new Promise((r,n)=>{let o=setTimeout(()=>{this.pending.delete(t),n(Error(\"Realtime request timed out\"))},15000);this.pending.set(t,{resolve:r,reject:n,timer:o}),this.socket.send(JSON.stringify({...e,id:t}))})}close(){this.stopped=!0,clearTimeout(this.retry),this.socket?.close()}}class Mp extends co{connection;name;ydoc=new ke({gc:!0});generation=\"\";stale=!1;bytes=0;me;ready;writes=Promise.resolve();lastWrite=Promise.resolve();peers=[];presenceData={};presenceTimer;closed=!1;schemaVersion;presence;constructor(e,t,r){super();this.connection=e;this.name=t;this.schemaVersion=r.schemaVersion??1;let n=this;this.presence={set(o){if(n.presenceData=structuredClone(o),!n.presenceTimer)n.presenceTimer=setTimeout(()=>{n.presenceTimer=void 0,e.request({op:\"presence\",name:t,data:n.presenceData}).catch((s)=>n.emit(\"error\",s))},50)},get peers(){return n.peers}},this.observe()}get state(){return so(this.ydoc)}observe(){this.ydoc.on(\"update\",(e,t)=>{if(this.emit(\"change\",this.state),t===\"remote\"||!this.generation||this.closed)return;if(this.connection.socket?.readyState!==WebSocket.OPEN)return;let r=Lp(St(this.ydoc)),n=this.generation,o=this.writes.then(async()=>{try{let s=await this.connection.request({op:\"update\",name:this.name,generation:n,schemaVersion:this.schemaVersion,snapshot:r});if(s.room)this.receive(s.room)}catch(s){if(this.connection.socket?.readyState===WebSocket.OPEN){let i=await this.connection.request({op:\"join\",name:this.name,schemaVersion:this.schemaVersion});this.receive(i.room,!0)}throw this.emit(\"error\",s),s}});this.lastWrite=o,this.writes=o.catch(()=>{})})}async join(e=!1){if(this.ready&&!e)return this.ready;return this.ready=(async()=>{let t=this.generation,r=await this.connection.request({op:\"join\",name:this.name,schemaVersion:this.schemaVersion});if(this.me=r.me,this.receive(r.room),this.receivePresence(r.peers),e&&t===this.generation&&!this.stale){let n=await this.connection.request({op:\"update\",name:this.name,schemaVersion:this.schemaVersion,generation:t,snapshot:Lp(St(this.ydoc))});this.receive(n.room)}if(e)this.presence.set(this.presenceData)})(),this.ready}receive(e,t=!1){if(this.closed||!e)return;let r=t||this.generation!==\"\"&&e.generation!==this.generation;if(this.generation=e.generation,this.stale=e.schemaVersion!==this.schemaVersion,this.bytes=e.bytes,r)this.ydoc.destroy(),this.ydoc=new ke({gc:!0}),this.observe();if(gn(this.ydoc,Py(e.snapshot),\"remote\"),r)this.emit(\"reset\",this.state)}receivePresence(e=[]){this.peers=e,this.emit(\"presence\",e)}deleted(){this.closed=!0,this.emit(\"error\",Error(\"Room owner was deleted\")),this.ydoc.destroy()}async change(e){if(this.closed)throw Error(\"Room is closed\");if(this.stale)throw Error(\"Room schema is stale. Read the state and reset explicitly.\");if(jp(this.ydoc,e).length>0)await this.lastWrite}async apply(e){if(this.closed||this.stale)throw Error(\"Room is closed or stale\");await this.writes;let t=await this.connection.request({op:\"change\",name:this.name,generation:this.generation,schemaVersion:this.schemaVersion,operations:e});this.receive(t.room)}async reset(e={}){if(this.closed)throw Error(\"Room is closed\");await this.writes;let t=await this.connection.request({op:\"reset\",name:this.name,schemaVersion:this.schemaVersion,state:e});this.receive(t.room)}async close(){this.closed=!0,clearTimeout(this.presenceTimer),this.connection.rooms.delete(this.name);try{await this.connection.request({op:\"leave\",name:this.name})}finally{this.ydoc.destroy()}}}class Vp extends co{connection;name;constructor(e,t){super();this.connection=e;this.name=t}async publish(e){await this.connection.request({op:\"publish\",name:this.name,data:e})}async close(){this.connection.channels.delete(this.name),await this.connection.request({op:\"unsubscribe\",name:this.name})}}var ze=new Bp;window.addEventListener(\"pagehide\",()=>ze.close());async function rb(e=\"default\",t={}){if(!/^[a-zA-Z0-9_-]{1,64}$/.test(e))throw Error(\"Invalid room name\");let r=ze.rooms.get(e);if(r&&r.schemaVersion!==(t.schemaVersion??1))throw Error(\"Room already opened with a different schema version\");if(!r)r=new Mp(ze,e,t),ze.rooms.set(e,r);try{await r.join()}catch(n){throw ze.rooms.delete(e),n}return r}async function nb(e){if(!/^[a-zA-Z0-9_-]{1,64}$/.test(e))throw Error(\"Invalid channel name\");let t=ze.channels.get(e);if(t)return t;let r=new Vp(ze,e);ze.channels.set(e,r);try{await ze.request({op:\"subscribe\",name:e})}catch(n){throw ze.channels.delete(e),n}return r}export{nb as channel,rb as room};\n\n";
|
|
36048
|
+
var browser_generated_default = "var J=()=>new Map,Er=(e)=>{let t=J();return e.forEach((r,n)=>{t.set(n,r)}),t},me=(e,t,r)=>{let n=e.get(t);if(n===void 0)e.set(t,n=r());return n},mi=(e,t)=>{let r=[];for(let[n,o]of e)r.push(t(o,n));return r},gi=(e,t)=>{for(let[r,n]of e)if(t(n,r))return!0;return!1};var Ie=()=>new Set;var Ar=(e)=>e[e.length-1];var yi=(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r])},ge=Array.from,Or=(e,t)=>{for(let r=0;r<e.length;r++)if(!t(e[r],r,e))return!1;return!0},Tr=(e,t)=>{for(let r=0;r<e.length;r++)if(t(e[r],r,e))return!0;return!1};var xi=(e,t)=>{let r=Array(e);for(let n=0;n<e;n++)r[n]=t(n,r);return r};var Me=Array.isArray;class fo{constructor(){this._observers=J()}on(e,t){return me(this._observers,e,Ie).add(t),t}once(e,t){let r=(...n)=>{this.off(e,r),t(...n)};this.on(e,r)}off(e,t){let r=this._observers.get(e);if(r!==void 0){if(r.delete(t),r.size===0)this._observers.delete(e)}}emit(e,t){return ge((this._observers.get(e)||J()).values()).forEach((r)=>r(...t))}destroy(){this._observers=J()}}var K=Math.floor;var Ve=Math.abs;var Pr=(e,t)=>e<t?e:t,Ee=(e,t)=>e>t?e:t;var Zr=(e)=>e!==0?e<0:1/e<0;var po=1,ho=2,Cr=4,Dr=8;var ot=32,ie=64,M=128;var jt=31,Lt=63,Ae=127;var _i=2147483647;var{MAX_SAFE_INTEGER:st,MIN_SAFE_INTEGER:go}=Number;var wi=Number.isInteger||((e)=>typeof e===\"number\"&&isFinite(e)&&K(e)===e);var{fromCharCode:xo,fromCodePoint:Kp}=String,Cy=xo(65535),qp=(e)=>e.toLowerCase(),Gp=/^\\s*/g,Wp=(e)=>e.replace(Gp,\"\"),Hp=/([A-Z])/g,_o=(e,t)=>Wp(e.replace(Hp,(r)=>`${t}${qp(r)}`));var Yp=(e)=>{let t=unescape(encodeURIComponent(e)),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.codePointAt(o);return n},ct=typeof TextEncoder<\"u\"?new TextEncoder:null,Xp=(e)=>ct.encode(e),bi=ct?Xp:Yp;var it=typeof TextDecoder>\"u\"?null:new TextDecoder(\"utf-8\",{fatal:!0,ignoreBOM:!0});if(it&&it.decode(new Uint8Array).length===1)it=null;var ki=(e,t)=>xi(t,()=>e).join(\"\");class ut{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Bt=()=>new ut;var Qp=(e)=>{let t=e.cpos;for(let r=0;r<e.bufs.length;r++)t+=e.bufs[r].length;return t};var ce=(e)=>{let t=new Uint8Array(Qp(e)),r=0;for(let n=0;n<e.bufs.length;n++){let o=e.bufs[n];t.set(o,r),r+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),r),t},ed=(e,t)=>{let r=e.cbuf.length;if(r-e.cpos<t)e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Ee(r,t)*2),e.cpos=0},N=(e,t)=>{let r=e.cbuf.length;if(e.cpos===r)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(r*2),e.cpos=0;e.cbuf[e.cpos++]=t};var Ur=N;var w=(e,t)=>{while(t>Ae)N(e,M|Ae&t),t=K(t/128);N(e,Ae&t)},Rr=(e,t)=>{let r=Zr(t);if(r)t=-t;N(e,(t>Lt?M:0)|(r?ie:0)|Lt&t),t=K(t/64);while(t>0)N(e,(t>Ae?M:0)|Ae&t),t=K(t/128)},wo=new Uint8Array(30000),td=wo.length/3,rd=(e,t)=>{if(t.length<td){let r=ct.encodeInto(t,wo).written||0;w(e,r);for(let n=0;n<r;n++)N(e,wo[n])}else W(e,bi(t))},nd=(e,t)=>{let r=unescape(encodeURIComponent(t)),n=r.length;w(e,n);for(let o=0;o<n;o++)N(e,r.codePointAt(o))},Fe=ct&&ct.encodeInto?rd:nd;var Mt=(e,t)=>{let r=e.cbuf.length,n=e.cpos,o=Pr(r-n,t.length),s=t.length-o;if(e.cbuf.set(t.subarray(0,o),n),e.cpos+=o,s>0)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Ee(r*2,s)),e.cbuf.set(t.subarray(o)),e.cpos=s},W=(e,t)=>{w(e,t.byteLength),Mt(e,t)},bo=(e,t)=>{ed(e,t);let r=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,r},od=(e,t)=>bo(e,4).setFloat32(0,t,!1),sd=(e,t)=>bo(e,8).setFloat64(0,t,!1),id=(e,t)=>bo(e,8).setBigInt64(0,t,!1);var vi=new DataView(new ArrayBuffer(4)),cd=(e)=>(vi.setFloat32(0,e),vi.getFloat32(0)===e),at=(e,t)=>{switch(typeof t){case\"string\":N(e,119),Fe(e,t);break;case\"number\":if(wi(t)&&Ve(t)<=_i)N(e,125),Rr(e,t);else if(cd(t))N(e,124),od(e,t);else N(e,123),sd(e,t);break;case\"bigint\":N(e,122),id(e,t);break;case\"object\":if(t===null)N(e,126);else if(Me(t)){N(e,117),w(e,t.length);for(let r=0;r<t.length;r++)at(e,t[r])}else if(t instanceof Uint8Array)N(e,116),W(e,t);else{N(e,118);let r=Object.keys(t);w(e,r.length);for(let n=0;n<r.length;n++){let o=r[n];Fe(e,o),at(e,t[o])}}break;case\"boolean\":N(e,t?120:121);break;default:N(e,127)}};class jr extends ut{constructor(e){super();this.w=e,this.s=null,this.count=0}write(e){if(this.s===e)this.count++;else{if(this.count>0)w(this,this.count-1);this.count=1,this.w(this,e),this.s=e}}}var Si=(e)=>{if(e.count>0){if(Rr(e.encoder,e.count===1?e.s:-e.s),e.count>1)w(e.encoder,e.count-2)}};class lt{constructor(){this.encoder=new ut,this.s=0,this.count=0}write(e){if(this.s===e)this.count++;else Si(this),this.count=1,this.s=e}toUint8Array(){return Si(this),ce(this.encoder)}}var $i=(e)=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);if(Rr(e.encoder,t),e.count>1)w(e.encoder,e.count-2)}};class Vt{constructor(){this.encoder=new ut,this.s=0,this.count=0,this.diff=0}write(e){if(this.diff===e-this.s)this.s=e,this.count++;else $i(this),this.count=1,this.diff=e-this.s,this.s=e}toUint8Array(){return $i(this),ce(this.encoder)}}class ko{constructor(){this.sarr=[],this.s=\"\",this.lensE=new lt}write(e){if(this.s+=e,this.s.length>19)this.sarr.push(this.s),this.s=\"\";this.lensE.write(e.length)}toUint8Array(){let e=new ut;return this.sarr.push(this.s),this.s=\"\",Fe(e,this.sarr.join(\"\")),Mt(e,this.lensE.toUint8Array()),ce(e)}}var X=(e)=>Error(e),Q=()=>{throw X(\"Method unimplemented\")},H=()=>{throw X(\"Unexpected case\")};var zi=X(\"Unexpected end of array\"),Ii=X(\"Integer out of Range\");class Ft{constructor(e){this.arr=e,this.pos=0}}var qe=(e)=>new Ft(e),Ei=(e)=>e.pos!==e.arr.length;var ud=(e,t)=>{let r=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,r},Y=(e)=>ud(e,_(e));var Je=(e)=>e.arr[e.pos++];var _=(e)=>{let t=0,r=1,n=e.arr.length;while(e.pos<n){let o=e.arr[e.pos++];if(t=t+(o&Ae)*r,r*=128,o<M)return t;if(t>st)throw Ii}throw zi},Lr=(e)=>{let t=e.arr[e.pos++],r=t&Lt,n=64,o=(t&ie)>0?-1:1;if((t&M)===0)return o*r;let s=e.arr.length;while(e.pos<s){if(t=e.arr[e.pos++],r=r+(t&Ae)*n,n*=128,t<M)return o*r;if(r>st)throw Ii}throw zi};var ld=(e)=>{let t=_(e);if(t===0)return\"\";else{let r=String.fromCodePoint(Je(e));if(--t<100)while(t--)r+=String.fromCodePoint(Je(e));else while(t>0){let n=t<1e4?t:1e4,o=e.arr.subarray(e.pos,e.pos+n);e.pos+=n,r+=String.fromCodePoint.apply(null,o),t-=n}return decodeURIComponent(escape(r))}},fd=(e)=>it.decode(Y(e)),Ke=it?fd:ld;var So=(e,t)=>{let r=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,r},pd=(e)=>So(e,4).getFloat32(0,!1),dd=(e)=>So(e,8).getFloat64(0,!1),hd=(e)=>So(e,8).getBigInt64(0,!1);var md=[(e)=>{return},(e)=>null,Lr,pd,dd,hd,(e)=>!1,(e)=>!0,Ke,(e)=>{let t=_(e),r={};for(let n=0;n<t;n++){let o=Ke(e);r[o]=ft(e)}return r},(e)=>{let t=_(e),r=[];for(let n=0;n<t;n++)r.push(ft(e));return r},Y],ft=(e)=>md[127-Je(e)](e);class Br extends Ft{constructor(e,t){super(e);this.reader=t,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Ei(this))this.count=_(this)+1;else this.count=-1;return this.count--,this.s}}class pt extends Ft{constructor(e){super(e);this.s=0,this.count=0}read(){if(this.count===0){this.s=Lr(this);let e=Zr(this.s);if(this.count=1,e)this.s=-this.s,this.count=_(this)+2}return this.count--,this.s}}class Jt extends Ft{constructor(e){super(e);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Lr(this),t=e&1;if(this.diff=K(e/2),this.count=1,t)this.count=_(this)+2}return this.s+=this.diff,this.count--,this.s}}class $o{constructor(e){this.decoder=new pt(e),this.str=Ke(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}var Uy=crypto.subtle,Ai=crypto.getRandomValues.bind(crypto);var zo=()=>Ai(new Uint32Array(1))[0];var yd=[1e7]+-1000+-4000+-8000+-100000000000,Oi=()=>yd.replace(/[018]/g,(e)=>(e^zo()&15>>e/4).toString(16));var Ti=Date.now;var Io=(e)=>new Promise(e);var Ly=Promise.all.bind(Promise);var Eo=(e)=>e===void 0?null:e;class Pi{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}var Zi=new Pi,kd=!0;try{if(typeof localStorage<\"u\"&&localStorage)Zi=localStorage,kd=!1}catch(e){}var Ci=Zi;var Ge=Symbol(\"Equality\"),Mr=(e,t)=>e===t||!!e?.[Ge]?.(t)||!1;var Di=(e)=>typeof e===\"object\",{assign:Ni,keys:Sd}=Object;var Ui=(e,t)=>{for(let r in e)t(e[r],r)};var Kt=(e)=>Sd(e).length;var Ri=(e)=>{for(let t in e)return!1;return!0},dt=(e,t)=>{for(let r in e)if(!t(e[r],r))return!1;return!0},qt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Oo=(e,t)=>e===t||Kt(e)===Kt(t)&&dt(e,(r,n)=>(r!==void 0||qt(t,n))&&Mr(t[n],r)),$d=Object.freeze,To=(e)=>{for(let t in e){let r=e[t];if(typeof r===\"object\"||typeof r===\"function\")To(e[t])}return $d(e)};var Wt=(e,t,r=0)=>{try{for(;r<e.length;r++)e[r](...t)}finally{if(r<e.length)Wt(e,t,r+1)}};var ji=(e)=>e;var Gt=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Ge]!=null)return e[Ge](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let r of e)if(!t.has(r))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let r of e.keys())if(!t.has(r)||!Gt(e.get(r),t.get(r)))return!1;break}case void 0:case Object:if(Kt(e)!==Kt(t))return!1;for(let r in e)if(!qt(e,r)||!Gt(e[r],t[r]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Gt(e[r],t[r]))return!1;break;default:return!1}return!0},Li=(e,t)=>t.includes(e);var Ht=typeof process<\"u\"&&process.release&&/node|io\\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<\"u\"?process:0)===\"[object process]\";var By=typeof navigator<\"u\"?/Mac/.test(navigator.platform):!1,ye,zd=[],Id=()=>{if(ye===void 0)if(Ht){ye=J();let e=process.argv,t=null;for(let r=0;r<e.length;r++){let n=e[r];if(n[0]===\"-\"){if(t!==null)ye.set(t,\"\");t=n}else if(t!==null)ye.set(t,n),t=null;else zd.push(n)}if(t!==null)ye.set(t,\"\")}else if(typeof location===\"object\")ye=J(),(location.search||\"?\").slice(1).split(\"&\").forEach((e)=>{if(e.length!==0){let[t,r]=e.split(\"=\");ye.set(`--${_o(t,\"-\")}`,r),ye.set(`-${_o(t,\"-\")}`,r)}});else ye=J();return ye},Co=(e)=>Id().has(e);var Yt=(e)=>Ht?Eo(process.env[e.toUpperCase().replaceAll(\"-\",\"_\")]):Eo(Ci.getItem(e));var Bi=(e)=>Co(\"--\"+e)||Yt(e)!==null,Mi=Bi(\"production\"),Ed=Ht&&Li(process.env.FORCE_COLOR,[\"true\",\"1\",\"2\"]),Vi=Ed||!Co(\"--no-colors\")&&!Bi(\"no-color\")&&(!Ht||process.stdout.isTTY)&&(!Ht||Co(\"--color\")||Yt(\"COLORTERM\")!==null||(Yt(\"TERM\")||\"\").includes(\"color\"));var Ad=(e)=>new Uint8Array(e);var Fi=(e)=>{let t=Ad(e.byteLength);return t.set(e),t};class Ji{constructor(e,t){this.left=e,this.right=t}}var xe=(e,t)=>new Ji(e,t);var No=(e)=>e.next()>=0.5,Vr=(e,t,r)=>K(e.next()*(r+1-t)+t);var Uo=(e,t,r)=>K(e.next()*(r+1-t)+t);var Ro=(e,t,r)=>Uo(e,t,r);var Pd=(e)=>xo(Ro(e,97,122)),Ki=(e,t=0,r=20)=>{let n=Ro(e,t,r),o=\"\";for(let s=0;s<n;s++)o+=Pd(e);return o};var Fr=(e,t)=>t[Ro(e,0,t.length-1)];var Cd=Symbol(\"0schema\");class Gi{constructor(){this._rerrs=[]}extend(e,t,r,n=null){this._rerrs.push({path:e,expected:t,has:r,message:n})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let r=this._rerrs[t];e.push(ki(\" \",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:\"\"}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`\n`)}}var jo=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor)return!1;if(e[Ge])return Mr(e,t);if(Me(e))return Or(e,(r)=>Tr(t,(n)=>jo(r,n)));else if(Di(e))return dt(e,(r,n)=>jo(r,t[n]));return!1};class V{static _dilutes=!1;extends(e){let[t,r]=[this.shape,e.shape];if(this.constructor._dilutes)[r,t]=[t,r];return jo(t,r)}equals(e){return this.constructor===e.constructor&&Gt(this.shape,e.shape)}[Cd](){return!0}[Ge](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Q()}get nullable(){return yt(this,Qr)}get optional(){return new Lo(this)}cast(e){return qi(e,this),e}expect(e){return qi(e,this),e}}class qr extends V{constructor(e,t){super();this.shape=e,this._c=t}check(e,t=void 0){let r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?\"Constructor match failed\":\"Check failed\"),r}}var T=(e,t=null)=>new qr(e,t),Vy=T(qr);class Gr extends V{constructor(e){super();this.shape=e}check(e,t){let r=this.shape(e);return!r&&t?.extend(null,\"custom prop\",e?.constructor.name,\"failed to check custom prop\"),r}}var Z=(e)=>new Gr(e),Fy=T(Gr);class Qt extends V{constructor(e){super();this.shape=e}check(e,t){let r=this.shape.some((n)=>n===e);return!r&&t?.extend(null,this.shape.join(\" | \"),e.toString()),r}}var Wr=(...e)=>new Qt(e),Wi=T(Qt),Dd=RegExp.escape||((e)=>e.replace(/[().|&,$^[\\]]/g,(t)=>\"\\\\\"+t)),Hi=(e)=>{if(gt.check(e))return[Dd(e)];if(Wi.check(e))return e.shape.map((t)=>t+\"\");if(oc.check(e))return[\"[+-]?\\\\d+.?\\\\d*\"];if(sc.check(e))return[\".*\"];if(Jr.check(e))return e.shape.map(Hi).flat(1);H()};class Yi extends V{constructor(e){super();this.shape=e,this._r=new RegExp(\"^\"+e.map(Hi).map((t)=>`(${t.join(\"|\")})`).join(\"\")+\"$\")}check(e,t){let r=this._r.exec(e)!=null;return!r&&t?.extend(null,this._r.toString(),e.toString(),\"String doesn't match string template.\"),r}}var Jy=T(Yi),Nd=Symbol(\"optional\");class Lo extends V{constructor(e){super();this.shape=e}check(e,t){let r=e===void 0||this.shape.check(e);return!r&&t?.extend(null,\"undefined (optional)\",\"()\"),r}get[Nd](){return!0}}var Ud=T(Lo);class Bo extends V{check(e,t){return t?.extend(null,\"never\",typeof e),!1}}var Ky=new Bo,qy=T(Bo);class Hr extends V{constructor(e,t=!1){super();this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new Hr(this.shape,!0)}check(e,t){if(e==null)return t?.extend(null,\"object\",\"null\"),!1;return dt(this.shape,(r,n)=>{let o=this._isPartial&&!qt(e,n)||r.check(e[n],t);return!o&&t?.extend(n.toString(),r.toString(),typeof e[n],\"Object property does not match\"),o})}}var Rd=(e)=>new Hr(e),jd=T(Hr),Ld=Z((e)=>e!=null&&(e.constructor===Object||e.constructor==null));class Mo extends V{constructor(e,t){super();this.shape={keys:e,values:t}}check(e,t){return e!=null&&dt(e,(r,n)=>{let o=this.shape.keys.check(n,t);return!o&&t?.extend(n+\"\",\"Record\",typeof e,o?\"Key doesn't match schema\":\"Value doesn't match value\"),o&&this.shape.values.check(r,t)})}}var Xi=(e,t)=>new Mo(e,t),Bd=T(Mo);class Vo extends V{constructor(e){super();this.shape=e}check(e,t){return e!=null&&dt(this.shape,(r,n)=>{let o=r.check(e[n],t);return!o&&t?.extend(n.toString(),\"Tuple\",typeof r),o})}}var Md=(...e)=>new Vo(e),Gy=T(Vo);class Fo extends V{constructor(e){super();this.shape=e.length===1?e[0]:new Yr(e)}check(e,t){let r=Me(e)&&Or(e,(n)=>this.shape.check(n));return!r&&t?.extend(null,\"Array\",\"\"),r}}var Qi=(...e)=>new Fo(e),Vd=T(Fo),Fd=Z((e)=>Me(e));class Jo extends V{constructor(e,t){super();this.shape=e,this._c=t}check(e,t){let r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name),r}}var Jd=(e,t=null)=>new Jo(e,t),Wy=T(Jo),Kd=Jd(V);class ec extends V{constructor(e){super();this.len=e.length-1,this.args=Md(...e.slice(-1)),this.res=e[this.len]}check(e,t){let r=e.constructor===Function&&e.length<=this.len;return!r&&t?.extend(null,\"function\",typeof e),r}}var qd=T(ec),Gd=Z((e)=>typeof e===\"function\");class tc extends V{constructor(e){super();this.shape=e}check(e,t){let r=Or(this.shape,(n)=>n.check(e,t));return!r&&t?.extend(null,\"Intersectinon\",typeof e),r}}var Hy=T(tc,(e)=>e.shape.length>0);class Yr extends V{static _dilutes=!0;constructor(e){super();this.shape=e}check(e,t){let r=Tr(this.shape,(n)=>n.check(e,t));return t?.extend(null,\"Union\",typeof e),r}}var yt=(...e)=>e.findIndex((t)=>Jr.check(t))>=0?yt(...e.map((t)=>Xt(t)).map((t)=>Jr.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new Yr(e),Jr=T(Yr),rc=()=>!0,Kr=Z(rc),Wd=T(Gr,(e)=>e.shape===rc),Ko=Z((e)=>typeof e===\"bigint\"),Hd=Z((e)=>e===Ko),nc=Z((e)=>typeof e===\"symbol\"),Yy=Z((e)=>e===nc),mt=Z((e)=>typeof e===\"number\"),oc=Z((e)=>e===mt),gt=Z((e)=>typeof e===\"string\"),sc=Z((e)=>e===gt),Xr=Z((e)=>typeof e===\"boolean\"),Yd=Z((e)=>e===Xr),ic=Wr(void 0),Xy=T(Qt,(e)=>e.shape.length===1&&e.shape[0]===void 0),Qy=Wr(void 0);var Qr=Wr(null),Xd=T(Qt,(e)=>e.shape.length===1&&e.shape[0]===null),ex=T(Uint8Array),tx=T(qr,(e)=>e.shape===Uint8Array),Qd=yt(mt,gt,Qr,ic,Ko,Xr,nc),rx=(()=>{let e=Qi(Kr),t=Xi(gt,Kr),r=yt(mt,gt,Qr,Xr,e,t);return e.shape=r,t.shape.values=r,r})(),Xt=(e)=>{if(Kd.check(e))return e;else if(Ld.check(e)){let t={};for(let r in e)t[r]=Xt(e[r]);return Rd(t)}else if(Fd.check(e))return yt(...e.map(Xt));else if(Qd.check(e))return Wr(e);else if(Gd.check(e))return T(e);H()},qi=Mi?()=>{}:(e,t)=>{let r=new Gi;if(!t.check(e,r))throw X(`Expected value to be of type ${t.constructor.name}.\n${r.toString()}`)};class cc{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Xt(e),h:t}),this}else(e){return this.if(Kr,e)}done(){return(e,t)=>{for(let r=0;r<this.patterns.length;r++){let n=this.patterns[r];if(n.if.check(e))return n.h(e,t)}throw X(\"Unhandled pattern\")}}}var eh=(e)=>new cc(e),ac=eh(Kr).if(oc,(e,t)=>Vr(t,go,st)).if(sc,(e,t)=>Ki(t)).if(Yd,(e,t)=>No(t)).if(Hd,(e,t)=>BigInt(Vr(t,go,st))).if(Jr,(e,t)=>ht(t,Fr(t,e.shape))).if(jd,(e,t)=>{let r={};for(let n in e.shape){let o=e.shape[n];if(Ud.check(o)){if(No(t))continue;o=o.shape}r[n]=ac(o,t)}return r}).if(Vd,(e,t)=>{let r=[],n=Uo(t,0,42);for(let o=0;o<n;o++)r.push(ht(t,e.shape));return r}).if(Wi,(e,t)=>Fr(t,e.shape)).if(Xd,(e,t)=>null).if(qd,(e,t)=>{let r=ht(t,e.res);return()=>r}).if(Wd,(e,t)=>ht(t,Fr(t,[mt,gt,Qr,ic,Ko,Xr,Qi(mt),Xi(yt(\"a\",\"b\",\"c\"),mt)]))).if(Bd,(e,t)=>{let r={},n=Vr(t,0,3);for(let o=0;o<n;o++){let s=ht(t,e.shape.keys),i=ht(t,e.shape.values);r[s]=i}return r}).done(),ht=(e,t)=>ac(Xt(t),e);var We=typeof document<\"u\"?document:{};var nx=Z((e)=>e.nodeType===sh);var ox=typeof DOMParser<\"u\"?new DOMParser:null;var sx=Z((e)=>e.nodeType===rh);var ix=Z((e)=>e.nodeType===nh);var uc=(e)=>mi(e,(t,r)=>`${r}:${t};`).join(\"\");var{ELEMENT_NODE:rh,TEXT_NODE:nh,CDATA_SECTION_NODE:cx,COMMENT_NODE:ax,DOCUMENT_NODE:oh,DOCUMENT_TYPE_NODE:ux,DOCUMENT_FRAGMENT_NODE:sh}=We,lx=Z((e)=>e.nodeType===oh);var _e=Symbol;var er=_e(),tr=_e(),qo=_e(),Go=_e(),Wo=_e(),rr=_e(),Ho=_e(),xt=_e(),Yo=_e(),lc=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],r=[],n=0;for(;n<e.length;n++){let o=e[n];if(o===void 0)break;else if(o.constructor===String||o.constructor===Number)t.push(o);else if(o.constructor===Object)break}if(n>0)r.push(t.join(\"\"));for(;n<e.length;n++){let o=e[n];if(!(o instanceof Symbol))r.push(o)}return r};var fx=Ti();var uh={[er]:xe(\"font-weight\",\"bold\"),[tr]:xe(\"font-weight\",\"normal\"),[qo]:xe(\"color\",\"blue\"),[Wo]:xe(\"color\",\"green\"),[Go]:xe(\"color\",\"grey\"),[rr]:xe(\"color\",\"red\"),[Ho]:xe(\"color\",\"purple\"),[xt]:xe(\"color\",\"orange\"),[Yo]:xe(\"color\",\"black\")},lh=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],r=[],n=J(),o=[],s=0;for(;s<e.length;s++){let i=e[s],c=uh[i];if(c!==void 0)n.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=uc(n);if(s>0||a.length>0)t.push(\"%c\"+i),r.push(a);else t.push(i)}else break}}if(s>0)o=r,o.unshift(t.join(\"\"));for(;s<e.length;s++){let i=e[s];if(!(i instanceof Symbol))o.push(i)}return o},fc=Vi?lh:lc,pc=(...e)=>{console.log(...fc(e)),hc.forEach((t)=>t.print(e))},dc=(...e)=>{console.warn(...fc(e)),e.unshift(xt),hc.forEach((t)=>t.print(e))};var hc=Ie();var mc=(e)=>({[Symbol.iterator](){return this},next:e}),gc=(e,t)=>mc(()=>{let r;do r=e.next();while(!r.done&&!t(r.value));return r}),en=(e,t)=>mc(()=>{let{done:r,value:n}=e.next();return{done:r,value:r?void 0:t(n)}});class ir{constructor(e,t){this.clock=e,this.len=t}}class bt{constructor(){this.clients=new Map}}var Ec=(e,t,r)=>t.clients.forEach((n,o)=>{let s=e.doc.store.clients.get(o);if(s!=null){let i=s[s.length-1],c=i.id.clock+i.length;for(let a=0,l=n[a];a<n.length&&l.clock<c;l=n[++a])Bc(e,s,l.clock,l.len,r)}}),dh=(e,t)=>{let r=0,n=e.length-1;while(r<=n){let o=K((r+n)/2),s=e[o],i=s.clock;if(i<=t){if(t<i+s.len)return o;r=o+1}else n=o-1}return null},Ac=(e,t)=>{let r=e.clients.get(t.client);return r!==void 0&&dh(r,t.clock)!==null},rs=(e)=>{e.clients.forEach((t)=>{t.sort((o,s)=>o.clock-s.clock);let r,n;for(r=1,n=1;r<t.length;r++){let o=t[n-1],s=t[r];if(o.clock+o.len>=s.clock)t[n-1]=new ir(o.clock,Ee(o.len,s.clock+s.len-o.clock));else{if(n<r)t[n]=s;n++}}t.length=n})},hh=(e)=>{let t=new bt;for(let r=0;r<e.length;r++)e[r].clients.forEach((n,o)=>{if(!t.clients.has(o)){let s=n.slice();for(let i=r+1;i<e.length;i++)yi(s,e[i].clients.get(o)||[]);t.clients.set(o,s)}});return rs(t),t},cn=(e,t,r,n)=>{me(e.clients,t,()=>[]).push(new ir(r,n))},Oc=()=>new bt,mh=(e)=>{let t=Oc();return e.clients.forEach((r,n)=>{let o=[];for(let s=0;s<r.length;s++){let i=r[s];if(i.deleted){let c=i.id.clock,a=i.length;if(s+1<r.length)for(let l=r[s+1];s+1<r.length&&l.deleted;l=r[++s+1])a+=l.length;o.push(new ir(c,a))}}if(o.length>0)t.clients.set(n,o)}),t},kt=(e,t)=>{w(e.restEncoder,t.clients.size),ge(t.clients.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{e.resetDsCurVal(),w(e.restEncoder,r);let o=n.length;w(e.restEncoder,o);for(let s=0;s<o;s++){let i=n[s];e.writeDsClock(i.clock),e.writeDsLen(i.len)}})},ns=(e)=>{let t=new bt,r=_(e.restDecoder);for(let n=0;n<r;n++){e.resetDsCurVal();let o=_(e.restDecoder),s=_(e.restDecoder);if(s>0){let i=me(t.clients,o,()=>[]);for(let c=0;c<s;c++)i.push(new ir(e.readDsClock(),e.readDsLen()))}}return t},yc=(e,t,r)=>{let n=new bt,o=_(e.restDecoder);for(let s=0;s<o;s++){e.resetDsCurVal();let i=_(e.restDecoder),c=_(e.restDecoder),a=r.clients.get(i)||[],l=U(r,i);for(let u=0;u<c;u++){let f=e.readDsClock(),p=f+e.readDsLen();if(f<l){if(l<p)cn(n,i,l,p-l);let d=we(a,f),h=a[d];if(!h.deleted&&h.id.clock<f)a.splice(d+1,0,mn(t,h,f-h.id.clock)),d++;while(d<a.length)if(h=a[d++],h.id.clock<p){if(!h.deleted){if(p<h.id.clock+h.length)a.splice(d,0,mn(t,h,p-h.id.clock));h.delete(t)}}else break}else cn(n,i,f,p-f)}}if(n.clients.size>0){let s=new Ne;return w(s.restEncoder,0),kt(s,n),s.toUint8Array()}return null};var Tc=zo;class ke extends fo{constructor({guid:e=Oi(),collectionid:t=null,gc:r=!0,gcFilter:n=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:i=!0}={}){super();this.gc=r,this.gcFilter=n,this.clientID=Tc(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new us,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Io((a)=>{this.on(\"load\",()=>{this.isLoaded=!0,a(this)})});let c=()=>Io((a)=>{let l=(u)=>{if(u===void 0||u===!0)this.off(\"sync\",l),a()};this.on(\"sync\",l)});this.on(\"sync\",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit(\"load\",[this])}),this.whenSynced=c()}load(){let e=this._item;if(e!==null&&!this.shouldLoad)v(e.parent.doc,(t)=>{t.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ge(this.subdocs).map((e)=>e.guid))}transact(e,t=null){return v(this,e,t)}get(e,t=R){let r=me(this.share,e,()=>{let o=new t;return o._integrate(this,null),o}),n=r.constructor;if(t!==R&&n!==t)if(n===R){let o=new t;o._map=r._map,r._map.forEach((s)=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=\"\"){return this.get(e,re)}getText(e=\"\"){return this.get(e,ae)}getMap(e=\"\"){return this.get(e,q)}getXmlElement(e=\"\"){return this.get(e,wt)}getXmlFragment(e=\"\"){return this.get(e,Xe)}toJSON(){let e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,ge(this.subdocs).forEach((t)=>t.destroy());let e=this._item;if(e!==null){this._item=null;let t=e.content;t.doc=new ke({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,v(e.parent.doc,(r)=>{let n=t.doc;if(!e.deleted)r.subdocsAdded.add(n);r.subdocsRemoved.add(this)},null,!0)}this.emit(\"destroyed\",[!0]),this.emit(\"destroy\",[this]),super.destroy()}}class os{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return _(this.restDecoder)}readDsLen(){return _(this.restDecoder)}}class ss extends os{readLeftID(){return b(_(this.restDecoder),_(this.restDecoder))}readRightID(){return b(_(this.restDecoder),_(this.restDecoder))}readClient(){return _(this.restDecoder)}readInfo(){return Je(this.restDecoder)}readString(){return Ke(this.restDecoder)}readParentInfo(){return _(this.restDecoder)===1}readTypeRef(){return _(this.restDecoder)}readLen(){return _(this.restDecoder)}readAny(){return ft(this.restDecoder)}readBuf(){return Fi(Y(this.restDecoder))}readJSON(){return JSON.parse(Ke(this.restDecoder))}readKey(){return Ke(this.restDecoder)}}class Pc{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=_(this.restDecoder),this.dsCurrVal}readDsLen(){let e=_(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ye extends Pc{constructor(e){super(e);this.keys=[],_(e),this.keyClockDecoder=new Jt(Y(e)),this.clientDecoder=new pt(Y(e)),this.leftClockDecoder=new Jt(Y(e)),this.rightClockDecoder=new Jt(Y(e)),this.infoDecoder=new Br(Y(e),Je),this.stringDecoder=new $o(Y(e)),this.parentInfoDecoder=new Br(Y(e),Je),this.typeRefDecoder=new pt(Y(e)),this.lenDecoder=new pt(Y(e))}readLeftID(){return new He(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new He(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return ft(this.restDecoder)}readBuf(){return Y(this.restDecoder)}readJSON(){return ft(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];else{let t=this.stringDecoder.read();return this.keys.push(t),t}}}class is{constructor(){this.restEncoder=Bt()}toUint8Array(){return ce(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){w(this.restEncoder,e)}writeDsLen(e){w(this.restEncoder,e)}}class vt extends is{writeLeftID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeRightID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeClient(e){w(this.restEncoder,e)}writeInfo(e){Ur(this.restEncoder,e)}writeString(e){Fe(this.restEncoder,e)}writeParentInfo(e){w(this.restEncoder,e?1:0)}writeTypeRef(e){w(this.restEncoder,e)}writeLen(e){w(this.restEncoder,e)}writeAny(e){at(this.restEncoder,e)}writeBuf(e){W(this.restEncoder,e)}writeJSON(e){Fe(this.restEncoder,JSON.stringify(e))}writeKey(e){Fe(this.restEncoder,e)}}class cs{constructor(){this.restEncoder=Bt(),this.dsCurrVal=0}toUint8Array(){return ce(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,w(this.restEncoder,t)}writeDsLen(e){if(e===0)H();w(this.restEncoder,e-1),this.dsCurrVal+=e}}class Ne extends cs{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Vt,this.clientEncoder=new lt,this.leftClockEncoder=new Vt,this.rightClockEncoder=new Vt,this.infoEncoder=new jr(Ur),this.stringEncoder=new ko,this.parentInfoEncoder=new jr(Ur),this.typeRefEncoder=new lt,this.lenEncoder=new lt}toUint8Array(){let e=Bt();return w(e,0),W(e,this.keyClockEncoder.toUint8Array()),W(e,this.clientEncoder.toUint8Array()),W(e,this.leftClockEncoder.toUint8Array()),W(e,this.rightClockEncoder.toUint8Array()),W(e,ce(this.infoEncoder)),W(e,this.stringEncoder.toUint8Array()),W(e,ce(this.parentInfoEncoder)),W(e,this.typeRefEncoder.toUint8Array()),W(e,this.lenEncoder.toUint8Array()),Mt(e,ce(this.restEncoder)),ce(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){at(this.restEncoder,e)}writeBuf(e){W(this.restEncoder,e)}writeJSON(e){at(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);if(t===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e);else this.keyClockEncoder.write(t)}}var gh=(e,t,r,n)=>{n=Ee(n,t[0].id.clock);let o=we(t,n);w(e.restEncoder,t.length-o),e.writeClient(r),w(e.restEncoder,n);let s=t[o];s.write(e,n-s.id.clock);for(let i=o+1;i<t.length;i++)t[i].write(e,0)},as=(e,t,r)=>{let n=new Map;r.forEach((o,s)=>{if(U(t,s)>o)n.set(s,o)}),yn(t).forEach((o,s)=>{if(!r.has(s))n.set(s,0)}),w(e.restEncoder,n.size),ge(n.entries()).sort((o,s)=>s[0]-o[0]).forEach(([o,s])=>{gh(e,t.clients.get(o),o,s)})},yh=(e,t)=>{let r=J(),n=_(e.restDecoder);for(let o=0;o<n;o++){let s=_(e.restDecoder),i=Array(s),c=e.readClient(),a=_(e.restDecoder);r.set(c,{i:0,refs:i});for(let l=0;l<s;l++){let u=e.readInfo();switch(jt&u){case 0:{let f=e.readLen();i[l]=new ee(b(c,a),f),a+=f;break}case 10:{let f=_(e.restDecoder);i[l]=new te(b(c,a),f),a+=f;break}default:{let f=(u&(ie|M))===0,p=new C(b(c,a),null,(u&M)===M?e.readLeftID():null,null,(u&ie)===ie?e.readRightID():null,f?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,f&&(u&ot)===ot?e.readString():null,pa(e,u));i[l]=p,a+=p.length}}}}return r},xh=(e,t,r)=>{let n=[],o=ge(r.keys()).sort((d,h)=>d-h);if(o.length===0)return null;let s=()=>{if(o.length===0)return null;let d=r.get(o[o.length-1]);while(d.refs.length===d.i)if(o.pop(),o.length>0)d=r.get(o[o.length-1]);else return null;return d},i=s();if(i===null)return null;let c=new us,a=new Map,l=(d,h)=>{let g=a.get(d);if(g==null||g>h)a.set(d,h)},u=i.refs[i.i++],f=new Map,p=()=>{for(let d of n){let h=d.id.client,g=r.get(h);if(g)g.i--,c.clients.set(h,g.refs.slice(g.i)),r.delete(h),g.i=0,g.refs=[];else c.clients.set(h,[d]);o=o.filter((x)=>x!==h)}n.length=0};while(!0){if(u.constructor!==te){let h=me(f,u.id.client,()=>U(t,u.id.client))-u.id.clock;if(h<0)n.push(u),l(u.id.client,u.id.clock-1),p();else{let g=u.getMissing(e,t);if(g!==null){n.push(u);let x=r.get(g)||{refs:[],i:0};if(x.refs.length===x.i)l(g,U(t,g)),p();else{u=x.refs[x.i++];continue}}else if(h===0||h<u.length)u.integrate(e,h),f.set(u.id.client,u.id.clock+u.length)}}if(n.length>0)u=n.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else if(i=s(),i===null)break;else u=i.refs[i.i++]}if(c.clients.size>0){let d=new Ne;return as(d,c,new Map),w(d.restEncoder,0),{missing:a,update:d.toUint8Array()}}return null},_h=(e,t)=>as(e,t.doc.store,t.beforeState),wh=(e,t,r,n=new Ye(e))=>v(t,(o)=>{o.local=!1;let s=!1,i=o.doc,c=i.store,a=yh(n,i),l=xh(o,c,a),u=c.pendingStructs;if(u){for(let[p,d]of u.missing)if(d<U(c,p)){s=!0;break}if(l){for(let[p,d]of l.missing){let h=u.missing.get(p);if(h==null||h>d)u.missing.set(p,d)}u.update=an([u.update,l.update])}}else c.pendingStructs=l;let f=yc(n,o,c);if(c.pendingDs){let p=new Ye(qe(c.pendingDs));_(p.restDecoder);let d=yc(p,o,c);if(f&&d)c.pendingDs=an([f,d]);else c.pendingDs=f||d}else c.pendingDs=f;if(s){let p=c.pendingStructs.update;c.pendingStructs=null,Zc(o.doc,p)}},r,!1);var Zc=(e,t,r,n=Ye)=>{let o=qe(t);wh(o,e,r,new n(o))},gn=(e,t,r)=>Zc(e,t,r,ss),bh=(e,t,r=new Map)=>{as(e,t.store,r),kt(e,mh(t.store))},kh=(e,t=new Uint8Array([0]),r=new Ne)=>{let n=Cc(t);bh(r,e,n);let o=[r.toUint8Array()];if(e.store.pendingDs)o.push(e.store.pendingDs);if(e.store.pendingStructs)o.push(Dh(e.store.pendingStructs.update,t));if(o.length>1){if(r.constructor===vt)return Zh(o.map((s,i)=>i===0?s:Uh(s)));else if(r.constructor===Ne)return an(o)}return o[0]},St=(e,t)=>kh(e,t,new vt),vh=(e)=>{let t=new Map,r=_(e.restDecoder);for(let n=0;n<r;n++){let o=_(e.restDecoder),s=_(e.restDecoder);t.set(o,s)}return t},Cc=(e)=>vh(new os(qe(e))),Dc=(e,t)=>(w(e.restEncoder,t.size),ge(t.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{w(e.restEncoder,r),w(e.restEncoder,n)}),e),Sh=(e,t)=>Dc(e,yn(t.store)),$h=(e,t=new cs)=>{if(e instanceof Map)Dc(t,e);else Sh(t,e);return t.toUint8Array()},Nc=(e)=>$h(e,new is);class Uc{constructor(){this.l=[]}}var xc=()=>new Uc,_c=(e,t)=>e.l.push(t),wc=(e,t)=>{let r=e.l,n=r.length;if(e.l=r.filter((o)=>t!==o),n===e.l.length)console.error(\"[yjs] Tried to remove event handler that doesn't exist.\")},Rc=(e,t,r)=>Wt(e.l,[t,r]);class He{constructor(e,t){this.client=e,this.clock=t}}var tn=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,b=(e,t)=>new He(e,t);var zh=(e)=>{for(let[t,r]of e.doc.share.entries())if(r===e)return t;throw H()};class jc{constructor(e,t){this.ds=e,this.sv=t}}var Ih=(e,t)=>new jc(e,t),kx=Ih(Oc(),new Map);var _t=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Ac(t.ds,e.id),es=(e,t)=>{let r=me(e.meta,es,Ie),n=e.doc.store;if(!r.has(t))t.sv.forEach((o,s)=>{if(o<U(n,s))Ue(e,b(s,o))}),Ec(e,t.ds,(o)=>{}),r.add(t)};class us{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var yn=(e)=>{let t=new Map;return e.clients.forEach((r,n)=>{let o=r[r.length-1];t.set(n,o.id.clock+o.length)}),t},U=(e,t)=>{let r=e.clients.get(t);if(r===void 0)return 0;let n=r[r.length-1];return n.id.clock+n.length},Lc=(e,t)=>{let r=e.clients.get(t.id.client);if(r===void 0)r=[],e.clients.set(t.id.client,r);else{let n=r[r.length-1];if(n.id.clock+n.length!==t.id.clock)throw H()}r.push(t)},we=(e,t)=>{let r=0,n=e.length-1,o=e[n],s=o.id.clock;if(s===t)return n;let i=K(t/(s+o.length-1)*n);while(r<=n){if(o=e[i],s=o.id.clock,s<=t){if(t<s+o.length)return i;r=i+1}else n=i-1;i=K((r+n)/2)}throw H()},Eh=(e,t)=>{let r=e.clients.get(t.client);return r[we(r,t.clock)]},Xo=Eh,ts=(e,t,r)=>{let n=we(t,r),o=t[n];if(o.id.clock<r&&o instanceof C)return t.splice(n+1,0,mn(e,o,r-o.id.clock)),n+1;return n},Ue=(e,t)=>{let r=e.doc.store.clients.get(t.client);return r[ts(e,r,t.clock)]},bc=(e,t,r)=>{let n=t.clients.get(r.client),o=we(n,r.clock),s=n[o];if(r.clock!==s.id.clock+s.length-1&&s.constructor!==ee)n.splice(o+1,0,mn(e,s,r.clock-s.id.clock+1));return s},Ah=(e,t,r)=>{let n=e.clients.get(t.id.client);n[we(n,t.id.clock)]=r},Bc=(e,t,r,n,o)=>{if(n===0)return;let s=r+n,i=ts(e,t,r),c;do{if(c=t[i++],s<c.id.clock+c.length)ts(e,t,s);o(c)}while(i<t.length&&t[i].id.clock<s)};class Mc{constructor(e,t,r){this.doc=e,this.deleteSet=new bt,this.beforeState=yn(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var kc=(e,t)=>{if(t.deleteSet.clients.size===0&&!gi(t.afterState,(r,n)=>t.beforeState.get(n)!==r))return!1;return rs(t.deleteSet),_h(e,t),kt(e,t.deleteSet),!0},vc=(e,t,r)=>{let n=t._item;if(n===null||n.id.clock<(e.beforeState.get(n.id.client)||0)&&!n.deleted)me(e.changed,t,Ie).add(r)},on=(e,t)=>{let r=e[t],n=e[t-1],o=t;for(;o>0;r=n,n=e[--o-1]){if(n.deleted===r.deleted&&n.constructor===r.constructor){if(n.mergeWith(r)){if(r instanceof C&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,n);continue}}break}let s=t-o;if(s)e.splice(t+1-s,s);return s},Oh=(e,t,r)=>{for(let[n,o]of e.clients.entries()){let s=t.clients.get(n);for(let i=o.length-1;i>=0;i--){let c=o[i],a=c.clock+c.len;for(let l=we(s,c.clock),u=s[l];l<s.length&&u.id.clock<a;u=s[++l]){let f=s[l];if(c.clock+c.len<=f.id.clock)break;if(f instanceof C&&f.deleted&&!f.keep&&r(f))f.gc(t,!1)}}}},Th=(e,t)=>{e.clients.forEach((r,n)=>{let o=t.clients.get(n);for(let s=r.length-1;s>=0;s--){let i=r[s],c=Pr(o.length-1,1+we(o,i.clock+i.len-1));for(let a=c,l=o[a];a>0&&l.id.clock>=i.clock;l=o[a])a-=1+on(o,a)}})};var Vc=(e,t)=>{if(t<e.length){let r=e[t],n=r.doc,o=n.store,{deleteSet:s,_mergeStructs:i}=r;try{rs(s),r.afterState=yn(r.doc.store),n.emit(\"beforeObserverCalls\",[r,n]);let c=[];r.changed.forEach((a,l)=>c.push(()=>{if(l._item===null||!l._item.deleted)l._callObserver(r,a)})),c.push(()=>{r.changedParentTypes.forEach((a,l)=>{if(l._dEH.l.length>0&&(l._item===null||!l._item.deleted))c.push(()=>{a=a.filter((u)=>u.target._item===null||!u.target._item.deleted),a.forEach((u)=>{u.currentTarget=l,u._path=null}),a.sort((u,f)=>u.path.length-f.path.length),Rc(l._dEH,a,r)})}),c.push(()=>n.emit(\"afterTransaction\",[r,n])),c.push(()=>{if(r._needFormattingCleanup)Gh(r)})}),Wt(c,[])}finally{if(n.gc)Oh(s,o,n.gcFilter);Th(s,o),r.afterState.forEach((u,f)=>{let p=r.beforeState.get(f)||0;if(p!==u){let d=o.clients.get(f),h=Ee(we(d,p),1);for(let g=d.length-1;g>=h;)g-=1+on(d,g)}});for(let u=i.length-1;u>=0;u--){let{client:f,clock:p}=i[u].id,d=o.clients.get(f),h=we(d,p);if(h+1<d.length){if(on(d,h+1)>1)continue}if(h>0)on(d,h)}if(!r.local&&r.afterState.get(n.clientID)!==r.beforeState.get(n.clientID))pc(xt,er,\"[yjs] \",tr,rr,\"Changed the client-id because another client seems to be using it.\"),n.clientID=Tc();if(n.emit(\"afterTransactionCleanup\",[r,n]),n._observers.has(\"update\")){let u=new vt;if(kc(u,r))n.emit(\"update\",[u.toUint8Array(),r.origin,n,r])}if(n._observers.has(\"updateV2\")){let u=new Ne;if(kc(u,r))n.emit(\"updateV2\",[u.toUint8Array(),r.origin,n,r])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:l}=r;if(c.size>0||l.size>0||a.size>0)c.forEach((u)=>{if(u.clientID=n.clientID,u.collectionid==null)u.collectionid=n.collectionid;n.subdocs.add(u)}),l.forEach((u)=>n.subdocs.delete(u)),n.emit(\"subdocs\",[{loaded:a,added:c,removed:l},n,r]),l.forEach((u)=>u.destroy());if(e.length<=t+1)n._transactionCleanups=[],n.emit(\"afterAllTransactions\",[n,e]);else Vc(e,t+1)}}},v=(e,t,r=null,n=!0)=>{let o=e._transactionCleanups,s=!1,i=null;if(e._transaction===null){if(s=!0,e._transaction=new Mc(e,r,n),o.push(e._transaction),o.length===1)e.emit(\"beforeAllTransactions\",[e]);e.emit(\"beforeTransaction\",[e._transaction,e])}try{i=t(e._transaction)}finally{if(s){let c=e._transaction===o[0];if(e._transaction=null,c)Vc(o,0)}}return i};function*Ph(e){let t=_(e.restDecoder);for(let r=0;r<t;r++){let n=_(e.restDecoder),o=e.readClient(),s=_(e.restDecoder);for(let i=0;i<n;i++){let c=e.readInfo();if(c===10){let a=_(e.restDecoder);yield new te(b(o,s),a),s+=a}else if((jt&c)!==0){let a=(c&(ie|M))===0,l=new C(b(o,s),null,(c&M)===M?e.readLeftID():null,null,(c&ie)===ie?e.readRightID():null,a?e.readParentInfo()?e.readString():e.readLeftID():null,a&&(c&ot)===ot?e.readString():null,pa(e,c));yield l,s+=l.length}else{let a=e.readLen();yield new ee(b(o,s),a),s+=a}}}}class xn{constructor(e,t){this.gen=Ph(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===te);return this.curr}}class _n{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}var Zh=(e)=>an(e,ss,vt);var Ch=(e,t)=>{if(e.constructor===ee){let{client:r,clock:n}=e.id;return new ee(b(r,n+t),e.length-t)}else if(e.constructor===te){let{client:r,clock:n}=e.id;return new te(b(r,n+t),e.length-t)}else{let r=e,{client:n,clock:o}=r.id;return new C(b(n,o+t),null,b(n,o+t-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(t))}},an=(e,t=Ye,r=Ne)=>{if(e.length===1)return e[0];let n=e.map((u)=>new t(qe(u))),o=n.map((u)=>new xn(u,!0)),s=null,i=new r,c=new _n(i);while(!0){if(o=o.filter((p)=>p.curr!==null),o.sort((p,d)=>{if(p.curr.id.client===d.curr.id.client){let h=p.curr.id.clock-d.curr.id.clock;if(h===0)return p.curr.constructor===d.curr.constructor?0:p.curr.constructor===te?1:-1;else return h}else return d.curr.id.client-p.curr.id.client}),o.length===0)break;let u=o[0],f=u.curr.id.client;if(s!==null){let p=u.curr,d=!1;while(p!==null&&p.id.clock+p.length<=s.struct.id.clock+s.struct.length&&p.id.client>=s.struct.id.client)p=u.next(),d=!0;if(p===null||p.id.client!==f||d&&p.id.clock>s.struct.id.clock+s.struct.length)continue;if(f!==s.struct.id.client)Ce(c,s.struct,s.offset),s={struct:p,offset:0},u.next();else if(s.struct.id.clock+s.struct.length<p.id.clock)if(s.struct.constructor===te)s.struct.length=p.id.clock+p.length-s.struct.id.clock;else{Ce(c,s.struct,s.offset);let h=p.id.clock-s.struct.id.clock-s.struct.length;s={struct:new te(b(f,s.struct.id.clock+s.struct.length),h),offset:0}}else{let h=s.struct.id.clock+s.struct.length-p.id.clock;if(h>0)if(s.struct.constructor===te)s.struct.length-=h;else p=Ch(p,h);if(!s.struct.mergeWith(p))Ce(c,s.struct,s.offset),s={struct:p,offset:0},u.next()}}else s={struct:u.curr,offset:0},u.next();for(let p=u.curr;p!==null&&p.id.client===f&&p.id.clock===s.struct.id.clock+s.struct.length&&p.constructor!==te;p=u.next())Ce(c,s.struct,s.offset),s={struct:p,offset:0}}if(s!==null)Ce(c,s.struct,s.offset),s=null;ls(c);let a=n.map((u)=>ns(u)),l=hh(a);return kt(i,l),i.toUint8Array()},Dh=(e,t,r=Ye,n=Ne)=>{let o=Cc(t),s=new n,i=new _n(s),c=new r(qe(e)),a=new xn(c,!1);while(a.curr){let u=a.curr,f=u.id.client,p=o.get(f)||0;if(a.curr.constructor===te){a.next();continue}if(u.id.clock+u.length>p){Ce(i,u,Ee(p-u.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===f)Ce(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===f&&a.curr.id.clock+a.curr.length<=p)a.next()}ls(i);let l=ns(c);return kt(s,l),s.toUint8Array()};var Fc=(e)=>{if(e.written>0)e.clientStructs.push({written:e.written,restEncoder:ce(e.encoder.restEncoder)}),e.encoder.restEncoder=Bt(),e.written=0},Ce=(e,t,r)=>{if(e.written>0&&e.currClient!==t.id.client)Fc(e);if(e.written===0)e.currClient=t.id.client,e.encoder.writeClient(t.id.client),w(e.encoder.restEncoder,t.id.clock+r);t.write(e.encoder,r),e.written++},ls=(e)=>{Fc(e);let t=e.encoder.restEncoder;w(t,e.clientStructs.length);for(let r=0;r<e.clientStructs.length;r++){let n=e.clientStructs[r];w(t,n.written),Mt(t,n.restEncoder)}},Nh=(e,t,r,n)=>{let o=new r(qe(e)),s=new xn(o,!1),i=new n,c=new _n(i);for(let l=s.curr;l!==null;l=s.next())Ce(c,t(l),0);ls(c);let a=ns(o);return kt(i,a),i.toUint8Array()};var Uh=(e)=>Nh(e,ji,Ye,vt),Sc=\"You must not compute changes after the event-handler fired.\";class cr{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Rh(this.currentTarget,this.target))}deletes(e){return Ac(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(Sc);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach((n)=>{if(n!==null){let o=t._map.get(n),s,i;if(this.adds(o)){let c=o.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(o))if(c!==null&&this.deletes(c))s=\"delete\",i=Ar(c.content.getContent());else return;else if(c!==null&&this.deletes(c))s=\"update\",i=Ar(c.content.getContent());else s=\"add\",i=void 0}else if(this.deletes(o))s=\"delete\",i=Ar(o.content.getContent());else return;e.set(n,{action:s,oldValue:i})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(Sc);let t=this.target,r=Ie(),n=Ie(),o=[];if(e={added:r,deleted:n,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let i=null,c=()=>{if(i)o.push(i)};for(let a=t._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,n.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),r.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=e}return e}}var Rh=(e,t)=>{let r=[];while(t._item!==null&&t!==e){if(t._item.parentSub!==null)r.unshift(t._item.parentSub);else{let n=0,o=t._item.parent._start;while(o!==t._item&&o!==null){if(!o.deleted&&o.countable)n+=o.length;o=o.right}r.unshift(n)}t=t._item.parent}return r},F=()=>{dc(\"Invalid access: Add Yjs type to a document before reading data.\")},Jc=80,fs=0;class Kc{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=fs++}}var jh=(e)=>{e.timestamp=fs++},qc=(e,t,r)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=r,e.timestamp=fs++},Lh=(e,t,r)=>{if(e.length>=Jc){let n=e.reduce((o,s)=>o.timestamp<s.timestamp?o:s);return qc(n,t,r),n}else{let n=new Kc(t,r);return e.push(n),n}},wn=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let r=e._searchMarker.length===0?null:e._searchMarker.reduce((s,i)=>Ve(t-s.index)<Ve(t-i.index)?s:i),n=e._start,o=0;if(r!==null)n=r.p,o=r.index,jh(r);while(n.right!==null&&o<t){if(!n.deleted&&n.countable){if(t<o+n.length)break;o+=n.length}n=n.right}while(n.left!==null&&o>t)if(n=n.left,!n.deleted&&n.countable)o-=n.length;while(n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock)if(n=n.left,!n.deleted&&n.countable)o-=n.length;if(r!==null&&Ve(r.index-o)<n.parent.length/Jc)return qc(r,n,o),r;else return Lh(e._searchMarker,n,o)},nr=(e,t,r)=>{for(let n=e.length-1;n>=0;n--){let o=e[n];if(r>0){let s=o.p;s.marker=!1;while(s&&(s.deleted||!s.countable))if(s=s.left,s&&!s.deleted&&s.countable)o.index-=s.length;if(s===null||s.marker===!0){e.splice(n,1);continue}o.p=s,s.marker=!0}if(t<o.index||r>0&&t===o.index)o.index=Ee(t,o.index+r)}};var bn=(e,t,r)=>{let n=e,o=t.changedParentTypes;while(!0){if(me(o,e,()=>[]).push(r),e._item===null)break;e=e._item.parent}Rc(n._eH,r,t)};class R{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=xc(),this._dEH=xc(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Q()}clone(){throw Q()}_write(e){}get _first(){let e=this._start;while(e!==null&&e.deleted)e=e.right;return e}_callObserver(e,t){if(!e.local&&this._searchMarker)this._searchMarker.length=0}observe(e){_c(this._eH,e)}observeDeep(e){_c(this._dEH,e)}unobserve(e){wc(this._eH,e)}unobserveDeep(e){wc(this._dEH,e)}toJSON(){}}var Gc=(e,t,r)=>{if(e.doc??F(),t<0)t=e._length+t;if(r<0)r=e._length+r;let n=r-t,o=[],s=e._start;while(s!==null&&n>0){if(s.countable&&!s.deleted){let i=s.content.getContent();if(i.length<=t)t-=i.length;else{for(let c=t;c<i.length&&n>0;c++)o.push(i[c]),n--;t=0}}s=s.right}return o},Wc=(e)=>{e.doc??F();let t=[],r=e._start;while(r!==null){if(r.countable&&!r.deleted){let n=r.content.getContent();for(let o=0;o<n.length;o++)t.push(n[o])}r=r.right}return t};var or=(e,t)=>{let r=0,n=e._start;e.doc??F();while(n!==null){if(n.countable&&!n.deleted){let o=n.content.getContent();for(let s=0;s<o.length;s++)t(o[s],r++,e)}n=n.right}},Hc=(e,t)=>{let r=[];return or(e,(n,o)=>{r.push(t(n,o,e))}),r},Bh=(e)=>{let t=e._start,r=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(t!==null&&t.deleted)t=t.right;if(t===null)return{done:!0,value:void 0};r=t.content.getContent(),n=0,t=t.right}let o=r[n++];if(r.length<=n)r=null;return{done:!1,value:o}}}},Yc=(e,t)=>{e.doc??F();let r=wn(e,t),n=e._start;if(r!==null)n=r.p,t-=r.index;for(;n!==null;n=n.right)if(!n.deleted&&n.countable){if(t<n.length)return n.content.getContent()[t];t-=n.length}},un=(e,t,r,n)=>{let o=r,s=e.doc,{clientID:i,store:c}=s,a=r===null?t._start:r.right,l=[],u=()=>{if(l.length>0)o=new C(b(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Qe(l)),o.integrate(e,0),l=[]};n.forEach((f)=>{if(f===null)l.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(f);break;default:switch(u(),f.constructor){case Uint8Array:case ArrayBuffer:o=new C(b(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new ar(new Uint8Array(f))),o.integrate(e,0);break;case ke:o=new C(b(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new ur(f)),o.integrate(e,0);break;default:if(f instanceof R)o=new C(b(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Oe(f)),o.integrate(e,0);else throw Error(\"Unexpected content type in insert operation\")}}}),u()},Xc=()=>X(\"Length exceeded!\"),Qc=(e,t,r,n)=>{if(r>t._length)throw Xc();if(r===0){if(t._searchMarker)nr(t._searchMarker,r,n.length);return un(e,t,null,n)}let o=r,s=wn(t,r),i=t._start;if(s!==null){if(i=s.p,r-=s.index,r===0)i=i.prev,r+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(r<=i.length){if(r<i.length)Ue(e,b(i.id.client,i.id.clock+r));break}r-=i.length}if(t._searchMarker)nr(t._searchMarker,o,n.length);return un(e,t,i,n)},Mh=(e,t,r)=>{let o=(t._searchMarker||[]).reduce((s,i)=>i.index>s.index?i:s,{index:0,p:t._start}).p;if(o)while(o.right)o=o.right;return un(e,t,o,r)},ea=(e,t,r,n)=>{if(n===0)return;let o=r,s=n,i=wn(t,r),c=t._start;if(i!==null)c=i.p,r-=i.index;for(;c!==null&&r>0;c=c.right)if(!c.deleted&&c.countable){if(r<c.length)Ue(e,b(c.id.client,c.id.clock+r));r-=c.length}while(n>0&&c!==null){if(!c.deleted){if(n<c.length)Ue(e,b(c.id.client,c.id.clock+n));c.delete(e),n-=c.length}c=c.right}if(n>0)throw Xc();if(t._searchMarker)nr(t._searchMarker,o,-s+n)},ln=(e,t,r)=>{let n=t._map.get(r);if(n!==void 0)n.delete(e)},ps=(e,t,r,n)=>{let o=t._map.get(r)||null,s=e.doc,i=s.clientID,c;if(n==null)c=new Qe([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Qe([n]);break;case Uint8Array:c=new ar(n);break;case ke:c=new ur(n);break;default:if(n instanceof R)c=new Oe(n);else throw Error(\"Unexpected content type\")}new C(b(i,U(s.store,i)),o,o&&o.lastId,null,null,t,r,c).integrate(e,0)},ds=(e,t)=>{e.doc??F();let r=e._map.get(t);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},ta=(e)=>{let t={};return e.doc??F(),e._map.forEach((r,n)=>{if(!r.deleted)t[n]=r.content.getContent()[r.length-1]}),t},ra=(e,t)=>{e.doc??F();let r=e._map.get(t);return r!==void 0&&!r.deleted};var Vh=(e,t)=>{let r={};return e._map.forEach((n,o)=>{let s=n;while(s!==null&&(!t.sv.has(s.id.client)||s.id.clock>=(t.sv.get(s.id.client)||0)))s=s.left;if(s!==null&&_t(s,t))r[o]=s.content.getContent()[s.length-1]}),r},rn=(e)=>(e.doc??F(),gc(e._map.entries(),(t)=>!t[1].deleted));class na extends cr{}class re extends R{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(e){let t=new re;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new re}clone(){let e=new re;return e.insert(0,this.toArray().map((t)=>t instanceof R?t.clone():t)),e}get length(){return this.doc??F(),this._length}_callObserver(e,t){super._callObserver(e,t),bn(this,e,new na(this,e))}insert(e,t){if(this.doc!==null)v(this.doc,(r)=>{Qc(r,this,e,t)});else this._prelimContent.splice(e,0,...t)}push(e){if(this.doc!==null)v(this.doc,(t)=>{Mh(t,this,e)});else this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){if(this.doc!==null)v(this.doc,(r)=>{ea(r,this,e,t)});else this._prelimContent.splice(e,t)}get(e){return Yc(this,e)}toArray(){return Wc(this)}slice(e=0,t=this.length){return Gc(this,e,t)}toJSON(){return this.map((e)=>e instanceof R?e.toJSON():e)}map(e){return Hc(this,e)}forEach(e){or(this,e)}[Symbol.iterator](){return Bh(this)}_write(e){e.writeTypeRef(fm)}}var Fh=(e)=>new re;class oa extends cr{constructor(e,t,r){super(e,t);this.keysChanged=r}}class q extends R{constructor(e){super();if(this._prelimContent=null,e===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,n)=>{this.set(n,r)}),this._prelimContent=null}_copy(){return new q}clone(){let e=new q;return this.forEach((t,r)=>{e.set(r,t instanceof R?t.clone():t)}),e}_callObserver(e,t){bn(this,e,new oa(this,e,t))}toJSON(){this.doc??F();let e={};return this._map.forEach((t,r)=>{if(!t.deleted){let n=t.content.getContent()[t.length-1];e[r]=n instanceof R?n.toJSON():n}}),e}get size(){return[...rn(this)].length}keys(){return en(rn(this),(e)=>e[0])}values(){return en(rn(this),(e)=>e[1].content.getContent()[e[1].length-1])}entries(){return en(rn(this),(e)=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??F(),this._map.forEach((t,r)=>{if(!t.deleted)e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){if(this.doc!==null)v(this.doc,(t)=>{ln(t,this,e)});else this._prelimContent.delete(e)}set(e,t){if(this.doc!==null)v(this.doc,(r)=>{ps(r,this,e,t)});else this._prelimContent.set(e,t);return t}get(e){return ds(this,e)}has(e){return ra(this,e)}clear(){if(this.doc!==null)v(this.doc,(e)=>{this.forEach(function(t,r,n){ln(e,n,r)})});else this._prelimContent.clear()}_write(e){e.writeTypeRef(pm)}}var Jh=(e)=>new q,De=(e,t)=>e===t||typeof e===\"object\"&&typeof t===\"object\"&&e&&t&&Oo(e,t);class fn{constructor(e,t,r,n){this.left=e,this.right=t,this.index=r,this.currentAttributes=n}forward(){if(this.right===null)H();switch(this.right.content.constructor){case D:if(!this.right.deleted)$t(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var $c=(e,t,r)=>{while(t.right!==null&&r>0){switch(t.right.content.constructor){case D:if(!t.right.deleted)$t(t.currentAttributes,t.right.content);break;default:if(!t.right.deleted){if(r<t.right.length)Ue(e,b(t.right.id.client,t.right.id.clock+r));t.index+=t.right.length,r-=t.right.length}break}t.left=t.right,t.right=t.right.right}return t},nn=(e,t,r,n)=>{let o=new Map,s=n?wn(t,r):null;if(s){let i=new fn(s.p.left,s.p,s.index,o);return $c(e,i,r-s.index)}else{let i=new fn(null,t._start,0,o);return $c(e,i,r)}},sa=(e,t,r,n)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===D&&De(n.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)n.delete(r.right.content.key);r.forward()}let o=e.doc,s=o.clientID;n.forEach((i,c)=>{let{left:a,right:l}=r,u=new C(b(s,U(o.store,s)),a,a&&a.lastId,l,l&&l.id,t,null,new D(c,i));u.integrate(e,0),r.right=u,r.forward()})},$t=(e,t)=>{let{key:r,value:n}=t;if(n===null)e.delete(r);else e.set(r,n)},ia=(e,t)=>{while(!0){if(e.right===null)break;else if(e.right.deleted||e.right.content.constructor===D&&De(t[e.right.content.key]??null,e.right.content.value));else break;e.forward()}},ca=(e,t,r,n)=>{let o=e.doc,s=o.clientID,i=new Map;for(let c in n){let a=n[c],l=r.currentAttributes.get(c)??null;if(!De(l,a)){i.set(c,l);let{left:u,right:f}=r;r.right=new C(b(s,U(o.store,s)),u,u&&u.lastId,f,f&&f.id,t,null,new D(c,a)),r.right.integrate(e,0),r.forward()}}return i},Qo=(e,t,r,n,o)=>{r.currentAttributes.forEach((p,d)=>{if(o[d]===void 0)o[d]=null});let s=e.doc,i=s.clientID;ia(r,o);let c=ca(e,t,r,o),a=n.constructor===String?new be(n):n instanceof R?new Oe(n):new et(n),{left:l,right:u,index:f}=r;if(t._searchMarker)nr(t._searchMarker,r.index,a.getLength());u=new C(b(i,U(s.store,i)),l,l&&l.lastId,u,u&&u.id,t,null,a),u.integrate(e,0),r.right=u,r.index=f,r.forward(),sa(e,t,r,c)},zc=(e,t,r,n,o)=>{let s=e.doc,i=s.clientID;ia(r,o);let c=ca(e,t,r,o);e:while(r.right!==null&&(n>0||c.size>0&&(r.right.deleted||r.right.content.constructor===D))){if(!r.right.deleted)switch(r.right.content.constructor){case D:{let{key:a,value:l}=r.right.content,u=o[a];if(u!==void 0){if(De(u,l))c.delete(a);else{if(n===0)break e;c.set(a,l)}r.right.delete(e)}else r.currentAttributes.set(a,l);break}default:if(n<r.right.length)Ue(e,b(r.right.id.client,r.right.id.clock+n));n-=r.right.length;break}r.forward()}if(n>0){let a=\"\";for(;n>0;n--)a+=`\n`;r.right=new C(b(i,U(s.store,i)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,t,null,new be(a)),r.right.integrate(e,0),r.forward()}sa(e,t,r,c)},aa=(e,t,r,n,o)=>{let s=t,i=J();while(s&&(!s.countable||s.deleted)){if(!s.deleted&&s.content.constructor===D){let l=s.content;i.set(l.key,l)}s=s.right}let c=0,a=!1;while(t!==s){if(r===t)a=!0;if(!t.deleted){let l=t.content;switch(l.constructor){case D:{let{key:u,value:f}=l,p=n.get(u)??null;if(i.get(u)!==l||p===f){if(t.delete(e),c++,!a&&(o.get(u)??null)===f&&p!==f)if(p===null)o.delete(u);else o.set(u,p)}if(!a&&!t.deleted)$t(o,l);break}}}t=t.right}return c},Kh=(e,t)=>{while(t&&t.right&&(t.right.deleted||!t.right.countable))t=t.right;let r=new Set;while(t&&(t.deleted||!t.countable)){if(!t.deleted&&t.content.constructor===D){let n=t.content.key;if(r.has(n))t.delete(e);else r.add(n)}t=t.left}},qh=(e)=>{let t=0;return v(e.doc,(r)=>{let{_start:n,_start:o}=e,s=J(),i=Er(s);while(o){if(o.deleted===!1)switch(o.content.constructor){case D:$t(i,o.content);break;default:t+=aa(r,n,o,s,i),s=Er(i),n=o;break}o=o.right}}),t},Gh=(e)=>{let t=new Set,r=e.doc;for(let[n,o]of e.afterState.entries()){let s=e.beforeState.get(n)||0;if(o===s)continue;Bc(e,r.store.clients.get(n),s,o,(i)=>{if(!i.deleted&&i.content.constructor===D&&i.constructor!==ee)t.add(i.parent)})}v(r,(n)=>{Ec(e,e.deleteSet,(o)=>{if(o instanceof ee||!o.parent._hasFormatting||t.has(o.parent))return;let s=o.parent;if(o.content.constructor===D)t.add(s);else Kh(n,o)});for(let o of t)qh(o)})},Ic=(e,t,r)=>{let n=r,o=Er(t.currentAttributes),s=t.right;while(r>0&&t.right!==null){if(t.right.deleted===!1)switch(t.right.content.constructor){case Oe:case et:case be:if(r<t.right.length)Ue(e,b(t.right.id.client,t.right.id.clock+r));r-=t.right.length,t.right.delete(e);break}t.forward()}if(s)aa(e,s,t.right,o,t.currentAttributes);let i=(t.left||t.right).parent;if(i._searchMarker)nr(i._searchMarker,t.index,-n+r);return t};class ua extends cr{constructor(e,t,r){super(e,t);this.childListChanged=!1,this.keysChanged=new Set,r.forEach((n)=>{if(n===null)this.childListChanged=!0;else this.keysChanged.add(n)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];v(e,(r)=>{let n=new Map,o=new Map,s=this.target._start,i=null,c={},a=\"\",l=0,u=0,f=()=>{if(i!==null){let p=null;switch(i){case\"delete\":if(u>0)p={delete:u};u=0;break;case\"insert\":if(typeof a===\"object\"||a.length>0){if(p={insert:a},n.size>0)p.attributes={},n.forEach((d,h)=>{if(d!==null)p.attributes[h]=d})}a=\"\";break;case\"retain\":if(l>0){if(p={retain:l},!Ri(c))p.attributes=Ni({},c)}l=0;break}if(p)t.push(p);i=null}};while(s!==null){switch(s.content.constructor){case Oe:case et:if(this.adds(s)){if(!this.deletes(s))f(),i=\"insert\",a=s.content.getContent()[0],f()}else if(this.deletes(s)){if(i!==\"delete\")f(),i=\"delete\";u+=1}else if(!s.deleted){if(i!==\"retain\")f(),i=\"retain\";l+=1}break;case be:if(this.adds(s)){if(!this.deletes(s)){if(i!==\"insert\")f(),i=\"insert\";a+=s.content.str}}else if(this.deletes(s)){if(i!==\"delete\")f(),i=\"delete\";u+=s.length}else if(!s.deleted){if(i!==\"retain\")f(),i=\"retain\";l+=s.length}break;case D:{let{key:p,value:d}=s.content;if(this.adds(s)){if(!this.deletes(s)){let h=n.get(p)??null;if(!De(h,d)){if(i===\"retain\")f();if(De(d,o.get(p)??null))delete c[p];else c[p]=d}else if(d!==null)s.delete(r)}}else if(this.deletes(s)){o.set(p,d);let h=n.get(p)??null;if(!De(h,d)){if(i===\"retain\")f();c[p]=h}}else if(!s.deleted){o.set(p,d);let h=c[p];if(h!==void 0){if(!De(h,d)){if(i===\"retain\")f();if(d===null)delete c[p];else c[p]=d}else if(h!==null)s.delete(r)}}if(!s.deleted){if(i===\"insert\")f();$t(n,s.content)}break}}s=s.right}f();while(t.length>0){let p=t[t.length-1];if(p.retain!==void 0&&p.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class ae extends R{constructor(e){super();this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??F(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach((r)=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ae}clone(){let e=new ae;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let r=new ua(this,e,t);if(bn(this,e,r),!e.local&&this._hasFormatting)e._needFormattingCleanup=!0}toString(){this.doc??F();let e=\"\",t=this._start;while(t!==null){if(!t.deleted&&t.countable&&t.content.constructor===be)e+=t.content.str;t=t.right}return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){if(this.doc!==null)v(this.doc,(r)=>{let n=new fn(null,this._start,0,new Map);for(let o=0;o<e.length;o++){let s=e[o];if(s.insert!==void 0){let i=!t&&typeof s.insert===\"string\"&&o===e.length-1&&n.right===null&&s.insert.slice(-1)===`\n`?s.insert.slice(0,-1):s.insert;if(typeof i!==\"string\"||i.length>0)Qo(r,this,n,i,s.attributes||{})}else if(s.retain!==void 0)zc(r,this,n,s.retain,s.attributes||{});else if(s.delete!==void 0)Ic(r,n,s.delete)}});else this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??F();let n=[],o=new Map,s=this.doc,i=\"\",c=this._start;function a(){if(i.length>0){let u={},f=!1;o.forEach((d,h)=>{f=!0,u[h]=d});let p={insert:i};if(f)p.attributes=u;n.push(p),i=\"\"}}let l=()=>{while(c!==null){if(_t(c,e)||t!==void 0&&_t(c,t))switch(c.content.constructor){case be:{let u=o.get(\"ychange\");if(e!==void 0&&!_t(c,e)){if(u===void 0||u.user!==c.id.client||u.type!==\"removed\")a(),o.set(\"ychange\",r?r(\"removed\",c.id):{type:\"removed\"})}else if(t!==void 0&&!_t(c,t)){if(u===void 0||u.user!==c.id.client||u.type!==\"added\")a(),o.set(\"ychange\",r?r(\"added\",c.id):{type:\"added\"})}else if(u!==void 0)a(),o.delete(\"ychange\");i+=c.content.str;break}case Oe:case et:{a();let u={insert:c.content.getContent()[0]};if(o.size>0){let f={};u.attributes=f,o.forEach((p,d)=>{f[d]=p})}n.push(u);break}case D:if(_t(c,e))a(),$t(o,c.content);break}c=c.right}a()};if(e||t)v(s,(u)=>{if(e)es(u,e);if(t)es(u,t);l()},\"cleanup\");else l();return n}insert(e,t,r){if(t.length<=0)return;let n=this.doc;if(n!==null)v(n,(o)=>{let s=nn(o,this,e,!r);if(!r)r={},s.currentAttributes.forEach((i,c)=>{r[c]=i});Qo(o,this,s,t,r)});else this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){let n=this.doc;if(n!==null)v(n,(o)=>{let s=nn(o,this,e,!r);Qo(o,this,s,t,r||{})});else this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;let r=this.doc;if(r!==null)v(r,(n)=>{Ic(n,nn(n,this,e,!0),t)});else this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;let n=this.doc;if(n!==null)v(n,(o)=>{let s=nn(o,this,e,!1);if(s.right===null)return;zc(o,this,s,t,r)});else this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){if(this.doc!==null)v(this.doc,(t)=>{ln(t,this,e)});else this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){if(this.doc!==null)v(this.doc,(r)=>{ps(r,this,e,t)});else this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return ds(this,e)}getAttributes(){return ta(this)}_write(e){e.writeTypeRef(dm)}}var Wh=(e)=>new ae;class sn{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??F()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===wt||t.constructor===Xe)&&t._start!==null)e=t._start;else while(e!==null){let r=e.next;if(r!==null){e=r;break}else if(e.parent===this._root)e=null;else e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));if(this._firstCall=!1,e===null)return{value:void 0,done:!0};return this._currentNode=e,{value:e.content.type,done:!1}}}class Xe extends R{constructor(){super();this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Xe}clone(){let e=new Xe;return e.insert(0,this.toArray().map((t)=>t instanceof R?t.clone():t)),e}get length(){return this.doc??F(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new sn(this,e)}querySelector(e){e=e.toUpperCase();let r=new sn(this,(n)=>n.nodeName&&n.nodeName.toUpperCase()===e).next();if(r.done)return null;else return r.value}querySelectorAll(e){return e=e.toUpperCase(),ge(new sn(this,(t)=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){bn(this,e,new la(this,t,e))}toString(){return Hc(this,(e)=>e.toString()).join(\"\")}toJSON(){return this.toString()}toDOM(e=document,t={},r){let n=e.createDocumentFragment();if(r!==void 0)r._createAssociation(n,this);return or(this,(o)=>{n.insertBefore(o.toDOM(e,t,r),null)}),n}insert(e,t){if(this.doc!==null)v(this.doc,(r)=>{Qc(r,this,e,t)});else this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)v(this.doc,(r)=>{let n=e&&e instanceof R?e._item:e;un(r,this,n,t)});else{let r=this._prelimContent,n=e===null?0:r.findIndex((o)=>o===e)+1;if(n===0&&e!==null)throw X(\"Reference item not found\");r.splice(n,0,...t)}}delete(e,t=1){if(this.doc!==null)v(this.doc,(r)=>{ea(r,this,e,t)});else this._prelimContent.splice(e,t)}toArray(){return Wc(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Yc(this,e)}slice(e=0,t=this.length){return Gc(this,e,t)}forEach(e){or(this,e)}_write(e){e.writeTypeRef(mm)}}var Hh=(e)=>new Xe;class wt extends Xe{constructor(e=\"UNDEFINED\"){super();this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,n)=>{this.setAttribute(n,r)}),this._prelimAttrs=null}_copy(){return new wt(this.nodeName)}clone(){let e=new wt(this.nodeName),t=this.getAttributes();return Ui(t,(r,n)=>{e.setAttribute(n,r)}),e.insert(0,this.toArray().map((r)=>r instanceof R?r.clone():r)),e}toString(){let e=this.getAttributes(),t=[],r=[];for(let i in e)r.push(i);r.sort();let n=r.length;for(let i=0;i<n;i++){let c=r[i];t.push(c+'=\"'+e[c]+'\"')}let o=this.nodeName.toLocaleLowerCase(),s=t.length>0?\" \"+t.join(\" \"):\"\";return`<${o}${s}>${super.toString()}</${o}>`}removeAttribute(e){if(this.doc!==null)v(this.doc,(t)=>{ln(t,this,e)});else this._prelimAttrs.delete(e)}setAttribute(e,t){if(this.doc!==null)v(this.doc,(r)=>{ps(r,this,e,t)});else this._prelimAttrs.set(e,t)}getAttribute(e){return ds(this,e)}hasAttribute(e){return ra(this,e)}getAttributes(e){return e?Vh(this,e):ta(this)}toDOM(e=document,t={},r){let n=e.createElement(this.nodeName),o=this.getAttributes();for(let s in o){let i=o[s];if(typeof i===\"string\")n.setAttribute(s,i)}if(or(this,(s)=>{n.appendChild(s.toDOM(e,t,r))}),r!==void 0)r._createAssociation(n,this);return n}_write(e){e.writeTypeRef(hm),e.writeKey(this.nodeName)}}var Yh=(e)=>new wt(e.readKey());class la extends cr{constructor(e,t,r){super(e,r);this.childListChanged=!1,this.attributesChanged=new Set,t.forEach((n)=>{if(n===null)this.childListChanged=!0;else this.attributesChanged.add(n)})}}class pn extends q{constructor(e){super();this.hookName=e}_copy(){return new pn(this.hookName)}clone(){let e=new pn(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){let n=t[this.hookName],o;if(n!==void 0)o=n.createDom(this);else o=document.createElement(this.hookName);if(o.setAttribute(\"data-yjs-hook\",this.hookName),r!==void 0)r._createAssociation(o,this);return o}_write(e){e.writeTypeRef(gm),e.writeKey(this.hookName)}}var Xh=(e)=>new pn(e.readKey());class dn extends ae{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new dn}clone(){let e=new dn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){let n=e.createTextNode(this.toString());if(r!==void 0)r._createAssociation(n,this);return n}toString(){return this.toDelta().map((e)=>{let t=[];for(let n in e.attributes){let o=[];for(let s in e.attributes[n])o.push({key:s,value:e.attributes[n][s]});o.sort((s,i)=>s.key<i.key?-1:1),t.push({nodeName:n,attrs:o})}t.sort((n,o)=>n.nodeName<o.nodeName?-1:1);let r=\"\";for(let n=0;n<t.length;n++){let o=t[n];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){let i=o.attrs[s];r+=` ${i.key}=\"${i.value}\"`}r+=\">\"}r+=e.insert;for(let n=t.length-1;n>=0;n--)r+=`</${t[n].nodeName}>`;return r}).join(\"\")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(ym)}}var Qh=(e)=>new dn;class kn{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Q()}mergeWith(e){return!1}write(e,t,r){throw Q()}integrate(e,t){throw Q()}}var em=0;class ee extends kn{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){if(t>0)this.id.clock+=t,this.length-=t;Lc(e.doc.store,this)}write(e,t){e.writeInfo(em),e.writeLen(this.length-t)}getMissing(e,t){return null}}class ar{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ar(this.content)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}var tm=(e)=>new ar(e.readBuf());class sr{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new sr(this.len)}splice(e){let t=new sr(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){cn(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}var rm=(e)=>new sr(e.readLen()),fa=(e,t)=>new ke({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class ur{constructor(e){if(e._item)console.error(\"This document was already integrated as a sub-document. You should create a second instance instead with the same guid.\");this.doc=e;let t={};if(this.opts=t,!e.gc)t.gc=!1;if(e.autoLoad)t.autoLoad=!0;if(e.meta!==null)t.meta=e.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new ur(fa(this.doc.guid,this.opts))}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){if(this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad)e.subdocsLoaded.add(this.doc)}delete(e){if(e.subdocsAdded.has(this.doc))e.subdocsAdded.delete(this.doc);else e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}var nm=(e)=>new ur(fa(e.readString(),e.readAny()));class et{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new et(this.embed)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}var om=(e)=>new et(e.readJSON());class D{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new D(this.key,this.value)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){let r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}var sm=(e)=>new D(e.readKey(),e.readJSON());class hn{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new hn(this.arr)}splice(e){let t=new hn(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let n=t;n<r;n++){let o=this.arr[n];e.writeString(o===void 0?\"undefined\":JSON.stringify(o))}}getRef(){return 2}}var im=(e)=>{let t=e.readLen(),r=[];for(let n=0;n<t;n++){let o=e.readString();if(o===\"undefined\")r.push(void 0);else r.push(JSON.parse(o))}return new hn(r)},cm=Yt(\"node_env\")===\"development\";class Qe{constructor(e){this.arr=e,cm&&To(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qe(this.arr)}splice(e){let t=new Qe(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let n=t;n<r;n++){let o=this.arr[n];e.writeAny(o)}}getRef(){return 8}}var am=(e)=>{let t=e.readLen(),r=[];for(let n=0;n<t;n++)r.push(e.readAny());return new Qe(r)};class be{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(\"\")}isCountable(){return!0}copy(){return new be(this.str)}splice(e){let t=new be(this.str.slice(e));this.str=this.str.slice(0,e);let r=this.str.charCodeAt(e-1);if(r>=55296&&r<=56319)this.str=this.str.slice(0,e-1)+\"�\",t.str=\"�\"+t.str.slice(1);return t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}var um=(e)=>new be(e.readString()),lm=[Fh,Jh,Wh,Yh,Hh,Xh,Qh],fm=0,pm=1,dm=2,hm=3,mm=4,gm=5,ym=6;class Oe{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Oe(this.type._copy())}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;while(t!==null){if(!t.deleted)t.delete(e);else if(t.id.clock<(e.beforeState.get(t.id.client)||0))e._mergeStructs.push(t);t=t.right}this.type._map.forEach((r)=>{if(!r.deleted)r.delete(e);else if(r.id.clock<(e.beforeState.get(r.id.client)||0))e._mergeStructs.push(r)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;while(t!==null)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach((r)=>{while(r!==null)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}var xm=(e)=>new Oe(lm[e.readTypeRef()](e));var mn=(e,t,r)=>{let{client:n,clock:o}=t.id,s=new C(b(n,o+r),t,b(n,o+r-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(r));if(t.deleted)s.markDeleted();if(t.keep)s.keep=!0;if(t.redone!==null)s.redone=b(t.redone.client,t.redone.clock+r);if(t.right=s,s.right!==null)s.right.left=s;if(e._mergeStructs.push(s),s.parentSub!==null&&s.right===null)s.parent._map.set(s.parentSub,s);return t.length=r,s};class C extends kn{constructor(e,t,r,n,o,s,i,c){super(e,c.getLength());this.origin=r,this.left=t,this.right=n,this.rightOrigin=o,this.parent=s,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?ho:0}set marker(e){if((this.info&Dr)>0!==e)this.info^=Dr}get marker(){return(this.info&Dr)>0}get keep(){return(this.info&po)>0}set keep(e){if(this.keep!==e)this.info^=po}get countable(){return(this.info&ho)>0}get deleted(){return(this.info&Cr)>0}set deleted(e){if(this.deleted!==e)this.info^=Cr}markDeleted(){this.info|=Cr}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=U(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=U(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===He&&this.id.client!==this.parent.client&&this.parent.clock>=U(t,this.parent.client))return this.parent.client;if(this.origin)this.left=bc(e,t,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=Ue(e,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===ee||this.right&&this.right.constructor===ee)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===C)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===C)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===He){let r=Xo(t,this.parent);if(r.constructor===ee)this.parent=null;else this.parent=r.content.type}return null}integrate(e,t){if(t>0)this.id.clock+=t,this.left=bc(e,e.doc.store,b(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,n;if(r!==null)n=r.right;else if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start;let o=new Set,s=new Set;while(n!==null&&n!==this.right){if(s.add(n),o.add(n),tn(this.origin,n.origin)){if(n.id.client<this.id.client)r=n,o.clear();else if(tn(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&s.has(Xo(e.doc.store,n.origin))){if(!o.has(Xo(e.doc.store,n.origin)))r=n,o.clear()}else break;n=n.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start,this.parent._start=this;this.right=r}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(e)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(Lc(e.doc.store,this),this.content.integrate(e,this),vc(e,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(e)}else new ee(this.id,this.length).integrate(e,0)}get next(){let e=this.right;while(e!==null&&e.deleted)e=e.right;return e}get prev(){let e=this.left;while(e!==null&&e.deleted)e=e.left;return e}get lastId(){return this.length===1?this.id:b(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&tn(e.origin,this.lastId)&&this.right===e&&tn(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;if(t)t.forEach((r)=>{if(r.p===e){if(r.p=this,!this.deleted&&this.countable)r.index-=this.length}});if(e.keep)this.keep=!0;if(this.right=e.right,this.right!==null)this.right.left=this;return this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;if(this.countable&&this.parentSub===null)t._length-=this.length;this.markDeleted(),cn(e.deleteSet,this.id.client,this.id.clock,this.length),vc(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw H();if(this.content.gc(e),t)Ah(e,this,new ee(this.id,this.length));else this.content=new sr(this.length)}write(e,t){let r=t>0?b(this.id.client,this.id.clock+t-1):this.origin,n=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&jt|(r===null?0:M)|(n===null?0:ie)|(o===null?0:ot);if(e.writeInfo(s),r!==null)e.writeLeftID(r);if(n!==null)e.writeRightID(n);if(r===null&&n===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=zh(i);e.writeParentInfo(!0),e.writeString(a)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else if(i.constructor===String)e.writeParentInfo(!0),e.writeString(i);else if(i.constructor===He)e.writeParentInfo(!1),e.writeLeftID(i);else H();if(o!==null)e.writeString(o)}this.content.write(e,t)}}var pa=(e,t)=>_m[t&jt](e),_m=[()=>{H()},rm,im,tm,um,om,sm,xm,am,nm,()=>{H()}],wm=10;class te extends kn{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){H()}write(e,t){e.writeInfo(wm),w(e.restEncoder,this.length-t)}getMissing(e,t){return null}}var da=typeof globalThis<\"u\"?globalThis:typeof window<\"u\"?window:typeof global<\"u\"?global:{},ha=\"__ $YJS$ __\";if(da[ha]===!0)console.error(\"Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438\");da[ha]=!0;function fr(e){let t=Object.values(e).filter((n)=>typeof n===\"number\");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ms(e,t=\"|\"){return e.map((r)=>xs(r)).join(t)}function pr(e,t){if(typeof t===\"bigint\")return t.toString();return t}class ga{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function dr(e){return new ga(e)}function ya(e){return e===null||e===void 0}function vn(e){let t=e.startsWith(\"^\")?1:0,r=e.endsWith(\"$\")?e.length-1:e.length;return e.slice(t,r)}function xa(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-n)<o)return 0;return r-n}function ue(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function hr(e){let t=Object.getOwnPropertyDescriptor(e,\"shape\");return t?.get?t.get.raw:t?.value}function Te(e){return hr(e._zod.def)??e._zod.def.shape}function _a(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return ue(this,t,n),n},enumerable:!0,configurable:!0})}function wa(e,t,r){if(t in e)ue(e,t,r);else e[t]=r}function tt(e,t,r,n){let o=Te(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);if(!i.enumerable)continue;if(i.get)_a(e,s,()=>{let c=t._zod.def.shape[s];return n?n(c,s):c});else wa(e,s,n?n(i.value,s):i.value)}}function bm(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)_a(e,r,()=>t[r]);else wa(e,r,n.value)}}function ne(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function ba(e){return JSON.stringify(e)}function ka(e){return e.toLowerCase().trim().replace(/[^\\w\\s-]/g,\"\").replace(/[\\s_-]+/g,\"-\").replace(/^-+|-+$/g,\"\")}var gs=\"captureStackTrace\"in Error?Error.captureStackTrace:(...e)=>{};function zt(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}var va=dr(()=>{if(oe.jitless)return!1;if(typeof navigator<\"u\"&&navigator?.userAgent?.includes(\"Cloudflare\"))return!1;try{return new Function(\"\"),!0}catch(e){return!1}});function It(e){if(zt(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!==\"function\")return!0;let r=t.prototype;if(zt(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,\"isPrototypeOf\")===!1)return!1;return!0}function ys(e){if(It(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Sa=new Set([\"string\",\"number\",\"symbol\"]);function je(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function ve(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function y(e){let t=e;if(!t)return{};if(typeof t===\"string\")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}if(delete t.message,typeof t.error===\"string\")return{...t,error:()=>t.error};return t}function xs(e){if(typeof e===\"bigint\")return e.toString()+\"n\";if(typeof e===\"string\")return`\"${e}\"`;return`${e}`}function $a(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===\"optional\")}var Sn=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),_s={int64:[BigInt(\"-9223372036854775808\"),BigInt(\"9223372036854775807\")],uint64:[BigInt(0),BigInt(\"18446744073709551615\")]};function km(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(\".pick() cannot be used on object schemas containing refinements\");let s={};return tt(s,e,$n(e,t)),ve(e,ne(r,{shape:s,checks:[]}))}function $n(e,t){let r=Te(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw Error(`Unrecognized key: \"${String(o)}\"`);if(t[o])n.push(o)}return n}function vm(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(\".omit() cannot be used on object schemas containing refinements\");let s=new Set($n(e,t)),i={};return tt(i,e,Reflect.ownKeys(Te(e)).filter((c)=>!s.has(c))),ve(e,ne(r,{shape:i,checks:[]}))}function Sm(e,t){if(!It(t))throw Error(\"Invalid input to extend: expected a plain object\");let r=e._zod.def.checks;if(r&&r.length>0){let o=Te(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw Error(\"Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.\")}return ve(e,ne(e._zod.def,{shape:za(e,t)}))}function za(e,t){let r={};return tt(r,e,Reflect.ownKeys(Te(e))),bm(r,t),r}function $m(e,t){if(!It(t))throw Error(\"Invalid input to safeExtend: expected a plain object\");return ve(e,ne(e._zod.def,{shape:za(e,t)}))}function zm(e,t){if(!t?._zod?.def)throw Error(\"Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.\");if(e._zod.def.checks?.length)throw Error(\".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.\");let r={};tt(r,e,Reflect.ownKeys(Te(e))),tt(r,t,Reflect.ownKeys(Te(t)));let n=ne(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ve(e,n)}function Ia(e,t,r,n=\"partial\"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${n}() cannot be used on object schemas containing refinements`);let c=r?new Set($n(t,r)):void 0,a={};return tt(a,t,Reflect.ownKeys(Te(t)),e&&((l,u)=>c&&!c.has(u)?l:new e({type:\"optional\",innerType:l}))),ve(t,ne(t._zod.def,{shape:a,checks:[]}))}function Im(e,t,r){let n=r?new Set($n(t,r)):void 0,o={};return tt(o,t,Reflect.ownKeys(Te(t)),(s,i)=>n&&!n.has(i)?s:new e({type:\"nonoptional\",innerType:s})),ve(t,ne(t._zod.def,{shape:o}))}function Se(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ea(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function zn(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function lr(e){return typeof e===\"string\"?e:e?.message}function ws(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;if(o>=0)t.push([o,r])}return t}function In(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Le(e,t,r){var n;let o=e.inst?._zod?.traits;if(o?.has(\"$ZodType\"))if(o.has(\"$ZodCheck\"))(n=e).schema??(n.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:lr(e.inst?._zod.def?.error?.(e))??lr(s?.(e))??lr(t?.error?.(e))??lr(r.customError?.(e))??lr(r.localeError?.(e))??\"Invalid input\",c={};for(let a of Object.keys(e)){if(a===\"inst\"||a===\"schema\"||a===\"continue\"||a===\"input\"||a===\"__proto__\")continue;c[a]=e[a]}if(c.path??(c.path=[]),c.message=i,t?.reportInput)c.input=e.input;return c}var Em=/[\\uD800-\\uDBFF]/;function En(e){let t=e.length;if(!Em.test(e))return t;let r=t;for(let n=0;n<t-1;n++)if((e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320)r--,n++;return r}function An(e){if(Array.isArray(e))return\"array\";if(typeof e===\"string\")return\"string\";return\"unknown\"}function Aa(e){let t=typeof e;switch(t){case\"number\":return Number.isNaN(e)?\"nan\":\"number\";case\"object\":{if(e===null)return\"null\";if(Array.isArray(e))return\"array\";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&\"constructor\"in r&&r.constructor)return r.constructor.name}}return t}function rt(...e){let[t,r,n]=e;if(typeof t===\"string\")return{message:t,code:\"custom\",input:r,inst:n};return{...t}}function Oa(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else Am(e,r,n.value)}}function Pe(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function On(e,t,r){return Pe(e,t,r,!1)}function Ta(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Pe(this,r,n(this))},set(o){Pe(this,r,o)}})}return t}function Am(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Pe(this,t,r.bind(this))},set(n){Pe(this,t,n)}})}function Om(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var hs,Re=!1,Tm={configurable:!0,get(){Re=!0;return}};function k(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&hs!==e._zod){hs=void 0;return}hs=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Tm);let o=Re;Re=!1;try{let s=r(this);if(Re)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Re=Re||o,s}catch(s){throw delete this[t],Re=Re||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Pm(e,t,r,n){let o=Om(e,t);if(!o)return;Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Zm=\"~constantCatch\";function Pa(e){let t=()=>e;return t[Zm]=!0,t}var Za;var bs={value:void 0,enumerable:!1},Ca=\"captureStackTrace\"in Error?Error:null;function Cm(e){let t=Ca;if(t){let r=t.stackTraceLimit;if(typeof r===\"number\"){try{t.stackTraceLimit=0}catch{return Ca=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function m(e,t,r,n){let o={};function s(p){this.def=p,this.constr=f,this.traits=new Set}s.prototype=o;let i=r,c=i&&new WeakSet;function a(p,d){if(!p._zod){bs.value=new s(d);try{Object.defineProperty(p,\"_zod\",bs)}finally{bs.value=void 0}}else if(p._zod.traits.has(e))return;if(p._zod.traits.add(e),t(p,d),c){let g=Object.getPrototypeOf(p),x=p._zod.constr.prototype,S=g;while(S&&S!==x)S=Object.getPrototypeOf(S);let de=S??g;if(!c.has(de))c.add(de),Oa(de,i)}let h=f.prototype;for(let g in h){if(!Object.prototype.hasOwnProperty.call(h,g))continue;if(!(g in p))p[g]=h[g].bind(p)}}let l=n?.Parent??Object;class u extends l{}Object.defineProperty(u,\"name\",{value:e});function f(p){let d=n?.Parent?Cm(u):this;a(d,p);let h=d._zod.deferred;if(h){for(let x of h)x();d._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;if(g)g(d);return d}return Object.defineProperty(f,\"init\",{value:a}),Object.defineProperty(f,Symbol.hasInstance,{value:(p)=>{if(n?.Parent&&p instanceof n.Parent)return!0;return p?._zod?.traits?.has(e)}}),Object.defineProperty(f,\"name\",{value:e}),f}class $e extends Error{constructor(){super(\"Encountered Promise during synchronous parse. Use .parseAsync() instead.\")}}class mr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name=\"ZodEncodeError\"}}(Za=globalThis).__zod_globalConfig??(Za.__zod_globalConfig={});var oe=globalThis.__zod_globalConfig;function fe(e){if(e)Object.assign(oe,e);return oe}function Dm(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,pr,2)),e.message}function Nm(e){this._zod.message=e}var Um={get:Dm,set:Nm,enumerable:!0,configurable:!0},vs={value:void 0,enumerable:!1},Da=new WeakSet([Object.prototype,Error.prototype]),Na=(e,t)=>{e.name=\"$ZodError\",vs.value=t,Object.defineProperty(e,\"issues\",vs),vs.value=void 0,Object.defineProperty(e,\"message\",Um);let r=Object.getPrototypeOf(e);if(!Da.has(r))Da.add(r),Object.defineProperty(r,\"toString\",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,\"toString\",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,\"toString\",{value:n,configurable:!0,writable:!0})}})},Ua=m(\"$ZodError\",Na),zx=m(\"$ZodError\",Na,void 0,{Parent:Error});function Rm(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t===\"__proto__\")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function Ra(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)Rm(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function ja(e,t=(r)=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code===\"invalid_union\"&&i.errors.length)i.errors.map((c)=>n({issues:c},[...s,...i.path]));else if(i.code===\"invalid_key\")n({issues:i.issues},[...s,...i.path]);else if(i.code===\"invalid_element\")n({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)r._errors.push(t(i));else{let a=r,l=0;while(l<c.length){let u=c[l],f=l===c.length-1;if(u===\"_errors\"){if(f)a._errors.push(t(i));l++;continue}if(!Object.prototype.hasOwnProperty.call(a,u))Object.defineProperty(a,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=a[u];if(f)p._errors.push(t(i));a=p,l++}}}};return n(e),r}function Tn(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Pn=(e)=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},c=r._zod.run({value:n,issues:[]},i);if(c instanceof Promise)throw new $e;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((l)=>Le(l,i,fe())));throw gs(a,s?.callee??t),a}return c.value};return t};var Zn=(e)=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},c=r._zod.run({value:n,issues:[]},i);if(c instanceof Promise)c=await c;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((l)=>Le(l,i,fe())));throw gs(a,s?.callee??t),a}return c.value};return t};var Cn=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new $e;return s.issues.length?La(e,s.issues,o):{success:!0,data:s.value}};function La(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>Le(o,r,fe()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var Dn=(e)=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)s=await s;return s.issues.length?La(e,s.issues,o):{success:!0,data:s.value}};var jm=Symbol.for(\"zod.compile.invalid\"),Lm=Symbol.for(\"zod.compile.fallback\"),Ss=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==jm)return!0;if(n.definite===!0&&r===void 0)return!1}return Bm(e,t,r)};function Bm(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o)n[Lm]=!0,s=o({value:t,issues:[]},n);else s=e._zod.run({value:t,issues:[]},n);if(s instanceof Promise)throw new $e;return s.issues.length===0}var $s=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);if(o instanceof Promise)o=await o;return o.issues.length===0},Ba=(e)=>{let t=Pn(e),r=(n,o,s,i)=>{let c=s?{...s,direction:\"backward\"}:{direction:\"backward\"};return t(n,o,c,Tn(r,i))};return r};var Ma=(e)=>{let t=Pn(e),r=(n,o,s,i)=>t(n,o,s,Tn(r,i));return r};var Va=(e)=>{let t=Zn(e),r=async(n,o,s,i)=>{let c=s?{...s,direction:\"backward\"}:{direction:\"backward\"};return await t(n,o,c,Tn(r,i))};return r};var Fa=(e)=>{let t=Zn(e),r=async(n,o,s,i)=>await t(n,o,s,Tn(r,i));return r};var Ja=(e)=>(t,r,n)=>{let o=n?{...n,direction:\"backward\"}:{direction:\"backward\"};return Cn(e)(t,r,o)};var Ka=(e)=>(t,r,n)=>Cn(e)(t,r,n);var qa=(e)=>async(t,r,n)=>{let o=n?{...n,direction:\"backward\"}:{direction:\"backward\"};return Dn(e)(t,r,o)};var Ga=(e)=>async(t,r,n)=>Dn(e)(t,r,n);var Wa=/^[cC][0-9a-z]{6,}$/,Ha=/^[0-9a-z]+$/,Ya=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Xa=/^[0-9a-vA-V]{20}$/,Qa=/^[A-Za-z0-9]{27}$/,eu=/^[a-zA-Z0-9_-]{21}$/;function tu(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ru=/^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$/;var nu=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Is=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var ou=/^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/;var Mm=\"^(?=[\\\\s\\\\S]*[\\\\p{Extended_Pictographic}\\\\p{Regional_Indicator}\\\\u20E3])[\\\\p{Extended_Pictographic}\\\\p{Emoji_Component}]+$\";function su(){return new RegExp(Mm,\"u\")}var iu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var au=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$/,uu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fu=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var pu=/^https?$/,du=/^\\+[1-9]\\d{6,14}$/;var hu=\"(?:(?:\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\\\d|30)|(?:02)-(?:0[1-9]|1\\\\d|2[0-8])))\";function Vm(e){return new RegExp(`^${e}$`)}var mu=Vm(hu);function zs(e){return typeof e.precision===\"number\"?e.precision===-1?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d\":e.precision===0?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\":`(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\\\\.\\\\d{${e.precision}}`:e.seconds?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d(?:\\\\.\\\\d+)?\":\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d(?::[0-5]\\\\d(?:\\\\.\\\\d+)?)?\"}function gu(e){return new RegExp(`^${zs(e)}$`)}function yu(e){let t=[\"Z\"];if(e.offset)t.push(\"([+-](?:[01]\\\\d|2[0-3]):[0-5]\\\\d)\");let r=`${zs({precision:e.precision,seconds:!0})}(?:${t.join(\"|\")})`,n=e.local?`${r}|${zs({precision:e.precision})}`:r;return new RegExp(`^${hu}T(?:${n})$`)}var xu=/^[\\s\\S]{0,}$/;var Es=/^-?\\d+(?:\\.\\d+)?$/;var _u=/^[^A-Z]*$/,wu=/^[^a-z]*$/;var L=m(\"$ZodCheck\",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var As=(e)=>{let t=e.value;return!ya(t)&&t.length!==void 0},Nn={number:\"number\",bigint:\"bigint\",object:\"date\"},Os=m(\"$ZodCheckLessThan\",(e,t)=>{L.init(e,t);let r=Nn[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:Nn[typeof n.value]??r,code:\"too_big\",maximum:typeof t.value===\"object\"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ts=m(\"$ZodCheckGreaterThan\",(e,t)=>{L.init(e,t);let r=Nn[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:Nn[typeof n.value]??r,code:\"too_small\",minimum:typeof t.value===\"object\"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bu=m(\"$ZodCheckMultipleOf\",(e,t)=>{L.init(e,t),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error(\"Cannot mix number and bigint in multiple_of check.\");if(typeof r.value===\"bigint\"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):xa(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:\"not_multiple_of\",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),ku=m(\"$ZodCheckNumberFormat\",(e,t)=>{L.init(e,t),t.format=t.format||\"float64\";let r=t.format?.includes(\"int\"),n=r?\"int\":\"number\",[o,s]=Sn[t.format];e._zod.check=(i)=>{let c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:\"invalid_type\",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)i.issues.push({input:c,code:\"too_big\",maximum:Number.MAX_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:n,inclusive:!0,continue:!t.abort});else i.issues.push({input:c,code:\"too_small\",minimum:Number.MIN_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(c<o)i.issues.push({origin:\"number\",input:c,code:\"too_small\",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(c>s)i.issues.push({origin:\"number\",input:c,code:\"too_big\",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var vu=m(\"$ZodCheckMaxLength\",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=As),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o===\"string\"&&s>t.maximum?En(o):s)<=t.maximum)return;let c=An(o);n.issues.push({origin:c,code:\"too_big\",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Su=m(\"$ZodCheckMinLength\",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=As),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o===\"string\"&&s>=t.minimum&&s<t.minimum*2?En(o):s)>=t.minimum)return;let c=An(o);n.issues.push({origin:c,code:\"too_small\",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),$u=m(\"$ZodCheckLengthEquals\",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=As),e._zod.check=(n)=>{let o=n.value,s=o.length,i=typeof o===\"string\"&&s>=t.length&&s<=t.length*2?En(o):s;if(i===t.length)return;let c=An(o),a=i>t.length;n.issues.push({origin:c,...a?{code:\"too_big\",maximum:t.length}:{code:\"too_small\",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yr=m(\"$ZodCheckStringFormat\",(e,t)=>{var r,n;if(L.init(e,t),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),zu=m(\"$ZodCheckRegex\",(e,t)=>{yr.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"regex\",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Iu=m(\"$ZodCheckLowerCase\",(e,t)=>{t.pattern??(t.pattern=_u),yr.init(e,t)}),Eu=m(\"$ZodCheckUpperCase\",(e,t)=>{t.pattern??(t.pattern=wu),yr.init(e,t)}),Au=m(\"$ZodCheckIncludes\",(e,t)=>{L.init(e,t);let r=je(t.includes),n=new RegExp(typeof t.position===\"number\"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:\"includes\",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Ou=m(\"$ZodCheckStartsWith\",(e,t)=>{L.init(e,t);let r=new RegExp(`^${je(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"starts_with\",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Tu=m(\"$ZodCheckEndsWith\",(e,t)=>{L.init(e,t);let r=new RegExp(`.*${je(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"ends_with\",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Pu=m(\"$ZodCheckOverwrite\",(e,t)=>{L.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Ps{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e===\"function\"){e(this,{execution:\"sync\"}),e(this,{execution:\"async\"});return}let r=e.split(`\n`).filter((s)=>s),n=Math.min(...r.map((s)=>s.length-s.trimStart().length)),o=r.map((s)=>s.slice(n)).map((s)=>\" \".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let e=Function,t=this?.content??[\"\"];return new e(...Object.keys(this.closed),`return function (${this.args.join(\", \")}) {\n${t.join(`\n`)}\n};`)(...Object.values(this.closed))}}var Cu={major:4,minor:6,patch:7};var A=m(\"$ZodType\",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Cu;let n=e._zod.def.checks,o=e._zod.traits.has(\"$ZodCheck\")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(c,a,l)=>{if(c.memo)return c;let u=Se(c),f;for(let p of a){if(p._zod.def.when){if(Ea(c))continue;if(!p._zod.def.when(c))continue}else if(u)continue;let d=c.issues.length,h=p._zod.check(c);if(h instanceof Promise&&l?.async===!1)throw new $e;if(f||h instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await h,c.issues.length===d)return;if(In(c.issues,d,e),!u)u=Se(c,d)});else{if(c.issues.length===d)continue;if(In(c.issues,d,e),!u)u=Se(c,d)}}if(f)return f.then(()=>c);return c},i=(c,a,l)=>{if(Se(c))return c.aborted=!0,c;let u=s(a,o,l);if(u instanceof Promise){if(l.async===!1)throw new $e;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction===\"backward\"){let u=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>i(f,c,a));return i(u,c,a)}let l=e._zod.parse(c,a);if(l instanceof Promise){if(a.async===!1)throw new $e;return l.then((u)=>s(u,o,a))}return s(l,o,a)}}},{get \"~standard\"(){return On(this,\"~standard\",Cs(this))},set \"~standard\"(e){Pe(this,\"~standard\",e)}}),Ju=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>Le(r,t,fe()))}:{value:e.value};async function Jm(e,t){let r={async:!0};return Ju(await e._zod.run({value:t,issues:[]},r),r)}function Cs(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Ju(n,r)}catch(n){}return Jm(e,t)},vendor:\"zod\",version:1}}var Ln=m(\"$ZodString\",(e,t)=>{A.init(e,t),e._zod.pattern=t.pattern??xu,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value===\"string\")return r;return r.issues.push({expected:\"string\",code:\"invalid_type\",input:r.value,inst:e}),r}}),I=m(\"$ZodStringFormat\",(e,t)=>{yr.init(e,t),Ln.init(e,t)}),Ku=m(\"$ZodGUID\",(e,t)=>{t.pattern??(t.pattern=nu),I.init(e,t)}),qu=m(\"$ZodUUID\",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: \"${t.version}\"`);t.pattern??(t.pattern=Is(n))}else t.pattern??(t.pattern=Is());I.init(e,t)}),Gu=m(\"$ZodEmail\",(e,t)=>{t.pattern??(t.pattern=ou),I.init(e,t)}),Wu=1,Rn=2;function Hu(e){try{if(typeof URL<\"u\"&&typeof URL.canParse===\"function\")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Km(e,t){if(!(\"normalize\"in t)&&!(\"hostname\"in t)&&!(\"protocol\"in t))return Hu(e)||Rn;return qm(e,t)}function qm(e,t){if(!t.normalize&&t.protocol?.source===pu.source&&!/^https?:\\/\\//i.test(e))return Wu;try{if(typeof URL<\"u\"){let r=URL;if(typeof r.parse===\"function\")return r.parse(e)??Rn}return new URL(e)}catch{return Rn}}var Gm=/[\\t\\n\\r]/g;function Du(e){return e.replace(Gm,\"\")}function Wm(e,t){return t.lastIndex=0,t.test(e.hostname)}function Hm(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(\":\")?e.protocol.slice(0,-1):e.protocol)}var Yu=m(\"$ZodURL\",(e,t)=>{I.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=Km(n,t);if(o===Wu){r.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid URL format\",input:r.value,inst:e,continue:!t.abort});return}if(o===Rn){r.issues.push({code:\"invalid_format\",format:\"url\",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Du(n);return}if(t.hostname&&!Wm(o,t.hostname))r.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid hostname\",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!Hm(o,t.protocol))r.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid protocol\",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?o.href:Du(n);return}catch(n){r.issues.push({code:\"invalid_format\",format:\"url\",input:r.value,inst:e,continue:!t.abort})}}}),Xu=m(\"$ZodEmoji\",(e,t)=>{t.pattern??(t.pattern=su()),I.init(e,t)}),Qu=m(\"$ZodNanoID\",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?eu:tu(t.length)),I.init(e,t)}),el=m(\"$ZodCUID\",(e,t)=>{t.pattern??(t.pattern=Wa),I.init(e,t)}),tl=m(\"$ZodCUID2\",(e,t)=>{t.pattern??(t.pattern=Ha),I.init(e,t)}),rl=m(\"$ZodULID\",(e,t)=>{t.pattern??(t.pattern=Ya),I.init(e,t)}),nl=m(\"$ZodXID\",(e,t)=>{t.pattern??(t.pattern=Xa),I.init(e,t)}),ol=m(\"$ZodKSUID\",(e,t)=>{t.pattern??(t.pattern=Qa),I.init(e,t)}),sl=m(\"$ZodISODateTime\",(e,t)=>{t.pattern??(t.pattern=yu(t)),I.init(e,t)}),il=m(\"$ZodISODate\",(e,t)=>{t.pattern??(t.pattern=mu),I.init(e,t)}),cl=m(\"$ZodISOTime\",(e,t)=>{t.pattern??(t.pattern=gu(t)),I.init(e,t)}),al=m(\"$ZodISODuration\",(e,t)=>{t.pattern??(t.pattern=ru),I.init(e,t)}),ul=m(\"$ZodIPv4\",(e,t)=>{t.pattern??(t.pattern=iu),I.init(e,t)}),Ym=/^[0-9a-fA-F:.]+$/;function ll(e){if(!Ym.test(e))return!1;return Hu(`http://[${e}]`)}var fl=m(\"$ZodIPv6\",(e,t)=>{t.pattern??(t.pattern=cu),I.init(e,t),e._zod.check=(r)=>{if(!ll(r.value))r.issues.push({code:\"invalid_format\",format:\"ipv6\",input:r.value,inst:e,continue:!t.abort})}});var pl=m(\"$ZodCIDRv4\",(e,t)=>{t.pattern??(t.pattern=au),I.init(e,t)});function Xm(e){let t=e.split(\"/\");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);if(`${o}`!==n)return!1;if(o<0||o>128)return!1;return ll(r)}var dl=m(\"$ZodCIDRv6\",(e,t)=>{t.pattern??(t.pattern=uu),I.init(e,t),e._zod.check=(r)=>{if(!Xm(r.value))r.issues.push({code:\"invalid_format\",format:\"cidrv6\",input:r.value,inst:e,continue:!t.abort})}});function hl(e){if(e===\"\")return!0;if(/\\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ds=/^[0-9a-zA-Z+/]*={0,2}$/,ml=m(\"$ZodBase64\",(e,t)=>{t.pattern??(t.pattern=Ds),I.init(e,t),e._zod.check=(r)=>{if(hl(r.value))return;r.issues.push({code:\"invalid_format\",format:\"base64\",input:r.value,inst:e,continue:!t.abort})}}),Bn=/^[A-Za-z0-9_-]*$/;function Qm(e){if(!Bn.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n===\"-\"?\"+\":\"/\"),r=t.padEnd(Math.ceil(t.length/4)*4,\"=\");return hl(r)}var gl=m(\"$ZodBase64URL\",(e,t)=>{t.pattern??(t.pattern=Bn),I.init(e,t),e._zod.check=(r)=>{if(Qm(r.value))return;r.issues.push({code:\"invalid_format\",format:\"base64url\",input:r.value,inst:e,continue:!t.abort})}}),yl=m(\"$ZodE164\",(e,t)=>{t.pattern??(t.pattern=du),I.init(e,t)});function eg(e,t=null){try{let r=e.split(\".\");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if(\"typ\"in o&&o?.typ!==\"JWT\")return!1;if(!o.alg)return!1;if(t&&(!(\"alg\"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var xl=m(\"$ZodJWT\",(e,t)=>{I.init(e,t),e._zod.check=(r)=>{if(eg(r.value,t.alg))return;r.issues.push({code:\"invalid_format\",format:\"jwt\",input:r.value,inst:e,continue:!t.abort})}});var Ns=m(\"$ZodNumber\",(e,t)=>{A.init(e,t),e._zod.pattern=Es,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let o=r.value;if(typeof o===\"number\"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o===\"number\"?Number.isNaN(o)?\"NaN\":!Number.isFinite(o)?String(o):void 0:void 0;return r.issues.push({expected:\"number\",code:\"invalid_type\",input:o,inst:e,...s?{received:s}:{}}),r}}),_l=m(\"$ZodNumberFormat\",(e,t)=>{ku.init(e,t),Ns.init(e,t)});var wl=m(\"$ZodUnknown\",(e,t)=>{A.init(e,t),e._zod.parse=(r)=>r}),bl=m(\"$ZodNever\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:\"never\",code:\"invalid_type\",input:r.value,inst:e}),r)});function tg(e,t){let r=ws(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map((s)=>s[0])),o=e._zod.parse;e._zod.parse=(s,i)=>{let c=t(s.value);if(c>n&&!i?.skipChecks&&i?.direction!==\"backward\"){for(let[a,l]of ws(e._zod.def.checks))if(c>a&&l._zod.def.when(s)){let u=s.issues.length;return l._zod.check(s),s.issues[u].continue=!1,In(s.issues,u,e),s}}return o(s,i)}}var rg=(e)=>Array.isArray(e)?e.length:-1;function Nu(e,t,r){if(e.issues.length)t.issues.push(...zn(r,e.issues));t.value[r]=e.value}var kl=m(\"$ZodArray\",(e,t)=>{A.init(e,t);let r=oe.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:\"array\",code:\"invalid_type\",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],c=o?.abortEarly;for(let a=0;a<s.length;a++){let l=s[a],u=t.element._zod.run({value:l,issues:[]},o);if(u instanceof Promise)i.push(u.then((f)=>Nu(f,n,a)));else if(Nu(u,n,a),c&&u.issues.length!==0&&Se(u))break}if(i.length)return Promise.all(i).then(()=>n);return n},tg(e,rg)});function jn(e,t,r,n,o,s){let i=r in n,c=s===\"optional\";if(!i&&c&&o===\"optional\")return;if(e.issues.length){if(o!==void 0&&c&&!i)return;t.issues.push(...zn(r,e.issues))}if(!i&&o===void 0){if(!e.issues.length)t.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:void 0,path:[r]});return}if(e.value===void 0){if(i||o===\"defaulted\"&&!c)t.value[r]=void 0}else t.value[r]=e.value}var ng=[];function vl(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:ng,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has(\"$ZodType\"))throw Error(`Invalid element at key \"${String(i)}\": expected a Zod schema`);let s=$a(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Sl(e,t,r,n,o,s,i){let c=[],a=o.keySet,l=o.catchall._zod,u=l.def.type,{optin:f,optout:p}=l,d=0;for(let h in t){if(i&&r.issues.length!==d){if(Se(r,d))break;d=r.issues.length}if(a.has(h))continue;if(h===\"__proto__\"){if(u===\"never\")c.push(h);continue}if(u===\"never\"){c.push(h);continue}let g=l.run({value:t[h],issues:[]},n);if(g instanceof Promise)e.push(g.then((x)=>jn(x,r,h,t,f,p)));else jn(g,r,h,t,f,p)}if(c.length)r.issues.push({code:\"unrecognized_keys\",keys:c,input:t,inst:s,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var og=m(\"$ZodObject\",(e,t)=>{A.init(e,t);let r=Object.getOwnPropertyDescriptor(t,\"shape\"),n=r?.get?r.get.raw:t.shape??{};if(n){let l=()=>{let u={...n};return Object.defineProperty(t,\"shape\",{value:u}),l.raw=u,u};l.raw=n,Object.defineProperty(t,\"shape\",{get:l})}let o=dr(()=>vl(t));k(e,\"propValues\",(l)=>{let u=l.def.shape,f={};for(let p in u){let d=u[p]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,p))ue(f,p,new Set);for(let h of d.values)f[p].add(h);if(d.optin!==void 0)f[p].add(void 0)}}return f});let s=zt,i=t.catchall,c,a=oe.memoizer;a?.attach(e),e._zod.parse=(l,u)=>{c??(c=o.value);let f=l.value;if(!s(f))return l.issues.push({expected:\"object\",code:\"invalid_type\",input:f,inst:e}),l;l.value=a?a.alloc(e,l,{},u):{};let p=[],d=c.shape,h=u?.abortEarly,g=l.issues.length;for(let x of c.allKeys){if(h&&l.issues.length!==g){if(Se(l,g))break;g=l.issues.length}if(x===\"__proto__\")continue;let S=d[x],de=S._zod.optin,Ct=S._zod.optout,Dt=S._zod.run({value:f[x],issues:[]},u);if(Dt instanceof Promise)p.push(Dt.then((P)=>jn(P,l,x,f,de,Ct)));else jn(Dt,l,x,f,de,Ct)}if(!i)return p.length?Promise.all(p).then(()=>l):l;return Sl(p,f,l,u,o.value,e,h===!0)}}),$l=m(\"$ZodObjectJIT\",(e,t)=>{og.init(e,t);let r=e._zod.parse,n=dr(()=>vl(t)),o=oe.memoizer,s=(d)=>{let h=n.value,g=h.symbolKeys,x=new Ps([\"payload\",\"ctx\"],{shape:d,inst:e,memo:o,syms:g}),S=(P)=>`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`,de=(P,z)=>`\n let ${P}_ab = false;\n for (let i = 0; i < ${P}.issues.length; i++) {\n const iss = ${P}.issues[i];\n iss.path = iss.path ? [${z}, ...iss.path] : [${z}];\n payload.issues.push(iss);\n if (iss.continue !== true) ${P}_ab = true;\n }\n if (${P}_ab && ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }`;x.write(\"const input = payload.value;\");let Ct=Object.create(null),Dt=0;for(let P of h.allKeys)Ct[P]=`key_${Dt++}`;x.write(o?\"const newResult = memo.alloc(inst, payload, {}, ctx);\":\"const newResult = {};\");for(let P of h.allKeys){if(P===\"__proto__\")continue;let z=Ct[P],he=typeof P===\"symbol\"?`syms[${g.indexOf(P)}]`:ba(P),ao=`${he} in input`,di=d[P],uo=di?._zod?.optin,hi=uo!==void 0,Fp=di?._zod?.optout===\"optional\";if(x.write(`const ${z} = ${S(he)};`),hi&&Fp){let Jp=uo===\"optional\"?`${z}_present`:`${z}.value !== undefined || ${z}_present`;x.write(`\n const ${z}_present = ${ao};\n if (!${z}.issues.length || ${z}_present) {\n if (${z}.issues.length) {${de(z,he)}\n }\n\n if (${Jp}) {\n newResult[${he}] = ${z}.value;\n }\n }\n\n `)}else if(!hi)x.write(`\n const ${z}_present = ${ao};\n if (${z}.issues.length) {${de(z,he)}\n }\n if (!${z}_present && !${z}.issues.length) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [${he}]\n });\n if (ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }\n }\n\n if (${z}_present) {\n newResult[${he}] = ${z}.value;\n }\n\n `);else if(x.write(`\n if (${z}.issues.length) {${de(z,he)}\n }\n `),uo===\"defaulted\")x.write(`newResult[${he}] = ${z}.value;`);else x.write(`\n if (${z}.value !== undefined || ${ao}) {\n newResult[${he}] = ${z}.value;\n }\n `)}return x.write(\"payload.value = newResult;\"),x.write(\"return payload;\"),x.compile()},i,c=zt,a=!oe.jitless,u=a&&va.value,f=t.catchall,p;e._zod.parse=(d,h)=>{p??(p=n.value);let g=d.value;if(!c(g))return d.issues.push({expected:\"object\",code:\"invalid_type\",input:g,inst:e}),d;if(a&&u&&h?.async===!1&&h.jitless!==!0){if(!i)i=s(t.shape);if(d=i(d,h),!f)return d;return Sl([],g,d,h,p,e,h?.abortEarly===!0)}return r(d,h)}});function Uu(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter((s)=>!Se(s));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:\"invalid_union\",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((i)=>Le(i,n,fe())))}),t}var Us=m(\"$ZodUnion\",(e,t)=>{A.init(e,t),k(e,\"optin\",(n)=>n.def.options.some((o)=>o._zod.optin===\"defaulted\")?\"defaulted\":n.def.options.some((o)=>o._zod.optin!==void 0)?\"optional\":void 0),k(e,\"optout\",(n)=>n.def.options.some((o)=>o._zod.optout===\"optional\")?\"optional\":void 0),k(e,\"values\",(n)=>{if(n.def.options.every((o)=>o._zod.values))return new Set(n.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),k(e,\"pattern\",(n)=>{if(n.def.options.every((o)=>o._zod.pattern)){let o=n.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${o.map((s)=>vn(s.source)).join(\"|\")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:n.value,issues:[]},o);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}if(!s)return Uu(i,n,e,o);return Promise.all(i).then((c)=>Uu(c,n,e,o))}});function sg(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw Error(`Invalid discriminated union option at index \"${e.options.indexOf(r)}\"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value \"${String(o)}\"`);t.set(o,null)}else t.set(o,r)}return t}var zl=m(\"$ZodDiscriminatedUnion\",(e,t)=>{t.inclusive=!1,Us.init(e,t);let r=e._zod.parse;k(e,\"propValues\",(o)=>{let s={},i=0;for(let c of o.def.options){let a=c._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index \"${o.def.options.indexOf(c)}\"`);if(a[o.def.discriminator]?.has(void 0))i++;for(let[l,u]of Object.entries(a)){if(!Object.prototype.hasOwnProperty.call(s,l))ue(s,l,new Set);for(let f of u)s[l].add(f)}}if(!o.def.unionFallback&&i>1)s[o.def.discriminator]?.delete(void 0);return s}),t.options.forEach((o,s)=>{let i=hr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index \"${s}\"`)});let n=dr(()=>sg(t));e._zod.parse=(o,s)=>{let i=o.value;if(!zt(i))return o.issues.push({code:\"invalid_type\",expected:\"object\",input:i,inst:e}),o;let c=i?.[t.discriminator],a=n.value.get(c);if(a&&(c!==void 0||s.direction!==\"backward\"))return a._zod.run(o,s);if(t.unionFallback||s.direction===\"backward\")return r(o,s);return o.issues.push({code:\"invalid_union\",errors:[],note:\"No matching discriminator\",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter((l)=>n.value.get(l)!==null),input:i,path:[t.discriminator],inst:e}),o}}),Il=m(\"$ZodIntersection\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([a,l])=>Ru(r,a,l));return Ru(r,s,i)}});function Zs(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(It(e)&&It(t)){let r=Object.keys(t),n=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,\"__proto__\"))delete o.__proto__;for(let s of n){if(s===\"__proto__\")continue;let i=Zs(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Zs(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Ru(e,t,r){let n=new Map,o,s=new Map,i=(l,u)=>{let f;if(l.code===\"unrecognized_keys\"&&!l.path?.length)o??(o=l),f=l.keys;else if(l.code===\"invalid_key\"&&l.origin===\"record\"&&l.path?.length===1){let p=String(l.path[0]);if(!s.has(p))s.set(p,l);f=[p]}else return!1;for(let p of f){if(!n.has(p))n.set(p,{});n.get(p)[u]=!0}return!0};for(let l of t.issues)if(!i(l,\"l\"))e.issues.push(l);for(let l of r.issues)if(!i(l,\"r\"))e.issues.push(l);let c=[...n].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(c.length){let l=o?c.filter((u)=>o.keys.includes(u)):[];if(l.length)e.issues.push({...o,keys:l});for(let u of c)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let a=Zs(t.value,r.value);if(!a.valid){if(Se(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}var El=m(\"$ZodEnum\",(e,t)=>{A.init(e,t);let r=fr(t.entries),n=new Set(r);e._zod.values=n,k(e,\"pattern\",(o)=>{let s=fr(o.def.entries).filter((i)=>Sa.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>je(i.toString())).join(\"|\")})$`:\"^[^\\\\s\\\\S]$\")}),e._zod.parse=(o,s)=>{let i=o.value;if(n.has(i))return o;return o.issues.push({code:\"invalid_value\",values:r,input:i,inst:e}),o}}),Al=m(\"$ZodLiteral\",(e,t)=>{A.init(e,t);let r=new Set(t.values);e._zod.values=r,k(e,\"pattern\",(n)=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map((s)=>typeof s===\"string\"?je(s):s?je(s.toString()):String(s)).join(\"|\")})$`:\"^[^\\\\s\\\\S]$\")}),e._zod.parse=(n,o)=>{let s=n.value;if(r.has(s))return n;return n.issues.push({code:\"invalid_value\",values:t.values,input:s,inst:e}),n}});var Ol=m(\"$ZodTransform\",(e,t)=>{A.init(e,t),e._zod.optin=\"optional\",oe.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")throw new mr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((i)=>(r.value=i,r));if(o instanceof Promise)throw new $e;return r.value=o,r}});function ju(e,t){return e.value=t.issues.length?void 0:t.value,e}var Rs=m(\"$ZodOptional\",(e,t)=>{A.init(e,t),k(e,\"optin\",(r)=>r.def.innerType._zod.optin===\"defaulted\"?\"defaulted\":\"optional\"),e._zod.optout=\"optional\",k(e,\"values\",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),k(e,\"pattern\",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${vn(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!==\"defaulted\")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>ju(r,s));return ju(r,o)}return t.innerType._zod.run(r,n)}}),Tl=m(\"$ZodExactOptional\",(e,t)=>{Rs.init(e,t),k(e,\"values\",(r)=>r.def.innerType._zod.values),k(e,\"pattern\",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Pl=m(\"$ZodNullable\",(e,t)=>{A.init(e,t),k(e,\"optin\",(r)=>r.def.innerType._zod.optin),k(e,\"optout\",(r)=>r.def.innerType._zod.optout),k(e,\"pattern\",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${vn(n.source)}|null)$`):void 0}),k(e,\"values\",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),Zl=m(\"$ZodDefault\",(e,t)=>{A.init(e,t),e._zod.optin=\"defaulted\",k(e,\"values\",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Lu(s,t));return Lu(o,t)}});function Lu(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Cl=m(\"$ZodPrefault\",(e,t)=>{A.init(e,t),e._zod.optin=\"defaulted\",k(e,\"values\",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),Dl=m(\"$ZodNonOptional\",(e,t)=>{A.init(e,t),k(e,\"values\",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Bu(s,e));return Bu(o,e)}});function Bu(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:e.value,inst:t});return e}function Mu(e,t,r,n){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>Le(o,n,fe()))},input:e.value}),e}var Nl=m(\"$ZodCatch\",(e,t)=>{A.init(e,t),k(e,\"optin\",(r)=>r.def.innerType._zod.optin===\"defaulted\"?\"defaulted\":\"optional\"),k(e,\"optout\",(r)=>r.def.innerType._zod.optout),k(e,\"values\",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>Mu(r,s,t,n));return Mu(r,o,t,n)}});var Ul=m(\"$ZodPipe\",(e,t)=>{A.init(e,t),k(e,\"values\",(r)=>r.def.in._zod.values),k(e,\"optin\",(r)=>r.def.in._zod.optin),k(e,\"optout\",(r)=>r.def.out._zod.optout),k(e,\"propValues\",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction===\"backward\"){let s=t.out._zod.run(r,n);if(s instanceof Promise)return s.then((i)=>Un(i,t.in,n));return Un(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Un(s,t.out,n));return Un(o,t.out,n)}});function Un(e,t,r){if(e.issues.some((n)=>n.code!==\"unrecognized_keys\"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var Rl=m(\"$ZodReadonly\",(e,t)=>{A.init(e,t),k(e,\"propValues\",(r)=>r.def.innerType._zod.propValues),k(e,\"values\",(r)=>r.def.innerType._zod.values),k(e,\"optin\",(r)=>r.def.innerType?._zod?.optin),k(e,\"optout\",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(Vu);return Vu(o)}});function Vu(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var jl=m(\"$ZodCustom\",(e,t)=>{L.init(e,t),A.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((s)=>Fu(s,r,n,e));Fu(o,r,n,e);return}});function Fu(e,t,r,n){if(!e){let o={code:\"custom\",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(rt(o))}}class Bl extends Error{constructor(){super(\"Cannot parse a reference cycle that closes through a transform\");this.name=\"ZodCyclicError\"}}var Ls=\"~memo\",Ll=[];function Ml(e){return e!==null&&typeof e===\"object\"}function js(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Vl=new WeakMap,xr=0,Fn=1,_r=2;function Jn(e,t,r){let n=Vl.get(e);if(n!==void 0)return n?_r:xr;if(t.has(e))return _r;t.add(e);let o=xr,s=(u)=>{if(o!==_r&&u?._zod){let f=Jn(u,t,r);if(f>o)o=f}},i=(u,f)=>{let p=xr;for(let d of Reflect.ownKeys(u)){let h=Object.getOwnPropertyDescriptor(u,d);if(f&&!h.enumerable)continue;let g=h.get?Fn:h.value?._zod?Jn(h.value,t,r):xr;if(g>p)p=g}return p},c=(u)=>{if(u>o)o=u},a=e._zod.def,l=a.type;switch(l){case\"object\":{let u=hr(a);c(u?i(u,!0):Fn),s(a.catchall);break}case\"array\":s(a.element);break;case\"tuple\":for(let u of a.items)s(u);s(a.rest);break;case\"record\":case\"map\":s(a.keyType),s(a.valueType);break;case\"set\":s(a.valueType);break;case\"union\":for(let u of a.options)s(u);break;case\"intersection\":s(a.left),s(a.right);break;case\"optional\":case\"nullable\":case\"default\":case\"prefault\":case\"catch\":case\"readonly\":case\"nonoptional\":case\"promise\":case\"success\":s(a.innerType);break;case\"pipe\":s(a.in),s(a.out);break;case\"function\":s(a.input),s(a.output);break;case\"lazy\":{let u=a._cachedInner??(r?e._zod.innerType:void 0);c(u?Jn(u,t,!1):Fn);break}case\"template_literal\":case\"string\":case\"number\":case\"int\":case\"boolean\":case\"bigint\":case\"symbol\":case\"undefined\":case\"null\":case\"void\":case\"never\":case\"any\":case\"unknown\":case\"date\":case\"nan\":case\"enum\":case\"literal\":case\"file\":case\"transform\":case\"custom\":break;default:for(let u in a){let f=Object.getOwnPropertyDescriptor(a,u);if(!f||f.get)continue;let p=f.value;if(!p||typeof p!==\"object\")continue;if(p._zod)s(p);else if(Array.isArray(p))for(let d of p)s(d)}}return t.delete(e),ig(e,o)}function ig(e,t){if(t!==Fn)Vl.set(e,t===_r);return t}function cg(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Mn,Vn=[],ag={alloc(e,t,r){let n=Mn;if(!n)return r;Mn=void 0;let o={value:r,issues:null};return n.set(t.value,o),Vn.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!==\"backward\"&&ug(s,o.value))throw new Bl;return r(o,s)};if(e._zod.parse=n,e._zod.run===r)e._zod.run=n})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,c=(a,l)=>{if(r===void 0){let S=Jn(e,new Set,!1);if(S===xr){if(e._zod.parse=i,e._zod.run===c)e._zod.run=i;return i(a,l)}if(S===_r||n)r=!0;else n=!0}let u=a.value;if(!Ml(u))return i(a,l);let f=l[Ls];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[Ls]=f;let p;if(o===l)p=s;else p=cg(f,e),o=l,s=p;let d=p.get(u);if(d){if(a.value=d.value,d.issues){if(d.issues.length)a.issues.push(...js(d.issues))}else a.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return a}Mn=p;let h=Vn.length,g=i(a,l);Mn=void 0;let x=Vn.length>h?Vn.pop():void 0;if(g instanceof Promise)return g.then((S)=>{if(x)x.issues=S.issues.length?js(S.issues):Ll;return S});if(x)x.issues=g.issues.length?js(g.issues):Ll;return g};if(e._zod.parse=c,e._zod.run===i)e._zod.run=c})}};function Fl(){return ag}function ug(e,t){let r=e[Ls]?.backEdges;return r!==void 0&&Ml(t)&&r.has(t)}var lg=()=>{let e={string:{unit:\"characters\",verb:\"to have\"},file:{unit:\"bytes\",verb:\"to have\"},array:{unit:\"items\",verb:\"to have\"},set:{unit:\"items\",verb:\"to have\"},map:{unit:\"entries\",verb:\"to have\"}};function t(s){return e[s]??null}let r={regex:\"input\",email:\"email address\",url:\"URL\",emoji:\"emoji\",uuid:\"UUID\",uuidv4:\"UUIDv4\",uuidv6:\"UUIDv6\",nanoid:\"nanoid\",guid:\"GUID\",cuid:\"cuid\",cuid2:\"cuid2\",ulid:\"ULID\",xid:\"XID\",ksuid:\"KSUID\",datetime:\"ISO datetime\",date:\"ISO date\",time:\"ISO time\",duration:\"ISO duration\",ipv4:\"IPv4 address\",ipv6:\"IPv6 address\",mac:\"MAC address\",cidrv4:\"IPv4 range\",cidrv6:\"IPv6 range\",base64:\"base64-encoded string\",base64url:\"base64url-encoded string\",json_string:\"JSON string\",e164:\"E.164 number\",currency_code:\"currency code\",credit_card:\"credit card number\",iban:\"IBAN\",jwt:\"JWT\",template_literal:\"input\"},n={nan:\"NaN\"};function o(s,i){if(s===\"number\"&&typeof i===\"number\"&&!Number.isFinite(i))return String(i);return n[s]??s}return(s)=>{switch(s.code){case\"invalid_type\":{let i=o(s.expected),c=Aa(s.input),a=o(c,s.input);return`Invalid input: expected ${i}, received ${a}`}case\"invalid_value\":if(s.values.length===1)return`Invalid input: expected ${xs(s.values[0])}`;return`Invalid option: expected one of ${ms(s.values,\"|\")}`;case\"too_big\":{let i=s.exact?\"exactly \":s.inclusive?\"<=\":\"<\",c=t(s.origin);if(c)return`Too big: expected ${s.origin??\"value\"} to have ${i}${s.maximum.toString()} ${c.unit??\"elements\"}`;return`Too big: expected ${s.origin??\"value\"} to be ${i}${s.maximum.toString()}`}case\"too_small\":{let i=s.exact?\"exactly \":s.inclusive?\">=\":\">\",c=t(s.origin);if(c)return`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${c.unit}`;return`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case\"invalid_format\":{let i=s;if(i.format===\"starts_with\")return`Invalid string: must start with \"${i.prefix}\"`;if(i.format===\"ends_with\")return`Invalid string: must end with \"${i.suffix}\"`;if(i.format===\"includes\")return`Invalid string: must include \"${i.includes}\"`;if(i.format===\"regex\")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??s.format}`}case\"not_multiple_of\":return`Invalid number: must be a multiple of ${s.divisor}`;case\"unrecognized_keys\":return`Unrecognized key${s.keys.length>1?\"s\":\"\"}: ${ms(s.keys,\", \")}`;case\"invalid_key\":return`Invalid key in ${s.origin}`;case\"invalid_union\":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((c)=>`'${c}'`).join(\" | \")}`;if(s.inclusive===!1)return\"Invalid input: more than one option matched\";return\"Invalid input\";case\"invalid_element\":return`Invalid value in ${s.origin}`;default:return\"Invalid input\"}}};function Bs(){return{localeError:lg()}}var Jl;class Kl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r===\"object\"&&\"id\"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t===\"object\"&&\"id\"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function fg(){return new Kl}(Jl=globalThis).__zod_globalRegistry??(Jl.__zod_globalRegistry=fg());var nt=globalThis.__zod_globalRegistry;function ql(e){if(e.checks)e.checks=[...e.checks];return e}function Gl(e,t){return new e(ql({type:\"string\",...y(t)}))}function Wl(e,t){return new e({type:\"string\",format:\"email\",check:\"string_format\",abort:!1,...y(t)})}function Hl(e,t){return new e({type:\"string\",format:\"guid\",check:\"string_format\",abort:!1,...y(t)})}function Yl(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,...y(t)})}function Xl(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v4\",...y(t)})}function Ql(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v6\",...y(t)})}function ef(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v7\",...y(t)})}function tf(e,t){return new e({type:\"string\",format:\"url\",check:\"string_format\",abort:!1,...y(t)})}function rf(e,t){return new e({type:\"string\",format:\"emoji\",check:\"string_format\",abort:!1,...y(t)})}function nf(e,t){return new e({type:\"string\",format:\"nanoid\",check:\"string_format\",abort:!1,...y(t)})}function of(e,t){return new e({type:\"string\",format:\"cuid\",check:\"string_format\",abort:!1,...y(t)})}function sf(e,t){return new e({type:\"string\",format:\"cuid2\",check:\"string_format\",abort:!1,...y(t)})}function cf(e,t){return new e({type:\"string\",format:\"ulid\",check:\"string_format\",abort:!1,...y(t)})}function af(e,t){return new e({type:\"string\",format:\"xid\",check:\"string_format\",abort:!1,...y(t)})}function uf(e,t){return new e({type:\"string\",format:\"ksuid\",check:\"string_format\",abort:!1,...y(t)})}function lf(e,t){return new e({type:\"string\",format:\"ipv4\",check:\"string_format\",abort:!1,...y(t)})}function ff(e,t){return new e({type:\"string\",format:\"ipv6\",check:\"string_format\",abort:!1,...y(t)})}function pf(e,t){return new e({type:\"string\",format:\"cidrv4\",check:\"string_format\",abort:!1,...y(t)})}function df(e,t){return new e({type:\"string\",format:\"cidrv6\",check:\"string_format\",abort:!1,...y(t)})}function hf(e,t){return new e({type:\"string\",format:\"base64\",check:\"string_format\",abort:!1,...y(t)})}function mf(e,t){return new e({type:\"string\",format:\"base64url\",check:\"string_format\",abort:!1,...y(t)})}function gf(e,t){return new e({type:\"string\",format:\"e164\",check:\"string_format\",abort:!1,...y(t)})}function yf(e,t){return new e({type:\"string\",format:\"jwt\",check:\"string_format\",abort:!1,...y(t)})}function xf(e,t){return new e({type:\"string\",format:\"datetime\",check:\"string_format\",offset:!1,local:!1,precision:null,...y(t)})}function _f(e,t){return new e({type:\"string\",format:\"date\",check:\"string_format\",...y(t)})}function wf(e,t){return new e({type:\"string\",format:\"time\",check:\"string_format\",precision:null,...y(t)})}function bf(e,t){return new e({type:\"string\",format:\"duration\",check:\"string_format\",...y(t)})}function kf(e,t){return new e(ql({type:\"number\",checks:[],...y(t)}))}function vf(e,t){return new e({type:\"number\",check:\"number_format\",abort:!1,format:\"safeint\",...y(t)})}function Sf(e){return new e({type:\"unknown\"})}function $f(e,t){return new e({type:\"never\",...y(t)})}function Kn(e,t){return new Os({check:\"less_than\",...y(t),value:e,inclusive:!1})}function wr(e,t){return new Os({check:\"less_than\",...y(t),value:e,inclusive:!0})}function qn(e,t){return new Ts({check:\"greater_than\",...y(t),value:e,inclusive:!1})}function br(e,t){return new Ts({check:\"greater_than\",...y(t),value:e,inclusive:!0})}function Gn(e,t){return new bu({check:\"multiple_of\",...y(t),value:e})}function Wn(e,t){return new vu({check:\"max_length\",...y(t),maximum:e})}function Et(e,t){return new Su({check:\"min_length\",...y(t),minimum:e})}function Hn(e,t){return new $u({check:\"length_equals\",...y(t),length:e})}function Ms(e,t){return new zu({check:\"string_format\",format:\"regex\",...y(t),pattern:e})}function Vs(e){return new Iu({check:\"string_format\",format:\"lowercase\",...y(e)})}function Fs(e){return new Eu({check:\"string_format\",format:\"uppercase\",...y(e)})}function Js(e,t){return new Au({check:\"string_format\",format:\"includes\",...y(t),includes:e})}function Ks(e,t){return new Ou({check:\"string_format\",format:\"starts_with\",...y(t),prefix:e})}function qs(e,t){return new Tu({check:\"string_format\",format:\"ends_with\",...y(t),suffix:e})}function Be(e){return new Pu({check:\"overwrite\",tx:e})}function Gs(e){return Be((t)=>t.normalize(e))}function Ws(){return Be((e)=>e.trim())}function Hs(){return Be((e)=>e.toLowerCase())}function Ys(){return Be((e)=>e.toUpperCase())}function Xs(){return Be((e)=>ka(e))}function zf(e,t,r){return new e({type:\"array\",element:t,...y(r)})}function If(e,t,r){return new e({type:\"custom\",check:\"custom\",fn:t,...y(r)})}function Ef(e,t){let r=pg((n)=>(n.addIssue=(o)=>{if(typeof o===\"string\")n.issues.push(rt(o,n.value,r._zod.def));else{let s=o;if(s.fatal)s.continue=!1;if(s.code??(s.code=\"custom\"),!(\"input\"in s))s.input=n.value;s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(rt(s))}},e(n.value,n)),t);return r}function pg(e,t){let r=new L({check:\"custom\",...y(t)});return r._zod.check=e,r}function kr(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))ue(e,n,r[n]);return e}function ei(e){let t=e?.target??\"draft-2020-12\";if(t===\"draft-4\")t=\"draft-04\";if(t===\"draft-7\")t=\"draft-07\";return{processors:e.processors??{},metadataRegistry:e?.metadata??nt,target:t,unrepresentable:e?.unrepresentable??\"throw\",override:e?.override??(()=>{}),io:e?.io??\"output\",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??\"ref\",reused:e?.reused??\"inline\",intersections:[],deferred:[],external:e?.external??void 0}}function Ze(e,t,r,n,o){let s=typeof t.unrepresentable===\"function\"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s===\"any\")return!1;if(s===void 0||s===\"throw\")throw Error(o);return Object.assign(r,s),!0}function j(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,u);else{let p=i.schema,d=t.processors[o.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);d(e,t,p,u)}let f=e._zod.parent;if(f){if(!i.ref)i.ref=f;j(f,t,u),t.seen.get(f).isParent=!0}}let a=t.metadataRegistry.get(e);if(a)kr(i.schema,a);if(t.io===\"input\"&&G(e))delete i.schema.examples,delete i.schema.default;if(t.io===\"input\"&&\"_prefault\"in i.schema)(n=i.schema).default??(n.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function Af(e){return e.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}function ti(e,t){let r=e.seen.get(t);if(!r)throw Error(\"Unprocessed schema. This is a bug in Zod.\");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=n.get(c);if(a&&a!==i[0])throw Error(`Duplicate schema id \"${c}\" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,i[0])}}let o=(i)=>{let c=e.target===\"draft-2020-12\"?\"$defs\":\"definitions\";if(e.external){let f=e.external.registry.get(i[0])?.id,p=e.external.uri??((h)=>h);if(f)return{ref:p(f)};let d=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=d,{defId:d,ref:`${p(\"__shared\")}#/${c}/${Af(d)}`}}let a=\"#\",l=`${a}/${c}/`;if(i[1]===r&&!i[1].schema.id)return{ref:a};let u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Af(u)}},s=(i)=>{if(i[1].schema.$ref)return;let c=i[1],{ref:a,defId:l}=o(i);if(c.def={...c.schema},l)c.defId=l;let u=c.schema;for(let f in u)delete u[f];u.$ref=a};if(e.cycles===\"throw\")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join(\"/\")}/<root>\n\nSet the \\`cycles\\` parameter to \\`\"ref\"\\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1){if(e.reused===\"ref\")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Pf(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!==\"object\")return;Pf(n);let o=Object.keys(n);if(o.length!==1||o[0]!==\"type\")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!==\"string\")return;if(!r.includes(i))r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Zf=new Set([\"type\",\"properties\",\"required\",\"additionalProperties\"]),Of=[\"oneOf\",\"anyOf\"];function Tf(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!==\"object\"||t===null)return null;return Object.keys(t).length?t:null}function Qs(e){let t=[];for(let s of e){if(typeof s!==\"object\"||s.type!==\"object\")return null;for(let i in s)if(!Zf.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let c=[];for(let l of t){let u=l.properties?.[i]??Tf(l);if(u===null||u===void 0)continue;if(!c.some((f)=>JSON.stringify(f)===JSON.stringify(u)))c.push(u)}let a=c.length===1?c[0]:Qs(c)??{allOf:c};ue(r,i,a)}for(let i of s.required??[])n.add(i)}let o={type:\"object\",properties:r};if(n.size)o.required=[...n];if(t.every((s)=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let c=Tf(i);if(c&&!s.some((a)=>JSON.stringify(a)===JSON.stringify(c)))s.push(c)}if(s.length===1)o.additionalProperties=s[0];else if(s.length>1)o.additionalProperties={allOf:s}}return o}function dg(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Zf)if(o in e)return;let r=t.filter((o)=>Of.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=Qs(t);else{let o=r[0],s=Of.find((a)=>Array.isArray(o[a]));if(Object.keys(o).length!==1)return;let i=t.filter((a)=>a!==o),c=o[s].map((a)=>Qs([...i,a]));if(c.some((a)=>!a))return;n={[s]:c}}if(!n)return;delete e.allOf,kr(e,n)}function ri(e,t){let r=e.seen.get(t);if(!r)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let n=(c)=>{let a=e.seen.get(c);if(a.ref===null)return;let l=a.def??a.schema,u={...l},f=a.ref;if(a.ref=null,f){n(f);let d=e.seen.get(f),h=d.schema;if(h.$ref&&(e.target===\"draft-07\"||e.target===\"draft-04\"||e.target===\"openapi-3.0\"))l.allOf=l.allOf??[],l.allOf.push(h);else kr(l,h);if(kr(l,u),c._zod.parent===f)for(let x in l){if(x===\"$ref\"||x===\"allOf\")continue;if(!(x in u))delete l[x]}if(h.$ref&&d.def)for(let x in l){if(x===\"$ref\"||x===\"allOf\")continue;if(x in d.def&&JSON.stringify(l[x])===JSON.stringify(d.def[x]))delete l[x]}}let p=c._zod.parent;if(p&&p!==f){n(p);let d=e.seen.get(p);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let h in l){if(h===\"$ref\"||h===\"allOf\")continue;if(h in d.def&&JSON.stringify(l[h])===JSON.stringify(d.def[h]))delete l[h]}}}e.override({zodSchema:c,jsonSchema:l,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())n(c[0]);if(e.target!==\"openapi-3.0\")for(let c of e.seen.entries())Pf(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let a of e.seen.values())for(let l of[a.schema,a.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=c.get(u);if(f)f.push(l);else c.set(u,[l])}for(let a of e.intersections)for(let l of c.get(a)??[])dg(l)}}let o={};if(e.target===\"draft-2020-12\")o.$schema=\"https://json-schema.org/draft/2020-12/schema\";else if(e.target===\"draft-07\")o.$schema=\"http://json-schema.org/draft-07/schema#\";else if(e.target===\"draft-04\")o.$schema=\"http://json-schema.org/draft-04/schema#\";else if(e.target===\"openapi-3.0\");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error(\"Schema is missing an `id` property\");o.$id=e.external.uri(c)}kr(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let a=c[1];if(a.def&&a.defId){if(a.def.id===a.defId)delete a.def.id;ue(i,a.defId,a.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target===\"draft-2020-12\")o.$defs=i;else o.definitions=i;try{let c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,\"~standard\",{value:{...t[\"~standard\"],jsonSchema:{input:vr(t,\"input\",e.processors),output:vr(t,\"output\",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error(\"Error converting schema to JSON.\")}}function G(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type===\"transform\")return!0;if(n.type===\"array\")return G(n.element,r);if(n.type===\"set\")return G(n.valueType,r);if(n.type===\"lazy\")return G(n.getter(),r);if(n.type===\"promise\"||n.type===\"optional\"||n.type===\"nonoptional\"||n.type===\"nullable\"||n.type===\"readonly\"||n.type===\"default\"||n.type===\"prefault\"||n.type===\"catch\")return G(n.innerType,r);if(n.type===\"intersection\")return G(n.left,r)||G(n.right,r);if(n.type===\"record\"||n.type===\"map\")return G(n.keyType,r)||G(n.valueType,r);if(n.type===\"pipe\"){if(e._zod.traits.has(\"$ZodCodec\"))return!0;return G(n.in,r)||G(n.out,r)}if(n.type===\"object\"){for(let o in n.shape)if(G(n.shape[o],r))return!0;return!1}if(n.type===\"union\"){for(let o of n.options)if(G(o,r))return!0;return!1}if(n.type===\"tuple\"){for(let o of n.items)if(G(o,r))return!0;if(n.rest&&G(n.rest,r))return!0;return!1}return!1}var Cf=(e,t={})=>(r)=>{let n=ei({...r,processors:t});return j(e,n),ti(n,e),ri(n,e)},vr=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=ei({...o??{},target:s,io:t,processors:r});return j(e,i),ti(i,e),ri(i,e)};var At=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},Ot=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Df=(e,t)=>{At(e,\"minimum\",t),Ot(e,\"maximum\",t)},jf=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Lf=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Bf=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Mf=(e,t)=>{if(e.format=t,t.includes(\"int\"))e.isInt=!0},Nf=(e,t)=>At(e,\"minimum\",t.minimum),Uf=(e,t)=>Ot(e,\"maximum\",t.maximum),Rf=(e)=>(t,r)=>{Mf(t,r.format);let[n,o]=e[r.format];At(t,\"minimum\",n),Ot(t,\"maximum\",o)},hg={greater_than:(e,t)=>At(e,t.inclusive?\"minimum\":\"exclusiveMinimum\",t.value),less_than:(e,t)=>Ot(e,t.inclusive?\"maximum\":\"exclusiveMaximum\",t.value),multiple_of:(e,t)=>jf(e,t.value),number_format:Rf(Sn),bigint_format:Rf(_s),min_length:Nf,max_length:Uf,length_equals:(e,t)=>Df(e,t.length),min_size:Nf,max_size:Uf,size_equals:(e,t)=>Df(e,t.size),string_format:(e,t)=>{if(Mf(e,t.format),t.pattern)Lf(e,t.pattern);if(t.format===\"base64\"||t.format===\"base64url\")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>Bf(e,t.mime)};function pe(e){let t={},r=e._zod.def,n=e._zod.traits.has(\"$ZodCheck\")?[e,...r.checks??[]]:r.checks??[];for(let s of n)hg[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)At(t,\"minimum\",o.minimum);if(o.exclusiveMinimum!==void 0)At(t,\"exclusiveMinimum\",o.exclusiveMinimum);if(o.maximum!==void 0)Ot(t,\"maximum\",o.maximum);if(o.exclusiveMaximum!==void 0)Ot(t,\"exclusiveMaximum\",o.exclusiveMaximum);if(o.multipleOf!==void 0)jf(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes(\"int\"))t.isInt=!0}if(o.mime)Bf(t,o.mime);for(let s of o.patterns??[])Lf(t,s);return t}var mg={guid:\"uuid\",url:\"uri\",datetime:\"date-time\",json_string:\"json-string\",regex:\"\"},gg=new Map([[Ds,lu],[Bn,fu]]),yg=(e)=>gg.get(e)??e,Vf=(e,t,r,n)=>{let o=r;o.type=\"string\";let{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:l,laxFormat:u}=pe(e);if(typeof s===\"number\")o.minLength=s;if(typeof i===\"number\")o.maxLength=i;if(c){if(o.format=mg[c]??c,o.format===\"\")delete o.format;if(c===\"time\"||u)delete o.format}if(l)o.contentEncoding=l;if(a&&a.size>0){let f=[...a].map(yg);if(f.length===1)o.pattern=f[0].source;else if(f.length>1)o.allOf=[...f.map((p)=>({...t.target===\"draft-07\"||t.target===\"draft-04\"||t.target===\"openapi-3.0\"?{type:\"string\"}:{},pattern:p.source}))]}},Ff=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:c,exclusiveMaximum:a,exclusiveMinimum:l,isInt:u}=pe(e);o.type=u?\"integer\":\"number\";let f=typeof l===\"number\"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof a===\"number\"&&a<=(i??Number.POSITIVE_INFINITY),d=t.target===\"draft-04\"||t.target===\"openapi-3.0\";if(f)if(d)o.minimum=l,o.exclusiveMinimum=!0;else o.exclusiveMinimum=l;else if(typeof s===\"number\")o.minimum=s;if(p)if(d)o.maximum=a,o.exclusiveMaximum=!0;else o.exclusiveMaximum=a;else if(typeof i===\"number\")o.maximum=i;if(c){let h=new Set;for(let S of c)if(Number.isFinite(S)&&S!==0)h.add(Math.abs(S));else Ze(e,t,o,n,`A multipleOf divisor of ${S} cannot be represented in JSON Schema`);let[g,...x]=h;if(g!==void 0)o.multipleOf=g;if(x.length)o.allOf=[...o.allOf??[],...x.map((S)=>({multipleOf:S}))]}};var Jf=(e,t,r,n)=>{r.not={}};var Kf=(e,t,r,n)=>{};var qf=(e,t,r,n)=>{let o=e._zod.def,s=fr(o.entries);if(s.length===0){r.not={};return}if(s.every((i)=>typeof i===\"number\"))r.type=\"number\";if(s.every((i)=>typeof i===\"string\"))r.type=\"string\";r.enum=s},Gf=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Ze(e,t,r,n,\"Literal `undefined` cannot be represented in JSON Schema\"))return}else if(typeof i===\"bigint\"){if(Ze(e,t,r,n,\"BigInt literals cannot be represented in JSON Schema\"))return;s.push(Number(i))}else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(r.type=i===null?\"null\":typeof i,t.target===\"draft-04\"||t.target===\"openapi-3.0\")r.enum=[i];else r.const=i}else{if(s.every((i)=>typeof i===\"number\"))r.type=\"number\";if(s.every((i)=>typeof i===\"string\"))r.type=\"string\";if(s.every((i)=>typeof i===\"boolean\"))r.type=\"boolean\";if(s.every((i)=>i===null))r.type=\"null\";r.enum=s}};var Wf=(e,t,r,n)=>{Ze(e,t,r,n,\"Custom types cannot be represented in JSON Schema\")};var Hf=(e,t,r,n)=>{Ze(e,t,r,n,\"Transforms cannot be represented in JSON Schema\")};var Yf=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:c}=pe(e);if(typeof i===\"number\")o.minItems=i;if(typeof c===\"number\")o.maxItems=c;o.type=\"array\",o.items=j(s.element,t,{...n,path:[...n.path,\"items\"]})};function ni(e){let t=e._zod.def;if(t.type===\"pipe\"&&t.in._zod.traits.has(\"$ZodTransform\"))return ni(t.out);if(t.type===\"catch\")return ni(t.innerType);return e._zod.optin}var Xf=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Ze(e,t,o,n,\"Symbol keys cannot be represented in JSON Schema\"))return;o.type=\"object\",o.properties={};for(let l in i)ue(o.properties,l,j(i[l],t,{...n,path:[...n.path,\"properties\",l]}));let a=[];for(let l of Object.keys(i)){let u=s.shape[l];if(t.io===\"input\"?ni(u)===void 0:u._zod.optout===void 0)a.push(l)}if(a.length>0)o.required=a;if(s.catchall?._zod.def.type===\"never\")o.additionalProperties=!1;else if(!s.catchall){if(t.io===\"output\")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=j(s.catchall,t,{...n,path:[...n.path,\"additionalProperties\"]})},Qf=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((c,a)=>j(c,t,{...n,path:[...n.path,s?\"oneOf\":\"anyOf\",a]}));if(s)r.oneOf=i;else r.anyOf=i},ep=(e,t,r,n)=>{let o=e._zod.def,s=j(o.left,t,{...n,path:[...n.path,\"allOf\",0]}),i=j(o.right,t,{...n,path:[...n.path,\"allOf\",1]}),c=(l)=>(\"allOf\"in l)&&Object.keys(l).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];r.allOf=a,t.intersections.push(a)};var tp=(e,t,r,n)=>{let o=e._zod.def,s=j(o.innerType,t,n),i=t.seen.get(e);if(t.target===\"openapi-3.0\")i.ref=o.innerType,r.nullable=!0;else r.anyOf=[s,{type:\"null\"}]},rp=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},oi=Symbol();function np(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(c,a)=>{if(typeof a!==\"bigint\")return a;return s=!0,null});if(!s)return JSON.parse(i);return Ze(t,r,n,o,\"BigInt defaults cannot be represented in JSON Schema\"),oi}var op=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=np(o.defaultValue,e,t,r,n);if(i!==oi)r.default=i},sp=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!==\"input\")return;let i=np(o.defaultValue,e,t,r,n);if(i!==oi)r._prefault=i},ip=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Ze(e,t,r,n,\"Dynamic catch values are not supported in JSON Schema\");return}r.default=i},cp=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has(\"$ZodTransform\"),i=t.io===\"input\"?s?o.out:o.in:o.out;j(i,t,n);let c=t.seen.get(e);c.ref=i},ap=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var si=(e,t,r,n)=>{let o=e._zod.def;j(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var up=new WeakSet([Object.prototype,Error.prototype]);function Yn(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var $g=(e,t)=>{Ua.init(e,t),e.name=\"ZodError\";let r=Object.getPrototypeOf(e);if(up.has(r))return;up.add(r),Yn(r,\"format\",(n)=>(o)=>ja(n,o)),Yn(r,\"flatten\",(n)=>(o)=>Ra(n,o)),Yn(r,\"addIssue\",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,pr,2)}),Yn(r,\"addIssues\",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,pr,2)}),Object.defineProperty(r,\"isEmpty\",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var se=m(\"ZodError\",$g,void 0,{Parent:Error});var lp=Pn(se),fp=Zn(se),pp=Cn(se),dp=Dn(se),hp=Ba(se),mp=Ma(se),gp=Va(se),yp=Fa(se),xp=Ja(se),_p=Ka(se),wp=qa(se),bp=Ga(se);function Ig(){if(!oe.localeError)fe(Bs())}function ai(){if(!oe.memoizer)fe({memoizer:Fl()})}var O=m(\"ZodType\",(e,t)=>(Ig(),A.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ne(t,{checks:[...t.checks??[],...e.map((r)=>typeof r===\"function\"?{_zod:{check:r,def:{check:\"custom\"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ve(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(vy(e,t))},superRefine(e,t){return this.check(Sy(e,t))},overwrite(e){return this.check(Be(e))},optional(){return vp(this)},exactOptional(){return ly(this)},nullable(){return Sp(this)},nullish(){return vp(Sp(this))},nonoptional(e){return gy(this,e)},array(){return Sr(this)},or(e){return li([this,e])},and(e){return sy(this,e)},transform(e){return $p(this,uy(e))},default(e){return dy(this,e)},prefault(e){return my(this,e)},catch(e){return xy(this,e)},pipe(e){return $p(this,e)},readonly(){return by(this)},describe(e){let t=this.clone();return nt.add(t,{description:e}),t},meta(...e){if(e.length===0)return nt.get(this);let t=this.clone();return nt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get \"~standard\"(){return On(this,\"~standard\",{...Cs(this),jsonSchema:{input:vr(this,\"input\"),output:vr(this,\"output\")}})},set \"~standard\"(e){Pe(this,\"~standard\",e)},parse:function e(t,r){return lp(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await fp(this,t,r,{callee:e})},safeParse(e,t){return pp(this,e,t)},async safeParseAsync(e,t){return dp(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Pe(this,\"spa\",e)},validate(e,t){return Ss(this,e,t)},validateAsync(e,t){return $s(this,e,t)},encode:function e(t,r){return hp(this,t,r,{callee:e})},decode:function e(t,r){return mp(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await gp(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await yp(this,t,r,{callee:e})},safeEncode(e,t){return xp(this,e,t)},safeDecode(e,t){return _p(this,e,t)},async safeEncodeAsync(e,t){return wp(this,e,t)},async safeDecodeAsync(e,t){return bp(this,e,t)},toJSONSchema(e){return Cf(this,{})(e)},get description(){return nt.get(this)?.description},get _def(){return this._zod.def}}),zp=m(\"_ZodString\",(e,t)=>{Ln.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vf(e,r,n,o)},Ta({format:(e)=>pe(e).format??null,minLength:(e)=>pe(e).minimum??null,maxLength:(e)=>pe(e).maximum??null},{regex(...e){return this.check(Ms(...e))},includes(...e){return this.check(Js(...e))},startsWith(...e){return this.check(Ks(...e))},endsWith(...e){return this.check(qs(...e))},min(...e){return this.check(Et(...e))},max(...e){return this.check(Wn(...e))},length(...e){return this.check(Hn(...e))},nonempty(...e){return this.check(Et(1,...e))},lowercase(e){return this.check(Vs(e))},uppercase(e){return this.check(Fs(e))},trim(){return this.check(Ws())},normalize(...e){return this.check(Gs(...e))},toLowerCase(){return this.check(Hs())},toUpperCase(){return this.check(Ys())},slugify(){return this.check(Xs())}})),Eg=m(\"ZodString\",(e,t)=>{Ln.init(e,t),zp.init(e,t)},{email(e){return this.check(Wl(Zg,e))},url(e){return this.check(tf(Dg,e))},jwt(e){return this.check(yf(Hg,e))},emoji(e){return this.check(rf(Ng,e))},guid(e){return this.check(Hl(Cg,e))},uuid(e){return this.check(Yl(Xn,e))},uuidv4(e){return this.check(Xl(Xn,e))},uuidv6(e){return this.check(Ql(Xn,e))},uuidv7(e){return this.check(ef(Xn,e))},nanoid(e){return this.check(nf(Ug,e))},cuid(e){return this.check(of(Rg,e))},cuid2(e){return this.check(sf(jg,e))},ulid(e){return this.check(cf(Lg,e))},base64(e){return this.check(hf(qg,e))},base64url(e){return this.check(mf(Gg,e))},xid(e){return this.check(af(Bg,e))},ksuid(e){return this.check(uf(Mg,e))},ipv4(e){return this.check(lf(Vg,e))},ipv6(e){return this.check(ff(Fg,e))},cidrv4(e){return this.check(pf(Jg,e))},cidrv6(e){return this.check(df(Kg,e))},e164(e){return this.check(gf(Wg,e))},datetime(e){return this.check(xf(Ag,e))},date(e){return this.check(_f(Og,e))},time(e){return this.check(wf(Tg,e))},duration(e){return this.check(bf(Pg,e))}});function ui(e){return Gl(Eg,e)}var E=m(\"ZodStringFormat\",(e,t)=>{I.init(e,t),zp.init(e,t)}),Ag=m(\"ZodISODateTime\",(e,t)=>{sl.init(e,t),E.init(e,t)}),Og=m(\"ZodISODate\",(e,t)=>{il.init(e,t),E.init(e,t)}),Tg=m(\"ZodISOTime\",(e,t)=>{cl.init(e,t),E.init(e,t)}),Pg=m(\"ZodISODuration\",(e,t)=>{al.init(e,t),E.init(e,t)}),Zg=m(\"ZodEmail\",(e,t)=>{Gu.init(e,t),E.init(e,t)});var Cg=m(\"ZodGUID\",(e,t)=>{Ku.init(e,t),E.init(e,t)});var Xn=m(\"ZodUUID\",(e,t)=>{qu.init(e,t),E.init(e,t)});var Dg=m(\"ZodURL\",(e,t)=>{Yu.init(e,t),E.init(e,t)});var Ng=m(\"ZodEmoji\",(e,t)=>{Xu.init(e,t),E.init(e,t)});var Ug=m(\"ZodNanoID\",(e,t)=>{Qu.init(e,t),E.init(e,t)});var Rg=m(\"ZodCUID\",(e,t)=>{el.init(e,t),E.init(e,t)});var jg=m(\"ZodCUID2\",(e,t)=>{tl.init(e,t),E.init(e,t)});var Lg=m(\"ZodULID\",(e,t)=>{rl.init(e,t),E.init(e,t)});var Bg=m(\"ZodXID\",(e,t)=>{nl.init(e,t),E.init(e,t)});var Mg=m(\"ZodKSUID\",(e,t)=>{ol.init(e,t),E.init(e,t)});var Vg=m(\"ZodIPv4\",(e,t)=>{ul.init(e,t),E.init(e,t)});var Fg=m(\"ZodIPv6\",(e,t)=>{fl.init(e,t),E.init(e,t)});var Jg=m(\"ZodCIDRv4\",(e,t)=>{pl.init(e,t),E.init(e,t)});var Kg=m(\"ZodCIDRv6\",(e,t)=>{dl.init(e,t),E.init(e,t)});var qg=m(\"ZodBase64\",(e,t)=>{ml.init(e,t),E.init(e,t)});var Gg=m(\"ZodBase64URL\",(e,t)=>{gl.init(e,t),E.init(e,t)});var Wg=m(\"ZodE164\",(e,t)=>{yl.init(e,t),E.init(e,t)});var Hg=m(\"ZodJWT\",(e,t)=>{xl.init(e,t),E.init(e,t)});var Ip=m(\"ZodNumber\",(e,t)=>{Ns.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ff(e,r,n,o),e.isFinite=!0},Ta({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=pe(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=pe(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=pe(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>pe(e).format??null},{gt(e,t){return this.check(qn(e,t))},gte(e,t){return this.check(br(e,t))},min(e,t){return this.check(br(e,t))},lt(e,t){return this.check(Kn(e,t))},lte(e,t){return this.check(wr(e,t))},max(e,t){return this.check(wr(e,t))},int(e){return this.check(kp(e))},safe(e){return this.check(kp(e))},positive(e){return this.check(qn(0,e))},nonnegative(e){return this.check(br(0,e))},negative(e){return this.check(Kn(0,e))},nonpositive(e){return this.check(wr(0,e))},multipleOf(e,t){return this.check(Gn(e,t))},step(e,t){return this.check(Gn(e,t))},finite(){return this}}));function Tt(e){return kf(Ip,e)}var Yg=m(\"ZodNumberFormat\",(e,t)=>{_l.init(e,t),Ip.init(e,t)});function kp(e){return vf(Yg,e)}var Xg=m(\"ZodUnknown\",(e,t)=>{wl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kf(e,r,n,o)});function Qn(){return Sf(Xg)}var Qg=m(\"ZodNever\",(e,t)=>{bl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jf(e,r,n,o)});function ey(e){return $f(Qg,e)}var ty=m(\"ZodArray\",(e,t)=>{ai(),kl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yf(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Et(e,t))},nonempty(e){return this.check(Et(1,e))},max(e,t){return this.check(Wn(e,t))},length(e,t){return this.check(Hn(e,t))},unwrap(){return this.element}});function Sr(e,t){return zf(ty,e,t)}var ry=m(\"ZodObject\",(e,t)=>{ai(),$l.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xf(e,r,n,o),Pm(e,\"shape\",(r)=>r._zod.def.shape,!1)},{keyof(){return iy(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ne(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ne(this._zod.def,{catchall:Qn()}))},loose(){return this.clone(ne(this._zod.def,{catchall:Qn()}))},strict(){return this.clone(ne(this._zod.def,{catchall:ey()}))},strip(){return this.clone(ne(this._zod.def,{catchall:void 0}))},extend(e){return Sm(this,e)},safeExtend(e){return $m(this,e)},merge(e){return zm(this,e)},pick(e){return km(this,e)},omit(e){return vm(this,e)},partial(...e){return Ia(Op,this,e[0])},exactPartial(...e){return Ia(Tp,this,e[0],\"exactPartial\")},required(...e){return Im(Pp,this,e[0])}});function Pt(e,t){let r={type:\"object\",shape:e??{},...y(t)};return new ry(r)}var Ep=m(\"ZodUnion\",(e,t)=>{Us.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qf(e,r,n,o),e.options=t.options});function li(e,t){return new Ep({type:\"union\",options:e,...y(t)})}var ny=m(\"ZodDiscriminatedUnion\",(e,t)=>{Ep.init(e,t),zl.init(e,t)});function Ap(e,t,r){return new ny({type:\"union\",options:t,discriminator:e,...y(r)})}var oy=m(\"ZodIntersection\",(e,t)=>{Il.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ep(e,r,n,o)});function sy(e,t){return new oy({type:\"intersection\",left:e,right:t})}var ci=m(\"ZodEnum\",(e,t)=>{El.init(e,t),O.init(e,t),e._zod.processJSONSchema=(n,o,s)=>qf(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new ci({...t,checks:[],...y(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new ci({...t,checks:[],...y(o),entries:s})}});function iy(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new ci({type:\"enum\",entries:r,...y(t)})}var cy=m(\"ZodLiteral\",(e,t)=>{Al.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gf(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,\"value\",{get(){if(t.values.length>1)throw Error(\"This schema contains multiple valid literal values. Use `.values` instead.\");return t.values[0]}})});function Zt(e,t){return new cy({type:\"literal\",values:Array.isArray(e)?e:[e],...y(t)})}var ay=m(\"ZodTransform\",(e,t)=>{ai(),Ol.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hf(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")throw new mr(e.constructor.name);r.addIssue=(s)=>{if(typeof s===\"string\")r.issues.push(rt(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;if(i.code??(i.code=\"custom\"),!(\"input\"in i))i.input=r.value;i.inst??(i.inst=e),r.issues.push(rt(i))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((s)=>(r.value=s,r));return r.value=o,r}});function uy(e){return new ay({type:\"transform\",transform:e})}var Op=m(\"ZodOptional\",(e,t)=>{Rs.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>si(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function vp(e){return new Op({type:\"optional\",innerType:e})}var Tp=m(\"ZodExactOptional\",(e,t)=>{Tl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>si(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ly(e){return new Tp({type:\"optional\",innerType:e})}var fy=m(\"ZodNullable\",(e,t)=>{Pl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Sp(e){return new fy({type:\"nullable\",innerType:e})}var py=m(\"ZodDefault\",(e,t)=>{Zl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>op(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function dy(e,t){return new py({type:\"default\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():ys(t)}})}var hy=m(\"ZodPrefault\",(e,t)=>{Cl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function my(e,t){return new hy({type:\"prefault\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():ys(t)}})}var Pp=m(\"ZodNonOptional\",(e,t)=>{Dl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function gy(e,t){return new Pp({type:\"nonoptional\",innerType:e,...y(t)})}var yy=m(\"ZodCatch\",(e,t)=>{Nl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ip(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xy(e,t){return new yy({type:\"catch\",innerType:e,catchValue:typeof t===\"function\"?t:Pa(t)})}var _y=m(\"ZodPipe\",(e,t)=>{Ul.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cp(e,r,n,o),e.in=t.in,e.out=t.out});function $p(e,t){return new _y({type:\"pipe\",in:e,out:t})}var wy=m(\"ZodReadonly\",(e,t)=>{Rl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ap(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function by(e){return new wy({type:\"readonly\",innerType:e})}var ky=m(\"ZodCustom\",(e,t)=>{jl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wf(e,r,n,o)});function vy(e,t={}){return If(ky,e,t)}function Sy(e,t){return Ef(e,t)}var zr=32,oo=new Set([\"__proto__\",\"constructor\",\"prototype\"]),$y=li([ui().min(1).max(512).refine((e)=>!oo.has(e),\"unsafe path key\"),Tt().int().nonnegative()]),$r=Sr($y).min(1).max(zr);function Ir(e,t=0){if(t>zr)return!1;if(e===null||typeof e===\"boolean\"||typeof e===\"string\")return!0;if(typeof e===\"number\")return Number.isFinite(e);if(Array.isArray(e))return e.every((n)=>Ir(n,t+1));if(typeof e!==\"object\")return!1;let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)return!1;return Object.entries(e).every(([n,o])=>!oo.has(n)&&Ir(o,t+1))}var Zp=Qn().refine(Ir,\"value must be safe JSON\"),zy=Ap(\"type\",[Pt({type:Zt(\"set\"),path:$r,value:Zp}),Pt({type:Zt(\"delete\"),path:$r}),Pt({type:Zt(\"insert\"),path:$r,index:Tt().int().nonnegative(),values:Sr(Zp).min(1)}),Pt({type:Zt(\"increment\"),path:$r,by:Tt().finite()}),Pt({type:Zt(\"text\"),path:$r,index:Tt().int().nonnegative(),deleteCount:Tt().int().nonnegative().optional(),insert:ui().optional()})]).superRefine((e,t)=>{if(e.type===\"text\"&&(e.deleteCount??0)===0&&(e.insert??\"\").length===0)t.addIssue({code:\"custom\",message:\"text operation must insert or delete content\"})});function ro(e){if(Array.isArray(e)){let t=new re;return t.insert(0,e.map(ro)),t}if(e!==null&&typeof e===\"object\"){let t=new q;for(let[r,n]of Object.entries(e))t.set(r,ro(n));return t}return e}function fi(e,t=0){if(t>zr)throw Error(\"room document exceeds the maximum nesting depth\");if(e instanceof q){let r=Object.create(null);for(let[n,o]of e.entries()){if(oo.has(n))throw Error(`room document contains unsafe key \"${n}\"`);r[n]=fi(o,t+1)}return r}if(e instanceof re)return e.toArray().map((r)=>fi(r,t+1));if(e instanceof ae)return e.toString();if(!Ir(e))throw Error(\"room document contains a non-JSON value\");return e}function so(e){return fi(e.getMap(\"root\"))}function B(e){return e.map(String).join(\".\")}function Up(e){if(e.length===0||e.length>zr)throw Error(`room path must contain 1 to ${zr} segments`);for(let t of e)if(typeof t===\"string\"){if(t.length===0||t.length>512||oo.has(t))throw Error(`invalid room path segment \"${t}\"`)}else if(!Number.isInteger(t)||t<0)throw Error(`invalid room array index ${String(t)}`)}function Rp(e,t,r){if(e instanceof q){if(typeof t!==\"string\")throw Error(`expected an object key at \"${B(r)}\"`);if(!e.has(t))throw Error(`room path does not exist: \"${B(r)}\"`);return e.get(t)}if(typeof t!==\"number\"||t>=e.length)throw Error(`invalid array index at \"${B(r)}\"`);return e.get(t)}function io(e,t){Up(t);let r=e.getMap(\"root\");for(let n=0;n<t.length-1;n+=1){if(!(r instanceof q)&&!(r instanceof re))throw Error(`room path crosses a scalar at \"${B(t.slice(0,n+1))}\"`);r=Rp(r,t[n],t.slice(0,n+1))}if(!(r instanceof q)&&!(r instanceof re))throw Error(`room path parent is not a container: \"${B(t)}\"`);return{parent:r,key:t[t.length-1]}}function eo(e,t){let{parent:r,key:n}=io(e,t);return Rp(r,n,t)}function Cp(e,t,r){let{parent:n,key:o}=io(e,t),s=ro(r);if(n instanceof q){if(typeof o!==\"string\")throw Error(`expected an object key at \"${B(t)}\"`);n.set(o,s);return}if(typeof o!==\"number\"||o>=n.length)throw Error(`invalid array index at \"${B(t)}\"`);n.delete(o,1),n.insert(o,[s])}function Iy(e,t){let{parent:r,key:n}=io(e,t);if(r instanceof q){if(typeof n!==\"string\")throw Error(`expected an object key at \"${B(t)}\"`);if(!r.has(n))throw Error(`room path does not exist: \"${B(t)}\"`);r.delete(n);return}if(typeof n!==\"number\"||n>=r.length)throw Error(`invalid array index at \"${B(t)}\"`);r.delete(n,1)}function Dp(e,t){e.transact(()=>{for(let r of t)switch(r.type){case\"set\":Cp(e,r.path,r.value);break;case\"delete\":Iy(e,r.path);break;case\"insert\":{Up(r.path);let n=eo(e,r.path);if(!(n instanceof re))throw Error(`insert target is not an array: \"${B(r.path)}\"`);if(r.index>n.length)throw Error(`insert index is outside the array: \"${B(r.path)}\"`);n.insert(r.index,r.values.map(ro));break}case\"increment\":{let n=eo(e,r.path);if(typeof n!==\"number\"||!Number.isFinite(n))throw Error(`increment target is not a finite number: \"${B(r.path)}\"`);let o=n+r.by;if(!Number.isFinite(o))throw Error(`increment result is not finite: \"${B(r.path)}\"`);Cp(e,r.path,o);break}case\"text\":{let n=eo(e,r.path),o;if(n instanceof ae)o=n;else if(typeof n===\"string\"){o=new ae(n);let{parent:i,key:c}=io(e,r.path);if(i instanceof q&&typeof c===\"string\")i.set(c,o);else if(i instanceof re&&typeof c===\"number\"&&c<i.length)i.delete(c,1),i.insert(c,[o]);else throw Error(`invalid text path: \"${B(r.path)}\"`)}else throw Error(`text target is not a string: \"${B(r.path)}\"`);let s=r.deleteCount??0;if(r.index>o.length||r.index+s>o.length)throw Error(`text range is outside the string: \"${B(r.path)}\"`);if(s>0)o.delete(r.index,s);if(r.insert)o.insert(r.index,r.insert);break}}})}function Ey(e,t){let r=Sr(zy).min(1).parse(t),n=new ke({gc:!0});try{gn(n,St(e)),Dp(n,r),so(n)}finally{n.destroy()}let o=Nc(e);return Dp(e,r),St(e,o)}function no(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,s)=>no(o,t[s]));if(e===null||t===null||typeof e!==\"object\"||typeof t!==\"object\")return!1;let r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((o)=>Object.hasOwn(t,o)&&no(e[o],t[o]))}function Ay(e,t){if(no(e,t))return!0;if(e!==null&&t!==null&&!Array.isArray(e)&&!Array.isArray(t)&&typeof e===\"object\"&&typeof t===\"object\"&&Object.hasOwn(e,\"id\")&&Object.hasOwn(t,\"id\")){let r=e.id;return(typeof r===\"string\"||typeof r===\"number\")&&Object.is(r,t.id)}return!1}function pi(e){if(e!==null&&!Array.isArray(e)&&typeof e===\"object\"&&(typeof e.id===\"string\"||typeof e.id===\"number\"))return`id:${typeof e.id}:${String(e.id)}`;return`value:${JSON.stringify(e)}`}function Np(e){let t=[],r=new Set;for(let n of e){if(n===null||Array.isArray(n)||typeof n!==\"object\"||typeof n.id!==\"string\"&&typeof n.id!==\"number\")return null;let o=pi(n);if(r.has(o))return null;r.add(o),t.push(o)}return t}function Oy(e,t){let r=new Map;for(let s=0;s<t.length;s+=1){let i=pi(t[s]),c=r.get(i);if(c)c.push(s);else r.set(i,[s])}let n=[],o=-1;for(let s=0;s<e.length;s+=1){let i=r.get(pi(e[s]));while(i?.length&&i[0]<=o)i.shift();let c=i?.shift();if(c===void 0)continue;if(!Ay(e[s],t[c]))continue;n.push([s,c]),o=c}return n}function Ty(e,t){try{return eo(e,t)}catch{return}}function to(e,t,r,n,o){if(no(t,r))return;if(t!==null&&r!==null&&!Array.isArray(t)&&!Array.isArray(r)&&typeof t===\"object\"&&typeof r===\"object\"){for(let s of Object.keys(t))if(!Object.hasOwn(r,s))o.push({type:\"delete\",path:[...n,s]});for(let[s,i]of Object.entries(r))if(!Object.hasOwn(t,s))o.push({type:\"set\",path:[...n,s],value:i});else to(e,t[s],i,[...n,s],o);return}if(Array.isArray(t)&&Array.isArray(r)){let s=Np(t),i=Np(r),c=s!==null&&i!==null&&(s.length!==i.length||s.some((f,p)=>f!==i[p]));if(t.length===r.length&&!c){for(let f=0;f<r.length;f+=1)to(e,t[f],r[f],[...n,f],o);return}let a=0,l=0,u=0;for(let[f,p]of[...Oy(t,r),[t.length,r.length]]){let d=f-a;for(let g=0;g<d;g+=1)o.push({type:\"delete\",path:[...n,u]});let h=r.slice(l,p);if(h.length>0)o.push({type:\"insert\",path:n,index:u,values:h}),u+=h.length;if(f<t.length&&p<r.length)to(e,t[f],r[p],[...n,u],o),u+=1;a=f+1,l=p+1}return}if(typeof t===\"string\"&&typeof r===\"string\"&&Ty(e,n)instanceof ae){let s=0;while(s<t.length&&s<r.length&&t[s]===r[s])s+=1;let i=0;while(i<t.length-s&&i<r.length-s&&t[t.length-1-i]===r[r.length-1-i])i+=1;o.push({type:\"text\",path:n,index:s,deleteCount:t.length-s-i,insert:r.slice(s,r.length-i)});return}o.push({type:\"set\",path:n,value:r})}function jp(e,t){let r=so(e),n=structuredClone(r),o=t(n);if(o!==null&&(typeof o===\"object\"||typeof o===\"function\")&&typeof o.then===\"function\")throw Error(\"room change callback must be synchronous\");if(!Ir(n)||Array.isArray(n))throw Error(\"room state must be a safe JSON object\");let s=[];if(to(e,r,n,[],s),s.length>0)Ey(e,s);return s}function Lp(e){let t=\"\";for(let r=0;r<e.length;r+=8192)t+=String.fromCharCode(...e.subarray(r,r+8192));return btoa(t)}function Py(e){return Uint8Array.from(atob(e),(t)=>t.charCodeAt(0))}class co{handlers=new Map;on(e,t){let r=this.handlers.get(e)??new Set;return r.add(t),this.handlers.set(e,r),()=>r.delete(t)}emit(e,t){for(let r of this.handlers.get(e)??[])r(t)}}class Bp extends co{socket;rooms=new Map;channels=new Map;pending=new Map;nextId=0;opening;retry;stopped=!1;me;async open(){if(this.socket?.readyState===WebSocket.OPEN)return;if(this.opening)return this.opening;let e=location.pathname.match(/^\\/p\\/([^/.]+)/);if(!e)throw Error(\"Realtime rooms require a Swarm page\");let t=new URL(\"/@swarm/realtime\",location.href);return t.protocol=location.protocol===\"https:\"?\"wss:\":\"ws:\",t.searchParams.set(\"pageId\",decodeURIComponent(e[1])),this.opening=new Promise((r,n)=>{let o=new WebSocket(t);this.socket=o,o.onopen=()=>{this.opening=void 0,r()},o.onerror=()=>n(Error(\"Realtime connection failed\")),o.onmessage=(s)=>{let i=JSON.parse(s.data),c=i;if(c.seq)o.send(JSON.stringify({ack:c.seq}));if(c.type===\"hello\")this.me=c.me;if(c.type===\"room\")this.rooms.get(c.name??\"\")?.receive(i);if(c.type===\"presence\")this.rooms.get(c.name??\"\")?.receivePresence(c.peers);if(c.type===\"channel\")this.channels.get(c.name??\"\")?.emit(\"message\",c.data);if(c.type===\"deleted\")this.rooms.get(c.name??\"\")?.deleted();if(c.id!==void 0){let a=this.pending.get(c.id);if(a)if(clearTimeout(a.timer),this.pending.delete(c.id),c.type===\"error\")a.reject(Error(c.error));else a.resolve(c)}},o.onclose=()=>{this.opening=void 0,n(Error(\"Realtime connection closed\"));for(let s of this.pending.values())clearTimeout(s.timer),s.reject(Error(\"Realtime connection closed\"));if(this.pending.clear(),!this.stopped)this.retry=setTimeout(()=>{this.reconnect()},1000)}}),this.opening}async reconnect(){try{await this.open();for(let e of this.rooms.values())await e.join(!0);for(let e of this.channels.keys())await this.request({op:\"subscribe\",name:e})}catch(e){for(let t of this.rooms.values())t.emit(\"error\",e)}}async request(e){await this.open();let t=++this.nextId;return new Promise((r,n)=>{let o=setTimeout(()=>{this.pending.delete(t),n(Error(\"Realtime request timed out\"))},15000);this.pending.set(t,{resolve:r,reject:n,timer:o}),this.socket.send(JSON.stringify({...e,id:t}))})}close(){this.stopped=!0,clearTimeout(this.retry),this.socket?.close()}}class Mp extends co{connection;name;ydoc=new ke({gc:!0});generation=\"\";stale=!1;bytes=0;me;ready;writes=Promise.resolve();lastWrite=Promise.resolve();peers=[];presenceData={};presenceTimer;closed=!1;schemaVersion;presence;constructor(e,t,r){super();this.connection=e;this.name=t;this.schemaVersion=r.schemaVersion??1;let n=this;this.presence={set(o){if(n.presenceData=structuredClone(o),!n.presenceTimer)n.presenceTimer=setTimeout(()=>{n.presenceTimer=void 0,e.request({op:\"presence\",name:t,data:n.presenceData}).catch((s)=>n.emit(\"error\",s))},50)},get peers(){return n.peers}},this.observe()}get state(){return so(this.ydoc)}observe(){this.ydoc.on(\"update\",(e,t)=>{if(this.emit(\"change\",this.state),t===\"remote\"||!this.generation||this.closed)return;if(this.connection.socket?.readyState!==WebSocket.OPEN)return;let r=Lp(St(this.ydoc)),n=this.generation,o=this.writes.then(async()=>{try{let s=await this.connection.request({op:\"update\",name:this.name,generation:n,schemaVersion:this.schemaVersion,snapshot:r});if(s.room)this.receive(s.room)}catch(s){if(this.connection.socket?.readyState===WebSocket.OPEN){let i=await this.connection.request({op:\"join\",name:this.name,schemaVersion:this.schemaVersion});this.receive(i.room,!0)}throw this.emit(\"error\",s),s}});this.lastWrite=o,this.writes=o.catch(()=>{})})}async join(e=!1){if(this.ready&&!e)return this.ready;return this.ready=(async()=>{let t=this.generation,r=await this.connection.request({op:\"join\",name:this.name,schemaVersion:this.schemaVersion});if(this.me=r.me,this.receive(r.room),this.receivePresence(r.peers),e&&t===this.generation&&!this.stale){let n=await this.connection.request({op:\"update\",name:this.name,schemaVersion:this.schemaVersion,generation:t,snapshot:Lp(St(this.ydoc))});this.receive(n.room)}if(e)this.presence.set(this.presenceData)})(),this.ready}receive(e,t=!1){if(this.closed||!e)return;let r=t||this.generation!==\"\"&&e.generation!==this.generation;if(this.generation=e.generation,this.stale=e.schemaVersion!==this.schemaVersion,this.bytes=e.bytes,r)this.ydoc.destroy(),this.ydoc=new ke({gc:!0}),this.observe();if(gn(this.ydoc,Py(e.snapshot),\"remote\"),r)this.emit(\"reset\",this.state)}receivePresence(e=[]){this.peers=e,this.emit(\"presence\",e)}deleted(){this.closed=!0,this.emit(\"error\",Error(\"Room owner was deleted\")),this.ydoc.destroy()}async change(e){if(this.closed)throw Error(\"Room is closed\");if(this.stale)throw Error(\"Room schema is stale. Read the state and reset explicitly.\");if(jp(this.ydoc,e).length>0)await this.lastWrite}async apply(e){if(this.closed||this.stale)throw Error(\"Room is closed or stale\");await this.writes;let t=await this.connection.request({op:\"change\",name:this.name,generation:this.generation,schemaVersion:this.schemaVersion,operations:e});this.receive(t.room)}async reset(e={}){if(this.closed)throw Error(\"Room is closed\");await this.writes;let t=await this.connection.request({op:\"reset\",name:this.name,schemaVersion:this.schemaVersion,state:e});this.receive(t.room)}async close(){this.closed=!0,clearTimeout(this.presenceTimer),this.connection.rooms.delete(this.name);try{await this.connection.request({op:\"leave\",name:this.name})}finally{this.ydoc.destroy()}}}class Vp extends co{connection;name;constructor(e,t){super();this.connection=e;this.name=t}async publish(e){await this.connection.request({op:\"publish\",name:this.name,data:e})}async close(){this.connection.channels.delete(this.name),await this.connection.request({op:\"unsubscribe\",name:this.name})}}var ze=new Bp;window.addEventListener(\"pagehide\",()=>ze.close());async function rb(e=\"default\",t={}){if(!/^[a-zA-Z0-9_-]{1,64}$/.test(e))throw Error(\"Invalid room name\");let r=ze.rooms.get(e);if(r&&r.schemaVersion!==(t.schemaVersion??1))throw Error(\"Room already opened with a different schema version\");if(!r)r=new Mp(ze,e,t),ze.rooms.set(e,r);try{await r.join()}catch(n){throw ze.rooms.delete(e),n}return r}async function nb(e){if(!/^[a-zA-Z0-9_-]{1,64}$/.test(e))throw Error(\"Invalid channel name\");let t=ze.channels.get(e);if(t)return t;let r=new Vp(ze,e);ze.channels.set(e,r);try{await ze.request({op:\"subscribe\",name:e})}catch(n){throw ze.channels.delete(e),n}return r}export{nb as channel,rb as room};\n\n";
|
|
35909
36049
|
|
|
35910
36050
|
// src/http/realtime.ts
|
|
35911
36051
|
init_favorite_owner();
|
|
@@ -36065,7 +36205,7 @@ var updateRepo = route({
|
|
|
36065
36205
|
404: { description: "Repo not found", schema: object2({ error: string2() }) },
|
|
36066
36206
|
409: { description: "Duplicate repo", schema: object2({ error: string2() }) }
|
|
36067
36207
|
},
|
|
36068
|
-
rbac: { permission: "repo.merge-policy.write" }
|
|
36208
|
+
rbac: { permission: "repo.merge-policy.write", alsoAdmits: ["repo.exec-config.write"] }
|
|
36069
36209
|
});
|
|
36070
36210
|
var deleteRepo = route({
|
|
36071
36211
|
method: "delete",
|
|
@@ -39734,6 +39874,7 @@ var scheduleUpdateBodySchema = object2({
|
|
|
39734
39874
|
model: string2().nullable().optional(),
|
|
39735
39875
|
modelTier: ModelTierSchema.nullable().optional(),
|
|
39736
39876
|
profile: string2().nullable().optional(),
|
|
39877
|
+
modelGroup: string2().nullable().optional(),
|
|
39737
39878
|
allowCustomModel: boolean().optional(),
|
|
39738
39879
|
nextRunAt: string2().nullable().optional(),
|
|
39739
39880
|
targetType: ScheduledTaskTargetTypeSchema.optional(),
|
|
@@ -39776,6 +39917,7 @@ var createSchedule = route({
|
|
|
39776
39917
|
model: string2().optional(),
|
|
39777
39918
|
modelTier: ModelTierSchema.optional(),
|
|
39778
39919
|
profile: string2().optional(),
|
|
39920
|
+
modelGroup: string2().optional(),
|
|
39779
39921
|
allowCustomModel: boolean().optional(),
|
|
39780
39922
|
scheduleType: _enum2(["recurring", "one_time"]).optional(),
|
|
39781
39923
|
targetType: ScheduledTaskTargetTypeSchema.optional(),
|
|
@@ -39792,6 +39934,9 @@ var createSchedule = route({
|
|
|
39792
39934
|
201: { description: "Schedule created", schema: ScheduledTaskSchema },
|
|
39793
39935
|
400: { description: "Validation error" },
|
|
39794
39936
|
409: { description: "Duplicate name" }
|
|
39937
|
+
},
|
|
39938
|
+
rbac: {
|
|
39939
|
+
ungated: "matches PATCH /api/schedules/{id}: bearer-authenticated agents may manage schedules"
|
|
39795
39940
|
}
|
|
39796
39941
|
});
|
|
39797
39942
|
var runScheduleNow = route({
|
|
@@ -39812,7 +39957,8 @@ var runScheduleNow = route({
|
|
|
39812
39957
|
},
|
|
39813
39958
|
400: { description: "Schedule is disabled" },
|
|
39814
39959
|
404: { description: "Schedule not found" }
|
|
39815
|
-
}
|
|
39960
|
+
},
|
|
39961
|
+
rbac: { permission: "schedule.run.any" }
|
|
39816
39962
|
});
|
|
39817
39963
|
var listSchedules = route({
|
|
39818
39964
|
method: "get",
|
|
@@ -39874,6 +40020,9 @@ var updateSchedule = route({
|
|
|
39874
40020
|
403: { description: "Deferral or target owned by another agent" },
|
|
39875
40021
|
404: { description: "Schedule not found" },
|
|
39876
40022
|
409: { description: "Duplicate name" }
|
|
40023
|
+
},
|
|
40024
|
+
rbac: {
|
|
40025
|
+
ungated: "matches PATCH /api/schedules/{id}: bearer-authenticated agents may manage schedules"
|
|
39877
40026
|
}
|
|
39878
40027
|
});
|
|
39879
40028
|
var patchSchedule = route({
|
|
@@ -39906,6 +40055,9 @@ var deleteSchedule = route({
|
|
|
39906
40055
|
responses: {
|
|
39907
40056
|
200: { description: "Schedule deleted", schema: object2({ success: literal2(true) }) },
|
|
39908
40057
|
404: { description: "Schedule not found" }
|
|
40058
|
+
},
|
|
40059
|
+
rbac: {
|
|
40060
|
+
ungated: "matches PATCH /api/schedules/{id}: bearer-authenticated agents may manage schedules"
|
|
39909
40061
|
}
|
|
39910
40062
|
});
|
|
39911
40063
|
async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
|
|
@@ -40033,6 +40185,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
40033
40185
|
profile: body.profile,
|
|
40034
40186
|
model: body.model,
|
|
40035
40187
|
modelTier: body.modelTier,
|
|
40188
|
+
modelGroup: body.modelGroup,
|
|
40036
40189
|
agentId: body.targetAgentId
|
|
40037
40190
|
});
|
|
40038
40191
|
if (profileError) {
|
|
@@ -40082,6 +40235,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
40082
40235
|
timezone: body.timezone,
|
|
40083
40236
|
...splitLegacyModelAlias({ model: body.model, modelTier: body.modelTier }),
|
|
40084
40237
|
profile: body.profile?.trim() || undefined,
|
|
40238
|
+
modelGroup: body.modelGroup?.trim() || undefined,
|
|
40085
40239
|
scheduleType: body.scheduleType,
|
|
40086
40240
|
targetType: body.targetType,
|
|
40087
40241
|
workflowId: body.workflowId,
|
|
@@ -40095,6 +40249,10 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
40095
40249
|
});
|
|
40096
40250
|
createSchedule.respond(res, 201, schedule);
|
|
40097
40251
|
} catch (error) {
|
|
40252
|
+
if (modelGroupRefError(error)) {
|
|
40253
|
+
jsonError(res, `Unknown model group "${body.modelGroup}".`, 400);
|
|
40254
|
+
return true;
|
|
40255
|
+
}
|
|
40098
40256
|
if (modelProfileRefError(error) === "missing") {
|
|
40099
40257
|
jsonError(res, `Unknown model profile "${body.profile}".`, 400);
|
|
40100
40258
|
return true;
|
|
@@ -40240,7 +40398,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
40240
40398
|
if (parsed.body.modelTier !== undefined || normalizedModel.modelTier) {
|
|
40241
40399
|
body.modelTier = normalizedModel.modelTier ?? null;
|
|
40242
40400
|
}
|
|
40243
|
-
} else if (agentChanged && existing.model && !profileUpdate.fields.profile) {
|
|
40401
|
+
} else if (agentChanged && existing.model && !profileUpdate.fields.profile && !profileUpdate.fields.modelGroup) {
|
|
40244
40402
|
const modelError = await explicitModelErrorForAgent({
|
|
40245
40403
|
model: existing.model,
|
|
40246
40404
|
allowCustomModel: true,
|
|
@@ -40355,6 +40513,10 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
40355
40513
|
try {
|
|
40356
40514
|
schedule = await updateScheduledTask2(parsed.params.id, body);
|
|
40357
40515
|
} catch (error) {
|
|
40516
|
+
if (modelGroupRefError(error)) {
|
|
40517
|
+
jsonError(res, `Unknown model group "${body.modelGroup}".`, 400);
|
|
40518
|
+
return true;
|
|
40519
|
+
}
|
|
40358
40520
|
if (modelProfileRefError(error) !== "missing")
|
|
40359
40521
|
throw error;
|
|
40360
40522
|
jsonError(res, `Unknown model profile "${body.profile}".`, 400);
|
|
@@ -42657,6 +42819,9 @@ var deleteScriptRunRoute = route({
|
|
|
42657
42819
|
responses: {
|
|
42658
42820
|
204: { description: "Script run cancelled, or already terminal" },
|
|
42659
42821
|
404: { description: "Script run not found" }
|
|
42822
|
+
},
|
|
42823
|
+
rbac: {
|
|
42824
|
+
ungated: "script workflow runs: open to agents like the script tools; no verb covers cancel, so user roles need admin"
|
|
42660
42825
|
}
|
|
42661
42826
|
});
|
|
42662
42827
|
var getInternalStepRoute = route({
|
|
@@ -42685,6 +42850,9 @@ var postInternalStepRoute = route({
|
|
|
42685
42850
|
responses: {
|
|
42686
42851
|
201: { description: "Journal step written", schema: object2({ ok: literal2(true) }) },
|
|
42687
42852
|
404: { description: "Script run not found" }
|
|
42853
|
+
},
|
|
42854
|
+
rbac: {
|
|
42855
|
+
ungated: "script-run subprocess callback authenticated by the run credential; no user flow calls it"
|
|
42688
42856
|
}
|
|
42689
42857
|
});
|
|
42690
42858
|
var heartbeatRoute = route({
|
|
@@ -42698,6 +42866,9 @@ var heartbeatRoute = route({
|
|
|
42698
42866
|
responses: {
|
|
42699
42867
|
204: { description: "Heartbeat recorded" },
|
|
42700
42868
|
404: { description: "Script run not found" }
|
|
42869
|
+
},
|
|
42870
|
+
rbac: {
|
|
42871
|
+
ungated: "script-run subprocess callback authenticated by the run credential; no user flow calls it"
|
|
42701
42872
|
}
|
|
42702
42873
|
});
|
|
42703
42874
|
var statusRoute2 = route({
|
|
@@ -42712,6 +42883,9 @@ var statusRoute2 = route({
|
|
|
42712
42883
|
responses: {
|
|
42713
42884
|
204: { description: "Status updated" },
|
|
42714
42885
|
404: { description: "Script run not found" }
|
|
42886
|
+
},
|
|
42887
|
+
rbac: {
|
|
42888
|
+
ungated: "script-run subprocess callback authenticated by the run credential; no user flow calls it"
|
|
42715
42889
|
}
|
|
42716
42890
|
});
|
|
42717
42891
|
var rawLlmRoute = route({
|
|
@@ -42725,6 +42899,9 @@ var rawLlmRoute = route({
|
|
|
42725
42899
|
responses: {
|
|
42726
42900
|
200: { description: "LLM call completed", schema: RawLlmOutputSchema },
|
|
42727
42901
|
500: { description: "LLM call failed" }
|
|
42902
|
+
},
|
|
42903
|
+
rbac: {
|
|
42904
|
+
ungated: "script-run subprocess callback authenticated by the run credential; no user flow calls it"
|
|
42728
42905
|
}
|
|
42729
42906
|
});
|
|
42730
42907
|
var agentTaskRoute = route({
|
|
@@ -42752,6 +42929,9 @@ var agentTaskRoute = route({
|
|
|
42752
42929
|
404: { description: "Script run not found" },
|
|
42753
42930
|
409: { description: "Agent task failed, was cancelled, or was superseded" },
|
|
42754
42931
|
422: { description: "Blocked by the follow-up re-delegation guard" }
|
|
42932
|
+
},
|
|
42933
|
+
rbac: {
|
|
42934
|
+
ungated: "script-run subprocess callback authenticated by the run credential; no user flow calls it"
|
|
42755
42935
|
}
|
|
42756
42936
|
});
|
|
42757
42937
|
async function stepParentRefusal(runAgentId, parentTaskId) {
|
|
@@ -43541,7 +43721,8 @@ var runRoute = route({
|
|
|
43541
43721
|
404: { description: "Script not found" },
|
|
43542
43722
|
409: { description: "Object busy, re-entry, or lease lost" },
|
|
43543
43723
|
501: { description: "workspace-rw scripts are not supported in v1" }
|
|
43544
|
-
}
|
|
43724
|
+
},
|
|
43725
|
+
rbac: { permission: "script.run" }
|
|
43545
43726
|
});
|
|
43546
43727
|
var searchRoute = route({
|
|
43547
43728
|
method: "post",
|
|
@@ -44506,7 +44687,8 @@ var createSessionLogsRoute = route({
|
|
|
44506
44687
|
schema: object2({ success: literal2(true), count: number2().int().nonnegative() })
|
|
44507
44688
|
},
|
|
44508
44689
|
400: { description: "Validation error" }
|
|
44509
|
-
}
|
|
44690
|
+
},
|
|
44691
|
+
rbac: { ungated: "worker telemetry ingest; no user flow writes it" }
|
|
44510
44692
|
});
|
|
44511
44693
|
var getSessionLogsByTask = route({
|
|
44512
44694
|
method: "get",
|
|
@@ -44569,7 +44751,8 @@ var createSessionCostRoute = route({
|
|
|
44569
44751
|
400: { description: "Validation error" },
|
|
44570
44752
|
403: { description: "Untrusted session attribution" },
|
|
44571
44753
|
409: { description: "Session identity conflict" }
|
|
44572
|
-
}
|
|
44754
|
+
},
|
|
44755
|
+
rbac: { ungated: "worker telemetry ingest; no user flow writes it" }
|
|
44573
44756
|
});
|
|
44574
44757
|
var getSessionCostSummaryRoute = route({
|
|
44575
44758
|
method: "get",
|
|
@@ -48071,7 +48254,8 @@ var jiraRefresh = route({
|
|
|
48071
48254
|
409: { description: "Jira not connected (no refresh token stored)" },
|
|
48072
48255
|
500: { description: "Refresh failed (e.g. revoked grant, network error)" },
|
|
48073
48256
|
503: { description: "Jira integration not configured" }
|
|
48074
|
-
}
|
|
48257
|
+
},
|
|
48258
|
+
rbac: { permission: "oauth-authorization.manage" }
|
|
48075
48259
|
});
|
|
48076
48260
|
var jiraWebhook = route({
|
|
48077
48261
|
method: "post",
|
|
@@ -48085,7 +48269,8 @@ var jiraWebhook = route({
|
|
|
48085
48269
|
200: { description: "Event accepted", schema: JiraWebhookEventResultSchema },
|
|
48086
48270
|
401: { description: "Invalid URL token" },
|
|
48087
48271
|
503: { description: "Jira webhook handler not configured" }
|
|
48088
|
-
}
|
|
48272
|
+
},
|
|
48273
|
+
rbac: { ungated: "inbound Jira webhook: the URL token is the credential, no bearer principal" }
|
|
48089
48274
|
});
|
|
48090
48275
|
var jiraWebhookRegister = route({
|
|
48091
48276
|
method: "post",
|
|
@@ -48517,7 +48702,8 @@ var linearRefresh = route({
|
|
|
48517
48702
|
409: { description: "Linear not connected (no refresh token stored)" },
|
|
48518
48703
|
500: { description: "Refresh failed" },
|
|
48519
48704
|
503: { description: "Linear integration not configured" }
|
|
48520
|
-
}
|
|
48705
|
+
},
|
|
48706
|
+
rbac: { permission: "oauth-authorization.manage" }
|
|
48521
48707
|
});
|
|
48522
48708
|
var linearWebhook = route({
|
|
48523
48709
|
method: "post",
|
|
@@ -48530,6 +48716,9 @@ var linearWebhook = route({
|
|
|
48530
48716
|
200: { description: "Event accepted", schema: LinearWebhookAcceptedSchema },
|
|
48531
48717
|
401: { description: "Invalid signature" },
|
|
48532
48718
|
503: { description: "Linear integration not configured" }
|
|
48719
|
+
},
|
|
48720
|
+
rbac: {
|
|
48721
|
+
ungated: "inbound webhook: the provider signature is the credential, no bearer principal"
|
|
48533
48722
|
}
|
|
48534
48723
|
});
|
|
48535
48724
|
var linearDisconnect = route({
|
|
@@ -48960,6 +49149,7 @@ var listUsers = route({
|
|
|
48960
49149
|
},
|
|
48961
49150
|
auth: { apiKey: true }
|
|
48962
49151
|
});
|
|
49152
|
+
var USER_ADMIN_UNGATED = "creates users or binds identities, which can reach a grant-all admin (operator-only admission)";
|
|
48963
49153
|
var createUserRoute = route({
|
|
48964
49154
|
method: "post",
|
|
48965
49155
|
path: "/api/users",
|
|
@@ -48989,7 +49179,8 @@ var createUserRoute = route({
|
|
|
48989
49179
|
401: { description: "Unauthorized" },
|
|
48990
49180
|
409: { description: "A user with this email already exists (user_exists)" }
|
|
48991
49181
|
},
|
|
48992
|
-
auth: { apiKey: true }
|
|
49182
|
+
auth: { apiKey: true },
|
|
49183
|
+
rbac: { ungated: USER_ADMIN_UNGATED }
|
|
48993
49184
|
});
|
|
48994
49185
|
var listUnmapped = route({
|
|
48995
49186
|
method: "get",
|
|
@@ -49039,7 +49230,8 @@ var resolveUnmapped = route({
|
|
|
49039
49230
|
},
|
|
49040
49231
|
404: { description: "Target user not found" }
|
|
49041
49232
|
},
|
|
49042
|
-
auth: { apiKey: true }
|
|
49233
|
+
auth: { apiKey: true },
|
|
49234
|
+
rbac: { ungated: USER_ADMIN_UNGATED }
|
|
49043
49235
|
});
|
|
49044
49236
|
var DISMISS_RBAC = {
|
|
49045
49237
|
ungated: "same posture as POST /api/users/unmapped/{kind}/{externalId}/resolve: bearer auth, guests rejected; it links and trusts nothing"
|
|
@@ -49136,7 +49328,8 @@ var updateUserRoute = route({
|
|
|
49136
49328
|
},
|
|
49137
49329
|
404: { description: "User not found" }
|
|
49138
49330
|
},
|
|
49139
|
-
auth: { apiKey: true }
|
|
49331
|
+
auth: { apiKey: true },
|
|
49332
|
+
rbac: { ungated: USER_ADMIN_UNGATED }
|
|
49140
49333
|
});
|
|
49141
49334
|
var mintUserMcpTokenRoute = route({
|
|
49142
49335
|
method: "post",
|
|
@@ -49164,7 +49357,10 @@ var mintUserMcpTokenRoute = route({
|
|
|
49164
49357
|
},
|
|
49165
49358
|
404: { description: "User not found" }
|
|
49166
49359
|
},
|
|
49167
|
-
auth: { apiKey: true }
|
|
49360
|
+
auth: { apiKey: true },
|
|
49361
|
+
rbac: {
|
|
49362
|
+
ungated: "mints another user's bearer token, so no scoped grant admits it (operator-only admission)"
|
|
49363
|
+
}
|
|
49168
49364
|
});
|
|
49169
49365
|
var revokeUserMcpTokenRoute = route({
|
|
49170
49366
|
method: "delete",
|
|
@@ -49181,7 +49377,8 @@ var revokeUserMcpTokenRoute = route({
|
|
|
49181
49377
|
401: { description: "Unauthorized" },
|
|
49182
49378
|
404: { description: "User or token not found" }
|
|
49183
49379
|
},
|
|
49184
|
-
auth: { apiKey: true }
|
|
49380
|
+
auth: { apiKey: true },
|
|
49381
|
+
rbac: { ungated: "same posture as POST /api/users/{id}/mcp-tokens (operator-only admission)" }
|
|
49185
49382
|
});
|
|
49186
49383
|
var createConnectorCodeRoute = route({
|
|
49187
49384
|
method: "post",
|
|
@@ -49349,7 +49546,8 @@ var mergeUsersRoute = route({
|
|
|
49349
49546
|
description: "Source is the last active admin (last_admin), or a merge job for the source or target is still running (merge_in_progress)"
|
|
49350
49547
|
}
|
|
49351
49548
|
},
|
|
49352
|
-
auth: { apiKey: true }
|
|
49549
|
+
auth: { apiKey: true },
|
|
49550
|
+
rbac: { ungated: USER_ADMIN_UNGATED }
|
|
49353
49551
|
});
|
|
49354
49552
|
var listMergeJobsRoute = route({
|
|
49355
49553
|
method: "get",
|
|
@@ -49429,7 +49627,8 @@ var addIdentityRoute = route({
|
|
|
49429
49627
|
404: { description: "User not found" },
|
|
49430
49628
|
409: { description: "The (kind, externalId) identity is already linked (identity_taken)" }
|
|
49431
49629
|
},
|
|
49432
|
-
auth: { apiKey: true }
|
|
49630
|
+
auth: { apiKey: true },
|
|
49631
|
+
rbac: { ungated: USER_ADMIN_UNGATED }
|
|
49433
49632
|
});
|
|
49434
49633
|
var deleteIdentityRoute = route({
|
|
49435
49634
|
method: "delete",
|
|
@@ -49446,7 +49645,8 @@ var deleteIdentityRoute = route({
|
|
|
49446
49645
|
401: { description: "Unauthorized" },
|
|
49447
49646
|
404: { description: "User not found" }
|
|
49448
49647
|
},
|
|
49449
|
-
auth: { apiKey: true }
|
|
49648
|
+
auth: { apiKey: true },
|
|
49649
|
+
rbac: { ungated: USER_ADMIN_UNGATED }
|
|
49450
49650
|
});
|
|
49451
49651
|
function writeGuarded(actor, targetUserId, write) {
|
|
49452
49652
|
return getDbClient2().transaction(async () => {
|
|
@@ -50571,6 +50771,9 @@ var githubWebhook = route({
|
|
|
50571
50771
|
},
|
|
50572
50772
|
401: { description: "Invalid signature" },
|
|
50573
50773
|
503: { description: "GitHub integration not configured" }
|
|
50774
|
+
},
|
|
50775
|
+
rbac: {
|
|
50776
|
+
ungated: "inbound webhook: the provider signature is the credential, no bearer principal"
|
|
50574
50777
|
}
|
|
50575
50778
|
});
|
|
50576
50779
|
var gitlabWebhook = route({
|
|
@@ -50584,6 +50787,9 @@ var gitlabWebhook = route({
|
|
|
50584
50787
|
200: { description: "Event processed", schema: WebhookDispatchResultSchema },
|
|
50585
50788
|
401: { description: "Invalid token" },
|
|
50586
50789
|
503: { description: "GitLab integration not configured" }
|
|
50790
|
+
},
|
|
50791
|
+
rbac: {
|
|
50792
|
+
ungated: "inbound webhook: the provider signature is the credential, no bearer principal"
|
|
50587
50793
|
}
|
|
50588
50794
|
});
|
|
50589
50795
|
var azureDevOpsWebhook = route({
|
|
@@ -50631,6 +50837,9 @@ var agentmailWebhook = route({
|
|
|
50631
50837
|
200: { description: "Event received", schema: object2({ received: literal2(true) }) },
|
|
50632
50838
|
401: { description: "Invalid signature" },
|
|
50633
50839
|
503: { description: "AgentMail integration not configured or inbound archive unavailable" }
|
|
50840
|
+
},
|
|
50841
|
+
rbac: {
|
|
50842
|
+
ungated: "inbound webhook: the provider signature is the credential, no bearer principal"
|
|
50634
50843
|
}
|
|
50635
50844
|
});
|
|
50636
50845
|
var kapsoWebhook = route({
|
|
@@ -50650,6 +50859,9 @@ var kapsoWebhook = route({
|
|
|
50650
50859
|
},
|
|
50651
50860
|
401: { description: "Invalid signature" },
|
|
50652
50861
|
503: { description: "Kapso integration not configured" }
|
|
50862
|
+
},
|
|
50863
|
+
rbac: {
|
|
50864
|
+
ungated: "inbound webhook: the provider signature is the credential, no bearer principal"
|
|
50653
50865
|
}
|
|
50654
50866
|
});
|
|
50655
50867
|
var chatSdkWebhook = route({
|
|
@@ -51397,6 +51609,7 @@ async function handleWebhooks(req, res, pathSegments) {
|
|
|
51397
51609
|
init_zod();
|
|
51398
51610
|
init_db4();
|
|
51399
51611
|
init_event_waits();
|
|
51612
|
+
init_post_bridge();
|
|
51400
51613
|
init_event_bus();
|
|
51401
51614
|
init_route_def();
|
|
51402
51615
|
init_utils2();
|
|
@@ -51422,10 +51635,13 @@ var runScopedSignalRoute = route({
|
|
|
51422
51635
|
})
|
|
51423
51636
|
},
|
|
51424
51637
|
404: { description: "Workflow run not found" },
|
|
51425
|
-
403: { description: "Event name is reserved for provider webhooks" },
|
|
51638
|
+
403: { description: "Event name is reserved for provider webhooks or server-emitted events" },
|
|
51426
51639
|
400: { description: "Validation error" }
|
|
51427
51640
|
},
|
|
51428
|
-
auth: { apiKey: true }
|
|
51641
|
+
auth: { apiKey: true },
|
|
51642
|
+
rbac: {
|
|
51643
|
+
ungated: "workflow runs: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51644
|
+
}
|
|
51429
51645
|
});
|
|
51430
51646
|
var globalSignalRoute = route({
|
|
51431
51647
|
method: "post",
|
|
@@ -51446,19 +51662,31 @@ var globalSignalRoute = route({
|
|
|
51446
51662
|
name: string2()
|
|
51447
51663
|
})
|
|
51448
51664
|
},
|
|
51449
|
-
403: { description: "Event name is reserved for provider webhooks" },
|
|
51665
|
+
403: { description: "Event name is reserved for provider webhooks or server-emitted events" },
|
|
51450
51666
|
400: { description: "Validation error" }
|
|
51451
51667
|
},
|
|
51452
|
-
auth: { apiKey: true }
|
|
51668
|
+
auth: { apiKey: true },
|
|
51669
|
+
rbac: {
|
|
51670
|
+
ungated: "workflow runs: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51671
|
+
}
|
|
51453
51672
|
});
|
|
51454
51673
|
var RESERVED_EVENT_MESSAGE = "Event name is reserved for provider webhooks";
|
|
51674
|
+
var SERVER_EVENT_MESSAGE = "Event name is reserved for server-emitted events";
|
|
51675
|
+
function reservedEventError(name) {
|
|
51676
|
+
if (isReservedProviderEvent(name))
|
|
51677
|
+
return RESERVED_EVENT_MESSAGE;
|
|
51678
|
+
if (isExtensionBridgedEvent(name))
|
|
51679
|
+
return SERVER_EVENT_MESSAGE;
|
|
51680
|
+
return null;
|
|
51681
|
+
}
|
|
51455
51682
|
async function handleWorkflowEvents(req, res, pathSegments, queryParams) {
|
|
51456
51683
|
if (runScopedSignalRoute.match(req.method, pathSegments)) {
|
|
51457
51684
|
const parsed = await runScopedSignalRoute.parse(req, res, pathSegments, queryParams);
|
|
51458
51685
|
if (!parsed)
|
|
51459
51686
|
return true;
|
|
51460
|
-
|
|
51461
|
-
|
|
51687
|
+
const reserved = reservedEventError(parsed.body.name);
|
|
51688
|
+
if (reserved) {
|
|
51689
|
+
jsonError(res, reserved, 403);
|
|
51462
51690
|
return true;
|
|
51463
51691
|
}
|
|
51464
51692
|
const run = await getWorkflowRun2(parsed.params.runId);
|
|
@@ -51479,8 +51707,9 @@ async function handleWorkflowEvents(req, res, pathSegments, queryParams) {
|
|
|
51479
51707
|
const parsed = await globalSignalRoute.parse(req, res, pathSegments, queryParams);
|
|
51480
51708
|
if (!parsed)
|
|
51481
51709
|
return true;
|
|
51482
|
-
|
|
51483
|
-
|
|
51710
|
+
const reserved = reservedEventError(parsed.body.name);
|
|
51711
|
+
if (reserved) {
|
|
51712
|
+
jsonError(res, reserved, 403);
|
|
51484
51713
|
return true;
|
|
51485
51714
|
}
|
|
51486
51715
|
workflowEventBus2.emit(parsed.body.name, parsed.body.payload ?? {});
|
|
@@ -51604,6 +51833,9 @@ var createWorkflowRoute = route({
|
|
|
51604
51833
|
403: { description: "Env var or secret input requires config.read.secrets" },
|
|
51605
51834
|
409: { description: "Idempotency-Key was already used for a different request" },
|
|
51606
51835
|
410: { description: "The workflow created under this Idempotency-Key was deleted" }
|
|
51836
|
+
},
|
|
51837
|
+
rbac: {
|
|
51838
|
+
ungated: "workflow definitions: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51607
51839
|
}
|
|
51608
51840
|
});
|
|
51609
51841
|
var getWorkflowRoute = route({
|
|
@@ -51655,6 +51887,9 @@ var updateWorkflowRoute = route({
|
|
|
51655
51887
|
400: { description: "Invalid definition" },
|
|
51656
51888
|
403: { description: "Env var or secret input requires config.read.secrets" },
|
|
51657
51889
|
404: { description: "Workflow not found" }
|
|
51890
|
+
},
|
|
51891
|
+
rbac: {
|
|
51892
|
+
ungated: "workflow definitions: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51658
51893
|
}
|
|
51659
51894
|
});
|
|
51660
51895
|
var patchWorkflowRoute = route({
|
|
@@ -51673,6 +51908,9 @@ var patchWorkflowRoute = route({
|
|
|
51673
51908
|
400: { description: "Invalid patch or resulting definition" },
|
|
51674
51909
|
403: { description: "Stored env var or secret input requires config.read.secrets" },
|
|
51675
51910
|
404: { description: "Workflow not found" }
|
|
51911
|
+
},
|
|
51912
|
+
rbac: {
|
|
51913
|
+
ungated: "workflow definitions: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51676
51914
|
}
|
|
51677
51915
|
});
|
|
51678
51916
|
var patchWorkflowNodeRoute = route({
|
|
@@ -51691,6 +51929,9 @@ var patchWorkflowNodeRoute = route({
|
|
|
51691
51929
|
400: { description: "Invalid patch or resulting definition" },
|
|
51692
51930
|
403: { description: "Stored env var or secret input requires config.read.secrets" },
|
|
51693
51931
|
404: { description: "Workflow or node not found" }
|
|
51932
|
+
},
|
|
51933
|
+
rbac: {
|
|
51934
|
+
ungated: "workflow definitions: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51694
51935
|
}
|
|
51695
51936
|
});
|
|
51696
51937
|
var deleteWorkflowRoute = route({
|
|
@@ -51703,6 +51944,9 @@ var deleteWorkflowRoute = route({
|
|
|
51703
51944
|
responses: {
|
|
51704
51945
|
204: { description: "Workflow deleted" },
|
|
51705
51946
|
404: { description: "Workflow not found" }
|
|
51947
|
+
},
|
|
51948
|
+
rbac: {
|
|
51949
|
+
ungated: "workflow definitions: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51706
51950
|
}
|
|
51707
51951
|
});
|
|
51708
51952
|
var triggerWorkflowRoute = route({
|
|
@@ -51727,6 +51971,9 @@ var triggerWorkflowRoute = route({
|
|
|
51727
51971
|
404: { description: "Workflow not found" },
|
|
51728
51972
|
409: { description: "Idempotency-Key was already used for a different request" },
|
|
51729
51973
|
410: { description: "The workflow triggered under this Idempotency-Key was deleted" }
|
|
51974
|
+
},
|
|
51975
|
+
rbac: {
|
|
51976
|
+
ungated: "workflow runs: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51730
51977
|
}
|
|
51731
51978
|
});
|
|
51732
51979
|
var validateTriggerRoute = route({
|
|
@@ -51743,6 +51990,9 @@ var validateTriggerRoute = route({
|
|
|
51743
51990
|
},
|
|
51744
51991
|
400: { description: "Payload failed validation; body matches the TriggerSchemaError contract" },
|
|
51745
51992
|
404: { description: "Workflow not found" }
|
|
51993
|
+
},
|
|
51994
|
+
rbac: {
|
|
51995
|
+
ungated: "workflow runs: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51746
51996
|
}
|
|
51747
51997
|
});
|
|
51748
51998
|
var listWorkflowRunsRoute = route({
|
|
@@ -51821,6 +52071,9 @@ var retryWorkflowRunRoute = route({
|
|
|
51821
52071
|
200: { description: "Retry started", schema: SuccessResponseSchema },
|
|
51822
52072
|
400: { description: "Cannot retry" },
|
|
51823
52073
|
404: { description: "Run not found" }
|
|
52074
|
+
},
|
|
52075
|
+
rbac: {
|
|
52076
|
+
ungated: "workflow runs: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
51824
52077
|
}
|
|
51825
52078
|
});
|
|
51826
52079
|
var cancelWorkflowRunRoute = route({
|
|
@@ -51835,7 +52088,10 @@ var cancelWorkflowRunRoute = route({
|
|
|
51835
52088
|
200: { description: "Run cancelled", schema: SuccessResponseSchema },
|
|
51836
52089
|
400: { description: "Cannot cancel" }
|
|
51837
52090
|
},
|
|
51838
|
-
auth: { apiKey: true }
|
|
52091
|
+
auth: { apiKey: true },
|
|
52092
|
+
rbac: {
|
|
52093
|
+
ungated: "workflow runs: open to agents like the workflow tools; no verb covers them, so user roles need admin"
|
|
52094
|
+
}
|
|
51839
52095
|
});
|
|
51840
52096
|
var listExecutorTypesRoute = route({
|
|
51841
52097
|
method: "get",
|
|
@@ -51892,6 +52148,9 @@ var webhookTriggerRoute = route({
|
|
|
51892
52148
|
201: { description: "Webhook processed", schema: object2({ runId: string2() }) },
|
|
51893
52149
|
401: { description: "Invalid signature" },
|
|
51894
52150
|
404: { description: "Workflow not found" }
|
|
52151
|
+
},
|
|
52152
|
+
rbac: {
|
|
52153
|
+
ungated: "inbound workflow webhook: the workflow's webhook secret is the credential, no bearer principal"
|
|
51895
52154
|
}
|
|
51896
52155
|
});
|
|
51897
52156
|
var listWorkflowVersionsRoute = route({
|
|
@@ -52551,6 +52810,9 @@ var scriptApiRoute = route({
|
|
|
52551
52810
|
schema: object2({ error: XScriptErrorSchema })
|
|
52552
52811
|
},
|
|
52553
52812
|
501: { description: "workspace-rw scripts are not supported" }
|
|
52813
|
+
},
|
|
52814
|
+
rbac: {
|
|
52815
|
+
ungated: "external script endpoint: its per-endpoint bearer is the credential; script.api.* gates who exposes it"
|
|
52554
52816
|
}
|
|
52555
52817
|
});
|
|
52556
52818
|
function extractBearer3(req) {
|
|
@@ -52931,7 +53193,7 @@ var httpServer = createHttpServer(async (req, res) => {
|
|
|
52931
53193
|
});
|
|
52932
53194
|
});
|
|
52933
53195
|
var detachRealtime = attachRealtimeTransport(httpServer);
|
|
52934
|
-
var { attachControllerTransport } = await import("./controllers-connect-
|
|
53196
|
+
var { attachControllerTransport } = await import("./controllers-connect-ynbvv8pv.js");
|
|
52935
53197
|
var detachControllers = attachControllerTransport(httpServer);
|
|
52936
53198
|
var stopWorkerNudges = startWorkerNudgeListener();
|
|
52937
53199
|
var taskAutoTitles = startTaskAutoTitleListener();
|
|
@@ -52962,7 +53224,7 @@ async function shutdown() {
|
|
|
52962
53224
|
sessionsProcessed: getServerSessionsProcessed()
|
|
52963
53225
|
});
|
|
52964
53226
|
if (hasCapability("scheduling")) {
|
|
52965
|
-
const { stopScheduler } = await import("./index-
|
|
53227
|
+
const { stopScheduler } = await import("./index-qffex5k4.js");
|
|
52966
53228
|
stopScheduler();
|
|
52967
53229
|
}
|
|
52968
53230
|
stopHeartbeat2();
|
|
@@ -52974,7 +53236,7 @@ async function shutdown() {
|
|
|
52974
53236
|
await stopSlackApp2();
|
|
52975
53237
|
await stopChatSdk();
|
|
52976
53238
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
52977
|
-
const { stopOAuthKeepalive } = await import("./keepalive-
|
|
53239
|
+
const { stopOAuthKeepalive } = await import("./keepalive-86z0tzzf.js");
|
|
52978
53240
|
await stopOAuthKeepalive();
|
|
52979
53241
|
}
|
|
52980
53242
|
stopOAuthPendingGc();
|
|
@@ -53065,21 +53327,21 @@ try {
|
|
|
53065
53327
|
console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
|
|
53066
53328
|
}
|
|
53067
53329
|
try {
|
|
53068
|
-
const { ensurePricingSeeded } = await import("./boot-seeds-
|
|
53330
|
+
const { ensurePricingSeeded } = await import("./boot-seeds-48rr6r29.js");
|
|
53069
53331
|
ensurePricingSeeded();
|
|
53070
|
-
const { startPricingRefreshLoop } = await import("./pricing-refresh-
|
|
53332
|
+
const { startPricingRefreshLoop } = await import("./pricing-refresh-4314hwtw.js");
|
|
53071
53333
|
startPricingRefreshLoop();
|
|
53072
53334
|
} catch (err) {
|
|
53073
53335
|
console.error("[startup] Failed to seed pricing rows:", err);
|
|
53074
53336
|
}
|
|
53075
53337
|
try {
|
|
53076
|
-
const { ensureModelProfilesSeeded } = await import("./boot-seeds-
|
|
53338
|
+
const { ensureModelProfilesSeeded } = await import("./boot-seeds-48rr6r29.js");
|
|
53077
53339
|
await ensureModelProfilesSeeded();
|
|
53078
53340
|
} catch (err) {
|
|
53079
53341
|
console.error("[startup] Failed to seed model profiles:", err);
|
|
53080
53342
|
}
|
|
53081
53343
|
try {
|
|
53082
|
-
const { ensureRbacSeeded } = await import("./boot-seeds-
|
|
53344
|
+
const { ensureRbacSeeded } = await import("./boot-seeds-48rr6r29.js");
|
|
53083
53345
|
ensureRbacSeeded();
|
|
53084
53346
|
} catch (err) {
|
|
53085
53347
|
console.error("[startup] Failed to sync RBAC seed rows:", err);
|
|
@@ -53087,13 +53349,13 @@ try {
|
|
|
53087
53349
|
throw err;
|
|
53088
53350
|
}
|
|
53089
53351
|
try {
|
|
53090
|
-
const { runAllSeeders } = await import("./index-
|
|
53352
|
+
const { runAllSeeders } = await import("./index-j6sqtb83.js");
|
|
53091
53353
|
await runAllSeeders({ scriptEmbeddingMode: "skip" });
|
|
53092
53354
|
} catch (err) {
|
|
53093
53355
|
console.error("[startup] Failed to seed built-in entities:", err);
|
|
53094
53356
|
}
|
|
53095
53357
|
try {
|
|
53096
|
-
const { runImports } = await import("./index-
|
|
53358
|
+
const { runImports } = await import("./index-wsf1f5pe.js");
|
|
53097
53359
|
await runImports();
|
|
53098
53360
|
} catch (err) {
|
|
53099
53361
|
console.error("[startup] File import failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
@@ -53145,10 +53407,10 @@ httpServer.listen(port, async () => {
|
|
|
53145
53407
|
startChatSdk().catch((err) => {
|
|
53146
53408
|
console.error("[chat-sdk] Failed to start, continuing without Chat SDK:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53147
53409
|
});
|
|
53148
|
-
import("./agent-fs-provision-
|
|
53410
|
+
import("./agent-fs-provision-aan1cgpx.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
|
|
53149
53411
|
console.warn("[agent-fs] Failed to set the org swarm URL:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53150
53412
|
});
|
|
53151
|
-
import("./object-webhooks-
|
|
53413
|
+
import("./object-webhooks-2kynmdf8.js").then(({ ensureObjectWebhooksForKnownDrives }) => ensureObjectWebhooksForKnownDrives()).catch((err) => {
|
|
53152
53414
|
console.warn("[objects] agent-fs webhook boot check failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53153
53415
|
});
|
|
53154
53416
|
startQueueStallAlarm();
|
|
@@ -53164,22 +53426,22 @@ httpServer.listen(port, async () => {
|
|
|
53164
53426
|
await initWorkflows2();
|
|
53165
53427
|
await startScriptRunSupervisor(getScriptApiBaseUrl());
|
|
53166
53428
|
if (hasCapability("scheduling")) {
|
|
53167
|
-
const { parseSchedulerIntervalMs, startScheduler } = await import("./index-
|
|
53168
|
-
const { getExecutorRegistry } = await import("./index-
|
|
53429
|
+
const { parseSchedulerIntervalMs, startScheduler } = await import("./index-qffex5k4.js");
|
|
53430
|
+
const { getExecutorRegistry } = await import("./index-8w09aggw.js");
|
|
53169
53431
|
startScheduler(getExecutorRegistry(), parseSchedulerIntervalMs(process.env.SCHEDULER_INTERVAL_MS), { runId: globalState.__runId });
|
|
53170
53432
|
}
|
|
53171
53433
|
if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
|
|
53172
|
-
const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-
|
|
53434
|
+
const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-g2jntx15.js");
|
|
53173
53435
|
startHeartbeat(parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS));
|
|
53174
53436
|
}
|
|
53175
53437
|
startPoolRouting();
|
|
53176
53438
|
startRuntimeSupervisor();
|
|
53177
53439
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
53178
|
-
const { startOAuthKeepalive } = await import("./keepalive-
|
|
53440
|
+
const { startOAuthKeepalive } = await import("./keepalive-86z0tzzf.js");
|
|
53179
53441
|
startOAuthKeepalive();
|
|
53180
53442
|
}
|
|
53181
53443
|
if (!isEnvFlagEnabled("OAUTH_REFRESH_SWEEP_DISABLE", false)) {
|
|
53182
|
-
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-
|
|
53444
|
+
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-6nmyrv32.js");
|
|
53183
53445
|
startOAuthRefreshSweep();
|
|
53184
53446
|
}
|
|
53185
53447
|
startOAuthPendingGc();
|
|
@@ -53189,19 +53451,19 @@ httpServer.listen(port, async () => {
|
|
|
53189
53451
|
startSavingsRollup(savingsRollupSql);
|
|
53190
53452
|
startHumanFreeDrain();
|
|
53191
53453
|
startTaskSearchBackfill();
|
|
53192
|
-
import("./embedding-space-
|
|
53454
|
+
import("./embedding-space-mjt5ksq0.js").then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: true })).catch((err) => {
|
|
53193
53455
|
console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
|
|
53194
53456
|
});
|
|
53195
|
-
import("./boot-args-schema-
|
|
53457
|
+
import("./boot-args-schema-rv97cmnt.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
|
|
53196
53458
|
console.error("[boot-args-schema] startup backfill failed (non-fatal):", err);
|
|
53197
53459
|
});
|
|
53198
|
-
import("./boot-scrub-sweep-
|
|
53460
|
+
import("./boot-scrub-sweep-20t8akhf.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
|
|
53199
53461
|
console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
|
|
53200
53462
|
});
|
|
53201
|
-
import("./user-merge-jobs-
|
|
53463
|
+
import("./user-merge-jobs-qfp40f2s.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
|
|
53202
53464
|
console.error("[user-merge] startup resume failed (non-fatal):", err);
|
|
53203
53465
|
});
|
|
53204
|
-
import("./session-source-backfill-
|
|
53466
|
+
import("./session-source-backfill-805p4wqr.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
|
|
53205
53467
|
console.error("[session-source-backfill] startup run failed (non-fatal):", err);
|
|
53206
53468
|
});
|
|
53207
53469
|
}).on("error", (err) => {
|