"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { intToRoman: () => intToRoman, isInt: () => isInt, isRoman: () => isRoman, romanToInt: () => romanToInt }); module.exports = __toCommonJS(src_exports); // src/lib/mapper.ts var INT_LIST = [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]; var ROMAN_LIST = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]; var map = /* @__PURE__ */ new Map(); INT_LIST.forEach((key, i) => map.set(key, ROMAN_LIST[i])); ROMAN_LIST.forEach((key, i) => map.set(key, INT_LIST[i])); function getVal(key) { return map.get(key); } // src/lib/intToRoman.ts var digitReg = /^\d*$/; var isInt = (num) => num > 0 && Number.isFinite(num) && digitReg.test(`${num}`); var intToRoman = (val) => { if (!isInt(val)) throw new Error(`Invalid integer number ${val}`); let roman = ""; let i = 0; while (i < INT_LIST.length && val !== 0) { const item = INT_LIST[i]; while (val >= item) { val -= item; roman += getVal(item); } i++; } return roman; }; // src/lib/romanToInt.ts var romanReg = /^(M{0,4})(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/; var isRoman = (str) => romanReg.test(str); var romanToInt = (str) => { if (!isRoman(str)) throw new TypeError(`Invalid Roman character ${str}`); let val = 0; let i = 0; while (i < str.length - 1) { const a = getVal(str[i]); const b = getVal(str[i + 1]); if (a < b) { val -= a; } else { val += a; } i++; } val += getVal(str[i]); return val; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { intToRoman, isInt, isRoman, romanToInt });