var e = /^-?\d+(\.\d+)?e[+-]?\d+$/i, t = /^-?\d+(\.\d+)?e[+-]?$/i;
/** "-", ".", "-." — NaN for Number() but clearly in-progress typing */
function n(e) {
	return e === "-" || e === "." || e === "-.";
}
/**
* Normalize a decimal string by removing cosmetic differences:
* leading +, leading zeros, trailing zeros after decimal, trailing dot.
* Used to compare user input with canonical float representation.
*/
function r(e) {
	let t = "";
	return e.startsWith("-") ? (t = "-", e = e.slice(1)) : e.startsWith("+") && (e = e.slice(1)), e = e.replace(/^0+(?=\d)/, ""), e.startsWith(".") && (e = "0" + e), e.includes(".") && (e = e.replace(/0+$/, "").replace(/\.$/, "")), e === "" || e === "0" ? "0" : t + e;
}
/** Complete partial exponential: "1e" → "1e+0", "1e-" → "1e-0", "1e+" → "1e+0" */
function i(e) {
	return /e$/i.test(e) ? e + "+0" : /e[+-]$/i.test(e) ? e + "0" : e;
}
function a(a) {
	if (a = a.trim(), a === "" || n(a)) return {};
	if (e.test(a) || t.test(a)) {
		let e = i(a), t = Number(e);
		return Number.isFinite(t) ? { value: t } : { error: "Value is not a number" };
	}
	let s = Number(a);
	if (!Number.isFinite(s)) return /^[-+]?[\d.,\s]+$/.test(a) ? { error: "Use dot as decimal separator, e.g. 3.14" } : { error: "Value is not a number" };
	let c = o(s);
	return r(a) === c ? { value: s } : { error: `Precision exceeded, actual value: ${c}` };
}
/**
* Converts a number to a plain decimal string (no exponential notation).
* E.g. 1e-7 → "0.0000001", 2e+21 → "2000000000000000000000"
*/
function o(e) {
	if (e === void 0) return "";
	let t = String(e);
	if (!t.includes("e") && !t.includes("E")) return t;
	try {
		return e.toFixed(20).replace(/\.?0+$/, "");
	} catch {
		return t;
	}
}
function s(e, t) {
	return t.minValue !== void 0 && e < t.minValue ? `Value must be higher than ${t.minValue}` : t.maxValue !== void 0 && e > t.maxValue ? `Value must be less than ${t.maxValue}` : t.validate?.(e);
}
export { o as numberToDecimalString, a as tryParseNumber, s as validateNumber };

//# sourceMappingURL=parseNumber.js.map