brick-engine-js 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (477) hide show
  1. package/.env.local.example +2 -0
  2. package/.github/workflows/publish.yml +73 -0
  3. package/.prettierignore +2 -0
  4. package/.prettierrc.json +8 -0
  5. package/README.adoc +84 -0
  6. package/dist/8e23286c2fdf41fd795f.svg +32 -0
  7. package/dist/CNAME +1 -0
  8. package/dist/app.js +2 -0
  9. package/dist/app.js.map +1 -0
  10. package/dist/brick-engine.js +2 -0
  11. package/dist/brick-engine.js.map +1 -0
  12. package/dist/config/configs.d.ts +180 -0
  13. package/dist/config/configs.test.d.ts +1 -0
  14. package/dist/config/env.d.ts +2 -0
  15. package/dist/config/env.test.d.ts +1 -0
  16. package/dist/config/styles.d.ts +0 -0
  17. package/dist/core/Game.d.ts +107 -0
  18. package/dist/core/Game.test.d.ts +1 -0
  19. package/dist/core/InitialStateSnapshot.d.ts +19 -0
  20. package/dist/core/InitialStateSnapshot.test.d.ts +1 -0
  21. package/dist/core/helpers/CellHelper.d.ts +13 -0
  22. package/dist/core/helpers/CellHelper.test.d.ts +1 -0
  23. package/dist/core/helpers/ControlInputHandlerHelper.d.ts +32 -0
  24. package/dist/core/helpers/ControlInputHandlerHelper.test.d.ts +1 -0
  25. package/dist/core/helpers/CoordinateHelper.d.ts +54 -0
  26. package/dist/core/helpers/CoordinateHelper.test.d.ts +1 -0
  27. package/dist/core/helpers/InterfaceIdentifierHelper.d.ts +7 -0
  28. package/dist/core/helpers/InterfaceIdentifierHelper.test.d.ts +1 -0
  29. package/dist/core/helpers/RelativeValuesHelper.d.ts +23 -0
  30. package/dist/core/helpers/RelativeValuesHelper.test.d.ts +1 -0
  31. package/dist/core/module/control/GameControl.d.ts +62 -0
  32. package/dist/core/module/control/GameControl.test.d.ts +1 -0
  33. package/dist/core/module/control/GameControlKeyBinding.d.ts +36 -0
  34. package/dist/core/module/control/GameControlKeyBinding.test.d.ts +1 -0
  35. package/dist/core/module/grid/GameGrid.d.ts +399 -0
  36. package/dist/core/module/grid/GameGrid.test.d.ts +1 -0
  37. package/dist/core/module/grid/GameHudGrid.d.ts +24 -0
  38. package/dist/core/module/grid/GameHudGrid.test.d.ts +1 -0
  39. package/dist/core/module/grid/engines/GridAnalysisEngine.d.ts +29 -0
  40. package/dist/core/module/grid/engines/GridAnalysisEngine.test.d.ts +1 -0
  41. package/dist/core/module/grid/engines/GridLineEngine.d.ts +56 -0
  42. package/dist/core/module/grid/engines/GridLineEngine.test.d.ts +1 -0
  43. package/dist/core/module/grid/engines/GridMovementEngine.d.ts +29 -0
  44. package/dist/core/module/grid/engines/GridMovementEngine.test.d.ts +1 -0
  45. package/dist/core/module/grid/engines/GridRegionEngine.d.ts +26 -0
  46. package/dist/core/module/grid/engines/GridRegionEngine.test.d.ts +1 -0
  47. package/dist/core/module/grid/engines/GridTransformEngine.d.ts +24 -0
  48. package/dist/core/module/grid/engines/GridTransformEngine.test.d.ts +1 -0
  49. package/dist/core/module/renderer/DisplayRenderer.d.ts +51 -0
  50. package/dist/core/module/renderer/DisplayRenderer.test.d.ts +1 -0
  51. package/dist/core/module/renderer/GameRenderer.d.ts +59 -0
  52. package/dist/core/module/renderer/GameRenderer.test.d.ts +1 -0
  53. package/dist/core/module/renderer/HudRenderer.d.ts +56 -0
  54. package/dist/core/module/renderer/HudRenderer.test.d.ts +1 -0
  55. package/dist/core/module/score/GameScore.d.ts +117 -0
  56. package/dist/core/module/score/GameScore.test.d.ts +1 -0
  57. package/dist/core/module/session/GameSession.d.ts +20 -0
  58. package/dist/core/module/session/GameSession.test.d.ts +1 -0
  59. package/dist/core/module/sound/GameSound.d.ts +85 -0
  60. package/dist/core/module/sound/GameSound.test.d.ts +1 -0
  61. package/dist/core/module/state/GameState.d.ts +172 -0
  62. package/dist/core/module/state/GameState.test.d.ts +1 -0
  63. package/dist/core/module/text/GameText.d.ts +87 -0
  64. package/dist/core/module/text/GameText.test.d.ts +1 -0
  65. package/dist/core/module/time/GameTime.d.ts +76 -0
  66. package/dist/core/module/time/GameTime.test.d.ts +1 -0
  67. package/dist/core/types/Interfaces.d.ts +53 -0
  68. package/dist/core/types/Types.d.ts +114 -0
  69. package/dist/core/types/enums.d.ts +106 -0
  70. package/dist/core/types/modules.d.ts +723 -0
  71. package/dist/css/app.743066d8e4172b0e73f9.css +824 -0
  72. package/dist/css/app.743066d8e4172b0e73f9.css.map +1 -0
  73. package/dist/docs/GAME_DEVELOPER_GUIDE.html +727 -0
  74. package/dist/docs/brick-engine-guide.html +610 -0
  75. package/dist/docs/diagrams/lifecycle.mmd +19 -0
  76. package/dist/docs/documentation_style_guide.html +994 -0
  77. package/dist/docs/getting-started.html +648 -0
  78. package/dist/docs/images/lifecycle.svg +1 -0
  79. package/dist/docs/index.html +593 -0
  80. package/dist/docs/jsdoc_standard.html +656 -0
  81. package/dist/docs/publishing.html +573 -0
  82. package/dist/docs/reference/enums/Color.html +533 -0
  83. package/dist/docs/reference/enums/ControlEventType.html +505 -0
  84. package/dist/docs/reference/enums/ControlKey.html +529 -0
  85. package/dist/docs/reference/enums/FontAlignment.html +545 -0
  86. package/dist/docs/reference/enums/FontSize.html +517 -0
  87. package/dist/docs/reference/enums/Sound.html +558 -0
  88. package/dist/docs/reference/enums/StateProperty.html +525 -0
  89. package/dist/docs/reference/helpers/CellHelper.html +520 -0
  90. package/dist/docs/reference/helpers/ControlInputHandlerHelper.html +569 -0
  91. package/dist/docs/reference/helpers/CoordinateHelper.html +703 -0
  92. package/dist/docs/reference/helpers/RelativeValuesHelper.html +560 -0
  93. package/dist/docs/reference/interfaces/Debuggable.html +501 -0
  94. package/dist/docs/reference/interfaces/GameModules.html +544 -0
  95. package/dist/docs/reference/interfaces/Initializable.html +495 -0
  96. package/dist/docs/reference/interfaces/RendererInitializable.html +517 -0
  97. package/dist/docs/reference/interfaces/StateSyncable.html +542 -0
  98. package/dist/docs/reference/interfaces/modules/Control.html +648 -0
  99. package/dist/docs/reference/interfaces/modules/Grid.html +1256 -0
  100. package/dist/docs/reference/interfaces/modules/Renderer.html +522 -0
  101. package/dist/docs/reference/interfaces/modules/RendererComposite.html +577 -0
  102. package/dist/docs/reference/interfaces/modules/Score.html +669 -0
  103. package/dist/docs/reference/interfaces/modules/Session.html +585 -0
  104. package/dist/docs/reference/interfaces/modules/State.html +897 -0
  105. package/dist/docs/reference/interfaces/modules/Text.html +668 -0
  106. package/dist/docs/reference/interfaces/modules/Time.html +684 -0
  107. package/dist/docs/reference/modules/Debugger.html +579 -0
  108. package/dist/docs/reference/modules/DisplayRenderer.html +557 -0
  109. package/dist/docs/reference/modules/Game.html +909 -0
  110. package/dist/docs/reference/modules/GameControl.html +716 -0
  111. package/dist/docs/reference/modules/GameGrid.html +1910 -0
  112. package/dist/docs/reference/modules/GameHudGrid.html +508 -0
  113. package/dist/docs/reference/modules/GameMenu.html +538 -0
  114. package/dist/docs/reference/modules/GameRenderer.html +589 -0
  115. package/dist/docs/reference/modules/GameScore.html +664 -0
  116. package/dist/docs/reference/modules/GameSession.html +533 -0
  117. package/dist/docs/reference/modules/GameSound.html +636 -0
  118. package/dist/docs/reference/modules/GameState.html +922 -0
  119. package/dist/docs/reference/modules/GameText.html +701 -0
  120. package/dist/docs/reference/modules/GameTime.html +696 -0
  121. package/dist/docs/reference/modules/HudRenderer.html +568 -0
  122. package/dist/docs/reference/modules/InitialStateSnapshot.html +557 -0
  123. package/dist/docs/reference/modules/SessionModal.html +520 -0
  124. package/dist/docs/reference/types/Axis.html +505 -0
  125. package/dist/docs/reference/types/Cell.html +514 -0
  126. package/dist/docs/reference/types/ControlCallback.html +488 -0
  127. package/dist/docs/reference/types/Coordinate.html +510 -0
  128. package/dist/docs/reference/types/GameEntry.html +514 -0
  129. package/dist/docs/reference/types/GameEvent.html +514 -0
  130. package/dist/docs/reference/types/Piece.html +506 -0
  131. package/dist/docs/reference/types/RendererMetrics.html +514 -0
  132. package/dist/docs/reference/types/Vector.html +509 -0
  133. package/dist/docs/testing_best_practices.html +770 -0
  134. package/dist/favicon.ico +0 -0
  135. package/dist/fonts/digital-7.monoitalic.ttf +0 -0
  136. package/dist/images/cell.svg +32 -0
  137. package/dist/images/close.png +0 -0
  138. package/dist/images/games.png +0 -0
  139. package/dist/images/github.png +0 -0
  140. package/dist/images/letter-a.png +0 -0
  141. package/dist/images/letter-d.png +0 -0
  142. package/dist/images/letter-j.png +0 -0
  143. package/dist/images/letter-s.png +0 -0
  144. package/dist/images/letter-w.png +0 -0
  145. package/dist/images/meta-image.png +0 -0
  146. package/dist/images/number-1.png +0 -0
  147. package/dist/images/number-2.png +0 -0
  148. package/dist/images/number-3.png +0 -0
  149. package/dist/images/number-4.png +0 -0
  150. package/dist/images/number-5.png +0 -0
  151. package/dist/images/number-6.png +0 -0
  152. package/dist/images/splash.gif +0 -0
  153. package/dist/index.d.ts +8 -0
  154. package/dist/index.html +1 -0
  155. package/dist/index.test.d.ts +1 -0
  156. package/dist/main.d.ts +3 -0
  157. package/dist/main.test.d.ts +1 -0
  158. package/dist/menu/GameMenu.d.ts +15 -0
  159. package/dist/menu/GameMenu.test.d.ts +1 -0
  160. package/dist/menu/GameMenuSingleton.d.ts +6 -0
  161. package/dist/menu/GameMenuSingleton.test.d.ts +1 -0
  162. package/dist/menu/GameRepository.d.ts +7 -0
  163. package/dist/menu/GameRepository.test.d.ts +1 -0
  164. package/dist/menu/manager/GameManager.d.ts +6 -0
  165. package/dist/menu/manager/GameManager.test.d.ts +1 -0
  166. package/dist/sounds/sound_00.wav +0 -0
  167. package/dist/sounds/sound_01.wav +0 -0
  168. package/dist/sounds/sound_02.wav +0 -0
  169. package/dist/sounds/sound_03.wav +0 -0
  170. package/dist/sounds/sound_04.wav +0 -0
  171. package/dist/sounds/sound_05.wav +0 -0
  172. package/dist/sounds/sound_06.wav +0 -0
  173. package/dist/sounds/sound_07.wav +0 -0
  174. package/dist/sounds/sound_08.wav +0 -0
  175. package/dist/sounds/sound_09.wav +0 -0
  176. package/dist/sounds/sound_10.wav +0 -0
  177. package/dist/sounds/sound_11.wav +0 -0
  178. package/dist/sounds/sound_12.wav +0 -0
  179. package/dist/sounds/sound_13.wav +0 -0
  180. package/dist/sounds/sound_14.wav +0 -0
  181. package/dist/sounds/sound_15.wav +0 -0
  182. package/dist/types/interfaces.d.ts +5 -0
  183. package/dist/vendor/p5.min.js +1 -0
  184. package/dist/view/Debugger.d.ts +12 -0
  185. package/dist/view/Debugger.test.d.ts +1 -0
  186. package/dist/view/GameView.d.ts +101 -0
  187. package/dist/view/GameView.test.d.ts +1 -0
  188. package/dist/view/SessionModal.d.ts +12 -0
  189. package/dist/view/SessionModal.test.d.ts +4 -0
  190. package/dist/view/components/layout/ButtonLayout.d.ts +25 -0
  191. package/dist/view/components/layout/ButtonLayout.test.d.ts +1 -0
  192. package/dist/view/components/layout/ContainerLayout.d.ts +23 -0
  193. package/dist/view/components/layout/ContainerLayout.test.d.ts +1 -0
  194. package/dist/view/components/layout/FrameLayout.d.ts +11 -0
  195. package/dist/view/components/layout/FrameLayout.test.d.ts +1 -0
  196. package/dist/view/components/ui/BigButton.d.ts +13 -0
  197. package/dist/view/components/ui/BigButton.test.d.ts +1 -0
  198. package/dist/view/components/ui/Button.d.ts +12 -0
  199. package/dist/view/components/ui/Button.test.d.ts +1 -0
  200. package/dist/view/components/ui/Canvas.d.ts +22 -0
  201. package/dist/view/components/ui/Canvas.test.d.ts +1 -0
  202. package/dist/view/components/ui/SmallButton.d.ts +13 -0
  203. package/dist/view/components/ui/SmallButton.test.d.ts +1 -0
  204. package/dist/view/theme/applyColors.d.ts +10 -0
  205. package/dist/view/theme/applyColors.test.d.ts +1 -0
  206. package/dist/view/theme/dimensions.d.ts +13 -0
  207. package/dist/view/theme/dimensions.test.d.ts +1 -0
  208. package/docs/GAME_DEVELOPER_GUIDE.adoc +167 -0
  209. package/docs/brick-engine-guide.adoc +87 -0
  210. package/docs/diagrams/lifecycle.mmd +19 -0
  211. package/docs/documentation_style_guide.adoc +210 -0
  212. package/docs/getting-started.adoc +147 -0
  213. package/docs/images/lifecycle.svg +1 -0
  214. package/docs/jsdoc_standard.adoc +109 -0
  215. package/docs/publishing.adoc +58 -0
  216. package/docs/reference/enums/Color.adoc +35 -0
  217. package/docs/reference/enums/ControlEventType.adoc +28 -0
  218. package/docs/reference/enums/ControlKey.adoc +34 -0
  219. package/docs/reference/enums/FontAlignment.adoc +43 -0
  220. package/docs/reference/enums/FontSize.adoc +31 -0
  221. package/docs/reference/enums/Sound.adoc +42 -0
  222. package/docs/reference/enums/StateProperty.adoc +33 -0
  223. package/docs/reference/helpers/CellHelper.adoc +37 -0
  224. package/docs/reference/helpers/ControlInputHandlerHelper.adoc +57 -0
  225. package/docs/reference/helpers/CoordinateHelper.adoc +118 -0
  226. package/docs/reference/helpers/RelativeValuesHelper.adoc +53 -0
  227. package/docs/reference/interfaces/Debuggable.adoc +29 -0
  228. package/docs/reference/interfaces/GameModules.adoc +35 -0
  229. package/docs/reference/interfaces/Initializable.adoc +24 -0
  230. package/docs/reference/interfaces/RendererInitializable.adoc +33 -0
  231. package/docs/reference/interfaces/StateSyncable.adoc +41 -0
  232. package/docs/reference/interfaces/modules/Control.adoc +98 -0
  233. package/docs/reference/interfaces/modules/Grid.adoc +411 -0
  234. package/docs/reference/interfaces/modules/Renderer.adoc +34 -0
  235. package/docs/reference/interfaces/modules/RendererComposite.adoc +57 -0
  236. package/docs/reference/interfaces/modules/Score.adoc +107 -0
  237. package/docs/reference/interfaces/modules/Session.adoc +66 -0
  238. package/docs/reference/interfaces/modules/State.adoc +290 -0
  239. package/docs/reference/interfaces/modules/Text.adoc +110 -0
  240. package/docs/reference/interfaces/modules/Time.adoc +119 -0
  241. package/docs/reference/modules/Debugger.adoc +71 -0
  242. package/docs/reference/modules/DisplayRenderer.adoc +55 -0
  243. package/docs/reference/modules/Game.adoc +256 -0
  244. package/docs/reference/modules/GameControl.adoc +139 -0
  245. package/docs/reference/modules/GameGrid.adoc +794 -0
  246. package/docs/reference/modules/GameHudGrid.adoc +38 -0
  247. package/docs/reference/modules/GameMenu.adoc +39 -0
  248. package/docs/reference/modules/GameRenderer.adoc +79 -0
  249. package/docs/reference/modules/GameScore.adoc +138 -0
  250. package/docs/reference/modules/GameSession.adoc +43 -0
  251. package/docs/reference/modules/GameSound.adoc +111 -0
  252. package/docs/reference/modules/GameState.adoc +318 -0
  253. package/docs/reference/modules/GameText.adoc +139 -0
  254. package/docs/reference/modules/GameTime.adoc +141 -0
  255. package/docs/reference/modules/HudRenderer.adoc +56 -0
  256. package/docs/reference/modules/InitialStateSnapshot.adoc +47 -0
  257. package/docs/reference/modules/SessionModal.adoc +34 -0
  258. package/docs/reference/types/Axis.adoc +28 -0
  259. package/docs/reference/types/Cell.adoc +29 -0
  260. package/docs/reference/types/ControlCallback.adoc +23 -0
  261. package/docs/reference/types/Coordinate.adoc +29 -0
  262. package/docs/reference/types/GameEntry.adoc +29 -0
  263. package/docs/reference/types/GameEvent.adoc +29 -0
  264. package/docs/reference/types/Piece.adoc +32 -0
  265. package/docs/reference/types/RendererMetrics.adoc +29 -0
  266. package/docs/reference/types/Vector.adoc +28 -0
  267. package/docs/testing_best_practices.adoc +190 -0
  268. package/eslint.config.mjs +29 -0
  269. package/package.json +54 -0
  270. package/public/CNAME +1 -0
  271. package/public/docs/GAME_DEVELOPER_GUIDE.html +727 -0
  272. package/public/docs/brick-engine-guide.html +610 -0
  273. package/public/docs/diagrams/lifecycle.mmd +19 -0
  274. package/public/docs/documentation_style_guide.html +994 -0
  275. package/public/docs/getting-started.html +648 -0
  276. package/public/docs/images/lifecycle.svg +1 -0
  277. package/public/docs/index.html +593 -0
  278. package/public/docs/jsdoc_standard.html +656 -0
  279. package/public/docs/publishing.html +573 -0
  280. package/public/docs/reference/enums/Color.html +533 -0
  281. package/public/docs/reference/enums/ControlEventType.html +505 -0
  282. package/public/docs/reference/enums/ControlKey.html +529 -0
  283. package/public/docs/reference/enums/FontAlignment.html +545 -0
  284. package/public/docs/reference/enums/FontSize.html +517 -0
  285. package/public/docs/reference/enums/Sound.html +558 -0
  286. package/public/docs/reference/enums/StateProperty.html +525 -0
  287. package/public/docs/reference/helpers/CellHelper.html +520 -0
  288. package/public/docs/reference/helpers/ControlInputHandlerHelper.html +569 -0
  289. package/public/docs/reference/helpers/CoordinateHelper.html +703 -0
  290. package/public/docs/reference/helpers/RelativeValuesHelper.html +560 -0
  291. package/public/docs/reference/interfaces/Debuggable.html +501 -0
  292. package/public/docs/reference/interfaces/GameModules.html +544 -0
  293. package/public/docs/reference/interfaces/Initializable.html +495 -0
  294. package/public/docs/reference/interfaces/RendererInitializable.html +517 -0
  295. package/public/docs/reference/interfaces/StateSyncable.html +542 -0
  296. package/public/docs/reference/interfaces/modules/Control.html +648 -0
  297. package/public/docs/reference/interfaces/modules/Grid.html +1256 -0
  298. package/public/docs/reference/interfaces/modules/Renderer.html +522 -0
  299. package/public/docs/reference/interfaces/modules/RendererComposite.html +577 -0
  300. package/public/docs/reference/interfaces/modules/Score.html +669 -0
  301. package/public/docs/reference/interfaces/modules/Session.html +585 -0
  302. package/public/docs/reference/interfaces/modules/State.html +897 -0
  303. package/public/docs/reference/interfaces/modules/Text.html +668 -0
  304. package/public/docs/reference/interfaces/modules/Time.html +684 -0
  305. package/public/docs/reference/modules/Debugger.html +579 -0
  306. package/public/docs/reference/modules/DisplayRenderer.html +557 -0
  307. package/public/docs/reference/modules/Game.html +909 -0
  308. package/public/docs/reference/modules/GameControl.html +716 -0
  309. package/public/docs/reference/modules/GameGrid.html +1910 -0
  310. package/public/docs/reference/modules/GameHudGrid.html +508 -0
  311. package/public/docs/reference/modules/GameMenu.html +538 -0
  312. package/public/docs/reference/modules/GameRenderer.html +589 -0
  313. package/public/docs/reference/modules/GameScore.html +664 -0
  314. package/public/docs/reference/modules/GameSession.html +533 -0
  315. package/public/docs/reference/modules/GameSound.html +636 -0
  316. package/public/docs/reference/modules/GameState.html +922 -0
  317. package/public/docs/reference/modules/GameText.html +701 -0
  318. package/public/docs/reference/modules/GameTime.html +696 -0
  319. package/public/docs/reference/modules/HudRenderer.html +568 -0
  320. package/public/docs/reference/modules/InitialStateSnapshot.html +557 -0
  321. package/public/docs/reference/modules/SessionModal.html +520 -0
  322. package/public/docs/reference/types/Axis.html +505 -0
  323. package/public/docs/reference/types/Cell.html +514 -0
  324. package/public/docs/reference/types/ControlCallback.html +488 -0
  325. package/public/docs/reference/types/Coordinate.html +510 -0
  326. package/public/docs/reference/types/GameEntry.html +514 -0
  327. package/public/docs/reference/types/GameEvent.html +514 -0
  328. package/public/docs/reference/types/Piece.html +506 -0
  329. package/public/docs/reference/types/RendererMetrics.html +514 -0
  330. package/public/docs/reference/types/Vector.html +509 -0
  331. package/public/docs/testing_best_practices.html +770 -0
  332. package/public/favicon.ico +0 -0
  333. package/public/fonts/digital-7.monoitalic.ttf +0 -0
  334. package/public/images/cell.svg +32 -0
  335. package/public/images/close.png +0 -0
  336. package/public/images/games.png +0 -0
  337. package/public/images/github.png +0 -0
  338. package/public/images/letter-a.png +0 -0
  339. package/public/images/letter-d.png +0 -0
  340. package/public/images/letter-j.png +0 -0
  341. package/public/images/letter-s.png +0 -0
  342. package/public/images/letter-w.png +0 -0
  343. package/public/images/meta-image.png +0 -0
  344. package/public/images/number-1.png +0 -0
  345. package/public/images/number-2.png +0 -0
  346. package/public/images/number-3.png +0 -0
  347. package/public/images/number-4.png +0 -0
  348. package/public/images/number-5.png +0 -0
  349. package/public/images/number-6.png +0 -0
  350. package/public/images/splash.gif +0 -0
  351. package/public/index.html +15 -0
  352. package/public/sounds/sound_00.wav +0 -0
  353. package/public/sounds/sound_01.wav +0 -0
  354. package/public/sounds/sound_02.wav +0 -0
  355. package/public/sounds/sound_03.wav +0 -0
  356. package/public/sounds/sound_04.wav +0 -0
  357. package/public/sounds/sound_05.wav +0 -0
  358. package/public/sounds/sound_06.wav +0 -0
  359. package/public/sounds/sound_07.wav +0 -0
  360. package/public/sounds/sound_08.wav +0 -0
  361. package/public/sounds/sound_09.wav +0 -0
  362. package/public/sounds/sound_10.wav +0 -0
  363. package/public/sounds/sound_11.wav +0 -0
  364. package/public/sounds/sound_12.wav +0 -0
  365. package/public/sounds/sound_13.wav +0 -0
  366. package/public/sounds/sound_14.wav +0 -0
  367. package/public/sounds/sound_15.wav +0 -0
  368. package/public/style/body.css +86 -0
  369. package/public/style/buttons.css +233 -0
  370. package/public/style/debugger.css +117 -0
  371. package/public/style/sessionModal.css +155 -0
  372. package/public/style/sourceCodeAndCommands.css +74 -0
  373. package/public/style/splash.css +13 -0
  374. package/public/style/theme.css +137 -0
  375. package/scripts/generate-diagrams.sh +20 -0
  376. package/scripts/generate-docs.js +111 -0
  377. package/src/client-game.d.ts +1 -0
  378. package/src/config/configs.test.ts +20 -0
  379. package/src/config/configs.ts +197 -0
  380. package/src/config/env.test.ts +59 -0
  381. package/src/config/env.ts +7 -0
  382. package/src/config/styles.ts +5 -0
  383. package/src/core/Game.test.ts +167 -0
  384. package/src/core/Game.ts +307 -0
  385. package/src/core/InitialStateSnapshot.test.ts +51 -0
  386. package/src/core/InitialStateSnapshot.ts +46 -0
  387. package/src/core/helpers/CellHelper.test.ts +33 -0
  388. package/src/core/helpers/CellHelper.ts +21 -0
  389. package/src/core/helpers/ControlInputHandlerHelper.test.ts +116 -0
  390. package/src/core/helpers/ControlInputHandlerHelper.ts +68 -0
  391. package/src/core/helpers/CoordinateHelper.test.ts +113 -0
  392. package/src/core/helpers/CoordinateHelper.ts +82 -0
  393. package/src/core/helpers/InterfaceIdentifierHelper.test.ts +122 -0
  394. package/src/core/helpers/InterfaceIdentifierHelper.ts +43 -0
  395. package/src/core/helpers/RelativeValuesHelper.test.ts +47 -0
  396. package/src/core/helpers/RelativeValuesHelper.ts +29 -0
  397. package/src/core/module/control/GameControl.test.ts +82 -0
  398. package/src/core/module/control/GameControl.ts +142 -0
  399. package/src/core/module/control/GameControlKeyBinding.test.ts +59 -0
  400. package/src/core/module/control/GameControlKeyBinding.ts +92 -0
  401. package/src/core/module/grid/GameGrid.test.ts +83 -0
  402. package/src/core/module/grid/GameGrid.ts +610 -0
  403. package/src/core/module/grid/GameHudGrid.test.ts +22 -0
  404. package/src/core/module/grid/GameHudGrid.ts +40 -0
  405. package/src/core/module/grid/engines/GridAnalysisEngine.test.ts +157 -0
  406. package/src/core/module/grid/engines/GridAnalysisEngine.ts +124 -0
  407. package/src/core/module/grid/engines/GridLineEngine.test.ts +132 -0
  408. package/src/core/module/grid/engines/GridLineEngine.ts +165 -0
  409. package/src/core/module/grid/engines/GridMovementEngine.test.ts +125 -0
  410. package/src/core/module/grid/engines/GridMovementEngine.ts +113 -0
  411. package/src/core/module/grid/engines/GridRegionEngine.test.ts +136 -0
  412. package/src/core/module/grid/engines/GridRegionEngine.ts +52 -0
  413. package/src/core/module/grid/engines/GridTransformEngine.test.ts +98 -0
  414. package/src/core/module/grid/engines/GridTransformEngine.ts +70 -0
  415. package/src/core/module/renderer/DisplayRenderer.test.ts +86 -0
  416. package/src/core/module/renderer/DisplayRenderer.ts +152 -0
  417. package/src/core/module/renderer/GameRenderer.test.ts +103 -0
  418. package/src/core/module/renderer/GameRenderer.ts +144 -0
  419. package/src/core/module/renderer/HudRenderer.test.ts +108 -0
  420. package/src/core/module/renderer/HudRenderer.ts +203 -0
  421. package/src/core/module/score/GameScore.test.ts +71 -0
  422. package/src/core/module/score/GameScore.ts +188 -0
  423. package/src/core/module/session/GameSession.test.ts +176 -0
  424. package/src/core/module/session/GameSession.ts +103 -0
  425. package/src/core/module/sound/GameSound.test.ts +117 -0
  426. package/src/core/module/sound/GameSound.ts +229 -0
  427. package/src/core/module/state/GameState.test.ts +101 -0
  428. package/src/core/module/state/GameState.ts +339 -0
  429. package/src/core/module/text/GameText.test.ts +87 -0
  430. package/src/core/module/text/GameText.ts +150 -0
  431. package/src/core/module/time/GameTime.test.ts +86 -0
  432. package/src/core/module/time/GameTime.ts +144 -0
  433. package/src/core/types/Interfaces.ts +59 -0
  434. package/src/core/types/Types.ts +124 -0
  435. package/src/core/types/enums.ts +113 -0
  436. package/src/core/types/modules.ts +841 -0
  437. package/src/index.test.ts +15 -0
  438. package/src/index.ts +9 -0
  439. package/src/main.test.ts +137 -0
  440. package/src/main.ts +77 -0
  441. package/src/menu/GameMenu.test.ts +157 -0
  442. package/src/menu/GameMenu.ts +124 -0
  443. package/src/menu/GameMenuSingleton.test.ts +26 -0
  444. package/src/menu/GameMenuSingleton.ts +13 -0
  445. package/src/menu/GameRepository.test.ts +46 -0
  446. package/src/menu/GameRepository.ts +47 -0
  447. package/src/menu/manager/GameManager.test.ts +68 -0
  448. package/src/menu/manager/GameManager.ts +50 -0
  449. package/src/types/global.d.ts +8 -0
  450. package/src/types/interfaces.ts +5 -0
  451. package/src/view/Debugger.test.ts +152 -0
  452. package/src/view/Debugger.ts +124 -0
  453. package/src/view/GameView.test.ts +95 -0
  454. package/src/view/GameView.ts +244 -0
  455. package/src/view/SessionModal.test.ts +141 -0
  456. package/src/view/SessionModal.ts +73 -0
  457. package/src/view/components/layout/ButtonLayout.test.ts +28 -0
  458. package/src/view/components/layout/ButtonLayout.ts +63 -0
  459. package/src/view/components/layout/ContainerLayout.test.ts +48 -0
  460. package/src/view/components/layout/ContainerLayout.ts +50 -0
  461. package/src/view/components/layout/FrameLayout.test.ts +24 -0
  462. package/src/view/components/layout/FrameLayout.ts +25 -0
  463. package/src/view/components/ui/BigButton.test.ts +28 -0
  464. package/src/view/components/ui/BigButton.ts +31 -0
  465. package/src/view/components/ui/Button.test.ts +30 -0
  466. package/src/view/components/ui/Button.ts +30 -0
  467. package/src/view/components/ui/Canvas.test.ts +32 -0
  468. package/src/view/components/ui/Canvas.ts +34 -0
  469. package/src/view/components/ui/SmallButton.test.ts +48 -0
  470. package/src/view/components/ui/SmallButton.ts +32 -0
  471. package/src/view/theme/applyColors.test.ts +47 -0
  472. package/src/view/theme/applyColors.ts +38 -0
  473. package/src/view/theme/dimensions.test.ts +34 -0
  474. package/src/view/theme/dimensions.ts +53 -0
  475. package/tsconfig.json +16 -0
  476. package/vitest.config.ts +14 -0
  477. package/webpack.config.js +133 -0
@@ -0,0 +1,2 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BrickEngine=e():t.BrickEngine=e()}(self,()=>(()=>{"use strict";var t,e,i,n,r,o,s,a,u={d:(t,e)=>{for(var i in e)u.o(e,i)&&!u.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},c={};u.r(c),u.d(c,{Color:()=>t,ControlEventType:()=>s,ControlKey:()=>o,FontAlign:()=>e,FontSize:()=>i,FontVerticalAlign:()=>n,Game:()=>ut,GameView:()=>Ut,Sound:()=>r,StateProperty:()=>a,configs:()=>l}),function(t){t.DEFAULT="rgb(19, 26, 18)",t.BLUE="rgb(0, 0, 128)",t.CYAN="rgb(0, 128, 128)",t.GRAY="rgb(128, 128, 128)",t.GREEN="rgb(0, 128, 0)",t.PURPLE="rgb(128, 0, 128)",t.RED="rgb(128, 0, 0)",t.YELLOW="rgb(128, 128, 0)",t.INACTIVE="rgb(166, 183, 165)"}(t||(t={})),function(t){t.CENTER="center",t.LEFT="left",t.RIGHT="right"}(e||(e={})),function(t){t[t.EXTRA_SMALL=0]="EXTRA_SMALL",t[t.SMALL=1]="SMALL",t[t.MEDIUM=2]="MEDIUM",t[t.LARGE=3]="LARGE",t[t.EXTRA_LARGE=4]="EXTRA_LARGE"}(i||(i={})),function(t){t.CENTER="center",t.TOP="top",t.BOTTOM="bottom"}(n||(n={})),function(t){t.SPAWN="./sounds/sound_01.wav",t.SCORE_1="./sounds/sound_15.wav",t.SCORE_2="./sounds/sound_03.wav",t.SCORE_3="./sounds/sound_02.wav",t.KEY_PRESS="./sounds/sound_14.wav",t.ACTION_1="./sounds/sound_05.wav",t.ACTION_2="./sounds/sound_13.wav",t.HIT_1="./sounds/sound_06.wav",t.HIT_2="./sounds/sound_08.wav",t.DODGE="./sounds/sound_07.wav",t.DROP="./sounds/sound_11.wav",t.EXPLOSION="./sounds/sound_09.wav",t.GAME_START="./sounds/sound_04.wav",t.SHOT="./sounds/sound_12.wav",t.START_THEME="./sounds/sound_10.wav"}(r||(r={})),function(t){t.UP="up;control",t.DOWN="down;control",t.LEFT="left;control",t.RIGHT="right;control",t.ACTION="action;control",t.POWER="power;system",t.START_PAUSE="start_pause;system",t.SOUND="sound;system",t.RESET="reset;system",t.EXIT="exit;system",t.COLOR="color;system"}(o||(o={})),function(t){t.PRESSED="pressed",t.HELD="held"}(s||(s={})),function(t){t.ON="on",t.START="start",t.PLAYING="playing",t.GAME_OVER="gameOver",t.COLOR_ENABLED="colorEnabled",t.MUTED="muted"}(a||(a={}));const l={colors:{background:"rgb(172, 189, 173)",active:"rgb(19, 26, 18)",inactive:"rgba(161, 178, 160, 1)",bodyMain:"rgb(0, 68, 187)",bodyButton:"rgb(247, 222, 57)"},screenLayout:{grid:{columns:11,rows:18},hudGrid:{columns:4,rows:4},display:{width:.65,height:.956,margin:.022,borderWeight:.0075},fontSize:{extraSmall:.05,small:.065,medium:.1,large:.125,extraLarge:.15},cell:{margin:.1,padding:.3,strokeWeight:.075}},viewLayout:{bodyHeightWidthMultiplier:1.9,mobileBreakpoint:600,canvas:{widthRatio:.7,aspectRatio:1.114},splashHideDelayMs:250,dimensions:{borderRadiusRatio:.05,borderWidthRatio:.006,button:{smSizeRatio:.08,mdSizeRatio:.18,lgSizeRatio:.25,mobile:{smSizeRatio:.13,mdSizeRatio:.26,lgSizeRatio:.35,fontRatio:.05,smFontRatio:.04,lgFontRatio:.055,spacingRatio:.018},borderRatio:.0045,animationDuration:"0.15s"}},shadowDispersion:"3px"},inputQueryParams:{mainColor:"body-color",buttonColor:"button-color",runningOnApp:"mobile"},selectors:{parent:"#brick-game",splash:"#splash",modalIds:{sessionModal:"#session-modal",sessionContinueYes:"#session-modal-yes",sessionContinueNo:"#session-modal-no"},viewElementIds:{canvas:"brick-game-canvas",container:"container",frame:"frame",buttonContainer:"button-container",smallButtonContainer:"small-button-container",innerButtonContainer:"inner-button-container",mediumButtonContainer:"medium-button-container",directionVerticalContainer:"direction-vertical-container",directionHorizontalContainer:"direction-horizontal-container",largeButtonContainer:"large-button-container"}},storageKeys:{muted:"STATE.MUTED",colorEnabled:"STATE.COLOR_ENABLED",grid:"GAME.GRID",hudGrid:"GAME.HUD_GRID",tickInterval:"GAME.TICK_INTERVAL",score:"GAME.SCORE"},buttonHold:{holdDelayMs:250,holdIntervalMs:50},game:{tickInterval:1e3/30,minTickInterval:1e3/60,debugger:{msInterval:100,enabled:!0},sound:{volume:.025}}},h=function(){function t(t){this._activeKeys=new Map,this._control=t}return t.prototype.handlePress=function(t){var e=this;if(!this._activeKeys.has(t)){this._control.notify(t,s.PRESSED);var i=setTimeout(function(){var i=setInterval(function(){e._control.notify(t,s.HELD)},l.buttonHold.holdIntervalMs),n=e._activeKeys.get(t);n&&(n.hold=i)},l.buttonHold.holdDelayMs);this._activeKeys.set(t,{delay:i,hold:null})}},t.prototype.handleRelease=function(t){var e=this._activeKeys.get(t);e&&(clearTimeout(e.delay),e.hold&&clearInterval(e.hold),this._activeKeys.delete(t))},t}();var d={ArrowUp:o.UP,ArrowDown:o.DOWN,ArrowLeft:o.LEFT,ArrowRight:o.RIGHT,KeyW:o.UP,KeyS:o.DOWN,KeyA:o.LEFT,KeyD:o.RIGHT,KeyJ:o.ACTION,Digit1:o.POWER,Digit2:o.START_PAUSE,Digit3:o.SOUND,Digit4:o.RESET,Digit5:o.EXIT,Digit6:o.COLOR};const p=function(){function t(t){this._inputHandler=new h(t),this._boundHandleKeyDown=this._handleKeyDown.bind(this),this._boundHandleKeyUp=this._handleKeyUp.bind(this)}return t.prototype.bindControls=function(){window.addEventListener("keydown",this._boundHandleKeyDown),window.addEventListener("keyup",this._boundHandleKeyUp)},t.prototype.unbindControls=function(){window.removeEventListener("keydown",this._boundHandleKeyDown),window.removeEventListener("keyup",this._boundHandleKeyUp)},t.prototype._handleKeyDown=function(t){var e=d[t.code];e&&(t.repeat||this._inputHandler.handlePress(e))},t.prototype._handleKeyUp=function(t){var e=d[t.code];e&&this._inputHandler.handleRelease(e)},t}();var f=function(){function t(){this._subscribers=new Map}return t.prototype.setup=function(){this._keyBinding=new p(this),this._keyBinding.bindControls()},t.prototype.unbindControls=function(){this._keyBinding.unbindControls(),this._subscribers.clear()},t.prototype.bindControls=function(){this._keyBinding.bindControls()},t.prototype.setModules=function(t){this._modules=t},t.prototype.subscribe=function(t,e,i){this._subscribers.has(t)||this._subscribers.set(t,new Map);var n=this._subscribers.get(t);n.has(e)||n.set(e,new Set),n.get(e).add(i)},t.prototype.unsubscribe=function(t,e,i){var n=this._subscribers.get(t);if(n){var r=n.get(e);r&&r.delete(i)}},t.prototype.notify=function(t,e){var i;if(!this._modules)throw new Error("Modules not initialized");var n={key:t,type:e,modules:this._modules},r=this._modules.state,s=!1;r.isOff()?s=t===o.POWER:!r.isStarted()||r.isPlaying()||r.isGameOver()?s=!0:r.isPaused()&&(s=t.endsWith(";system"));var a=null===(i=this._subscribers.get(t))||void 0===i?void 0:i.get(e);a&&s&&a.forEach(function(t){return t(n)})},t.prototype.getDebugData=function(){var t=0;return this._subscribers.forEach(function(e){e.forEach(function(e){t+=e.size})}),{total_subscribers:t,tracked_keys:this._subscribers.size}},t}();const g=f,y=function(){function e(){}return e.emptyCell=function(e){return{value:0,color:t.DEFAULT,coordinate:e}},e}();var _=function(){return _=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},_.apply(this,arguments)},v=function(){function t(t){this.grid=t}return t.prototype.movePiece=function(t,e){var i=this,n=t.map(function(t){return _(_({},t),{coordinate:{x:t.coordinate.x+(e.x||0),y:t.coordinate.y+(e.y||0)}})}),r=n.some(function(e){return!i.grid.isValidCoordinate(e.coordinate)||i.grid.isCellActive(e.coordinate)&&(n=e.coordinate,!t.some(function(t){return t.coordinate.x===n.x&&t.coordinate.y===n.y}));var n});return r?null:n},t.prototype.movePieceLeft=function(t){return this.movePiece(t,{x:-1,y:0})},t.prototype.movePieceRight=function(t){return this.movePiece(t,{x:1,y:0})},t.prototype.movePieceUp=function(t){return this.movePiece(t,{x:0,y:-1})},t.prototype.movePieceDown=function(t){return this.movePiece(t,{x:0,y:1})},t.prototype.moveCell=function(t,e){var i={x:t.coordinate.x+(e.x||0),y:t.coordinate.y+(e.y||0)};return!this.grid.isValidCoordinate(i)||this.grid.isCellActive(i)?null:_(_({},t),{coordinate:i})},t.prototype.moveCellLeft=function(t){return this.moveCell(t,{x:-1,y:0})},t.prototype.moveCellRight=function(t){return this.moveCell(t,{x:1,y:0})},t.prototype.moveCellUp=function(t){return this.moveCell(t,{x:0,y:-1})},t.prototype.moveCellDown=function(t){return this.moveCell(t,{x:0,y:1})},t.prototype.getDropPath=function(t){for(var e=t,i=this.movePieceDown(e);null!==i;)e=i,i=this.movePieceDown(e);return e},t.prototype.getRisePath=function(t){for(var e=t,i=this.movePieceUp(e);null!==i;)e=i,i=this.movePieceUp(e);return e},t.prototype.getReachPathLeft=function(t){for(var e=t,i=this.movePieceLeft(e);null!==i;)e=i,i=this.movePieceLeft(e);return e},t.prototype.getReachPathRight=function(t){for(var e=t,i=this.movePieceRight(e);null!==i;)e=i,i=this.movePieceRight(e);return e},t}();const m=v;var b=function(){return b=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},b.apply(this,arguments)},E=function(){function t(t){this.grid=t}return t.prototype.rotatePiece=function(t,e,i){var n=this;void 0===i&&(i=!0);var r=t.map(function(t){var n=t.coordinate.x-e.x,r=t.coordinate.y-e.y,o=i?-r:r,s=i?n:-n;return b(b({},t),{coordinate:{x:e.x+o,y:e.y+s}})}),o=r.some(function(e){return!n.grid.isValidCoordinate(e.coordinate)||n.grid.isCellActive(e.coordinate)&&(i=e.coordinate,!t.some(function(t){return t.coordinate.x===i.x&&t.coordinate.y===i.y}));var i});return o?null:r},t.prototype.mirrorPiece=function(t,e){if(0===t.length)return[];var i=this.getPieceBounds(t),n="x"===e?(i.min.x+i.max.x)/2:(i.min.y+i.max.y)/2;return t.map(function(t){return b(b({},t),{coordinate:{x:"x"===e?Math.round(2*n-t.coordinate.x):t.coordinate.x,y:"y"===e?Math.round(2*n-t.coordinate.y):t.coordinate.y}})})},t.prototype.getPieceBounds=function(t){var e=t.map(function(t){return t.coordinate.x}),i=t.map(function(t){return t.coordinate.y});return{min:{x:Math.min.apply(Math,e),y:Math.min.apply(Math,i)},max:{x:Math.max.apply(Math,e),y:Math.max.apply(Math,i)}}},t}();const w=E;var S=function(){return S=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},S.apply(this,arguments)},C=function(){function t(t){this.grid=t}return t.prototype.getFullRows=function(){for(var t=[],e=0;e<this.grid.height;e++){for(var i=!0,n=0;n<this.grid.width;n++)if(!this.grid.isCellActive({x:n,y:e})){i=!1;break}i&&t.push(e)}return t},t.prototype.getFullColumns=function(){for(var t=[],e=0;e<this.grid.width;e++){for(var i=!0,n=0;n<this.grid.height;n++)if(!this.grid.isCellActive({x:e,y:n})){i=!1;break}i&&t.push(e)}return t},t.prototype.getNeighbors=function(t,e){var i=this;void 0===e&&(e=!1);var n=[],r=[{x:-1,y:0},{x:1,y:0},{x:0,y:-1},{x:0,y:1}];return e&&r.push({x:-1,y:-1},{x:1,y:-1},{x:-1,y:1},{x:1,y:1}),r.forEach(function(e){var r={x:t.x+e.x,y:t.y+e.y};i.grid.isValidCoordinate(r)&&n.push(i.grid.getCell(r))}),n},t.prototype.findConnectedCells=function(t){var e=this;if(!this.grid.isCellActive(t))return[];var i=this.grid.getCell(t).value,n=[],r=new Set,o=[t],s=function(t){return"".concat(t.x,",").concat(t.y)};for(r.add(s(t));o.length>0;){var a=o.shift(),u=this.grid.getCell(a);u.value===i&&(n.push(u),[{x:a.x-1,y:a.y},{x:a.x+1,y:a.y},{x:a.x,y:a.y-1},{x:a.x,y:a.y+1}].forEach(function(t){var i=s(t);e.grid.isValidCoordinate(t)&&!r.has(i)&&e.grid.isCellActive(t)&&(r.add(i),o.push(t))}))}return n},t.prototype.swapCells=function(t,e){var i=S({},this.grid.getCell(t)),n=S({},this.grid.getCell(e));this.grid.stampCell(S(S({},n),{coordinate:t})),this.grid.stampCell(S(S({},i),{coordinate:e}))},t}();const x=C;var R=function(){function t(t){this.grid=t}return t.prototype.isRowFull=function(t){var e=this.grid.getGrid();return!(t<0||t>=this.grid.height)&&e[t].every(function(t){return t.value>0})},t.prototype.isRowEmpty=function(t){var e=this.grid.getGrid();return t<0||t>=this.grid.height||e[t].every(function(t){return 0===t.value})},t.prototype.clearRow=function(t){var e=this.grid.getGrid();if(!(t<0||t>=this.grid.height))for(var i=0;i<this.grid.width;i++)e[t][i]=y.emptyCell({x:i,y:t})},t.prototype.shiftRowsDown=function(t){for(var e=this.grid.getGrid(),i=t;i>0;i--)for(var n=0;n<this.grid.width;n++){var r=e[i-1][n];e[i][n].value=r.value,e[i][n].color=r.color}this.clearRow(0)},t.prototype.shiftRowsUp=function(t){for(var e=this.grid.getGrid(),i=t;i<this.grid.height-1;i++)for(var n=0;n<this.grid.width;n++){var r=e[i+1][n];e[i][n].value=r.value,e[i][n].color=r.color}this.clearRow(this.grid.height-1)},t.prototype.clearFullRows=function(){for(var t=0,e=this.grid.height-1;e>=0;e--)this.isRowFull(e)&&(this.clearRow(e),this.shiftRowsDown(e),t++,e++);return t},t.prototype.isColumnFull=function(t){var e=this.grid.getGrid();if(t<0||t>=this.grid.width)return!1;for(var i=0;i<this.grid.height;i++)if(0===e[i][t].value)return!1;return!0},t.prototype.isColumnEmpty=function(t){var e=this.grid.getGrid();if(t<0||t>=this.grid.width)return!0;for(var i=0;i<this.grid.height;i++)if(0!==e[i][t].value)return!1;return!0},t.prototype.clearColumn=function(t){var e=this.grid.getGrid();if(!(t<0||t>=this.grid.width))for(var i=0;i<this.grid.height;i++)e[i][t]=y.emptyCell({x:t,y:i})},t.prototype.shiftColumnsRight=function(t){for(var e=this.grid.getGrid(),i=t;i>0;i--)for(var n=0;n<this.grid.height;n++){var r=e[n][i-1];e[n][i].value=r.value,e[n][i].color=r.color}this.clearColumn(0)},t.prototype.shiftColumnsLeft=function(t){for(var e=this.grid.getGrid(),i=t;i<this.grid.width-1;i++)for(var n=0;n<this.grid.height;n++){var r=e[n][i+1];e[n][i].value=r.value,e[n][i].color=r.color}this.clearColumn(this.grid.width-1)},t.prototype.clearFullColumns=function(){for(var t=0,e=this.grid.width-1;e>=0;e--)this.isColumnFull(e)&&(this.clearColumn(e),this.shiftColumnsRight(e),t++,e++);return t},t}();const P=R;var O=function(){function t(t){this.grid=t}return t.prototype.isAreaOccupied=function(t){var e=this;return t.some(function(t){return!e.grid.isValidCoordinate(t)||e.grid.isCellActive(t)})},t.prototype.fillArea=function(t,e,i,n){for(var r=Math.max(0,Math.min(t.x,e.x)),o=Math.min(this.grid.width-1,Math.max(t.x,e.x)),s=Math.max(0,Math.min(t.y,e.y)),a=Math.min(this.grid.height-1,Math.max(t.y,e.y)),u=s;u<=a;u++)for(var c=r;c<=o;c++)this.grid.setCellValue({x:c,y:u},i),this.grid.setCellColor({x:c,y:u},n)},t.prototype.stampPiece=function(t){var e=this;t.forEach(function(t){return e.grid.stampCell(t)})},t.prototype.stampCell=function(t){this.grid.setCellValue(t.coordinate,t.value),this.grid.setCellColor(t.coordinate,t.color)},t}();const M=O;var I=function(){function t(){this._grid=[],this.serialId="grid",this._movementEngine=new m(this),this._transformEngine=new w(this),this._analysisEngine=new x(this),this._lineEngine=new P(this),this._regionEngine=new M(this)}return t.prototype.getGrid=function(){return this._grid},Object.defineProperty(t.prototype,"width",{get:function(){return l.screenLayout.grid.columns},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return l.screenLayout.grid.rows},enumerable:!1,configurable:!0}),t.prototype.setup=function(){this.resetGrid()},t.prototype.resetGrid=function(){this._grid=[];for(var t=0;t<this.height;t++){this._grid[t]=[];for(var e=0;e<this.width;e++)this._grid[t][e]=y.emptyCell({x:e,y:t})}},t.prototype.forEach=function(t){for(var e=0;e<this.height;e++)for(var i=0;i<this.width;i++)t(this._grid[e][i])},t.prototype.isValidCoordinate=function(t){return t.x>=0&&t.x<this.width&&t.y>=0&&t.y<this.height},t.prototype.getCell=function(t){return this.isValidCoordinate(t)?this._grid[t.y][t.x]:null},t.prototype.setCellValue=function(t,e){this.isValidCoordinate(t)&&(this._grid[t.y][t.x].value=e)},t.prototype.setCellColor=function(t,e){this.isValidCoordinate(t)&&(this._grid[t.y][t.x].color=e)},t.prototype.isCellActive=function(t){var e=this.getCell(t);return null!==e&&e.value>0},t.prototype.isCellInactive=function(t){var e=this.getCell(t);return null!==e&&0===e.value},t.prototype.isRowFull=function(t){return this._lineEngine.isRowFull(t)},t.prototype.isRowEmpty=function(t){return this._lineEngine.isRowEmpty(t)},t.prototype.clearRow=function(t){this._lineEngine.clearRow(t)},t.prototype.shiftRowsDown=function(t){this._lineEngine.shiftRowsDown(t)},t.prototype.shiftRowsUp=function(t){this._lineEngine.shiftRowsUp(t)},t.prototype.clearFullRows=function(){return this._lineEngine.clearFullRows()},t.prototype.isColumnFull=function(t){return this._lineEngine.isColumnFull(t)},t.prototype.isColumnEmpty=function(t){return this._lineEngine.isColumnEmpty(t)},t.prototype.clearColumn=function(t){this._lineEngine.clearColumn(t)},t.prototype.shiftColumnsRight=function(t){this._lineEngine.shiftColumnsRight(t)},t.prototype.shiftColumnsLeft=function(t){this._lineEngine.shiftColumnsLeft(t)},t.prototype.clearFullColumns=function(){return this._lineEngine.clearFullColumns()},t.prototype.isAreaOccupied=function(t){return this._regionEngine.isAreaOccupied(t)},t.prototype.fillArea=function(t,e,i,n){this._regionEngine.fillArea(t,e,i,n)},t.prototype.stampPiece=function(t){this._regionEngine.stampPiece(t)},t.prototype.stampCell=function(t){this._regionEngine.stampCell(t)},t.prototype.movePiece=function(t,e){return this._movementEngine.movePiece(t,e)},t.prototype.movePieceLeft=function(t){return this._movementEngine.movePieceLeft(t)},t.prototype.movePieceRight=function(t){return this._movementEngine.movePieceRight(t)},t.prototype.movePieceUp=function(t){return this._movementEngine.movePieceUp(t)},t.prototype.movePieceDown=function(t){return this._movementEngine.movePieceDown(t)},t.prototype.moveCell=function(t,e){return this._movementEngine.moveCell(t,e)},t.prototype.moveCellLeft=function(t){return this._movementEngine.moveCellLeft(t)},t.prototype.moveCellRight=function(t){return this._movementEngine.moveCellRight(t)},t.prototype.moveCellUp=function(t){return this._movementEngine.moveCellUp(t)},t.prototype.moveCellDown=function(t){return this._movementEngine.moveCellDown(t)},t.prototype.rotatePiece=function(t,e,i){return void 0===i&&(i=!0),this._transformEngine.rotatePiece(t,e,i)},t.prototype.getFullRows=function(){return this._analysisEngine.getFullRows()},t.prototype.getFullColumns=function(){return this._analysisEngine.getFullColumns()},t.prototype.getDropPath=function(t){return this._movementEngine.getDropPath(t)},t.prototype.getRisePath=function(t){return this._movementEngine.getRisePath(t)},t.prototype.getReachPathLeft=function(t){return this._movementEngine.getReachPathLeft(t)},t.prototype.getReachPathRight=function(t){return this._movementEngine.getReachPathRight(t)},t.prototype.getNeighbors=function(t,e){return void 0===e&&(e=!1),this._analysisEngine.getNeighbors(t,e)},t.prototype.findConnectedCells=function(t){return this._analysisEngine.findConnectedCells(t)},t.prototype.mirrorPiece=function(t,e){return this._transformEngine.mirrorPiece(t,e)},t.prototype.swapCells=function(t,e){this._analysisEngine.swapCells(t,e)},t.prototype.getPieceBounds=function(t){return this._transformEngine.getPieceBounds(t)},t.prototype.getDebugData=function(){return{width:this.width,height:this.height,activeCells:this._grid.flat().filter(function(t){return t.value>0}).length}},t.prototype.serialize=function(){return console.log("serialize"),JSON.stringify({grid:this._grid})},t.prototype.deserialize=function(t){console.log("deserialize");var e=JSON.parse(t);this._grid=e.grid},t}();const T=I;var L=function(){function t(){}return t.getRelativeWidth=function(t,e){return e*t.width},t.getRelativeHeight=function(t,e){return e*t.height},t}();const A=L;var D=function(){function e(t){this._p=t}return e.prototype.setup=function(t){this._rendererMetrics=t;var e=l.screenLayout.cell,i=e.margin,n=e.padding,r=e.strokeWeight,o=this._rendererMetrics.cell.size;this._cellPreCalculatedGeometry={innerOffset:i*o,innerSize:o-i*o*2,paddingOffset:n*o,paddingSize:o-n*o*2,strokeWeight:r*o},this._renderStaticElements()},e.prototype.render=function(t,e){this._p.push(),this._p.image(this._staticGraphics,0,0),this.renderGrid(t,e.state),this._p.pop()},e.prototype._renderStaticElements=function(){var t=l.screenLayout.display.borderWeight;this._staticGraphics=this._p.createGraphics(this._p.width,this._p.height),this._staticGraphics.background(l.colors.background),this._staticGraphics.strokeWeight(A.getRelativeWidth(this._p,t)),this._staticGraphics.noFill(),this._staticGraphics.stroke(l.colors.active),this._staticGraphics.rect(this._rendererMetrics.display.origin.x,this._rendererMetrics.display.origin.y,this._rendererMetrics.display.width,this._rendererMetrics.display.height)},e.prototype.renderCell=function(e,i){var n=e.coordinate,r=e.color,o=e.value,s=n.x,a=n.y,u=this._cellPreCalculatedGeometry,c=u.innerOffset,l=u.innerSize,h=u.paddingOffset,d=u.paddingSize,p=u.strokeWeight;r=0===o||!i.isPlaying()&&!i.isPaused()?t.INACTIVE:i.isColorEnabled()?r:t.DEFAULT,this._p.push(),this._p.translate(this._rendererMetrics.display.origin.x+s*this._rendererMetrics.cell.size,this._rendererMetrics.display.origin.y+a*this._rendererMetrics.cell.size),this._p.strokeWeight(p),this._p.stroke(r),this._p.noFill(),this._p.rect(c,c,l,l),this._p.fill(r),this._p.rect(h,h,d,d),this._p.pop()},e.prototype.renderGrid=function(t,e){var i=this;t.forEach(function(t){t.forEach(function(t){i.renderCell(t,e)})})},e}();const G=D;var B=function(){function t(){}return t.getRelativeCoordinate=function(t,e){return{x:A.getRelativeWidth(t,e.x),y:A.getRelativeHeight(t,e.y)}},t.getDisplayPosX=function(t,e,i){var n=l.screenLayout.display.margin;return i*e+A.getRelativeWidth(t,n)},t.getDisplayPosY=function(t,e,i){var n=l.screenLayout.display.margin;return i*e+A.getRelativeHeight(t,n)},t.getHudPosX=function(t,e,i){var n=l.screenLayout.display.margin,r=i+2*A.getRelativeWidth(t,n);return(t.width-r-A.getRelativeWidth(t,n))*e+r},t.getHudPosY=function(t,e,i){var n=l.screenLayout.display.margin;return i*e+A.getRelativeHeight(t,n)},t}();const k=B;var H=function(){function r(t){this._p=t}return r.prototype.setup=function(t){this._cellSize=t.cell.size,this._gridOrigin={x:k.getHudPosX(this._p,.078,t.display.width),y:k.getHudPosY(this._p,.375,t.display.height)},this._hudBorderRect={x:this._gridOrigin.x-A.getRelativeWidth(this._p,.005),y:this._gridOrigin.y-A.getRelativeHeight(this._p,.005),w:4*this._cellSize+A.getRelativeWidth(this._p,.01),h:4*this._cellSize+A.getRelativeHeight(this._p,.01)}},r.prototype.render=function(t,e){this._renderHud(e),this._drawHudGrid(e)},r.prototype._renderHud=function(t){var r=t.text,o=t.state,s=t.score;this._p.push(),r.setTextSize(i.SMALL),r.setInactiveText(),r.setTextAlign(e.LEFT,n.BOTTOM),r.textOnHud("88888888",{x:.05,y:.13}),r.textOnHud("88888888",{x:.05,y:.3}),r.textOnHud("88 - 88",{x:.05,y:.8}),o.isOn()&&r.setActiveText(),r.textOnHud("Score",{x:.05,y:.06}),r.textOnHud(s.score.toString(),{x:.05,y:.13}),r.textOnHud("Hi-Score",{x:.05,y:.23}),r.textOnHud(s.highScore.toString(),{x:.05,y:.3}),r.textOnHud("Level",{x:.05,y:.72});var a="".concat(s.level<10?"0"+s.level:s.level," - ").concat(s.maxLevel);r.textOnHud(a,{x:.05,y:.8}),r.setTextAlign(e.CENTER,n.BOTTOM),o.isPaused()?r.setActiveText():r.setInactiveText(),r.textOnHud("Paused",{x:.5,y:.9}),o.isOn()&&o.isMuted()?r.setActiveText():r.setInactiveText(),r.textOnHud("Muted",{x:.5,y:.97}),this._p.pop(),this._drawHudGrid(t)},r.prototype._drawHudGrid=function(e){var i=this,n=e.hudGrid,r=e.state;this._p.push(),n.forEach(function(e){var n=e.coordinate,o=n.x,s=n.y;r.isOff()&&!r.isPlaying()&&(e.value=0);var a=0!==e.value?t.DEFAULT:t.INACTIVE;r.isColorEnabled()&&0!==e.value&&(a=e.color),i.drawCellElement({w:i._cellSize,h:i._cellSize,posX:i._gridOrigin.x+i._cellSize*o,posY:i._gridOrigin.y+i._cellSize*s,color:a})}),this._p.noFill(),this._p.stroke(r.isOn()?t.DEFAULT:t.INACTIVE),this._p.rect(this._hudBorderRect.x,this._hudBorderRect.y,this._hudBorderRect.w,this._hudBorderRect.h),this._p.pop()},r.prototype.drawCellElement=function(t){var e=t.w,i=t.posX,n=t.posY,r=t.color,o=l.screenLayout.cell,s=o.margin,a=o.padding,u=s*e,c=e-s*e*2,h=a*e,d=e-a*e*2,p=o.strokeWeight*e;this._p.push(),this._p.translate(i,n),this._p.strokeWeight(p),this._p.stroke(r),this._p.noFill(),this._p.rect(u,u,c,c),this._p.fill(r),this._p.rect(h,h,d,d),this._p.pop()},r}();const z=H;var N=function(){function t(t){this._p=t}return t.prototype.addRenderer=function(t){this._renderers.push(t)},t.prototype.setup=function(){var t=this;this._displayRenderer=new G(this._p),this._hudRenderer=new z(this._p),this._renderers=[],this.addRenderer(this._displayRenderer),this.addRenderer(this._hudRenderer),this._calculateMetrics(),this._renderers.forEach(function(e){return e.setup(t.rendererMetrics)})},t.prototype._calculateMetrics=function(){var t=l.screenLayout.display,e=t.width,i=t.height,n=t.margin,r=l.screenLayout.grid.columns,o=A.getRelativeWidth(this._p,e),s=A.getRelativeHeight(this._p,i),a=k.getRelativeCoordinate(this._p,{x:n,y:n}),u=o/r,c={x:k.getHudPosX(this._p,0,o),y:k.getHudPosY(this._p,0,s)},h=k.getHudPosX(this._p,1,o)-c.x,d=k.getHudPosY(this._p,1,s)-c.y;this._rendererMetrics={display:{width:o,height:s,origin:a},hud:{width:h,height:d,origin:c},cell:{size:u}}},t.prototype.render=function(t,e){this._renderers.forEach(function(i){return i.render(t,e)})},Object.defineProperty(t.prototype,"rendererMetrics",{get:function(){return this._rendererMetrics},enumerable:!1,configurable:!0}),t.prototype.getDebugData=function(){return{display_width:this._rendererMetrics.display.width.toFixed(2),display_height:this._rendererMetrics.display.height.toFixed(2),hud_width:this._rendererMetrics.hud.width.toFixed(2),hud_height:this._rendererMetrics.hud.height.toFixed(2),cell_size:this._rendererMetrics.cell.size.toFixed(2)}},t}();const F=N;var U,W=((U={})[a.ON]={defaultValue:!1},U[a.START]={defaultValue:!1},U[a.PLAYING]={defaultValue:!1},U[a.GAME_OVER]={defaultValue:!1},U[a.COLOR_ENABLED]={defaultValue:!0,storageKey:"colorEnabled"},U[a.MUTED]={defaultValue:!1,storageKey:"muted"},U),j=function(){function t(){this._state=new Map,this._subscribers=new Map}return t.prototype.setup=function(){var t=this;Object.values(a).forEach(function(e){var i=W[e];t._state.set(e,i.defaultValue)}),this._loadPersistentState()},t.prototype._loadPersistentState=function(){var t=this;Object.values(a).forEach(function(e){var i=W[e];if(i.storageKey){var n=localStorage.getItem(i.storageKey);null!==n&&t._state.set(e,JSON.parse(n))}})},t.prototype._set=function(t,e){if(this._state.get(t)!==e){this._state.set(t,e);var i=W[t];i.storageKey&&localStorage.setItem(i.storageKey,JSON.stringify(e)),this._notify(t,e)}},t.prototype._notify=function(t,e){var i=this._subscribers.get(t);i&&i.forEach(function(t){return t(e)})},t.prototype.isOn=function(){return this._state.get(a.ON)},t.prototype.isOff=function(){return!this.isOn()},t.prototype.isStarted=function(){return this._state.get(a.START)},t.prototype.isPlaying=function(){return this._state.get(a.PLAYING)},t.prototype.isPaused=function(){return this.isStarted()&&!this.isPlaying()&&!this.isGameOver()},t.prototype.isGameOver=function(){return this._state.get(a.GAME_OVER)},t.prototype.turnOn=function(){this._set(a.ON,!0),this._set(a.START,!1),this._set(a.PLAYING,!1),this._set(a.GAME_OVER,!1)},t.prototype.turnOff=function(){this._set(a.ON,!1),this._set(a.START,!1),this._set(a.PLAYING,!1),this._set(a.GAME_OVER,!1)},t.prototype.startGame=function(){this.isOn()&&(this._set(a.START,!0),this._set(a.PLAYING,!0),this._set(a.GAME_OVER,!1))},t.prototype.resetGameOver=function(){this._set(a.GAME_OVER,!1),this._set(a.START,!0),this._set(a.PLAYING,!0)},t.prototype.exitGame=function(){this._set(a.START,!1),this._set(a.PLAYING,!1),this._set(a.GAME_OVER,!1)},t.prototype.pause=function(){this.isStarted()&&!this.isGameOver()&&this._set(a.PLAYING,!1)},t.prototype.resume=function(){this.isStarted()&&!this.isGameOver()&&this._set(a.PLAYING,!0)},t.prototype.triggerGameOver=function(){this._set(a.PLAYING,!1),this._set(a.GAME_OVER,!0)},t.prototype.resetGame=function(){this.isOn()&&(this._set(a.GAME_OVER,!1),this._set(a.START,!0),this._set(a.PLAYING,!0))},t.prototype.isColorEnabled=function(){return this._state.get(a.COLOR_ENABLED)},t.prototype.setColorEnabled=function(t){this._set(a.COLOR_ENABLED,t)},t.prototype.isMuted=function(){return this._state.get(a.MUTED)},t.prototype.setMuted=function(t){this._set(a.MUTED,t)},t.prototype.toggleColorEnabled=function(){this.setColorEnabled(!this.isColorEnabled())},t.prototype.toggleMuted=function(){this.setMuted(!this.isMuted())},t.prototype.subscribe=function(t,e){var i;this._subscribers.has(t)||this._subscribers.set(t,[]),null===(i=this._subscribers.get(t))||void 0===i||i.push(e)},t.prototype.unsubscribe=function(t,e){var i=this._subscribers.get(t);i&&this._subscribers.set(t,i.filter(function(t){return t!==e}))},t.prototype.getDebugData=function(){return{on:this.isOn(),start:this.isStarted(),playing:this.isPlaying(),paused:this.isPaused(),game_over:this.isGameOver(),color_enabled:this.isColorEnabled(),muted:this.isMuted()}},t}();const V=j;var K=function(){function t(t){this.defaultFontFamily="retro-gamming",this.fontSizes=[0],this._p=t}return t.prototype.setup=function(){var t=l.screenLayout.fontSize,e=t.extraSmall,n=t.small,r=t.medium,o=t.large,s=t.extraLarge;this._p.textFont(this.defaultFontFamily),this.fontSizes=[],this.fontSizes[i.EXTRA_SMALL]=A.getRelativeWidth(this._p,e),this.fontSizes[i.SMALL]=A.getRelativeWidth(this._p,n),this.fontSizes[i.MEDIUM]=A.getRelativeWidth(this._p,r),this.fontSizes[i.LARGE]=A.getRelativeWidth(this._p,o),this.fontSizes[i.EXTRA_LARGE]=A.getRelativeWidth(this._p,s)},t.prototype.setRendererMetrics=function(t){this._rendererMetrics=t},t.prototype.setTextState=function(t){var e=l.colors,i=e.active,n=e.inactive;this._p.fill(t?i:n)},t.prototype.setActiveText=function(){this.setTextState(!0)},t.prototype.setInactiveText=function(){this.setTextState(!1)},t.prototype.setTextSize=function(t){this._p.textSize(this.fontSizes[t])},t.prototype.setTextAlign=function(t,e){this._p.textAlign(t,e)},t.prototype.textOnHud=function(t,e){var i=k.getHudPosX(this._p,e.x,this._rendererMetrics.display.width),n=k.getHudPosY(this._p,e.y,this._rendererMetrics.display.height);this._p.text(t,i,n)},t.prototype.textOnDisplay=function(t,e){var i=k.getDisplayPosX(this._p,e.x,this._rendererMetrics.display.width),n=k.getDisplayPosY(this._p,e.y,this._rendererMetrics.display.height);this._p.text(t,i,n)},t.prototype.getDebugData=function(){return{current_font_family:this.defaultFontFamily,font_sizes_count:this.fontSizes.length}},t}();const Y=K,X=function(){function t(){this._accumulatedTime=0,this._initialTickInterval=l.game.tickInterval,this._minTickInterval=l.game.minTickInterval,this._tickInterval=l.game.tickInterval,this._fps=0,this._tps=0,this._tickCounter=0,this._timeSinceLastTpsUpdate=0,this.serialId="time"}return t.prototype.setup=function(){this.reset()},t.prototype.update=function(t){this._accumulatedTime+=t,this._fps=1e3/t,this._timeSinceLastTpsUpdate+=t,this._timeSinceLastTpsUpdate>=1e3&&(this._tps=this._tickCounter,this._tickCounter=0,this._timeSinceLastTpsUpdate-=1e3)},t.prototype.shouldTick=function(){return this._accumulatedTime>=this._tickInterval&&(this._accumulatedTime-=this._tickInterval,this._tickCounter++,!0)},t.prototype.reset=function(){this._accumulatedTime=0,this._fps=0,this._tps=0,this._tickCounter=0,this._timeSinceLastTpsUpdate=0,this._tickInterval=this._initialTickInterval},Object.defineProperty(t.prototype,"tickInterval",{get:function(){return this._tickInterval},set:function(t){this._tickInterval=t},enumerable:!1,configurable:!0}),t.prototype.incrementTickInterval=function(t){this.tickInterval=this._tickInterval+t},t.prototype.decrementTickInterval=function(t){var e=Math.max(this._minTickInterval,this._tickInterval-t);this.tickInterval=e},t.prototype.getDebugData=function(){return{fps:Math.round(this._fps),tps:this._tps,tick_interval:this._tickInterval.toFixed(2),accumulated_time:this._accumulatedTime.toFixed(2)}},t.prototype.serialize=function(){return JSON.stringify({tickInterval:this._tickInterval})},t.prototype.deserialize=function(t){var e=JSON.parse(t);this._tickInterval=e.tickInterval},t.prototype.setTickInterval=function(t){this._tickInterval=t},t.prototype.setMinTickInterval=function(t){this._minTickInterval=t},t}();var J=function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},Q=function(t,e){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},$=function(){function t(){this._buffers=new Map,this._activeSources=new Map,this._volume=1}return t.prototype.setup=function(){var t=l.game.sound.volume;this._volume=t;var e=window.AudioContext||window.webkitAudioContext;this._audioContext=new e({latencyHint:"interactive"}),this._gainNode=this._audioContext.createGain(),this._gainNode.connect(this._audioContext.destination),this._updateGain(),this._loadAll()},t.prototype.play=function(t){return J(this,void 0,void 0,function(){var e,i,n;return Q(this,function(r){return"suspended"===this._audioContext.state&&this._audioContext.resume(),(e=this._buffers.get(t))?((i=this._audioContext.createBufferSource()).buffer=e,i.connect(this._gainNode),this._activeSources.has(t)||this._activeSources.set(t,[]),(n=this._activeSources.get(t)).push(i),i.onended=function(){var t=n.indexOf(i);t>-1&&n.splice(t,1)},i.start(0),[2]):(console.warn("Sound buffer not found for: ".concat(t)),[2])})})},t.prototype.stop=function(t){return J(this,void 0,void 0,function(){var e;return Q(this,function(i){return(e=this._activeSources.get(t))&&(e.forEach(function(t){try{t.stop()}catch(t){}}),e.length=0),[2]})})},t.prototype.stopAll=function(){return J(this,void 0,void 0,function(){var t,e,i,n;return Q(this,function(r){switch(r.label){case 0:t=Array.from(this._activeSources.keys()),e=0,i=t,r.label=1;case 1:return e<i.length?(n=i[e],[4,this.stop(n)]):[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}})})},t.prototype._updateGain=function(){var t=!!this._state&&this._state.isMuted();this._gainNode&&(t?this._gainNode.gain.setValueAtTime(0,this._audioContext.currentTime):this._gainNode.gain.setValueAtTime(this._volume,this._audioContext.currentTime))},t.prototype._loadAll=function(){return J(this,void 0,void 0,function(){var t,e=this;return Q(this,function(i){switch(i.label){case 0:return t=Object.values(r).map(function(t){return J(e,void 0,void 0,function(){var e,i,n;return Q(this,function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),[4,fetch(t)];case 1:return[4,r.sent().arrayBuffer()];case 2:return e=r.sent(),[4,this._audioContext.decodeAudioData(e)];case 3:return i=r.sent(),this._buffers.set(t,i),[3,5];case 4:return n=r.sent(),console.error("Failed to load sound: ".concat(t),n),[3,5];case 5:return[2]}})})}),[4,Promise.all(t)];case 1:return i.sent(),[2]}})})},t.prototype.toggleMute=function(){this._state.toggleMuted(),this._updateGain()},t.prototype.syncState=function(t){var e=this;this._state=t,t.subscribe(a.MUTED,function(){e._updateGain()}),this._updateGain()},t.prototype.getDebugData=function(){var t=0;return this._activeSources.forEach(function(e){return t+=e.length}),{muted:!!this._state&&this._state.isMuted(),volume:this._volume,active_sources:t,loaded_buffers:this._buffers.size}},t}();const q=$,Z=function(){function t(){this._score=0,this._multiplier=1,this._level=1,this._maxLevel=10,this._highScore=0,this.serialId="score"}return t.prototype.setup=function(){this._highScore=Number(localStorage.getItem("highScore"))},t.prototype.increaseScore=function(t){this._score+=t*this._multiplier,this._score>this._highScore&&(this.highScore=this._score)},t.prototype.resetScore=function(){this._score=0},t.prototype.getFormattedScore=function(t){return void 0===t&&(t=6),this._score.toString().padStart(t,"0")},t.prototype.increaseLevel=function(t){this._level+=t},t.prototype.resetLevel=function(){this._level=1},Object.defineProperty(t.prototype,"multiplier",{get:function(){return this._multiplier},set:function(t){this._multiplier=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._level},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"score",{get:function(){return this._score},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxLevel",{get:function(){return this._maxLevel},set:function(t){this._maxLevel=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highScore",{get:function(){return this._highScore},set:function(t){this._highScore=t,localStorage.setItem("highScore",t.toString())},enumerable:!1,configurable:!0}),t.prototype.getDebugData=function(){return{score:this._score,multiplier:this._multiplier,level:this._level,max_level:this._maxLevel}},t.prototype.serialize=function(){return JSON.stringify({score:this._score,multiplier:this._multiplier,level:this._level,max_level:this._maxLevel})},t.prototype.deserialize=function(t){var e=JSON.parse(t);this._score=e.score,this._multiplier=e.multiplier,this._level=e.level,this._maxLevel=e.max_level},t}();var tt,et=(tt=function(t,e){return tt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},tt(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}tt(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});const it=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.serialId="hud_grid",e}return et(e,t),Object.defineProperty(e.prototype,"width",{get:function(){return 4},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return 4},enumerable:!1,configurable:!0}),e.prototype.serialize=function(){return JSON.stringify({grid:this._grid})},e.prototype.deserialize=function(t){var e=JSON.parse(t);this._grid=e.grid},e}(T),nt=function(){function t(){}return t.isSerializable=function(t){if(null==t)return!1;var e=t,i="function"==typeof e.serialize,n="function"==typeof e.deserialize,r="string"==typeof e.serialId;return i&&n&&r},t.isInitializable=function(t){return null!=t&&"function"==typeof t.setup},t.isStateSyncable=function(t){if(null==t)return!1;var e=t;return"function"==typeof e.syncState&&!(e instanceof V)},t.isDebuggable=function(t){return null!=t&&"function"==typeof t.getDebugData},t}();var rt=function(){function t(){this._initialState=new Map,this._baseProperties=[]}return t.prototype.captureBaseProperties=function(t){this._baseProperties=Object.keys(t)},t.prototype.captureInitialState=function(t){var e=this;console.log("capturing initial state for snapshot"),Object.entries(t).forEach(function(t){var i=t[0],n=t[1];if(!e._baseProperties.includes(i)&&"function"!=typeof n){var r=n;try{r=structuredClone(n),console.log("capturing property",i,r)}catch(t){console.error("Failed to clone property ".concat(i,":"),t)}e._initialState.set(i,r)}})},t.prototype.restoreInitialState=function(t){console.log("restoring initial snapshot"),this._initialState.forEach(function(e,i){t[i]=e,console.log("restoring property",i,e)})},t}();const ot=rt,st=function(){function t(){this._isModalClosed=!1,this._serializables=[]}return t.prototype.register=function(t){this._serializables.push(t)},t.prototype.saveSession=function(){var t=this;this._isModalClosed&&!this._isGameMenuInstance()&&this._serializables.forEach(function(e){localStorage.setItem(t._key(e.serialId),e.serialize())})},t.prototype.clearSession=function(){var t=this;this._serializables.forEach(function(e){localStorage.removeItem(t._key(e.serialId))})},t.prototype.setShowModalFunction=function(t){this._showSessionModal=t},t.prototype._isGameMenuInstance=function(){return"game-menu"===this.gameId},t.prototype._hasSession=function(){var t=this;return this._serializables.every(function(e){return null!==localStorage.getItem(t._key(e.serialId))})},t.prototype._loadSession=function(){var t=this;this._serializables.forEach(function(e){var i=localStorage.getItem(t._key(e.serialId));i&&e.deserialize(i)})},t.prototype._destroySession=function(){var t=this;this._serializables.forEach(function(e){localStorage.removeItem(t._key(e.serialId))})},t.prototype.syncState=function(t){var e=this;t.subscribe(a.PLAYING,function(t){if(t&&!1===e._isModalClosed){if(!e._hasSession()||e._isGameMenuInstance())return void(e._isModalClosed=!0);e._showSessionModal(function(){e._hasSession()&&!e._isGameMenuInstance()&&e._loadSession(),e._isModalClosed=!0},function(){e._destroySession(),e._isModalClosed=!0})}}),t.subscribe(a.GAME_OVER,function(t){t&&e._destroySession()}),t.subscribe(a.ON,function(t){t||(e._isModalClosed=!1)})},t.prototype.getDebugData=function(){return{gameId:this.gameId,serializables:this._serializables.map(function(t){return t.serialId}).join(", ")}},t.prototype._key=function(t){return"".concat(this.gameId,"::").concat(t)},t}();var at=function(){function t(t,e){this._modules=void 0,this._initialStateSnapshot=new ot,this._gameId="unknown",this._switchHandler=void 0,this._p=t,this._view=e,this._initialStateSnapshot.captureBaseProperties(this)}return Object.defineProperty(t.prototype,"gameId",{get:function(){return this._gameId},set:function(t){this._gameId=t},enumerable:!1,configurable:!0}),t.prototype.setSwitchHandler=function(t){this._switchHandler=t},t.prototype.propagateSwitchHandler=function(t){this.setSwitchHandler(t._switchHandler)},Object.defineProperty(t.prototype,"view",{get:function(){return this._view},enumerable:!1,configurable:!0}),t.prototype.switchGame=function(t){this.destroy(),this._switchHandler?this._switchHandler(t):console.error("Game switch handler not registered. Cannot switch game.")},Object.defineProperty(t.prototype,"modules",{get:function(){return this._modules},enumerable:!1,configurable:!0}),t.prototype.setup=function(){var t=this;this._view.build(),this._modules={renderer:new F(this._p),grid:new T,hudGrid:new it,text:new Y(this._p),state:new V,control:new g,time:new X,sound:new q,score:new Z,session:new st},Object.values(this._modules).forEach(function(t){nt.isInitializable(t)&&t.setup()}),Object.values(this._modules).forEach(function(e){nt.isStateSyncable(e)&&e.syncState(t._modules.state)}),Object.values(this._modules).forEach(function(e){nt.isSerializable(e)&&t._modules.session.register(e)});var e=this._modules,i=e.text,n=e.control,r=e.renderer,o=e.session;o.gameId=this.gameId,o.setShowModalFunction(this._view.showSessionModal.bind(this._view)),n.setModules(this._modules),i.setRendererMetrics(r.rendererMetrics),this.setupGame(),this._initialStateSnapshot.captureInitialState(this),this._subscribeSystemControls(),this._view.bindControls(n)},t.prototype.draw=function(){if(this._modules){var t=this._modules,e=t.renderer,i=t.grid,n=t.time,r=t.state;e.render(i.getGrid(),this._modules),r.isOn()&&(r.isStarted()?r.isPlaying()?(n.update(this._p.deltaTime),n.shouldTick()&&(this.update(this._p.deltaTime),this._modules.session.saveSession()),this.render()):r.isPaused()&&this.render():this.drawTitleScreen(),r.isGameOver()&&this.drawGameOverScreen())}},t.prototype.destroy=function(){this._p.noLoop(),this._modules&&(this._modules.control.unbindControls(),this._modules.sound.stopAll())},Object.defineProperty(t.prototype,"p",{get:function(){return this._p},enumerable:!1,configurable:!0}),t.prototype._subscribeSystemControls=function(){var t=this,e=this._modules,i=e.control,n=e.state,r=e.grid;i.subscribe(o.POWER,s.PRESSED,function(){n.isOn()?(n.turnOff(),t.modules.sound.stopAll()):n.turnOn()}),i.subscribe(o.SOUND,s.PRESSED,function(){return n.toggleMuted()}),i.subscribe(o.COLOR,s.PRESSED,function(){return n.toggleColorEnabled()}),i.subscribe(o.RESET,s.PRESSED,function(){r.resetGrid(),t.modules.score.resetScore(),t.modules.score.resetLevel(),t.modules.time.reset(),t._modules.session.clearSession(),n.resetGame(),t._initialStateSnapshot.restoreInitialState(t)}),i.subscribe(o.EXIT,s.PRESSED,function(){t._modules.session.clearSession()}),i.subscribe(o.START_PAUSE,s.PRESSED,function(){n.isStarted()?n.isPlaying()?n.pause():n.isPaused()?n.resume():n.isGameOver()&&(r.resetGrid(),t.modules.score.resetScore(),t.modules.score.resetLevel(),t.modules.time.reset(),t.modules.session.clearSession(),t._initialStateSnapshot.restoreInitialState(t),n.resetGameOver()):n.startGame()}),n.subscribe(a.ON,function(e){e||(r.resetGrid(),t.modules.score.resetScore(),t.modules.score.resetLevel(),t.modules.time.reset())})},t}();const ut=at;var ct={grad:.9,turn:360,rad:360/(2*Math.PI)},lt=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},ht=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},dt=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},pt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},ft=function(t){return{r:dt(t.r,0,255),g:dt(t.g,0,255),b:dt(t.b,0,255),a:dt(t.a)}},gt=function(t){return{r:ht(t.r),g:ht(t.g),b:ht(t.b),a:ht(t.a,3)}},yt=/^#([0-9a-f]{3,8})$/i,_t=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},vt=function(t){var e=t.r,i=t.g,n=t.b,r=t.a,o=Math.max(e,i,n),s=o-Math.min(e,i,n),a=s?o===e?(i-n)/s:o===i?2+(n-e)/s:4+(e-i)/s:0;return{h:60*(a<0?a+6:a),s:o?s/o*100:0,v:o/255*100,a:r}},mt=function(t){var e=t.h,i=t.s,n=t.v,r=t.a;e=e/360*6,i/=100,n/=100;var o=Math.floor(e),s=n*(1-i),a=n*(1-(e-o)*i),u=n*(1-(1-e+o)*i),c=o%6;return{r:255*[n,a,s,s,u,n][c],g:255*[u,n,n,a,s,s][c],b:255*[s,s,u,n,n,a][c],a:r}},bt=function(t){return{h:pt(t.h),s:dt(t.s,0,100),l:dt(t.l,0,100),a:dt(t.a)}},Et=function(t){return{h:ht(t.h),s:ht(t.s),l:ht(t.l),a:ht(t.a,3)}},wt=function(t){return mt((i=(e=t).s,{h:e.h,s:(i*=((n=e.l)<50?n:100-n)/100)>0?2*i/(n+i)*100:0,v:n+i,a:e.a}));var e,i,n},St=function(t){return{h:(e=vt(t)).h,s:(r=(200-(i=e.s))*(n=e.v)/100)>0&&r<200?i*n/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,i,n,r},Ct=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,xt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Rt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ot={string:[[function(t){var e=yt.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?ht(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?ht(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=Rt.exec(t)||Pt.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:ft({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=Ct.exec(t)||xt.exec(t);if(!e)return null;var i,n,r=bt({h:(i=e[1],n=e[2],void 0===n&&(n="deg"),Number(i)*(ct[n]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return wt(r)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,n=t.b,r=t.a,o=void 0===r?1:r;return lt(e)&&lt(i)&&lt(n)?ft({r:Number(e),g:Number(i),b:Number(n),a:Number(o)}):null},"rgb"],[function(t){var e=t.h,i=t.s,n=t.l,r=t.a,o=void 0===r?1:r;if(!lt(e)||!lt(i)||!lt(n))return null;var s=bt({h:Number(e),s:Number(i),l:Number(n),a:Number(o)});return wt(s)},"hsl"],[function(t){var e=t.h,i=t.s,n=t.v,r=t.a,o=void 0===r?1:r;if(!lt(e)||!lt(i)||!lt(n))return null;var s=function(t){return{h:pt(t.h),s:dt(t.s,0,100),v:dt(t.v,0,100),a:dt(t.a)}}({h:Number(e),s:Number(i),v:Number(n),a:Number(o)});return mt(s)},"hsv"]]},Mt=function(t,e){for(var i=0;i<e.length;i++){var n=e[i][0](t);if(n)return[n,e[i][1]]}return[null,void 0]},It=function(t,e){var i=St(t);return{h:i.h,s:dt(i.s+100*e,0,100),l:i.l,a:i.a}},Tt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Lt=function(t,e){var i=St(t);return{h:i.h,s:i.s,l:dt(i.l+100*e,0,100),a:i.a}},At=function(){function t(t){this.parsed=function(t){return"string"==typeof t?Mt(t.trim(),Ot.string):"object"==typeof t&&null!==t?Mt(t,Ot.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return ht(Tt(this.rgba),2)},t.prototype.isDark=function(){return Tt(this.rgba)<.5},t.prototype.isLight=function(){return Tt(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=gt(this.rgba)).r,i=t.g,n=t.b,o=(r=t.a)<1?_t(ht(255*r)):"","#"+_t(e)+_t(i)+_t(n)+o;var t,e,i,n,r,o},t.prototype.toRgb=function(){return gt(this.rgba)},t.prototype.toRgbString=function(){return e=(t=gt(this.rgba)).r,i=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+i+", "+n+", "+r+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,r},t.prototype.toHsl=function(){return Et(St(this.rgba))},t.prototype.toHslString=function(){return e=(t=Et(St(this.rgba))).h,i=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+r+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,r},t.prototype.toHsv=function(){return t=vt(this.rgba),{h:ht(t.h),s:ht(t.s),v:ht(t.v),a:ht(t.a,3)};var t},t.prototype.invert=function(){return Dt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),Dt(It(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),Dt(It(this.rgba,-t))},t.prototype.grayscale=function(){return Dt(It(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),Dt(Lt(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),Dt(Lt(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?Dt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ht(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=St(this.rgba);return"number"==typeof t?Dt({h:t,s:e.s,l:e.l,a:e.a}):ht(e.h)},t.prototype.isEqual=function(t){return this.toHex()===Dt(t).toHex()},t}(),Dt=function(t){return t instanceof At?t:new At(t)};function Gt(t,e,i){var n=t.createDiv();n.parent(e),n.addClass("btn-container");var r=t.createButton(i);return r.parent(n),r.addClass("btn"),r}function Bt(t,e,i,n){var r=t.createDiv();r.parent(e),r.addClass("sm-btn-container"),r.addClass(n?"sm-btn-container-top":"sm-btn-container-bottom");var o=t.createButton("");o.parent(r),o.addClass("sm-btn");var s=t.createP(i);return s.parent(r),s.addClass("sm-btn-p"),o}var kt=function(){function t(t,e){this._moduleElements=[],this._gameModules=t,this._p=e}return t.prototype.setup=function(){var t=this;if(l.game.debugger.enabled){var e=this._p.select("#debugger"),i=!!e&&e.elt.hasAttribute("open"),n=new Set;e&&(this._p.selectAll(".debugger-module").forEach(function(t){t.elt.hasAttribute("open")&&n.add(t.id())}),e.remove()),this._moduleElements=[];var r=this._p.createElement("details");r.id("debugger"),i&&r.attribute("open",""),r.parent(this._p.select("body"));var o=this._p.createElement("summary");o.id("debugger-summary"),o.html("Debug"),o.parent(r),Object.entries(this._gameModules).forEach(function(e){var i=e[0],o=e[1];if("getDebugData"in o){var s={module:o,properties:[]},a=t._p.createElement("details");a.class("debugger-module"),a.id("debugger-".concat(i)),n.has("debugger-".concat(i))&&a.attribute("open",""),a.parent(r);var u=t._p.createElement("summary");u.id("debugger-".concat(i,"-summary")),u.html(i),u.class("debugger-module-summary"),u.parent(a);var c=o.getDebugData();Object.entries(c).forEach(function(e){var i=e[0],n=e[1],r=t._p.createElement("div");r.class("debugger-container"),r.id("debugger-container-".concat(i,"-").concat(n)),r.parent(a),r.mouseClicked(function(){r.toggleClass("highlight")});var o=t._p.createElement("p");o.id("debugger-".concat(i,"-").concat(n)),o.html("".concat(i,":")),o.parent(r);var u=t._p.createElement("span");u.id("debugger-".concat(i,"-").concat(n,"-value")),u.html("".concat(n)),u.parent(r),s.properties.push({key:i,element:u})}),t._moduleElements.push(s)}})}},t.prototype.setGameModules=function(t){this._gameModules=t,this.setup()},t.prototype.update=function(){this._moduleElements.forEach(function(t){var e=t.module.getDebugData();t.properties.forEach(function(t){t.element.html("".concat(e[t.key]))})})},t}();const Ht=kt;var zt=function(){function t(t){this._p=t}return t.prototype.setup=function(){this._container=this._p.createDiv(),this._container.parent(this._p.select("body")),this._container.id("modal-background"),this._container.class("hidden");var t=this._p.createDiv();t.parent(this._container),t.id("session-modal");var e=this._p.createDiv();e.parent(t),e.id("session-modal-frame");var i=this._p.createP();i.parent(e),i.html("Brick Engine Session");var n=this._p.createDiv();n.parent(e),n.id("session-modal-screen");var r=this._p.createP();r.parent(n),r.html("<span>Looks like you have an active session.</span><br><br>Do you want to continue?");var o=this._p.createDiv();o.parent(t),o.id("session-modal-buttons"),this._cancelButton=this._p.createButton("Cancel"),this._cancelButton.parent(o),this._cancelButton.class("session-modal-button"),this._confirmButton=this._p.createButton("Confirm"),this._confirmButton.parent(o),this._confirmButton.class("session-modal-button")},t.prototype.show=function(t,e){var i=this;this._confirmButton.mousePressed(function(){t(),i._hide()}),this._cancelButton.mousePressed(function(){e(),i._hide()}),this._container.removeClass("hidden")},t.prototype._hide=function(){this._confirmButton.mousePressed(null),this._cancelButton.mousePressed(null),this._container.addClass("hidden")},t}();const Nt=zt;var Ft=function(){function t(t,e){this._parent=e,this._p=t}return t.prototype.isBodyBuilt=function(){return null!=this._cachedCanvas},t.prototype.build=function(){if(this._cachedCanvas)return this._cachedCanvas;var t,e,i,n,r;t=document.querySelector(":root"),e=window.location.href.substring(window.location.href.indexOf("?")+1),n=(i=new URLSearchParams(e)).has(l.inputQueryParams.mainColor)?i.get(l.inputQueryParams.mainColor):l.colors.bodyMain,r=i.has(l.inputQueryParams.buttonColor)?i.get(l.inputQueryParams.buttonColor):l.colors.bodyButton,t.style.setProperty("--main-color",n),t.style.setProperty("--button-color",r),t.style.setProperty("--color-shadow",Dt(n).darken(.15).toHex()),t.style.setProperty("--color-shadow-reflexion",Dt(n).lighten(.15).toHex()),t.style.setProperty("--button-color-reflexion",Dt(r).lighten(.15).toHex()),t.style.setProperty("--button-color-shadow",Dt(r).darken(.15).toHex());var o=function(t,e){var i,n=t.createDiv();if(n.parent(l.selectors.parent),n.id(l.selectors.viewElementIds.container),e.clientWidth<=l.viewLayout.mobileBreakpoint)return{container:n,width:i=e.clientWidth,height:e.clientHeight};var r=e.clientHeight/(1.05*l.viewLayout.bodyHeightWidthMultiplier);return{container:n,width:i=Math.min(e.clientWidth,r),height:i*l.viewLayout.bodyHeightWidthMultiplier}}(this._p,this._parent),s=o.container,a=o.height,u=o.width,c=function(t,e){var i=t.createDiv();i.parent(e),i.id(l.selectors.viewElementIds.frame);var n=t.createDiv();return n.parent(i),t.createP("Brick Game").parent(n),i}(this._p,s),h=function(t,e,i){var n=i*l.viewLayout.canvas.widthRatio,r=n*l.viewLayout.canvas.aspectRatio,o=t.createCanvas(n,r);return o.parent(e),o.id(l.selectors.viewElementIds.canvas),{canvasWidth:n,canvasHeight:r,canvas:o}}(this._p,c,u),d=h.canvas,p=h.canvasHeight,f=h.canvasWidth,g=function(t,e){var i=t.createDiv();i.parent(e),i.id(l.selectors.viewElementIds.buttonContainer);var n=t.createDiv();n.parent(i),n.id(l.selectors.viewElementIds.smallButtonContainer);var r=t.createDiv();r.parent(i),r.id(l.selectors.viewElementIds.innerButtonContainer);var o=t.createDiv();o.parent(r),o.id(l.selectors.viewElementIds.mediumButtonContainer);var s=t.createDiv();s.parent(o),s.id(l.selectors.viewElementIds.directionVerticalContainer);var a=t.createDiv();a.parent(o),a.id(l.selectors.viewElementIds.directionHorizontalContainer);var u=t.createDiv();return u.parent(r),u.id(l.selectors.viewElementIds.largeButtonContainer),{smallButtonContainer:n,mediumButtonContainer:o,largeButtonContainer:u,directionVerticalContainer:s,directionHorizontalContainer:a}}(this._p,s),y=g.largeButtonContainer,_=g.smallButtonContainer,v=g.directionHorizontalContainer,m=g.directionVerticalContainer;return this._onOffBtn=Bt(this._p,_,"On<br/>Off",!0),this._startPauseBtn=Bt(this._p,_,"Start<br/>Pause",!1),this._soundBtn=Bt(this._p,_,"Sound",!0),this._resetBtn=Bt(this._p,_,"Reset",!1),this._exitBtn=Bt(this._p,_,"Exit",!0),this._enableColorBtn=Bt(this._p,_,"Enable<br/>Colors",!1),this._upBtn=Gt(this._p,m,"UP"),this._leftBtn=Gt(this._p,v,"LEFT"),this._downBtn=Gt(this._p,m,"DOWN"),this._rightBtn=Gt(this._p,v,"RIGHT"),this._actionBtn=function(t,e){var i=t.createDiv();i.parent(e),i.addClass("lg-btn-container");var n=t.createButton("Action");return n.parent(i),n.addClass("lg-btn"),n}(this._p,y),function(t,e,i,n){var r=document.querySelector(":root");r.style.setProperty("--dispersion",l.viewLayout.shadowDispersion),r.style.setProperty("--width","".concat(t,"px")),r.style.setProperty("--height","".concat(e,"px")),r.style.setProperty("--canvas-width","".concat(i,"px")),r.style.setProperty("--canvas-height","".concat(n,"px")),r.style.setProperty("--border-radius","".concat(t*l.viewLayout.dimensions.borderRadiusRatio,"px")),r.style.setProperty("--border","".concat(t*l.viewLayout.dimensions.borderWidthRatio,"px solid black")),r.style.setProperty("--sm-button-size","".concat(t*l.viewLayout.dimensions.button.smSizeRatio,"px")),r.style.setProperty("--button-size","".concat(t*l.viewLayout.dimensions.button.mdSizeRatio,"px")),r.style.setProperty("--lg-button-size","".concat(t*l.viewLayout.dimensions.button.lgSizeRatio,"px")),r.style.setProperty("--sm-button-size-mobile","".concat(t*l.viewLayout.dimensions.button.mobile.smSizeRatio,"px")),r.style.setProperty("--button-size-mobile","".concat(t*l.viewLayout.dimensions.button.mobile.mdSizeRatio,"px")),r.style.setProperty("--lg-button-size-mobile","".concat(t*l.viewLayout.dimensions.button.mobile.lgSizeRatio,"px")),r.style.setProperty("--sm-button-size-mobile-font-size","".concat(t*l.viewLayout.dimensions.button.mobile.smFontRatio,"px")),r.style.setProperty("--sm-button-size-mobile-line-height","".concat(t*l.viewLayout.dimensions.button.mobile.smFontRatio,"px")),r.style.setProperty("--button-size-mobile-font-size","".concat(t*l.viewLayout.dimensions.button.mobile.fontRatio,"px")),r.style.setProperty("--lg-button-size-mobile-font-size","".concat(t*l.viewLayout.dimensions.button.mobile.lgFontRatio,"px")),r.style.setProperty("--button-size-mobile-spacing","".concat(t*l.viewLayout.dimensions.button.mobile.spacingRatio,"px")),r.style.setProperty("--button-border","".concat(t*l.viewLayout.dimensions.button.borderRatio,"px solid black")),r.style.setProperty("--button-animation-duration",l.viewLayout.dimensions.button.animationDuration)}(u,a,f,p),this._hideSplash(),this._cachedCanvas={canvas:d,canvasWidth:f,canvasHeight:p},this._cachedCanvas},t.prototype.setupSessionModal=function(){this._sessionModal=new Nt(this._p),this._sessionModal.setup()},t.prototype.showSessionModal=function(t,e){this._sessionModal.show(t,e)},t.prototype.setupDebugger=function(t){this._debugger=new Ht(t,this._p),this._debugger.setup()},t.prototype.updateDebuggerGameModules=function(t){this._debugger.setGameModules(t)},t.prototype.updateDebugger=function(){this._debugger.update()},t.prototype.bindControls=function(t){this._inputHandler=new h(t),this._bindButtonEvents(this._onOffBtn,o.POWER),this._bindButtonEvents(this._startPauseBtn,o.START_PAUSE),this._bindButtonEvents(this._soundBtn,o.SOUND),this._bindButtonEvents(this._resetBtn,o.RESET),this._bindButtonEvents(this._exitBtn,o.EXIT),this._bindButtonEvents(this._enableColorBtn,o.COLOR),this._bindButtonEvents(this._upBtn,o.UP),this._bindButtonEvents(this._downBtn,o.DOWN),this._bindButtonEvents(this._rightBtn,o.RIGHT),this._bindButtonEvents(this._leftBtn,o.LEFT),this._bindButtonEvents(this._actionBtn,o.ACTION)},t.prototype.unbindControls=function(){this._onOffBtn.mousePressed(function(){}).mouseReleased(function(){}),this._startPauseBtn.mousePressed(function(){}).mouseReleased(function(){}),this._soundBtn.mousePressed(function(){}).mouseReleased(function(){}),this._resetBtn.mousePressed(function(){}).mouseReleased(function(){}),this._exitBtn.mousePressed(function(){}).mouseReleased(function(){}),this._enableColorBtn.mousePressed(function(){}).mouseReleased(function(){}),this._upBtn.mousePressed(function(){}).mouseReleased(function(){}),this._downBtn.mousePressed(function(){}).mouseReleased(function(){}),this._rightBtn.mousePressed(function(){}).mouseReleased(function(){}),this._leftBtn.mousePressed(function(){}).mouseReleased(function(){}),this._actionBtn.mousePressed(function(){}).mouseReleased(function(){})},t.prototype._bindButtonEvents=function(t,e){var i=this;t.mousePressed(function(){return i._inputHandler.handlePress(e)}),t.mouseReleased(function(){return i._inputHandler.handleRelease(e)}),t.mouseOut(function(){return i._inputHandler.handleRelease(e)})},t.prototype._hideSplash=function(t){void 0===t&&(t=l.viewLayout.splashHideDelayMs);var e=document.querySelector(l.selectors.splash);setTimeout(function(){e.style.display="none"},t)},t}();const Ut=Ft;return c})());
2
+ //# sourceMappingURL=brick-engine.js.map