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Aa,GACb,AAAA,CAAA,EAAA,EAAA,WAAU,AAAV,EAAY,GAGZ,WAAW,EADY,I,C","sources":["","src/scripts/ui.js","src/scripts/ui.ts","src/scripts/constants.js","src/scripts/constants.ts","src/scripts/getbalance.ts","src/scripts/validators.js","src/scripts/validators.ts","src/scripts/apimethods.js","src/scripts/apimethods.ts"],"sourcesContent":["(() => {\n\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequire931a\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequire931a\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nparcelRegister(\"awDB0\", function(module, exports) {\n\n$parcel$export(module.exports, \"hideErrorDiv\", () => $7a9b9b6f36c0e64b$export$975f08228d4cf7e6);\n$parcel$export(module.exports, \"hideSpinner\", () => $7a9b9b6f36c0e64b$export$95fec50f68454318);\n$parcel$export(module.exports, \"showErrorDiv\", () => $7a9b9b6f36c0e64b$export$ee84ddf60d287b00);\n$parcel$export(module.exports, \"showSpinner\", () => $7a9b9b6f36c0e64b$export$2a7a135fa1ec651f);\n$parcel$export(module.exports, \"toggleAccountNumberValidationMessage\", () => $7a9b9b6f36c0e64b$export$ea3c98ca50021456);\n$parcel$export(module.exports, \"togglePinValidationMessage\", () => $7a9b9b6f36c0e64b$export$2e1877e251fe8d2f);\nfunction $7a9b9b6f36c0e64b$export$975f08228d4cf7e6(div) {\n div.innerText = \"\";\n div.classList.add(\"hide\");\n div.setAttribute(\"aria-live\", \"off\");\n}\nfunction $7a9b9b6f36c0e64b$export$95fec50f68454318(spinnerDiv) {\n spinnerDiv.classList.add(\"hide\");\n}\nfunction $7a9b9b6f36c0e64b$export$ee84ddf60d287b00(div, message) {\n div.classList.remove(\"hide\");\n div.innerText = message;\n div.setAttribute(\"aria-live\", \"assertive\");\n}\nfunction $7a9b9b6f36c0e64b$export$2a7a135fa1ec651f(spinnerDiv) {\n spinnerDiv.classList.remove(\"hide\");\n}\nfunction $7a9b9b6f36c0e64b$export$ea3c98ca50021456(accountNumberTextBox, isAccountNumberValid) {\n const accountErrorMessageDiv = document.getElementById(\"accountErrorMessage\");\n if (isAccountNumberValid) $7a9b9b6f36c0e64b$export$975f08228d4cf7e6(accountErrorMessageDiv);\n else {\n const accountNumberLengthMessage = \"Account number must be at least 7 characters long\";\n const accountNumberRequiredMessage = \"Billing account number is required\";\n let message;\n if (accountNumberTextBox.validity.valueMissing) message = accountNumberRequiredMessage;\n else if (accountNumberTextBox.validity.patternMismatch) message = accountNumberLengthMessage;\n else message = \"\";\n $7a9b9b6f36c0e64b$export$ee84ddf60d287b00(accountErrorMessageDiv, message);\n }\n accountNumberTextBox.setAttribute(\"aria-invalid\", isAccountNumberValid ? \"false\" : \"true\");\n}\nfunction $7a9b9b6f36c0e64b$export$2e1877e251fe8d2f(pinTextBox, isPinValid) {\n const pinErrorMessageDiv = document.getElementById(\"pinErrorMessage\");\n if (isPinValid) $7a9b9b6f36c0e64b$export$975f08228d4cf7e6(pinErrorMessageDiv);\n else {\n const pinRequiredMessage = \"4-digit PIN is required\";\n $7a9b9b6f36c0e64b$export$ee84ddf60d287b00(pinErrorMessageDiv, pinRequiredMessage);\n }\n pinTextBox.setAttribute(\"aria-invalid\", isPinValid ? \"false\" : \"true\");\n}\n\n});\n\nparcelRegister(\"hJMXW\", function(module, exports) {\n\n$parcel$export(module.exports, \"nonAlphanumericRegex\", () => $ce9c9f376cb2511d$export$85ceed2b2a591268);\n$parcel$export(module.exports, \"nonNumericRegex\", () => $ce9c9f376cb2511d$export$9839fa8d0b5c8aae);\nconst $ce9c9f376cb2511d$export$85ceed2b2a591268 = /[^0-9a-zA-Z]/g;\nconst $ce9c9f376cb2511d$export$9839fa8d0b5c8aae = /[^0-9]/g;\n\n});\n\nfunction $33d2723ce1692680$export$76ea90c17c1016df(accountNumberElement) {\n return accountNumberElement.checkValidity();\n}\nfunction $33d2723ce1692680$export$6e3f5be18b3338ce(pinElement) {\n return !pinElement.validity.valueMissing && !pinElement.validity.patternMismatch;\n}\n\n\n\nvar $awDB0 = parcelRequire(\"awDB0\");\n\nvar $hJMXW = parcelRequire(\"hJMXW\");\nvar $65ae20bed3355038$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function(resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function(resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nconst $65ae20bed3355038$var$unknownErrorMessage = \"There was an unexpected error that may be temporary. Please try again later.\";\nfunction $65ae20bed3355038$export$4af2bca4e077d115() {\n return $65ae20bed3355038$var$__awaiter(this, void 0, void 0, function*() {\n const errorMessageDiv = document.getElementById(\"errMessage\");\n const spinnerDiv = document.getElementById(\"spinner\");\n const accountNumberTextBox = document.getElementById(\"billingAccountNumber\");\n const accountNumber = accountNumberTextBox.value.replace((0, $hJMXW.nonAlphanumericRegex), \"\");\n const pinTextBox = document.getElementById(\"customerPin\");\n const payload = {\n accountnumber: accountNumber,\n enteredpin: pinTextBox.value\n };\n const apiUrl = \"/api/Balance\";\n const contentTypeKey = \"Content-Type\";\n const RequestVerificationTokenKey = \"RequestVerificationToken\";\n const tokenElement = document.querySelector('input[name=\"__RequestVerificationToken\"]');\n let token = tokenElement.value;\n let headers = new Headers();\n headers.append(contentTypeKey, \"application/json\");\n headers.append(RequestVerificationTokenKey, token);\n try {\n yield $65ae20bed3355038$export$3b7ffcb18dc836b8();\n const response = yield fetch(apiUrl, {\n method: \"post\",\n headers: headers,\n body: JSON.stringify(payload)\n });\n if (response.ok) {\n const responsedata = yield response.json();\n const redirectUrlKey = \"redirectUrl\";\n (0, $awDB0.hideSpinner)(spinnerDiv);\n if (redirectUrlKey in responsedata) window.location.href = responsedata[redirectUrlKey];\n else (0, $awDB0.showErrorDiv)(errorMessageDiv, $65ae20bed3355038$var$unknownErrorMessage);\n } else {\n (0, $awDB0.hideSpinner)(spinnerDiv);\n const responsedata = yield response.json();\n const controllerApiErrorKey = \"controllerApiError\";\n var errorMessage;\n if (controllerApiErrorKey in responsedata) errorMessage = responsedata[controllerApiErrorKey];\n else errorMessage = $65ae20bed3355038$var$unknownErrorMessage;\n (0, $awDB0.showErrorDiv)(errorMessageDiv, errorMessage);\n }\n } catch (error) {\n console.error(\"Error : \", error);\n (0, $awDB0.hideSpinner)(spinnerDiv);\n (0, $awDB0.showErrorDiv)(errorMessageDiv, $65ae20bed3355038$var$unknownErrorMessage);\n }\n });\n}\nfunction $65ae20bed3355038$export$3b7ffcb18dc836b8() {\n return $65ae20bed3355038$var$__awaiter(this, void 0, void 0, function*() {\n try {\n const apiUrl = \"/api/Balance/GetNewToken\";\n const response = yield fetch(apiUrl, {\n method: \"GET\",\n credentials: \"include\"\n });\n const token = yield response.text();\n const antiForegeryTokenElement = document.querySelector('[name = \"__RequestVerificationToken\"]');\n if (antiForegeryTokenElement) antiForegeryTokenElement.value = token;\n } catch (error) {\n console.error(\"Error:\", error);\n }\n });\n}\n\n\n\nvar $hJMXW = parcelRequire(\"hJMXW\");\n\nvar $awDB0 = parcelRequire(\"awDB0\");\nconst $ea41d65ac2a28d87$var$accountErrorMessageDiv = document.getElementById(\"accountErrorMessage\");\nconst $ea41d65ac2a28d87$var$accountNumberTextBox = document.getElementById(\"billingAccountNumber\");\nconst $ea41d65ac2a28d87$var$errorMessageDiv = document.getElementById(\"errMessage\");\nconst $ea41d65ac2a28d87$var$pinErrorMessageDiv = document.getElementById(\"pinErrorMessage\");\nconst $ea41d65ac2a28d87$var$pinTextBox = document.getElementById(\"customerPin\");\nconst $ea41d65ac2a28d87$var$spinnerDiv = document.getElementById(\"spinner\");\n$ea41d65ac2a28d87$var$initialize();\nfunction $ea41d65ac2a28d87$var$deleteInvalidCharactersFromAccountNumber(accountNumber) {\n const accountNumberFormatRegex = /^[0-9]{10}/;\n if (accountNumberFormatRegex.test(accountNumber) && accountNumber.substring(10, 11).match(\"/\")) {\n accountNumber = accountNumber.substring(0, 11) + accountNumber.substring(11, 16).replace((0, $hJMXW.nonNumericRegex), \"\");\n accountNumber = accountNumber.substring(0, 12);\n } else accountNumber = accountNumber?.substring(0, 16).replace((0, $hJMXW.nonAlphanumericRegex), \"\") || \"\";\n return accountNumber;\n}\nfunction $ea41d65ac2a28d87$var$initialize() {\n $ea41d65ac2a28d87$var$accountNumberTextBox.addEventListener(\"input\", ()=>{\n $ea41d65ac2a28d87$var$accountNumberTextBox.value = $ea41d65ac2a28d87$var$deleteInvalidCharactersFromAccountNumber($ea41d65ac2a28d87$var$accountNumberTextBox.value);\n });\n $ea41d65ac2a28d87$var$accountNumberTextBox.addEventListener(\"paste\", (event)=>{\n event.preventDefault();\n const nonAlphaNumericAndBackSlashRegex = /[^0-9a-zA-Z\\/]/g;\n const typeText = \"text/plain\";\n let accountNumberInput = event.clipboardData?.getData(typeText) || \"\";\n $ea41d65ac2a28d87$var$accountNumberTextBox.value = $ea41d65ac2a28d87$var$deleteInvalidCharactersFromAccountNumber(accountNumberInput.replace(nonAlphaNumericAndBackSlashRegex, \"\"));\n });\n $ea41d65ac2a28d87$var$accountNumberTextBox.addEventListener(\"blur\", ()=>{\n let isAccountNumberValid = (0, $33d2723ce1692680$export$76ea90c17c1016df)($ea41d65ac2a28d87$var$accountNumberTextBox);\n (0, $awDB0.toggleAccountNumberValidationMessage)($ea41d65ac2a28d87$var$accountNumberTextBox, isAccountNumberValid);\n });\n $ea41d65ac2a28d87$var$pinTextBox.addEventListener(\"input\", ()=>{\n $ea41d65ac2a28d87$var$pinTextBox.value = $ea41d65ac2a28d87$var$pinTextBox.value.replace((0, $hJMXW.nonNumericRegex), \"\");\n });\n $ea41d65ac2a28d87$var$pinTextBox.addEventListener(\"blur\", ()=>{\n let isPinValid = (0, $33d2723ce1692680$export$6e3f5be18b3338ce)($ea41d65ac2a28d87$var$pinTextBox);\n (0, $awDB0.togglePinValidationMessage)($ea41d65ac2a28d87$var$pinTextBox, isPinValid);\n });\n document.getElementById(\"otp-signIn\")?.addEventListener(\"click\", async (event)=>{\n event.preventDefault();\n let isAccountNumberValid = (0, $33d2723ce1692680$export$76ea90c17c1016df)($ea41d65ac2a28d87$var$accountNumberTextBox);\n let isPinValid = (0, $33d2723ce1692680$export$6e3f5be18b3338ce)($ea41d65ac2a28d87$var$pinTextBox);\n (0, $awDB0.toggleAccountNumberValidationMessage)($ea41d65ac2a28d87$var$accountNumberTextBox, isAccountNumberValid);\n (0, $awDB0.togglePinValidationMessage)($ea41d65ac2a28d87$var$pinTextBox, isPinValid);\n if (isAccountNumberValid && isPinValid) {\n (0, $awDB0.showSpinner)($ea41d65ac2a28d87$var$spinnerDiv);\n (0, $65ae20bed3355038$export$4af2bca4e077d115)();\n }\n });\n (0, $awDB0.hideErrorDiv)($ea41d65ac2a28d87$var$accountErrorMessageDiv);\n (0, $awDB0.hideErrorDiv)($ea41d65ac2a28d87$var$errorMessageDiv);\n (0, $awDB0.hideErrorDiv)($ea41d65ac2a28d87$var$pinErrorMessageDiv);\n (0, $awDB0.hideSpinner)($ea41d65ac2a28d87$var$spinnerDiv);\n const sessionTimeout = 60000;\n setTimeout((0, $65ae20bed3355038$export$3b7ffcb18dc836b8), sessionTimeout);\n}\n\n})();\n//# sourceMappingURL=getbalance.js.map\n","export function hideErrorDiv(div) {\n div.innerText = \"\";\n div.classList.add(\"hide\");\n div.setAttribute(\"aria-live\", \"off\");\n}\nexport function hideSpinner(spinnerDiv) {\n spinnerDiv.classList.add(\"hide\");\n}\nexport function showErrorDiv(div, message) {\n div.classList.remove(\"hide\");\n div.innerText = message;\n div.setAttribute(\"aria-live\", \"assertive\");\n}\nexport function showSpinner(spinnerDiv) {\n spinnerDiv.classList.remove(\"hide\");\n}\nexport function toggleAccountNumberValidationMessage(accountNumberTextBox, isAccountNumberValid) {\n const accountErrorMessageDiv = document.getElementById(\"accountErrorMessage\");\n if (isAccountNumberValid) {\n hideErrorDiv(accountErrorMessageDiv);\n }\n else {\n const accountNumberLengthMessage = \"Account number must be at least 7 characters long\";\n const accountNumberRequiredMessage = \"Billing account number is required\";\n let message;\n if (accountNumberTextBox.validity.valueMissing) {\n message = accountNumberRequiredMessage;\n }\n else if (accountNumberTextBox.validity.patternMismatch) {\n message = accountNumberLengthMessage;\n }\n else {\n message = \"\";\n }\n showErrorDiv(accountErrorMessageDiv, message);\n }\n accountNumberTextBox.setAttribute(\"aria-invalid\", isAccountNumberValid ? \"false\" : \"true\");\n}\nexport function togglePinValidationMessage(pinTextBox, isPinValid) {\n const pinErrorMessageDiv = document.getElementById(\"pinErrorMessage\");\n if (isPinValid) {\n hideErrorDiv(pinErrorMessageDiv);\n }\n else {\n const pinRequiredMessage = \"4-digit PIN is required\";\n showErrorDiv(pinErrorMessageDiv, pinRequiredMessage);\n }\n pinTextBox.setAttribute(\"aria-invalid\", isPinValid ? \"false\" : \"true\");\n}\n//# sourceMappingURL=ui.js.map","export function hideErrorDiv(div: HTMLDivElement): void {\r\n div.innerText = \"\";\r\n div.classList.add(\"hide\");\r\n div.setAttribute(\"aria-live\", \"off\");\r\n}\r\n\r\nexport function hideSpinner(spinnerDiv: HTMLDivElement) {\r\n spinnerDiv.classList.add(\"hide\");\r\n}\r\n\r\nexport function showErrorDiv(div: HTMLDivElement, message: string): void {\r\n div.classList.remove(\"hide\");\r\n div.innerText = message;\r\n div.setAttribute(\"aria-live\", \"assertive\");\r\n}\r\n\r\nexport function showSpinner(spinnerDiv: HTMLDivElement) {\r\n spinnerDiv.classList.remove(\"hide\");\r\n}\r\n\r\nexport function toggleAccountNumberValidationMessage(\r\n accountNumberTextBox: HTMLInputElement, isAccountNumberValid: boolean): void {\r\n const accountErrorMessageDiv = document.getElementById(\"accountErrorMessage\") as HTMLDivElement;\r\n\r\n if (isAccountNumberValid) {\r\n hideErrorDiv(accountErrorMessageDiv);\r\n }\r\n else {\r\n const accountNumberLengthMessage = \"Account number must be at least 7 characters long\";\r\n const accountNumberRequiredMessage = \"Billing account number is required\";\r\n let message: string;\r\n\r\n if (accountNumberTextBox.validity.valueMissing) {\r\n message = accountNumberRequiredMessage;\r\n }\r\n else if (accountNumberTextBox.validity.patternMismatch) {\r\n message = accountNumberLengthMessage;\r\n }\r\n else {\r\n message = \"\";\r\n }\r\n\r\n showErrorDiv(accountErrorMessageDiv, message);\r\n }\r\n\r\n accountNumberTextBox.setAttribute(\"aria-invalid\", isAccountNumberValid ? \"false\" : \"true\");\r\n}\r\n\r\nexport function togglePinValidationMessage(pinTextBox: HTMLInputElement, isPinValid: boolean): void {\r\n const pinErrorMessageDiv = document.getElementById(\"pinErrorMessage\") as HTMLDivElement;\r\n\r\n if (isPinValid) {\r\n hideErrorDiv(pinErrorMessageDiv);\r\n }\r\n else {\r\n const pinRequiredMessage = \"4-digit PIN is required\";\r\n showErrorDiv(pinErrorMessageDiv, pinRequiredMessage);\r\n }\r\n\r\n pinTextBox.setAttribute(\"aria-invalid\", isPinValid ? \"false\" : \"true\");\r\n}\r\n","export const nonAlphanumericRegex = /[^0-9a-zA-Z]/g;\nexport const nonNumericRegex = /[^0-9]/g;\n//# sourceMappingURL=constants.js.map","export const nonAlphanumericRegex: RegExp = /[^0-9a-zA-Z]/g;\r\nexport const nonNumericRegex: RegExp = /[^0-9]/g;\r\n\r\n","import { isValidAccountNumber, isValidPin } from \"./validators.js\"\r\nimport { getBalanceAsync, refreshAntiForgeryTokenAsync } from \"./apimethods.js\"\r\nimport { nonAlphanumericRegex, nonNumericRegex } from \"./constants.js\"\r\nimport {\r\n hideErrorDiv,\r\n hideSpinner,\r\n showSpinner,\r\n toggleAccountNumberValidationMessage,\r\n togglePinValidationMessage\r\n} from \"./ui.js\"\r\n\r\nconst accountErrorMessageDiv = document.getElementById(\"accountErrorMessage\") as HTMLDivElement;\r\nconst accountNumberTextBox = document.getElementById(\"billingAccountNumber\") as HTMLInputElement;\r\nconst errorMessageDiv = document.getElementById(\"errMessage\") as HTMLDivElement;\r\nconst pinErrorMessageDiv = document.getElementById(\"pinErrorMessage\") as HTMLDivElement;\r\nconst pinTextBox = document.getElementById(\"customerPin\") as HTMLInputElement;\r\nconst spinnerDiv = document.getElementById(\"spinner\") as HTMLDivElement;\r\n\r\ninitialize();\r\n\r\nfunction deleteInvalidCharactersFromAccountNumber(accountNumber: string): string {\r\n const accountNumberFormatRegex: RegExp = /^[0-9]{10}/;\r\n\r\n if (accountNumberFormatRegex.test(accountNumber) && accountNumber.substring(10, 11).match(\"/\")) {\r\n accountNumber = accountNumber.substring(0, 11) + accountNumber.substring(11, 16).replace(nonNumericRegex, \"\");\r\n accountNumber = accountNumber.substring(0, 12);\r\n }\r\n else {\r\n accountNumber = accountNumber?.substring(0, 16).replace(nonAlphanumericRegex, \"\") || \"\";\r\n }\r\n\r\n return accountNumber;\r\n}\r\n\r\nfunction initialize(): void {\r\n accountNumberTextBox.addEventListener(\"input\", () => {\r\n accountNumberTextBox.value = deleteInvalidCharactersFromAccountNumber(accountNumberTextBox.value);\r\n });\r\n\r\n accountNumberTextBox.addEventListener(\"paste\", (event: ClipboardEvent) => {\r\n event.preventDefault();\r\n const nonAlphaNumericAndBackSlashRegex = /[^0-9a-zA-Z\\/]/g;\r\n const typeText: string = \"text/plain\";\r\n let accountNumberInput = event.clipboardData?.getData(typeText) || \"\";\r\n accountNumberTextBox.value = deleteInvalidCharactersFromAccountNumber(\r\n accountNumberInput.replace(nonAlphaNumericAndBackSlashRegex, \"\"));\r\n });\r\n\r\n accountNumberTextBox.addEventListener(\"blur\", () => {\r\n let isAccountNumberValid = isValidAccountNumber(accountNumberTextBox);\r\n toggleAccountNumberValidationMessage(accountNumberTextBox, isAccountNumberValid);\r\n });\r\n\r\n pinTextBox.addEventListener(\"input\", () => {\r\n pinTextBox.value = pinTextBox.value.replace(nonNumericRegex, \"\");\r\n });\r\n\r\n pinTextBox.addEventListener(\"blur\", () => {\r\n let isPinValid = isValidPin(pinTextBox);\r\n togglePinValidationMessage(pinTextBox, isPinValid);\r\n });\r\n\r\n document.getElementById(\"otp-signIn\")?.addEventListener(\"click\", async (event) => {\r\n event.preventDefault();\r\n let isAccountNumberValid = isValidAccountNumber(accountNumberTextBox);\r\n let isPinValid = isValidPin(pinTextBox);\r\n\r\n toggleAccountNumberValidationMessage(accountNumberTextBox, isAccountNumberValid);\r\n togglePinValidationMessage(pinTextBox, isPinValid);\r\n\r\n if (isAccountNumberValid && isPinValid) {\r\n showSpinner(spinnerDiv);\r\n getBalanceAsync();\r\n }\r\n });\r\n\r\n hideErrorDiv(accountErrorMessageDiv);\r\n hideErrorDiv(errorMessageDiv);\r\n hideErrorDiv(pinErrorMessageDiv);\r\n hideSpinner(spinnerDiv);\r\n\r\n const sessionTimeout = 60000;\r\n setTimeout(refreshAntiForgeryTokenAsync, sessionTimeout);\r\n}\r\n","export function isValidAccountNumber(accountNumberElement) {\n return accountNumberElement.checkValidity();\n}\nexport function isValidPin(pinElement) {\n return !pinElement.validity.valueMissing && !pinElement.validity.patternMismatch;\n}\n//# sourceMappingURL=validators.js.map","export function isValidAccountNumber(accountNumberElement: HTMLInputElement): boolean {\r\n return accountNumberElement.checkValidity();\r\n}\r\n\r\nexport function isValidPin(pinElement: HTMLInputElement): boolean {\r\n return !pinElement.validity.valueMissing && !pinElement.validity.patternMismatch;\r\n}\r\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport { hideSpinner, showErrorDiv } from \"./ui.js\";\nimport { nonAlphanumericRegex } from \"./constants.js\";\nconst unknownErrorMessage = \"There was an unexpected error that may be temporary. Please try again later.\";\nexport function getBalanceAsync() {\n return __awaiter(this, void 0, void 0, function* () {\n const errorMessageDiv = document.getElementById(\"errMessage\");\n const spinnerDiv = document.getElementById(\"spinner\");\n const accountNumberTextBox = document.getElementById(\"billingAccountNumber\");\n const accountNumber = accountNumberTextBox.value.replace(nonAlphanumericRegex, \"\");\n const pinTextBox = document.getElementById(\"customerPin\");\n const payload = { accountnumber: accountNumber, enteredpin: pinTextBox.value };\n const apiUrl = '/api/Balance';\n const contentTypeKey = \"Content-Type\";\n const RequestVerificationTokenKey = \"RequestVerificationToken\";\n const tokenElement = document.querySelector('input[name=\"__RequestVerificationToken\"]');\n let token = tokenElement.value;\n let headers = new Headers();\n headers.append(contentTypeKey, \"application/json\");\n headers.append(RequestVerificationTokenKey, token);\n try {\n yield refreshAntiForgeryTokenAsync();\n const response = yield fetch(apiUrl, {\n method: 'post',\n headers: headers,\n body: JSON.stringify(payload)\n });\n if (response.ok) {\n const responsedata = yield response.json();\n const redirectUrlKey = \"redirectUrl\";\n hideSpinner(spinnerDiv);\n if (redirectUrlKey in responsedata) {\n window.location.href = responsedata[redirectUrlKey];\n }\n else {\n showErrorDiv(errorMessageDiv, unknownErrorMessage);\n }\n }\n else {\n hideSpinner(spinnerDiv);\n const responsedata = yield response.json();\n const controllerApiErrorKey = \"controllerApiError\";\n var errorMessage;\n if (controllerApiErrorKey in responsedata) {\n errorMessage = responsedata[controllerApiErrorKey];\n }\n else {\n errorMessage = unknownErrorMessage;\n }\n showErrorDiv(errorMessageDiv, errorMessage);\n }\n }\n catch (error) {\n console.error('Error : ', error);\n hideSpinner(spinnerDiv);\n showErrorDiv(errorMessageDiv, unknownErrorMessage);\n }\n });\n}\nexport function refreshAntiForgeryTokenAsync() {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n const apiUrl = '/api/Balance/GetNewToken';\n const response = yield fetch(apiUrl, {\n method: 'GET',\n credentials: 'include'\n });\n const token = yield response.text();\n const antiForegeryTokenElement = document.querySelector('[name = \"__RequestVerificationToken\"]');\n if (antiForegeryTokenElement) {\n antiForegeryTokenElement.value = token;\n }\n }\n catch (error) {\n console.error('Error:', error);\n }\n });\n}\n//# sourceMappingURL=apimethods.js.map","import { hideSpinner, showErrorDiv } from \"./ui.js\"\r\nimport { nonAlphanumericRegex } from \"./constants.js\"\r\n\r\nconst unknownErrorMessage = \"There was an unexpected error that may be temporary. Please try again later.\";\r\n\r\nexport async function getBalanceAsync() {\r\n const errorMessageDiv = document.getElementById(\"errMessage\") as HTMLDivElement;\r\n const spinnerDiv = document.getElementById(\"spinner\") as HTMLDivElement;\r\n const accountNumberTextBox = document.getElementById(\"billingAccountNumber\") as HTMLInputElement;\r\n const accountNumber = accountNumberTextBox.value.replace(nonAlphanumericRegex, \"\");\r\n const pinTextBox = document.getElementById(\"customerPin\") as HTMLInputElement;\r\n const payload = { accountnumber: accountNumber, enteredpin: pinTextBox.value };\r\n const apiUrl = '/api/Balance';\r\n const contentTypeKey = \"Content-Type\";\r\n const RequestVerificationTokenKey = \"RequestVerificationToken\";\r\n const tokenElement = document.querySelector('input[name=\"__RequestVerificationToken\"]') as HTMLInputElement;\r\n let token = tokenElement.value;\r\n let headers = new Headers();\r\n headers.append(contentTypeKey, \"application/json\");\r\n headers.append(RequestVerificationTokenKey, token);\r\n\r\n try {\r\n await refreshAntiForgeryTokenAsync();\r\n\r\n const response = await fetch(apiUrl, {\r\n method: 'post',\r\n headers: headers,\r\n body: JSON.stringify(payload)\r\n });\r\n\r\n if (response.ok) {\r\n const responsedata = await response.json();\r\n const redirectUrlKey = \"redirectUrl\";\r\n hideSpinner(spinnerDiv);\r\n\r\n if (redirectUrlKey in responsedata) {\r\n window.location.href = responsedata[redirectUrlKey];\r\n }\r\n else {\r\n showErrorDiv(errorMessageDiv, unknownErrorMessage);\r\n }\r\n }\r\n else {\r\n hideSpinner(spinnerDiv);\r\n const responsedata = await response.json();\r\n const controllerApiErrorKey = \"controllerApiError\";\r\n var errorMessage;\r\n\r\n if (controllerApiErrorKey in responsedata) {\r\n errorMessage = responsedata[controllerApiErrorKey];\r\n }\r\n else {\r\n errorMessage = unknownErrorMessage;\r\n }\r\n\r\n showErrorDiv(errorMessageDiv, errorMessage);\r\n }\r\n }\r\n catch (error) {\r\n console.error('Error : ', error);\r\n hideSpinner(spinnerDiv);\r\n showErrorDiv(errorMessageDiv, unknownErrorMessage);\r\n }\r\n}\r\n\r\nexport async function refreshAntiForgeryTokenAsync() {\r\n try {\r\n const apiUrl = '/api/Balance/GetNewToken'\r\n const response = await fetch(apiUrl, {\r\n method: 'GET',\r\n credentials: 'include'\r\n });\r\n\r\n const token = await response.text();\r\n const antiForegeryTokenElement =\r\n document.querySelector('[name = \"__RequestVerificationToken\"]');\r\n\r\n if (antiForegeryTokenElement) {\r\n antiForegeryTokenElement.value = token;\r\n }\r\n }\r\n catch (error) {\r\n console.error('Error:', error);\r\n }\r\n}\r\n"],"names":["$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","$33d2723ce1692680$export$76ea90c17c1016df","accountNumberElement","checkValidity","$33d2723ce1692680$export$6e3f5be18b3338ce","pinElement","validity","valueMissing","patternMismatch","$7a9b9b6f36c0e64b$export$975f08228d4cf7e6","div","innerText","classList","add","setAttribute","$7a9b9b6f36c0e64b$export$95fec50f68454318","spinnerDiv","$7a9b9b6f36c0e64b$export$ee84ddf60d287b00","message","remove","$7a9b9b6f36c0e64b$export$2a7a135fa1ec651f","$7a9b9b6f36c0e64b$export$ea3c98ca50021456","accountNumberTextBox","isAccountNumberValid","accountErrorMessageDiv","document","getElementById","$7a9b9b6f36c0e64b$export$2e1877e251fe8d2f","pinTextBox","isPinValid","pinErrorMessageDiv","$ce9c9f376cb2511d$export$85ceed2b2a591268","$ce9c9f376cb2511d$export$9839fa8d0b5c8aae","$awDB0","$hJMXW","$65ae20bed3355038$var$__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","rejected","result","done","adopt","then","apply","$65ae20bed3355038$var$unknownErrorMessage","$65ae20bed3355038$export$3b7ffcb18dc836b8","response","fetch","method","credentials","token","text","antiForegeryTokenElement","querySelector","error","console","$ea41d65ac2a28d87$var$accountErrorMessageDiv","$ea41d65ac2a28d87$var$accountNumberTextBox","$ea41d65ac2a28d87$var$errorMessageDiv","$ea41d65ac2a28d87$var$pinErrorMessageDiv","$ea41d65ac2a28d87$var$pinTextBox","$ea41d65ac2a28d87$var$spinnerDiv","$ea41d65ac2a28d87$var$deleteInvalidCharactersFromAccountNumber","accountNumber","accountNumberFormatRegex","test","substring","match","replace","nonNumericRegex","nonAlphanumericRegex","addEventListener","event","preventDefault","accountNumberInput","clipboardData","getData","toggleAccountNumberValidationMessage","togglePinValidationMessage","showSpinner","errorMessageDiv","payload","accountnumber","enteredpin","tokenElement","headers","Headers","append","body","JSON","stringify","ok","responsedata","json","redirectUrlKey","hideSpinner","window","location","href","showErrorDiv","errorMessage","controllerApiErrorKey","hideErrorDiv","setTimeout"],"version":3,"file":"getbalance.js.map"}