@desplega.ai/agent-swarm 2.13.5 → 2.14.1

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.
Files changed (551) hide show
  1. package/dist/acp-adapter-7jv7w8jh.js +17 -0
  2. package/dist/{acp-targets-w8dbs4nr.js → acp-targets-0ebmg3et.js} +10 -10
  3. package/dist/{actions-8zrcbjrx.js → actions-0ds9dx6c.js} +63 -42
  4. package/dist/{agent-fs-provision-cbt2ttds.js → agent-fs-provision-zpbxa9jc.js} +4 -4
  5. package/dist/{amp-adapter-8x6zp8w4.js → amp-adapter-awh5nn7a.js} +3 -3
  6. package/dist/{anthropic-messages-vdd1zmha.js → anthropic-messages-gtgp9r85.js} +17 -17
  7. package/dist/{app-zfa9dwjw.js → app-nzejkvpp.js} +10 -10
  8. package/dist/{approval-notifications-rv92zmza.js → approval-notifications-hbqtb2w3.js} +11 -11
  9. package/dist/{assistant-q7s7rm1q.js → assistant-1paft129.js} +42 -37
  10. package/dist/{boot-args-schema-g27kpzr1.js → boot-args-schema-zs435mfx.js} +1 -1
  11. package/dist/{boot-reembed-1mjs52nt.js → boot-reembed-7xq2qgg4.js} +1 -1
  12. package/dist/{boot-reembed-m62dpdkg.js → boot-reembed-91qrd4mz.js} +1 -1
  13. package/dist/{boot-scrub-sweep-ss1vcamw.js → boot-scrub-sweep-3h5xscw6.js} +2 -2
  14. package/dist/{boot-seeds-hwnvgbb3.js → boot-seeds-xkxqa8zc.js} +4 -4
  15. package/dist/{boxd-y0szhp0g.js → boxd-464x3w4m.js} +4 -4
  16. package/dist/{claude-adapter-0rjmbhjk.js → claude-adapter-6d8eyf2f.js} +12 -13
  17. package/dist/{claude-managed-adapter-6k032agg.js → claude-managed-adapter-jzxcaf9m.js} +4 -4
  18. package/dist/{claude-managed-setup-6czvve8q.js → claude-managed-setup-5fcx0qh3.js} +10 -10
  19. package/dist/{claude-sdk-session-pr0znb81.js → claude-sdk-session-11vhz1hc.js} +12720 -13882
  20. package/dist/{cli-kr0jpw9c.js → cli-02ba8qx5.js} +1 -1
  21. package/dist/{cli-ywy8yz6t.js → cli-08gfvs58.js} +2 -2
  22. package/dist/{cli-0qt3epg4.js → cli-0dkpdvnn.js} +10 -10
  23. package/dist/{cli-s8dhq7rj.js → cli-0mq8kxfx.js} +5 -5
  24. package/dist/{cli-ybte1fqc.js → cli-0nvqg1hb.js} +1 -1
  25. package/dist/{cli-f9xw9pr4.js → cli-0qyfna7a.js} +5 -5
  26. package/dist/cli-0vxbrxr3.js +1006 -0
  27. package/dist/{cli-ehg90jd1.js → cli-132h67ps.js} +64 -59
  28. package/dist/{cli-f7b9nyvk.js → cli-1e13gvfn.js} +17 -17
  29. package/dist/cli-1hj68b3h.js +30 -0
  30. package/dist/{cli-srktrbby.js → cli-1zbj28py.js} +1 -1
  31. package/dist/{cli-q41qar56.js → cli-20mkgwev.js} +173 -46
  32. package/dist/{cli-v09eza21.js → cli-288k5ep1.js} +15 -15
  33. package/dist/{cli-abby987g.js → cli-2n7qdqfv.js} +3 -3
  34. package/dist/{cli-kezzteka.js → cli-2r62jy9s.js} +1 -1
  35. package/dist/{cli-qmx8bnt4.js → cli-3179w2rz.js} +2 -2
  36. package/dist/cli-3a3hm1z8.js +15 -0
  37. package/dist/cli-3bagv8rt.js +37 -0
  38. package/dist/{cli-zxa1vmx7.js → cli-3bcsc3m7.js} +2 -2
  39. package/dist/{cli-j69pzrrz.js → cli-3g0vbq46.js} +5 -5
  40. package/dist/{cli-69szn7w7.js → cli-3ktfe5jx.js} +71 -47
  41. package/dist/{cli-69zzpjgh.js → cli-44r66df2.js} +1 -1
  42. package/dist/{cli-grbngev5.js → cli-466jjrwe.js} +11 -2
  43. package/dist/{cli-1jq2em7b.js → cli-4y2bekkn.js} +10 -9
  44. package/dist/cli-547fsc36.js +15 -0
  45. package/dist/{cli-6p8p2e6r.js → cli-5pyes68e.js} +1278 -23
  46. package/dist/{cli-ewk3sg68.js → cli-5t00r6c9.js} +3 -3
  47. package/dist/{cli-wzecestt.js → cli-5xjdft4s.js} +4063 -1835
  48. package/dist/{cli-4dyzzkfb.js → cli-643skca1.js} +954 -180
  49. package/dist/{cli-vr4eyq6p.js → cli-6a77m17n.js} +540 -412
  50. package/dist/{cli-v41kn3cd.js → cli-6prwz0zn.js} +4427 -5566
  51. package/dist/{cli-ks06cd0n.js → cli-6xrbpj5j.js} +8 -8
  52. package/dist/{cli-meydjstb.js → cli-6yhjqd6k.js} +4965 -69
  53. package/dist/{cli-bvamr9g0.js → cli-727sq1f9.js} +4 -4
  54. package/dist/{cli-snxhtehz.js → cli-7abeph0b.js} +7 -8
  55. package/dist/{cli-ty3gha1p.js → cli-7b9bwrfg.js} +2 -2
  56. package/dist/{cli-vbge4rsp.js → cli-7dwsn9y5.js} +4 -4
  57. package/dist/{cli-1kvcsd2f.js → cli-7qkbab03.js} +76 -8
  58. package/dist/{cli-8b4rpnwj.js → cli-7svwhw1a.js} +1 -1
  59. package/dist/{cli-jdq3jmny.js → cli-83kf2y60.js} +8 -10
  60. package/dist/{cli-tgc1kgg3.js → cli-84wxwt3z.js} +1 -1
  61. package/dist/{cli-sejvnjvw.js → cli-8crn0510.js} +1 -1
  62. package/dist/{cli-19d6v8er.js → cli-8kemtj1r.js} +172 -18
  63. package/dist/{cli-qrvk9nka.js → cli-967jrz7j.js} +40 -26
  64. package/dist/{cli-cp163xga.js → cli-976m0zcw.js} +72 -50
  65. package/dist/{cli-887vhew6.js → cli-98sea4d9.js} +2716 -2643
  66. package/dist/{cli-xh5fpmg8.js → cli-9txap41q.js} +101 -18
  67. package/dist/{cli-nrt048ys.js → cli-aktk3qt6.js} +40 -3
  68. package/dist/{cli-t0n9svkb.js → cli-b70cpf8f.js} +12 -7
  69. package/dist/{cli-2ap1the6.js → cli-by7s3n4p.js} +1 -1
  70. package/dist/{cli-tt7dkwjj.js → cli-byzq8xht.js} +7 -7
  71. package/dist/{cli-55h8m1x3.js → cli-d1zkys4j.js} +150 -99
  72. package/dist/cli-dr6x9qdk.js +15 -0
  73. package/dist/cli-dt931hb8.js +9740 -0
  74. package/dist/{cli-emdfd8fh.js → cli-dy754erz.js} +9 -1
  75. package/dist/{cli-2wzkvfgm.js → cli-e1wprqnd.js} +3 -3
  76. package/dist/{cli-pedm2kht.js → cli-e2wzzw17.js} +2 -2
  77. package/dist/{cli-1jx0srjt.js → cli-e9p9h14n.js} +1921 -80
  78. package/dist/{cli-evy3egte.js → cli-eaqxkeq0.js} +14 -103
  79. package/dist/{cli-he5nxaa8.js → cli-etykr11s.js} +3062 -728
  80. package/dist/{cli-3vw6dd4g.js → cli-f07sgaax.js} +2 -2
  81. package/dist/{cli-z1vam71h.js → cli-fe8he9cy.js} +2 -2
  82. package/dist/{cli-94gx6ze9.js → cli-h0edykd1.js} +1 -1
  83. package/dist/cli-h5cveb69.js +15 -0
  84. package/dist/{cli-5tq15aa7.js → cli-hamdfjtx.js} +2 -2
  85. package/dist/{cli-kwj3131p.js → cli-hh5m39pt.js} +1 -1
  86. package/dist/{cli-tvyt8w6n.js → cli-j8fmn3wv.js} +11 -11
  87. package/dist/cli-jngvszex.js +1514 -0
  88. package/dist/{cli-9n6g14vs.js → cli-k791mabe.js} +6 -6
  89. package/dist/{cli-6msnpj1z.js → cli-k9m8fckz.js} +10 -10
  90. package/dist/{cli-2vp0z049.js → cli-kz8rar0g.js} +1 -1
  91. package/dist/{cli-94mxerrp.js → cli-n15fhd43.js} +1 -1
  92. package/dist/{cli-htb5bpz2.js → cli-nmdy8bzf.js} +10 -3
  93. package/dist/{cli-t9pzz2eq.js → cli-ntmjzyte.js} +4 -1
  94. package/dist/{cli-avax5mp9.js → cli-ny8f5g7t.js} +19 -7
  95. package/dist/cli-p0g0erm9.js +15 -0
  96. package/dist/{cli-n79j1vxc.js → cli-pgdqhdkw.js} +4 -4
  97. package/dist/cli-ph1jce1b.js +16 -0
  98. package/dist/{cli-ced4azn1.js → cli-phantfg3.js} +771 -401
  99. package/dist/{cli-ebpq3c5z.js → cli-rb1z91g8.js} +10221 -1397
  100. package/dist/{cli-a49frv85.js → cli-redtbppc.js} +1 -1
  101. package/dist/{cli-cmbb2t8a.js → cli-s7bfz1ye.js} +15 -15
  102. package/dist/{cli-8pd1t17c.js → cli-sf5kp73f.js} +18 -18
  103. package/dist/{cli-zbbtp02a.js → cli-sq32dgfe.js} +1837 -7206
  104. package/dist/{cli-k0nebh10.js → cli-tbrjvrrg.js} +1 -1
  105. package/dist/{cli-4gaf3tx5.js → cli-tdd9dvw6.js} +1 -1
  106. package/dist/{cli-7ypg8hka.js → cli-tjrrabez.js} +3 -3
  107. package/dist/{cli-q1h041y8.js → cli-tkrp183j.js} +11 -11
  108. package/dist/{cli-srre41gb.js → cli-trvtxwzt.js} +2 -2
  109. package/dist/{cli-ffn0a515.js → cli-v1rhq77v.js} +68 -25
  110. package/dist/{cli-t879ww0y.js → cli-v3jxx8dv.js} +2 -2
  111. package/dist/{cli-b42yfn17.js → cli-v84kb7af.js} +14 -14
  112. package/dist/{cli-sa02jsqt.js → cli-vp2ksaq9.js} +1 -1
  113. package/dist/{cli-b0m3bg0f.js → cli-vrb8pvrf.js} +6 -6
  114. package/dist/cli-vxxdf2ma.js +15 -0
  115. package/dist/{cli-x2adbg4j.js → cli-w81s97bn.js} +1 -1
  116. package/dist/{cli-4vynxtrb.js → cli-wkzrknpt.js} +10 -3
  117. package/dist/{cli-fw67mnyc.js → cli-wqpvfq2m.js} +1 -1
  118. package/dist/{cli-prz1p3ft.js → cli-wsh5vfa7.js} +9 -9
  119. package/dist/{cli-hd5bm1e1.js → cli-wtwe8vng.js} +45 -45
  120. package/dist/{cli-34fygf87.js → cli-ww8wxfzx.js} +2 -2
  121. package/dist/{cli-e8trbfx1.js → cli-x80zagf5.js} +1 -1
  122. package/dist/{cli-zntvmqmm.js → cli-xd6ntv7x.js} +2 -2
  123. package/dist/{cli-vcpyttcw.js → cli-xmc2nrtv.js} +1 -1
  124. package/dist/{cli-z40t85ms.js → cli-ytgtqsy9.js} +1 -1
  125. package/dist/{cli-r3dxpmyt.js → cli-yvnnyjxm.js} +1 -1
  126. package/dist/{cli-zzq96q57.js → cli-z0c98h7h.js} +2450 -554
  127. package/dist/{cli-ryem5cfq.js → cli-z0effej1.js} +217 -27
  128. package/dist/{cli-0h8skzss.js → cli-zcb64xzv.js} +4 -3
  129. package/dist/{cli-5web09sb.js → cli-zdkcp8p0.js} +8 -10
  130. package/dist/{cli-z3x7h79n.js → cli-zgsd2w2k.js} +20 -22
  131. package/dist/{cli-7r9tvk8v.js → cli-zmfs06hg.js} +15 -9
  132. package/dist/{cli-3860pmrq.js → cli-zvsy4abb.js} +4 -4
  133. package/dist/{cli-5n9w2xzx.js → cli-zyf288rw.js} +2 -2
  134. package/dist/cli.js +64 -65
  135. package/dist/{codex-adapter-bn7eaxk5.js → codex-adapter-seht4h9t.js} +9 -9
  136. package/dist/{codex-hook-nnmezjg9.js → codex-hook-w5nmtrn2.js} +3 -3
  137. package/dist/{codex-login-ktfg1cxk.js → codex-login-67qarfcg.js} +1 -1
  138. package/dist/{codex-session-runner-j1e9hffc.js → codex-session-runner-tq95x3gq.js} +10 -10
  139. package/dist/{commands-amhpafrr.js → commands-0awwqxq5.js} +3 -3
  140. package/dist/{controller-tw7g10j2.js → controller-hgjx521c.js} +4 -4
  141. package/dist/{controllers-connect-2ssqz7f4.js → controllers-connect-j4kdmhfj.js} +28 -29
  142. package/dist/core-8fw1gwg7.js +41 -0
  143. package/dist/{cursor-adapter-d6knjmwa.js → cursor-adapter-0rg8wk6j.js} +2 -2
  144. package/dist/{db-fd6xxm77.js → db-8xs2js3s.js} +3 -3
  145. package/dist/{db-sc59379z.js → db-dd6hj211.js} +4 -2
  146. package/dist/{devin-adapter-3bp6rape.js → devin-adapter-tn1twrha.js} +1 -1
  147. package/dist/{devtools-qxfgbsqz.js → devtools-b8qts77k.js} +1 -1
  148. package/dist/{dispatcher-a2gdqz8c.js → dispatcher-v7drd034.js} +24 -25
  149. package/dist/{docker-a59g3ebm.js → docker-6007r2fj.js} +2 -2
  150. package/dist/dsh-adapter-ah8npj2x.js +11 -0
  151. package/dist/{e2b-qnxyfea6.js → e2b-hg80w0qr.js} +3 -3
  152. package/dist/{e2b-cn7cvjqy.js → e2b-z1g7vpz6.js} +16 -5
  153. package/dist/{easter-egg-3d-a0pphy71.js → easter-egg-3d-8n4w3s9k.js} +1 -1
  154. package/dist/{embedding-space-qepzrach.js → embedding-space-0p921zt3.js} +13 -23
  155. package/dist/{embeddings-d7vr881x.js → embeddings-9s7kbrc6.js} +1 -1
  156. package/dist/emscripten-module-Q67P5WYC-3sde6cre.js +2458 -0
  157. package/dist/{event-bus-7gbsr0g4.js → event-bus-pawddp92.js} +1 -1
  158. package/dist/{execute-6afts2bn.js → execute-x0fy9j0m.js} +1 -1
  159. package/dist/{external-channel-881zq1x4.js → external-channel-ktfvn29c.js} +2 -2
  160. package/dist/ffi-cbfmmtqk.js +85 -0
  161. package/dist/fx-adapter-15vjxvgm.js +20 -0
  162. package/dist/getMachineId-bsd-2rd3pnz7.js +36 -0
  163. package/dist/getMachineId-bsd-3p48mkt1.js +36 -0
  164. package/dist/{getMachineId-bsd-637a7rbk.js → getMachineId-bsd-bk6tmeen.js} +5 -5
  165. package/dist/getMachineId-bsd-pssqgwmm.js +37 -0
  166. package/dist/getMachineId-bsd-v218x3xd.js +36 -0
  167. package/dist/getMachineId-bsd-wbxcazef.js +36 -0
  168. package/dist/getMachineId-bsd-x0942pbz.js +36 -0
  169. package/dist/getMachineId-darwin-5qsy4qcg.js +36 -0
  170. package/dist/getMachineId-darwin-6v7zsshx.js +37 -0
  171. package/dist/getMachineId-darwin-fcc3fjag.js +36 -0
  172. package/dist/getMachineId-darwin-pg84hftj.js +36 -0
  173. package/dist/{getMachineId-darwin-9vytrcnn.js → getMachineId-darwin-tyyevt26.js} +5 -5
  174. package/dist/getMachineId-darwin-wagmbf0d.js +36 -0
  175. package/dist/getMachineId-darwin-zvkmwr3y.js +36 -0
  176. package/dist/{getMachineId-linux-mkzsvyyz.js → getMachineId-linux-2ncg1epd.js} +3 -3
  177. package/dist/getMachineId-linux-2tmt2ptc.js +29 -0
  178. package/dist/getMachineId-linux-empwyp2y.js +29 -0
  179. package/dist/getMachineId-linux-fanqd45b.js +29 -0
  180. package/dist/getMachineId-linux-h6fyga0x.js +29 -0
  181. package/dist/getMachineId-linux-tbhgz1k9.js +29 -0
  182. package/dist/getMachineId-linux-zrbyw7dt.js +29 -0
  183. package/dist/getMachineId-unsupported-29g9dkgv.js +19 -0
  184. package/dist/getMachineId-unsupported-8xfq8djv.js +19 -0
  185. package/dist/getMachineId-unsupported-8y9cag1p.js +19 -0
  186. package/dist/getMachineId-unsupported-a6sjrm02.js +19 -0
  187. package/dist/getMachineId-unsupported-bp3w7ds0.js +19 -0
  188. package/dist/{getMachineId-unsupported-4cfs2n11.js → getMachineId-unsupported-sj6fk8sw.js} +3 -3
  189. package/dist/getMachineId-unsupported-v0p5gdxp.js +19 -0
  190. package/dist/getMachineId-win-hc996p0x.js +38 -0
  191. package/dist/{getMachineId-win-154s3qma.js → getMachineId-win-msq9ad87.js} +6 -6
  192. package/dist/getMachineId-win-tajyqwd6.js +38 -0
  193. package/dist/getMachineId-win-tzc163da.js +38 -0
  194. package/dist/getMachineId-win-xdaa0mgq.js +38 -0
  195. package/dist/getMachineId-win-xk6p98m5.js +38 -0
  196. package/dist/getMachineId-win-xtk658fm.js +38 -0
  197. package/dist/{google-generative-ai-sw77egmr.js → google-generative-ai-nzndg246.js} +1 -1
  198. package/dist/{google-vertex-rrw93g8h.js → google-vertex-ragh3nnw.js} +1 -1
  199. package/dist/grok-adapter-77httan0.js +20 -0
  200. package/dist/handlers-c1jp5b6h.js +39 -0
  201. package/dist/heartbeat-5yaj6dym.js +49 -0
  202. package/dist/{hook-a7eh6zty.js → hook-2jttae8s.js} +13 -14
  203. package/dist/hook-c99nycyh.js +21 -0
  204. package/dist/{http-6aw5wanc.js → http-7y9dbfrr.js} +870 -219
  205. package/dist/{index-kzdqn3dd.js → index-6g9rdcrj.js} +3036 -758
  206. package/dist/index-7dwh9kxh.js +41 -0
  207. package/dist/{index-ym9fgxad.js → index-8p03vx1h.js} +8 -8
  208. package/dist/{index-maddg9ys.js → index-cw8nxnba.js} +4330 -15375
  209. package/dist/{index-yq9hhhhy.js → index-dm7c6hw5.js} +28 -29
  210. package/dist/index-fqf82sbk.js +10584 -0
  211. package/dist/{index-126v2d0t.js → index-g7rthzrv.js} +11 -2923
  212. package/dist/{index-z2g9469g.js → index-h9xnzfhx.js} +114 -33
  213. package/dist/{index-42jq9yy3.js → index-jvfp0j47.js} +516 -10
  214. package/dist/{index-3j803vnb.js → index-q60mhcpd.js} +25094 -20637
  215. package/dist/index-qxcfv8vq.js +17 -0
  216. package/dist/{index-rz8ve510.js → index-t274qhhs.js} +6 -6
  217. package/dist/{index-kdmkfjt7.js → index-t4n9z755.js} +3491 -2487
  218. package/dist/{index-7dgxveck.js → index-tcegcysh.js} +5 -5
  219. package/dist/{index-whysn1wf.js → index-tn1m3q9b.js} +3 -3
  220. package/dist/index-wp9tarbt.js +43 -0
  221. package/dist/{index-xhad0n8m.js → index-xhp7yp3t.js} +1 -1
  222. package/dist/index-z6np2405.js +38 -0
  223. package/dist/{k8s-36gfn847.js → k8s-mr1r12th.js} +2 -2
  224. package/dist/{keepalive-zhbmztqw.js → keepalive-7eyb8y4t.js} +4 -5
  225. package/dist/lead-50cgn8s1.js +81 -0
  226. package/dist/{maintenance-rsp0591h.js → maintenance-tdrd8nwv.js} +1 -1
  227. package/dist/module-ES6BEMUI-6htewwha.js +1210 -0
  228. package/dist/{node-0as4n1ef.js → node-gbx1t3pa.js} +1 -1
  229. package/dist/{node-rxte5hc6.js → node-jkdd5w7m.js} +1 -1
  230. package/dist/{oauth-refresh-sweep-w3cqmxq7.js → oauth-refresh-sweep-f4c7g37h.js} +3 -4
  231. package/dist/{object-webhooks-331hay92.js → object-webhooks-p190rdxp.js} +7 -7
  232. package/dist/{onboard-n2w80m2n.js → onboard-56h4sks6.js} +12 -10
  233. package/dist/{opencode-adapter-z98127cz.js → opencode-adapter-xg3yxfr0.js} +8 -8
  234. package/dist/{otel-impl-xsk35tvf.js → otel-impl-kepzgm4n.js} +36360 -9179
  235. package/dist/{pending-2e6trkxd.js → pending-xgv316w0.js} +25 -26
  236. package/dist/{pi-mono-adapter-wh6yndtm.js → pi-mono-adapter-txe0syzb.js} +19 -22
  237. package/dist/{pricing-refresh-9355dj1t.js → pricing-refresh-041zpyhf.js} +2 -2
  238. package/dist/{rbac-roles-8eajw4s6.js → rbac-roles-8f3jbcaf.js} +2 -2
  239. package/dist/{rbac-roles-58y3m912.js → rbac-roles-cw7rrw5b.js} +3 -3
  240. package/dist/{render-v2-7gskkmd4.js → render-v2-2ezw4mzt.js} +10 -10
  241. package/dist/{resume-0drnmpja.js → resume-p14wdx8m.js} +13 -13
  242. package/dist/{runtime-d2tcmqte.js → runtime-he7c9g1r.js} +1 -1
  243. package/dist/{session-access-0ztys6bd.js → session-access-8jvq86fj.js} +5 -5
  244. package/dist/{session-source-backfill-cdm5s046.js → session-source-backfill-6fe3hcgb.js} +3 -3
  245. package/dist/{setup-pqwb9tcc.js → setup-6v0bn4r1.js} +15 -6
  246. package/dist/thread-buffer-8860v1ta.js +40 -0
  247. package/dist/{token-util-pjgekqxr.js → token-util-hnzceyn9.js} +1 -1
  248. package/dist/{token-pgr2w4s3.js → token-xnc02n6w.js} +21 -14
  249. package/dist/{tree-visibility-rwz67mje.js → tree-visibility-g1a8ff4r.js} +2 -2
  250. package/dist/{user-merge-jobs-mxrhamwt.js → user-merge-jobs-vjsps179.js} +3 -3
  251. package/dist/{virtual-modules-71y1gsmg.js → virtual-modules-mreda4fp.js} +3 -3
  252. package/dist/{work-objects-3k4ykt9j.js → work-objects-hfw15e35.js} +29 -33
  253. package/dist/{worker-follow-up-y0h64xpr.js → worker-follow-up-gbaz2ydz.js} +24 -25
  254. package/dist/worker-hkm8ftqp.js +81 -0
  255. package/dist/{x-d27jj7z7.js → x-k29vmskt.js} +2 -2
  256. package/openapi.json +303 -20
  257. package/package.json +45 -45
  258. package/src/apps/definition.ts +76 -24
  259. package/src/apps/row-store.ts +67 -0
  260. package/src/apps/script-types.ts +131 -21
  261. package/src/apps/store.ts +4 -1
  262. package/src/be/db/model-profiles.ts +103 -12
  263. package/src/be/db/script-runs.ts +33 -0
  264. package/src/be/db/slack-card-groups.ts +147 -0
  265. package/src/be/db/slack-trees.ts +26 -0
  266. package/src/be/db/task-idempotency.ts +63 -0
  267. package/src/be/db/tasks/read.ts +7 -0
  268. package/src/be/db/tasks/write.ts +4 -2
  269. package/src/be/db/workflow-idempotency.ts +6 -1
  270. package/src/be/db/workflows/read.ts +79 -0
  271. package/src/be/db.ts +65 -151
  272. package/src/be/improvements.ts +24 -2
  273. package/src/be/mcp-proxy.ts +45 -11
  274. package/src/be/memory/embedding-space.ts +10 -20
  275. package/src/be/memory/index.ts +35 -0
  276. package/src/be/memory/providers/openai-embedding.ts +10 -0
  277. package/src/be/migrations/348_task_deferred_until.sql +4 -0
  278. package/src/be/migrations/354_durable_objects.sql +9 -0
  279. package/src/be/migrations/356_slack_outcome_card_groups.sql +14 -0
  280. package/src/be/migrations/357_task_idempotency_keys.sql +27 -0
  281. package/src/be/migrations/362_favorites_app.sql +36 -0
  282. package/src/be/model-group-resolution.ts +134 -0
  283. package/src/be/model-tier-resolution.ts +120 -17
  284. package/src/be/model-validation.ts +9 -1
  285. package/src/be/repo-checked-update.ts +58 -5
  286. package/src/be/requester-timezone.ts +10 -0
  287. package/src/be/runtime-pools/routing.ts +22 -8
  288. package/src/be/script-connections.ts +5 -1
  289. package/src/be/script-credential-broker.ts +29 -2
  290. package/src/be/scripts/durable.ts +204 -0
  291. package/src/be/scripts/extract-schema.ts +36 -4
  292. package/src/be/scripts/run-credential.ts +1 -8
  293. package/src/be/scripts/typecheck.ts +32 -7
  294. package/src/be/seed-scripts/catalog/memory-eval.ts +11 -2
  295. package/src/be/seed-scripts/catalog/tool-usage.ts +27 -8
  296. package/src/be/swarm-config-guard.ts +104 -14
  297. package/src/be/users.ts +33 -12
  298. package/src/comb/review-batch.ts +16 -5
  299. package/src/commands/context-preamble.ts +237 -0
  300. package/src/commands/e2b.ts +14 -0
  301. package/src/commands/entrypoint-mcp-config.ts +231 -0
  302. package/src/commands/onboard/agent-fs-version.ts +1 -1
  303. package/src/commands/onboard/compose-generator.ts +2 -1
  304. package/src/commands/onboard/env-generator.ts +16 -7
  305. package/src/commands/runner.ts +23 -7
  306. package/src/commands/setup.tsx +17 -3
  307. package/src/extensions/contract-types.generated.ts +1 -1
  308. package/src/hooks/hook.ts +8 -2
  309. package/src/hooks/native-tool-hooks.ts +4 -2
  310. package/src/http/apps.ts +82 -42
  311. package/src/http/comb.ts +21 -5
  312. package/src/http/config.ts +8 -4
  313. package/src/http/db-query.ts +8 -2
  314. package/src/http/heartbeat.ts +5 -0
  315. package/src/http/index.ts +12 -6
  316. package/src/http/kv.ts +7 -5
  317. package/src/http/mcp-oauth.ts +16 -0
  318. package/src/http/mcp-servers.ts +43 -3
  319. package/src/http/memory.ts +28 -1
  320. package/src/http/metrics.ts +11 -4
  321. package/src/http/onboarding.ts +12 -1
  322. package/src/http/operator-actor.ts +3 -8
  323. package/src/http/poll.ts +20 -1
  324. package/src/http/repos.ts +30 -12
  325. package/src/http/request-principal.ts +27 -1
  326. package/src/http/schedules.ts +59 -11
  327. package/src/http/script-connection-proxy.ts +3 -1
  328. package/src/http/script-runs.ts +21 -10
  329. package/src/http/scripts.ts +177 -26
  330. package/src/http/session-cost-recompute.ts +9 -4
  331. package/src/http/skills.ts +70 -0
  332. package/src/http/status.ts +2 -0
  333. package/src/http/tasks.ts +103 -15
  334. package/src/http/trackers/jira.ts +18 -3
  335. package/src/http/trackers/linear.ts +3 -0
  336. package/src/kv-limits.ts +2 -0
  337. package/src/kv-reserved-namespaces.ts +25 -2
  338. package/src/prompts/base-prompt.ts +10 -6
  339. package/src/prompts/session-templates.ts +52 -3
  340. package/src/prompts/session-turns.ts +30 -0
  341. package/src/providers/acp-targets.ts +1 -1
  342. package/src/providers/amp-adapter.ts +11 -9
  343. package/src/providers/claude-managed-adapter.ts +14 -0
  344. package/src/providers/claude-sdk-session.ts +14 -1
  345. package/src/providers/cursor-adapter.ts +1 -1
  346. package/src/providers/dsh-adapter.ts +1 -1
  347. package/src/providers/opencode-adapter.ts +3 -5
  348. package/src/providers/runtime-dependencies.ts +11 -8
  349. package/src/rbac/legacy-policy.ts +7 -0
  350. package/src/rbac/permissions.ts +27 -0
  351. package/src/realtime/browser.generated.txt +1 -1
  352. package/src/scheduler/schedule-task.ts +1 -0
  353. package/src/scheduler/scheduler.ts +36 -18
  354. package/src/script-workflows/executor.ts +37 -8
  355. package/src/script-workflows/supervisor.ts +14 -0
  356. package/src/scripts-runtime/ctx.ts +5 -1
  357. package/src/scripts-runtime/durable-object-base.ts +19 -0
  358. package/src/scripts-runtime/eval-harness.ts +46 -1
  359. package/src/scripts-runtime/executors/native.ts +13 -1
  360. package/src/scripts-runtime/executors/quickjs-bundle.ts +20 -1
  361. package/src/scripts-runtime/executors/quickjs-prelude.ts +40 -1
  362. package/src/scripts-runtime/executors/quickjs-runner.ts +26 -3
  363. package/src/scripts-runtime/executors/quickjs-worker.ts +2 -1
  364. package/src/scripts-runtime/executors/types.ts +26 -0
  365. package/src/scripts-runtime/extract-signature.ts +96 -1
  366. package/src/scripts-runtime/loader.ts +11 -5
  367. package/src/scripts-runtime/mcp-client.ts +1 -1
  368. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  369. package/src/scripts-runtime/swarm-config.ts +7 -0
  370. package/src/scripts-runtime/swarm-sdk.ts +4 -1
  371. package/src/scripts-runtime/types/stdlib.d.ts +19 -0
  372. package/src/scripts-runtime/types/swarm-extension.d.ts +3 -0
  373. package/src/scripts-runtime/types/swarm-sdk.d.ts +19 -0
  374. package/src/slack/actions.ts +24 -0
  375. package/src/slack/assistant.ts +8 -0
  376. package/src/slack/blocks.ts +35 -0
  377. package/src/slack/channel-activity.ts +7 -0
  378. package/src/slack/config.ts +4 -0
  379. package/src/slack/enrich.ts +46 -54
  380. package/src/slack/files.ts +173 -23
  381. package/src/slack/handlers.test.ts +17 -19
  382. package/src/slack/handlers.ts +15 -14
  383. package/src/slack/render-v2.ts +265 -19
  384. package/src/slack/responses.ts +62 -5
  385. package/src/slack/session-mirror.ts +10 -5
  386. package/src/slack/task-output.ts +25 -14
  387. package/src/slack/templates.ts +9 -0
  388. package/src/slack/thread-participants.ts +64 -24
  389. package/src/slack/watcher.ts +4 -4
  390. package/src/slack/work-objects.ts +1 -1
  391. package/src/stdio.ts +5 -0
  392. package/src/tasks/follow-up-gate.ts +142 -38
  393. package/src/tasks/worker-follow-up.ts +126 -37
  394. package/src/tests/agents-list-model-display.test.ts +4 -0
  395. package/src/tests/amp-adapter.test.ts +57 -9
  396. package/src/tests/apps-script-types.test.ts +63 -16
  397. package/src/tests/apps-sort-order.test.ts +87 -0
  398. package/src/tests/base-prompt.test.ts +36 -2
  399. package/src/tests/bedrock-model-groups.test.ts +4 -0
  400. package/src/tests/channel-activity.test.ts +9 -0
  401. package/src/tests/chatgpt-subscription-model-groups.test.ts +4 -0
  402. package/src/tests/claude-hook-output.test.ts +2 -0
  403. package/src/tests/claude-managed-adapter.test.ts +15 -3
  404. package/src/tests/claude-sdk-stderr.test.ts +28 -0
  405. package/src/tests/codex-gpt6-release.test.ts +4 -0
  406. package/src/tests/comb-review-batch.test.ts +17 -4
  407. package/src/tests/comb-status.test.ts +1 -0
  408. package/src/tests/db-client.test.ts +11 -5
  409. package/src/tests/db-retention-defaults.test.ts +28 -3
  410. package/src/tests/db-task-read-contract.test.ts +1 -0
  411. package/src/tests/db-task-write-contract.test.ts +2 -2
  412. package/src/tests/defer-task.test.ts +23 -1
  413. package/src/tests/dsh-adapter.test.ts +1 -1
  414. package/src/tests/e2b-dispatch.test.ts +13 -1
  415. package/src/tests/entrypoint-mcp-config.test.ts +642 -0
  416. package/src/tests/entrypoint-repo-autoclone-args.test.ts +10 -0
  417. package/src/tests/fixtures/onboard/content.env.txt +2 -2
  418. package/src/tests/fixtures/onboard/dev.env.txt +2 -2
  419. package/src/tests/fixtures/onboard/full-all.env.txt +2 -2
  420. package/src/tests/fixtures/onboard/full.env.txt +2 -2
  421. package/src/tests/fixtures/onboard/research.env.txt +2 -2
  422. package/src/tests/fixtures/onboard/solo.env.txt +2 -2
  423. package/src/tests/fixtures/runner-missing-dependency.ts +2 -1
  424. package/src/tests/follow-up-gate-shadow.test.ts +268 -10
  425. package/src/tests/fx-adapter.test.ts +4 -5
  426. package/src/tests/hook-mcp-config-precedence.test.ts +59 -0
  427. package/src/tests/hook-ping-me-order.test.ts +1 -0
  428. package/src/tests/hook-runtime-close.test.ts +1 -0
  429. package/src/tests/improvements-payload.test.ts +2 -2
  430. package/src/tests/linear-outbound-sync.test.ts +59 -25
  431. package/src/tests/model-groups-live-catalog.test.ts +4 -0
  432. package/src/tests/oauth-credential-bindings.test.ts +8 -3
  433. package/src/tests/oauth-refresh-failure.test.ts +15 -3
  434. package/src/tests/onboard-env.test.ts +1 -1
  435. package/src/tests/openai-compatible-providers.test.ts +5 -0
  436. package/src/tests/openapi-route-headers.test.ts +2 -1
  437. package/src/tests/operator-actor-keyless.test.ts +103 -0
  438. package/src/tests/opus-5-5-registry.test.ts +4 -0
  439. package/src/tests/profile-tier-alias.test.ts +9 -3
  440. package/src/tests/provider-runtime-dependencies.test.ts +26 -15
  441. package/src/tests/routing-affinity-inventory.test.ts +11 -0
  442. package/src/tests/runner-context-preamble.test.ts +202 -0
  443. package/src/tests/runner-repo-clone-args.test.ts +125 -0
  444. package/src/tests/scheduler-occurrence.test.ts +60 -9
  445. package/src/tests/script-connections-mcp.test.ts +6 -3
  446. package/src/tests/script-connections.test.ts +4 -0
  447. package/src/tests/scripts-namespaces.test.ts +3 -1
  448. package/src/tests/secret-scrubber.test.ts +8 -2
  449. package/src/tests/session-cost-recompute-unit.test.ts +39 -0
  450. package/src/tests/session-costs-recompute-all-providers.test.ts +6 -3
  451. package/src/tests/session-route-posture.test.ts +7 -1
  452. package/src/tests/slack-file-tools-attachments.test.ts +14 -9
  453. package/src/tests/slack-identity-resolution.test.ts +10 -3
  454. package/src/tests/slack-inline-output.test.ts +10 -8
  455. package/src/tests/slack-render-v2.test.ts +9 -4
  456. package/src/tests/slack-steering.test.ts +8 -2
  457. package/src/tests/slack-thread-participants.test.ts +11 -1
  458. package/src/tests/sonnet-5-5-registry.test.ts +4 -0
  459. package/src/tests/swarm-config-encryption.test.ts +5 -8
  460. package/src/tests/ui-spec-script-actions-config.test.ts +7 -3
  461. package/src/tests/workflow-system-one-extraction.test.ts +21 -0
  462. package/src/tests/workflow-triggers-v2.test.ts +35 -11
  463. package/src/tests/workflow-wait-filter.test.ts +7 -7
  464. package/src/tests/worktree-reaper.test.ts +15 -4
  465. package/src/tools/app-patch.ts +6 -2
  466. package/src/tools/app-upsert.ts +8 -4
  467. package/src/tools/defer-task.ts +17 -77
  468. package/src/tools/kv/kv-get.ts +2 -0
  469. package/src/tools/kv/kv-list.ts +11 -5
  470. package/src/tools/kv/kv-set.ts +1 -3
  471. package/src/tools/repos/update-repo.ts +37 -19
  472. package/src/tools/schedules/create-schedule.ts +20 -3
  473. package/src/tools/schedules/patch-schedule.ts +30 -4
  474. package/src/tools/schedules/run-schedule-now.ts +21 -1
  475. package/src/tools/schedules/update-schedule.ts +30 -4
  476. package/src/tools/script-apis.ts +9 -4
  477. package/src/tools/script-common.ts +2 -2
  478. package/src/tools/script-run.ts +8 -0
  479. package/src/tools/script-upsert.ts +1 -1
  480. package/src/tools/send-task.ts +17 -3
  481. package/src/tools/slack-download-file.ts +15 -12
  482. package/src/tools/slack-post.ts +14 -3
  483. package/src/tools/slack-read.ts +3 -1
  484. package/src/tools/slack-reply.ts +22 -2
  485. package/src/tools/slack-start-thread.ts +8 -1
  486. package/src/tools/slack-upload-file.ts +99 -96
  487. package/src/tools/swarm-config/set-config.ts +3 -1
  488. package/src/tools/swarm-x.ts +0 -2
  489. package/src/tools/task-action.ts +16 -3
  490. package/src/tools/utils.ts +4 -1
  491. package/src/types.ts +18 -2
  492. package/src/utils/amp-models.ts +20 -4
  493. package/src/utils/constants.ts +20 -0
  494. package/src/utils/deferral-time.ts +61 -0
  495. package/src/utils/request-auth-context.ts +15 -16
  496. package/src/utils/secret-scrubber.ts +7 -5
  497. package/src/workflows/engine.ts +42 -19
  498. package/src/workflows/executors/agent-task.ts +13 -2
  499. package/src/workflows/executors/code-match.ts +11 -31
  500. package/src/workflows/executors/script.ts +13 -0
  501. package/src/workflows/executors/swarm-script.ts +0 -2
  502. package/src/workflows/executors/system-one-extraction.ts +9 -6
  503. package/src/workflows/executors/wait.ts +1 -1
  504. package/src/workflows/foreach-driver.ts +11 -13
  505. package/src/workflows/input.ts +24 -1
  506. package/src/workflows/model-validation.ts +13 -1
  507. package/src/workflows/node-timeout.ts +18 -0
  508. package/src/workflows/predicate-sandbox.ts +171 -0
  509. package/src/workflows/retry-poller.ts +3 -2
  510. package/src/workflows/triggers.ts +21 -11
  511. package/src/workflows/wait-filter.ts +14 -192
  512. package/src/x/composio.ts +10 -1
  513. package/templates/skills/apps/SKILL.md +4 -2
  514. package/templates/skills/apps/content.md +4 -2
  515. package/templates/skills/code-quality/content.md +4 -4
  516. package/templates/skills/heartbeat-runbook/content.md +1 -0
  517. package/templates/skills/scheduled-task-resilience/SKILL.md +2 -0
  518. package/templates/skills/scheduled-task-resilience/content.md +2 -0
  519. package/templates/skills/slack-interaction/content.md +4 -0
  520. package/templates/skills/swarm-docs/content.md +8 -0
  521. package/templates/skills/swarm-scripts/SKILL.md +44 -0
  522. package/templates/skills/swarm-scripts/content.md +44 -0
  523. package/dist/acp-adapter-tbt61zkm.js +0 -17
  524. package/dist/cli-5ss6qqt9.js +0 -45
  525. package/dist/cli-b9ygp1kz.js +0 -459
  526. package/dist/cli-dzzh58sy.js +0 -6996
  527. package/dist/cli-j9ccfveb.js +0 -1849
  528. package/dist/cli-kj0hyr43.js +0 -51
  529. package/dist/cli-m8f4379k.js +0 -173
  530. package/dist/cli-mna6pmfx.js +0 -1485
  531. package/dist/cli-r8ddn0hf.js +0 -25583
  532. package/dist/core-bwp98v4w.js +0 -42
  533. package/dist/dsh-adapter-43ygwqn7.js +0 -9
  534. package/dist/fx-adapter-cr2hq17y.js +0 -20
  535. package/dist/grok-adapter-ayddnbsc.js +0 -20
  536. package/dist/handlers-7ghs84x2.js +0 -41
  537. package/dist/heartbeat-4c022m6a.js +0 -50
  538. package/dist/hook-4k84x499.js +0 -22
  539. package/dist/index-dtt0d634.js +0 -44
  540. package/dist/index-hmszyqkk.js +0 -42
  541. package/dist/index-j6rm1rtn.js +0 -39
  542. package/dist/index-rwwhsmjg.js +0 -13
  543. package/dist/index-t56y945n.js +0 -4
  544. package/dist/index-vfemrwwk.js +0 -10002
  545. package/dist/lead-g2j4q39z.js +0 -83
  546. package/dist/thread-buffer-epx3san4.js +0 -42
  547. package/dist/worker-09gqn9xy.js +0 -83
  548. package/dist/{azure-openai-responses-jeaas6x0.js → azure-openai-responses-e76k86gf.js} +4 -4
  549. package/dist/{openai-codex-responses-70g39cgz.js → openai-codex-responses-z2h941b8.js} +4 -4
  550. package/dist/{openai-completions-cv3hp4h5.js → openai-completions-5bxdkeg9.js} +4 -4
  551. package/dist/{openai-responses-trsvnks6.js → openai-responses-dzf3e8r5.js} +4 -4
@@ -1,5 +1,5 @@
1
- import"./cli-6p8p2e6r.js";
2
- import"./cli-2ap1the6.js";
1
+ import"./cli-5pyes68e.js";
2
+ import"./cli-by7s3n4p.js";
3
3
  import {
4
4
  auditAssetKeys,
5
5
  init_asset_key_audit,
@@ -87,6 +87,8 @@ import {
87
87
  isChatSdkTask,
88
88
  selectTaskTools,
89
89
  init_task_tool_manifest,
90
+ isApiOnlyConfigKey,
91
+ isInternalConfigKey,
90
92
  MAX_DB_RETENTION_DAYS,
91
93
  DB_RETENTION_TUNING_BOUNDS,
92
94
  CODEX_OAUTH_KEEP_WARM_MAX_AGE_HOURS_BOUNDS,
@@ -144,6 +146,22 @@ import {
144
146
  init_workflow_runs,
145
147
  OpenAI2,
146
148
  init_openai2,
149
+ isInvalidClientError,
150
+ publicEndpointSsrfOptions,
151
+ mcpOAuthSsrfOptions,
152
+ discoverProtectedResourceMetadata,
153
+ discoverAuthorizationServerMetadata,
154
+ normalizeTokenEndpointAuthMethod,
155
+ resolveAdvertisedTokenEndpointAuthMethod,
156
+ authMethodForStoredClient,
157
+ selectDcrTokenEndpointAuthMethod,
158
+ registerClient,
159
+ buildAuthorizeUrl,
160
+ exchangeCodeForTokens,
161
+ refreshMcpToken,
162
+ revokeMcpToken,
163
+ computeExpiresAt,
164
+ init_mcp_wrapper,
147
165
  CANDIDATE_SET_MULTIPLIER,
148
166
  EMBEDDING_DIMENSIONS,
149
167
  init_constants2,
@@ -159,6 +177,7 @@ import {
159
177
  getEmbeddingProvider2,
160
178
  resetEmbeddingProvider2,
161
179
  getMemoryStore2,
180
+ setDeploymentEnvReader2,
162
181
  init_memory,
163
182
  searchScripts2,
164
183
  init_embeddings,
@@ -230,6 +249,8 @@ import {
230
249
  checkProfileForAgent,
231
250
  formatProfileCheckFailures,
232
251
  init_model_profile_check,
252
+ resolveGroupForAgent,
253
+ init_model_group_resolution,
233
254
  startTaskSearchBackfill,
234
255
  stopTaskSearchBackfill,
235
256
  init_search_index,
@@ -256,6 +277,7 @@ import {
256
277
  MAX_MODEL_PROFILE_FALLBACKS,
257
278
  modelProfileFallbacksError,
258
279
  taskProfileError,
280
+ modelGroupRefError,
259
281
  scheduleProfileUpdate,
260
282
  init_model_profiles,
261
283
  refreshActiveSessionOnActivity2,
@@ -314,7 +336,9 @@ import {
314
336
  updateTaskProgress2,
315
337
  init_write,
316
338
  IdempotencyKeyTakenError,
339
+ sha256,
317
340
  workflowRequestFingerprint,
341
+ requestFingerprint,
318
342
  assertWorkflowIdempotencyKeyUnused,
319
343
  recordAcceptedWorkflowOperation,
320
344
  init_workflow_idempotency,
@@ -523,7 +547,7 @@ import {
523
547
  countScriptRunJournalSteps2,
524
548
  countScriptRunJournalAgentTaskSteps2,
525
549
  init_db4
526
- } from "./cli-zzq96q57.js";
550
+ } from "./cli-z0c98h7h.js";
527
551
  import {
528
552
  PRIMARY_ROLE_NAMES2,
529
553
  OperatorGrantedTargetError2,
@@ -537,7 +561,7 @@ import {
537
561
  assertNotLastAdmin2,
538
562
  setUserRoles2,
539
563
  init_rbac_roles
540
- } from "./cli-34fygf87.js";
564
+ } from "./cli-ww8wxfzx.js";
541
565
  import {
542
566
  MAX_MODEL_GROUP_MEMBERS,
543
567
  listModelGroups,
@@ -547,21 +571,25 @@ import {
547
571
  modelGroupReferences,
548
572
  deleteModelGroup,
549
573
  init_model_groups
550
- } from "./cli-7ypg8hka.js";
574
+ } from "./cli-tjrrabez.js";
551
575
  import {
552
576
  requestModelCatalogRefresh2,
553
577
  init_pricing_refresh
554
- } from "./cli-pedm2kht.js";
578
+ } from "./cli-e2wzzw17.js";
555
579
  import {
556
580
  workflowEventBus2,
557
581
  init_event_bus
558
- } from "./cli-ybte1fqc.js";
559
- import"./cli-5n9w2xzx.js";
560
- import"./cli-4gaf3tx5.js";
561
- import"./cli-vr4eyq6p.js";
562
- import"./cli-r8ddn0hf.js";
582
+ } from "./cli-0nvqg1hb.js";
583
+ import {
584
+ shouldBlockChannel2,
585
+ init_external_channel
586
+ } from "./cli-zyf288rw.js";
587
+ import"./cli-tdd9dvw6.js";
588
+ import"./cli-6a77m17n.js";
589
+ import {
590
+ require_dist6
591
+ } from "./cli-dt931hb8.js";
563
592
  import {
564
- require_dist4,
565
593
  getSlackConnectionState,
566
594
  init_connection_state,
567
595
  getSlackInboundDiagnostics,
@@ -583,7 +611,7 @@ import {
583
611
  TaskUiSpecSchema,
584
612
  getTaskUiSpec,
585
613
  getTaskUiSpecsForTasks,
586
- init_task_ui_spec,
614
+ init_task_ui_spec2,
587
615
  initialize,
588
616
  ensure,
589
617
  init_business_use,
@@ -597,7 +625,7 @@ import {
597
625
  startSlackApp2,
598
626
  stopSlackApp2,
599
627
  init_app4
600
- } from "./cli-zbbtp02a.js";
628
+ } from "./cli-sq32dgfe.js";
601
629
  import {
602
630
  reconcileAgentMaxTasksPolicy,
603
631
  upsertSwarmConfigWithPolicyMirror,
@@ -611,12 +639,12 @@ import {
611
639
  reconcileAgentStatusFromRuntimes,
612
640
  listRuntimeInstancesForPool,
613
641
  init_multi_runtime
614
- } from "./cli-evy3egte.js";
642
+ } from "./cli-eaqxkeq0.js";
615
643
  import {
616
644
  retryFailedRun2,
617
645
  cancelWorkflowRun2,
618
646
  init_resume
619
- } from "./cli-55h8m1x3.js";
647
+ } from "./cli-d1zkys4j.js";
620
648
  import {
621
649
  safeParse,
622
650
  getObjectShape,
@@ -691,6 +719,7 @@ import {
691
719
  init_event_waits,
692
720
  stripSiblingBlock,
693
721
  init_sibling_block,
722
+ prepareTaskWithSiblingAwareness,
694
723
  createTaskWithSiblingAwareness,
695
724
  init_sibling_awareness,
696
725
  hasPendingEventWait,
@@ -900,6 +929,7 @@ import {
900
929
  agentFirstPrincipal,
901
930
  requireAuthKind,
902
931
  rejectGuest,
932
+ refuseAgentTokenWithout,
903
933
  init_request_principal,
904
934
  nextFallback2,
905
935
  createWorkerTaskFollowUp2,
@@ -999,7 +1029,10 @@ import {
999
1029
  reservedNamespaceError,
1000
1030
  privateNamespaceError,
1001
1031
  reservedRoomKeyError,
1032
+ scrubReservedRead,
1002
1033
  init_kv_reserved_namespaces,
1034
+ MAX_KV_BODY_BYTES,
1035
+ init_kv_limits,
1003
1036
  updateMcpServerChecked,
1004
1037
  init_mcp_server_checked_update,
1005
1038
  updateTouchesStdioExecution,
@@ -1024,6 +1057,7 @@ import {
1024
1057
  init_config3,
1025
1058
  changesMergePolicy,
1026
1059
  init_repo_merge_policy,
1060
+ execConfigRefusal,
1027
1061
  updateSwarmRepoChecked,
1028
1062
  init_repo_checked_update,
1029
1063
  getCombConfig,
@@ -1114,6 +1148,7 @@ import {
1114
1148
  init_model_validation,
1115
1149
  patchWorkflowDefinition,
1116
1150
  init_patch_definition,
1151
+ IDEMPOTENT_REPLAYED_HEADER,
1117
1152
  idempotencyKeyHeader,
1118
1153
  readIdempotencyKey,
1119
1154
  replayAcceptedOperation,
@@ -1125,7 +1160,7 @@ import {
1125
1160
  getEnabledCapabilities,
1126
1161
  createServer,
1127
1162
  init_server
1128
- } from "./cli-wzecestt.js";
1163
+ } from "./cli-5xjdft4s.js";
1129
1164
  import {
1130
1165
  getFileStorageProvider2,
1131
1166
  init_registry2
@@ -1151,7 +1186,7 @@ import {
1151
1186
  resolvePoolDelivery2,
1152
1187
  createPoolAgent2,
1153
1188
  init_db2
1154
- } from "./cli-f9xw9pr4.js";
1189
+ } from "./cli-0qyfna7a.js";
1155
1190
  import {
1156
1191
  warnIfCorsAllowsAnyOrigin,
1157
1192
  isOriginAllowedForCredentials,
@@ -1200,7 +1235,7 @@ import {
1200
1235
  describeRequestRoute,
1201
1236
  route,
1202
1237
  init_route_def
1203
- } from "./cli-tt7dkwjj.js";
1238
+ } from "./cli-byzq8xht.js";
1204
1239
  import {
1205
1240
  startPoolRouting,
1206
1241
  stopPoolRouting,
@@ -1213,29 +1248,29 @@ import {
1213
1248
  checkHeartbeatChecklist2,
1214
1249
  runHeartbeatSweep2,
1215
1250
  stopHeartbeat2
1216
- } from "./cli-qrvk9nka.js";
1217
- import"./cli-5tq15aa7.js";
1251
+ } from "./cli-967jrz7j.js";
1252
+ import"./cli-hamdfjtx.js";
1218
1253
  import {
1219
1254
  runtimeSupervisorStatus,
1220
1255
  startRuntimeSupervisor,
1221
1256
  stopRuntimeSupervisor
1222
- } from "./cli-b42yfn17.js";
1257
+ } from "./cli-v84kb7af.js";
1223
1258
  import {
1224
1259
  TASK_TITLE_TIMEOUT_MS,
1225
1260
  generateTaskTitle
1226
- } from "./cli-9n6g14vs.js";
1261
+ } from "./cli-k791mabe.js";
1227
1262
  import"./cli-ns59dc6r.js";
1228
1263
  import {
1229
1264
  ACP_TARGET_IDS
1230
- } from "./cli-k0nebh10.js";
1265
+ } from "./cli-tbrjvrrg.js";
1231
1266
  import {
1232
1267
  reasoningCapability,
1233
1268
  supportedReasoningLevels
1234
- } from "./cli-ywy8yz6t.js";
1269
+ } from "./cli-08gfvs58.js";
1235
1270
  import {
1236
1271
  MAX_RATE_LIMIT_RESET_MS,
1237
1272
  MAX_SPEND_CAP_HOLD_MS
1238
- } from "./cli-sejvnjvw.js";
1273
+ } from "./cli-8crn0510.js";
1239
1274
  import {
1240
1275
  AgentFsRequestError2,
1241
1276
  resolveAgentFsSharedContext2,
@@ -1246,10 +1281,10 @@ import {
1246
1281
  agentFsRequest2,
1247
1282
  resolveApiUrl2,
1248
1283
  init_agent_fs_provision
1249
- } from "./cli-ewk3sg68.js";
1284
+ } from "./cli-5t00r6c9.js";
1250
1285
  import {
1251
1286
  Anthropic
1252
- } from "./cli-q41qar56.js";
1287
+ } from "./cli-20mkgwev.js";
1253
1288
  import {
1254
1289
  isLeadChannelMonitoringEnabled,
1255
1290
  SIMILARITY_THRESHOLD,
@@ -1257,13 +1292,19 @@ import {
1257
1292
  isUnknownModelError,
1258
1293
  checkProviderPoolKey,
1259
1294
  writeSkillsToFilesystem
1260
- } from "./cli-jdq3jmny.js";
1295
+ } from "./cli-83kf2y60.js";
1261
1296
  import {
1262
1297
  objectWebhookSecret2,
1263
1298
  handleObjectWebhookEvent2,
1264
1299
  init_object_webhooks
1265
- } from "./cli-s8dhq7rj.js";
1266
- import"./cli-3860pmrq.js";
1300
+ } from "./cli-0mq8kxfx.js";
1301
+ import"./cli-z0effej1.js";
1302
+ import {
1303
+ LOOKUP_USER_TEAM2,
1304
+ isUserAllowed2,
1305
+ init_handlers
1306
+ } from "./cli-v1rhq77v.js";
1307
+ import"./cli-zvsy4abb.js";
1267
1308
  import {
1268
1309
  createUserMergeJob2,
1269
1310
  getUserMergeJob2,
@@ -1272,7 +1313,7 @@ import {
1272
1313
  findFailedUserMergeJob2,
1273
1314
  requeueUserMergeJob2,
1274
1315
  runUserMergeJobs2
1275
- } from "./cli-abby987g.js";
1316
+ } from "./cli-2n7qdqfv.js";
1276
1317
  import {
1277
1318
  isCodexOAuthConfigKey
1278
1319
  } from "./cli-j4bwnpkm.js";
@@ -1302,8 +1343,8 @@ import {
1302
1343
  init_person_responder,
1303
1344
  handleApprovalRequests,
1304
1345
  init_approval_requests
1305
- } from "./cli-v09eza21.js";
1306
- import"./cli-z40t85ms.js";
1346
+ } from "./cli-288k5ep1.js";
1347
+ import"./cli-ytgtqsy9.js";
1307
1348
  import {
1308
1349
  RATING_MODEL_MAX_LENGTH,
1309
1350
  REFERENCES_SOURCE_MAX_LENGTH,
@@ -1359,14 +1400,19 @@ import {
1359
1400
  init_oauth_credential_bindings,
1360
1401
  buildScriptCredentialBindingsWithFailures,
1361
1402
  init_script_credential_broker,
1403
+ DEFAULT_SANDBOX_LIMITS,
1404
+ resolveSandboxIdentity,
1362
1405
  buildSandboxedCommand,
1363
1406
  sandboxSpawnEnv,
1364
1407
  readStreamCapped,
1365
1408
  init_sandboxed_process,
1409
+ readRunDirFile,
1410
+ init_native,
1366
1411
  isExecutorAllowedByDeployment,
1367
1412
  init_registry,
1368
1413
  MIN_SCRIPT_WALL_CLOCK_MS,
1369
1414
  MAX_SCRIPT_WALL_CLOCK_MS,
1415
+ DEFAULT_SCRIPT_RESOURCES,
1370
1416
  init_types3,
1371
1417
  HOST_VALIDATED_ARGS,
1372
1418
  init_host_validated_args,
@@ -1399,7 +1445,7 @@ import {
1399
1445
  init_typecheck,
1400
1446
  parseSkillContent,
1401
1447
  init_skill_parser
1402
- } from "./cli-ced4azn1.js";
1448
+ } from "./cli-phantfg3.js";
1403
1449
  import {
1404
1450
  signalProcessGroup,
1405
1451
  detachedProcessGroup,
@@ -1416,17 +1462,17 @@ import {
1416
1462
  forceRefreshAuthorizationOrThrow,
1417
1463
  forceRefreshTokenOrThrow,
1418
1464
  init_ensure_token
1419
- } from "./cli-5web09sb.js";
1465
+ } from "./cli-zdkcp8p0.js";
1420
1466
  import {
1421
1467
  PRIMITIVE_KINDS,
1422
1468
  ObjectsError,
1423
1469
  recordObjectVersion,
1424
1470
  init_objects
1425
- } from "./cli-j69pzrrz.js";
1471
+ } from "./cli-3g0vbq46.js";
1426
1472
  import {
1427
1473
  agentFsClientFor,
1428
1474
  init_agent_fs_identity
1429
- } from "./cli-zxa1vmx7.js";
1475
+ } from "./cli-3bcsc3m7.js";
1430
1476
  import {
1431
1477
  FilesError,
1432
1478
  normalizeFilesError,
@@ -1435,7 +1481,7 @@ import {
1435
1481
  AgentFsProvider,
1436
1482
  init_agent_fs_provider
1437
1483
  } from "./cli-skd2c4ej.js";
1438
- import"./cli-r3dxpmyt.js";
1484
+ import"./cli-yvnnyjxm.js";
1439
1485
  import {
1440
1486
  automationIntegrationFixUrl,
1441
1487
  preflightAutomation,
@@ -1457,7 +1503,7 @@ import {
1457
1503
  definitionNodeIds,
1458
1504
  validateDefinition,
1459
1505
  init_definition2
1460
- } from "./cli-cp163xga.js";
1506
+ } from "./cli-976m0zcw.js";
1461
1507
  import {
1462
1508
  _fetchHolder,
1463
1509
  CLIENT_ID,
@@ -1473,23 +1519,19 @@ import {
1473
1519
  loadAllCodexOAuthSlots,
1474
1520
  getValidCodexOAuth,
1475
1521
  init_storage
1476
- } from "./cli-2vp0z049.js";
1522
+ } from "./cli-kz8rar0g.js";
1477
1523
  import {
1478
1524
  isMultiRuntimeEnabled,
1479
1525
  init_multi_runtime2
1480
1526
  } from "./cli-mdb054w3.js";
1481
- import {
1482
- getApiKey,
1483
- init_api_key
1484
- } from "./cli-pax9q4ff.js";
1485
1527
  import {
1486
1528
  createRuntimeProvider,
1487
1529
  init_runtime_providers
1488
- } from "./cli-n79j1vxc.js";
1530
+ } from "./cli-pgdqhdkw.js";
1489
1531
  import {
1490
- require_content_type
1491
- } from "./cli-1jx0srjt.js";
1492
- import"./cli-b0m3bg0f.js";
1532
+ getApiKey,
1533
+ init_api_key
1534
+ } from "./cli-pax9q4ff.js";
1493
1535
  import {
1494
1536
  hasSessionAccess,
1495
1537
  getSessionRoot,
@@ -1499,31 +1541,16 @@ import {
1499
1541
  toSessionSharesState,
1500
1542
  setSessionShares,
1501
1543
  init_session_shares
1502
- } from "./cli-kwj3131p.js";
1544
+ } from "./cli-hh5m39pt.js";
1503
1545
  import {
1504
- isInvalidClientError,
1505
- publicEndpointSsrfOptions,
1506
- mcpOAuthSsrfOptions,
1507
- discoverProtectedResourceMetadata,
1508
- discoverAuthorizationServerMetadata,
1509
- normalizeTokenEndpointAuthMethod,
1510
- resolveAdvertisedTokenEndpointAuthMethod,
1511
- authMethodForStoredClient,
1512
- selectDcrTokenEndpointAuthMethod,
1513
- registerClient,
1514
- buildAuthorizeUrl,
1515
- exchangeCodeForTokens,
1516
- refreshMcpToken,
1517
- revokeMcpToken,
1518
- computeExpiresAt,
1519
- init_mcp_wrapper
1520
- } from "./cli-b9ygp1kz.js";
1521
- import"./cli-v41kn3cd.js";
1546
+ require_content_type
1547
+ } from "./cli-e9p9h14n.js";
1548
+ import"./cli-vrb8pvrf.js";
1522
1549
  import {
1523
1550
  import_websocket,
1524
1551
  import_websocket_server,
1525
1552
  init_wrapper2
1526
- } from "./cli-69szn7w7.js";
1553
+ } from "./cli-1hj68b3h.js";
1527
1554
  import {
1528
1555
  registerSessionTokenConnection,
1529
1556
  init_session_token_connections,
@@ -1553,7 +1580,7 @@ import {
1553
1580
  revokeAllAgentSessionTokens,
1554
1581
  fingerprintApiKey,
1555
1582
  init_users
1556
- } from "./cli-avax5mp9.js";
1583
+ } from "./cli-ny8f5g7t.js";
1557
1584
  import {
1558
1585
  CORE_TOOLS,
1559
1586
  init_tool_config
@@ -1566,7 +1593,7 @@ import {
1566
1593
  providerAccountTelemetrySchema,
1567
1594
  rateLimitReplacementSchema,
1568
1595
  init_provider_account_telemetry
1569
- } from "./cli-fw67mnyc.js";
1596
+ } from "./cli-wqpvfq2m.js";
1570
1597
  import {
1571
1598
  CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
1572
1599
  CODEX_AUTH_WATCH_NAMESPACE,
@@ -1581,11 +1608,11 @@ import {
1581
1608
  IDENTITY_FIELD_BUDGETS,
1582
1609
  IdentityFieldBudgetError,
1583
1610
  init_identity_field_budget
1584
- } from "./cli-19d6v8er.js";
1611
+ } from "./cli-8kemtj1r.js";
1585
1612
  import {
1586
1613
  getSlackConfiguration,
1587
1614
  init_config5
1588
- } from "./cli-t9pzz2eq.js";
1615
+ } from "./cli-ntmjzyte.js";
1589
1616
  import {
1590
1617
  isSteeringEnabled2,
1591
1618
  init_steering_enabled
@@ -1596,33 +1623,6 @@ import {
1596
1623
  isSubscriptionPlanId,
1597
1624
  init_subscription_plans
1598
1625
  } from "./cli-nh7x3133.js";
1599
- import {
1600
- MODEL_SCOPED_WINDOWS,
1601
- KEY_WIDE_WINDOWS,
1602
- modelFamilyOf,
1603
- isModelScopedWindow,
1604
- activeModelBlocks,
1605
- init_model_rate_limit_windows,
1606
- CREDENTIAL_SELECTION_STRATEGIES,
1607
- credentialSelectionStrategy,
1608
- init_key_usage,
1609
- CREDENTIAL_POOL_VARS,
1610
- PROVIDER_CREDENTIAL_VARS,
1611
- getModelAwareCredentialVars,
1612
- splitCredentialPool,
1613
- selectCredential,
1614
- init_credentials2
1615
- } from "./cli-x2adbg4j.js";
1616
- import {
1617
- interpolate,
1618
- init_template2,
1619
- getTemplateDefinition,
1620
- getAllTemplateDefinitions,
1621
- init_registry3,
1622
- resolveTemplate,
1623
- init_resolver,
1624
- init_session_templates
1625
- } from "./cli-nrt048ys.js";
1626
1626
  import {
1627
1627
  getOpenRouterAttributionHeaders,
1628
1628
  init_openrouter_base_url
@@ -1803,7 +1803,34 @@ import {
1803
1803
  KvKeySchema,
1804
1804
  KvEntrySchema,
1805
1805
  init_types5
1806
- } from "./cli-7r9tvk8v.js";
1806
+ } from "./cli-zmfs06hg.js";
1807
+ import {
1808
+ MODEL_SCOPED_WINDOWS,
1809
+ KEY_WIDE_WINDOWS,
1810
+ modelFamilyOf,
1811
+ isModelScopedWindow,
1812
+ activeModelBlocks,
1813
+ init_model_rate_limit_windows,
1814
+ CREDENTIAL_SELECTION_STRATEGIES,
1815
+ credentialSelectionStrategy,
1816
+ init_key_usage,
1817
+ CREDENTIAL_POOL_VARS,
1818
+ PROVIDER_CREDENTIAL_VARS,
1819
+ getModelAwareCredentialVars,
1820
+ splitCredentialPool,
1821
+ selectCredential,
1822
+ init_credentials2
1823
+ } from "./cli-w81s97bn.js";
1824
+ import {
1825
+ interpolate,
1826
+ init_template2,
1827
+ getTemplateDefinition,
1828
+ getAllTemplateDefinitions,
1829
+ init_registry3,
1830
+ resolveTemplate,
1831
+ init_resolver,
1832
+ init_session_templates
1833
+ } from "./cli-aktk3qt6.js";
1807
1834
  import {
1808
1835
  init_zod
1809
1836
  } from "./cli-96234j5w.js";
@@ -1840,6 +1867,8 @@ import {
1840
1867
  getAppUrl,
1841
1868
  getLocalDevAppOrigins,
1842
1869
  getMcpBaseUrl,
1870
+ setApiLoopbackBaseUrl,
1871
+ getScriptApiBaseUrl,
1843
1872
  getPublicMcpBaseUrl,
1844
1873
  getAgentFsLiveUrl,
1845
1874
  agentFsFileRoute,
@@ -1847,7 +1876,11 @@ import {
1847
1876
  isCombEnabled,
1848
1877
  isAgentFsProxyEnabled,
1849
1878
  init_constants3
1850
- } from "./cli-grbngev5.js";
1879
+ } from "./cli-466jjrwe.js";
1880
+ import {
1881
+ realtimeBus,
1882
+ init_bus
1883
+ } from "./cli-syfdvhkc.js";
1851
1884
  import {
1852
1885
  parseEnvFlag,
1853
1886
  isEnvFlagEnabled,
@@ -1856,11 +1889,7 @@ import {
1856
1889
  import {
1857
1890
  init_package,
1858
1891
  package_default
1859
- } from "./cli-hd5bm1e1.js";
1860
- import {
1861
- realtimeBus,
1862
- init_bus
1863
- } from "./cli-syfdvhkc.js";
1892
+ } from "./cli-wtwe8vng.js";
1864
1893
  import {
1865
1894
  isAlias,
1866
1895
  baseUrlEnvVar,
@@ -1872,7 +1901,7 @@ import {
1872
1901
  registerVolatileSecret,
1873
1902
  registerEnvSecrets,
1874
1903
  init_secret_scrubber
1875
- } from "./cli-1kvcsd2f.js";
1904
+ } from "./cli-7qkbab03.js";
1876
1905
  import {
1877
1906
  __toESM
1878
1907
  } from "./cli-242037k3.js";
@@ -3152,6 +3181,7 @@ function stopMcpOverflowSweep() {
3152
3181
  }
3153
3182
 
3154
3183
  // src/http/index.ts
3184
+ init_memory();
3155
3185
  init_rbac_audit();
3156
3186
 
3157
3187
  // src/be/runtime-pools/seed.ts
@@ -5743,16 +5773,18 @@ function connect(ws, auth, runtimeId) {
5743
5773
 
5744
5774
  // src/script-workflows/supervisor.ts
5745
5775
  init_db4();
5776
+ init_registry();
5746
5777
  init_api_key();
5747
5778
  init_secret_scrubber();
5748
5779
 
5749
5780
  // src/script-workflows/executor.ts
5781
+ init_native();
5750
5782
  init_response_limit();
5751
5783
  init_process_group();
5752
5784
  init_sandboxed_process();
5753
5785
  import { randomUUID } from "node:crypto";
5754
5786
  import { existsSync } from "node:fs";
5755
- import { mkdtemp, rm } from "node:fs/promises";
5787
+ import { chown, mkdtemp, rm } from "node:fs/promises";
5756
5788
  import { createServer as createServer2 } from "node:net";
5757
5789
  import { join, resolve } from "node:path";
5758
5790
  import { fileURLToPath } from "node:url";
@@ -6354,6 +6386,7 @@ class LocalProcessScriptExecutor {
6354
6386
  const { run, apiKey } = input;
6355
6387
  const baseUrl = input.baseUrl.replace(/\/$/, "");
6356
6388
  const harnessPath = getScriptWorkflowHarnessPath();
6389
+ const runAs = resolveSandboxIdentity();
6357
6390
  const tmpdir = await mkdtemp(join(process.env.TMPDIR ?? "/tmp", `script-workflow-${run.id}-`));
6358
6391
  const sourceFile = `${tmpdir}/source.ts`;
6359
6392
  const argsFile = `${tmpdir}/args.json`;
@@ -6529,7 +6562,7 @@ class LocalProcessScriptExecutor {
6529
6562
  }
6530
6563
  const harnessEnv = {
6531
6564
  PATH: process.env.PATH ?? "/usr/bin:/bin",
6532
- HOME: process.env.HOME ?? "/tmp",
6565
+ HOME: runAs ? tmpdir : process.env.HOME ?? "/tmp",
6533
6566
  LANG: process.env.LANG ?? "C.UTF-8",
6534
6567
  LC_ALL: process.env.LC_ALL ?? "C.UTF-8",
6535
6568
  TMPDIR: tmpdir,
@@ -6544,7 +6577,11 @@ class LocalProcessScriptExecutor {
6544
6577
  SCRIPT_RUN_CAPABILITY_TOKEN: capabilityToken
6545
6578
  };
6546
6579
  try {
6547
- proc = registerProcessGroup(Bun.spawn(buildSandboxedCommand(["bun", "run", harnessPath], harnessEnv), {
6580
+ if (runAs) {
6581
+ await Promise.all([tmpdir, sourceFile, argsFile, socketPath].map((path) => chown(path, runAs.uid, runAs.gid)));
6582
+ }
6583
+ const command = buildSandboxedCommand(["bun", "run", harnessPath], harnessEnv, DEFAULT_SANDBOX_LIMITS, "inline", runAs);
6584
+ proc = registerProcessGroup(Bun.spawn(command, {
6548
6585
  cwd: tmpdir,
6549
6586
  detached: detachedProcessGroup,
6550
6587
  env: sandboxSpawnEnv(harnessEnv),
@@ -6569,6 +6606,10 @@ class LocalProcessScriptExecutor {
6569
6606
  const stderrPromise = readStreamCapped(proc.stderr, MAX_STDERR_BYTES).then(({ text, truncated }) => truncated ? `${text}
6570
6607
  …[stderr truncated]` : text, () => "");
6571
6608
  const spawned = proc;
6609
+ const runDirCheck = {
6610
+ maxBytes: DEFAULT_SANDBOX_LIMITS.maxFileKb * 1024,
6611
+ ...runAs ? { ownerUid: runAs.uid } : {}
6612
+ };
6572
6613
  const exited = spawned.exited.then(async (processExitCode) => {
6573
6614
  clearInterval(heartbeat);
6574
6615
  await terminateProcessGroup(spawned.pid);
@@ -6579,12 +6620,15 @@ class LocalProcessScriptExecutor {
6579
6620
  if (protocolFailure)
6580
6621
  throw protocolFailure;
6581
6622
  if (processExitCode !== 0) {
6582
- const file = Bun.file(errorFile);
6583
- const failure = await file.exists() ? JSON.parse(await file.text()) : undefined;
6623
+ const errorText = await readRunDirFile(errorFile, runDirCheck);
6624
+ const failure = errorText === undefined ? undefined : JSON.parse(errorText);
6584
6625
  const message = typeof failure?.message === "string" ? failure.message : `guest exited with ${processExitCode}`;
6585
6626
  throw new Error(message);
6586
6627
  }
6587
- const output = JSON.parse(await Bun.file(resultFile).text());
6628
+ const resultText = await readRunDirFile(resultFile, runDirCheck);
6629
+ if (resultText === undefined)
6630
+ throw new Error("guest wrote no readable result file");
6631
+ const output = JSON.parse(resultText);
6588
6632
  await postStatus(run, baseUrl, apiKey, { status: "completed", output });
6589
6633
  return { exitCode: 0, stderr };
6590
6634
  } catch (error) {
@@ -6653,11 +6697,17 @@ var scriptExecutor = localProcessScriptExecutor;
6653
6697
  function supervisorDisabled() {
6654
6698
  return process.env.SCRIPT_RUN_SUPERVISOR_DISABLE === "true";
6655
6699
  }
6700
+ var DURABLE_RUNS_NATIVE_REFUSED = 'Durable script runs use the native executor, which is not permitted when deployment SCRIPT_EXECUTOR="quickjs"';
6701
+ function durableScriptRunsAllowed() {
6702
+ return isExecutorAllowedByDeployment("native");
6703
+ }
6656
6704
  async function startScriptRunProcess(run, baseUrl, apiKeyOverride) {
6657
6705
  if (supervisorDisabled())
6658
6706
  return;
6659
6707
  if (managed.has(run.id))
6660
6708
  return;
6709
+ if (!durableScriptRunsAllowed())
6710
+ throw new Error(DURABLE_RUNS_NATIVE_REFUSED);
6661
6711
  const apiKey = apiKeyOverride ?? getApiKey();
6662
6712
  if (!apiKey)
6663
6713
  throw new Error("AGENT_SWARM_API_KEY is required to spawn script runs");
@@ -7313,10 +7363,7 @@ function getOperatorActor(req, res) {
7313
7363
  }
7314
7364
  const rawKey = extractBearer(req);
7315
7365
  const swarmKey = getApiKey();
7316
- if (!swarmKey) {
7317
- return { kind: "operator", id: fingerprintApiKey("") };
7318
- }
7319
- if (!rawKey || !verifyTokenEquality(swarmKey, rawKey)) {
7366
+ if (!swarmKey || !rawKey || !verifyTokenEquality(swarmKey, rawKey)) {
7320
7367
  jsonError(res, "Unauthorized", 401);
7321
7368
  return null;
7322
7369
  }
@@ -12574,6 +12621,7 @@ async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
12574
12621
  // src/http/comb.ts
12575
12622
  init_zod();
12576
12623
  init_audit_user();
12624
+ init_db4();
12577
12625
  init_config4();
12578
12626
 
12579
12627
  // src/comb/review-batch.ts
@@ -12756,12 +12804,16 @@ async function sendReviewBatch(input, deps = {}) {
12756
12804
  ...repairs.map((repair) => alreadySent(repair.id, repair.taskId))
12757
12805
  ]);
12758
12806
  }
12759
- const lead = await getLeadAgent2();
12807
+ const parent = input.parent;
12808
+ const lead = parent?.agentId ? null : await getLeadAgent2();
12760
12809
  leadState = !lead ? "none" : lead.status === "offline" ? "offline" : "online";
12761
12810
  const task = await createTask(text, {
12762
- agentId: lead?.id ?? "",
12763
- routingReason: lead ? "skill" : undefined,
12764
- routingSource: lead ? "engine_default" : undefined,
12811
+ agentId: parent?.agentId || lead?.id || "",
12812
+ parentTaskId: parent?.id,
12813
+ inheritParentOutputSchema: parent?.agentCaller,
12814
+ routingAffinity: parent && !parent.agentCaller ? { capabilities: [] } : undefined,
12815
+ routingReason: parent?.agentId ? "continuity" : lead ? "skill" : undefined,
12816
+ routingSource: parent?.agentId || lead ? "engine_default" : undefined,
12765
12817
  source: "comb",
12766
12818
  taskType: "comb-review",
12767
12819
  tags: ["comb"],
@@ -12794,7 +12846,13 @@ async function sendReviewBatch(input, deps = {}) {
12794
12846
  if (taskId === null && repaired.length === 0) {
12795
12847
  throw new ReviewBatchError(409, "Nothing to send", skipped);
12796
12848
  }
12797
- return taskId === null ? { taskId, sent: wonIds, skipped, repaired } : { taskId, sent: wonIds, skipped, repaired, lead: leadState };
12849
+ return taskId === null ? { taskId, sent: wonIds, skipped, repaired } : {
12850
+ taskId,
12851
+ sent: wonIds,
12852
+ skipped,
12853
+ repaired,
12854
+ lead: input.parent?.agentId ? undefined : leadState
12855
+ };
12798
12856
  }
12799
12857
  async function mapLimited(items, limit, fn) {
12800
12858
  const results = new Array(items.length);
@@ -12998,6 +13056,7 @@ init_errors2();
12998
13056
  init_secret_scrubber();
12999
13057
  init_request_principal();
13000
13058
  init_route_def();
13059
+ init_session_access();
13001
13060
  init_utils2();
13002
13061
  var skippedSchema = object2({
13003
13062
  id: string2(),
@@ -13019,10 +13078,11 @@ var reviewBatchRoute = route({
13019
13078
  method: "post",
13020
13079
  path: "/api/comb/review-batches",
13021
13080
  pattern: ["api", "comb", "review-batches"],
13022
- summary: "Send agent-fs comments to the swarm as one lead task",
13023
- description: "Comb's 'Send to swarm'. The server reads each comment again from agent-fs with its bootstrap key, skips replies, resolved comments, and comments already sent, and creates ONE task for the lead. Each sent comment gets a `[comb:sent task=<id>]` reply from the swarm service account. A comment is sent at most once. An optional `note` from the sender goes into the task text. When an earlier send lost its reply, the batch posts that reply again (`repaired`). Answers 404 while COMB_ENABLED is off.",
13081
+ summary: "Send agent-fs comments to the swarm as one task",
13082
+ description: "Comb's 'Send to swarm'. The server reads each comment again from agent-fs with its bootstrap key, skips replies, resolved comments, and comments already sent, and creates one task. An optional parentTaskId attaches it as a follow-up for the parent’s agent. Without a parent assignee it routes to the lead. Each sent comment gets a `[comb:sent task=<id>]` reply from the swarm service account. A comment is sent at most once. An optional `note` from the sender goes into the task text. When an earlier send lost its reply, the batch posts that reply again (`repaired`). Answers 404 while COMB_ENABLED is off.",
13024
13083
  tags: ["Comb"],
13025
13084
  body: object2({
13085
+ parentTaskId: uuid().optional(),
13026
13086
  orgId: string2().min(1),
13027
13087
  driveId: string2().min(1),
13028
13088
  commentIds: array2(uuid()).min(1).max(REVIEW_BATCH_MAX),
@@ -13049,6 +13109,7 @@ var reviewBatchRoute = route({
13049
13109
  schema: batchErrorSchema
13050
13110
  }
13051
13111
  },
13112
+ session: bodyTask("parentTaskId"),
13052
13113
  rbac: { permission: "task.create.own" }
13053
13114
  });
13054
13115
  async function handleComb(req, res, pathSegments, queryParams, myAgentId) {
@@ -13067,8 +13128,18 @@ async function handleComb(req, res, pathSegments, queryParams, myAgentId) {
13067
13128
  return true;
13068
13129
  }
13069
13130
  try {
13131
+ const { parentTaskId, ...batch } = parsed.body;
13132
+ const parent = parentTaskId ? await getTaskById2(parentTaskId) : null;
13133
+ if (parentTaskId && !parent) {
13134
+ jsonError(res, "Parent task not found", 404);
13135
+ return true;
13136
+ }
13137
+ const sender = parent ? await agentFirstPrincipal(req, myAgentId) : null;
13138
+ if (parent && sender && await denyParentAttach2(req, res, myAgentId, parent, sender))
13139
+ return true;
13070
13140
  const result = await sendReviewBatch({
13071
- ...parsed.body,
13141
+ ...batch,
13142
+ parent: parent ? { id: parent.id, agentId: parent.agentId, agentCaller: sender?.kind === "agent" } : undefined,
13072
13143
  requestedByUserId: await resolveHttpRequesterUserId(req, myAgentId)
13073
13144
  });
13074
13145
  reviewBatchRoute.respond(res, result.taskId === null ? 200 : 201, result);
@@ -13587,6 +13658,7 @@ declare module "swarm-extension" {
13587
13658
  modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;
13588
13659
  effort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
13589
13660
  profile?: string | undefined;
13661
+ modelGroup?: string | undefined;
13590
13662
  fallbackHops?:
13591
13663
  | {
13592
13664
  from: string;
@@ -13776,6 +13848,7 @@ declare module "swarm-extension" {
13776
13848
  resolvedEffort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
13777
13849
  profile?: string | undefined;
13778
13850
  resolvedProfile?: string | undefined;
13851
+ modelGroup?: string | undefined;
13779
13852
  fallbackHops?:
13780
13853
  | {
13781
13854
  from: string;
@@ -13806,6 +13879,7 @@ declare module "swarm-extension" {
13806
13879
  }
13807
13880
  | undefined;
13808
13881
  deferredAt?: string | undefined;
13882
+ deferredUntil?: string | undefined;
13809
13883
  compactionCount?: number | undefined;
13810
13884
  peakContextPercent?: number | undefined;
13811
13885
  peakContextTokens?: number | undefined;
@@ -18793,6 +18867,7 @@ async function handleGitHubToken(req, res, pathSegments, myAgentId) {
18793
18867
 
18794
18868
  // src/http/heartbeat.ts
18795
18869
  init_zod();
18870
+ init_request_principal();
18796
18871
  init_route_def();
18797
18872
  init_utils2();
18798
18873
  var HeartbeatActionResultSchema = object2({
@@ -18809,7 +18884,8 @@ var triggerSweep = route({
18809
18884
  200: { description: "Sweep completed successfully", schema: HeartbeatActionResultSchema },
18810
18885
  401: { description: "Unauthorized" }
18811
18886
  },
18812
- auth: { apiKey: true }
18887
+ auth: { apiKey: true },
18888
+ rbac: { permission: "heartbeat.trigger" }
18813
18889
  });
18814
18890
  var triggerChecklist = route({
18815
18891
  method: "post",
@@ -18824,13 +18900,16 @@ var triggerChecklist = route({
18824
18900
  },
18825
18901
  401: { description: "Unauthorized" }
18826
18902
  },
18827
- auth: { apiKey: true }
18903
+ auth: { apiKey: true },
18904
+ rbac: { permission: "heartbeat.trigger" }
18828
18905
  });
18829
18906
  async function handleHeartbeat(req, res, pathSegments) {
18830
18907
  if (triggerSweep.match(req.method, pathSegments)) {
18831
18908
  const parsed = await triggerSweep.parse(req, res, pathSegments, new URLSearchParams);
18832
18909
  if (!parsed)
18833
18910
  return true;
18911
+ if (await refuseAgentTokenWithout(req, res, "heartbeat.trigger"))
18912
+ return true;
18834
18913
  try {
18835
18914
  await runHeartbeatSweep2();
18836
18915
  triggerSweep.respond(res, 200, { success: true, message: "Heartbeat sweep completed" });
@@ -18844,6 +18923,8 @@ async function handleHeartbeat(req, res, pathSegments) {
18844
18923
  const parsed = await triggerChecklist.parse(req, res, pathSegments, new URLSearchParams);
18845
18924
  if (!parsed)
18846
18925
  return true;
18926
+ if (await refuseAgentTokenWithout(req, res, "heartbeat.trigger"))
18927
+ return true;
18847
18928
  try {
18848
18929
  await checkHeartbeatChecklist2();
18849
18930
  triggerChecklist.respond(res, 200, {
@@ -19276,7 +19357,7 @@ init_zod();
19276
19357
 
19277
19358
  // src/slack/app-icon.ts
19278
19359
  init_app4();
19279
- var import_web_api = __toESM(require_dist4(), 1);
19360
+ var import_web_api = __toESM(require_dist6(), 1);
19280
19361
  var TTL_MS = 60 * 60 * 1000;
19281
19362
  var REQUEST_TIMEOUT_MS = 2500;
19282
19363
  var cached = null;
@@ -19664,6 +19745,7 @@ var handleIntegrations = createIntegrationsHandler();
19664
19745
  // src/http/kv.ts
19665
19746
  init_zod();
19666
19747
  init_db4();
19748
+ init_kv_limits();
19667
19749
  init_kv_overflow();
19668
19750
  init_kv_reserved_namespaces();
19669
19751
  init_kv_view();
@@ -19672,7 +19754,6 @@ init_context_key();
19672
19754
  init_types5();
19673
19755
  init_route_def();
19674
19756
  init_utils2();
19675
- var MAX_KV_BODY_BYTES = 2 * 1024 * 1024;
19676
19757
  var MAX_KV_LIST_LIMIT = 1000;
19677
19758
  var kvSetBodySchema = object2({
19678
19759
  value: unknown(),
@@ -20164,6 +20245,7 @@ async function sendGet(req, res, namespace, key, query, respond) {
20164
20245
  jsonError(res, "not found", 404);
20165
20246
  return true;
20166
20247
  }
20248
+ entry.value = scrubReservedRead(namespace, entry.value);
20167
20249
  if (hasKvViewArgs(query)) {
20168
20250
  const view = resolveKvView(entry.value, query);
20169
20251
  if (!view.ok) {
@@ -20240,7 +20322,10 @@ async function sendList(req, res, namespace, query, respond) {
20240
20322
  const limit = Math.min(query.limit ?? 100, MAX_KV_LIST_LIMIT);
20241
20323
  const offset = query.offset ?? 0;
20242
20324
  const prefix = query.prefix && query.prefix.length > 0 ? query.prefix : undefined;
20243
- const entries = await listKv2(namespace, { prefix, limit, offset });
20325
+ const entries = (await listKv2(namespace, { prefix, limit, offset })).map((entry) => ({
20326
+ ...entry,
20327
+ value: scrubReservedRead(namespace, entry.value)
20328
+ }));
20244
20329
  const total = await countKv2(namespace, { prefix });
20245
20330
  respond(res, 200, { entries, total, namespace });
20246
20331
  return true;
@@ -21888,6 +21973,7 @@ init_ensure_mcp_token();
21888
21973
  init_mcp_wrapper();
21889
21974
  init_types5();
21890
21975
  init_constants3();
21976
+ init_request_principal();
21891
21977
  init_route_def();
21892
21978
  init_utils2();
21893
21979
  function callbackRedirectUri() {
@@ -21979,6 +22065,15 @@ async function discoverForMcp(resourceUrl) {
21979
22065
  if (!issuer)
21980
22066
  return null;
21981
22067
  const as = await discoverAuthorizationServerMetadata(issuer);
22068
+ for (const endpoint of [
22069
+ as.authorization_endpoint,
22070
+ as.token_endpoint,
22071
+ as.registration_endpoint,
22072
+ as.revocation_endpoint
22073
+ ]) {
22074
+ if (endpoint)
22075
+ assertUrlSafe(endpoint, mcpOAuthSsrfOptions());
22076
+ }
21982
22077
  return {
21983
22078
  resourceUrl: prmd.resource ?? resourceUrl,
21984
22079
  authorizationServerIssuer: as.issuer,
@@ -22112,6 +22207,7 @@ var refreshRoute = route({
22112
22207
  tags: ["MCP OAuth"],
22113
22208
  auth: { apiKey: true },
22114
22209
  params: object2({ mcpServerId: string2() }),
22210
+ rbac: { permission: "mcp-oauth.manage" },
22115
22211
  body: object2({
22116
22212
  userId: string2().optional()
22117
22213
  }).optional(),
@@ -22130,6 +22226,7 @@ var disconnectRoute = route({
22130
22226
  tags: ["MCP OAuth"],
22131
22227
  auth: { apiKey: true },
22132
22228
  params: object2({ mcpServerId: string2() }),
22229
+ rbac: { permission: "mcp-oauth.manage" },
22133
22230
  query: object2({ userId: string2().optional() }),
22134
22231
  responses: {
22135
22232
  200: { description: "Token revoked/deleted", schema: OkResponseSchema },
@@ -22144,6 +22241,7 @@ var manualClientRoute = route({
22144
22241
  tags: ["MCP OAuth"],
22145
22242
  auth: { apiKey: true },
22146
22243
  params: object2({ mcpServerId: string2() }),
22244
+ rbac: { permission: "mcp-oauth.manage" },
22147
22245
  body: object2({
22148
22246
  clientId: string2().min(1),
22149
22247
  clientSecret: string2().optional(),
@@ -22490,6 +22588,8 @@ async function handleMcpOAuth(req, res, pathSegments, queryParams) {
22490
22588
  const parsed = await refreshRoute.parse(req, res, pathSegments, queryParams);
22491
22589
  if (!parsed)
22492
22590
  return true;
22591
+ if (await refuseAgentTokenWithout(req, res, "mcp-oauth.manage"))
22592
+ return true;
22493
22593
  const userId = parsed.body?.userId ?? null;
22494
22594
  const existing = await getMcpOAuthToken(parsed.params.mcpServerId, userId);
22495
22595
  if (!existing || !existing.refreshToken) {
@@ -22531,6 +22631,8 @@ async function handleMcpOAuth(req, res, pathSegments, queryParams) {
22531
22631
  const parsed = await disconnectRoute.parse(req, res, pathSegments, queryParams);
22532
22632
  if (!parsed)
22533
22633
  return true;
22634
+ if (await refuseAgentTokenWithout(req, res, "mcp-oauth.manage"))
22635
+ return true;
22534
22636
  const userId = parsed.query.userId ?? null;
22535
22637
  const token = await getMcpOAuthToken(parsed.params.mcpServerId, userId);
22536
22638
  if (!token) {
@@ -22560,6 +22662,8 @@ async function handleMcpOAuth(req, res, pathSegments, queryParams) {
22560
22662
  const parsed = await manualClientRoute.parse(req, res, pathSegments, queryParams);
22561
22663
  if (!parsed)
22562
22664
  return true;
22665
+ if (await refuseAgentTokenWithout(req, res, "mcp-oauth.manage"))
22666
+ return true;
22563
22667
  const server = await getMcpOrError(res, parsed.params.mcpServerId);
22564
22668
  if (!server)
22565
22669
  return true;
@@ -22643,6 +22747,7 @@ init_mcp_server_checked_update();
22643
22747
  init_mcp_server_stdio_gate();
22644
22748
  init_rbac_audit();
22645
22749
  init_rbac_roles();
22750
+ init_swarm_config_guard();
22646
22751
  init_ensure_mcp_token();
22647
22752
  init_mcp_wrapper();
22648
22753
  init_rbac();
@@ -22817,7 +22922,10 @@ var getAgentMcpServersRoute = route({
22817
22922
  }
22818
22923
  });
22819
22924
  async function canResolveMcpSecretsForHttpUser(req) {
22820
- const userId = authUserId(getRequestAuth(req));
22925
+ const auth = getRequestAuth(req);
22926
+ if (auth?.kind === "agent" && auth.tokenKind === "task")
22927
+ return false;
22928
+ const userId = authUserId(auth);
22821
22929
  if (!userId)
22822
22930
  return true;
22823
22931
  if (!isRbacEnabled())
@@ -22877,7 +22985,7 @@ async function handleMcpServers(req, res, pathSegments, queryParams) {
22877
22985
  jsonError(res, "Forbidden: admission: missing permission 'mcp-server.read.secrets'", 403);
22878
22986
  return true;
22879
22987
  }
22880
- const configs = await getResolvedConfig2(parsed.params.id);
22988
+ const configs = (await getResolvedConfig2(parsed.params.id)).filter((c) => !isApiOnlyConfigKey(c.key) && !isInternalConfigKey(c.key) && !isCodexOAuthConfigKey(c.key));
22881
22989
  const configMap = new Map(configs.map((c) => [c.key, c.value]));
22882
22990
  const serversWithSecrets = await Promise.all(servers.map(async (server) => {
22883
22991
  const resolvedEnv = {};
@@ -22966,6 +23074,12 @@ async function handleMcpServers(req, res, pathSegments, queryParams) {
22966
23074
  jsonError(res, "MCP server not found", 404);
22967
23075
  return true;
22968
23076
  }
23077
+ if (parsed.body.agentId !== singleHeader3(req, "x-agent-id") && await refuseAgentTokenWithout(req, res, "mcp-server.install.any", {
23078
+ kind: "agent",
23079
+ agentId: parsed.body.agentId
23080
+ })) {
23081
+ return true;
23082
+ }
22969
23083
  try {
22970
23084
  const agentMcpServer = await installMcpServer2(parsed.body.agentId, parsed.params.id);
22971
23085
  installMcpServerRoute.respond(res, 200, { agentMcpServer });
@@ -22978,6 +23092,12 @@ async function handleMcpServers(req, res, pathSegments, queryParams) {
22978
23092
  const parsed = await uninstallMcpServerRoute.parse(req, res, pathSegments, queryParams);
22979
23093
  if (!parsed)
22980
23094
  return true;
23095
+ if (parsed.params.agentId !== singleHeader3(req, "x-agent-id") && await refuseAgentTokenWithout(req, res, "mcp-server.uninstall.any", {
23096
+ kind: "agent",
23097
+ agentId: parsed.params.agentId
23098
+ })) {
23099
+ return true;
23100
+ }
22981
23101
  const removed = await uninstallMcpServer2(parsed.params.agentId, parsed.params.id);
22982
23102
  uninstallMcpServerRoute.respond(res, 200, { success: removed });
22983
23103
  return true;
@@ -23107,6 +23227,13 @@ async function handleMcpServers(req, res, pathSegments, queryParams) {
23107
23227
  const parsed = await deleteMcpServerRoute.parse(req, res, pathSegments, queryParams);
23108
23228
  if (!parsed)
23109
23229
  return true;
23230
+ const existing = await getMcpServerById2(parsed.params.id);
23231
+ if (existing && await refuseAgentTokenWithout(req, res, "mcp-server.delete.any", {
23232
+ kind: "owned",
23233
+ ownerAgentId: existing.ownerAgentId
23234
+ })) {
23235
+ return true;
23236
+ }
23110
23237
  const result = await deleteMcpServer2(parsed.params.id);
23111
23238
  if (!result.deleted) {
23112
23239
  jsonError(res, "MCP server not found", 404);
@@ -24640,6 +24767,16 @@ async function handleMemory(req, res, pathSegments, callerAgentId) {
24640
24767
  contextKey
24641
24768
  } = parsed.body;
24642
24769
  const memoryAgentId = agentId ?? (scope === "agent" ? myAgentId : undefined);
24770
+ const auth = getRequestAuth(req);
24771
+ if (auth?.kind === "agent" && memoryAgentId !== undefined && memoryAgentId !== auth.agentId && !can({
24772
+ principal: await ingestPrincipal(req, myAgentId),
24773
+ verb: "memory.edit.any",
24774
+ resource: { kind: "owned", ownerAgentId: memoryAgentId },
24775
+ source: "http"
24776
+ }).allow) {
24777
+ jsonError(res, "An agent token can index memory only for its own agent", 403);
24778
+ return true;
24779
+ }
24643
24780
  if (source === "session_summary" && sourceTaskId) {
24644
24781
  const sourceTask = await getTaskById2(sourceTaskId);
24645
24782
  if (sourceTask && !shouldPersistAutomaticTaskMemory(sourceTask, persistMemory)) {
@@ -25071,6 +25208,15 @@ async function handleMemory(req, res, pathSegments, callerAgentId) {
25071
25208
  const parsed = await reEmbedMemory.parse(req, res, pathSegments, new URLSearchParams);
25072
25209
  if (!parsed)
25073
25210
  return true;
25211
+ const reembedDecision = can({
25212
+ principal: await requestPrincipal(req, myAgentId, { unauthenticatedFallback: "operator" }),
25213
+ verb: "memory.reembed",
25214
+ source: "http"
25215
+ });
25216
+ if (!reembedDecision.allow) {
25217
+ jsonError(res, `Forbidden: ${reembedDecision.reason}`, 403);
25218
+ return true;
25219
+ }
25074
25220
  const { agentId, batchSize } = parsed.body;
25075
25221
  const store = getMemoryStore2();
25076
25222
  const provider = getEmbeddingProvider2();
@@ -25293,6 +25439,7 @@ init_zod();
25293
25439
  init_db4();
25294
25440
  init_version2();
25295
25441
  init_types5();
25442
+ init_secret_scrubber();
25296
25443
  init_db_query();
25297
25444
  init_route_def();
25298
25445
  init_utils2();
@@ -25342,7 +25489,7 @@ function resolveVariableOptions(metric) {
25342
25489
  }
25343
25490
  const options = resolveVariableOptionValues(variable);
25344
25491
  optionsByKey[variable.key] = options;
25345
- return { ...variable, options };
25492
+ return { ...variable, options: scrubObject(options) };
25346
25493
  });
25347
25494
  return { variables, optionsByKey };
25348
25495
  }
@@ -25401,7 +25548,7 @@ function runMetricWidget(widget, variables) {
25401
25548
  widget,
25402
25549
  result: {
25403
25550
  ...result,
25404
- rows: result.rows.map((row) => Object.fromEntries(result.columns.map((column, index) => [column, row[index]]))),
25551
+ rows: scrubObject(result.rows.map((row) => Object.fromEntries(result.columns.map((column, index) => [column, row[index]])))),
25405
25552
  truncated: result.total > result.rows.length,
25406
25553
  maxRows
25407
25554
  }
@@ -25416,7 +25563,7 @@ function runMetric(metric, providedVariables = {}) {
25416
25563
  ...metric,
25417
25564
  definition: { ...metric.definition, variables: resolved.variables }
25418
25565
  },
25419
- variables,
25566
+ variables: scrubObject(variables),
25420
25567
  widgets,
25421
25568
  result: widgets[0]?.result
25422
25569
  };
@@ -27683,6 +27830,7 @@ var StatusCombSchema = object2({
27683
27830
  live_url: string2(),
27684
27831
  org_id: string2().nullable(),
27685
27832
  drive_id: string2().nullable(),
27833
+ review_follow_ups: boolean(),
27686
27834
  service_user_id: string2().nullable()
27687
27835
  });
27688
27836
  var StatusTelemetrySchema = object2({
@@ -28121,6 +28269,7 @@ function getCombStatus(serviceUserId) {
28121
28269
  live_url: comb.liveUrl,
28122
28270
  org_id: comb.orgId,
28123
28271
  drive_id: comb.driveId,
28272
+ review_follow_ups: comb.enabled,
28124
28273
  service_user_id: comb.enabled ? serviceUserId : null
28125
28274
  };
28126
28275
  }
@@ -28453,7 +28602,8 @@ async function handleMemoryProbe(body) {
28453
28602
  defaultHeaders: getOpenRouterAttributionHeaders(endpoint.toString()),
28454
28603
  timeout: 15000,
28455
28604
  maxRetries: 0,
28456
- fetchOptions: { redirect: "manual" }
28605
+ fetchOptions: { redirect: "manual" },
28606
+ fetch: configuredEndpoint ? undefined : createSsrfGuardedFetch(publicEndpointSsrfOptions())
28457
28607
  });
28458
28608
  const response = await client.embeddings.create({
28459
28609
  model,
@@ -28482,6 +28632,14 @@ async function handleMemoryProbe(body) {
28482
28632
  });
28483
28633
  return { ok: true, dimensions, latencyMs };
28484
28634
  } catch (error) {
28635
+ if (error instanceof Error && error.cause instanceof EgressDeniedError) {
28636
+ return {
28637
+ ok: false,
28638
+ latencyMs: 0,
28639
+ error: "The endpoint URL is not allowed.",
28640
+ errorClass: "network"
28641
+ };
28642
+ }
28485
28643
  const errorClass = classifyMemoryError(error);
28486
28644
  const latencyMs = Math.max(0, Math.round(performance.now() - started));
28487
28645
  const message = memoryErrorMessage(errorClass, memoryErrorStatus(error));
@@ -28772,12 +28930,46 @@ init_asset_key_auth();
28772
28930
  init_audit_user();
28773
28931
  init_db4();
28774
28932
  init_model_profiles();
28933
+
28934
+ // src/be/db/task-idempotency.ts
28935
+ init_request_auth_context();
28936
+ init_runtime2();
28937
+ init_workflow_idempotency();
28938
+ async function findAcceptedTaskCreate(claim) {
28939
+ const row = await getDbClient2().get("SELECT requestFingerprint, taskId FROM task_idempotency_keys WHERE principal = ? AND keyHash = ?", [claim.principal, sha256(claim.key)]);
28940
+ return row ? { fingerprint: row.requestFingerprint, taskId: row.taskId } : null;
28941
+ }
28942
+ async function recordAcceptedTaskCreate(claim, taskId) {
28943
+ const actor = getCurrentRequestUserId() ?? null;
28944
+ try {
28945
+ await getDbClient2().run(`INSERT INTO task_idempotency_keys
28946
+ (id, principal, keyHash, requestFingerprint, taskId, createdAt, created_by, updated_by)
28947
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [
28948
+ crypto.randomUUID(),
28949
+ claim.principal,
28950
+ sha256(claim.key),
28951
+ claim.fingerprint,
28952
+ taskId,
28953
+ new Date().toISOString(),
28954
+ actor,
28955
+ actor
28956
+ ]);
28957
+ } catch (err) {
28958
+ if (err instanceof Error && err.message.includes("UNIQUE constraint failed")) {
28959
+ throw new IdempotencyKeyTakenError;
28960
+ }
28961
+ throw err;
28962
+ }
28963
+ }
28964
+
28965
+ // src/http/tasks.ts
28966
+ init_workflow_idempotency();
28775
28967
  init_model_validation2();
28776
28968
  init_rbac_roles();
28777
28969
  init_session_shares();
28778
28970
  init_steering2();
28779
28971
  init_task_citations2();
28780
- init_task_ui_spec();
28972
+ init_task_ui_spec2();
28781
28973
  init_rbac();
28782
28974
  init_session_mirror();
28783
28975
  init_context_key();
@@ -28793,6 +28985,7 @@ init_request_auth_context();
28793
28985
  init_secret_scrubber();
28794
28986
  init_vcs_repo_match();
28795
28987
  init_config();
28988
+ init_idempotency_key();
28796
28989
 
28797
28990
  // src/http/list-total-cache.ts
28798
28991
  var LIST_TOTAL_TTL_MS = 30000;
@@ -28963,6 +29156,7 @@ var AgentTaskSummarySchema = AgentTaskSchema.pick({
28963
29156
  resolvedEffort: true,
28964
29157
  profile: true,
28965
29158
  resolvedProfile: true,
29159
+ modelGroup: true,
28966
29160
  provider: true,
28967
29161
  requestedByUserId: true,
28968
29162
  progress: true,
@@ -29080,6 +29274,7 @@ var createTask = route({
29080
29274
  rbac: { permission: "task.create.own" },
29081
29275
  summary: "Create a new task",
29082
29276
  tags: ["Tasks"],
29277
+ headers: idempotencyKeyHeader("creates one task (a replay returns that task as it is now)"),
29083
29278
  body: object2({
29084
29279
  task: string2().min(1),
29085
29280
  agentId: string2().optional(),
@@ -29103,6 +29298,7 @@ var createTask = route({
29103
29298
  allowCustomModel: boolean().optional(),
29104
29299
  effort: ReasoningEffortSchema.optional(),
29105
29300
  profile: string2().trim().min(1).optional(),
29301
+ modelGroup: string2().trim().min(1).optional(),
29106
29302
  draft: boolean().optional()
29107
29303
  }).superRefine((body, ctx) => {
29108
29304
  if ((body.agentId !== undefined || body.offeredTo !== undefined) && !body.routingReason) {
@@ -29116,10 +29312,12 @@ var createTask = route({
29116
29312
  responses: {
29117
29313
  201: { description: "Task created", schema: AgentTaskSchema },
29118
29314
  400: {
29119
- description: "Validation error, an unknown `model` (set `allowCustomModel` to store a custom id), a `vcsRepo` that is not exactly one registered repo, or agentId/offeredTo targets an extension identity"
29315
+ description: "Validation error, an unknown `model` (set `allowCustomModel` to store a custom id), a `vcsRepo` that is not exactly one registered repo, agentId/offeredTo targets an extension identity, or a malformed Idempotency-Key"
29120
29316
  },
29317
+ 409: { description: "Idempotency-Key was already used for a different request" },
29318
+ 410: { description: "The task created under this Idempotency-Key was deleted" },
29121
29319
  403: {
29122
- description: "Parent/session access denied, unauthorized chat-thread binding, or routing requirements reject the assignment"
29320
+ description: "Parent/session access denied, unauthorized chat-thread binding, routing requirements reject the assignment, or an Idempotency-Key replay of a task whose session the caller can no longer read"
29123
29321
  },
29124
29322
  422: {
29125
29323
  description: "Task creation blocked by an extension",
@@ -29716,9 +29914,35 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
29716
29914
  return true;
29717
29915
  }
29718
29916
  if (createTask.match(req.method, pathSegments)) {
29917
+ const idempotency = readIdempotencyKey(req, res, myAgentId);
29918
+ if (idempotency === null)
29919
+ return true;
29719
29920
  const parsed = await createTask.parse(req, res, pathSegments, queryParams);
29720
29921
  if (!parsed)
29721
29922
  return true;
29923
+ const claim = idempotency && {
29924
+ ...idempotency,
29925
+ fingerprint: requestFingerprint("task.create", parsed.body)
29926
+ };
29927
+ const replayCreate = async () => {
29928
+ const accepted = claim && await findAcceptedTaskCreate(claim);
29929
+ if (!accepted)
29930
+ return false;
29931
+ const task = accepted.fingerprint === claim.fingerprint ? await getTaskById2(accepted.taskId) : null;
29932
+ if (accepted.fingerprint !== claim.fingerprint) {
29933
+ jsonError(res, "Idempotency-Key was already used for a different request", 409);
29934
+ } else if (!task) {
29935
+ jsonError(res, "The task this Idempotency-Key created was deleted", 410);
29936
+ } else if (!await canReadSession2(req, myAgentId, task.id)) {
29937
+ jsonError(res, SESSION_READ_DENIED2, 403);
29938
+ } else {
29939
+ res.setHeader(IDEMPOTENT_REPLAYED_HEADER, "true");
29940
+ createTask.respond(res, 201, task);
29941
+ }
29942
+ return true;
29943
+ };
29944
+ if (await replayCreate())
29945
+ return true;
29722
29946
  const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
29723
29947
  const requestedByUserId = await resolveTaskRequester(req, myAgentId, parsed.body.requestedByUserId, trustedUserId);
29724
29948
  let defaultAgentId = parsed.body.agentId || undefined;
@@ -29765,6 +29989,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
29765
29989
  }
29766
29990
  const profileError = await taskProfileError({
29767
29991
  profile: parsed.body.profile,
29992
+ modelGroup: parsed.body.modelGroup,
29768
29993
  ...splitLegacyModelAlias({ model: parsed.body.model, modelTier: parsed.body.modelTier }),
29769
29994
  agentId: defaultAgentId,
29770
29995
  vcsRepo: vcsRepo ?? parentTask?.vcsRepo
@@ -29786,7 +30011,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
29786
30011
  throw error;
29787
30012
  }
29788
30013
  try {
29789
- const task = await createTaskWithSiblingAwareness(parsed.body.task, {
30014
+ const prepared = await prepareTaskWithSiblingAwareness(parsed.body.task, {
29790
30015
  key: assetKey,
29791
30016
  agentId: defaultAgentId,
29792
30017
  routingReason: parsed.body.routingReason ?? (defaultAgentId ? parentTask?.agentId === defaultAgentId ? "continuity" : "skill" : undefined),
@@ -29813,8 +30038,16 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
29813
30038
  modelTier: parsed.body.modelTier
29814
30039
  }),
29815
30040
  effort: parsed.body.effort,
29816
- profile: parsed.body.profile
30041
+ profile: parsed.body.profile,
30042
+ modelGroup: parsed.body.modelGroup
29817
30043
  }, { origin: "rest", allowCustomModel: parsed.body.allowCustomModel });
30044
+ const task = claim ? await getDbClient2().transaction(async () => {
30045
+ if (await findAcceptedTaskCreate(claim))
30046
+ throw new IdempotencyKeyTakenError;
30047
+ const created = await createTaskExtended2(prepared.description, prepared.options);
30048
+ await recordAcceptedTaskCreate(claim, created.id);
30049
+ return created;
30050
+ }) : await createTaskExtended2(prepared.description, prepared.options);
29818
30051
  ensure({
29819
30052
  id: "created",
29820
30053
  flow: "task",
@@ -29835,6 +30068,8 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
29835
30068
  }
29836
30069
  createTask.respond(res, 201, task);
29837
30070
  } catch (error) {
30071
+ if (error instanceof IdempotencyKeyTakenError && await replayCreate())
30072
+ return true;
29838
30073
  if (error instanceof TaskRoutingAuthorizationError) {
29839
30074
  console.warn("[HTTP] Task assignment rejected:", scrubSecrets(JSON.stringify({
29840
30075
  parentTaskId: parsed.body.parentTaskId,
@@ -29853,6 +30088,10 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
29853
30088
  jsonError(res, error.message, 400);
29854
30089
  return true;
29855
30090
  }
30091
+ if (modelGroupRefError(error)) {
30092
+ jsonError(res, `Unknown model group "${parsed.body.modelGroup}"`, 400);
30093
+ return true;
30094
+ }
29856
30095
  if (modelProfileRefError(error) === "missing") {
29857
30096
  jsonError(res, `Unknown model profile "${parsed.body.profile}"`, 400);
29858
30097
  return true;
@@ -29891,7 +30130,25 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
29891
30130
  const parsed = await updateSession.parse(req, res, pathSegments, queryParams);
29892
30131
  if (!parsed)
29893
30132
  return true;
29894
- const task = await updateTaskClaudeSessionId2(parsed.params.id, parsed.body.claudeSessionId, parsed.body.provider, parsed.body.providerMeta, parsed.body.model, "harnessVariant" in parsed.body ? parsed.body.harnessVariant : undefined, "harnessVariantMeta" in parsed.body ? parsed.body.harnessVariantMeta : undefined, "effort" in parsed.body ? parsed.body.effort : undefined);
30133
+ const auth = getRequestAuth(req);
30134
+ const task = await getDbClient2().transaction(async () => {
30135
+ if (auth?.kind === "agent") {
30136
+ if (auth.taskId !== null && auth.taskId !== parsed.params.id)
30137
+ return "forbidden";
30138
+ const existing = await getTaskById2(parsed.params.id);
30139
+ if (!existing)
30140
+ return null;
30141
+ const offerOpen = existing.status === "offered" || existing.status === "reviewing";
30142
+ const holder = offerOpen ? existing.offeredTo : existing.agentId;
30143
+ if (holder !== auth.agentId)
30144
+ return "forbidden";
30145
+ }
30146
+ return await updateTaskClaudeSessionId2(parsed.params.id, parsed.body.claudeSessionId, parsed.body.provider, parsed.body.providerMeta, parsed.body.model, "harnessVariant" in parsed.body ? parsed.body.harnessVariant : undefined, "harnessVariantMeta" in parsed.body ? parsed.body.harnessVariantMeta : undefined, "effort" in parsed.body ? parsed.body.effort : undefined);
30147
+ });
30148
+ if (task === "forbidden") {
30149
+ jsonError(res, "Task belongs to another token agent", 403);
30150
+ return true;
30151
+ }
29895
30152
  if (!task) {
29896
30153
  jsonError(res, "Task not found", 404);
29897
30154
  return true;
@@ -34080,6 +34337,7 @@ init_api_drain();
34080
34337
  init_budget_admission();
34081
34338
  init_budget_refusal_notify();
34082
34339
  init_db4();
34340
+ init_model_group_resolution();
34083
34341
  init_model_profile_check();
34084
34342
  init_model_tier_resolution();
34085
34343
  init_model_validation2();
@@ -34088,6 +34346,8 @@ init_server();
34088
34346
 
34089
34347
  // src/slack/channel-activity.ts
34090
34348
  init_app4();
34349
+ init_external_channel();
34350
+ init_handlers();
34091
34351
  var cachedBotUserId = null;
34092
34352
  var channelCache = null;
34093
34353
  var CHANNEL_CACHE_TTL_MS = 5 * 60 * 1000;
@@ -34118,6 +34378,8 @@ async function fetchChannelActivity(cursors, allowedChannelIds, limit = 10) {
34118
34378
  const channelId = channel.id;
34119
34379
  const cursor = cursors.get(channelId);
34120
34380
  try {
34381
+ if (await shouldBlockChannel2(client, channelId))
34382
+ continue;
34121
34383
  if (!cursor) {
34122
34384
  const seedResult = await client.conversations.history({
34123
34385
  channel: channelId,
@@ -34145,6 +34407,8 @@ async function fetchChannelActivity(cursors, allowedChannelIds, limit = 10) {
34145
34407
  continue;
34146
34408
  if (msg.thread_ts && msg.thread_ts !== msg.ts)
34147
34409
  continue;
34410
+ if (!await isUserAllowed2(client, msg.user, LOOKUP_USER_TEAM2))
34411
+ continue;
34148
34412
  messages.push({
34149
34413
  channelId,
34150
34414
  channelName: channel.name,
@@ -34588,7 +34852,17 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
34588
34852
  profileOk.set(memoKey, ok);
34589
34853
  return ok;
34590
34854
  };
34591
- const unassignedIds = await getUnassignedTaskIdsForAgent2(myAgentId, 5, async (task) => await poolTaskRunsOnHarness(task, harness) && (!task.profile || await passesProfileCheck(task.profile, task.vcsRepo)));
34855
+ const groupOk = new Map;
34856
+ const passesGroupCheck = async (group, vcsRepo) => {
34857
+ const memoKey = JSON.stringify([group, vcsRepo ?? null]);
34858
+ const cached = groupOk.get(memoKey);
34859
+ if (cached !== undefined)
34860
+ return cached;
34861
+ const ok = (await resolveGroupForAgent(group, myAgentId, { vcsRepo, includeRepoSecrets })).kind !== "none";
34862
+ groupOk.set(memoKey, ok);
34863
+ return ok;
34864
+ };
34865
+ 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)));
34592
34866
  if (unassignedIds.length > 0) {
34593
34867
  if (probe)
34594
34868
  return NEEDS_WRITE;
@@ -35652,7 +35926,7 @@ init_users();
35652
35926
  init_rbac();
35653
35927
 
35654
35928
  // src/realtime/browser.generated.txt
35655
- 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";
35929
+ 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";
35656
35930
 
35657
35931
  // src/http/realtime.ts
35658
35932
  init_favorite_owner();
@@ -35730,9 +36004,11 @@ init_repo_merge_policy();
35730
36004
  init_rbac();
35731
36005
  init_telemetry();
35732
36006
  init_types5();
36007
+ init_request_auth_context();
35733
36008
  init_request_principal();
35734
36009
  init_route_def();
35735
36010
  init_utils2();
36011
+ var notOptionLike = (schema, field) => schema.refine((value) => !value.startsWith("-"), `${field} must not start with "-"`);
35736
36012
  var getRepo = route({
35737
36013
  method: "get",
35738
36014
  path: "/api/repos/{id}",
@@ -35766,10 +36042,10 @@ var createRepo = route({
35766
36042
  summary: "Create a new repo",
35767
36043
  tags: ["Repos"],
35768
36044
  body: object2({
35769
- url: string2().min(1),
36045
+ url: notOptionLike(string2().min(1), "url"),
35770
36046
  name: string2().min(1),
35771
- clonePath: string2().optional(),
35772
- defaultBranch: string2().optional(),
36047
+ clonePath: notOptionLike(string2(), "clonePath").optional(),
36048
+ defaultBranch: notOptionLike(string2(), "defaultBranch").optional(),
35773
36049
  autoClone: boolean().optional(),
35774
36050
  hooks: RepoHooksSchema.optional(),
35775
36051
  guidelines: RepoGuidelinesInputSchema.nullable().optional()
@@ -35778,7 +36054,7 @@ var createRepo = route({
35778
36054
  201: { description: "Repo created", schema: SwarmRepoSchema },
35779
36055
  400: { description: "Validation error", schema: object2({ error: string2() }) },
35780
36056
  403: {
35781
- description: "Only the lead, the operator or a user can turn allowMerge on or set a mergePolicy",
36057
+ description: "Only the lead, the operator or a user can turn allowMerge on, set a mergePolicy or enable hooks",
35782
36058
  schema: object2({ error: string2() })
35783
36059
  },
35784
36060
  409: { description: "Duplicate repo", schema: object2({ error: string2() }) }
@@ -35793,10 +36069,10 @@ var updateRepo = route({
35793
36069
  tags: ["Repos"],
35794
36070
  params: object2({ id: string2().uuid() }),
35795
36071
  body: object2({
35796
- url: string2().optional(),
36072
+ url: notOptionLike(string2(), "url").optional(),
35797
36073
  name: string2().optional(),
35798
- clonePath: string2().optional(),
35799
- defaultBranch: string2().optional(),
36074
+ clonePath: notOptionLike(string2(), "clonePath").optional(),
36075
+ defaultBranch: notOptionLike(string2(), "defaultBranch").optional(),
35800
36076
  autoClone: boolean().optional(),
35801
36077
  hooks: RepoHooksSchema.nullable().optional(),
35802
36078
  guidelines: RepoGuidelinesInputSchema.nullable().optional()
@@ -35804,13 +36080,13 @@ var updateRepo = route({
35804
36080
  responses: {
35805
36081
  200: { description: "Repo updated", schema: SwarmRepoSchema },
35806
36082
  403: {
35807
- description: "Only the lead, the operator or a user can change allowMerge or mergePolicy",
36083
+ description: "Only the lead, the operator or a user can change allowMerge, mergePolicy, url, clonePath or hooks",
35808
36084
  schema: object2({ error: string2() })
35809
36085
  },
35810
36086
  404: { description: "Repo not found", schema: object2({ error: string2() }) },
35811
36087
  409: { description: "Duplicate repo", schema: object2({ error: string2() }) }
35812
36088
  },
35813
- rbac: { permission: "repo.merge-policy.write" }
36089
+ rbac: { permission: "repo.merge-policy.write", alsoAdmits: ["repo.exec-config.write"] }
35814
36090
  });
35815
36091
  var deleteRepo = route({
35816
36092
  method: "delete",
@@ -35822,7 +36098,8 @@ var deleteRepo = route({
35822
36098
  responses: {
35823
36099
  200: { description: "Repo deleted", schema: object2({ success: boolean() }) },
35824
36100
  404: { description: "Repo not found", schema: object2({ error: string2() }) }
35825
- }
36101
+ },
36102
+ rbac: { permission: "repo.delete" }
35826
36103
  });
35827
36104
  async function allowMergeRefusal(req, myAgentId) {
35828
36105
  const decision = can({
@@ -35870,6 +36147,11 @@ async function handleRepos(req, res, pathSegments, queryParams, myAgentId) {
35870
36147
  return true;
35871
36148
  }
35872
36149
  }
36150
+ const execRefusal = await execConfigRefusal(getRequestAuth(req), "http");
36151
+ if (execRefusal && parsed.body.hooks?.enabled === true) {
36152
+ jsonError(res, execRefusal, 403);
36153
+ return true;
36154
+ }
35873
36155
  try {
35874
36156
  const repo = await createSwarmRepo2({
35875
36157
  url: parsed.body.url,
@@ -35877,7 +36159,7 @@ async function handleRepos(req, res, pathSegments, queryParams, myAgentId) {
35877
36159
  clonePath: parsed.body.clonePath,
35878
36160
  defaultBranch: parsed.body.defaultBranch,
35879
36161
  autoClone: parsed.body.autoClone,
35880
- hooks: parsed.body.hooks,
36162
+ hooks: parsed.body.hooks ?? (execRefusal ? { enabled: false } : undefined),
35881
36163
  guidelines: parsed.body.guidelines
35882
36164
  });
35883
36165
  try {
@@ -35907,7 +36189,7 @@ async function handleRepos(req, res, pathSegments, queryParams, myAgentId) {
35907
36189
  autoClone: parsed.body.autoClone,
35908
36190
  hooks: parsed.body.hooks,
35909
36191
  guidelines: parsed.body.guidelines
35910
- }, () => allowMergeRefusal(req, myAgentId));
36192
+ }, () => allowMergeRefusal(req, myAgentId), () => execConfigRefusal(getRequestAuth(req), "http"));
35911
36193
  if (result.kind === "refused") {
35912
36194
  jsonError(res, result.refusal, 403);
35913
36195
  return true;
@@ -35931,6 +36213,8 @@ async function handleRepos(req, res, pathSegments, queryParams, myAgentId) {
35931
36213
  const parsed = await deleteRepo.parse(req, res, pathSegments, queryParams);
35932
36214
  if (!parsed)
35933
36215
  return true;
36216
+ if (await refuseAgentTokenWithout(req, res, "repo.delete"))
36217
+ return true;
35934
36218
  const deleted = await deleteSwarmRepo2(parsed.params.id);
35935
36219
  if (!deleted) {
35936
36220
  jsonError(res, "Repo not found", 404);
@@ -39449,6 +39733,7 @@ init_db3();
39449
39733
  init_rbac();
39450
39734
  init_scheduler();
39451
39735
  init_types5();
39736
+ init_request_auth_context();
39452
39737
  var import_cron_parser = __toESM(require_dist(), 1);
39453
39738
  init_favorite_owner();
39454
39739
  init_request_principal();
@@ -39470,6 +39755,7 @@ var scheduleUpdateBodySchema = object2({
39470
39755
  model: string2().nullable().optional(),
39471
39756
  modelTier: ModelTierSchema.nullable().optional(),
39472
39757
  profile: string2().nullable().optional(),
39758
+ modelGroup: string2().nullable().optional(),
39473
39759
  allowCustomModel: boolean().optional(),
39474
39760
  nextRunAt: string2().nullable().optional(),
39475
39761
  targetType: ScheduledTaskTargetTypeSchema.optional(),
@@ -39512,6 +39798,7 @@ var createSchedule = route({
39512
39798
  model: string2().optional(),
39513
39799
  modelTier: ModelTierSchema.optional(),
39514
39800
  profile: string2().optional(),
39801
+ modelGroup: string2().optional(),
39515
39802
  allowCustomModel: boolean().optional(),
39516
39803
  scheduleType: _enum2(["recurring", "one_time"]).optional(),
39517
39804
  targetType: ScheduledTaskTargetTypeSchema.optional(),
@@ -39769,6 +40056,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
39769
40056
  profile: body.profile,
39770
40057
  model: body.model,
39771
40058
  modelTier: body.modelTier,
40059
+ modelGroup: body.modelGroup,
39772
40060
  agentId: body.targetAgentId
39773
40061
  });
39774
40062
  if (profileError) {
@@ -39818,6 +40106,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
39818
40106
  timezone: body.timezone,
39819
40107
  ...splitLegacyModelAlias({ model: body.model, modelTier: body.modelTier }),
39820
40108
  profile: body.profile?.trim() || undefined,
40109
+ modelGroup: body.modelGroup?.trim() || undefined,
39821
40110
  scheduleType: body.scheduleType,
39822
40111
  targetType: body.targetType,
39823
40112
  workflowId: body.workflowId,
@@ -39831,6 +40120,10 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
39831
40120
  });
39832
40121
  createSchedule.respond(res, 201, schedule);
39833
40122
  } catch (error) {
40123
+ if (modelGroupRefError(error)) {
40124
+ jsonError(res, `Unknown model group "${body.modelGroup}".`, 400);
40125
+ return true;
40126
+ }
39834
40127
  if (modelProfileRefError(error) === "missing") {
39835
40128
  jsonError(res, `Unknown model profile "${body.profile}".`, 400);
39836
40129
  return true;
@@ -39848,6 +40141,15 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
39848
40141
  jsonError(res, "Schedule not found", 404);
39849
40142
  return true;
39850
40143
  }
40144
+ if (getRequestAuth(req)?.kind === "agent" && !can({
40145
+ principal: await agentFirstPrincipal(req, myAgentId),
40146
+ verb: "schedule.run.any",
40147
+ resource: { kind: "owned", ownerAgentId: schedule.createdByAgentId },
40148
+ source: "http"
40149
+ }).allow) {
40150
+ jsonError(res, `Schedule "${schedule.name}" runs as the agent that created it. Only that agent or a lead can run it.`, 403);
40151
+ return true;
40152
+ }
39851
40153
  if (!schedule.enabled) {
39852
40154
  jsonError(res, "Schedule is disabled", 400);
39853
40155
  return true;
@@ -39967,7 +40269,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
39967
40269
  if (parsed.body.modelTier !== undefined || normalizedModel.modelTier) {
39968
40270
  body.modelTier = normalizedModel.modelTier ?? null;
39969
40271
  }
39970
- } else if (agentChanged && existing.model && !profileUpdate.fields.profile) {
40272
+ } else if (agentChanged && existing.model && !profileUpdate.fields.profile && !profileUpdate.fields.modelGroup) {
39971
40273
  const modelError = await explicitModelErrorForAgent({
39972
40274
  model: existing.model,
39973
40275
  allowCustomModel: true,
@@ -40048,6 +40350,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40048
40350
  }
40049
40351
  }
40050
40352
  const newEnabled = parsed.body.enabled !== undefined ? parsed.body.enabled : existing.enabled;
40353
+ const cronTimezoneChanged = Boolean(existing.cronExpression) && parsed.body.timezone !== undefined && parsed.body.timezone !== existing.timezone;
40051
40354
  if (existing.scheduleType === "one_time") {
40052
40355
  if (!newEnabled) {
40053
40356
  body.nextRunAt = null;
@@ -40055,18 +40358,23 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40055
40358
  } else {
40056
40359
  if (!newEnabled) {
40057
40360
  body.nextRunAt = null;
40058
- } else if (parsed.body.cronExpression !== undefined || parsed.body.intervalMs !== undefined || parsed.body.enabled === true && !existing.enabled) {
40361
+ } else if (parsed.body.cronExpression !== undefined || parsed.body.intervalMs !== undefined || cronTimezoneChanged || parsed.body.enabled === true && !existing.enabled) {
40059
40362
  const timing = mergeScheduleTiming({
40060
40363
  cronExpression: existing.cronExpression ?? null,
40061
40364
  intervalMs: existing.intervalMs ?? null
40062
40365
  }, { cronExpression: parsed.body.cronExpression, intervalMs: parsed.body.intervalMs });
40063
- const mergedTimezone = parsed.body.timezone !== undefined ? parsed.body.timezone : existing.timezone;
40064
40366
  if (timing.mergedCron || timing.mergedInterval) {
40065
- body.nextRunAt = calculateNextRun2({
40066
- cronExpression: timing.mergedCron,
40067
- intervalMs: timing.mergedInterval,
40068
- timezone: mergedTimezone
40069
- });
40367
+ try {
40368
+ body.nextRunAt = calculateNextRun2({
40369
+ ...existing,
40370
+ cronExpression: timing.mergedCron ?? undefined,
40371
+ intervalMs: timing.mergedInterval ?? undefined,
40372
+ timezone: parsed.body.timezone ?? existing.timezone
40373
+ });
40374
+ } catch {
40375
+ jsonError(res, "Cannot calculate the next run for this schedule.", 400);
40376
+ return true;
40377
+ }
40070
40378
  }
40071
40379
  }
40072
40380
  }
@@ -40076,6 +40384,10 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40076
40384
  try {
40077
40385
  schedule = await updateScheduledTask2(parsed.params.id, body);
40078
40386
  } catch (error) {
40387
+ if (modelGroupRefError(error)) {
40388
+ jsonError(res, `Unknown model group "${body.modelGroup}".`, 400);
40389
+ return true;
40390
+ }
40079
40391
  if (modelProfileRefError(error) !== "missing")
40080
40392
  throw error;
40081
40393
  jsonError(res, `Unknown model profile "${body.profile}".`, 400);
@@ -40255,7 +40567,7 @@ async function handleScriptConnectionProxy(req, res, pathSegments, queryParams,
40255
40567
  } catch (err) {
40256
40568
  mcpCallRoute.respond(res, 200, {
40257
40569
  ok: false,
40258
- error: err instanceof Error ? err.message : String(err)
40570
+ error: scrubSecrets(err instanceof Error ? err.message : String(err))
40259
40571
  });
40260
40572
  }
40261
40573
  return true;
@@ -42263,6 +42575,8 @@ var listScriptRunsQuerySchema = object2({
42263
42575
  status: ScriptRunStatusSchema.optional(),
42264
42576
  agentId: string2().optional(),
42265
42577
  scriptName: string2().optional(),
42578
+ objectScriptId: string2().optional(),
42579
+ objectId: string2().optional(),
42266
42580
  limit: exports_coerce.number().int().min(1).max(500).optional(),
42267
42581
  offset: exports_coerce.number().int().min(0).optional()
42268
42582
  });
@@ -42555,6 +42869,10 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
42555
42869
  const agent = await requireAgent(res, agentId);
42556
42870
  if (!agent)
42557
42871
  return true;
42872
+ if (!durableScriptRunsAllowed()) {
42873
+ jsonError(res, DURABLE_RUNS_NATIVE_REFUSED, 400);
42874
+ return true;
42875
+ }
42558
42876
  const secretRefusal = refuseSourceWithSecrets(parsed.body.source);
42559
42877
  if (secretRefusal) {
42560
42878
  json(res, secretRefusal, 400);
@@ -42600,7 +42918,7 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
42600
42918
  }
42601
42919
  const { run, existing } = creation;
42602
42920
  if (!existing && parsed.body.background) {
42603
- startScriptRunProcess(run, getMcpBaseUrl(), bearerToken(req)).catch(async (err) => {
42921
+ startScriptRunProcess(run, getScriptApiBaseUrl(), bearerToken(req)).catch(async (err) => {
42604
42922
  await updateScriptRun2(run.id, {
42605
42923
  status: "failed",
42606
42924
  pid: null,
@@ -42628,20 +42946,20 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
42628
42946
  const parsed = await listScriptRunsRoute.parse(req, res, pathSegments, queryParams);
42629
42947
  if (!parsed)
42630
42948
  return true;
42631
- const opts = {
42949
+ const filter = {
42632
42950
  status: parsed.query.status,
42633
42951
  agentId: parsed.query.agentId,
42634
42952
  scriptName: parsed.query.scriptName,
42635
- limit: parsed.query.limit ?? 50,
42636
- offset: parsed.query.offset ?? 0
42953
+ objectScriptId: parsed.query.objectScriptId,
42954
+ objectId: parsed.query.objectId
42637
42955
  };
42638
42956
  listScriptRunsRoute.respond(res, 200, {
42639
- runs: await listScriptRuns2(opts),
42640
- total: await countScriptRuns2({
42641
- status: opts.status,
42642
- agentId: opts.agentId,
42643
- scriptName: opts.scriptName
42644
- })
42957
+ runs: await listScriptRuns2({
42958
+ ...filter,
42959
+ limit: parsed.query.limit ?? 50,
42960
+ offset: parsed.query.offset ?? 0
42961
+ }),
42962
+ total: await countScriptRuns2(filter)
42645
42963
  });
42646
42964
  return true;
42647
42965
  }
@@ -42924,10 +43242,157 @@ init_events();
42924
43242
  init_script_connections();
42925
43243
  init_script_credential_broker();
42926
43244
  init_db3();
43245
+
43246
+ // src/be/scripts/durable.ts
43247
+ init_kv_limits();
43248
+ init_types3();
43249
+ init_secret_scrubber();
43250
+ init_db4();
43251
+ init_run_credential();
43252
+ async function callDurableObject({
43253
+ script,
43254
+ objectId,
43255
+ method,
43256
+ args,
43257
+ agentId,
43258
+ caller,
43259
+ provenance = {},
43260
+ executor,
43261
+ fsMode,
43262
+ nested = false,
43263
+ ...runContext
43264
+ }) {
43265
+ let signature;
43266
+ try {
43267
+ signature = JSON.parse(script.signatureJson);
43268
+ } catch {
43269
+ return { ok: false, code: "not_callable", message: "not callable" };
43270
+ }
43271
+ if (signature?.kind !== "durable" || !signature.methods || !Object.hasOwn(signature.methods, method)) {
43272
+ return { ok: false, code: "not_callable", message: "not callable" };
43273
+ }
43274
+ const identity = `${script.id}:${objectId}`;
43275
+ const objectChain = provenance.objectChain ?? [];
43276
+ if (objectChain.includes(identity)) {
43277
+ return { ok: false, code: "reentry", message: "already in this call chain" };
43278
+ }
43279
+ const namespace = `durable:${script.id}`;
43280
+ const leaseKey = `lease/${objectId}`;
43281
+ const stateKey = `state/${objectId}`;
43282
+ const token = crypto.randomUUID();
43283
+ const deadline = Date.now() + (nested ? 5000 : 30000);
43284
+ for (;; ) {
43285
+ if (await claimKv2({
43286
+ namespace,
43287
+ key: leaseKey,
43288
+ value: { token },
43289
+ valueType: "json",
43290
+ expiresAt: Date.now() + DEFAULT_SCRIPT_RESOURCES.wallClockMs + 1e4
43291
+ }))
43292
+ break;
43293
+ const remaining = deadline - Date.now();
43294
+ if (remaining <= 0)
43295
+ return { ok: false, code: "busy", message: "object busy" };
43296
+ await Bun.sleep(Math.min(remaining, 50 + Math.floor(Math.random() * 351)));
43297
+ if (Date.now() >= deadline)
43298
+ return { ok: false, code: "busy", message: "object busy" };
43299
+ }
43300
+ const client = getDbClient2();
43301
+ const release = async () => {
43302
+ await client.transaction(async () => {
43303
+ const lease = await getKv2(namespace, leaseKey);
43304
+ if (lease?.value?.token === token) {
43305
+ await deleteKv2(namespace, leaseKey);
43306
+ }
43307
+ });
43308
+ };
43309
+ let output;
43310
+ try {
43311
+ const entry = await getKv2(namespace, stateKey);
43312
+ const stored = entry?.value;
43313
+ output = await runScriptWithRunCredential({
43314
+ ...runContext,
43315
+ source: script.source,
43316
+ args,
43317
+ agentId,
43318
+ executor: executor === undefined ? script.executor : executor,
43319
+ fsMode: fsMode ?? script.fsMode,
43320
+ signal: AbortSignal.timeout(DEFAULT_SCRIPT_RESOURCES.wallClockMs),
43321
+ durable: {
43322
+ id: objectId,
43323
+ method,
43324
+ state: stored?.state,
43325
+ codeVersion: script.version,
43326
+ storedCodeVersion: stored?.codeVersion ?? script.version,
43327
+ caller
43328
+ }
43329
+ }, {
43330
+ ...provenance,
43331
+ objectChain: [...objectChain, identity],
43332
+ depth: (provenance.depth ?? 0) + 1
43333
+ });
43334
+ if (output.error || output.exitCode !== 0 || !output.durable) {
43335
+ await release();
43336
+ return { ok: false, code: "run_failed", message: "object run failed", output };
43337
+ }
43338
+ const { state, destroyed } = output.durable;
43339
+ const ttl = output.durable.idleTtlSec;
43340
+ const idleTtlSec = typeof ttl === "number" && Number.isFinite(ttl) && ttl > 0 ? ttl : null;
43341
+ const encoded = JSON.stringify(state);
43342
+ if (encoded === undefined) {
43343
+ await release();
43344
+ return { ok: false, code: "run_failed", message: "state must be JSON-serializable" };
43345
+ }
43346
+ if (Buffer.byteLength(encoded, "utf8") > MAX_KV_BODY_BYTES) {
43347
+ await release();
43348
+ return { ok: false, code: "too_large", message: "state too large" };
43349
+ }
43350
+ const changed = !stored || stored.codeVersion !== script.version || encoded !== JSON.stringify(stored.state);
43351
+ const stateVersion = (stored?.stateVersion ?? 0) + (!destroyed && changed ? 1 : 0);
43352
+ const committed = await client.transaction(async () => {
43353
+ const lease = await getKv2(namespace, leaseKey);
43354
+ if (lease?.value?.token !== token)
43355
+ return false;
43356
+ if (destroyed) {
43357
+ await deleteKv2(namespace, stateKey);
43358
+ } else if (changed) {
43359
+ await upsertKv2({
43360
+ namespace,
43361
+ key: stateKey,
43362
+ value: { codeVersion: script.version, stateVersion, state },
43363
+ valueType: "json",
43364
+ expiresAt: idleTtlSec !== null ? Date.now() + idleTtlSec * 1000 : null
43365
+ });
43366
+ } else if (idleTtlSec !== null) {
43367
+ const expiresAt = Date.now() + idleTtlSec * 1000;
43368
+ const refreshed = await client.run("UPDATE kv_entries SET expires_at = ? WHERE namespace = ? AND key = ?", [expiresAt, namespace, stateKey]);
43369
+ if (refreshed.changes === 0) {
43370
+ await upsertKv2({ namespace, key: stateKey, value: stored, valueType: "json", expiresAt });
43371
+ }
43372
+ }
43373
+ await deleteKv2(namespace, leaseKey);
43374
+ return true;
43375
+ });
43376
+ if (!committed)
43377
+ return { ok: false, code: "lease_lost", message: "lease lost" };
43378
+ return { ok: true, output, object: { id: objectId, stateVersion, destroyed } };
43379
+ } catch (error) {
43380
+ await release();
43381
+ return {
43382
+ ok: false,
43383
+ code: "run_failed",
43384
+ message: scrubSecrets(error instanceof Error ? error.message : "object run failed"),
43385
+ output
43386
+ };
43387
+ }
43388
+ }
43389
+
43390
+ // src/http/scripts.ts
42927
43391
  init_embeddings();
42928
43392
  init_extract_schema();
42929
43393
  init_run_credential();
42930
43394
  init_typecheck();
43395
+ init_users();
42931
43396
  init_rbac();
42932
43397
  init_registry();
42933
43398
  init_extract_signature();
@@ -42935,6 +43400,7 @@ init_quickjs_compat();
42935
43400
  init_types5();
42936
43401
  init_request_auth_context();
42937
43402
  init_secret_scrubber();
43403
+ init_request_principal();
42938
43404
  init_route_def();
42939
43405
  init_utils2();
42940
43406
  var scriptNameSchema2 = string2().min(1).max(200);
@@ -42950,6 +43416,7 @@ var upsertBodySchema = object2({
42950
43416
  var runBodySchema = object2({
42951
43417
  name: scriptNameSchema2.optional(),
42952
43418
  source: string2().min(1).optional(),
43419
+ object: object2({ id: string2().min(1).max(256), method: string2().min(1).max(128) }).optional(),
42953
43420
  args: unknown().optional(),
42954
43421
  intent: string2().default(""),
42955
43422
  scope: ScriptScopeSchema.optional(),
@@ -42958,6 +43425,8 @@ var runBodySchema = object2({
42958
43425
  idempotencyKey: string2().max(200).optional()
42959
43426
  }).refine((body) => Boolean(body.name) !== Boolean(body.source), {
42960
43427
  message: "Provide exactly one of name or source"
43428
+ }).refine((body) => !body.object || Boolean(body.name), {
43429
+ message: "object requires name"
42961
43430
  });
42962
43431
  var searchBodySchema = object2({
42963
43432
  query: string2().default(""),
@@ -42973,6 +43442,8 @@ var listScriptsQuerySchema = object2({
42973
43442
  includeScratch: _enum2(["true", "false"]).optional()
42974
43443
  });
42975
43444
  var scriptSignatureSchema = object2({
43445
+ kind: literal2("durable").optional(),
43446
+ methods: record2(string2(), object2({ argsType: string2(), resultType: string2(), description: string2() })).optional(),
42976
43447
  argsType: string2(),
42977
43448
  resultType: string2(),
42978
43449
  description: string2()
@@ -42982,11 +43453,20 @@ var rowAuditColumnsShape = {
42982
43453
  created_by: string2().nullable().optional(),
42983
43454
  updated_by: string2().nullable().optional()
42984
43455
  };
43456
+ function scriptKind(signatureJson) {
43457
+ try {
43458
+ return JSON.parse(signatureJson)?.kind === "durable" ? "durable" : "function";
43459
+ } catch {
43460
+ return "function";
43461
+ }
43462
+ }
42985
43463
  var scriptListItemSchema = ScriptRecordSchema.omit({
42986
43464
  source: true,
42987
43465
  signatureJson: true,
42988
43466
  argsJsonSchema: true,
42989
43467
  contentHash: true
43468
+ }).extend({
43469
+ kind: _enum2(["function", "durable"])
42990
43470
  });
42991
43471
  var scriptDetailSchema = ScriptRecordSchema.omit({ argsJsonSchema: true }).extend({
42992
43472
  signature: scriptSignatureSchema,
@@ -42998,6 +43478,7 @@ var scriptApiWithSecretSchema = ScriptApiRecordSchema.extend({
42998
43478
  });
42999
43479
  var scriptRunResponseSchema = object2({
43000
43480
  result: unknown().optional(),
43481
+ object: object2({ id: string2(), stateVersion: number2(), destroyed: boolean() }).optional(),
43001
43482
  autoSaved: object2({ slug: string2(), reason: string2() }).optional(),
43002
43483
  kvSaved: object2({ namespace: string2(), key: string2() }).optional(),
43003
43484
  truncated: object2({ stdout: boolean(), stderr: boolean() }),
@@ -43066,7 +43547,7 @@ var upsertRoute2 = route({
43066
43547
  name: string2(),
43067
43548
  version: number2(),
43068
43549
  contentDeduped: boolean(),
43069
- warnings: array2(string2()).optional().describe("Advisory quickjs-executor compatibility findings. Never blocks the save.")
43550
+ warnings: array2(string2()).optional().describe("Advisory findings: quickjs-executor compatibility, and apps the script names that have no generated script types. Never blocks the save.")
43070
43551
  })
43071
43552
  },
43072
43553
  400: { description: "Validation or typecheck failure" },
@@ -43091,6 +43572,7 @@ var runRoute = route({
43091
43572
  200: { description: "Script run completed", schema: scriptRunResponseSchema },
43092
43573
  400: { description: "Validation error" },
43093
43574
  404: { description: "Script not found" },
43575
+ 409: { description: "Object busy, re-entry, or lease lost" },
43094
43576
  501: { description: "workspace-rw scripts are not supported in v1" }
43095
43577
  }
43096
43578
  });
@@ -43412,6 +43894,10 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43412
43894
  json(res, secretRefusal, 400);
43413
43895
  return true;
43414
43896
  }
43897
+ if (parsed.body.scope !== "global" && extractScriptSignature(parsed.body.source).kind === "durable") {
43898
+ jsonError(res, "DurableObject scripts must be global scope", 400);
43899
+ return true;
43900
+ }
43415
43901
  const typecheck = await typecheckScript(parsed.body.source, { agentId: agent.id });
43416
43902
  if (!typecheck.ok) {
43417
43903
  json(res, {
@@ -43448,7 +43934,10 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43448
43934
  isPromotion: Boolean(existingAgentScript)
43449
43935
  });
43450
43936
  }
43451
- const warnings = quickJSCompatWarnings(checkQuickJSCompat(parsed.body.source, { fsMode: parsed.body.fsMode }));
43937
+ const warnings = [
43938
+ ...quickJSCompatWarnings(checkQuickJSCompat(parsed.body.source, { fsMode: parsed.body.fsMode })),
43939
+ ...typecheck.warnings ?? []
43940
+ ];
43452
43941
  upsertRoute2.respond(res, 200, {
43453
43942
  name: result.script.name,
43454
43943
  version: result.script.version,
@@ -43464,6 +43953,12 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43464
43953
  const agent = await requireAgent2(res, agentId);
43465
43954
  if (!agent)
43466
43955
  return true;
43956
+ const callerProvenance = getCurrentRunProvenance();
43957
+ const depth = callerProvenance?.depth ?? 0;
43958
+ if (depth >= 16) {
43959
+ jsonError(res, "call depth exceeds 16", 400);
43960
+ return true;
43961
+ }
43467
43962
  const runtimeInstanceId = ((h) => Array.isArray(h) ? h[0] : h)(req.headers["x-runtime-instance-id"]);
43468
43963
  const sourceTaskId = ((h) => Array.isArray(h) ? h[0] : h)(req.headers["x-source-task-id"]);
43469
43964
  const secretRefusal = parsed.body.source ? refuseSourceWithSecrets(parsed.body.source) : null;
@@ -43471,6 +43966,10 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43471
43966
  json(res, secretRefusal, 400);
43472
43967
  return true;
43473
43968
  }
43969
+ if (parsed.body.source && extractScriptSignature(parsed.body.source).kind === "durable") {
43970
+ jsonError(res, "DurableObject scripts must be saved globally and called by name", 400);
43971
+ return true;
43972
+ }
43474
43973
  let source = parsed.body.source;
43475
43974
  let fsMode = parsed.body.fsMode;
43476
43975
  let executor = parsed.body.executor ?? null;
@@ -43486,6 +43985,20 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43486
43985
  fsMode = script.fsMode;
43487
43986
  executor = parsed.body.executor !== undefined ? parsed.body.executor : script.executor;
43488
43987
  }
43988
+ const isDurable = namedScript && JSON.parse(namedScript.signatureJson).kind === "durable";
43989
+ if (isDurable && namedScript) {
43990
+ if (namedScript.scope !== "global") {
43991
+ jsonError(res, "DurableObject scripts must be global scope", 400);
43992
+ return true;
43993
+ }
43994
+ if (!parsed.body.object) {
43995
+ jsonError(res, "DurableObject scripts require object: { id, method }", 400);
43996
+ return true;
43997
+ }
43998
+ } else if (parsed.body.object) {
43999
+ jsonError(res, "not a DurableObject", 400);
44000
+ return true;
44001
+ }
43489
44002
  if (fsMode === "workspace-rw") {
43490
44003
  jsonError(res, "workspace-rw scripts are not supported by /api/scripts/run in v1", 501);
43491
44004
  return true;
@@ -43496,14 +44009,13 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43496
44009
  }
43497
44010
  const startedAt = new Date().toISOString();
43498
44011
  const runStartTouch = namedScript?.isScratch ? await touchScratchScriptLastUsed(namedScript.id) : null;
43499
- const credentials = await buildScriptCredentialBindingsWithFailures({ agentId: agent.id });
43500
44012
  const runId = crypto.randomUUID();
43501
- const callerProvenance = getCurrentRunProvenance();
43502
- const output = await runScriptWithRunCredential({
43503
- source,
43504
- args: parsed.body.args,
43505
- fsMode,
43506
- executor,
44013
+ const provenance = {
44014
+ ...callerProvenance,
44015
+ sourceScriptRunId: runId
44016
+ };
44017
+ const credentials = await buildScriptCredentialBindingsWithFailures({ agentId: agent.id });
44018
+ const runContext = {
43507
44019
  agentId: agent.id,
43508
44020
  runtimeInstanceId,
43509
44021
  sourceTaskId,
@@ -43513,10 +44025,55 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43513
44025
  agentFs: credentials.agentFs,
43514
44026
  apiConnections: getScriptApiConnectionDescriptors({ agentId: agent.id }),
43515
44027
  mcpConnections: getScriptMcpConnectionDescriptors({ agentId: agent.id })
43516
- }, {
43517
- sourceScriptRunId: runId,
43518
- sourceStepId: callerProvenance?.sourceStepId ?? undefined
43519
- });
44028
+ };
44029
+ let output;
44030
+ let object;
44031
+ if (isDurable && namedScript && parsed.body.object) {
44032
+ const auth = getRequestAuth(req);
44033
+ const caller = auth?.kind === "agent" && await isScriptRunToken(auth.tokenId) ? { kind: "script", agentId: agent.id } : { kind: "agent", agentId: agent.id };
44034
+ const result = await callDurableObject({
44035
+ ...runContext,
44036
+ script: namedScript,
44037
+ objectId: parsed.body.object.id,
44038
+ method: parsed.body.object.method,
44039
+ args: parsed.body.args,
44040
+ caller,
44041
+ provenance,
44042
+ executor,
44043
+ fsMode,
44044
+ nested: callerProvenance !== null
44045
+ });
44046
+ if (!result.ok && result.code !== "run_failed") {
44047
+ const status = ["busy", "reentry", "lease_lost"].includes(result.code) ? 409 : 400;
44048
+ jsonError(res, result.message, status);
44049
+ return true;
44050
+ }
44051
+ if (result.ok) {
44052
+ output = result.output;
44053
+ object = result.object;
44054
+ } else {
44055
+ output = result.output ?? {
44056
+ result: undefined,
44057
+ stdout: "",
44058
+ stderr: result.message,
44059
+ truncated: { stdout: false, stderr: false },
44060
+ durationMs: 0,
44061
+ exitCode: 1,
44062
+ error: "executor_error"
44063
+ };
44064
+ if (output.exitCode === 0 && !output.error && !output.runtimeError) {
44065
+ output = { ...output, exitCode: 1, error: "executor_error", stderr: result.message };
44066
+ }
44067
+ }
44068
+ } else {
44069
+ output = await runScriptWithRunCredential({
44070
+ ...runContext,
44071
+ source,
44072
+ args: parsed.body.args,
44073
+ fsMode,
44074
+ executor
44075
+ }, { ...provenance, depth: depth + 1 });
44076
+ }
43520
44077
  const ok = output.exitCode === 0 && !output.error && !output.runtimeError;
43521
44078
  if (namedScript?.isScratch && ok) {
43522
44079
  await touchScratchScriptLastUsed(namedScript.id);
@@ -43574,6 +44131,9 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43574
44131
  source,
43575
44132
  args: scrubObject(parsed.body.args ?? null),
43576
44133
  scriptName: parsed.body.name ?? "(inline source)",
44134
+ objectScriptId: isDurable ? namedScript?.id : undefined,
44135
+ objectId: parsed.body.object?.id,
44136
+ objectMethod: parsed.body.object?.method,
43577
44137
  status: ok ? "completed" : "failed",
43578
44138
  output: scrubObject(output.result),
43579
44139
  error: runError,
@@ -43583,6 +44143,7 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43583
44143
  } catch {}
43584
44144
  runRoute.respond(res, 200, scrubObject({
43585
44145
  result: output.result,
44146
+ object,
43586
44147
  autoSaved,
43587
44148
  kvSaved,
43588
44149
  truncated: output.truncated,
@@ -43635,7 +44196,8 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43635
44196
  createdBy: script.createdBy,
43636
44197
  updatedBy: script.updatedBy,
43637
44198
  createdAt: script.createdAt,
43638
- updatedAt: script.updatedAt
44199
+ updatedAt: script.updatedAt,
44200
+ kind: scriptKind(script.signatureJson)
43639
44201
  }));
43640
44202
  listScriptsRoute.respond(res, 200, { scripts });
43641
44203
  return true;
@@ -43755,6 +44317,23 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43755
44317
  jsonError(res, "agentId is required: this script has no owning agent to run as", 400);
43756
44318
  return true;
43757
44319
  }
44320
+ const auth = getRequestAuth(req);
44321
+ if (auth?.kind === "agent") {
44322
+ const caller = await getAgentById2(auth.agentId);
44323
+ const decision = can({
44324
+ principal: { kind: "agent", agentId: auth.agentId, isLead: caller?.isLead === true },
44325
+ verb: "script.api.create",
44326
+ source: "http"
44327
+ });
44328
+ if (!decision.allow) {
44329
+ jsonError(res, `Forbidden: ${decision.reason}`, 403);
44330
+ return true;
44331
+ }
44332
+ if (!await getAgentById2(runAsAgentId)) {
44333
+ jsonError(res, `agentId "${runAsAgentId}" is not a registered agent`, 400);
44334
+ return true;
44335
+ }
44336
+ }
43758
44337
  const endpoint = await createScriptApi({
43759
44338
  scriptId: script.id,
43760
44339
  agentId: runAsAgentId,
@@ -43786,6 +44365,8 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43786
44365
  const parsed = await revealScriptApiSecretRoute.parse(req, res, pathSegments, queryParams);
43787
44366
  if (!parsed)
43788
44367
  return true;
44368
+ if (await refuseAgentTokenWithout(req, res, "script.api.read.secrets"))
44369
+ return true;
43789
44370
  const endpoint = await getScriptApiById(parsed.params.endpointId);
43790
44371
  if (!endpoint || endpoint.scriptId !== parsed.params.id) {
43791
44372
  jsonError(res, "Endpoint not found", 404);
@@ -43798,6 +44379,8 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43798
44379
  const parsed = await rotateScriptApiRoute.parse(req, res, pathSegments, queryParams);
43799
44380
  if (!parsed)
43800
44381
  return true;
44382
+ if (await refuseAgentTokenWithout(req, res, "script.api.rotate"))
44383
+ return true;
43801
44384
  const endpoint = await getScriptApiById(parsed.params.endpointId);
43802
44385
  if (!endpoint || endpoint.scriptId !== parsed.params.id) {
43803
44386
  jsonError(res, "Endpoint not found", 404);
@@ -43815,6 +44398,8 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43815
44398
  const parsed = await patchScriptApiRoute.parse(req, res, pathSegments, queryParams);
43816
44399
  if (!parsed)
43817
44400
  return true;
44401
+ if (await refuseAgentTokenWithout(req, res, "script.api.update"))
44402
+ return true;
43818
44403
  const endpoint = await getScriptApiById(parsed.params.endpointId);
43819
44404
  if (!endpoint || endpoint.scriptId !== parsed.params.id) {
43820
44405
  jsonError(res, "Endpoint not found", 404);
@@ -43832,6 +44417,8 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43832
44417
  const parsed = await deleteScriptApiRoute.parse(req, res, pathSegments, queryParams);
43833
44418
  if (!parsed)
43834
44419
  return true;
44420
+ if (await refuseAgentTokenWithout(req, res, "script.api.delete"))
44421
+ return true;
43835
44422
  const endpoint = await getScriptApiById(parsed.params.endpointId);
43836
44423
  if (!endpoint || endpoint.scriptId !== parsed.params.id) {
43837
44424
  jsonError(res, "Endpoint not found", 404);
@@ -44305,7 +44892,7 @@ init_rbac_roles();
44305
44892
  init_session_shares();
44306
44893
  init_steering2();
44307
44894
  init_task_citations2();
44308
- init_task_ui_spec();
44895
+ init_task_ui_spec2();
44309
44896
  init_users();
44310
44897
  init_rbac();
44311
44898
  init_auth2();
@@ -45667,6 +46254,7 @@ async function getSkillUsageDetail(skillId, window, tzOffsetMinutes = 0, now = D
45667
46254
 
45668
46255
  // src/http/skills.ts
45669
46256
  init_types5();
46257
+ init_request_principal();
45670
46258
  init_route_def();
45671
46259
  init_utils2();
45672
46260
  var SYSTEM_DEFAULT_SKILL_LOCKED_MESSAGE = "This skill is system-managed and cannot be edited from the UI; it is re-seeded on each start. Fork it under a new name to customize.";
@@ -46170,6 +46758,8 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46170
46758
  const parsed = await installRemoteRoute.parse(req, res, pathSegments, queryParams);
46171
46759
  if (!parsed)
46172
46760
  return true;
46761
+ if (await refuseAgentTokenWithout(req, res, "skill.install.global"))
46762
+ return true;
46173
46763
  try {
46174
46764
  const branch = "main";
46175
46765
  const filePath = parsed.body.sourcePath ? `${parsed.body.sourcePath}/SKILL.md` : "SKILL.md";
@@ -46291,6 +46881,12 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46291
46881
  jsonError(res, "Skill not found", 404);
46292
46882
  return true;
46293
46883
  }
46884
+ if (parsed.body.agentId !== myAgentId && await refuseAgentTokenWithout(req, res, "skill.install.any", {
46885
+ kind: "agent",
46886
+ agentId: parsed.body.agentId
46887
+ })) {
46888
+ return true;
46889
+ }
46294
46890
  try {
46295
46891
  const agentSkill = await installSkill2(parsed.body.agentId, parsed.params.id);
46296
46892
  installSkillRoute.respond(res, 200, { agentSkill });
@@ -46303,6 +46899,12 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46303
46899
  const parsed = await uninstallSkillRoute.parse(req, res, pathSegments, queryParams);
46304
46900
  if (!parsed)
46305
46901
  return true;
46902
+ if (parsed.params.agentId !== myAgentId && await refuseAgentTokenWithout(req, res, "skill.uninstall.any", {
46903
+ kind: "agent",
46904
+ agentId: parsed.params.agentId
46905
+ })) {
46906
+ return true;
46907
+ }
46306
46908
  const removed = await uninstallSkill2(parsed.params.agentId, parsed.params.id);
46307
46909
  uninstallSkillRoute.respond(res, 200, { success: removed });
46308
46910
  return true;
@@ -46365,6 +46967,12 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46365
46967
  jsonError(res, "Skill not found", 404);
46366
46968
  return true;
46367
46969
  }
46970
+ if (await refuseAgentTokenWithout(req, res, "skill.update.any", {
46971
+ kind: "owned",
46972
+ ownerAgentId: skill.ownerAgentId
46973
+ })) {
46974
+ return true;
46975
+ }
46368
46976
  if (skill.systemDefault) {
46369
46977
  jsonError(res, SYSTEM_DEFAULT_SKILL_LOCKED_MESSAGE, 403);
46370
46978
  return true;
@@ -46413,6 +47021,12 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46413
47021
  jsonError(res, "Skill not found", 404);
46414
47022
  return true;
46415
47023
  }
47024
+ if (await refuseAgentTokenWithout(req, res, "skill.update.any", {
47025
+ kind: "owned",
47026
+ ownerAgentId: skill.ownerAgentId
47027
+ })) {
47028
+ return true;
47029
+ }
46416
47030
  if (skill.systemDefault) {
46417
47031
  jsonError(res, SYSTEM_DEFAULT_SKILL_LOCKED_MESSAGE, 403);
46418
47032
  return true;
@@ -46439,6 +47053,12 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46439
47053
  jsonError(res, "Skill not found", 404);
46440
47054
  return true;
46441
47055
  }
47056
+ if (await refuseAgentTokenWithout(req, res, "skill.update.any", {
47057
+ kind: "owned",
47058
+ ownerAgentId: skill.ownerAgentId
47059
+ })) {
47060
+ return true;
47061
+ }
46442
47062
  if (skill.systemDefault) {
46443
47063
  jsonError(res, SYSTEM_DEFAULT_SKILL_LOCKED_MESSAGE, 403);
46444
47064
  return true;
@@ -46473,6 +47093,9 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46473
47093
  const parsed = await createSkillRoute.parse(req, res, pathSegments, queryParams);
46474
47094
  if (!parsed)
46475
47095
  return true;
47096
+ if (((parsed.body.scope ?? "agent") !== "agent" || parsed.body.systemDefault === true) && await refuseAgentTokenWithout(req, res, "skill.create.swarm")) {
47097
+ return true;
47098
+ }
46476
47099
  try {
46477
47100
  const pm = parseSkillContent(parsed.body.content);
46478
47101
  const skill = await createSkill2({
@@ -46508,6 +47131,13 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46508
47131
  jsonError(res, "Skill not found", 404);
46509
47132
  return true;
46510
47133
  }
47134
+ const owned = { kind: "owned", ownerAgentId: existing.ownerAgentId };
47135
+ if (await refuseAgentTokenWithout(req, res, "skill.update.any", owned))
47136
+ return true;
47137
+ const { scope, systemDefault, ownerAgentId } = parsed.body;
47138
+ if ((scope !== undefined && scope !== existing.scope && scope !== "agent" || systemDefault === true || Object.hasOwn(parsed.body, "ownerAgentId") && ownerAgentId !== existing.ownerAgentId) && await refuseAgentTokenWithout(req, res, "skill.promote.swarm", owned)) {
47139
+ return true;
47140
+ }
46511
47141
  const protectedSystemDefaultFields = [
46512
47142
  "content",
46513
47143
  "name",
@@ -46570,6 +47200,12 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46570
47200
  jsonError(res, "Skill not found", 404);
46571
47201
  return true;
46572
47202
  }
47203
+ if (await refuseAgentTokenWithout(req, res, "skill.delete.any", {
47204
+ kind: "owned",
47205
+ ownerAgentId: existing.ownerAgentId
47206
+ })) {
47207
+ return true;
47208
+ }
46573
47209
  if (existing.systemDefault) {
46574
47210
  jsonError(res, SYSTEM_DEFAULT_SKILL_LOCKED_MESSAGE, 403);
46575
47211
  return true;
@@ -47339,6 +47975,8 @@ init_metadata();
47339
47975
  init_webhook();
47340
47976
  init_webhook_lifecycle();
47341
47977
  init_ensure_token();
47978
+ init_config();
47979
+ init_request_principal();
47342
47980
  init_route_def();
47343
47981
  init_utils2();
47344
47982
 
@@ -47491,6 +48129,7 @@ var jiraWebhookRegister = route({
47491
48129
  body: object2({
47492
48130
  jqlFilter: string2().min(1)
47493
48131
  }),
48132
+ rbac: { permission: "oauth-authorization.manage" },
47494
48133
  responses: {
47495
48134
  200: { description: "Webhook registered", schema: JiraWebhookRegisteredSchema },
47496
48135
  400: { description: "Invalid jqlFilter" },
@@ -47506,6 +48145,7 @@ var jiraWebhookDelete = route({
47506
48145
  params: object2({
47507
48146
  id: exports_coerce.number().int().positive()
47508
48147
  }),
48148
+ rbac: { permission: "oauth-authorization.manage" },
47509
48149
  responses: {
47510
48150
  200: { description: "Webhook deleted", schema: JiraWebhookDeletedSchema },
47511
48151
  400: { description: "Invalid webhook id" },
@@ -47518,13 +48158,15 @@ var jiraDisconnect = route({
47518
48158
  pattern: ["api", "trackers", "jira", "disconnect"],
47519
48159
  summary: "Fully disconnect Jira: delete all webhooks, drop tokens, clear metadata",
47520
48160
  tags: ["Trackers"],
48161
+ rbac: { permission: "oauth-authorization.manage" },
47521
48162
  responses: {
47522
48163
  200: { description: "Disconnected", schema: JiraDisconnectResultSchema },
47523
48164
  503: { description: "Jira not configured" }
47524
48165
  }
47525
48166
  });
47526
- function getWebhookUrl(req) {
47527
- const token = process.env.JIRA_WEBHOOK_TOKEN ?? "<unset>";
48167
+ async function getWebhookUrl(req) {
48168
+ const configured = process.env.JIRA_WEBHOOK_TOKEN;
48169
+ const token = !configured ? "<unset>" : await requestSecretReadScope(req) === "all" ? configured : "<redacted>";
47528
48170
  return `${deriveApiBaseUrl(req)}/api/trackers/jira/webhook/${token}`;
47529
48171
  }
47530
48172
  function getRedirectUri(req) {
@@ -47548,7 +48190,7 @@ async function buildJiraStatusPayload(req) {
47548
48190
  scope,
47549
48191
  hasManageWebhookScope,
47550
48192
  webhookTokenConfigured: Boolean(process.env.JIRA_WEBHOOK_TOKEN),
47551
- webhookUrl: getWebhookUrl(req),
48193
+ webhookUrl: await getWebhookUrl(req),
47552
48194
  redirectUri: getRedirectUri(req),
47553
48195
  webhookIds: meta.webhookIds ?? []
47554
48196
  };
@@ -47665,6 +48307,8 @@ async function handleJiraTracker(req, res, pathSegments) {
47665
48307
  return true;
47666
48308
  }
47667
48309
  if (jiraWebhookRegister.match(req.method, pathSegments)) {
48310
+ if (await refuseAgentTokenWithout(req, res, "oauth-authorization.manage"))
48311
+ return true;
47668
48312
  if (!isJiraEnabled()) {
47669
48313
  res.writeHead(503, { "Content-Type": "application/json" });
47670
48314
  res.end(JSON.stringify({ error: "Jira integration not configured" }));
@@ -47691,6 +48335,8 @@ async function handleJiraTracker(req, res, pathSegments) {
47691
48335
  return true;
47692
48336
  }
47693
48337
  if (jiraWebhookDelete.match(req.method, pathSegments)) {
48338
+ if (await refuseAgentTokenWithout(req, res, "oauth-authorization.manage"))
48339
+ return true;
47694
48340
  if (!isJiraEnabled()) {
47695
48341
  res.writeHead(503, { "Content-Type": "application/json" });
47696
48342
  res.end(JSON.stringify({ error: "Jira integration not configured" }));
@@ -47712,6 +48358,8 @@ async function handleJiraTracker(req, res, pathSegments) {
47712
48358
  return true;
47713
48359
  }
47714
48360
  if (jiraDisconnect.match(req.method, pathSegments)) {
48361
+ if (await refuseAgentTokenWithout(req, res, "oauth-authorization.manage"))
48362
+ return true;
47715
48363
  if (!isJiraEnabled()) {
47716
48364
  res.writeHead(503, { "Content-Type": "application/json" });
47717
48365
  res.end(JSON.stringify({ error: "Jira integration not configured" }));
@@ -47820,6 +48468,7 @@ async function handleLinearWebhook(rawBody, headers) {
47820
48468
 
47821
48469
  // src/http/trackers/linear.ts
47822
48470
  init_ensure_token();
48471
+ init_request_principal();
47823
48472
  init_route_def();
47824
48473
  init_utils2();
47825
48474
  var LinearStatusSchema = object2({
@@ -47922,6 +48571,7 @@ var linearDisconnect = route({
47922
48571
  pattern: ["api", "trackers", "linear", "disconnect"],
47923
48572
  summary: "Fully disconnect Linear: revoke OAuth grant + drop tokens",
47924
48573
  tags: ["Trackers"],
48574
+ rbac: { permission: "oauth-authorization.manage" },
47925
48575
  responses: {
47926
48576
  200: { description: "Disconnected", schema: LinearDisconnectSchema },
47927
48577
  503: { description: "Linear not configured" }
@@ -48043,6 +48693,8 @@ async function handleLinearTracker(req, res, pathSegments) {
48043
48693
  return true;
48044
48694
  }
48045
48695
  if (linearDisconnect.match(req.method, pathSegments)) {
48696
+ if (await refuseAgentTokenWithout(req, res, "oauth-authorization.manage"))
48697
+ return true;
48046
48698
  if (!isLinearEnabled()) {
48047
48699
  res.writeHead(503, { "Content-Type": "application/json" });
48048
48700
  res.end(JSON.stringify({ error: "Linear integration not configured" }));
@@ -52312,7 +52964,7 @@ var httpServer = createHttpServer(async (req, res) => {
52312
52964
  });
52313
52965
  });
52314
52966
  var detachRealtime = attachRealtimeTransport(httpServer);
52315
- var { attachControllerTransport } = await import("./controllers-connect-2ssqz7f4.js");
52967
+ var { attachControllerTransport } = await import("./controllers-connect-j4kdmhfj.js");
52316
52968
  var detachControllers = attachControllerTransport(httpServer);
52317
52969
  var stopWorkerNudges = startWorkerNudgeListener();
52318
52970
  var taskAutoTitles = startTaskAutoTitleListener();
@@ -52343,7 +52995,7 @@ async function shutdown() {
52343
52995
  sessionsProcessed: getServerSessionsProcessed()
52344
52996
  });
52345
52997
  if (hasCapability("scheduling")) {
52346
- const { stopScheduler } = await import("./index-hmszyqkk.js");
52998
+ const { stopScheduler } = await import("./index-7dwh9kxh.js");
52347
52999
  stopScheduler();
52348
53000
  }
52349
53001
  stopHeartbeat2();
@@ -52355,7 +53007,7 @@ async function shutdown() {
52355
53007
  await stopSlackApp2();
52356
53008
  await stopChatSdk();
52357
53009
  if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
52358
- const { stopOAuthKeepalive } = await import("./keepalive-zhbmztqw.js");
53010
+ const { stopOAuthKeepalive } = await import("./keepalive-7eyb8y4t.js");
52359
53011
  await stopOAuthKeepalive();
52360
53012
  }
52361
53013
  stopOAuthPendingGc();
@@ -52428,6 +53080,7 @@ try {
52428
53080
  throw err;
52429
53081
  }
52430
53082
  warnIfCorsAllowsAnyOrigin();
53083
+ setDeploymentEnvReader2(getDeploymentEnvValue2);
52431
53084
  try {
52432
53085
  const loaded = await loadSecretRegistry();
52433
53086
  console.log(`[secret-registry] registered config=${loaded.config} oauth=${loaded.oauth} scriptApi=${loaded.scriptApi} runtimeController=${loaded.runtimeController} failed=${loaded.failed}`);
@@ -52445,21 +53098,21 @@ try {
52445
53098
  console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
52446
53099
  }
52447
53100
  try {
52448
- const { ensurePricingSeeded } = await import("./boot-seeds-hwnvgbb3.js");
53101
+ const { ensurePricingSeeded } = await import("./boot-seeds-xkxqa8zc.js");
52449
53102
  ensurePricingSeeded();
52450
- const { startPricingRefreshLoop } = await import("./pricing-refresh-9355dj1t.js");
53103
+ const { startPricingRefreshLoop } = await import("./pricing-refresh-041zpyhf.js");
52451
53104
  startPricingRefreshLoop();
52452
53105
  } catch (err) {
52453
53106
  console.error("[startup] Failed to seed pricing rows:", err);
52454
53107
  }
52455
53108
  try {
52456
- const { ensureModelProfilesSeeded } = await import("./boot-seeds-hwnvgbb3.js");
53109
+ const { ensureModelProfilesSeeded } = await import("./boot-seeds-xkxqa8zc.js");
52457
53110
  await ensureModelProfilesSeeded();
52458
53111
  } catch (err) {
52459
53112
  console.error("[startup] Failed to seed model profiles:", err);
52460
53113
  }
52461
53114
  try {
52462
- const { ensureRbacSeeded } = await import("./boot-seeds-hwnvgbb3.js");
53115
+ const { ensureRbacSeeded } = await import("./boot-seeds-xkxqa8zc.js");
52463
53116
  ensureRbacSeeded();
52464
53117
  } catch (err) {
52465
53118
  console.error("[startup] Failed to sync RBAC seed rows:", err);
@@ -52467,13 +53120,13 @@ try {
52467
53120
  throw err;
52468
53121
  }
52469
53122
  try {
52470
- const { runAllSeeders } = await import("./index-z2g9469g.js");
53123
+ const { runAllSeeders } = await import("./index-h9xnzfhx.js");
52471
53124
  await runAllSeeders({ scriptEmbeddingMode: "skip" });
52472
53125
  } catch (err) {
52473
53126
  console.error("[startup] Failed to seed built-in entities:", err);
52474
53127
  }
52475
53128
  try {
52476
- const { runImports } = await import("./index-yq9hhhhy.js");
53129
+ const { runImports } = await import("./index-dm7c6hw5.js");
52477
53130
  await runImports();
52478
53131
  } catch (err) {
52479
53132
  console.error("[startup] File import failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
@@ -52493,6 +53146,7 @@ httpServer.listen(port, async () => {
52493
53146
  const boundAddress = httpServer.address();
52494
53147
  if (boundAddress && typeof boundAddress === "object") {
52495
53148
  setExtensionLoopbackBaseUrl(`http://127.0.0.1:${boundAddress.port}`);
53149
+ setApiLoopbackBaseUrl(`http://127.0.0.1:${boundAddress.port}`);
52496
53150
  }
52497
53151
  console.log(`MCP HTTP server running on http://localhost:${port}/mcp`);
52498
53152
  ensure({
@@ -52524,10 +53178,10 @@ httpServer.listen(port, async () => {
52524
53178
  startChatSdk().catch((err) => {
52525
53179
  console.error("[chat-sdk] Failed to start, continuing without Chat SDK:", scrubSecrets(err instanceof Error ? err.message : String(err)));
52526
53180
  });
52527
- import("./agent-fs-provision-cbt2ttds.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
53181
+ import("./agent-fs-provision-zpbxa9jc.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
52528
53182
  console.warn("[agent-fs] Failed to set the org swarm URL:", scrubSecrets(err instanceof Error ? err.message : String(err)));
52529
53183
  });
52530
- import("./object-webhooks-331hay92.js").then(({ ensureObjectWebhooksForKnownDrives }) => ensureObjectWebhooksForKnownDrives()).catch((err) => {
53184
+ import("./object-webhooks-p190rdxp.js").then(({ ensureObjectWebhooksForKnownDrives }) => ensureObjectWebhooksForKnownDrives()).catch((err) => {
52531
53185
  console.warn("[objects] agent-fs webhook boot check failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
52532
53186
  });
52533
53187
  startQueueStallAlarm();
@@ -52541,24 +53195,24 @@ httpServer.listen(port, async () => {
52541
53195
  await initLinear();
52542
53196
  await initJira();
52543
53197
  await initWorkflows2();
52544
- await startScriptRunSupervisor(getMcpBaseUrl());
53198
+ await startScriptRunSupervisor(getScriptApiBaseUrl());
52545
53199
  if (hasCapability("scheduling")) {
52546
- const { parseSchedulerIntervalMs, startScheduler } = await import("./index-hmszyqkk.js");
52547
- const { getExecutorRegistry } = await import("./index-dtt0d634.js");
53200
+ const { parseSchedulerIntervalMs, startScheduler } = await import("./index-7dwh9kxh.js");
53201
+ const { getExecutorRegistry } = await import("./index-wp9tarbt.js");
52548
53202
  startScheduler(getExecutorRegistry(), parseSchedulerIntervalMs(process.env.SCHEDULER_INTERVAL_MS), { runId: globalState.__runId });
52549
53203
  }
52550
53204
  if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
52551
- const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-j6rm1rtn.js");
53205
+ const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-z6np2405.js");
52552
53206
  startHeartbeat(parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS));
52553
53207
  }
52554
53208
  startPoolRouting();
52555
53209
  startRuntimeSupervisor();
52556
53210
  if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
52557
- const { startOAuthKeepalive } = await import("./keepalive-zhbmztqw.js");
53211
+ const { startOAuthKeepalive } = await import("./keepalive-7eyb8y4t.js");
52558
53212
  startOAuthKeepalive();
52559
53213
  }
52560
53214
  if (!isEnvFlagEnabled("OAUTH_REFRESH_SWEEP_DISABLE", false)) {
52561
- const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-w3cqmxq7.js");
53215
+ const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-f4c7g37h.js");
52562
53216
  startOAuthRefreshSweep();
52563
53217
  }
52564
53218
  startOAuthPendingGc();
@@ -52568,22 +53222,19 @@ httpServer.listen(port, async () => {
52568
53222
  startSavingsRollup(savingsRollupSql);
52569
53223
  startHumanFreeDrain();
52570
53224
  startTaskSearchBackfill();
52571
- import("./embedding-space-qepzrach.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
52572
- setDeploymentEnvReader(getDeploymentEnvValue2);
52573
- return runEmbeddingMaintenance({ backfill: true });
52574
- }).catch((err) => {
53225
+ import("./embedding-space-0p921zt3.js").then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: true })).catch((err) => {
52575
53226
  console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
52576
53227
  });
52577
- import("./boot-args-schema-g27kpzr1.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
53228
+ import("./boot-args-schema-zs435mfx.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
52578
53229
  console.error("[boot-args-schema] startup backfill failed (non-fatal):", err);
52579
53230
  });
52580
- import("./boot-scrub-sweep-ss1vcamw.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
53231
+ import("./boot-scrub-sweep-3h5xscw6.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
52581
53232
  console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
52582
53233
  });
52583
- import("./user-merge-jobs-mxrhamwt.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
53234
+ import("./user-merge-jobs-vjsps179.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
52584
53235
  console.error("[user-merge] startup resume failed (non-fatal):", err);
52585
53236
  });
52586
- import("./session-source-backfill-cdm5s046.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
53237
+ import("./session-source-backfill-6fe3hcgb.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
52587
53238
  console.error("[session-source-backfill] startup run failed (non-fatal):", err);
52588
53239
  });
52589
53240
  }).on("error", (err) => {