cuju-render 0.1.0__py3-none-any.whl

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 (382) hide show
  1. cuju/render/__init__.py +759 -0
  2. cuju/render/__main__.py +1065 -0
  3. cuju/render/_export/__init__.py +3 -0
  4. cuju/render/_export/feed.py +542 -0
  5. cuju/render/_export/sizes.py +157 -0
  6. cuju/render/_export/video.py +1618 -0
  7. cuju/render/_export/video_jobs.py +408 -0
  8. cuju/render/_format/__init__.py +3 -0
  9. cuju/render/_format/annotations.py +235 -0
  10. cuju/render/_format/codec.py +307 -0
  11. cuju/render/_format/keep.py +121 -0
  12. cuju/render/_format/recording.py +860 -0
  13. cuju/render/_format/writer.py +54 -0
  14. cuju/render/_guide/__init__.py +3 -0
  15. cuju/render/_guide/doctor.py +523 -0
  16. cuju/render/_guide/help.py +62 -0
  17. cuju/render/_guide/tutorial.py +254 -0
  18. cuju/render/_http/__init__.py +3 -0
  19. cuju/render/_http/commands.py +57 -0
  20. cuju/render/_http/headers.py +103 -0
  21. cuju/render/_http/launch.py +500 -0
  22. cuju/render/_http/launchers.py +408 -0
  23. cuju/render/_http/pwa.py +128 -0
  24. cuju/render/_http/server.py +2105 -0
  25. cuju/render/_http/window.py +360 -0
  26. cuju/render/_moments/__init__.py +3 -0
  27. cuju/render/_moments/captions.py +284 -0
  28. cuju/render/_moments/events.py +1123 -0
  29. cuju/render/_moments/search.py +694 -0
  30. cuju/render/_packages/__init__.py +3 -0
  31. cuju/render/_packages/glsl.py +746 -0
  32. cuju/render/_packages/loudness.py +334 -0
  33. cuju/render/_packages/pack.py +1959 -0
  34. cuju/render/_packages/presentation.py +1376 -0
  35. cuju/render/_packages/vocabulary.py +609 -0
  36. cuju/render/_playing/__init__.py +3 -0
  37. cuju/render/_playing/achievements.py +463 -0
  38. cuju/render/_playing/bench.py +609 -0
  39. cuju/render/_playing/challenges.py +1813 -0
  40. cuju/render/_playing/demo.py +323 -0
  41. cuju/render/_playing/draw.py +211 -0
  42. cuju/render/_playing/errors.py +20 -0
  43. cuju/render/_playing/game.py +645 -0
  44. cuju/render/_playing/limits.py +339 -0
  45. cuju/render/_playing/play.py +926 -0
  46. cuju/render/_playing/policy_worker.py +250 -0
  47. cuju/render/_playing/strict.py +810 -0
  48. cuju/render/_registry/__init__.py +3 -0
  49. cuju/render/_registry/clips.py +394 -0
  50. cuju/render/_registry/joints.py +108 -0
  51. cuju/render/_registry/teams.py +2058 -0
  52. cuju/render/_store/__init__.py +3 -0
  53. cuju/render/_store/home.py +70 -0
  54. cuju/render/_store/library.py +604 -0
  55. cuju/render/_store/samples.py +163 -0
  56. cuju/render/_text/__init__.py +3 -0
  57. cuju/render/_text/languages.py +637 -0
  58. cuju/render/_text/messages.py +1396 -0
  59. cuju/render/_tournaments/__init__.py +3 -0
  60. cuju/render/_tournaments/results.py +547 -0
  61. cuju/render/_tournaments/tournament.py +2742 -0
  62. cuju/render/_tournaments/tournament_cli.py +587 -0
  63. cuju/render/_tournaments/tournament_runner.py +1975 -0
  64. cuju/render/_version.py +6 -0
  65. cuju/render/_watch/__init__.py +3 -0
  66. cuju/render/_watch/grid.py +265 -0
  67. cuju/render/_watch/live.py +664 -0
  68. cuju/render/_watch/notebook.py +79 -0
  69. cuju/render/_watch/show.py +171 -0
  70. cuju/render/samples/sample-11v11.cjr +0 -0
  71. cuju/render/samples/sample-5v5.cjr +0 -0
  72. cuju/render/samples/teams/starter/main.py +33 -0
  73. cuju/render/scenarios/benchmark_full_game_11_vs_11_easy.py +46 -0
  74. cuju/render/scenarios/benchmark_full_game_11_vs_11_hard.py +46 -0
  75. cuju/render/scenarios/benchmark_full_game_11_vs_11_medium.py +46 -0
  76. cuju/render/scenarios/benchmark_full_game_5_vs_5_easy.py +34 -0
  77. cuju/render/scenarios/benchmark_full_game_5_vs_5_hard.py +34 -0
  78. cuju/render/scenarios/benchmark_full_game_5_vs_5_medium.py +34 -0
  79. cuju/render/web/assets/adboard_polygon.webp +0 -0
  80. cuju/render/web/assets/adboard_your_ad_here.webp +0 -0
  81. cuju/render/web/assets/animations/kaykit-rig-medium-combatmelee.glb +0 -0
  82. cuju/render/web/assets/animations/kaykit-rig-medium-general.glb +0 -0
  83. cuju/render/web/assets/animations/kaykit-rig-medium-movementadvanced.glb +0 -0
  84. cuju/render/web/assets/animations/kaykit-rig-medium-movementbasic.glb +0 -0
  85. cuju/render/web/assets/animations/kaykit-rig-medium-simulation.glb +0 -0
  86. cuju/render/web/assets/animations/kaykit-rig-medium-special.glb +0 -0
  87. cuju/render/web/assets/ball.glb +0 -0
  88. cuju/render/web/assets/challenges/3_vs_1_with_keeper.mp4 +0 -0
  89. cuju/render/web/assets/challenges/3_vs_1_with_keeper.webp +0 -0
  90. cuju/render/web/assets/challenges/corner.mp4 +0 -0
  91. cuju/render/web/assets/challenges/corner.webp +0 -0
  92. cuju/render/web/assets/challenges/counterattack_easy.mp4 +0 -0
  93. cuju/render/web/assets/challenges/counterattack_easy.webp +0 -0
  94. cuju/render/web/assets/challenges/counterattack_hard.mp4 +0 -0
  95. cuju/render/web/assets/challenges/counterattack_hard.webp +0 -0
  96. cuju/render/web/assets/challenges/empty_goal.mp4 +0 -0
  97. cuju/render/web/assets/challenges/empty_goal.webp +0 -0
  98. cuju/render/web/assets/challenges/empty_goal_close.mp4 +0 -0
  99. cuju/render/web/assets/challenges/empty_goal_close.webp +0 -0
  100. cuju/render/web/assets/challenges/manifest.json +375 -0
  101. cuju/render/web/assets/challenges/one_on_one.mp4 +0 -0
  102. cuju/render/web/assets/challenges/one_on_one.webp +0 -0
  103. cuju/render/web/assets/challenges/one_on_one_hard.mp4 +0 -0
  104. cuju/render/web/assets/challenges/one_on_one_hard.webp +0 -0
  105. cuju/render/web/assets/challenges/pass_and_shoot_with_keeper.mp4 +0 -0
  106. cuju/render/web/assets/challenges/pass_and_shoot_with_keeper.webp +0 -0
  107. cuju/render/web/assets/challenges/run_pass_and_shoot_with_keeper.mp4 +0 -0
  108. cuju/render/web/assets/challenges/run_pass_and_shoot_with_keeper.webp +0 -0
  109. cuju/render/web/assets/challenges/run_to_score.mp4 +0 -0
  110. cuju/render/web/assets/challenges/run_to_score.webp +0 -0
  111. cuju/render/web/assets/challenges/run_to_score_with_keeper.mp4 +0 -0
  112. cuju/render/web/assets/challenges/run_to_score_with_keeper.webp +0 -0
  113. cuju/render/web/assets/challenges/single_goal_versus_lazy.mp4 +0 -0
  114. cuju/render/web/assets/challenges/single_goal_versus_lazy.webp +0 -0
  115. cuju/render/web/assets/crowd.webp +0 -0
  116. cuju/render/web/assets/crowd_normal.webp +0 -0
  117. cuju/render/web/assets/cuju-logo-384.png +0 -0
  118. cuju/render/web/assets/cuju-logo.png +0 -0
  119. cuju/render/web/assets/cuju-logo.svg +46 -0
  120. cuju/render/web/assets/cuju-mark-light.svg +33 -0
  121. cuju/render/web/assets/cuju-mark.svg +33 -0
  122. cuju/render/web/assets/goal.glb +0 -0
  123. cuju/render/web/assets/grass.webp +0 -0
  124. cuju/render/web/assets/hair_black.png +0 -0
  125. cuju/render/web/assets/hair_blonde.png +0 -0
  126. cuju/render/web/assets/hair_brown.png +0 -0
  127. cuju/render/web/assets/hair_darkblonde.png +0 -0
  128. cuju/render/web/assets/hair_long01.glb +0 -0
  129. cuju/render/web/assets/hair_long02.glb +0 -0
  130. cuju/render/web/assets/hair_medium01.glb +0 -0
  131. cuju/render/web/assets/hair_red.png +0 -0
  132. cuju/render/web/assets/hair_short01.glb +0 -0
  133. cuju/render/web/assets/hair_short02.glb +0 -0
  134. cuju/render/web/assets/icons/cuju-192.png +0 -0
  135. cuju/render/web/assets/icons/cuju-512.png +0 -0
  136. cuju/render/web/assets/icons/cuju-maskable-512.png +0 -0
  137. cuju/render/web/assets/kit_goalkeeper.webp +0 -0
  138. cuju/render/web/assets/kit_mask.png +0 -0
  139. cuju/render/web/assets/kit_normal.webp +0 -0
  140. cuju/render/web/assets/manifest.json +601 -0
  141. cuju/render/web/assets/models/kaykit-barbarian.glb +0 -0
  142. cuju/render/web/assets/models/kaykit-barbarian.json +23 -0
  143. cuju/render/web/assets/models/kaykit-knight.glb +0 -0
  144. cuju/render/web/assets/models/kaykit-knight.json +23 -0
  145. cuju/render/web/assets/models/kaykit-mage.glb +0 -0
  146. cuju/render/web/assets/models/kaykit-mage.json +23 -0
  147. cuju/render/web/assets/models/kaykit-mannequin-medium.glb +0 -0
  148. cuju/render/web/assets/models/kaykit-mannequin-medium.json +23 -0
  149. cuju/render/web/assets/models/kaykit-ranger.glb +0 -0
  150. cuju/render/web/assets/models/kaykit-ranger.json +23 -0
  151. cuju/render/web/assets/models/kaykit-rogue-hooded.glb +0 -0
  152. cuju/render/web/assets/models/kaykit-rogue-hooded.json +23 -0
  153. cuju/render/web/assets/models/kaykit-rogue.glb +0 -0
  154. cuju/render/web/assets/models/kaykit-rogue.json +23 -0
  155. cuju/render/web/assets/models/kaykit-skeleton-mage.glb +0 -0
  156. cuju/render/web/assets/models/kaykit-skeleton-mage.json +23 -0
  157. cuju/render/web/assets/models/kaykit-skeleton-minion.glb +0 -0
  158. cuju/render/web/assets/models/kaykit-skeleton-minion.json +23 -0
  159. cuju/render/web/assets/models/kaykit-skeleton-rogue.glb +0 -0
  160. cuju/render/web/assets/models/kaykit-skeleton-rogue.json +23 -0
  161. cuju/render/web/assets/models/kaykit-skeleton-warrior.glb +0 -0
  162. cuju/render/web/assets/models/kaykit-skeleton-warrior.json +23 -0
  163. cuju/render/web/assets/pitch.webp +0 -0
  164. cuju/render/web/assets/pitch_normal.webp +0 -0
  165. cuju/render/web/assets/player.glb +0 -0
  166. cuju/render/web/assets/shoe.webp +0 -0
  167. cuju/render/web/assets/shoe_sole.png +0 -0
  168. cuju/render/web/assets/skin_01.png +0 -0
  169. cuju/render/web/assets/skin_02.png +0 -0
  170. cuju/render/web/assets/skin_03.png +0 -0
  171. cuju/render/web/assets/skin_04.png +0 -0
  172. cuju/render/web/assets/sounds/applause.ogg +0 -0
  173. cuju/render/web/assets/sounds/beach-wave-1.ogg +0 -0
  174. cuju/render/web/assets/sounds/beach-wave-2.ogg +0 -0
  175. cuju/render/web/assets/sounds/beach-wave-3.ogg +0 -0
  176. cuju/render/web/assets/sounds/beach-wave-4.ogg +0 -0
  177. cuju/render/web/assets/sounds/city-horn.ogg +0 -0
  178. cuju/render/web/assets/sounds/city-loop.ogg +0 -0
  179. cuju/render/web/assets/sounds/city-siren.ogg +0 -0
  180. cuju/render/web/assets/sounds/crowd-cheer.ogg +0 -0
  181. cuju/render/web/assets/sounds/crowd-loop.ogg +0 -0
  182. cuju/render/web/assets/sounds/crowd-ooh.ogg +0 -0
  183. cuju/render/web/assets/sounds/gulls.ogg +0 -0
  184. cuju/render/web/assets/sounds/neon-sting.ogg +0 -0
  185. cuju/render/web/assets/sounds/rain-loop.ogg +0 -0
  186. cuju/render/web/assets/sounds/sounds.json +46 -0
  187. cuju/render/web/assets/sounds/space-beep.ogg +0 -0
  188. cuju/render/web/assets/sounds/space-hum.ogg +0 -0
  189. cuju/render/web/assets/sounds/space-radio.ogg +0 -0
  190. cuju/render/web/assets/sounds/whistle-long.ogg +0 -0
  191. cuju/render/web/assets/sounds/whistle-short.ogg +0 -0
  192. cuju/render/web/assets/sounds/wind-loop.ogg +0 -0
  193. cuju/render/web/easy.css +357 -0
  194. cuju/render/web/export.html +23 -0
  195. cuju/render/web/feed.css +262 -0
  196. cuju/render/web/feed.html +28 -0
  197. cuju/render/web/flat.css +120 -0
  198. cuju/render/web/home.css +837 -0
  199. cuju/render/web/index.html +373 -0
  200. cuju/render/web/js/boot.js +50 -0
  201. cuju/render/web/js/broadcast/audio.js +2141 -0
  202. cuju/render/web/js/broadcast/celebrate.js +1238 -0
  203. cuju/render/web/js/broadcast/decisions.js +609 -0
  204. cuju/render/web/js/broadcast/hud.js +352 -0
  205. cuju/render/web/js/broadcast/show.js +3614 -0
  206. cuju/render/web/js/broadcast/transition.js +2231 -0
  207. cuju/render/web/js/broadcast/voices.js +153 -0
  208. cuju/render/web/js/capture.js +101 -0
  209. cuju/render/web/js/core/accessibility.js +90 -0
  210. cuju/render/web/js/core/api.js +429 -0
  211. cuju/render/web/js/core/comfort.js +135 -0
  212. cuju/render/web/js/core/i18n.js +705 -0
  213. cuju/render/web/js/core/icons.js +167 -0
  214. cuju/render/web/js/core/input-settings.js +156 -0
  215. cuju/render/web/js/core/keys.js +277 -0
  216. cuju/render/web/js/core/language-ui.js +125 -0
  217. cuju/render/web/js/core/menu.js +853 -0
  218. cuju/render/web/js/core/names.js +113 -0
  219. cuju/render/web/js/core/page-structure.js +110 -0
  220. cuju/render/web/js/core/scenarios.js +109 -0
  221. cuju/render/web/js/core/spoilers.js +236 -0
  222. cuju/render/web/js/core/typeahead.js +38 -0
  223. cuju/render/web/js/export/dom-picture.js +330 -0
  224. cuju/render/web/js/export/export-host.js +97 -0
  225. cuju/render/web/js/export/feed-dialog.js +191 -0
  226. cuju/render/web/js/export/feed-params.js +266 -0
  227. cuju/render/web/js/export/feed.js +363 -0
  228. cuju/render/web/js/export/mp4-mux.js +295 -0
  229. cuju/render/web/js/export/photo-core.js +313 -0
  230. cuju/render/web/js/export/photo.js +1314 -0
  231. cuju/render/web/js/export/safe-frame.js +59 -0
  232. cuju/render/web/js/export/size-fields.js +103 -0
  233. cuju/render/web/js/export/sizes.js +178 -0
  234. cuju/render/web/js/export/video-boot.js +55 -0
  235. cuju/render/web/js/export/video-browser.js +325 -0
  236. cuju/render/web/js/export/video-export.js +417 -0
  237. cuju/render/web/js/export/video-plan.js +207 -0
  238. cuju/render/web/js/export/video-range.js +185 -0
  239. cuju/render/web/js/export/webm-mux.js +198 -0
  240. cuju/render/web/js/feed-boot.js +151 -0
  241. cuju/render/web/js/feed-frame.js +101 -0
  242. cuju/render/web/js/help/doctor.js +488 -0
  243. cuju/render/web/js/help/firstrun.js +379 -0
  244. cuju/render/web/js/help/help-center.js +438 -0
  245. cuju/render/web/js/help/install-offer.js +164 -0
  246. cuju/render/web/js/help/install-state.js +104 -0
  247. cuju/render/web/js/help/lessons-core.js +207 -0
  248. cuju/render/web/js/help/lessons.js +463 -0
  249. cuju/render/web/js/help/palette.js +584 -0
  250. cuju/render/web/js/help/pwa.js +257 -0
  251. cuju/render/web/js/help/tour-core.js +241 -0
  252. cuju/render/web/js/help/tour.js +461 -0
  253. cuju/render/web/js/main.js +2513 -0
  254. cuju/render/web/js/pages/draw.js +188 -0
  255. cuju/render/web/js/pages/fieldpage.js +530 -0
  256. cuju/render/web/js/pages/home.js +521 -0
  257. cuju/render/web/js/pages/matches.js +779 -0
  258. cuju/render/web/js/pages/moments-ui.js +359 -0
  259. cuju/render/web/js/pages/queue-filters.js +63 -0
  260. cuju/render/web/js/pages/recording-groups.js +80 -0
  261. cuju/render/web/js/pages/recordings.js +1069 -0
  262. cuju/render/web/js/play/bench.js +347 -0
  263. cuju/render/web/js/play/challenges.js +1302 -0
  264. cuju/render/web/js/play/medals.js +127 -0
  265. cuju/render/web/js/play/play.js +1953 -0
  266. cuju/render/web/js/play/teasers.js +196 -0
  267. cuju/render/web/js/play/touch.js +350 -0
  268. cuju/render/web/js/play/tournament-layout.js +487 -0
  269. cuju/render/web/js/play/tournament-results.js +441 -0
  270. cuju/render/web/js/play/tournament-strict.js +560 -0
  271. cuju/render/web/js/play/tournament.js +2585 -0
  272. cuju/render/web/js/players/animate.js +972 -0
  273. cuju/render/web/js/players/clips.js +224 -0
  274. cuju/render/web/js/players/kaykit.js +162 -0
  275. cuju/render/web/js/players/kits.js +676 -0
  276. cuju/render/web/js/players/number-patch.js +82 -0
  277. cuju/render/web/js/players/players.js +2694 -0
  278. cuju/render/web/js/players/recolor.js +893 -0
  279. cuju/render/web/js/players/retarget.js +325 -0
  280. cuju/render/web/js/players/rig-numbers.js +174 -0
  281. cuju/render/web/js/presentation/animator.js +231 -0
  282. cuju/render/web/js/presentation/assign.js +85 -0
  283. cuju/render/web/js/presentation/behaviors.js +440 -0
  284. cuju/render/web/js/presentation/budget.js +209 -0
  285. cuju/render/web/js/presentation/catalog.js +1674 -0
  286. cuju/render/web/js/presentation/clocks.js +72 -0
  287. cuju/render/web/js/presentation/commands.js +301 -0
  288. cuju/render/web/js/presentation/contract.js +240 -0
  289. cuju/render/web/js/presentation/effects.js +904 -0
  290. cuju/render/web/js/presentation/flash.js +605 -0
  291. cuju/render/web/js/presentation/freeze-worklet.js +22 -0
  292. cuju/render/web/js/presentation/glsl.js +464 -0
  293. cuju/render/web/js/presentation/host.js +323 -0
  294. cuju/render/web/js/presentation/index.js +2066 -0
  295. cuju/render/web/js/presentation/loudness-worklet.js +235 -0
  296. cuju/render/web/js/presentation/loudness.js +740 -0
  297. cuju/render/web/js/presentation/moments.js +536 -0
  298. cuju/render/web/js/presentation/post.js +327 -0
  299. cuju/render/web/js/presentation/preview.js +180 -0
  300. cuju/render/web/js/presentation/protocol.js +174 -0
  301. cuju/render/web/js/presentation/reach.js +158 -0
  302. cuju/render/web/js/presentation/rigging.js +130 -0
  303. cuju/render/web/js/presentation/sandbox.js +157 -0
  304. cuju/render/web/js/presentation/shaders.js +235 -0
  305. cuju/render/web/js/presentation/stage.js +402 -0
  306. cuju/render/web/js/presentation/teamaudio.js +722 -0
  307. cuju/render/web/js/presentation/tracks.js +197 -0
  308. cuju/render/web/js/presentation/values.js +81 -0
  309. cuju/render/web/js/recording/annotation-data.js +203 -0
  310. cuju/render/web/js/recording/captions.js +491 -0
  311. cuju/render/web/js/recording/codec.js +185 -0
  312. cuju/render/web/js/recording/decode-worker.js +70 -0
  313. cuju/render/web/js/recording/decode.js +94 -0
  314. cuju/render/web/js/recording/episodes.js +46 -0
  315. cuju/render/web/js/recording/format.js +461 -0
  316. cuju/render/web/js/recording/live.js +348 -0
  317. cuju/render/web/js/recording/moments-query.js +59 -0
  318. cuju/render/web/js/recording/moments.js +149 -0
  319. cuju/render/web/js/recording/pose.js +86 -0
  320. cuju/render/web/js/recording/timeline.js +275 -0
  321. cuju/render/web/js/teams/art.js +50 -0
  322. cuju/render/web/js/teams/clip-editor.js +293 -0
  323. cuju/render/web/js/teams/editor.js +1979 -0
  324. cuju/render/web/js/teams/library.js +344 -0
  325. cuju/render/web/js/teams/painter.js +633 -0
  326. cuju/render/web/js/teams/surprise-ui.js +195 -0
  327. cuju/render/web/js/teams/surprise.js +497 -0
  328. cuju/render/web/js/teams/team-check.js +127 -0
  329. cuju/render/web/js/watch/annotations.js +270 -0
  330. cuju/render/web/js/watch/flat.js +366 -0
  331. cuju/render/web/js/watch/grid.js +436 -0
  332. cuju/render/web/js/watch/pitch2d.js +289 -0
  333. cuju/render/web/js/watch/player-tools.js +192 -0
  334. cuju/render/web/js/watch/presets.js +201 -0
  335. cuju/render/web/js/world/arenas.js +997 -0
  336. cuju/render/web/js/world/ball.js +204 -0
  337. cuju/render/web/js/world/cameras.js +982 -0
  338. cuju/render/web/js/world/crowd.js +376 -0
  339. cuju/render/web/js/world/field.js +227 -0
  340. cuju/render/web/js/world/framing.js +145 -0
  341. cuju/render/web/js/world/occlusion.js +48 -0
  342. cuju/render/web/js/world/pitch.js +703 -0
  343. cuju/render/web/js/world/scene.js +395 -0
  344. cuju/render/web/js/world/sky.js +325 -0
  345. cuju/render/web/js/world/stadium.js +1262 -0
  346. cuju/render/web/js/world/vendor-sky.js +367 -0
  347. cuju/render/web/js/world/weather.js +264 -0
  348. cuju/render/web/languages/en.json +4750 -0
  349. cuju/render/web/lessons.json +137 -0
  350. cuju/render/web/manifest.webmanifest +23 -0
  351. cuju/render/web/style.css +8399 -0
  352. cuju/render/web/sw.js +235 -0
  353. cuju/render/web/vendor/fabric/LICENSE +16 -0
  354. cuju/render/web/vendor/fabric/fabric.min.mjs +1 -0
  355. cuju/render/web/vendor/lucide/LICENSE +43 -0
  356. cuju/render/web/vendor/lucide/icons.js +141 -0
  357. cuju/render/web/vendor/three/LICENSE +21 -0
  358. cuju/render/web/vendor/three/build/three.core.js +60586 -0
  359. cuju/render/web/vendor/three/build/three.module.js +19719 -0
  360. cuju/render/web/vendor/three/examples/jsm/loaders/GLTFLoader.js +4925 -0
  361. cuju/render/web/vendor/three/examples/jsm/postprocessing/EffectComposer.js +365 -0
  362. cuju/render/web/vendor/three/examples/jsm/postprocessing/MaskPass.js +195 -0
  363. cuju/render/web/vendor/three/examples/jsm/postprocessing/OutputPass.js +148 -0
  364. cuju/render/web/vendor/three/examples/jsm/postprocessing/Pass.js +191 -0
  365. cuju/render/web/vendor/three/examples/jsm/postprocessing/RenderPass.js +193 -0
  366. cuju/render/web/vendor/three/examples/jsm/postprocessing/ShaderPass.js +135 -0
  367. cuju/render/web/vendor/three/examples/jsm/postprocessing/UnrealBloomPass.js +541 -0
  368. cuju/render/web/vendor/three/examples/jsm/shaders/CopyShader.js +52 -0
  369. cuju/render/web/vendor/three/examples/jsm/shaders/LuminosityHighPassShader.js +68 -0
  370. cuju/render/web/vendor/three/examples/jsm/shaders/OutputShader.js +103 -0
  371. cuju/render/web/vendor/three/examples/jsm/utils/BufferGeometryUtils.js +1501 -0
  372. cuju/render/web/vendor/three/examples/jsm/utils/SkeletonUtils.js +496 -0
  373. cuju_render-0.1.0.dist-info/METADATA +116 -0
  374. cuju_render-0.1.0.dist-info/RECORD +382 -0
  375. cuju_render-0.1.0.dist-info/WHEEL +4 -0
  376. cuju_render-0.1.0.dist-info/licenses/LICENSE +202 -0
  377. cuju_render-0.1.0.dist-info/licenses/LICENSES/CC-BY-4.0.txt +396 -0
  378. cuju_render-0.1.0.dist-info/licenses/LICENSES/CC0-1.0.txt +127 -0
  379. cuju_render-0.1.0.dist-info/licenses/LICENSES/ISC.txt +16 -0
  380. cuju_render-0.1.0.dist-info/licenses/LICENSES/MIT.txt +24 -0
  381. cuju_render-0.1.0.dist-info/licenses/LICENSES/Unlicense.txt +13 -0
  382. cuju_render-0.1.0.dist-info/licenses/NOTICE +35 -0
@@ -0,0 +1,536 @@
1
+ // Copyright 2026 The cuju Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // The shared things a team borrows on its own moments, section 10 of the contract. Camera and
5
+ // time suggestions, environment moments of the sky, the floodlights, the fog, lightning and a tifo
6
+ // in the team's own stand, and the overlay slots a worker draws in.
7
+ //
8
+ // Each is a suggestion that the renderer weighs, by the limits L1 to L6. A suggestion counts only
9
+ // for the team's own events. The camera follows one only in the broadcast camera or in the team's
10
+ // own celebration, never while the viewer uses the transport, and in open play only to tighten the
11
+ // framing for at most 1.5 seconds. A time suggestion freezes for at most 0.3 seconds or slows to no
12
+ // less than a quarter for at most 1.5 seconds, once per team in 30 seconds, on recordings and
13
+ // replays and on a live stream only with a second of buffer left. An environment moment lasts at
14
+ // most 6 seconds, one at a time with 20 seconds between a team's moments, and fades in and out over
15
+ // at least 0.3 seconds through the flash governor. Reduced motion and the viewer's setting refuse
16
+ // camera and time suggestions. Overlay slots never cover the score, the clock or the banners,
17
+ // and each slot counts the flashes of what it shows and hides for a while once it reaches the
18
+ // limit of the flash governor, since its drawing sits beside the picture the backstop reads.
19
+
20
+ import * as THREE from 'three';
21
+ import { SLOT_SIZES } from './commands.js';
22
+ import { SLOT_GRID, SlotGuard, downsample } from './flash.js';
23
+ import { clamp } from './values.js';
24
+
25
+ export const CAMERA_PLAY_SECONDS = 1.5;
26
+ export const CAMERA_SECONDS = 4;
27
+ export const TIME_COOLDOWN = 30;
28
+ export const MOMENT_SECONDS = 6;
29
+ export const MOMENT_COOLDOWN = 20;
30
+ export const MOMENT_FADE = 0.3;
31
+ export const SLOTS = ['badge', 'lowerThird', 'sting', 'card', 'lineup'];
32
+ // The fields of view of the shots, as a share of the framing they tighten.
33
+ const SHOTS = { closeup: 0.55, orbit: 0.75, low: 0.8, behindBall: 0.85, path: 0.9 };
34
+ // Where each slot sits, by the side of its team, in the stage's own frame.
35
+ const SLOT_STYLES = {
36
+ badge: (side) => `top:58px;${side ? 'right' : 'left'}:16px;width:96px;height:96px`,
37
+ lowerThird: (side) => `bottom:96px;${side ? 'right' : 'left'}:24px;width:360px;height:90px`,
38
+ sting: () => 'top:50%;left:50%;width:320px;height:180px;transform:translate(-50%,-50%)',
39
+ card: (side) => `top:30%;${side ? 'right' : 'left'}:24px;width:200px;height:200px`,
40
+ lineup: (side) => `top:20%;${side ? 'right' : 'left'}:8%;width:30%;height:50%`,
41
+ };
42
+
43
+ export class Moments {
44
+ constructor(presentation) {
45
+ this.presentation = presentation;
46
+ this.camera = null;
47
+ this.time = null;
48
+ this.environment = null;
49
+ this.lastTime = [-Infinity, -Infinity];
50
+ this.lastMoment = [-Infinity, -Infinity];
51
+ this.refused = [];
52
+ this.accepted = { camera: 0, time: 0, environment: 0, overlays: 0 };
53
+ this.slots = new Map();
54
+ // The viewer's settings, which turn the team's camera and time suggestions off.
55
+ this.settings = { camera: true, time: true };
56
+ try {
57
+ this.settings.camera = localStorage.getItem('cuju.teamCamera') !== 'false';
58
+ this.settings.time = localStorage.getItem('cuju.teamTime') !== 'false';
59
+ } catch {
60
+ // Storage can be unavailable, the settings then keep their defaults.
61
+ }
62
+ }
63
+
64
+ refuse(kind, why) {
65
+ this.refused.push(`${kind}: ${why}`);
66
+ this.refused = this.refused.slice(-12);
67
+ return false;
68
+ }
69
+
70
+ // The event a suggestion answers, which must be the team's own.
71
+ own(pkg, id) {
72
+ const p = this.presentation;
73
+ const step = Number(String(id || '').split(':')[1]);
74
+ const events = Number.isFinite(step) && p.catalog ? p.catalog.eventsAt(step) : [];
75
+ const hit = events.find((e) => e.id === id) || p.recent.get(id) || null;
76
+ return hit && hit.team === pkg.side ? hit : null;
77
+ }
78
+
79
+ // The viewer uses the transport while a key or a click of the timeline is less than two
80
+ // seconds old.
81
+ transportBusy() {
82
+ const app = this.presentation.app;
83
+ return performance.now() - (app.lastTransport || -Infinity) < 2000;
84
+ }
85
+
86
+ suggestCamera(pkg, c) {
87
+ const p = this.presentation;
88
+ const app = p.app;
89
+ if (!this.settings.camera || app.reducedMotion) {
90
+ return this.refuse('camera', 'the viewer turned team cameras off or reduces motion');
91
+ }
92
+ const event = this.own(pkg, c.event);
93
+ if (!event) {
94
+ return this.refuse('camera', 'not the team’s own event');
95
+ }
96
+ const director = app.director;
97
+ const celebration = director && director.cel && director.cel.goal && director.cel.goal.team === pkg.side;
98
+ const mode = app.cameras ? app.cameras.mode : null;
99
+ if (!(mode === 'broadcast' && !(director && director.running)) && !(mode === 'scripted' && celebration)) {
100
+ return this.refuse('camera', 'the camera is the viewer’s or the director’s');
101
+ }
102
+ if (this.transportBusy()) {
103
+ return this.refuse('camera', 'the viewer uses the transport');
104
+ }
105
+ if (this.camera && this.camera.priority > (c.priority ?? 1)) {
106
+ return this.refuse('camera', 'a stronger suggestion runs');
107
+ }
108
+ const seconds = Math.min(c.duration ?? 2, celebration ? CAMERA_SECONDS : CAMERA_PLAY_SECONDS);
109
+ const now = p.clocks.cosmetic;
110
+ this.camera = { pkg, shot: c.shot, subject: c.subject || (event.player != null ? `p${event.player}` : 'ball'), from: now, to: now + seconds, priority: c.priority ?? 1, fov: SHOTS[c.shot] || 0.8 };
111
+ this.accepted.camera += 1;
112
+ return true;
113
+ }
114
+
115
+ // The point a camera suggestion frames, in three's frame, or null.
116
+ subjectPoint(subject, out = new THREE.Vector3()) {
117
+ const p = this.presentation;
118
+ if (subject === 'ball' || !subject) {
119
+ return p.app.ball ? out.copy(p.app.ball.mesh.position) : null;
120
+ }
121
+ if (/^p\d+$/.test(subject) && p.players && p.app.pose) {
122
+ return p.players.position(p.app.pose, Number(subject.slice(1)), out).setY(1.1);
123
+ }
124
+ return null;
125
+ }
126
+
127
+ // What the camera takes of a running suggestion this drawing, a target to lean toward and a
128
+ // share of the field of view, or null. The cameras call it as they finish a shot.
129
+ cameraAdjust() {
130
+ const s = this.camera;
131
+ if (!s) {
132
+ return null;
133
+ }
134
+ const now = this.presentation.clocks.cosmetic;
135
+ if (now > s.to || this.transportBusy() || this.presentation.app.reducedMotion) {
136
+ this.camera = null;
137
+ return null;
138
+ }
139
+ const k = Math.min(1, (now - s.from) / 0.4, (s.to - now) / 0.4);
140
+ const target = this.subjectPoint(s.subject);
141
+ return target ? { target, amount: clamp(k, 0, 1) * 0.6, fov: 1 + (s.fov - 1) * clamp(k, 0, 1) } : null;
142
+ }
143
+
144
+ suggestTime(pkg, c) {
145
+ const p = this.presentation;
146
+ const app = p.app;
147
+ const tl = app.timeline;
148
+ if (!this.settings.time || app.reducedMotion) {
149
+ return this.refuse('time', 'the viewer turned team time off or reduces motion');
150
+ }
151
+ if (!this.own(pkg, c.event)) {
152
+ return this.refuse('time', 'not the team’s own event');
153
+ }
154
+ const now = p.clocks.cosmetic;
155
+ if (now - this.lastTime[pkg.side] < TIME_COOLDOWN || this.time) {
156
+ return this.refuse('time', 'one time suggestion per team in 30 seconds');
157
+ }
158
+ if (!tl || !tl.playing || tl.direction < 0 || tl.speed !== 1 || this.transportBusy()) {
159
+ return this.refuse('time', 'the viewer’s transport is not at plain play');
160
+ }
161
+ const freeze = clamp(c.freeze || 0, 0, 0.3);
162
+ const slow = c.slow ? { speed: clamp(c.slow.speed, 0.25, 1), seconds: clamp(c.slow.seconds, 0, 1.5) } : null;
163
+ const cost = freeze + (slow ? slow.seconds * (1 - slow.speed) : 0);
164
+ if (tl.live && tl.behindLive - cost < 1) {
165
+ return this.refuse('time', 'a live stream needs a second of buffer after it');
166
+ }
167
+ const event = this.own(pkg, c.event);
168
+ const at = c.at === 'contact' && event.data && event.data.contactT != null ? event.data.contactT : event.t + (typeof c.at === 'number' ? c.at : 0);
169
+ this.time = { pkg, at, freeze, slow, started: null };
170
+ this.lastTime[pkg.side] = now;
171
+ this.accepted.time += 1;
172
+ return true;
173
+ }
174
+
175
+ // The share of real time the timeline plays this drawing, 1 without a time suggestion. The
176
+ // page multiplies its step of play by it.
177
+ timeScale(dt) {
178
+ const t = this.time;
179
+ if (!t) {
180
+ return 1;
181
+ }
182
+ const p = this.presentation;
183
+ const tl = p.app.timeline;
184
+ if (!tl || !tl.playing || tl.direction < 0 || this.transportBusy() || p.app.reducedMotion) {
185
+ this.time = null;
186
+ return 1;
187
+ }
188
+ if (t.started == null) {
189
+ if (p.clocks.sim + 1e-6 < t.at) {
190
+ return 1;
191
+ }
192
+ t.started = p.clocks.cosmetic;
193
+ }
194
+ const age = p.clocks.cosmetic - t.started;
195
+ if (age < t.freeze) {
196
+ return 0;
197
+ }
198
+ if (t.slow && age < t.freeze + t.slow.seconds) {
199
+ return t.slow.speed;
200
+ }
201
+ this.time = null;
202
+ return 1;
203
+ }
204
+
205
+ // An environment moment of a reflex or a worker, the sky, the floodlights, the fog, lightning
206
+ // or a tifo, each needing its feature.
207
+ moment(pkg, c) {
208
+ const p = this.presentation;
209
+ const event = this.own(pkg, c.event);
210
+ if (!event) {
211
+ return this.refuse('environment', 'not the team’s own event');
212
+ }
213
+ const now = p.clocks.cosmetic;
214
+ if (this.environment || now - this.lastMoment[pkg.side] < MOMENT_COOLDOWN) {
215
+ return this.refuse('environment', 'one moment at a time, 20 seconds apart for a team');
216
+ }
217
+ const has = (f) => p.hasFeature(pkg, f);
218
+ const m = { pkg, from: now, to: now + clamp(c.duration ?? 4, MOMENT_FADE * 2, MOMENT_SECONDS), base: null, parts: {} };
219
+ if (has('environment.sky')) {
220
+ for (const key of ['sky', 'floodlights', 'fog']) {
221
+ if (c[key]) {
222
+ m.parts[key] = { color: c[key].color || c[key].tint || [255, 255, 255], amount: clamp(c[key].amount ?? c[key].level ?? 1, 0, 1.5) };
223
+ }
224
+ }
225
+ }
226
+ if (has('environment.lightning') && c.lightning) {
227
+ m.parts.lightning = { target: c.lightning.target || 'goal', event, done: false };
228
+ }
229
+ if (has('fans.tifo') && c.tifo) {
230
+ m.parts.tifo = { file: c.tifo };
231
+ }
232
+ if (!Object.keys(m.parts).length) {
233
+ return this.refuse('environment', 'the package lists none of the features of its parts');
234
+ }
235
+ this.environment = m;
236
+ this.lastMoment[pkg.side] = now;
237
+ this.accepted.environment += 1;
238
+ this.capture(m);
239
+ return true;
240
+ }
241
+
242
+ // The renderer's own values a moment changes, kept to give back when it ends.
243
+ capture(m) {
244
+ const app = this.presentation.app;
245
+ const sky = app.environment && app.environment.sky ? app.environment.sky.material.uniforms : null;
246
+ const flood = app.stadium && app.stadium.floodlights ? app.stadium.floodlights : null;
247
+ m.base = {
248
+ tint: sky && sky.uTint ? sky.uTint.value.clone() : null,
249
+ flood: flood ? flood.lights.map((l) => ({ color: l.color.clone(), intensity: l.intensity })) : null,
250
+ fog: app.view && app.view.scene.fog ? app.view.scene.fog.color.clone() : null,
251
+ hemi: app.view && app.view.hemi ? app.view.hemi.intensity : null,
252
+ };
253
+ }
254
+
255
+ // Moves the moment on by one drawing, faded and governed, and gives the renderer's values
256
+ // back as it ends.
257
+ update() {
258
+ const m = this.environment;
259
+ const p = this.presentation;
260
+ if (!m) {
261
+ return;
262
+ }
263
+ const app = p.app;
264
+ const now = p.clocks.cosmetic;
265
+ const k = clamp(Math.min((now - m.from) / MOMENT_FADE, (m.to - now) / MOMENT_FADE), 0, 1);
266
+ const env = p.flash.envelope(`${m.pkg.side}:environment`);
267
+ const level = env.apply(now, k) * p.flashFactor();
268
+ const color = (c) => new THREE.Color().setRGB(c[0] / 255, c[1] / 255, c[2] / 255, THREE.SRGBColorSpace);
269
+ const sky = app.environment && app.environment.sky ? app.environment.sky.material.uniforms : null;
270
+ if (m.parts.sky && sky && sky.uTint && m.base.tint) {
271
+ sky.uTint.value.copy(m.base.tint).lerp(color(m.parts.sky.color), Math.min(1, m.parts.sky.amount) * level);
272
+ }
273
+ const flood = app.stadium && app.stadium.floodlights;
274
+ if (m.parts.floodlights && flood && m.base.flood) {
275
+ flood.lights.forEach((l, i) => {
276
+ l.color.copy(m.base.flood[i].color).lerp(color(m.parts.floodlights.color), level);
277
+ l.intensity = m.base.flood[i].intensity * (1 + (m.parts.floodlights.amount - 1) * level);
278
+ });
279
+ }
280
+ if (m.parts.fog && app.view.scene.fog && m.base.fog) {
281
+ app.view.scene.fog.color.copy(m.base.fog).lerp(color(m.parts.fog.color), Math.min(1, m.parts.fog.amount) * level);
282
+ }
283
+ if (m.parts.lightning) {
284
+ this.lightning(m, now);
285
+ }
286
+ if (m.parts.tifo) {
287
+ this.tifo(m, level);
288
+ }
289
+ if (now >= m.to) {
290
+ this.restore(m);
291
+ this.environment = null;
292
+ }
293
+ }
294
+
295
+ // One bolt from the sky to the team's target, a single rise of light that the governor counts.
296
+ lightning(m, now) {
297
+ const p = this.presentation;
298
+ const app = p.app;
299
+ const part = m.parts.lightning;
300
+ if (!part.bolt) {
301
+ const side = m.pkg.side;
302
+ const target = part.target === 'ball' && app.ball ? app.ball.mesh.position.clone()
303
+ : Array.isArray(part.target) ? new THREE.Vector3(part.target[0], part.target[2], -part.target[1])
304
+ // The goal the team attacks, its crossbar.
305
+ : new THREE.Vector3(side === 0 ? 52.5 : -52.5, 2.44, 0);
306
+ const points = [];
307
+ const rand = mulberry(m.from * 1000);
308
+ const top = target.clone().add(new THREE.Vector3((rand() - 0.5) * 20, 70, (rand() - 0.5) * 20));
309
+ for (let i = 0; i <= 16; i++) {
310
+ const u = i / 16;
311
+ const q = top.clone().lerp(target, u);
312
+ if (i > 0 && i < 16) {
313
+ q.x += (rand() - 0.5) * 4 * (1 - u * 0.5);
314
+ q.z += (rand() - 0.5) * 4 * (1 - u * 0.5);
315
+ }
316
+ points.push(q);
317
+ }
318
+ const geometry = new THREE.BufferGeometry().setFromPoints(points);
319
+ part.bolt = new THREE.Line(geometry, new THREE.LineBasicMaterial({ color: 0xe8efff, transparent: true, blending: THREE.AdditiveBlending, depthWrite: false, fog: false }));
320
+ part.bolt.frustumCulled = false;
321
+ app.view.scene.add(part.bolt);
322
+ part.at = now;
323
+ }
324
+ const age = now - part.at;
325
+ // One rise and one fall of light, never a strobe.
326
+ const env = p.flash.envelope(`${m.pkg.side}:lightning`);
327
+ const flash = env.apply(now, age < 0.08 ? 1 : Math.max(0, 1 - (age - 0.08) / 0.4)) * p.flashFactor();
328
+ part.bolt.material.opacity = flash;
329
+ if (app.view.hemi && m.base.hemi != null) {
330
+ app.view.hemi.intensity = m.base.hemi * (1 + 0.8 * flash);
331
+ }
332
+ if (age > 0.6 && !part.done) {
333
+ part.done = true;
334
+ part.bolt.removeFromParent();
335
+ part.bolt.geometry.dispose();
336
+ part.bolt.material.dispose();
337
+ if (app.view.hemi && m.base.hemi != null) {
338
+ app.view.hemi.intensity = m.base.hemi;
339
+ }
340
+ }
341
+ }
342
+
343
+ // A tifo, an image of the package, raised in the stand behind the goal the team defends.
344
+ tifo(m, level) {
345
+ const p = this.presentation;
346
+ const part = m.parts.tifo;
347
+ if (!part.mesh) {
348
+ const texture = new THREE.Texture();
349
+ const material = new THREE.MeshBasicMaterial({ map: texture, transparent: true, opacity: 0, side: THREE.DoubleSide, fog: true });
350
+ part.mesh = new THREE.Mesh(new THREE.PlaneGeometry(34, 11), material);
351
+ // Team 0 defends negative x, its fans stand behind that goal.
352
+ const x = m.pkg.side === 0 ? -62 : 62;
353
+ part.mesh.position.set(x, 9, 0);
354
+ part.mesh.rotation.y = m.pkg.side === 0 ? Math.PI / 2 : -Math.PI / 2;
355
+ p.app.view.scene.add(part.mesh);
356
+ p.fetchFile(m.pkg, part.file).then((data) => createImageBitmap(new Blob([data]))).then((bitmap) => {
357
+ texture.image = bitmap;
358
+ texture.colorSpace = THREE.SRGBColorSpace;
359
+ texture.needsUpdate = true;
360
+ part.ready = true;
361
+ }).catch((err) => m.pkg.errors.push(`tifo ${part.file} not shown, ${err.message || err}`));
362
+ }
363
+ part.mesh.material.opacity = part.ready ? 0.95 * level : 0;
364
+ part.mesh.position.y = 4 + 5 * level;
365
+ }
366
+
367
+ restore(m) {
368
+ const app = this.presentation.app;
369
+ const sky = app.environment && app.environment.sky ? app.environment.sky.material.uniforms : null;
370
+ if (m.parts.sky && sky && m.base.tint) {
371
+ sky.uTint.value.copy(m.base.tint);
372
+ }
373
+ const flood = app.stadium && app.stadium.floodlights;
374
+ if (m.parts.floodlights && flood && m.base.flood) {
375
+ flood.lights.forEach((l, i) => {
376
+ l.color.copy(m.base.flood[i].color);
377
+ l.intensity = m.base.flood[i].intensity;
378
+ });
379
+ }
380
+ if (m.parts.fog && app.view.scene.fog && m.base.fog) {
381
+ app.view.scene.fog.color.copy(m.base.fog);
382
+ }
383
+ if (m.parts.lightning && m.parts.lightning.bolt && !m.parts.lightning.done) {
384
+ m.parts.lightning.bolt.removeFromParent();
385
+ }
386
+ if (m.parts.tifo && m.parts.tifo.mesh) {
387
+ m.parts.tifo.mesh.removeFromParent();
388
+ m.parts.tifo.mesh.geometry.dispose();
389
+ m.parts.tifo.mesh.material.map.dispose();
390
+ m.parts.tifo.mesh.material.dispose();
391
+ }
392
+ }
393
+
394
+ // A new epoch or another match ends what runs.
395
+ end() {
396
+ if (this.environment) {
397
+ this.restore(this.environment);
398
+ this.environment = null;
399
+ }
400
+ this.camera = null;
401
+ this.time = null;
402
+ }
403
+
404
+ // The overlay slots of a package, a canvas each, which the worker's bitmaps fill.
405
+ slot(pkg, name) {
406
+ const key = `${pkg.side}:${name}`;
407
+ let s = this.slots.get(key);
408
+ if (!s) {
409
+ const stage = document.getElementById('stage');
410
+ if (!stage) {
411
+ return null;
412
+ }
413
+ const canvas = document.createElement('canvas');
414
+ canvas.className = 'team-overlay';
415
+ canvas.dataset.slot = name;
416
+ canvas.dataset.team = String(pkg.side);
417
+ canvas.setAttribute('aria-hidden', 'true');
418
+ canvas.style.cssText = `position:absolute;pointer-events:none;z-index:2;${SLOT_STYLES[name](pkg.side)}`;
419
+ canvas.hidden = true;
420
+ stage.appendChild(canvas);
421
+ s = { canvas, context: canvas.getContext('bitmaprenderer'), shown: false, until: Infinity, pkg, name, guard: new SlotGuard(), trips: 0 };
422
+ this.slots.set(key, s);
423
+ }
424
+ return s;
425
+ }
426
+
427
+ // Whether a slot may show now, by the windows of section 10.2.
428
+ window(pkg, name) {
429
+ const p = this.presentation;
430
+ const director = p.app.director;
431
+ if (name === 'badge') {
432
+ return true;
433
+ }
434
+ if (name === 'lineup') {
435
+ return !!(director && director.lineup);
436
+ }
437
+ if (name === 'lowerThird' || name === 'sting') {
438
+ return !!(director && director.cel && director.cel.goal && director.cel.goal.team === pkg.side)
439
+ || (p.recentOwn(pkg, ['goal', 'winner.reveal'], name === 'sting' ? 0.72 : 5));
440
+ }
441
+ if (name === 'card') {
442
+ return p.recentOwn(pkg, ['mvp.reveal', 'winner.reveal'], 8);
443
+ }
444
+ return false;
445
+ }
446
+
447
+ // An overlay command of a worker, with the bitmap the sandbox drew when it draws.
448
+ overlay(pkg, c, bitmap = null) {
449
+ if (!(pkg.manifest.overlays && pkg.manifest.overlays[c.slot])) {
450
+ return this.refuse('overlay', `the package declares no slot ${c.slot}`);
451
+ }
452
+ const s = this.slot(pkg, c.slot);
453
+ if (!s) {
454
+ return false;
455
+ }
456
+ const [width, height] = SLOT_SIZES[c.slot];
457
+ if (bitmap && (bitmap.width !== width || bitmap.height !== height)) {
458
+ bitmap.close();
459
+ return this.refuse('overlay', `a drawing of ${bitmap.width} by ${bitmap.height} pixels for the slot ${c.slot}`);
460
+ }
461
+ if (bitmap && s.context) {
462
+ s.guard.draw(this.measure(bitmap));
463
+ s.canvas.width = width;
464
+ s.canvas.height = height;
465
+ s.context.transferFromImageBitmap(bitmap);
466
+ }
467
+ if (c.op === 'hide') {
468
+ s.shown = false;
469
+ } else {
470
+ s.shown = true;
471
+ }
472
+ this.accepted.overlays += 1;
473
+ return true;
474
+ }
475
+
476
+ // A drawing of a worker as the guard of its slot reads it, over black, or null when the page
477
+ // cannot read it.
478
+ measure(bitmap) {
479
+ try {
480
+ const canvas = this.sampler || (this.sampler = document.createElement('canvas'));
481
+ canvas.width = bitmap.width;
482
+ canvas.height = bitmap.height;
483
+ const g = this.samplerContext || (this.samplerContext = canvas.getContext('2d', { willReadFrequently: true }));
484
+ g.fillStyle = '#000';
485
+ g.fillRect(0, 0, bitmap.width, bitmap.height);
486
+ g.drawImage(bitmap, 0, 0);
487
+ return downsample(g.getImageData(0, 0, bitmap.width, bitmap.height).data, bitmap.width, bitmap.height, SLOT_GRID);
488
+ } catch {
489
+ return null;
490
+ }
491
+ }
492
+
493
+ // Shows each slot only inside its window, hidden on other pages and in the 2D view, and hides
494
+ // for a while a slot whose drawings flash past the limit.
495
+ updateSlots() {
496
+ const p = this.presentation;
497
+ const onStage = p.app.page === 'watch' || p.app.page === 'play';
498
+ const now = p.clocks.cosmetic;
499
+ for (const s of this.slots.values()) {
500
+ const wanted = onStage && s.shown && this.window(s.pkg, s.name);
501
+ s.canvas.hidden = !s.guard.show(now, wanted);
502
+ if (s.guard.trips !== s.trips) {
503
+ s.trips = s.guard.trips;
504
+ this.refuse('overlay', `the slot ${s.name} flashed past the limit and hides for ${s.guard.hold} s`);
505
+ }
506
+ }
507
+ }
508
+
509
+ disposeSlots() {
510
+ for (const s of this.slots.values()) {
511
+ s.canvas.remove();
512
+ }
513
+ this.slots.clear();
514
+ }
515
+
516
+ snapshot() {
517
+ return {
518
+ camera: this.camera ? { shot: this.camera.shot, subject: this.camera.subject } : null,
519
+ time: this.time ? { freeze: this.time.freeze, slow: this.time.slow, started: this.time.started != null } : null,
520
+ environment: this.environment ? Object.keys(this.environment.parts) : null,
521
+ accepted: { ...this.accepted }, refused: this.refused.slice(), settings: { ...this.settings },
522
+ slots: [...this.slots.values()].map((s) => ({ team: s.pkg.side, slot: s.name, shown: !s.canvas.hidden, trips: s.guard.trips })),
523
+ };
524
+ }
525
+ }
526
+
527
+ function mulberry(seed) {
528
+ let a = Math.floor(seed) >>> 0;
529
+ return () => {
530
+ a = (a + 0x6D2B79F5) >>> 0;
531
+ let t = a;
532
+ t = Math.imul(t ^ (t >>> 15), t | 1);
533
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
534
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
535
+ };
536
+ }