const DEFAULT_CURRENCY_DECIMALS=2,CURRENCY_DECIMALS={BHD:3,BIF:0,BYR:0,CLF:4,CLP:0,DJF:0,GNF:0,IQD:3,ISK:0,JOD:3,JPY:0,KMF:0,KRW:0,KWD:3,LYD:3,MRO:5,OMR:3,PYG:0,RWF:0,TND:3,UGX:0,UYI:0,UYW:4,VND:0,VUV:0,XAF:0,XAG:0,XAU:0,XBA:0,XBB:0,XBC:0,XBD:0,XDR:0,XOF:0,XPD:0,XPF:0,XPT:0,XSU:0,XTS:0,XUA:0};function getCurrencyPrecision(currency){return CURRENCY_DECIMALS[currency.toUpperCase()]??2}function getCurrencyDivisor(currency){return Math.pow(10,getCurrencyPrecision(currency))}export function convertMoneyToMinorUnits(value,currency){const precision=getCurrencyPrecision(currency),multiplier=Math.pow(10,precision);if(!value||!value.trim())return null;const parts=value.trim().split(/[^0-9]/).filter(Boolean);if(parts.length===0)return null;const lastPart=parts[parts.length-1]??"",lastPartIsDecimal=precision>0&&parts.length>1&&lastPart.length<=precision;let wholeStr,fractionStr;lastPartIsDecimal?(fractionStr=lastPart,wholeStr=parts.slice(0,-1).join("")):(wholeStr=parts.join(""),fractionStr="");const whole=parseInt(wholeStr,10);if(isNaN(whole))return null;let fraction=0;if(precision>0&&fractionStr){const fractionStrLength=fractionStr.length;fraction=parseInt(fractionStr,10)||0,fraction=fraction*Math.pow(10,precision-fractionStrLength)}return whole*multiplier+fraction}function formatCents(moneyValue,thousandsSeparator,decimalSeparator,precision,divisor){const roundedNumber=(moneyValue/divisor).toFixed(precision);let[a,b]=roundedNumber.split(".");return a||(a="0"),b||(b=""),a=a.replace(/\d(?=(\d\d\d)+(?!\d))/g,digit=>digit+thousandsSeparator),precision<=0?a:a+decimalSeparator+b.padEnd(precision,"0")}export function formatMoney(moneyValue,format,currency){const currencyPrecision=getCurrencyPrecision(currency),divisor=getCurrencyDivisor(currency);return format.replace(/{{\s*(\w+)\s*}}/g,(_,placeholder)=>{if(typeof placeholder!="string")return"";if(placeholder==="currency")return currency;let thousandsSeparator=",",decimalSeparator=".",precision=currencyPrecision;switch(placeholder){case"amount":break;case"amount_no_decimals":precision=0;break;case"amount_with_comma_separator":thousandsSeparator=".",decimalSeparator=",";break;case"amount_no_decimals_with_comma_separator":thousandsSeparator=".",precision=0;break;case"amount_no_decimals_with_space_separator":thousandsSeparator=" ",precision=0;break;case"amount_with_space_separator":thousandsSeparator=" ",decimalSeparator=",";break;case"amount_with_period_and_space_separator":thousandsSeparator=" ",decimalSeparator=".";break;case"amount_with_apostrophe_separator":thousandsSeparator="'",decimalSeparator=".";break;default:break}return formatCents(moneyValue,thousandsSeparator,decimalSeparator,precision,divisor)})}
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/money-formatting.js.map?v=1783078800
