{"version":3,"sources":["App.js","serviceWorker.js","index.js"],"names":["videoConstraints","width","height","codes","nameToCamvidTags","Map","nameToCamvidIdxs","Array","from","map","friendly","strings","Set","s","indexOf","camvidIdxsToName","App","props","state","originalPicture","processedPicture","categories","get","facingMode","webcamref","React","createRef","INFERENCE_ENDPOINT","this","join","handleWebcam","current","getScreenshot","screenshot","ingestPicture","console","log","requestAnimationFrame","startDate","Date","now","setState","formdata","FormData","append","dataURLToBlob","parameterizedEndpoint","parameterizeEndpoint","fetch","method","body","redaction","blob","redactedBlob","endDate","URL","createObjectURL","millis","checked","i","newcats","add","delete","className","id","onChange","e","target","value","src","has","justChoseDIY","keys","k","type","toggleCode","audio","ref","screenshotFormat","Component","Boolean","window","location","hostname","match","ReactDOM","render","StrictMode","document","getElementById","navigator","serviceWorker","ready","then","registration","unregister","catch","error","message"],"mappings":"+VAQMA,EAAmB,CACvBC,MAAO,IACPC,OAAQ,KAGJC,EAAQ,CAAC,SAAU,UAAW,YAAa,SAAU,WAAY,MAAO,kBAAmB,QAAS,cAAe,QAAS,eAAgB,kBAAmB,YAAa,oBAAqB,cAAe,eAAgB,aAAc,OAAQ,eAAgB,WAAY,aAAc,MAAO,iBAAkB,cAAe,eAAgB,QAAS,OAAQ,YAAa,SAAU,iBAAkB,OAAQ,QAE1ZC,EAAmB,IAAIC,IAAI,CAC/B,CAAC,iCAAkC,CAAC,YAAa,QAAS,oBAAqB,aAAc,YAAY,SACzG,CAAC,WAAY,CAAC,MAAO,mBACrB,CAAC,mBAAoB,CAAC,MAAO,OAAQ,mBACrC,CAAC,oBAAqB,CAAC,WAGnBC,EAAmB,IAAID,IAC3BE,MAAMC,KAAKJ,GAAkBK,KAAI,mCAAEC,EAAF,KAAYC,EAAZ,WAAyB,CAACD,EAAU,IAAIE,IAAID,EAAQF,KAAI,SAAAI,GAAC,OAAIV,EAAMW,QAAQD,YAGxGE,EAAmB,IAAIV,IAC3BE,MAAMC,KAAKF,GAAkBG,KAAI,mCAAEC,EAA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,eAAMA,EAAN,CAAwBuB,sB,GA1F9BE,IAAMsD,WClBJC,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,2DCZNC,IAASC,OACP,kBAAC,IAAMC,WAAP,KACE,kBAAC,EAAD,OAEFC,SAASC,eAAe,SDyHpB,kBAAmBC,WACrBA,UAAUC,cAAcC,MACrBC,MAAK,SAAAC,GACJA,EAAaC,gBAEdC,OAAM,SAAAC,GACL9D,QAAQ8D,MAAMA,EAAMC,c","file":"static/js/main.3947f957.chunk.js","sourcesContent":["import React from 'react';\nimport './App.css';\nimport Webcam from 'react-webcam';\nimport { dataURLToBlob } from 'blob-util';\n\nconst INFERENCE_ENDPOINT = \"https://redacting-camera.onrender.com/redact\"\n// const INFERENCE_ENDPOINT = \"https://94607.leebutterman.com/redact\"\n\nconst videoConstraints = {\n width: 300,\n height: 300,\n};\n\nconst codes = ['Animal', 'Archway', 'Bicyclist', 'Bridge', 'Building', 'Car', 'CartLuggagePram', 'Child', 'Column_Pole', 'Fence', 'LaneMkgsDriv', 'LaneMkgsNonDriv', 'Misc_Text', 'MotorcycleScooter', 'OtherMoving', 'ParkingBlock', 'Pedestrian', 'Road', 'RoadShoulder', 'Sidewalk', 'SignSymbol', 'Sky', 'SUVPickupTruck', 'TrafficCone', 'TrafficLight', 'Train', 'Tree', 'Truck_Bus', 'Tunnel', 'VegetationMisc', 'Void', 'Wall'];\n\nconst nameToCamvidTags = new Map([\n [\"no people (for street rallies)\", ['Bicyclist', 'Child', 'MotorcycleScooter', 'Pedestrian', 'Truck_Bus','Void']],\n ['ban cars', ['Car', 'SUVPickupTruck']],\n ['no sky, no trees', ['Sky', 'Tree', 'VegetationMisc']],\n ['nothing uncertain', ['Void']],\n]);\n\nconst nameToCamvidIdxs = new Map(\n Array.from(nameToCamvidTags).map(([friendly, strings]) => [friendly, new Set(strings.map(s => codes.indexOf(s)))] )\n);\n\nconst camvidIdxsToName = new Map(\n Array.from(nameToCamvidIdxs).map(([friendly, idxs]) => [idxs, friendly])\n);\n\nclass App extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n originalPicture: null,\n processedPicture: null,\n categories: nameToCamvidIdxs.get('no people (for street rallies)'),\n facingMode: \"environment\",\n };\n this.webcamref = React.createRef();\n }\n parameterizeEndpoint() {\n return INFERENCE_ENDPOINT + \"?categories=\" + Array.from(this.state.categories).join(',');\n }\n componentDidMount() {\n this.handleWebcam();\n }\n handleWebcam() {\n if(this.webcamref && this.webcamref.current && this.webcamref.current.getScreenshot) {\n const screenshot = this.webcamref.current.getScreenshot();\n if (screenshot !== null) {\n this.ingestPicture(screenshot);\n } else {\n console.log('screenshot is null, might be still loading');\n requestAnimationFrame(() => this.handleWebcam());\n\n }\n }\n }\n async ingestPicture(originalPicture) {\n const startDate = Date.now();\n const firstPicture = this.state.originalPicture === null && this.state.processedPicture === null;\n if (firstPicture) { this.setState({processedPicture: originalPicture})}\n this.setState({originalPicture});\n const formdata = new FormData();\n formdata.append('image', dataURLToBlob(originalPicture));\n const parameterizedEndpoint = this.parameterizeEndpoint();\n const redaction = await fetch(parameterizedEndpoint, {\n method: \"POST\",\n body: formdata,\n });\n const redactedBlob = await redaction.blob();\n const endDate = Date.now();\n requestAnimationFrame(() => this.handleWebcam());\n this.setState({processedPicture: URL.createObjectURL(redactedBlob), millis: endDate-startDate});\n }\n toggleCode({checked, i}) {\n const newcats = new Set(this.state.categories);\n checked ? newcats.add(i) : newcats.delete(i);\n this.setState({categories: newcats});\n }\n render() {\n const {processedPicture, millis, facingMode, categories} = this.state;\n return
\n

Redacting Camera

\n

\n via your  webcam!\n

\n
{millis}
\n
\n \n \n \n
\n
\n
how to redact‽
\n
\n !nameToCamvidIdxs.has(e.target.value) ? this.setState({justChoseDIY: true}) : this.setState({categories: nameToCamvidIdxs.get(e.target.value), justChoseDIY: false})}\n value={this.state.justChoseDIY || !camvidIdxsToName.has(this.state.categories) ? 'diy' : camvidIdxsToName.get(this.state.categories)}\n >\n {Array.from(nameToCamvidIdxs.keys()).map(k => ( ))}\n \n \n
\n
\n {codes.map((e,i) => () )}\n
\n
\n \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(\n \n \n ,\n document.getElementById('root')\n);\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":""}