var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellCashCounting/utils.ts
var utils_exports = {};
__export(utils_exports, {
  buildEmptyQuantities: () => buildEmptyQuantities,
  getDenominationId: () => getDenominationId,
  getEffectiveDenominationsForCurrency: () => getEffectiveDenominationsForCurrency,
  isEffectiveDenomination: () => isEffectiveDenomination,
  normalizeAmount: () => normalizeAmount
});
module.exports = __toCommonJS(utils_exports);
var getDenominationId = (item) => `${item.currency_code}-${item.denomination_type}-${item.denomination_value}`;
var normalizeAmount = (value, precision) => {
  const numberValue = Number(String(value ?? 0).replace(/,/g, ""));
  if (!Number.isFinite(numberValue)) {
    return 0;
  }
  const factor = Math.pow(10, precision);
  return Math.round(numberValue * factor) / factor;
};
var isEffectiveDenomination = (item) => {
  if (item.is_enabled === false) {
    return false;
  }
  if (item.effective_status === false || item.effective_status === "inactive") {
    return false;
  }
  return true;
};
var getEffectiveDenominationsForCurrency = (denominations, currencyCode) => denominations.filter((item) => item.currency_code === currencyCode && isEffectiveDenomination(item)).sort((a, b) => a.sort_order - b.sort_order);
var buildEmptyQuantities = (items) => items.reduce((acc, item) => {
  acc[getDenominationId(item)] = 0;
  return acc;
}, {});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  buildEmptyQuantities,
  getDenominationId,
  getEffectiveDenominationsForCurrency,
  isEffectiveDenomination,
  normalizeAmount
});
