brick-engine-js 1.0.36 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/game.bundle.css +271 -46
- package/dist/game.bundle.js +1 -1
- package/dist/types/core/event/GameEventRegistry.d.ts +2 -1
- package/dist/types/core/types/enums.d.ts +2 -1
- package/dist/types/view/GameView.d.ts +7 -0
- package/dist/types/view/ShortcutsModal.d.ts +20 -0
- package/package.json +1 -1
package/dist/css/game.bundle.css
CHANGED
|
@@ -321,79 +321,87 @@
|
|
|
321
321
|
|
|
322
322
|
#debugger {
|
|
323
323
|
font-family: 'retro-gamming', monospace;
|
|
324
|
-
background-color:
|
|
325
|
-
color:
|
|
326
|
-
border:
|
|
327
|
-
|
|
328
|
-
padding:
|
|
324
|
+
background-color: var(--main-color);
|
|
325
|
+
color: white;
|
|
326
|
+
border: var(--border);
|
|
327
|
+
border-radius: var(--border-radius);
|
|
328
|
+
padding: 0; /* Removed container padding */
|
|
329
329
|
position: absolute;
|
|
330
330
|
top: 10px;
|
|
331
331
|
right: 10px;
|
|
332
|
-
width:
|
|
332
|
+
width: 320px;
|
|
333
333
|
max-height: calc(100vh - 40px);
|
|
334
334
|
overflow-y: auto;
|
|
335
335
|
user-select: none;
|
|
336
336
|
-webkit-user-select: none;
|
|
337
337
|
z-index: 9999;
|
|
338
338
|
font-size: 14px;
|
|
339
|
-
|
|
339
|
+
box-shadow:
|
|
340
|
+
calc(var(--width) * -0.015) calc(var(--width) * 0.015) var(--dispersion) black,
|
|
341
|
+
calc(var(--width) * -0.01) calc(var(--width) * 0.01) var(--dispersion) var(--color-shadow-reflexion) inset,
|
|
342
|
+
calc(var(--width) * 0.005) calc(var(--width) * -0.005) var(--dispersion) var(--color-shadow) inset;
|
|
340
343
|
}
|
|
341
344
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
+
#debugger-summary {
|
|
346
|
+
font-weight: bold;
|
|
347
|
+
font-size: 14px;
|
|
348
|
+
cursor: pointer;
|
|
349
|
+
padding: 0 15px;
|
|
350
|
+
height: 40px;
|
|
351
|
+
display: flex;
|
|
352
|
+
align-items: center;
|
|
353
|
+
justify-content: center;
|
|
354
|
+
list-style: none;
|
|
355
|
+
text-shadow: 1px 1px var(--color-shadow);
|
|
356
|
+
outline: none;
|
|
357
|
+
text-align: center;
|
|
345
358
|
}
|
|
346
359
|
|
|
347
|
-
#debugger
|
|
348
|
-
|
|
360
|
+
#debugger[open] #debugger-summary {
|
|
361
|
+
margin-bottom: 10px;
|
|
362
|
+
border-bottom: 1px dashed white;
|
|
349
363
|
}
|
|
350
364
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
365
|
+
/* Custom Scrollbar to match retro look */
|
|
366
|
+
#debugger::-webkit-scrollbar {
|
|
367
|
+
width: 6px;
|
|
354
368
|
}
|
|
355
369
|
|
|
356
|
-
#debugger::-webkit-scrollbar-
|
|
357
|
-
background:
|
|
370
|
+
#debugger::-webkit-scrollbar-track {
|
|
371
|
+
background: rgba(0, 0, 0, 0.1);
|
|
358
372
|
}
|
|
359
373
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
font-size: 16px;
|
|
364
|
-
cursor: pointer;
|
|
365
|
-
margin-bottom: 10px;
|
|
366
|
-
/* text-transform: uppercase; */
|
|
367
|
-
border-bottom: 1px dashed #0f0;
|
|
368
|
-
padding-bottom: 5px;
|
|
369
|
-
list-style: none;
|
|
374
|
+
#debugger::-webkit-scrollbar-thumb {
|
|
375
|
+
background: var(--button-color);
|
|
376
|
+
border-radius: 3px;
|
|
370
377
|
}
|
|
371
378
|
|
|
372
379
|
/* Module Sections */
|
|
373
380
|
.debugger-module {
|
|
374
|
-
margin
|
|
375
|
-
border-left: 1px solid
|
|
381
|
+
margin: 0 15px 10px 15px;
|
|
382
|
+
border-left: 1px solid rgba(255, 255, 255, 0.2);
|
|
376
383
|
padding-left: 8px;
|
|
377
384
|
}
|
|
378
385
|
|
|
379
386
|
.debugger-module-summary {
|
|
380
387
|
cursor: pointer;
|
|
381
388
|
font-weight: bold;
|
|
382
|
-
color: #
|
|
389
|
+
color: #eee;
|
|
383
390
|
margin-bottom: 4px;
|
|
384
391
|
}
|
|
385
392
|
|
|
386
393
|
.debugger-module-summary:hover {
|
|
387
394
|
color: #fff;
|
|
388
|
-
/* text-shadow: 0 0 4px #fff; */
|
|
389
395
|
}
|
|
390
396
|
|
|
391
397
|
/* Data Rows */
|
|
392
398
|
.debugger-container {
|
|
393
399
|
display: flex;
|
|
394
400
|
justify-content: space-between;
|
|
395
|
-
padding:
|
|
396
|
-
border-bottom: 1px dotted
|
|
401
|
+
padding: 4px 6px;
|
|
402
|
+
border-bottom: 1px dotted rgba(255, 255, 255, 0.1);
|
|
403
|
+
background: rgba(0, 0, 0, 0.05);
|
|
404
|
+
margin-bottom: 2px;
|
|
397
405
|
}
|
|
398
406
|
|
|
399
407
|
/* Closed State */
|
|
@@ -401,9 +409,19 @@
|
|
|
401
409
|
width: auto;
|
|
402
410
|
height: auto;
|
|
403
411
|
max-height: none;
|
|
404
|
-
padding:
|
|
405
|
-
|
|
406
|
-
|
|
412
|
+
padding: 0; /* No padding on container */
|
|
413
|
+
background-color: var(--main-color);
|
|
414
|
+
border: var(--border);
|
|
415
|
+
border-radius: var(--border-radius);
|
|
416
|
+
box-shadow:
|
|
417
|
+
calc(var(--width) * -0.015) calc(var(--width) * 0.015) var(--dispersion) black,
|
|
418
|
+
calc(var(--width) * -0.01) calc(var(--width) * 0.01) var(--dispersion) var(--color-shadow-reflexion) inset,
|
|
419
|
+
calc(var(--width) * 0.005) calc(var(--width) * -0.005) var(--dispersion) var(--color-shadow) inset;
|
|
420
|
+
transition: all 0.2s;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
#debugger:not([open]):active {
|
|
424
|
+
transform: translate(-2px, 2px);
|
|
407
425
|
box-shadow: none;
|
|
408
426
|
}
|
|
409
427
|
|
|
@@ -414,29 +432,29 @@
|
|
|
414
432
|
}
|
|
415
433
|
|
|
416
434
|
.debugger-container:hover {
|
|
417
|
-
background-color: rgba(
|
|
435
|
+
background-color: rgba(255, 255, 255, 0.05);
|
|
418
436
|
}
|
|
419
437
|
|
|
420
438
|
.debugger-container.highlight {
|
|
421
|
-
background-color:
|
|
422
|
-
color: #
|
|
423
|
-
/* text-shadow: 0 0 5px #fff; */
|
|
424
|
-
border-bottom: 1px solid #fff;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
.debugger-container.highlight span {
|
|
428
|
-
color: #fff;
|
|
439
|
+
background-color: #87cefa; /* LightSkyBlue */
|
|
440
|
+
color: #000;
|
|
429
441
|
}
|
|
430
442
|
|
|
431
443
|
.debugger-container p {
|
|
432
444
|
margin: 0;
|
|
433
|
-
opacity: 0.
|
|
445
|
+
opacity: 0.9;
|
|
434
446
|
}
|
|
435
447
|
|
|
436
448
|
.debugger-container span {
|
|
437
449
|
font-weight: bold;
|
|
438
450
|
}
|
|
439
451
|
|
|
452
|
+
@media only screen and (max-width: 600px) {
|
|
453
|
+
#debugger {
|
|
454
|
+
display: none !important;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
440
458
|
#modal-background {
|
|
441
459
|
position: absolute;
|
|
442
460
|
inset: 0;
|
|
@@ -668,6 +686,213 @@
|
|
|
668
686
|
left: 15px;
|
|
669
687
|
}
|
|
670
688
|
|
|
689
|
+
#shortcuts-modal-background {
|
|
690
|
+
position: absolute;
|
|
691
|
+
inset: 0;
|
|
692
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
693
|
+
z-index: 1000;
|
|
694
|
+
display: flex;
|
|
695
|
+
justify-content: center;
|
|
696
|
+
align-items: center;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
#shortcuts-modal-background.hidden {
|
|
700
|
+
display: none;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
#shortcuts-modal {
|
|
704
|
+
width: 80%;
|
|
705
|
+
max-width: 500px;
|
|
706
|
+
height: auto;
|
|
707
|
+
max-height: 80vh;
|
|
708
|
+
min-width: 320px;
|
|
709
|
+
position: relative;
|
|
710
|
+
overflow: hidden;
|
|
711
|
+
|
|
712
|
+
display: flex;
|
|
713
|
+
flex-direction: column;
|
|
714
|
+
align-items: center;
|
|
715
|
+
box-sizing: border-box;
|
|
716
|
+
padding: 1rem 0;
|
|
717
|
+
|
|
718
|
+
background-color: var(--main-color);
|
|
719
|
+
|
|
720
|
+
border-radius: var(--border-radius);
|
|
721
|
+
border: var(--border);
|
|
722
|
+
|
|
723
|
+
box-shadow:
|
|
724
|
+
calc(var(--width) * -0.03) calc(var(--width) * 0.03) var(--dispersion) black,
|
|
725
|
+
calc(var(--width) * -0.02) calc(var(--width) * 0.02) var(--dispersion) var(--color-shadow-reflexion) inset,
|
|
726
|
+
calc(var(--width) * 0.01) calc(var(--width) * -0.01) var(--dispersion) var(--color-shadow) inset;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
#shortcuts-modal-frame {
|
|
730
|
+
border: var(--border);
|
|
731
|
+
border-radius: var(--border-radius);
|
|
732
|
+
|
|
733
|
+
position: relative;
|
|
734
|
+
|
|
735
|
+
width: 90%;
|
|
736
|
+
flex: 1;
|
|
737
|
+
margin: 1rem 0;
|
|
738
|
+
min-height: 0;
|
|
739
|
+
|
|
740
|
+
display: flex;
|
|
741
|
+
flex-direction: column;
|
|
742
|
+
justify-content: center;
|
|
743
|
+
align-items: center;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
#shortcuts-modal-frame > h2 {
|
|
747
|
+
position: absolute;
|
|
748
|
+
top: 0;
|
|
749
|
+
transform: translateY(-50%);
|
|
750
|
+
|
|
751
|
+
text-align: center;
|
|
752
|
+
|
|
753
|
+
font-family: 'retro-gamming';
|
|
754
|
+
font-weight: bold;
|
|
755
|
+
font-size: clamp(1rem, calc(var(--height) * 0.03), 1.4rem);
|
|
756
|
+
|
|
757
|
+
background-color: var(--main-color);
|
|
758
|
+
padding: 0 calc(var(--width) * 0.02);
|
|
759
|
+
|
|
760
|
+
text-shadow:
|
|
761
|
+
calc(var(--width) * -0.003) calc(var(--width) * 0.003) 0 var(--color-shadow),
|
|
762
|
+
calc(var(--width) * 0.002) calc(var(--width) * -0.002) 0 var(--color-shadow-reflexion);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
#shortcuts-modal-screen {
|
|
766
|
+
width: 84%;
|
|
767
|
+
height: 80%;
|
|
768
|
+
margin: 1.5rem 0;
|
|
769
|
+
|
|
770
|
+
border: var(--border);
|
|
771
|
+
box-shadow:
|
|
772
|
+
calc(var(--width) * -0.01) calc(var(--width) * 0.01) var(--dispersion) var(--color-shadow),
|
|
773
|
+
calc(var(--width) * 0.01) calc(var(--width) * -0.01) var(--dispersion) var(--color-shadow-reflexion);
|
|
774
|
+
|
|
775
|
+
background-image: url('../images/cell.svg');
|
|
776
|
+
background-size: 3.7%;
|
|
777
|
+
background-repeat: repeat;
|
|
778
|
+
|
|
779
|
+
display: flex;
|
|
780
|
+
flex-direction: column;
|
|
781
|
+
justify-content: flex-start;
|
|
782
|
+
align-items: center;
|
|
783
|
+
padding: 1rem;
|
|
784
|
+
overflow-y: auto;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
.shortcuts-grid {
|
|
788
|
+
width: 100%;
|
|
789
|
+
display: grid;
|
|
790
|
+
grid-template-columns: 1fr;
|
|
791
|
+
gap: 0.5rem;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
.shortcut-item {
|
|
795
|
+
display: flex;
|
|
796
|
+
justify-content: space-between;
|
|
797
|
+
align-items: center;
|
|
798
|
+
padding: 0.4rem 0.6rem;
|
|
799
|
+
border-bottom: 1px dashed rgba(0, 0, 0, 0.2);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
.shortcut-key {
|
|
803
|
+
font-family: 'retro-gamming';
|
|
804
|
+
background: rgba(0, 0, 0, 0.1);
|
|
805
|
+
padding: 0.3rem 0.6rem;
|
|
806
|
+
border-radius: 4px;
|
|
807
|
+
font-size: 1.1rem;
|
|
808
|
+
color: #333;
|
|
809
|
+
font-weight: bold;
|
|
810
|
+
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.shortcut-action {
|
|
814
|
+
font-family: 'retro-gamming';
|
|
815
|
+
font-size: 1.2rem;
|
|
816
|
+
color: #222;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
#close-shortcuts {
|
|
820
|
+
width: 40%;
|
|
821
|
+
max-width: 150px;
|
|
822
|
+
padding: 0.8rem 0;
|
|
823
|
+
margin-bottom: 0.5rem;
|
|
824
|
+
|
|
825
|
+
border: var(--border);
|
|
826
|
+
border-radius: var(--border-radius);
|
|
827
|
+
|
|
828
|
+
background-color: var(--button-color);
|
|
829
|
+
box-shadow:
|
|
830
|
+
calc(var(--width) * -0.015) calc(var(--width) * 0.015) var(--dispersion) var(--color-shadow),
|
|
831
|
+
calc(var(--width) * -0.0175) calc(var(--width) * 0.0175) var(--dispersion) var(--button-color-reflexion) inset;
|
|
832
|
+
|
|
833
|
+
font-family: 'retro-gamming';
|
|
834
|
+
color: white;
|
|
835
|
+
text-align: center;
|
|
836
|
+
cursor: pointer;
|
|
837
|
+
|
|
838
|
+
font-size: 1rem;
|
|
839
|
+
|
|
840
|
+
text-shadow:
|
|
841
|
+
calc(var(--width) * -0.003) calc(var(--width) * 0.003) 0 var(--button-color-shadow),
|
|
842
|
+
calc(var(--width) * 0.002) calc(var(--width) * -0.002) 0 var(--button-color-reflexion);
|
|
843
|
+
|
|
844
|
+
transition:
|
|
845
|
+
transform var(--button-animation-duration),
|
|
846
|
+
box-shadow var(--button-animation-duration);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
#close-shortcuts:active {
|
|
850
|
+
box-shadow:
|
|
851
|
+
calc(var(--width) * -0.005) calc(var(--width) * 0.005) var(--dispersion) var(--color-shadow),
|
|
852
|
+
calc(var(--width) * -0.004) calc(var(--width) * 0.004) var(--dispersion) var(--button-color-reflexion) inset;
|
|
853
|
+
transform: translate(calc(var(--width) * -0.005), calc(var(--width) * 0.005));
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
#btn-shortcuts-external {
|
|
857
|
+
position: absolute;
|
|
858
|
+
top: 10px;
|
|
859
|
+
left: 10px;
|
|
860
|
+
padding: 0 15px;
|
|
861
|
+
height: 40px;
|
|
862
|
+
display: flex;
|
|
863
|
+
align-items: center;
|
|
864
|
+
justify-content: center;
|
|
865
|
+
background-color: var(--main-color);
|
|
866
|
+
color: white;
|
|
867
|
+
border: var(--border);
|
|
868
|
+
font-family: 'retro-gamming', monospace;
|
|
869
|
+
font-size: 14px;
|
|
870
|
+
font-weight: bold;
|
|
871
|
+
cursor: pointer;
|
|
872
|
+
z-index: 9998;
|
|
873
|
+
border-radius: var(--border-radius);
|
|
874
|
+
box-shadow:
|
|
875
|
+
calc(var(--width) * -0.015) calc(var(--width) * 0.015) var(--dispersion) black,
|
|
876
|
+
calc(var(--width) * -0.01) calc(var(--width) * 0.01) var(--dispersion) var(--color-shadow-reflexion) inset,
|
|
877
|
+
calc(var(--width) * 0.005) calc(var(--width) * -0.005) var(--dispersion) var(--color-shadow) inset;
|
|
878
|
+
transition: all 0.2s;
|
|
879
|
+
text-shadow: 1px 1px var(--color-shadow);
|
|
880
|
+
box-sizing: border-box;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
#btn-shortcuts-external:active {
|
|
884
|
+
transform: translate(-2px, 2px);
|
|
885
|
+
box-shadow: none;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/* Hide external trigger and modal on mobile */
|
|
889
|
+
@media only screen and (max-width: 600px) {
|
|
890
|
+
#shortcuts-modal-background,
|
|
891
|
+
#btn-shortcuts-external {
|
|
892
|
+
display: none !important;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
671
896
|
#splash {
|
|
672
897
|
position: absolute;
|
|
673
898
|
top: 0;
|
package/dist/game.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("p5")):"function"==typeof define&&define.amd?define(["p5"],e):"object"==typeof exports?exports.BrickEngine=e(require("p5")):t.BrickEngine=e(t.p5)}(self,t=>(()=>{"use strict";var e={991(e){e.exports=t}},i={};function n(t){var r=i[t];if(void 0!==r)return r.exports;var o=i[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r,o,s,a,u,c,l,h,d,p={};n.r(p),n.d(p,{Color:()=>r,ControlEventType:()=>h,ControlKey:()=>l,EventEmitter:()=>m,FontAlign:()=>o,FontSize:()=>a,FontVerticalAlign:()=>u,Game:()=>ft,GameView:()=>qt,RendererContext:()=>N,Sound:()=>c,StateProperty:()=>d,TextTheme:()=>s,bootstrap:()=>ee,configs:()=>f,setActiveGame:()=>te}),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.SHADOW="rgb(93, 105, 92)"}(r||(r={})),function(t){t.CENTER="center",t.LEFT="left",t.RIGHT="right"}(o||(o={})),function(t){t.ACTIVE="active",t.INACTIVE="inactive",t.SHADOW="shadow"}(s||(s={})),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"}(a||(a={})),function(t){t.CENTER="center",t.TOP="top",t.BOTTOM="bottom"}(u||(u={})),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"}(c||(c={})),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",t.TRACKPAD="trackpad;system"}(l||(l={})),function(t){t.PRESSED="pressed",t.HELD="held"}(h||(h={})),function(t){t.ON="on",t.START="start",t.PLAYING="playing",t.GAME_OVER="gameOver",t.COLOR_ENABLED="colorEnabled",t.MUTED="muted",t.TRACKPAD="trackpadEnabled"}(d||(d={}));const f={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},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"},buttonHold:{holdDelayMs:250,holdIntervalMs:50},game:{tickInterval:1e3/30,minTickInterval:1e3/60,debugger:{enabled:!0},sound:{volume:.025}}},g=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,h.PRESSED);var i=setTimeout(function(){var i=setInterval(function(){e._control.notify(t,h.HELD)},f.buttonHold.holdIntervalMs),n=e._activeKeys.get(t);n&&(n.hold=i)},f.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 y={ArrowUp:l.UP,ArrowDown:l.DOWN,ArrowLeft:l.LEFT,ArrowRight:l.RIGHT,KeyW:l.UP,KeyS:l.DOWN,KeyA:l.LEFT,KeyD:l.RIGHT,KeyJ:l.ACTION,Digit1:l.POWER,Digit2:l.START_PAUSE,Digit3:l.SOUND,Digit4:l.RESET,Digit5:l.EXIT,Digit6:l.COLOR,Digit7:l.TRACKPAD};const v=function(){function t(t){this._inputHandler=new g(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=y[t.code];e&&(t.repeat||this._inputHandler.handlePress(e))},t.prototype._handleKeyUp=function(t){var e=y[t.code];e&&this._inputHandler.handleRelease(e)},t}();var _;!function(t){t.TITLE="title",t.PLAYING="playing",t.GAMEOVER="gameover",t.PAUSED="paused"}(_||(_={}));const m=function(){function t(){}return t.subscribe=function(t,e,i){var n=this._formatName(t,i);this._events[n]||(this._events[n]=[]),this._events[n].push(e)},t.unsubscribe=function(t,e,i){var n=this._formatName(t,i);this._events[n]&&(this._events[n]=this._events[n].filter(function(t){return t!==e}))},t.notify=function(t,e){this._events[t]&&this._events[t].forEach(function(t){return t(e)})},t.notifyContextual=function(t,e,i){this.notify(t,e),i.isPlaying()?this.notify(this._formatName(t,_.PLAYING),e):i.isPaused()?this.notify(this._formatName(t,_.PAUSED),e):i.isOn()&&!i.isStarted()?this.notify(this._formatName(t,_.TITLE),e):i.isGameOver()&&this.notify(this._formatName(t,_.GAMEOVER),e)},t._formatName=function(t,e){return e?"".concat(t,":").concat(e):t},t.clear=function(){this._events={}},t._events={},t}();var b=function(){function t(){this._activeListeners=[]}return t.prototype.setup=function(){this._keyBinding=new v(this),this._keyBinding.bindControls()},t.prototype.unbindControls=function(){this._keyBinding.unbindControls(),this._activeListeners.forEach(function(t){var e=t.event,i=t.callback;m.unsubscribe(e,i)}),this._activeListeners=[]},t.prototype.bindControls=function(){this._keyBinding.bindControls()},t.prototype.setModules=function(t){this._modules=t},t.prototype.subscribe=function(t,e,i){this._subscribe(t,e,i)},t.prototype.unsubscribe=function(t,e,i){this._unsubscribe(t,e,i)},t.prototype.subscribeForTitleScreen=function(t,e,i){this._subscribe(t,e,i,_.TITLE)},t.prototype.unsubscribeForTitleScreen=function(t,e,i){this._unsubscribe(t,e,i,_.TITLE)},t.prototype.subscribeForGameOverScreen=function(t,e,i){this._subscribe(t,e,i,_.GAMEOVER)},t.prototype.unsubscribeForGameOverScreen=function(t,e,i){this._unsubscribe(t,e,i,_.GAMEOVER)},t.prototype.subscribeForPlayingScreen=function(t,e,i){this._subscribe(t,e,i,_.PLAYING)},t.prototype.unsubscribeForPlayingScreen=function(t,e,i){this._unsubscribe(t,e,i,_.PLAYING)},t.prototype.subscribeForPausedScreen=function(t,e,i){this._subscribe(t,e,i,_.PAUSED)},t.prototype.unsubscribeForPausedScreen=function(t,e,i){this._unsubscribe(t,e,i,_.PAUSED)},t.prototype._subscribe=function(t,e,i,n){var r="".concat(t,":").concat(e);m.subscribe(r,i,n);var o=n?"".concat(r,":").concat(n):r;this._activeListeners.push({event:o,callback:i})},t.prototype._unsubscribe=function(t,e,i,n){var r="".concat(t,":").concat(e);m.unsubscribe(r,i,n);var o=n?"".concat(r,":").concat(n):r;this._activeListeners=this._activeListeners.filter(function(t){return!(t.event===o&&t.callback===i)})},t.prototype.notify=function(t,e){if(!this._modules)throw new Error("Modules not initialized");var i={key:t,type:e,modules:this._modules},n=this._modules.state,r=this._modules.session,o=!1;r.isModalOpen()||n.isPlaying()&&!r.isSessionResolved()?o=!1:n.isOff()?o=t===l.POWER||t===l.TRACKPAD:!n.isStarted()||n.isPlaying()||n.isGameOver()?o=!0:n.isPaused()&&(o=t.endsWith(";system")),o&&m.notifyContextual("".concat(t,":").concat(e),i,n)},t.prototype.getDebugData=function(){return{total_active_listeners:this._activeListeners.length}},t}();const E=b,S=function(){function t(){}return t.emptyCell=function(t){return{value:0,color:r.DEFAULT,coordinate:t}},t}();var w=function(){return w=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},w.apply(this,arguments)},P=function(){function t(t){this.grid=t}return t.prototype.movePiece=function(t,e){var i=this,n=t.map(function(t){return w(w({},t),{coordinate:{x:t.coordinate.x+(e.x||0),y:t.coordinate.y+(e.y||0)}})}),r=n.some(function(e){if(!i.grid.isCoordinateValid(e.coordinate))return!0;var n,r=i.grid.getCell(e.coordinate);return r&&i.grid.isCellActive(r)&&(n=e.coordinate,!t.some(function(t){return t.coordinate.x===n.x&&t.coordinate.y===n.y}))});return r?t: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)};if(!this.grid.isCoordinateValid(i))return t;var n=this.grid.getCell(i);return n&&this.grid.isCellActive(n)?t:w(w({},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);i!==e;)e=i,i=this.movePieceDown(e);return e},t.prototype.getRisePath=function(t){for(var e=t,i=this.movePieceUp(e);i!==e;)e=i,i=this.movePieceUp(e);return e},t.prototype.getReachPathLeft=function(t){for(var e=t,i=this.movePieceLeft(e);i!==e;)e=i,i=this.movePieceLeft(e);return e},t.prototype.getReachPathRight=function(t){for(var e=t,i=this.movePieceRight(e);i!==e;)e=i,i=this.movePieceRight(e);return e},t}();const R=P;var x=function(){return x=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},x.apply(this,arguments)},C=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 x(x({},t),{coordinate:{x:e.x+o,y:e.y+s}})}),o=r.some(function(e){if(!n.grid.isCoordinateValid(e.coordinate))return!0;var i,r=n.grid.getCell(e.coordinate);return r&&n.grid.isCellActive(r)&&(i=e.coordinate,!t.some(function(t){return t.coordinate.x===i.x&&t.coordinate.y===i.y}))});return o?t: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 x(x({},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 O=C;var T=function(){return T=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},T.apply(this,arguments)},A=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++){var r=this.grid.getCell({x:n,y:e});if(r&&!this.grid.isCellActive(r)){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++){var r=this.grid.getCell({x:e,y:n});if(r&&!this.grid.isCellActive(r)){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};if(i.grid.isCoordinateValid(r)){var o=i.grid.getCell(r);o&&n.push(o)}}),n},t.prototype.findConnectedCells=function(t){var e=this,i=this.grid.getCell(t);if(!i||!this.grid.isCellActive(i))return[];var n=i.value,r=[],o=new Set,s=[t],a=function(t){return"".concat(t.x,",").concat(t.y)};for(o.add(a(t));s.length>0;){var u=s.shift(),c=this.grid.getCell(u);c.value===n&&(r.push(c),[{x:u.x-1,y:u.y},{x:u.x+1,y:u.y},{x:u.x,y:u.y-1},{x:u.x,y:u.y+1}].forEach(function(t){var i=a(t),n=e.grid.getCell(t);e.grid.isCoordinateValid(t)&&!o.has(i)&&n&&e.grid.isCellActive(n)&&(o.add(i),s.push(t))}))}return r},t.prototype.swapCells=function(t,e){var i=T({},this.grid.getCell(t)),n=T({},this.grid.getCell(e));this.grid.stampCell(T(T({},n),{coordinate:t})),this.grid.stampCell(T(T({},i),{coordinate:e}))},t}();const D=A;var L=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]=S.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]=S.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 k=L;var M=function(){function t(t){this.grid=t}return t.prototype.isAreaOccupied=function(t){var e=this;return t.some(function(t){if(!e.grid.isCoordinateValid(t))return!0;var i=e.grid.getCell(t);return i&&e.grid.isCellActive(i)})},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 I=M;var G=function(){function t(){this._grid=[],this.serialId="grid",this._movementEngine=new R(this),this._transformEngine=new O(this),this._analysisEngine=new D(this),this._lineEngine=new k(this),this._regionEngine=new I(this)}return t.prototype.getGrid=function(){return this._grid},Object.defineProperty(t.prototype,"width",{get:function(){return f.screenLayout.grid.columns},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return f.screenLayout.grid.rows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"topRow",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottomRow",{get:function(){return this.height-1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftColumn",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightColumn",{get:function(){return this.width-1},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]=S.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.isCoordinateValid=function(t){return t.x>=0&&t.x<this.width&&t.y>=0&&t.y<this.height},t.prototype.getCell=function(t){return this.isCoordinateValid(t)?this._grid[t.y][t.x]:null},t.prototype.setCellValue=function(t,e){this.isCoordinateValid(t)&&(this._grid[t.y][t.x].value=e)},t.prototype.setCellColor=function(t,e){this.isCoordinateValid(t)&&(this._grid[t.y][t.x].color=e)},t.prototype.isCellActive=function(t){return null!==t&&t.value>0},t.prototype.isCellInactive=function(t){return null!==t&&0===t.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 JSON.stringify({grid:this._grid})},t.prototype.deserialize=function(t){var e=JSON.parse(t);this._grid=e.grid},t}();const B=G,N=function(){function t(){}return t.init=function(t){this._p?console.warn("[BrickEngine] RendererContext is already initialized. Ignoring subsequent initialization."):this._p=t},Object.defineProperty(t,"p",{get:function(){if(!this._p)throw new Error("RendererContext not initialized yet. Ensure the Game object has been created.");return this._p},enumerable:!1,configurable:!0}),t.reset=function(){this._p=void 0},t}(),H=function(){function t(){}return t.getRelativeWidth=function(t){return t*N.p.width},t.getRelativeHeight=function(t){return t*N.p.height},t}();var F=function(){function t(){}return t.prototype.setup=function(t){this._rendererMetrics=t;var e=f.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()},t.prototype.render=function(t,e){var i=N.p;i.push(),i.image(this._staticGraphics,0,0),this.renderGrid(t,e.state),i.pop()},t.prototype._renderStaticElements=function(){var t=N.p,e=f.screenLayout.display.borderWeight;this._staticGraphics=t.createGraphics(t.width,t.height),this._staticGraphics.background(f.colors.background),this._staticGraphics.strokeWeight(H.getRelativeWidth(e)),this._staticGraphics.noFill(),this._staticGraphics.stroke(f.colors.active),this._staticGraphics.rect(this._rendererMetrics.display.origin.x,this._rendererMetrics.display.origin.y,this._rendererMetrics.display.width,this._rendererMetrics.display.height)},t.prototype.renderCell=function(t,e){var i=t.coordinate,n=t.color,o=t.value,s=N.p,a=i.x,u=i.y,c=this._cellPreCalculatedGeometry,l=c.innerOffset,h=c.innerSize,d=c.paddingOffset,p=c.paddingSize,f=c.strokeWeight;n=0===o||!e.isPlaying()&&!e.isPaused()?r.INACTIVE:e.isColorEnabled()||n===r.SHADOW?n:r.DEFAULT,s.push(),s.translate(this._rendererMetrics.display.origin.x+a*this._rendererMetrics.cell.size,this._rendererMetrics.display.origin.y+u*this._rendererMetrics.cell.size),s.strokeWeight(f),s.stroke(n),s.noFill(),s.rect(l,l,h,h),s.fill(n),s.rect(d,d,p,p),s.pop()},t.prototype.renderGrid=function(t,e){var i=this;t.forEach(function(t){t.forEach(function(t){i.renderCell(t,e)})})},t}();const z=F;var U=function(){function t(){}return t.getRelativeCoordinate=function(t){return{x:H.getRelativeWidth(t.x),y:H.getRelativeHeight(t.y)}},t.getDisplayPosX=function(t,e){var i=f.screenLayout.display.margin;return e*t+H.getRelativeWidth(i)},t.getDisplayPosY=function(t,e){var i=f.screenLayout.display.margin;return e*t+H.getRelativeHeight(i)},t.getHudPosX=function(t,e){var i=N.p,n=f.screenLayout.display.margin,r=H.getRelativeWidth(n),o=e+2*r;return(i.width-o-r)*t+o},t.getHudPosY=function(t,e){var i=f.screenLayout.display.margin;return e*t+H.getRelativeHeight(i)},t}();const j=U;var W=function(){function t(){}return t.prototype.setup=function(t){this._cellSize=t.cell.size,this._gridOrigin={x:j.getHudPosX(.078,t.display.width),y:j.getHudPosY(.375,t.display.height)},this._hudBorderRect={x:this._gridOrigin.x-H.getRelativeWidth(.005),y:this._gridOrigin.y-H.getRelativeHeight(.005),w:4*this._cellSize+H.getRelativeWidth(.01),h:4*this._cellSize+H.getRelativeHeight(.01)}},t.prototype.render=function(t,e){this._renderHud(e),this._drawHudGrid(e)},t.prototype._renderHud=function(t){var e=N.p,i=t.text,n=t.state,r=t.score;e.push(),i.setTextSize(a.SMALL),i.setInactiveText(),i.setTextAlign(o.LEFT,u.BOTTOM),i.writeOnHud("88888888",{x:.05,y:.13}),i.writeOnHud("88888888",{x:.05,y:.3}),i.writeOnHud("88 - 88",{x:.05,y:.8}),n.isOn()&&i.setActiveText(),i.writeOnHud("Score",{x:.05,y:.06}),i.writeOnHud(r.score.toString(),{x:.05,y:.13}),i.writeOnHud("Hi-Score",{x:.05,y:.23}),i.writeOnHud(r.highScore.toString(),{x:.05,y:.3}),i.writeOnHud("Level",{x:.05,y:.72});var s="".concat(r.level<10?"0"+r.level:r.level," - ").concat(r.maxLevel);i.writeOnHud(s,{x:.05,y:.8}),i.setTextAlign(o.CENTER,u.BOTTOM),n.isPaused()?i.setActiveText():i.setInactiveText(),i.writeOnHud("Paused",{x:.5,y:.9}),n.isOn()&&n.isMuted()?i.setActiveText():i.setInactiveText(),i.writeOnHud("Muted",{x:.5,y:.97}),e.pop(),this._drawHudGrid(t)},t.prototype._drawHudGrid=function(t){var e=this,i=N.p,n=t.hudGrid,o=t.state;i.push(),n.forEach(function(t){var i=t.coordinate,n=i.x,s=i.y;o.isOff()&&!o.isPlaying()&&(t.value=0);var a=0!==t.value?r.DEFAULT:r.INACTIVE;o.isColorEnabled()&&0!==t.value&&(a=t.color),e.drawCellElement({w:e._cellSize,h:e._cellSize,posX:e._gridOrigin.x+e._cellSize*n,posY:e._gridOrigin.y+e._cellSize*s,color:a})}),i.noFill(),i.stroke(o.isOn()?r.DEFAULT:r.INACTIVE),i.rect(this._hudBorderRect.x,this._hudBorderRect.y,this._hudBorderRect.w,this._hudBorderRect.h),i.pop()},t.prototype.drawCellElement=function(t){var e=t.w,i=t.posX,n=t.posY,r=t.color,o=N.p,s=f.screenLayout.cell,a=s.margin,u=s.padding,c=a*e,l=e-a*e*2,h=u*e,d=e-u*e*2,p=s.strokeWeight*e;o.push(),o.translate(i,n),o.strokeWeight(p),o.stroke(r),o.noFill(),o.rect(c,c,l,l),o.fill(r),o.rect(h,h,d,d),o.pop()},t}();const V=W;var K=function(){function t(){}return t.prototype.addRenderer=function(t){this._renderers.push(t)},t.prototype.setup=function(){var t=this;this._displayRenderer=new z,this._hudRenderer=new V,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=f.screenLayout.display,e=t.width,i=t.height,n=t.margin,r=f.screenLayout.grid.columns,o=H.getRelativeWidth(e),s=H.getRelativeHeight(i),a=j.getRelativeCoordinate({x:n,y:n}),u=o/r,c={x:j.getHudPosX(0,o),y:j.getHudPosY(0,s)},l=j.getHudPosX(1,o)-c.x,h=j.getHudPosY(1,s)-c.y;this._rendererMetrics={display:{width:o,height:s,origin:a},hud:{width:l,height:h,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 Y=K;var X,J=((X={})[d.ON]={defaultValue:!1},X[d.START]={defaultValue:!1},X[d.PLAYING]={defaultValue:!1},X[d.GAME_OVER]={defaultValue:!1},X[d.COLOR_ENABLED]={defaultValue:!0,storageKey:"colorEnabled"},X[d.MUTED]={defaultValue:!1,storageKey:"muted"},X[d.TRACKPAD]={defaultValue:!1,storageKey:"trackpadEnabled"},X);const q=function(){function t(){this._state=new Map}return t.prototype.setup=function(){var t=this;Object.values(d).forEach(function(e){var i=J[e];t._state.set(e,i.defaultValue)}),this._loadPersistentState()},t.prototype._loadPersistentState=function(){var t=this;Object.values(d).forEach(function(e){var i=J[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=J[t];i.storageKey&&localStorage.setItem(i.storageKey,JSON.stringify(e)),this.notify(t)}},t.prototype.notify=function(t){var e=this._state.get(t);m.notifyContextual(t,e,this)},t.prototype.isOn=function(){return this._state.get(d.ON)},t.prototype.isOff=function(){return!this.isOn()},t.prototype.isStarted=function(){return this._state.get(d.START)},t.prototype.isPlaying=function(){return this._state.get(d.PLAYING)},t.prototype.isPaused=function(){return this.isStarted()&&!this.isPlaying()&&!this.isGameOver()},t.prototype.isGameOver=function(){return this._state.get(d.GAME_OVER)},t.prototype.turnOn=function(){this._set(d.ON,!0),this._set(d.START,!1),this._set(d.PLAYING,!1),this._set(d.GAME_OVER,!1)},t.prototype.turnOff=function(){this._set(d.ON,!1),this._set(d.START,!1),this._set(d.PLAYING,!1),this._set(d.GAME_OVER,!1)},t.prototype.startGame=function(){this.isOn()&&(this._set(d.START,!0),this._set(d.PLAYING,!0),this._set(d.GAME_OVER,!1))},t.prototype.resetGameOver=function(){this._set(d.GAME_OVER,!1),this._set(d.START,!0),this._set(d.PLAYING,!0)},t.prototype.exitGame=function(){this._set(d.START,!1),this._set(d.PLAYING,!1),this._set(d.GAME_OVER,!1)},t.prototype.pause=function(){this.isStarted()&&!this.isGameOver()&&this._set(d.PLAYING,!1)},t.prototype.resume=function(){this.isStarted()&&!this.isGameOver()&&this._set(d.PLAYING,!0)},t.prototype.triggerGameOver=function(){this._set(d.PLAYING,!1),this._set(d.GAME_OVER,!0)},t.prototype.resetGame=function(){this.isOn()&&(this._set(d.GAME_OVER,!1),this._set(d.START,!0),this._set(d.PLAYING,!0))},t.prototype.isColorEnabled=function(){return this._state.get(d.COLOR_ENABLED)},t.prototype.setColorEnabled=function(t){this._set(d.COLOR_ENABLED,t)},t.prototype.isMuted=function(){return this._state.get(d.MUTED)},t.prototype.setMuted=function(t){this._set(d.MUTED,t)},t.prototype.toggleColorEnabled=function(){this.setColorEnabled(!this.isColorEnabled())},t.prototype.toggleMuted=function(){this.setMuted(!this.isMuted())},t.prototype.isTrackpadEnabled=function(){return this._state.get(d.TRACKPAD)},t.prototype.setTrackpadEnabled=function(t){this._set(d.TRACKPAD,t)},t.prototype.toggleTrackpadEnabled=function(){this.setTrackpadEnabled(!this.isTrackpadEnabled())},t.prototype.subscribe=function(t,e){this._subscribe(t,e)},t.prototype.unsubscribe=function(t,e){this._unsubscribe(t,e)},t.prototype.subscribeForTitleScreen=function(t,e){this._subscribe(t,e,_.TITLE)},t.prototype.unsubscribeForTitleScreen=function(t,e){this._unsubscribe(t,e,_.TITLE)},t.prototype.subscribeForGameOverScreen=function(t,e){this._subscribe(t,e,_.GAMEOVER)},t.prototype.unsubscribeForGameOverScreen=function(t,e){this._unsubscribe(t,e,_.GAMEOVER)},t.prototype.subscribeForPlayingScreen=function(t,e){this._subscribe(t,e,_.PLAYING)},t.prototype.unsubscribeForPlayingScreen=function(t,e){this._unsubscribe(t,e,_.PLAYING)},t.prototype.subscribeForPausedScreen=function(t,e){this._subscribe(t,e,_.PAUSED)},t.prototype.unsubscribeForPausedScreen=function(t,e){this._unsubscribe(t,e,_.PAUSED)},t.prototype._subscribe=function(t,e,i){m.subscribe(t,e,i)},t.prototype._unsubscribe=function(t,e,i){m.unsubscribe(t,e,i)},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(),trackpad:this.isTrackpadEnabled()}},t}();var Q=function(){function t(){this.defaultFontFamily="retro-gamming",this.fontSizes=[0]}return t.prototype.setup=function(){var t=N.p,e=f.screenLayout.fontSize,i=e.extraSmall,n=e.small,r=e.medium,o=e.large,s=e.extraLarge;t.textFont(this.defaultFontFamily),this.fontSizes=[],this.fontSizes[a.EXTRA_SMALL]=H.getRelativeWidth(i),this.fontSizes[a.SMALL]=H.getRelativeWidth(n),this.fontSizes[a.MEDIUM]=H.getRelativeWidth(r),this.fontSizes[a.LARGE]=H.getRelativeWidth(o),this.fontSizes[a.EXTRA_LARGE]=H.getRelativeWidth(s)},t.prototype.setTime=function(t){this._time=t},t.prototype.setRendererMetrics=function(t){this._rendererMetrics=t},t.prototype.setTextState=function(t){var e=N.p,i=f.colors,n=i.active,r=i.inactive;e.fill(t?n:r)},t.prototype.setActiveText=function(){this.setTextState(!0)},t.prototype.setInactiveText=function(){this.setTextState(!1)},t.prototype.setShadowText=function(){N.p.fill(r.SHADOW)},t.prototype.setTextTheme=function(t){switch(t){case s.ACTIVE:this.setActiveText();break;case s.INACTIVE:this.setInactiveText();break;case s.SHADOW:this.setShadowText()}},t.prototype.setTextSize=function(t){N.p.textSize(this.fontSizes[t])},t.prototype.setTextAlign=function(t,e){N.p.textAlign(t,e)},t.prototype.writeOnHud=function(t,e){var i=N.p,n=j.getHudPosX(e.x,this._rendererMetrics.display.width),r=j.getHudPosY(e.y,this._rendererMetrics.display.height);i.text(t,n,r)},t.prototype.writeOnDisplay=function(t,e){var i=N.p,n=j.getDisplayPosX(e.x,this._rendererMetrics.display.width),r=j.getDisplayPosY(e.y,this._rendererMetrics.display.height);i.text(t,n,r)},t.prototype.writePulsingTextOnHud=function(t,e,i){void 0===i&&(i=1e3);var n=Math.floor(this._time.elapsedTime%i/(i/4));0===n?(this.setActiveText(),this.writeOnHud(t,e)):1!==n&&3!==n||(this.setShadowText(),this.writeOnHud(t,e))},t.prototype.writePulsingTextOnDisplay=function(t,e,i){void 0===i&&(i=1e3);var n=Math.floor(this._time.elapsedTime%i/(i/4));0===n?(this.setActiveText(),this.writeOnDisplay(t,e)):1!==n&&3!==n||(this.setShadowText(),this.writeOnDisplay(t,e))},t.prototype.getDebugData=function(){return{current_font_family:this.defaultFontFamily,font_sizes_count:this.fontSizes.length}},t}();const $=Q,Z=function(){function t(){this._tickAccumulator=0,this._initialTickInterval=f.game.tickInterval,this._minTickInterval=f.game.minTickInterval,this._tickInterval=f.game.tickInterval,this._fps=0,this._tps=0,this._tickCounter=0,this._totalTicks=0,this._timeSinceLastTpsUpdate=0,this._totalElapsedTime=0,this.serialId="time"}return t.prototype.setup=function(){this.reset()},t.prototype.update=function(t){this._tickAccumulator+=t,this._totalElapsedTime+=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(){if(this._tickAccumulator>=this._tickInterval){for(;this._tickAccumulator>=this._tickInterval;)this._tickAccumulator-=this._tickInterval;return this._tickCounter++,this._totalTicks++,!0}return!1},t.prototype.reset=function(){this._tickAccumulator=0,this._fps=0,this._tps=0,this._tickCounter=0,this._totalTicks=0,this._timeSinceLastTpsUpdate=0,this._totalElapsedTime=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),tick_accumulator:this._tickAccumulator.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},Object.defineProperty(t.prototype,"totalTicks",{get:function(){return this._totalTicks},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"elapsedTime",{get:function(){return this._totalElapsedTime},enumerable:!1,configurable:!0}),t.prototype.isTickEvery=function(t){return this._totalTicks>0&&this._totalTicks%t===0},t.prototype.captureInitialState=function(){this._initialTickInterval=this._tickInterval},t}();var tt=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())})},et=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])}}},it=function(){function t(){this._buffers=new Map,this._activeSources=new Map,this._volume=1}return t.prototype.setup=function(){var t=f.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 tt(this,void 0,void 0,function(){var e,i,n;return et(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 tt(this,void 0,void 0,function(){var e;return et(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 tt(this,void 0,void 0,function(){var t,e,i,n;return et(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 tt(this,void 0,void 0,function(){var t,e=this;return et(this,function(i){switch(i.label){case 0:return t=Object.values(c).map(function(t){return tt(e,void 0,void 0,function(){var e,i,n;return et(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(d.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 nt=it,rt=function(){function t(){this._score=0,this._multiplier=1,this._level=1,this._maxLevel=10,this._highScore=0,this._gameId="unknown",this.serialId="score"}return t.prototype.setupGameHighScore=function(t){this._gameId=t,this._highScore=Number(localStorage.getItem("".concat(this._gameId,"::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("".concat(this._gameId,"::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 ot,st=(ot=function(t,e){return ot=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])},ot(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}ot(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});const at=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.serialId="hud_grid",e}return st(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}(B),ut=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 q)},t.isDebuggable=function(t){return null!=t&&"function"==typeof t.getDebugData},t}();var ct=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{if(n&&"object"==typeof n){var o=Object.getPrototypeOf(n)===Object.prototype||null===Object.getPrototypeOf(n),s=Array.isArray(n);o||s?r=structuredClone(n):(console.warn("[BrickEngine] Property '".concat(i,"' is a complex object without a clone() or copy() method. A reference will be saved. State reset might not work for its internal properties.")),r=n)}else r=n;console.log("capturing property",i,r)}catch(t){console.error("Failed to clone property '".concat(i,"' (value: ").concat(String(n),"). Saving reference instead. Reset may not work as expected for this property. Error:"),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 lt=ct,ht=function(){function t(){this._isSessionResolved=!1,this._isModalOpen=!1,this._isEnabled=!0,this._resetFn=function(){},this._serializables=[]}return t.prototype.register=function(t){this._serializables.push(t)},t.prototype.saveSession=function(){var t=this;this._isSessionResolved&&this._isEnabled&&!this._state.isGameOver()&&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.setResetFunction=function(t){this._resetFn=t},t.prototype.setSessionEnabled=function(t){this._isEnabled=t},t.prototype.isModalOpen=function(){return this._isModalOpen},t.prototype.isSessionResolved=function(){return this._isSessionResolved},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.syncState=function(t){var e=this;this._state=t,t.subscribe(d.PLAYING,function(t){if(t&&!e._isSessionResolved){if(!e._hasSession()||!e._isEnabled)return void(e._isSessionResolved=!0);e._isModalOpen=!0,N.p.noLoop(),e._showSessionModal(function(){e._loadSession(),e._isModalOpen=!1,e._isSessionResolved=!0,N.p.loop()},function(){e.clearSession(),e._resetFn(),e._isModalOpen=!1,e._isSessionResolved=!0,N.p.loop()})}}),t.subscribe(d.ON,function(t){t||(e._isModalOpen=!1,e._isSessionResolved=!1)}),t.subscribe(d.START,function(t){t||(e._isSessionResolved=!1)}),t.subscribe(d.GAME_OVER,function(t){t&&e.clearSession()})},t.prototype.getDebugData=function(){return{game_id:this.gameId,is_session_resolved:this._isSessionResolved,is_modal_open:this._isModalOpen,is_enabled:this._isEnabled,serializables:this._serializables.map(function(t){return t.serialId}).join(", ")}},t.prototype._key=function(t){return"".concat(this.gameId,"::").concat(t)},t}(),dt=function(){function t(){}return t.setupControlEvents=function(t,e){var i=t.control,n=t.state,r=t.session,o=t.sound;i.subscribe(l.SOUND,h.PRESSED,function(){return n.toggleMuted()}),i.subscribe(l.COLOR,h.PRESSED,function(){return n.toggleColorEnabled()}),i.subscribe(l.EXIT,h.PRESSED,function(){return r.clearSession()}),i.subscribe(l.TRACKPAD,h.PRESSED,function(){return n.toggleTrackpadEnabled()}),i.subscribe(l.POWER,h.PRESSED,function(){n.isOn()?(n.turnOff(),o.stopAll()):n.turnOn()}),i.subscribeForGameOverScreen(l.POWER,h.PRESSED,function(){e(),n.resetGameOver()}),i.subscribeForTitleScreen(l.START_PAUSE,h.PRESSED,function(){return n.startGame()}),i.subscribeForPlayingScreen(l.START_PAUSE,h.PRESSED,function(){return n.pause()}),i.subscribeForGameOverScreen(l.START_PAUSE,h.PRESSED,function(){e(),n.resetGameOver()}),i.subscribeForPausedScreen(l.START_PAUSE,h.PRESSED,function(){return n.resume()}),i.subscribeForPlayingScreen(l.RESET,h.PRESSED,function(){e(),n.resetGame()}),i.subscribeForPausedScreen(l.RESET,h.PRESSED,function(){e(),n.resetGame()})},t.setupStateEvents=function(t,e){var i=t.state,n=t.session;i.subscribe(d.ON,function(e){e||(t.grid.resetGrid(),t.score.resetScore(),t.score.resetLevel(),t.time.reset())}),i.subscribeForGameOverScreen(d.GAME_OVER,function(){n.clearSession()}),i.subscribe(d.TRACKPAD,function(t){e.applyTrackpadState(t)}),e.applyTrackpadState(i.isTrackpadEnabled())},t}();var pt=function(){function t(t){this._modules=void 0,this._initialStateSnapshot=new lt,this._gameId="unknown",this._view=t,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}),Object.defineProperty(t.prototype,"view",{get:function(){return this._view},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"modules",{get:function(){return this._modules},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"p",{get:function(){return N.p},enumerable:!1,configurable:!0}),t.prototype.setup=function(){var t=this;m.clear(),this._view.build(),this._modules={renderer:new Y,grid:new B,hudGrid:new at,text:new $,state:new q,control:new E,time:new Z,sound:new nt,score:new rt,session:new ht},Object.values(this._modules).forEach(function(t){ut.isInitializable(t)&&t.setup()}),Object.values(this._modules).forEach(function(e){ut.isStateSyncable(e)&&e.syncState(t._modules.state)}),Object.values(this._modules).forEach(function(e){ut.isSerializable(e)&&t._modules.session.register(e)});var e=this._modules,i=e.text,n=e.control,r=e.renderer,o=e.session,s=e.score,a=e.time;o.gameId=this.gameId,o.setShowModalFunction(this._view.showSessionModal.bind(this._view)),o.setResetFunction(this.reset.bind(this)),n.setModules(this._modules),i.setRendererMetrics(r.rendererMetrics),i.setTime(a),s.setupGameHighScore(this.gameId),this.setupGame(),dt.setupControlEvents(this._modules,this.reset.bind(this)),dt.setupStateEvents(this._modules,this._view),this._view.bindControls(n),this._modules.time.captureInitialState(),this._initialStateSnapshot.captureInitialState(this)},t.prototype.draw=function(){var t=N.p;if(this._modules){var e=this._modules,i=e.renderer,n=e.grid,r=e.time,o=e.state,s=e.session;s.isModalOpen()||o.isPlaying()&&!s.isSessionResolved()||(r.update(t.deltaTime),i.render(n.getGrid(),this._modules),o.isOn()&&(o.isStarted()?o.isPlaying()?(r.shouldTick()&&(this.update(t.deltaTime),this._modules.session.saveSession()),this.render()):o.isPaused()&&this.render():this.drawTitleScreen(),o.isGameOver()&&this.drawGameOverScreen()))}},t.prototype.destroy=function(){N.p.noLoop(),this._modules&&(this._modules.control.unbindControls(),this._modules.sound.stopAll()),m.clear()},t.prototype.reset=function(){this._modules.grid.resetGrid(),this._modules.score.resetScore(),this._modules.score.resetLevel(),this._modules.time.reset(),this._modules.session.clearSession(),this._initialStateSnapshot.restoreInitialState(this)},t}();const ft=pt;var gt={grad:.9,turn:360,rad:360/(2*Math.PI)},yt=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},vt=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},_t=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},mt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},bt=function(t){return{r:_t(t.r,0,255),g:_t(t.g,0,255),b:_t(t.b,0,255),a:_t(t.a)}},Et=function(t){return{r:vt(t.r),g:vt(t.g),b:vt(t.b),a:vt(t.a,3)}},St=/^#([0-9a-f]{3,8})$/i,wt=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Pt=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}},Rt=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}},xt=function(t){return{h:mt(t.h),s:_t(t.s,0,100),l:_t(t.l,0,100),a:_t(t.a)}},Ct=function(t){return{h:vt(t.h),s:vt(t.s),l:vt(t.l),a:vt(t.a,3)}},Ot=function(t){return Rt((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},Tt=function(t){return{h:(e=Pt(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},At=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Dt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,kt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Mt={string:[[function(t){var e=St.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?vt(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?vt(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=Lt.exec(t)||kt.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:bt({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=At.exec(t)||Dt.exec(t);if(!e)return null;var i,n,r=xt({h:(i=e[1],n=e[2],void 0===n&&(n="deg"),Number(i)*(gt[n]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return Ot(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 yt(e)&&yt(i)&&yt(n)?bt({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(!yt(e)||!yt(i)||!yt(n))return null;var s=xt({h:Number(e),s:Number(i),l:Number(n),a:Number(o)});return Ot(s)},"hsl"],[function(t){var e=t.h,i=t.s,n=t.v,r=t.a,o=void 0===r?1:r;if(!yt(e)||!yt(i)||!yt(n))return null;var s=function(t){return{h:mt(t.h),s:_t(t.s,0,100),v:_t(t.v,0,100),a:_t(t.a)}}({h:Number(e),s:Number(i),v:Number(n),a:Number(o)});return Rt(s)},"hsv"]]},It=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]},Gt=function(t,e){var i=Tt(t);return{h:i.h,s:_t(i.s+100*e,0,100),l:i.l,a:i.a}},Bt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Nt=function(t,e){var i=Tt(t);return{h:i.h,s:i.s,l:_t(i.l+100*e,0,100),a:i.a}},Ht=function(){function t(t){this.parsed=function(t){return"string"==typeof t?It(t.trim(),Mt.string):"object"==typeof t&&null!==t?It(t,Mt.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 vt(Bt(this.rgba),2)},t.prototype.isDark=function(){return Bt(this.rgba)<.5},t.prototype.isLight=function(){return Bt(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=Et(this.rgba)).r,i=t.g,n=t.b,o=(r=t.a)<1?wt(vt(255*r)):"","#"+wt(e)+wt(i)+wt(n)+o;var t,e,i,n,r,o},t.prototype.toRgb=function(){return Et(this.rgba)},t.prototype.toRgbString=function(){return e=(t=Et(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 Ct(Tt(this.rgba))},t.prototype.toHslString=function(){return e=(t=Ct(Tt(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=Pt(this.rgba),{h:vt(t.h),s:vt(t.s),v:vt(t.v),a:vt(t.a,3)};var t},t.prototype.invert=function(){return Ft({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),Ft(Gt(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),Ft(Gt(this.rgba,-t))},t.prototype.grayscale=function(){return Ft(Gt(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),Ft(Nt(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),Ft(Nt(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?Ft({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):vt(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=Tt(this.rgba);return"number"==typeof t?Ft({h:t,s:e.s,l:e.l,a:e.a}):vt(e.h)},t.prototype.isEqual=function(t){return this.toHex()===Ft(t).toHex()},t}(),Ft=function(t){return t instanceof Ht?t:new Ht(t)};function zt(t,e){var i=N.p,n=i.createDiv();n.parent(t),n.addClass("btn-container");var r=i.createButton(e);return r.parent(n),r.addClass("btn"),r}function Ut(t,e,i){var n=N.p,r=n.createDiv();r.parent(t),r.addClass("sm-btn-container"),r.addClass(i?"sm-btn-container-top":"sm-btn-container-bottom");var o=n.createButton("");o.parent(r),o.addClass("sm-btn");var s=n.createP(e);return s.parent(r),s.addClass("sm-btn-p"),o}var jt=function(){function t(t){this._moduleElements=[],this._gameModules=t}return t.prototype.setup=function(){var t=this;if(f.game.debugger.enabled){var e=N.p,i=e.select("#debugger"),n=!!i&&i.elt.hasAttribute("open"),r=new Set;i&&(e.selectAll(".debugger-module").forEach(function(t){t.elt.hasAttribute("open")&&r.add(t.id())}),i.remove()),this._moduleElements=[];var o=e.createElement("details");o.id("debugger"),n&&o.attribute("open",""),o.parent(e.select("body"));var s=e.createElement("summary");s.id("debugger-summary"),s.html("Debug"),s.parent(o),Object.entries(this._gameModules).forEach(function(i){var n=i[0],s=i[1];if("getDebugData"in s){var a={module:s,properties:[]},u=e.createElement("details");u.class("debugger-module"),u.id("debugger-".concat(n)),r.has("debugger-".concat(n))&&u.attribute("open",""),u.parent(o);var c=e.createElement("summary");c.id("debugger-".concat(n,"-summary")),c.html(n),c.class("debugger-module-summary"),c.parent(u);var l=s.getDebugData();Object.entries(l).forEach(function(t){var i=t[0],n=t[1],r=e.createElement("div");r.class("debugger-container"),r.id("debugger-container-".concat(i,"-").concat(n)),r.parent(u),r.mouseClicked(function(){r.toggleClass("highlight")});var o=e.createElement("p");o.id("debugger-".concat(i,"-").concat(n)),o.html("".concat(i,":")),o.parent(r);var s=e.createElement("span");s.id("debugger-".concat(i,"-").concat(n,"-value")),s.html("".concat(n)),s.parent(r),a.properties.push({key:i,element:s})}),t._moduleElements.push(a)}})}},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 Wt=jt;var Vt=function(){function t(){}return t.prototype.setup=function(){var t=N.p;this._container=t.createDiv(),this._container.parent(t.select("body")),this._container.id("modal-background"),this._container.class("hidden");var e=t.createDiv();e.parent(this._container),e.id("session-modal");var i=t.createDiv();i.parent(e),i.id("session-modal-frame");var n=t.createP();n.parent(i),n.html("Brick Engine Session");var r=t.createDiv();r.parent(i),r.id("session-modal-screen");var o=t.createP();o.parent(r),o.html("<span>Looks like you have an active session.</span><br><br>Do you want to continue?");var s=t.createDiv();s.parent(e),s.id("session-modal-buttons"),this._cancelButton=t.createButton("Cancel"),this._cancelButton.parent(s),this._cancelButton.class("session-modal-button"),this._confirmButton=t.createButton("Confirm"),this._confirmButton.parent(s),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 Kt=Vt;var Yt=function(){function t(t,e){var i=this;this._isDrawing=!1,this._startX=0,this._startY=0,this._maxDist=0,this._lastDirection=null,this._threshold=30,this._tapThreshold=10,this._points=[],this._loop=function(){if(i._ctx&&(i._ctx.globalCompositeOperation="destination-out",i._ctx.fillStyle="rgba(255, 255, 255, 0.1)",i._ctx.fillRect(0,0,i._canvas.width,i._canvas.height),i._ctx.globalCompositeOperation="source-over",i._isDrawing&&i._points.length>1)){i._ctx.beginPath(),i._ctx.strokeStyle=f.colors.bodyButton,i._ctx.lineWidth=6,i._ctx.lineCap="round",i._ctx.lineJoin="round";var t=i._points[i._points.length-1],e=i._points[i._points.length-2];i._ctx.moveTo(e.x,e.y),i._ctx.lineTo(t.x,t.y),i._ctx.stroke()}i._animationFrameId=requestAnimationFrame(i._loop)},this._inputHandler=e;var n=N.p;this._container=n.createDiv(),this._container.parent(t),this._container.addClass("trackpad-surface");var r=n.createP("Swipe for Directions<br/>Tap for Action");r.parent(this._container),r.addClass("trackpad-hint"),this._canvas=document.createElement("canvas"),this._canvas.classList.add("trackpad-canvas"),this._container.elt.appendChild(this._canvas),this._ctx=this._canvas.getContext("2d"),new ResizeObserver(function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];i._canvas.width=r.contentRect.width,i._canvas.height=r.contentRect.height}}).observe(this._container.elt),this._bindEvents(),this._loop()}return t.prototype._bindEvents=function(){var t=this._container.elt;t.addEventListener("pointerdown",this._onPointerDown.bind(this)),t.addEventListener("pointermove",this._onPointerMove.bind(this)),t.addEventListener("pointerup",this._onPointerUp.bind(this)),t.addEventListener("pointercancel",this._onPointerUp.bind(this)),t.addEventListener("pointerout",this._onPointerUp.bind(this)),t.addEventListener("contextmenu",function(t){return t.preventDefault()})},t.prototype._getCoords=function(t){var e=this._container.elt.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}},t.prototype._onPointerDown=function(t){this._isDrawing=!0;var e=this._getCoords(t),i=e.x,n=e.y;this._startX=i,this._startY=n,this._maxDist=0,this._lastDirection=null,this._points=[{x:i,y:n}],t.preventDefault(),this._container.elt.setPointerCapture(t.pointerId)},t.prototype._onPointerMove=function(t){if(this._isDrawing){var e=this._getCoords(t),i=e.x,n=e.y;this._points.push({x:i,y:n});var r=i-this._startX,o=n-this._startY,s=Math.sqrt(r*r+o*o);if(s>this._maxDist&&(this._maxDist=s),s>this._threshold){var a;a=Math.abs(r)>Math.abs(o)?r>0?l.RIGHT:l.LEFT:o>0?l.DOWN:l.UP,this._lastDirection!==a&&(this._lastDirection&&this._inputHandler.handleRelease(this._lastDirection),this._inputHandler.handlePress(a),this._lastDirection=a)}t.preventDefault()}},t.prototype._onPointerUp=function(t){var e=this;this._isDrawing&&(this._isDrawing=!1,this._lastDirection?(this._inputHandler.handleRelease(this._lastDirection),this._lastDirection=null):this._maxDist<this._tapThreshold&&(this._inputHandler.handlePress(l.ACTION),setTimeout(function(){return e._inputHandler.handleRelease(l.ACTION)},50)),this._container.elt.releasePointerCapture(t.pointerId))},t.prototype.destroy=function(){cancelAnimationFrame(this._animationFrameId),this._container.remove()},t}();const Xt=Yt;var Jt=function(){function t(t){this._trackpad=null,this._parent=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(f.inputQueryParams.mainColor)?i.get(f.inputQueryParams.mainColor):f.colors.bodyMain,r=i.has(f.inputQueryParams.buttonColor)?i.get(f.inputQueryParams.buttonColor):f.colors.bodyButton,t.style.setProperty("--main-color",n),t.style.setProperty("--button-color",r),t.style.setProperty("--color-shadow",Ft(n).darken(.15).toHex()),t.style.setProperty("--color-shadow-reflexion",Ft(n).lighten(.15).toHex()),t.style.setProperty("--button-color-reflexion",Ft(r).lighten(.15).toHex()),t.style.setProperty("--button-color-shadow",Ft(r).darken(.15).toHex());var o=function(t){var e,i=N.p.createDiv();if(i.parent("#brick-game"),i.id("container"),t.clientWidth<=f.viewLayout.mobileBreakpoint)return{container:i,width:e=t.clientWidth,height:t.clientHeight};var n=t.clientHeight/(1.05*f.viewLayout.bodyHeightWidthMultiplier);return{container:i,width:e=Math.min(t.clientWidth,n),height:e*f.viewLayout.bodyHeightWidthMultiplier}}(this._parent),s=o.container,a=o.height,u=o.width,c=function(t){var e=N.p,i=e.createDiv();i.parent(t),i.id("frame");var n=e.createDiv();return n.parent(i),e.createP("Brick Engine").parent(n),i}(s),l=function(t,e){var i=N.p,n=e*f.viewLayout.canvas.widthRatio,r=n*f.viewLayout.canvas.aspectRatio,o=i.createCanvas(n,r);return o.parent(t),o.id("brick-game-canvas"),{canvasWidth:n,canvasHeight:r,canvas:o}}(c,u),h=l.canvas,d=l.canvasHeight,p=l.canvasWidth,g=function(t){var e=N.p,i=e.createDiv();i.parent(t),i.id("button-container");var n=e.createDiv();n.parent(i),n.id("small-button-container");var r=e.createDiv();r.parent(i),r.id("inner-button-container");var o=e.createDiv();o.parent(r),o.id("medium-button-container");var s=e.createDiv();s.parent(o),s.id("direction-vertical-container");var a=e.createDiv();a.parent(o),a.id("direction-horizontal-container");var u=e.createDiv();u.parent(r),u.id("large-button-container");var c=e.createDiv();return c.parent(r),c.id("trackpad-container"),{smallButtonContainer:n,mediumButtonContainer:o,largeButtonContainer:u,directionVerticalContainer:s,directionHorizontalContainer:a,trackpadContainer:c}}(s),y=g.largeButtonContainer,v=g.smallButtonContainer,_=g.directionHorizontalContainer,m=g.directionVerticalContainer,b=g.mediumButtonContainer,E=g.trackpadContainer;return this._mediumButtonContainer=b,this._largeButtonContainer=y,this._trackpadContainer=E,this._onOffBtn=Ut(v,"On<br/>Off",!0),this._startPauseBtn=Ut(v,"Start<br/>Pause",!1),this._soundBtn=Ut(v,"Sound",!0),this._resetBtn=Ut(v,"Reset",!1),this._exitBtn=Ut(v,"Exit",!0),this._enableColorBtn=Ut(v,"Enable<br/>Colors",!1),this._trackpadBtn=Ut(v,"Track<br/>Pad",!0),this._upBtn=zt(m,"UP"),this._leftBtn=zt(_,"LEFT"),this._downBtn=zt(m,"DOWN"),this._rightBtn=zt(_,"RIGHT"),this._actionBtn=function(t){var e=N.p,i=e.createDiv();i.parent(t),i.addClass("lg-btn-container");var n=e.createButton("Action");return n.parent(i),n.addClass("lg-btn"),n}(y),function(t,e,i,n){var r=document.querySelector(":root");r.style.setProperty("--dispersion",f.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*f.viewLayout.dimensions.borderRadiusRatio,"px")),r.style.setProperty("--border","".concat(t*f.viewLayout.dimensions.borderWidthRatio,"px solid black")),r.style.setProperty("--sm-button-size","".concat(t*f.viewLayout.dimensions.button.smSizeRatio,"px")),r.style.setProperty("--button-size","".concat(t*f.viewLayout.dimensions.button.mdSizeRatio,"px")),r.style.setProperty("--lg-button-size","".concat(t*f.viewLayout.dimensions.button.lgSizeRatio,"px")),r.style.setProperty("--sm-button-size-mobile","".concat(t*f.viewLayout.dimensions.button.mobile.smSizeRatio,"px")),r.style.setProperty("--button-size-mobile","".concat(t*f.viewLayout.dimensions.button.mobile.mdSizeRatio,"px")),r.style.setProperty("--lg-button-size-mobile","".concat(t*f.viewLayout.dimensions.button.mobile.lgSizeRatio,"px")),r.style.setProperty("--sm-button-size-mobile-font-size","".concat(t*f.viewLayout.dimensions.button.mobile.smFontRatio,"px")),r.style.setProperty("--sm-button-size-mobile-line-height","".concat(t*f.viewLayout.dimensions.button.mobile.smFontRatio,"px")),r.style.setProperty("--button-size-mobile-font-size","".concat(t*f.viewLayout.dimensions.button.mobile.fontRatio,"px")),r.style.setProperty("--lg-button-size-mobile-font-size","".concat(t*f.viewLayout.dimensions.button.mobile.lgFontRatio,"px")),r.style.setProperty("--button-size-mobile-spacing","".concat(t*f.viewLayout.dimensions.button.mobile.spacingRatio,"px")),r.style.setProperty("--button-border","".concat(t*f.viewLayout.dimensions.button.borderRatio,"px solid black")),r.style.setProperty("--button-animation-duration",f.viewLayout.dimensions.button.animationDuration)}(u,a,p,d),this._hideSplash(),this._cachedCanvas={canvas:h,canvasWidth:p,canvasHeight:d},this._cachedCanvas},t.prototype.setupSessionModal=function(){this._sessionModal=new Kt,this._sessionModal.setup()},t.prototype.showSessionModal=function(t,e){this._sessionModal.show(t,e)},t.prototype.setupDebugger=function(t){this._debugger=new Wt(t),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 g(t),this._trackpad&&this._trackpad.destroy(),this._trackpad=new Xt(this._trackpadContainer,this._inputHandler),this._bindButtonEvents(this._onOffBtn,l.POWER),this._bindButtonEvents(this._startPauseBtn,l.START_PAUSE),this._bindButtonEvents(this._soundBtn,l.SOUND),this._bindButtonEvents(this._resetBtn,l.RESET),this._bindButtonEvents(this._exitBtn,l.EXIT),this._bindButtonEvents(this._enableColorBtn,l.COLOR),this._bindButtonEvents(this._trackpadBtn,l.TRACKPAD),this._bindButtonEvents(this._upBtn,l.UP),this._bindButtonEvents(this._downBtn,l.DOWN),this._bindButtonEvents(this._rightBtn,l.RIGHT),this._bindButtonEvents(this._leftBtn,l.LEFT),this._bindButtonEvents(this._actionBtn,l.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._trackpadBtn.mousePressed(function(){}).mouseReleased(function(){}),this._trackpad&&(this._trackpad.destroy(),this._trackpad=null),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=f.viewLayout.splashHideDelayMs);var e=document.querySelector("#splash");setTimeout(function(){e.style.display="none"},t)},t.prototype.applyTrackpadState=function(t){t?(this._mediumButtonContainer.style("display","none"),this._largeButtonContainer.style("display","none"),this._trackpadContainer.style("display","flex")):(this._mediumButtonContainer.style("display","flex"),this._largeButtonContainer.style("display","flex"),this._trackpadContainer.style("display","none"))},t}();const qt=Jt;var Qt,$t=n(991),Zt=n.n($t);function te(t){Qt=t}function ee(t){return window.BrickEngineGame=t,new(Zt())(function(e){N.init(e);var i=new qt(document.body);te(new t(i)),"unknown"===Qt.gameId&&(Qt.gameId="game"),e.setup=function(){Qt.setup(),Qt.view.setupDebugger(Qt.modules),Qt.view.setupSessionModal()},e.draw=function(){Qt.draw(),Qt.view.updateDebugger()}})}return p})());
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("p5")):"function"==typeof define&&define.amd?define(["p5"],e):"object"==typeof exports?exports.BrickEngine=e(require("p5")):t.BrickEngine=e(t.p5)}(self,t=>(()=>{"use strict";var e={991(e){e.exports=t}},i={};function n(t){var r=i[t];if(void 0!==r)return r.exports;var o=i[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r,o,s,a,u,c,l,h,d,p={};n.r(p),n.d(p,{Color:()=>r,ControlEventType:()=>h,ControlKey:()=>l,EventEmitter:()=>m,FontAlign:()=>o,FontSize:()=>a,FontVerticalAlign:()=>u,Game:()=>ft,GameView:()=>$t,RendererContext:()=>H,Sound:()=>c,StateProperty:()=>d,TextTheme:()=>s,bootstrap:()=>ne,configs:()=>f,setActiveGame:()=>ie}),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.SHADOW="rgb(93, 105, 92)"}(r||(r={})),function(t){t.CENTER="center",t.LEFT="left",t.RIGHT="right"}(o||(o={})),function(t){t.ACTIVE="active",t.INACTIVE="inactive",t.SHADOW="shadow"}(s||(s={})),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"}(a||(a={})),function(t){t.CENTER="center",t.TOP="top",t.BOTTOM="bottom"}(u||(u={})),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"}(c||(c={})),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",t.TRACKPAD="trackpad;system",t.SHORTCUTS="shortcuts;system"}(l||(l={})),function(t){t.PRESSED="pressed",t.HELD="held"}(h||(h={})),function(t){t.ON="on",t.START="start",t.PLAYING="playing",t.GAME_OVER="gameOver",t.COLOR_ENABLED="colorEnabled",t.MUTED="muted",t.TRACKPAD="trackpadEnabled"}(d||(d={}));const f={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},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"},buttonHold:{holdDelayMs:250,holdIntervalMs:50},game:{tickInterval:1e3/30,minTickInterval:1e3/60,debugger:{enabled:!0},sound:{volume:.025}}},g=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,h.PRESSED);var i=setTimeout(function(){var i=setInterval(function(){e._control.notify(t,h.HELD)},f.buttonHold.holdIntervalMs),n=e._activeKeys.get(t);n&&(n.hold=i)},f.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 y={ArrowUp:l.UP,ArrowDown:l.DOWN,ArrowLeft:l.LEFT,ArrowRight:l.RIGHT,KeyW:l.UP,KeyS:l.DOWN,KeyA:l.LEFT,KeyD:l.RIGHT,KeyJ:l.ACTION,Digit1:l.POWER,Digit2:l.START_PAUSE,Digit3:l.SOUND,Digit4:l.RESET,Digit5:l.EXIT,Digit6:l.COLOR,Digit7:l.TRACKPAD,KeyH:l.SHORTCUTS};const _=function(){function t(t){this._inputHandler=new g(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=y[t.code];e&&(t.repeat||this._inputHandler.handlePress(e))},t.prototype._handleKeyUp=function(t){var e=y[t.code];e&&this._inputHandler.handleRelease(e)},t}();var v;!function(t){t.TITLE="title",t.PLAYING="playing",t.GAMEOVER="gameover",t.PAUSED="paused"}(v||(v={}));const m=function(){function t(){}return t.subscribe=function(t,e,i){var n=this._formatName(t,i);this._events[n]||(this._events[n]=[]),this._events[n].push(e)},t.unsubscribe=function(t,e,i){var n=this._formatName(t,i);this._events[n]&&(this._events[n]=this._events[n].filter(function(t){return t!==e}))},t.notify=function(t,e){this._events[t]&&this._events[t].forEach(function(t){return t(e)})},t.notifyContextual=function(t,e,i){this.notify(t,e),i.isPlaying()?this.notify(this._formatName(t,v.PLAYING),e):i.isPaused()?this.notify(this._formatName(t,v.PAUSED),e):i.isOn()&&!i.isStarted()?this.notify(this._formatName(t,v.TITLE),e):i.isGameOver()&&this.notify(this._formatName(t,v.GAMEOVER),e)},t._formatName=function(t,e){return e?"".concat(t,":").concat(e):t},t.clear=function(){this._events={}},t._events={},t}();var b=function(){function t(){this._activeListeners=[]}return t.prototype.setup=function(){this._keyBinding=new _(this),this._keyBinding.bindControls()},t.prototype.unbindControls=function(){this._keyBinding.unbindControls(),this._activeListeners.forEach(function(t){var e=t.event,i=t.callback;m.unsubscribe(e,i)}),this._activeListeners=[]},t.prototype.bindControls=function(){this._keyBinding.bindControls()},t.prototype.setModules=function(t){this._modules=t},t.prototype.subscribe=function(t,e,i){this._subscribe(t,e,i)},t.prototype.unsubscribe=function(t,e,i){this._unsubscribe(t,e,i)},t.prototype.subscribeForTitleScreen=function(t,e,i){this._subscribe(t,e,i,v.TITLE)},t.prototype.unsubscribeForTitleScreen=function(t,e,i){this._unsubscribe(t,e,i,v.TITLE)},t.prototype.subscribeForGameOverScreen=function(t,e,i){this._subscribe(t,e,i,v.GAMEOVER)},t.prototype.unsubscribeForGameOverScreen=function(t,e,i){this._unsubscribe(t,e,i,v.GAMEOVER)},t.prototype.subscribeForPlayingScreen=function(t,e,i){this._subscribe(t,e,i,v.PLAYING)},t.prototype.unsubscribeForPlayingScreen=function(t,e,i){this._unsubscribe(t,e,i,v.PLAYING)},t.prototype.subscribeForPausedScreen=function(t,e,i){this._subscribe(t,e,i,v.PAUSED)},t.prototype.unsubscribeForPausedScreen=function(t,e,i){this._unsubscribe(t,e,i,v.PAUSED)},t.prototype._subscribe=function(t,e,i,n){var r="".concat(t,":").concat(e);m.subscribe(r,i,n);var o=n?"".concat(r,":").concat(n):r;this._activeListeners.push({event:o,callback:i})},t.prototype._unsubscribe=function(t,e,i,n){var r="".concat(t,":").concat(e);m.unsubscribe(r,i,n);var o=n?"".concat(r,":").concat(n):r;this._activeListeners=this._activeListeners.filter(function(t){return!(t.event===o&&t.callback===i)})},t.prototype.notify=function(t,e){if(!this._modules)throw new Error("Modules not initialized");var i={key:t,type:e,modules:this._modules},n=this._modules.state,r=this._modules.session,o=!1;r.isModalOpen()||n.isPlaying()&&!r.isSessionResolved()?o=!1:n.isOff()?o=[l.POWER,l.TRACKPAD,l.SHORTCUTS].includes(t):!n.isStarted()||n.isPlaying()||n.isGameOver()?o=!0:n.isPaused()&&(o=t.endsWith(";system")||t===l.SHORTCUTS),o&&m.notifyContextual("".concat(t,":").concat(e),i,n)},t.prototype.getDebugData=function(){return{total_active_listeners:this._activeListeners.length}},t}();const E=b,S=function(){function t(){}return t.emptyCell=function(t){return{value:0,color:r.DEFAULT,coordinate:t}},t}();var w=function(){return w=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},w.apply(this,arguments)},P=function(){function t(t){this.grid=t}return t.prototype.movePiece=function(t,e){var i=this,n=t.map(function(t){return w(w({},t),{coordinate:{x:t.coordinate.x+(e.x||0),y:t.coordinate.y+(e.y||0)}})}),r=n.some(function(e){if(!i.grid.isCoordinateValid(e.coordinate))return!0;var n,r=i.grid.getCell(e.coordinate);return r&&i.grid.isCellActive(r)&&(n=e.coordinate,!t.some(function(t){return t.coordinate.x===n.x&&t.coordinate.y===n.y}))});return r?t: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)};if(!this.grid.isCoordinateValid(i))return t;var n=this.grid.getCell(i);return n&&this.grid.isCellActive(n)?t:w(w({},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);i!==e;)e=i,i=this.movePieceDown(e);return e},t.prototype.getRisePath=function(t){for(var e=t,i=this.movePieceUp(e);i!==e;)e=i,i=this.movePieceUp(e);return e},t.prototype.getReachPathLeft=function(t){for(var e=t,i=this.movePieceLeft(e);i!==e;)e=i,i=this.movePieceLeft(e);return e},t.prototype.getReachPathRight=function(t){for(var e=t,i=this.movePieceRight(e);i!==e;)e=i,i=this.movePieceRight(e);return e},t}();const R=P;var C=function(){return C=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},C.apply(this,arguments)},x=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 C(C({},t),{coordinate:{x:e.x+o,y:e.y+s}})}),o=r.some(function(e){if(!n.grid.isCoordinateValid(e.coordinate))return!0;var i,r=n.grid.getCell(e.coordinate);return r&&n.grid.isCellActive(r)&&(i=e.coordinate,!t.some(function(t){return t.coordinate.x===i.x&&t.coordinate.y===i.y}))});return o?t: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 C(C({},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 O=x;var T=function(){return T=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},T.apply(this,arguments)},A=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++){var r=this.grid.getCell({x:n,y:e});if(r&&!this.grid.isCellActive(r)){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++){var r=this.grid.getCell({x:e,y:n});if(r&&!this.grid.isCellActive(r)){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};if(i.grid.isCoordinateValid(r)){var o=i.grid.getCell(r);o&&n.push(o)}}),n},t.prototype.findConnectedCells=function(t){var e=this,i=this.grid.getCell(t);if(!i||!this.grid.isCellActive(i))return[];var n=i.value,r=[],o=new Set,s=[t],a=function(t){return"".concat(t.x,",").concat(t.y)};for(o.add(a(t));s.length>0;){var u=s.shift(),c=this.grid.getCell(u);c.value===n&&(r.push(c),[{x:u.x-1,y:u.y},{x:u.x+1,y:u.y},{x:u.x,y:u.y-1},{x:u.x,y:u.y+1}].forEach(function(t){var i=a(t),n=e.grid.getCell(t);e.grid.isCoordinateValid(t)&&!o.has(i)&&n&&e.grid.isCellActive(n)&&(o.add(i),s.push(t))}))}return r},t.prototype.swapCells=function(t,e){var i=T({},this.grid.getCell(t)),n=T({},this.grid.getCell(e));this.grid.stampCell(T(T({},n),{coordinate:t})),this.grid.stampCell(T(T({},i),{coordinate:e}))},t}();const D=A;var k=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]=S.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]=S.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 M=k;var L=function(){function t(t){this.grid=t}return t.prototype.isAreaOccupied=function(t){var e=this;return t.some(function(t){if(!e.grid.isCoordinateValid(t))return!0;var i=e.grid.getCell(t);return i&&e.grid.isCellActive(i)})},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 I=L;var G=function(){function t(){this._grid=[],this.serialId="grid",this._movementEngine=new R(this),this._transformEngine=new O(this),this._analysisEngine=new D(this),this._lineEngine=new M(this),this._regionEngine=new I(this)}return t.prototype.getGrid=function(){return this._grid},Object.defineProperty(t.prototype,"width",{get:function(){return f.screenLayout.grid.columns},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return f.screenLayout.grid.rows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"topRow",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottomRow",{get:function(){return this.height-1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftColumn",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightColumn",{get:function(){return this.width-1},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]=S.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.isCoordinateValid=function(t){return t.x>=0&&t.x<this.width&&t.y>=0&&t.y<this.height},t.prototype.getCell=function(t){return this.isCoordinateValid(t)?this._grid[t.y][t.x]:null},t.prototype.setCellValue=function(t,e){this.isCoordinateValid(t)&&(this._grid[t.y][t.x].value=e)},t.prototype.setCellColor=function(t,e){this.isCoordinateValid(t)&&(this._grid[t.y][t.x].color=e)},t.prototype.isCellActive=function(t){return null!==t&&t.value>0},t.prototype.isCellInactive=function(t){return null!==t&&0===t.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 JSON.stringify({grid:this._grid})},t.prototype.deserialize=function(t){var e=JSON.parse(t);this._grid=e.grid},t}();const B=G,H=function(){function t(){}return t.init=function(t){this._p?console.warn("[BrickEngine] RendererContext is already initialized. Ignoring subsequent initialization."):this._p=t},Object.defineProperty(t,"p",{get:function(){if(!this._p)throw new Error("RendererContext not initialized yet. Ensure the Game object has been created.");return this._p},enumerable:!1,configurable:!0}),t.reset=function(){this._p=void 0},t}(),N=function(){function t(){}return t.getRelativeWidth=function(t){return t*H.p.width},t.getRelativeHeight=function(t){return t*H.p.height},t}();var F=function(){function t(){}return t.prototype.setup=function(t){this._rendererMetrics=t;var e=f.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()},t.prototype.render=function(t,e){var i=H.p;i.push(),i.image(this._staticGraphics,0,0),this.renderGrid(t,e.state),i.pop()},t.prototype._renderStaticElements=function(){var t=H.p,e=f.screenLayout.display.borderWeight;this._staticGraphics=t.createGraphics(t.width,t.height),this._staticGraphics.background(f.colors.background),this._staticGraphics.strokeWeight(N.getRelativeWidth(e)),this._staticGraphics.noFill(),this._staticGraphics.stroke(f.colors.active),this._staticGraphics.rect(this._rendererMetrics.display.origin.x,this._rendererMetrics.display.origin.y,this._rendererMetrics.display.width,this._rendererMetrics.display.height)},t.prototype.renderCell=function(t,e){var i=t.coordinate,n=t.color,o=t.value,s=H.p,a=i.x,u=i.y,c=this._cellPreCalculatedGeometry,l=c.innerOffset,h=c.innerSize,d=c.paddingOffset,p=c.paddingSize,f=c.strokeWeight;n=0===o||!e.isPlaying()&&!e.isPaused()?r.INACTIVE:e.isColorEnabled()||n===r.SHADOW?n:r.DEFAULT,s.push(),s.translate(this._rendererMetrics.display.origin.x+a*this._rendererMetrics.cell.size,this._rendererMetrics.display.origin.y+u*this._rendererMetrics.cell.size),s.strokeWeight(f),s.stroke(n),s.noFill(),s.rect(l,l,h,h),s.fill(n),s.rect(d,d,p,p),s.pop()},t.prototype.renderGrid=function(t,e){var i=this;t.forEach(function(t){t.forEach(function(t){i.renderCell(t,e)})})},t}();const z=F;var U=function(){function t(){}return t.getRelativeCoordinate=function(t){return{x:N.getRelativeWidth(t.x),y:N.getRelativeHeight(t.y)}},t.getDisplayPosX=function(t,e){var i=f.screenLayout.display.margin;return e*t+N.getRelativeWidth(i)},t.getDisplayPosY=function(t,e){var i=f.screenLayout.display.margin;return e*t+N.getRelativeHeight(i)},t.getHudPosX=function(t,e){var i=H.p,n=f.screenLayout.display.margin,r=N.getRelativeWidth(n),o=e+2*r;return(i.width-o-r)*t+o},t.getHudPosY=function(t,e){var i=f.screenLayout.display.margin;return e*t+N.getRelativeHeight(i)},t}();const j=U;var W=function(){function t(){}return t.prototype.setup=function(t){this._cellSize=t.cell.size,this._gridOrigin={x:j.getHudPosX(.078,t.display.width),y:j.getHudPosY(.375,t.display.height)},this._hudBorderRect={x:this._gridOrigin.x-N.getRelativeWidth(.005),y:this._gridOrigin.y-N.getRelativeHeight(.005),w:4*this._cellSize+N.getRelativeWidth(.01),h:4*this._cellSize+N.getRelativeHeight(.01)}},t.prototype.render=function(t,e){this._renderHud(e),this._drawHudGrid(e)},t.prototype._renderHud=function(t){var e=H.p,i=t.text,n=t.state,r=t.score;e.push(),i.setTextSize(a.SMALL),i.setInactiveText(),i.setTextAlign(o.LEFT,u.BOTTOM),i.writeOnHud("88888888",{x:.05,y:.13}),i.writeOnHud("88888888",{x:.05,y:.3}),i.writeOnHud("88 - 88",{x:.05,y:.8}),n.isOn()&&i.setActiveText(),i.writeOnHud("Score",{x:.05,y:.06}),i.writeOnHud(r.score.toString(),{x:.05,y:.13}),i.writeOnHud("Hi-Score",{x:.05,y:.23}),i.writeOnHud(r.highScore.toString(),{x:.05,y:.3}),i.writeOnHud("Level",{x:.05,y:.72});var s="".concat(r.level<10?"0"+r.level:r.level," - ").concat(r.maxLevel);i.writeOnHud(s,{x:.05,y:.8}),i.setTextAlign(o.CENTER,u.BOTTOM),n.isPaused()?i.setActiveText():i.setInactiveText(),i.writeOnHud("Paused",{x:.5,y:.9}),n.isOn()&&n.isMuted()?i.setActiveText():i.setInactiveText(),i.writeOnHud("Muted",{x:.5,y:.97}),e.pop(),this._drawHudGrid(t)},t.prototype._drawHudGrid=function(t){var e=this,i=H.p,n=t.hudGrid,o=t.state;i.push(),n.forEach(function(t){var i=t.coordinate,n=i.x,s=i.y;o.isOff()&&!o.isPlaying()&&(t.value=0);var a=0!==t.value?r.DEFAULT:r.INACTIVE;o.isColorEnabled()&&0!==t.value&&(a=t.color),e.drawCellElement({w:e._cellSize,h:e._cellSize,posX:e._gridOrigin.x+e._cellSize*n,posY:e._gridOrigin.y+e._cellSize*s,color:a})}),i.noFill(),i.stroke(o.isOn()?r.DEFAULT:r.INACTIVE),i.rect(this._hudBorderRect.x,this._hudBorderRect.y,this._hudBorderRect.w,this._hudBorderRect.h),i.pop()},t.prototype.drawCellElement=function(t){var e=t.w,i=t.posX,n=t.posY,r=t.color,o=H.p,s=f.screenLayout.cell,a=s.margin,u=s.padding,c=a*e,l=e-a*e*2,h=u*e,d=e-u*e*2,p=s.strokeWeight*e;o.push(),o.translate(i,n),o.strokeWeight(p),o.stroke(r),o.noFill(),o.rect(c,c,l,l),o.fill(r),o.rect(h,h,d,d),o.pop()},t}();const V=W;var K=function(){function t(){}return t.prototype.addRenderer=function(t){this._renderers.push(t)},t.prototype.setup=function(){var t=this;this._displayRenderer=new z,this._hudRenderer=new V,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=f.screenLayout.display,e=t.width,i=t.height,n=t.margin,r=f.screenLayout.grid.columns,o=N.getRelativeWidth(e),s=N.getRelativeHeight(i),a=j.getRelativeCoordinate({x:n,y:n}),u=o/r,c={x:j.getHudPosX(0,o),y:j.getHudPosY(0,s)},l=j.getHudPosX(1,o)-c.x,h=j.getHudPosY(1,s)-c.y;this._rendererMetrics={display:{width:o,height:s,origin:a},hud:{width:l,height:h,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 Y=K;var X,J=((X={})[d.ON]={defaultValue:!1},X[d.START]={defaultValue:!1},X[d.PLAYING]={defaultValue:!1},X[d.GAME_OVER]={defaultValue:!1},X[d.COLOR_ENABLED]={defaultValue:!0,storageKey:"colorEnabled"},X[d.MUTED]={defaultValue:!1,storageKey:"muted"},X[d.TRACKPAD]={defaultValue:!1,storageKey:"trackpadEnabled"},X);const q=function(){function t(){this._state=new Map}return t.prototype.setup=function(){var t=this;Object.values(d).forEach(function(e){var i=J[e];t._state.set(e,i.defaultValue)}),this._loadPersistentState()},t.prototype._loadPersistentState=function(){var t=this;Object.values(d).forEach(function(e){var i=J[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=J[t];i.storageKey&&localStorage.setItem(i.storageKey,JSON.stringify(e)),this.notify(t)}},t.prototype.notify=function(t){var e=this._state.get(t);m.notifyContextual(t,e,this)},t.prototype.isOn=function(){return this._state.get(d.ON)},t.prototype.isOff=function(){return!this.isOn()},t.prototype.isStarted=function(){return this._state.get(d.START)},t.prototype.isPlaying=function(){return this._state.get(d.PLAYING)},t.prototype.isPaused=function(){return this.isStarted()&&!this.isPlaying()&&!this.isGameOver()},t.prototype.isGameOver=function(){return this._state.get(d.GAME_OVER)},t.prototype.turnOn=function(){this._set(d.ON,!0),this._set(d.START,!1),this._set(d.PLAYING,!1),this._set(d.GAME_OVER,!1)},t.prototype.turnOff=function(){this._set(d.ON,!1),this._set(d.START,!1),this._set(d.PLAYING,!1),this._set(d.GAME_OVER,!1)},t.prototype.startGame=function(){this.isOn()&&(this._set(d.START,!0),this._set(d.PLAYING,!0),this._set(d.GAME_OVER,!1))},t.prototype.resetGameOver=function(){this._set(d.GAME_OVER,!1),this._set(d.START,!0),this._set(d.PLAYING,!0)},t.prototype.exitGame=function(){this._set(d.START,!1),this._set(d.PLAYING,!1),this._set(d.GAME_OVER,!1)},t.prototype.pause=function(){this.isStarted()&&!this.isGameOver()&&this._set(d.PLAYING,!1)},t.prototype.resume=function(){this.isStarted()&&!this.isGameOver()&&this._set(d.PLAYING,!0)},t.prototype.triggerGameOver=function(){this._set(d.PLAYING,!1),this._set(d.GAME_OVER,!0)},t.prototype.resetGame=function(){this.isOn()&&(this._set(d.GAME_OVER,!1),this._set(d.START,!0),this._set(d.PLAYING,!0))},t.prototype.isColorEnabled=function(){return this._state.get(d.COLOR_ENABLED)},t.prototype.setColorEnabled=function(t){this._set(d.COLOR_ENABLED,t)},t.prototype.isMuted=function(){return this._state.get(d.MUTED)},t.prototype.setMuted=function(t){this._set(d.MUTED,t)},t.prototype.toggleColorEnabled=function(){this.setColorEnabled(!this.isColorEnabled())},t.prototype.toggleMuted=function(){this.setMuted(!this.isMuted())},t.prototype.isTrackpadEnabled=function(){return this._state.get(d.TRACKPAD)},t.prototype.setTrackpadEnabled=function(t){this._set(d.TRACKPAD,t)},t.prototype.toggleTrackpadEnabled=function(){this.setTrackpadEnabled(!this.isTrackpadEnabled())},t.prototype.subscribe=function(t,e){this._subscribe(t,e)},t.prototype.unsubscribe=function(t,e){this._unsubscribe(t,e)},t.prototype.subscribeForTitleScreen=function(t,e){this._subscribe(t,e,v.TITLE)},t.prototype.unsubscribeForTitleScreen=function(t,e){this._unsubscribe(t,e,v.TITLE)},t.prototype.subscribeForGameOverScreen=function(t,e){this._subscribe(t,e,v.GAMEOVER)},t.prototype.unsubscribeForGameOverScreen=function(t,e){this._unsubscribe(t,e,v.GAMEOVER)},t.prototype.subscribeForPlayingScreen=function(t,e){this._subscribe(t,e,v.PLAYING)},t.prototype.unsubscribeForPlayingScreen=function(t,e){this._unsubscribe(t,e,v.PLAYING)},t.prototype.subscribeForPausedScreen=function(t,e){this._subscribe(t,e,v.PAUSED)},t.prototype.unsubscribeForPausedScreen=function(t,e){this._unsubscribe(t,e,v.PAUSED)},t.prototype._subscribe=function(t,e,i){m.subscribe(t,e,i)},t.prototype._unsubscribe=function(t,e,i){m.unsubscribe(t,e,i)},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(),trackpad:this.isTrackpadEnabled()}},t}();var Q=function(){function t(){this.defaultFontFamily="retro-gamming",this.fontSizes=[0]}return t.prototype.setup=function(){var t=H.p,e=f.screenLayout.fontSize,i=e.extraSmall,n=e.small,r=e.medium,o=e.large,s=e.extraLarge;t.textFont(this.defaultFontFamily),this.fontSizes=[],this.fontSizes[a.EXTRA_SMALL]=N.getRelativeWidth(i),this.fontSizes[a.SMALL]=N.getRelativeWidth(n),this.fontSizes[a.MEDIUM]=N.getRelativeWidth(r),this.fontSizes[a.LARGE]=N.getRelativeWidth(o),this.fontSizes[a.EXTRA_LARGE]=N.getRelativeWidth(s)},t.prototype.setTime=function(t){this._time=t},t.prototype.setRendererMetrics=function(t){this._rendererMetrics=t},t.prototype.setTextState=function(t){var e=H.p,i=f.colors,n=i.active,r=i.inactive;e.fill(t?n:r)},t.prototype.setActiveText=function(){this.setTextState(!0)},t.prototype.setInactiveText=function(){this.setTextState(!1)},t.prototype.setShadowText=function(){H.p.fill(r.SHADOW)},t.prototype.setTextTheme=function(t){switch(t){case s.ACTIVE:this.setActiveText();break;case s.INACTIVE:this.setInactiveText();break;case s.SHADOW:this.setShadowText()}},t.prototype.setTextSize=function(t){H.p.textSize(this.fontSizes[t])},t.prototype.setTextAlign=function(t,e){H.p.textAlign(t,e)},t.prototype.writeOnHud=function(t,e){var i=H.p,n=j.getHudPosX(e.x,this._rendererMetrics.display.width),r=j.getHudPosY(e.y,this._rendererMetrics.display.height);i.text(t,n,r)},t.prototype.writeOnDisplay=function(t,e){var i=H.p,n=j.getDisplayPosX(e.x,this._rendererMetrics.display.width),r=j.getDisplayPosY(e.y,this._rendererMetrics.display.height);i.text(t,n,r)},t.prototype.writePulsingTextOnHud=function(t,e,i){void 0===i&&(i=1e3);var n=Math.floor(this._time.elapsedTime%i/(i/4));0===n?(this.setActiveText(),this.writeOnHud(t,e)):1!==n&&3!==n||(this.setShadowText(),this.writeOnHud(t,e))},t.prototype.writePulsingTextOnDisplay=function(t,e,i){void 0===i&&(i=1e3);var n=Math.floor(this._time.elapsedTime%i/(i/4));0===n?(this.setActiveText(),this.writeOnDisplay(t,e)):1!==n&&3!==n||(this.setShadowText(),this.writeOnDisplay(t,e))},t.prototype.getDebugData=function(){return{current_font_family:this.defaultFontFamily,font_sizes_count:this.fontSizes.length}},t}();const $=Q,Z=function(){function t(){this._tickAccumulator=0,this._initialTickInterval=f.game.tickInterval,this._minTickInterval=f.game.minTickInterval,this._tickInterval=f.game.tickInterval,this._fps=0,this._tps=0,this._tickCounter=0,this._totalTicks=0,this._timeSinceLastTpsUpdate=0,this._totalElapsedTime=0,this.serialId="time"}return t.prototype.setup=function(){this.reset()},t.prototype.update=function(t){this._tickAccumulator+=t,this._totalElapsedTime+=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(){if(this._tickAccumulator>=this._tickInterval){for(;this._tickAccumulator>=this._tickInterval;)this._tickAccumulator-=this._tickInterval;return this._tickCounter++,this._totalTicks++,!0}return!1},t.prototype.reset=function(){this._tickAccumulator=0,this._fps=0,this._tps=0,this._tickCounter=0,this._totalTicks=0,this._timeSinceLastTpsUpdate=0,this._totalElapsedTime=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),tick_accumulator:this._tickAccumulator.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},Object.defineProperty(t.prototype,"totalTicks",{get:function(){return this._totalTicks},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"elapsedTime",{get:function(){return this._totalElapsedTime},enumerable:!1,configurable:!0}),t.prototype.isTickEvery=function(t){return this._totalTicks>0&&this._totalTicks%t===0},t.prototype.captureInitialState=function(){this._initialTickInterval=this._tickInterval},t}();var tt=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())})},et=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])}}},it=function(){function t(){this._buffers=new Map,this._activeSources=new Map,this._volume=1}return t.prototype.setup=function(){var t=f.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 tt(this,void 0,void 0,function(){var e,i,n;return et(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 tt(this,void 0,void 0,function(){var e;return et(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 tt(this,void 0,void 0,function(){var t,e,i,n;return et(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 tt(this,void 0,void 0,function(){var t,e=this;return et(this,function(i){switch(i.label){case 0:return t=Object.values(c).map(function(t){return tt(e,void 0,void 0,function(){var e,i,n;return et(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(d.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 nt=it,rt=function(){function t(){this._score=0,this._multiplier=1,this._level=1,this._maxLevel=10,this._highScore=0,this._gameId="unknown",this.serialId="score"}return t.prototype.setupGameHighScore=function(t){this._gameId=t,this._highScore=Number(localStorage.getItem("".concat(this._gameId,"::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("".concat(this._gameId,"::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 ot,st=(ot=function(t,e){return ot=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])},ot(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}ot(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});const at=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.serialId="hud_grid",e}return st(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}(B),ut=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 q)},t.isDebuggable=function(t){return null!=t&&"function"==typeof t.getDebugData},t}();var ct=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{if(n&&"object"==typeof n){var o=Object.getPrototypeOf(n)===Object.prototype||null===Object.getPrototypeOf(n),s=Array.isArray(n);o||s?r=structuredClone(n):(console.warn("[BrickEngine] Property '".concat(i,"' is a complex object without a clone() or copy() method. A reference will be saved. State reset might not work for its internal properties.")),r=n)}else r=n;console.log("capturing property",i,r)}catch(t){console.error("Failed to clone property '".concat(i,"' (value: ").concat(String(n),"). Saving reference instead. Reset may not work as expected for this property. Error:"),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 lt=ct,ht=function(){function t(){this._isSessionResolved=!1,this._isModalOpen=!1,this._isEnabled=!0,this._resetFn=function(){},this._serializables=[]}return t.prototype.register=function(t){this._serializables.push(t)},t.prototype.saveSession=function(){var t=this;this._isSessionResolved&&this._isEnabled&&!this._state.isGameOver()&&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.setResetFunction=function(t){this._resetFn=t},t.prototype.setSessionEnabled=function(t){this._isEnabled=t},t.prototype.isModalOpen=function(){return this._isModalOpen},t.prototype.isSessionResolved=function(){return this._isSessionResolved},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.syncState=function(t){var e=this;this._state=t,t.subscribe(d.PLAYING,function(t){if(t&&!e._isSessionResolved){if(!e._hasSession()||!e._isEnabled)return void(e._isSessionResolved=!0);e._isModalOpen=!0,H.p.noLoop(),e._showSessionModal(function(){e._loadSession(),e._isModalOpen=!1,e._isSessionResolved=!0,H.p.loop()},function(){e.clearSession(),e._resetFn(),e._isModalOpen=!1,e._isSessionResolved=!0,H.p.loop()})}}),t.subscribe(d.ON,function(t){t||(e._isModalOpen=!1,e._isSessionResolved=!1)}),t.subscribe(d.START,function(t){t||(e._isSessionResolved=!1)}),t.subscribe(d.GAME_OVER,function(t){t&&e.clearSession()})},t.prototype.getDebugData=function(){return{game_id:this.gameId,is_session_resolved:this._isSessionResolved,is_modal_open:this._isModalOpen,is_enabled:this._isEnabled,serializables:this._serializables.map(function(t){return t.serialId}).join(", ")}},t.prototype._key=function(t){return"".concat(this.gameId,"::").concat(t)},t}(),dt=function(){function t(){}return t.setupControlEvents=function(t,e,i){var n=t.control,r=t.state,o=t.session,s=t.sound;n.subscribe(l.SOUND,h.PRESSED,function(){return r.toggleMuted()}),n.subscribe(l.COLOR,h.PRESSED,function(){return r.toggleColorEnabled()}),n.subscribe(l.EXIT,h.PRESSED,function(){return o.clearSession()}),n.subscribe(l.TRACKPAD,h.PRESSED,function(){return r.toggleTrackpadEnabled()}),n.subscribe(l.SHORTCUTS,h.PRESSED,function(){return e.toggleShortcutsModal()}),n.subscribe(l.POWER,h.PRESSED,function(){r.isOn()?(r.turnOff(),s.stopAll()):r.turnOn()}),n.subscribeForGameOverScreen(l.POWER,h.PRESSED,function(){i(),r.resetGameOver()}),n.subscribeForTitleScreen(l.START_PAUSE,h.PRESSED,function(){return r.startGame()}),n.subscribeForPlayingScreen(l.START_PAUSE,h.PRESSED,function(){return r.pause()}),n.subscribeForGameOverScreen(l.START_PAUSE,h.PRESSED,function(){i(),r.resetGameOver()}),n.subscribeForPausedScreen(l.START_PAUSE,h.PRESSED,function(){return r.resume()}),n.subscribeForPlayingScreen(l.RESET,h.PRESSED,function(){i(),r.resetGame()}),n.subscribeForPausedScreen(l.RESET,h.PRESSED,function(){i(),r.resetGame()})},t.setupStateEvents=function(t,e){var i=t.state,n=t.session;i.subscribe(d.ON,function(e){e||(t.grid.resetGrid(),t.score.resetScore(),t.score.resetLevel(),t.time.reset())}),i.subscribeForGameOverScreen(d.GAME_OVER,function(){n.clearSession()}),i.subscribe(d.TRACKPAD,function(t){e.applyTrackpadState(t)}),e.applyTrackpadState(i.isTrackpadEnabled())},t}();var pt=function(){function t(t){this._modules=void 0,this._initialStateSnapshot=new lt,this._gameId="unknown",this._view=t,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}),Object.defineProperty(t.prototype,"view",{get:function(){return this._view},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"modules",{get:function(){return this._modules},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"p",{get:function(){return H.p},enumerable:!1,configurable:!0}),t.prototype.setup=function(){var t=this;m.clear(),this._view.build(),this._modules={renderer:new Y,grid:new B,hudGrid:new at,text:new $,state:new q,control:new E,time:new Z,sound:new nt,score:new rt,session:new ht},Object.values(this._modules).forEach(function(t){ut.isInitializable(t)&&t.setup()}),Object.values(this._modules).forEach(function(e){ut.isStateSyncable(e)&&e.syncState(t._modules.state)}),Object.values(this._modules).forEach(function(e){ut.isSerializable(e)&&t._modules.session.register(e)});var e=this._modules,i=e.text,n=e.control,r=e.renderer,o=e.session,s=e.score,a=e.time;o.gameId=this.gameId,o.setShowModalFunction(this._view.showSessionModal.bind(this._view)),o.setResetFunction(this.reset.bind(this)),n.setModules(this._modules),i.setRendererMetrics(r.rendererMetrics),i.setTime(a),s.setupGameHighScore(this.gameId),this.setupGame(),dt.setupControlEvents(this._modules,this._view,this.reset.bind(this)),dt.setupStateEvents(this._modules,this._view),this._view.bindControls(n),this._modules.time.captureInitialState(),this._initialStateSnapshot.captureInitialState(this)},t.prototype.draw=function(){var t=H.p;if(this._modules){var e=this._modules,i=e.renderer,n=e.grid,r=e.time,o=e.state,s=e.session;s.isModalOpen()||o.isPlaying()&&!s.isSessionResolved()||(r.update(t.deltaTime),i.render(n.getGrid(),this._modules),o.isOn()&&(o.isStarted()?o.isPlaying()?(r.shouldTick()&&(this.update(t.deltaTime),this._modules.session.saveSession()),this.render()):o.isPaused()&&this.render():this.drawTitleScreen(),o.isGameOver()&&this.drawGameOverScreen()))}},t.prototype.destroy=function(){H.p.noLoop(),this._modules&&(this._modules.control.unbindControls(),this._modules.sound.stopAll()),m.clear()},t.prototype.reset=function(){this._modules.grid.resetGrid(),this._modules.score.resetScore(),this._modules.score.resetLevel(),this._modules.time.reset(),this._modules.session.clearSession(),this._initialStateSnapshot.restoreInitialState(this)},t}();const ft=pt;var gt={grad:.9,turn:360,rad:360/(2*Math.PI)},yt=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},_t=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},vt=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},mt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},bt=function(t){return{r:vt(t.r,0,255),g:vt(t.g,0,255),b:vt(t.b,0,255),a:vt(t.a)}},Et=function(t){return{r:_t(t.r),g:_t(t.g),b:_t(t.b),a:_t(t.a,3)}},St=/^#([0-9a-f]{3,8})$/i,wt=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Pt=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}},Rt=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}},Ct=function(t){return{h:mt(t.h),s:vt(t.s,0,100),l:vt(t.l,0,100),a:vt(t.a)}},xt=function(t){return{h:_t(t.h),s:_t(t.s),l:_t(t.l),a:_t(t.a,3)}},Ot=function(t){return Rt((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},Tt=function(t){return{h:(e=Pt(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},At=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Dt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,kt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Mt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lt={string:[[function(t){var e=St.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?_t(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?_t(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=kt.exec(t)||Mt.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:bt({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=At.exec(t)||Dt.exec(t);if(!e)return null;var i,n,r=Ct({h:(i=e[1],n=e[2],void 0===n&&(n="deg"),Number(i)*(gt[n]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return Ot(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 yt(e)&&yt(i)&&yt(n)?bt({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(!yt(e)||!yt(i)||!yt(n))return null;var s=Ct({h:Number(e),s:Number(i),l:Number(n),a:Number(o)});return Ot(s)},"hsl"],[function(t){var e=t.h,i=t.s,n=t.v,r=t.a,o=void 0===r?1:r;if(!yt(e)||!yt(i)||!yt(n))return null;var s=function(t){return{h:mt(t.h),s:vt(t.s,0,100),v:vt(t.v,0,100),a:vt(t.a)}}({h:Number(e),s:Number(i),v:Number(n),a:Number(o)});return Rt(s)},"hsv"]]},It=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]},Gt=function(t,e){var i=Tt(t);return{h:i.h,s:vt(i.s+100*e,0,100),l:i.l,a:i.a}},Bt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Ht=function(t,e){var i=Tt(t);return{h:i.h,s:i.s,l:vt(i.l+100*e,0,100),a:i.a}},Nt=function(){function t(t){this.parsed=function(t){return"string"==typeof t?It(t.trim(),Lt.string):"object"==typeof t&&null!==t?It(t,Lt.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 _t(Bt(this.rgba),2)},t.prototype.isDark=function(){return Bt(this.rgba)<.5},t.prototype.isLight=function(){return Bt(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=Et(this.rgba)).r,i=t.g,n=t.b,o=(r=t.a)<1?wt(_t(255*r)):"","#"+wt(e)+wt(i)+wt(n)+o;var t,e,i,n,r,o},t.prototype.toRgb=function(){return Et(this.rgba)},t.prototype.toRgbString=function(){return e=(t=Et(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 xt(Tt(this.rgba))},t.prototype.toHslString=function(){return e=(t=xt(Tt(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=Pt(this.rgba),{h:_t(t.h),s:_t(t.s),v:_t(t.v),a:_t(t.a,3)};var t},t.prototype.invert=function(){return Ft({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),Ft(Gt(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),Ft(Gt(this.rgba,-t))},t.prototype.grayscale=function(){return Ft(Gt(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),Ft(Ht(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),Ft(Ht(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?Ft({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):_t(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=Tt(this.rgba);return"number"==typeof t?Ft({h:t,s:e.s,l:e.l,a:e.a}):_t(e.h)},t.prototype.isEqual=function(t){return this.toHex()===Ft(t).toHex()},t}(),Ft=function(t){return t instanceof Nt?t:new Nt(t)};function zt(t,e){var i=H.p,n=i.createDiv();n.parent(t),n.addClass("btn-container");var r=i.createButton(e);return r.parent(n),r.addClass("btn"),r}function Ut(t,e,i){var n=H.p,r=n.createDiv();r.parent(t),r.addClass("sm-btn-container"),r.addClass(i?"sm-btn-container-top":"sm-btn-container-bottom");var o=n.createButton("");o.parent(r),o.addClass("sm-btn");var s=n.createP(e);return s.parent(r),s.addClass("sm-btn-p"),o}var jt=function(){function t(t){this._moduleElements=[],this._gameModules=t}return t.prototype.setup=function(){var t=this;if(f.game.debugger.enabled){var e=H.p,i=e.select("#debugger"),n=!!i&&i.elt.hasAttribute("open"),r=new Set;i&&(e.selectAll(".debugger-module").forEach(function(t){t.elt.hasAttribute("open")&&r.add(t.id())}),i.remove()),this._moduleElements=[];var o=e.createElement("details");o.id("debugger"),n&&o.attribute("open",""),o.parent(e.select("body"));var s=e.createElement("summary");s.id("debugger-summary"),s.html("Debug"),s.parent(o),Object.entries(this._gameModules).forEach(function(i){var n=i[0],s=i[1];if("getDebugData"in s){var a={module:s,properties:[]},u=e.createElement("details");u.class("debugger-module"),u.id("debugger-".concat(n)),r.has("debugger-".concat(n))&&u.attribute("open",""),u.parent(o);var c=e.createElement("summary");c.id("debugger-".concat(n,"-summary")),c.html(n),c.class("debugger-module-summary"),c.parent(u);var l=s.getDebugData();Object.entries(l).forEach(function(t){var i=t[0],n=t[1],r=e.createElement("div");r.class("debugger-container"),r.id("debugger-container-".concat(i,"-").concat(n)),r.parent(u),r.mouseClicked(function(){r.toggleClass("highlight")});var o=e.createElement("p");o.id("debugger-".concat(i,"-").concat(n)),o.html("".concat(i,":")),o.parent(r);var s=e.createElement("span");s.id("debugger-".concat(i,"-").concat(n,"-value")),s.html("".concat(n)),s.parent(r),a.properties.push({key:i,element:s})}),t._moduleElements.push(a)}})}},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 Wt=jt;var Vt=function(){function t(){}return t.prototype.setup=function(){var t=H.p;this._container=t.createDiv(),this._container.parent(t.select("body")),this._container.id("modal-background"),this._container.class("hidden");var e=t.createDiv();e.parent(this._container),e.id("session-modal");var i=t.createDiv();i.parent(e),i.id("session-modal-frame");var n=t.createP();n.parent(i),n.html("Brick Engine Session");var r=t.createDiv();r.parent(i),r.id("session-modal-screen");var o=t.createP();o.parent(r),o.html("<span>Looks like you have an active session.</span><br><br>Do you want to continue?");var s=t.createDiv();s.parent(e),s.id("session-modal-buttons"),this._cancelButton=t.createButton("Cancel"),this._cancelButton.parent(s),this._cancelButton.class("session-modal-button"),this._confirmButton=t.createButton("Confirm"),this._confirmButton.parent(s),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 Kt=Vt;var Yt=function(){function t(){}return t.prototype.setup=function(){var t=this,e=H.p;this._externalToggleButton=e.createButton("Shortcuts [H]"),this._externalToggleButton.parent(e.select("body")),this._externalToggleButton.id("btn-shortcuts-external"),this._externalToggleButton.mousePressed(function(){return t.toggle()}),this._container=e.createDiv(),this._container.parent(e.select("body")),this._container.id("shortcuts-modal-background"),this._container.class("hidden");var i=e.createDiv();i.parent(this._container),i.id("shortcuts-modal");var n=e.createDiv();n.parent(i),n.id("shortcuts-modal-frame");var r=e.createElement("h2");r.parent(n),r.html("Keyboard Shortcuts");var o=e.createDiv();o.parent(n),o.id("shortcuts-modal-screen");var s=e.createDiv();s.parent(o),s.class("shortcuts-grid"),[{key:"Arrows / WASD",action:"Move"},{key:"J",action:"Action"},{key:"1",action:"Power"},{key:"2",action:"Start / Pause"},{key:"3",action:"Sound"},{key:"4",action:"Reset"},{key:"5",action:"Exit"},{key:"6",action:"Enable Colors"},{key:"7",action:"Enable Trackpad"},{key:"H",action:"Help (Shortcuts)"}].forEach(function(t){var i=e.createDiv();i.parent(s),i.class("shortcut-item");var n=e.createSpan();n.parent(i),n.class("shortcut-key"),n.html(t.key);var r=e.createSpan();r.parent(i),r.class("shortcut-action"),r.html(t.action)}),this._closeButton=e.createButton("Close"),this._closeButton.parent(i),this._closeButton.id("close-shortcuts"),this._closeButton.mousePressed(function(){return t._hide()})},t.prototype.toggle=function(){this._container.hasClass("hidden")?this._show():this._hide()},t.prototype._show=function(){this._container.removeClass("hidden")},t.prototype._hide=function(){this._container.addClass("hidden")},t}();const Xt=Yt;var Jt=function(){function t(t,e){var i=this;this._isDrawing=!1,this._startX=0,this._startY=0,this._maxDist=0,this._lastDirection=null,this._threshold=30,this._tapThreshold=10,this._points=[],this._loop=function(){if(i._ctx&&(i._ctx.globalCompositeOperation="destination-out",i._ctx.fillStyle="rgba(255, 255, 255, 0.1)",i._ctx.fillRect(0,0,i._canvas.width,i._canvas.height),i._ctx.globalCompositeOperation="source-over",i._isDrawing&&i._points.length>1)){i._ctx.beginPath(),i._ctx.strokeStyle=f.colors.bodyButton,i._ctx.lineWidth=6,i._ctx.lineCap="round",i._ctx.lineJoin="round";var t=i._points[i._points.length-1],e=i._points[i._points.length-2];i._ctx.moveTo(e.x,e.y),i._ctx.lineTo(t.x,t.y),i._ctx.stroke()}i._animationFrameId=requestAnimationFrame(i._loop)},this._inputHandler=e;var n=H.p;this._container=n.createDiv(),this._container.parent(t),this._container.addClass("trackpad-surface");var r=n.createP("Swipe for Directions<br/>Tap for Action");r.parent(this._container),r.addClass("trackpad-hint"),this._canvas=document.createElement("canvas"),this._canvas.classList.add("trackpad-canvas"),this._container.elt.appendChild(this._canvas),this._ctx=this._canvas.getContext("2d"),new ResizeObserver(function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];i._canvas.width=r.contentRect.width,i._canvas.height=r.contentRect.height}}).observe(this._container.elt),this._bindEvents(),this._loop()}return t.prototype._bindEvents=function(){var t=this._container.elt;t.addEventListener("pointerdown",this._onPointerDown.bind(this)),t.addEventListener("pointermove",this._onPointerMove.bind(this)),t.addEventListener("pointerup",this._onPointerUp.bind(this)),t.addEventListener("pointercancel",this._onPointerUp.bind(this)),t.addEventListener("pointerout",this._onPointerUp.bind(this)),t.addEventListener("contextmenu",function(t){return t.preventDefault()})},t.prototype._getCoords=function(t){var e=this._container.elt.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}},t.prototype._onPointerDown=function(t){this._isDrawing=!0;var e=this._getCoords(t),i=e.x,n=e.y;this._startX=i,this._startY=n,this._maxDist=0,this._lastDirection=null,this._points=[{x:i,y:n}],t.preventDefault(),this._container.elt.setPointerCapture(t.pointerId)},t.prototype._onPointerMove=function(t){if(this._isDrawing){var e=this._getCoords(t),i=e.x,n=e.y;this._points.push({x:i,y:n});var r=i-this._startX,o=n-this._startY,s=Math.sqrt(r*r+o*o);if(s>this._maxDist&&(this._maxDist=s),s>this._threshold){var a;a=Math.abs(r)>Math.abs(o)?r>0?l.RIGHT:l.LEFT:o>0?l.DOWN:l.UP,this._lastDirection!==a&&(this._lastDirection&&this._inputHandler.handleRelease(this._lastDirection),this._inputHandler.handlePress(a),this._lastDirection=a)}t.preventDefault()}},t.prototype._onPointerUp=function(t){var e=this;this._isDrawing&&(this._isDrawing=!1,this._lastDirection?(this._inputHandler.handleRelease(this._lastDirection),this._lastDirection=null):this._maxDist<this._tapThreshold&&(this._inputHandler.handlePress(l.ACTION),setTimeout(function(){return e._inputHandler.handleRelease(l.ACTION)},50)),this._container.elt.releasePointerCapture(t.pointerId))},t.prototype.destroy=function(){cancelAnimationFrame(this._animationFrameId),this._container.remove()},t}();const qt=Jt;var Qt=function(){function t(t){this._trackpad=null,this._parent=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(f.inputQueryParams.mainColor)?i.get(f.inputQueryParams.mainColor):f.colors.bodyMain,r=i.has(f.inputQueryParams.buttonColor)?i.get(f.inputQueryParams.buttonColor):f.colors.bodyButton,t.style.setProperty("--main-color",n),t.style.setProperty("--button-color",r),t.style.setProperty("--color-shadow",Ft(n).darken(.15).toHex()),t.style.setProperty("--color-shadow-reflexion",Ft(n).lighten(.15).toHex()),t.style.setProperty("--button-color-reflexion",Ft(r).lighten(.15).toHex()),t.style.setProperty("--button-color-shadow",Ft(r).darken(.15).toHex());var o=function(t){var e,i=H.p.createDiv();if(i.parent("#brick-game"),i.id("container"),t.clientWidth<=f.viewLayout.mobileBreakpoint)return{container:i,width:e=t.clientWidth,height:t.clientHeight};var n=t.clientHeight/(1.05*f.viewLayout.bodyHeightWidthMultiplier);return{container:i,width:e=Math.min(t.clientWidth,n),height:e*f.viewLayout.bodyHeightWidthMultiplier}}(this._parent),s=o.container,a=o.height,u=o.width,c=function(t){var e=H.p,i=e.createDiv();i.parent(t),i.id("frame");var n=e.createDiv();return n.parent(i),e.createP("Brick Engine").parent(n),i}(s),l=function(t,e){var i=H.p,n=e*f.viewLayout.canvas.widthRatio,r=n*f.viewLayout.canvas.aspectRatio,o=i.createCanvas(n,r);return o.parent(t),o.id("brick-game-canvas"),{canvasWidth:n,canvasHeight:r,canvas:o}}(c,u),h=l.canvas,d=l.canvasHeight,p=l.canvasWidth,g=function(t){var e=H.p,i=e.createDiv();i.parent(t),i.id("button-container");var n=e.createDiv();n.parent(i),n.id("small-button-container");var r=e.createDiv();r.parent(i),r.id("inner-button-container");var o=e.createDiv();o.parent(r),o.id("medium-button-container");var s=e.createDiv();s.parent(o),s.id("direction-vertical-container");var a=e.createDiv();a.parent(o),a.id("direction-horizontal-container");var u=e.createDiv();u.parent(r),u.id("large-button-container");var c=e.createDiv();return c.parent(r),c.id("trackpad-container"),{smallButtonContainer:n,mediumButtonContainer:o,largeButtonContainer:u,directionVerticalContainer:s,directionHorizontalContainer:a,trackpadContainer:c}}(s),y=g.largeButtonContainer,_=g.smallButtonContainer,v=g.directionHorizontalContainer,m=g.directionVerticalContainer,b=g.mediumButtonContainer,E=g.trackpadContainer;return this._mediumButtonContainer=b,this._largeButtonContainer=y,this._trackpadContainer=E,this._onOffBtn=Ut(_,"On<br/>Off",!0),this._startPauseBtn=Ut(_,"Start<br/>Pause",!1),this._soundBtn=Ut(_,"Sound",!0),this._resetBtn=Ut(_,"Reset",!1),this._exitBtn=Ut(_,"Exit",!0),this._enableColorBtn=Ut(_,"Enable<br/>Colors",!1),this._trackpadBtn=Ut(_,"Track<br/>Pad",!0),this._upBtn=zt(m,"UP"),this._leftBtn=zt(v,"LEFT"),this._downBtn=zt(m,"DOWN"),this._rightBtn=zt(v,"RIGHT"),this._actionBtn=function(t){var e=H.p,i=e.createDiv();i.parent(t),i.addClass("lg-btn-container");var n=e.createButton("Action");return n.parent(i),n.addClass("lg-btn"),n}(y),function(t,e,i,n){var r=document.querySelector(":root");r.style.setProperty("--dispersion",f.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*f.viewLayout.dimensions.borderRadiusRatio,"px")),r.style.setProperty("--border","".concat(t*f.viewLayout.dimensions.borderWidthRatio,"px solid black")),r.style.setProperty("--sm-button-size","".concat(t*f.viewLayout.dimensions.button.smSizeRatio,"px")),r.style.setProperty("--button-size","".concat(t*f.viewLayout.dimensions.button.mdSizeRatio,"px")),r.style.setProperty("--lg-button-size","".concat(t*f.viewLayout.dimensions.button.lgSizeRatio,"px")),r.style.setProperty("--sm-button-size-mobile","".concat(t*f.viewLayout.dimensions.button.mobile.smSizeRatio,"px")),r.style.setProperty("--button-size-mobile","".concat(t*f.viewLayout.dimensions.button.mobile.mdSizeRatio,"px")),r.style.setProperty("--lg-button-size-mobile","".concat(t*f.viewLayout.dimensions.button.mobile.lgSizeRatio,"px")),r.style.setProperty("--sm-button-size-mobile-font-size","".concat(t*f.viewLayout.dimensions.button.mobile.smFontRatio,"px")),r.style.setProperty("--sm-button-size-mobile-line-height","".concat(t*f.viewLayout.dimensions.button.mobile.smFontRatio,"px")),r.style.setProperty("--button-size-mobile-font-size","".concat(t*f.viewLayout.dimensions.button.mobile.fontRatio,"px")),r.style.setProperty("--lg-button-size-mobile-font-size","".concat(t*f.viewLayout.dimensions.button.mobile.lgFontRatio,"px")),r.style.setProperty("--button-size-mobile-spacing","".concat(t*f.viewLayout.dimensions.button.mobile.spacingRatio,"px")),r.style.setProperty("--button-border","".concat(t*f.viewLayout.dimensions.button.borderRatio,"px solid black")),r.style.setProperty("--button-animation-duration",f.viewLayout.dimensions.button.animationDuration)}(u,a,p,d),this._hideSplash(),this._cachedCanvas={canvas:h,canvasWidth:p,canvasHeight:d},this._cachedCanvas},t.prototype.setupSessionModal=function(){this._sessionModal=new Kt,this._sessionModal.setup(),this._shortcutsModal=new Xt,this._shortcutsModal.setup()},t.prototype.showSessionModal=function(t,e){this._sessionModal.show(t,e)},t.prototype.toggleShortcutsModal=function(){this._shortcutsModal.toggle()},t.prototype.setupDebugger=function(t){this._debugger=new Wt(t),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 g(t),this._trackpad&&this._trackpad.destroy(),this._trackpad=new qt(this._trackpadContainer,this._inputHandler),this._bindButtonEvents(this._onOffBtn,l.POWER),this._bindButtonEvents(this._startPauseBtn,l.START_PAUSE),this._bindButtonEvents(this._soundBtn,l.SOUND),this._bindButtonEvents(this._resetBtn,l.RESET),this._bindButtonEvents(this._exitBtn,l.EXIT),this._bindButtonEvents(this._enableColorBtn,l.COLOR),this._bindButtonEvents(this._trackpadBtn,l.TRACKPAD),this._bindButtonEvents(this._upBtn,l.UP),this._bindButtonEvents(this._downBtn,l.DOWN),this._bindButtonEvents(this._rightBtn,l.RIGHT),this._bindButtonEvents(this._leftBtn,l.LEFT),this._bindButtonEvents(this._actionBtn,l.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._trackpadBtn.mousePressed(function(){}).mouseReleased(function(){}),this._trackpad&&(this._trackpad.destroy(),this._trackpad=null),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=f.viewLayout.splashHideDelayMs);var e=document.querySelector("#splash");setTimeout(function(){e.style.display="none"},t)},t.prototype.applyTrackpadState=function(t){t?(this._mediumButtonContainer.style("display","none"),this._largeButtonContainer.style("display","none"),this._trackpadContainer.style("display","flex")):(this._mediumButtonContainer.style("display","flex"),this._largeButtonContainer.style("display","flex"),this._trackpadContainer.style("display","none"))},t}();const $t=Qt;var Zt,te=n(991),ee=n.n(te);function ie(t){Zt=t}function ne(t){return window.BrickEngineGame=t,new(ee())(function(e){H.init(e);var i=new $t(document.body);ie(new t(i)),"unknown"===Zt.gameId&&(Zt.gameId="game"),e.setup=function(){Zt.setup(),Zt.view.setupDebugger(Zt.modules),Zt.view.setupSessionModal()},e.draw=function(){Zt.draw(),Zt.view.updateDebugger()}})}return p})());
|
|
@@ -17,10 +17,11 @@ export default class GameEventRegistry {
|
|
|
17
17
|
* sound and color.
|
|
18
18
|
*
|
|
19
19
|
* @param {GameModules} modules - The collection of initialized game modules to bind.
|
|
20
|
+
* @param {GameView} view - The active game view to notify about visual state changes.
|
|
20
21
|
* @param {() => void} onReset - Callback to be executed immediately to restore the initial properties of the game instance during soft resets.
|
|
21
22
|
* @returns {void} Returns nothing.
|
|
22
23
|
*/
|
|
23
|
-
static setupControlEvents(modules: GameModules, onReset: () => void): void;
|
|
24
|
+
static setupControlEvents(modules: GameModules, view: GameView, onReset: () => void): void;
|
|
24
25
|
/**
|
|
25
26
|
* Sets up all system-level state property subscriptions.
|
|
26
27
|
*
|
|
@@ -91,7 +91,8 @@ export declare enum ControlKey {
|
|
|
91
91
|
RESET = "reset;system",
|
|
92
92
|
EXIT = "exit;system",
|
|
93
93
|
COLOR = "color;system",
|
|
94
|
-
TRACKPAD = "trackpad;system"
|
|
94
|
+
TRACKPAD = "trackpad;system",
|
|
95
|
+
SHORTCUTS = "shortcuts;system"
|
|
95
96
|
}
|
|
96
97
|
/**
|
|
97
98
|
* Enumerates the types of input events.
|
|
@@ -30,6 +30,7 @@ export default class GameView {
|
|
|
30
30
|
private _largeButtonContainer;
|
|
31
31
|
private _debugger;
|
|
32
32
|
private _sessionModal;
|
|
33
|
+
private _shortcutsModal;
|
|
33
34
|
/**
|
|
34
35
|
* Bootstraps the root listener binding it to a persistent layout container.
|
|
35
36
|
*
|
|
@@ -71,6 +72,12 @@ export default class GameView {
|
|
|
71
72
|
* @returns {void} Returns nothing.
|
|
72
73
|
*/
|
|
73
74
|
showSessionModal(onConfirm: () => void, onCancel: () => void): void;
|
|
75
|
+
/**
|
|
76
|
+
* Toggles the shortcuts visual guide overlay.
|
|
77
|
+
*
|
|
78
|
+
* @returns {void} Returns nothing.
|
|
79
|
+
*/
|
|
80
|
+
toggleShortcutsModal(): void;
|
|
74
81
|
/**
|
|
75
82
|
* Instantiates the technical UI diagnostics tool aggregating dynamic execution values into the DOM.
|
|
76
83
|
*
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Initializable } from '../core/types/Interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Modal displaying keyboard shortcuts, visible only on desktop.
|
|
4
|
+
*/
|
|
5
|
+
export default class ShortcutsModal implements Initializable {
|
|
6
|
+
private _container;
|
|
7
|
+
private _closeButton;
|
|
8
|
+
private _externalToggleButton;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Bootstraps the Vanilla DOM creation for the shortcuts modal.
|
|
12
|
+
*/
|
|
13
|
+
setup(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Toggles the visibility of the shortcuts modal.
|
|
16
|
+
*/
|
|
17
|
+
toggle(): void;
|
|
18
|
+
private _show;
|
|
19
|
+
private _hide;
|
|
20
|
+
}
|