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C,KAAKC,aAAavB,EAAQkB,GAASM,OAAOjB,GAE9C,MAAbU,IACJb,EAAMY,UAAYC,EAAWI,EAEjC,GACF,CACD,C,qCCxCKI,EAAW,YAGbC,EAAAA,EAAAA,IAIJ,EAE4B,YAAxBvC,SAASwC,WACXxC,SAASyC,iBAAiB,oBAAoB,kBAAMH,GAAU,IAE9DA,G","sources":["webpack://Emeritus/./app/javascript/modules/bootstrapper/index.js","webpack://Emeritus/./app/javascript/modules/marketing/formattingNumberLocalized.js","webpack://Emeritus/./app/javascript/packs/refer.js"],"sourcesContent":["const create = () => {\n const bootstrapper = {};\n const data = document.head.dataset || {};\n\n Object.keys(data).forEach((key) => {\n const val = data[key];\n if (val.length > 0) {\n try {\n bootstrapper[key] = JSON.parse(val);\n } catch (_) {\n bootstrapper[key] = val;\n }\n }\n });\n\n return bootstrapper;\n};\n\nconst bootstrapper = create();\n\nexport default bootstrapper;\n","import bootstrapper from '../bootstrapper';\n\nconst formatAmount = (amount) => {\n let formattedAmount = amount.replace(/[^0-9.,]/g, '');\n let decimalPart = false;\n const lastComma = formattedAmount.lastIndexOf(',');\n const lastPoint = formattedAmount.lastIndexOf('.');\n\n if (lastComma > lastPoint) {\n if (formattedAmount.split(',').at(-1).length === 2) { decimalPart = true; }\n formattedAmount = formattedAmount.replace(/\\./g, '').replace(/,/, '.');\n } else if (lastPoint > lastComma) {\n if (formattedAmount.split('.').at(-1).length === 2) { decimalPart = true; }\n formattedAmount = formattedAmount.replace(/,/g, '');\n } else {\n formattedAmount = formattedAmount.replace(/[.,]/g, '');\n }\n if (!decimalPart) { formattedAmount = formattedAmount.replace(/\\./g, ''); }\n\n return { formattedAmount, decimalPart };\n};\n\nexport default () => {\n const { numberLocalizedEnabled } = bootstrapper;\n\n if (numberLocalizedEnabled) {\n const locale = navigator.language;\n const prices = document.querySelectorAll('.js-number-localized');\n\n prices.forEach((price) => {\n const { formattedAmount, decimalPart } = formatAmount(price.innerHTML);\n const currency = price.innerHTML.replace(/[0-9]/g, '').replace(/,/g, '').replace(/\\./g, '');\n\n const options = { numberingSystem: 'latn' };\n if (decimalPart) { options.minimumFractionDigits = 2; }\n const formattedPrice = Intl.NumberFormat(locale, options).format(formattedAmount);\n\n if (!(currency === '%')) {\n price.innerHTML = currency + formattedPrice;\n }\n });\n }\n};\n","import formattingNumberLocalized from '../modules/marketing/formattingNumberLocalized';\n\nconst initPage = () => {\n const loadHandler = () => {\n // Formatting numbers localized for the country\n formattingNumberLocalized();\n };\n\n loadHandler();\n};\n\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => initPage());\n} else {\n initPage();\n}\n"],"names":["bootstrapper","data","document","head","dataset","Object","keys","forEach","key","val","length","JSON","parse","_","create","locale","navigator","language","querySelectorAll","price","_formatAmount","amount","formattedAmount","replace","decimalPart","lastComma","lastIndexOf","lastPoint","split","at","formatAmount","innerHTML","currency","options","numberingSystem","minimumFractionDigits","formattedPrice","Intl","NumberFormat","format","initPage","formattingNumberLocalized","readyState","addEventListener"],"sourceRoot":""}