(this.webpackJsonpcaptotetris2=this.webpackJsonpcaptotetris2||[]).push([[0],{25:function(e,t,a){},30:function(e,t,a){"use strict";a.r(t);var i,n,o,s,r,c,l,h,u,d,m,b,f,k,v,g,B,p,O,A,w,j,y,C,R,T,E=a(1),S=a.n(E),P=a(17),x=a.n(P),L=(a(25),a(4)),N=a(5),I=a(6),D=a(3),M=a(9),G=function(){function e(t){var a=t.imagesToLoad,i=t.onDone;Object(N.a)(this,e),this.images={},this.numImagesRemaining=Object.keys(a).length,this.onLoadedAll=i;for(var n=0,o=Object.entries(a);n0&&void 0!==arguments[0]?arguments[0]:{},a=t.blockType,i=void 0===a?_.NORMAL:a,n=t.color;Object(N.a)(this,e),this._blockImageName=null,this._color=n||q(),this.imageMeta={numberOfFrames:1,framesPerColumn:1,numberOfRows:1},this.animationState=Fe,this.imageFrameIdx=0,this.frameXCoord=0,this.frameYCoord=0,this.updateBlockType(i)}return Object(I.a)(e,[{key:"blockType",get:function(){return this._blockType}},{key:"color",get:function(){return this._color}},{key:"isBreaker",get:function(){return this._isBreaker}},{key:"isBreakable",get:function(){return this._isBreakable}},{key:"isStone",get:function(){return this._isStone}},{key:"imageName",get:function(){return this._blockImageName}},{key:"getImageSrcXandY",value:function(){return[this.frameXCoord,this.frameYCoord]}},{key:"playRareAnimation",value:function(){this.animationState!==Ue&&(this.animationState=Ue,this._blockImageName=Ve[this._blockType][this._color][this.animationState],this.imageFrameIdx=0,this.updateImageCoordinates(this.imageFrameIdx))}},{key:"playIdleAnimation",value:function(){this.animationState!==Fe&&(this.animationState=Fe,this._blockImageName=Ve[this._blockType][this._color][this.animationState],this.imageFrameIdx=0,this.updateImageCoordinates(this.imageFrameIdx))}},{key:"updateImageCoordinates",value:function(e){var t=this.imageMeta.framesPerColumn,a=e%t,i=Math.floor(e/t);this.frameXCoord=a*We,this.frameYCoord=i*We}},{key:"updateFrame",value:function(){var e=this.imageMeta.numberOfFrames;if(e>1){var t=this.imageFrameIdx===e-1;this.animationState===Ue&&t?this.playIdleAnimation():this.imageFrameIdx=t?0:this.imageFrameIdx+1,this.updateImageCoordinates(this.imageFrameIdx)}}},{key:"updateBlockType",value:function(e){if(Boolean(_[e])){var t=H[e];this.animationState=Fe,this._blockType=e,this._isBreakable=t.isBreakable,this._isBreaker=t.isBreaker,this._isStone=t.isStone,this._blockImageName=Ve[this._blockType][this._color][this.animationState],this.imageMeta=Object.assign({},De[this._blockImageName]),this.imageFrameIdx=Math.floor(Math.random()*this.imageMeta.numberOfFrames)}}},{key:"progressBlockType",value:function(){this.updateBlockType(function(e){var t=e;switch(e){case _.CEMENT:t=_.TRANSPARENT;break;case _.TRANSPARENT:t=_.NORMAL}return t}(this._blockType))}}]),e}(),ze=a(14),Ke=a.n(ze),qe=a(32),_e=Object(qe.a)((function(e,t){var a=Object(L.a)(e,1)[0];return Object(L.a)(t,1)[0]-a})),He=function(){function e(t){var a=t.numRows,i=t.numCols,n=t.onEndTurn,o=t.onCannotSpawn,s=t.onDoneDroppingBlocks;Object(N.a)(this,e),this.numRows=a,this.numCols=i,this.blockStartCol=3,this.startRowBlockOne=0,this.startRowBlockTwo=1,this.board=this.resetBoard(this.numRows,this.numCols),window.theBoard=this.board,this.activeBlock1=null,this.activeBlock2=null,this.blocksThatNeedToFall=[],this.onEndTurn=function(){return n()},this.onCannotSpawn=function(){return o()},this.onDoneDroppingBlocks=function(){return s()}}return Object(I.a)(e,[{key:"blocksIterable",value:Ke.a.mark((function e(){var t,a,i;return Ke.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=2;case 1:if(!(t=0&&t>=0&&e0&&void 0!==arguments[0]?arguments[0]:[];this.blocksThatNeedToFall=_e(e)}},{key:"canSpawnNewPiece",value:function(){return null===this.board[1][this.blockStartCol]&&null===this.board[2][this.blockStartCol]}},{key:"getPossibleBreaks",value:function(){for(var e=[],t=2;t1&&e.push({color:i.color,cells:o})}}return e}},{key:"isCellANewMatch",value:function(e,t,a){var i=Object(L.a)(e,2),n=i[0],o=i[1];return this.isWithinBounds(n,o)&&null!==this.getCell(n,o)&&this.getCell(n,o).color===a&&!t.some((function(e){var t=Object(L.a)(e,2),a=t[0],i=t[1];return a===n&&i===o}))}},{key:"findLinkedBlocks",value:function(e,t,a){var i=Object(L.a)(e,2),n=i[0],o=i[1],s=[n-1,o],r=[n,o+1],c=[n+1,o],l=[n,o-1],h=Object(D.a)(a);return this.isCellANewMatch(s,h,t)&&(h.push(s),h=this.findLinkedBlocks(s,t,h)),this.isCellANewMatch(r,h,t)&&(h.push(r),h=this.findLinkedBlocks(r,t,h)),this.isCellANewMatch(c,h,t)&&(h.push(c),h=this.findLinkedBlocks(c,t,h)),this.isCellANewMatch(l,h,t)&&(h.push(l),h=this.findLinkedBlocks(l,t,h)),h}},{key:"breakBlocks",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=Object(M.a)(t);try{for(a.s();!(e=a.n()).done;){var i,n=e.value,o=Object(M.a)(n.cells);try{for(o.s();!(i=o.n()).done;){var s=Object(L.a)(i.value,2),r=s[0],c=s[1];this.board[r][c]=null}}catch(l){o.e(l)}finally{o.f()}}}catch(l){a.e(l)}finally{a.f()}}},{key:"updateBlockAnimations",value:function(){var e,t=Object(M.a)(this.blocksIterable());try{for(t.s();!(e=t.n()).done;){e.value.updateFrame()}}catch(a){t.e(a)}finally{t.f()}}},{key:"tryToPlayRareAnimation",value:function(){var e,t=Object(M.a)(this.blocksIterable());try{for(t.s();!(e=t.n()).done;){var a=e.value;a.isBreaker&&X()&&a.playRareAnimation()}}catch(i){t.e(i)}finally{t.f()}}}]),e}(),Ze=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(N.a)(this,e),this.sounds=this.init(t),this.currentlyPlayingSound=null}return Object(I.a)(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};for(var a in e){var i=new window.Audio(e[a].path);i.volume=e[a].volume||.1,t[a]=i}return t}},{key:"play",value:function(e){this.sounds[e]&&null===this.currentlyPlayingSound&&this.sounds[e].play()}}]),e}(),Je={tink:{path:a.p+"static/media/tink.1c59f9eb.wav",volume:.12},success:{path:a.p+"static/media/success.27ff5922.wav",volume:.1}},Qe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.isPlaying,i=void 0===a||a;Object(N.a)(this,e),this.imageMeta=Object.assign({},Me),this.frameIndex=0,this.frameXCoord=0,this.frameYCoord=0,this._imageName=i?Le:Ne,this.updateImageCoordinates(0)}return Object(I.a)(e,[{key:"imageName",get:function(){return this._imageName}},{key:"getImageSrcXandY",value:function(){return[this.frameXCoord,this.frameYCoord]}},{key:"doPlayingAnimation",value:function(){this._imageName=Le}},{key:"doPausedAnimation",value:function(){this._imageName=Ne}},{key:"updateImageCoordinates",value:function(e){var t=this.imageMeta,a=t.framesPerColumn,i=t.frameSize,n=e%a,o=Math.floor(e/a);this.frameXCoord=n*i,this.frameYCoord=o*i}},{key:"updateFrame",value:function(){var e=this.imageMeta.numberOfFrames;if(e>1){var t=this.frameIndex===e-1;this.frameIndex=t?0:this.frameIndex+1,this.updateImageCoordinates(this.frameIndex)}}}]),e}(),$e=function(){function e(){Object(N.a)(this,e),this._state=this.getEmptyState(),this._stateToRestoreLater=null,this._gameHasStarted=!1}return Object(I.a)(e,[{key:"getEmptyState",value:function(){return{acceptsUserInput:!1,needToProcessTheBoard:!1,droppingBlocks:!1,pieceIsDropping:!1,gameIsOver:!1,gameIsPaused:!1,borderingBlocks:!1,shatteringBlocks:!1}}},{key:"hasStarted",get:function(){return this._gameHasStarted},set:function(e){this._gameHasStarted=Boolean(e)}},{key:"acceptsUserInput",get:function(){return this._state.acceptsUserInput}},{key:"needToProcessTheBoard",get:function(){return this._state.needToProcessTheBoard}},{key:"droppingBlocks",get:function(){return this._state.droppingBlocks}},{key:"pieceIsDropping",get:function(){return this._state.pieceIsDropping}},{key:"gameIsOver",get:function(){return this._state.gameIsOver}},{key:"gameIsPaused",get:function(){return this._state.gameIsPaused}},{key:"borderingBlocks",get:function(){return this._state.borderingBlocks}},{key:"shatteringBlocks",get:function(){return this._state.shatteringBlocks}},{key:"updateGameState",value:function(e){this._state=Object.assign(this.getEmptyState(),e)}},{key:"setControllingPiece",value:function(){this.updateGameState({acceptsUserInput:!0,pieceIsDropping:!0})}},{key:"setProcessingBoard",value:function(){this.updateGameState({needToProcessTheBoard:!0})}},{key:"setDroppingBlocks",value:function(){this.updateGameState({droppingBlocks:!0})}},{key:"setGameIsOver",value:function(){this.updateGameState({gameIsOver:!0})}},{key:"setPauseGame",value:function(){this.updateGameState({gameIsPaused:!0})}},{key:"setBorderingBlocks",value:function(){this.updateGameState({borderingBlocks:!0})}},{key:"setShatteringBlocks",value:function(){this.updateGameState({shatteringBlocks:!0})}},{key:"stashCurrentState",value:function(){this._stateToRestoreLater=Object.assign({},this._state)}},{key:"restoreStashedState",value:function(){null!==this._stateToRestoreLater&&(this._state=Object.assign({},this._stateToRestoreLater),this._stateToRestoreLater=null)}}]),e}(),et=function(){function e(){Object(N.a)(this,e),this._monitoredEvents={}}return Object(I.a)(e,[{key:"on",value:function(e,t){"function"===typeof t&&(this._monitoredEvents[e]=this._monitoredEvents[e]||[],this._monitoredEvents[e].push(t))}},{key:"fire",value:function(e){if(Array.isArray(this._monitoredEvents[e])){var t,a=Object(M.a)(this._monitoredEvents[e]);try{for(a.s();!(t=a.n()).done;){(0,t.value)()}}catch(i){a.e(i)}finally{a.f()}}}},{key:"handleKeyUp",value:function(e){switch(e){case 87:case 38:this.fire("up");break;case 83:case 40:this.fire("down");break;case 65:case 37:this.fire("left");break;case 32:this.fire("space");break;case 68:case 39:this.fire("right")}}}]),e}(),tt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.numRows,i=t.numCols;Object(N.a)(this,e),this.numRows=a,this.numCols=i,this._cellsToBeBordered=[],this._allCellCoordinates=[]}return Object(I.a)(e,[{key:"doesAnythingNeedBordered",get:function(){return this._cellsToBeBordered.length>0}},{key:"cellsToBeBordered",get:function(){return this._cellsToBeBordered}},{key:"getCoords",value:function(e,t,a){return this._allCellCoordinates[e][t][a]}},{key:"clearCellsToBeBordered",value:function(){this._cellsToBeBordered=[]}},{key:"setCellsToBeBordered",value:function(e){var t,a=[],i=Object(M.a)(e);try{for(i.s();!(t=i.n()).done;){var n,o=t.value,s=Object(M.a)(o.cells);try{var r=function(){var e=Object(L.a)(n.value,2),t=e[0],i=e[1],s=!o.cells.some((function(e){var a=Object(L.a)(e,2),n=a[0],o=a[1];return n===t-1&&o===i})),r=!o.cells.some((function(e){var a=Object(L.a)(e,2),n=a[0],o=a[1];return n===t&&o===i+1})),c=!o.cells.some((function(e){var a=Object(L.a)(e,2),n=a[0],o=a[1];return n===t+1&&o===i})),l=!o.cells.some((function(e){var a=Object(L.a)(e,2),n=a[0],o=a[1];return n===t&&o===i-1})),h={color:o.color,row:t,col:i,sides:[].concat(Object(D.a)(s?["top"]:[]),Object(D.a)(r?["right"]:[]),Object(D.a)(c?["bottom"]:[]),Object(D.a)(l?["left"]:[]))};h.sides.length&&a.push(h)};for(s.s();!(n=s.n()).done;)r()}catch(c){s.e(c)}finally{s.f()}}}catch(c){i.e(c)}finally{i.f()}this._cellsToBeBordered=a}},{key:"recalculateAllCellCoordinates",value:function(e){var t=this,a=e.blockSize,i=e.xOffset;this._allCellCoordinates=Object(D.a)(new Array(this.numRows)).map((function(){return Object(D.a)(new Array(t.numCols)).fill(null)}));for(var n=0;n1&&(this._frameIndex===e-1||(this._frameIndex=this._frameIndex+1,this.updateImageCoordinates(this._frameIndex)))}}]),e}(),it=function(){function e(t){var a=t.duration;Object(N.a)(this,e),this.counter=0,this.duration=a||0}return Object(I.a)(e,[{key:"updateAndCheck",value:function(e){return this.counter+=e,this.counter>this.duration&&(this.counter=0,!0)}},{key:"reset",value:function(){this.counter=0}},{key:"percentDone",value:function(){return this.counter/this.duration}}]),e}(),nt=function(){function e(t){var a=this,i=t.ctx;Object(N.a)(this,e),this.onEndTurn=function(){a.soundManager.play("tink"),a.state.setProcessingBoard()},this.onCannotSpawn=function(){a.state.setProcessingBoard()},this.onDoneDroppingBlocks=function(){a.state.setProcessingBoard()},this.ctx=i,this.dim=this.getInitialPositionsAndSizes(),this.state=new $e,this.nextBlock1=this.makeRegularBlock(),this.nextBlock2=this.makeRegularBlock(),this.time=this.getInitialTimers(),this.pauseButton=new Qe,this.cellsToBreakLater=null,this.shatterAnimations=[],this.boardManager=new He({numRows:e.NUMROWS,numCols:e.NUMCOLS,onEndTurn:this.onEndTurn,onCannotSpawn:this.onCannotSpawn,onDoneDroppingBlocks:this.onDoneDroppingBlocks}),this.borders=new tt({numRows:e.NUMROWS,numCols:e.NUMCOLS}),this.inputManager=new et,this.registerInputHandlers(),this.soundManager=new Ze(Je),this.imageManager=new G({imagesToLoad:Ie,onDone:function(){return a.allImagesAreLoaded()}})}return Object(I.a)(e,[{key:"getInitialTimers",value:function(){return{pieceDrop:new it({duration:1e3}),blockFall:new it({duration:50}),blockAnim:new it({duration:Math.floor(100)}),blockRareAnim:new it({duration:5e3}),pauseBtnAnim:new it({duration:Math.floor(2e3/30)}),drawBorders:new it({duration:1500}),shatterAnim:new it({duration:Math.floor(500/30)}),shattering:new it({duration:500})}}},{key:"getInitialPositionsAndSizes",value:function(){return{canvasWidth:0,canvasHeight:0,leftSidebarWidth:0,boardWidth:0,blockWidth:0,blockHeight:0,blockSrcDimensions:[0,0],sidebarBlockOffsetX:0,sidebarBlockOffsetY:0,sidebarBlockGapY:0,sidebarNextOffsetY:0,blockTargetSize:[0,0],sidebarBlockOneDims:[0,0,0,0],sidebarBlockTwoDims:[0,0,0,0],pauseButtonDims:[0,0,0,0],shatterAnimationSize:0,shatterAnimationOffset:0}}},{key:"registerInputHandlers",value:function(){var e=this;this.inputManager.on("up",(function(){return e.boardManager.rotateTheActivePieceCCW()})),this.inputManager.on("right",(function(){return e.boardManager.rightTheActivePiece()})),this.inputManager.on("down",(function(){return e.boardManager.rotateTheActivePieceCW()})),this.inputManager.on("left",(function(){return e.boardManager.leftTheActivePiece()})),this.inputManager.on("space",(function(){return e.boardManager.dropTheActivePiece()}))}},{key:"allImagesAreLoaded",value:function(){this.startTheGame()}},{key:"startTheGame",value:function(){this.state.hasStarted=!0,this.boardManager.spawnNewActivePiece(new Ye({blockType:"BREAKER",color:"GREEN"}),this.makeRegularBlock()),this.state.setControllingPiece(),document.hasFocus()||(console.log("The game begins paused, document does not have focus."),this.pauseTheGame())}},{key:"update",value:function(e){this.state.hasStarted&&(this.state.gameIsPaused||(this.updateGameLogic(e),this.updateBlockAnimations(e)),this.updatePausePlayButtonAnimation(e))}},{key:"updateGameLogic",value:function(e){if(this.state.needToProcessTheBoard)this.processTheBoardGetNewState();else if(this.state.pieceIsDropping)this.time.pieceDrop.updateAndCheck(e)&&this.boardManager.dropTheActivePiece();else if(this.state.droppingBlocks)this.time.blockFall.updateAndCheck(e)&&this.boardManager.dropBlocksWithSpacesBeneath();else if(this.state.borderingBlocks)this.time.drawBorders.updateAndCheck(e)&&this.stopBorderingsStartShattering();else if(this.state.shatteringBlocks){var t=this.time.shattering.updateAndCheck(e),a=this.time.shatterAnim.updateAndCheck(e);if(t)this.time.shatterAnim.reset(),this.stopShattering();else if(a){var i,n=Object(M.a)(this.shatterAnimations);try{for(n.s();!(i=n.n()).done;){i.value.updateFrame()}}catch(o){n.e(o)}finally{n.f()}}}}},{key:"updateBlockAnimations",value:function(e){this.time.blockAnim.updateAndCheck(e)&&this.boardManager.updateBlockAnimations(),this.time.blockRareAnim.updateAndCheck(e)&&this.boardManager.tryToPlayRareAnimation()}},{key:"updatePausePlayButtonAnimation",value:function(e){this.time.pauseBtnAnim.updateAndCheck(e)&&this.pauseButton.updateFrame()}},{key:"draw",value:function(){this.state.hasStarted&&(this.drawLeftSidebar(),this.drawBoard(),this.state.gameIsPaused&&this.drawPaused())}},{key:"drawLeftSidebar",value:function(){var e,t,a,i=this.dim,n=i.leftSidebarWidth,o=i.canvasHeight,s=i.sidebarNextOffsetY,r=i.blockSrcDimensions,c=i.sidebarBlockOneDims,l=i.sidebarBlockTwoDims,h=i.blockWidth,u=i.pauseButtonDims;(this.ctx.globalAlpha=.3,this.ctx.fillStyle="#000000",this.ctx.fillRect(0,0,n,o),this.ctx.globalAlpha=1,this.ctx.font="".concat(.45*h,"px TradeWinds"),this.ctx.fillStyle="white",this.ctx.textAlign="center",this.ctx.fillText("Next",n/2,s),this.nextBlock1&&this.nextBlock2)&&((t=this.ctx).drawImage.apply(t,[this.imageManager.getImage(this.nextBlock1.imageName)].concat(Object(D.a)(this.nextBlock1.getImageSrcXandY()),Object(D.a)(r),Object(D.a)(c))),(a=this.ctx).drawImage.apply(a,[this.imageManager.getImage(this.nextBlock2.imageName)].concat(Object(D.a)(this.nextBlock2.getImageSrcXandY()),Object(D.a)(r),Object(D.a)(l))));(e=this.ctx).drawImage.apply(e,[this.imageManager.getImage(this.pauseButton.imageName)].concat(Object(D.a)(this.pauseButton.getImageSrcXandY()),Object(D.a)(r),Object(D.a)(u)))}},{key:"drawBoard",value:function(){for(var t=0,a=0,i=this.dim,n=i.leftSidebarWidth,o=i.blockWidth,s=i.blockHeight,r=i.blockSrcDimensions,c=i.blockTargetSize,l=i.shatterAnimationOffset,h=i.shatterAnimationSize,u=2;u0,a=t?[]:this.boardManager.getPossibleBreaks(),i=a.length>0;t?(this.boardManager.setBlocksThatNeedToFall(e),this.state.setDroppingBlocks()):i?(this.cellsToBreakLater=a,this.borders.setCellsToBeBordered(a),this.state.setBorderingBlocks()):this.boardManager.canSpawnNewPiece()?(this.boardManager.setBlocksThatNeedToFall([]),this.boardManager.spawnNewActivePiece(this.nextBlock1,this.nextBlock2),this.nextBlock1=this.makeRegularBlock(),this.nextBlock2=this.makeRegularBlock(),this.state.setControllingPiece()):this.handleGameIsOver()}},{key:"checkBoardForBlocksThatCanDrop",value:function(){for(var t=null,a=null,i=[],n=e.NUMROWS-1;n>=2;n--)for(var o=0;o=2&&!this.boardManager.isCellAvailable(s,o);)i.push([s,o]),s--}return function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=[],i=Object(M.a)(t);try{var n=function(){var t=Object(L.a)(e.value,2),i=t[0],n=t[1];a.some((function(e){var t=Object(L.a)(e,2),a=t[0],o=t[1];return a===i&&o===n}))||a.push([i,n])};for(i.s();!(e=i.n()).done;)n()}catch(o){i.e(o)}finally{i.f()}return a}(i)}},{key:"makeRegularBlock",value:function(){return new Ye({blockType:V()?_.BREAKER:_.NORMAL})}},{key:"stopBorderingsStartShattering",value:function(){this.boardManager.breakBlocks(this.cellsToBreakLater),this.soundManager.play("success"),this.borders.clearCellsToBeBordered(),this.setupCellsToShatter(),this.state.setShatteringBlocks()}},{key:"stopShattering",value:function(){this.cellsToBreakLater=null,this.shatterAnimations=[],this.state.setProcessingBoard()}},{key:"onKeyPressed",value:function(e){this.state.acceptsUserInput&&this.boardManager.hasActivePiece()&&this.inputManager.handleKeyUp(e)}},{key:"onClick",value:function(e){var t=e.x,a=e.y;this.checkIfPauseButtonClicked(t,a)&&this.handlePauseButtonClicked()}},{key:"onTabFocused",value:function(){}},{key:"onTabBlurred",value:function(){this.pauseTheGame()}},{key:"unpauseTheGame",value:function(){console.log("Unpausing"),this.state.restoreStashedState(),this.pauseButton.doPlayingAnimation()}},{key:"pauseTheGame",value:function(){console.log("Pausing"),this.state.gameIsPaused||(this.state.stashCurrentState(),this.state.setPauseGame(),this.pauseButton.doPausedAnimation())}},{key:"handlePauseButtonClicked",value:function(){this.state.gameIsPaused?this.unpauseTheGame():this.pauseTheGame()}},{key:"checkIfPauseButtonClicked",value:function(e,t){var a=Object(L.a)(this.dim.pauseButtonDims,4),i=a[0],n=a[1],o=a[2],s=a[3];return e>=i&&t>=n&&e<=i+o&&t<=n+s}},{key:"setupCellsToShatter",value:function(){this.shatterAnimations=this.cellsToBreakLater.map((function(e){var t=e.color;return e.cells.map((function(e){var a=Object(L.a)(e,2);return{row:a[0],col:a[1],color:t}}))})).flat().map((function(e){return new at(e)}))}}]),e}();nt.NUMROWS=15,nt.NUMCOLS=7;var ot,st,rt,ct,lt,ht,ut,dt,mt,bt,ft,kt,vt,gt,Bt,pt,Ot=nt,At=function(){function e(t,a){var i=this;Object(N.a)(this,e),this.setGame=function(e){i.game=new e({ctx:i._ctx}),i.onWindowResize()},this.draw=function(){i.clearCanvas(),i.game.draw()},this.start=function(){i.game?i.gameLoop(0):console.warn("No Game was set in the loop.")},this.gameLoop=function(e){i.deltaTime=e-i.timeLastUpdate,i.timeLastUpdate=e,i.game&&(i.game.update(i.deltaTime),i.draw(),window.requestAnimationFrame(i.gameLoop))},this.onWindowResize=function(){var e=i.gameArea.getBoundingClientRect().height,t=Math.floor(e/(Ot.NUMROWS-2)),a=2*t,n=t*Ot.NUMCOLS,o=t*(Ot.NUMROWS-2),s=n+a;i.canvasWidth=s,i.canvasHeight=o,i.canvasEl.width=s*window.devicePixelRatio,i.canvasEl.height=o*window.devicePixelRatio,i.canvasEl.style.width=s+"px",i.canvasEl.style.height=o+"px",i._ctx.scale(window.devicePixelRatio,window.devicePixelRatio),i.game&&i.game.updateCanvasBounds(s,o,a,n)},this.onKeyDown=function(e){i.game&&i.game.onKeyPressed(e.keyCode)},this.onTabFocus=function(){i.game&&i.game.onTabFocused()},this.onTabBlur=function(){i.game&&i.game.onTabBlurred()},this.onClick=function(e){if(i.game){var t=i.canvasEl.getBoundingClientRect(),a=t.left,n=t.top,o=e.clientX-a,s=e.clientY-n;i.game.onClick({x:o,y:s})}},this.stop=function(){i.game=null,window.removeEventListener("resize",i.onWindowResize),window.removeEventListener("keydown",i.onKeyDown),window.removeEventListener("focus",i.onTabFocus),window.removeEventListener("blur",i.onTabBlur),i.canvasEl.removeEventListener("mouseup",i.onClick)},this.canvasEl=t.current,this.gameArea=a.current,this._ctx=this.canvasEl.getContext("2d"),this.canvasWidth=this.canvasEl.width,this.canvasHeight=this.canvasEl.height,this.game=null,this.deltaTime=0,this.timeLastUpdate=0,this.onWindowResize(),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("focus",this.onTabFocus),window.addEventListener("blur",this.onTabBlur),this.canvasEl.addEventListener("mouseup",this.onClick)}return Object(I.a)(e,[{key:"updateCanvasBounds",value:function(){this.canvasWidth=this.canvasEl.width,this.canvasHeight=this.canvasEl.height,this.onWindowResize()}},{key:"clearCanvas",value:function(){this._ctx.clearRect(0,0,this._ctx.canvas.width,this._ctx.canvas.height),this._ctx.fillStyle="#002d42",this._ctx.globalAlpha=.8,this._ctx.fillRect(0,0,this._ctx.canvas.width,this._ctx.canvas.height),this._ctx.globalAlpha=1}}]),e}(),wt=function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},jt=a(7),yt=a(8),Ct=yt.a.img(ot||(ot=Object(jt.a)(["\n position: absolute;\n z-index: 4;\n"]))),Rt=yt.a.img(st||(st=Object(jt.a)(["\n position: absolute;\n z-index: -3;\n"]))),Tt=Object(yt.a)(Ct)(rt||(rt=Object(jt.a)(["\n top: -7%;\n left: -5%;\n width: 110%;\n height: 8%;\n transform: rotate3d(1, 1, 1, -3deg);\n"]))),Et=Object(yt.a)(Ct)(ct||(ct=Object(jt.a)(["\n bottom: -7%;\n left: -5%;\n width: 110%;\n height: 8%;\n transform: rotate3d(1, 1, 1, -1deg);\n"]))),St=Object(yt.a)(Ct)(lt||(lt=Object(jt.a)(["\n bottom: -15%;\n left: -8%;\n width: 160%;\n height: 10%;\n transform: rotate3d(0, 0, 1, -92deg);\n transform-origin: top left;\n"]))),Pt=Object(yt.a)(Ct)(ht||(ht=Object(jt.a)(["\n bottom: -14%;\n right: -12%;\n width: 160%;\n height: 10%;\n transform: rotate3d(0, 0, 1, 91deg);\n transform-origin: top right;\n"]))),xt=Object(yt.a)(Rt)(ut||(ut=Object(jt.a)(["\n top: -6%;\n left: -9%;\n width: 115%;\n height: 12%;\n transform: rotate3d(1, 1, 1, -3deg);\n"]))),Lt=Object(yt.a)(Rt)(dt||(dt=Object(jt.a)(["\n bottom: -7%;\n left: -14%;\n width: 125%;\n height: 12%;\n transform: rotate3d(0, 0, 1, 178deg);\n"]))),Nt=Object(yt.a)(Rt)(mt||(mt=Object(jt.a)(["\n top: -6%;\n left: 8%;\n width: 160%;\n height: 13%;\n transform: rotate3d(0, 0, 1, 91deg);\n transform-origin: top left;\n"]))),It=Object(yt.a)(Rt)(bt||(bt=Object(jt.a)(["\n bottom: -17%;\n right: -10%;\n width: 160%;\n height: 12%;\n transform: rotate3d(0, 0, 1, 88deg);\n transform-origin: top right;\n"]))),Dt=a.p+"static/media/plank_frame.eeb9c35e.png",Mt=a.p+"static/media/plank_frame_darker.764fcd18.png",Gt=a(2),Wt=function(){return Object(Gt.jsxs)(Gt.Fragment,{children:[Object(Gt.jsx)(Tt,{src:Dt}),Object(Gt.jsx)(Et,{src:Dt}),Object(Gt.jsx)(St,{src:Dt}),Object(Gt.jsx)(Pt,{src:Dt}),Object(Gt.jsx)(xt,{src:Mt}),Object(Gt.jsx)(Lt,{src:Mt}),Object(Gt.jsx)(Nt,{src:Mt}),Object(Gt.jsx)(It,{src:Mt})]})},Ft=yt.a.video(ft||(ft=Object(jt.a)(["\n position: absolute;\n top: 0;\n left: 0;\n z-index: -20;\n object-fit: cover;\n width: 100%;\n height: 100%;\n"]))),Ut=function(e){var t=e.videoUrl,a=e.playbackSpeed,i=void 0===a?1:a,n=Object(E.useRef)(null);return Object(E.useEffect)((function(){n.current&&(n.current.playbackRate=i)}),[i]),Object(Gt.jsx)(Ft,{playsinline:!0,autoPlay:!0,muted:!0,loop:!0,ref:n,children:Object(Gt.jsx)("source",{src:t,type:"video/mp4"})})},Vt=a.p+"static/media/1000_40fps_medium_8-5MB.827a0441.mp4",Xt=a.p+"static/media/simple_plants.601d8cb2.png",Yt=yt.a.div(kt||(kt=Object(jt.a)(["\n position: fixed;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n overflow: hidden;\n background-color: #4a2400;\n background-image: url(",");\n background-position: top left;\n background-size: 50% 10%;\n"])),Dt),zt=yt.a.div(vt||(vt=Object(jt.a)(["\n display: block;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n padding: 15px;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n"]))),Kt=yt.a.div(gt||(gt=Object(jt.a)(["\n width: 90%;\n height: 90%;\n display: flex;\n justify-content: center;\n align-items: flex-start;\n"]))),qt=yt.a.canvas(Bt||(Bt=Object(jt.a)(["\n display: block;\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n border: 5px solid #462a1a;\n"]))),_t=yt.a.div(pt||(pt=Object(jt.a)(["\n position: relative;\n ","\n ","\n ","\n ","\n"])),(function(e){return e.staticBG&&'background-image: url("'+Xt+'");'}),(function(e){return e.staticBG&&"background-position: left;"}),(function(e){return e.staticBG&&"background-size: cover;"}),(function(e){return e.staticBG&&"background-repeat: no-repeat;"})),Ht=function(){var e=Object(E.useRef)(null),t=Object(E.useRef)(null),a=Object(E.useState)((function(){return wt()})),i=Object(L.a)(a,1)[0];return Object(E.useEffect)((function(){console.log("Mounting",Date.now());var a=new At(e,t);return a.setGame(Ot),a.start(),function(){console.warn("Unmounting!!!!!!!!",Date.now()),a.stop()}}),[]),Object(Gt.jsx)(Yt,{children:Object(Gt.jsx)(zt,{children:Object(Gt.jsx)(Kt,{ref:t,children:Object(Gt.jsxs)(_t,{staticBG:i,children:[Object(Gt.jsx)(qt,{id:"gameCanvas",ref:e,width:"500px",height:"500px"}),!i&&Object(Gt.jsx)(Ut,{videoUrl:Vt,playbackSpeed:.5}),Object(Gt.jsx)(Wt,{})]})})})})},Zt=function(){return Object(Gt.jsx)(Ht,{})},Jt=function(e){e&&e instanceof Function&&a.e(3).then(a.bind(null,33)).then((function(t){var a=t.getCLS,i=t.getFID,n=t.getFCP,o=t.getLCP,s=t.getTTFB;a(e),i(e),n(e),o(e),s(e)}))};x.a.render(Object(Gt.jsx)(S.a.StrictMode,{children:Object(Gt.jsx)(Zt,{})}),document.getElementById("root")),Jt()}},[[30,1,2]]]); //# sourceMappingURL=main.ecf71c05.chunk.js.map