const pricingTable = [
    // Gemini 3.x Pro tier.
    { pattern: /(gemini-?3|3\.\d).*pro|gemini-?3-pro/i, price: { inputPerMillion: 2, outputPerMillion: 12 } },
    // Gemini 2.5 Pro.
    { pattern: /2[._-]?5.*pro|gemini-pro|^pro$/i, price: { inputPerMillion: 1.25, outputPerMillion: 10 } },
    // Flash-Lite.
    { pattern: /flash[-_ ]?lite/i, price: { inputPerMillion: 0.1, outputPerMillion: 0.4 } },
    // Gemini 2.5 / 2.0 Flash.
    { pattern: /flash/i, price: { inputPerMillion: 0.3, outputPerMillion: 2.5 } },
];
// "auto" and unknown models: assume the Flash tier (the common default route).
const fallbackPrice = { inputPerMillion: 0.3, outputPerMillion: 2.5 };
/** Resolve the public API price for a Gemini model id. */
export function geminiPriceFor(model) {
    for (const entry of pricingTable) {
        if (entry.pattern.test(model)) {
            return entry.price;
        }
    }
    return fallbackPrice;
}
/** Estimate the paid-API cost (USD) of the given token counts for a model. */
export function estimateGeminiCost(promptTokens, responseTokens, model) {
    const price = geminiPriceFor(model);
    const safePrompt = Math.max(0, promptTokens || 0);
    const safeResponse = Math.max(0, responseTokens || 0);
    return (safePrompt / 1_000_000) * price.inputPerMillion + (safeResponse / 1_000_000) * price.outputPerMillion;
}
/** Format a saved-cost figure for the header counter. */
export function formatSavedCost(usd) {
    if (!Number.isFinite(usd) || usd <= 0) {
        return "$0.00";
    }
    if (usd < 0.01) {
        return "<$0.01";
    }
    return `$${usd.toFixed(2)}`;
}
//# sourceMappingURL=geminiPricing.js.map