'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const ky = { Zero: "\u043D\u043E\u043B\u044C", Hundred: "\u0436\u04AF\u0437", Negative: "\u043C\u0438\u043D\u0443\u0441", Point: "\u0431\u04AF\u0442\u04AF\u043D", Ones: { 1: "\u0431\u0438\u0440", 2: "\u044D\u043A\u0438", 3: "\u04AF\u0447", 4: "\u0442\u04E9\u0440\u0442", 5: "\u0431\u0435\u0448", 6: "\u0430\u043B\u0442\u044B", 7: "\u0436\u0435\u0442\u0438", 8: "\u0441\u0435\u0433\u0438\u0437", 9: "\u0442\u043E\u0433\u0443\u0437" }, Tens: { 1: "\u043E\u043D", 2: "\u0436\u044B\u0439\u044B\u0440\u043C\u0430", 3: "\u043E\u0442\u0443\u0437", 4: "\u043A\u044B\u0440\u043A", 5: "\u044D\u043B\u04AF\u04AF", 6: "\u0430\u043B\u0442\u044B\u043C\u044B\u0448", 7: "\u0436\u0435\u0442\u0438\u043C\u0438\u0448", 8: "\u0441\u0435\u043A\u0441\u0435\u043D", 9: "\u0442\u043E\u043A\u0441\u043E\u043D" }, Triplets: { 1: "", 2: "\u043C\u0438\u04A3", 3: "\u043C\u0438\u043B\u043B\u0438\u043E\u043D", 4: "\u043C\u0438\u043B\u043B\u0438\u0430\u0440\u0434", 5: "\u0442\u0440\u0438\u043B\u043B\u0438\u043E\u043D", 6: "\u043A\u0432\u0430\u0434\u0440\u0438\u043B\u043B\u0438\u043E\u043D", 7: "\u0441\u0435\u043A\u0441\u0442\u0438\u043B\u043B\u0438\u043E\u043D", 8: "\u0441\u0435\u043F\u0442\u0438\u043B\u043B\u0438\u043E\u043D", 9: "\u043E\u043A\u0442\u0438\u043B\u043B\u0438\u043E\u043D" }, OnesOrdinal: { 0: "\u0443\u043D\u0447\u0443", 1: "\u0438\u043D\u0447\u0438", 2: "\u043D\u0447\u0438", 3: "\u04AF\u043D\u0447\u04AF", 4: "\u04AF\u043D\u0447\u04AF", 5: "\u0438\u043D\u0447\u0438", 6: "\u043D\u0447\u044B", 7: "\u043D\u0447\u0438", 8: "\u0438\u043D\u0447\u0438", 9: "\u0443\u043D\u0447\u0443" }, TensOrdinal: { 1: "\u0443\u043D\u0447\u0443", 2: "\u043D\u0447\u044B", 3: "\u0443\u043D\u0447\u0443", 4: "\u044B\u043D\u0447\u044B", 5: "\u043D\u0447\u04AF", 6: "\u044B\u043D\u0447\u044B", 7: "\u0438\u043D\u0447\u0438", 8: "\u0447\u0438", 9: "\u0447\u0443" }, TripletsOrdinal: { 0: "\u0443\u043D\u0447\u0443", 1: "\u04AF\u043D\u0447\u04AF", 2: "\u0438\u043D\u0447\u0438", 3: "\u0443\u043D\u0447\u0443", 4: "\u044B\u043D\u0447\u044B", 5: "\u0443\u043D\u0447\u0443", 6: "\u0443\u043D\u0447\u0443", 7: "\u0443\u043D\u0447\u0443", 8: "\u0443\u043D\u0447\u0443", 9: "\u0443\u043D\u0447\u0443" }, OnesAblative: { 1: "\u0434\u0435\u043D", 2: "\u0434\u0435\u043D", 3: "\u0442\u04E9\u043D", 4: "\u0442\u04E9\u043D", 5: "\u0442\u0435\u043D", 6: "\u0434\u0430\u043D", 7: "\u0434\u0435\u043D", 8: "\u0434\u0435\u043D", 9: "\u0434\u0430\u043D" }, TensAblative: { 1: "\u0434\u043E\u043D", 2: "\u0434\u0430\u043D", 3: "\u0434\u0430\u043D", 4: "\u0442\u0430\u043D", 5: "\u0434\u04E9\u043D", 6: "\u0442\u0430\u043D", 7: "\u0442\u0435\u043D", 8: "\u0434\u0435\u043D", 9: "\u0434\u043E\u043D" }, TripletsAblative: { 1: "\u0434\u04E9\u043D", 2: "\u0434\u0435\u043D", 3: "\u0434\u043E\u043D", 4: "\u0434\u0430\u043D", 5: "\u0434\u043E\u043D", 6: "\u0434\u043E\u043D", 7: "\u0434\u043E\u043D", 8: "\u0434\u043E\u043D", 9: "\u0434\u043E\u043D" } }; const kk = { Zero: "\u043D\u04E9\u043B", Hundred: "\u0436\u04AF\u0437", Negative: "\u043C\u0438\u043D\u0443\u0441", Point: "\u0431\u04AF\u0442\u0456\u043D", Ones: { 1: "\u0431i\u0440", 2: "\u0435\u043Ai", 3: "\u04AF\u0448", 4: "\u0442\u04E9\u0440\u0442", 5: "\u0431\u0435\u0441", 6: "\u0430\u043B\u0442\u044B", 7: "\u0436\u0435\u0442i", 8: "\u0441\u0435\u0433i\u0437", 9: "\u0442\u043E\u0493\u044B\u0437" }, Tens: { 1: "\u043E\u043D", 2: "\u0436\u0438\u044B\u0440\u043C\u0430", 3: "\u043E\u0442\u044B\u0437", 4: "\u049B\u044B\u0440\u044B\u049B", 5: "\u0435\u043B\u0443", 6: "\u0430\u043B\u043F\u044B\u0441", 7: "\u0436\u0435\u0442\u043Fi\u0441", 8: "\u0441\u0435\u043A\u0441\u0435\u043D", 9: "\u0442\u043E\u049B\u0441\u0430\u043D" }, Triplets: { 1: "", 2: "\u043C\u044B\u04A3", 3: "\u043C\u0438\u043B\u043B\u0438\u043E\u043D", 4: "\u043C\u0438\u043B\u043B\u0438\u0430\u0440\u0434", 5: "\u0442\u0440\u0438\u043B\u043B\u0438\u043E\u043D", 6: "\u043A\u0432\u0430\u0434\u0440\u0438\u043B\u043B\u0438\u043E\u043D", 7: "\u0441\u0435\u043A\u0441\u0442\u0438\u043B\u043B\u0438\u043E\u043D", 8: "\u0441\u0435\u043F\u0442\u0438\u043B\u043B\u0438\u043E\u043D", 9: "\u043E\u043A\u0442\u0438\u043B\u043B\u0438\u043E\u043D" }, OnesOrdinal: { 0: "\u0456\u043D\u0448\u0456", 1: "\u0456\u043D\u0448\u0456", 2: "\u043D\u0448\u0456", 3: "\u0456\u043D\u0448\u0456", 4: "\u0456\u043D\u0448\u0456", 5: "\u0456\u043D\u0448\u0456", 6: "\u043D\u0448\u044B", 7: "\u043D\u0448\u0456", 8: "\u0456\u043D\u0448\u0456", 9: "\u0456\u043D\u0448\u0456" }, TensOrdinal: { 1: "\u044B\u043D\u0448\u044B", 2: "\u0441\u044B\u043D\u0448\u044B", 3: "\u044B\u043D\u0448\u044B", 4: "\u044B\u043D\u0448\u044B", 5: "\u0456\u043D\u0448\u0456", 6: "\u044B\u043D\u0448\u044B", 7: "\u0456\u043D\u0448\u0456", 8: "\u0456\u043D\u0448\u0456", 9: "\u044B\u043D\u0448\u044B" }, TripletsOrdinal: { 0: "\u044B\u043D\u0448\u044B", 1: "\u0456\u043D\u0448\u0456", 2: "\u044B\u043D\u0448\u044B", 3: "\u044B\u043D\u0448\u044B", 4: "\u044B\u043D\u0448\u044B", 5: "\u044B\u043D\u0448\u044B", 6: "\u044B\u043D\u0448\u044B", 7: "\u044B\u043D\u0448\u044B", 8: "\u044B\u043D\u0448\u044B", 9: "\u044B\u043D\u0448\u044B" } }; const kk_latin = { Zero: "n\xF6l", Hundred: "j\xFCz", Negative: "minus", Point: "b\xFCt\u0131n", Ones: { 1: "b\u0131r", 2: "ek\u0131", 3: "\xFC\u015F", 4: "t\xF6rt", 5: "bes", 6: "alty", 7: "jet\u0131", 8: "seg\u0131z", 9: "to\u011Fyz" }, Tens: { 1: "on", 2: "jiyrma", 3: "otyz", 4: "qyryq", 5: "elu", 6: "alpys", 7: "jetp\u0131s", 8: "seksen", 9: "toqsan" }, Triplets: { 1: "", 2: "my\xF1", 3: "million", 4: "milliard", 5: "trillion", 6: "kvadrillion", 7: "sekstillion", 8: "septillion", 9: "oktillion" }, OnesOrdinal: { 0: "\u0131n\u015F\u0131", 1: "\u0131n\u015F\u0131", 2: "\u043D\u0448\u0456", 3: "\u0131n\u015F\u0131", 4: "\u0131n\u015F\u0131", 5: "\u0131n\u015F\u0131", 6: "n\u015Fy", 7: "n\u015F\u0131", 8: "\u0131n\u015F\u0131", 9: "\u0131n\u015F\u0131" }, TensOrdinal: { 1: "yn\u015Fy", 2: "\u0441\u044B\u043D\u0448\u044B", 3: "yn\u015Fy", 4: "yn\u015Fy", 5: "\u0131n\u015F\u0131", 6: "yn\u015Fy", 7: "\u0131n\u015F\u0131", 8: "\u0131n\u015F\u0131", 9: "yn\u015Fy" }, TripletsOrdinal: { 0: "yn\u015Fy", 1: "\u0131n\u015F\u0131", 2: "yn\u015Fy", 3: "yn\u015Fy", 4: "yn\u015Fy", 5: "yn\u015Fy", 6: "yn\u015Fy", 7: "yn\u015Fy", 8: "yn\u015Fy", 9: "yn\u015Fy" }, OnesAblative: { 1: "\u0434\u0435\u043D", 2: "\u0434\u0435\u043D", 3: "\u0442\u04E9\u043D", 4: "\u0442\u04E9\u043D", 5: "\u0442\u0435\u043D", 6: "\u0434\u0430\u043D", 7: "\u0434\u0435\u043D", 8: "\u0434\u0435\u043D", 9: "\u0434\u0430\u043D" }, TensAblative: { 1: "\u0434\u043E\u043D", 2: "\u0434\u0430\u043D", 3: "\u0434\u0430\u043D", 4: "\u0442\u0430\u043D", 5: "\u0434\u04E9\u043D", 6: "\u0442\u0430\u043D", 7: "\u0442\u0435\u043D", 8: "\u0434\u0435\u043D", 9: "\u0434\u043E\u043D" }, TripletsAblative: { 1: "\u0434\u04E9\u043D", 2: "\u0434\u0435\u043D", 3: "\u0434\u043E\u043D", 4: "\u0434\u0430\u043D", 5: "\u0434\u043E\u043D", 6: "\u0434\u043E\u043D", 7: "\u0434\u043E\u043D", 8: "\u0434\u043E\u043D", 9: "\u0434\u043E\u043D" } }; function isNumberSafe(number) { if (typeof number === "number" && !isFinite(number)) { throw new TypeError(`Given an infinite or too large number input`); } if (isNaN(Number(number))) { throw new TypeError(`Given input of "${number}" is not lang number. `); } if (number.toString().length > 21) { throw new RangeError("Overflow: given input is more than 21 digits."); } if (typeof number === "number" && number >= Number.MAX_SAFE_INTEGER || number <= Number.MIN_SAFE_INTEGER) { console.log(`Warning: Precision may be lost for the given input of ${number}. Passing numbers as string is recommended.`); } return true; } function removeComma(number) { if (typeof number === "string") { number = number.replace(/[, ]/g, ""); } return number; } function toTriplets(number) { return number.match(/\d{1,3}(?=(\d{3})*$)/g)?.reverse() || []; } function isLangSupported(lang) { if (lang || (lang = "ky"), typeof lang === "string" && lang.toLowerCase() in langs) return true; if (typeof lang === "object" && (lang.lang || (lang.lang = "ky") && lang.lang.toLowerCase() in langs)) return true; throw new TypeError(`"${lang}" language is not supported.`); } function setLanguage(lang) { if (!lang) { lang = "ky"; } const language = typeof lang === "string" ? langs[lang.toLowerCase()] : langs[lang.lang.toLowerCase()]; return language; } const langs = { ky, kk, "kk-latin": kk_latin }; class Sandar { constructor(language = "ky") { if (isLangSupported(typeof language === "string" ? language : language.lang)) ; this.language = typeof language === "string" ? language : language.lang; } toWord(number) { return toWord(number, this.language); } toOrdinal(number) { return toOrdinal(number, this.language); } get lang() { return this.language; } set lang(lang) { if (isLangSupported(lang)) { this.language = lang; } } } function toWord(number, lang = "ky") { const language = setLanguage(lang); if (Math.abs(Number(number)) === 0) return language.Zero; function convert(number2) { function parseTens(number3) { const tens = Math.floor(number3 / 10); const rem = number3 % 10 > 0 ? `${language.Ones[number3 % 10]}` : ""; return tens ? `${language.Tens[tens] ? language.Tens[tens] : ""} ${rem}` : rem; } function parseHundreds(number3) { const hundreds = Math.floor(number3 / 100); const rem = number3 % 100 > 0 ? parseTens(number3 % 100) : ""; return hundreds > 1 ? rem ? `${language.Ones[hundreds]} ${language.Hundred} ${rem}` : `${language.Ones[hundreds]} ${language.Hundred}` : `${language.Hundred} ${rem}`; } return number2 >= 100 ? parseHundreds(number2) : parseTens(number2); } function generate() { number = removeComma(number); const triplets = toTriplets(number.toString()); const words = []; if (isNumberSafe(number) && isLangSupported(lang)) { triplets.forEach((word, index) => { if (parseInt(word) !== 0) { word = convert(parseInt(word)).trim(); if (word) words.push(`${word} ${language.Triplets[index + 1]}`); } }); } return words.reverse().join(" ").trim(); } return (number < 0 ? `${language.Negative} ` : "") + generate(); } function toOrdinal(number, lang = "ky") { const language = setLanguage(lang); function parseHundreds(number2) { let suffix = number2 % 10 ? language.OnesOrdinal[number2 % 10] : language.TensOrdinal[number2 % 100 / 10]; return suffix = suffix ?? language.TripletsOrdinal[1], suffix; } function parseThousands(number2) { const triplets = toTriplets(number2.toString()); const thousands = 0; for (const triple of triplets) { if (parseInt(triple) === 0) ; else return thousands ? language.TripletsOrdinal[thousands + 1] : parseHundreds(Number(triple)); } } function generateSuffix(number2) { number2 = removeComma(number2); if (isNumberSafe(number2)) { if (Math.abs(Number(number2)) === 0) return language.TripletsOrdinal[0]; return 1e3 < number2 ? parseThousands(Number(number2)) : parseHundreds(Number(number2)); } } return toWord(number, lang) + generateSuffix(number); } exports.Sandar = Sandar; exports.toOrdinal = toOrdinal; exports.toWord = toWord;