import { formatNumber } from "@pisell/utils";
//#region src/components/pisellCurrency/utils/currencyFormatter.ts
/**
* 格式化货币数值
* 
* @param value 数值
* @param options 格式化选项
* @returns 格式化后的货币字符串
* 
* @example
* formatCurrency(1234.56, { currencySymbol: '¥', symbolPosition: 'before', showSymbol: true, precision: 2, useGrouping: true })
* // 返回: '¥1,234.56'
* 
* @example
* formatCurrency(999.99, { currencySymbol: '€', symbolPosition: 'after', showSymbol: true, precision: 2, useGrouping: true })
* // 返回: '999.99€'
*/
function formatCurrency(value, options) {
	if (value === null || value === void 0) return null;
	const { currencySymbol, symbolPosition, showSymbol, precision, useGrouping } = options;
	const formatted = formatNumber(value, {
		precision,
		useGrouping
	});
	if (!formatted) return null;
	if (!showSymbol) return formatted;
	if (symbolPosition === "before") return `${currencySymbol}${formatted}`;
	else return `${formatted}${currencySymbol}`;
}
//#endregion
export { formatCurrency };
