import { ZERO_COST } from '../constants/limits.js';
export { ZERO_COST };
export function calculateCost(usage, pricing, cacheDiscount = 0) {
    const inputCost = (usage.promptTokens / 1_000_000) * pricing.inputCostPer1M;
    const outputCost = (usage.completionTokens / 1_000_000) * pricing.outputCostPer1M;
    const gross = inputCost + outputCost;
    return {
        inputCostPer1M: pricing.inputCostPer1M,
        outputCostPer1M: pricing.outputCostPer1M,
        totalCost: gross - cacheDiscount,
        cacheDiscount,
    };
}
export function accumulateCost(current, additionalUsage, pricing, cacheDiscount = 0) {
    const additional = calculateCost(additionalUsage, pricing, cacheDiscount);
    return {
        inputCostPer1M: pricing.inputCostPer1M,
        outputCostPer1M: pricing.outputCostPer1M,
        totalCost: current.totalCost + additional.totalCost,
        cacheDiscount: current.cacheDiscount + additional.cacheDiscount,
    };
}
export function formatCost(usd) {
    if (usd === 0)
        return '$0.00';
    if (usd < 0.01)
        return `$${usd.toFixed(4)}`;
    return `$${usd.toFixed(2)}`;
}
//# sourceMappingURL=cost.js.map