{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./app/javascript/packs/sign-up/js/dev-autofill-data.js","webpack:///./app/javascript/packs/sign-up/js/mixpanel-distinct-id.js","webpack:///./app/javascript/packs/sign-up/js/toggle-password-visibility.js","webpack:///./app/javascript/packs/sign-up/js/add-timezone-info.js","webpack:///./app/javascript/packs/sign-up/js/set-initial-library.js","webpack:///./app/javascript/packs/sign-up/js/auto-fill-email.js","webpack:///./app/javascript/packs/sign-up.js","webpack:///./app/javascript/packs/sign-up/js/front-end-validation.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","require","setErrorElement","FORM_ELEMENTS","form","autoFillButton","document","querySelector","addEventListener","email","Date","now","firstname","password","occupation","field","EMAIL","FIRSTNAME","OCCUPATION","PASSWORD","autoFillData","mixpanelDistinctIdHiddenInput","getElementById","window","mixpanel","get_distinct_id","error","console","passwordField","toggleIcon","type","src","tzNameElement","tzOffsetElement","Intl","DateTimeFormat","resolvedOptions","timeZone","Math","abs","round","getTimezoneOffset","initialLibrary","URLSearchParams","location","search","initialLibraryElement","parameter","emailValue","emailElement","addAutofillData","isFormValid","setupFormValidation","setMixpanelDistinctId","togglePasswordVisibility","getForm","resetGtmTrialTrackedCookie","cookieName","currentUrl","domain","pastDate","expires","href","URL","hostname","split","slice","join","toUTCString","cookie","event","preventDefault","grecaptcha","execute","addSignUpFormEventListener","Promise","resolve","interval","setInterval","clearInterval","then","track","handleFinalSignUpFormSubmit","disabled","submit","FORM_ERRORS","addEventListeners","validator","inputElement","errorElement","innerHTML","classList","add","remove","isValidEmail","match","isValidFirstname","length","isValidOccupation","isValidPassword","test","validEmail","validFirstname","validPassword","validOccupation","showErrorLabels","errors","errorsElement","formErrorKey","localizedError","toLowerCase","setLocalizedErrorMessages"],"mappings":"aACE,IAAIA,EAAmB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AAMwG,KAAgBvB,EAAa,CAAC,IAAD,EAChCwB,EAA4F,QAA9E,EAAGvG,SAASC,cAAc,uBAAD,OAAwBqG,EAAaE,uBAAgB,aAA3E,EAA6EpB,UAEhGmB,IACFxB,EAAYuB,GAAgBC,EAEhC,CACF,CAvIEE,GACAzB,EAAkB,CAAElF,OAAMW,MAAOZ,EAAca,MAAOuE,UAAWO,EAAcpE,MAAO2D,EAAYrE,QAClGsE,EAAkB,CAChBlF,OACAW,MAAOZ,EAAcc,UACrBsE,UAAWS,EACXtE,MAAO2D,EAAYpE,YAErBqE,EAAkB,CAChBlF,OACAW,MAAOZ,EAAce,WACrBqE,UAAWW,EACXxE,MAAO2D,EAAYnE,aAErBoE,EAAkB,CAChBlF,OACAW,MAAOZ,EAAcgB,SACrBoE,UAAWY,EACXzE,MAAO2D,EAAYlE,UAEvB,EAyHEjB,kBACAC,gB","file":"js/sign-up-36e0db105a8d92e02dc2.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/packs/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1449);\n","// when working on certain features we have often to create many new accounts\n// this is just for convenience, it allows to autofill the form with valid data\nconst { setErrorElement, FORM_ELEMENTS } = require('./front-end-validation');\n\n/* eslint-disable no-param-reassign */\nfunction autoFillData(form) {\n form.email.value = `test${Date.now()}@uxpin.com`;\n form.firstname.value = 'firstname';\n form.password.value = 'Test123!';\n form.occupation.value = 'other';\n\n setErrorElement({ form, field: FORM_ELEMENTS.EMAIL });\n setErrorElement({ form, field: FORM_ELEMENTS.FIRSTNAME });\n setErrorElement({ form, field: FORM_ELEMENTS.OCCUPATION });\n setErrorElement({ form, field: FORM_ELEMENTS.PASSWORD });\n}\n\nfunction addAutofillData(form) {\n const autoFillButton = document.querySelector('.button-autofill');\n if (autoFillButton) {\n autoFillButton.addEventListener('click', () => {\n autoFillData(form);\n });\n }\n}\n\nmodule.exports = addAutofillData;\n","// used to set the value on a form on submit (need to wait for the snippet to load)\n// this value is then used in the registration request to merge the anonymous mixpanel id\n// with the id_dms_user, so that both front end and back end events reconcile to one single user\n// check uxpin-app, file app/Utils/class/TrackingEvents.inc, method mergeIdentities\nfunction setMixpanelDistinctId() {\n const mixpanelDistinctIdHiddenInput = document.getElementById(\n 'mixpanel_distinct_id'\n );\n\n if (mixpanelDistinctIdHiddenInput) {\n try {\n mixpanelDistinctIdHiddenInput.value = window.mixpanel.get_distinct_id();\n } catch (error) {\n // this error happens when using Firefox in private mode,\n // just catch the error to prevent the sign-up flow from breaking\n // https://github.com/mixpanel/mixpanel-js/issues/106\n }\n } else {\n console.error('Could not find the element with id mixpanel_distinct_id');\n }\n}\n\nmodule.exports = setMixpanelDistinctId;\n","function togglePasswordVisibility() {\n var passwordField = document.getElementById('password');\n var toggleIcon = document.querySelector('.password-toggle');\n \n if (passwordField.type === 'password') {\n passwordField.type = 'text';\n toggleIcon.src = '/images/users/sign-up/icon-eye-open.svg';\n } else {\n passwordField.type = 'password';\n toggleIcon.src = '/images/users/sign-up/icon-eye-closed.svg';\n }\n}\n\nmodule.exports = togglePasswordVisibility;\n","window.addEventListener('load', () => {\n const tzNameElement = document.querySelector('input[name=timezone]');\n const tzOffsetElement = document.querySelector('input[name=timezone_offset]');\n\n if (tzNameElement) {\n tzNameElement.value = Intl.DateTimeFormat().resolvedOptions().timeZone;\n }\n\n if (tzOffsetElement) {\n tzOffsetElement.value = Math.abs(Math.round(new Date().getTimezoneOffset() / 60));\n }\n});\n","window.addEventListener('load', () => {\n const urlParams = new URLSearchParams(window.location.search);\n const initialLibrary = urlParams.get('library');\n const initialLibraryElement = document.querySelector('input[name=initial_library]');\n\n if (initialLibrary && initialLibraryElement) {\n initialLibraryElement.value = initialLibrary;\n }\n});\n","// when users click on sign up from the homepage they prefill their email;\n// in that case, get the value and pre-set the email field\nwindow.addEventListener('load', () => {\n function getQueryStringValue(parameter) {\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(parameter);\n }\n\n const emailValue = getQueryStringValue('email');\n const emailElement = document.getElementById('email');\n\n if (emailValue && emailElement) {\n emailElement.value = emailValue;\n }\n});\n","const addAutofillData = require('./sign-up/js/dev-autofill-data');\nconst { isFormValid, setupFormValidation } = require('./sign-up/js/front-end-validation');\nconst setMixpanelDistinctId = require('./sign-up/js/mixpanel-distinct-id');\nconst togglePasswordVisibility = require('./sign-up/js/toggle-password-visibility');\nrequire('./sign-up/js/add-timezone-info');\nrequire('./sign-up/js/set-initial-library');\nrequire('./sign-up/js/auto-fill-email');\n\nconst GTM_TRIAL_STARTED_TRACKED_COOKIE = 'gtm_trial_started_tracked';\nconst PAST_DATE = '2000-01-01';\n\nconst getMixPanel = () => {\n return new Promise((resolve) => {\n const interval = setInterval(() => {\n if (window.mixpanel) {\n clearInterval(interval);\n return resolve(window.mixpanel);\n }\n }, 1500);\n });\n};\n\nwindow.addEventListener('load', () => {\n const form = getForm();\n if (form) {\n // Used for dev env to quickly fill in form data\n addAutofillData(form);\n\n // Attach event listener to the password toggle icon\n const toggleIcon = document.querySelector('.password-toggle');\n if (toggleIcon) {\n toggleIcon.addEventListener('click', togglePasswordVisibility);\n }\n\n addSignUpFormEventListener(form);\n setupFormValidation(form);\n }\n\n getMixPanel().then((mixpanel) => {\n mixpanel.track('sign_up_page_loaded');\n });\n});\n\n// Initially validate the form on the frontend\nfunction addSignUpFormEventListener(form) {\n form.addEventListener('submit', (event) => {\n event.preventDefault();\n\n if (isFormValid(form)) {\n setMixpanelDistinctId();\n handleRecaptchaValidation();\n }\n });\n}\n\n// If the validation on the frontend is successful show recaptcha\nfunction handleRecaptchaValidation() {\n window.grecaptcha.execute();\n resetGtmTrialTrackedCookie();\n}\n\n// If the recaptcha is successful submit the form\nfunction handleFinalSignUpFormSubmit() {\n const form = getForm();\n\n setMixpanelDistinctId();\n toggleSubmitButtonDisabled(true);\n resetGtmTrialTrackedCookie();\n\n form.submit();\n}\n\nwindow.handleFinalSignUpFormSubmit = handleFinalSignUpFormSubmit;\n\nfunction toggleSubmitButtonDisabled(disabled) {\n document.querySelector('.sign-up-button').disabled = disabled;\n}\n\nfunction getForm() {\n return document.querySelector('.sign-up-form__fields');\n}\n\nfunction unsetCookie(cookieName) {\n const currentUrl = window.location.href;\n const urlObject = new URL(currentUrl);\n const parts = urlObject.hostname.split('.');\n const domain = parts.slice(-2).join('.');\n const pastDate = new Date(PAST_DATE); // to unset the cookie\n const expires = `expires=${pastDate.toUTCString()}`;\n document.cookie = `${cookieName}=; domain=${domain}; ${expires}; path=/`;\n}\n\n// This cookie is used to track GTM trial_started event.\n// Remove the cookie, just in case the user is signing\n// up again for a new trial on the same computer\nfunction resetGtmTrialTrackedCookie() {\n unsetCookie(GTM_TRIAL_STARTED_TRACKED_COOKIE);\n}\n","const FORM_ELEMENTS = {\n EMAIL: 'email',\n FIRSTNAME: 'firstname',\n OCCUPATION: 'occupation',\n PASSWORD: 'password',\n};\n\n// these values will be localized by the method setLocalizedErrorMessages;\n// just in case leave this as default initial values\nconst FORM_ERRORS = {\n EMAIL: 'Email is invalid',\n FIRSTNAME: 'First name is invalid',\n OCCUPATION: 'Must select an occupation',\n PASSWORD: 'Must have at least one lowercase letter, one uppercase letter, one digit, and one special character',\n};\n\nfunction setupFormValidation(form) {\n setLocalizedErrorMessages();\n addEventListeners({ form, field: FORM_ELEMENTS.EMAIL, validator: isValidEmail, error: FORM_ERRORS.EMAIL });\n addEventListeners({\n form,\n field: FORM_ELEMENTS.FIRSTNAME,\n validator: isValidFirstname,\n error: FORM_ERRORS.FIRSTNAME,\n });\n addEventListeners({\n form,\n field: FORM_ELEMENTS.OCCUPATION,\n validator: isValidOccupation,\n error: FORM_ERRORS.OCCUPATION,\n });\n addEventListeners({\n form,\n field: FORM_ELEMENTS.PASSWORD,\n validator: isValidPassword,\n error: FORM_ERRORS.PASSWORD,\n });\n}\n\nfunction addEventListeners({ form, field, validator, error }) {\n const inputElement = form.querySelector(`#${field}`);\n\n if (inputElement) {\n inputElement.addEventListener('blur', () => {\n if (!validator(inputElement.value)) {\n setErrorElement({ form, field, error });\n } else {\n // clean up the error if the validator succeeds\n setErrorElement({ form, field });\n }\n });\n\n // clean up error as the user types if the field becomes valid\n inputElement.addEventListener('keyup', () => {\n if (validator(inputElement.value)) {\n setErrorElement({ form, field });\n }\n });\n }\n}\n\nfunction setErrorElement({ form, field, error }) {\n const errorElement = form.querySelector(`.error-message.${field}`);\n const inputElement = form.querySelector(`#${field}`);\n\n if (error) {\n errorElement.innerHTML = error;\n inputElement.classList.add('input-error-border');\n } else {\n errorElement.innerHTML = '';\n inputElement.classList.remove('input-error-border');\n }\n}\n\nfunction isFormValid(form) {\n const validEmail = isValidEmail(form.querySelector('#email').value);\n const validFirstname = isValidFirstname(form.querySelector('#firstname').value);\n const validPassword = isValidPassword(form.querySelector('#password').value);\n const validOccupation = isValidOccupation(form.querySelector('#occupation').value);\n\n if (!validEmail) {\n setErrorElement({ form, field: FORM_ELEMENTS.EMAIL, error: FORM_ERRORS.EMAIL });\n }\n\n if (!validFirstname) {\n setErrorElement({ form, field: FORM_ELEMENTS.FIRSTNAME, error: FORM_ERRORS.FIRSTNAME });\n }\n\n if (!validOccupation) {\n setErrorElement({ form, field: FORM_ELEMENTS.OCCUPATION, error: FORM_ERRORS.OCCUPATION });\n }\n\n if (!validPassword) {\n setErrorElement({ form, field: FORM_ELEMENTS.PASSWORD, error: FORM_ERRORS.PASSWORD });\n }\n\n return validEmail && validFirstname && validOccupation && validPassword;\n}\n\nfunction isValidEmail(email) {\n // Validate email with this standard: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address\n const VALID_EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;\n\n return email.match(VALID_EMAIL_REGEX);\n}\n\nfunction isValidFirstname(name) {\n // Allow only names that do not contain special characters not commonly used in names or `http` (case-insensitive)\n const ALLOWED_NAME_REGEX = /^(?!.*(http|\\.[^\\s]|[!\"#$%&()*+/:;<=>?@[\\\\\\]^_`{|}~])).*$/i;\n\n if (name.length === 0) {\n return false;\n }\n\n if (name.length > 50) {\n return false;\n }\n\n return name.match(ALLOWED_NAME_REGEX);\n}\n\nfunction isValidOccupation(occupation) {\n return occupation?.length > 0;\n}\n\nfunction isValidPassword(password) {\n // Minimum eight characters, at least one uppercase letter,\n // one lowercase letter, one number and one special character:\n // eslint-disable-next-line max-len\n const VALID_PASSWORD_REGEXP = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\\\\])[A-Za-z\\d!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\\\\]{8,}$/;\n\n return VALID_PASSWORD_REGEXP.test(password);\n}\n\nfunction showErrorLabels(errors) {\n const errorsElement = document.querySelector('.errors');\n\n if (errorsElement) {\n errorsElement.innerHTML = errors.join('
');\n }\n}\n\n// we can't access the localization from js packs, therefore\n// add dedicated fields in the haml file and get the contents\nfunction setLocalizedErrorMessages() {\n for (const formErrorKey in FORM_ERRORS) {\n const localizedError = document.querySelector(`.error-localization-${formErrorKey.toLowerCase()}`)?.innerHTML;\n\n if (localizedError) {\n FORM_ERRORS[formErrorKey] = localizedError;\n }\n }\n}\n\nmodule.exports = {\n isFormValid,\n showErrorLabels,\n setupFormValidation,\n setErrorElement,\n FORM_ELEMENTS,\n};\n"],"sourceRoot":""}