{"version":3,"sources":["webpack:///./src/helpers/transformation/price.ts"],"names":["cov_243ma3iy2q","actualCoverage","formatPrice","price","b","showCurrency","_priceArray$0$toStrin","f","priceArray","s","split","toString","match","join","formatStripePrice","value","string","String","slice","lastTwo","substr","length","firstCharacter","formatPriceToNumber","parseFloat","replace","formatPriceTrim","trimText","formatPorcentageTrim","porcentage","max","integerValue","decimalValue","includes","porcentageParts","trimPorcentage","updatePriceInput","e","form","priceField","preventDefault","target"],"mappings":"qgYAqBI,OAAAA,EAAA,kBAAAC,KArBE,SAAUC,EACdC,GAAAH,IAAAI,EAAA,QAAyB,GACzBC,GAAYL,IAAAI,EAAA,SAAG,IAAI,IAAAE,EAAAN,IAAAO,EAAA,KAEnB,MAAMC,GAAUR,IAAAS,EAAA,MAAG,GAAGN,GAAQO,MAAM,MACpC,OADyCV,IAAAS,EAAA,MAEtCJ,GAAYL,IAAAI,EAAA,QAAG,MAAGJ,IAAAI,EAAA,QAAG,MAGS,QAHPE,EACxBE,EAAW,GACRG,WACAC,MAAM,8BAAsB,IAAAN,OAAA,EAF/BA,EAGIO,KAAK,OACRL,EAAW,IAAER,IAAAI,EAAA,QAAG,IAAMI,EAAW,KAAER,IAAAI,EAAA,QAAG,K,+SAUvCJ,IARHA,IAAAS,EAAA,KAEM,MAAMK,EAAoBA,CAACC,GAAKf,IAAAI,EAAA,QAAG,GAAGC,GAAYL,IAAAI,EAAA,SAAG,MAAgBJ,IAAAO,EAAA,KAC1E,IAAIS,GAAMhB,IAAAS,EAAA,KAAGQ,OAAOF,IAAOf,IAAAS,EAAA,KAC3BO,EAASA,EAAOE,MAAM,GAAI,GAAK,IAAMF,EAAOE,OAAO,GACnD,MAAMC,GAAOnB,IAAAS,EAAA,KAAGO,EAAOI,OAAOJ,EAAOK,OAAS,IACxCC,GAActB,IAAAS,EAAA,KAAGO,EAAOI,OAAO,EAAG,IAIxC,OAJ2CpB,IAAAS,EAAA,KACpB,MAAnBa,GAAwBtB,IAAAI,EAAA,QAAA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,EAAgB,GAAGlC,IAAAS,EAAA,MAClCuB,EAAe,IAAME,EAAgB,QACtClC,IAAAI,EAAA,SACD,MAAM+B,GAAcnC,IAAAS,EAAA,MAAGiB,EAAgBK,GAAcN,QAAQ,MAAO,KACpE,OADwEzB,IAAAS,EAAA,MACpE0B,GAEHnC,IAAAI,EAAA,SAAAJ,IAAAS,EAAA,MACET,IAAAI,EAAA,SAAA0B,IAAG9B,IAAAI,EAAA,SAAI+B,EAAeV,QAAQ,KAAM,KAA4BK,IAAK9B,IAAAI,EAAA,SAAAJ,IAAAS,EAAA,MAC/DqB,EAAInB,aACZX,IAAAI,EAAA,SAAAJ,IAAAS,EAAA,MACMsB,EAAeC,KANFhC,IAAAI,EAAA,SAAAJ,IAAAS,EAAA,MACX,QAMTT,IAAAS,EAAA,MAEK,MAAM2B,EAAmBA,CAACC,EAAWC,EAA+BC,KAAsBvC,IAAAO,EAAA,KAAAP,IAAAS,EAAA,MAC/F4B,EAAEG,iBACF,MAAMC,GAAMzC,IAAAS,EAAA,MAAG4B,EAAEI,QACX1B,GAAKf,IAAAS,EAAA,MAAGiB,EAAgBe,EAAO1B,QAAOf,IAAAS,EAAA,MAC5C6B,EAAKC,GAAchB,EAAoBR,K","file":"js/BuilderBorrowCalculator~RequestQuoteView~admin18~admin22~admin3~admin4~admin6.40dd1ec2.js","sourcesContent":["export function formatPrice(\n price: number | string = 0,\n showCurrency = true\n): string {\n const priceArray = `${price}`.split(\".\");\n return (\n (showCurrency ? \"$\" : \"\") +\n priceArray[0]\n .toString()\n .match(/.{1,3}(?=(.{3})*$)/g)\n ?.join(\",\") +\n (priceArray[1] ? \".\" + priceArray[1] : \"\")\n );\n}\n\nexport const formatStripePrice = (value = 0, showCurrency = true): string => {\n let string = String(value);\n string = string.slice(0, -2) + \".\" + string.slice(-2);\n const lastTwo = string.substr(string.length - 2);\n const firstCharacter = string.substr(0, 1);\n if (firstCharacter === \".\") {\n string = \"0\" + string;\n }\n if (lastTwo === \"00\") {\n return formatPrice(string.slice(0, -3), showCurrency);\n }\n return formatPrice(string, showCurrency);\n};\n\nexport const formatPriceToNumber = (price: string): number => {\n return parseFloat(price.replace(/,/g, '').replace(/\\$/g, ''));\n}\n\n\nexport const formatPriceTrim = (price: number | string = 0,) : string => {\n const trimText = price ? price.toString()\n .replace(/[^\\d.]/g, '')\n : undefined;\n if(!trimText || trimText === '$') {\n return '$0';\n }\n return formatPrice(trimText);\n};\n\nexport const formatPorcentageTrim = (porcentage: number | string = 0, max ?: number) : string => {\n let integerValue = porcentage;\n let decimalValue = '';\n if(typeof porcentage === 'string' && porcentage.includes('.')) {\n const porcentageParts = porcentage.split('.');\n integerValue = porcentageParts[0];\n decimalValue = '.' + porcentageParts[1];\n }\n const trimPorcentage = formatPriceTrim(integerValue).replace(/\\$/g, '');\n if(!trimPorcentage) {\n return '0.0';\n }\n if(max && trimPorcentage.replace(/,/g, '') as unknown as number >= max) {\n return max.toString();\n }\n return integerValue + decimalValue;\n};\n\nexport const updatePriceInput = (e : Event, form: Record, priceField: string) => {\n e.preventDefault();\n const target = e.target as HTMLInputElement;\n const value = formatPriceTrim(target.value);\n form[priceField] = formatPriceToNumber(value);\n}\n"],"sourceRoot":""}