@cimplify/sdk 0.108.0 → 0.110.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (608) hide show
  1. package/LICENSE +21 -0
  2. package/dist/advanced.d.mts +4 -3
  3. package/dist/advanced.d.ts +4 -3
  4. package/dist/advanced.js +24 -24
  5. package/dist/advanced.mjs +5 -5
  6. package/dist/animation-4EXBXRVX.js +27 -0
  7. package/dist/animation-6DICNWUP.mjs +6 -0
  8. package/dist/audio-DhvyjqdA.d.mts +249 -0
  9. package/dist/audio-m0w8cnxq.d.ts +249 -0
  10. package/dist/avatars.d.mts +110 -0
  11. package/dist/avatars.d.ts +110 -0
  12. package/dist/avatars.js +82 -0
  13. package/dist/avatars.mjs +5 -0
  14. package/dist/backend-gUCzs5Kg.d.mts +3866 -0
  15. package/dist/backend-gUCzs5Kg.d.ts +3866 -0
  16. package/dist/{catalogue-B4eLL8Mi.d.ts → catalogue-CPTMyBUz.d.mts} +109 -221
  17. package/dist/catalogue-DzrTXP3v.d.mts +541 -0
  18. package/dist/catalogue-DzrTXP3v.d.ts +541 -0
  19. package/dist/{catalogue-OT89_Ifs.d.mts → catalogue-OTuS5zp-.d.ts} +109 -221
  20. package/dist/chunk-22BD3RHN.mjs +1809 -0
  21. package/dist/chunk-25T4JHEA.mjs +21 -0
  22. package/dist/chunk-2AQ237Y4.js +508 -0
  23. package/dist/chunk-2IC4H6OV.mjs +48 -0
  24. package/dist/chunk-2LHLG4OB.mjs +71 -0
  25. package/dist/chunk-2O2CG465.js +1709 -0
  26. package/dist/chunk-2Q4DTHXK.js +316 -0
  27. package/dist/chunk-2QTQ6BUH.mjs +46 -0
  28. package/dist/chunk-2UN4SFLR.mjs +100 -0
  29. package/dist/chunk-2V75I7K3.js +454 -0
  30. package/dist/chunk-2V7IL4HC.js +10 -0
  31. package/dist/chunk-34XBXUMW.js +296 -0
  32. package/dist/chunk-3C4C654I.js +71 -0
  33. package/dist/chunk-3DAD2LDF.mjs +72 -0
  34. package/dist/chunk-3GXH2NFD.mjs +4 -0
  35. package/dist/chunk-3O47ZFW3.js +961 -0
  36. package/dist/chunk-3OY3VYNF.mjs +11 -0
  37. package/dist/chunk-3S6WPBZL.js +2936 -0
  38. package/dist/chunk-3TUOUP5T.js +399 -0
  39. package/dist/chunk-3VEH23I5.mjs +1380 -0
  40. package/dist/chunk-3ZYSAW2T.mjs +263 -0
  41. package/dist/chunk-4ANVF274.js +103 -0
  42. package/dist/chunk-4C7I3ELN.js +388 -0
  43. package/dist/chunk-4DYKAYFO.mjs +8 -0
  44. package/dist/chunk-4ZDR72SG.js +329 -0
  45. package/dist/chunk-52YS45RR.js +1066 -0
  46. package/dist/chunk-5325XSCH.js +107 -0
  47. package/dist/chunk-5AD5X6AV.js +13 -0
  48. package/dist/chunk-5BYDGGWO.mjs +197 -0
  49. package/dist/chunk-5C3C7VDM.mjs +55 -0
  50. package/dist/chunk-5HFMY3D7.js +660 -0
  51. package/dist/chunk-5LH2QN3T.js +1862 -0
  52. package/dist/chunk-5PJEXSOW.js +44 -0
  53. package/dist/chunk-5SXDH3Y7.js +90 -0
  54. package/dist/chunk-5YFBGGCK.mjs +502 -0
  55. package/dist/chunk-5YWN6H5Q.mjs +133 -0
  56. package/dist/chunk-66QP3SMN.js +402 -0
  57. package/dist/chunk-6DAEZKIG.mjs +385 -0
  58. package/dist/chunk-6DATW7TB.mjs +420 -0
  59. package/dist/{chunk-JRGK3NXR.mjs → chunk-6ETDAU62.mjs} +72 -212
  60. package/dist/chunk-6H254EVP.mjs +178 -0
  61. package/dist/chunk-6PFNJPBJ.mjs +820 -0
  62. package/dist/chunk-6PJWXIFX.mjs +357 -0
  63. package/dist/chunk-6SWKWCMS.js +80 -0
  64. package/dist/chunk-6VVXXX7S.js +808 -0
  65. package/dist/chunk-6WUBSMTX.js +1403 -0
  66. package/dist/chunk-73SGZLAQ.mjs +35 -0
  67. package/dist/chunk-76L2V6KD.mjs +4 -0
  68. package/dist/chunk-7AAIAVAA.js +1531 -0
  69. package/dist/chunk-7ARSJPV3.mjs +93 -0
  70. package/dist/chunk-7BHW5GTC.mjs +1234 -0
  71. package/dist/chunk-7DQSDKDU.js +6 -0
  72. package/dist/chunk-7IQQQENP.mjs +401 -0
  73. package/dist/chunk-7KFTYENS.js +11357 -0
  74. package/dist/chunk-7SM6XSPZ.js +3171 -0
  75. package/dist/chunk-7SXOHAIR.mjs +28 -0
  76. package/dist/chunk-A2MAX6S4.js +90 -0
  77. package/dist/chunk-A33OORT7.mjs +1530 -0
  78. package/dist/{chunk-U6ACF76H.mjs → chunk-A36JRXXH.mjs} +1075 -1845
  79. package/dist/chunk-A7BU3BK4.js +52 -0
  80. package/dist/chunk-A7MQSN2V.mjs +77 -0
  81. package/dist/chunk-A7V4L2IT.mjs +416 -0
  82. package/dist/chunk-AABEK6XU.js +226 -0
  83. package/dist/chunk-AGV33FWC.mjs +5005 -0
  84. package/dist/chunk-AHNR3BXI.js +108 -0
  85. package/dist/chunk-AQ5RLBU2.mjs +286 -0
  86. package/dist/chunk-AQOE6WCG.js +1270 -0
  87. package/dist/chunk-ATAWRACV.mjs +62 -0
  88. package/dist/chunk-ATCURNUV.js +14 -0
  89. package/dist/chunk-AWPV33OO.js +6 -0
  90. package/dist/chunk-AYJPHKYV.js +337 -0
  91. package/dist/chunk-AZ5BGWHB.js +162 -0
  92. package/dist/chunk-AZAXD44P.js +1373 -0
  93. package/dist/chunk-BBGKQIJJ.mjs +406 -0
  94. package/dist/chunk-BP4JLSUA.js +1453 -0
  95. package/dist/{chunk-SUCE7FWA.mjs → chunk-BTUSVHIE.mjs} +539 -978
  96. package/dist/chunk-BU6OK542.mjs +818 -0
  97. package/dist/chunk-CVSRWM6W.js +418 -0
  98. package/dist/chunk-CYBMFMJD.mjs +247 -0
  99. package/dist/chunk-DDJLDOUX.mjs +217 -0
  100. package/dist/{chunk-V32BCG7M.js → chunk-DFZWHNRG.js} +75 -215
  101. package/dist/chunk-DJ2C7AVG.js +644 -0
  102. package/dist/chunk-DS2VU4WW.mjs +102 -0
  103. package/dist/chunk-DSAG7T5P.js +7290 -0
  104. package/dist/chunk-E2QPPH7I.js +327 -0
  105. package/dist/chunk-E65WCTIG.mjs +1187 -0
  106. package/dist/{chunk-33VCYWVL.mjs → chunk-E6QQKDNE.mjs} +30 -42
  107. package/dist/chunk-ECDK6QBF.mjs +981 -0
  108. package/dist/chunk-EIB4OWVQ.mjs +620 -0
  109. package/dist/chunk-EQUZYCGO.js +250 -0
  110. package/dist/chunk-F3UJ6ZRM.mjs +313 -0
  111. package/dist/chunk-F63N2ZTQ.js +7023 -0
  112. package/dist/chunk-F6XRYEM3.mjs +26 -0
  113. package/dist/chunk-FE6VCE4K.js +5030 -0
  114. package/dist/chunk-FLWD6GRR.js +1372 -0
  115. package/dist/chunk-FQBFWJBS.mjs +110 -0
  116. package/dist/chunk-FXVJ2HFU.js +26 -0
  117. package/dist/chunk-FZMQMQBW.js +312 -0
  118. package/dist/chunk-G3EEC44R.js +53 -0
  119. package/dist/{chunk-KG3WT4PR.mjs → chunk-GCKWKLZF.mjs} +73 -104
  120. package/dist/chunk-GCX7TY4D.mjs +6826 -0
  121. package/dist/chunk-GDB6TCSD.js +450 -0
  122. package/dist/chunk-GDCV4IWO.mjs +21 -0
  123. package/dist/chunk-GDZT5LZ5.js +170 -0
  124. package/dist/chunk-GHPUYD4I.mjs +213 -0
  125. package/dist/chunk-GHS6MIL6.mjs +1432 -0
  126. package/dist/chunk-GPS2THCL.mjs +11 -0
  127. package/dist/{chunk-EV2EVOYS.js → chunk-GTJWQAGU.js} +31 -42
  128. package/dist/chunk-GVTI6UJQ.mjs +130 -0
  129. package/dist/chunk-GXKI64OT.mjs +1138 -0
  130. package/dist/chunk-GYDYF2WX.js +275 -0
  131. package/dist/chunk-GYLP6UG4.mjs +705 -0
  132. package/dist/chunk-H3OQKK6X.js +1158 -0
  133. package/dist/chunk-H5DFSCJ6.js +40 -0
  134. package/dist/chunk-HAGEIC2L.mjs +186 -0
  135. package/dist/chunk-HAJ4JRFO.js +293 -0
  136. package/dist/chunk-HDR72GB6.js +188 -0
  137. package/dist/chunk-HF5HPS4T.mjs +40 -0
  138. package/dist/chunk-HK6LOFDS.js +218 -0
  139. package/dist/chunk-HMWYTXCY.mjs +143 -0
  140. package/dist/chunk-HPCSRCMA.js +89 -0
  141. package/dist/chunk-HSEO6TPU.js +247 -0
  142. package/dist/chunk-I5FOHCLH.js +132 -0
  143. package/dist/chunk-IDLW4NWA.mjs +85 -0
  144. package/dist/chunk-IIDZ5WUX.js +61 -0
  145. package/dist/chunk-IR74FJHU.js +2332 -0
  146. package/dist/chunk-IRVFYAKP.mjs +100 -0
  147. package/dist/{chunk-XBL3TMPC.mjs → chunk-IZDWAL53.mjs} +1795 -3287
  148. package/dist/chunk-J2KZXIU3.js +51 -0
  149. package/dist/chunk-J2U6PJSO.js +91 -0
  150. package/dist/chunk-J5AJNY2N.js +283 -0
  151. package/dist/chunk-J6KQZ4FO.mjs +821 -0
  152. package/dist/{chunk-OWW5GUSB.js → chunk-JGBCIKJV.js} +7 -6
  153. package/dist/chunk-JKGTBMU7.mjs +25 -0
  154. package/dist/chunk-JR3TNEQC.js +422 -0
  155. package/dist/chunk-JURRXY2J.mjs +29 -0
  156. package/dist/chunk-K3HW5I2A.mjs +317 -0
  157. package/dist/chunk-K46SMZ66.mjs +103 -0
  158. package/dist/chunk-K4UDGE3Z.mjs +6 -0
  159. package/dist/chunk-KDQOR4QQ.mjs +350 -0
  160. package/dist/chunk-KDTVOLHI.mjs +288 -0
  161. package/dist/chunk-KGHJH5KJ.mjs +35 -0
  162. package/dist/chunk-KIZOA5LX.mjs +140 -0
  163. package/dist/chunk-KK6HYVBI.mjs +242 -0
  164. package/dist/chunk-KMKWGXMK.js +856 -0
  165. package/dist/chunk-KPA6K5IB.js +80 -0
  166. package/dist/chunk-KU7O4IXU.mjs +260 -0
  167. package/dist/chunk-KVFNRJOR.mjs +11142 -0
  168. package/dist/chunk-KZJRSXHK.js +2432 -0
  169. package/dist/chunk-LHWPRUJL.js +79 -0
  170. package/dist/chunk-LIV3KXJG.mjs +369 -0
  171. package/dist/chunk-LKV4LACG.js +21 -0
  172. package/dist/chunk-LUY45X3U.mjs +263 -0
  173. package/dist/chunk-LYEZZEEF.mjs +17 -0
  174. package/dist/chunk-M5EXQZYY.mjs +1519 -0
  175. package/dist/chunk-ME6HGG4I.mjs +1338 -0
  176. package/dist/chunk-MEXP6DA6.js +31 -0
  177. package/dist/chunk-MG52AW3H.js +902 -0
  178. package/dist/chunk-MIPO6F72.js +334 -0
  179. package/dist/{chunk-5QW7CQBA.js → chunk-MKIJQL5Q.js} +211 -321
  180. package/dist/chunk-MN3YETVN.mjs +17 -0
  181. package/dist/chunk-MOBSBXVE.mjs +2391 -0
  182. package/dist/chunk-MOMOZEUM.mjs +88 -0
  183. package/dist/chunk-MRFUNRAP.js +62 -0
  184. package/dist/chunk-MTIHEW2M.js +433 -0
  185. package/dist/chunk-N4RGGDEL.mjs +73 -0
  186. package/dist/chunk-NH654HAT.js +10 -0
  187. package/dist/chunk-NHJUGZUR.mjs +253 -0
  188. package/dist/chunk-NMQT4HG3.mjs +757 -0
  189. package/dist/chunk-NPSYB6DC.mjs +906 -0
  190. package/dist/chunk-NW2GPMSO.js +857 -0
  191. package/dist/chunk-NXKQOQ6L.js +76 -0
  192. package/dist/chunk-NXLAZIJZ.js +309 -0
  193. package/dist/chunk-NYWNA5CF.js +148 -0
  194. package/dist/chunk-NZTKLY2W.js +1442 -0
  195. package/dist/chunk-O2ICABUD.js +36 -0
  196. package/dist/chunk-OIVVQQ22.js +862 -0
  197. package/dist/chunk-OKC2B4O3.mjs +312 -0
  198. package/dist/chunk-OLWFPDBK.js +2220 -0
  199. package/dist/chunk-OMTVH334.js +3779 -0
  200. package/dist/chunk-OQRVEM56.mjs +362 -0
  201. package/dist/chunk-OXMIBOD4.js +337 -0
  202. package/dist/chunk-PBL6YL5L.mjs +288 -0
  203. package/dist/chunk-PDOELNNQ.js +97 -0
  204. package/dist/chunk-PDQJY2GZ.js +136 -0
  205. package/dist/chunk-PKOZXD2Q.js +1274 -0
  206. package/dist/chunk-PPF2BYFL.mjs +2191 -0
  207. package/dist/chunk-PQTQKNKD.js +539 -0
  208. package/dist/chunk-PRSR4FAV.mjs +81 -0
  209. package/dist/chunk-PTRNO5UD.js +95 -0
  210. package/dist/chunk-Q2Y3VMKH.js +2000 -0
  211. package/dist/chunk-QCZOE65N.js +96 -0
  212. package/dist/chunk-QDYFLATW.mjs +52 -0
  213. package/dist/chunk-QQABGCMM.js +22 -0
  214. package/dist/chunk-QS6TRHMR.js +345 -0
  215. package/dist/chunk-R56P64LB.mjs +208 -0
  216. package/dist/chunk-RCQ2MPBV.js +428 -0
  217. package/dist/chunk-RFVRPYR2.mjs +856 -0
  218. package/dist/chunk-RKBLPGPV.js +11521 -0
  219. package/dist/chunk-RM2V4IND.mjs +327 -0
  220. package/dist/chunk-RQXN5A34.mjs +613 -0
  221. package/dist/chunk-RUVGVNOF.mjs +2687 -0
  222. package/dist/chunk-SAFJIGYB.mjs +165 -0
  223. package/dist/chunk-SKQFLBDD.js +263 -0
  224. package/dist/chunk-SMK6JU2F.mjs +2092 -0
  225. package/dist/{chunk-UVRPC2P7.js → chunk-SNNEOS5Z.js} +1984 -3476
  226. package/dist/chunk-SPCRQ6NO.mjs +1246 -0
  227. package/dist/chunk-SWX4SALA.mjs +19 -0
  228. package/dist/{chunk-JVODCGFP.mjs → chunk-SYEO2WV4.mjs} +128 -238
  229. package/dist/chunk-T2QQMX2N.js +10 -0
  230. package/dist/chunk-T3AFF3L7.mjs +57 -0
  231. package/dist/chunk-T6Z2EXYL.js +712 -0
  232. package/dist/chunk-T7LOXGYX.js +118 -0
  233. package/dist/chunk-TJCAE7RC.mjs +1315 -0
  234. package/dist/chunk-TJI3K6RP.js +137 -0
  235. package/dist/chunk-TL2SVO4P.mjs +55 -0
  236. package/dist/chunk-TM63CYGN.mjs +399 -0
  237. package/dist/chunk-TU5RYTYU.mjs +13 -0
  238. package/dist/chunk-TVJZ4GPS.js +1553 -0
  239. package/dist/chunk-TWM6DLYF.js +371 -0
  240. package/dist/chunk-U63OC4TQ.js +30 -0
  241. package/dist/{chunk-L5GKVQVJ.js → chunk-U6BVSJZ6.js} +25 -57
  242. package/dist/chunk-U6UVWEAK.mjs +792 -0
  243. package/dist/chunk-UCEPNO6N.mjs +11048 -0
  244. package/dist/{chunk-ANT574FD.js → chunk-UCR5HRYM.js} +74 -105
  245. package/dist/chunk-UG5BTOTF.mjs +334 -0
  246. package/dist/chunk-UGH37BQW.mjs +157 -0
  247. package/dist/chunk-V7ZRH3PY.mjs +271 -0
  248. package/dist/chunk-VBGHBL3E.mjs +1394 -0
  249. package/dist/chunk-VRBDAS5I.js +920 -0
  250. package/dist/chunk-VVE3Y76O.js +230 -0
  251. package/dist/chunk-W65JIRI4.mjs +1182 -0
  252. package/dist/chunk-WHYKAT7G.js +62 -0
  253. package/dist/{chunk-YOIVZ6OA.mjs → chunk-WIZRUIZB.mjs} +25 -57
  254. package/dist/chunk-WKWTDZS7.js +385 -0
  255. package/dist/chunk-WLMINRC4.mjs +78 -0
  256. package/dist/chunk-WOF3AD3J.js +22 -0
  257. package/dist/chunk-WWKMOA76.js +1262 -0
  258. package/dist/chunk-X5A5FOWW.js +615 -0
  259. package/dist/chunk-X6CN6KQF.mjs +192 -0
  260. package/dist/chunk-XD2PMH46.mjs +517 -0
  261. package/dist/chunk-XJA2NGTI.mjs +88 -0
  262. package/dist/chunk-XJIHN3BY.mjs +8 -0
  263. package/dist/chunk-XK6UDWJS.js +203 -0
  264. package/dist/chunk-XPG3N5CF.mjs +415 -0
  265. package/dist/chunk-XVZ2NKSU.mjs +74 -0
  266. package/dist/chunk-XYP45OLE.js +117 -0
  267. package/dist/chunk-XZSDGZX6.mjs +301 -0
  268. package/dist/chunk-Y2EMGN4T.mjs +120 -0
  269. package/dist/chunk-Y3XWP5XW.mjs +298 -0
  270. package/dist/chunk-Y4K22JL6.js +228 -0
  271. package/dist/chunk-Y65LXQGA.mjs +3164 -0
  272. package/dist/chunk-Y66WVMO5.mjs +87 -0
  273. package/dist/chunk-Y7JWLB25.mjs +7280 -0
  274. package/dist/chunk-YCDXAJKU.js +175 -0
  275. package/dist/chunk-YRDQCCIS.js +152 -0
  276. package/dist/chunk-YV52DGSA.js +111 -0
  277. package/dist/chunk-YXGZQPUD.js +94 -0
  278. package/dist/chunk-Z3A3AFVU.mjs +102 -0
  279. package/dist/chunk-ZCY6YKKP.mjs +475 -0
  280. package/dist/chunk-ZEQHXVU5.js +215 -0
  281. package/dist/chunk-ZF7JCXCI.js +284 -0
  282. package/dist/chunk-ZJBRUH6V.js +29 -0
  283. package/dist/chunk-ZMIL4ZOA.js +365 -0
  284. package/dist/chunk-ZR5ULMN2.mjs +337 -0
  285. package/dist/chunk-ZXREOYOW.js +87 -0
  286. package/dist/{client-BSP9U1O1.d.mts → client-CX_WR0-J.d.mts} +2 -2
  287. package/dist/client-Dytx_ZTC.d.ts +230 -0
  288. package/dist/{client-B878xeAP.d.ts → client-dqOhP9Nc.d.ts} +2 -2
  289. package/dist/client-hTKbCuhG.d.mts +230 -0
  290. package/dist/clock-B-UAjkKa.d.mts +5 -0
  291. package/dist/clock-B-UAjkKa.d.ts +5 -0
  292. package/dist/config-BlXQluJR.d.mts +36 -0
  293. package/dist/config-BlXQluJR.d.ts +36 -0
  294. package/dist/courier-Cnn-edJ4.d.ts +95 -0
  295. package/dist/courier-FmGfkvIN.d.mts +95 -0
  296. package/dist/crowd-DdHFbqKK.d.ts +186 -0
  297. package/dist/crowd-hOVSAmA3.d.mts +186 -0
  298. package/dist/danfo-BEBapFlX.d.mts +146 -0
  299. package/dist/danfo-UQ_PTIIx.d.ts +146 -0
  300. package/dist/{elements-Bty6Qs_N.d.mts → elements-DdsRig-2.d.mts} +1548 -257
  301. package/dist/{elements-Bty6Qs_N.d.ts → elements-DdsRig-2.d.ts} +1548 -257
  302. package/dist/engines/godot.d.mts +56 -0
  303. package/dist/engines/godot.d.ts +56 -0
  304. package/dist/engines/godot.js +28 -0
  305. package/dist/engines/godot.mjs +3 -0
  306. package/dist/engines/wasm.d.mts +11 -0
  307. package/dist/engines/wasm.d.ts +11 -0
  308. package/dist/engines/wasm.js +178 -0
  309. package/dist/engines/wasm.mjs +176 -0
  310. package/dist/fallback-CrG_lTFk.d.mts +270 -0
  311. package/dist/fallback-CrG_lTFk.d.ts +270 -0
  312. package/dist/fallback-KDB4Y2CE.mjs +6 -0
  313. package/dist/fallback-Y26TQENE.js +19 -0
  314. package/dist/features-CZB4rmcD.d.mts +118 -0
  315. package/dist/features-CZB4rmcD.d.ts +118 -0
  316. package/dist/fit-BWiE7rgA.d.mts +44 -0
  317. package/dist/fit-DK0oT7zO.d.ts +44 -0
  318. package/dist/five-a-side-Bv1AOUy3.d.mts +115 -0
  319. package/dist/five-a-side-EC51SJY1.d.ts +115 -0
  320. package/dist/fluid-ARr0qUIL.d.ts +939 -0
  321. package/dist/fluid-DLlEj2cs.d.mts +939 -0
  322. package/dist/game/conformance.d.mts +84 -0
  323. package/dist/game/conformance.d.ts +84 -0
  324. package/dist/game/conformance.js +1025 -0
  325. package/dist/game/conformance.mjs +994 -0
  326. package/dist/game/heap.d.mts +40 -0
  327. package/dist/game/heap.d.ts +40 -0
  328. package/dist/game/heap.js +48 -0
  329. package/dist/game/heap.mjs +7 -0
  330. package/dist/game/kit/canvas.d.mts +240 -0
  331. package/dist/game/kit/canvas.d.ts +240 -0
  332. package/dist/game/kit/canvas.js +3566 -0
  333. package/dist/game/kit/canvas.mjs +1039 -0
  334. package/dist/game/kit/courier.d.mts +17 -0
  335. package/dist/game/kit/courier.d.ts +17 -0
  336. package/dist/game/kit/courier.js +66 -0
  337. package/dist/game/kit/courier.mjs +49 -0
  338. package/dist/game/kit/danfo.d.mts +11 -0
  339. package/dist/game/kit/danfo.d.ts +11 -0
  340. package/dist/game/kit/danfo.js +109 -0
  341. package/dist/game/kit/danfo.mjs +44 -0
  342. package/dist/game/kit/engine.d.mts +29 -0
  343. package/dist/game/kit/engine.d.ts +29 -0
  344. package/dist/game/kit/engine.js +183 -0
  345. package/dist/game/kit/engine.mjs +30 -0
  346. package/dist/game/kit/five-a-side.d.mts +11 -0
  347. package/dist/game/kit/five-a-side.d.ts +11 -0
  348. package/dist/game/kit/five-a-side.js +86 -0
  349. package/dist/game/kit/five-a-side.mjs +41 -0
  350. package/dist/game/kit/frontier.d.mts +344 -0
  351. package/dist/game/kit/frontier.d.ts +344 -0
  352. package/dist/game/kit/frontier.js +435 -0
  353. package/dist/game/kit/frontier.mjs +14 -0
  354. package/dist/game/kit/genesis.d.mts +752 -0
  355. package/dist/game/kit/genesis.d.ts +752 -0
  356. package/dist/game/kit/genesis.js +380 -0
  357. package/dist/game/kit/genesis.mjs +15 -0
  358. package/dist/game/kit/ludo.d.mts +15 -0
  359. package/dist/game/kit/ludo.d.ts +15 -0
  360. package/dist/game/kit/ludo.js +87 -0
  361. package/dist/game/kit/ludo.mjs +42 -0
  362. package/dist/game/kit/runner.d.mts +12 -0
  363. package/dist/game/kit/runner.d.ts +12 -0
  364. package/dist/game/kit/runner.js +83 -0
  365. package/dist/game/kit/runner.mjs +46 -0
  366. package/dist/game/kit/shootout.d.mts +13 -0
  367. package/dist/game/kit/shootout.d.ts +13 -0
  368. package/dist/game/kit/shootout.js +122 -0
  369. package/dist/game/kit/shootout.mjs +57 -0
  370. package/dist/game/kit/slots.d.mts +392 -0
  371. package/dist/game/kit/slots.d.ts +392 -0
  372. package/dist/game/kit/slots.js +215 -0
  373. package/dist/game/kit/slots.mjs +6 -0
  374. package/dist/game/kit/tycoon.d.mts +16 -0
  375. package/dist/game/kit/tycoon.d.ts +16 -0
  376. package/dist/game/kit/tycoon.js +145 -0
  377. package/dist/game/kit/tycoon.mjs +44 -0
  378. package/dist/game/kit/word.d.mts +11 -0
  379. package/dist/game/kit/word.d.ts +11 -0
  380. package/dist/game/kit/word.js +78 -0
  381. package/dist/game/kit/word.mjs +41 -0
  382. package/dist/game/kit/worlds.d.mts +18 -0
  383. package/dist/game/kit/worlds.d.ts +18 -0
  384. package/dist/game/kit/worlds.js +74 -0
  385. package/dist/game/kit/worlds.mjs +49 -0
  386. package/dist/game/kit.d.mts +53 -0
  387. package/dist/game/kit.d.ts +53 -0
  388. package/dist/game/kit.js +2610 -0
  389. package/dist/game/kit.mjs +101 -0
  390. package/dist/game/prepared.d.mts +14 -0
  391. package/dist/game/prepared.d.ts +14 -0
  392. package/dist/game/prepared.js +81 -0
  393. package/dist/game/prepared.mjs +32 -0
  394. package/dist/game-Bx8onkhX.d.mts +1451 -0
  395. package/dist/game-fgQy2YIm.d.ts +1451 -0
  396. package/dist/game-theme-CBTw1b_d.d.mts +35 -0
  397. package/dist/game-theme-Dg-ict5A.d.ts +35 -0
  398. package/dist/game.d.mts +3546 -0
  399. package/dist/game.d.ts +3546 -0
  400. package/dist/game.js +4455 -0
  401. package/dist/game.mjs +50 -0
  402. package/dist/graphics-C6YjWYvP.d.ts +5 -0
  403. package/dist/graphics-Dk2yQnYN.d.mts +5 -0
  404. package/dist/guest-DrsA00XD.d.mts +732 -0
  405. package/dist/guest-wIdfoT05.d.ts +732 -0
  406. package/dist/hit-stop-BKkVwTq7.d.mts +43 -0
  407. package/dist/hit-stop-D-8pPYnM.d.ts +43 -0
  408. package/dist/hot-Crn9XpHJ.d.ts +29 -0
  409. package/dist/hot-DH3nOhQD.d.mts +29 -0
  410. package/dist/{index-CQStGb3B.d.mts → index-6gkHMGAq.d.mts} +2 -2
  411. package/dist/index-B8ybCKJI.d.ts +41 -0
  412. package/dist/{index-DJwXmoaP.d.ts → index-B98Xac8e.d.ts} +2 -2
  413. package/dist/{index-B7oA_1XI.d.ts → index-B_ByTtIT.d.ts} +2 -2
  414. package/dist/index-DHjNHb1c.d.mts +41 -0
  415. package/dist/{index-DhUSTAhT.d.mts → index-DbAN_VQE.d.mts} +2 -2
  416. package/dist/index.d.mts +134 -24
  417. package/dist/index.d.ts +134 -24
  418. package/dist/index.js +407 -248
  419. package/dist/index.mjs +184 -58
  420. package/dist/interactives-authoring.d.mts +231 -0
  421. package/dist/interactives-authoring.d.ts +231 -0
  422. package/dist/interactives-authoring.js +1743 -0
  423. package/dist/interactives-authoring.mjs +1704 -0
  424. package/dist/interactives-canvas.global.js +148 -0
  425. package/dist/interactives-guest.d.mts +20 -0
  426. package/dist/interactives-guest.d.ts +20 -0
  427. package/dist/interactives-guest.js +63 -0
  428. package/dist/interactives-guest.json +1 -0
  429. package/dist/interactives-guest.mjs +61 -0
  430. package/dist/interactives-jsc.global.js +9357 -0
  431. package/dist/interactives-meters.d.mts +93 -0
  432. package/dist/interactives-meters.d.ts +93 -0
  433. package/dist/interactives-meters.js +252 -0
  434. package/dist/interactives-meters.mjs +68 -0
  435. package/dist/interactives-production.d.mts +430 -0
  436. package/dist/interactives-production.d.ts +430 -0
  437. package/dist/interactives-production.js +1231 -0
  438. package/dist/interactives-production.mjs +1170 -0
  439. package/dist/interactives-record.d.mts +112 -0
  440. package/dist/interactives-record.d.ts +112 -0
  441. package/dist/interactives-record.js +302 -0
  442. package/dist/interactives-record.mjs +295 -0
  443. package/dist/interactives-runtime.d.mts +61 -0
  444. package/dist/interactives-runtime.d.ts +61 -0
  445. package/dist/interactives-runtime.js +442 -0
  446. package/dist/interactives-runtime.mjs +25 -0
  447. package/dist/interactives-studio-kernel.global.js +1 -0
  448. package/dist/interactives-studio.d.mts +806 -0
  449. package/dist/interactives-studio.d.ts +806 -0
  450. package/dist/interactives-studio.js +5741 -0
  451. package/dist/interactives-studio.mjs +5651 -0
  452. package/dist/interactives-tick.d.mts +90 -0
  453. package/dist/interactives-tick.d.ts +90 -0
  454. package/dist/interactives-tick.js +203 -0
  455. package/dist/interactives-tick.mjs +6 -0
  456. package/dist/interactives-web.d.mts +762 -0
  457. package/dist/interactives-web.d.ts +762 -0
  458. package/dist/interactives-web.js +5000 -0
  459. package/dist/interactives-web.mjs +4628 -0
  460. package/dist/interactives.d.mts +2430 -0
  461. package/dist/interactives.d.ts +2430 -0
  462. package/dist/interactives.js +5723 -0
  463. package/dist/interactives.mjs +4333 -0
  464. package/dist/juice-CoHxlpKA.d.ts +42 -0
  465. package/dist/juice-DQztFS43.d.mts +42 -0
  466. package/dist/launch-T2f4_Di4.d.mts +151 -0
  467. package/dist/launch-d6oreMzR.d.ts +151 -0
  468. package/dist/library-DXYaMFhi.d.mts +69 -0
  469. package/dist/library-DXYaMFhi.d.ts +69 -0
  470. package/dist/link-BUTqGmyi.d.mts +38 -0
  471. package/dist/link-BUTqGmyi.d.ts +38 -0
  472. package/dist/lint.js +104 -204
  473. package/dist/lint.mjs +103 -203
  474. package/dist/local-D8_I6UeL.d.mts +6967 -0
  475. package/dist/local-VZkqsCzR.d.ts +6967 -0
  476. package/dist/lockstep-BLf6dglI.d.mts +321 -0
  477. package/dist/lockstep-D50Ia0JW.d.ts +321 -0
  478. package/dist/ludo-B8ClkDqr.d.ts +205 -0
  479. package/dist/ludo-BOuohQ-M.d.mts +205 -0
  480. package/dist/mock/cli.mjs +200 -56
  481. package/dist/mock/library.js +200 -56
  482. package/dist/mock/library.mjs +200 -56
  483. package/dist/mock/msw.js +200 -56
  484. package/dist/mock/msw.mjs +200 -56
  485. package/dist/native-BodxSh03.d.mts +16 -0
  486. package/dist/native-DUHMT8gA.d.ts +16 -0
  487. package/dist/network-ZXLD7l1b.d.mts +19 -0
  488. package/dist/network-ZXLD7l1b.d.ts +19 -0
  489. package/dist/online-XeymeM9s.d.ts +381 -0
  490. package/dist/online-d7W_Al9a.d.mts +381 -0
  491. package/dist/params-DxFb5G_U.d.mts +155 -0
  492. package/dist/params-DxFb5G_U.d.ts +155 -0
  493. package/dist/play-BRRlfLhX.d.ts +940 -0
  494. package/dist/play-ClrMd_e8.d.mts +940 -0
  495. package/dist/policy-CCw8tXLm.d.mts +3078 -0
  496. package/dist/policy-CMqOSQIu.d.ts +3078 -0
  497. package/dist/ports-B_0v_P3A.d.mts +13 -0
  498. package/dist/ports-CGU_3e_0.d.ts +13 -0
  499. package/dist/prefetch-BHnicOQj.d.ts +117 -0
  500. package/dist/prefetch-CBXgYacv.d.mts +117 -0
  501. package/dist/{price-CSztR02F.d.mts → price-BOzexBww.d.mts} +1 -1
  502. package/dist/{price-C_vasx9A.d.ts → price-C1h9sPxE.d.ts} +1 -1
  503. package/dist/protocol-C8qbpUbT.d.mts +242 -0
  504. package/dist/protocol-C8qbpUbT.d.ts +242 -0
  505. package/dist/rapier-AZHT4YI7.js +7886 -0
  506. package/dist/rapier-ODEPCQA6.mjs +7792 -0
  507. package/dist/react.d.mts +157 -15
  508. package/dist/react.d.ts +157 -15
  509. package/dist/react.js +5564 -5904
  510. package/dist/react.mjs +5451 -5808
  511. package/dist/runner-CQcLL7By.d.ts +189 -0
  512. package/dist/runner-D46Yj-wE.d.mts +189 -0
  513. package/dist/runtime-BRWfkf_q.d.mts +51 -0
  514. package/dist/runtime-DyuBMkKM.d.ts +51 -0
  515. package/dist/scheduling-D2ajXpMC.d.ts +224 -0
  516. package/dist/scheduling-DSRbbaZb.d.mts +224 -0
  517. package/dist/schema-BrWxzKp6.d.mts +63 -0
  518. package/dist/schema-BrWxzKp6.d.ts +63 -0
  519. package/dist/server/evict.js +34 -37
  520. package/dist/server/evict.mjs +34 -37
  521. package/dist/server/tanstack.d.mts +49 -3
  522. package/dist/server/tanstack.d.ts +49 -3
  523. package/dist/server/tanstack.js +169 -117
  524. package/dist/server/tanstack.mjs +166 -118
  525. package/dist/{server-Dckg4Vdr.d.ts → server-D29IIuDV.d.ts} +136 -130
  526. package/dist/{server-B6dW7-Lj.d.mts → server-DQMWPnc8.d.mts} +136 -130
  527. package/dist/server.d.mts +45 -5
  528. package/dist/server.d.ts +45 -5
  529. package/dist/server.js +171 -227
  530. package/dist/server.mjs +165 -225
  531. package/dist/session-grant-CJ27DwrT.d.mts +19 -0
  532. package/dist/session-grant-CJ27DwrT.d.ts +19 -0
  533. package/dist/shootout-BJZeX6FG.d.ts +140 -0
  534. package/dist/shootout-tcZd1Rxt.d.mts +140 -0
  535. package/dist/state-replica-stMtdkVD.d.mts +42 -0
  536. package/dist/state-replica-stMtdkVD.d.ts +42 -0
  537. package/dist/studio-CowqWqez.d.mts +14 -0
  538. package/dist/studio-CowqWqez.d.ts +14 -0
  539. package/dist/styles.css +1 -1
  540. package/dist/template-AhCdB1kW.d.mts +190 -0
  541. package/dist/template-BkEGVTQj.d.ts +190 -0
  542. package/dist/terrain-BMxEc6Oc.d.ts +429 -0
  543. package/dist/terrain-C-XC1Oui.d.mts +429 -0
  544. package/dist/testing/msw.d.mts +28 -4
  545. package/dist/testing/msw.d.ts +28 -4
  546. package/dist/testing/msw.js +15 -21
  547. package/dist/testing/msw.mjs +15 -21
  548. package/dist/testing/suite.d.mts +6 -5
  549. package/dist/testing/suite.d.ts +6 -5
  550. package/dist/testing/suite.js +89 -124
  551. package/dist/testing/suite.mjs +81 -116
  552. package/dist/testing.d.mts +27 -1227
  553. package/dist/testing.d.ts +27 -1227
  554. package/dist/testing.js +127 -131
  555. package/dist/testing.mjs +19 -23
  556. package/dist/tick-transport-C8QEh8Uw.d.mts +50 -0
  557. package/dist/tick-transport-UjHY3xK1.d.ts +50 -0
  558. package/dist/timeline-protocol-hp6e8zFB.d.mts +47 -0
  559. package/dist/timeline-protocol-hp6e8zFB.d.ts +47 -0
  560. package/dist/tokens-DhanQRQS.d.mts +21 -0
  561. package/dist/tokens-K8yxwd6G.d.ts +21 -0
  562. package/dist/tree-C-Io2Hbx.d.mts +35 -0
  563. package/dist/tree-CP_qSW4H.d.ts +35 -0
  564. package/dist/tycoon-B5KHk2Xx.d.mts +255 -0
  565. package/dist/tycoon-hmHo-3HX.d.ts +255 -0
  566. package/dist/types-BQkxPwZP.d.mts +219 -0
  567. package/dist/types-D_f6UUxM.d.ts +219 -0
  568. package/dist/ui-DwHicuFv.d.mts +563 -0
  569. package/dist/ui-hi7S2YcH.d.ts +563 -0
  570. package/dist/{sign-in-DQlIdqsi.d.mts → url-52ndUruG.d.mts} +15 -1
  571. package/dist/{sign-in-DQlIdqsi.d.ts → url-52ndUruG.d.ts} +15 -1
  572. package/dist/utils.d.mts +3 -3
  573. package/dist/utils.d.ts +3 -3
  574. package/dist/utils.js +37 -37
  575. package/dist/utils.mjs +4 -4
  576. package/dist/vars-Dc_PrhBK.d.mts +511 -0
  577. package/dist/vars-Dc_PrhBK.d.ts +511 -0
  578. package/dist/vm-IUARFFAI.mjs +63 -0
  579. package/dist/vm-N7L6MGGH.js +65 -0
  580. package/dist/weave-delivery-CW-Kstut.d.mts +360 -0
  581. package/dist/weave-delivery-CW-Kstut.d.ts +360 -0
  582. package/dist/web-Dss74a7v.d.ts +883 -0
  583. package/dist/web-f9ZQPoyw.d.mts +883 -0
  584. package/dist/web-transport-C7MkBL0a.d.ts +19 -0
  585. package/dist/web-transport-aYEqXMd9.d.mts +19 -0
  586. package/dist/weight-CPGjsgjV.d.ts +92 -0
  587. package/dist/weight-tF1ODR1p.d.mts +92 -0
  588. package/dist/word-BcX9Jcmv.d.mts +70 -0
  589. package/dist/word-C7sVPLHm.d.ts +70 -0
  590. package/dist/world-PvILHDR1.d.ts +2285 -0
  591. package/dist/world-qekkXjJv.d.mts +2285 -0
  592. package/dist/worlds-Br2Pb0Cs.d.ts +109 -0
  593. package/dist/worlds-D5ydYr7d.d.mts +109 -0
  594. package/engines/c/cimplify.h +108 -0
  595. package/engines/c/cimplify.lib.js +11 -0
  596. package/engines/godot/addons/cimplify/cimplify.gd +97 -0
  597. package/engines/rust/interactives-ctx/Cargo.toml +9 -0
  598. package/engines/rust/interactives-ctx/src/lib.rs +189 -0
  599. package/package.json +189 -3
  600. package/vendor/rapier3d-compat/LICENSE +201 -0
  601. package/vendor/rapier3d-compat/PATCHES.md +61 -0
  602. package/dist/chunk-2P4KXFB6.js +0 -274
  603. package/dist/chunk-3G6RQLXK.mjs +0 -21
  604. package/dist/chunk-3V4DVXV3.mjs +0 -254
  605. package/dist/chunk-EDK3LNM6.js +0 -2436
  606. package/dist/chunk-F7J3HK27.js +0 -4549
  607. package/dist/chunk-U4MW6PYU.mjs +0 -23
  608. package/dist/chunk-XREIZ56K.js +0 -26
@@ -0,0 +1,1553 @@
1
+ 'use strict';
2
+
3
+ var chunkQCZOE65N_js = require('./chunk-QCZOE65N.js');
4
+ var chunk66QP3SMN_js = require('./chunk-66QP3SMN.js');
5
+ var chunkWWKMOA76_js = require('./chunk-WWKMOA76.js');
6
+
7
+ // src/interactives/rooms/connect.ts
8
+ var Connecting = {
9
+ Idle: 0,
10
+ Pending: 1,
11
+ Won: 2,
12
+ Failed: 3
13
+ }, Settled = {
14
+ Waiting: 0,
15
+ Dialed: 1,
16
+ Failed: 2
17
+ }, Attempt = class {
18
+ constructor(dialer, race) {
19
+ this.settled = Settled.Waiting;
20
+ this.dialed = null;
21
+ this.done = (dialed) => {
22
+ this.dialed = dialed, this.settled = dialed ? Settled.Dialed : Settled.Failed, this.race.settled(this);
23
+ };
24
+ this.failed = () => {
25
+ this.done(null);
26
+ };
27
+ this.dialer = dialer, this.race = race;
28
+ }
29
+ start(request) {
30
+ this.dialer.dial(request, this).then(this.done, this.failed);
31
+ }
32
+ frame(lane, bytes) {
33
+ this.race.forward(this, lane, bytes);
34
+ }
35
+ closed() {
36
+ this.race.lost(this);
37
+ }
38
+ backpressure(failures, status) {
39
+ this.race.backpressure(this, failures, status);
40
+ }
41
+ }, Connector = class {
42
+ constructor(primary, fallback, memory, network) {
43
+ this.sink = null;
44
+ this.request = null;
45
+ this.first = null;
46
+ this.second = null;
47
+ this.won = null;
48
+ this.networkKey = "";
49
+ this.startedAt = 0;
50
+ this.lastNow = 0;
51
+ this.state = Connecting.Idle;
52
+ this.primary = primary, this.fallback = fallback, this.memory = memory, this.network = network;
53
+ }
54
+ get winner() {
55
+ return this.won?.dialed ?? null;
56
+ }
57
+ begin(request, sink, nowMs) {
58
+ this.cancel(), this.sink = sink, this.request = request, this.startedAt = nowMs, this.lastNow = nowMs, this.state = Connecting.Pending, this.networkKey = this.network();
59
+ let remembered = this.memory.recall(this.networkKey, nowMs), opener = this.fallback !== null && remembered === this.fallback.transport || !this.primary ? this.fallback : this.primary;
60
+ if (!opener) {
61
+ this.state = Connecting.Failed;
62
+ return;
63
+ }
64
+ this.first = new Attempt(opener, this), opener === this.fallback && (this.second = this.first), this.first.start(request);
65
+ }
66
+ poll(nowMs) {
67
+ if (this.lastNow = nowMs, this.state !== Connecting.Pending) return this.state;
68
+ let elapsed = nowMs - this.startedAt;
69
+ return !this.second && this.fallback && (elapsed >= chunkQCZOE65N_js.FALLBACK_AFTER_MS || this.first?.settled === Settled.Failed) && this.launchFallback(), this.state === Connecting.Pending && (elapsed >= chunkQCZOE65N_js.CONNECT_TIMEOUT_MS || this.exhausted()) && this.fail(), this.state;
70
+ }
71
+ cancel() {
72
+ for (let attempt of [this.first, this.second]) attempt?.dialed?.link.close();
73
+ this.first = null, this.second = null, this.won = null, this.sink = null, this.state = Connecting.Idle;
74
+ }
75
+ release() {
76
+ let dialed = this.winner;
77
+ return this.first = null, this.second = null, this.state = Connecting.Idle, dialed;
78
+ }
79
+ forward(attempt, lane, bytes) {
80
+ attempt === this.won && this.sink?.frame(lane, bytes);
81
+ }
82
+ lost(attempt) {
83
+ attempt === this.won && this.sink?.closed();
84
+ }
85
+ backpressure(attempt, failures, status) {
86
+ attempt === this.won && this.sink?.backpressure?.(failures, status);
87
+ }
88
+ settled(attempt) {
89
+ if (attempt !== this.first && attempt !== this.second) {
90
+ attempt.dialed?.link.close();
91
+ return;
92
+ }
93
+ if (attempt.settled !== Settled.Dialed) return;
94
+ if (this.won) {
95
+ attempt !== this.won && attempt.dialed?.link.close();
96
+ return;
97
+ }
98
+ this.won = attempt, this.state = Connecting.Won;
99
+ let loser = attempt === this.first ? this.second : this.first;
100
+ loser && loser !== attempt && loser.dialed?.link.close(), this.primary && this.fallback && this.memory.remember(this.networkKey, attempt.dialer.transport, this.lastNow);
101
+ }
102
+ launchFallback() {
103
+ !this.fallback || !this.request || (this.second = new Attempt(this.fallback, this), this.second.start(this.request));
104
+ }
105
+ exhausted() {
106
+ let firstDone = !this.first || this.first.settled === Settled.Failed, secondDone = this.second ? this.second.settled === Settled.Failed : !this.fallback;
107
+ return firstDone && secondDone;
108
+ }
109
+ fail() {
110
+ let sink = this.sink;
111
+ this.cancel(), this.sink = sink, this.state = Connecting.Failed;
112
+ }
113
+ };
114
+
115
+ // src/interactives/rooms/join.ts
116
+ var JoinStatus = {
117
+ Admitted: 0,
118
+ Malformed: 1,
119
+ Forged: 2,
120
+ Expired: 3,
121
+ UnknownResume: 4,
122
+ Full: 5,
123
+ Overloaded: 6,
124
+ Unavailable: 7,
125
+ Prewarmed: 8,
126
+ Denied: 9
127
+ }, LAST_STATUS = JoinStatus.Denied, LITTLE_ENDIAN = true;
128
+ function blankReply() {
129
+ return {
130
+ status: JoinStatus.Unavailable,
131
+ slot: 0,
132
+ route: 0,
133
+ resume: new Uint8Array(chunkQCZOE65N_js.RESUME_TOKEN_BYTES),
134
+ simulationHz: 0,
135
+ sendHz: 0,
136
+ tick: 0
137
+ };
138
+ }
139
+ function joinRequest(kind, body, version) {
140
+ if (chunkQCZOE65N_js.JOIN_HEADER_BYTES + body.length > chunkQCZOE65N_js.MAX_JOIN_BYTES) throw new RangeError("the join request is too large");
141
+ let out = new Uint8Array(chunkQCZOE65N_js.JOIN_HEADER_BYTES + body.length), view = new DataView(out.buffer);
142
+ return view.setUint8(0, version), view.setUint8(1, kind), view.setUint16(2, body.length, (true)), out.set(body, chunkQCZOE65N_js.JOIN_HEADER_BYTES), out;
143
+ }
144
+ function ticketRequest(ticket, version = chunkQCZOE65N_js.JOIN_VERSION_DELTA) {
145
+ return joinRequest(chunkQCZOE65N_js.JOIN_TICKET, ticket, version);
146
+ }
147
+ function resumeRequest(token, version = chunkQCZOE65N_js.JOIN_VERSION_DELTA) {
148
+ return joinRequest(chunkQCZOE65N_js.JOIN_RESUME, token, version);
149
+ }
150
+ function withoutDeltaPresence(request) {
151
+ return request.length === 0 || request[0] !== chunkQCZOE65N_js.JOIN_VERSION_DELTA ? false : (request[0] = chunkQCZOE65N_js.JOIN_VERSION, true);
152
+ }
153
+ function decodeJoinReply(bytes, out) {
154
+ if (bytes.length !== chunkQCZOE65N_js.JOIN_REPLY_BYTES) return false;
155
+ let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
156
+ if (view.getUint8(0) !== chunkQCZOE65N_js.JOIN_VERSION) return false;
157
+ let status = view.getUint8(1);
158
+ return status > LAST_STATUS ? false : (out.status = status, out.slot = view.getUint16(2, (true)), out.route = view.getUint32(4, (true)), out.resume.set(bytes.subarray(8, 8 + chunkQCZOE65N_js.RESUME_TOKEN_BYTES)), out.simulationHz = view.getUint16(24, (true)), out.sendHz = view.getUint16(26, (true)), out.tick = view.getUint32(32, (true)) * chunkQCZOE65N_js.U32_RANGE + view.getUint32(28, (true)), true);
159
+ }
160
+
161
+ // src/interactives/rooms/locomotion.ts
162
+ var FRACTION_BITS = BigInt(24), LIMIT_SQUARED = chunkQCZOE65N_js.AXIS_LIMIT * chunkQCZOE65N_js.AXIS_LIMIT;
163
+ function perAxisUnit(unitsPerSecond, stepNs) {
164
+ let scaled = BigInt(unitsPerSecond) * BigInt(stepNs) << FRACTION_BITS, divisor = BigInt(chunkQCZOE65N_js.AXIS_LIMIT) * BigInt(chunkQCZOE65N_js.NANOS_PER_SECOND);
165
+ return Number(scaled / divisor);
166
+ }
167
+ function isqrt(value) {
168
+ let root = Math.floor(Math.sqrt(value));
169
+ for (; root * root > value; ) root -= 1;
170
+ for (; (root + 1) * (root + 1) <= value; ) root += 1;
171
+ return root;
172
+ }
173
+ function spawn(body, slot) {
174
+ body.x = chunkQCZOE65N_js.SPAWN_ORIGIN_UNITS + slot % chunkQCZOE65N_js.SPAWN_ROW * chunkQCZOE65N_js.SPAWN_SPACING_UNITS, body.z = chunkQCZOE65N_js.SPAWN_ORIGIN_UNITS + Math.floor(slot / chunkQCZOE65N_js.SPAWN_ROW) * chunkQCZOE65N_js.SPAWN_SPACING_UNITS, body.axisX = 0, body.axisZ = 0, body.buttons = 0;
175
+ }
176
+ function steer(body, axisX, axisZ, buttons) {
177
+ let x = Math.max(axisX, -chunkQCZOE65N_js.AXIS_LIMIT), z = Math.max(axisZ, -chunkQCZOE65N_js.AXIS_LIMIT), magnitudeSquared = x * x + z * z;
178
+ if (magnitudeSquared <= LIMIT_SQUARED)
179
+ body.axisX = x, body.axisZ = z;
180
+ else {
181
+ let magnitude = isqrt(magnitudeSquared);
182
+ body.axisX = Math.trunc(x * chunkQCZOE65N_js.AXIS_LIMIT / magnitude), body.axisZ = Math.trunc(z * chunkQCZOE65N_js.AXIS_LIMIT / magnitude);
183
+ }
184
+ body.buttons = buttons;
185
+ }
186
+ function clampUnits(value) {
187
+ return value < 0 ? 0 : value > chunkQCZOE65N_js.CELL_MAX_UNITS ? chunkQCZOE65N_js.CELL_MAX_UNITS : value;
188
+ }
189
+ var Locomotion = class {
190
+ constructor(simulationHz, physicsHz) {
191
+ this.substeps = Math.ceil(physicsHz / simulationHz), this.stepNs = Math.floor(chunkQCZOE65N_js.NANOS_PER_SECOND / (simulationHz * this.substeps)), this.walk = perAxisUnit(chunkQCZOE65N_js.WALK_UNITS_PER_SECOND, this.stepNs), this.sprint = perAxisUnit(chunkQCZOE65N_js.SPRINT_UNITS_PER_SECOND, this.stepNs);
192
+ }
193
+ step(body) {
194
+ let scale = (body.buttons & chunkQCZOE65N_js.BUTTON_SPRINT) !== 0 ? this.sprint : this.walk, stepX = Math.floor(body.axisX * scale / chunkQCZOE65N_js.VELOCITY_FRACTION), stepZ = Math.floor(body.axisZ * scale / chunkQCZOE65N_js.VELOCITY_FRACTION);
195
+ body.x = clampUnits(body.x + stepX * this.substeps), body.z = clampUnits(body.z + stepZ * this.substeps);
196
+ }
197
+ };
198
+
199
+ // src/interactives/rooms/motion.ts
200
+ var EXACT = 0, LocomotionMotion = class {
201
+ constructor(simulationHz, physicsHz) {
202
+ this.toleranceUnits = (0);
203
+ this.body = { x: 0, z: 0, axisX: 0, axisZ: 0, buttons: 0 };
204
+ this.locomotion = new Locomotion(simulationHz, physicsHz);
205
+ }
206
+ get x() {
207
+ return this.body.x;
208
+ }
209
+ get y() {
210
+ return 0;
211
+ }
212
+ get z() {
213
+ return this.body.z;
214
+ }
215
+ spawn(slot) {
216
+ spawn(this.body, slot);
217
+ }
218
+ steer(axisX, axisZ, buttons) {
219
+ steer(this.body, axisX, axisZ, buttons);
220
+ }
221
+ step() {
222
+ this.locomotion.step(this.body);
223
+ }
224
+ place(x, _y, z) {
225
+ this.body.x = x, this.body.z = z;
226
+ }
227
+ }, locomotionMotion = (simulationHz, physicsHz) => new LocomotionMotion(simulationHz, physicsHz);
228
+
229
+ // src/interactives/rooms/link.ts
230
+ var Transport = {
231
+ WebTransport: "web_transport",
232
+ WebSocket: "web_socket"
233
+ };
234
+
235
+ // src/interactives/rooms/network-memory.ts
236
+ function known(value) {
237
+ return value === Transport.WebTransport || value === Transport.WebSocket;
238
+ }
239
+ function fresh(remembered, nowMs) {
240
+ return !remembered || nowMs - remembered.at > chunkQCZOE65N_js.NETWORK_MEMORY_TTL_MS ? null : remembered.transport;
241
+ }
242
+ var InMemoryNetworkMemory = class {
243
+ constructor() {
244
+ this.entries = /* @__PURE__ */ new Map();
245
+ }
246
+ recall(network, nowMs) {
247
+ return fresh(this.entries.get(network), nowMs);
248
+ }
249
+ remember(network, transport, nowMs) {
250
+ this.entries.set(network, { transport, at: nowMs });
251
+ }
252
+ }, StorageNetworkMemory = class {
253
+ constructor() {
254
+ this.fallback = new InMemoryNetworkMemory();
255
+ }
256
+ recall(network, nowMs) {
257
+ try {
258
+ let raw = globalThis.localStorage?.getItem(chunkQCZOE65N_js.NETWORK_MEMORY_PREFIX + network);
259
+ if (!raw) return this.fallback.recall(network, nowMs);
260
+ let parsed = JSON.parse(raw);
261
+ if (typeof parsed != "object" || parsed === null) return null;
262
+ let entry = parsed;
263
+ return !known(entry.transport) || typeof entry.at != "number" ? null : fresh({ transport: entry.transport, at: entry.at }, nowMs);
264
+ } catch {
265
+ return this.fallback.recall(network, nowMs);
266
+ }
267
+ }
268
+ remember(network, transport, nowMs) {
269
+ this.fallback.remember(network, transport, nowMs);
270
+ try {
271
+ globalThis.localStorage?.setItem(chunkQCZOE65N_js.NETWORK_MEMORY_PREFIX + network, JSON.stringify({ transport, at: nowMs }));
272
+ } catch {
273
+ return;
274
+ }
275
+ }
276
+ };
277
+ function currentNetwork() {
278
+ let connection = globalThis.navigator?.connection;
279
+ return connection?.type ?? connection?.effectiveType ?? chunkQCZOE65N_js.DEFAULT_NETWORK;
280
+ }
281
+
282
+ // src/interactives/rooms/clock-sync.ts
283
+ var ClockSync = class {
284
+ constructor() {
285
+ this.tickMs = 0;
286
+ this.sendIntervalMs = 0;
287
+ this.offsets = new Float64Array(chunkQCZOE65N_js.OFFSET_WINDOW);
288
+ this.rtts = new Float64Array(chunkQCZOE65N_js.RTT_WINDOW);
289
+ this.offsetCount = 0;
290
+ this.offsetNext = 0;
291
+ this.rttCount = 0;
292
+ this.rttNext = 0;
293
+ this.offsetMs = 0;
294
+ this.jitter = 0;
295
+ this.smoothedRtt = 0;
296
+ this.delay = 0;
297
+ }
298
+ configure(simulationHz, sendHz, handshakeRttMs) {
299
+ this.tickMs = chunkQCZOE65N_js.MS_PER_SECOND / simulationHz, this.sendIntervalMs = chunkQCZOE65N_js.MS_PER_SECOND / sendHz, this.offsetCount = 0, this.offsetNext = 0, this.rttCount = 0, this.rttNext = 0, this.jitter = 0, this.offsetMs = 0, this.smoothedRtt = handshakeRttMs, this.delay = chunkQCZOE65N_js.INTERPOLATION_SEND_INTERVALS * this.sendIntervalMs;
300
+ }
301
+ get tickIntervalMs() {
302
+ return this.tickMs;
303
+ }
304
+ get rttMs() {
305
+ return this.smoothedRtt;
306
+ }
307
+ get jitterMs() {
308
+ return this.jitter;
309
+ }
310
+ get interpolationDelayMs() {
311
+ return this.delay;
312
+ }
313
+ get synchronised() {
314
+ return this.offsetCount > 0;
315
+ }
316
+ snapshot(serverTick, nowMs) {
317
+ let sample = serverTick * this.tickMs - nowMs;
318
+ this.offsets[this.offsetNext] = sample, this.offsetNext = (this.offsetNext + 1) % chunkQCZOE65N_js.OFFSET_WINDOW, this.offsetCount < chunkQCZOE65N_js.OFFSET_WINDOW && (this.offsetCount += 1);
319
+ let best = sample;
320
+ for (let index = 0; index < this.offsetCount; index++) this.offsets[index] > best && (best = this.offsets[index]);
321
+ this.offsetMs = best, this.jitter += (best - sample - this.jitter) * chunkQCZOE65N_js.JITTER_SMOOTHING;
322
+ let target = Math.min(
323
+ chunkQCZOE65N_js.INTERPOLATION_SEND_INTERVALS * this.sendIntervalMs + chunkQCZOE65N_js.JITTER_MULTIPLIER * this.jitter,
324
+ chunkQCZOE65N_js.MAX_INTERPOLATION_DELAY_MS
325
+ );
326
+ this.delay += (target - this.delay) * chunkQCZOE65N_js.DELAY_SMOOTHING;
327
+ }
328
+ roundTrip(sampleMs) {
329
+ if (!(sampleMs >= 0)) return;
330
+ this.rtts[this.rttNext] = sampleMs, this.rttNext = (this.rttNext + 1) % chunkQCZOE65N_js.RTT_WINDOW, this.rttCount < chunkQCZOE65N_js.RTT_WINDOW && (this.rttCount += 1);
331
+ let lowest = sampleMs;
332
+ for (let index = 0; index < this.rttCount; index++) this.rtts[index] < lowest && (lowest = this.rtts[index]);
333
+ this.smoothedRtt += (lowest - this.smoothedRtt) * chunkQCZOE65N_js.RTT_SMOOTHING;
334
+ }
335
+ serverTick(nowMs) {
336
+ return (nowMs + this.offsetMs) / this.tickMs;
337
+ }
338
+ renderTick(nowMs) {
339
+ return (nowMs + this.offsetMs - this.delay) / this.tickMs;
340
+ }
341
+ leadTicks() {
342
+ return this.smoothedRtt / 2 / this.tickMs;
343
+ }
344
+ };
345
+
346
+ // src/interactives/rooms/inbound.ts
347
+ var InboundQueue = class {
348
+ constructor() {
349
+ this.pool = new chunk66QP3SMN_js.FrameBufferPool(chunkQCZOE65N_js.INBOUND_POOL_SLOTS, chunkQCZOE65N_js.PACKET_BYTES);
350
+ this.slots = new Int32Array(chunkQCZOE65N_js.INBOUND_POOL_SLOTS);
351
+ this.lanes = new Uint8Array(chunkQCZOE65N_js.INBOUND_POOL_SLOTS);
352
+ this.lengths = new Int32Array(chunkQCZOE65N_js.INBOUND_POOL_SLOTS);
353
+ this.head = 0;
354
+ this.count = 0;
355
+ this.current = -1;
356
+ this.dropped = 0;
357
+ this.sendFailures = 0;
358
+ this.lastSendStatus = 0;
359
+ this.lost = false;
360
+ }
361
+ clear() {
362
+ for (this.release(); this.count > 0; )
363
+ this.pool.release(this.slots[this.head]), this.head = (this.head + 1) % chunkQCZOE65N_js.INBOUND_POOL_SLOTS, this.count -= 1;
364
+ this.lost = false;
365
+ }
366
+ frame(lane, bytes) {
367
+ if (bytes.length > chunkQCZOE65N_js.PACKET_BYTES || this.count === chunkQCZOE65N_js.INBOUND_POOL_SLOTS) {
368
+ this.dropped += 1;
369
+ return;
370
+ }
371
+ let slot = this.pool.acquire();
372
+ if (slot < 0) {
373
+ this.dropped += 1;
374
+ return;
375
+ }
376
+ this.pool.bytes(slot).set(bytes);
377
+ let at = (this.head + this.count) % chunkQCZOE65N_js.INBOUND_POOL_SLOTS;
378
+ this.slots[at] = slot, this.lanes[at] = lane, this.lengths[at] = bytes.length, this.count += 1;
379
+ }
380
+ closed() {
381
+ this.lost = true;
382
+ }
383
+ backpressure(failures, status) {
384
+ this.sendFailures += failures, this.lastSendStatus = status;
385
+ }
386
+ next() {
387
+ return this.release(), this.count === 0 ? false : (this.current = this.head, this.head = (this.head + 1) % chunkQCZOE65N_js.INBOUND_POOL_SLOTS, this.count -= 1, true);
388
+ }
389
+ get view() {
390
+ return this.pool.view(this.slots[this.current]);
391
+ }
392
+ get length() {
393
+ return this.lengths[this.current];
394
+ }
395
+ get lane() {
396
+ return this.lanes[this.current];
397
+ }
398
+ release() {
399
+ this.current < 0 || (this.pool.release(this.slots[this.current]), this.current = -1);
400
+ }
401
+ };
402
+
403
+ // src/interactives/rooms/input-log.ts
404
+ var InputLog = class {
405
+ constructor() {
406
+ this.buttons = new Uint8Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY);
407
+ this.axisX = new Int16Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY);
408
+ this.axisZ = new Int16Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY);
409
+ this.yaw = new Uint16Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY);
410
+ this.clientTick = new Float64Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY);
411
+ this.subtick = new Uint8Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY);
412
+ this.sentAt = new Float64Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY);
413
+ this.frame = {
414
+ buttons: 0,
415
+ sequence: 0,
416
+ client_tick: 0,
417
+ axis_x: 0,
418
+ axis_z: 0,
419
+ yaw: 0,
420
+ layer: chunkQCZOE65N_js.ROOM_LAYER,
421
+ subtick: 0
422
+ };
423
+ this.latestSequence = 0;
424
+ this.appliedSequence = 0;
425
+ this.durableSequence = 0;
426
+ }
427
+ get latest() {
428
+ return this.latestSequence;
429
+ }
430
+ get applied() {
431
+ return this.appliedSequence;
432
+ }
433
+ get durable() {
434
+ return this.durableSequence;
435
+ }
436
+ get pending() {
437
+ return this.latestSequence - this.appliedSequence;
438
+ }
439
+ rebase(applied) {
440
+ this.appliedSequence = applied, this.durableSequence > applied && (this.durableSequence = applied), (this.latestSequence < applied || this.latestSequence - this.durableSequence >= chunkQCZOE65N_js.INPUT_LOG_CAPACITY) && (this.latestSequence = applied, this.durableSequence = applied);
441
+ }
442
+ reset(applied) {
443
+ this.latestSequence = applied, this.appliedSequence = applied, this.durableSequence = applied;
444
+ }
445
+ acknowledge(applied) {
446
+ return applied <= this.appliedSequence || applied > this.latestSequence ? false : (this.appliedSequence = applied, true);
447
+ }
448
+ persist(durable) {
449
+ durable > this.durableSequence && (this.durableSequence = Math.min(durable, this.latestSequence));
450
+ }
451
+ holds(sequence) {
452
+ return sequence > this.durableSequence && sequence <= this.latestSequence;
453
+ }
454
+ push(axisX, axisZ, yaw, buttons, clientTick, subtick) {
455
+ this.latestSequence - this.durableSequence >= chunkQCZOE65N_js.INPUT_LOG_CAPACITY && (this.durableSequence += 1);
456
+ let sequence = this.latestSequence + 1, at = sequence % chunkQCZOE65N_js.INPUT_LOG_CAPACITY;
457
+ return this.axisX[at] = axisX, this.axisZ[at] = axisZ, this.yaw[at] = yaw, this.buttons[at] = buttons, this.clientTick[at] = clientTick, this.subtick[at] = subtick, this.sentAt[at] = Number.NaN, this.latestSequence = sequence, sequence;
458
+ }
459
+ axisXOf(sequence) {
460
+ return this.axisX[sequence % chunkQCZOE65N_js.INPUT_LOG_CAPACITY];
461
+ }
462
+ axisZOf(sequence) {
463
+ return this.axisZ[sequence % chunkQCZOE65N_js.INPUT_LOG_CAPACITY];
464
+ }
465
+ buttonsOf(sequence) {
466
+ return this.buttons[sequence % chunkQCZOE65N_js.INPUT_LOG_CAPACITY];
467
+ }
468
+ yawOf(sequence) {
469
+ return this.yaw[sequence % chunkQCZOE65N_js.INPUT_LOG_CAPACITY];
470
+ }
471
+ sentAtOf(sequence) {
472
+ return this.holds(sequence) ? this.sentAt[sequence % chunkQCZOE65N_js.INPUT_LOG_CAPACITY] : Number.NaN;
473
+ }
474
+ write(view, offset, nowMs) {
475
+ let first = Math.max(this.appliedSequence, this.durableSequence) + 1, last = Math.min(this.latestSequence, first + chunkQCZOE65N_js.MAX_INPUTS_PER_PACKET - 1), at = offset, frame = this.frame;
476
+ for (let sequence = first; sequence <= last; sequence++) {
477
+ let slot = sequence % chunkQCZOE65N_js.INPUT_LOG_CAPACITY;
478
+ frame.buttons = this.buttons[slot], frame.sequence = sequence % chunkQCZOE65N_js.U16_RANGE, frame.client_tick = this.clientTick[slot] >>> 0, frame.axis_x = this.axisX[slot], frame.axis_z = this.axisZ[slot], frame.yaw = this.yaw[slot], frame.subtick = this.subtick[slot];
479
+ let written = chunk66QP3SMN_js.encodeMoveInput(view, at, frame);
480
+ if (written < 0) break;
481
+ at += written, Number.isNaN(this.sentAt[slot]) && (this.sentAt[slot] = nowMs);
482
+ }
483
+ return at - offset;
484
+ }
485
+ };
486
+
487
+ // src/interactives/rooms/interpolation.ts
488
+ var Sampled = {
489
+ None: 0,
490
+ Interpolated: 1,
491
+ Extrapolated: 2
492
+ }, SAMPLES = chunkQCZOE65N_js.ENTITY_CAPACITY * chunkQCZOE65N_js.REMOTE_HISTORY;
493
+ function yawBetween(from, to, alpha) {
494
+ let delta = to - from;
495
+ return delta > chunkQCZOE65N_js.HALF_YAW_UNITS ? delta -= chunkQCZOE65N_js.YAW_UNITS_PER_TURN : delta < -chunkQCZOE65N_js.HALF_YAW_UNITS && (delta += chunkQCZOE65N_js.YAW_UNITS_PER_TURN), ((from + delta * alpha) % chunkQCZOE65N_js.YAW_UNITS_PER_TURN + chunkQCZOE65N_js.YAW_UNITS_PER_TURN) % chunkQCZOE65N_js.YAW_UNITS_PER_TURN;
496
+ }
497
+ var RemoteTracks = class {
498
+ constructor() {
499
+ this.ticks = new Float64Array(SAMPLES);
500
+ this.xs = new Int32Array(SAMPLES);
501
+ this.ys = new Int32Array(SAMPLES);
502
+ this.zs = new Int32Array(SAMPLES);
503
+ this.yaws = new Uint16Array(SAMPLES);
504
+ this.animations = new Uint8Array(SAMPLES);
505
+ this.heads = new Int32Array(chunkQCZOE65N_js.ENTITY_CAPACITY);
506
+ this.counts = new Int32Array(chunkQCZOE65N_js.ENTITY_CAPACITY);
507
+ }
508
+ reset() {
509
+ this.counts.fill(0), this.heads.fill(0);
510
+ }
511
+ newestTick(slot) {
512
+ return this.counts[slot] === 0 ? -1 : this.ticks[slot * chunkQCZOE65N_js.REMOTE_HISTORY + this.heads[slot]];
513
+ }
514
+ push(slot, tick, x, y, z, yaw, animation) {
515
+ if (this.counts[slot] > 0 && tick <= this.newestTick(slot)) return;
516
+ let head = this.counts[slot] === 0 ? 0 : (this.heads[slot] + 1) % chunkQCZOE65N_js.REMOTE_HISTORY, at = slot * chunkQCZOE65N_js.REMOTE_HISTORY + head;
517
+ this.ticks[at] = tick, this.xs[at] = x, this.ys[at] = y, this.zs[at] = z, this.yaws[at] = yaw, this.animations[at] = animation, this.heads[slot] = head, this.counts[slot] < chunkQCZOE65N_js.REMOTE_HISTORY && (this.counts[slot] += 1);
518
+ }
519
+ sample(slot, renderTick, capTicks, out) {
520
+ let count = this.counts[slot];
521
+ if (count === 0) return Sampled.None;
522
+ let base = slot * chunkQCZOE65N_js.REMOTE_HISTORY, newest = base + this.heads[slot];
523
+ if (renderTick >= this.ticks[newest]) {
524
+ if (count === 1)
525
+ return this.copy(newest, out), Sampled.Extrapolated;
526
+ let previous = base + (this.heads[slot] + chunkQCZOE65N_js.REMOTE_HISTORY - 1) % chunkQCZOE65N_js.REMOTE_HISTORY, span = this.ticks[newest] - this.ticks[previous], ahead = Math.min(renderTick - this.ticks[newest], capTicks);
527
+ return this.blend(previous, newest, span > 0 ? 1 + ahead / span : 1, out), Sampled.Extrapolated;
528
+ }
529
+ let later = newest;
530
+ for (let back = 1; back < count; back++) {
531
+ let earlier = base + (this.heads[slot] + chunkQCZOE65N_js.REMOTE_HISTORY - back) % chunkQCZOE65N_js.REMOTE_HISTORY;
532
+ if (this.ticks[earlier] <= renderTick) {
533
+ let span = this.ticks[later] - this.ticks[earlier];
534
+ return this.blend(earlier, later, span > 0 ? (renderTick - this.ticks[earlier]) / span : 0, out), Sampled.Interpolated;
535
+ }
536
+ later = earlier;
537
+ }
538
+ return this.copy(later, out), Sampled.Interpolated;
539
+ }
540
+ copy(at, out) {
541
+ out.x = this.xs[at], out.y = this.ys[at], out.z = this.zs[at], out.yaw = this.yaws[at], out.animation = this.animations[at];
542
+ }
543
+ blend(from, to, alpha, out) {
544
+ out.x = this.xs[from] + (this.xs[to] - this.xs[from]) * alpha, out.y = this.ys[from] + (this.ys[to] - this.ys[from]) * alpha, out.z = this.zs[from] + (this.zs[to] - this.zs[from]) * alpha, out.yaw = yawBetween(this.yaws[from], this.yaws[to], alpha), out.animation = this.animations[to];
545
+ }
546
+ };
547
+
548
+ // src/interactives/rooms/pacing.ts
549
+ function paceOf(code) {
550
+ return code === chunkQCZOE65N_js.Pace.Faster ? chunkQCZOE65N_js.Pace.Faster : code === chunkQCZOE65N_js.Pace.Slower ? chunkQCZOE65N_js.Pace.Slower : chunkQCZOE65N_js.Pace.Steady;
551
+ }
552
+ var ClientTicker = class {
553
+ constructor() {
554
+ this.nominalMs = 0;
555
+ this.intervalMs = 0;
556
+ this.nextAt = 0;
557
+ this.lastAt = 0;
558
+ this.current = chunkQCZOE65N_js.Pace.Steady;
559
+ this.tick = 0;
560
+ this.changes = 0;
561
+ }
562
+ start(simulationHz, firstTick, nowMs) {
563
+ this.nominalMs = chunkQCZOE65N_js.MS_PER_SECOND / simulationHz, this.intervalMs = this.nominalMs, this.current = chunkQCZOE65N_js.Pace.Steady, this.tick = firstTick, this.lastAt = nowMs, this.nextAt = nowMs + this.intervalMs;
564
+ }
565
+ get pace() {
566
+ return this.current;
567
+ }
568
+ get interval() {
569
+ return this.intervalMs;
570
+ }
571
+ steer(pace) {
572
+ pace !== this.current && (this.current = pace, this.changes += 1, this.intervalMs = pace === chunkQCZOE65N_js.Pace.Faster ? this.nominalMs * chunkQCZOE65N_js.PACE_FASTER_SCALE : pace === chunkQCZOE65N_js.Pace.Slower ? this.nominalMs * chunkQCZOE65N_js.PACE_SLOWER_SCALE : this.nominalMs);
573
+ }
574
+ due(nowMs) {
575
+ if (nowMs < this.nextAt) return 0;
576
+ let count = 0;
577
+ for (; nowMs >= this.nextAt && count < chunkQCZOE65N_js.MAX_CATCH_UP_TICKS; )
578
+ this.lastAt = this.nextAt, this.nextAt += this.intervalMs, count += 1;
579
+ return nowMs >= this.nextAt && (this.lastAt = nowMs, this.nextAt = nowMs + this.intervalMs), count;
580
+ }
581
+ subtick(sampledAtMs) {
582
+ let fraction = (sampledAtMs - this.lastAt) / this.intervalMs, units = Math.floor(fraction * chunkQCZOE65N_js.SUBTICKS_PER_TICK);
583
+ return units < 0 ? 0 : units > chunkQCZOE65N_js.MAX_SUBTICK ? chunkQCZOE65N_js.MAX_SUBTICK : units;
584
+ }
585
+ };
586
+
587
+ // src/interactives/rooms/prediction.ts
588
+ var Predictor = class {
589
+ constructor(motion) {
590
+ this.xs = new Int32Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY);
591
+ this.zs = new Int32Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY);
592
+ this.predicted = new Float64Array(chunkQCZOE65N_js.INPUT_LOG_CAPACITY).fill(-1);
593
+ this.settled = false;
594
+ this.offsetX = 0;
595
+ this.offsetZ = 0;
596
+ this.stats = { corrections: 0, maxUnits: 0, totalUnits: 0 };
597
+ this.motion = motion;
598
+ }
599
+ get x() {
600
+ return this.motion.x;
601
+ }
602
+ get z() {
603
+ return this.motion.z;
604
+ }
605
+ get renderX() {
606
+ return this.motion.x + this.offsetX;
607
+ }
608
+ get renderZ() {
609
+ return this.motion.z + this.offsetZ;
610
+ }
611
+ begin(slot, applied) {
612
+ this.motion.spawn(slot), this.predicted.fill(-1), this.remember(applied), this.settled = false, this.offsetX = 0, this.offsetZ = 0;
613
+ }
614
+ predict(sequence, log) {
615
+ this.apply(sequence, log), this.remember(sequence);
616
+ }
617
+ reconcile(applied, x, y, z, log) {
618
+ let at = applied % chunkQCZOE65N_js.INPUT_LOG_CAPACITY;
619
+ if (this.predicted[at] !== applied) return false;
620
+ let errorX = x - this.xs[at], errorZ = z - this.zs[at], tolerance = this.motion.toleranceUnits;
621
+ if (Math.abs(errorX) <= tolerance && Math.abs(errorZ) <= tolerance)
622
+ return this.settled = true, true;
623
+ let motion = this.motion, beforeX = motion.x + this.offsetX, beforeZ = motion.z + this.offsetZ;
624
+ motion.place(x, y, z), this.remember(applied);
625
+ for (let sequence = applied + 1; sequence <= log.latest; sequence++) this.predict(sequence, log);
626
+ if (this.settled) {
627
+ let units = Math.hypot(errorX, errorZ);
628
+ this.stats.corrections += 1, this.stats.totalUnits += units, units > this.stats.maxUnits && (this.stats.maxUnits = units), this.offsetX = beforeX - motion.x, this.offsetZ = beforeZ - motion.z;
629
+ }
630
+ return this.settled = true, true;
631
+ }
632
+ decay(elapsedMs) {
633
+ if (this.offsetX === 0 && this.offsetZ === 0) return;
634
+ let keep = Math.exp(-elapsedMs / chunkQCZOE65N_js.SMOOTHING_TIME_CONSTANT_MS);
635
+ this.offsetX *= keep, this.offsetZ *= keep, Math.abs(this.offsetX) < chunkQCZOE65N_js.SETTLED_OFFSET_UNITS && Math.abs(this.offsetZ) < chunkQCZOE65N_js.SETTLED_OFFSET_UNITS && (this.offsetX = 0, this.offsetZ = 0);
636
+ }
637
+ apply(sequence, log) {
638
+ let motion = this.motion;
639
+ motion.steer(log.axisXOf(sequence), log.axisZOf(sequence), log.buttonsOf(sequence)), motion.step();
640
+ }
641
+ remember(sequence) {
642
+ let at = sequence % chunkQCZOE65N_js.INPUT_LOG_CAPACITY;
643
+ this.xs[at] = this.motion.x, this.zs[at] = this.motion.z, this.predicted[at] = sequence;
644
+ }
645
+ };
646
+
647
+ // src/interactives/rooms/send-governor.ts
648
+ var SendGovernor = class {
649
+ constructor() {
650
+ this.stride = 1;
651
+ this.shed = 0;
652
+ this.skipped = 0;
653
+ this.calmSince = 0;
654
+ }
655
+ get pressured() {
656
+ return this.stride > 1;
657
+ }
658
+ pressure(nowMs) {
659
+ this.stride = Math.min(this.stride * 2, chunkQCZOE65N_js.MAX_SEND_STRIDE), this.calmSince = nowMs;
660
+ }
661
+ recover(nowMs) {
662
+ this.stride === 1 || nowMs - this.calmSince < chunkQCZOE65N_js.SEND_RECOVER_MS || (this.stride >>= 1, this.calmSince = nowMs, this.stride === 1 && (this.skipped = 0));
663
+ }
664
+ admit() {
665
+ return this.stride === 1 ? true : (this.skipped += 1, this.skipped < this.stride ? (this.shed += 1, false) : (this.skipped = 0, true));
666
+ }
667
+ force() {
668
+ return this.skipped = 0, true;
669
+ }
670
+ reset() {
671
+ this.stride = 1, this.skipped = 0, this.calmSince = 0;
672
+ }
673
+ };
674
+
675
+ // src/interactives/rooms/sized-views.ts
676
+ var SizedViews = class {
677
+ constructor(buffer) {
678
+ this.buffer = buffer, this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength), this.views = Array.from({ length: buffer.length + 1 });
679
+ }
680
+ of(length) {
681
+ let cached = this.views[length];
682
+ if (cached) return cached;
683
+ let view = this.buffer.subarray(0, length);
684
+ return this.views[length] = view, view;
685
+ }
686
+ };
687
+
688
+ // src/interactives/rooms/snapshots.ts
689
+ var Decoded = {
690
+ Stored: 0,
691
+ Duplicate: 1,
692
+ MissingBaseline: 2,
693
+ Malformed: 3
694
+ }, DELTA_FULL = chunkWWKMOA76_js.FRAME_FLAGS.presence_delta.entry_full, DELTA_ANIMATION = chunkWWKMOA76_js.FRAME_FLAGS.presence_delta.entry_animation, DELTA_FLAGS = chunkWWKMOA76_js.FRAME_FLAGS.presence_delta.entry_flags, NO_TICK = -1, NO_ROW = -1, CELLS = chunkQCZOE65N_js.SNAPSHOT_RING * chunkQCZOE65N_js.ENTITY_CAPACITY;
695
+ function newerTick(candidate, than) {
696
+ let ahead = (candidate - than + chunkQCZOE65N_js.U32_RANGE) % chunkQCZOE65N_js.U32_RANGE;
697
+ return ahead !== 0 && ahead < chunkQCZOE65N_js.U32_RANGE / 2;
698
+ }
699
+ var SnapshotStore = class {
700
+ constructor() {
701
+ this.present = new Uint8Array(CELLS);
702
+ this.x = new Uint16Array(CELLS);
703
+ this.y = new Int16Array(CELLS);
704
+ this.z = new Uint16Array(CELLS);
705
+ this.yaw = new Uint16Array(CELLS);
706
+ this.animation = new Uint8Array(CELLS);
707
+ this.flags = new Uint8Array(CELLS);
708
+ this.ticks = new Float64Array(chunkQCZOE65N_js.SNAPSHOT_RING).fill((-1));
709
+ this.seen = new Float64Array(chunkQCZOE65N_js.SEEN_TICKS).fill((-1));
710
+ this.header = {
711
+ flags: 0,
712
+ server_tick: 0,
713
+ cell_index: 0,
714
+ acked_input: 0,
715
+ layer: 0,
716
+ baseline_age: 0,
717
+ count: 0,
718
+ entries_offset: 0,
719
+ end: 0
720
+ };
721
+ this.entry = { slot: 0, x: 0, y: 0, z: 0, yaw: 0, animation: 0, flags: 0 };
722
+ this.delta = { slot: 0, mask: 0, x: 0, y: 0, z: 0, yaw: 0, animation: 0, flags: 0 };
723
+ this.next = 0;
724
+ this.latestRow = (-1);
725
+ this.lastKeyframe = false;
726
+ }
727
+ reset() {
728
+ this.ticks.fill((-1)), this.seen.fill((-1)), this.present.fill(0), this.next = 0, this.latestRow = (-1);
729
+ }
730
+ get hasLatest() {
731
+ return this.latestRow !== (-1);
732
+ }
733
+ get latestTick() {
734
+ return this.latestRow === (-1) ? (-1) : this.ticks[this.latestRow];
735
+ }
736
+ get latest() {
737
+ return this.latestRow;
738
+ }
739
+ tickOf(row) {
740
+ return this.ticks[row];
741
+ }
742
+ row(tick) {
743
+ for (let row = 0; row < chunkQCZOE65N_js.SNAPSHOT_RING; row++) if (this.ticks[row] === tick) return row;
744
+ return (-1);
745
+ }
746
+ rowByShortTick(short) {
747
+ let found = (-1);
748
+ for (let row = 0; row < chunkQCZOE65N_js.SNAPSHOT_RING; row++) {
749
+ let tick = this.ticks[row];
750
+ tick === (-1) || (tick & chunkQCZOE65N_js.SHORT_TICK_MASK) !== short || (found === (-1) || newerTick(tick, this.ticks[found])) && (found = row);
751
+ }
752
+ return found;
753
+ }
754
+ received(tick) {
755
+ return this.seen[tick % chunkQCZOE65N_js.SEEN_TICKS] === tick;
756
+ }
757
+ decode(view, offset, end) {
758
+ let header = this.header, compact = chunk66QP3SMN_js.peekFrameCode(view, offset, end) === chunk66QP3SMN_js.FrameCode.presence_delta;
759
+ if ((compact ? chunk66QP3SMN_js.decodePresenceDelta(view, offset, end, header) : chunk66QP3SMN_js.decodePresenceTick(view, offset, end, header)) < 0) return Decoded.Malformed;
760
+ let tick = header.server_tick;
761
+ if (this.row(tick) !== (-1)) return Decoded.Duplicate;
762
+ let keyframe = (header.flags & chunkQCZOE65N_js.KEYFRAME_FLAG) !== 0, row = this.next, start = row * chunkQCZOE65N_js.ENTITY_CAPACITY;
763
+ if (keyframe)
764
+ this.present.fill(0, start, start + chunkQCZOE65N_js.ENTITY_CAPACITY);
765
+ else {
766
+ let base = this.row((tick - header.baseline_age + chunkQCZOE65N_js.U32_RANGE) % chunkQCZOE65N_js.U32_RANGE);
767
+ if (base === (-1)) return Decoded.MissingBaseline;
768
+ base !== row && this.copyRow(base * chunkQCZOE65N_js.ENTITY_CAPACITY, start);
769
+ }
770
+ return compact ? this.applyDelta(view, start) : this.applyFull(view, start), this.ticks[row] = tick, this.seen[tick % chunkQCZOE65N_js.SEEN_TICKS] = tick, this.next = (row + 1) % chunkQCZOE65N_js.SNAPSHOT_RING, this.lastKeyframe = keyframe, this.latestRow = this.newestRow(), Decoded.Stored;
771
+ }
772
+ applyFull(view, start) {
773
+ let header = this.header, entry = this.entry;
774
+ for (let index = 0; index < header.count; index++) {
775
+ if (chunk66QP3SMN_js.readPresenceEntry(view, header, index, entry), entry.slot >= chunkQCZOE65N_js.ENTITY_CAPACITY) continue;
776
+ let cell = start + entry.slot;
777
+ this.present[cell] = 1, this.x[cell] = entry.x, this.y[cell] = entry.y, this.z[cell] = entry.z, this.yaw[cell] = entry.yaw, this.animation[cell] = entry.animation, this.flags[cell] = entry.flags;
778
+ }
779
+ }
780
+ applyDelta(view, start) {
781
+ let header = this.header, entry = this.delta, cursor = header.entries_offset;
782
+ for (let index = 0; index < header.count; index++) {
783
+ if (cursor = chunk66QP3SMN_js.readPresenceDeltaEntry(view, cursor, header.end, entry), cursor < 0) return;
784
+ if (entry.slot >= chunkQCZOE65N_js.ENTITY_CAPACITY) continue;
785
+ let cell = start + entry.slot;
786
+ if (this.present[cell] = 1, (entry.mask & DELTA_FULL) !== 0) {
787
+ this.x[cell] = entry.x, this.y[cell] = entry.y, this.z[cell] = entry.z, this.yaw[cell] = entry.yaw, this.animation[cell] = entry.animation, this.flags[cell] = entry.flags;
788
+ continue;
789
+ }
790
+ this.x[cell] += entry.x, this.y[cell] += entry.y, this.z[cell] += entry.z, this.yaw[cell] += entry.yaw, (entry.mask & DELTA_ANIMATION) !== 0 && (this.animation[cell] = entry.animation), (entry.mask & DELTA_FLAGS) !== 0 && (this.flags[cell] = entry.flags);
791
+ }
792
+ }
793
+ newestRow() {
794
+ let newest = (-1);
795
+ for (let row = 0; row < chunkQCZOE65N_js.SNAPSHOT_RING; row++)
796
+ this.ticks[row] !== (-1) && (newest === (-1) || newerTick(this.ticks[row], this.ticks[newest])) && (newest = row);
797
+ return newest;
798
+ }
799
+ get decodedRow() {
800
+ return (this.next + chunkQCZOE65N_js.SNAPSHOT_RING - 1) % chunkQCZOE65N_js.SNAPSHOT_RING;
801
+ }
802
+ copyRow(from, to) {
803
+ let until = from + chunkQCZOE65N_js.ENTITY_CAPACITY;
804
+ this.present.copyWithin(to, from, until), this.x.copyWithin(to, from, until), this.y.copyWithin(to, from, until), this.z.copyWithin(to, from, until), this.yaw.copyWithin(to, from, until), this.animation.copyWithin(to, from, until), this.flags.copyWithin(to, from, until);
805
+ }
806
+ };
807
+
808
+ // src/interactives/rooms/client.ts
809
+ var RoomPhase = {
810
+ Idle: 0,
811
+ Ticketing: 1,
812
+ Connecting: 2,
813
+ Joined: 3,
814
+ Waiting: 4,
815
+ Refused: 5,
816
+ Closed: 6
817
+ }, GAME_CHANNEL_SLOTS = chunkWWKMOA76_js.FRAME_LIMITS.game_channel_slots, GAME_CHANNEL_RELIABLE_BASE = chunkWWKMOA76_js.FRAME_LIMITS.game_channel_reliable_base, NO_TICK2 = -1, RATE_KEY_SCALE = 65536, ROOM_INPUT_COMMAND = chunkWWKMOA76_js.FRAME_FLAGS.room_input.command, ROOM_INPUT_HEADER = chunkWWKMOA76_js.FRAME_LAYOUT.room_input.header_bytes, CHANNEL_HEADER = chunkWWKMOA76_js.FRAME_LAYOUT.channel.header_bytes, LITTLE_ENDIAN2 = true, RETRYABLE = [JoinStatus.Full, JoinStatus.Overloaded, JoinStatus.Unavailable], RoomClient = class {
818
+ constructor(options) {
819
+ this.queue = new InboundQueue();
820
+ this.outbound = Array.from({ length: chunkQCZOE65N_js.OUTBOUND_POOL_SLOTS }, () => new SizedViews(new Uint8Array(chunkQCZOE65N_js.PACKET_BYTES)));
821
+ this.reply = blankReply();
822
+ this.ack = { slot: 0, sequence: 0, received_mask: 0 };
823
+ this.streamAcks = [];
824
+ this.clock = new ClockSync();
825
+ this.ticker = new ClientTicker();
826
+ this.governor = new SendGovernor();
827
+ this.seenSendFailures = 0;
828
+ this.leadBoost = 0;
829
+ this.log = new InputLog();
830
+ this.store = new SnapshotStore();
831
+ this.tracks = new RemoteTracks();
832
+ this.units = { x: 0, y: 0, z: 0, yaw: 0, animation: 0 };
833
+ this.appliedShort = new Int32Array(chunkQCZOE65N_js.APPLIED_RING).fill((-1));
834
+ this.appliedSequence = new Float64Array(chunkQCZOE65N_js.APPLIED_RING);
835
+ this.remoteSlots = new Uint16Array(chunkQCZOE65N_js.ENTITY_CAPACITY);
836
+ this.roomInput = { flags: ROOM_INPUT_COMMAND, action: 0, sequence: 0, client_tick: 0, sender: 0 };
837
+ this.channelHeader = { flags: 0, slot: 0, sequence: 0, sender: 0 };
838
+ this.channelMessage = { flags: 0, slot: 0, sequence: 0, sender: 0, payload_offset: 0, payload_length: 0 };
839
+ this.channelSequence = 0;
840
+ this.statistics = {
841
+ slot: chunkQCZOE65N_js.WATCHER_SLOT,
842
+ transport: null,
843
+ corrections: 0,
844
+ maxCorrectionM: 0,
845
+ meanCorrectionM: 0,
846
+ inputsSent: 0,
847
+ snapshots: 0,
848
+ deltas: 0,
849
+ keyframes: 0,
850
+ missingBaselines: 0,
851
+ rttMs: 0,
852
+ interpolationDelayMs: 0,
853
+ extrapolatingFrames: 0,
854
+ paceChanges: 0,
855
+ reconnects: 0,
856
+ dropped: 0,
857
+ sendFailures: 0,
858
+ sendStride: 1,
859
+ statesShed: 0
860
+ };
861
+ this.predictor = null;
862
+ this.predictorRates = 0;
863
+ this.link = null;
864
+ this.stateValue = RoomPhase.Idle;
865
+ this.pendingTicket = null;
866
+ this.ticketFailed = false;
867
+ this.resumeToken = null;
868
+ this.joinVersion = chunkQCZOE65N_js.JOIN_VERSION_DELTA;
869
+ this.request = null;
870
+ this.admittedAt = 0;
871
+ this.dialStartedAt = 0;
872
+ this.retryAt = 0;
873
+ this.lastUpdate = 0;
874
+ this.outboundNext = 0;
875
+ this.appliedNext = 0;
876
+ this.remoteCountValue = 0;
877
+ this.joins = 0;
878
+ this.slotValue = chunkQCZOE65N_js.WATCHER_SLOT;
879
+ this.watcher = true;
880
+ this.started = false;
881
+ this.freshSnapshot = false;
882
+ this.lastReconciled = (-1);
883
+ this.extrapolating = false;
884
+ this.ownTick = (-1);
885
+ this.ownX = 0;
886
+ this.ownY = 0;
887
+ this.ownZ = 0;
888
+ this.ownVelocityX = 0;
889
+ this.ownVelocityZ = 0;
890
+ this.inputAxisX = 0;
891
+ this.inputAxisZ = 0;
892
+ this.inputYaw = 0;
893
+ this.inputButtons = 0;
894
+ this.inputSubtick = 0;
895
+ this.commandSequence = 0;
896
+ this.cameraSequence = 0;
897
+ this.cameraX = 0;
898
+ this.cameraZ = 0;
899
+ this.cameraRadius = 0;
900
+ this.cameraDirty = false;
901
+ this.cameraSentAt = Number.NEGATIVE_INFINITY;
902
+ this.unackedSnapshots = 0;
903
+ this.ticketArrived = (ticket) => {
904
+ this.pendingTicket = ticket;
905
+ };
906
+ this.ticketRefused = () => {
907
+ this.ticketFailed = true;
908
+ };
909
+ this.tickets = options.tickets, this.spectatorAckEvery = Math.max(1, Math.floor(options.spectatorAckEvery ?? chunkQCZOE65N_js.SPECTATOR_ACK_EVERY)), this.physicsHz = options.physicsHz ?? 0, this.channelSink = options.channels ?? null, this.motionFactory = options.motion ?? locomotionMotion, this.connector = new Connector(
910
+ options.primary ?? null,
911
+ options.fallback ?? null,
912
+ options.memory ?? new StorageNetworkMemory(),
913
+ options.network ?? currentNetwork
914
+ );
915
+ }
916
+ get state() {
917
+ return this.stateValue;
918
+ }
919
+ get slot() {
920
+ return this.slotValue;
921
+ }
922
+ ackStream(slot, sequence) {
923
+ this.streamAcks.push({ slot, sequence });
924
+ }
925
+ get watching() {
926
+ return this.watcher;
927
+ }
928
+ get extrapolatingLocal() {
929
+ return this.extrapolating;
930
+ }
931
+ get serverTick() {
932
+ return this.store.latestTick;
933
+ }
934
+ get remoteCount() {
935
+ return this.remoteCountValue;
936
+ }
937
+ remoteSlot(index) {
938
+ return this.remoteSlots[index];
939
+ }
940
+ get stats() {
941
+ let stats = this.statistics, corrections = this.predictor?.stats;
942
+ return stats.slot = this.slotValue, stats.transport = this.link?.transport ?? null, stats.corrections = corrections?.corrections ?? 0, stats.maxCorrectionM = chunk66QP3SMN_js.dequantiseCellOffset(corrections?.maxUnits ?? 0), stats.meanCorrectionM = corrections && corrections.corrections > 0 ? chunk66QP3SMN_js.dequantiseCellOffset(corrections.totalUnits / corrections.corrections) : 0, stats.rttMs = this.clock.rttMs, stats.interpolationDelayMs = this.clock.interpolationDelayMs, stats.paceChanges = this.ticker.changes, stats.dropped = this.queue.dropped, stats.sendFailures = this.queue.sendFailures, stats.sendStride = this.governor.stride, stats.statesShed = this.governor.shed, stats;
943
+ }
944
+ start(nowMs) {
945
+ this.stateValue === RoomPhase.Idle && (this.lastUpdate = nowMs, this.fetchTicket());
946
+ }
947
+ close() {
948
+ this.connector.cancel(), this.link?.close(), this.link = null, this.stateValue = RoomPhase.Closed;
949
+ }
950
+ setInput(axisX, axisZ, yawRadians, buttons, nowMs) {
951
+ this.inputAxisX = chunk66QP3SMN_js.quantiseAxis(axisX), this.inputAxisZ = chunk66QP3SMN_js.quantiseAxis(axisZ), this.inputYaw = chunk66QP3SMN_js.quantiseYaw(yawRadians), this.inputButtons = buttons, this.inputSubtick = this.ticker.subtick(nowMs);
952
+ }
953
+ setCamera(xMetres, zMetres, radiusMetres) {
954
+ this.cameraX = chunk66QP3SMN_js.quantiseCellOffset(xMetres), this.cameraZ = chunk66QP3SMN_js.quantiseCellOffset(zMetres), this.cameraRadius = Math.max(0, Math.min(Math.round(radiusMetres), chunkQCZOE65N_js.SHORT_TICK_MASK)), this.cameraSequence += 1, this.cameraDirty = true;
955
+ }
956
+ sendCommand(action, payload, length) {
957
+ let link = this.link;
958
+ if (!link || this.watcher || this.stateValue !== RoomPhase.Joined) return -1;
959
+ let packet = this.packet(), input = this.roomInput;
960
+ input.flags = ROOM_INPUT_COMMAND, input.action = action, input.sequence = (this.commandSequence + 1) % chunkQCZOE65N_js.U32_RANGE, input.client_tick = this.ticker.tick >>> 0;
961
+ let total = chunk66QP3SMN_js.writeRoomInputHeader(packet.view, 0, input, length);
962
+ if (total < 0) return total;
963
+ let buffer = packet.buffer;
964
+ for (let index = 0; index < length; index++) buffer[ROOM_INPUT_HEADER + index] = payload[index];
965
+ return this.commandSequence = input.sequence, link.send(chunkQCZOE65N_js.Lane.Reliable, packet.of(total)), input.sequence;
966
+ }
967
+ sendChannel(slot, payload, length) {
968
+ let link = this.link;
969
+ if (!link || this.watcher || this.stateValue !== RoomPhase.Joined || slot < 0 || slot >= GAME_CHANNEL_SLOTS) return -1;
970
+ let packet = this.packet(), header = this.channelHeader;
971
+ header.slot = slot, header.sequence = (this.channelSequence + 1) % chunkQCZOE65N_js.U32_RANGE;
972
+ let total = chunk66QP3SMN_js.writeChannelHeader(packet.view, 0, header, length);
973
+ if (total < 0) return total;
974
+ let buffer = packet.buffer;
975
+ for (let index = 0; index < length; index++) buffer[CHANNEL_HEADER + index] = payload[index];
976
+ return this.channelSequence = header.sequence, link.send(slot < GAME_CHANNEL_RELIABLE_BASE ? chunkQCZOE65N_js.Lane.Datagram : chunkQCZOE65N_js.Lane.Reliable, packet.of(total)), header.sequence;
977
+ }
978
+ update(nowMs) {
979
+ let elapsed = nowMs - this.lastUpdate;
980
+ switch (this.lastUpdate = nowMs, this.stateValue) {
981
+ case RoomPhase.Ticketing:
982
+ this.dial(nowMs);
983
+ break;
984
+ case RoomPhase.Connecting:
985
+ this.connecting(nowMs);
986
+ break;
987
+ case RoomPhase.Waiting:
988
+ nowMs >= this.retryAt && this.fetchTicket();
989
+ break;
990
+ }
991
+ if (this.stateValue === RoomPhase.Joined) {
992
+ if (this.drain(nowMs), this.queue.lost) {
993
+ this.reconnect(nowMs);
994
+ return;
995
+ }
996
+ this.govern(nowMs), this.play(nowMs), this.predictor?.decay(elapsed), this.watchLatency();
997
+ }
998
+ }
999
+ localPose(out, nowMs) {
1000
+ let predictor = this.predictor;
1001
+ if (!predictor || !this.started) return false;
1002
+ let x = predictor.renderX, z = predictor.renderZ;
1003
+ if (this.extrapolating && this.ownTick !== (-1)) {
1004
+ let projected = this.clock.serverTick(nowMs) + this.clock.leadTicks(), ahead = Math.max(0, Math.min(projected - this.ownTick, this.capTicks()));
1005
+ x = this.ownX + this.ownVelocityX * ahead, z = this.ownZ + this.ownVelocityZ * ahead;
1006
+ }
1007
+ return out.x = chunk66QP3SMN_js.dequantiseCellOffset(x), out.y = chunk66QP3SMN_js.dequantiseHeight(this.ownY), out.z = chunk66QP3SMN_js.dequantiseCellOffset(z), out.yaw = chunk66QP3SMN_js.dequantiseYaw(this.inputYaw), out.animation = 0, true;
1008
+ }
1009
+ presence(slot, out) {
1010
+ let store = this.store, row = store.latest;
1011
+ if (slot < 0 || slot >= chunkQCZOE65N_js.ENTITY_CAPACITY || !store.hasLatest) return false;
1012
+ let cell = row * chunkQCZOE65N_js.ENTITY_CAPACITY + slot;
1013
+ return store.present[cell] === 0 ? false : (out.tick = store.tickOf(row), out.x = store.x[cell], out.y = store.y[cell], out.z = store.z[cell], out.yaw = store.yaw[cell], out.animation = store.animation[cell], out.flags = store.flags[cell], true);
1014
+ }
1015
+ remotePose(slot, out, nowMs) {
1016
+ if (slot >= chunkQCZOE65N_js.ENTITY_CAPACITY) return false;
1017
+ let units = this.units;
1018
+ return this.tracks.sample(slot, this.clock.renderTick(nowMs), this.capTicks(), units) === Sampled.None ? false : (out.x = chunk66QP3SMN_js.dequantiseCellOffset(units.x), out.y = chunk66QP3SMN_js.dequantiseHeight(units.y), out.z = chunk66QP3SMN_js.dequantiseCellOffset(units.z), out.yaw = chunk66QP3SMN_js.dequantiseYaw(units.yaw), out.animation = units.animation, true);
1019
+ }
1020
+ capTicks() {
1021
+ return chunkQCZOE65N_js.EXTRAPOLATION_CAP_MS / this.clock.tickIntervalMs;
1022
+ }
1023
+ fetchTicket() {
1024
+ this.stateValue = RoomPhase.Ticketing, this.pendingTicket = null, this.ticketFailed = false, this.tickets().then(this.ticketArrived, this.ticketRefused);
1025
+ }
1026
+ dial(nowMs) {
1027
+ if (this.ticketFailed) {
1028
+ this.waitAndRetry(nowMs);
1029
+ return;
1030
+ }
1031
+ let ticket = this.pendingTicket;
1032
+ ticket && (this.pendingTicket = null, this.begin(ticketRequest(ticket, this.joinVersion), nowMs));
1033
+ }
1034
+ begin(request, nowMs) {
1035
+ this.request = request, this.queue.clear(), this.dialStartedAt = nowMs, this.stateValue = RoomPhase.Connecting, this.connector.begin(request, this.queue, nowMs);
1036
+ }
1037
+ connecting(nowMs) {
1038
+ let state = this.connector.poll(nowMs);
1039
+ if (state === Connecting.Failed) {
1040
+ this.waitAndRetry(nowMs);
1041
+ return;
1042
+ }
1043
+ if (state !== Connecting.Won) return;
1044
+ let dialed = this.connector.release();
1045
+ if (!dialed || !decodeJoinReply(dialed.reply, this.reply)) {
1046
+ dialed?.link.close(), this.waitAndRetry(nowMs);
1047
+ return;
1048
+ }
1049
+ let status = this.reply.status;
1050
+ if (status === JoinStatus.Admitted) {
1051
+ this.joined(dialed.link, nowMs);
1052
+ return;
1053
+ }
1054
+ dialed.link.close();
1055
+ let request = this.request;
1056
+ if (status === JoinStatus.Malformed && request !== null && withoutDeltaPresence(request)) {
1057
+ this.joinVersion = chunkQCZOE65N_js.JOIN_VERSION, this.begin(request, nowMs);
1058
+ return;
1059
+ }
1060
+ status === JoinStatus.UnknownResume || status === JoinStatus.Expired ? (this.resumeToken = null, this.fetchTicket()) : RETRYABLE.indexOf(status) >= 0 ? this.waitAndRetry(nowMs) : this.stateValue = RoomPhase.Refused;
1061
+ }
1062
+ waitAndRetry(nowMs) {
1063
+ this.stateValue = RoomPhase.Waiting, this.retryAt = nowMs + chunkQCZOE65N_js.RETRY_AFTER_MS;
1064
+ }
1065
+ reconnect(nowMs) {
1066
+ this.link?.close(), this.link = null;
1067
+ let token = this.resumeToken;
1068
+ if (token && nowMs - this.admittedAt < chunkQCZOE65N_js.RESUME_GRACE_MS) {
1069
+ this.resumeToken = null, this.begin(resumeRequest(token, this.joinVersion), nowMs);
1070
+ return;
1071
+ }
1072
+ this.resumeToken = null, this.fetchTicket();
1073
+ }
1074
+ joined(link, nowMs) {
1075
+ let reply = this.reply;
1076
+ this.link = link, this.stateValue = RoomPhase.Joined, this.admittedAt = nowMs, this.resumeToken = reply.resume.slice(), this.slotValue = reply.slot, this.watcher = reply.slot === chunkQCZOE65N_js.WATCHER_SLOT, this.joins > 0 && (this.statistics.reconnects += 1), this.joins += 1, this.clock.configure(reply.simulationHz, reply.sendHz, nowMs - this.dialStartedAt);
1077
+ let physicsHz = this.physicsHz > 0 ? this.physicsHz : reply.simulationHz * chunkQCZOE65N_js.DEFAULT_SUBSTEPS, rates = reply.simulationHz * (65536) + physicsHz;
1078
+ (!this.predictor || this.predictorRates !== rates) && (this.predictor = new Predictor(this.motionFactory(reply.simulationHz, physicsHz)), this.predictorRates = rates), this.store.reset(), this.tracks.reset(), this.appliedShort.fill((-1)), this.remoteCountValue = 0, this.lastReconciled = (-1), this.ownTick = (-1), this.started = false, this.freshSnapshot = false, this.extrapolating = false, this.cameraDirty = this.cameraSequence > 0, this.governor.reset(), this.seenSendFailures = this.queue.sendFailures, this.leadBoost = 0;
1079
+ }
1080
+ govern(nowMs) {
1081
+ let failures = this.queue.sendFailures;
1082
+ if (failures === this.seenSendFailures) {
1083
+ this.governor.recover(nowMs);
1084
+ return;
1085
+ }
1086
+ this.seenSendFailures = failures, this.governor.pressure(nowMs);
1087
+ }
1088
+ drain(nowMs) {
1089
+ let queue = this.queue;
1090
+ for (; queue.next(); ) {
1091
+ let view = queue.view, end = queue.length, offset = 0;
1092
+ for (; offset < end; ) {
1093
+ let length = chunk66QP3SMN_js.frameLength(view, offset, end);
1094
+ if (length <= 0) break;
1095
+ let code = chunk66QP3SMN_js.peekFrameCode(view, offset, end);
1096
+ code === chunk66QP3SMN_js.FrameCode.presence_tick || code === chunk66QP3SMN_js.FrameCode.presence_delta ? this.snapshot(view, offset, offset + length, nowMs) : code === chunk66QP3SMN_js.FrameCode.ack && chunk66QP3SMN_js.decodeAck(view, offset, offset + length, this.ack) > 0 ? this.acknowledged(nowMs) : code === chunk66QP3SMN_js.FrameCode.channel && this.channel(view, offset, offset + length), offset += length;
1097
+ }
1098
+ }
1099
+ }
1100
+ channel(view, offset, end) {
1101
+ let sink = this.channelSink;
1102
+ if (sink === null) return;
1103
+ let message = this.channelMessage;
1104
+ chunk66QP3SMN_js.decodeChannelFrame(view, offset, end, message) < 0 || sink.deliver(message.slot, message.sender, view, message.payload_offset, message.payload_length);
1105
+ }
1106
+ snapshot(view, offset, end, nowMs) {
1107
+ let store = this.store, decoded = store.decode(view, offset, end);
1108
+ if (decoded === Decoded.MissingBaseline) {
1109
+ this.statistics.missingBaselines += 1;
1110
+ return;
1111
+ }
1112
+ if (decoded !== Decoded.Stored) return;
1113
+ let stats = this.statistics;
1114
+ stats.snapshots += 1, store.lastKeyframe ? stats.keyframes += 1 : stats.deltas += 1;
1115
+ let row = store.decodedRow, tick = store.tickOf(row);
1116
+ this.clock.snapshot(tick, nowMs), this.freshSnapshot = true;
1117
+ let fresh2 = row === store.latest, start = row * chunkQCZOE65N_js.ENTITY_CAPACITY;
1118
+ fresh2 && (this.remoteCountValue = 0);
1119
+ for (let slot = 0; slot < chunkQCZOE65N_js.ENTITY_CAPACITY; slot++) {
1120
+ let cell = start + slot;
1121
+ if (store.present[cell] !== 0) {
1122
+ if (slot === this.slotValue) {
1123
+ this.observeOwn(tick, store.x[cell], store.y[cell], store.z[cell]);
1124
+ continue;
1125
+ }
1126
+ this.tracks.push(slot, tick, store.x[cell], store.y[cell], store.z[cell], store.yaw[cell], store.animation[cell]), fresh2 && (this.remoteSlots[this.remoteCountValue++] = slot);
1127
+ }
1128
+ }
1129
+ let short = tick & chunkQCZOE65N_js.SHORT_TICK_MASK;
1130
+ for (let index = 0; index < chunkQCZOE65N_js.APPLIED_RING; index++)
1131
+ this.appliedShort[index] === short && this.reconcile(this.appliedSequence[index], row);
1132
+ }
1133
+ observeOwn(tick, x, y, z) {
1134
+ if (!(this.ownTick !== (-1) && !newerTick(tick, this.ownTick))) {
1135
+ if (this.ownTick !== (-1)) {
1136
+ let span = tick - this.ownTick;
1137
+ this.ownVelocityX = (x - this.ownX) / span, this.ownVelocityZ = (z - this.ownZ) / span;
1138
+ }
1139
+ this.ownTick = tick, this.ownX = x, this.ownY = y, this.ownZ = z;
1140
+ }
1141
+ }
1142
+ acknowledged(nowMs) {
1143
+ let ack = this.ack;
1144
+ switch (ack.slot) {
1145
+ case chunkQCZOE65N_js.MOVE_APPLIED_SLOT:
1146
+ this.applied(ack.sequence, ack.received_mask, nowMs);
1147
+ return;
1148
+ case chunkQCZOE65N_js.MOVE_DURABLE_SLOT:
1149
+ this.log.persist(ack.sequence);
1150
+ return;
1151
+ case chunkQCZOE65N_js.COMMAND_DURABLE_SLOT:
1152
+ ack.sequence > this.commandSequence && (this.commandSequence = ack.sequence);
1153
+ return;
1154
+ default:
1155
+ return;
1156
+ }
1157
+ }
1158
+ applied(applied, mask, nowMs) {
1159
+ let buffered = mask & chunkQCZOE65N_js.TIMING_BUFFERED_MASK, pace = paceOf(mask >>> chunkQCZOE65N_js.TIMING_PACE_SHIFT & chunkQCZOE65N_js.TIMING_BUFFERED_MASK), short = mask >>> chunkQCZOE65N_js.TIMING_TICK_SHIFT;
1160
+ if (this.watcher) return;
1161
+ this.started ? this.log.acknowledge(applied) && this.clock.roundTrip(nowMs - this.log.sentAtOf(applied) - buffered * this.clock.tickIntervalMs) : this.beginSession(applied, nowMs), this.ticker.steer(pace), this.appliedShort[this.appliedNext] = short, this.appliedSequence[this.appliedNext] = applied, this.appliedNext = (this.appliedNext + 1) % chunkQCZOE65N_js.APPLIED_RING;
1162
+ let row = this.store.rowByShortTick(short);
1163
+ row >= 0 && this.reconcile(applied, row);
1164
+ }
1165
+ beginSession(applied, nowMs) {
1166
+ let log = this.log;
1167
+ log.latest > applied && log.holds(applied + 1) ? log.rebase(applied) : (log.reset(applied), this.predictor?.begin(this.slotValue, applied));
1168
+ let lead = Math.ceil(this.clock.leadTicks()) + chunkQCZOE65N_js.INPUT_BUFFER_TARGET;
1169
+ this.ticker.start(this.reply.simulationHz, this.reply.tick + lead, nowMs), this.started = true;
1170
+ }
1171
+ reconcile(applied, row) {
1172
+ let predictor = this.predictor;
1173
+ if (!predictor || !this.started) return;
1174
+ let store = this.store, tick = store.tickOf(row);
1175
+ if (this.lastReconciled !== (-1) && !newerTick(tick, this.lastReconciled)) return;
1176
+ let cell = row * chunkQCZOE65N_js.ENTITY_CAPACITY + this.slotValue;
1177
+ store.present[cell] !== 0 && predictor.reconcile(applied, store.x[cell], store.y[cell], store.z[cell], this.log) && (this.lastReconciled = tick);
1178
+ }
1179
+ play(nowMs) {
1180
+ if (this.watcher) {
1181
+ this.freshSnapshot && (this.unackedSnapshots += 1), (this.unackedSnapshots >= this.spectatorAckEvery || this.cameraDue(nowMs)) && (this.unackedSnapshots = 0, this.governor.admit() && this.send(nowMs)), this.freshSnapshot = false;
1182
+ return;
1183
+ }
1184
+ if (!this.started) return;
1185
+ let predictor = this.predictor;
1186
+ if (!predictor) return;
1187
+ let boost = this.leadDebt(), due = this.ticker.due(nowMs) + boost, coalesce = this.governor.pressured;
1188
+ for (let index = 0; index < due; index++) {
1189
+ let sequence = this.log.push(
1190
+ this.inputAxisX,
1191
+ this.inputAxisZ,
1192
+ this.inputYaw,
1193
+ this.inputButtons,
1194
+ this.ticker.tick,
1195
+ this.inputSubtick
1196
+ );
1197
+ this.ticker.tick += 1, this.inputSubtick = 0, predictor.predict(sequence, this.log), this.statistics.inputsSent += 1, coalesce || this.send(nowMs);
1198
+ }
1199
+ coalesce && due > 0 && (boost > 0 ? this.governor.force() : this.governor.admit()) && this.send(nowMs), this.freshSnapshot = false;
1200
+ }
1201
+ leadDebt() {
1202
+ let want = this.governor.stride - 1;
1203
+ if (want <= this.leadBoost)
1204
+ return this.leadBoost = want, 0;
1205
+ let extra = want - this.leadBoost;
1206
+ return this.leadBoost = want, extra;
1207
+ }
1208
+ cameraDue(nowMs) {
1209
+ return this.cameraSequence > 0 && (this.cameraDirty || nowMs - this.cameraSentAt >= chunkQCZOE65N_js.CAMERA_RESEND_MS);
1210
+ }
1211
+ packet() {
1212
+ let packet = this.outbound[this.outboundNext];
1213
+ return this.outboundNext = (this.outboundNext + 1) % chunkQCZOE65N_js.OUTBOUND_POOL_SLOTS, packet;
1214
+ }
1215
+ send(nowMs) {
1216
+ let link = this.link;
1217
+ if (!link) return;
1218
+ let packet = this.packet(), view = packet.view, offset = this.watcher ? 0 : this.log.write(view, 0, nowMs);
1219
+ if (this.watcher && this.cameraDue(nowMs) && (offset += this.writeCamera(view, offset, nowMs)), this.store.hasLatest) {
1220
+ let ack = this.ack;
1221
+ ack.slot = chunkQCZOE65N_js.SNAPSHOT_STREAM_SLOT, ack.sequence = this.store.latestTick, ack.received_mask = this.receivedMask(ack.sequence);
1222
+ let written = chunk66QP3SMN_js.encodeAck(view, offset, ack);
1223
+ written > 0 && (offset += written);
1224
+ }
1225
+ for (let i = 0; i < this.streamAcks.length; i++) {
1226
+ let stream = this.streamAcks[i], sequence = stream.sequence();
1227
+ if (sequence < 0) continue;
1228
+ let ack = this.ack;
1229
+ ack.slot = stream.slot, ack.sequence = sequence >>> 0, ack.received_mask = 0;
1230
+ let written = chunk66QP3SMN_js.encodeAck(view, offset, ack);
1231
+ written > 0 && (offset += written);
1232
+ }
1233
+ offset > 0 && link.send(chunkQCZOE65N_js.Lane.Datagram, packet.of(offset));
1234
+ }
1235
+ writeCamera(view, offset, nowMs) {
1236
+ let input = this.roomInput;
1237
+ input.flags = 0, input.action = chunkQCZOE65N_js.CAMERA_ACTION, input.sequence = this.cameraSequence, input.client_tick = 0;
1238
+ let total = chunk66QP3SMN_js.writeRoomInputHeader(view, offset, input, chunkQCZOE65N_js.CAMERA_PAYLOAD_BYTES);
1239
+ if (total < 0) return 0;
1240
+ let at = offset + ROOM_INPUT_HEADER;
1241
+ return view.setUint16(at, this.cameraX, (true)), view.setUint16(at + 2, this.cameraZ, (true)), view.setUint16(at + 4, this.cameraRadius, (true)), this.cameraDirty = false, this.cameraSentAt = nowMs, total;
1242
+ }
1243
+ receivedMask(latest) {
1244
+ let simulation = this.reply.simulationHz, sends = this.reply.sendHz, mask = 0, tick = latest;
1245
+ for (let bit = 0; bit < chunkQCZOE65N_js.ACK_HISTORY_BITS && (tick = previousSend(tick, simulation, sends), !(tick < 0)); bit++)
1246
+ this.store.received(tick) && (mask = (mask | 1 << bit) >>> 0);
1247
+ return mask;
1248
+ }
1249
+ watchLatency() {
1250
+ let rtt = this.clock.rttMs;
1251
+ !this.extrapolating && rtt > chunkQCZOE65N_js.HIGH_LATENCY_ENTER_MS ? this.extrapolating = true : this.extrapolating && rtt < chunkQCZOE65N_js.HIGH_LATENCY_LEAVE_MS && (this.extrapolating = false), this.extrapolating && (this.statistics.extrapolatingFrames += 1);
1252
+ }
1253
+ };
1254
+ function sendsOn(tick, simulationHz, sendHz) {
1255
+ return Math.floor(tick * sendHz / simulationHz) !== Math.floor((tick - 1) * sendHz / simulationHz);
1256
+ }
1257
+ function previousSend(tick, simulationHz, sendHz) {
1258
+ for (let candidate = tick - 1; candidate > 0; candidate--)
1259
+ if (sendsOn(candidate, simulationHz, sendHz)) return candidate;
1260
+ return -1;
1261
+ }
1262
+
1263
+ // src/interactives/rooms/state-replica.ts
1264
+ var ROOM_STATE_SLOT = 65520;
1265
+ var STATE_CHUNK_BYTES = 16, STATE_FRAME_VERSION = 1, STATE_HEADER_BYTES = 20;
1266
+ var MAX_STATE_FRAGMENTS = 255;
1267
+ var TickStateReplica = class {
1268
+ constructor() {
1269
+ this.confirmed = new Uint8Array(0);
1270
+ this.confirmedView = new DataView(this.confirmed.buffer);
1271
+ this.pending = new Uint8Array(0);
1272
+ this.predictedBytes = new Uint8Array(0);
1273
+ this.predictedView = new DataView(this.predictedBytes.buffer);
1274
+ this.received = new Uint8Array(Math.ceil(256 / 8));
1275
+ this.confirmedTickValue = -1;
1276
+ this.pendingTick = -1;
1277
+ this.pendingCount = 0;
1278
+ this.pendingFragments = 0;
1279
+ this.listeners = [];
1280
+ this.predictor = null;
1281
+ this.stats = { fragments: 0, completed: 0, keyframes: 0, stale: 0, malformed: 0 };
1282
+ }
1283
+ get tick() {
1284
+ return this.confirmedTickValue;
1285
+ }
1286
+ get bytes() {
1287
+ return this.confirmed.length;
1288
+ }
1289
+ get state() {
1290
+ return this.confirmedView;
1291
+ }
1292
+ get stateBytes() {
1293
+ return this.confirmed;
1294
+ }
1295
+ onState(listener) {
1296
+ return this.listeners.push(listener), () => {
1297
+ let at = this.listeners.indexOf(listener);
1298
+ at >= 0 && this.listeners.splice(at, 1);
1299
+ };
1300
+ }
1301
+ predict(predictor) {
1302
+ this.predictor = predictor;
1303
+ }
1304
+ predicted(toTick) {
1305
+ let predictor = this.predictor;
1306
+ return predictor === null || this.confirmedTickValue === -1 || toTick <= this.confirmedTickValue ? this.confirmedView : (this.predictedBytes.set(this.confirmed), predictor(this.confirmedView, this.predictedView, this.confirmedTickValue, toTick), this.predictedView);
1307
+ }
1308
+ ingest(view, offset, length) {
1309
+ if (length < 20 || view.getUint8(offset + 0) !== 1)
1310
+ return this.stats.malformed++, false;
1311
+ this.stats.fragments++;
1312
+ let keyframe = (view.getUint8(offset + 1) & 1) !== 0, fragment = view.getUint8(offset + 2), fragments = view.getUint8(offset + 3), tick = view.getUint32(offset + 4, true), base = view.getUint32(offset + 8, true), firstChunk = view.getUint16(offset + 12, true), chunkCount = view.getUint16(offset + 14, true), stateBytes = view.getUint32(offset + 16, true);
1313
+ if (fragment >= fragments)
1314
+ return this.stats.malformed++, false;
1315
+ if (this.confirmedTickValue !== -1 && tick <= this.confirmedTickValue)
1316
+ return this.stats.stale++, false;
1317
+ if (!keyframe && (this.confirmedTickValue === -1 || base !== this.confirmedTickValue || stateBytes !== this.confirmed.length))
1318
+ return this.stats.stale++, false;
1319
+ if (tick !== this.pendingTick) {
1320
+ if (this.pendingTick !== -1 && tick < this.pendingTick)
1321
+ return this.stats.stale++, false;
1322
+ this.begin(tick, stateBytes, fragments, keyframe);
1323
+ }
1324
+ let bit = 1 << fragment % 8, byte = fragment >> 3;
1325
+ return (this.received[byte] & bit) !== 0 ? false : this.apply(view, offset + 20, offset + length, firstChunk, chunkCount) ? (this.received[byte] |= bit, this.pendingCount++, this.pendingCount < this.pendingFragments ? false : (this.complete(keyframe), true)) : (this.stats.malformed++, this.pendingTick = -1, false);
1326
+ }
1327
+ begin(tick, stateBytes, fragments, keyframe) {
1328
+ this.confirmed.length !== stateBytes && (this.confirmed = new Uint8Array(stateBytes), this.confirmedView = new DataView(this.confirmed.buffer), this.pending = new Uint8Array(stateBytes), this.predictedBytes = new Uint8Array(stateBytes), this.predictedView = new DataView(this.predictedBytes.buffer), keyframe || (this.confirmedTickValue = -1)), this.pending.set(this.confirmed), this.received.fill(0), this.pendingTick = tick, this.pendingCount = 0, this.pendingFragments = fragments;
1329
+ }
1330
+ apply(view, at, end, firstChunk, chunkCount) {
1331
+ let maskBytes = Math.ceil(chunkCount / 8), read = at + maskBytes;
1332
+ if (read > end) return false;
1333
+ let state = this.pending;
1334
+ for (let index = 0; index < chunkCount; index++) {
1335
+ if ((view.getUint8(at + (index >> 3)) & 1 << index % 8) === 0) continue;
1336
+ let from = (firstChunk + index) * 16, to = Math.min(from + 16, state.length);
1337
+ if (from >= to || read + (to - from) > end) return false;
1338
+ for (let i = from; i < to; i++) state[i] = view.getUint8(read++);
1339
+ }
1340
+ return true;
1341
+ }
1342
+ complete(keyframe) {
1343
+ this.confirmed.set(this.pending), this.confirmedTickValue = this.pendingTick, this.pendingTick = -1, this.stats.completed++, keyframe && this.stats.keyframes++;
1344
+ for (let i = 0; i < this.listeners.length; i++) this.listeners[i](this.confirmedTickValue, this.confirmedView);
1345
+ }
1346
+ };
1347
+
1348
+ // src/interactives/rooms/links/web-socket.ts
1349
+ var BINARY = "arraybuffer", OPEN = 1, WebSocketLink = class {
1350
+ constructor(socket) {
1351
+ this.transport = Transport.WebSocket;
1352
+ this.socket = socket;
1353
+ }
1354
+ send(_lane, bytes) {
1355
+ this.socket.readyState === (1) && this.socket.send(bytes);
1356
+ }
1357
+ close() {
1358
+ this.socket.close();
1359
+ }
1360
+ }, Session = class {
1361
+ constructor(socket, request, handler, settle) {
1362
+ this.admitted = false;
1363
+ this.finished = false;
1364
+ this.opened = () => {
1365
+ this.socket.send(this.request);
1366
+ };
1367
+ this.message = (event) => {
1368
+ let data = event.data;
1369
+ if (typeof data == "string") return;
1370
+ let bytes = new Uint8Array(data);
1371
+ if (this.admitted) {
1372
+ this.handler.frame(chunkQCZOE65N_js.Lane.Datagram, bytes);
1373
+ return;
1374
+ }
1375
+ this.admitted = true, this.settle({ link: new WebSocketLink(this.socket), reply: bytes });
1376
+ };
1377
+ this.ended = () => {
1378
+ this.finished || (this.finished = true, this.admitted ? this.handler.closed() : this.settle(null));
1379
+ };
1380
+ this.socket = socket, this.request = request, this.handler = handler, this.settle = settle;
1381
+ }
1382
+ attach() {
1383
+ let socket = this.socket;
1384
+ socket.binaryType = BINARY, socket.onopen = this.opened, socket.onmessage = this.message, socket.onerror = this.ended, socket.onclose = this.ended;
1385
+ }
1386
+ }, WebSocketDialer = class {
1387
+ constructor(url) {
1388
+ this.transport = Transport.WebSocket;
1389
+ this.url = url;
1390
+ }
1391
+ dial(request, handler) {
1392
+ return typeof globalThis.WebSocket != "function" ? Promise.resolve(null) : new Promise((settle) => {
1393
+ try {
1394
+ new Session(new WebSocket(this.url), request, handler, settle).attach();
1395
+ } catch {
1396
+ settle(null);
1397
+ }
1398
+ });
1399
+ }
1400
+ };
1401
+
1402
+ // src/interactives/rooms/links/stream-framer.ts
1403
+ var StreamFramer = class {
1404
+ constructor() {
1405
+ this.buffer = new Uint8Array(chunkQCZOE65N_js.STREAM_BUFFER_BYTES);
1406
+ this.view = new DataView(this.buffer.buffer);
1407
+ this.start = 0;
1408
+ this.end = 0;
1409
+ }
1410
+ push(chunk) {
1411
+ return this.end + chunk.length > this.buffer.length && (this.buffer.copyWithin(0, this.start, this.end), this.end -= this.start, this.start = 0), this.end + chunk.length > this.buffer.length ? false : (this.buffer.set(chunk, this.end), this.end += chunk.length, true);
1412
+ }
1413
+ next() {
1414
+ if (this.end - this.start < chunkQCZOE65N_js.LANE_LENGTH_BYTES) return null;
1415
+ let length = this.view.getUint16(this.start, true), from = this.start + chunkQCZOE65N_js.LANE_LENGTH_BYTES;
1416
+ return this.end - from < length ? null : (this.start = from + length, this.buffer.subarray(from, from + length));
1417
+ }
1418
+ };
1419
+ function lengthPrefixed(bytes, out) {
1420
+ let total = chunkQCZOE65N_js.LANE_LENGTH_BYTES + bytes.length;
1421
+ return total > out.length ? -1 : (out[0] = bytes.length & 255, out[1] = bytes.length >>> 8, out.set(bytes, chunkQCZOE65N_js.LANE_LENGTH_BYTES), total);
1422
+ }
1423
+
1424
+ // src/interactives/rooms/links/web-transport.ts
1425
+ var RELIABLE_SCRATCH = 8;
1426
+ function ignore() {
1427
+ }
1428
+ function shut(session) {
1429
+ try {
1430
+ session?.close();
1431
+ } catch {
1432
+ return;
1433
+ }
1434
+ }
1435
+ var WebTransportLink = class {
1436
+ constructor(session, stream, datagrams) {
1437
+ this.transport = Transport.WebTransport;
1438
+ this.next = 0;
1439
+ this.open = true;
1440
+ this.session = session, this.stream = stream, this.datagrams = datagrams, this.scratch = Array.from({ length: (8) }, () => new SizedViews(new Uint8Array(chunkQCZOE65N_js.PACKET_BYTES + chunkQCZOE65N_js.LANE_LENGTH_BYTES)));
1441
+ }
1442
+ send(lane, bytes) {
1443
+ if (!this.open) return;
1444
+ if (lane === chunkQCZOE65N_js.Lane.Datagram) {
1445
+ this.datagrams.write(bytes).catch(ignore);
1446
+ return;
1447
+ }
1448
+ let scratch = this.scratch[this.next];
1449
+ this.next = (this.next + 1) % (8);
1450
+ let length = lengthPrefixed(bytes, scratch.buffer);
1451
+ length < 0 || this.stream.write(scratch.of(length)).catch(ignore);
1452
+ }
1453
+ close() {
1454
+ this.open && (this.open = false, shut(this.session));
1455
+ }
1456
+ }, Watch = class {
1457
+ constructor(handler) {
1458
+ this.done = false;
1459
+ this.end = () => {
1460
+ this.done || (this.done = true, this.handler.closed());
1461
+ };
1462
+ this.handler = handler;
1463
+ }
1464
+ };
1465
+ async function pumpDatagrams(reader, handler, watch) {
1466
+ try {
1467
+ for (; ; ) {
1468
+ let read = await reader.read();
1469
+ if (read.done) break;
1470
+ handler.frame(chunkQCZOE65N_js.Lane.Datagram, read.value);
1471
+ }
1472
+ } catch {
1473
+ watch.end();
1474
+ return;
1475
+ }
1476
+ watch.end();
1477
+ }
1478
+ async function pumpStream(reader, framer, handler, watch) {
1479
+ try {
1480
+ for (; ; ) {
1481
+ for (let frame = framer.next(); frame; frame = framer.next()) handler.frame(chunkQCZOE65N_js.Lane.Reliable, frame);
1482
+ let read = await reader.read();
1483
+ if (read.done || !framer.push(read.value)) break;
1484
+ }
1485
+ } catch {
1486
+ watch.end();
1487
+ return;
1488
+ }
1489
+ watch.end();
1490
+ }
1491
+ var WebTransportDialer = class _WebTransportDialer {
1492
+ constructor(url, options = {}) {
1493
+ this.transport = Transport.WebTransport;
1494
+ this.url = url, this.options = options;
1495
+ }
1496
+ static available() {
1497
+ return typeof globalThis.WebTransport == "function";
1498
+ }
1499
+ async dial(request, handler) {
1500
+ if (!_WebTransportDialer.available()) return null;
1501
+ let session = null;
1502
+ try {
1503
+ session = new WebTransport(this.url, this.options), await session.ready;
1504
+ let stream = await session.createBidirectionalStream(), writer = stream.writable.getWriter(), prefixed = new Uint8Array(chunkQCZOE65N_js.LANE_LENGTH_BYTES + request.length);
1505
+ lengthPrefixed(request, prefixed), await writer.write(prefixed);
1506
+ let reader = stream.readable.getReader(), framer = new StreamFramer(), reply = framer.next();
1507
+ for (; !reply; ) {
1508
+ let read = await reader.read();
1509
+ if (read.done || !framer.push(read.value))
1510
+ return shut(session), null;
1511
+ reply = framer.next();
1512
+ }
1513
+ let copied = reply.slice(), watch = new Watch(handler), datagrams = session.datagrams.writable.getWriter(), link = new WebTransportLink(session, writer, datagrams);
1514
+ return pumpDatagrams(session.datagrams.readable.getReader(), handler, watch), pumpStream(reader, framer, handler, watch), session.closed.then(watch.end, watch.end), { link, reply: copied };
1515
+ } catch {
1516
+ return shut(session), null;
1517
+ }
1518
+ }
1519
+ };
1520
+
1521
+ exports.Connecting = Connecting;
1522
+ exports.Connector = Connector;
1523
+ exports.GAME_CHANNEL_RELIABLE_BASE = GAME_CHANNEL_RELIABLE_BASE;
1524
+ exports.GAME_CHANNEL_SLOTS = GAME_CHANNEL_SLOTS;
1525
+ exports.InMemoryNetworkMemory = InMemoryNetworkMemory;
1526
+ exports.JoinStatus = JoinStatus;
1527
+ exports.Locomotion = Locomotion;
1528
+ exports.LocomotionMotion = LocomotionMotion;
1529
+ exports.MAX_STATE_FRAGMENTS = (255);
1530
+ exports.ROOM_STATE_SLOT = (65520);
1531
+ exports.RoomClient = RoomClient;
1532
+ exports.RoomPhase = RoomPhase;
1533
+ exports.STATE_CHUNK_BYTES = (16);
1534
+ exports.STATE_FRAME_VERSION = (1);
1535
+ exports.STATE_HEADER_BYTES = (20);
1536
+ exports.SizedViews = SizedViews;
1537
+ exports.StorageNetworkMemory = StorageNetworkMemory;
1538
+ exports.TickStateReplica = TickStateReplica;
1539
+ exports.Transport = Transport;
1540
+ exports.WebSocketDialer = WebSocketDialer;
1541
+ exports.WebTransportDialer = WebTransportDialer;
1542
+ exports.blankReply = blankReply;
1543
+ exports.currentNetwork = currentNetwork;
1544
+ exports.decodeJoinReply = decodeJoinReply;
1545
+ exports.isqrt = isqrt;
1546
+ exports.locomotionMotion = locomotionMotion;
1547
+ exports.perAxisUnit = perAxisUnit;
1548
+ exports.previousSend = previousSend;
1549
+ exports.resumeRequest = resumeRequest;
1550
+ exports.sendsOn = sendsOn;
1551
+ exports.spawn = spawn;
1552
+ exports.steer = steer;
1553
+ exports.ticketRequest = ticketRequest;