{"version":3,"file":"auth.compiled.js","sources":["../../iamkey/assets/js/modules/helpers.js","../../iamkey/assets/js/modules/youtubevideo.js","../../iamkey/assets/js/modules/dialogs.js","../../iamkey/assets/js/vendor/hibp.js","../../iamkey/assets/js/modules/inputs.js","../../scripts/auth.js"],"sourcesContent":["// @ts-nocheck\n/**\n * Global helper functions to help maintain and enhance framework elements.\n * @module Helpers\n */\n/**\n * Add global classes used by the CSS and later JavaScript.\n * @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.\n */\nexport const addBodyClasses = (body) => {\n body.classList.add(\"js-enabled\");\n if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {\n body.classList.add(\"ie\");\n }\n return null;\n};\n/**\n * Add global events.\n * @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.\n */\nexport const addGlobalEvents = (body) => {\n const checkElements = function (hash) {\n const label = document.querySelector(`label[for=\"${hash.replace('#', '')}\"]`);\n const summary = document.querySelector(hash + ' summary');\n const dialog = document.querySelector(`dialog${hash}`);\n const detail = document.querySelector(`detail${hash}`);\n if (label instanceof HTMLElement)\n label.click();\n else if (summary instanceof HTMLElement)\n summary.click();\n else if (dialog instanceof HTMLElement)\n dialog.showModal();\n else if (detail instanceof HTMLElement)\n detail.addAttribute('open');\n };\n if (location.hash)\n checkElements(location.hash);\n window.addEventListener('hashchange', function () { checkElements(location.hash); }, false);\n addEventListener(\"popstate\", (event) => {\n if (event && event.state && event.state.type && event.state.type == \"pagination\") {\n let form = document.querySelector(`#${event.state.form}`);\n let pageInput = document.querySelector(`#${event.state.form} [data-pagination]`);\n if (pageInput)\n pageInput.value = event.state.page;\n else\n form.innerHTML += ``;\n form.dispatchEvent(new Event(\"submit\"));\n }\n });\n document.addEventListener(\"submit\", (event) => {\n if (event && event.target instanceof HTMLElement && event.target.matches('form')) {\n let form = event.target;\n // Reset password types\n Array.from(form.querySelectorAll('[data-password-type]')).forEach((input, index) => {\n input.setAttribute('type', 'password');\n });\n if (form.querySelector(':invalid') || form.querySelector('.pwd-checker[data-strength=\"1\"]') || form.querySelector('.pwd-checker[data-strength=\"2\"]')) {\n form.classList.add('was-validated');\n event.preventDefault();\n }\n if (form.querySelector('iam-multiselect[data-is-required][data-error]')) {\n form.classList.add('was-validated');\n event.preventDefault();\n }\n }\n });\n document.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Escape\") {\n if (document.querySelector('.dialog--transactional[open], .dialog--acknowledgement[open]')) {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n });\n Array.from(document.querySelectorAll('label progress')).forEach((progress, index) => {\n let label = progress.closest('label');\n label.setAttribute('data-percent', progress.getAttribute('value'));\n });\n return null;\n};\nexport const isNumeric = function (str) {\n if (typeof str != \"string\")\n return false; // we only process strings! \n return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...\n !isNaN(parseFloat(str)); // ...and ensure strings of whitespace fail\n};\nexport const zeroPad = (num, places) => String(num).padStart(places, '0');\nexport const ucfirst = (str) => str.charAt(0).toUpperCase() + str.slice(1);\nexport const ucwords = (str) => str.split(' ').map(s => ucfirst(s)).join(' ');\nexport const unsnake = (str) => str.replace(/_/g, ' ');\nexport const snake = (str) => str.replace(/ /g, '_');\nexport const safeID = function (str) {\n str = str.toLowerCase();\n str = snake(str);\n str = str.replace(/\\W/g, '');\n return str;\n};\nexport const numberOfDays = function (startDateString, endDateString) {\n let convertStart = startDateString.split('/');\n let convertEnd = endDateString.split('/');\n let dateStart = new Date(convertStart[1] + '/' + convertStart[0] + '/' + convertStart[2]);\n let dateEnd = new Date(convertEnd[1] + '/' + convertEnd[0] + '/' + convertEnd[2]);\n if (dateStart == \"Invalid Date\")\n throw \"Start date is not a valid date\";\n if (dateEnd == \"Invalid Date\")\n throw \"End date is not a valid date\";\n // To calculate the time difference of two dates\n let diffTime = dateEnd.getTime() - dateStart.getTime();\n let numberOfDays = (diffTime / (1000 * 3600 * 24) + 1);\n if (numberOfDays < 0)\n throw \"The start date should be before the end date\";\n return numberOfDays;\n};\n// Used to get values from nested json objects\nexport const resolvePath = (object, path, defaultValue) => path.split(/[\\.\\[\\]\\'\\\"]/).filter(p => p).reduce((o, p) => o ? o[p] : defaultValue, object);\nexport const isTraversable = o => Array.isArray(o) || o !== null && ['function', 'object'].includes(typeof o);\nexport const getSwipeDirection = (touchstartX, touchstartY, touchendX, touchendY) => {\n const limit = Math.tan(45 * 1.5 / 180 * Math.PI);\n let pageWidth = window.innerWidth || document.body.clientWidth;\n let treshold = Math.max(1, Math.floor(0.01 * (pageWidth)));\n let x = touchendX - touchstartX;\n let y = touchendY - touchstartY;\n let xy = Math.abs(x / y);\n let yx = Math.abs(y / x);\n if (Math.abs(x) > treshold || Math.abs(y) > treshold) {\n if (yx <= limit) {\n if (x < 0) {\n return \"left\";\n }\n else {\n return \"right\";\n }\n }\n if (xy <= limit) {\n if (y < 0) {\n return \"top\";\n }\n else {\n return \"bottom\";\n }\n }\n }\n else {\n return \"tap\";\n }\n};\n","// @ts-nocheck\n/**\n * Integrate YouTube videos as a way of hosting videos without the overhead and worry surrounding hosting vides. i.e. file sizes, performance and accessibility.\n */\nclass youtubeVideo {\n /** @param {Element} embed dom element */\n constructor(embed) {\n // If the scripts is already loaded then lets just create the embed\n if (document.body.classList.contains('youtubeLoaded')) {\n embed.addEventListener('click', function (e) {\n // loop parent nodes from the target to the delegation node\n for (var target = e.target; target && target != this; target = target.parentNode) {\n if (target.matches('a')) {\n e.preventDefault();\n createEmbed(target);\n break;\n }\n }\n }, false);\n }\n else {\n this.loadScripts(embed, this.createEmbed);\n }\n }\n /**\n * Load the YouTube scripts before trying to create the embed\n * @param {HTMLElement} embed dom element\n */\n loadScripts(embed) {\n return new Promise((resolve, reject) => {\n const image = new Image();\n image.onload = function () {\n // This code loads the IFrame Player API code asynchronously.\n var tag = document.createElement('script');\n tag.src = \"https://www.youtube.com/iframe_api\";\n var firstScriptTag = document.getElementsByTagName('script')[0];\n firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n document.body.classList.add('youtubeLoaded');\n resolve(true);\n // script has loaded, you can now use it safely\n tag.onload = () => {\n embed.addEventListener('click', function (event) {\n console.log('click');\n // loop parent nodes from the target to the delegation node\n if (event && event.target instanceof HTMLElement && event.target.closest('a')) {\n event.preventDefault();\n createEmbed(event.target.closest('a'));\n }\n }, false);\n };\n };\n image.onerror = function () {\n reject(false);\n };\n image.src = \"https://youtube.com/favicon.ico\";\n });\n }\n}\nexport const createEmbed = function (target) {\n // If there is more than one video lets make sure there is only one playing at a time.\n if (typeof window.player != \"undefined\" && typeof window.player.pauseVideo == \"function\")\n window.player.pauseVideo();\n var video_id = target.getAttribute('data-id');\n var link_id = target.getAttribute('id');\n // create an id to pass t the script if one isn't present\n if (typeof link_id == 'undefined' || link_id == null) {\n var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));\n link_id = randLetter + Date.now();\n target.setAttribute('id', link_id);\n }\n // This function creates an