use super::super::types::{ConceptCandidate, UnitFamily};

const fn candidate(
    prefix: &'static str,
    local_name: &'static str,
    unit_family: UnitFamily,
) -> ConceptCandidate {
    ConceptCandidate {
        prefix,
        local_name,
        unit_family,
    }
}

pub(crate) const REVENUE_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "us-gaap",
        "RevenueFromContractWithCustomerExcludingAssessedTax",
        UnitFamily::Currency,
    ),
    candidate("us-gaap", "SalesRevenueNet", UnitFamily::Currency),
    candidate("us-gaap", "Revenues", UnitFamily::Currency),
    candidate("ifrs-full", "Revenue", UnitFamily::Currency),
    candidate(
        "us-gaap",
        "RevenueFromContractWithCustomerExcludingAssessedTax",
        UnitFamily::Currency,
    ),
];

pub(crate) const COST_OF_SALES_CONCEPTS: &[ConceptCandidate] = &[
    candidate("us-gaap", "CostOfRevenue", UnitFamily::Currency),
    candidate("us-gaap", "CostOfGoodsSold", UnitFamily::Currency),
    candidate("us-gaap", "CostOfSales", UnitFamily::Currency),
];

pub(crate) const GROSS_PROFIT_CONCEPTS: &[ConceptCandidate] =
    &[candidate("us-gaap", "GrossProfit", UnitFamily::Currency)];

pub(crate) const SELLING_GENERAL_AND_ADMINISTRATIVE_CONCEPTS: &[ConceptCandidate] = &[candidate(
    "us-gaap",
    "SellingGeneralAndAdministrativeExpense",
    UnitFamily::Currency,
)];

pub(crate) const RESEARCH_AND_DEVELOPMENT_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "us-gaap",
        "ResearchAndDevelopmentExpense",
        UnitFamily::Currency,
    ),
    candidate(
        "ifrs-full",
        "ResearchAndDevelopmentExpense",
        UnitFamily::Currency,
    ),
];

pub(crate) const R_AND_D_CONCEPTS: &[ConceptCandidate] = RESEARCH_AND_DEVELOPMENT_CONCEPTS;

// This row is often company-specific in presentation, so custom mappings are the primary escape
// hatch when the standard formula-derived value is unavailable.
#[allow(dead_code)]
pub(crate) const OTHER_OPERATING_EXPENSES_CONCEPTS: &[ConceptCandidate] = &[
    candidate("us-gaap", "OtherOperatingExpenses", UnitFamily::Currency),
    candidate(
        "us-gaap",
        "ImpairmentOfLongLivedAssetsToBeHeldAndUsed",
        UnitFamily::Currency,
    ),
    candidate("us-gaap", "RestructuringCosts", UnitFamily::Currency),
];

pub(crate) const OPERATING_PROFIT_CONCEPTS: &[ConceptCandidate] = &[
    candidate("us-gaap", "OperatingIncomeLoss", UnitFamily::Currency),
    candidate(
        "ifrs-full",
        "ProfitLossFromOperatingActivities",
        UnitFamily::Currency,
    ),
    candidate(
        "us-gaap",
        "IncomeLossFromContinuingOperationsBeforeIncomeTaxesMinorityInterestAndIncomeLossFromEquityMethodInvestments",
        UnitFamily::Currency,
    ),
];

pub(crate) const NON_OPERATING_INCOME_CONCEPTS: &[ConceptCandidate] = &[candidate(
    "us-gaap",
    "OtherNonoperatingIncomeExpense",
    UnitFamily::Currency,
)];

pub(crate) const TOTAL_NON_OPERATING_INCOME_CONCEPTS: &[ConceptCandidate] = &[candidate(
    "us-gaap",
    "NonoperatingIncomeExpense",
    UnitFamily::Currency,
)];

pub(crate) const INCOME_BEFORE_TAX_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "us-gaap",
        "IncomeLossFromContinuingOperationsBeforeIncomeTaxesExtraordinaryItemsNoncontrollingInterest",
        UnitFamily::Currency,
    ),
    candidate("ifrs-full", "ProfitLossBeforeTax", UnitFamily::Currency),
    candidate(
        "us-gaap",
        "IncomeLossFromContinuingOperationsBeforeIncomeTaxesMinorityInterest",
        UnitFamily::Currency,
    ),
];

pub(crate) const PROVISION_FOR_INCOME_TAXES_CONCEPTS: &[ConceptCandidate] = &[
    candidate("us-gaap", "IncomeTaxExpenseBenefit", UnitFamily::Currency),
    candidate(
        "ifrs-full",
        "IncomeTaxExpenseContinuingOperations",
        UnitFamily::Currency,
    ),
];

pub(crate) const CONSOLIDATED_NET_INCOME_CONCEPTS: &[ConceptCandidate] = &[
    candidate("us-gaap", "NetIncomeLoss", UnitFamily::Currency),
    candidate("ifrs-full", "ProfitLoss", UnitFamily::Currency),
    candidate(
        "us-gaap",
        "NetIncomeLossAttributableToTheCompany",
        UnitFamily::Currency,
    ),
];

pub(crate) const COMMON_SHAREHOLDER_NET_INCOME_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "us-gaap",
        "NetIncomeLossAvailableToCommonStockholdersBasic",
        UnitFamily::Currency,
    ),
    candidate(
        "us-gaap",
        "NetIncomeLossAvailableToCommonStockholdersDiluted",
        UnitFamily::Currency,
    ),
    candidate(
        "ifrs-full",
        "ProfitLossAttributableToOwnersOfParent",
        UnitFamily::Currency,
    ),
    candidate(
        "us-gaap",
        "NetIncomeLossAttributableToParent",
        UnitFamily::Currency,
    ),
];

pub(crate) const BASIC_EPS_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "us-gaap",
        "EarningsPerShareBasic",
        UnitFamily::CurrencyPerShare,
    ),
    candidate(
        "ifrs-full",
        "BasicEarningsLossPerShare",
        UnitFamily::CurrencyPerShare,
    ),
];

pub(crate) const DILUTED_EPS_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "us-gaap",
        "EarningsPerShareDiluted",
        UnitFamily::CurrencyPerShare,
    ),
    candidate(
        "ifrs-full",
        "DilutedEarningsLossPerShare",
        UnitFamily::CurrencyPerShare,
    ),
    candidate(
        "ifrs-full",
        "BasicAndDilutedEarningsLossPerShare",
        UnitFamily::CurrencyPerShare,
    ),
];

pub(crate) const BASIC_SHARES_CONCEPTS: &[ConceptCandidate] = &[candidate(
    "us-gaap",
    "WeightedAverageNumberOfSharesOutstandingBasic",
    UnitFamily::Shares,
)];

pub(crate) const DILUTED_SHARES_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "us-gaap",
        "WeightedAverageNumberOfDilutedSharesOutstanding",
        UnitFamily::Shares,
    ),
    candidate(
        "ifrs-full",
        "WeightedAverageNumberOfSharesOutstandingDiluted",
        UnitFamily::Shares,
    ),
];

pub(crate) const TOTAL_SHARES_OUTSTANDING_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "dei",
        "EntityCommonStockSharesOutstanding",
        UnitFamily::Shares,
    ),
    candidate(
        "us-gaap",
        "CommonStockSharesOutstanding",
        UnitFamily::Shares,
    ),
    candidate("ifrs-full", "NumberOfSharesOutstanding", UnitFamily::Shares),
];

pub(crate) const EBITDA_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "us-gaap",
        "EarningsBeforeInterestTaxesDepreciationAndAmortization",
        UnitFamily::Currency,
    ),
    candidate(
        "ifrs-full",
        "EarningsBeforeInterestTaxesDepreciationAndAmortisation",
        UnitFamily::Currency,
    ),
];

pub(crate) const EFFECTIVE_TAX_RATE_CONCEPTS: &[ConceptCandidate] = &[
    candidate(
        "us-gaap",
        "EffectiveIncomeTaxRateContinuingOperations",
        UnitFamily::Pure,
    ),
    candidate(
        "ifrs-full",
        "EffectiveIncomeTaxRateContinuingOperations",
        UnitFamily::Pure,
    ),
];
