namespace Nalu.Web.Services;

/// <summary>
/// Credit cost per validator.
/// 3 = all standard validators (deterministic + LLM extraction + smart suggestion included).
/// 5 = validate_reply (always LLM, full agent+user pair analysis).
/// </summary>
public static class CreditCosts
{
    private static readonly Dictionary<string, int> _costs = new(StringComparer.OrdinalIgnoreCase)
    {
        // 3 credits — standard (includes smart contextual re-ask on failure)
        ["validate_cpf"]           = 3,
        ["validate_cep"]           = 3,
        ["validate_cnpj"]          = 3,
        ["validate_email"]         = 3,
        ["validate_phone_br"]      = 3,
        ["validate_plate_br"]      = 3,
        ["validate_postal_code"]   = 3,
        ["validate_name"]          = 3,
        ["validate_full_name"]     = 3,
        ["validate_yes_no"]        = 3,
        ["validate_birthdate"]     = 3,
        ["validate_handoff"]       = 3,
        ["validate_cancel_intent"] = 3,
        ["validate_company_name"]  = 3,

        // 5 credits — validate_reply (always LLM, agent+user context analysis)
        ["validate_reply"]         = 5,
    };

    public static int Get(string validatorId) =>
        _costs.TryGetValue(validatorId, out var cost) ? cost : 3;

    private static readonly Dictionary<string, string> _aliases = new(StringComparer.OrdinalIgnoreCase)
    {
        ["name"]          = "validate_name",
        ["full-name"]     = "validate_full_name",
        ["cpf"]           = "validate_cpf",
        ["cep"]           = "validate_cep",
        ["phone-br"]      = "validate_phone_br",
        ["email"]         = "validate_email",
        ["postal-code"]   = "validate_postal_code",
        ["yes-no"]        = "validate_yes_no",
        ["birthdate"]     = "validate_birthdate",
        ["handoff"]       = "validate_handoff",
        ["cancel-intent"] = "validate_cancel_intent",
        ["cnpj"]          = "validate_cnpj",
        ["plate-br"]      = "validate_plate_br",
        ["company-name"]  = "validate_company_name",
        ["reply"]         = "validate_reply",
    };

    public static int GetByEndpoint(string endpoint) =>
        _aliases.TryGetValue(endpoint, out var id) ? Get(id) : 3;
}
