{"version":3,"sources":["App.tsx","index.tsx"],"names":["useStyles","makeStyles","theme","appBar","position","layout","width","marginLeft","spacing","marginRight","breakpoints","up","paper","marginTop","marginBottom","padding","stepper","buttons","display","justifyContent","button","AppState","selectedFiles","fileStates","isProcessing","id2Offset","offset2Id","this","Map","App","useState","state","setState","apiRoot","window","location","host","protocol","ws","WebSocket","processPDF","fileObj","fileOffset","a","formData","FormData","append","axios","post","headers","uploadResult","set","data","send","JSON","stringify","event","i","length","onmessage","msg","evt","parse","console","log","newStatus","step","status","offset","get","job_id","undefined","stillProcessing","classes","className","Paper","Typography","component","variant","align","LinearProgress","FormGroup","disabled","style","id","multiple","type","onChange","target","files","file","item","push","htmlFor","Button","color","Grid","List","map","idx","ListItem","secondaryAction","CircularProgress","IconButton","edge","aria-label","onClick","open","Download","ListItemAvatar","ListItemText","primary","name","secondary","ReactDOM","render","StrictMode","document","getElementById"],"mappings":"6YASMA,EAAkBC,aAAW,SAACC,GAAD,MAAiB,CAClDC,OAAQ,CACNC,SAAU,YAEZC,OAAO,aACLC,MAAO,OACPC,WAAYL,EAAMM,QAAQ,GAC1BC,YAAaP,EAAMM,QAAQ,IAC1BN,EAAMQ,YAAYC,GAAG,IAAyB,EAAnBT,EAAMM,QAAQ,IAAU,CAClDF,MAAO,IACPC,WAAY,OACZE,YAAa,SAGjBG,MAAM,aACJC,UAAWX,EAAMM,QAAQ,GACzBM,aAAcZ,EAAMM,QAAQ,GAC5BO,QAASb,EAAMM,QAAQ,IACtBN,EAAMQ,YAAYC,GAAG,IAAyB,EAAnBT,EAAMM,QAAQ,IAAU,CAClDK,UAAWX,EAAMM,QAAQ,GACzBM,aAAcZ,EAAMM,QAAQ,GAC5BO,QAASb,EAAMM,QAAQ,KAG3BQ,QAAS,CACPD,QAASb,EAAMM,QAAQ,EAAG,EAAG,IAE/BS,QAAS,CACPC,QAAS,OACTC,eAAgB,YAElBC,OAAQ,CACNP,UAAWX,EAAMM,QAAQ,GACzBD,WAAYL,EAAMM,Q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AAM,YAAYjB,QAAQ,YAAY4B,QA3KzE,4CA2KH,8BAEE,WC5OdQ,IAASC,OACP,cAAC,IAAMC,WAAP,UACE,cAAC,EAAD,MAEFC,SAASC,eAAe,U","file":"static/js/main.e82c8351.chunk.js","sourcesContent":["import React, { ChangeEvent, useState } from 'react';\nimport './App.css';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { Button, CircularProgress, FormGroup, Grid, List, ListItem, ListItemAvatar, ListItemText, Paper, Typography } from '@mui/material';\nimport DescriptionIcon from '@mui/icons-material/Description';\nimport { IconButton, LinearProgress } from '@material-ui/core';\nimport axios, { AxiosResponse } from 'axios';\nimport { Download as DownloadIcon } from '@mui/icons-material';\n\nconst useStyles : any = makeStyles((theme: any) => ({\n appBar: {\n position: 'relative',\n },\n layout: {\n width: 'auto',\n marginLeft: theme.spacing(2),\n marginRight: theme.spacing(2),\n [theme.breakpoints.up(600 + theme.spacing(2) * 2)]: {\n width: 600,\n marginLeft: 'auto',\n marginRight: 'auto',\n },\n },\n paper: {\n marginTop: theme.spacing(3),\n marginBottom: theme.spacing(3),\n padding: theme.spacing(2),\n [theme.breakpoints.up(600 + theme.spacing(3) * 2)]: {\n marginTop: theme.spacing(6),\n marginBottom: theme.spacing(6),\n padding: theme.spacing(3),\n },\n },\n stepper: {\n padding: theme.spacing(3, 0, 5),\n },\n buttons: {\n display: 'flex',\n justifyContent: 'flex-end',\n },\n button: {\n marginTop: theme.spacing(3),\n marginLeft: theme.spacing(1),\n },\n}));\n\nclass AppState{\n selectedFiles?: Array\n fileStates: Array\n isProcessing: boolean\n id2Offset: Map\n offset2Id: Map\n\n constructor(){\n this.fileStates = [];\n this.isProcessing = false;\n this.id2Offset = new Map();\n this.offset2Id = new Map();\n }\n}\n\ninterface SapientaEvent {\n step: string\n status: string\n job_id: string\n}\n\n\nfunction App() {\n\n const [state, setState] = useState(new AppState());\n\n const apiRoot = (window.location.host === \"localhost:3000\") ? \"localhost:8000\" : window.location.host;\n\n const protocol = window.location.protocol === \"http:\" ? \"ws:\" : \"wss:\";\n\n const ws = new WebSocket(`${protocol}//${apiRoot}/ws`);\n\n ws.onmessage = (msg) => {\n let evt: SapientaEvent = JSON.parse(msg.data);\n console.log(evt);\n\n\n let newStatus = \"\";\n \n\n if ((evt.step === \"convert_pdf\") && (evt.status===\"complete\")){\n newStatus = \"Splitting Sentences\";\n }\n\n else if ((evt.step === \"split\") && (evt.status===\"complete\")){\n newStatus = \"Annotating Sentences\";\n }\n\n else if ((evt.step === \"annotate\") && (evt.status===\"complete\")){\n newStatus = \"Complete\";\n }\n\n\n let offset = state.id2Offset.get(evt.job_id);\n\n if (offset !== undefined) {\n state.fileStates[offset] = newStatus;\n\n var stillProcessing = false;\n\n for(var i=0; i < state.fileStates.length; i++){\n if (state.fileStates[i] !== \"Complete\"){\n stillProcessing = true;\n }\n }\n\n state.isProcessing = stillProcessing;\n\n setState({...state})\n }\n }\n \n function onFileChange(event: ChangeEvent){\n if (event.target.files !== null){\n var selectedFiles = [];\n var fileStates = [];\n\n for(var i=0; i = await axios.post(`//${apiRoot}/submit`, formData,{\n headers: {\"Content-Type\": \"multipart/form-data\"}\n });\n\n state.fileStates[fileOffset] = \"Processing...\";\n state.id2Offset.set(uploadResult.data[\"job_id\"], fileOffset);\n state.offset2Id.set(fileOffset, uploadResult.data[\"job_id\"]);\n\n setState({...state});\n\n ws.send(JSON.stringify({\"action\":\"subscribe\", \"job_id\":uploadResult.data[\"job_id\"]}))\n \n }\n\n async function onUploadFiles(event: React.MouseEvent) {\n\n if(!state.selectedFiles){\n return;\n }\n\n state.isProcessing = true;\n\n \n setState({...state});\n\n for(var i=0; i)\n } else if (state.fileStates[fileOffset] === \"Complete\") {\n return ({window.open(`//${apiRoot}/${state.offset2Id.get(fileOffset)}/result`, \"_blank\")}}>\n \n )\n }\n\n }\n\n return (\n
\n\n
\n \n \n SAPIENTA: Annotate Papers\n \n\n \n\n {(state.isProcessing ?

Processing...

:

Please select one or more scientific papers to annotate.

)}\n\n

 

\n\n \n \n \n \n\n {(state.selectedFiles != null && state.selectedFiles.length > 0) ? (\n \n \n {state.selectedFiles?.map((file, idx) => (\n \n \n \n \n ) )}\n \n \n \n ) : \"\" }\n
\n
\n\n
\n );\n}\n\nexport default App;\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n"],"sourceRoot":""}