{"version":3,"sources":["Constants.js","FormValueChangeHandler.js","VwError.js","VwLoading.js","VwInput.js","VwForgotCreds.js","VwValidateEmail.js","Api.js","App.js","serviceWorker.js","index.js"],"names":["Constants","VwInput","VwError","VwLoading","VwForgotCreds","VwValidateEmail","VwDisplay","StMsciAccountCreationAppState","FormValueChangeHandler","component","statePropName","e","newState","target","value","setState","className","this","props","Message","Button","variant","onClick","OnTryAgainClick","block","React","Component","state","ActiveView","ErrorMessage","Email","ReturnTo","onSubmit","bind","onSubmitClick","onErrorTryAgainClick","handleAccountFound","returnTo","URLSearchParams","window","location","search","get","Form","Group","Label","Control","type","onChange","Text","preventDefault","Api","EmailLookup","then","data","console","info","length","found","username","SetActiveViewForApp","UpdateNewAccountData","ImisId","imis_id","SendEmailValidation","catch","err","message","onDoneClick","rel","href","apiKey","apiUrl","headers","email","url","trim","req","Request","method","fetch","response","ok","json","status","statusText","error","Error","returnToUrl","validationBaseUrl","JSON","stringify","body","App","NewAccountData","SetAndPersistAppState","newAcctData","existing","Object","assign","updated","store","set","viewName","Boolean","hostname","match","ReactDOM","render","StrictMode","document","getElementById","navigator","serviceWorker","ready","registration","unregister"],"mappings":"wSASeA,EATC,CACZC,QAAS,QACTC,QAAS,QACTC,UAAW,UACXC,cAAe,eACfC,gBAAiB,iBACjBC,UAAW,UACXC,8BAA+B,2C,gBCCpBC,MARf,SAAgCC,EAAWC,GACvC,OAAO,SAACC,GACJ,IAAIC,EAAW,GACfA,EAASF,GAAiBC,EAAEE,OAAOC,MACnCL,EAAUM,SAASH,KCcZV,E,uKAXP,OACI,yBAAKc,UAAU,mBACX,2BAAIC,KAAKC,MAAMC,SACf,6BACA,kBAACC,EAAA,EAAD,CAAQC,QAAQ,kBAAkBC,QAASL,KAAKC,MAAMK,gBAAiBC,OAAK,GAA5E,kB,GAPMC,IAAMC,WCWbvB,E,uKATP,OACI,yBAAKa,UAAU,qBACX,8E,GALQS,IAAMC,WC6HfzB,E,kDAtHX,WAAYiB,GAAQ,IA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OACP,kBAAC,IAAMC,WAAP,KACE,kBAAC,EAAD,OAEFC,SAASC,eAAe,SDyHpB,kBAAmBC,WACrBA,UAAUC,cAAcC,MACrB7D,MAAK,SAAA8D,GACJA,EAAaC,gBAEdnD,OAAM,SAAAqB,GACL/B,QAAQ+B,MAAMA,EAAMnB,c","file":"static/js/main.a606ffe3.chunk.js","sourcesContent":["var Constants = {\r\n VwInput: \"INPUT\",\r\n VwError: \"ERROR\",\r\n VwLoading: \"LOADING\",\r\n VwForgotCreds: \"FORGOT_CREDS\", // if the email exists and has account creds display this\r\n VwValidateEmail: \"VALIDATE_EMAIL\", // else display this\r\n VwDisplay: \"DISPLAY\",\r\n StMsciAccountCreationAppState: \"MSCI.ACCOUNT_CREATION_APP.STEP_01.STATE\"\r\n}\r\nexport default Constants;\r\n","function FormValueChangeHandler(component, statePropName) {\r\n return (e) => {\r\n var newState = {};\r\n newState[statePropName] = e.target.value;\r\n component.setState(newState);\r\n };\r\n}\r\n\r\nexport default FormValueChangeHandler;","import React from 'react';\r\nimport Button from 'react-bootstrap/Button';\r\n\r\n\r\nclass VwError extends React.Component {\r\n\r\n render() {\r\n return (\r\n
\r\n

{this.props.Message}

\r\n

\r\n \r\n
\r\n );\r\n }\r\n\r\n}\r\n\r\nexport default VwError;\r\n","import React from 'react';\r\n\r\n\r\nclass VwLoading extends React.Component {\r\n\r\n render() {\r\n return (\r\n
\r\n

Please wait while we process your request.

\r\n
\r\n );\r\n }\r\n\r\n}\r\n\r\nexport default VwLoading;\r\n","import React from 'react';\r\nimport Button from 'react-bootstrap/Button';\r\nimport Form from 'react-bootstrap/Form';\r\nimport Constants from './Constants';\r\nimport FormValueChangeHandler from './FormValueChangeHandler';\r\nimport VwError from './VwError';\r\nimport VwLoading from './VwLoading';\r\n\r\n\r\nclass VwInput extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n ActiveView: Constants.VwInput,\r\n ErrorMessage: \"\",\r\n Email: \"\",\r\n ReturnTo: \"\"\r\n };\r\n this.onSubmit = this.onSubmit.bind(this);\r\n this.onSubmitClick = this.onSubmitClick.bind(this);\r\n this.onErrorTryAgainClick = this.onErrorTryAgainClick.bind(this);\r\n this.handleAccountFound = this.handleAccountFound.bind(this);\r\n }\r\n\r\n componentDidMount() {\r\n var queryParams = new URLSearchParams(window.location.search);\r\n var returnTo = queryParams.get(\"return_to\");\r\n if (returnTo) {\r\n this.setState({\r\n ReturnTo: returnTo\r\n });\r\n }\r\n }\r\n\r\n render() {\r\n switch (this.state.ActiveView) {\r\n case Constants.VwInput:\r\n return (\r\n
\r\n
\r\n \r\n Email\r\n \r\n Please use a work email address.\r\n \r\n \r\n
\r\n
\r\n );\r\n case Constants.VwLoading:\r\n return ;\r\n default:\r\n return \r\n }\r\n\r\n }\r\n\r\n onSubmit(e) {\r\n e.preventDefault();\r\n this.onSubmitClick();\r\n }\r\n\r\n onSubmitClick() {\r\n if (this.state.Email === \"\") {\r\n return;\r\n }\r\n this.setState({\r\n ActiveView: Constants.VwLoading\r\n });\r\n this.props.Api.EmailLookup(this.state.Email).then(data => {\r\n console.info(data);\r\n // we found an email in our system\r\n if (data.length > 0) {\r\n var found = data[0];\r\n // the found email also has a username...so instruct the user to recover their creds\r\n if (found.username) {\r\n this.props.SetActiveViewForApp(Constants.VwForgotCreds);\r\n return;\r\n }\r\n // the found email does not have a username...so we send them through the validation flow\r\n // we will stash the imis_id for later, because this person will only need to create a username and password\r\n this.props.UpdateNewAccountData({\r\n Email: this.state.Email,\r\n ImisId: found.imis_id\r\n });\r\n this.props.Api.SendEmailValidation(this.state.Email).then(data => {\r\n console.info(data);\r\n this.props.SetActiveViewForApp(Constants.VwValidateEmail);\r\n }).catch(err => {\r\n this.setState({\r\n ErrorMessage: err.message,\r\n ActiveView: Constants.VwError\r\n });\r\n });\r\n return;\r\n }\r\n\r\n // we did not find an email in our system...so we send them through the validation flow\r\n this.props.Api.SendEmailValidation(this.state.Email, this.state.ReturnTo).then(data => {\r\n console.info(data);\r\n this.props.SetActiveViewForApp(Constants.VwValidateEmail);\r\n }).catch(err => {\r\n this.setState({\r\n ErrorMessage: err.message,\r\n ActiveView: Constants.VwError\r\n });\r\n });\r\n }).catch(err => {\r\n this.setState({\r\n ErrorMessage: err.message,\r\n ActiveView: Constants.VwError\r\n });\r\n });\r\n }\r\n\r\n onErrorTryAgainClick() {\r\n this.setState({\r\n ActiveView: Constants.VwInput,\r\n ErrorMessage: \"\",\r\n Email: \"\"\r\n });\r\n }\r\n\r\n handleAccountFound() {\r\n this.props.SetActiveViewForApp(Constants.VwForgotCreds);\r\n }\r\n}\r\n\r\nexport default VwInput;\r\n","import React from 'react';\r\nimport Button from 'react-bootstrap/Button';\r\nimport Constants from './Constants';\r\n\r\n\r\nclass VwForgotCreds extends React.Component {\r\n\r\n constructor(props) {\r\n super(props);\r\n this.onDoneClick = this.onDoneClick.bind(this);\r\n }\r\n\r\n render() {\r\n return (\r\n
\r\n

Hello again!

\r\n

We found an existing account for this email. Click here to recover your username and/or password.

\r\n

\r\n \r\n
\r\n );\r\n }\r\n\r\n onDoneClick() {\r\n this.props.SetActiveViewForApp(Constants.VwInput);\r\n }\r\n}\r\n\r\nexport default VwForgotCreds;\r\n","import React from 'react';\r\nimport Button from 'react-bootstrap/Button';\r\nimport Constants from './Constants';\r\n\r\n\r\nclass VwValidateEmail extends React.Component {\r\n\r\n constructor(props) {\r\n super(props);\r\n this.onDoneClick = this.onDoneClick.bind(this);\r\n }\r\n\r\n render() {\r\n return (\r\n
\r\n

Thanks!

\r\n

We sent an email to the address you provided. Please click the link in that message to validate you email address and continue account creation.

\r\n

\r\n \r\n
\r\n );\r\n }\r\n onDoneClick() {\r\n this.props.SetActiveViewForApp(Constants.VwInput);\r\n }\r\n}\r\n\r\nexport default VwValidateEmail;\r\n","class Api {\r\n constructor(apiKey) {\r\n this.apiUrl = \"https://msciaccountcreationapi.azurewebsites.net/api\"\r\n this.headers = {\r\n \"Content-Type\": \"application/json\",\r\n \"x-functions-key\": apiKey\r\n };\r\n }\r\n\r\n EmailLookup(email) {\r\n let url = this.apiUrl + \"/email_lookup?email=\" + email.trim();\r\n let req = new Request(url, {\r\n method: 'GET',\r\n headers: this.headers\r\n });\r\n return fetch(req).then(response => {\r\n if (response.ok) {\r\n return response.json();\r\n }\r\n if (response.status !== 400) {\r\n var message = \"GET request to \" + url + \" returned an error \" + response.statusText;\r\n console.error(message);\r\n throw new Error(message);\r\n }\r\n return response.json().then(data => {\r\n throw new Error(data.error);\r\n });\r\n });\r\n }\r\n\r\n SendEmailValidation(email, returnToUrl) {\r\n var url = this.apiUrl + \"/email_validation\";\r\n var validationBaseUrl = \"https://members.msci.org/MSCIIMIS/iMIS/ContactManagement/AccountCreation-Step02.aspx\";\r\n if (returnToUrl) {\r\n validationBaseUrl = validationBaseUrl + \"?return_to=\" + returnToUrl;\r\n }\r\n let data = JSON.stringify({\r\n \"email\": email,\r\n \"validation_base_url\": validationBaseUrl\r\n });\r\n let req = new Request(url, {\r\n method: \"POST\",\r\n headers: this.headers,\r\n body: data\r\n });\r\n return fetch(req).then(response => {\r\n if (response.ok) {\r\n return response.json();\r\n }\r\n if (response.status !== 400) {\r\n var message = \"POST request to \" + url + \" returned an error \" + response.statusText;\r\n throw new Error(message);\r\n }\r\n return response.json().then(data => {\r\n throw new Error(data.error);\r\n });\r\n });\r\n }\r\n}\r\n\r\nexport default Api\r\n","import React from 'react';\r\nimport Constants from './Constants';\r\nimport VwInput from './VwInput';\r\nimport VwForgotCreds from './VwForgotCreds';\r\nimport VwValidateEmail from './VwValidateEmail';\r\nimport VwError from './VwError';\r\nimport Api from './Api';\r\nimport store from 'store';\r\n\r\nimport './App.css';\r\nimport 'bootstrap/dist/css/bootstrap.min.css';\r\n\r\n\r\nclass App extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n ActiveView: Constants.VwInput,\r\n NewAccountData: {\r\n Email: \"\",\r\n ImisId: \"\"\r\n }\r\n };\r\n this.UpdateNewAccountData = this.UpdateNewAccountData.bind(this);\r\n this.SetAndPersistAppState = this.SetAndPersistAppState.bind(this);\r\n this.SetActiveViewForApp = this.SetActiveViewForApp.bind(this);\r\n this.Api = new Api(\"BPYb2KfKHThoOZ/pnjxjDuyVqzuPVfBEcJAMsyH4//zkmFZHiXUBzw==\");\r\n }\r\n\r\n render() {\r\n switch (this.state.ActiveView) {\r\n case Constants.VwInput:\r\n return \r\n case Constants.VwForgotCreds:\r\n return ;\r\n case Constants.VwValidateEmail:\r\n return ;\r\n default:\r\n return \r\n }\r\n }\r\n\r\n UpdateNewAccountData(newAcctData) {\r\n let existing = Object.assign({}, this.state.NewAccountData);\r\n let updated = Object.assign(existing, newAcctData);\r\n this.SetAndPersistAppState({\r\n NewAccountData: updated\r\n });\r\n }\r\n\r\n SetAndPersistAppState(state) {\r\n this.setState(state, () => {\r\n store.set(Constants.StMsciAccountCreationAppState, this.state);\r\n });\r\n }\r\n\r\n SetActiveViewForApp(viewName) {\r\n this.SetAndPersistAppState({\r\n ActiveView: viewName\r\n });\r\n }\r\n}\r\n\r\nexport default App;\r\n","// This optional code is used to register a service worker.\r\n// register() is not called by default.\r\n\r\n// This lets the app load faster on subsequent visits in production, and gives\r\n// it offline capabilities. However, it also means that developers (and users)\r\n// will only see deployed updates on subsequent visits to a page, after all the\r\n// existing tabs open on the page have been closed, since previously cached\r\n// resources are updated in the background.\r\n\r\n// To learn more about the benefits of this model and instructions on how to\r\n// opt-in, read https://bit.ly/CRA-PWA\r\n\r\nconst isLocalhost = Boolean(\r\n window.location.hostname === 'localhost' ||\r\n // [::1] is the IPv6 localhost address.\r\n window.location.hostname === '[::1]' ||\r\n // 127.0.0.0/8 are considered localhost for IPv4.\r\n window.location.hostname.match(\r\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\r\n )\r\n);\r\n\r\nexport function register(config) {\r\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\r\n // The URL constructor is available in all browsers that support SW.\r\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\r\n if (publicUrl.origin !== window.location.origin) {\r\n // Our service worker won't work if PUBLIC_URL is on a different origin\r\n // from what our page is served on. This might happen if a CDN is used to\r\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\r\n return;\r\n }\r\n\r\n window.addEventListener('load', () => {\r\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\r\n\r\n if (isLocalhost) {\r\n // This is running on localhost. Let's check if a service worker still exists or not.\r\n checkValidServiceWorker(swUrl, config);\r\n\r\n // Add some additional logging to localhost, pointing developers to the\r\n // service worker/PWA documentation.\r\n navigator.serviceWorker.ready.then(() => {\r\n console.log(\r\n 'This web app is being served cache-first by a service ' +\r\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\r\n );\r\n });\r\n } else {\r\n // Is not localhost. Just register service worker\r\n registerValidSW(swUrl, config);\r\n }\r\n });\r\n }\r\n}\r\n\r\nfunction registerValidSW(swUrl, config) {\r\n navigator.serviceWorker\r\n .register(swUrl)\r\n .then(registration => {\r\n registration.onupdatefound = () => {\r\n const installingWorker = registration.installing;\r\n if (installingWorker == null) {\r\n return;\r\n }\r\n installingWorker.onstatechange = () => {\r\n if (installingWorker.state === 'installed') {\r\n if (navigator.serviceWorker.controller) {\r\n // At this point, the updated precached content has been fetched,\r\n // but the previous service worker will still serve the older\r\n // content until all client tabs are closed.\r\n console.log(\r\n 'New content is available and will be used when all ' +\r\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\r\n );\r\n\r\n // Execute callback\r\n if (config && config.onUpdate) {\r\n config.onUpdate(registration);\r\n }\r\n } else {\r\n // At this point, everything has been precached.\r\n // It's the perfect time to display a\r\n // \"Content is cached for offline use.\" message.\r\n console.log('Content is cached for offline use.');\r\n\r\n // Execute callback\r\n if (config && config.onSuccess) {\r\n config.onSuccess(registration);\r\n }\r\n }\r\n }\r\n };\r\n };\r\n })\r\n .catch(error => {\r\n console.error('Error during service worker registration:', error);\r\n });\r\n}\r\n\r\nfunction checkValidServiceWorker(swUrl, config) {\r\n // Check if the service worker can be found. If it can't reload the page.\r\n fetch(swUrl, {\r\n headers: { 'Service-Worker': 'script' },\r\n })\r\n .then(response => {\r\n // Ensure service worker exists, and that we really are getting a JS file.\r\n const contentType = response.headers.get('content-type');\r\n if (\r\n response.status === 404 ||\r\n (contentType != null && contentType.indexOf('javascript') === -1)\r\n ) {\r\n // No service worker found. Probably a different app. Reload the page.\r\n navigator.serviceWorker.ready.then(registration => {\r\n registration.unregister().then(() => {\r\n window.location.reload();\r\n });\r\n });\r\n } else {\r\n // Service worker found. Proceed as normal.\r\n registerValidSW(swUrl, config);\r\n }\r\n })\r\n .catch(() => {\r\n console.log(\r\n 'No internet connection found. App is running in offline mode.'\r\n );\r\n });\r\n}\r\n\r\nexport function unregister() {\r\n if ('serviceWorker' in navigator) {\r\n navigator.serviceWorker.ready\r\n .then(registration => {\r\n registration.unregister();\r\n })\r\n .catch(error => {\r\n console.error(error.message);\r\n });\r\n }\r\n}\r\n","import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\nimport App from './App';\r\nimport * as serviceWorker from './serviceWorker';\r\n\r\nReactDOM.render(\r\n \r\n \r\n ,\r\n document.getElementById('root')\r\n);\r\n\r\n// If you want your app to work offline and load faster, you can change\r\n// unregister() to register() below. Note this comes with some pitfalls.\r\n// Learn more about service workers: https://bit.ly/CRA-PWA\r\nserviceWorker.unregister();\r\n"],"sourceRoot":""}