n2words 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/languages/am-Latn.js +2 -2
  3. package/dist/languages/am-Latn.js.map +1 -1
  4. package/dist/languages/am.js +2 -2
  5. package/dist/languages/am.js.map +1 -1
  6. package/dist/languages/ar.js +1 -1
  7. package/dist/languages/az.js +2 -2
  8. package/dist/languages/az.js.map +1 -1
  9. package/dist/languages/bn.js +2 -2
  10. package/dist/languages/bn.js.map +1 -1
  11. package/dist/languages/cs.js +2 -2
  12. package/dist/languages/cs.js.map +1 -1
  13. package/dist/languages/da.js +2 -2
  14. package/dist/languages/da.js.map +1 -1
  15. package/dist/languages/de.js +2 -2
  16. package/dist/languages/de.js.map +1 -1
  17. package/dist/languages/el.js +2 -2
  18. package/dist/languages/el.js.map +1 -1
  19. package/dist/languages/en.js +2 -2
  20. package/dist/languages/en.js.map +1 -1
  21. package/dist/languages/es.js +2 -2
  22. package/dist/languages/es.js.map +1 -1
  23. package/dist/languages/fa.js +1 -1
  24. package/dist/languages/fi.js +2 -2
  25. package/dist/languages/fi.js.map +1 -1
  26. package/dist/languages/fil.js +2 -2
  27. package/dist/languages/fil.js.map +1 -1
  28. package/dist/languages/fr-BE.js +2 -2
  29. package/dist/languages/fr-BE.js.map +1 -1
  30. package/dist/languages/fr.js +2 -2
  31. package/dist/languages/fr.js.map +1 -1
  32. package/dist/languages/gu.js +2 -2
  33. package/dist/languages/gu.js.map +1 -1
  34. package/dist/languages/ha.js +2 -2
  35. package/dist/languages/ha.js.map +1 -1
  36. package/dist/languages/hbo.js +2 -2
  37. package/dist/languages/hbo.js.map +1 -1
  38. package/dist/languages/he.js +2 -2
  39. package/dist/languages/he.js.map +1 -1
  40. package/dist/languages/hi.js +2 -2
  41. package/dist/languages/hi.js.map +1 -1
  42. package/dist/languages/hr.js +2 -2
  43. package/dist/languages/hr.js.map +1 -1
  44. package/dist/languages/hu.js +1 -1
  45. package/dist/languages/id.js +2 -2
  46. package/dist/languages/id.js.map +1 -1
  47. package/dist/languages/it.js +2 -2
  48. package/dist/languages/it.js.map +1 -1
  49. package/dist/languages/ja.js +2 -2
  50. package/dist/languages/ja.js.map +1 -1
  51. package/dist/languages/ka.js +3 -0
  52. package/dist/languages/ka.js.map +1 -0
  53. package/dist/languages/kn.js +2 -2
  54. package/dist/languages/kn.js.map +1 -1
  55. package/dist/languages/ko.js +2 -2
  56. package/dist/languages/ko.js.map +1 -1
  57. package/dist/languages/lt.js +2 -2
  58. package/dist/languages/lt.js.map +1 -1
  59. package/dist/languages/lv.js +2 -2
  60. package/dist/languages/lv.js.map +1 -1
  61. package/dist/languages/mr.js +2 -2
  62. package/dist/languages/mr.js.map +1 -1
  63. package/dist/languages/ms.js +2 -2
  64. package/dist/languages/ms.js.map +1 -1
  65. package/dist/languages/nb.js +2 -2
  66. package/dist/languages/nb.js.map +1 -1
  67. package/dist/languages/nl.js +2 -2
  68. package/dist/languages/nl.js.map +1 -1
  69. package/dist/languages/pa.js +2 -2
  70. package/dist/languages/pa.js.map +1 -1
  71. package/dist/languages/pl.js +2 -2
  72. package/dist/languages/pl.js.map +1 -1
  73. package/dist/languages/pt.js +2 -2
  74. package/dist/languages/pt.js.map +1 -1
  75. package/dist/languages/ro.js +1 -1
  76. package/dist/languages/ru.js +2 -2
  77. package/dist/languages/ru.js.map +1 -1
  78. package/dist/languages/sr-Cyrl.js +2 -2
  79. package/dist/languages/sr-Cyrl.js.map +1 -1
  80. package/dist/languages/sr-Latn.js +2 -2
  81. package/dist/languages/sr-Latn.js.map +1 -1
  82. package/dist/languages/sv.js +2 -2
  83. package/dist/languages/sv.js.map +1 -1
  84. package/dist/languages/sw.js +1 -1
  85. package/dist/languages/ta.js +2 -2
  86. package/dist/languages/ta.js.map +1 -1
  87. package/dist/languages/te.js +2 -2
  88. package/dist/languages/te.js.map +1 -1
  89. package/dist/languages/th.js +1 -1
  90. package/dist/languages/tr.js +2 -2
  91. package/dist/languages/tr.js.map +1 -1
  92. package/dist/languages/uk.js +2 -2
  93. package/dist/languages/uk.js.map +1 -1
  94. package/dist/languages/ur.js +2 -2
  95. package/dist/languages/ur.js.map +1 -1
  96. package/dist/languages/vi.js +2 -2
  97. package/dist/languages/vi.js.map +1 -1
  98. package/dist/languages/yo.js +3 -0
  99. package/dist/languages/yo.js.map +1 -0
  100. package/dist/languages/zh-Hans.js +1 -1
  101. package/dist/languages/zh-Hant.js +1 -1
  102. package/dist/n2words.js +2 -2
  103. package/dist/n2words.js.map +1 -1
  104. package/lib/languages/am-Latn.js +4 -9
  105. package/lib/languages/am.js +4 -9
  106. package/lib/languages/az.js +4 -9
  107. package/lib/languages/bn.js +51 -30
  108. package/lib/languages/cs.js +9 -26
  109. package/lib/languages/da.js +6 -13
  110. package/lib/languages/de.js +21 -33
  111. package/lib/languages/el.js +6 -13
  112. package/lib/languages/en.js +44 -58
  113. package/lib/languages/es.js +10 -30
  114. package/lib/languages/fi.js +6 -13
  115. package/lib/languages/fil.js +6 -17
  116. package/lib/languages/fr-BE.js +17 -26
  117. package/lib/languages/fr.js +18 -31
  118. package/lib/languages/gu.js +43 -30
  119. package/lib/languages/ha.js +4 -9
  120. package/lib/languages/hbo.js +7 -25
  121. package/lib/languages/he.js +7 -18
  122. package/lib/languages/hi.js +55 -30
  123. package/lib/languages/hr.js +61 -55
  124. package/lib/languages/id.js +8 -13
  125. package/lib/languages/it.js +64 -99
  126. package/lib/languages/ja.js +8 -20
  127. package/lib/languages/ka.d.ts +17 -0
  128. package/lib/languages/ka.js +291 -0
  129. package/lib/languages/kn.js +43 -30
  130. package/lib/languages/ko.js +6 -13
  131. package/lib/languages/lt.js +6 -15
  132. package/lib/languages/lv.js +6 -15
  133. package/lib/languages/mr.js +43 -30
  134. package/lib/languages/ms.js +8 -13
  135. package/lib/languages/nb.js +13 -23
  136. package/lib/languages/nl.js +11 -29
  137. package/lib/languages/pa.js +32 -37
  138. package/lib/languages/pl.js +7 -20
  139. package/lib/languages/pt.js +17 -31
  140. package/lib/languages/ru.js +64 -59
  141. package/lib/languages/sr-Cyrl.js +58 -52
  142. package/lib/languages/sr-Latn.js +58 -52
  143. package/lib/languages/sv.js +14 -24
  144. package/lib/languages/ta.js +55 -42
  145. package/lib/languages/te.js +33 -41
  146. package/lib/languages/tr.js +7 -18
  147. package/lib/languages/uk.js +61 -55
  148. package/lib/languages/ur.js +32 -37
  149. package/lib/languages/vi.js +23 -43
  150. package/lib/languages/yo.d.ts +7 -0
  151. package/lib/languages/yo.js +303 -0
  152. package/lib/n2words.d.ts +3 -1
  153. package/lib/n2words.js +4 -0
  154. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
- /*! n2words/nl v3.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,n;e=this,n=function(e){"use strict";function n(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function t(e){const[n,t]=e.toLowerCase().split("e"),i=parseInt(t,10),r=n.indexOf("."),o=-1===r?n:n.slice(0,r)+n.slice(r+1),u=(-1===r?n.length:r)+i;return u>=o.length?o+"0".repeat(u-o.length):u<=0?"0."+"0".repeat(-u)+o:o.slice(0,u)+"."+o.slice(u)}const i=["","een","twee","drie","vier","vijf","zes","zeven","acht","negen"],r=["tien","elf","twaalf","dertien","veertien","vijftien","zestien","zeventien","achttien","negentien"],o=["","","twintig","dertig","veertig","vijftig","zestig","zeventig","tachtig","negentig"],u="honderd",l=["duizend","miljoen","miljard","biljoen","biljard","triljoen","triljard","quadriljoen","quadriljard"];function s(e,n){if(0===e)return"";const t=e%10,l=Math.floor(e/10)%10,s=Math.floor(e/100),c=e%100;let f="";if(s>0&&(f=1===s?u:i[s]+u),0===c);else if(c<10)f+=s>0&&n?"en"+i[c]:i[c];else if(c<20)f+=s>0&&n&&c<13?"en"+r[t]:r[t];else if(0===t)f+=o[l];else{const e=i[t],n=e.endsWith("e")?"ën":"en";f+=e+n+o[l]}return f}const c=new Array(1e3);for(let e=0;e<1e3;e++)c[e]=s(e,!1);const f=new Array(1e3);for(let e=0;e<1e3;e++)f[e]=s(e,!0);function a(e,n){if(0n===e)return"nul";const{accentOne:t,includeOptionalAnd:i,noHundredPairing:r}=n,o=i?f:c,s=e=>t?e.replace(/\been\b/g,"één"):e;if(e<1000n)return s(o[Number(e)]);if(!r&&e>=1100n&&e<10000n){const n=Number(e/100n),t=Number(e%100n);if(n%10!=0){let e=o[n]+u;if(t>0){const n=o[t];e+=i&&t<13?" en "+n:" "+n}return s(e)}}if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n);let r;if(r=1===n?l[0]:o[n]+l[0],t>0){const e=o[t];r+=i&&t<13?" en "+e:" "+e}return s(r)}return s(function(e,n){const{includeOptionalAnd:t}=n,i=t?f:c,r=[];let o=e;for(;o>0n;)r.push(Number(o%1000n)),o/=1000n;let u="",s=!1;for(let e=r.length-1;e>=0;e--){const n=r[e];if(0!==n)if(0===e){const e=i[n];u?u+=s&&t&&n<13?" en "+e:" "+e:u=e,s=!1}else if(1===e)u&&(u+=" "),u+=1===n?l[0]:i[n]+l[0],s=!0;else{const t=l[e-1];u&&(u+=" "),u+=1===n?"een "+t:i[n]+" "+t,s=!0}}return u}(e,n))}e.nl=function(e,i){i=function(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}(i);const{isNegative:r,integerPart:o,decimalPart:u}=function(e){const i=typeof e;if("bigint"===i)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===i){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:n(function(e){const n=e.toString();return n.includes("e")||n.includes("E")?t(n):n}(e))}if("string"===i)return n(function(e){const n=e.trim();if(0===n.length||Number.isNaN(Number(n)))throw new Error(`Invalid number format: "${e}"`);return n.includes("e")||n.includes("E")?t(n):n}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(e),l={accentOne:!1!==i.accentOne,includeOptionalAnd:i.includeOptionalAnd||!1,noHundredPairing:i.noHundredPairing||!1};let s="";return r&&(s="min "),s+=a(o,l),u&&(s+=" komma "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+="nul",i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=a(BigInt(r),{...n,noHundredPairing:!0})),t}(u,l)),s}},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/nl v3.1.0 | MIT License | github.com/forzagreen/n2words */
2
+ var e,n;e=this,n=function(e){"use strict";function n(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function t(e){const[n,t]=e.toLowerCase().split("e"),i=parseInt(t,10),r=n.indexOf("."),o=-1===r?n:n.slice(0,r)+n.slice(r+1),u=(-1===r?n.length:r)+i;return u>=o.length?o+"0".repeat(u-o.length):u<=0?"0."+"0".repeat(-u)+o:o.slice(0,u)+"."+o.slice(u)}const i=["","een","twee","drie","vier","vijf","zes","zeven","acht","negen"],r=["tien","elf","twaalf","dertien","veertien","vijftien","zestien","zeventien","achttien","negentien"],o=["","","twintig","dertig","veertig","vijftig","zestig","zeventig","tachtig","negentig"],u="honderd",l=["duizend","miljoen","miljard","biljoen","biljard","triljoen","triljard","quadriljoen","quadriljard"];function s(e,n){if(0===e)return"";const t=e%10,l=Math.floor(e/10)%10,s=Math.floor(e/100),c=e%100;let f="";if(s>0&&(f=1===s?u:i[s]+u),0===c);else if(c<10)f+=s>0&&n?"en"+i[c]:i[c];else if(c<20)f+=s>0&&n&&c<13?"en"+r[t]:r[t];else if(0===t)f+=o[l];else{const e=i[t],n=e.endsWith("e")?"ën":"en";f+=e+n+o[l]}return f}function c(e,n){if(0n===e)return"nul";const{accentOne:t,includeOptionalAnd:i,noHundredPairing:r}=n,o=e=>t?e.replace(/\been\b/g,"één"):e;if(e<1000n)return o(s(Number(e),i));if(!r&&e>=1100n&&e<10000n){const n=Number(e/100n),t=Number(e%100n);if(n%10!=0){let e=s(n,i)+u;if(t>0){const n=s(t,i);e+=i&&t<13?" en "+n:" "+n}return o(e)}}if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n);let r;if(r=1===n?l[0]:s(n,i)+l[0],t>0){const e=s(t,i);r+=i&&t<13?" en "+e:" "+e}return o(r)}return o(function(e,n){const{includeOptionalAnd:t}=n,i=[];let r=e;for(;r>0n;)i.push(Number(r%1000n)),r/=1000n;let o="",u=!1;for(let e=i.length-1;e>=0;e--){const n=i[e];if(0!==n)if(0===e){const e=s(n,t);o?o+=u&&t&&n<13?" en "+e:" "+e:o=e,u=!1}else if(1===e)o&&(o+=" "),o+=1===n?l[0]:s(n,t)+l[0],u=!0;else{const i=l[e-1];o&&(o+=" "),o+=1===n?"een "+i:s(n,t)+" "+i,u=!0}}return o}(e,n))}e.nl=function(e,i){i=function(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}(i);const{isNegative:r,integerPart:o,decimalPart:u}=function(e){const i=typeof e;if("bigint"===i)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===i){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:n(function(e){const n=e.toString();return n.includes("e")||n.includes("E")?t(n):n}(e))}if("string"===i)return n(function(e){const n=e.trim();if(0===n.length||Number.isNaN(Number(n)))throw new Error(`Invalid number format: "${e}"`);return n.includes("e")||n.includes("E")?t(n):n}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(e),l={accentOne:!1!==i.accentOne,includeOptionalAnd:i.includeOptionalAnd||!1,noHundredPairing:i.noHundredPairing||!1};let s="";return r&&(s="min "),s+=c(o,l),u&&(s+=" komma "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+="nul",i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=c(BigInt(r),{...n,noHundredPairing:!0})),t}(u,l)),s}},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
3
3
  //# sourceMappingURL=nl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nl.js","sources":["../../lib/utils/parse-numeric.js","../../lib/languages/nl.js","../../lib/utils/validate-options.js","../../lib/utils/is-plain-object.js"],"sourcesContent":["/**\n * Numeric value parsing utility.\n * Transforms user input (number, string, or bigint) into normalized components.\n * @module parse-numeric\n */\n\n/**\n * Parses a numeric value into its components.\n * @param {number|string|bigint} value\n * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}\n * @throws {TypeError} If value is not number, string, or bigint\n * @throws {Error} If value is not a valid number format\n */\nexport function parseNumericValue (value) {\n const type = typeof value\n\n // BigInt: simplest case\n if (type === 'bigint') {\n return value < 0n\n ? { isNegative: true, integerPart: -value }\n : { isNegative: false, integerPart: value }\n }\n\n // Number: fast path for safe integers\n if (type === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error('Number must be finite (NaN and Infinity are not supported)')\n }\n if (Number.isSafeInteger(value)) {\n return value < 0\n ? { isNegative: true, integerPart: BigInt(-value) }\n : { isNegative: false, integerPart: BigInt(value) }\n }\n return parseNumericString(numberToString(value))\n }\n\n // String input\n if (type === 'string') {\n return parseNumericString(normalizeString(value))\n }\n\n throw new TypeError(\n `Invalid value type: expected number, string, or bigint, received ${type}`\n )\n}\n\n/**\n * Converts a number to decimal string, expanding scientific notation if needed.\n */\nfunction numberToString (value) {\n const str = value.toString()\n return (str.includes('e') || str.includes('E'))\n ? expandScientificNotation(str)\n : str\n}\n\n/**\n * Validates and normalizes a string numeric input.\n */\nfunction normalizeString (value) {\n const trimmed = value.trim()\n if (trimmed.length === 0 || Number.isNaN(Number(trimmed))) {\n throw new Error(`Invalid number format: \"${value}\"`)\n }\n return (trimmed.includes('e') || trimmed.includes('E'))\n ? expandScientificNotation(trimmed)\n : trimmed\n}\n\n/**\n * Parses a normalized numeric string into components.\n */\nfunction parseNumericString (str) {\n const isNegative = str[0] === '-'\n if (isNegative) str = str.slice(1)\n\n const dotIndex = str.indexOf('.')\n if (dotIndex === -1) {\n return { isNegative, integerPart: BigInt(str) }\n }\n\n const integerStr = str.slice(0, dotIndex) || '0'\n const decimalPart = str.slice(dotIndex + 1)\n return { isNegative, integerPart: BigInt(integerStr), decimalPart }\n}\n\n/**\n * Expands scientific notation to decimal form (e.g., \"1e21\" → \"1000...\").\n */\nfunction expandScientificNotation (str) {\n const [mantissa, expStr] = str.toLowerCase().split('e')\n const exp = parseInt(expStr, 10)\n\n const dotIndex = mantissa.indexOf('.')\n const digits = dotIndex === -1\n ? mantissa\n : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)\n const integerLength = dotIndex === -1 ? mantissa.length : dotIndex\n const newDotPosition = integerLength + exp\n\n if (newDotPosition >= digits.length) {\n return digits + '0'.repeat(newDotPosition - digits.length)\n }\n if (newDotPosition <= 0) {\n return '0.' + '0'.repeat(-newDotPosition) + digits\n }\n return digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)\n}\n","/**\n * Dutch language converter - Functional Implementation\n *\n * A performance-optimized number-to-words converter using precomputed lookup tables.\n * Self-contained module with its own input validation, ready for subpath exports.\n *\n * Key optimization: Precompute all segment values (0-999) at module load.\n * This eliminates all per-call string manipulation for segment conversion.\n *\n * Dutch-specific rules (handled in precomputation):\n * - Inverted tens-ones: eenentwintig (one-and-twenty)\n * - \"ën\" connector when ones ends in 'e' (twee, drie)\n * - Compound words without spaces\n * - Hundred pairing for 1100-9999 (elfhonderd style)\n * - \"één\" vs \"een\" (accentOne option)\n * - Optional \"en\" separator (includeOptionalAnd option)\n * - Long scale with -ard forms\n */\n\nimport { parseNumericValue } from '../utils/parse-numeric.js'\nimport { validateOptions } from '../utils/validate-options.js'\n\n// ============================================================================\n// Vocabulary (module-level constants)\n// ============================================================================\n\nconst ONES = ['', 'een', 'twee', 'drie', 'vier', 'vijf', 'zes', 'zeven', 'acht', 'negen']\nconst TEENS = ['tien', 'elf', 'twaalf', 'dertien', 'veertien', 'vijftien', 'zestien', 'zeventien', 'achttien', 'negentien']\nconst TENS = ['', '', 'twintig', 'dertig', 'veertig', 'vijftig', 'zestig', 'zeventig', 'tachtig', 'negentig']\n\nconst HUNDRED = 'honderd'\n\n// Scale words (long scale with -ard forms)\nconst SCALES = ['duizend', 'miljoen', 'miljard', 'biljoen', 'biljard', 'triljoen', 'triljard', 'quadriljoen', 'quadriljard']\n\nconst ZERO = 'nul'\nconst NEGATIVE = 'min'\nconst DECIMAL_SEP = 'komma'\n\n// ============================================================================\n// Precomputed Lookup Tables (built once at module load)\n// ============================================================================\n\n/**\n * Builds segment word for 0-999.\n * @param {number} n - Segment value\n * @param {boolean} withAnd - Include \"en\" for values < 13 after hundreds\n * @returns {string} Dutch word (compound, no spaces)\n */\nfunction buildSegment (n, withAnd) {\n if (n === 0) return ''\n\n const ones = n % 10\n const tens = Math.floor(n / 10) % 10\n const hundreds = Math.floor(n / 100)\n const tensOnes = n % 100\n\n let result = ''\n\n // Hundreds\n if (hundreds > 0) {\n if (hundreds === 1) {\n result = HUNDRED\n } else {\n result = ONES[hundreds] + HUNDRED\n }\n }\n\n // Tens and ones\n if (tensOnes === 0) {\n // Just hundreds\n } else if (tensOnes < 10) {\n // Single digit - add \"en\" if withAnd and after hundreds\n if (hundreds > 0 && withAnd) {\n result += 'en' + ONES[tensOnes]\n } else {\n result += ONES[tensOnes]\n }\n } else if (tensOnes < 20) {\n // Teens - add \"en\" if withAnd and after hundreds and < 13\n if (hundreds > 0 && withAnd && tensOnes < 13) {\n result += 'en' + TEENS[ones]\n } else {\n result += TEENS[ones]\n }\n } else {\n // 20-99: Dutch inverts with connector\n if (ones === 0) {\n result += TENS[tens]\n } else {\n // \"ën\" if ones ends in 'e' (twee, drie)\n const onesWord = ONES[ones]\n const connector = onesWord.endsWith('e') ? 'ën' : 'en'\n result += onesWord + connector + TENS[tens]\n }\n }\n\n return result\n}\n\n// Precompute all 1000 segment words (0-999) - standard form\nconst SEGMENTS = new Array(1000)\nfor (let i = 0; i < 1000; i++) {\n SEGMENTS[i] = buildSegment(i, false)\n}\n\n// Precompute all 1000 segment words (0-999) - with optional \"en\"\nconst SEGMENTS_WITH_AND = new Array(1000)\nfor (let i = 0; i < 1000; i++) {\n SEGMENTS_WITH_AND[i] = buildSegment(i, true)\n}\n\n// ============================================================================\n// Conversion Functions\n// ============================================================================\n\n/**\n * Converts a non-negative integer to Dutch words.\n *\n * @param {bigint} n - Non-negative integer to convert\n * @param {Object} options - Conversion options\n * @returns {string} Dutch words\n */\nfunction integerToWords (n, options) {\n if (n === 0n) return ZERO\n\n const { accentOne, includeOptionalAnd, noHundredPairing } = options\n const segments = includeOptionalAnd ? SEGMENTS_WITH_AND : SEGMENTS\n\n // Apply één/een replacement\n const applyAccent = (word) => {\n if (accentOne) {\n return word.replace(/\\been\\b/g, 'één')\n }\n return word\n }\n\n // Fast path: numbers < 1000 (direct lookup)\n if (n < 1000n) {\n return applyAccent(segments[Number(n)])\n }\n\n // Hundred pairing for 1100-9999\n if (!noHundredPairing && n >= 1100n && n < 10000n) {\n const high = Number(n / 100n)\n const low = Number(n % 100n)\n\n // Only use pairing when high is not a multiple of 10\n if (high % 10 !== 0) {\n let result = segments[high] + HUNDRED\n if (low > 0) {\n const lowWord = segments[low]\n if (includeOptionalAnd && low < 13) {\n result += ' en ' + lowWord\n } else {\n result += ' ' + lowWord\n }\n }\n return applyAccent(result)\n }\n }\n\n // Fast path: numbers < 1,000,000 (thousands)\n if (n < 1_000_000n) {\n const thousands = Number(n / 1000n)\n const remainder = Number(n % 1000n)\n\n let result\n if (thousands === 1) {\n // \"duizend\" not \"eenduizend\"\n result = SCALES[0]\n } else {\n // Compound: \"vijfduizend\"\n result = segments[thousands] + SCALES[0]\n }\n\n if (remainder > 0) {\n const remainderWord = segments[remainder]\n if (includeOptionalAnd && remainder < 13) {\n result += ' en ' + remainderWord\n } else {\n result += ' ' + remainderWord\n }\n }\n\n return applyAccent(result)\n }\n\n // For numbers >= 1,000,000, use scale decomposition\n return applyAccent(buildLargeNumberWords(n, options))\n}\n\n/**\n * Builds words for numbers >= 1,000,000.\n * Uses BigInt division for faster segment extraction (4x faster than string slicing).\n *\n * @param {bigint} n - Number >= 1,000,000\n * @param {Object} options - Conversion options\n * @returns {string} Dutch words\n */\nfunction buildLargeNumberWords (n, options) {\n const { includeOptionalAnd } = options\n const segmentLookup = includeOptionalAnd ? SEGMENTS_WITH_AND : SEGMENTS\n\n // Extract segments using BigInt division (faster than string slicing)\n // Segments stored least-significant first (index 0 = ones, 1 = thousands, etc.)\n const segmentValues = []\n let temp = n\n while (temp > 0n) {\n segmentValues.push(Number(temp % 1000n))\n temp = temp / 1000n\n }\n\n // Build result string directly (avoids object allocation and join)\n let result = ''\n let prevWasScale = false\n\n for (let i = segmentValues.length - 1; i >= 0; i--) {\n const segment = segmentValues[i]\n if (segment === 0) continue\n\n if (i === 0) {\n // Units segment\n const word = segmentLookup[segment]\n if (result) {\n if (prevWasScale && includeOptionalAnd && segment < 13) {\n result += ' en ' + word\n } else {\n result += ' ' + word\n }\n } else {\n result = word\n }\n prevWasScale = false\n } else if (i === 1) {\n // Thousands - compound\n if (result) result += ' '\n if (segment === 1) {\n result += SCALES[0]\n } else {\n result += segmentLookup[segment] + SCALES[0]\n }\n prevWasScale = true\n } else {\n // Million and above - space around scale\n const scaleWord = SCALES[i - 1]\n if (result) result += ' '\n if (segment === 1) {\n result += 'een ' + scaleWord\n } else {\n result += segmentLookup[segment] + ' ' + scaleWord\n }\n prevWasScale = true\n }\n }\n\n return result\n}\n\n/**\n * Converts decimal digits to Dutch words.\n *\n * @param {string} decimalPart - Decimal digits (without the point)\n * @param {Object} options - Conversion options\n * @returns {string} Dutch words for decimal part\n */\nfunction decimalPartToWords (decimalPart, options) {\n let result = ''\n\n // Handle leading zeros\n let i = 0\n while (i < decimalPart.length && decimalPart[i] === '0') {\n if (result) result += ' '\n result += ZERO\n i++\n }\n\n // Convert remainder as a single number\n const remainder = decimalPart.slice(i)\n if (remainder) {\n if (result) result += ' '\n const word = integerToWords(BigInt(remainder), { ...options, noHundredPairing: true })\n result += word\n }\n\n return result\n}\n\n/**\n * Converts a numeric value to Dutch words.\n *\n * This is the main public API. It accepts any valid numeric input\n * (number, string, or bigint) and handles parsing internally.\n *\n * @param {number | string | bigint} value - The numeric value to convert\n * @param {Object} [options] - Optional configuration\n * @param {boolean} [options.accentOne=true] - Use \"één\" instead of \"een\"\n * @param {boolean} [options.includeOptionalAnd=false] - Include \"en\" before small numbers\n * @param {boolean} [options.noHundredPairing=false] - Disable hundred pairing (1104→duizend honderdvier)\n * @returns {string} The number in Dutch words\n * @throws {TypeError} If value is not a valid numeric type\n * @throws {Error} If value is not a valid number format\n *\n * @example\n * toWords(21) // 'eenentwintig'\n * toWords(1) // 'één'\n * toWords(1, {accentOne: false}) // 'een'\n * toWords(1104) // 'elfhonderd vier'\n */\nfunction toWords (value, options) {\n options = validateOptions(options)\n const { isNegative, integerPart, decimalPart } = parseNumericValue(value)\n\n const opts = {\n accentOne: options.accentOne !== false, // default true\n includeOptionalAnd: options.includeOptionalAnd || false,\n noHundredPairing: options.noHundredPairing || false\n }\n\n let result = ''\n\n if (isNegative) {\n result = NEGATIVE + ' '\n }\n\n result += integerToWords(integerPart, opts)\n\n if (decimalPart) {\n result += ' ' + DECIMAL_SEP + ' ' + decimalPartToWords(decimalPart, opts)\n }\n\n return result\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\nexport { toWords }\n","import { isPlainObject } from './is-plain-object.js'\n\n/**\n * Validates and normalizes the options parameter.\n *\n * @param {*} options The options value to validate\n * @returns {Object} A valid options object (empty object if undefined)\n * @throws {TypeError} If options is not undefined or a plain object\n */\nexport function validateOptions (options) {\n if (options === undefined) return {}\n if (isPlainObject(options)) return options\n throw new TypeError(\n `Invalid options: expected plain object or undefined, got ${typeof options}`\n )\n}\n","/**\n * Checks if a value is a plain object (not null, array, or other object types).\n *\n * A plain object is one created by:\n * - Object literal: `{}`\n * - Object.create(null): null-prototype object\n *\n * This excludes arrays, class instances, Map, Set, and other object types.\n *\n * @param {*} value Value to check\n * @returns {boolean} True if value is a plain object\n */\nexport function isPlainObject (value) {\n if (value === null || typeof value !== 'object') return false\n const proto = Object.getPrototypeOf(value)\n return proto === null || proto === Object.prototype\n}\n"],"names":["parseNumericString","str","isNegative","slice","dotIndex","indexOf","integerPart","BigInt","integerStr","decimalPart","expandScientificNotation","mantissa","expStr","toLowerCase","split","exp","parseInt","digits","newDotPosition","length","repeat","ONES","TEENS","TENS","HUNDRED","SCALES","buildSegment","n","withAnd","ones","tens","Math","floor","hundreds","tensOnes","result","onesWord","connector","endsWith","SEGMENTS","Array","i","SEGMENTS_WITH_AND","integerToWords","options","accentOne","includeOptionalAnd","noHundredPairing","segments","applyAccent","word","replace","Number","high","low","lowWord","thousands","remainder","remainderWord","segmentLookup","segmentValues","temp","push","prevWasScale","segment","scaleWord","buildLargeNumberWords","value","undefined","proto","Object","getPrototypeOf","prototype","isPlainObject","TypeError","validateOptions","type","isFinite","Error","isSafeInteger","toString","includes","numberToString","trimmed","trim","isNaN","normalizeString","parseNumericValue","opts","NEGATIVE","decimalPartToWords"],"mappings":";0CAwEA,SAASA,EAAoBC,GAC3B,MAAMC,EAAwB,MAAXD,EAAI,GACnBC,IAAYD,EAAMA,EAAIE,MAAM,IAEhC,MAAMC,EAAWH,EAAII,QAAQ,KAC7B,IAAiB,IAAbD,EACF,MAAO,CAAEF,aAAYI,YAAaC,OAAON,IAG3C,MAAMO,EAAaP,EAAIE,MAAM,EAAGC,IAAa,IACvCK,EAAcR,EAAIE,MAAMC,EAAW,GACzC,MAAO,CAAEF,aAAYI,YAAaC,OAAOC,GAAaC,cACxD,CAKA,SAASC,EAA0BT,GACjC,MAAOU,EAAUC,GAAUX,EAAIY,cAAcC,MAAM,KAC7CC,EAAMC,SAASJ,EAAQ,IAEvBR,EAAWO,EAASN,QAAQ,KAC5BY,OAASb,EACXO,EACAA,EAASR,MAAM,EAAGC,GAAYO,EAASR,MAAMC,EAAW,GAEtDc,IAD6B,IAAbd,EAAkBO,EAASQ,OAASf,GACnBW,EAEvC,OAAIG,GAAkBD,EAAOE,OACpBF,EAAS,IAAIG,OAAOF,EAAiBD,EAAOE,QAEjDD,GAAkB,EACb,KAAO,IAAIE,QAAQF,GAAkBD,EAEvCA,EAAOd,MAAM,EAAGe,GAAkB,IAAMD,EAAOd,MAAMe,EAC9D,CCjFA,MAAMG,EAAO,CAAC,GAAI,MAAO,OAAQ,OAAQ,OAAQ,OAAQ,MAAO,QAAS,OAAQ,SAC3EC,EAAQ,CAAC,OAAQ,MAAO,SAAU,UAAW,WAAY,WAAY,UAAW,YAAa,WAAY,aACzGC,EAAO,CAAC,GAAI,GAAI,UAAW,SAAU,UAAW,UAAW,SAAU,WAAY,UAAW,YAE5FC,EAAU,UAGVC,EAAS,CAAC,UAAW,UAAW,UAAW,UAAW,UAAW,WAAY,WAAY,cAAe,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IAAIL,MAAM,2BAA2BX,MAE7C,OAAQgB,EAAQF,SAAS,MAAQE,EAAQF,SAAS,KAC9CvE,EAAyByE,GACzBA,CACN,CA7B8BG,CAAgBnB,IAG5C,MAAM,IAAIO,UACR,oEAAoEE,IAExE,CC2QmDW,CAAkBpB,GAE7DqB,EAAO,CACX3C,WAAiC,IAAtBD,EAAQC,UACnBC,mBAAoBF,EAAQE,qBAAsB,EAClDC,iBAAkBH,EAAQG,mBAAoB,GAGhD,IAAIZ,EAAS,GAYb,OAVIjC,IACFiC,EAASsD,QAGXtD,GAAUQ,EAAerC,EAAakF,GAElC/E,IACF0B,GAAU,UA9Dd,SAA6B1B,EAAamC,GACxC,IAAIT,EAAS,GAGTM,EAAI,EACR,KAAOA,EAAIhC,EAAYU,QAA6B,MAAnBV,EAAYgC,IACvCN,IAAQA,GAAU,KACtBA,GA9OS,MA+OTM,IAIF,MAAMgB,EAAYhD,EAAYN,MAAMsC,GAOpC,OANIgB,IACEtB,IAAQA,GAAU,KAEtBA,GADaQ,EAAepC,OAAOkD,GAAY,IAAKb,EAASG,kBAAkB,KAI1EZ,CACT,CA0CwCuD,CAAmBjF,EAAa+E,IAG/DrD,CACT"}
1
+ {"version":3,"file":"nl.js","sources":["../../lib/utils/parse-numeric.js","../../lib/languages/nl.js","../../lib/utils/validate-options.js","../../lib/utils/is-plain-object.js"],"sourcesContent":["/**\n * Numeric value parsing utility.\n * Transforms user input (number, string, or bigint) into normalized components.\n * @module parse-numeric\n */\n\n/**\n * Parses a numeric value into its components.\n * @param {number|string|bigint} value\n * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}\n * @throws {TypeError} If value is not number, string, or bigint\n * @throws {Error} If value is not a valid number format\n */\nexport function parseNumericValue (value) {\n const type = typeof value\n\n // BigInt: simplest case\n if (type === 'bigint') {\n return value < 0n\n ? { isNegative: true, integerPart: -value }\n : { isNegative: false, integerPart: value }\n }\n\n // Number: fast path for safe integers\n if (type === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error('Number must be finite (NaN and Infinity are not supported)')\n }\n if (Number.isSafeInteger(value)) {\n return value < 0\n ? { isNegative: true, integerPart: BigInt(-value) }\n : { isNegative: false, integerPart: BigInt(value) }\n }\n return parseNumericString(numberToString(value))\n }\n\n // String input\n if (type === 'string') {\n return parseNumericString(normalizeString(value))\n }\n\n throw new TypeError(\n `Invalid value type: expected number, string, or bigint, received ${type}`\n )\n}\n\n/**\n * Converts a number to decimal string, expanding scientific notation if needed.\n */\nfunction numberToString (value) {\n const str = value.toString()\n return (str.includes('e') || str.includes('E'))\n ? expandScientificNotation(str)\n : str\n}\n\n/**\n * Validates and normalizes a string numeric input.\n */\nfunction normalizeString (value) {\n const trimmed = value.trim()\n if (trimmed.length === 0 || Number.isNaN(Number(trimmed))) {\n throw new Error(`Invalid number format: \"${value}\"`)\n }\n return (trimmed.includes('e') || trimmed.includes('E'))\n ? expandScientificNotation(trimmed)\n : trimmed\n}\n\n/**\n * Parses a normalized numeric string into components.\n */\nfunction parseNumericString (str) {\n const isNegative = str[0] === '-'\n if (isNegative) str = str.slice(1)\n\n const dotIndex = str.indexOf('.')\n if (dotIndex === -1) {\n return { isNegative, integerPart: BigInt(str) }\n }\n\n const integerStr = str.slice(0, dotIndex) || '0'\n const decimalPart = str.slice(dotIndex + 1)\n return { isNegative, integerPart: BigInt(integerStr), decimalPart }\n}\n\n/**\n * Expands scientific notation to decimal form (e.g., \"1e21\" → \"1000...\").\n */\nfunction expandScientificNotation (str) {\n const [mantissa, expStr] = str.toLowerCase().split('e')\n const exp = parseInt(expStr, 10)\n\n const dotIndex = mantissa.indexOf('.')\n const digits = dotIndex === -1\n ? mantissa\n : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)\n const integerLength = dotIndex === -1 ? mantissa.length : dotIndex\n const newDotPosition = integerLength + exp\n\n if (newDotPosition >= digits.length) {\n return digits + '0'.repeat(newDotPosition - digits.length)\n }\n if (newDotPosition <= 0) {\n return '0.' + '0'.repeat(-newDotPosition) + digits\n }\n return digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)\n}\n","/**\n * Dutch language converter - Functional Implementation\n *\n * Self-contained module with its own input validation, ready for subpath exports.\n *\n * Dutch-specific rules:\n * - Inverted tens-ones: eenentwintig (one-and-twenty)\n * - \"ën\" connector when ones ends in 'e' (twee, drie)\n * - Compound words without spaces\n * - Hundred pairing for 1100-9999 (elfhonderd style)\n * - \"één\" vs \"een\" (accentOne option)\n * - Optional \"en\" separator (includeOptionalAnd option)\n * - Long scale with -ard forms\n */\n\nimport { parseNumericValue } from '../utils/parse-numeric.js'\nimport { validateOptions } from '../utils/validate-options.js'\n\n// ============================================================================\n// Vocabulary (module-level constants)\n// ============================================================================\n\nconst ONES = ['', 'een', 'twee', 'drie', 'vier', 'vijf', 'zes', 'zeven', 'acht', 'negen']\nconst TEENS = ['tien', 'elf', 'twaalf', 'dertien', 'veertien', 'vijftien', 'zestien', 'zeventien', 'achttien', 'negentien']\nconst TENS = ['', '', 'twintig', 'dertig', 'veertig', 'vijftig', 'zestig', 'zeventig', 'tachtig', 'negentig']\n\nconst HUNDRED = 'honderd'\n\n// Scale words (long scale with -ard forms)\nconst SCALES = ['duizend', 'miljoen', 'miljard', 'biljoen', 'biljard', 'triljoen', 'triljard', 'quadriljoen', 'quadriljard']\n\nconst ZERO = 'nul'\nconst NEGATIVE = 'min'\nconst DECIMAL_SEP = 'komma'\n\n// ============================================================================\n// Segment Building\n// ============================================================================\n\n/**\n * Builds segment word for 0-999.\n * @param {number} n - Segment value\n * @param {boolean} withAnd - Include \"en\" for values < 13 after hundreds\n * @returns {string} Dutch word (compound, no spaces)\n */\nfunction buildSegment (n, withAnd) {\n if (n === 0) return ''\n\n const ones = n % 10\n const tens = Math.floor(n / 10) % 10\n const hundreds = Math.floor(n / 100)\n const tensOnes = n % 100\n\n let result = ''\n\n // Hundreds\n if (hundreds > 0) {\n if (hundreds === 1) {\n result = HUNDRED\n } else {\n result = ONES[hundreds] + HUNDRED\n }\n }\n\n // Tens and ones\n if (tensOnes === 0) {\n // Just hundreds\n } else if (tensOnes < 10) {\n // Single digit - add \"en\" if withAnd and after hundreds\n if (hundreds > 0 && withAnd) {\n result += 'en' + ONES[tensOnes]\n } else {\n result += ONES[tensOnes]\n }\n } else if (tensOnes < 20) {\n // Teens - add \"en\" if withAnd and after hundreds and < 13\n if (hundreds > 0 && withAnd && tensOnes < 13) {\n result += 'en' + TEENS[ones]\n } else {\n result += TEENS[ones]\n }\n } else {\n // 20-99: Dutch inverts with connector\n if (ones === 0) {\n result += TENS[tens]\n } else {\n // \"ën\" if ones ends in 'e' (twee, drie)\n const onesWord = ONES[ones]\n const connector = onesWord.endsWith('e') ? 'ën' : 'en'\n result += onesWord + connector + TENS[tens]\n }\n }\n\n return result\n}\n\n// ============================================================================\n// Conversion Functions\n// ============================================================================\n\n/**\n * Converts a non-negative integer to Dutch words.\n *\n * @param {bigint} n - Non-negative integer to convert\n * @param {Object} options - Conversion options\n * @returns {string} Dutch words\n */\nfunction integerToWords (n, options) {\n if (n === 0n) return ZERO\n\n const { accentOne, includeOptionalAnd, noHundredPairing } = options\n\n // Apply één/een replacement\n const applyAccent = (word) => {\n if (accentOne) {\n return word.replace(/\\been\\b/g, 'één')\n }\n return word\n }\n\n // Fast path: numbers < 1000\n if (n < 1000n) {\n return applyAccent(buildSegment(Number(n), includeOptionalAnd))\n }\n\n // Hundred pairing for 1100-9999\n if (!noHundredPairing && n >= 1100n && n < 10000n) {\n const high = Number(n / 100n)\n const low = Number(n % 100n)\n\n // Only use pairing when high is not a multiple of 10\n if (high % 10 !== 0) {\n let result = buildSegment(high, includeOptionalAnd) + HUNDRED\n if (low > 0) {\n const lowWord = buildSegment(low, includeOptionalAnd)\n if (includeOptionalAnd && low < 13) {\n result += ' en ' + lowWord\n } else {\n result += ' ' + lowWord\n }\n }\n return applyAccent(result)\n }\n }\n\n // Fast path: numbers < 1,000,000 (thousands)\n if (n < 1_000_000n) {\n const thousands = Number(n / 1000n)\n const remainder = Number(n % 1000n)\n\n let result\n if (thousands === 1) {\n // \"duizend\" not \"eenduizend\"\n result = SCALES[0]\n } else {\n // Compound: \"vijfduizend\"\n result = buildSegment(thousands, includeOptionalAnd) + SCALES[0]\n }\n\n if (remainder > 0) {\n const remainderWord = buildSegment(remainder, includeOptionalAnd)\n if (includeOptionalAnd && remainder < 13) {\n result += ' en ' + remainderWord\n } else {\n result += ' ' + remainderWord\n }\n }\n\n return applyAccent(result)\n }\n\n // For numbers >= 1,000,000, use scale decomposition\n return applyAccent(buildLargeNumberWords(n, options))\n}\n\n/**\n * Builds words for numbers >= 1,000,000.\n * Uses BigInt division for faster segment extraction (4x faster than string slicing).\n *\n * @param {bigint} n - Number >= 1,000,000\n * @param {Object} options - Conversion options\n * @returns {string} Dutch words\n */\nfunction buildLargeNumberWords (n, options) {\n const { includeOptionalAnd } = options\n\n // Extract segments using BigInt division (faster than string slicing)\n // Segments stored least-significant first (index 0 = ones, 1 = thousands, etc.)\n const segmentValues = []\n let temp = n\n while (temp > 0n) {\n segmentValues.push(Number(temp % 1000n))\n temp = temp / 1000n\n }\n\n // Build result string directly (avoids object allocation and join)\n let result = ''\n let prevWasScale = false\n\n for (let i = segmentValues.length - 1; i >= 0; i--) {\n const segment = segmentValues[i]\n if (segment === 0) continue\n\n if (i === 0) {\n // Units segment\n const word = buildSegment(segment, includeOptionalAnd)\n if (result) {\n if (prevWasScale && includeOptionalAnd && segment < 13) {\n result += ' en ' + word\n } else {\n result += ' ' + word\n }\n } else {\n result = word\n }\n prevWasScale = false\n } else if (i === 1) {\n // Thousands - compound\n if (result) result += ' '\n if (segment === 1) {\n result += SCALES[0]\n } else {\n result += buildSegment(segment, includeOptionalAnd) + SCALES[0]\n }\n prevWasScale = true\n } else {\n // Million and above - space around scale\n const scaleWord = SCALES[i - 1]\n if (result) result += ' '\n if (segment === 1) {\n result += 'een ' + scaleWord\n } else {\n result += buildSegment(segment, includeOptionalAnd) + ' ' + scaleWord\n }\n prevWasScale = true\n }\n }\n\n return result\n}\n\n/**\n * Converts decimal digits to Dutch words.\n *\n * @param {string} decimalPart - Decimal digits (without the point)\n * @param {Object} options - Conversion options\n * @returns {string} Dutch words for decimal part\n */\nfunction decimalPartToWords (decimalPart, options) {\n let result = ''\n\n // Handle leading zeros\n let i = 0\n while (i < decimalPart.length && decimalPart[i] === '0') {\n if (result) result += ' '\n result += ZERO\n i++\n }\n\n // Convert remainder as a single number\n const remainder = decimalPart.slice(i)\n if (remainder) {\n if (result) result += ' '\n const word = integerToWords(BigInt(remainder), { ...options, noHundredPairing: true })\n result += word\n }\n\n return result\n}\n\n/**\n * Converts a numeric value to Dutch words.\n *\n * This is the main public API. It accepts any valid numeric input\n * (number, string, or bigint) and handles parsing internally.\n *\n * @param {number | string | bigint} value - The numeric value to convert\n * @param {Object} [options] - Optional configuration\n * @param {boolean} [options.accentOne=true] - Use \"één\" instead of \"een\"\n * @param {boolean} [options.includeOptionalAnd=false] - Include \"en\" before small numbers\n * @param {boolean} [options.noHundredPairing=false] - Disable hundred pairing (1104→duizend honderdvier)\n * @returns {string} The number in Dutch words\n * @throws {TypeError} If value is not a valid numeric type\n * @throws {Error} If value is not a valid number format\n *\n * @example\n * toWords(21) // 'eenentwintig'\n * toWords(1) // 'één'\n * toWords(1, {accentOne: false}) // 'een'\n * toWords(1104) // 'elfhonderd vier'\n */\nfunction toWords (value, options) {\n options = validateOptions(options)\n const { isNegative, integerPart, decimalPart } = parseNumericValue(value)\n\n const opts = {\n accentOne: options.accentOne !== false, // default true\n includeOptionalAnd: options.includeOptionalAnd || false,\n noHundredPairing: options.noHundredPairing || false\n }\n\n let result = ''\n\n if (isNegative) {\n result = NEGATIVE + ' '\n }\n\n result += integerToWords(integerPart, opts)\n\n if (decimalPart) {\n result += ' ' + DECIMAL_SEP + ' ' + decimalPartToWords(decimalPart, opts)\n }\n\n return result\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\nexport { toWords }\n","import { isPlainObject } from './is-plain-object.js'\n\n/**\n * Validates and normalizes the options parameter.\n *\n * @param {*} options The options value to validate\n * @returns {Object} A valid options object (empty object if undefined)\n * @throws {TypeError} If options is not undefined or a plain object\n */\nexport function validateOptions (options) {\n if (options === undefined) return {}\n if (isPlainObject(options)) return options\n throw new TypeError(\n `Invalid options: expected plain object or undefined, got ${typeof options}`\n )\n}\n","/**\n * Checks if a value is a plain object (not null, array, or other object types).\n *\n * A plain object is one created by:\n * - Object literal: `{}`\n * - Object.create(null): null-prototype object\n *\n * This excludes arrays, class instances, Map, Set, and other object types.\n *\n * @param {*} value Value to check\n * @returns {boolean} True if value is a plain object\n */\nexport function isPlainObject (value) {\n if (value === null || typeof value !== 'object') return false\n const proto = Object.getPrototypeOf(value)\n return proto === null || proto === Object.prototype\n}\n"],"names":["parseNumericString","str","isNegative","slice","dotIndex","indexOf","integerPart","BigInt","integerStr","decimalPart","expandScientificNotation","mantissa","expStr","toLowerCase","split","exp","parseInt","digits","newDotPosition","length","repeat","ONES","TEENS","TENS","HUNDRED","SCALES","buildSegment","n","withAnd","ones","tens","Math","floor","hundreds","tensOnes","result","onesWord","connector","endsWith","integerToWords","options","accentOne","includeOptionalAnd","noHundredPairing","applyAccent","word","replace","Number","high","low","lowWord","thousands","remainder","remainderWord","segmentValues","temp","push","prevWasScale","i","segment","scaleWord","buildLargeNumberWords","value","undefined","proto","Object","getPrototypeOf","prototype","isPlainObject","TypeError","validateOptions","type","isFinite","Error","isSafeInteger","toString","includes","numberToString","trimmed","trim","isNaN","normalizeString","parseNumericValue","opts","NEGATIVE","decimalPartToWords"],"mappings":";0CAwEA,SAASA,EAAoBC,GAC3B,MAAMC,EAAwB,MAAXD,EAAI,GACnBC,IAAYD,EAAMA,EAAIE,MAAM,IAEhC,MAAMC,EAAWH,EAAII,QAAQ,KAC7B,IAAiB,IAAbD,EACF,MAAO,CAAEF,aAAYI,YAAaC,OAAON,IAG3C,MAAMO,EAAaP,EAAIE,MAAM,EAAGC,IAAa,IACvCK,EAAcR,E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aI,EAAehC,OAAO6C,GAAY,IAAKZ,EAASG,kBAAkB,KAI1ER,CACT,CA0CwCkD,CAAmB5E,EAAa0E,IAG/DhD,CACT"}
@@ -1,3 +1,3 @@
1
- /*! n2words/pa v3.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,t;e=this,t=function(e){"use strict";function t(e){const t="-"===e[0];t&&(e=e.slice(1));const n=e.indexOf(".");if(-1===n)return{isNegative:t,integerPart:BigInt(e)};const i=e.slice(0,n)||"0",r=e.slice(n+1);return{isNegative:t,integerPart:BigInt(i),decimalPart:r}}function n(e){const[t,n]=e.toLowerCase().split("e"),i=parseInt(n,10),r=t.indexOf("."),o=-1===r?t:t.slice(0,r)+t.slice(r+1),s=(-1===r?t.length:r)+i;return s>=o.length?o+"0".repeat(s-o.length):s<=0?"0."+"0".repeat(-s)+o:o.slice(0,s)+"."+o.slice(s)}const i="ਸਿਫ਼ਰ",r=["ਸਿਫ਼ਰ","ਇੱਕ","ਦੋ","ਤਿੰਨ","ਚਾਰ","ਪੰਜ","ਛੇ","ਸੱਤ","ਅੱਠ","ਨੌਂ","ਦੱਸ","ਗਿਆਰਾਂ","ਬਾਰਾਂ","ਤੇਰਾਂ","ਚੌਦਾਂ","ਪੰਦਰਾਂ","ਸੋਲਾਂ","ਸਤਾਰਾਂ","ਅਠਾਰਾਂ","ਉੱਨੀ","ਵੀਹ","ਇੱਕੀ","ਬਾਈ","ਤੇਈ","ਚੌਬੀ","ਪੱਚੀ","ਛੱਬੀ","ਸਤਾਈ","ਅਠਾਈ","ਉਨੱਤੀ","ਤੀਹ","ਇਕੱਤੀ","ਬੱਤੀ","ਤੇਤੀ","ਚੌਂਤੀ","ਪੈਂਤੀ","ਛੱਤੀ","ਸੈਂਤੀ","ਅਠੱਤੀ","ਉਨਤਾਲੀ","ਚਾਲੀ","ਇਕਤਾਲੀ","ਬਿਆਲੀ","ਤਿਰਤਾਲੀ","ਚੁਵਾਲੀ","ਪੰਤਾਲੀ","ਛਿਆਲੀ","ਸੈਂਤਾਲੀ","ਅਠਤਾਲੀ","ਉਨੰਜਾ","ਪੰਜਾਹ","ਇਕਵੰਜਾ","ਬਵੰਜਾ","ਤਰਵੰਜਾ","ਚੁਰਵੰਜਾ","ਪੰਜਵੰਜਾ","ਛਪੰਜਾ","ਸੱਤਵੰਜਾ","ਅਠਵੰਜਾ","ਉਨਾਹਠ","ਸੱਠ","ਇਕਾਹਠ","ਬਾਹਠ","ਤਰਸਠ","ਚੌਂਸਠ","ਪੈਂਸਠ","ਛਿਆਸਠ","ਸੜਸਠ","ਅੜਸਠ","ਉਣਹੱਤਰ","ਸਤੱਰ","ਇਕਹੱਤਰ","ਬਹੱਤਰ","ਤਹੱਤਰ","ਚੌਹੱਤਰ","ਪੰਝਹੱਤਰ","ਛਿਹੱਤਰ","ਸਤੱਤਰ","ਅਠੱਤਰ","ਉਨਾਸੀ","ਅੱਸੀ","ਇਕਿਆਸੀ","ਬਿਆਸੀ","ਤਰਿਆਸੀ","ਚੌਰਿਆਸੀ","ਪਚਾਸੀ","ਛਿਆਸੀ","ਸੱਤਾਸੀ","ਅਠਾਸੀ","ਨਵਾਸੀ","ਨੱਬੇ","ਇਕਾਨਵੇਂ","ਬਾਨਵੇਂ","ਤਰਾਨਵੇਂ","ਚੁਰਾਨਵੇਂ","ਪੰਚਾਨਵੇਂ","ਛਿਆਨਵੇਂ","ਸਤਾਨਵੇਂ","ਅਠਾਨਵੇਂ","ਨਿਨਾਨਵੇਂ"],o=["","ਹਜ਼ਾਰ","ਲੱਖ","ਕਰੋੜ","ਅਰਬ","ਖਰਬ","ਨੀਲ","ਪਦਮ","ਸ਼ੰਖ"];function s(e){if(0===e)return"";if(e<100)return r[e];const t=Math.trunc(e/100),n=e%100;return 0===n?r[t]+" ਸੌ":r[t]+" ਸੌ "+r[n]}function u(e){return 0n===e?i:e<1000n?s(Number(e)):c(e,0)}function c(e,t){if(0n===e)return"";const n=0===t?1000n:100n,i=Number(e%n),u=e/n;let f="";return u>0n&&(f=c(u,t+1)),i>0&&(f&&(f+=" "),f+=0===t?s(i):r[i]+" "+o[t]),f}e.pa=function(e){const{isNegative:r,integerPart:o,decimalPart:s}=function(e){const i=typeof e;if("bigint"===i)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===i){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:t(function(e){const t=e.toString();return t.includes("e")||t.includes("E")?n(t):t}(e))}if("string"===i)return t(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new Error(`Invalid number format: "${e}"`);return t.includes("e")||t.includes("E")?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(e);let c="";return r&&(c="ਮਾਇਨਸ "),c+=u(o),s&&(c+=" ਦਸ਼ਮਲਵ "+function(e){let t="",n=0;for(;n<e.length&&"0"===e[n];)t&&(t+=" "),t+=i,n++;const r=e.slice(n);return r&&(t&&(t+=" "),t+=u(BigInt(r))),t}(s)),c}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/pa v3.1.0 | MIT License | github.com/forzagreen/n2words */
2
+ var e,t;e=this,t=function(e){"use strict";function t(e){const t="-"===e[0];t&&(e=e.slice(1));const n=e.indexOf(".");if(-1===n)return{isNegative:t,integerPart:BigInt(e)};const r=e.slice(0,n)||"0",i=e.slice(n+1);return{isNegative:t,integerPart:BigInt(r),decimalPart:i}}function n(e){const[t,n]=e.toLowerCase().split("e"),r=parseInt(n,10),i=t.indexOf("."),s=-1===i?t:t.slice(0,i)+t.slice(i+1),o=(-1===i?t.length:i)+r;return o>=s.length?s+"0".repeat(o-s.length):o<=0?"0."+"0".repeat(-o)+s:s.slice(0,o)+"."+s.slice(o)}const r="ਸਿਫ਼ਰ",i=["ਸਿਫ਼ਰ","ਇੱਕ","ਦੋ","ਤਿੰਨ","ਚਾਰ","ਪੰਜ","ਛੇ","ਸੱਤ","ਅੱਠ","ਨੌਂ","ਦੱਸ","ਗਿਆਰਾਂ","ਬਾਰਾਂ","ਤੇਰਾਂ","ਚੌਦਾਂ","ਪੰਦਰਾਂ","ਸੋਲਾਂ","ਸਤਾਰਾਂ","ਅਠਾਰਾਂ","ਉੱਨੀ","ਵੀਹ","ਇੱਕੀ","ਬਾਈ","ਤੇਈ","ਚੌਬੀ","ਪੱਚੀ","ਛੱਬੀ","ਸਤਾਈ","ਅਠਾਈ","ਉਨੱਤੀ","ਤੀਹ","ਇਕੱਤੀ","ਬੱਤੀ","ਤੇਤੀ","ਚੌਂਤੀ","ਪੈਂਤੀ","ਛੱਤੀ","ਸੈਂਤੀ","ਅਠੱਤੀ","ਉਨਤਾਲੀ","ਚਾਲੀ","ਇਕਤਾਲੀ","ਬਿਆਲੀ","ਤਿਰਤਾਲੀ","ਚੁਵਾਲੀ","ਪੰਤਾਲੀ","ਛਿਆਲੀ","ਸੈਂਤਾਲੀ","ਅਠਤਾਲੀ","ਉਨੰਜਾ","ਪੰਜਾਹ","ਇਕਵੰਜਾ","ਬਵੰਜਾ","ਤਰਵੰਜਾ","ਚੁਰਵੰਜਾ","ਪੰਜਵੰਜਾ","ਛਪੰਜਾ","ਸੱਤਵੰਜਾ","ਅਠਵੰਜਾ","ਉਨਾਹਠ","ਸੱਠ","ਇਕਾਹਠ","ਬਾਹਠ","ਤਰਸਠ","ਚੌਂਸਠ","ਪੈਂਸਠ","ਛਿਆਸਠ","ਸੜਸਠ","ਅੜਸਠ","ਉਣਹੱਤਰ","ਸਤੱਰ","ਇਕਹੱਤਰ","ਬਹੱਤਰ","ਤਹੱਤਰ","ਚੌਹੱਤਰ","ਪੰਝਹੱਤਰ","ਛਿਹੱਤਰ","ਸਤੱਤਰ","ਅਠੱਤਰ","ਉਨਾਸੀ","ਅੱਸੀ","ਇਕਿਆਸੀ","ਬਿਆਸੀ","ਤਰਿਆਸੀ","ਚੌਰਿਆਸੀ","ਪਚਾਸੀ","ਛਿਆਸੀ","ਸੱਤਾਸੀ","ਅਠਾਸੀ","ਨਵਾਸੀ","ਨੱਬੇ","ਇਕਾਨਵੇਂ","ਬਾਨਵੇਂ","ਤਰਾਨਵੇਂ","ਚੁਰਾਨਵੇਂ","ਪੰਚਾਨਵੇਂ","ਛਿਆਨਵੇਂ","ਸਤਾਨਵੇਂ","ਅਠਾਨਵੇਂ","ਨਿਨਾਨਵੇਂ"],s=["","ਹਜ਼ਾਰ","ਲੱਖ","ਕਰੋੜ","ਅਰਬ","ਖਰਬ","ਨੀਲ","ਪਦਮ","ਸ਼ੰਖ"];function o(e){if(0===e)return"";if(e<100)return i[e];const t=Math.trunc(e/100),n=e%100;return 0===n?i[t]+" ਸੌ":i[t]+" ਸੌ "+i[n]}function u(e){if(0n===e)return r;if(e<1000n)return o(Number(e));const t=[];t.push(Number(e%1000n));let n=e/1000n;for(;n>0n;)t.push(Number(n%100n)),n/=100n;const u=[];for(let e=t.length-1;e>=0;e--){const n=t[e];0!==n&&(u.push(0===e?o(n):i[n]),e>0&&s[e]&&u.push(s[e]))}return u.join(" ")}e.pa=function(e){const{isNegative:i,integerPart:s,decimalPart:o}=function(e){const r=typeof e;if("bigint"===r)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===r){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:t(function(e){const t=e.toString();return t.includes("e")||t.includes("E")?n(t):t}(e))}if("string"===r)return t(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new Error(`Invalid number format: "${e}"`);return t.includes("e")||t.includes("E")?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${r}`)}(e);let c="";return i&&(c="ਮਾਇਨਸ "),c+=u(s),o&&(c+=" ਦਸ਼ਮਲਵ "+function(e){let t="",n=0;for(;n<e.length&&"0"===e[n];)t&&(t+=" "),t+=r,n++;const i=e.slice(n);return i&&(t&&(t+=" "),t+=u(BigInt(i))),t}(o)),c}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
3
3
  //# sourceMappingURL=pa.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pa.js","sources":["../../lib/utils/parse-numeric.js","../../lib/languages/pa.js"],"sourcesContent":["/**\n * Numeric value parsing utility.\n * Transforms user input (number, string, or bigint) into normalized components.\n * @module parse-numeric\n */\n\n/**\n * Parses a numeric value into its components.\n * @param {number|string|bigint} value\n * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}\n * @throws {TypeError} If value is not number, string, or bigint\n * @throws {Error} If value is not a valid number format\n */\nexport function parseNumericValue (value) {\n const type = typeof value\n\n // BigInt: simplest case\n if (type === 'bigint') {\n return value < 0n\n ? { isNegative: true, integerPart: -value }\n : { isNegative: false, integerPart: value }\n }\n\n // Number: fast path for safe integers\n if (type === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error('Number must be finite (NaN and Infinity are not supported)')\n }\n if (Number.isSafeInteger(value)) {\n return value < 0\n ? { isNegative: true, integerPart: BigInt(-value) }\n : { isNegative: false, integerPart: BigInt(value) }\n }\n return parseNumericString(numberToString(value))\n }\n\n // String input\n if (type === 'string') {\n return parseNumericString(normalizeString(value))\n }\n\n throw new TypeError(\n `Invalid value type: expected number, string, or bigint, received ${type}`\n )\n}\n\n/**\n * Converts a number to decimal string, expanding scientific notation if needed.\n */\nfunction numberToString (value) {\n const str = value.toString()\n return (str.includes('e') || str.includes('E'))\n ? expandScientificNotation(str)\n : str\n}\n\n/**\n * Validates and normalizes a string numeric input.\n */\nfunction normalizeString (value) {\n const trimmed = value.trim()\n if (trimmed.length === 0 || Number.isNaN(Number(trimmed))) {\n throw new Error(`Invalid number format: \"${value}\"`)\n }\n return (trimmed.includes('e') || trimmed.includes('E'))\n ? expandScientificNotation(trimmed)\n : trimmed\n}\n\n/**\n * Parses a normalized numeric string into components.\n */\nfunction parseNumericString (str) {\n const isNegative = str[0] === '-'\n if (isNegative) str = str.slice(1)\n\n const dotIndex = str.indexOf('.')\n if (dotIndex === -1) {\n return { isNegative, integerPart: BigInt(str) }\n }\n\n const integerStr = str.slice(0, dotIndex) || '0'\n const decimalPart = str.slice(dotIndex + 1)\n return { isNegative, integerPart: BigInt(integerStr), decimalPart }\n}\n\n/**\n * Expands scientific notation to decimal form (e.g., \"1e21\" → \"1000...\").\n */\nfunction expandScientificNotation (str) {\n const [mantissa, expStr] = str.toLowerCase().split('e')\n const exp = parseInt(expStr, 10)\n\n const dotIndex = mantissa.indexOf('.')\n const digits = dotIndex === -1\n ? mantissa\n : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)\n const integerLength = dotIndex === -1 ? mantissa.length : dotIndex\n const newDotPosition = integerLength + exp\n\n if (newDotPosition >= digits.length) {\n return digits + '0'.repeat(newDotPosition - digits.length)\n }\n if (newDotPosition <= 0) {\n return '0.' + '0'.repeat(-newDotPosition) + digits\n }\n return digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)\n}\n","/**\n * Punjabi language converter - Functional Implementation\n *\n * Self-contained converter for South Asian numbering.\n *\n * Key features:\n * - Indian numbering system (ਹਜ਼ਾਰ, ਲੱਖ, ਕਰੋੜ)\n * - Gurmukhi script\n * - 3-2-2 grouping pattern (last 3 digits, then groups of 2)\n * - Complete word forms for 0-99\n */\n\nimport { parseNumericValue } from '../utils/parse-numeric.js'\n\n// ============================================================================\n// Vocabulary\n// ============================================================================\n\nconst ZERO = 'ਸਿਫ਼ਰ'\nconst NEGATIVE = 'ਮਾਇਨਸ'\nconst DECIMAL_SEP = 'ਦਸ਼ਮਲਵ'\nconst HUNDRED = 'ਸੌ'\n\nconst BELOW_HUNDRED = [\n 'ਸਿਫ਼ਰ', 'ਇੱਕ', 'ਦੋ', 'ਤਿੰਨ', 'ਚਾਰ', 'ਪੰਜ', 'ਛੇ', 'ਸੱਤ', 'ਅੱਠ', 'ਨੌਂ',\n 'ਦੱਸ', 'ਗਿਆਰਾਂ', 'ਬਾਰਾਂ', 'ਤੇਰਾਂ', 'ਚੌਦਾਂ', 'ਪੰਦਰਾਂ', 'ਸੋਲਾਂ', 'ਸਤਾਰਾਂ', 'ਅਠਾਰਾਂ', 'ਉੱਨੀ',\n 'ਵੀਹ', 'ਇੱਕੀ', 'ਬਾਈ', 'ਤੇਈ', 'ਚੌਬੀ', 'ਪੱਚੀ', 'ਛੱਬੀ', 'ਸਤਾਈ', 'ਅਠਾਈ', 'ਉਨੱਤੀ',\n 'ਤੀਹ', 'ਇਕੱਤੀ', 'ਬੱਤੀ', 'ਤੇਤੀ', 'ਚੌਂਤੀ', 'ਪੈਂਤੀ', 'ਛੱਤੀ', 'ਸੈਂਤੀ', 'ਅਠੱਤੀ', 'ਉਨਤਾਲੀ',\n 'ਚਾਲੀ', 'ਇਕਤਾਲੀ', 'ਬਿਆਲੀ', 'ਤਿਰਤਾਲੀ', 'ਚੁਵਾਲੀ', 'ਪੰਤਾਲੀ', 'ਛਿਆਲੀ', 'ਸੈਂਤਾਲੀ', 'ਅਠਤਾਲੀ', 'ਉਨੰਜਾ',\n 'ਪੰਜਾਹ', 'ਇਕਵੰਜਾ', 'ਬਵੰਜਾ', 'ਤਰਵੰਜਾ', 'ਚੁਰਵੰਜਾ', 'ਪੰਜਵੰਜਾ', 'ਛਪੰਜਾ', 'ਸੱਤਵੰਜਾ', 'ਅਠਵੰਜਾ', 'ਉਨਾਹਠ',\n 'ਸੱਠ', 'ਇਕਾਹਠ', 'ਬਾਹਠ', 'ਤਰਸਠ', 'ਚੌਂਸਠ', 'ਪੈਂਸਠ', 'ਛਿਆਸਠ', 'ਸੜਸਠ', 'ਅੜਸਠ', 'ਉਣਹੱਤਰ',\n 'ਸਤੱਰ', 'ਇਕਹੱਤਰ', 'ਬਹੱਤਰ', 'ਤਹੱਤਰ', 'ਚੌਹੱਤਰ', 'ਪੰਝਹੱਤਰ', 'ਛਿਹੱਤਰ', 'ਸਤੱਤਰ', 'ਅਠੱਤਰ', 'ਉਨਾਸੀ',\n 'ਅੱਸੀ', 'ਇਕਿਆਸੀ', 'ਬਿਆਸੀ', 'ਤਰਿਆਸੀ', 'ਚੌਰਿਆਸੀ', 'ਪਚਾਸੀ', 'ਛਿਆਸੀ', 'ਸੱਤਾਸੀ', 'ਅਠਾਸੀ', 'ਨਵਾਸੀ',\n 'ਨੱਬੇ', 'ਇਕਾਨਵੇਂ', 'ਬਾਨਵੇਂ', 'ਤਰਾਨਵੇਂ', 'ਚੁਰਾਨਵੇਂ', 'ਪੰਚਾਨਵੇਂ', 'ਛਿਆਨਵੇਂ', 'ਸਤਾਨਵੇਂ', 'ਅਠਾਨਵੇਂ', 'ਨਿਨਾਨਵੇਂ'\n]\n\n// Scale words: index 0 = units (empty), 1 = thousand, 2 = lakh, 3 = crore, etc.\nconst SCALE_WORDS = ['', 'ਹਜ਼ਾਰ', 'ਲੱਖ', 'ਕਰੋੜ', 'ਅਰਬ', 'ਖਰਬ', 'ਨੀਲ', 'ਪਦਮ', 'ਸ਼ੰਖ']\n\n// ============================================================================\n// Conversion Functions\n// ============================================================================\n\n/**\n * Converts 0-999 to Punjabi words.\n */\nfunction segmentToWords (n) {\n if (n === 0) return ''\n if (n < 100) return BELOW_HUNDRED[n]\n\n const hundreds = Math.trunc(n / 100)\n const remainder = n % 100\n\n if (remainder === 0) {\n return BELOW_HUNDRED[hundreds] + ' ' + HUNDRED\n }\n return BELOW_HUNDRED[hundreds] + ' ' + HUNDRED + ' ' + BELOW_HUNDRED[remainder]\n}\n\n/**\n * Converts a non-negative integer to Punjabi words.\n * Uses recursive approach for Indian 3-2-2 grouping pattern.\n *\n * @param {bigint} n - Non-negative integer to convert\n * @returns {string} Punjabi words\n */\nfunction integerToWords (n) {\n if (n === 0n) return ZERO\n\n // Fast path: numbers < 1000 (direct lookup)\n if (n < 1000n) {\n return segmentToWords(Number(n))\n }\n\n return buildLargeNumberWords(n, 0)\n}\n\n/**\n * Recursively builds words for numbers >= 1000.\n * Indian grouping: first 3 digits, then 2-digit groups.\n *\n * @param {bigint} n - Number to convert\n * @param {number} scale - Current scale index (0=units, 1=thousands, etc.)\n * @returns {string} Punjabi words\n */\nfunction buildLargeNumberWords (n, scale) {\n if (n === 0n) return ''\n\n // Determine divisor: 1000 for first split, 100 for rest\n const divisor = scale === 0 ? 1000n : 100n\n const segment = Number(n % divisor)\n const rest = n / divisor\n\n // Build higher segments first (recursive)\n let result = ''\n if (rest > 0n) {\n result = buildLargeNumberWords(rest, scale + 1)\n }\n\n // Add current segment\n if (segment > 0) {\n if (result) result += ' '\n\n if (scale === 0) {\n // Units segment (0-999)\n result += segmentToWords(segment)\n } else {\n // Scale segments (0-99)\n result += BELOW_HUNDRED[segment] + ' ' + SCALE_WORDS[scale]\n }\n }\n\n return result\n}\n\nfunction decimalPartToWords (decimalPart) {\n let result = ''\n let i = 0\n\n while (i < decimalPart.length && decimalPart[i] === '0') {\n if (result) result += ' '\n result += ZERO\n i++\n }\n\n const remainder = decimalPart.slice(i)\n if (remainder) {\n if (result) result += ' '\n result += integerToWords(BigInt(remainder))\n }\n\n return result\n}\n\n/**\n * Converts a numeric value to Punjabi words.\n *\n * @param {number | string | bigint} value - The numeric value to convert\n * @returns {string} The number in Punjabi words\n */\nfunction toWords (value) {\n const { isNegative, integerPart, decimalPart } = parseNumericValue(value)\n\n let result = ''\n\n if (isNegative) {\n result = NEGATIVE + ' '\n }\n\n result += integerToWords(integerPart)\n\n if (decimalPart) {\n result += ' ' + DECIMAL_SEP + ' ' + decimalPartToWords(decimalPart)\n }\n\n return result\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport { toWords }\n"],"names":["parseNumericString","str","isNegative","slice","dotIndex","indexOf","integerPart","BigInt","integerStr","decimalPart","expandScientificNotation","mantissa","expStr","toLowerCase","split","exp","parseInt","digits","newDotPosition","length","repeat","ZERO","BELOW_HUNDRED","SCALE_WORDS","segmentToWords","n","hundreds","Math","trunc","remainder","integerToWords","Number","buildLargeNumberWords","scale","divisor","segment","rest","result","value","type","isFinite","Error","isSafeInteger","toString","includes","numberToString","trimmed","trim","isNaN","normalizeString","TypeError","parseNumericValue","NEGATIVE","i","decimalPartToWords"],"mappings":";0CAwEA,SAASA,EAAoBC,GAC3B,MAAMC,EAAwB,MAAXD,EAAI,GACnBC,IAAYD,EAAMA,EAAIE,MAAM,IAEhC,MAAMC,EAAWH,EAAII,QAAQ,KAC7B,IAAiB,IAAbD,EACF,MAAO,CAAEF,aAAYI,YAAaC,OAAON,IAG3C,MAAMO,EAAaP,EAAIE,MAAM,EAAGC,IAAa,IACvCK,EAAcR,EAAIE,MAAMC,EAAW,GACzC,MAAO,CAAEF,aAAYI,YAAaC,OAAOC,GAAaC,cACxD,CAKA,SAASC,EAA0BT,GACjC,MAAOU,EAAUC,GAAUX,EAAIY,cAAcC,MAAM,KAC7CC,EAAMC,SAASJ,EAAQ,IAEvBR,EAAWO,EAASN,QAAQ,KAC5BY,OAASb,EACXO,EACAA,EAASR,MAAM,EAAGC,GAAYO,EAASR,MAAMC,EAAW,GAEtDc,IAD6B,IAAbd,EAAkBO,EAASQ,OAASf,GACnBW,EAEvC,OAAIG,GAAkBD,EAAOE,OACpBF,EAAS,IAAIG,OAAOF,EAAiBD,EAAOE,QAEjDD,GAAkB,EACb,KAAO,IAAIE,QAAQF,GAAkBD,EAEvCA,EAAOd,MAAM,EAAGe,GAAkB,IAAMD,EAAOd,MAAMe,EAC9D,CCzFA,MAAMG,EAAO,QAKPC,EAAgB,CACpB,QAAS,MAAO,KAAM,OAAQ,MAAO,MAAO,KAAM,MAAO,MAAO,MAChE,MAAO,SAAU,QAAS,QAAS,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AMxB,EAAYpB,EAAYN,MAAMkD,GAMpC,OALIxB,IACEQ,IAAQA,GAAU,KACtBA,GAAUP,EAAevB,OAAOsB,KAG3BQ,CACT,CAoBwCiB,CAAmB7C,IAGlD4B,CACT"}
1
+ {"version":3,"file":"pa.js","sources":["../../lib/utils/parse-numeric.js","../../lib/languages/pa.js"],"sourcesContent":["/**\n * Numeric value parsing utility.\n * Transforms user input (number, string, or bigint) into normalized components.\n * @module parse-numeric\n */\n\n/**\n * Parses a numeric value into its components.\n * @param {number|string|bigint} value\n * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}\n * @throws {TypeError} If value is not number, string, or bigint\n * @throws {Error} If value is not a valid number format\n */\nexport function parseNumericValue (value) {\n const type = typeof value\n\n // BigInt: simplest case\n if (type === 'bigint') {\n return value < 0n\n ? { isNegative: true, integerPart: -value }\n : { isNegative: false, integerPart: value }\n }\n\n // Number: fast path for safe integers\n if (type === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error('Number must be finite (NaN and Infinity are not supported)')\n }\n if (Number.isSafeInteger(value)) {\n return value < 0\n ? { isNegative: true, integerPart: BigInt(-value) }\n : { isNegative: false, integerPart: BigInt(value) }\n }\n return parseNumericString(numberToString(value))\n }\n\n // String input\n if (type === 'string') {\n return parseNumericString(normalizeString(value))\n }\n\n throw new TypeError(\n `Invalid value type: expected number, string, or bigint, received ${type}`\n )\n}\n\n/**\n * Converts a number to decimal string, expanding scientific notation if needed.\n */\nfunction numberToString (value) {\n const str = value.toString()\n return (str.includes('e') || str.includes('E'))\n ? expandScientificNotation(str)\n : str\n}\n\n/**\n * Validates and normalizes a string numeric input.\n */\nfunction normalizeString (value) {\n const trimmed = value.trim()\n if (trimmed.length === 0 || Number.isNaN(Number(trimmed))) {\n throw new Error(`Invalid number format: \"${value}\"`)\n }\n return (trimmed.includes('e') || trimmed.includes('E'))\n ? expandScientificNotation(trimmed)\n : trimmed\n}\n\n/**\n * Parses a normalized numeric string into components.\n */\nfunction parseNumericString (str) {\n const isNegative = str[0] === '-'\n if (isNegative) str = str.slice(1)\n\n const dotIndex = str.indexOf('.')\n if (dotIndex === -1) {\n return { isNegative, integerPart: BigInt(str) }\n }\n\n const integerStr = str.slice(0, dotIndex) || '0'\n const decimalPart = str.slice(dotIndex + 1)\n return { isNegative, integerPart: BigInt(integerStr), decimalPart }\n}\n\n/**\n * Expands scientific notation to decimal form (e.g., \"1e21\" → \"1000...\").\n */\nfunction expandScientificNotation (str) {\n const [mantissa, expStr] = str.toLowerCase().split('e')\n const exp = parseInt(expStr, 10)\n\n const dotIndex = mantissa.indexOf('.')\n const digits = dotIndex === -1\n ? mantissa\n : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)\n const integerLength = dotIndex === -1 ? mantissa.length : dotIndex\n const newDotPosition = integerLength + exp\n\n if (newDotPosition >= digits.length) {\n return digits + '0'.repeat(newDotPosition - digits.length)\n }\n if (newDotPosition <= 0) {\n return '0.' + '0'.repeat(-newDotPosition) + digits\n }\n return digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)\n}\n","/**\n * Punjabi language converter - Functional Implementation\n *\n * Self-contained module with its own input validation, ready for subpath exports.\n *\n * Key features:\n * - Indian numbering system (ਹਜ਼ਾਰ, ਲੱਖ, ਕਰੋੜ)\n * - Gurmukhi script\n * - 3-2-2 grouping pattern (last 3 digits, then groups of 2)\n * - Complete word forms for 0-99\n */\n\nimport { parseNumericValue } from '../utils/parse-numeric.js'\n\n// ============================================================================\n// Vocabulary\n// ============================================================================\n\nconst ZERO = 'ਸਿਫ਼ਰ'\nconst NEGATIVE = 'ਮਾਇਨਸ'\nconst DECIMAL_SEP = 'ਦਸ਼ਮਲਵ'\nconst HUNDRED = 'ਸੌ'\n\nconst BELOW_HUNDRED = [\n 'ਸਿਫ਼ਰ', 'ਇੱਕ', 'ਦੋ', 'ਤਿੰਨ', 'ਚਾਰ', 'ਪੰਜ', 'ਛੇ', 'ਸੱਤ', 'ਅੱਠ', 'ਨੌਂ',\n 'ਦੱਸ', 'ਗਿਆਰਾਂ', 'ਬਾਰਾਂ', 'ਤੇਰਾਂ', 'ਚੌਦਾਂ', 'ਪੰਦਰਾਂ', 'ਸੋਲਾਂ', 'ਸਤਾਰਾਂ', 'ਅਠਾਰਾਂ', 'ਉੱਨੀ',\n 'ਵੀਹ', 'ਇੱਕੀ', 'ਬਾਈ', 'ਤੇਈ', 'ਚੌਬੀ', 'ਪੱਚੀ', 'ਛੱਬੀ', 'ਸਤਾਈ', 'ਅਠਾਈ', 'ਉਨੱਤੀ',\n 'ਤੀਹ', 'ਇਕੱਤੀ', 'ਬੱਤੀ', 'ਤੇਤੀ', 'ਚੌਂਤੀ', 'ਪੈਂਤੀ', 'ਛੱਤੀ', 'ਸੈਂਤੀ', 'ਅਠੱਤੀ', 'ਉਨਤਾਲੀ',\n 'ਚਾਲੀ', 'ਇਕਤਾਲੀ', 'ਬਿਆਲੀ', 'ਤਿਰਤਾਲੀ', 'ਚੁਵਾਲੀ', 'ਪੰਤਾਲੀ', 'ਛਿਆਲੀ', 'ਸੈਂਤਾਲੀ', 'ਅਠਤਾਲੀ', 'ਉਨੰਜਾ',\n 'ਪੰਜਾਹ', 'ਇਕਵੰਜਾ', 'ਬਵੰਜਾ', 'ਤਰਵੰਜਾ', 'ਚੁਰਵੰਜਾ', 'ਪੰਜਵੰਜਾ', 'ਛਪੰਜਾ', 'ਸੱਤਵੰਜਾ', 'ਅਠਵੰਜਾ', 'ਉਨਾਹਠ',\n 'ਸੱਠ', 'ਇਕਾਹਠ', 'ਬਾਹਠ', 'ਤਰਸਠ', 'ਚੌਂਸਠ', 'ਪੈਂਸਠ', 'ਛਿਆਸਠ', 'ਸੜਸਠ', 'ਅੜਸਠ', 'ਉਣਹੱਤਰ',\n 'ਸਤੱਰ', 'ਇਕਹੱਤਰ', 'ਬਹੱਤਰ', 'ਤਹੱਤਰ', 'ਚੌਹੱਤਰ', 'ਪੰਝਹੱਤਰ', 'ਛਿਹੱਤਰ', 'ਸਤੱਤਰ', 'ਅਠੱਤਰ', 'ਉਨਾਸੀ',\n 'ਅੱਸੀ', 'ਇਕਿਆਸੀ', 'ਬਿਆਸੀ', 'ਤਰਿਆਸੀ', 'ਚੌਰਿਆਸੀ', 'ਪਚਾਸੀ', 'ਛਿਆਸੀ', 'ਸੱਤਾਸੀ', 'ਅਠਾਸੀ', 'ਨਵਾਸੀ',\n 'ਨੱਬੇ', 'ਇਕਾਨਵੇਂ', 'ਬਾਨਵੇਂ', 'ਤਰਾਨਵੇਂ', 'ਚੁਰਾਨਵੇਂ', 'ਪੰਚਾਨਵੇਂ', 'ਛਿਆਨਵੇਂ', 'ਸਤਾਨਵੇਂ', 'ਅਠਾਨਵੇਂ', 'ਨਿਨਾਨਵੇਂ'\n]\n\n// Scale words: index 0 = units (empty), 1 = thousand, 2 = lakh, 3 = crore, etc.\nconst SCALE_WORDS = ['', 'ਹਜ਼ਾਰ', 'ਲੱਖ', 'ਕਰੋੜ', 'ਅਰਬ', 'ਖਰਬ', 'ਨੀਲ', 'ਪਦਮ', 'ਸ਼ੰਖ']\n\n// ============================================================================\n// Segment Building\n// ============================================================================\n\n/**\n * Builds words for a 0-999 segment.\n */\nfunction buildSegment (n) {\n if (n === 0) return ''\n if (n < 100) return BELOW_HUNDRED[n]\n\n const hundreds = Math.trunc(n / 100)\n const remainder = n % 100\n\n if (remainder === 0) {\n return BELOW_HUNDRED[hundreds] + ' ' + HUNDRED\n }\n return BELOW_HUNDRED[hundreds] + ' ' + HUNDRED + ' ' + BELOW_HUNDRED[remainder]\n}\n\n// ============================================================================\n// Conversion Functions\n// ============================================================================\n\n/**\n * Converts a non-negative integer to Punjabi words.\n *\n * Uses BigInt modulo for segment extraction (faster than string slicing).\n * South Asian 3-2-2 grouping: first 3 digits, then groups of 2.\n *\n * @param {bigint} n - Non-negative integer to convert\n * @returns {string} Punjabi words\n */\nfunction integerToWords (n) {\n if (n === 0n) return ZERO\n\n // Fast path: numbers < 1000 (direct lookup)\n if (n < 1000n) {\n return buildSegment(Number(n))\n }\n\n // Extract segments using BigInt modulo\n const segments = []\n segments.push(Number(n % 1000n))\n let temp = n / 1000n\n\n while (temp > 0n) {\n segments.push(Number(temp % 100n))\n temp = temp / 100n\n }\n\n // Build result string (process from most-significant to least)\n const words = []\n for (let i = segments.length - 1; i >= 0; i--) {\n const segment = segments[i]\n if (segment === 0) continue\n\n if (i === 0) {\n words.push(buildSegment(segment))\n } else {\n words.push(BELOW_HUNDRED[segment])\n }\n\n if (i > 0 && SCALE_WORDS[i]) {\n words.push(SCALE_WORDS[i])\n }\n }\n\n return words.join(' ')\n}\n\nfunction decimalPartToWords (decimalPart) {\n let result = ''\n let i = 0\n\n while (i < decimalPart.length && decimalPart[i] === '0') {\n if (result) result += ' '\n result += ZERO\n i++\n }\n\n const remainder = decimalPart.slice(i)\n if (remainder) {\n if (result) result += ' '\n result += integerToWords(BigInt(remainder))\n }\n\n return result\n}\n\n/**\n * Converts a numeric value to Punjabi words.\n *\n * @param {number | string | bigint} value - The numeric value to convert\n * @returns {string} The number in Punjabi words\n */\nfunction toWords (value) {\n const { isNegative, integerPart, decimalPart } = parseNumericValue(value)\n\n let result = ''\n\n if (isNegative) {\n result = NEGATIVE + ' '\n }\n\n result += integerToWords(integerPart)\n\n if (decimalPart) {\n result += ' ' + DECIMAL_SEP + ' ' + decimalPartToWords(decimalPart)\n }\n\n return result\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport { toWords }\n"],"names":["parseNumericString","str","isNegative","slice","dotIndex","indexOf","integerPart","BigInt","integerStr","decimalPart","expandScientificNotation","mantissa","expStr","toLowerCase","split","exp","parseInt","digits","newDotPosition","length","repeat","ZERO","BELOW_HUNDRED","SCALE_WORDS","buildSegment","n","hundreds","Math","trunc","remainder","integerToWords","Number","segments","push","temp","words","i","segment","join","value","type","isFinite","Error","isSafeInteger","toString","includes","numberToString","trimmed","trim","isNaN","normalizeString","TypeError","parseNumericValue","result","NEGATIVE","decimalPartToWords"],"mappings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AAaiC,GAIxC,GAAa,WAATC,EAAmB,CACrB,IAAKT,OAAOU,SAASF,GACnB,MAAM,IAAIG,MAAM,8DAElB,OAAIX,OAAOY,cAAcJ,GAChBA,EAAQ,EACX,CAAErC,YAAY,EAAMI,YAAaC,QAAQgC,IACzC,CAAErC,YAAY,EAAOI,YAAaC,OAAOgC,IAExCvC,EAgBX,SAAyBuC,GACvB,MAAMtC,EAAMsC,EAAMK,WAClB,OAAQ3C,EAAI4C,SAAS,MAAQ5C,EAAI4C,SAAS,KACtCnC,EAAyBT,GACzBA,CACN,CArB8B6C,CAAeP,GAC3C,CAGA,GAAa,WAATC,EACF,OAAOxC,EAqBX,SAA0BuC,GACxB,MAAMQ,EAAUR,EAAMS,OACtB,GAAuB,IAAnBD,EAAQ5B,QAAgBY,OAAOkB,MAAMlB,OAAOgB,IAC9C,MAAM,IAAIL,MAAM,2BAA2BH,MAE7C,OAAQQ,EAAQF,SAAS,MAAQE,EAAQF,SAAS,KAC9CnC,EAAyBqC,GACzBA,CACN,CA7B8BG,CAAgBX,IAG5C,MAAM,IAAIY,UACR,oEAAoEX,IAExE,CC4FmDY,CAAkBb,GAEnE,IAAIc,EAAS,GAYb,OAVInD,IACFmD,EAASC,UAGXD,GAAUvB,EAAexB,GAErBG,IACF4C,GAAU,WArCd,SAA6B5C,GAC3B,IAAI4C,EAAS,GACTjB,EAAI,EAER,KAAOA,EAAI3B,EAAYU,QAA6B,MAAnBV,EAAY2B,IACvCiB,IAAQA,GAAU,KACtBA,GAAUhC,EACVe,IAGF,MAAMP,EAAYpB,EAAYN,MAAMiC,GAMpC,OALIP,IACEwB,IAAQA,GAAU,KACtBA,GAAUvB,EAAevB,OAAOsB,KAG3BwB,CACT,CAoBwCE,CAAmB9C,IAGlD4C,CACT"}
@@ -1,3 +1,3 @@
1
- /*! n2words/pl v3.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,i;e=this,i=function(e){"use strict";function i(e){const i="-"===e[0];i&&(e=e.slice(1));const n=e.indexOf(".");if(-1===n)return{isNegative:i,integerPart:BigInt(e)};const t=e.slice(0,n)||"0",r=e.slice(n+1);return{isNegative:i,integerPart:BigInt(t),decimalPart:r}}function n(e){const[i,n]=e.toLowerCase().split("e"),t=parseInt(n,10),r=i.indexOf("."),o=-1===r?i:i.slice(0,r)+i.slice(r+1),s=(-1===r?i.length:r)+t;return s>=o.length?o+"0".repeat(s-o.length):s<=0?"0."+"0".repeat(-s)+o:o.slice(0,s)+"."+o.slice(s)}const t=["","jeden","dwa","trzy","cztery","pięć","sześć","siedem","osiem","dziewięć"],r=["","jedna","dwie","trzy","cztery","pięć","sześć","siedem","osiem","dziewięć"],o=["dziesięć","jedenaście","dwanaście","trzynaście","czternaście","piętnaście","szesnaście","siedemnaście","osiemnaście","dziewiętnaście"],s=["","","dwadzieścia","trzydzieści","czterdzieści","pięćdziesiąt","sześćdziesiąt","siedemdziesiąt","osiemdziesiąt","dziewięćdziesiąt"],c=["","sto","dwieście","trzysta","czterysta","pięćset","sześćset","siedemset","osiemset","dziewięćset"],u={1:["tysiąc","tysiące","tysięcy"],2:["milion","miliony","milionów"],3:["miliard","miliardy","miliardów"],4:["bilion","biliony","bilionów"],5:["biliard","biliardy","biliardów"],6:["trylion","tryliony","trylionów"],7:["tryliard","tryliardy","tryliardów"],8:["kwadrylion","kwadryliony","kwadrylionów"],9:["kwaryliard","kwadryliardy","kwadryliardów"],10:["kwintylion","kwintyliony","kwintylionów"]},a="zero";function l(e){if(0===e)return"";const i=e%10,n=Math.floor(e/10)%10,r=Math.floor(e/100),u=[];return r>0&&u.push(c[r]),1===n?u.push(o[i]):(n>=2&&u.push(s[n]),i>0&&u.push(t[i])),u.join(" ")}function d(e){if(0===e)return"";const i=e%10,n=Math.floor(e/10)%10,t=Math.floor(e/100),u=[];return t>0&&u.push(c[t]),1===n?u.push(o[i]):(n>=2&&u.push(s[n]),i>0&&u.push(r[i])),u.join(" ")}const f=new Array(1e3),y=new Array(1e3);for(let e=0;e<1e3;e++)f[e]=l(e),y[e]=d(e);function p(e,i){if(1n===e)return i[0];const n=e%10n,t=e%100n;return n>=2n&&n<=4n&&(t<10n||t>20n)?i[1]:i[2]}function w(e,i={}){if(0n===e)return a;if(e<1000n)return("feminine"===i.gender?y:f)[Number(e)];if(e<1000000n){const i=Number(e/1000n),n=Number(e%1000n),t=p(BigInt(i),u[1]);let r;return r=1===i?t:f[i]+" "+t,n>0&&(r+=" "+f[n]),r}return function(e){const i=[];let n=e;for(;n>0n;)i.push(n%1000n),n/=1000n;let t="";for(let e=i.length-1;e>=0;e--){const n=i[e];if(0n===n)continue;const r=f[Number(n)];if(t&&(t+=" "),0===e)t+=r;else{const i=u[e];if(i){const e=p(n,i);t+=1n===n?e:r+" "+e}}}return t}(e)}e.pl=function(e,t){t=function(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const i=Object.getPrototypeOf(e);return null===i||i===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}(t);const{isNegative:r,integerPart:o,decimalPart:s}=function(e){const t=typeof e;if("bigint"===t)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===t){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:i(function(e){const i=e.toString();return i.includes("e")||i.includes("E")?n(i):i}(e))}if("string"===t)return i(function(e){const i=e.trim();if(0===i.length||Number.isNaN(Number(i)))throw new Error(`Invalid number format: "${e}"`);return i.includes("e")||i.includes("E")?n(i):i}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);let c="";return r&&(c="minus "),c+=w(o,t),s&&(c+=" przecinek "+function(e,i){let n="",t=0;for(;t<e.length&&"0"===e[t];)n&&(n+=" "),n+=a,t++;const r=e.slice(t);return r&&(n&&(n+=" "),n+=w(BigInt(r),i)),n}(s,t)),c}},"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/pl v3.1.0 | MIT License | github.com/forzagreen/n2words */
2
+ var e,i;e=this,i=function(e){"use strict";function i(e){const i="-"===e[0];i&&(e=e.slice(1));const n=e.indexOf(".");if(-1===n)return{isNegative:i,integerPart:BigInt(e)};const t=e.slice(0,n)||"0",r=e.slice(n+1);return{isNegative:i,integerPart:BigInt(t),decimalPart:r}}function n(e){const[i,n]=e.toLowerCase().split("e"),t=parseInt(n,10),r=i.indexOf("."),o=-1===r?i:i.slice(0,r)+i.slice(r+1),s=(-1===r?i.length:r)+t;return s>=o.length?o+"0".repeat(s-o.length):s<=0?"0."+"0".repeat(-s)+o:o.slice(0,s)+"."+o.slice(s)}const t=["","jeden","dwa","trzy","cztery","pięć","sześć","siedem","osiem","dziewięć"],r=["","jedna","dwie","trzy","cztery","pięć","sześć","siedem","osiem","dziewięć"],o=["dziesięć","jedenaście","dwanaście","trzynaście","czternaście","piętnaście","szesnaście","siedemnaście","osiemnaście","dziewiętnaście"],s=["","","dwadzieścia","trzydzieści","czterdzieści","pięćdziesiąt","sześćdziesiąt","siedemdziesiąt","osiemdziesiąt","dziewięćdziesiąt"],c=["","sto","dwieście","trzysta","czterysta","pięćset","sześćset","siedemset","osiemset","dziewięćset"],u={1:["tysiąc","tysiące","tysięcy"],2:["milion","miliony","milionów"],3:["miliard","miliardy","miliardów"],4:["bilion","biliony","bilionów"],5:["biliard","biliardy","biliardów"],6:["trylion","tryliony","trylionów"],7:["tryliard","tryliardy","tryliardów"],8:["kwadrylion","kwadryliony","kwadrylionów"],9:["kwaryliard","kwadryliardy","kwadryliardów"],10:["kwintylion","kwintyliony","kwintylionów"]},a="zero";function d(e){if(0===e)return"";const i=e%10,n=Math.floor(e/10)%10,r=Math.floor(e/100),u=[];return r>0&&u.push(c[r]),1===n?u.push(o[i]):(n>=2&&u.push(s[n]),i>0&&u.push(t[i])),u.join(" ")}function l(e,i){if(1n===e)return i[0];const n=e%10n,t=e%100n;return n>=2n&&n<=4n&&(t<10n||t>20n)?i[1]:i[2]}function f(e,i={}){if(0n===e)return a;if(e<1000n)return"feminine"===i.gender?function(e){if(0===e)return"";const i=e%10,n=Math.floor(e/10)%10,t=Math.floor(e/100),u=[];return t>0&&u.push(c[t]),1===n?u.push(o[i]):(n>=2&&u.push(s[n]),i>0&&u.push(r[i])),u.join(" ")}(Number(e)):d(Number(e));if(e<1000000n){const i=Number(e/1000n),n=Number(e%1000n),t=l(BigInt(i),u[1]);let r;return r=1===i?t:d(i)+" "+t,n>0&&(r+=" "+d(n)),r}return function(e){const i=[];let n=e;for(;n>0n;)i.push(n%1000n),n/=1000n;let t="";for(let e=i.length-1;e>=0;e--){const n=i[e];if(0n===n)continue;const r=d(Number(n));if(t&&(t+=" "),0===e)t+=r;else{const i=u[e];if(i){const e=l(n,i);t+=1n===n?e:r+" "+e}}}return t}(e)}e.pl=function(e,t){t=function(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const i=Object.getPrototypeOf(e);return null===i||i===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}(t);const{isNegative:r,integerPart:o,decimalPart:s}=function(e){const t=typeof e;if("bigint"===t)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===t){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:i(function(e){const i=e.toString();return i.includes("e")||i.includes("E")?n(i):i}(e))}if("string"===t)return i(function(e){const i=e.trim();if(0===i.length||Number.isNaN(Number(i)))throw new Error(`Invalid number format: "${e}"`);return i.includes("e")||i.includes("E")?n(i):i}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);let c="";return r&&(c="minus "),c+=f(o,t),s&&(c+=" przecinek "+function(e,i){let n="",t=0;for(;t<e.length&&"0"===e[t];)n&&(n+=" "),n+=a,t++;const r=e.slice(t);return r&&(n&&(n+=" "),n+=f(BigInt(r),i)),n}(s,t)),c}},"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
3
3
  //# sourceMappingURL=pl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pl.js","sources":["../../lib/utils/parse-numeric.js","../../lib/languages/pl.js","../../lib/utils/validate-options.js","../../lib/utils/is-plain-object.js"],"sourcesContent":["/**\n * Numeric value parsing utility.\n * Transforms user input (number, string, or bigint) into normalized components.\n * @module parse-numeric\n */\n\n/**\n * Parses a numeric value into its components.\n * @param {number|string|bigint} value\n * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}\n * @throws {TypeError} If value is not number, string, or bigint\n * @throws {Error} If value is not a valid number format\n */\nexport function parseNumericValue (value) {\n const type = typeof value\n\n // BigInt: simplest case\n if (type === 'bigint') {\n return value < 0n\n ? { isNegative: true, integerPart: -value }\n : { isNegative: false, integerPart: value }\n }\n\n // Number: fast path for safe integers\n if (type === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error('Number must be finite (NaN and Infinity are not supported)')\n }\n if (Number.isSafeInteger(value)) {\n return value < 0\n ? { isNegative: true, integerPart: BigInt(-value) }\n : { isNegative: false, integerPart: BigInt(value) }\n }\n return parseNumericString(numberToString(value))\n }\n\n // String input\n if (type === 'string') {\n return parseNumericString(normalizeString(value))\n }\n\n throw new TypeError(\n `Invalid value type: expected number, string, or bigint, received ${type}`\n )\n}\n\n/**\n * Converts a number to decimal string, expanding scientific notation if needed.\n */\nfunction numberToString (value) {\n const str = value.toString()\n return (str.includes('e') || str.includes('E'))\n ? expandScientificNotation(str)\n : str\n}\n\n/**\n * Validates and normalizes a string numeric input.\n */\nfunction normalizeString (value) {\n const trimmed = value.trim()\n if (trimmed.length === 0 || Number.isNaN(Number(trimmed))) {\n throw new Error(`Invalid number format: \"${value}\"`)\n }\n return (trimmed.includes('e') || trimmed.includes('E'))\n ? expandScientificNotation(trimmed)\n : trimmed\n}\n\n/**\n * Parses a normalized numeric string into components.\n */\nfunction parseNumericString (str) {\n const isNegative = str[0] === '-'\n if (isNegative) str = str.slice(1)\n\n const dotIndex = str.indexOf('.')\n if (dotIndex === -1) {\n return { isNegative, integerPart: BigInt(str) }\n }\n\n const integerStr = str.slice(0, dotIndex) || '0'\n const decimalPart = str.slice(dotIndex + 1)\n return { isNegative, integerPart: BigInt(integerStr), decimalPart }\n}\n\n/**\n * Expands scientific notation to decimal form (e.g., \"1e21\" → \"1000...\").\n */\nfunction expandScientificNotation (str) {\n const [mantissa, expStr] = str.toLowerCase().split('e')\n const exp = parseInt(expStr, 10)\n\n const dotIndex = mantissa.indexOf('.')\n const digits = dotIndex === -1\n ? mantissa\n : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)\n const integerLength = dotIndex === -1 ? mantissa.length : dotIndex\n const newDotPosition = integerLength + exp\n\n if (newDotPosition >= digits.length) {\n return digits + '0'.repeat(newDotPosition - digits.length)\n }\n if (newDotPosition <= 0) {\n return '0.' + '0'.repeat(-newDotPosition) + digits\n }\n return digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)\n}\n","/**\n * Polish language converter - Functional Implementation\n *\n * A performance-optimized number-to-words converter using precomputed lookup tables.\n * Self-contained module with its own input validation, ready for subpath exports.\n *\n * Key optimization: Precompute all segment values (0-999) at module load.\n * This eliminates all per-call string manipulation for segment conversion.\n *\n * Polish-specific rules (handled in precomputation):\n * - Three-form pluralization: 1 = singular, 2-4 = few, 5+ = many\n * - Gender agreement (masculine/feminine for numbers < 1000)\n * - Omit \"jeden\" before scale words (tysiąc, milion, etc.)\n * - Irregular hundreds: dwieście, trzysta, czterysta, pięćset...\n * - Long scale with -ard forms: miliard, biliard, tryliard\n */\n\nimport { parseNumericValue } from '../utils/parse-numeric.js'\nimport { validateOptions } from '../utils/validate-options.js'\n\n// ============================================================================\n// Vocabulary (module-level constants)\n// ============================================================================\n\nconst ONES_MASC = ['', 'jeden', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć', 'siedem', 'osiem', 'dziewięć']\nconst ONES_FEM = ['', 'jedna', 'dwie', 'trzy', 'cztery', 'pięć', 'sześć', 'siedem', 'osiem', 'dziewięć']\n\nconst TEENS = ['dziesięć', 'jedenaście', 'dwanaście', 'trzynaście', 'czternaście', 'piętnaście', 'szesnaście', 'siedemnaście', 'osiemnaście', 'dziewiętnaście']\n\nconst TENS = ['', '', 'dwadzieścia', 'trzydzieści', 'czterdzieści', 'pięćdziesiąt', 'sześćdziesiąt', 'siedemdziesiąt', 'osiemdziesiąt', 'dziewięćdziesiąt']\n\n// Irregular hundreds\nconst HUNDREDS = ['', 'sto', 'dwieście', 'trzysta', 'czterysta', 'pięćset', 'sześćset', 'siedemset', 'osiemset', 'dziewięćset']\n\n// Scale words: [singular, few (2-4), many (5+)]\nconst PLURAL_FORMS = {\n 1: ['tysiąc', 'tysiące', 'tysięcy'],\n 2: ['milion', 'miliony', 'milionów'],\n 3: ['miliard', 'miliardy', 'miliardów'],\n 4: ['bilion', 'biliony', 'bilionów'],\n 5: ['biliard', 'biliardy', 'biliardów'],\n 6: ['trylion', 'tryliony', 'trylionów'],\n 7: ['tryliard', 'tryliardy', 'tryliardów'],\n 8: ['kwadrylion', 'kwadryliony', 'kwadrylionów'],\n 9: ['kwaryliard', 'kwadryliardy', 'kwadryliardów'],\n 10: ['kwintylion', 'kwintyliony', 'kwintylionów']\n}\n\nconst ZERO = 'zero'\nconst NEGATIVE = 'minus'\nconst DECIMAL_SEP = 'przecinek'\n\n// ============================================================================\n// Precomputed Lookup Tables (built once at module load)\n// ============================================================================\n\n/**\n * Builds segment word for 0-999 (masculine form).\n * @param {number} n - Segment value\n * @returns {string} Polish word\n */\nfunction buildSegment (n) {\n if (n === 0) return ''\n\n const ones = n % 10\n const tens = Math.floor(n / 10) % 10\n const hundreds = Math.floor(n / 100)\n\n const parts = []\n\n // Hundreds\n if (hundreds > 0) {\n parts.push(HUNDREDS[hundreds])\n }\n\n // Tens and ones\n if (tens === 1) {\n // Teens (10-19)\n parts.push(TEENS[ones])\n } else {\n if (tens >= 2) {\n parts.push(TENS[tens])\n }\n if (ones > 0) {\n parts.push(ONES_MASC[ones])\n }\n }\n\n return parts.join(' ')\n}\n\n/**\n * Builds segment word for 0-999 (feminine form - only differs in ones).\n * @param {number} n - Segment value\n * @returns {string} Polish word\n */\nfunction buildSegmentFeminine (n) {\n if (n === 0) return ''\n\n const ones = n % 10\n const tens = Math.floor(n / 10) % 10\n const hundreds = Math.floor(n / 100)\n\n const parts = []\n\n // Hundreds\n if (hundreds > 0) {\n parts.push(HUNDREDS[hundreds])\n }\n\n // Tens and ones - feminine for ones only\n if (tens === 1) {\n parts.push(TEENS[ones])\n } else {\n if (tens >= 2) {\n parts.push(TENS[tens])\n }\n if (ones > 0) {\n parts.push(ONES_FEM[ones])\n }\n }\n\n return parts.join(' ')\n}\n\n// Precompute all 1000 segment words (0-999)\nconst SEGMENTS_MASC = new Array(1000)\nconst SEGMENTS_FEM = new Array(1000)\nfor (let i = 0; i < 1000; i++) {\n SEGMENTS_MASC[i] = buildSegment(i)\n SEGMENTS_FEM[i] = buildSegmentFeminine(i)\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Polish pluralization: 1 = singular, 2-4 = few, else = many.\n * Special case: 11-19 always use many form.\n *\n * @param {bigint} n - Number to pluralize\n * @param {string[]} forms - [singular, few, many]\n * @returns {string} Correct plural form\n */\nfunction pluralize (n, forms) {\n if (n === 1n) {\n return forms[0]\n }\n\n const lastDigit = n % 10n\n const lastTwoDigits = n % 100n\n\n // Teens (11-19) always use many form\n // 2-4 use few form (but not 12-14)\n if (lastDigit >= 2n && lastDigit <= 4n && (lastTwoDigits < 10n || lastTwoDigits > 20n)) {\n return forms[1]\n }\n\n return forms[2]\n}\n\n// ============================================================================\n// Conversion Functions\n// ============================================================================\n\n/**\n * Converts a non-negative integer to Polish words.\n *\n * @param {bigint} n - Non-negative integer to convert\n * @param {Object} options - Conversion options\n * @returns {string} Polish words\n */\nfunction integerToWords (n, options = {}) {\n if (n === 0n) return ZERO\n\n // Fast path: numbers < 1000 (direct lookup)\n if (n < 1000n) {\n const segments = options.gender === 'feminine' ? SEGMENTS_FEM : SEGMENTS_MASC\n return segments[Number(n)]\n }\n\n // Fast path: numbers < 1,000,000 (thousands)\n if (n < 1_000_000n) {\n const thousands = Number(n / 1000n)\n const remainder = Number(n % 1000n)\n\n const scaleWord = pluralize(BigInt(thousands), PLURAL_FORMS[1])\n\n let result\n if (thousands === 1) {\n // Omit \"jeden\" before tysiąc\n result = scaleWord\n } else {\n result = SEGMENTS_MASC[thousands] + ' ' + scaleWord\n }\n\n if (remainder > 0) {\n result += ' ' + SEGMENTS_MASC[remainder]\n }\n\n return result\n }\n\n // For numbers >= 1,000,000, use scale decomposition\n return buildLargeNumberWords(n, options)\n}\n\n/**\n * Builds words for numbers >= 1,000,000.\n * Uses BigInt division for faster segment extraction.\n *\n * @param {bigint} n - Number >= 1,000,000\n * @param {Object} options - Conversion options\n * @returns {string} Polish words\n */\nfunction buildLargeNumberWords (n, options) {\n // Extract segments using BigInt division (faster than string slicing)\n // Segments stored least-significant first (index 0 = ones, 1 = thousands, etc.)\n const segmentValues = []\n let temp = n\n while (temp > 0n) {\n segmentValues.push(temp % 1000n)\n temp = temp / 1000n\n }\n\n // Build result string directly\n let result = ''\n\n for (let i = segmentValues.length - 1; i >= 0; i--) {\n const segment = segmentValues[i]\n if (segment === 0n) continue\n\n const segmentWord = SEGMENTS_MASC[Number(segment)]\n\n if (result) result += ' '\n\n if (i === 0) {\n // Units segment\n result += segmentWord\n } else {\n // Scale word needed\n const forms = PLURAL_FORMS[i]\n if (forms) {\n const scaleWord = pluralize(segment, forms)\n\n if (segment === 1n) {\n // Omit \"jeden\" before scale words\n result += scaleWord\n } else {\n result += segmentWord + ' ' + scaleWord\n }\n }\n }\n }\n\n return result\n}\n\n/**\n * Converts decimal digits to Polish words.\n *\n * @param {string} decimalPart - Decimal digits (without the point)\n * @param {Object} options - Conversion options\n * @returns {string} Polish words for decimal part\n */\nfunction decimalPartToWords (decimalPart, options) {\n let result = ''\n\n // Handle leading zeros\n let i = 0\n while (i < decimalPart.length && decimalPart[i] === '0') {\n if (result) result += ' '\n result += ZERO\n i++\n }\n\n // Convert remainder as a single number\n const remainder = decimalPart.slice(i)\n if (remainder) {\n if (result) result += ' '\n result += integerToWords(BigInt(remainder), options)\n }\n\n return result\n}\n\n/**\n * Converts a numeric value to Polish words.\n *\n * This is the main public API. It accepts any valid numeric input\n * (number, string, or bigint) and handles parsing internally.\n *\n * @param {number | string | bigint} value - The numeric value to convert\n * @param {Object} [options] - Conversion options\n * @param {string} [options.gender='masculine'] - Gender for numbers < 1000\n * @returns {string} The number in Polish words\n * @throws {TypeError} If value is not a valid numeric type\n * @throws {Error} If value is not a valid number format\n *\n * @example\n * toWords(1) // 'jeden'\n * toWords(1, { gender: 'feminine' }) // 'jedna'\n * toWords(1000) // 'tysiąc'\n * toWords(2000) // 'dwa tysiące'\n */\nfunction toWords (value, options) {\n options = validateOptions(options)\n const { isNegative, integerPart, decimalPart } = parseNumericValue(value)\n\n let result = ''\n\n if (isNegative) {\n result = NEGATIVE + ' '\n }\n\n result += integerToWords(integerPart, options)\n\n if (decimalPart) {\n result += ' ' + DECIMAL_SEP + ' ' + decimalPartToWords(decimalPart, options)\n }\n\n return result\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\nexport { toWords }\n","import { isPlainObject } from './is-plain-object.js'\n\n/**\n * Validates and normalizes the options parameter.\n *\n * @param {*} options The options value to validate\n * @returns {Object} A valid options object (empty object if undefined)\n * @throws {TypeError} If options is not undefined or a plain object\n */\nexport function validateOptions (options) {\n if (options === undefined) return {}\n if (isPlainObject(options)) return options\n throw new TypeError(\n `Invalid options: expected plain object or undefined, got ${typeof options}`\n )\n}\n","/**\n * Checks if a value is a plain object (not null, array, or other object types).\n *\n * A plain object is one created by:\n * - Object literal: `{}`\n * - Object.create(null): null-prototype object\n *\n * This excludes arrays, class instances, Map, Set, and other object types.\n *\n * @param {*} value Value to check\n * @returns {boolean} True if value is a plain object\n */\nexport function isPlainObject (value) {\n if (value === null || typeof value !== 'object') return false\n const proto = Object.getPrototypeOf(value)\n return proto === null || proto === Object.prototype\n}\n"],"names":["parseNumericString","str","isNegative","slice","dotIndex","indexOf","integerPart","BigInt","integerStr","decimalPart","expandScientificNotation","mantissa","expStr","toLowerCase","split","exp","parseInt","digits","newDotPosition","length","repeat","ONES_MASC","ONES_FEM","TEENS","TENS","HUNDREDS","PLURAL_FORMS","ZERO","buildSegment","n","ones","tens","Math","floor","hundreds","parts","push","join","buildSegmentFeminine","SEGMENTS_MASC","Array","SEGMENTS_FEM","i","pluralize","forms","lastDigit","lastTwoDigits","integerToWords","options","gender","Number","thousands","remainder","scaleWord","result","segmentValues","temp","segment","segmentWord","buildLargeNumberWords","value","undefined","proto","Object","getPrototypeOf","prototype","isPlainObject","TypeError","validateOptions","type","isFinite","Error","isSafeInteger","toString","includes","numberToString","trimmed","trim","isNaN","normalizeString","parseNumericValue","NEGATIVE","decimalPartToWords"],"mappings":";0CAwEA,SAASA,EAAoBC,GAC3B,MAAMC,EAAwB,MAAXD,EAAI,GACnBC,IAAYD,EAAMA,EAAIE,MAAM,IAEhC,MAAMC,EAAWH,EAAII,QAAQ,KAC7B,IAAiB,IAAbD,EACF,MAAO,CAAEF,aAAYI,YAAaC,OAAON,IAG3C,MAAMO,EAAaP,EAAIE,MAAM,EAAGC,IAAa,IACvCK,EAAcR,EAAIE,MAAMC,EAAW,GACzC,MAAO,CAAEF,aAAYI,YAAaC,OAAOC,GAAaC,cACxD,CAKA,SAASC,EAA0BT,GACjC,MAAOU,EAAUC,GAAUX,E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.js","../../lib/languages/pl.js","../../lib/utils/validate-options.js","../../lib/utils/is-plain-object.js"],"sourcesContent":["/**\n * Numeric value parsing utility.\n * Transforms user input (number, string, or bigint) into normalized components.\n * @module parse-numeric\n */\n\n/**\n * Parses a numeric value into its components.\n * @param {number|string|bigint} value\n * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}\n * @throws {TypeError} If value is not number, string, or bigint\n * @throws {Error} If value is not a valid number format\n */\nexport function parseNumericValue (value) {\n const type = typeof value\n\n // BigInt: simplest case\n if (type === 'bigint') {\n return value < 0n\n ? { isNegative: true, integerPart: -value }\n : { isNegative: false, integerPart: value }\n }\n\n // Number: fast path for safe integers\n if (type === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error('Number must be finite (NaN and Infinity are not supported)')\n }\n if (Number.isSafeInteger(value)) {\n return value < 0\n ? { isNegative: true, integerPart: BigInt(-value) }\n : { isNegative: false, integerPart: BigInt(value) }\n }\n return parseNumericString(numberToString(value))\n }\n\n // String input\n if (type === 'string') {\n return parseNumericString(normalizeString(value))\n }\n\n throw new TypeError(\n `Invalid value type: expected number, string, or bigint, received ${type}`\n )\n}\n\n/**\n * Converts a number to decimal string, expanding scientific notation if needed.\n */\nfunction numberToString (value) {\n const str = value.toString()\n return (str.includes('e') || str.includes('E'))\n ? expandScientificNotation(str)\n : str\n}\n\n/**\n * Validates and normalizes a string numeric input.\n */\nfunction normalizeString (value) {\n const trimmed = value.trim()\n if (trimmed.length === 0 || Number.isNaN(Number(trimmed))) {\n throw new Error(`Invalid number format: \"${value}\"`)\n }\n return (trimmed.includes('e') || trimmed.includes('E'))\n ? expandScientificNotation(trimmed)\n : trimmed\n}\n\n/**\n * Parses a normalized numeric string into components.\n */\nfunction parseNumericString (str) {\n const isNegative = str[0] === '-'\n if (isNegative) str = str.slice(1)\n\n const dotIndex = str.indexOf('.')\n if (dotIndex === -1) {\n return { isNegative, integerPart: BigInt(str) }\n }\n\n const integerStr = str.slice(0, dotIndex) || '0'\n const decimalPart = str.slice(dotIndex + 1)\n return { isNegative, integerPart: BigInt(integerStr), decimalPart }\n}\n\n/**\n * Expands scientific notation to decimal form (e.g., \"1e21\" → \"1000...\").\n */\nfunction expandScientificNotation (str) {\n const [mantissa, expStr] = str.toLowerCase().split('e')\n const exp = parseInt(expStr, 10)\n\n const dotIndex = mantissa.indexOf('.')\n const digits = dotIndex === -1\n ? mantissa\n : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)\n const integerLength = dotIndex === -1 ? mantissa.length : dotIndex\n const newDotPosition = integerLength + exp\n\n if (newDotPosition >= digits.length) {\n return digits + '0'.repeat(newDotPosition - digits.length)\n }\n if (newDotPosition <= 0) {\n return '0.' + '0'.repeat(-newDotPosition) + digits\n }\n return digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)\n}\n","/**\n * Polish language converter - Functional Implementation\n *\n * Self-contained module with its own input validation, ready for subpath exports.\n *\n * Polish-specific rules:\n * - Three-form pluralization: 1 = singular, 2-4 = few, 5+ = many\n * - Gender agreement (masculine/feminine for numbers < 1000)\n * - Omit \"jeden\" before scale words (tysiąc, milion, etc.)\n * - Irregular hundreds: dwieście, trzysta, czterysta, pięćset...\n * - Long scale with -ard forms: miliard, biliard, tryliard\n */\n\nimport { parseNumericValue } from '../utils/parse-numeric.js'\nimport { validateOptions } from '../utils/validate-options.js'\n\n// ============================================================================\n// Vocabulary (module-level constants)\n// ============================================================================\n\nconst ONES_MASC = ['', 'jeden', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć', 'siedem', 'osiem', 'dziewięć']\nconst ONES_FEM = ['', 'jedna', 'dwie', 'trzy', 'cztery', 'pięć', 'sześć', 'siedem', 'osiem', 'dziewięć']\n\nconst TEENS = ['dziesięć', 'jedenaście', 'dwanaście', 'trzynaście', 'czternaście', 'piętnaście', 'szesnaście', 'siedemnaście', 'osiemnaście', 'dziewiętnaście']\n\nconst TENS = ['', '', 'dwadzieścia', 'trzydzieści', 'czterdzieści', 'pięćdziesiąt', 'sześćdziesiąt', 'siedemdziesiąt', 'osiemdziesiąt', 'dziewięćdziesiąt']\n\n// Irregular hundreds\nconst HUNDREDS = ['', 'sto', 'dwieście', 'trzysta', 'czterysta', 'pięćset', 'sześćset', 'siedemset', 'osiemset', 'dziewięćset']\n\n// Scale words: [singular, few (2-4), many (5+)]\nconst PLURAL_FORMS = {\n 1: ['tysiąc', 'tysiące', 'tysięcy'],\n 2: ['milion', 'miliony', 'milionów'],\n 3: ['miliard', 'miliardy', 'miliardów'],\n 4: ['bilion', 'biliony', 'bilionów'],\n 5: ['biliard', 'biliardy', 'biliardów'],\n 6: ['trylion', 'tryliony', 'trylionów'],\n 7: ['tryliard', 'tryliardy', 'tryliardów'],\n 8: ['kwadrylion', 'kwadryliony', 'kwadrylionów'],\n 9: ['kwaryliard', 'kwadryliardy', 'kwadryliardów'],\n 10: ['kwintylion', 'kwintyliony', 'kwintylionów']\n}\n\nconst ZERO = 'zero'\nconst NEGATIVE = 'minus'\nconst DECIMAL_SEP = 'przecinek'\n\n// ============================================================================\n// Segment Building\n// ============================================================================\n\n/**\n * Builds segment word for 0-999 (masculine form).\n * @param {number} n - Segment value\n * @returns {string} Polish word\n */\nfunction buildSegment (n) {\n if (n === 0) return ''\n\n const ones = n % 10\n const tens = Math.floor(n / 10) % 10\n const hundreds = Math.floor(n / 100)\n\n const parts = []\n\n // Hundreds\n if (hundreds > 0) {\n parts.push(HUNDREDS[hundreds])\n }\n\n // Tens and ones\n if (tens === 1) {\n // Teens (10-19)\n parts.push(TEENS[ones])\n } else {\n if (tens >= 2) {\n parts.push(TENS[tens])\n }\n if (ones > 0) {\n parts.push(ONES_MASC[ones])\n }\n }\n\n return parts.join(' ')\n}\n\n/**\n * Builds segment word for 0-999 (feminine form - only differs in ones).\n * @param {number} n - Segment value\n * @returns {string} Polish word\n */\nfunction buildSegmentFeminine (n) {\n if (n === 0) return ''\n\n const ones = n % 10\n const tens = Math.floor(n / 10) % 10\n const hundreds = Math.floor(n / 100)\n\n const parts = []\n\n // Hundreds\n if (hundreds > 0) {\n parts.push(HUNDREDS[hundreds])\n }\n\n // Tens and ones - feminine for ones only\n if (tens === 1) {\n parts.push(TEENS[ones])\n } else {\n if (tens >= 2) {\n parts.push(TENS[tens])\n }\n if (ones > 0) {\n parts.push(ONES_FEM[ones])\n }\n }\n\n return parts.join(' ')\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Polish pluralization: 1 = singular, 2-4 = few, else = many.\n * Special case: 11-19 always use many form.\n *\n * @param {bigint} n - Number to pluralize\n * @param {string[]} forms - [singular, few, many]\n * @returns {string} Correct plural form\n */\nfunction pluralize (n, forms) {\n if (n === 1n) {\n return forms[0]\n }\n\n const lastDigit = n % 10n\n const lastTwoDigits = n % 100n\n\n // Teens (11-19) always use many form\n // 2-4 use few form (but not 12-14)\n if (lastDigit >= 2n && lastDigit <= 4n && (lastTwoDigits < 10n || lastTwoDigits > 20n)) {\n return forms[1]\n }\n\n return forms[2]\n}\n\n// ============================================================================\n// Conversion Functions\n// ============================================================================\n\n/**\n * Converts a non-negative integer to Polish words.\n *\n * @param {bigint} n - Non-negative integer to convert\n * @param {Object} options - Conversion options\n * @returns {string} Polish words\n */\nfunction integerToWords (n, options = {}) {\n if (n === 0n) return ZERO\n\n // Fast path: numbers < 1000\n if (n < 1000n) {\n return options.gender === 'feminine' ? buildSegmentFeminine(Number(n)) : buildSegment(Number(n))\n }\n\n // Fast path: numbers < 1,000,000 (thousands)\n if (n < 1_000_000n) {\n const thousands = Number(n / 1000n)\n const remainder = Number(n % 1000n)\n\n const scaleWord = pluralize(BigInt(thousands), PLURAL_FORMS[1])\n\n let result\n if (thousands === 1) {\n // Omit \"jeden\" before tysiąc\n result = scaleWord\n } else {\n result = buildSegment(thousands) + ' ' + scaleWord\n }\n\n if (remainder > 0) {\n result += ' ' + buildSegment(remainder)\n }\n\n return result\n }\n\n // For numbers >= 1,000,000, use scale decomposition\n return buildLargeNumberWords(n, options)\n}\n\n/**\n * Builds words for numbers >= 1,000,000.\n * Uses BigInt division for faster segment extraction.\n *\n * @param {bigint} n - Number >= 1,000,000\n * @param {Object} options - Conversion options\n * @returns {string} Polish words\n */\nfunction buildLargeNumberWords (n, options) {\n // Extract segments using BigInt division (faster than string slicing)\n // Segments stored least-significant first (index 0 = ones, 1 = thousands, etc.)\n const segmentValues = []\n let temp = n\n while (temp > 0n) {\n segmentValues.push(temp % 1000n)\n temp = temp / 1000n\n }\n\n // Build result string directly\n let result = ''\n\n for (let i = segmentValues.length - 1; i >= 0; i--) {\n const segment = segmentValues[i]\n if (segment === 0n) continue\n\n const segmentWord = buildSegment(Number(segment))\n\n if (result) result += ' '\n\n if (i === 0) {\n // Units segment\n result += segmentWord\n } else {\n // Scale word needed\n const forms = PLURAL_FORMS[i]\n if (forms) {\n const scaleWord = pluralize(segment, forms)\n\n if (segment === 1n) {\n // Omit \"jeden\" before scale words\n result += scaleWord\n } else {\n result += segmentWord + ' ' + scaleWord\n }\n }\n }\n }\n\n return result\n}\n\n/**\n * Converts decimal digits to Polish words.\n *\n * @param {string} decimalPart - Decimal digits (without the point)\n * @param {Object} options - Conversion options\n * @returns {string} Polish words for decimal part\n */\nfunction decimalPartToWords (decimalPart, options) {\n let result = ''\n\n // Handle leading zeros\n let i = 0\n while (i < decimalPart.length && decimalPart[i] === '0') {\n if (result) result += ' '\n result += ZERO\n i++\n }\n\n // Convert remainder as a single number\n const remainder = decimalPart.slice(i)\n if (remainder) {\n if (result) result += ' '\n result += integerToWords(BigInt(remainder), options)\n }\n\n return result\n}\n\n/**\n * Converts a numeric value to Polish words.\n *\n * This is the main public API. It accepts any valid numeric input\n * (number, string, or bigint) and handles parsing internally.\n *\n * @param {number | string | bigint} value - The numeric value to convert\n * @param {Object} [options] - Conversion options\n * @param {string} [options.gender='masculine'] - Gender for numbers < 1000\n * @returns {string} The number in Polish words\n * @throws {TypeError} If value is not a valid numeric type\n * @throws {Error} If value is not a valid number format\n *\n * @example\n * toWords(1) // 'jeden'\n * toWords(1, { gender: 'feminine' }) // 'jedna'\n * toWords(1000) // 'tysiąc'\n * toWords(2000) // 'dwa tysiące'\n */\nfunction toWords (value, options) {\n options = validateOptions(options)\n const { isNegative, integerPart, decimalPart } = parseNumericValue(value)\n\n let result = ''\n\n if (isNegative) {\n result = NEGATIVE + ' '\n }\n\n result += integerToWords(integerPart, options)\n\n if (decimalPart) {\n result += ' ' + DECIMAL_SEP + ' ' + decimalPartToWords(decimalPart, options)\n }\n\n return result\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\nexport { toWords }\n","import { isPlainObject } from './is-plain-object.js'\n\n/**\n * Validates and normalizes the options parameter.\n *\n * @param {*} options The options value to validate\n * @returns {Object} A valid options object (empty object if undefined)\n * @throws {TypeError} If options is not undefined or a plain object\n */\nexport function validateOptions (options) {\n if (options === undefined) return {}\n if (isPlainObject(options)) return options\n throw new TypeError(\n `Invalid options: expected plain object or undefined, got ${typeof options}`\n )\n}\n","/**\n * Checks if a value is a plain object (not null, array, or other object types).\n *\n * A plain object is one created by:\n * - Object literal: `{}`\n * - Object.create(null): null-prototype object\n *\n * This excludes arrays, class instances, Map, Set, and other object types.\n *\n * @param {*} value Value to check\n * @returns {boolean} True if value is a plain object\n */\nexport function isPlainObject (value) {\n if (value === null || typeof value !== 'object') return false\n const proto = Object.getPrototypeOf(value)\n return proto === null || proto === Object.prototype\n}\n"],"names":["parseNumericString","str","isNegative","slice","dotIndex","indexOf","integerPart","BigInt","integerStr","decimalPart","expandScientificNotation","mantissa","expStr","toLowerCase","split","exp","parseInt","digits","newDotPosition","length","repeat","ONES_MASC","ONES_FEM","TEENS","TENS","HUNDREDS","PLURAL_FORMS","ZERO","buildSegment","n","ones","tens","Math","floor","hundreds","parts","push","join","pluralize","forms","lastDigit","lastTwoDigits","integerToWords","options","gender","buildSegmentFeminine","Number","thousands","remainder","scaleWord","result","segmentValues","temp","i","segment","segmentWord","buildLargeNumberWords","value","undefined","proto","Object","getPrototypeOf","prototype","isPlainObject","TypeError","validateOptions","type","isFinite","Error","isSafeInteger","toString","includes","numberToString","trimmed","trim","isNaN","normalizeString","parseNumericValue","NEGATIVE","decimalPartToWords"],"mappings":";0CAwEA,SAASA,EAAoBC,GAC3B,MAAMC,EAAwB,MAAXD,EAAI,GACnBC,IAAYD,EAAMA,EAAIE,MAAM,IAEhC,MAAMC,EAAWH,EAAII,QAAQ,KAC7B,IAAiB,IAAbD,EACF,MAAO,CAAEF,aAAYI,YAAaC,OAAON,IAG3C,MAAMO,EAAaP,EAAIE,MAAM,EAAGC,IAAa,IACvCK,EAAcR,EAAIE,MAAMC,EAAW,GACzC,MAAO,CAAEF,aAAYI,YAAaC,OAAOC,GAAaC,cACxD,CAKA,SAASC,EAA0BT,GACjC,MAAOU,EAAUC,GAAUX,EAAIY,cAAcC,MAAM,KAC7CC,EAAMC,SAASJ,EAAQ,IAEvBR,EAAWO,EAASN,QAAQ,KAC5BY,OAASb,EACXO,EACAA,EAASR,MAAM,EAAGC,GAAYO,EAASR,MAAMC,EAAW,GAEtDc,IAD6B,IAAbd,EAAkBO,EAASQ,OAASf,GACnBW,EAEvC,OAAIG,GAAkBD,EAAOE,OACpBF,EAAS,IAAIG,OAAOF,EAAiBD,EAAOE,QAEjDD,GAAkB,EACb,KAAO,IAAIE,QAAQF,GAAkBD,EAEvCA,EAAOd,MAAM,EAAGe,GAAkB,IAAMD,EAAOd,MAAMe,EAC9D,CCvFA,MAAMG,EAAY,CAAC,GAAI,QAAS,MAAO,OAAQ,SAAU,OAAQ,QAAS,SAAU,QAAS,YACvFC,EAAW,CAAC,GAAI,QAAS,OAAQ,OAAQ,SAAU,OAAQ,QAAS,SAAU,QAAS,YAEvFC,EAAQ,CAAC,WAAY,aAAc,YAAa,aAAc,cAAe,aAAc,aAAc,eAAgB,cAAe,kBAExIC,EAAO,CAAC,GAAI,GAAI,cAAe,cAAe,eAAgB,eAAgB,gBAAiB,iBAAkB,gBAAiB,oBAGlIC,EAAW,CAAC,GAAI,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,GACxC,IAAIO,EAAS,GAGTG,EAAI,EACR,KAAOA,EAAI5C,EAAYU,QAA6B,MAAnBV,EAAY4C,IACvCH,IAAQA,GAAU,KACtBA,GAAUvB,EACV0B,IAIF,MAAML,EAAYvC,EAAYN,MAAMkD,GAMpC,OALIL,IACEE,IAAQA,GAAU,KACtBA,GAAUR,EAAenC,OAAOyC,GAAYL,IAGvCO,CACT,CAkCwC6B,CAAmBtE,EAAakC,IAG/DO,CACT"}
@@ -1,3 +1,3 @@
1
- /*! n2words/pt v3.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,t;e=this,t=function(e){"use strict";function t(e){const t="-"===e[0];t&&(e=e.slice(1));const n=e.indexOf(".");if(-1===n)return{isNegative:t,integerPart:BigInt(e)};const i=e.slice(0,n)||"0",r=e.slice(n+1);return{isNegative:t,integerPart:BigInt(i),decimalPart:r}}function n(e){const[t,n]=e.toLowerCase().split("e"),i=parseInt(n,10),r=t.indexOf("."),o=-1===r?t:t.slice(0,r)+t.slice(r+1),s=(-1===r?t.length:r)+i;return s>=o.length?o+"0".repeat(s-o.length):s<=0?"0."+"0".repeat(-s)+o:o.slice(0,s)+"."+o.slice(s)}const i=["","um","dois","três","quatro","cinco","seis","sete","oito","nove"],r=["dez","onze","doze","treze","catorze","quinze","dezasseis","dezassete","dezoito","dezanove"],o=["","","vinte","trinta","quarenta","cinquenta","sessenta","setenta","oitenta","noventa"],s=["","cento","duzentos","trezentos","quatrocentos","quinhentos","seiscentos","setecentos","oitocentos","novecentos"],u="mil",l="zero";function c(e){if(0===e)return{word:"",isExactHundred:!1};if(100===e)return{word:"cem",isExactHundred:!0};const t=e%10,n=Math.floor(e/10)%10,u=Math.floor(e/100),l=[];return u>0&&l.push(s[u]),1===n?l.push(r[t]):n>=2?l.push(t>0?o[n]+" e "+i[t]:o[n]):t>0&&l.push(i[t]),{word:l.join(" e "),isExactHundred:u>0&&0===n&&0===t}}const a=new Array(1e3),f=new Array(1e3);for(let e=0;e<1e3;e++){const t=c(e);a[e]=t.word,f[e]=e>=100}const d=["",u,"milhão","mil milhões","bilião","mil biliões","trilião","mil triliões","quatrilião"],g=["",u,"milhões","mil milhões","biliões","mil biliões","triliões","mil triliões","quatriliões"];function m(e){if(0n===e)return l;if(e<1000n)return a[Number(e)];if(e<1000000n){const t=Number(e/1000n),n=Number(e%1000n);let i;return i=1===t?u:a[t]+" "+u,n>0&&(i+=f[n]?" "+a[n]:" e "+a[n]),i}return function(e){const t=[];let n=e;for(;n>0n;)t.push(Number(n%1000n)),n/=1000n;let i=0;for(let e=0;e<t.length;e++)if(0!==t[e]){i=e;break}let r="",o=!1;for(let e=t.length-1;e>=0;e--){const n=t[e];if(0===n)continue;const s=a[n];if(r&&e===i&&o&&!f[n]&&(r+=" e"),r&&(r+=" "),0===e)r+=s,o=!1;else if(1===e)r+=1===n?u:s+" "+u,o=!0;else{const t=1===n?d[e]:g[e];r+=1===n?"um "+t:s+" "+t,o=!0}}return r}(e)}e.pt=function(e){const{isNegative:i,integerPart:r,decimalPart:o}=function(e){const i=typeof e;if("bigint"===i)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===i){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:t(function(e){const t=e.toString();return t.includes("e")||t.includes("E")?n(t):t}(e))}if("string"===i)return t(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new Error(`Invalid number format: "${e}"`);return t.includes("e")||t.includes("E")?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(e);let s="";return i&&(s="menos "),s+=m(r),o&&(s+=" vírgula "+function(e){let t="",n=0;for(;n<e.length&&"0"===e[n];)t&&(t+=" "),t+=l,n++;const i=e.slice(n);return i&&(t&&(t+=" "),t+=m(BigInt(i))),t}(o)),s}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/pt v3.1.0 | MIT License | github.com/forzagreen/n2words */
2
+ var e,t;e=this,t=function(e){"use strict";function t(e){const t="-"===e[0];t&&(e=e.slice(1));const n=e.indexOf(".");if(-1===n)return{isNegative:t,integerPart:BigInt(e)};const i=e.slice(0,n)||"0",r=e.slice(n+1);return{isNegative:t,integerPart:BigInt(i),decimalPart:r}}function n(e){const[t,n]=e.toLowerCase().split("e"),i=parseInt(n,10),r=t.indexOf("."),s=-1===r?t:t.slice(0,r)+t.slice(r+1),o=(-1===r?t.length:r)+i;return o>=s.length?s+"0".repeat(o-s.length):o<=0?"0."+"0".repeat(-o)+s:s.slice(0,o)+"."+s.slice(o)}const i=["","um","dois","três","quatro","cinco","seis","sete","oito","nove"],r=["dez","onze","doze","treze","catorze","quinze","dezasseis","dezassete","dezoito","dezanove"],s=["","","vinte","trinta","quarenta","cinquenta","sessenta","setenta","oitenta","noventa"],o=["","cento","duzentos","trezentos","quatrocentos","quinhentos","seiscentos","setecentos","oitocentos","novecentos"],u="mil",l="zero";function c(e){if(0===e)return{word:"",isExactHundred:!1};if(100===e)return{word:"cem",isExactHundred:!0};const t=e%10,n=Math.floor(e/10)%10,u=Math.floor(e/100),l=[];return u>0&&l.push(o[u]),1===n?l.push(r[t]):n>=2?l.push(t>0?s[n]+" e "+i[t]:s[n]):t>0&&l.push(i[t]),{word:l.join(" e "),isExactHundred:u>0&&0===n&&0===t,startsWithHundreds:e>=100}}const a=["",u,"milhão","mil milhões","bilião","mil biliões","trilião","mil triliões","quatrilião"],d=["",u,"milhões","mil milhões","biliões","mil biliões","triliões","mil triliões","quatriliões"];function f(e){if(0n===e)return l;if(e<1000n)return c(Number(e)).word;if(e<1000000n){const t=Number(e/1000n),n=Number(e%1000n);let i;if(i=1===t?u:c(t).word+" "+u,n>0){const e=c(n);i+=e.startsWithHundreds?" "+e.word:" e "+e.word}return i}return function(e){const t=[];let n=e;for(;n>0n;)t.push(Number(n%1000n)),n/=1000n;let i=0;for(let e=0;e<t.length;e++)if(0!==t[e]){i=e;break}let r="",s=!1;for(let e=t.length-1;e>=0;e--){const n=t[e];if(0===n)continue;const o=c(n);if(r&&e===i&&s&&!o.startsWithHundreds&&(r+=" e"),r&&(r+=" "),0===e)r+=o.word,s=!1;else if(1===e)r+=1===n?u:o.word+" "+u,s=!0;else{const t=1===n?a[e]:d[e];r+=1===n?"um "+t:o.word+" "+t,s=!0}}return r}(e)}e.pt=function(e){const{isNegative:i,integerPart:r,decimalPart:s}=function(e){const i=typeof e;if("bigint"===i)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===i){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:t(function(e){const t=e.toString();return t.includes("e")||t.includes("E")?n(t):t}(e))}if("string"===i)return t(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new Error(`Invalid number format: "${e}"`);return t.includes("e")||t.includes("E")?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(e);let o="";return i&&(o="menos "),o+=f(r),s&&(o+=" vírgula "+function(e){let t="",n=0;for(;n<e.length&&"0"===e[n];)t&&(t+=" "),t+=l,n++;const i=e.slice(n);return i&&(t&&(t+=" "),t+=f(BigInt(i))),t}(s)),o}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
3
3
  //# sourceMappingURL=pt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pt.js","sources":["../../lib/utils/parse-numeric.js","../../lib/languages/pt.js"],"sourcesContent":["/**\n * Numeric value parsing utility.\n * Transforms user input (number, string, or bigint) into normalized components.\n * @module parse-numeric\n */\n\n/**\n * Parses a numeric value into its components.\n * @param {number|string|bigint} value\n * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}\n * @throws {TypeError} If value is not number, string, or bigint\n * @throws {Error} If value is not a valid number format\n */\nexport function parseNumericValue (value) {\n const type = typeof value\n\n // BigInt: simplest case\n if (type === 'bigint') {\n return value < 0n\n ? { isNegative: true, integerPart: -value }\n : { isNegative: false, integerPart: value }\n }\n\n // Number: fast path for safe integers\n if (type === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error('Number must be finite (NaN and Infinity are not supported)')\n }\n if (Number.isSafeInteger(value)) {\n return value < 0\n ? { isNegative: true, integerPart: BigInt(-value) }\n : { isNegative: false, integerPart: BigInt(value) }\n }\n return parseNumericString(numberToString(value))\n }\n\n // String input\n if (type === 'string') {\n return parseNumericString(normalizeString(value))\n }\n\n throw new TypeError(\n `Invalid value type: expected number, string, or bigint, received ${type}`\n )\n}\n\n/**\n * Converts a number to decimal string, expanding scientific notation if needed.\n */\nfunction numberToString (value) {\n const str = value.toString()\n return (str.includes('e') || str.includes('E'))\n ? expandScientificNotation(str)\n : str\n}\n\n/**\n * Validates and normalizes a string numeric input.\n */\nfunction normalizeString (value) {\n const trimmed = value.trim()\n if (trimmed.length === 0 || Number.isNaN(Number(trimmed))) {\n throw new Error(`Invalid number format: \"${value}\"`)\n }\n return (trimmed.includes('e') || trimmed.includes('E'))\n ? expandScientificNotation(trimmed)\n : trimmed\n}\n\n/**\n * Parses a normalized numeric string into components.\n */\nfunction parseNumericString (str) {\n const isNegative = str[0] === '-'\n if (isNegative) str = str.slice(1)\n\n const dotIndex = str.indexOf('.')\n if (dotIndex === -1) {\n return { isNegative, integerPart: BigInt(str) }\n }\n\n const integerStr = str.slice(0, dotIndex) || '0'\n const decimalPart = str.slice(dotIndex + 1)\n return { isNegative, integerPart: BigInt(integerStr), decimalPart }\n}\n\n/**\n * Expands scientific notation to decimal form (e.g., \"1e21\" → \"1000...\").\n */\nfunction expandScientificNotation (str) {\n const [mantissa, expStr] = str.toLowerCase().split('e')\n const exp = parseInt(expStr, 10)\n\n const dotIndex = mantissa.indexOf('.')\n const digits = dotIndex === -1\n ? mantissa\n : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)\n const integerLength = dotIndex === -1 ? mantissa.length : dotIndex\n const newDotPosition = integerLength + exp\n\n if (newDotPosition >= digits.length) {\n return digits + '0'.repeat(newDotPosition - digits.length)\n }\n if (newDotPosition <= 0) {\n return '0.' + '0'.repeat(-newDotPosition) + digits\n }\n return digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)\n}\n","/**\n * Portuguese language converter - Functional Implementation\n *\n * A performance-optimized number-to-words converter using precomputed lookup tables.\n * Self-contained module with its own input validation, ready for subpath exports.\n *\n * Key optimization: Precompute all segment values (0-999) at module load.\n * This eliminates all per-call string manipulation for segment conversion.\n *\n * Portuguese-specific rules (handled in precomputation):\n * - \"e\" conjunction everywhere: vinte e um, cento e um, mil e um\n * - \"cem\" for exact 100, \"cento\" for 100+ remainder\n * - Irregular hundreds: duzentos, trezentos, quatrocentos, etc.\n * - Compound scale: milhão (10^6), mil milhões (10^9), bilião (10^12)\n * - Omit \"um\" before \"mil\"\n */\n\nimport { parseNumericValue } from '../utils/parse-numeric.js'\n\n// ============================================================================\n// Vocabulary (module-level constants)\n// ============================================================================\n\nconst ONES = ['', 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove']\nconst TEENS = ['dez', 'onze', 'doze', 'treze', 'catorze', 'quinze', 'dezasseis', 'dezassete', 'dezoito', 'dezanove']\nconst TENS = ['', '', 'vinte', 'trinta', 'quarenta', 'cinquenta', 'sessenta', 'setenta', 'oitenta', 'noventa']\n\n// Irregular hundreds\nconst HUNDREDS = ['', 'cento', 'duzentos', 'trezentos', 'quatrocentos', 'quinhentos', 'seiscentos', 'setecentos', 'oitocentos', 'novecentos']\n\nconst THOUSAND = 'mil'\nconst ZERO = 'zero'\nconst NEGATIVE = 'menos'\nconst DECIMAL_SEP = 'vírgula'\n\n// ============================================================================\n// Precomputed Lookup Tables (built once at module load)\n// ============================================================================\n\n/**\n * Builds segment word for 0-999 with Portuguese \"e\" rules.\n * Returns the word and whether it's an exact hundred (for \"cem\" handling).\n */\nfunction buildSegment (n) {\n if (n === 0) return { word: '', isExactHundred: false }\n\n // Special case: exact 100 is \"cem\"\n if (n === 100) return { word: 'cem', isExactHundred: true }\n\n const ones = n % 10\n const tens = Math.floor(n / 10) % 10\n const hundreds = Math.floor(n / 100)\n\n const parts = []\n\n // Hundreds\n if (hundreds > 0) {\n parts.push(HUNDREDS[hundreds])\n }\n\n // Tens and ones\n if (tens === 1) {\n // Teens (10-19)\n parts.push(TEENS[ones])\n } else if (tens >= 2) {\n if (ones > 0) {\n // Tens + ones with \"e\": \"vinte e um\"\n parts.push(TENS[tens] + ' e ' + ONES[ones])\n } else {\n parts.push(TENS[tens])\n }\n } else if (ones > 0) {\n parts.push(ONES[ones])\n }\n\n // Join hundreds with \"e\": \"cento e um\", \"duzentos e trinta e um\"\n const word = parts.join(' e ')\n\n return { word, isExactHundred: hundreds > 0 && tens === 0 && ones === 0 }\n}\n\n// Precompute all 1000 segment words (0-999)\nconst SEGMENTS = new Array(1000)\nconst SEGMENTS_STARTS_WITH_HUNDREDS = new Array(1000)\n\nfor (let i = 0; i < 1000; i++) {\n const result = buildSegment(i)\n SEGMENTS[i] = result.word\n // Precompute whether segment starts with hundreds (100-999)\n SEGMENTS_STARTS_WITH_HUNDREDS[i] = i >= 100\n}\n\n// ============================================================================\n// Scale Word Lookup (precomputed for common scales)\n// ============================================================================\n\n// Precompute scale words for singular and plural forms\n// Index 1 = thousands, 2 = millions, 3 = billions (mil milhões), etc.\nconst SCALE_WORDS_SINGULAR = [\n '', // 0 unused\n THOUSAND, // 1: mil\n 'milhão', // 2: 10^6\n 'mil milhões', // 3: 10^9 (compound)\n 'bilião', // 4: 10^12\n 'mil biliões', // 5: 10^15 (compound)\n 'trilião', // 6: 10^18\n 'mil triliões', // 7: 10^21 (compound)\n 'quatrilião' // 8: 10^24\n]\n\nconst SCALE_WORDS_PLURAL = [\n '', // 0 unused\n THOUSAND, // 1: mil (same)\n 'milhões', // 2: 10^6\n 'mil milhões', // 3: 10^9 (compound, same)\n 'biliões', // 4: 10^12\n 'mil biliões', // 5: 10^15 (compound, same)\n 'triliões', // 6: 10^18\n 'mil triliões', // 7: 10^21 (compound, same)\n 'quatriliões' // 8: 10^24\n]\n\n// ============================================================================\n// Conversion Functions\n// ============================================================================\n\n/**\n * Converts a non-negative integer to Portuguese words.\n *\n * @param {bigint} n - Non-negative integer to convert\n * @returns {string} Portuguese words\n */\nfunction integerToWords (n) {\n if (n === 0n) return ZERO\n\n // Fast path: numbers < 1000 (direct lookup)\n if (n < 1000n) {\n return SEGMENTS[Number(n)]\n }\n\n // Fast path: numbers < 1,000,000 (thousands)\n if (n < 1_000_000n) {\n const thousands = Number(n / 1000n)\n const remainder = Number(n % 1000n)\n\n let result\n if (thousands === 1) {\n // \"mil\" not \"um mil\"\n result = THOUSAND\n } else {\n result = SEGMENTS[thousands] + ' ' + THOUSAND\n }\n\n if (remainder > 0) {\n // Insert \"e\" before remainder if it doesn't start with hundreds (< 100)\n if (!SEGMENTS_STARTS_WITH_HUNDREDS[remainder]) {\n result += ' e ' + SEGMENTS[remainder]\n } else {\n result += ' ' + SEGMENTS[remainder]\n }\n }\n\n return result\n }\n\n // For numbers >= 1,000,000, use scale decomposition\n return buildLargeNumberWords(n)\n}\n\n/**\n * Builds words for numbers >= 1,000,000.\n * Uses BigInt division for faster segment extraction.\n *\n * @param {bigint} n - Number >= 1,000,000\n * @returns {string} Portuguese words\n */\nfunction buildLargeNumberWords (n) {\n // Extract segments using BigInt division\n // Segments stored least-significant first (index 0 = ones, 1 = thousands, etc.)\n const segments = []\n let temp = n\n while (temp > 0n) {\n segments.push(Number(temp % 1000n))\n temp = temp / 1000n\n }\n\n // Find the first non-zero segment index (lowest scale with value)\n let firstNonZeroIdx = 0\n for (let i = 0; i < segments.length; i++) {\n if (segments[i] !== 0) {\n firstNonZeroIdx = i\n break\n }\n }\n\n // Build result string directly\n let result = ''\n let prevWasScale = false\n\n for (let i = segments.length - 1; i >= 0; i--) {\n const segment = segments[i]\n if (segment === 0) continue\n\n const segmentWord = SEGMENTS[segment]\n const isLastSegment = (i === firstNonZeroIdx)\n\n // Add \"e\" before final segment if previous was scale and this doesn't start with hundreds\n if (result && isLastSegment && prevWasScale && !SEGMENTS_STARTS_WITH_HUNDREDS[segment]) {\n result += ' e'\n }\n\n if (result) result += ' '\n\n if (i === 0) {\n // Units segment\n result += segmentWord\n prevWasScale = false\n } else if (i === 1) {\n // Thousands\n if (segment === 1) {\n result += THOUSAND\n } else {\n result += segmentWord + ' ' + THOUSAND\n }\n prevWasScale = true\n } else {\n // Million and above - use precomputed scale arrays\n const scaleWord = segment === 1 ? SCALE_WORDS_SINGULAR[i] : SCALE_WORDS_PLURAL[i]\n if (segment === 1) {\n result += 'um ' + scaleWord\n } else {\n result += segmentWord + ' ' + scaleWord\n }\n prevWasScale = true\n }\n }\n\n return result\n}\n\n/**\n * Converts decimal digits to Portuguese words.\n *\n * @param {string} decimalPart - Decimal digits (without the point)\n * @returns {string} Portuguese words for decimal part\n */\nfunction decimalPartToWords (decimalPart) {\n let result = ''\n\n // Handle leading zeros\n let i = 0\n while (i < decimalPart.length && decimalPart[i] === '0') {\n if (result) result += ' '\n result += ZERO\n i++\n }\n\n // Convert remainder as a single number\n const remainder = decimalPart.slice(i)\n if (remainder) {\n if (result) result += ' '\n result += integerToWords(BigInt(remainder))\n }\n\n return result\n}\n\n/**\n * Converts a numeric value to Portuguese words.\n *\n * This is the main public API. It accepts any valid numeric input\n * (number, string, or bigint) and handles parsing internally.\n *\n * @param {number | string | bigint} value - The numeric value to convert\n * @returns {string} The number in Portuguese words\n * @throws {TypeError} If value is not a valid numeric type\n * @throws {Error} If value is not a valid number format\n *\n * @example\n * toWords(21) // 'vinte e um'\n * toWords(100) // 'cem'\n * toWords(1000000) // 'um milhão'\n */\nfunction toWords (value) {\n const { isNegative, integerPart, decimalPart } = parseNumericValue(value)\n\n let result = ''\n\n if (isNegative) {\n result = NEGATIVE + ' '\n }\n\n result += integerToWords(integerPart)\n\n if (decimalPart) {\n result += ' ' + DECIMAL_SEP + ' ' + decimalPartToWords(decimalPart)\n }\n\n return result\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\nexport { toWords }\n"],"names":["parseNumericString","str","isNegative","slice","dotIndex","indexOf","integerPart","BigInt","integerStr","decimalPart","expandScientificNotation","mantissa","expStr","toLowerCase","split","exp","parseInt","digits","newDotPosition","length","repeat","ONES","TEENS","TENS","HUNDREDS","THOUSAND","ZERO","buildSegment","n","word","isExactHundred","ones","tens","Math","floor","hundreds","parts","push","join","SEGMENTS","Array","SEGMENTS_STARTS_WITH_HUNDREDS","i","result","SCALE_WORDS_SINGULAR","SCALE_WORDS_PLURAL","integerToWords","Number","thousands","remainder","segments","temp","firstNonZeroIdx","prevWasScale","segment","segmentWord","scaleWord","buildLargeNumberWords","value","type","isFinite","Error","isSafeInteger","toString","includes","numberToString","trimmed","trim","isNaN","normalizeString","TypeError","parseNumericValue","NEGATIVE","decimalPartToWords"],"mappings":";0CAwEA,SAASA,EAAoBC,GAC3B,MAAMC,EAAwB,MAAXD,EAAI,GACnBC,IAAYD,EAAMA,EAAIE,MAAM,IAEhC,MAAMC,EAAWH,EAAII,QAAQ,KAC7B,IAAiB,IAAbD,EACF,MAAO,CAAEF,aAAYI,YAAaC,OAAON,IAG3C,MAAMO,EAAaP,EAAIE,MAAM,EAAGC,IAAa,IACvCK,EAAcR,EAAIE,MAAMC,EAAW,GACzC,MAAO,CAAEF,aAAYI,YAAaC,OAAOC,GAAaC,cACxD,CAKA,SAASC,EAA0BT,GACjC,MAAOU,EAAUC,GAAUX,EAAIY,cAAcC,MAAM,KAC7CC,EAAMC,SAASJ,EAAQ,IAEvBR,EAA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mDY,CAAkBb,GAEnE,IAAIf,EAAS,GAYb,OAVIzC,IACFyC,EAAS6B,UAGX7B,GAAUG,EAAexC,GAErBG,IACFkC,GAAU,YAjDd,SAA6BlC,GAC3B,IAAIkC,EAAS,GAGTD,EAAI,EACR,KAAOA,EAAIjC,EAAYU,QAA6B,MAAnBV,EAAYiC,IACvCC,IAAQA,GAAU,KACtBA,GAAUjB,EACVgB,IAIF,MAAMO,EAAYxC,EAAYN,MAAMuC,GAMpC,OALIO,IACEN,IAAQA,GAAU,KACtBA,GAAUG,EAAevC,OAAO0C,KAG3BN,CACT,CA8BwC8B,CAAmBhE,IAGlDkC,CACT"}
1
+ {"version":3,"file":"pt.js","sources":["../../lib/utils/parse-numeric.js","../../lib/languages/pt.js"],"sourcesContent":["/**\n * Numeric value parsing utility.\n * Transforms user input (number, string, or bigint) into normalized components.\n * @module parse-numeric\n */\n\n/**\n * Parses a numeric value into its components.\n * @param {number|string|bigint} value\n * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}\n * @throws {TypeError} If value is not number, string, or bigint\n * @throws {Error} If value is not a valid number format\n */\nexport function parseNumericValue (value) {\n const type = typeof value\n\n // BigInt: simplest case\n if (type === 'bigint') {\n return value < 0n\n ? { isNegative: true, integerPart: -value }\n : { isNegative: false, integerPart: value }\n }\n\n // Number: fast path for safe integers\n if (type === 'number') {\n if (!Number.isFinite(value)) {\n throw new Error('Number must be finite (NaN and Infinity are not supported)')\n }\n if (Number.isSafeInteger(value)) {\n return value < 0\n ? { isNegative: true, integerPart: BigInt(-value) }\n : { isNegative: false, integerPart: BigInt(value) }\n }\n return parseNumericString(numberToString(value))\n }\n\n // String input\n if (type === 'string') {\n return parseNumericString(normalizeString(value))\n }\n\n throw new TypeError(\n `Invalid value type: expected number, string, or bigint, received ${type}`\n )\n}\n\n/**\n * Converts a number to decimal string, expanding scientific notation if needed.\n */\nfunction numberToString (value) {\n const str = value.toString()\n return (str.includes('e') || str.includes('E'))\n ? expandScientificNotation(str)\n : str\n}\n\n/**\n * Validates and normalizes a string numeric input.\n */\nfunction normalizeString (value) {\n const trimmed = value.trim()\n if (trimmed.length === 0 || Number.isNaN(Number(trimmed))) {\n throw new Error(`Invalid number format: \"${value}\"`)\n }\n return (trimmed.includes('e') || trimmed.includes('E'))\n ? expandScientificNotation(trimmed)\n : trimmed\n}\n\n/**\n * Parses a normalized numeric string into components.\n */\nfunction parseNumericString (str) {\n const isNegative = str[0] === '-'\n if (isNegative) str = str.slice(1)\n\n const dotIndex = str.indexOf('.')\n if (dotIndex === -1) {\n return { isNegative, integerPart: BigInt(str) }\n }\n\n const integerStr = str.slice(0, dotIndex) || '0'\n const decimalPart = str.slice(dotIndex + 1)\n return { isNegative, integerPart: BigInt(integerStr), decimalPart }\n}\n\n/**\n * Expands scientific notation to decimal form (e.g., \"1e21\" → \"1000...\").\n */\nfunction expandScientificNotation (str) {\n const [mantissa, expStr] = str.toLowerCase().split('e')\n const exp = parseInt(expStr, 10)\n\n const dotIndex = mantissa.indexOf('.')\n const digits = dotIndex === -1\n ? mantissa\n : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)\n const integerLength = dotIndex === -1 ? mantissa.length : dotIndex\n const newDotPosition = integerLength + exp\n\n if (newDotPosition >= digits.length) {\n return digits + '0'.repeat(newDotPosition - digits.length)\n }\n if (newDotPosition <= 0) {\n return '0.' + '0'.repeat(-newDotPosition) + digits\n }\n return digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)\n}\n","/**\n * Portuguese language converter - Functional Implementation\n *\n * Self-contained module with its own input validation, ready for subpath exports.\n *\n * Portuguese-specific rules:\n * - \"e\" conjunction everywhere: vinte e um, cento e um, mil e um\n * - \"cem\" for exact 100, \"cento\" for 100+ remainder\n * - Irregular hundreds: duzentos, trezentos, quatrocentos, etc.\n * - Compound scale: milhão (10^6), mil milhões (10^9), bilião (10^12)\n * - Omit \"um\" before \"mil\"\n */\n\nimport { parseNumericValue } from '../utils/parse-numeric.js'\n\n// ============================================================================\n// Vocabulary (module-level constants)\n// ============================================================================\n\nconst ONES = ['', 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove']\nconst TEENS = ['dez', 'onze', 'doze', 'treze', 'catorze', 'quinze', 'dezasseis', 'dezassete', 'dezoito', 'dezanove']\nconst TENS = ['', '', 'vinte', 'trinta', 'quarenta', 'cinquenta', 'sessenta', 'setenta', 'oitenta', 'noventa']\n\n// Irregular hundreds\nconst HUNDREDS = ['', 'cento', 'duzentos', 'trezentos', 'quatrocentos', 'quinhentos', 'seiscentos', 'setecentos', 'oitocentos', 'novecentos']\n\nconst THOUSAND = 'mil'\nconst ZERO = 'zero'\nconst NEGATIVE = 'menos'\nconst DECIMAL_SEP = 'vírgula'\n\n// ============================================================================\n// Segment Building\n// ============================================================================\n\n/**\n * Builds segment word for 0-999 with Portuguese \"e\" rules.\n * Returns the word and whether it's an exact hundred (for \"cem\" handling).\n */\nfunction buildSegment (n) {\n if (n === 0) return { word: '', isExactHundred: false }\n\n // Special case: exact 100 is \"cem\"\n if (n === 100) return { word: 'cem', isExactHundred: true }\n\n const ones = n % 10\n const tens = Math.floor(n / 10) % 10\n const hundreds = Math.floor(n / 100)\n\n const parts = []\n\n // Hundreds\n if (hundreds > 0) {\n parts.push(HUNDREDS[hundreds])\n }\n\n // Tens and ones\n if (tens === 1) {\n // Teens (10-19)\n parts.push(TEENS[ones])\n } else if (tens >= 2) {\n if (ones > 0) {\n // Tens + ones with \"e\": \"vinte e um\"\n parts.push(TENS[tens] + ' e ' + ONES[ones])\n } else {\n parts.push(TENS[tens])\n }\n } else if (ones > 0) {\n parts.push(ONES[ones])\n }\n\n // Join hundreds with \"e\": \"cento e um\", \"duzentos e trinta e um\"\n const word = parts.join(' e ')\n\n return { word, isExactHundred: hundreds > 0 && tens === 0 && ones === 0, startsWithHundreds: n >= 100 }\n}\n\n// ============================================================================\n// Scale Word Lookup\n// ============================================================================\n\n// Precompute scale words for singular and plural forms\n// Index 1 = thousands, 2 = millions, 3 = billions (mil milhões), etc.\nconst SCALE_WORDS_SINGULAR = [\n '', // 0 unused\n THOUSAND, // 1: mil\n 'milhão', // 2: 10^6\n 'mil milhões', // 3: 10^9 (compound)\n 'bilião', // 4: 10^12\n 'mil biliões', // 5: 10^15 (compound)\n 'trilião', // 6: 10^18\n 'mil triliões', // 7: 10^21 (compound)\n 'quatrilião' // 8: 10^24\n]\n\nconst SCALE_WORDS_PLURAL = [\n '', // 0 unused\n THOUSAND, // 1: mil (same)\n 'milhões', // 2: 10^6\n 'mil milhões', // 3: 10^9 (compound, same)\n 'biliões', // 4: 10^12\n 'mil biliões', // 5: 10^15 (compound, same)\n 'triliões', // 6: 10^18\n 'mil triliões', // 7: 10^21 (compound, same)\n 'quatriliões' // 8: 10^24\n]\n\n// ============================================================================\n// Conversion Functions\n// ============================================================================\n\n/**\n * Converts a non-negative integer to Portuguese words.\n *\n * @param {bigint} n - Non-negative integer to convert\n * @returns {string} Portuguese words\n */\nfunction integerToWords (n) {\n if (n === 0n) return ZERO\n\n // Fast path: numbers < 1000\n if (n < 1000n) {\n return buildSegment(Number(n)).word\n }\n\n // Fast path: numbers < 1,000,000 (thousands)\n if (n < 1_000_000n) {\n const thousands = Number(n / 1000n)\n const remainder = Number(n % 1000n)\n\n let result\n if (thousands === 1) {\n // \"mil\" not \"um mil\"\n result = THOUSAND\n } else {\n result = buildSegment(thousands).word + ' ' + THOUSAND\n }\n\n if (remainder > 0) {\n const remainderResult = buildSegment(remainder)\n // Insert \"e\" before remainder if it doesn't start with hundreds (< 100)\n if (!remainderResult.startsWithHundreds) {\n result += ' e ' + remainderResult.word\n } else {\n result += ' ' + remainderResult.word\n }\n }\n\n return result\n }\n\n // For numbers >= 1,000,000, use scale decomposition\n return buildLargeNumberWords(n)\n}\n\n/**\n * Builds words for numbers >= 1,000,000.\n * Uses BigInt division for faster segment extraction.\n *\n * @param {bigint} n - Number >= 1,000,000\n * @returns {string} Portuguese words\n */\nfunction buildLargeNumberWords (n) {\n // Extract segments using BigInt division\n // Segments stored least-significant first (index 0 = ones, 1 = thousands, etc.)\n const segments = []\n let temp = n\n while (temp > 0n) {\n segments.push(Number(temp % 1000n))\n temp = temp / 1000n\n }\n\n // Find the first non-zero segment index (lowest scale with value)\n let firstNonZeroIdx = 0\n for (let i = 0; i < segments.length; i++) {\n if (segments[i] !== 0) {\n firstNonZeroIdx = i\n break\n }\n }\n\n // Build result string directly\n let result = ''\n let prevWasScale = false\n\n for (let i = segments.length - 1; i >= 0; i--) {\n const segment = segments[i]\n if (segment === 0) continue\n\n const segmentResult = buildSegment(segment)\n const isLastSegment = (i === firstNonZeroIdx)\n\n // Add \"e\" before final segment if previous was scale and this doesn't start with hundreds\n if (result && isLastSegment && prevWasScale && !segmentResult.startsWithHundreds) {\n result += ' e'\n }\n\n if (result) result += ' '\n\n if (i === 0) {\n // Units segment\n result += segmentResult.word\n prevWasScale = false\n } else if (i === 1) {\n // Thousands\n if (segment === 1) {\n result += THOUSAND\n } else {\n result += segmentResult.word + ' ' + THOUSAND\n }\n prevWasScale = true\n } else {\n // Million and above - use scale arrays\n const scaleWord = segment === 1 ? SCALE_WORDS_SINGULAR[i] : SCALE_WORDS_PLURAL[i]\n if (segment === 1) {\n result += 'um ' + scaleWord\n } else {\n result += segmentResult.word + ' ' + scaleWord\n }\n prevWasScale = true\n }\n }\n\n return result\n}\n\n/**\n * Converts decimal digits to Portuguese words.\n *\n * @param {string} decimalPart - Decimal digits (without the point)\n * @returns {string} Portuguese words for decimal part\n */\nfunction decimalPartToWords (decimalPart) {\n let result = ''\n\n // Handle leading zeros\n let i = 0\n while (i < decimalPart.length && decimalPart[i] === '0') {\n if (result) result += ' '\n result += ZERO\n i++\n }\n\n // Convert remainder as a single number\n const remainder = decimalPart.slice(i)\n if (remainder) {\n if (result) result += ' '\n result += integerToWords(BigInt(remainder))\n }\n\n return result\n}\n\n/**\n * Converts a numeric value to Portuguese words.\n *\n * This is the main public API. It accepts any valid numeric input\n * (number, string, or bigint) and handles parsing internally.\n *\n * @param {number | string | bigint} value - The numeric value to convert\n * @returns {string} The number in Portuguese words\n * @throws {TypeError} If value is not a valid numeric type\n * @throws {Error} If value is not a valid number format\n *\n * @example\n * toWords(21) // 'vinte e um'\n * toWords(100) // 'cem'\n * toWords(1000000) // 'um milhão'\n */\nfunction toWords (value) {\n const { isNegative, integerPart, decimalPart } = parseNumericValue(value)\n\n let result = ''\n\n if (isNegative) {\n result = NEGATIVE + ' '\n }\n\n result += integerToWords(integerPart)\n\n if (decimalPart) {\n result += ' ' + DECIMAL_SEP + ' ' + decimalPartToWords(decimalPart)\n }\n\n return result\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\nexport { toWords }\n"],"names":["parseNumericString","str","isNegative","slice","dotIndex","indexOf","integerPart","BigInt","integerStr","decimalPart","expandScientificNotation","mantissa","expStr","toLowerCase","split","exp","parseInt","digits","newDotPosition","length","repeat","ONES","TEENS","TENS","HUNDREDS","THOUSAND","ZERO","buildSegment","n","word","isExactHundred","ones","tens","Math","floor","hundreds","parts","push","join","startsWithHundreds","SCALE_WORDS_SINGULAR","SCALE_WORDS_PLURAL","integerToWords","Number","thousands","remainder","result","remainderResult","segments","temp","firstNonZeroIdx","i","prevWasScale","segment","segmentResult","scaleWord","buildLargeNumberWords","value","type","isFinite","Error","isSafeInteger","toString","includes","numberToString","trimmed","trim","isNaN","normalizeString","TypeError","parseNumericValue","NEGATIVE","decimalPartToWords"],"mappings":";0CAwEA,SAASA,EAAoBC,GAC3B,MAAMC,EAAwB,MAAXD,EAAI,GACnBC,IAAYD,EAAMA,EAAIE,MAAM,IAEhC,MAAMC,EAAWH,EAAII,QAAQ,KAC7B,IAAiB,IAAbD,EACF,MAAO,CAAEF,aAAYI,YAAaC,OAAON,IAG3C,MAAMO,EAAaP,EAAIE,MAAM,EAAGC,IAAa,IACvCK,EAAcR,EAAIE,MAAMC,EAAW,GACzC,MAAO,CAAEF,aAAYI,YAAaC,OAAOC,GAAaC,cACxD,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R,oEAAoEX,IAExE,CCkOmDY,CAAkBb,GAEnE,IAAIX,EAAS,GAYb,OAVI5C,IACF4C,EAASyB,UAGXzB,GAAUJ,EAAepC,GAErBG,IACFqC,GAAU,YAjDd,SAA6BrC,GAC3B,IAAIqC,EAAS,GAGTK,EAAI,EACR,KAAOA,EAAI1C,EAAYU,QAA6B,MAAnBV,EAAY0C,IACvCL,IAAQA,GAAU,KACtBA,GAAUpB,EACVyB,IAIF,MAAMN,EAAYpC,EAAYN,MAAMgD,GAMpC,OALIN,IACEC,IAAQA,GAAU,KACtBA,GAAUJ,EAAenC,OAAOsC,KAG3BC,CACT,CA8BwC0B,CAAmB/D,IAGlDqC,CACT"}
@@ -1,3 +1,3 @@
1
- /*! n2words/ro v3.0.0 | MIT License | github.com/forzagreen/n2words */
1
+ /*! n2words/ro v3.1.0 | MIT License | github.com/forzagreen/n2words */
2
2
  var e,n;e=this,n=function(e){"use strict";function n(e){const n="-"===e[0];n&&(e=e.slice(1));const i=e.indexOf(".");if(-1===i)return{isNegative:n,integerPart:BigInt(e)};const t=e.slice(0,i)||"0",r=e.slice(i+1);return{isNegative:n,integerPart:BigInt(t),decimalPart:r}}function i(e){const[n,i]=e.toLowerCase().split("e"),t=parseInt(i,10),r=n.indexOf("."),u=-1===r?n:n.slice(0,r)+n.slice(r+1),o=(-1===r?n.length:r)+t;return o>=u.length?u+"0".repeat(o-u.length):o<=0?"0."+"0".repeat(-o)+u:u.slice(0,o)+"."+u.slice(o)}const t=["","unu","doi","trei","patru","cinci","șase","șapte","opt","nouă"],r=["","una","două","trei","patru","cinci","șase","șapte","opt","nouă"],u=["zece","unsprezece","douăsprezece","treisprezece","paisprezece","cincisprezece","șaisprezece","șaptesprezece","optsprezece","nouăsprezece"],o=["zece","unsprezece","doisprezece","treisprezece","paisprezece","cincisprezece","șaisprezece","șaptesprezece","optsprezece","nouăsprezece"],s=["","","douăzeci","treizeci","patruzeci","cincizeci","șaizeci","șaptezeci","optzeci","nouăzeci"],c=["","o sută","două sute","trei sute","patru sute","cinci sute","șase sute","șapte sute","opt sute","nouă sute"],l="zero",a=[{singular:"mie",plural:"mii",article:"o",feminine:!0,needsDe:!0},{singular:"milion",plural:"milioane",article:"un",feminine:!1,needsDe:!0},{singular:"miliard",plural:"miliarde",article:"un",feminine:!1,needsDe:!0},{singular:"trilion",plural:"trilioane",article:"un",feminine:!1,needsDe:!0},{singular:"cvadrilion",plural:"cvadrilioane",article:"un",feminine:!1,needsDe:!0},{singular:"cvintilion",plural:"cvintilioane",article:"un",feminine:!1,needsDe:!0},{singular:"sextilion",plural:"sextilioane",article:"un",feminine:!1,needsDe:!0},{singular:"septilion",plural:"septilioane",article:"un",feminine:!1,needsDe:!0},{singular:"octilion",plural:"octilioane",article:"un",feminine:!1,needsDe:!0}];function p(e,n=!1,i=!1){if(0===e)return"";if(e<10)return n?r[e]:t[e];if(e<20)return i?o[e-10]:u[e-10];const c=Math.floor(e/10),l=e%10;return 0===l?s[c]:s[c]+" și "+(n?r[l]:t[l])}function f(e,n=!1,i=!1){if(0===e)return"";if(e<100)return p(e,n,i);const t=Math.floor(e/100),r=e%100,u=c[t];return 0===r?u:u+" "+p(r,n,i)}function d(e,n){const i=a[n-1];return i?1===e?i.article+" "+i.singular:21===e&&i.needsDe?"douăzeci și una de "+i.plural:f(e,!0)+(i.needsDe&&e>=20?" de ":" ")+i.plural:f(e,!0)}function g(e,n={}){if(0n===e)return l;if(e<1000n){const i="feminine"===n.gender;return f(Number(e),i)}return function(e,n){const i=[];let t=e;for(;t>0n;)i.push(Number(t%1000n)),t/=1000n;let r="";for(let e=i.length-1;e>=0;e--){const t=i[e];if(0===t)continue;let u;u=0===e?f(t,"feminine"===n.gender):d(t,e),r&&u?r+=" "+u:u&&(r=u)}return r}(e,n)}e.ro=function(e,t){t=function(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}(t);const{isNegative:r,integerPart:u,decimalPart:o}=function(e){const t=typeof e;if("bigint"===t)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===t){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:n(function(e){const n=e.toString();return n.includes("e")||n.includes("E")?i(n):n}(e))}if("string"===t)return n(function(e){const n=e.trim();if(0===n.length||Number.isNaN(Number(n)))throw new Error(`Invalid number format: "${e}"`);return n.includes("e")||n.includes("E")?i(n):n}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);let s="";return r&&(s="minus "),s+=g(u,t),o&&(s+=" virgulă "+function(e){let n="",i=0;for(;i<e.length&&"0"===e[i];)n&&(n+=" "),n+=l,i++;const t=e.slice(i);if(t){n&&(n+=" ");const e=BigInt(t);n+=e<1000n?f(Number(e),!1,!0):g(e,{gender:"masculine"})}return n}(o)),s}},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
3
3
  //# sourceMappingURL=ro.js.map
@@ -1,3 +1,3 @@
1
- /*! n2words/ru v3.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,t;e=this,t=function(e){"use strict";function t(e){const t="-"===e[0];t&&(e=e.slice(1));const n=e.indexOf(".");if(-1===n)return{isNegative:t,integerPart:BigInt(e)};const r=e.slice(0,n)||"0",i=e.slice(n+1);return{isNegative:t,integerPart:BigInt(r),decimalPart:i}}function n(e){const[t,n]=e.toLowerCase().split("e"),r=parseInt(n,10),i=t.indexOf("."),o=-1===i?t:t.slice(0,i)+t.slice(i+1),u=(-1===i?t.length:i)+r;return u>=o.length?o+"0".repeat(u-o.length):u<=0?"0."+"0".repeat(-u)+o:o.slice(0,u)+"."+o.slice(u)}function r(e,t){const n="bigint"==typeof e?Number(e):e,r=n%10,i=n%100;return i>=11&&i<=19?t[2]:1===r?t[0]:r>=2&&r<=4?t[1]:t[2]}function i(e,t,n,r,i){if(0===e)return"";const o=e%10,u=Math.floor(e/10)%10,s=Math.floor(e/100),c=[];return s>0&&c.push(i[s]),u>1&&c.push(r[u]),1===u?c.push(n[o]):o>0&&c.push(t[o]),c.join(" ")}const o="ноль",u=[["тысяча","тысячи","тысяч"],["миллион","миллиона","миллионов"],["миллиард","миллиарда","миллиардов"],["триллион","триллиона","триллионов"],["квадриллион","квадриллиона","квадриллионов"],["квинтиллион","квинтиллиона","квинтиллионов"],["секстиллион","секстиллиона","секстиллионов"],["септиллион","септиллиона","септиллионов"],["октиллион","октиллиона","октиллионов"],["нониллион","нониллиона","нониллионов"]],{masc:s,fem:c}=function(e,t,n,r,o){const u=new Array(1e3),s=new Array(1e3);for(let c=0;c<1e3;c++)u[c]=i(c,e,n,r,o),s[c]=i(c,t,n,r,o);return{masc:u,fem:s}}(["","один","два","три","четыре","пять","шесть","семь","восемь","девять"],["","одна","две","три","четыре","пять","шесть","семь","восемь","девять"],["десять","одиннадцать","двенадцать","тринадцать","четырнадцать","пятнадцать","шестнадцать","семнадцать","восемнадцать","девятнадцать"],["","","двадцать","тридцать","сорок","пятьдесят","шестьдесят","семьдесят","восемьдесят","девяносто"],["","сто","двести","триста","четыреста","пятьсот","шестьсот","семьсот","восемьсот","девятьсот"]);function f(e,t={}){if(0n===e)return o;const n="feminine"===t.gender;if(e<1000n)return(n?c:s)[Number(e)];if(e<1000000n){const t=Number(e/1000n),i=Number(e%1000n);let o=c[t]+" "+r(t,u[0]);return i>0&&(o+=" "+(n?c:s)[i]),o}return function(e,t){const n="feminine"===t.gender,i=e.toString(),o=i.length,f=[],l=o%3;let a=0;for(l>0&&(f.push(Number(i.slice(0,l))),a=l);a<o;)f.push(Number(i.slice(a,a+3))),a+=3;const g=[];let p=f.length-1;for(let e=0;e<f.length;e++){const t=f[e];if(0!==t)if(0===p)g.push((n?c:s)[t]);else{const e=r(t,u[p-1]);g.push((1===p?c:s)[t]+" "+e)}p--}return g.join(" ")}(e,t)}e.ru=function(e,r){r=function(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}(r);const{isNegative:i,integerPart:u,decimalPart:s}=function(e){const r=typeof e;if("bigint"===r)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===r){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:t(function(e){const t=e.toString();return t.includes("e")||t.includes("E")?n(t):t}(e))}if("string"===r)return t(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new Error(`Invalid number format: "${e}"`);return t.includes("e")||t.includes("E")?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${r}`)}(e);let c="";return i&&(c="минус "),c+=f(u,r),s&&(c+=" запятая "+function(e,t){let n="",r=0;for(;r<e.length&&"0"===e[r];)n&&(n+=" "),n+=o,r++;const i=e.slice(r);return i&&(n&&(n+=" "),n+=f(BigInt(i),t)),n}(s,r)),c}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/ru v3.1.0 | MIT License | github.com/forzagreen/n2words */
2
+ var e,t;e=this,t=function(e){"use strict";function t(e){const t="-"===e[0];t&&(e=e.slice(1));const n=e.indexOf(".");if(-1===n)return{isNegative:t,integerPart:BigInt(e)};const r=e.slice(0,n)||"0",i=e.slice(n+1);return{isNegative:t,integerPart:BigInt(r),decimalPart:i}}function n(e){const[t,n]=e.toLowerCase().split("e"),r=parseInt(n,10),i=t.indexOf("."),o=-1===i?t:t.slice(0,i)+t.slice(i+1),u=(-1===i?t.length:i)+r;return u>=o.length?o+"0".repeat(u-o.length):u<=0?"0."+"0".repeat(-u)+o:o.slice(0,u)+"."+o.slice(u)}const r=["","один","два","три","четыре","пять","шесть","семь","восемь","девять"],i=["","одна","две","три","четыре","пять","шесть","семь","восемь","девять"],o=["десять","одиннадцать","двенадцать","тринадцать","четырнадцать","пятнадцать","шестнадцать","семнадцать","восемнадцать","девятнадцать"],u=["","","двадцать","тридцать","сорок","пятьдесят","шестьдесят","семьдесят","восемьдесят","девяносто"],s=["","сто","двести","триста","четыреста","пятьсот","шестьсот","семьсот","восемьсот","девятьсот"],f="ноль",c=[["тысяча","тысячи","тысяч"],["миллион","миллиона","миллионов"],["миллиард","миллиарда","миллиардов"],["триллион","триллиона","триллионов"],["квадриллион","квадриллиона","квадриллионов"],["квинтиллион","квинтиллиона","квинтиллионов"],["секстиллион","секстиллиона","секстиллионов"],["септиллион","септиллиона","септиллионов"],["октиллион","октиллиона","октиллионов"],["нониллион","нониллиона","нониллионов"]];function l(e,t){const n="bigint"==typeof e?Number(e):e,r=n%10,i=n%100;return i>=11&&i<=19?t[2]:1===r?t[0]:r>=2&&r<=4?t[1]:t[2]}function a(e){if(0===e)return"";const t=e%10,n=Math.floor(e/10)%10,i=Math.floor(e/100),f=[];return i>0&&f.push(s[i]),n>1&&f.push(u[n]),1===n?f.push(o[t]):t>0&&f.push(r[t]),f.join(" ")}function g(e){if(0===e)return"";const t=e%10,n=Math.floor(e/10)%10,r=Math.floor(e/100),f=[];return r>0&&f.push(s[r]),n>1&&f.push(u[n]),1===n?f.push(o[t]):t>0&&f.push(i[t]),f.join(" ")}function p(e,t={}){if(0n===e)return f;const n="feminine"===t.gender;if(e<1000n)return n?g(Number(e)):a(Number(e));if(e<1000000n){const t=Number(e/1000n),r=Number(e%1000n);let i=g(t)+" "+l(t,c[0]);return r>0&&(i+=" "+(n?g(r):a(r))),i}return function(e,t){const n="feminine"===t.gender,r=e.toString(),i=r.length,o=[],u=i%3;let s=0;for(u>0&&(o.push(Number(r.slice(0,u))),s=u);s<i;)o.push(Number(r.slice(s,s+3))),s+=3;const f=[];let p=o.length-1;for(let e=0;e<o.length;e++){const t=o[e];if(0!==t)if(0===p)f.push(n?g(t):a(t));else{const e=l(t,c[p-1]),n=1===p?g(t):a(t);f.push(n+" "+e)}p--}return f.join(" ")}(e,t)}e.ru=function(e,r){r=function(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}(r);const{isNegative:i,integerPart:o,decimalPart:u}=function(e){const r=typeof e;if("bigint"===r)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===r){if(!Number.isFinite(e))throw new Error("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:t(function(e){const t=e.toString();return t.includes("e")||t.includes("E")?n(t):t}(e))}if("string"===r)return t(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new Error(`Invalid number format: "${e}"`);return t.includes("e")||t.includes("E")?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${r}`)}(e);let s="";return i&&(s="минус "),s+=p(o,r),u&&(s+=" запятая "+function(e,t){let n="",r=0;for(;r<e.length&&"0"===e[r];)n&&(n+=" "),n+=f,r++;const i=e.slice(r);return i&&(n&&(n+=" "),n+=p(BigInt(i),t)),n}(u,r)),s}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
3
3
  //# sourceMappingURL=ru.js.map