"use client";
//#region packages/@mantine/core/src/components/RollingNumber/get-render-slots.ts
function padLeft(arr, length) {
	return [...Array(length - arr.length).fill(null), ...arr];
}
function padRight(arr, length) {
	return [...arr, ...Array(length - arr.length).fill(null)];
}
function getRenderSlots({ current, previous, prefix, suffix, decimalSeparator = ".", thousandSeparator }) {
	const maxIntLen = Math.max(current.intDigits.length, previous.intDigits.length);
	const maxFracLen = Math.max(current.fracDigits.length, previous.fracDigits.length);
	const currIntPadded = padLeft(current.intDigits, maxIntLen);
	const prevIntPadded = padLeft(previous.intDigits, maxIntLen);
	const currFracPadded = padRight(current.fracDigits, maxFracLen);
	const prevFracPadded = padRight(previous.fracDigits, maxFracLen);
	const sep = thousandSeparator ? typeof thousandSeparator === "string" ? thousandSeparator : "," : null;
	const slots = [];
	if (prefix) for (let i = 0; i < prefix.length; i++) slots.push({
		type: "char",
		key: `prefix-${i}`,
		char: prefix[i],
		empty: false
	});
	if (current.negative || previous.negative) slots.push({
		type: "char",
		key: "sign",
		char: "-",
		empty: !current.negative
	});
	for (let i = 0; i < maxIntLen; i++) {
		const posFromRight = maxIntLen - 1 - i;
		const currDigit = currIntPadded[i];
		const prevDigit = prevIntPadded[i];
		const isEmpty = currDigit === null;
		slots.push({
			type: "digit",
			key: `int-${posFromRight}`,
			digit: currDigit ?? "0",
			previousDigit: prevDigit,
			empty: isEmpty
		});
		if (sep && posFromRight > 0 && posFromRight % 3 === 0) slots.push({
			type: "char",
			key: `sep-${posFromRight}`,
			char: sep,
			empty: isEmpty
		});
	}
	if (current.hasDecimal || previous.hasDecimal) slots.push({
		type: "char",
		key: "dec",
		char: decimalSeparator,
		empty: !current.hasDecimal
	});
	for (let i = 0; i < maxFracLen; i++) {
		const currDigit = currFracPadded[i];
		const prevDigit = prevFracPadded[i];
		const isEmpty = currDigit === null;
		slots.push({
			type: "digit",
			key: `frac-${i}`,
			digit: currDigit ?? "0",
			previousDigit: prevDigit,
			empty: isEmpty
		});
	}
	if (suffix) for (let i = 0; i < suffix.length; i++) slots.push({
		type: "char",
		key: `suffix-${i}`,
		char: suffix[i],
		empty: false
	});
	return slots;
}
//#endregion
export { getRenderSlots };

//# sourceMappingURL=get-render-slots.mjs.map