//#region src/components/pisellCashCounting/utils.ts
/** 面额配置唯一键，用于数量映射 */
const getDenominationId = (item) => `${item.currency_code}-${item.denomination_type}-${item.denomination_value}`;
/** 按小数位规范化金额，避免浮点误差 */
const normalizeAmount = (value, precision) => {
	const numberValue = Number(String(value !== null && value !== void 0 ? value : 0).replace(/,/g, ""));
	if (!Number.isFinite(numberValue)) return 0;
	const factor = Math.pow(10, precision);
	return Math.round(numberValue * factor) / factor;
};
/** 业务规则：是否可作为有效面额参与点钞 */
const isEffectiveDenomination = (item) => {
	if (item.is_enabled === false) return false;
	if (item.effective_status === false || item.effective_status === "inactive") return false;
	return true;
};
/** 当前币种下已启用且排序后的面额列表 */
const getEffectiveDenominationsForCurrency = (denominations, currencyCode) => denominations.filter((item) => item.currency_code === currencyCode && isEffectiveDenomination(item)).sort((a, b) => a.sort_order - b.sort_order);
const buildEmptyQuantities = (items) => items.reduce((acc, item) => {
	acc[getDenominationId(item)] = 0;
	return acc;
}, {});
//#endregion
exports.buildEmptyQuantities = buildEmptyQuantities;
exports.getDenominationId = getDenominationId;
exports.getEffectiveDenominationsForCurrency = getEffectiveDenominationsForCurrency;
exports.normalizeAmount = normalizeAmount;
