{"version":3,"sources":["data/gridData.js","Grid.jsx","Calculate.jsx","App.js","serviceWorker.js","index.js"],"names":["voidLavaSquares","gateSquares","Row","array","rowKey","map","square","idx","key","className","Rows","grid","row","Grid","props","Calculate","setGrid","setVisited","thisGrid","onClick","visited","length","rows","columns","data","forEach","coords","split","x","parseFloat","y","boundaryDFS","push","App","useState","href","target","Fragment","temp","i","ii","gridValue","Math","round","random","includes","JSON","stringify","Boolean","window","location","hostname","match","ReactDOM","render","document","getElementById","navigator","serviceWorker","ready","then","registration","unregister","catch","error","console","message"],"mappings":"0PAEaA,G,MAAkB,CAC7B,MACA,MACA,OACA,OACA,MACA,MACA,QAGWC,EAAc,CAAC,MAAO,MAAO,MAAO,MAAO,OAAQ,MAAO,OCFjEC,EAAM,SAAC,GAAuB,IAArBC,EAAoB,EAApBA,MAAOC,EAAa,EAAbA,OAQpB,OAPYD,EAAME,KAAI,SAACC,EAAQC,GAC7B,OACE,yBAAKC,IAAG,UAAKJ,EAAL,YAAeG,GAAOE,UAAS,iBAAYH,IAChDA,OAaHI,EAAO,SAAC,GASZ,OATyB,EAAXC,KACIN,KAAI,SAACO,EAAKL,GAC1B,IAAMC,EAAMD,EACZ,OACE,yBAAKC,IAAKA,GACR,kBAAC,EAAD,CAAKL,MAAOS,EAAKR,OAAQI,SAqBlBK,EATF,SAAAC,GAAU,IACbH,EAASG,EAATH,KACR,OACE,6BACE,kBAAC,EAAD,CAAMA,KAAMA,M,OC2CHI,EA/EG,SAAAD,GAAU,IAClBH,EAA8BG,EAA9BH,KAAMK,EAAwBF,EAAxBE,QAASC,EAAeH,EAAfG,WAEjBC,EAAQ,YAAOP,GAqErB,OACE,6BACE,4BAAQQ,QAhCU,WACpB,IAAMC,EAAU,GAChB,GAAyB,KAApBF,EAASG,QAAiBH,EAAS,GAAGG,OAA3C,CAGA,IAAIC,EAAOJ,EAASG,OAChBE,EAAUL,EAAS,GAAGG,OAE1BG,EAAiBC,SAAQ,SAAAnB,GACvB,IAAMoB,EA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CzB,GACC,kBAAC,IAAM0B,SAAP,KACE,kBAAC,EAAD,CAAM1B,KAAMA,IACZ,kBAAC,EAAD,CAAWA,KAAMA,EAAMK,QAASA,EAASC,WAAYA,KAGzD,4BAAQE,QAjCO,WACjB,IAAMmB,EAAO,GACbrB,EAAW,MACX,IAAK,IAAIsB,EAAI,EAAGA,EAAI,EAAGA,GAAK,EAAG,CAE7B,IADA,IAAM3B,EAAM,GACH4B,EAAK,EAAGA,EAAK,GAAIA,GAAM,EAAG,CACjC,IAAIC,EAAYC,KAAKC,MAAMD,KAAKE,UAAY,IAAM,IAC9CpB,EAAqBqB,SAArB,UAAiCN,EAAjC,YAAsCC,MACxCC,EAAY,KAEI,MAAdA,GAAqBjB,EAAiBqB,SAAjB,UAA6BN,EAA7B,YAAkCC,MACzDC,EAAY,KAEd7B,EAAIoB,KAAKS,GAEXH,EAAKN,KAAKpB,GAEZI,EAAQsB,KAgBN,YACA,6BAAMQ,KAAKC,UAAU3B,MC/CP4B,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,2DCZNC,IAASC,OAAO,kBAAC,EAAD,MAASC,SAASC,eAAe,SD6H3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MACrBC,MAAK,SAAAC,GACJA,EAAaC,gBAEdC,OAAM,SAAAC,GACLC,QAAQD,MAAMA,EAAME,c","file":"static/js/main.cc544d55.chunk.js","sourcesContent":["/** @module gridData */\r\n\r\nexport const voidLavaSquares = [\r\n \"0_8\",\r\n \"0_9\",\r\n \"0_10\",\r\n \"1_10\",\r\n \"6_0\",\r\n \"6_1\",\r\n \"6_2\"\r\n];\r\n\r\nexport const gateSquares = [\"0_0\", \"0_5\", \"1_9\", \"4_0\", \"4_10\", \"6_6\", \"6_8\"];\r\n","/** @module Grid */\r\n\r\nimport React from \"react\";\r\n\r\n/**\r\n * @function Row\r\n * @description returns Row\r\n * @param {Object} props\r\n * @returns {React.Component}\r\n */\r\nconst Row = ({ array, rowKey }) => {\r\n const row = array.map((square, idx) => {\r\n return (\r\n
\r\n {square}\r\n
\r\n );\r\n });\r\n return row;\r\n};\r\n\r\n/**\r\n * @function Rows\r\n * @description returns Rows (Grid)\r\n * @param {Object} props\r\n * @returns {React.Component}\r\n */\r\nconst Rows = ({ grid }) => {\r\n const rows = grid.map((row, idx) => {\r\n const key = idx;\r\n return (\r\n
\r\n \r\n
\r\n );\r\n });\r\n return rows;\r\n};\r\n\r\n/**\r\n * @function Grid\r\n * @description Presentational Component that converts grid array to visual grid\r\n * @param {Object} props\r\n */\r\nconst Grid = props => {\r\n const { grid } = props;\r\n return (\r\n
\r\n \r\n
\r\n );\r\n};\r\n\r\nexport default Grid;\r\n","/** @module Calculate */\r\n\r\nimport React from \"react\";\r\n\r\nimport * as data from \"./data/gridData\";\r\n\r\n/**\r\n * @function Calculate\r\n * @description Component with logic for determining which open spaces are ot be covered in lava\r\n * @param {Object} props \r\n * @returns {React.Component}\r\n */\r\nconst Calculate = props => {\r\n const { grid, setGrid, setVisited } = props;\r\n\r\n const thisGrid = [...grid];\r\n\r\n /**\r\n * @function boundardDFS\r\n * @description recursive DFS helper function that converts all squared touching an exit to \"*\"\r\n * @param {Array} thisGrid - copy of source grid array\r\n * @param {Number} x - coordinate\r\n * @param {Number} y - coordinate\r\n */\r\n const boundaryDFS = (thisGrid, x, y) => {\r\n if (x > thisGrid.length - 1 || x < 0 || y > thisGrid[0].length || y < 0)\r\n return;\r\n\r\n if (thisGrid[x][y] === \"O\") thisGrid[x][y] = \"*\";\r\n\r\n if (x > 0 && thisGrid[x - 1][y] === \"O\") {\r\n boundaryDFS(thisGrid, x - 1, y);\r\n }\r\n\r\n if (x < thisGrid.length - 1 && thisGrid[x + 1][y] === \"O\") {\r\n boundaryDFS(thisGrid, x + 1, y);\r\n }\r\n\r\n if (y > 0 && thisGrid[x][y - 1] === \"O\") {\r\n boundaryDFS(thisGrid, x, y - 1);\r\n }\r\n\r\n if (x < thisGrid[0].length - 1 && thisGrid[x][y + 1] === \"O\") {\r\n boundaryDFS(thisGrid, x, y + 1);\r\n }\r\n\r\n return;\r\n };\r\n\r\n /**\r\n * @function convertToLava\r\n * @description loops through exits, applies boundaryDFS recursive function to each, then converts\r\n * untouched open squares to lava\r\n */\r\n const convertToLava = () => {\r\n const visited = [];\r\n if (!thisGrid.length === 0 || !thisGrid[0].length) {\r\n return;\r\n }\r\n let rows = thisGrid.length;\r\n let columns = thisGrid[0].length;\r\n\r\n data.gateSquares.forEach(square => {\r\n const coords = square.split(\"_\");\r\n const x = parseFloat(coords[0]);\r\n const y = parseFloat(coords[1]);\r\n\r\n if (thisGrid[x][y] === \"X\") boundaryDFS(thisGrid, x, y);\r\n });\r\n\r\n for (let x = 0; x < rows; x += 1) {\r\n for (let y = 0; y < columns; y += 1) {\r\n if (thisGrid[x][y] === \"O\") {\r\n thisGrid[x][y] = \"L\";\r\n visited.push(`${x}_${y}`);\r\n } else if (thisGrid[x][y] === \"*\") {\r\n thisGrid[x][y] = \"O\";\r\n }\r\n }\r\n }\r\n setGrid(thisGrid);\r\n setVisited(visited);\r\n };\r\n\r\n return (\r\n
\r\n \r\n
\r\n );\r\n};\r\n\r\nexport default Calculate;\r\n","/** @module App */\n\nimport React, { useState } from \"react\";\nimport \"./App.css\";\n\nimport * as data from \"./data/gridData\";\n\nimport Grid from \"./Grid\";\nimport Calculate from \"./Calculate\";\n\n/**\n * @function App\n * @description Functional Component for Island Problem app\n * @returns {React.Component}\n */\nfunction App() {\n const [grid, setGrid] = useState(null);\n const [visited, setVisited] = useState(null);\n\n /**\n * @function createGrid\n * @description generates 11 by 7 grid, each square is either open (\"O\") or lava (\"L\") 50/50\n * Some corner squares (that don't exist in the Pompeii board) are skipped, and open exits are also\n * changed to \"X\"\n */\n const createGrid = () => {\n const temp = [];\n setVisited(null);\n for (let i = 0; i < 7; i += 1) {\n const row = [];\n for (let ii = 0; ii < 11; ii += 1) {\n let gridValue = Math.round(Math.random()) ? \"L\" : \"O\";\n if (data.voidLavaSquares.includes(`${i}_${ii}`)) {\n gridValue = \"W\";\n }\n if (gridValue === \"O\" && data.gateSquares.includes(`${i}_${ii}`)) {\n gridValue = \"X\";\n }\n row.push(gridValue);\n }\n temp.push(row);\n }\n setGrid(temp);\n };\n\n return (\n
\n
\n rbr.com\n GitHub\n
\n

Surrounded By Lava

\n {grid && (\n \n \n \n \n )}\n \n
{JSON.stringify(visited)}
\n
\n );\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' }\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then(registration => {\n registration.unregister();\n })\n .catch(error => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(, document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""}