{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "core-big-number",
  "type": "registry:lib",
  "title": "core/big-number",
  "description": "Framework-free behaviour shared by the ui-* components (big-number); no DOM, no lit. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/core/big-number.ts",
      "type": "registry:lib",
      "target": "components/ui/core/big-number.ts",
      "content": "/** Carbon `BigNumber` sizes. */\nexport type BigNumberSize = 'default' | 'lg' | 'xl';\n\n/** Carbon's default locale for BigNumber (used when none is given or the given one is invalid). */\nexport const BIG_NUMBER_LOCALE = 'en-US';\n\nexport interface BigNumberFormat {\n    locale?: string;\n    /** Fraction digits of an abbreviated number (Carbon default 1). */\n    fractionDigits?: number;\n    /** Abbreviate: 12,345 → 12.3K (Carbon default true). */\n    truncate?: boolean;\n}\n\n/** The locale itself when Intl accepts it, else en-US (Carbon `getSupportedLocale`). */\nexport function supportedLocale(locale: string | undefined): string {\n    if (!locale) return BIG_NUMBER_LOCALE;\n    try {\n        Intl.NumberFormat.supportedLocalesOf(locale);\n        return locale;\n    } catch {\n        return BIG_NUMBER_LOCALE;\n    }\n}\n\n/** Carbon's formatting: compact notation with the fraction digits when truncating, else the full grouped number. */\nexport function formatBigNumber(value: number | null | undefined, { locale, fractionDigits = 1, truncate = true }: BigNumberFormat = {}): string | null {\n    if (typeof value !== 'number' || Number.isNaN(value)) return null;\n    const lang = supportedLocale(locale);\n    if (!truncate) return new Intl.NumberFormat(lang).format(value);\n    return new Intl.NumberFormat(lang, { notation: 'compact', minimumFractionDigits: fractionDigits, maximumFractionDigits: Math.round(fractionDigits) }).format(value);\n}\n\nexport interface BigNumberParts {\n    /** The value as shown, or \"–\" without one. */\n    value: string;\n    /** \"/total\" when the total shows, else null. */\n    total: string | null;\n}\n\nexport interface BigNumberInput extends BigNumberFormat {\n    value?: number | null;\n    total?: number | null;\n    percentage?: boolean;\n    /** Show the total even when Carbon would hide it. */\n    forceShowTotal?: boolean;\n    /** Shown for a missing total that is forced to show (Carbon \"Unknown\"). */\n    unknown?: string;\n}\n\n/**\n * What BigNumber shows: the value (\"–\" when missing) and \"/total\" — only when the total is larger than the value\n * and reads differently once abbreviated, never with `percentage` (Carbon), unless `forceShowTotal`.\n */\nexport function bigNumberParts({ value, total, percentage = false, forceShowTotal = false, unknown = 'Unknown', ...format }: BigNumberInput): BigNumberParts {\n    const shownValue = formatBigNumber(value, format) ?? '–';\n    const shownTotal = formatBigNumber(total, format) ?? unknown;\n    const larger = typeof value === 'number' && typeof total === 'number' && total > value;\n    const show = forceShowTotal || (!percentage && larger && shownValue !== shownTotal);\n    return { value: shownValue, total: show ? `/${shownTotal}` : null };\n}\n"
    }
  ]
}
