"""
Balance sheet canonical concepts.

Ordered following the standard balance sheet layout:
Assets (current → non-current → total) →
Liabilities (current → non-current → total) →
Equity → Total L&E
"""

from .concepts import CanonicalConcept

BALANCE_SHEET_CONCEPTS = (
  # ── Assets: Current ──────────────────────────────────────────────────
  CanonicalConcept(
    id="cash_and_equivalents",
    display_name="Cash and Cash Equivalents",
    category="balance_sheet",
    description="Cash and short-term highly liquid investments",
    aliases=("cash", "cash equivalents", "cash and short-term investments"),
    expected_elements=(
      "us-gaap:CashAndCashEquivalentsAtCarryingValue",
      "us-gaap:CashCashEquivalentsAndShortTermInvestments",
      "us-gaap:Cash",
    ),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="short_term_investments",
    display_name="Short-Term Investments",
    category="balance_sheet",
    description="Short-term marketable securities and investments",
    aliases=("marketable securities", "trading securities"),
    expected_elements=(
      "us-gaap:ShortTermInvestments",
      "us-gaap:MarketableSecuritiesCurrent",
      "us-gaap:AvailableForSaleSecuritiesDebtSecuritiesCurrent",
    ),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="accounts_receivable",
    display_name="Accounts Receivable",
    category="balance_sheet",
    description="Amounts owed to the entity by customers",
    aliases=("receivables", "trade receivables", "net receivables"),
    expected_elements=(
      "us-gaap:AccountsReceivableNetCurrent",
      "us-gaap:AccountsReceivableNet",
      "us-gaap:AccountsNotesAndLoansReceivableNetCurrent",
      "us-gaap:ReceivablesNetCurrent",
      "us-gaap:AccountsAndOtherReceivablesNetCurrent",
    ),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="inventory",
    display_name="Inventory",
    category="balance_sheet",
    description="Inventory of goods available for sale",
    aliases=("inventories", "net inventory"),
    expected_elements=(
      "us-gaap:InventoryNet",
      "us-gaap:InventoryGross",
      "us-gaap:InventoryFinishedGoods",
      "us-gaap:InventoryNetOfAllowancesCustomerAdvancesAndProgressBillings",
      "us-gaap:RetailRelatedInventory",
      "us-gaap:AgriculturalRelatedInventory",
      "us-gaap:AirlineRelatedInventory",
      "us-gaap:EnergyRelatedInventory",
      "us-gaap:PublicUtilitiesInventory",
    ),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="other_current_assets",
    display_name="Other Current Assets",
    category="balance_sheet",
    description="Other current assets not separately classified including prepaid expenses",
    aliases=(
      "other assets current",
      "prepaid expenses",
      "prepaid and other current assets",
    ),
    expected_elements=(
      "us-gaap:OtherAssetsCurrent",
      "us-gaap:PrepaidExpenseAndOtherAssetsCurrent",
      "us-gaap:PrepaidExpenseCurrent",
    ),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="current_assets",
    display_name="Current Assets",
    category="balance_sheet",
    description="Total current assets expected to be converted to cash within one year",
    aliases=("total current assets",),
    expected_elements=("us-gaap:AssetsCurrent",),
    period_type="instant",
    balance="debit",
  ),
  # ── Assets: Non-Current ──────────────────────────────────────────────
  CanonicalConcept(
    id="property_plant_equipment",
    display_name="Property, Plant and Equipment",
    category="balance_sheet",
    description="Net property, plant and equipment",
    aliases=("pp&e", "ppe", "fixed assets", "net ppe"),
    expected_elements=(
      "us-gaap:PropertyPlantAndEquipmentNet",
      "us-gaap:PropertyPlantAndEquipmentGross",
      "us-gaap:PropertyPlantAndEquipmentAndFinanceLeaseRightOfUseAssetAfterAccumulatedDepreciationAndAmortization",
      "us-gaap:PropertyPlantAndEquipmentAndFinanceLeaseRightOfUseAssetBeforeAccumulatedDepreciationAndAmortization",
    ),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="goodwill",
    display_name="Goodwill",
    category="balance_sheet",
    description="Goodwill from business acquisitions",
    aliases=(),
    expected_elements=("us-gaap:Goodwill",),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="intangible_assets",
    display_name="Intangible Assets",
    category="balance_sheet",
    description="Net intangible assets excluding goodwill",
    aliases=("net intangibles",),
    expected_elements=(
      "us-gaap:IntangibleAssetsNetExcludingGoodwill",
      "us-gaap:IntangibleAssetsGrossExcludingGoodwill",
      "us-gaap:FiniteLivedIntangibleAssetsNet",
      "us-gaap:FiniteLivedIntangibleAssetsGross",
    ),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="long_term_investments",
    display_name="Long-Term Investments",
    category="balance_sheet",
    description="Long-term investments in securities, equity method investments, and other non-current investment assets",
    aliases=(
      "long-term marketable securities",
      "non-current investments",
      "equity method investments",
      "nonmarketable equity securities",
    ),
    expected_elements=(
      "us-gaap:LongTermInvestments",
      "us-gaap:OtherLongTermInvestments",
      "us-gaap:EquitySecuritiesWithoutReadilyDeterminableFairValueAmount",
      "us-gaap:EquitySecuritiesFvNiCurrentAndNoncurrent",
      "us-gaap:MarketableSecuritiesNoncurrent",
      "us-gaap:AvailableForSaleSecuritiesDebtSecuritiesNoncurrent",
    ),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="other_noncurrent_assets",
    display_name="Other Non-Current Assets",
    category="balance_sheet",
    description="Other non-current assets not separately classified",
    aliases=("other assets noncurrent", "other long-term assets"),
    expected_elements=(
      "us-gaap:OtherAssetsNoncurrent",
      "us-gaap:OtherAssets",
      "us-gaap:OperatingLeaseRightOfUseAsset",
      "us-gaap:FinanceLeaseRightOfUseAsset",
      "us-gaap:AssetsNoncurrent",
    ),
    period_type="instant",
    balance="debit",
  ),
  CanonicalConcept(
    id="total_assets",
    display_name="Total Assets",
    category="balance_sheet",
    description="Total assets of the entity",
    aliases=("assets",),
    expected_elements=("us-gaap:Assets",),
    period_type="instant",
    balance="debit",
  ),
  # ── Liabilities: Current ─────────────────────────────────────────────
  CanonicalConcept(
    id="accounts_payable",
    display_name="Accounts Payable",
    category="balance_sheet",
    description="Amounts owed to suppliers and vendors for goods and services received",
    aliases=("trade payables", "payables"),
    expected_elements=(
      "us-gaap:AccountsPayableCurrent",
      "us-gaap:AccountsPayableTradeCurrent",
      "us-gaap:AccountsPayableAndAccruedLiabilitiesCurrent",
    ),
    period_type="instant",
    balance="credit",
  ),
  CanonicalConcept(
    id="deferred_revenue",
    display_name="Deferred Revenue",
    category="balance_sheet",
    description="Revenue collected but not yet earned, recognized as a liability",
    aliases=(
      "contract liability",
      "unearned revenue",
      "deferred income",
    ),
    expected_elements=(
      "us-gaap:ContractWithCustomerLiabilityCurrent",
      "us-gaap:ContractWithCustomerLiability",
      "us-gaap:DeferredRevenueCurrent",
      "us-gaap:DeferredRevenueNoncurrent",
    ),
    period_type="instant",
    balance="credit",
  ),
  CanonicalConcept(
    id="other_current_liabilities",
    display_name="Other Current Liabilities",
    category="balance_sheet",
    description="Other current liabilities not separately classified including accrued liabilities",
    aliases=(
      "accrued liabilities",
      "accrued expenses",
      "other liabilities current",
      "accounts payable and accrued liabilities",
    ),
    expected_elements=(
      "us-gaap:OtherLiabilitiesCurrent",
      "us-gaap:AccruedLiabilitiesCurrent",
      "us-gaap:OperatingLeaseLiabilityCurrent",
      "us-gaap:FinanceLeaseLiabilityCurrent",
    ),
    period_type="instant",
    balance="credit",
  ),
  CanonicalConcept(
    id="current_liabilities",
    display_name="Current Liabilities",
    category="balance_sheet",
    description="Total current liabilities due within one year",
    aliases=("total current liabilities",),
    expected_elements=("us-gaap:LiabilitiesCurrent",),
    period_type="instant",
    balance="credit",
  ),
  # ── Liabilities: Non-Current ─────────────────────────────────────────
  CanonicalConcept(
    id="long_term_debt",
    display_name="Long-Term Debt",
    category="balance_sheet",
    description="Long-term debt obligations excluding current portion",
    aliases=("non-current debt", "long term borrowings"),
    expected_elements=(
      "us-gaap:LongTermDebtNoncurrent",
      "us-gaap:LongTermDebt",
      "us-gaap:LongTermDebtAndCapitalLeaseObligations",
      "us-gaap:DebtInstrumentCarryingAmount",
      "us-gaap:DebtInstrumentFaceAmount",
    ),
    period_type="instant",
    balance="credit",
  ),
  CanonicalConcept(
    id="other_noncurrent_liabilities",
    display_name="Other Non-Current Liabilities",
    category="balance_sheet",
    description="Other non-current liabilities not separately classified",
    aliases=("other liabilities noncurrent", "other long-term liabilities"),
    expected_elements=(
      "us-gaap:OtherLiabilitiesNoncurrent",
      "us-gaap:OtherLiabilities",
      "us-gaap:OperatingLeaseLiabilityNoncurrent",
      "us-gaap:FinanceLeaseLiabilityNoncurrent",
      "us-gaap:LiabilitiesNoncurrent",
    ),
    period_type="instant",
    balance="credit",
  ),
  CanonicalConcept(
    id="total_debt",
    display_name="Total Debt",
    category="balance_sheet",
    description="Total short-term and long-term debt",
    aliases=("debt",),
    expected_elements=(
      "us-gaap:DebtAndCapitalLeaseObligations",
      "us-gaap:LongTermDebtAndCapitalLeaseObligationsIncludingCurrentMaturities",
    ),
    period_type="instant",
    balance="credit",
  ),
  CanonicalConcept(
    id="total_liabilities",
    display_name="Total Liabilities",
    category="balance_sheet",
    description="Total liabilities of the entity",
    aliases=("liabilities",),
    expected_elements=("us-gaap:Liabilities",),
    period_type="instant",
    balance="credit",
  ),
  # ── Equity ───────────────────────────────────────────────────────────
  CanonicalConcept(
    id="retained_earnings",
    display_name="Retained Earnings",
    category="balance_sheet",
    description="Accumulated retained earnings or deficit",
    aliases=("accumulated deficit", "retained deficit"),
    expected_elements=("us-gaap:RetainedEarningsAccumulatedDeficit",),
    period_type="instant",
    balance="credit",
  ),
  CanonicalConcept(
    id="accumulated_other_comprehensive_income",
    display_name="Accumulated Other Comprehensive Income",
    category="balance_sheet",
    description="Cumulative other comprehensive income or loss reported in stockholders equity",
    aliases=("AOCI", "accumulated OCI", "accumulated other comprehensive loss"),
    expected_elements=(
      "us-gaap:AccumulatedOtherComprehensiveIncomeLossNetOfTax",
      "us-gaap:AccumulatedOtherComprehensiveIncomeLossDefinedBenefitPensionAndOtherPostretirementPlansNetOfTax",
    ),
    period_type="instant",
    balance="credit",
  ),
  CanonicalConcept(
    id="stockholders_equity",
    display_name="Stockholders' Equity",
    category="balance_sheet",
    description="Total stockholders' equity attributable to the entity",
    aliases=("shareholders equity", "total equity", "book value"),
    expected_elements=(
      "us-gaap:StockholdersEquity",
      "us-gaap:StockholdersEquityIncludingPortionAttributableToNoncontrollingInterest",
      "us-gaap:MembersEquity",
      "us-gaap:PartnersCapital",
    ),
    period_type="instant",
    balance="credit",
  ),
  CanonicalConcept(
    id="shares_outstanding",
    display_name="Shares Outstanding",
    category="balance_sheet",
    description="Total shares of common stock outstanding (often parenthetical)",
    aliases=("common shares outstanding", "shares issued"),
    expected_elements=(
      "us-gaap:CommonStockSharesOutstanding",
      "us-gaap:CommonStockSharesIssued",
    ),
    period_type="instant",
    balance=None,
    is_monetary=False,
  ),
  # ── Total ────────────────────────────────────────────────────────────
  CanonicalConcept(
    id="total_liabilities_and_equity",
    display_name="Total Liabilities and Equity",
    category="balance_sheet",
    description="Total liabilities and stockholders equity combined",
    aliases=("liabilities and equity", "total liabilities and stockholders equity"),
    expected_elements=("us-gaap:LiabilitiesAndStockholdersEquity",),
    period_type="instant",
    balance="credit",
  ),
)
