import { getText } from "../../../../locales/index.js";
//#region src/components/dataSourceComponents/fields/InputNumber/utils.ts
const THOUSAND = 1e3;
const MILLION = 1e6;
const BILLION = 1e9;
const getUnitText = (key) => {
	return getText(`pisell-number-format-${key}`);
};
const formatNumberWithUnit = (value, precision = 0, previewFormatter) => {
	if (!value) return "0";
	const units = {
		billion: {
			value: BILLION,
			getText: () => getUnitText("billion")
		},
		million: {
			value: MILLION,
			getText: () => getUnitText("million")
		},
		thousand: {
			value: THOUSAND,
			getText: () => getUnitText("thousand")
		}
	};
	if (!previewFormatter || previewFormatter === "none") return value.toFixed(precision);
	const unit = units[previewFormatter];
	if (!unit) return value.toFixed(precision);
	const convertedValue = value / unit.value;
	const suffix = unit.getText();
	return `${convertedValue.toFixed(precision)}${suffix}`;
};
//#endregion
export { formatNumberWithUnit };
