diff --git a/index.46841683.js b/index.46841683.js new file mode 100644 index 000000000..95e406bcb --- /dev/null +++ b/index.46841683.js @@ -0,0 +1,2 @@ +const t=new class{constructor(t){this.initialState=t,this.initialStateRestart=t?t.map(t=>t.map(t=>t)):[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],this.state=t||[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],this.score=0,this.status="idle",this.isMerged=[[!1,!1,!1,!1],[!1,!1,!1,!1],[!1,!1,!1,!1],[!1,!1,!1,!1]]}moveLeft(){if("playing"!==this.status)return;let t=!1;for(let e=0;e0&&(0===this.state[e][i-1]||this.state[e][i-1]===this.state[e][i]);)if(0===this.state[e][i-1])this.state[e][i-1]=this.state[e][i],this.state[e][i]=0,t=!0,i--;else if(this.state[e][i-1]!==this.state[e][i]||this.isMerged[e][i-1])break;else this.state[e][i-1]*=2,this.state[e][i]=0,this.score+=this.state[e][i-1],this.isMerged[e][i-1]=!0,t=!0}t&&(this.isMerged.forEach(t=>t.fill(!1)),this.generateNewTiles())}moveRight(){if("playing"!==this.status)return;let t=!1;for(let e=0;e=0;s--)if(0!==this.state[e][s]){let i=s;for(;it.fill(!1)),this.generateNewTiles())}moveUp(){if("playing"!==this.status)return;let t=!1;for(let e=1;e0&&(0===this.state[i-1][s]||this.state[i-1][s]===this.state[i][s]);)if(0===this.state[i-1][s])this.state[i-1][s]=this.state[i][s],this.state[i][s]=0,t=!0,i--;else if(this.state[i-1][s]!==this.state[i][s]||this.isMerged[i-1][s])break;else this.state[i-1][s]*=2,this.score+=this.state[i-1][s],this.state[i][s]=0,t=!0,this.isMerged[i-1][s]=!0}t&&(this.isMerged.forEach(t=>t.fill(!1)),this.generateNewTiles())}moveDown(){if("playing"!==this.status)return;let t=!1;for(let e=this.state.length-2;e>=0;e--)for(let s=0;st.fill(!1)),this.generateNewTiles())}getScore(){return this.score}getState(){return this.getStatus(),this.state}getStatus(){return this.state.some(t=>t.includes(2048))&&(this.status="win"),this.canMove()||(this.status="lose"),this.status}start(){this.status="playing",this.generateNewTiles(),this.generateNewTiles()}restart(){this.score=0,this.status="idle",this.state=this.initialStateRestart.map(t=>[...t])}generateNewTiles(){if("win"===this.status||"lose"===this.status)return;let t=[];for(let e=0;e0){let e=Math.floor(Math.random()*t.length),{row:s,col:i}=t[e];this.state[s][i]=.9>Math.random()?2:4}}canMove(){for(let t=0;t{s.classList.contains("start")?(t.start(),s.classList.remove("start"),s.classList.add("restart"),s.textContent="Restart"):(t.restart(),s.classList.remove("restart"),s.classList.add("start"),s.textContent="Start"),e()}),document.addEventListener("keydown",s=>{if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(s.key)&&s.preventDefault(),"playing"===t.getStatus()){switch(s.key){case"ArrowLeft":t.moveLeft();break;case"ArrowRight":t.moveRight();break;case"ArrowUp":t.moveUp();break;case"ArrowDown":t.moveDown()}e(),t.getStatus()}})}); +//# sourceMappingURL=index.46841683.js.map diff --git a/index.46841683.js.map b/index.46841683.js.map new file mode 100644 index 000000000..ad6f40644 --- /dev/null +++ b/index.46841683.js.map @@ -0,0 +1 @@ +{"mappings":"ACMA,MAAM,EAAO,ICIb,MAgBE,YAAY,CAAY,CACxB,CACE,IAAI,CAAC,YAAY,CAAG,EAEpB,IAAI,CAAC,mBAAmB,CAAG,EAAe,EAAa,GAAG,CAAC,AAAA,GAAO,EAAI,GAAG,CAAC,AAAA,GAAQ,IAAS,CACzF,CAAC,EAAG,EAAG,EAAG,EAAE,CACZ,CAAC,EAAG,EAAG,EAAG,EAAE,CACZ,CAAC,EAAG,EAAG,EAAG,EAAE,CACZ,CAAC,EAAG,EAAG,EAAG,EAAE,CACb,CAED,IAAI,CAAC,KAAK,CAAG,GAAgB,CAC3B,CAAC,EAAG,EAAG,EAAG,EAAE,CACZ,CAAC,EAAG,EAAG,EAAG,EAAE,CACZ,CAAC,EAAG,EAAG,EAAG,EAAE,CACZ,CAAC,EAAG,EAAG,EAAG,EAAE,CACb,CAED,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Aa,SAAS,aAAa,CAAC,gBACpC,EAAc,SAAS,aAAa,CAAC,gBAEvC,AAAe,CAAA,YAAf,EAEF,EAAa,SAAS,CAAC,GAAG,CAAC,UAEpB,AAAe,QAAf,EAEP,EAAW,SAAS,CAAC,MAAM,CAAC,UAErB,AAAe,SAAf,EAEP,EAAY,SAAS,CAAC,MAAM,CAAC,WAI7B,EAAa,SAAS,CAAC,MAAM,CAAC,UAC9B,EAAW,SAAS,CAAC,GAAG,CAAC,UACzB,EAAY,SAAS,CAAC,GAAG,CAAC,UAE9B,CAEA,SAAS,gBAAgB,CAAC,mBA5G1B,WAEE,IAAM,EAAc,SAAS,aAAa,CAAC,UAE3C,EAAY,gBAAgB,CAAC,QAAS,KAEhC,EAAY,SAAS,CAAC,QAAQ,CAAC,UAEjC,EAAK,KAAK,GACV,EAAY,SAAS,CAAC,MAAM,CAAC,SAC7B,EAAY,SAAS,CAAC,GAAG,CAAC,WAC1B,EAAY,WAAW,CAAG,YAI1B,EAAK,OAAO,GACZ,EAAY,SAAS,CAAC,MAAM,CAAC,WAC7B,EAAY,SAAS,CAAC,GAAG,CAAC,SAC1B,EAAY,WAAW,CAAG,SAG5B,GACF,GAEA,SAAS,gBAAgB,CAAC,UAAW,AAAC,IASpC,GANE,CAAC,YAAa,aAAc,UAAW,YAAY,CAAC,QAAQ,CAAC,EAAS,GAAG,GAGzE,EAAS,cAAc,GAGrB,AAAqB,YAArB,EAAK,SAAS,GAClB,CACE,OAAQ,EAAS,GAAG,EAElB,IAAK,YACH,EAAK,QAAQ,GACb,KACF,KAAK,aACH,EAAK,SAAS,GACd,KACF,KAAK,UACH,EAAK,MAAM,GACX,KACF,KAAK,YACH,EAAK,QAAQ,EAEjB,CACA,IACA,EAAK,SAAS,EAChB,CACF,EACF","sources":["","src/scripts/main.js","src/modules/Game.class.js"],"sourcesContent":["/* eslint-disable brace-style */ /* eslint-disable prettier/prettier */ \"use strict\";\nvar $a5fd07fa01589658$exports = {};\n/* eslint-disable max-len */ /* eslint-disable prettier/prettier */ /* eslint-disable brace-style */ \"use strict\";\n/**\n * This class represents the game.\n * Now it has a basic structure, that is needed for testing.\n * Feel free to add more props and methods if needed.\n */ class $a5fd07fa01589658$var$Game {\n /**\n * Creates a new game instance.\n *\n * @param {number[][]} initialState\n * The initial state of the board.\n * @default\n * [[0, 0, 0, 0],\n * [0, 0, 0, 0],\n * [0, 0, 0, 0],\n * [0, 0, 0, 0]]\n *\n * If passed, the board will be initialized with the provided\n * initial state.\n */ constructor(initialState){\n this.initialState = initialState;\n this.initialStateRestart = initialState ? initialState.map((row)=>row.map((cell)=>cell)) : [\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ]\n ];\n this.state = initialState || [\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ]\n ];\n this.score = 0;\n this.status = \"idle\";\n this.isMerged = [\n [\n false,\n false,\n false,\n false\n ],\n [\n false,\n false,\n false,\n false\n ],\n [\n false,\n false,\n false,\n false\n ],\n [\n false,\n false,\n false,\n false\n ]\n ];\n }\n moveLeft() {\n if (this.status !== \"playing\") return;\n let moved = false;\n for(let i = 0; i < this.state.length; i++){\n for(let j = 1; j < this.state[i].length; j++)if (this.state[i][j] !== 0) {\n let k = j;\n while(k > 0 && (this.state[i][k - 1] === 0 || this.state[i][k - 1] === this.state[i][k])){\n if (this.state[i][k - 1] === 0) {\n this.state[i][k - 1] = this.state[i][k];\n this.state[i][k] = 0;\n moved = true;\n k--;\n } else if (this.state[i][k - 1] === this.state[i][k] && !this.isMerged[i][k - 1]) {\n this.state[i][k - 1] *= 2;\n this.state[i][k] = 0;\n this.score += this.state[i][k - 1];\n this.isMerged[i][k - 1] = true;\n moved = true;\n } else break;\n }\n }\n }\n if (moved) {\n this.isMerged.forEach((row)=>row.fill(false));\n this.generateNewTiles();\n }\n }\n moveRight() {\n if (this.status !== \"playing\") return;\n let moved = false;\n for(let i = 0; i < this.state.length; i++){\n for(let j = this.state[i].length - 2; j >= 0; j--)if (this.state[i][j] !== 0) {\n let k = j;\n while(k < this.state[i].length - 1 && (this.state[i][k + 1] === 0 || this.state[i][k + 1] === this.state[i][k])){\n if (this.state[i][k + 1] === 0) {\n this.state[i][k + 1] = this.state[i][k];\n this.state[i][k] = 0;\n moved = true;\n k++;\n } else if (this.state[i][k + 1] === this.state[i][k] && !this.isMerged[i][k + 1]) {\n this.state[i][k + 1] *= 2;\n this.score += this.state[i][k + 1];\n this.state[i][k] = 0;\n moved = true;\n this.isMerged[i][k + 1] = true;\n } else break;\n }\n }\n }\n if (moved) {\n this.isMerged.forEach((row)=>row.fill(false));\n this.generateNewTiles();\n }\n }\n moveUp() {\n if (this.status !== \"playing\") return;\n let moved = false;\n for(let i = 1; i < this.state.length; i++){\n for(let j = 0; j < this.state[i].length; j++)if (this.state[i][j] !== 0) {\n let k = i;\n while(k > 0 && (this.state[k - 1][j] === 0 || this.state[k - 1][j] === this.state[k][j])){\n if (this.state[k - 1][j] === 0) {\n this.state[k - 1][j] = this.state[k][j];\n this.state[k][j] = 0;\n moved = true;\n k--;\n } else if (this.state[k - 1][j] === this.state[k][j] && !this.isMerged[k - 1][j]) {\n this.state[k - 1][j] *= 2;\n this.score += this.state[k - 1][j];\n this.state[k][j] = 0;\n moved = true;\n this.isMerged[k - 1][j] = true;\n } else break;\n }\n }\n }\n if (moved) {\n this.isMerged.forEach((row)=>row.fill(false));\n this.generateNewTiles();\n }\n }\n moveDown() {\n if (this.status !== \"playing\") return;\n let moved = false;\n for(let i = this.state.length - 2; i >= 0; i--){\n for(let j = 0; j < this.state[i].length; j++)if (this.state[i][j] !== 0) {\n let k = i;\n while(k < this.state.length - 1 && (this.state[k + 1][j] === 0 || this.state[k + 1][j] === this.state[k][j])){\n if (this.state[k + 1][j] === 0) {\n this.state[k + 1][j] = this.state[k][j];\n this.state[k][j] = 0;\n moved = true;\n k++;\n } else if (this.state[k + 1][j] === this.state[k][j] && !this.isMerged[k + 1][j]) {\n this.state[k + 1][j] *= 2;\n this.score += this.state[k + 1][j];\n this.state[k][j] = 0;\n moved = true;\n this.isMerged[k + 1][j] = true;\n } else break;\n }\n }\n }\n if (moved) {\n this.isMerged.forEach((row)=>row.fill(false));\n this.generateNewTiles();\n }\n }\n /**\n * @returns {number}\n */ getScore() {\n return this.score;\n }\n /**\n * @returns {number[][]}\n */ getState() {\n this.getStatus();\n return this.state;\n }\n /**\n * Returns the current game status.\n *\n * @returns {string} One of: 'idle', 'playing', 'win', 'lose'\n *\n * `idle` - the game has not started yet (the initial state);\n * `playing` - the game is in progress;\n * `win` - the game is won;\n * `lose` - the game is lost\n */ getStatus() {\n if (this.state.some((row)=>row.includes(2048))) this.status = \"win\";\n if (!this.canMove()) this.status = \"lose\";\n return this.status;\n }\n /**\n * Starts the game.\n */ start() {\n this.status = \"playing\";\n this.generateNewTiles();\n this.generateNewTiles();\n }\n /**\n * Resets the game.\n */ restart() {\n this.score = 0;\n this.status = \"idle\";\n this.state = this.initialStateRestart.map((row)=>[\n ...row\n ]);\n }\n // Add your own methods here\n generateNewTiles() {\n if (this.status === \"win\" || this.status === \"lose\") return;\n const emptyCells = [];\n for(let i = 0; i < this.state.length; i++){\n for(let j = 0; j < this.state[i].length; j++)if (this.state[i][j] === 0) emptyCells.push({\n row: i,\n col: j\n });\n }\n if (emptyCells.length > 0) {\n const randomIndex = Math.floor(Math.random() * emptyCells.length);\n const { row: row, col: col } = emptyCells[randomIndex];\n this.state[row][col] = Math.random() < 0.9 ? 2 : 4;\n }\n }\n canMove() {\n for(let i = 0; i < this.state.length; i++)for(let j = 0; j < this.state[i].length; j++){\n if (this.state[i][j] === 0 || j < this.state[i].length - 1 && this.state[i][j] === this.state[i][j + 1] || i < this.state.length - 1 && this.state[i][j] === this.state[i + 1][j]) return true;\n }\n return false;\n }\n}\n$a5fd07fa01589658$exports = $a5fd07fa01589658$var$Game;\n\n\nconst $09e991522ca7e64e$var$game = new $a5fd07fa01589658$exports([\n [\n 1024,\n 1024,\n 2,\n 4\n ],\n [\n 4,\n 2,\n 4,\n 2\n ],\n [\n 2,\n 4,\n 2,\n 4\n ],\n [\n 0,\n 2,\n 4,\n 2\n ]\n]);\n// Write your code here\nfunction $09e991522ca7e64e$var$initializeGame() {\n const buttonStart = document.querySelector(\".start\");\n buttonStart.addEventListener(\"click\", ()=>{\n if (buttonStart.classList.contains(\"start\")) {\n $09e991522ca7e64e$var$game.start();\n buttonStart.classList.remove(\"start\");\n buttonStart.classList.add(\"restart\");\n buttonStart.textContent = \"Restart\";\n } else {\n $09e991522ca7e64e$var$game.restart();\n buttonStart.classList.remove(\"restart\");\n buttonStart.classList.add(\"start\");\n buttonStart.textContent = \"Start\";\n }\n $09e991522ca7e64e$var$updateUI();\n });\n document.addEventListener(\"keydown\", (eventKey)=>{\n if ([\n \"ArrowLeft\",\n \"ArrowRight\",\n \"ArrowUp\",\n \"ArrowDown\"\n ].includes(eventKey.key)) eventKey.preventDefault();\n if ($09e991522ca7e64e$var$game.getStatus() === \"playing\") {\n switch(eventKey.key){\n case \"ArrowLeft\":\n $09e991522ca7e64e$var$game.moveLeft();\n break;\n case \"ArrowRight\":\n $09e991522ca7e64e$var$game.moveRight();\n break;\n case \"ArrowUp\":\n $09e991522ca7e64e$var$game.moveUp();\n break;\n case \"ArrowDown\":\n $09e991522ca7e64e$var$game.moveDown();\n break;\n }\n $09e991522ca7e64e$var$updateUI();\n $09e991522ca7e64e$var$game.getStatus();\n }\n });\n}\nfunction $09e991522ca7e64e$var$updateUI() {\n const scoreElement = document.querySelector(\".game-score\");\n scoreElement.textContent = $09e991522ca7e64e$var$game.getScore();\n const state = $09e991522ca7e64e$var$game.getState();\n const cells = document.querySelectorAll(\".field-cell\");\n let index = 0;\n for(let i = 0; i < state.length; i++)for(let j = 0; j < state[i].length; j++){\n cells[index].textContent = state[i][j] !== 0 ? state[i][j] : \"\";\n cells[index].className = \"field-cell\";\n if (state[i][j] !== 0) cells[index].classList.add(`field-cell--${state[i][j]}`);\n index++;\n }\n const gameStatus = $09e991522ca7e64e$var$game.getStatus();\n const messageStart = document.querySelector(\".message-start\");\n const messageWin = document.querySelector(\".message-win\");\n const messageLose = document.querySelector(\".message-lose\");\n if (gameStatus === \"playing\") messageStart.classList.add(\"hidden\");\n else if (gameStatus === \"win\") messageWin.classList.remove(\"hidden\");\n else if (gameStatus === \"lose\") messageLose.classList.remove(\"hidden\");\n else {\n messageStart.classList.remove(\"hidden\");\n messageWin.classList.add(\"hidden\");\n messageLose.classList.add(\"hidden\");\n }\n}\ndocument.addEventListener(\"DOMContentLoaded\", $09e991522ca7e64e$var$initializeGame);\n\n\n//# sourceMappingURL=index.46841683.js.map\n","/* eslint-disable brace-style */\n/* eslint-disable prettier/prettier */\n'use strict';\n\n// Uncomment the next lines to use your game instance in the browser\nconst Game = require('../modules/Game.class');\nconst game = new Game(\n [\n [1024, 1024, 2, 4],\n [4, 2, 4, 2],\n [2, 4, 2, 4],\n [0, 2, 4, 2],\n ],\n);\n\n// Write your code here\nfunction initializeGame()\n{\n const buttonStart = document.querySelector('.start');\n\n buttonStart.addEventListener('click', () =>\n {\n if (buttonStart.classList.contains('start'))\n {\n game.start();\n buttonStart.classList.remove('start');\n buttonStart.classList.add('restart');\n buttonStart.textContent = 'Restart';\n }\n else\n {\n game.restart();\n buttonStart.classList.remove('restart');\n buttonStart.classList.add('start');\n buttonStart.textContent = 'Start';\n }\n\n updateUI();\n });\n\n document.addEventListener('keydown', (eventKey) =>\n {\n if (\n ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(eventKey.key)\n )\n {\n eventKey.preventDefault();\n }\n\n if (game.getStatus() === 'playing')\n {\n switch (eventKey.key)\n {\n case 'ArrowLeft':\n game.moveLeft();\n break;\n case 'ArrowRight':\n game.moveRight();\n break;\n case 'ArrowUp':\n game.moveUp();\n break;\n case 'ArrowDown':\n game.moveDown();\n break;\n }\n updateUI();\n game.getStatus();\n }\n });\n}\n\nfunction updateUI()\n{\n const scoreElement = document.querySelector('.game-score');\n\n scoreElement.textContent = game.getScore();\n\n const state = game.getState();\n\n const cells = document.querySelectorAll('.field-cell');\n let index = 0;\n\n for (let i = 0; i < state.length; i++)\n {\n for (let j = 0; j < state[i].length; j++)\n {\n cells[index].textContent = state[i][j] !== 0 ? state[i][j] : '';\n cells[index].className = 'field-cell';\n\n if (state[i][j] !== 0)\n {\n cells[index].classList.add(`field-cell--${state[i][j]}`);\n }\n index++;\n }\n }\n\n const gameStatus = game.getStatus();\n\n const messageStart = document.querySelector('.message-start');\n const messageWin = document.querySelector('.message-win');\n const messageLose = document.querySelector('.message-lose');\n\n if (gameStatus === 'playing')\n {\n messageStart.classList.add('hidden');\n }\n else if (gameStatus === 'win')\n {\n messageWin.classList.remove('hidden');\n }\n else if (gameStatus === 'lose')\n {\n messageLose.classList.remove('hidden');\n }\n else\n {\n messageStart.classList.remove('hidden');\n messageWin.classList.add('hidden');\n messageLose.classList.add('hidden');\n }\n}\n\ndocument.addEventListener('DOMContentLoaded', initializeGame);\n","/* eslint-disable max-len */\n/* eslint-disable prettier/prettier */\n/* eslint-disable brace-style */\n'use strict';\n\n/**\n * This class represents the game.\n * Now it has a basic structure, that is needed for testing.\n * Feel free to add more props and methods if needed.\n */\nclass Game\n{\n /**\n * Creates a new game instance.\n *\n * @param {number[][]} initialState\n * The initial state of the board.\n * @default\n * [[0, 0, 0, 0],\n * [0, 0, 0, 0],\n * [0, 0, 0, 0],\n * [0, 0, 0, 0]]\n *\n * If passed, the board will be initialized with the provided\n * initial state.\n */\n constructor(initialState)\n {\n this.initialState = initialState;\n\n this.initialStateRestart = initialState ? initialState.map(row => row.map(cell => cell)) : [\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n ];\n\n this.state = initialState || [\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n ];\n\n this.score = 0;\n this.status = 'idle';\n\n this.isMerged = [\n [false, false, false, false],\n [false, false, false, false],\n [false, false, false, false],\n [false, false, false, false],\n ];\n }\n\n moveLeft()\n {\n if (this.status !== 'playing')\n {\n return;\n }\n\n let moved = false;\n\n for (let i = 0; i < this.state.length; i++)\n {\n for (let j = 1; j < this.state[i].length; j++)\n {\n if (this.state[i][j] !== 0)\n {\n let k = j;\n\n while (k > 0 && (this.state[i][k - 1] === 0 || this.state[i][k - 1] === this.state[i][k]))\n {\n if (this.state[i][k - 1] === 0)\n {\n this.state[i][k - 1] = this.state[i][k];\n this.state[i][k] = 0;\n moved = true;\n k--;\n }\n else if (this.state[i][k - 1] === this.state[i][k] && !this.isMerged[i][k - 1])\n {\n this.state[i][k - 1] *= 2;\n this.state[i][k] = 0;\n this.score += this.state[i][k - 1];\n this.isMerged[i][k - 1] = true;\n moved = true;\n }\n else\n {\n break;\n }\n }\n }\n }\n }\n\n if (moved)\n {\n this.isMerged.forEach(row => row.fill(false));\n this.generateNewTiles();\n }\n }\n\n moveRight()\n {\n if (this.status !== 'playing')\n {\n return;\n }\n\n let moved = false;\n\n for (let i = 0; i < this.state.length; i++)\n {\n for (let j = this.state[i].length - 2; j >= 0; j--)\n {\n if (this.state[i][j] !== 0)\n {\n let k = j;\n\n while (k < this.state[i].length - 1 && (this.state[i][k + 1] === 0 || this.state[i][k + 1] === this.state[i][k]))\n {\n if (this.state[i][k + 1] === 0)\n {\n this.state[i][k + 1] = this.state[i][k];\n this.state[i][k] = 0;\n moved = true;\n k++;\n }\n else if (this.state[i][k + 1] === this.state[i][k] && !this.isMerged[i][k + 1])\n {\n this.state[i][k + 1] *= 2;\n this.score += this.state[i][k + 1];\n this.state[i][k] = 0;\n moved = true;\n this.isMerged[i][k + 1] = true;\n }\n else\n {\n break;\n }\n }\n }\n }\n }\n\n if (moved)\n {\n this.isMerged.forEach(row => row.fill(false));\n this.generateNewTiles();\n }\n }\n\n moveUp()\n {\n if (this.status !== 'playing')\n {\n return;\n }\n\n let moved = false;\n\n for (let i = 1; i < this.state.length; i++)\n {\n for (let j = 0; j < this.state[i].length; j++)\n {\n if (this.state[i][j] !== 0)\n {\n let k = i;\n\n while (k > 0 && (this.state[k - 1][j] === 0 || this.state[k - 1][j] === this.state[k][j]))\n {\n if (this.state[k - 1][j] === 0)\n {\n this.state[k - 1][j] = this.state[k][j];\n this.state[k][j] = 0;\n moved = true;\n k--;\n }\n else if (this.state[k - 1][j] === this.state[k][j] && !this.isMerged[k - 1][j])\n {\n this.state[k - 1][j] *= 2;\n this.score += this.state[k - 1][j];\n this.state[k][j] = 0;\n moved = true;\n this.isMerged[k - 1][j] = true;\n }\n else\n {\n break;\n }\n }\n }\n }\n }\n\n if (moved)\n {\n this.isMerged.forEach(row => row.fill(false));\n this.generateNewTiles();\n }\n }\n\n moveDown()\n {\n if (this.status !== 'playing')\n {\n return;\n }\n\n let moved = false;\n\n for (let i = this.state.length - 2; i >= 0; i--)\n {\n for (let j = 0; j < this.state[i].length; j++)\n {\n if (this.state[i][j] !== 0)\n {\n let k = i;\n\n while (k < this.state.length - 1 && (this.state[k + 1][j] === 0 || this.state[k + 1][j] === this.state[k][j]))\n {\n if (this.state[k + 1][j] === 0)\n {\n this.state[k + 1][j] = this.state[k][j];\n this.state[k][j] = 0;\n moved = true;\n k++;\n }\n else if (this.state[k + 1][j] === this.state[k][j] && !this.isMerged[k + 1][j])\n {\n this.state[k + 1][j] *= 2;\n this.score += this.state[k + 1][j];\n this.state[k][j] = 0;\n moved = true;\n this.isMerged[k + 1][j] = true;\n }\n else\n {\n break;\n }\n }\n }\n }\n }\n\n if (moved)\n {\n this.isMerged.forEach(row => row.fill(false));\n this.generateNewTiles();\n }\n\n }\n\n /**\n * @returns {number}\n */\n getScore()\n {\n return this.score;\n }\n\n /**\n * @returns {number[][]}\n */\n getState()\n {\n this.getStatus();\n\n return this.state;\n }\n\n /**\n * Returns the current game status.\n *\n * @returns {string} One of: 'idle', 'playing', 'win', 'lose'\n *\n * `idle` - the game has not started yet (the initial state);\n * `playing` - the game is in progress;\n * `win` - the game is won;\n * `lose` - the game is lost\n */\n getStatus()\n {\n if (this.state.some(row => row.includes(2048)))\n {\n this.status = 'win';\n }\n\n if (!this.canMove())\n {\n this.status = 'lose';\n }\n\n return this.status;\n }\n\n /**\n * Starts the game.\n */\n start()\n {\n this.status = 'playing';\n this.generateNewTiles();\n this.generateNewTiles();\n }\n\n /**\n * Resets the game.\n */\n restart()\n {\n this.score = 0;\n this.status = 'idle';\n this.state = this.initialStateRestart.map(row => [...row]);\n }\n\n // Add your own methods here\n generateNewTiles()\n {\n\n if (this.status === 'win' || this.status === 'lose')\n {\n return;\n }\n\n const emptyCells = [];\n\n for (let i = 0; i < this.state.length; i++)\n {\n for (let j = 0; j < this.state[i].length; j++)\n {\n if (this.state[i][j] === 0)\n {\n emptyCells.push({\n row: i,\n col: j,\n });\n }\n }\n }\n\n if (emptyCells.length > 0)\n {\n const randomIndex = Math.floor(Math.random() * emptyCells.length);\n const { row, col } = emptyCells[randomIndex];\n\n this.state[row][col] = Math.random() < 0.9 ? 2 : 4;\n }\n }\n\n canMove()\n {\n for (let i = 0; i < this.state.length; i++)\n {\n for (let j = 0; j < this.state[i].length; j++)\n {\n if (\n this.state[i][j] === 0\n || (j < this.state[i].length - 1 && this.state[i][j] === this.state[i][j + 1])\n || (i < this.state.length - 1 && this.state[i][j] === this.state[i + 1][j])\n )\n {\n return true;\n }\n }\n }\n\n return false;\n }\n}\n\nmodule.exports = Game;\n"],"names":["$09e991522ca7e64e$var$game","constructor","initialState","initialStateRestart","map","row","cell","state","score","status","isMerged","moveLeft","moved","i","length","j","k","forEach","fill","generateNewTiles","moveRight","moveUp","moveDown","getScore","getState","getStatus","some","includes","canMove","start","restart","emptyCells","push","col","randomIndex","Math","floor","random","$09e991522ca7e64e$var$updateUI","scoreElement","document","querySelector","textContent","cells","querySelectorAll","index","className","classList","add","gameStatus","messageStart","messageWin","messageLose","remove","addEventListener","buttonStart","contains","eventKey","key","preventDefault"],"version":3,"file":"index.46841683.js.map"} \ No newline at end of file diff --git a/index.6910ad39.css b/index.6910ad39.css new file mode 100644 index 000000000..3cd0f3b4d --- /dev/null +++ b/index.6910ad39.css @@ -0,0 +1,2 @@ +body{background:#fbf8ef;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;min-height:100vh;margin:0;font-family:sans-serif;font-size:24px;font-weight:900;display:-ms-flexbox;display:flex}.field-cell{color:#776e65;box-sizing:border-box;text-align:center;vertical-align:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;background:#d6cdc4;border-radius:5px;width:75px;height:75px}.field-cell--2{background:#eee4da}.field-cell--4{background:#ede0c8}.field-cell--8{color:#f9f6f2;background:#f2b179}.field-cell--16{color:#f9f6f2;background:#f59563}.field-cell--32{color:#f9f6f2;background:#f67c5f}.field-cell--64{color:#f9f6f2;background:#f65e3b}.field-cell--128{color:#f9f6f2;background:#edcf72}.field-cell--256{color:#f9f6f2;background:#edcc61}.field-cell--512{color:#f9f6f2;background:#edc850}.field-cell--1024{color:#f9f6f2;background:#edc53f}.field-cell--2048{color:#f9f6f2;background:#edc22e}.game-field{border-spacing:10px;background:#bbada0;border-radius:5px}.game-header{box-sizing:border-box;-ms-flex-pack:justify;justify-content:space-between;width:100%;margin-bottom:24px;padding:10px;display:-ms-flexbox;display:flex}h1{color:#f9f6f2;box-sizing:border-box;background:#edc22e;border-radius:5px;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;width:75px;height:75px;margin:0;font-size:24px;display:-ms-flexbox;display:flex}.info{color:#776e65;box-sizing:border-box;background:#d6cdc4;border-radius:5px;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;width:75px;height:75px;margin:0 8px 0 0;font-size:16px;display:-ms-flexbox;display:flex}.controls{display:-ms-flexbox;display:flex}.button{cursor:pointer;color:#f9f6f2;border:none;border-radius:5px;width:75px;height:75px;font-family:sans-serif;font-size:16px;font-weight:700;transition:background .25s}.start{background:#1dae28;font-size:20px}.start:hover{background:#179921}.restart{background:#f1b2b2}.restart:hover{background:#f87474}.message{box-sizing:border-box;color:#776e65;text-align:center;background:#d6cdc4;border-radius:5px;width:100%;padding:10px;font-size:20px}.hidden{display:none}.container{-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;width:350px;display:-ms-flexbox;display:flex}.message-win{color:#f9f6f2;background:#edc22e}.message-container{width:100%;height:150px} +/*# sourceMappingURL=index.6910ad39.css.map */ diff --git a/index.6910ad39.css.map b/index.6910ad39.css.map new file mode 100644 index 000000000..747fdd5ba --- /dev/null +++ b/index.6910ad39.css.map @@ -0,0 +1 @@ +{"mappings":"ACAA,8NAYA,mNAWE,kCAIA,kCAIA,gDAKA,iDAKA,iDAKA,iDAKA,kDAKA,kDAKA,kDAKA,mDAKA,mDAMF,qEAMA,mKASA,iPAcA,4SAeA,2CAIA,2KAcA,yCAIE,gCAKF,4BAGE,kCAKF,2IAWA,qBAIA,iJAOA,8CAKA","sources":["index.6910ad39.css","src/styles/main.scss"],"sourcesContent":["body {\n background: #fbf8ef;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-align: center;\n align-items: center;\n min-height: 100vh;\n margin: 0;\n font-family: sans-serif;\n font-size: 24px;\n font-weight: 900;\n display: -ms-flexbox;\n display: flex;\n}\n\n.field-cell {\n color: #776e65;\n box-sizing: border-box;\n text-align: center;\n vertical-align: center;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background: #d6cdc4;\n border-radius: 5px;\n width: 75px;\n height: 75px;\n}\n\n.field-cell--2 {\n background: #eee4da;\n}\n\n.field-cell--4 {\n background: #ede0c8;\n}\n\n.field-cell--8 {\n color: #f9f6f2;\n background: #f2b179;\n}\n\n.field-cell--16 {\n color: #f9f6f2;\n background: #f59563;\n}\n\n.field-cell--32 {\n color: #f9f6f2;\n background: #f67c5f;\n}\n\n.field-cell--64 {\n color: #f9f6f2;\n background: #f65e3b;\n}\n\n.field-cell--128 {\n color: #f9f6f2;\n background: #edcf72;\n}\n\n.field-cell--256 {\n color: #f9f6f2;\n background: #edcc61;\n}\n\n.field-cell--512 {\n color: #f9f6f2;\n background: #edc850;\n}\n\n.field-cell--1024 {\n color: #f9f6f2;\n background: #edc53f;\n}\n\n.field-cell--2048 {\n color: #f9f6f2;\n background: #edc22e;\n}\n\n.game-field {\n border-spacing: 10px;\n background: #bbada0;\n border-radius: 5px;\n}\n\n.game-header {\n box-sizing: border-box;\n -ms-flex-pack: justify;\n justify-content: space-between;\n width: 100%;\n margin-bottom: 24px;\n padding: 10px;\n display: -ms-flexbox;\n display: flex;\n}\n\nh1 {\n color: #f9f6f2;\n box-sizing: border-box;\n background: #edc22e;\n border-radius: 5px;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-align: center;\n align-items: center;\n width: 75px;\n height: 75px;\n margin: 0;\n font-size: 24px;\n display: -ms-flexbox;\n display: flex;\n}\n\n.info {\n color: #776e65;\n box-sizing: border-box;\n background: #d6cdc4;\n border-radius: 5px;\n -ms-flex-direction: column;\n flex-direction: column;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-align: center;\n align-items: center;\n width: 75px;\n height: 75px;\n margin: 0 8px 0 0;\n font-size: 16px;\n display: -ms-flexbox;\n display: flex;\n}\n\n.controls {\n display: -ms-flexbox;\n display: flex;\n}\n\n.button {\n cursor: pointer;\n color: #f9f6f2;\n border: none;\n border-radius: 5px;\n width: 75px;\n height: 75px;\n font-family: sans-serif;\n font-size: 16px;\n font-weight: 700;\n transition: background .25s;\n}\n\n.start {\n background: #1dae28;\n font-size: 20px;\n}\n\n.start:hover {\n background: #179921;\n}\n\n.restart {\n background: #f1b2b2;\n}\n\n.restart:hover {\n background: #f87474;\n}\n\n.message {\n box-sizing: border-box;\n color: #776e65;\n text-align: center;\n background: #d6cdc4;\n border-radius: 5px;\n width: 100%;\n padding: 10px;\n font-size: 20px;\n}\n\n.hidden {\n display: none;\n}\n\n.container {\n -ms-flex-direction: column;\n flex-direction: column;\n -ms-flex-align: center;\n align-items: center;\n width: 350px;\n display: -ms-flexbox;\n display: flex;\n}\n\n.message-win {\n color: #f9f6f2;\n background: #edc22e;\n}\n\n.message-container {\n width: 100%;\n height: 150px;\n}\n\n/*# sourceMappingURL=index.6910ad39.css.map */\n","body {\n margin: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: #fbf8ef;\n font-family: sans-serif;\n font-size: 24px;\n font-weight: 900;\n}\n\n.field-cell {\n background: #d6cdc4;\n width: 75px;\n height: 75px;\n border-radius: 5px;\n color: #776e65;\n box-sizing: border-box;\n text-align: center;\n vertical-align: center;\n user-select: none;\n\n &--2 {\n background: #eee4da;\n }\n\n &--4 {\n background: #ede0c8;\n }\n\n &--8 {\n background: #f2b179;\n color: #f9f6f2;\n }\n\n &--16 {\n background: #f59563;\n color: #f9f6f2;\n }\n\n &--32 {\n background: #f67c5f;\n color: #f9f6f2;\n }\n\n &--64 {\n background: #f65e3b;\n color: #f9f6f2;\n }\n\n &--128 {\n background: #edcf72;\n color: #f9f6f2;\n }\n\n &--256 {\n background: #edcc61;\n color: #f9f6f2;\n }\n\n &--512 {\n background: #edc850;\n color: #f9f6f2;\n }\n\n &--1024 {\n background: #edc53f;\n color: #f9f6f2;\n }\n\n &--2048 {\n background: #edc22e;\n color: #f9f6f2;\n }\n}\n\n.game-field {\n background: #bbada0;\n border-spacing: 10px;\n border-radius: 5px;\n}\n\n.game-header {\n display: flex;\n width: 100%;\n justify-content: space-between;\n margin-bottom: 24px;\n padding: 10px;\n box-sizing: border-box;\n}\n\nh1 {\n background: #edc22e;\n color: #f9f6f2;\n width: 75px;\n height: 75px;\n font-size: 24px;\n border-radius: 5px;\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n margin: 0;\n}\n\n.info {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background: #d6cdc4;\n width: 75px;\n height: 75px;\n border-radius: 5px;\n color: #776e65;\n box-sizing: border-box;\n font-size: 16px;\n margin: 0 8px 0 0;\n}\n\n.controls {\n display: flex;\n}\n\n.button {\n border: none;\n border-radius: 5px;\n cursor: pointer;\n color: #f9f6f2;\n font-family: sans-serif;\n font-weight: 700;\n font-size: 16px;\n width: 75px;\n height: 75px;\n\n transition: 0.25s ease background;\n}\n\n.start {\n background: #1dae28;\n font-size: 20px;\n\n &:hover {\n background: #179921;\n }\n}\n\n.restart {\n background: #f1b2b2;\n\n &:hover {\n background: #f87474;\n }\n}\n\n.message {\n box-sizing: border-box;\n width: 100%;\n background: #d6cdc4;\n color: #776e65;\n padding: 10px;\n text-align: center;\n border-radius: 5px;\n font-size: 20px;\n}\n\n.hidden {\n display: none;\n}\n\n.container {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 350px;\n}\n\n.message-win {\n background: #edc22e;\n color: #f9f6f2;\n}\n\n.message-container {\n width: 100%;\n height: 150px;\n}\n"],"names":[],"version":3,"file":"index.6910ad39.css.map"} \ No newline at end of file diff --git a/index.971c2ea4.css b/index.971c2ea4.css new file mode 100644 index 000000000..3fe31ab5e --- /dev/null +++ b/index.971c2ea4.css @@ -0,0 +1,189 @@ +body { + background: #fbf8ef; + justify-content: center; + align-items: center; + min-height: 100vh; + margin: 0; + font-family: sans-serif; + font-size: 24px; + font-weight: 900; + display: flex; +} + +.field-cell { + color: #776e65; + box-sizing: border-box; + text-align: center; + vertical-align: center; + -webkit-user-select: none; + user-select: none; + background: #d6cdc4; + border-radius: 5px; + width: 75px; + height: 75px; +} + +.field-cell--2 { + background: #eee4da; +} + +.field-cell--4 { + background: #ede0c8; +} + +.field-cell--8 { + color: #f9f6f2; + background: #f2b179; +} + +.field-cell--16 { + color: #f9f6f2; + background: #f59563; +} + +.field-cell--32 { + color: #f9f6f2; + background: #f67c5f; +} + +.field-cell--64 { + color: #f9f6f2; + background: #f65e3b; +} + +.field-cell--128 { + color: #f9f6f2; + background: #edcf72; +} + +.field-cell--256 { + color: #f9f6f2; + background: #edcc61; +} + +.field-cell--512 { + color: #f9f6f2; + background: #edc850; +} + +.field-cell--1024 { + color: #f9f6f2; + background: #edc53f; +} + +.field-cell--2048 { + color: #f9f6f2; + background: #edc22e; +} + +.game-field { + border-spacing: 10px; + background: #bbada0; + border-radius: 5px; +} + +.game-header { + box-sizing: border-box; + justify-content: space-between; + width: 100%; + margin-bottom: 24px; + padding: 10px; + display: flex; +} + +h1 { + color: #f9f6f2; + box-sizing: border-box; + background: #edc22e; + border-radius: 5px; + justify-content: center; + align-items: center; + width: 75px; + height: 75px; + margin: 0; + font-size: 24px; + display: flex; +} + +.info { + color: #776e65; + box-sizing: border-box; + background: #d6cdc4; + border-radius: 5px; + flex-direction: column; + justify-content: center; + align-items: center; + width: 75px; + height: 75px; + margin: 0 8px 0 0; + font-size: 16px; + display: flex; +} + +.controls { + display: flex; +} + +.button { + cursor: pointer; + color: #f9f6f2; + border: none; + border-radius: 5px; + width: 75px; + height: 75px; + font-family: sans-serif; + font-size: 16px; + font-weight: 700; + transition: background .25s; +} + +.start { + background: #1dae28; + font-size: 20px; +} + +.start:hover { + background: #179921; +} + +.restart { + background: #f1b2b2; +} + +.restart:hover { + background: #f87474; +} + +.message { + box-sizing: border-box; + color: #776e65; + text-align: center; + background: #d6cdc4; + border-radius: 5px; + width: 100%; + padding: 10px; + font-size: 20px; +} + +.hidden { + display: none; +} + +.container { + flex-direction: column; + align-items: center; + width: 350px; + display: flex; +} + +.message-win { + color: #f9f6f2; + background: #edc22e; +} + +.message-container { + width: 100%; + height: 150px; +} + +/*# sourceMappingURL=index.971c2ea4.css.map */ diff --git a/index.971c2ea4.css.map b/index.971c2ea4.css.map new file mode 100644 index 000000000..e797e1bb7 --- /dev/null +++ b/index.971c2ea4.css.map @@ -0,0 +1 @@ +{"mappings":"AAAA;;;;;;;;;;;;AAYA;;;;;;;;;;;;;AAWE;;;;AAIA;;;;AAIA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAMF;;;;;;AAMA;;;;;;;;;AASA;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;AAeA;;;;AAIA;;;;;;;;;;;;;AAcA;;;;;AAIE;;;;AAKF;;;;AAGE;;;;AAKF;;;;;;;;;;;AAWA;;;;AAIA;;;;;;;AAOA;;;;;AAKA","sources":["src/styles/main.scss"],"sourcesContent":["body {\n margin: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: #fbf8ef;\n font-family: sans-serif;\n font-size: 24px;\n font-weight: 900;\n}\n\n.field-cell {\n background: #d6cdc4;\n width: 75px;\n height: 75px;\n border-radius: 5px;\n color: #776e65;\n box-sizing: border-box;\n text-align: center;\n vertical-align: center;\n user-select: none;\n\n &--2 {\n background: #eee4da;\n }\n\n &--4 {\n background: #ede0c8;\n }\n\n &--8 {\n background: #f2b179;\n color: #f9f6f2;\n }\n\n &--16 {\n background: #f59563;\n color: #f9f6f2;\n }\n\n &--32 {\n background: #f67c5f;\n color: #f9f6f2;\n }\n\n &--64 {\n background: #f65e3b;\n color: #f9f6f2;\n }\n\n &--128 {\n background: #edcf72;\n color: #f9f6f2;\n }\n\n &--256 {\n background: #edcc61;\n color: #f9f6f2;\n }\n\n &--512 {\n background: #edc850;\n color: #f9f6f2;\n }\n\n &--1024 {\n background: #edc53f;\n color: #f9f6f2;\n }\n\n &--2048 {\n background: #edc22e;\n color: #f9f6f2;\n }\n}\n\n.game-field {\n background: #bbada0;\n border-spacing: 10px;\n border-radius: 5px;\n}\n\n.game-header {\n display: flex;\n width: 100%;\n justify-content: space-between;\n margin-bottom: 24px;\n padding: 10px;\n box-sizing: border-box;\n}\n\nh1 {\n background: #edc22e;\n color: #f9f6f2;\n width: 75px;\n height: 75px;\n font-size: 24px;\n border-radius: 5px;\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n margin: 0;\n}\n\n.info {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background: #d6cdc4;\n width: 75px;\n height: 75px;\n border-radius: 5px;\n color: #776e65;\n box-sizing: border-box;\n font-size: 16px;\n margin: 0 8px 0 0;\n}\n\n.controls {\n display: flex;\n}\n\n.button {\n border: none;\n border-radius: 5px;\n cursor: pointer;\n color: #f9f6f2;\n font-family: sans-serif;\n font-weight: 700;\n font-size: 16px;\n width: 75px;\n height: 75px;\n\n transition: 0.25s ease background;\n}\n\n.start {\n background: #1dae28;\n font-size: 20px;\n\n &:hover {\n background: #179921;\n }\n}\n\n.restart {\n background: #f1b2b2;\n\n &:hover {\n background: #f87474;\n }\n}\n\n.message {\n box-sizing: border-box;\n width: 100%;\n background: #d6cdc4;\n color: #776e65;\n padding: 10px;\n text-align: center;\n border-radius: 5px;\n font-size: 20px;\n}\n\n.hidden {\n display: none;\n}\n\n.container {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 350px;\n}\n\n.message-win {\n background: #edc22e;\n color: #f9f6f2;\n}\n\n.message-container {\n width: 100%;\n height: 150px;\n}\n"],"names":[],"version":3,"file":"index.971c2ea4.css.map","sourceRoot":"/__parcel_source_root/"} \ No newline at end of file diff --git a/index.b8fca702.js b/index.b8fca702.js new file mode 100644 index 000000000..384fe991a --- /dev/null +++ b/index.b8fca702.js @@ -0,0 +1,957 @@ +// modules are defined as an array +// [ module function, map of requires ] +// +// map of requires is short require name -> numeric require +// +// anything defined in a previous bundle is accessed via the +// orig method which is the require for previous bundles + +(function (modules, entry, mainEntry, parcelRequireName, globalName) { + /* eslint-disable no-undef */ + var globalObject = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : {}; + /* eslint-enable no-undef */ + + // Save the require from previous bundle to this closure if any + var previousRequire = + typeof globalObject[parcelRequireName] === 'function' && + globalObject[parcelRequireName]; + + var cache = previousRequire.cache || {}; + // Do not use `require` to prevent Webpack from trying to bundle this call + var nodeRequire = + typeof module !== 'undefined' && + typeof module.require === 'function' && + module.require.bind(module); + + function newRequire(name, jumped) { + if (!cache[name]) { + if (!modules[name]) { + // if we cannot find the module within our internal map or + // cache jump to the current global require ie. the last bundle + // that was added to the page. + var currentRequire = + typeof globalObject[parcelRequireName] === 'function' && + globalObject[parcelRequireName]; + if (!jumped && currentRequire) { + return currentRequire(name, true); + } + + // If there are other bundles on this page the require from the + // previous one is saved to 'previousRequire'. Repeat this as + // many times as there are bundles until the module is found or + // we exhaust the require chain. + if (previousRequire) { + return previousRequire(name, true); + } + + // Try the node require function if it exists. + if (nodeRequire && typeof name === 'string') { + return nodeRequire(name); + } + + var err = new Error("Cannot find module '" + name + "'"); + err.code = 'MODULE_NOT_FOUND'; + throw err; + } + + localRequire.resolve = resolve; + localRequire.cache = {}; + + var module = (cache[name] = new newRequire.Module(name)); + + modules[name][0].call( + module.exports, + localRequire, + module, + module.exports, + this + ); + } + + return cache[name].exports; + + function localRequire(x) { + var res = localRequire.resolve(x); + return res === false ? {} : newRequire(res); + } + + function resolve(x) { + var id = modules[name][1][x]; + return id != null ? id : x; + } + } + + function Module(moduleName) { + this.id = moduleName; + this.bundle = newRequire; + this.exports = {}; + } + + newRequire.isParcelRequire = true; + newRequire.Module = Module; + newRequire.modules = modules; + newRequire.cache = cache; + newRequire.parent = previousRequire; + newRequire.register = function (id, exports) { + modules[id] = [ + function (require, module) { + module.exports = exports; + }, + {}, + ]; + }; + + Object.defineProperty(newRequire, 'root', { + get: function () { + return globalObject[parcelRequireName]; + }, + }); + + globalObject[parcelRequireName] = newRequire; + + for (var i = 0; i < entry.length; i++) { + newRequire(entry[i]); + } + + if (mainEntry) { + // Expose entry point to Node, AMD or browser globals + // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js + var mainExports = newRequire(mainEntry); + + // CommonJS + if (typeof exports === 'object' && typeof module !== 'undefined') { + module.exports = mainExports; + + // RequireJS + } else if (typeof define === 'function' && define.amd) { + define(function () { + return mainExports; + }); + + // \ No newline at end of file