{"version":3,"file":"NumberUtils.js","names":["defineDs","formatCurrency","amount","arguments","length","undefined","decimals","Number","isNaN","Intl","NumberFormat","style","currency","minimumFractionDigits","maximumFractionDigits","format","formatNumber","number","prefixNumberWithZeros","digits","numString","toString","padStart"],"sources":["DanskeSpil/Framework/NumberGames/Scripts/Helpers/Utils/NumberUtils.js"],"sourcesContent":["defineDs('DanskeSpil/Framework/NumberGames/Scripts/Helpers/Utils/NumberUtils', () => {\r\n\r\n\r\n /**\r\n * Formats a number as currency.\r\n * @param {number} [amount=0] - The amount to be formatted as currency.\r\n * @param {number} [decimals=0] - The number of decimal places to use in the formatting.\r\n * @returns {string} - The formatted currency string.\r\n */\r\n const formatCurrency = (amount = 0, decimals = 0) => {\r\n amount = Number(amount);\r\n if (isNaN(amount)) return '-';\r\n return new Intl.NumberFormat('da-DK', {\r\n style: 'currency',\r\n currency: 'DKK',\r\n minimumFractionDigits: decimals ? decimals : 0,\r\n maximumFractionDigits: decimals ? decimals : 0,\r\n }).format(amount);\r\n };\r\n\r\n\r\n /**\r\n * Formats a number to the Danish decimal format.\r\n * @param {number} [number=0] The number to be formatted.\r\n * @param {number} [decimals=0] The number of decimal places to include in the formatted number.\r\n * @returns {string} The formatted number as a string. If the input is not a valid number, returns '-'.\r\n */\r\n const formatNumber = (number = 0, decimals = 0) => {\r\n number = Number(number);\r\n if (isNaN(number)) return '-';\r\n return new Intl.NumberFormat('da-DK', {\r\n style: 'decimal',\r\n minimumFractionDigits: decimals ? decimals : 0,\r\n maximumFractionDigits: decimals ? decimals : 0,\r\n }).format(number);\r\n };\r\n\r\n\r\n /**\r\n * Prefixes a number with zeros.\r\n * @param {number} number - The number to be prefixed.\r\n * @param {number} [digits=2] - The total number of digits the result should have.\r\n * @returns {string} The prefixed number as a string.\r\n */\r\n const prefixNumberWithZeros = (number, digits = 2) => {\r\n if (typeof number !== 'number' || digits <= 0) return '';\r\n let numString = number.toString().padStart(digits, '0');\r\n return numString;\r\n };\r\n\r\n return {\r\n form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